Jump to content

Lasombra's Attached Char Tutorial


Recommended Posts

Interactive Stages in IKEMEN Go: AttachedChar Tutorial

                  tutorial v 1.0
                  by Lasombra Demon
                     for the IKEMEÑ Discord

For many, many years we have wanted to make stages with interactive objects
in MUGEN. Whether it's breaking Ken's barrels in SF2, the falling floor on
Wolverine's stage in Marvel Super Heroes, or facing the famous Deathmatch stages
of World Heroes 1 and 2, doing fatal blows on stages like in Mortal Kombat 2
(and Eternal Champions)...

Not so for Bonus Stages, since those are easily doable since the MUGEN DOS days
and it is not necessary to use this use this feature; you just program a normal
character to be the Bonus stage.

Why is it interactive stages have not been common and widespread, then?

=0.1: A history of interactive stages in MUGEN
=0.2: Remembering some elements of the stages
=1.0: What is AttachedChar (AC)?
=1.1: How to put a AC in a stage?
=1.2: Why do you use a ".CHR" extension?
=2.0: What should a AC have?
=2.1: The two types of interactive stages
=3.0: The only aesthetic interactive stage
=3.1: Putting deltas to character objects, the trick of PotS and Ricepigeon
=3.2: Imitating Sin.Y
=3.3: ModifyBGCtrl, the real interactivity with scenery
=3.4: The real challenge, layers and sprpriorities
=3.5: Using explods when you have to
=4.0: The fully interactive scenery
5.0: Using a single AC for many stages =5.
=X: What's to come
=6.0: Examples and references
=7.0: Special thanks

=0.1: A history of interactive stages in MUGEN
The short answer is because the engine at the time was clearly not made for that.
The long answer is that, until now, it was necessary to solve the lack of truly interactive
for stages in MUGEN by implementing code, graphics, animations and sounds in the characters,
which then had to detect which stage they were in, to then activate all those elements.
In the older times (WinMugen just released, back in 2004), p1startz and p2startz were used for
the characters to detect which stage they were in; the zoffset method. Electr0, Syn and others
did a lot of this. From MUGEN 1.0 onwards, stages could be detected by stagename and
authorname, specific triggers for this.
But this implied copying many lines of code, drawings, sounds and animations into each of the characters,
a solution far from the kind of global implementation that should be sought in something like
the MUGEN engine. Many times crucial variables or states were replaced, functionality was broken, and it
it was honestly a nuisance to modify all that if you had a significant amount of stages and characters.
On the other hand, using the common.cns, in the words of Syn (one of the authors of the most interesting
interactive stages), was not a good idea because the characters often overwrite those and use their own code.
Then IKEMEN Go and its AttachedChar enters the scene.

=0.2: Remembering some stage elements
The excellent basic tutorial for stage creation made by Cybaster made a few years ago is worth a read:
We are going to assume that the contents of that tutorial and the basic one by Elecbyte are already
familiar to the reader; http://www.elecbyte.com/mugendocs/bgs.html.

=1.0: What is AttachedChar (AC)?
"AttachedChar" is a functionality of IKEMEN Go to be able to generate a programmable entity neutral to the
fight between Player 1 and Player 2 teams. For identification purposes, if we are going to consider each team has
4 Players (Players 1 and Player 2), then we have 4 Players in each. Players 1, 3, 5 and 7 are one, and
2, 4, 6, and 8 are the other; then the AC will be player number 9. It can kill the other characters but cannot win
the round, nor continue or have a game over, nor be selected by anyone. It is only summoned when playing in the
stage where it is referenced. Nor does it appear in the "select.def". They are simply integrated into a stage.
ACs are, on the other hand, like any other character. For their creation there are plenty of
tutorials, and the basic steps to create those exceed the scope of this tutorial. Suffice it to know that
ACs have sprites, animations, sounds, code and definitions, like any other character. I don't mention palettes
because there can only be one AttachedChar per combat, therefore selecting varied palettes doesn't even make sense.

=1.1: How to put an AC in a stage?
If we want to add the AC to the game, it must be integrated into any stage.
To do this, we will write in the [Info] section of any stage a line with the parameter.
"AttachedChar=", and refer to the ".DEF" of our AC.
Example (without quotes):  "AttachedChar = KFMStageInteractive.DEF"

