Author Topic: Event OnPlayer Damaged?  (Read 483 times)

Legacy_WhiteTiger

  • Hero Member
  • *****
  • Posts: 889
  • Karma: +0/-0
Event OnPlayer Damaged?
« on: June 23, 2014, 09:12:01 pm »


               

How to do an action when player is damaged?



               
               

               
            

Legacy_Shadooow

  • Hero Member
  • *****
  • Posts: 7698
  • Karma: +0/-0
Event OnPlayer Damaged?
« Reply #1 on: June 24, 2014, 12:27:42 am »


               

This has been discussed several times already. Summing up this thread:


 


1. A NWNX plugin exists that enables an OnDamaged event for player. (however Im not sure whether this exists on windows too - clarification anyone?)


2. It can be done within NWScript by adding an OnHitCastSpell: Unique Power (or custom spell if you use haks) on armor or skin when naked. (However Funky reports this is not absolutely reliable in very specific and high magic environment where character is target of dozens of attacks each second. But for a normal environment it works just fine)


3. While the script with name default run for player in multiple events, it does not run when OnDamaged. Furthermore this script runs as OnHeartbeat for each trap created by script which makes this terrible choice for persistant world - better to workaround with pseudo-heartbeat.



               
               

               
            

Legacy_WhiteTiger

  • Hero Member
  • *****
  • Posts: 889
  • Karma: +0/-0
Event OnPlayer Damaged?
« Reply #2 on: June 24, 2014, 06:21:43 am »


               

Thanks, Shad. It worked with me using OnHitCastSpell: Unique power



               
               

               
            

Baaleos

  • Administrator
  • Hero Member
  • *****
  • Posts: 1916
  • Karma: +0/-0
Event OnPlayer Damaged?
« Reply #3 on: June 24, 2014, 09:56:51 am »


               

My own version of the onPlayerDamaged hook is discussed here.


http://nwnx.org/phpB...opic.php?t=2111


 


It allows you to modify damage amounts before they appear in the combat log, and even set the damage amounts to 0, and then heal the creature/player instead.


 


I use it for some custom feats, that allow players to heal themselves with fire damage.



               
               

               
            

Legacy_WhiteTiger

  • Hero Member
  • *****
  • Posts: 889
  • Karma: +0/-0
Event OnPlayer Damaged?
« Reply #4 on: June 25, 2014, 02:59:23 am »


               


I use it for some custom feats, that allow players to heal themselves with fire damage.




 


good idea


               
               

               
            

Legacy_WhiZard

  • Hero Member
  • *****
  • Posts: 2149
  • Karma: +0/-0
Event OnPlayer Damaged?
« Reply #5 on: June 25, 2014, 05:48:11 am »


               

I use it for some custom feats, that allow players to heal themselves with fire damage.



 


That somewhat disinterests me.  Not that creatures couldn't be given the ability to heal when encountering a particular damage, but giving this power to player characters.  For example, fire elementals seem a perfect fit for this ability; add fire to fire and get more fire.  However, unless you have a druid shifting into this form, there is really no need for a PC to have or even expect this ability.  I have so often read threads where immunities to ability loss, critical hits, and other things were deemed way to powerful and servers were looking for ways to bypass them for abilities such as crippling strike.  My take is why (besides shifted forms) are you actually giving these to players? A lot of these immunities were designed for creatures that would naturally be unaffected by ability loss, critical hits, etc. by the form they exist in.  Don't expect to find a critical weakness in golems.  Negative energy bursts should probably not be lowering a golem's strength.  If we stop the PCs from having monster-like immunities then the monsters may actually look more dangerous and more unique.  But that's my rant.


               
               

               
            

Legacy_Wallack

  • Full Member
  • ***
  • Posts: 221
  • Karma: +0/-0
Event OnPlayer Damaged?
« Reply #6 on: June 25, 2014, 10:14:05 am »


               


My own version of the onPlayerDamaged hook is discussed here.


http://nwnx.org/phpB...opic.php?t=2111


 


It allows you to modify damage amounts before they appear in the combat log, and even set the damage amounts to 0, and then heal the creature/player instead.


 


I use it for some custom feats, that allow players to heal themselves with fire damage.




 


Does it allow to get the attacker and attacked object? because I want to create a custom durability script for weapons, armors and shields and this is exactly what I'm looking for (so I don't have to add an onhitcastspell to every object)


               
               

               
            

Baaleos

  • Administrator
  • Hero Member
  • *****
  • Posts: 1916
  • Karma: +0/-0
Event OnPlayer Damaged?
« Reply #7 on: June 25, 2014, 04:02:36 pm »


               

