YesNoOk
avatar

Glowing Palette for Mugen 1.0 (Read 12622 times)

Started by RajaaBoy, June 12, 2012, 05:35:37 pm
Share this topic:
Glowing Palette for Mugen 1.0
New #1  June 12, 2012, 05:35:37 pm
  • avatar
  • ******
    • Thailand
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


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.
Last Edit: June 13, 2012, 04:03:11 pm by Rajaa
Re: Glowing Palette for Mugen 1.0
#2  June 13, 2012, 12:26:14 am
  • ****
    • Hungary
    • seravy.x10.mx/Wordpress
Quote
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.
Quote
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)


Quote
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...

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 :
Code:
[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.
Re: Glowing Palette for Mugen 1.0
#3  June 13, 2012, 12:37:25 am
  • ******
  • If you’re gonna reach for a star...
  • reach for the lowest one you can.
    • USA
    • network.mugenguild.com/jmorphman
but his code was long and drawn out like his posts
I will end you

Oh wait, is this supposed to be some sort of a joke or something? I downloaded the character and this is the actual code...
That's actually from the joke character Shadow Lady, I believe Rajaa is talking about the Shadow Lady alternate mode in my Chun-Li.

although I seem to recall doing the remappal stuff mostly the same way

EDIT: yeah I didn't have the palettes cycling back for jokeShadow Lady, but for the nonjoke version some palettes cycle back
Last Edit: June 13, 2012, 12:50:36 am by Jmorphman
Re: Glowing Palette for Mugen 1.0
#4  June 13, 2012, 01:03:25 am
  • ****
    • Hungary
    • seravy.x10.mx/Wordpress
Quote
EDIT: yeah I didn't have the palettes cycling back for jokeShadow Lady, but for the nonjoke version some palettes cycle back
Easiest way to make the palettes cycle back is to add them in reverse order one more time (7=5,8=4,9=3,10=2) in the SFF, then make it go from 1 to 10 instead of 1 to 6.

Or this works, too :
dest = 1,1+Cond(gametime %55<35,floor((Gametime %55) /5) ,5-floor((Gametime %55-35) /5))

Using Cos would result in an uneven time duration for each color, and abs even turns it asymmetric. Instead of using abs, adding +17 to make it go from 1-33 instead of -16 to 16 would be better, as it retains the symmetry of cos.
Re: Glowing Palette for Mugen 1.0
#5  June 13, 2012, 08:31:16 am
  • avatar
  • ******
    • Thailand
The unequal time duration for each color gives the glowing effect that glowing feeling. It slows down on the last palette if you set the values "correctly", or you could index the palettes in reverse order of how you want them. It worked perfectly for what I wanted to do and the "asymmetry" is hardly noticeable and practically absent, if present at all.

I guess if people need equal distribution then they could use your code or something. You could even make a new thread about it. =p

But thank you for pointing out the abs simplicity. I certainly can just get the absolute value without having to do the flow control nonsense.  I mean, this is just something quick I did -- I didn't sit down for hours trying to devise it. ;P

Thanks, Seravy. I'll just edit my post.
Re: Glowing Palette for Mugen 1.0
#6  June 13, 2012, 03:46:41 pm
  • ******
  • Limited time to use Infinite power !
    • France
    • network.mugenguild.com/cybaster/
This topic is much more useful than this one. Thanks. :D
Re: Glowing Palette for Mugen 1.0
#7  June 13, 2012, 03:59:32 pm
  • avatar
  • ******
    • Thailand
LMAO!

I was smoking some kind of retarded stick when I made that over complicated topic!