Author Topic: Event for Using Weapon in Fight  (Read 1359 times)

Legacy_Stormsong_NWN

  • Newbie
  • *
  • Posts: 20
  • Karma: +0/-0
Event for Using Weapon in Fight
« on: November 06, 2015, 05:05:58 pm »


               

I am looking for a method for responding to an event when an item is used in a fight. So a start fight/end fight type event. I'm just coming back to building after a long time away and remember the frustration that I had when I couldn't latch on to this type of event. Has anyone had this figured out?



               
               

               
            

Legacy_Pstemarie

  • Hero Member
  • *****
  • Posts: 4368
  • Karma: +0/-0
Event for Using Weapon in Fight
« Reply #1 on: November 06, 2015, 10:35:52 pm »


               

OnHeartbeat - check to see if the character is in combat then do the other checks. However, using heartbeats can be processor intensive depending upon what you are trying to do.


 


OnCombatRoundEnd - checks if a combat round just ended.


 


OnAttacked - checks if a character was just attacked.


 


If you look at the BIC files for the pre-generated PCs, you'll see they all have a built in "default" script - no actual script in the game, but if you create one it will be recognized and accessed - which is used to handle ALL PC event calls if it exists.



               
               

               
            

Legacy_Stormsong_NWN

  • Newbie
  • *
  • Posts: 20
  • Karma: +0/-0
Event for Using Weapon in Fight
« Reply #2 on: November 06, 2015, 11:05:31 pm »


               

Thank you! This should give me a place to move forward from.



               
               

               
            

Legacy_Stormsong_NWN

  • Newbie
  • *
  • Posts: 20
  • Karma: +0/-0
Event for Using Weapon in Fight
« Reply #3 on: November 06, 2015, 11:19:47 pm »


               

So let me be sure I understand. Since the event is not in the module properties, I need to add it to the character, or if I create a script with that name does NWN pick it up when running?



               
               

               
            

Legacy_Pstemarie

  • Hero Member
  • *****
  • Posts: 4368
  • Karma: +0/-0
Event for Using Weapon in Fight
« Reply #4 on: November 07, 2015, 12:41:03 am »


               

The "default" script will only work with PCs and is used for ALL events. you cannot use it for NPCs or monsters. Instead you would need to make custom event scripts to handle what you need to do.


 


Yes, NWN will "pick up" a script named "default" when running.



               
               

               
            

Legacy_Shadooow

  • Hero Member
  • *****
  • Posts: 7698
  • Karma: +0/-0
Event for Using Weapon in Fight
« Reply #5 on: November 07, 2015, 01:37:00 am »


               


The "default" script will only work with PCs and is used for ALL events. you cannot use it for NPCs or monsters. Instead you would need to make custom event scripts to handle what you need to do.


 


Yes, NWN will "pick up" a script named "default" when running.




I dont think it runs for anything else than OnHeartbeat. And hearbeat type of even can be easily coded via recursive function.


 


Since I discovered that newly created traps via scripting runs "default" script too every 6seconds I abadoned this solution as Im creating random traps all the time.


               
               

               
            

Legacy_Pstemarie

  • Hero Member
  • *****
  • Posts: 4368
  • Karma: +0/-0
Event for Using Weapon in Fight
« Reply #6 on: November 07, 2015, 01:52:23 am »


               


I dont think it runs for anything else than OnHeartbeat. And hearbeat type of even can be easily coded via recursive function.


 


Since I discovered that newly created traps via scripting runs "default" script too every 6seconds I abadoned this solution as Im creating random traps all the time.




 


Yeah I don't know a lot about it. I know OMB used it for his PC as Henchmen system - can't remember what that was called...