Author Topic: On activateitem question  (Read 980 times)

Legacy_Surek

  • Full Member
  • ***
  • Posts: 169
  • Karma: +0/-0
On activateitem question
« on: May 27, 2016, 05:17:58 pm »


               I have a question about on activateitem. I was wondering is there a way lets say the PC is in combat and uses an on activateitem but gets hit during combat is there any way to stop the item from firing its script?
               
               

               
            

Legacy_KMdS!

  • Sr. Member
  • ****
  • Posts: 364
  • Karma: +0/-0
On activateitem question
« Reply #1 on: May 27, 2016, 05:53:34 pm »


               

hmm, interesting question.....


 


There is no on hit  or damage event on a PC......unless there is a hook using  NWNX????


 


Otherwise it might be doable but by a very circuitous route through scripting...I have something developing in my mind, but it would be a logic bender....ouch, head hurts  ':blink:'  '<img'>


 


Anyone else?



               
               

               
            

Baaleos

  • Administrator
  • Hero Member
  • *****
  • Posts: 1916
  • Karma: +0/-0
On activateitem question
« Reply #2 on: May 27, 2016, 06:09:33 pm »


               

I don't think there is any native way to get the action queue items - is there?


So what you initially asked for -


When you use an item, can you cancel using the item when hit.


 


Once the item animation has played, that's when the script plays - so its too late at this point.


The only chance to stop the item being used before that, is when it is in the action queue, and all you can do is 


ClearAllIActions();  or whatever it is called - which will empty the action queue.


 


You could put that in a creatures Claw / Sword etc impact script - so it clears the actions of the player it strikes - but then that could disrupt normal combat actions too.


 


You can make a pseudo onHit event via using the default.nss script.


By monitoring your current hp each hb, you can determine if you have suffered any damage.


You can then modify your idea so the onActivate item plays a casting animation for 2 seconds.


During those two seconds - if your health changes - then you know you suffered a hit.


Then you set a local variable 'OnHit' to 1


In your onActivate script - you wait for those 2 seconds, then check the value of the variable.


If it is equal to 1 =  play spell fizzle animation.


If it is equal to 0 = complete the casting, and do the desired effect


 


 


Without nwnx - there is no nice clean way to do it.


               
               

               
            

Legacy_Surek

  • Full Member
  • ***
  • Posts: 169
  • Karma: +0/-0
On activateitem question
« Reply #3 on: May 28, 2016, 04:15:58 am »


               Thanks for the answers, it's Ok  I was just wondering if it was doable. Sounds like no easy way of doing it. But  thank you anyway
               
               

               
            

Legacy_KMdS!

  • Sr. Member
  • ****
  • Posts: 364
  • Karma: +0/-0
On activateitem question
« Reply #4 on: May 28, 2016, 05:00:12 am »


               

I believe there is a way to do this without the use of nwnx.....have to verify it though. Here's the skinny....


 


Armor and shield respond to being hit if I remember right, have an event tied to the strike. You might be able to script a method to catch all strikes to the equipped armor slot and use it to set a variable on the player equal to the instant of the strike time in seconds plus a modifier of a few seconds and have your on activate event script check the stored time value to see if they are allowed to use their item........or something like that? ':huh:'  ':huh:'  ':huh:'