Author Topic: OnSpawn Script  (Read 342 times)

Legacy_henesua

  • Hero Member
  • *****
  • Posts: 6519
  • Karma: +0/-0
OnSpawn Script
« on: February 08, 2012, 05:54:59 pm »


               How many times should this script execute when a creature spawns?

I am noticing that when a familiar is summoned the OnSpawn script executes twice. Is there a reason for that? Or would it be better to catch and abort the second iteration of the script? 
               
               

               
            

Legacy_Lightfoot8

  • Hero Member
  • *****
  • Posts: 4797
  • Karma: +0/-0
OnSpawn Script
« Reply #1 on: February 08, 2012, 11:11:57 pm »


               Ok, I am at a loss on this one,   I am not even sure what script is firing for th eonspawn of a fimmiliar.  How are you determining that the script is firing twice?
               
               

               
            

Legacy_henesua

  • Hero Member
  • *****
  • Posts: 6519
  • Karma: +0/-0
OnSpawn Script
« Reply #2 on: February 08, 2012, 11:48:59 pm »


               Its the familiar's OnSpawn that I am examining in this case. I think the name of the script is nw_ac_acani9. or something like that. I'll post the exact name when I get home.

I put a check in the script that notifies the first pc everytime the script executes. Its been executing twice when I summon the familiar. This isn't really a problem... BUT given that spawn events are considered a potential source of lag, I'm thinking that if every spawn script executes twice... thats part of the problem.

Anyway... lets just focus on familiars. Would there be any reason why the script needs to execute twice? If not, I'll short circuit the second execution.
               
               

               
            

Legacy_Lightfoot8

  • Hero Member
  • *****
  • Posts: 4797
  • Karma: +0/-0
OnSpawn Script
« Reply #3 on: February 09, 2012, 12:35:43 am »


               ok,  Yep that one ran twice when I called a fimiliar also.  

So here is a guess,   I am guessing that the creature is created once, then copyed/created a second time to init the creature as a fimiliar.  So if you did stop one of them from running you would want to stop the first one and not the second.  

However the script itself does not take that long to run. It only takes 0.00005 seconds on my rig.  It is the spawning of the creature that takes the time, not the OnSpawn script.  So I do not think it is worth the possiable bugs you could interduce in trying to stop it from running an extra time.
               
               

               
            

Legacy_henesua

  • Hero Member
  • *****
  • Posts: 6519
  • Karma: +0/-0
OnSpawn Script
« Reply #4 on: February 09, 2012, 08:11:08 pm »


               OK thanks for the info. I looked deeper into the OnSpawn options this morning and played more with this script. My changes only happen on the familiar's second pass through. Everything is working well...

...casting a spell so that effects granted by familiar summoning can be easily removed when the familiar is unsummoned.