=1.2: Why do you use a ".CHR" extension?
When I noticed that the definition files of the interactive objects are .DEF, an identical extension to those of
the stages, I figured it would be a problem to differentiate one from the other. I decided then to use the extension
".CHR" for the ACs, and the file is still text. On the other hand, Winane's "Small" creation taught us that there is
no need to have a thousand files for each character. Small only had a .DEF file containing all the contents of the
CMD, the CNS, the ST, the DEF, and the AIR. The key is in the order; first the DEF, then the CMD, then the ST and CNS,
then the animations (the only detail is that if we work in ZSS this must go in a separate file, it cannot be mixed
with CNS in the same file).
This allows for two things: to compress almost all the AC to a single file, on the one hand, and to distinguish that
file from the rest.

=2.0: What should be in a AC?
The first thing that one should notice with the AC is that it does not use the character itself, but rather
helpers of the character itself. The character itself in fact is better not used, so we use the following
commands to guarantee it does not interfere with combat, in the -4 of the code.
-Assertspecial with invisible, noshadow, and noautoturn

Other SCTRLs that are highly useful:
-AttackDist = 0 so that characters in the fight don't try to block the AC,
-Screenbound to get out of camera, and the MoveCamera parameter according to the desired effect
(the best way to manipulate the camera is still to create a giant helper and move it),
-NotHitBy with SCA just in case,
-PlayerPush with 0 just in case.

When creating the Helper, it is important to use two new parameters of IKEMEN Go,
which are Immortal = 1 and Preserve = 1. The first one so that they do not kill our instrument of
interaction with the game world, the second so that when the intro is skipped it does not disappear,
and it remains from round to round.

=2.1: The two types of interactive stages
While this is a rather arbitrary distinction, it makes sense to start by thinking of at least two common types of
interactive stages; those that are interactive in a purely aesthetic sense (Darkstalkers, Street Fighter 2, King
of Fighters, Moral Kombat 2), and those that have elements that do affect the combat (items in Samurai Shodown 1
and 2, ring outs, World Heroes in Deathmatch mode). This type of distinction is crucial when designing and deciding
on aspects of the creation to be made.

=3.0: The purely aesthetic interactive stage
Let's think of a purely aesthetic interaction. The girls in the Boxer stage of Street Fighter 2 take off their hats
when the round is over. As a Trigger we will surely use RoundState = 3, so that at the end of the round we define
the change of animation of the girls.

This would involve using one of three strategies:

-Make the girls as Helpers.
-Make the girls as Explods.
-Make the girls as an element of the stage itself.

Creating them as Helpers has the advantage that it allows their absolute manipulation, because we have great control
of the helpers.
Creating them as Explods has the advantage that it consumes less resources, but their manipulation is
harder and more complex. But IKEMEN Go allows to change the animation of the Explods by modifyexplod, so we can at least
try. We should also use IKEMEN Go's unique IKEMEN Go exclusive parameter called "under", so that they are behind the
characters and life bars.
Creating them as objects on the stage has the advantage of allowing us to interact with "layers" of the stage in another way.

For the first two, we will need to use a complex trick to "simulate" the delta in a

=3.1: Putting deltas to character objects, the trick of PotS and Ricepigeon
One of the points that one observes when creating a helper or an explod is that it follows the same speed of movement
as the characters, i.e., it gives the impression of being in the same plane.
The elements of the scenery have an equivalent to that, which is called Delta.
It is enough to remember that a delta of 1 corresponds to the plane of the characters, and a delta of 0 is a
totally immobile object. In other words: the higher the delta, the "closer" the object appears to be.
But objects created by characters do not have this parameter, so we will have to craft an alternative.
The best thing to do is to create a helper with ScreenBound = 0, and constantly refer to the X Position of that
helper with the following formula(without quotes):
"x = ceil(helper(No Of Helper),pos x * 0.75); to simulate a delta = 0.75, 1."
This allows you to "follow" the extra helper (which functions as a reference point), without getting lost.
If you are going to do it with explods, it is necessary to remember to use "bindtime = -2" because the idea is to
follow the helper.

