Author Topic: Scripted Irresistable Damage?  (Read 436 times)

Legacy_FunkySwerve

  • Hero Member
  • *****
  • Posts: 2325
  • Karma: +0/-0
Scripted Irresistable Damage?
« Reply #15 on: April 16, 2014, 04:52:56 am »


               

Look in nwnx_defenses for GetEffectDamageResistance. It can be done via nwscript as well, though the nwnx function is faster. It also, I believe, allows for stacking damage resistances and debuffs of them, though I don't recall offhand if our ability to do that comes from that plugin or elsewhere, and you don't need that to do what you want.


 


GetTrueDamageImmunity, also in nwnx_defenses, essentially gets their total immunity to the specified element. It handles stacking errors in nwscript, or did - I don't remember if they were all fixed in 1.69 or not, and they're pretty uncommon scenarios either way (iirc bugged when stacking past 255, though I could be misremembering). The main thing it does that you can't easily do otherwise in nwscript is to check for absolute damage immunity ala RDD. Again, not something mission-critical for most applications. We rely on it mainly because we like to do partial absolute immunity for some situations - immunity that can be dubuffed by stacking vulns, but down to a minimum value greater than 0 (like 50%).


 


Funky



               
               

               
            

Legacy_Shadooow

  • Hero Member
  • *****
  • Posts: 7698
  • Karma: +0/-0
Scripted Irresistable Damage?
« Reply #16 on: April 16, 2014, 08:30:30 am »


               


So we all know you could do something along these lines to apply 100 magic damage to a creature:


 


ApplyEffectToObject(DURATION_TYPE_INSTANT, EffectDamage(100), oTarget);


 


However, if oTarget has 50% magic immunity and 50 magic resist he won't take any damage.  Is there a way to get around this?


 


If you're wondering why I ask, it's due to my HP display script that I'm improving at the moment.  Specifically I'm trying to make it play nicely with heals by default -- which means if a creature has 10 max HP, 100k total scripted HP (so 90k hidden initially), and 15k effective HP they'd be sitting at 2499 actual HP and 12501 hidden HP (so they appear Near Death).  However, if they get healed for 5k HP then they'll shoot up to 7499 HP and appear Injured instead.


 


Now, my script will update their health percentage correctly (since it considers both actual and hidden HP) -- but ideally I'd like to be able to detect that they're above 2499 HP while being below 25% effective HP (easy to do), knock their HP back down to 2499 (the point of this thread), and then bump their hidden HP up by 5000 (easy to do) which gets everything back on track as the player has 2499 actual HP and 127501 hidden HP at the end (20% health and thus stays at "Near Death").


 


If the target doesn't have resistances, vulnerabilities, or immunities that's simple (just apply 5000 damage of some type in this case) -- but I'm not sure what to do if they do possess one or more of those.  Ideally I want a "pure/true" damage value like the DamageEffectIncrease for non-physical damage but applied via scripting instead of a creature having to swing a weapon.


 


Another example where this would be a problem is if a creature has a lot of regeneration -- they might be brought down to, say, 36% HP (and thus slip into Badly Wounded) and then start regenerating.  But since they're "held" at 49.9% of HP the regeneration will nudge them back into "Injured" status.


 


Obviously this is mainly a visual display issue and the builder can always get around this by adding hidden HP rather than an actual heal effect...but it would be nice to be able to fix this problem.




long story short, this is not possible to do properly without heavily usage of linux nwnx plugins