Yes, the OBJECT_SELF is the person suffering the damage, and the GetEventTarget from nwnx_cool allows you to get the attacker.


You would need to script the code yourself to determine what armor specifically is attacked/damaged.


But you will be able to determine the attacker and attackee in real combat time.



               
               

               
            

Legacy_Wallack

  • Full Member
  • ***
  • Posts: 221
  • Karma: +0/-0
Event OnPlayer Damaged?
« Reply #8 on: June 25, 2014, 04:06:12 pm »


               

Thanks, that is perfect for my needs '<img'>



               
               

               
            

Baaleos

  • Administrator
  • Hero Member
  • *****
  • Posts: 1916
  • Karma: +0/-0
Event OnPlayer Damaged?
« Reply #9 on: June 25, 2014, 07:17:12 pm »


               


That somewhat disinterests me.  Not that creatures couldn't be given the ability to heal when encountering a particular damage, but giving this power to player characters.  For example, fire elementals seem a perfect fit for this ability; add fire to fire and get more fire.  However, unless you have a druid shifting into this form, there is really no need for a PC to have or even expect this ability.  I have so often read threads where immunities to ability loss, critical hits, and other things were deemed way to powerful and servers were looking for ways to bypass them for abilities such as crippling strike.  My take is why (besides shifted forms) are you actually giving these to players? A lot of these immunities were designed for creatures that would naturally be unaffected by ability loss, critical hits, etc. by the form they exist in.  Don't expect to find a critical weakness in golems.  Negative energy bursts should probably not be lowering a golem's strength.  If we stop the PCs from having monster-like immunities then the monsters may actually look more dangerous and more unique.  But that's my rant.




Hi WhiZ


While I word it that Players can manipulate their damage and heal, it is actually at a creature level.


So NPC's and Players alike can make use of the feature.


 


Some Persistent Worlds use tools like nwnx to extend and reach new limits of functionality in nwn.


For instance, with nwnx_cool - you can have as many nwn levels as you want.


With this in mind, you could have HP in the range of 5000+


In which case the typical damage levels associated with some bosses or high level content may need adjusted.


Eg: Instead of a boss dealing 100 points of damage, you could apply a multiplier at combat time to adjust it by 2x


 


 


With damage hooks, the limit is your imagination.


Heal on damage types, apply extra damage per type


Convert damage types to another damage type etc


I have even made a boss who is immune to damage types based on switches that are toggled on and off around his arena


Players have to turn them off every 1 minutes to keep him damagable.


Also implemented a final fantasy XIII stagger type system - every time damage is suffered, 1% of the damage is added to a counter, and when that counter gets to 500, it staggers the boss.


This then makes all damage he suffers for 1 minute be doubled.


Then when he recovers, he deals double damage for 25 seconds.


 


This dynamic promotes pummelling the boss and then running away or defensive behaviour when he suddenly goes all ragey on the players.


               
               

               
            

Legacy_WhiZard

  • Hero Member
  • *****
  • Posts: 2149
  • Karma: +0/-0
Event OnPlayer Damaged?
« Reply #10 on: June 25, 2014, 11:38:16 pm »


               


Hi WhiZ


While I word it that Players can manipulate their damage and heal, it is actually at a creature level.


So NPC's and Players alike can make use of the feature.


 


Some Persistent Worlds use tools like nwnx to extend and reach new limits of functionality in nwn.


For instance, with nwnx_cool - you can have as many nwn levels as you want.


With this in mind, you could have HP in the range of 5000+


In which case the typical damage levels associated with some bosses or high level content may need adjusted.


Eg: Instead of a boss dealing 100 points of damage, you could apply a multiplier at combat time to adjust it by 2x


 


 


With damage hooks, the limit is your imagination.


Heal on damage types, apply extra damage per type


Convert damage types to another damage type etc


I have even made a boss who is immune to damage types based on switches that are toggled on and off around his arena


Players have to turn them off every 1 minutes to keep him damagable.


Also implemented a final fantasy XIII stagger type system - every time damage is suffered, 1% of the damage is added to a counter, and when that counter gets to 500, it staggers the boss.


This then makes all damage he suffers for 1 minute be doubled.


Then when he recovers, he deals double damage for 25 seconds.


 


This dynamic promotes pummelling the boss and then running away or defensive behaviour when he suddenly goes all ragey on the players.




 


