UPDATED 2/16/2017
This tutorial will instruct you how to control the defeated opponent throughout one or multiple Win Poses.
EXAMPLE VIDEO
Please read this tutorial carefully, because the conditions for this to work properly are very strict.
Required Steps: (ALL STEPS ARE EXPLAINED IN DETAIL BELOW)
- Add a variable in STATE -2 (OR State 5900 - round initialization) to determine whether the custom win pose will be executed.
- Adjust the triggers in State 180 (Where Win Poses are initiated from)
- Create a custom KO state, which must be Statedef 5150
- Create another custom state (or states), which will contain all the fun stuff you want the defeated opponent to do.
- Adjust ALL of your character's HitDefs
===========================================================
COMMENTS (READ THIS)
Before starting off, there are some things that you must understand.
Your character will always go into this Custom State 5150 when defeated!!!
Your character will NOT be affected by any of the custom code, as long as you follow the instructions carefully.
The custom code will only affect the defeated opponent.
Also, as will be explained in the very last step... you must include a few often completely unused parameters (which do not affect gameplay) in ALL of your character's HitDefs
fall.envshake.freq = TeamSide ;Optional... but recommended as another failproof
fall.envshake.ampl = ID ;REQUIRED
fall.envshake.phase = var(59) ;A VAR IS REQUIRED
By doing this, you can actually access this information from the Custom State that you send your opponent into, by using the "GetHitVar" trigger.
Here is an example from one of the controllers found in this tutorial:
[State 5150, CUSTOM] ;SEND OPPONENT TO CUSTOM WIN POSE
type = ChangeState
trigger1 = Roundstate = 4
trigger1 = gethitvar(fall.envshake.freq) != Teamside
trigger1 = gethitvar(fall.envshake.phase) = 1 ;value of var(59)
value = 5151 ;The state you want to send the opponent into
trigger1 = gethitvar(fall.envshake.freq) != Teamside
This will prevent the code from being triggered by your own character.
trigger1 = gethitvar(fall.envshake.phase) = 1
As mentioned above, "fall.envshake.phase" actually represents the value of your var(59), or whatever var you are going to use to select the Win Pose.
If you use the parameter "fall.envshake.ampl = ID" as mentioned above, you can then redirect trigger to your character from the opponent's custom state by using for example "PlayerID(gethitvar(fall.envshake.ampl)),Pos X" If your character has Player ID 57, then this would essentially translate to "PlayerID(57),Pos X"
If you don't understand, then just copy and paste all the code and it will work. K?
===========================================================
Step 1: Code for State -2 (or State 5900)
Whether this win pose will be executed or not MUST be determined BEFORE the round ends, unlike an ordinary Win Pose. In this tutorial, I am using var(59) to store the Win Pose selection.
Also required in State -2 is a TargetState controller that will send the opponent into the custom state when he is being KO'd
Therefore, add the following code into State -2 (or State 5900):
[State -2, Randomly Select Win Pose at Beginning of Each Round]
type = VarRandom
trigger1 = RoundState = 0 ;Win Pose is selected at the beginning of each round
v = 59 ;Dedicate a variable to assign the win pose selection to. In this example, I am using var(59)
range = 1,4 ;The range. Start with 1, followed by the total number of win poses you have. In this example there are a total of 4 win poses.
Add the following code into State -2:
[State -2, Send Dying Target to Custom State 5150 for Custom Win pose]
type = TargetState
triggerall = numtarget = 1 ;if you have ONE target (use custom winpose for simul mode at your own peril)
triggerall = target,life <= 0 ;if P2 is ready to die
triggerall = var(59) = 1 ;SPECIFY THE CUSTOM WIN POSE, OR MULTIPLE WIN POSES. In this example, the FIRST win pose will control the opponent. SO this will not trigger when var(59) = 2 or 3 or 4.
triggerall = TeamMode != Simul ;Not for TeamMode (use custom winpose for simul mode at your own peril)
trigger1 = target,StateNo = 5110 ;enemy is lying on ground, defeated
value = 5150
ignorehitpause = 1
Step 2: Adjustments to State 180
State 180 must be adjusted to take the new selection method into account. Please review the following code to see what must be done.
[Statedef 180] ;Win Pose is predetermined at round start.
type = S
[State 180, CUSTOM WIN POSE]
type = ChangeState
trigger1 = var(59) = 1 ;THE CUSTOM WIN POSE
value = 181
[State 180, NORMAL WIN POSE]
type = ChangeState
trigger1 = var(59) = 2 ;NORMAL WIN POSE
value = 182
[State 180, 3] ;Win Pose 3 ("Normal" Win Pose)
type = ChangeState
trigger1 = Var(59) = 3 ;NORMAL WIN POSE
value = 183
[State 180, 4] ;Win Pose 4 ("Normal" Win Pose)
type = ChangeState
trigger1 = Var(59) = 4 ;NORMAL WIN POSE
value = 184
Step 3: Create the Custom KO State 5150
The conditions for any round to end are:
1. The winning character must be in State 0.
2. The defeated opponent must be in State 5150.
THEREFORE, THE CUSTOM STATE MUST BE 5150, OTHERWISE THE ROUND WILL NEVER END!
With that in mind, go ahead and create this StateDef. It uses all of the default controllers found in common1.cns, but with a few custom controllers and modifications.
As with any State, this will override the State 5150 found in common1.cns.
;CUSTOM KO
[Statedef 5150]
type = L
movetype = H
physics = U
sprpriority = -3
ctrl = 0
[State 5150, DEFAULT] ;Normal anim
type = ChangeAnim
triggerall = Time = 0
triggerall = SelfAnimExist(5140)
trigger1 = (anim != [5111,5119]) && (anim != [5171,5179])
trigger2 = !SelfAnimExist(5140 + (anim % 10))
value = 5140
[State 5150, DEFAULT] ;Hit up type anim
type = ChangeAnim
trigger1 = Time = 0
trigger1 = (anim = [5111,5119]) || (anim = [5171,5179])
trigger1 = SelfAnimExist(5140 + (anim % 10))
value = 5140 + (anim % 10)
[State 5150, DEFAULT] ;Match over anim
type = ChangeAnim
persistent = 0
;trigger1 = Time = 0
trigger1 = MatchOver = 1
trigger1 = Anim = [5140,5149]
trigger1 = SelfAnimExist(anim+10)
value = anim+10
[State 5150, DEFAULT] ;Switch to 5110 if liedead anim does not exist
type = ChangeAnim
trigger1 = Time = 0
trigger1 = Anim != [5140,5159]
trigger1 = Anim != [5110,5119]
value = 5110
[State 5150, DEFAULT] ;Friction
type = VelMul
trigger1 = 1
x = 0.85
[State 5150, DEFAULT] ;Friction
type = VelSet
trigger1 = abs(Vel x) < Const(movement.down.friction.threshold)
persistent = 0
x = 0
[State 5150, DEFAULT]
type = NotHitBy
trigger1 = 1
value = SCA
time = 1
[State 5150, CUSTOM] ;SEND OPPONENT TO CUSTOM WIN POSE
type = ChangeState
triggerall = Roundstate = 4
trigger1 = PlayerIDExist(gethitvar(fall.envshake.ampl)) ;Triggers only if your character delivered the finishing blow
trigger1 = gethitvar(fall.envshake.freq) != Teamside ;Double-checks that this is not your own character!
trigger1 = gethitvar(fall.envshake.phase) = 1 ;This means var(59) = 1 (custom win pose was selected)
value = 5151 ;The state you want to send the opponent into
If you want to control the opponent for multiple Win Poses, just add another controller at the end, specifying another variable.
[State 5150, CUSTOM] ;SEND OPPONENT TO A DIFFERENT CUSTOM WIN POSE
type = ChangeState
triggerall = Roundstate = 4
trigger1 = PlayerIDExist(gethitvar(fall.envshake.ampl)) ;Triggers only if your character delivered the finishing blow
trigger1 = gethitvar(fall.envshake.freq) != Teamside ;Double-checks that this is not your own character!
trigger1 = gethitvar(fall.envshake.phase) = 2 ;This means var(59) = 2 (custom win pose #2 was selected)
value = 5152 ;The state you want to send the opponent into
Step 4: Create State(s) containing all the things you want P2 to do in your Win Pose(s)
You can now have the defeated opponent do whatever it is you want him or her to do during your character's Win Pose.
Step 5: Adjust ALL Your Character's HitDefs
Don't skip this Step, because this is the most important one
Add the following parameters to ALL of your character's HitDefs:
fall.envshake.freq = TeamSide ;Provide your character's current Teamside.
fall.envshake.ampl = ID ;Provide your character's PlayerID. Useful for redirecting triggers to your character, from the opponent's custom state!
fall.envshake.phase = var(59) ;Provides your characters pre-determined win pose. This parameter is required if you have multiple custom win poses.
ENJOY! HAVE FUN!