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

Legacy_MagicalMaster

  • Hero Member
  • *****
  • Posts: 2712
  • Karma: +0/-0
Scripted Irresistable Damage?
« on: April 12, 2014, 04:53:12 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.



               
               

               
            

Legacy_FunkySwerve

  • Hero Member
  • *****
  • Posts: 2325
  • Karma: +0/-0
Scripted Irresistable Damage?
« Reply #1 on: April 13, 2014, 01:11:21 am »


               

Take a look at ApplyDirectDamage in the module I gave you.


 


Another, slightly more hacktastic way, is similar to the way we coded effects that ignore itemprop immunities (other than Death, which is easy with Ex or Su). Just strip and reapply the props, applying the damage in between. It actually works quite flawlessly. For that, look at the includes for the endcombats in that module, the functions beginning ApplyEffectIgnoring... . Of course, that leaves the problem of effects, but you can strip and reapply those as well, with the proper duration, if you're running nwnx_structs.


 


Funky



               
               

               
            

Legacy_MagicalMaster

  • Hero Member
  • *****
  • Posts: 2712
  • Karma: +0/-0
Scripted Irresistable Damage?
« Reply #2 on: April 13, 2014, 04:27:51 am »


               

Unfortunately, this is being updated in general (though mainly due to the needs of a particular person) and thus I have no guarantee nwnx_structs will be running.  So not sure what to do about effects -- was hoping I wouldn't have to try to strip item properties and reapply them constantly (potentially once per second).


 


Where are ApplyDirectDamage and ApplyEffectIgnoring... located?  I opened the OnCombatEnd script which had access to AEI (but not ADD) but the only include was nw_i0_generic -- so I opened that (modified in the module) to find that it didn't have either of the functions.  So I checked that ;ibrary's includes (x0_i0_behavior and x0_i0_anims) but neither of those appear on the modified module specific resource list.


 


What libraries would hold those functions?



               
               

               
            

Legacy_Proleric

  • Hero Member
  • *****
  • Posts: 1750
  • Karma: +0/-0
Scripted Irresistable Damage?
« Reply #3 on: April 13, 2014, 08:46:19 am »


               Evidently, these are custom functions.

To find them, open the module with NWNExplorer. Right-click on the Scripts heading, then export to a folder of your choice. Search the folder using any tool that allows you to find content (e.g. FreeCommander).
               
               

               
            

Legacy_FunkySwerve

  • Hero Member
  • *****
  • Posts: 2325
  • Karma: +0/-0
Scripted Irresistable Damage?
« Reply #4 on: April 13, 2014, 10:22:38 pm »


               

There's an easier way to find them. Just open the mod script editor, and do a Find for the function name, making sure to search all scripts. Is how I find em myself, since we're north of 5000 scripts in the mod. In the search pane that opens below, you'll see the function declarations and implementations, if you scroll through. Most likely they're in a script ending in _inc, though I can't guarantee that.


 


Funky



               
               

               
            

Legacy_Proleric

  • Hero Member
  • *****
  • Posts: 1750
  • Karma: +0/-0
Scripted Irresistable Damage?
« Reply #5 on: April 13, 2014, 11:07:10 pm »


               lol I forgot it was just one module - started out describing how to pool Bioware / hak scripts, but lost my way...
               
               

               
            

Legacy_MagicalMaster

  • Hero Member
  • *****
  • Posts: 2712
  • Karma: +0/-0
Scripted Irresistable Damage?
« Reply #6 on: April 14, 2014, 01:19:58 am »


               

Found it, looking through it, thanks.



               
               

               
            

Legacy_SKIPPNUTTZ

  • Full Member
  • ***
  • Posts: 148
  • Karma: +0/-0
Scripted Irresistable Damage?
« Reply #7 on: April 14, 2014, 03:46:44 pm »


               


Take a look at ApplyDirectDamage in the module I gave you.


 


Another, slightly more hacktastic way, is similar to the way we coded effects that ignore itemprop immunities (other than Death, which is easy with Ex or Su). Just strip and reapply the props, applying the damage in between. It actually works quite flawlessly. For that, look at the includes for the endcombats in that module, the functions beginning ApplyEffectIgnoring... . Of course, that leaves the problem of effects, but you can strip and reapply those as well, with the proper duration, if you're running nwnx_structs.


 


Funky




 


Lol really?  I would like to see your code you use to do that, ive been thinking of trying this for some boss abilities. Quite sick of players and  monsters running around with Immunity to X,X,X,X,X,X,X,X,X,X,X,X, and  YZ '<img'>   So I'm guessing:


 


Boss casts custom Mass Hold Person at location.


Checks target for all effects, Remove temporary freedom of movement, and then it would get a little more difficult if you had to remove the itemstat i assume. Get item with freedom on it, remove the prop, Apply paralyze


 


 


And then apply the item prop back to the item?? Yes I need this please '<3'


 


And if you could take a second, how the hell could I apply something like this to Knockdown, Stunning Fist, Called Shot, etc events? We use a windows nwnx last i knew I seem to recall a plugin that would let u hook into these events but not sure how customizable it is.


               
               

               
            