=3.2: Imitating Sin.Y
Another point that is a challenge is to imitate the speed of the elements of the stages.
If we are going to do something like this, it is important that the element has very high SuperMoveTime
and PauseMoveTime, in order to maintain synchrony with the elements of the background in case there is
a pause that allows movement of the stage (pause with pausebg = 0). The trick to imitate the Sin parameter of the
stages with a character, is to use the following formula.
Suppose the formula is "sin.Y = -10, 220"; then for the PosSet of the character you should use:
"y = - 10 * Sin ((2 * (pi) /220.0) * time)".
Special thanks to Whiplash for the mathematical help.

=3.3: ModifyBGCtrl, true interactivity with stages
So far we have used only Triggers and SCTRLs assembled for "normal" characters, and made them do stage
functionalities. But IKEMEN Go implemented a special SCTRL for the AttachedChars: ModifyBgCtrl.
It allows, by using a parameter called SCTRLID, to modify the values of a BGCtrl.
You probably remember clearly that BGCtrls allow you to do almost anything with the elements of a stage...
The list of what they can do is visible, enable, velset, veladd, posset, posadd, anim, sinx and siny.
The trick I use is to start by setting the BgCTRL to a null value, and change it via the SCTRL when I want.

I attach an example where I hide element 3 from the stage after 2 seconds.

This requires two parts, one in the stage itself (the element to hide has an ID of 3),
[BGCtrl 3]
type = Visible
time = 1,99999,-1
value = 1
sctrlid = 3

And one in the AC code
[State Hide]
trigger1 = Time = 120
supermovetime = 99999
pausemovetime = 99999
type = ModifyBGCtrl
SctrlID = 3
ID = 3
value = 0

And why complicate things like that?

=3.4: The real challenge, layers and sprpriorities
As any stage dev knows, the order in which the elements of a stage are drawn is static, and you start with the
objects furthest back and finish the file with those on top.
This kind of thing is unchangeable in IKEMEN Go... Unless we assemble duplicate elements and make them visible
or invisible at will. What is unchangeable for now, is that you can't intersperse stage elements (that are not
in a layer in front of the characters), with character objects. That is, explods and helpers. This demands extra
planning and care when developing each interactive stage.

=3.5: Using explods when you must
On the other hand, someone reading this tutorial may think I am discarding explods. Nothing could be further
from the truth. In my experience and as a piece of advice, it is almost always better to test an effect using an explod
and then start using other alternatives (especially if the effect doesn't need to be between the stage layers). Another
crucial example is when you make fatalities or animations that include the characters in the fight; in that case it is
practically mandatory to use explods because manipulating the character itself is more complex. You can simply use an
Explod and RedirectID to redirect the effect of the Explod to any player.

=4.0: The full interactive stage
This applies the resources used in the aesthetic stage.... But maximizes them. With what? With whatever
is needed. The first thing is that this will mean starting to use helpers with active collision boxes,
with frames, with LifeAdd and PowerAdd effects... And HitDefs.
Only here you can really start to glimpse the potential of IKEMEN Go stages even as a narrative tool.^

=5.0: Use a single AC for many stages
This trick is useful when working on a very large project ^^ It is best to simply create a single file with all the effects,
another one with all the sounds, and just one for code; and in the code file use a trigger that is
StageVar(info.name) to decide which effects to do. Then simply add the same AC to all the stages, and the AC itself
will detect which stage we are in.

=X: What's to come
Talking with IKEMEN Go devs over the past couple of years has filled me with excitement about the future of the engine.
Specifically, about stages and their interactivity, there's been talk for some time now about several improvements.
One of them could be something like "ModifyStageConst", allowing to "widen" the stages, for example.
This would make it possible to make MvC1's Honda's bathroom stage with real destructible walls, or
the Power Instinct and Rage of the Dragons stages where you break barriers before they expand.
The other big addition that has been mentioned is the ability to do platforming, something that would add enormous
possibilities to mimic Smash Bros type levels with more ease.

=6.0: Examples and references
^I made several stages of this type, from those of World Heroes in Deathmatch to Hikyaku from Samurai
Shodown, which throws items and bombs on the stage. The biggest stage so far, with several modes and changes
that was made, to my knowledge, is SFvsMK.

^^As I did with all the stages of the Double Dragon saga of Neo Geo.

=7.0: Special thanks
K4thos and Gacel for carrying the torch left to them by Suehiro.
Kamekaze and the Discord People of IKEMEN
Cyanide, 2OS, Cybaster, Whiplash and the Guild's Discord People
XGargoyle and the IKEMEÑ Discord People

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Create New...