So. I was going to steal Jmorphman's Shadow Lady's code for glowing palettes, but his code was long and drawn out like his posts (Just kidding!), so I came up with something else a little less "heavy." It might be complicated if you can't plug in basic values and follow directions.
So, here's the code broken down into the steps of its development. Nothing ground breaking.
*By glowing palette, I mean using multiple palette files to emulate a glowing effect for a character. This comes in handy for people who want to make fancy glowing palettes for their characters. Some characters like Gill and Shadow Lady use these effects in their source games.
*The bold code is the crucial code.
Click this Text to Jump to Mugen Documentation about Stuff you don't Understand (http://elecbyte.com/mugendocs/mugen.html#documentation)
1. In the Loop
Let's say you have 16 palettes that you need to iterate through 1 by 1 forward and backward (Going from 0 to 1 to 2 and then back to 1 and then 0 again), to do that you would use the cos trigger. And you might be wandering why I'm using trigonometry, and the answer is, if you have to ask that, then you don't need to know, you just need to copy and paste! ;P
Anyway, here is how your code should start:
[state -2, Glowing Palette Effect]
type = remappal
trigger1 = 1
source = 1, 1
dest = 2, A * cos(gametime * pi / B)
Let's break down the two variables (not "variables" in the programming sense):
- A is the range, so if A was equal to 16, then the value that the dest parameter would return for its argument would go from -16 to 16. This value is arbitrary.
- B is how long it takes to go from -16 to 16. You already know that 60 ticks equal a second (you do now if you didn't before), so play around until it looks right. This value is arbitrary.
2. Don't be so Negative
You might have noticed in the above section that the value of the dest argument would go from -16 to 16 if A was 0, but who uses negative values to index their palettes? Is that even possible? I don't even know, but that's beside the point. The point is that we have to get rid of the negative value so that it only goes from 0 to 16. Thankfully we have the absolute value trigger, and it's really simple to use. Here's how your code will look now:
[state -2, Glowing Palette Effect]
type = remappal
trigger1 = 1
source = 1, 1
dest = 2, abs(A * cos(gametime * pi / B))
Now if A were equal to 16, your range would now be a value from 0 to 16, no matter what.
3. Going Up?
The next issue you will come across is decimals. It's completely impossible to have palettes indexed at decimals points, so what are we gonna do now? We're gonna need to do some rounding.
With all of that out of the, way here is what our code has come to:
[state -2, Glowing Palette Effect]
type = remappal
trigger1 = 1
source = 1, 1
dest = 2, ceil(abs(A * cos(gametime * pi / B)))
And that's all there is to it. This could theoretically give you debug spam if the value somehow becomes 0 (if you use floor instead of ceil), so if you get an error, then you should just add 1 to the whole equation and then decrease your range by 1. That will insure you don't go to palette X, 0, which won't exist, unless you make it exist.
4. Multiple Glowing Palettes
If you're gonna have multiple glowing palettes, then you can simply add your palettes to different groups and use the palno trigger. Here's a few examples:
[state -2, Glowing Palette Effect]
type = remappal
trigger1 = palno = 1
source = 1, 1
dest = 1, ceil(abs(A * cos(gametime * pi / B)))
[state -2, Glowing Palette Effect]
type = remappal
trigger1 = palno = 2
source = 1, 1
dest = 2, ceil(abs(A * cos(gametime * pi / B)))
[state -2, Glowing Palette Effect]
type = remappal
trigger1 = palno = 3
source = 1, 1
dest = 3, ceil(abs(A * cos(gametime * pi / B)))
5. Limitations of this Code
The limitations of this code is palfx. I consider it a bug in the engine, but when you have a constantly active remappal, palfx won't affect your character. You can make it only trigger when your character is not hit. But that's the only limitation of this code in terms of being functional in a fighting environment.
Make sure your effects use their own palettes and their own remappals, if necessary.
Cheers, Rajaa.
Unfortunately, since Mugen doesn't have a simple round function, which would be perfect here
Floor(x) returns y for any x=[y,y+1)
rounding returns y for any x=[y-0.5,y+0.5)
so Floor(x+0.5) will give you the rounded value, unless you want to use non-standard rounding rules.
We need flow control because if you simply use floor or ceil, either or, at the end point of each rotation, depending on if the actual number is positive or negative (the number without abs applied), you'll miss one palette.
Can't you use abs first, and that way ignore this whole problem?
dest = 2, floor(abs(A * cos(gametime * pi / B) < 0)+0.5)
and you might be wandering why I'm using trigonometry
Actually, yes, I wonder. Wouldn't an even distribution of time for each palette displayed work better? Oh wait, is this supposed to be some sort of a joke or something? I downloaded the character and this is the actual code...
[State -2, VarAdd]
type = VarAdd
trigger1 = GameTime % 5 = 0
var(41) = 1
ignoreHitPause = 1
[State -2, VarSet]
type = VarSet
trigger1 = var(41) = 7 && (PalNo = [1,6])
var(41) = 1
ignoreHitPause = 1
[State -2, RemapPal]
type = RemapPal
trigger1 = GameTime % 5 = 0 && (PalNo = [1,6])
trigger1 = StateNo != 3200 && StateNo != 4110
source = 1,1
dest = 1,var(41)
ignoreHitPause = 1
Simply goes to the next palette every 5 ticks and that's it.
Then again, it definitely could be simpler, for example, like this :
[State -2, RemapPal]
type = RemapPal
trigger1 = GameTime % 5 = 0 && (PalNo = [1,6])
trigger1 = StateNo != 3200 && StateNo != 4110
source = 1,1
dest = 1,1+floor(Gametime /5) %7
ignoreHitPause = 1
Saves a variable, too.