How do I avoid general slowdown with a colorized boss script?

Icezer

Local Ice Cube Frien. Robotic Hedgehog Enthusiast.
Hey there, everyone. Recently I got an idea from playing as Eggpack to make a script just for fun that turns all the Eggman bosses (and their associated objects) monochrome, much like the Metal Sonic and Fang clones in the base game. Then I actually got the idea to refine this script to get it ready for a release.

All works as intended in the actual boss levels. However, in some non-boss levels such as Deep Sea Act 1 or Arid Canyon Act 2, the game chugs very badly. I have tried changing what objects get colorized with little to no luck, and I can confirm it only occurs when the script is added.


At the moment, the script checks if you are playing as Eggpack to colorize the bosses/boss objects. Maybe a way to make it map dependent exists, but I digress.

Whether it has to do with the amount of objects colorized or something else, help would be greatly appreciated at this point. Files can be attached in replies if necessary, as well.
 
My guess is perhaps that you are performing searches for these boss objects on a per-frame basis? I would recommend hooking a MobjSpawn function to the object types you wish to adjust; I don't think any of the vanilla bosses recolor themselves so you should be safe to set their color and colorization values upon spawn.
 
My guess is perhaps that you are performing searches for these boss objects on a per-frame basis? I would recommend hooking a MobjSpawn function to the object types you wish to adjust; I don't think any of the vanilla bosses recolor themselves so you should be safe to set their color and colorization values upon spawn.


Just tried using MobjSpawn and everything works except the actual bosses. Trying to colorize them with MobjSpawn yields no changes, while something like MobjThinker works. However, when using MobjThinker in the script, the game lags like before.
EDIT: Tried using BossThinker instead of MobjThinker for the boss portion of the script and it works perfectly. Help has been appreciated since MobjSpawn did wonders for all the extra objects :)
 
Last edited:
Ah, you might not be aware that you can hook MobjThinkers to specific object types with the third argument to addHook—for instance:

Code:
addHook("MobjThinker", function(mo)
    print("Hello, I am a blue crawla!")
end, MT_BLUECRAWLA)

This will only call the function for blue crawlas in the level, rather than every thinking object in the level.
 

Who is viewing this thread (Total: 1, Members: 0, Guests: 1)

Back
Top