Author Topic: Order of Events  (Read 341 times)

Legacy_henesua

  • Hero Member
  • *****
  • Posts: 6519
  • Karma: +0/-0
Order of Events
« on: November 20, 2011, 07:49:39 pm »


               I have given the property OnHitCast (Unique Power) to a creature's bite. I want to determine whether the creature has caused damage before applying the effect.

So... I assume that OnHitCast is triggered by a hit. Does the engine determine first if damage is applied before triggering the spell?

Or is the order
hit
trigger spell.
Determine bite damage.

what is the most efficient way (using the onhitcast event of a creature weapon) to determine whether this particular weapon has caused damage?
               
               

               


                     Modifié par henesua, 27 novembre 2011 - 08:06 .
                     
                  


            

Legacy_WhiZard

  • Hero Member
  • *****
  • Posts: 2149
  • Karma: +0/-0
Order of Events
« Reply #1 on: November 20, 2011, 11:43:51 pm »


               

henesua wrote...
Or is the order
hit
trigger spell.
Determine bite damage.

Determining hit and damage comes before any NWScript (including the creature's OnPhysicalAttacked script).  However the damage is applied after the On Hit Script fires.
               
               

               


                     Modifié par WhiZard, 20 novembre 2011 - 11:45 .
                     
                  


            

Legacy_Lightfoot8

  • Hero Member
  • *****
  • Posts: 4797
  • Karma: +0/-0
Order of Events
« Reply #2 on: November 20, 2011, 11:55:04 pm »


               The On-Hit also only happens if there was damage done.
               
               

               
            

Legacy_henesua

  • Hero Member
  • *****
  • Posts: 6519
  • Karma: +0/-0
Order of Events
« Reply #3 on: November 21, 2011, 12:27:26 am »


               Thanks. Thats what I needed to know. If the On-Hit only happens if damage is done, then I've got what I need.
               
               

               
            

Legacy_Shadooow

  • Hero Member
  • *****
  • Posts: 7698
  • Karma: +0/-0
Order of Events
« Reply #4 on: November 21, 2011, 03:37:08 am »


               I suspect it does work the same way as on armor. I do use opposite approach and I added onhit to the PC armor. Each time someone damages PC, the onhit script is triggered before the damage is done. 0.1 second later, the damage is applied and allOnDamaged functions works in there.
               
               

               
            

Legacy_WhiZard

  • Hero Member
  • *****
  • Posts: 2149
  • Karma: +0/-0
Order of Events
« Reply #5 on: November 21, 2011, 04:33:07 am »


               

Lightfoot8 wrote...

The On-Hit also only happens if there was damage done.


You are thinking standard on-hits.  On-hit cast spell (a separate category which unique power is under) is called on every single hit (regardless if damage was done). 
               
               

               
            

Legacy_henesua

  • Hero Member
  • *****
  • Posts: 6519
  • Karma: +0/-0
Order of Events
« Reply #6 on: November 21, 2011, 07:04:53 pm »


               Crap... so I think I'll need a work around then. This could be complicated.

Is it possible to make a custom disease, and to disallow immunity to said disease? [Edit apparently not]

I wonder if there is another way of creating an effect on a character in reponse to an attack that inflicts damage (and only if it has inflicted damage).

[edit again] Had an idea: my OnHitCast Unique script could include a delayed function call (delayed by just a fraction of a second) that fucntion would compare before and after HP on the character thereby determining if that particular attack caused damage.

Only problem I can think of with that is inefficiency. Or possibly if too many attacks are happening all at the same time, you might capture the wrong damage if you do not identify the source of damage.
               
               

               


                     Modifié par henesua, 21 novembre 2011 - 07:46 .
                     
                  


            

Legacy_WhiZard

  • Hero Member
  • *****
  • Posts: 2149
  • Karma: +0/-0
Order of Events
« Reply #7 on: November 22, 2011, 01:18:45 am »


               

henesua wrote...
Only problem I can think of with that is inefficiency. Or possibly if too many attacks are happening all at the same time, you might capture the wrong damage if you do not identify the source of damage.

You could try a combination, such as a standard on-hit blindness with an on-hit cast spell unique power.  The unique power would have a delay and checks if the target has blindness that did not come from a spell.  It then removes the blindness and proceeds with its standard routine.  Just don't have other items with on-hit blindness.
               
               

               
            

Legacy_henesua

  • Hero Member
  • *****
  • Posts: 6519
  • Karma: +0/-0
Order of Events
« Reply #8 on: November 22, 2011, 01:30:15 am »


               That could work, although I think on-hit wounding would work better as I don't think it has an immunity. And it wouldn't cause any obvious change for the player.

However I thought on-hit properties caused a big hit on the server? Wouldn't applying two on-hit properties be problematic?
               
               

               
            

Legacy_Shadooow

  • Hero Member
  • *****
  • Posts: 7698
  • Karma: +0/-0
Order of Events
« Reply #9 on: November 22, 2011, 06:40:32 am »


               

henesua wrote...

However I thought on-hit properties caused a big hit on the server? Wouldn't applying two on-hit properties be problematic?

Not really, impact on CPU is overrated. Unless you have full area of npcs with 10 attacks it will be fine.

Every creature triggers OnAttacked script each time you attack, OnDamaged each time you hit , OnHeartbeat each six seconds, OnConversation each time you attack any creature nearby etc. Unless your onhit performs 2k instructions, you cannot make it worse.
               
               

               
            

Legacy_henesua

  • Hero Member
  • *****
  • Posts: 6519
  • Karma: +0/-0
Order of Events
« Reply #10 on: November 27, 2011, 08:07:38 pm »


               OK another order of events question:

Does the OnDamaged event always occur before OnDeath if the creature was killed by damage?