Yeah I had found if I put the skill increments script into one "global" script, and have it "called" by another script. . .every time the player got a skill-up the engine would lag, causing a lag spike ingame.
By putting the skill-up script directly in the script being run when the skill-up occurs, it executed better and smoother, with no lag spike.
Some of the combinations repeat because there is more than one type of item that does basically the same thing, like there is 4 different hammers and their scripts are near identically besides damage/speed/breakage variable.
Another Example:
When you kill any animal and get a +1 Hunting skill-up the script is ran at that very moment with no lag spike. If it had to call one global script it makes a small lag spike the player experiences ingame. Therefore I put the +1 Hunting script attached to every unit. . .the engine executes it without have to look for it globally and returns the text onscreen +1 Hunting. . .immediately.
There are some other scripts I did the same thing with as to reduce lag. Mostly, any script that is executed "during" game play. The exception is the 2 main scripts, executed every 2 seconds, and the hourly skybox. I can only optimize them best I can. The rest generally occur at new day update, or when the player sleeps when it doesnt effect the players gameplay.
In a Nutshell: Anytime the engine has to look outside the current script that is running, it puts a strain on the engine. So, multiple identical scripts placed "inside" the currently running script runs faster, as the engine doesn't have to stop and look for something that's being requested. . .it's right there already, to be ran.
P.S. As for the script format, I have kept the same script format that Builder-02 already had established in Massive-Mod, with some very minor adjustments. The scripting is not the source-code, the source-code lies within the .exe file, and I don't personally mess with that.
edited 4×, last 22.02.18 04:08:05 pm