Author Topic: Scripts causing lag/split second jump  (Read 212 times)

Legacy_Tonden_Ockay

  • Hero Member
  • *****
  • Posts: 891
  • Karma: +0/-0
Scripts causing lag/split second jump
« on: June 11, 2015, 02:05:34 pm »


               

Hi all


I was going to use this HCR but when using it I see the game jump/lag/hold for a split second or whatever you call it every few seconds. Will this or does happen with all scripts like this? Is it due to heartbeat scripts or something. Does this happen with NESS? Is this something that is just going to happen if you want to use good scripts in your module?


Thanks for your time.



               
               

               
            

Legacy_Shadooow

  • Hero Member
  • *****
  • Posts: 7698
  • Karma: +0/-0
Scripts causing lag/split second jump
« Reply #1 on: June 11, 2015, 05:34:23 pm »


               

Absolutely not. Scripts rarely cause lags really and when they do they are doing some extremely heavy stuff (like PRC preloading 2DAs into database and thats only one time deal) or they are causing TMI.


 


Usually lagspike is a sign of a bad script. There are several instances when lag is going to happen but a good scripter is able to workaround it.


 


1) endless cycle causing TMI, after some thousand of commands NWN will terminate script if it still didnt finished. There might be a lagspike when that happen. Aside of endless loops, solution is to delay rest of the script and do it 0.1sec later etc.


 


2) ExportAllCharacters when there is 10+ players on server. Never use this function instead save all players separately one by one with slight delay (0.1)


 


3) *Campaign* line of functions. Bioware database is quite slow, IIRC reading is fast but writing is very slow and might cause lagspike especially if you are using this in loop. For anything complex, using NWNX and (My)SQL is recommended. If thats not the option then at least some workarounds like NDBE etc.


 


4) CreateObject used extensively in loops might cause this. (Re)creating a shop of 200+ items might cause lagspike.


 


Im not familiar with HCR so much except what it is about and whats there so Im not sure what this can be but if its very few seconds heartbeat could be really the cause of this. But its not heartbeat itself, Im using HB for PCs and I have no problems so its how its written. Also note that the lag you get might be graphical, if the script is changing your appearance somehow (aka horse lag).


 


Extra notes:


 


There is few vanilla issues causing huge lag spikes. Since this is not the subject of this thread I will just note that my patch is fixing this.



               
               

               
            

Legacy_ehye_khandee

  • Hero Member
  • *****
  • Posts: 1415
  • Karma: +0/-0
Scripts causing lag/split second jump
« Reply #2 on: June 11, 2015, 07:37:12 pm »


               

Rare case here but I agree with shadow, lagspikes in general are a sign of poor scripts.


               
               

               
            

Legacy_The Mad Poet

  • Hero Member
  • *****
  • Posts: 715
  • Karma: +0/-0
Scripts causing lag/split second jump
« Reply #3 on: June 11, 2015, 08:14:54 pm »


               

I've played with HCR in the past, and I know some people are strong advocates of it. Personally I don't care for the what the system does. Hunger, Thirst, and Fatigue is really very micromanage like for me. The bleeding and death system isn't my favorite, and nothing else really suited me.


 


If your looking for alternatives the HABD is pretty good for a robust bleed system. 


 


I've built my own respawn scripts, but Axe's is pretty good. I've used it in the past.


 


As for HTF, I haven't messed with it much because I'm not a fan, but this one claims to have pulled it out of the HCR set as a stand-alone. Might want to give that a try.


 


As for NESS there are two ways to setup the spawn cycle. One is through heartbeats, and the other is done on the Area Enter and Area Exit scripts. The documentation should show you how. Heartbeat system is just fine, and less work, for single player modules. For a PW though I would set it up through the area enter and exit scripts.



               
               

               
            

Legacy_Terrorble

  • Sr. Member
  • ****
  • Posts: 370
  • Karma: +0/-0
Scripts causing lag/split second jump
« Reply #4 on: June 12, 2015, 02:46:39 am »


               

You could run the module with NWNx and use the profiler.  You could probably find the offending script(s) in its list pretty quick and work it out from there.