This is the code that makes the Helper (Bag) appear if the intro is skipped. It is located in Statedef -2 of the characters main Constants.cns file. Making it a part of Statedef -2 makes it always active.
;Bag - Skipped Intro
[State -2, Skipped Intro Bag]
type = Helper
triggerall = RoundState >= 0 ;Prevents the Bag from appearing unless the Intro is skipped.
triggerall = !NumHelper(1912) ;Prevents Multiples from appearing.
trigger1 = Time
name = "Skipped Intro Bag"
ID = 1912 ;Making this the same number as the !NumHelper above is crucial. If the numbers where different, multiples of the helper would appear.
stateno = ifelse(RoundNo = 1,1913,var(13)) ;If this is the first round load helper state 1913, else load state # indicated by var(13).
pos = 58,-7
postype = p1 ;p1,p2,front,back,left,right
facing = 1
keyctrl = 0
ownpal = 1
size.shadowoffset = -6
supermovetime = -1
pausemovetime = -1
ignorehitpause = 1
persistent = 0
The Helper code itself; (In my case, located in a Helpers.st file for organization purposes. I have skipped ahead of the beginning few States as those are not important to what I am explaining.)
This is where the magic happens. The ParentVarSet codes set Variable 13 to the same number of the state that the helper is currently in. This is done so the helper loads correctly at the start of each round, (If the helper was left untouched it will remain standing up the next round, but if it was hit, it will be laying down.), thanks to the Helper Caller using var(13) for its state number after the first round.
The ParentVarSet for var(14) is used to remember if the Helper was knocked over to the left. If it was, then var(14) is set to 1. Then the second "Turn" State checks var(14) after the first round and if it is 1 or more it turns the helper to the left, if not, then it leaves the Helper turned to the Right.
The ChangeAnim State keeps the Helper in the correct frame of animation after the first round. If it was not there, the bag would automatically fall over at the start of each round.
[State 1914, ParentVarSet]
type = ParentVarSet
triggerall = RoundsExisted >= 0
trigger1 = 1
var(13) = 1914
ignorehitpause = 1
persistent = 0
;---------------------------------------------------------
;Can only be hit by Crouching Normal Attacks.
[State 1914, HitBy]
type = HitBy
trigger1 = 1
value = C,NA
time = -1
ignorehitpause = 1
persistent = 0
;This is necessary for the Helper to go to the correct state after being hit. If this was not here, the Helper would turn into a copy of the character ;because the hit would send the Helper to the characters get hit state.
[State 1914, HitOverride]
type = HitOverride
trigger1 = Time
attr = SCA,NA,SA,HA,NP,SP,HP,NT,ST,HT
slot = 1
stateno = 1915 ;Change to "Bag - Knocked Over" State below.
time = 1
forceair = 0
ignorehitpause = 1
persistent = 1
;---------------------------------------------------------------------------------------------------------------
; Helper - Knocked Over.
[Statedef 1915]
type = S ;S-tanding, C-rouching, A-ir, L-ay Down
Movetype = I ;A-ttack, I-dle, H-urt, U-nchanged
Physics = S ;S-tanding, C-rouching, A-ir, N-utural, U-nchanged
Anim = 1915 ;Animation of the Bag falling over.
SprPriority = -3 ;Insures the bag appers in back of the player(s).
VelSet = ifelse(GetHitVar(xvel) < 0,-2,2),0
;Set Parent Variable 13 to the Value when the helper enters this state. (Gets Hit)
[State 1915, ParentVarSet]
type = ParentVarSet
triggerall = RoundsExisted >= 0
trigger1 = 1
var(13) = 1915
ignorehitpause = 1
persistent = 0
;Set Parent Variable 14 to the Value when the helper falls to the left.
[State 1915, ParentVarSet]
type = ParentVarSet
triggerall = RoundsExisted >= 0
trigger1 = 1
var(14) = ifelse(GetHitVar(xvel) < 0,1,Parent,Var(14))
ignorehitpause = 1
persistent = 0
;--------------------------------------------------------
;Helper falls to the Right or Left according to which side the attacker is on. The trigger makes the Helper fall to the
;Left if it is hit from the right. (There by imparting a negative velocity to it.) Or to the Right if hit from
;the Left. (There by imparting a positive velocity to it.)
[State 1915, Turn When Hit]
type = Turn
trigger1 = GetHitVar(xvel) < 0
ignorehitpause = 1
persistent = 0
;Stay turned after the first round if the bag fell to the left.
[State 1915, Stay Turned]
type = Turn
triggerall = RoundNo > 1
trigger1 = Parent,Var(14) > 0
ignorehitpause = 1
persistent = 0
;--------------------------------------------------------
;Remain at Animation Frame 3 after the first round.
[State 1915, ChangeAnim]
type = ChangeAnim
trigger1 = RoundNo > 1
value = 1915
elem = 3
ignorehitpause = 1
persistent = 0
Finally, as a fun little extra, I made the Helper able to be hit by the Parent, (Player), as well as the Opponent by giving the Helper a blue collision box in it's animation and using these hitdefs in the Parents attack state. (In this case, the Parent's crouching strong kick.)
[State 440, 3] ;Only hit the Opponents.
type = HitDef
triggerall = !NumHelper(1912)
trigger1 = Time = 0
attr = C, NA
affectteam = E ;B-oth (all players), E-nemy (opponents), F-riendly (your own)
damage = 75
hitflag = M ;H-igh, L-ow, A-ir, M-id (Same as "HL"), F-all, D-own (Lieing Down)
guardflag = L
pausetime = 10,10
sparkno = 1
sparkxy = -5,-10
hitsound = 5,2
guardsound = 6,0
ground.type = Trip
ground.slidetime = 10
ground.hittime = 17
ground.velocity = -1.5,-2
air.velocity = -1.2,-3
guard.velocity = -5
fall = 1
[State 440, 4] ;Hit the bag.
type = HitDef
triggerall = NumHelper(1912)
trigger1 = Time = 0
attr = C, NA
affectteam = B ;B-oth (all players), E-nemy (opponents), F-riendly (your own)
damage = 75
hitflag = M ;H-igh, L-ow, A-ir, M-id (Same as "HL"), F-all, D-own (Lieing Down)
guardflag = L
pausetime = 10,10
sparkno = 1
sparkxy = -5,-10
hitsound = 5,2
guardsound = 6,0
ground.type = Trip
ground.slidetime = 10
ground.hittime = 17
ground.velocity = -1.5,-2
air.velocity = -1.2,-3
guard.velocity = -5
fall = 0
We need two separate hitdefs for the attack to hit both the Opponent and The Helper because the "affectteam" part of the hitdef will not accept an ifelse statement, nor will it accept a Variable.