Legacy_SKIPPNUTTZ

  • Full Member
  • ***
  • Posts: 148
  • Karma: +0/-0
Scripted Irresistable Damage?
« Reply #8 on: April 14, 2014, 03:56:03 pm »


               


Unfortunately, this is being updated in general (though mainly due to the needs of a particular person) and thus I have no guarantee nwnx_structs will be running. 




 


Is  nwnx_structs still Linux only? I'll ask the admin tonight, but im pretty sure out current server runs on windows.


               
               

               
            

Legacy_MagicalMaster

  • Hero Member
  • *****
  • Posts: 2712
  • Karma: +0/-0
Scripted Irresistable Damage?
« Reply #9 on: April 14, 2014, 05:21:51 pm »


               

Skipp, keep in mind you can use Cutscene Paralyze to get around some of that -- can use it as a stun/knockdown/paralyze and players can't resist it even with immunity to paralysis/freedom.


 



And if you could take a second, how the hell could I apply something like this to Knockdown, Stunning Fist, Called Shot, etc events? We use a windows nwnx last i knew I seem to recall a plugin that would let u hook into these events but not sure how customizable it is.



 


One option would be to give either a new feat or use a player tool feat that only works if you possess the feat, can only be used every so often, and simulates the main feat.  Higher Ground does something similar with Knockdown/Disarm as I recall.



               
               

               
            

Legacy_FunkySwerve

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


               


Lol really?  I would like to see your code you use to do that, ive been thinking of trying this for some boss abilities. Quite sick of players and  monsters running around with Immunity to X,X,X,X,X,X,X,X,X,X,X,X, and  YZ '<img'>   So I'm guessing:


 


Boss casts custom Mass Hold Person at location.


Checks target for all effects, Remove temporary freedom of movement, and then it would get a little more difficult if you had to remove the itemstat i assume. Get item with freedom on it, remove the prop, Apply paralyze


 


 


And then apply the item prop back to the item?? Yes I need this please '<3'


 


And if you could take a second, how the hell could I apply something like this to Knockdown, Stunning Fist, Called Shot, etc events? We use a windows nwnx last i knew I seem to recall a plugin that would let u hook into these events but not sure how customizable it is.




Here are our basic ignoring functions, taken from hg_inc and hg_attack_inc. The latter functions don't have declarations with them in the paste I made:


 


http://pastebin.com/4c92pPmR


 


Here are some sample implementations:


 


http://pastebin.com/Fq5wjQ67


 


Lastly, some KD functions:


 


http://pastebin.com/GxYcKHxR


 


Note that the vanilla compiler won't let you do for loops like this, you have to do whiles instead:

 


    for (oTarget = GetFirstObjectInShape(SHAPE_SPHERE, fRadius, lSelf, TRUE, nTargetMask);

         GetIsObjectValid(oTarget);

         oTarget = GetNextObjectInShape(SHAPE_SPHERE, fRadius, lSelf, TRUE, nTargetMask)) {...}


 


I'm not going to attempt to include every single subfunction, or else I'd be posting for hours, but that should be enough to give you the general gist of it. As you can see, we don't bother with getting duration and reapplying, as these functions predate that capability, and we simply haven't made it a priority yet, as our players were already accustomed to the current setup.


 


Funky


               
               

               
            

Legacy_FunkySwerve

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


               


Is  nwnx_structs still Linux only? I'll ask the admin tonight, but im pretty sure out current server runs on windows.




Don't know anymore, but as I note in the reply I just posted, you don't really need it unless you feel compelled to reapply.


 


Funky


               
               

               
            

Legacy_SKIPPNUTTZ

  • Full Member
  • ***
  • Posts: 148
  • Karma: +0/-0
Scripted Irresistable Damage?
« Reply #12 on: April 15, 2014, 11:47:18 pm »


               

You guys are great, thanks a bunch.


 


And yes MagicalMaster, thank god for Cutscene Paralyze, I use it a lot.



               
               

               
            

Legacy_FunkySwerve

  • Hero Member
  • *****
  • Posts: 2325
  • Karma: +0/-0
Scripted Irresistable Damage?
« Reply #13 on: April 16, 2014, 01:54:19 am »


               

By the way, here's a paste of ApplyDirectDamage, mentioned above, from a while back on these boards:


 


http://pastebin.com/vpaLtxAj


 


Funky



               
               

               
            

Legacy_MagicalMaster

  • Hero Member
  • *****
  • Posts: 2712
  • Karma: +0/-0
Scripted Irresistable Damage?
« Reply #14 on: April 16, 2014, 02:24:49 am »


               

Yes, was looking at it a bit yesterday and was confused by some things.  For example, what are GetTrueDamageImmunity and GetEffectDamageResistance?


 


Looks like those might be NWNX functions?


 


Would have to do some testing to see if it's possible to get the integer value of an effect's damage immunity.  If it was a property on an item then presumably one could get the associated cost of the property but if it's simply an applied effect I don't know if that'll work.