The Mugen Fighters Guild

Help => M.U.G.E.N Development Help => Code Library => Topic started by: The Railgunner on December 01, 2008, 11:52:47 am

Title: Transformations in Mugen, DBZ style
Post by: The Railgunner on December 01, 2008, 11:52:47 am
This is relatively easy to achieve, it just takes patience (I'll be skipping everything in the code that's not relevant to the transformation).

First add this code to all of your states:


[State 0]
anim=ifelse(var(1)=1,10000,0

where var(1) is the transformation variable. Now, for more than one transformation (using three as an example):


[State 0]
anim=ifelse(var(1)=3,30000,ifelse(var(1)=2,20000,ifelse(var(1)=1,10000,0)

meaning that if var(1) equals 3 (i.e., the third transformation), than state 0's anim is 30000, if it's 2, 20000, if 1, 10000, and if in base form (no transformation), 0.

Now, for attack values, simply move the ifelse(s) from the first state and put them in the hitdef, adjusting the values accordingly.

Light Punch:


[State 200]
damage=ifelse(var(1)=3,45,ifelse(var(1)=2,35,ifelse(var(1)=1,25,20)

Now, the actual transformation. There are two logical ways of doing this. Here is the first, which is command-based:


[State 4000];Transformation
anim=ifelse(var(1)=2,24000,ifelse(var(1)=1,14000,4000);The characters transformations aren't going to look identical, are they?

[State 4000];Varset
type=varset
trigger1=command="transform"
v=1
value=ifelse(var(1)=2,3,ifelse(var(1)=1,2,1)

[State 4000];Changestate
type=changestate
trigger1=animelem=5;it doesn't have to be five, that's just a placeholder
value=0;back to standing state

The other method is power-based, where you replace "command="transform"" with this:

power=>###;### is the number, if that wasn't already evident

The transformation can be reversed like so:


[State 4001];Revert
anim=ifelse(var(1)=3,34001,ifelse(var(2)=1,24001,14001);The characters transformations aren't going to look identical, are they?

[State 4001];Varset
type=varset
trigger1=command="untransform"
v=1
value=ifelse(var(1)=3,2,ifelse(var(1)=2,1,0)

[State 4001];Changestate
type=changestate
trigger1=animelem=5;it doesn't have to be five, that's just a placeholder
value=0;back to standing state

And the power trigger:

power<=###

And that's it, really. You can have an indefinite amount of transformations with this method. There's a much harder way of doing this, but I'll post that another day.
Title: Re: Transformations in Mugen, DBZ style
Post by: EVILNEON on December 02, 2008, 04:03:51 am
Awesome Vegeta , thanks a million ! were do you put in the sprite #'s in ? Im trying to learn, its just really confusing at this point  ??? .
Title: Re: Transformations in Mugen, DBZ style
Post by: The Railgunner on December 03, 2008, 01:45:00 am
You have to make the animation in the AIR file first. When you do that, put the animation number in the place of the 4000 that I used in this code. You should look at another Mugen character's AIR file to see how an animation is made in Mugen.

The first number is the sprite group number. The second is the sprite number within the group. The third and fourth numbers are x and y offset, which is how many pixels the sprite is shifted from it's original position in the SFF. The last number is the amount of time (in ticks, 60 to a second) the animation frame takes.
Title: Re: Transformations in Mugen, DBZ style
Post by: Xarian on February 12, 2009, 05:36:47 pm
ok im kinda confused...if i want my char to have 3 transes i need to put [State 0]
anim=ifelse(var(1)=3,30000
but... u said to add that code to ALL states...when i opened chars data file
where states are i got confused...so where do i put [State 0]
anim=ifelse(var(1)=3,30000 exactly?:S ??? any explaination is appreciated
Title: Re: Transformations in Mugen, DBZ style
Post by: Anjel on February 12, 2009, 08:54:32 pm
There is a easier way.
Set a variable to like 10000 (your transformation anims needs to be 10000 + then).
Then set you anim to.
Anim = 0+var(yourvar)
Title: Re: Transformations in Mugen, DBZ style
Post by: XGargoyle on February 13, 2009, 09:26:58 pm
in any case, you will have issues with custom states
Title: Re: Transformations in Mugen, DBZ style
Post by: Xarian on February 14, 2009, 01:24:27 am
so basicly i gotta add to CNS files some custom states?
such as for transformation...but if i do how i put commands then?
tnx in advance guys im still noob at this :)
Title: Re: Transformations in Mugen, DBZ style
Post by: DavidGee on March 27, 2009, 09:57:25 pm
From what I can tell, characters with transformations are common. But, there doesn't seem to be an unofficial transformation standard. Although there are characters that transform, there are not characters that support these transformations in custom states (namely, throws), besides probably the particular transformation character itself and perhaps other characters by the same author. Please correct me if I'm wrong.

So what we do have so far is the indices that characters should use for required sprites and animations of their alternate forms. Simply increase the index by 10,000 for each form.


Assuming all transformation characters follow this numbering scheme, there is only one thing that prevents us from making our character use the correct sprites when throwing a transformed character. We can't tell what form the character is in!

We need a way to determine (A) that the opponent has multiple forms, and (B) what form they are currently in.

What I want to know is... has anybody done this? Is there a reliable method that has been used by multiple authors? Is there a single author who has released multiple transformation characters using a reliable method? If a good method already exists, is already implemented in more than 1 existing characters, then it should be taken and made an unofficial standard. Otherwise, a new standard should be documented and implemented in a new character, and then (hopefully) adopted in future character releases.
Title: Re: Transformations in Mugen, DBZ style
Post by: Bastard Mami on March 27, 2009, 10:20:06 pm
the closer we got to that is gm's gill.

While I am also doing transformations using a very similar method I gave uup on comunitty standars and am making it for a closed game.
Title: Re: Transformations in Mugen, DBZ style
Post by: DavidGee on March 28, 2009, 12:04:07 am
I downloaded GM's SF3 characters, and they just use authorname="GM" and name="Gill" as triggers, so there's no standard detection method there. And Gill's form simply depends on the direction he's facing. The only thing that indicates the character's current form is the facing trigger.

So far, I know of no implemented method that can be standardized to use in any character. It's a rather simple matter though. All you need is a variable that says "I have multiple forms" and another variable that says "I am in this form right now." It could be reduced to 1 variable if you use something else (like action numbers) to indicate that multiple forms exist.
Title: Re: Transformations in Mugen, DBZ style
Post by: XGargoyle on March 28, 2009, 01:39:36 pm
Again, the problem is that some characters will have just one form (Goku -> SSJ Goku) whereas others will have more than 1 (MVC Ryu -> MVC Ken or MVC Akuma)

Therefore, even if all characters use the same variable, you still don't know how many transformations your enemy has. Are you going to include thousands of custom states just for the sake of compatibility with that character who happens to have 13 transformations (Shang Tsung, for example)
Title: Re: Transformations in Mugen, DBZ style
Post by: DavidGee on March 28, 2009, 02:56:33 pm
Well you wouldn't need to duplicate states; only animations. And the only modification you'd need to make to them is prepending the sprite numbers with 10, 20, 30... And then you put a variable in the value of changeanim2, so not much work would be involved in making any given character compliant.

And I don't see a reason to support more than 5 forms. Shang Tsung isn't something I think is worth mimicking in Mugen. But I am thinking of characters that drop weapons or armor (Vega), characters with multiple costumes (KOF), and characters that power up and change their appearance (DBZ). Apart from something like Shang Tsung, is there a character that would need more than 5 forms? Deciding on a specific number would be nice.
Title: Re: Transformations in Mugen, DBZ style
Post by: c001357 on March 28, 2009, 04:06:07 pm
Twelve.
Title: Re: Transformations in Mugen, DBZ style
Post by: USL-Intelligence on May 10, 2009, 11:14:07 am
how about changing the get-hit animations (5000-whatever) using variables and "ifelse" trigger?

Anyway, I can use this for my edit.
Title: Re: Transformations in Mugen, DBZ style
Post by: _Josue_ on June 11, 2009, 05:10:22 am
I don't know whether what I'm about to do is right or wrong,
 however I think there's a genius among us that already solved this trouble:
The maker of reploids (http://mugenguild.com/forumx/index.php?action=profile;user=GCNMario)
Yes, N-mario, and I say this because Vent&Aile have up to 7 transformations and can keep track of the correct animation even in custom states. I know N-mario already said Vent&Aile were unfinished crap, (and he abandoned them because of his rockman game I guess... (http://mugenguild.com/forumx/index.php?topic=89638.0))
However the three models that are working (X,Zx and Ox) can be normally thrown without loosing the corresponding anim i.e. you throw them as model Ox and they remain as model Ox while thrown.
Yet, even being "unfinished crap" (some sprites are not correct)
the problem is that I can't seem to find how the heck he did it.
I wanted to try to work on them so I asked him "where's the trick",
 and he only answered with evasive. ???
Title: Re: Transformations in Mugen, DBZ style
Post by: LivingVoodooDoll on June 11, 2009, 07:51:03 pm
As far as i know FIREBOY the MK mugen creator did a shang tsung that can fully transform.maybe u should ask him.Also there is a twelve done by "rei" he can transform sakura and ken.Folder contains all 3 chars' def in it.but it turns to twelve whenever it is thrown.Anyway its not looking so absurd in those chars. but probably suck at DBZ chars.
Title: Re: Transformations in Mugen, DBZ style
Post by: XGargoyle on June 11, 2009, 08:46:34 pm
@Josue: What GCNMario did is a full game, where you know beforehand the sprites that each character will require during a custom state. This is nothing out of the extraordinary, and any developer with a basic experience can do it.

What is impossible, is doing that on a standard and open mugen environment.
Title: Re: Transformations in Mugen, DBZ style
Post by: _Josue_ on June 12, 2009, 06:49:00 am
@Josue: What GCNMario did is a full game, where you know beforehand the sprites that each character will require during a custom state. This is nothing out of the extraordinary, and any developer with a basic experience can do it.

What is impossible, is doing that on a standard and open mugen environment.

Wait a minute. I don't get it, why do you say "full game", Vent&Aile are just chars, they can be thrown in any mugen by any other char that means they can be put into any custom state you
desire no matter who is the opponent or what kind of throw made!
Or I just misunderstood the whole thing ???
Title: Re: Transformations in Mugen, DBZ style
Post by: XsLaught on June 12, 2009, 08:51:43 pm
I believe I know how this can work with transformations. I believe it was discussed long ago.

Your required get hit sprites must all have all forms in them but with their offset way separate. Like say 1000 pixels separate in the y-axis. This way when you are in a custom state, the sprites for both forms are shown. However what will appear on screen is the current form and the other form will be 1000 pixels or so above or below depending on how you set it.

Use the offset controller to trigger when you are in a custom gethit state. This would have to be put in statedef -2. Apply the offset for y so that it will be offset by 1000 in form 2 when in a custom state to show form 2's sprites on screen with form 1's sprite 1000 pixels above/below depending on how you set it.

I haven't tested it out but it should work.

Hope someone understands it.
Title: Re: Transformations in Mugen, DBZ style
Post by: Byakko on June 12, 2009, 11:56:26 pm
Won't work if the enemy uses a targetbind or a constant posset in the custom state.
Title: Re: Transformations in Mugen, DBZ style
Post by: XsLaught on June 13, 2009, 12:01:53 am
Won't work if the enemy uses a targetbind or a constant posset in the custom state.

I'm not talking about the position offset but the display offset. PosSet and TargetBind would affect the position but not the display. The Offset sctrl would have to be applied every tick in the custom state.
Title: Re: Transformations in Mugen, DBZ style
Post by: Byakko on June 13, 2009, 01:31:57 am
... type = Offset affects the display and not the axis ? Never tested it...
Title: Re: Transformations in Mugen, DBZ style
Post by: _Josue_ on June 13, 2009, 02:16:28 am
I believe I know how this can work with transformations. I believe it was discussed long ago.

Your required get hit sprites must all have all forms in them but with their offset way separate. Like say 1000 pixels separate in the y-axis. This way when you are in a custom state, the sprites for both forms are shown. However what will appear on screen is the current form and the other form will be 1000 pixels or so above or below depending on how you set it.

Use the offset controller to trigger when you are in a custom get hit state. This would have to be put in statedef -2. Apply the offset for y so that it will be offset by 1000 in form 2 when in a custom state to show form 2's sprites on screen with form 1's sprite 1000 pixels above/below depending on how you set it.

I haven't tested it out but it should work.

Hope someone understands it.

Understood, seems to be a good possibility,

M.U.G.E.N 2002.04.14 Manual said:

Changes the player's display offset. The player is drawn shifted from his axis by this amount.
 (http://mugenguild.com/docs/sctrls.html#Offset)

However now the question is :
Trigger1=???
How do you know you're in a custom state?
maybe excluding ALL your own states?



[State -3, Offset]
type = Offset
x = 1000*var(Trans_Control)
ignorehitpause = 1
Trigger1= stateno != [0,20]
Trigger1= stateno != [130,132]
Trigger1= stateno != [5000,5900]
;and so on

and what if the stateno # is the same as in your foe's custom state?
is there any easier way to detect custom states?
I still wonder what the heck N-mario did to make Vent&Aile work!
Title: Re: Transformations in Mugen, DBZ style
Post by: XsLaught on June 13, 2009, 03:33:15 am
I use a simple variable to check if I am in a custom state using the knowledge statedef -3 is not checked when you are in a custom state.

In statedef -2:


[State -2, SelfState Check]
type = VarAdd
trigger1 = 1
var(22) = 1

In statedef -3:


[State -3, SelfState Check]
type = VarSet
trigger1 = 1
var(22) = 0

[State -3, SelfAnim Check]
type = VarSet
trigger1 = 1
var(23) = Anim


Any code that should execute for when you are in a custom state should be above that first state controller with trigger1 or triggerall = Var(22).

ex:


[State -2, OffSet]
type = OffSet
trigger1 = Var(22)
trigger1 = Var(50) = 2 ; Form 2
trigger1 = Anim != Var(23) ; You probably need this trigger to see if your anim changed from when you were in your own states.
trigger1 = Anim != [5000, 5510] ; In case you are put into a custom state and use your own action number
trigger1 = Anim != [0, 195] ; In case you are put into a custom state and use your own action number
x = 0
y = 1000 + (ScreenPos Y < 0) * (ScreenPos Y) + (ScreenPos Y >= 240) * (ScreenPos Y - 240) : I think this is the correct math.
; I may be off on the math

[State -2, SelfState Check]
type = VarAdd
trigger1 = 1
var(22) = 1

The offset sctrl needs to be adjusted for incase the player is moved off the screen. Use the ScreenPos Y trigger for it.

This assume the opponent does not use a custom action number between 0, 195 and 5000, 5510 for your gethit sprites. That's the problem with this. To work around that would be a bit more complicated as you need to detect if you are using your own action number or one from your opponent's .air file. I guess one way (not the best way) to get around this is to make sure every sprite you use for action numbers 0-195 and 5000-5510 has both forms in them. Then you can remove those bottom 2 triggers. Or you just make adjustments for each of those action numbers by using ChangeAnim, SelfAnimExist, etc. I can't think of an easy way to get around this at the moment. Like if the opponent puts you in a custom state then use your own dizzy animation.

EDIT:
AnimExist
"The result of this trigger is undefined if the player has been placed in a custom state by a successful hit"
I believe this trigger can be used to detect if you are using an anim from your .air file or your opponent's .air file.
Title: Re: Transformations in Mugen, DBZ style
Post by: MirageAtoli on June 13, 2009, 07:24:18 am
Does the CLSNs move when the "player is drawn shifted from his axis by this amount"? Do the CLSNs stay in place or should they be drawn around all of the forms in the gethit sprites?
Title: Re: Transformations in Mugen, DBZ style
Post by: Cyanide on June 13, 2009, 07:33:04 am
Unless you do all of them, it breaks if using something like flowagirls flash battle code, which looks for your basic attacks and plays them. Also, there is still the chance that through some sort of fluke they posset you by 1000 in some direction and your other sprite shows, and AFTER all that, there's still the fact that the sff is going to be about 20 times bigger than it would have been if you'd just left it as it was.
Title: Re: Transformations in Mugen, DBZ style
Post by: _Josue_ on June 13, 2009, 08:25:54 am
Unless you do all of them, it breaks if using something like flowagirls flash battle code, which looks for your basic attacks and plays them. Also, there is still the chance that through some sort of fluke they posset you by 1000 in some direction and your other sprite shows, and AFTER all that, there's still the fact that the sff is going to be about 20 times bigger than it would have been if you'd just left it as it was.

Besides of those issues XsLaught's method seems to work. if the offset is 10000 instead of 1000
bugs will be less likely to happen.
I think that if you're going to use this method to have transformations, you must still "do all of them".
However I still wonder what N-Mario did to Vent&Aile so they can be thrown by any char on any mugen.

[...]
I wanted to try to work on them so I asked him "where's the trick",
 and he only answered with evasive. ???
someone said "full game" but I don't get why.
Title: Re: Transformations in Mugen, DBZ style
Post by: XsLaught on June 13, 2009, 09:59:38 am
An assertspecial of flag invisible with triggers of ScreenPos Y < 0 or ScreenPos Y > 240 will solve the other sprite appearing on screen accidently. Numbers can change to fit the character.
As for the file size, yeah that can't be avoided. 1000 difference is a bit big. It could probably be reduced a bit to optimized the SFF file.
For using basic attack anims, that is a tough issue to solve. You could use

[State -2, ChangeAnim]
type = ChangeAnim
trigger1 = Anim < 9999
trigger1 = Var(50) = 2; 2nd form
trigger1 = Var(22) && Anim != Var(23) ; In custom state and anim was changed from when you were in your own states
trigger1 = SelfAnimExist(Anim + 10000)
value = Anim + 10000 ; Can adjust

Where form 2's action numbers are in the 10000s. This only works for if the opponent uses ChangeAnim in the custom state instead of ChangeAnim2

However, suppose the code in the other player does require detecting p2's anim. You do not want to interfere it. You could make yourself invisible when in a custom state and not change the anim allowing P2 to detect everything as if nothing happened. Use a helper to appear over yourself giving the illusion it is P1. Have it be binded to P1 with the same anim at start then have it use:
[State xx, ChangeAnim]
type = ChangeAnim
trigger1 = Anim < 9999
trigger1 = SelfAnimExist(Anim + 10000)
value = Anim + 10000 ; Can adjust

Again this only works if the opponent uses ChangeAnim instead of ChangeAnim2.

You cannot detect if you are using an anim from your opponent's .air file or your own .air file. Meaning you cannot tell if ChangeAnim or ChangeAnim2 was used in the custom state.

So suppose the opponent puts you in your own action number 5300 using ChangeAnim. You could just ChangeAnim to 15300 within state -2 to show form 2's anim "5300". However, if the opponent puts you into their own action number of say 850 using ChangeAnim2. You would have to apply the Offset method to show form 2's sprite on screen. You won't know when to use which.

The best way I can think of of detecting if ChangeAnim or ChangeAnim2 was used would be to use SelfAnimExist(Anim). This wouldn't work if you have the same action number in your air file as the one your opponent is using to put you into a Custom State. You could create a helper with that same action number and see if the AnimTime matches to check if it is the same anim but it won't always work.

As for Clsn boxes. They stay with the position not the display.
Title: Re: Transformations in Mugen, DBZ style
Post by: _Josue_ on June 13, 2009, 07:11:25 pm
[...]
The best way I can think of of detecting if ChangeAnim or ChangeAnim2 was used would be to use SelfAnimExist(Anim). This wouldn't work if you have the same action number in your air file as the one your opponent is using to put you into a Custom State. You could create a helper with that same action number and see if the AnimTime matches to check if it is the same anim but it won't always work.

As for Clsn boxes. They stay with the position not the display.

well, after all this, we can conclude that:
1.-When our char is in a custom state we can detect wheter the animation is within our AIR file or not
    (maybe not accurately though?)

2.-if it's within our AIR we use

trigger1 = SelfAnimExist(Anim + 10000)
value = Anim + 10000*Var(Transformation_numer) ; Can adjust

Seems like this is what Aile&Vent uses, however it doesnt explain why it works in custom states.

3.-If it's not we use the offset trick.

[State -2, OffSet]
type = OffSet
y = 1000*Var(50)
trigger1 = Var(22)
;[...]


therefore all sprites that are normally used to create custom state animations will have a 1000 offset
all other sprites will go normally.
With this almost all problems seem solved, however I still wonder if there's anything else that can make this fail.


I also had an Idea but...
Spoiler, click to toggle visibilty
I'm not saying this is practical, but if it had been standard when elecbyte created MUGEN
most of this problem wouldn't exist.
Title: Re: Transformations in Mugen, DBZ style
Post by: The Railgunner on July 11, 2009, 02:06:33 am
in any case, you will have issues with custom states

the closer we got to that is gm's gill.

While I am also doing transformations using a very similar method I gave uup on comunitty standars and am making it for a closed game.

I have a solution to the custom states problem (in another topic).
Title: Re: Transformations in Mugen, DBZ style
Post by: Shmoodle on October 15, 2014, 03:35:01 am
So then could i use this code to make Goku Z2 transform into Super Saiyan Goku Z2?
Title: Re: Transformations in Mugen, DBZ style
Post by: XGargoyle on October 15, 2014, 08:50:58 am
I have a solution to the custom states problem (in another topic).

At least have the courtesy to provide a link to such topic of yours ¬_¬
Title: Re: Transformations in Mugen, DBZ style
Post by: AlexSin on October 16, 2014, 11:56:42 pm
Five years necrobump!
So then could i use this code to make Goku Z2 transform into Super Saiyan Goku Z2?
in any case, you will have issues with custom states

At least have the courtesy to provide a link to such topic of yours ¬_¬
Well, he probably meant the offset method.
But he hasn't been active for a long time, so I wouldn't expect an answer.
Title: Re: Transformations in Mugen, DBZ style
Post by: XGargoyle on October 17, 2014, 08:49:26 am
Well, I didn't notice the necrobump and all I saw was Vegeta 20XX's comment about his method and Shmoodle's silly question :P