Author Topic: default.nss  (Read 1863 times)

Legacy_azaz1234

  • Full Member
  • ***
  • Posts: 154
  • Karma: +0/-0
default.nss
« on: June 27, 2016, 12:47:37 am »


               

i'm interested in hooking a couple of the pc events handled by the default.nss script. has anyone ever done this before ?  how would i go about differentiating between the various events within the script -- just check the validity of a hypothetical GetLast*() object in a certain sequence ?


 


fwiw, i've already tried editing a test bic and replacing the default.nss entries w/custom handlers, but they're overwritten by the system.


 


also, for anyone who has done this, have you noticed any decrease in performance as a result ?


 


thanks much.



               
               

               
            

Legacy_SHOVA

  • Hero Member
  • *****
  • Posts: 893
  • Karma: +0/-0
default.nss
« Reply #1 on: June 27, 2016, 01:10:32 am »


               

Scripts with default as part of the name like, nw_c2_default1 are for NPC/creatures. Any changes made to those scripts will do nothing for the PC. The PC uses the scripts attached to the mod properties page, as named x2_mod_def_rest- for the PC rest. I recommend you copy the script make any changes to it and rename it - then place it in the correct place on the mod properties page. Note no change will happen to any script until you compile the scripts via the build mod tab.



               
               

               
            

Legacy_meaglyn

  • Hero Member
  • *****
  • Posts: 1451
  • Karma: +0/-0
default.nss
« Reply #2 on: June 27, 2016, 02:32:17 am »


               

I believe only the heartbeat event actually fires (unless the PC is in a bad state, possibly). I use default.nss as a PC heartbeat for a few fairly quick system checks. What I use it for could just as easily be done with the module HB though.  As far as I know that's the only event it gets called for. Most of the other events are for the AI which the PC does not need anyway.  As SHOVA said the other interesting events for PCs are all defined in the module events.



               
               

               
            

Legacy_Shadooow

  • Hero Member
  • *****
  • Posts: 7698
  • Karma: +0/-0
default.nss
« Reply #3 on: June 27, 2016, 03:40:44 am »


               

I recommend not to use default.nss. Afaik it runs only for heartbeat. Problem is that if this script exists in module another objects might fire it as well more specifically script-created traps.


 


So either pseudo-hb or rename default.nss to somescript.nss using nwnx



               
               

               
            

Baaleos

  • Administrator
  • Hero Member
  • *****
  • Posts: 1916
  • Karma: +0/-0
default.nss
« Reply #4 on: June 27, 2016, 09:37:51 am »


               

The default.nss is not the best choice - I've noticed it get fired even more rapidly depending on combat situations, it definitely isn't regular 100% of the time. I think it can even fire multiple times when you get hit by physical blows - suggesting it handles much more than just heartbeats.


Just my observations, perhaps it was a fluke?



               
               

               
            

Legacy_azaz1234

  • Full Member
  • ***
  • Posts: 154
  • Karma: +0/-0
default.nss
« Reply #5 on: June 27, 2016, 01:42:14 pm »


               

thanks for the replies, everyone.


 






Scripts with default as part of the name like, nw_c2_default1 are for NPC/creatures. Any changes made to those scripts will do nothing for the PC. The PC uses the scripts attached to the mod properties page, as named x2_mod_def_rest- for the PC rest. I recommend you copy the script make any changes to it and rename it - then place it in the correct place on the mod properties page. Note no change will happen to any script until you compile the scripts via the build mod tab.




 


in fact, i wasn't talking about nw_c2_default*, there's a script called default.nss that, if present, gets called for a number of pc-related events that aren't hookable via the module's pc-related defined event system. a couple of the things i was looking at hooking were the on-attacked, on-damaged, and on-spell-cast-at events which, unfortunately, aren't catchable for pc's.


 


 






I recommend not to use default.nss. Afaik it runs only for heartbeat. Problem is that if this script exists in module another objects might fire it as well more specifically script-created traps.




 


aha !  really ?  i didn't know it was used for anything else. have you actually seen it do this ?


 


 






The default.nss is not the best choice - I've noticed it get fired even more rapidly depending on combat situations, it definitely isn't regular 100% of the time. I think it can even fire multiple times when you get hit by physical blows - suggesting it handles much more than just heartbeats.


Just my observations, perhaps it was a fluke?




 


no, i don't think it was a fluke. if you were to open a bic, you'll see it listed for all sorts of events that aren't hookable in the module's editable properties. what you're saying leads me to believe that it might actually called for the on-damaged and/or on-attacked events, which is what i'd hoped. i don't suppose you happened to notice if it was called multiple times for each damaging blow ? [i know, i'm asking a lot... ;p ]


 


and when you say it isn't 'regular', do you mean that it sometimes doesn't fire when you think it should ?



               
               

               
            

Legacy_meaglyn

  • Hero Member
  • *****
  • Posts: 1451
  • Karma: +0/-0
default.nss
« Reply #6 on: June 27, 2016, 02:16:10 pm »


               

No. I'm pretty sure it only fires for heartbeat. Take a look at the discussions about it in the NWN Omnibus as well. It can be pretty easily retested too. 


 


@Shadoow: I'm not sure what you mean by script created traps calling default.  From what I can see the default for on disarmed is "" and on triggered if empty will run the default defined in traps.2da.


 


The fact that it is listed in the BIC file does not mean the script is getting called for those events.  The engine treats PCs differently in a lot of ways.  


 


There are some systems out there that use it (OHS for one I think) so for that reason it could be worth not using it, especially since that system is override based.



               
               

               
            

Legacy_Shadooow

  • Hero Member
  • *****
  • Posts: 7698
  • Karma: +0/-0
default.nss
« Reply #7 on: June 27, 2016, 03:00:54 pm »


               


No. I'm pretty sure it only fires for heartbeat. Take a look at the discussions about it in the NWN Omnibus as well. It can be pretty easily retested too. 


 


@Shadoow: I'm not sure what you mean by script created traps calling default.  From what I can see the default for on disarmed is "" and on triggered if empty will run the default defined in traps.2da.




Every trap created via CreateTrapAtLocation/OnObject will fire default.nss every 6 seconds. Thats something I witnessed in my own module and why I moved on from this approach.


               
               

               
            

Legacy_meaglyn

  • Hero Member
  • *****
  • Posts: 1451
  • Karma: +0/-0
default.nss
« Reply #8 on: June 27, 2016, 03:25:05 pm »


               


Every trap created via CreateTrapAtLocation/OnObject will fire default.nss every 6 seconds. Thats something I witnessed in my own module and why I moved on from this approach.




 


Well, that's an interesting result. Thanks. I'll have to look at that... 


 


Edit: yep, sure enough.  That's an odd bug.   Thanks Shadooow. I had not noticed that.  I agree ... don't bother with default. I've removed my use of it too.


               
               

               
            

Legacy_azaz1234

  • Full Member
  • ***
  • Posts: 154
  • Karma: +0/-0
default.nss
« Reply #9 on: June 28, 2016, 02:27:30 am »


               

i finally ended up writing a little test module for this. i can confirm that, for me at least, it's called only on heartbeat -- nothing else.


seems a complete waste of resources for something that can already be handled easily through the module's editable properties.


'<img'>


 


thanks for all your input guys !


 



               
               

               
            

Legacy_meaglyn

  • Hero Member
  • *****
  • Posts: 1451
  • Karma: +0/-0
default.nss
« Reply #10 on: June 28, 2016, 01:49:06 pm »


               

Yeah, if it did fire for all of those other creature AI events people would have put it to good use long before now '<img'>