Palette Cycling [AKA Super Sonic Effect]

Greetings, fellow developers!

I'm currently working on a Sonic fangame, and I'd like to share my newest script; a palette cycling effect, useful for many things (the most important of them, at least for me, is shown on the video below). This is my first attempt on doing my own ondrawscript, and I would like some feedback on it, and also a little help.

I'm currently using mod (%) to control the palette change interval, but greater number (i.e.: 10) make the script behave weirdly, locking the character in a single, random palette for too long.

Here's the script code:
Code:
void LoopPal(void LastMap, void LoopInterval)
{
	void	self 	 = getlocalvar("self");	//get caller
	void	selfMap  = getentityproperty(self, "map");
	void	Alive 	 = getentityproperty(self, "exists");
	void	gametime = openborvariant("elapsed_time");
	void	NewMap;
	void	CheckInterval = (gametime % LoopInterval);
//-----------------------------------------------------

if(openborvariant("in_level"))
	{ 
//		settextobj(12,4,4,1,  170, gametime);
//		settextobj(13,4,16,1, 170, CheckInterval);
//		settextobj(14,4,28,1, 170, selfMap);
		if (CheckInterval == 0)
		{
			if (selfMap == LastMap)		{NewMap = 0;}
			else 						{NewMap = (selfMap +1);}
			changeentityproperty(self, "map", NewMap);
		}
	}
}

To use it, open your character's ondrawscript and import this script. Inside main(), call LoopPal with the needed parameters.

There are two videos showing the script in action:
 
Looks good, reminds me of similar FX I've made for Rainbow and temporary boosters.  ;D

but greater number (i.e.: 10) make the script behave weirdly, locking the character in a single, random palette for too long

Hmmm... I am not sure what you mean by that.
 
If I set the LoopInterval as a big number, the script simply behaves bizarrely; the palette changes becomes almost completely random, with moments where your character gets stuck in a single palette for almost 10 seconds, then changes rapidly between all other palletes.
 
Back
Top Bottom