I already realize the vast freedoms that NWNX offers, however, your last example does not need any NWNX implementation to carry out.  Nor does "apply extra damage per type".  Heal on damage type is doable, so long as the hitpoints don't get low enough that the blow would be lethal.  All this can work for creatures, but is it really necessary to overhaul this to player characters?  Giving PCs the ability to switch around their damage immunities?  I'm not sure how well the creature AI can keep up with this, and I only see major exp|0it potential if the PC's options are too dynamic.


               
               

               
            

Baaleos

  • Administrator
  • Hero Member
  • *****
  • Posts: 1916
  • Karma: +0/-0
Event OnPlayer Damaged?
« Reply #11 on: June 26, 2014, 09:25:20 am »


               


I already realize the vast freedoms that NWNX offers, however, your last example does not need any NWNX implementation to carry out.  Nor does "apply extra damage per type".  Heal on damage type is doable, so long as the hitpoints don't get low enough that the blow would be lethal.  All this can work for creatures, but is it really necessary to overhaul this to player characters?  Giving PCs the ability to switch around their damage immunities?  I'm not sure how well the creature AI can keep up with this, and I only see major exp|0it potential if the PC's options are too dynamic.




 


Can you remember what the max damage vulnerability value that can be applied is via scripting? I just assumed it was 100%. This system would allow damage vulnerabilities of any amount. (as long as the figure can fit in a 32bit integer)


Whats not currently do-able through vanilla nwn is the modification of the combat damages before they reach the combat log.


And as you say, it is possible to do a 'pseudo' damage event for players, but it doesnt fire on every attack or every damage sustained event.


 


As for whether its wise to let PC's switch their immunities - that's the challenge for PW Admins to overcome. There is nothing inherently wrong with the functionality itself, its how it is used and balanced in a PW Environment that can be good or bad.


               
               

               
            

Legacy_WhiZard

  • Hero Member
  • *****
  • Posts: 2149
  • Karma: +0/-0
Event OnPlayer Damaged?
« Reply #12 on: June 26, 2014, 03:21:48 pm »


               


Can you remember what the max damage vulnerability value that can be applied is via scripting? I just assumed it was 100%. This system would allow damage vulnerabilities of any amount. (as long as the figure can fit in a 32bit integer)


Whats not currently do-able through vanilla nwn is the modification of the combat damages before they reach the combat log.


And as you say, it is possible to do a 'pseudo' damage event for players, but it doesnt fire on every attack or every damage sustained event.


 


As for whether its wise to let PC's switch their immunities - that's the challenge for PW Admins to overcome. There is nothing inherently wrong with the functionality itself, its how it is used and balanced in a PW Environment that can be good or bad.




 


 


There are ways of avoiding the vulnerability change.  For example, making the creature OnDamaged script deal a separate damage effect and make a handler in OnDamaged to prevent this second application from triggering a third. 


 


The vulnerability is capped by default at 100%, and the total damage the system supports is by default a 14 bit number.


 


I understand there is a lot of potential with NWNX.  I just don't think that the manipulation of the PC OnDamaged is the best illustration of NWNX's capabilities.


               
               

               
            

Baaleos

  • Administrator
  • Hero Member
  • *****
  • Posts: 1916
  • Karma: +0/-0
Event OnPlayer Damaged?
« Reply #13 on: June 26, 2014, 07:20:02 pm »


               Yes, but it is an illustration of an onDamaged hook for players/Creatures.
Remember the original poster was requesting something that can give an onDamaged event, whatever he wants to do during that event is up to him.
Im just supplying the capability to do what he needs and more.

Wallack also wants to get the Creature inflicting the damage, which is something you just cannot do accurately with a Default script hb system that tracks damage inflicted each hb. You end up missing creatures that are inflicting damage between hb.

As far as I know, this NWNX code method is the only way of registering onDamaged events for players.

(There is actually 2 hooks in my plugin, one is for onDamaged - after the calculations are done, the other is before the damage appears in the combat log but after the damage is worked out (EffectHandler_ApplyDamage): Both allow you to change the values, but to slightly different results. You can always elect to not change the combat damage at all, and use it for something more passive, like a durability system, as mentioned above. Which of course means you no longer need to use an onHit system on your armor or weapons.)
               
               

               
            

Legacy_Shadooow

  • Hero Member
  • *****
  • Posts: 7698
  • Karma: +0/-0
Event OnPlayer Damaged?
« Reply #14 on: June 26, 2014, 07:26:50 pm »


               



As far as I know, this NWNX code method is the only way of registering onDamaged events for players.




Seems you misread my post about the onhitcastspell on armor/skin. And yes its reliable, allows to retrieve a damager and allows to block the damage being done.


 


Not to question your plugin, that has its uses of course and allow much more than the OnHitCastSpell way.