YesNoOk
avatar

Street Fighter 4 Ultra Bar / EX Bar System (Read 7468 times)

Started by Rolento, January 29, 2010, 08:25:07 pm
Share this topic:
Street Fighter 4 Ultra Bar / EX Bar System
#1  January 29, 2010, 08:25:07 pm
  • ***
  • Figuring things out, one sprite at a time.
    • irwt.iammanyninjas.com
Before I go into the details of the code, I just want to curse the fact that Explods are affected by Envshake, thank Bia for bugtesting this absurd code and helping to fix some of the more annoying parts along the way, and Vans for some SF4 system rips he passed me earlier on which I forgot I had until recently. With that said, here we go:

Things To Look At
For the earlier Focus Attack / Saving Attack code - http://mugenguild.com/forumx/index.php?topic=111652.0
To see a sample of this code in action, download the SF IV KFM located at my site - http://irwt.smeenet.org

What This Code Does:
The code does 2 things: First it deals with the behind-the-scenes work of converting the damage you recieve into a recordable value that makes up the ultra system as well as providing a visual cue for it in terms of the circular bar. The second part is  providing a secondary power display that changes appearance as you build up more power. Both aspects are part of a single helper state that is launched at the beginning of the round. The Ultra combo value is measured out through the use of several variables and a tragically high number of anims; seems Rei was onto something in his own take on this.

I also want to make note of here that although this code does a decent job, there are a few graphical issues here and there due to the fact that it is not currently possible to make Explods ignore the effects of Envshake, which causes some iffy behavior in binding things to a certain position.

Vars Used
var(3) - Primary ultra combo recording var, used in building meter
var(4) - Part A of life measurement in cases of custom states
var(5) - Part B of life measurement in cases of custom states
var(6) - Used to calculate custom state damage using above vars in equation
var(7) - Secondary ultra combo recording var, used in damage multiplier

Command Entry Info
The example character shows this off better, but instead of using a trigger based on power level, you use the following:
triggerall = var(3)>= 36

Animation Entry Info
... Just trust me that it would be easier to download the sample to see it. It would take too much room to be reasonable to show in this post. I've placed the related animations after KFM's normal animations for reference sake.

The Main Code Itself

Regular States:

;------------------
;SF4 Ultra Bar / Ex Bar
[Statedef 2000]
type    = S
movetype= I
physics = N
anim = 1; <-- Note that I am using a blank anim here.
sprpriority = 1

;Ultra's Green circle background
[State 0, Explod p1]
type = Explod
trigger1 = !numexplod(105)
anim = 2176
ID = 105
pos = 20,145
postype = Back
facing = 1
bindtime = -1
removetime = -1
scale = 0.25,0.25
sprpriority = 2
ontop = 0
shadow = 0,0,0
ownpal = 1
removeongethit = 0
ignorehitpause = 1
pausemovetime = -1
supermovetime = -1

;Ultra's Green circle when filling
[State 0, Explod]
type = Explod
trigger1 = numexplod(100)< 2
anim = 2100+root,Var(3)
ID = 100
pos = 20,145
postype = Back
facing = 1
bindtime = -1
removetime = 2
scale = 0.25,0.25
sprpriority = 3
ontop = 0
shadow = 0,0,0
ownpal = 1
removeongethit = 0
ignorehitpause = 1
pausemovetime = 0
supermovetime = 0

;Full Ultra Meter
[State 0, Explod-full]
type = Explod
trigger1 = !numexplod(101)
trigger1 = root,Var(3)>= 75
anim = 2000
ID = 101
pos = 20,145
postype = Back
facing = 1
bindtime = -1
removetime = -1
scale = 0.25,0.25
sprpriority = 3
ontop = 0
shadow = 0,0,0
ownpal = 1
removeongethit = 0
ignorehitpause = 1
pausemovetime = -1
supermovetime = -1

;Makes sure the above disappears on Ultra use
[State 0, RemoveExplod]
type = RemoveExplod
trigger1 = root,Var(3)<75
id = 101

; Ultra bar interface, aka black covering thing.
[State 0, Explod p1]
type = Explod
trigger1 = !numexplod(102)
anim = 2200
ID = 102
pos = 20,145
postype = Back
facing = 1
bindtime = -1
removetime = -1
scale = 0.25,0.25
sprpriority = 4
ontop = 0
shadow = 0,0,0
ownpal = 1
removeongethit = 0
ignorehitpause = 1
pausemovetime = -1
supermovetime = -1

;Revenge Lettering
[State 0, Explod p1]
type = Explod
triggerall= teamside = 1
trigger1 = !numexplod(103)
anim = 2201
ID = 103
pos = 20,145
postype = Back
facing = 1
bindtime = -1
removetime = -1
scale = 0.25,0.25
sprpriority = 4
ontop = 1
shadow = 0,0,0
ownpal = 1
removeongethit = 0
ignorehitpause = 1
pausemovetime = -1
supermovetime = -1

[State 0, Explod p2]
type = Explod
triggerall= teamside = 2
trigger1 = !numexplod(103)
anim = 2202
ID = 103
pos = 20,145
postype = Back
facing = 1
bindtime = -1
removetime = -1
scale = 0.25,0.25
sprpriority = 4
ontop = 1
shadow = 0,0,0
ownpal = 1
removeongethit = 0
ignorehitpause = 1
pausemovetime = -1
supermovetime = -1

;Makes the above disappear if an Ultra is possible.
[State 0, RemoveExplod]
type = RemoveExplod
trigger1 = root,var(3)>= 37
id = 103
ignorehitpause = 1
persistent = 1

;ULTRA Lettering
[State 0, Explod p1]
type = Explod
triggerall= teamside = 1
trigger1 = numexplod(104)<2
anim = 2203
ID = 104
pos = 20,145
postype = Back
facing = 1
bindtime = -1
removetime = 2
scale = 0.25,0.25
sprpriority = 4
ontop = 1
shadow = 0,0,0
ownpal = 1
removeongethit = 0
ignorehitpause = 1
pausemovetime = 0
supermovetime = 0

[State 0, Explod p2]
type = Explod
triggerall= teamside = 2
trigger1 = numexplod(104)<2
anim = 2204
ID = 104
pos = 20,145
postype = Back
facing = 1
bindtime = -1
removetime = 2
scale = 0.25,0.25
sprpriority = 4
ontop = 1
shadow = 0,0,0
ownpal = 1
removeongethit = 0
ignorehitpause = 1
pausemovetime = 0
supermovetime = 0

;Makes the above disappear when you have used the ultra.
[State 0, RemoveExplod]
type = RemoveExplod
trigger1 = root,var(3)<= 36
id = 104
ignorehitpause = 1
persistent = 1

;Okay, now for the EX/Super components.

;EX meter Background
[State 0, bg p1]
type = Explod
triggerall= teamside = 1
trigger1 = !numexplod(106)
anim = 2205
ID = 106
pos = 20,145
postype = Back
facing = 1
bindtime = -1
removetime = -1
scale = 0.25,0.25
sprpriority = 2
ontop = 0
shadow = 0,0,0
ownpal = 1
removeongethit = 0
ignorehitpause = 1
pausemovetime = -1
supermovetime = -1

[State 0, bg p1]
type = Explod
triggerall= teamside = 2
trigger1 = !numexplod(106)
anim = 2205
ID = 106
pos = 20,145
postype = Back
facing = 1
bindtime = -1
removetime = -1
scale = 0.25,0.25
sprpriority = 2
ontop = 0
shadow = 0,0,0
ownpal = 1
removeongethit = 0
ignorehitpause = 1
pausemovetime = -1
supermovetime = -1

;Building Power bar Explod
[State 0, Explod]
type = Explod
trigger1 = !NumExplod(107)
trigger1= 1
anim = 2206
ID = 107
postype = Back
pos = 80,148
facing = -1
ownpal = 0
bindtime = -1
removetime = -1
ignorehitpause = 1
sprpriority = 3
ontop = 0
pausemovetime = -1
supermovetime = -1
scale = .25,.25

[State 0, ModifyExplod]
type = ModifyExplod
trigger1 = NumExplod(107) && power <= 1000
ID = 107
scale = ((parent,power)/4175.0),0.27
ignorehitpause = 1
pausemovetime = 99999999999999
supermovetime = 99999999999999

; These next 4 explods are the blinking EX Boxes that appear every 250 power.
[State 0, blinking box 1]
type = Explod
trigger1 = !numexplod(110)
anim = Cond(power>=250,2208,2207)
ID = 110
pos = 63,145
postype = Back
facing = 1
bindtime = -1
removetime = 1
scale = 0.26,0.25
sprpriority = 4
ontop = 0
shadow = 0,0,0
ownpal = 1
removeongethit = 0
ignorehitpause = 1
pausemovetime = -1
supermovetime = -1

[State 0, blinking box 2]
type = Explod
trigger1 = !numexplod(111)
anim = Cond(power>=500,2208,2207)
ID = 111
pos = 49,145
postype = Back
facing = 1
bindtime = -1
removetime = 1
scale = 0.26,0.25
sprpriority = 4
ontop = 0
shadow = 0,0,0
ownpal = 1
removeongethit = 0
ignorehitpause = 1
pausemovetime = -1
supermovetime = -1

[State 0, blinking box 3]
type = Explod
trigger1 = !numexplod(112)
anim = Cond(power>=750,2208,2207)
ID = 112
pos = 35,145
postype = Back
facing = 1
bindtime = -1
removetime = 1
scale = 0.26,0.25
sprpriority = 4
ontop = 0
shadow = 0,0,0
ownpal = 1
removeongethit = 0
ignorehitpause = 1
pausemovetime = -1
supermovetime = -1

[State 0, blinking box 4]
type = Explod
trigger1 = !numexplod(113)
anim = Cond(power=1000,2208,2207)
ID = 113
pos = 21,145
postype = Back
facing = 1
bindtime = -1
removetime = 1
scale = 0.26,0.25
sprpriority = 4
ontop = 0
shadow = 0,0,0
ownpal = 1
removeongethit = 0
ignorehitpause = 1
pausemovetime = -1
supermovetime = -1

;Combo/EX Text
;Text changes when power is over 250
[State 0, Combo p1]
type = Explod
triggerall = teamside = 1
trigger1 = numexplod(114)<2
anim = Cond(power>=250,2210,2209)
ID = 114
pos = 91,145
postype = Back
facing = 1
bindtime = -1
removetime = 2
scale = 0.26,0.25
sprpriority = 5
ontop = 0
shadow = 0,0,0
ownpal = 1
removeongethit = 0
ignorehitpause = 1
pausemovetime = 1
supermovetime = 1

[State 0, Combo p2]
type = Explod
triggerall = teamside = 2
trigger1 = numexplod(114)<2
anim = Cond(power>=250,2210,2209)
ID = 114
pos = 91,145
postype = Back
facing = -1
bindtime = -1
removetime = 2
scale = 0.26,0.25
sprpriority = 5
ontop = 0
shadow = 0,0,0
ownpal = 1
removeongethit = 0
ignorehitpause = 1
pausemovetime = 1
supermovetime = 1

;Super Text
;Set to pop up only when power is full
[State 0, Super p1]
type = Explod
triggerall = teamside = 1
trigger1 = numexplod(115)<2
anim = Cond(power=1000,2211,1)
ID = 115
pos = 91,145
postype = Back
facing = 1
bindtime = -1
removetime = 2
scale = 0.26,0.25
sprpriority = 5
ontop = 1
shadow = 0,0,0
ownpal = 1
removeongethit = 0
ignorehitpause = 1
pausemovetime = 0
supermovetime = 0

[State 0, Super p2]
type = Explod
triggerall = teamside = 2
trigger1 = numexplod(115)<2
anim = Cond(power=1000,2211,1)
ID = 115
pos = 91,145
postype = Back
facing = -1
bindtime = -1
removetime = 2
scale = 0.26,0.25
sprpriority = 5
ontop = 1
shadow = 0,0,0
ownpal = 1
removeongethit = 0
ignorehitpause = 1
pausemovetime = 0
supermovetime = 0

Negative States:
;Ultra Bar summon
[State -2, ultra bar helper]
type = Helper
trigger1 = !NumHelper(20)
helpertype = normal
name = "Bar"
ID = 20
stateno = 2000
postype = back
pos = 40,-20
bindtime = -1
removetime = -1
ignorehitpause = 1
facing = 1
ownpal = 1
size.xscale =0.25
size.yscale =0.25
persistent = 1

;Sets the ultra var at the start of each round
[State -2, ultra value at roundstate]
type = varset
trigger1 = roundstate = 1
var(3) = 0

;Limits the var to a value of 75, which is the max value
[State -2, ultra value limit]
type = varset
trigger1 = var(3)>=75
trigger1 = 1
var(3) = 75

;Resets the ultra var when you use ultra moves, with KFM's new ultra states as examples.
[State -2, ultra reset upon ultra use]
type = varset
trigger1 = stateno = 3001 || stateno = 3052
var(3) = 0

;This adds to the ultra var through conventional damage
[State -2, adding to ultra value due to damage]
type = varadd
triggerall = var(3)<=75 && movetype = H
trigger1 = gethitvar(damage)
var(3) = gethitvar(damage)/6

;This adds to the ultra var through custom states using lifeadd
[State -2, adding to ultra value due to lifeadd]
type = varadd
triggerall = var(3)<=75 && movetype = H
trigger1 = !gethitvar(damage) && time = 1
var(3) = var(6)/6

;These next sctrls track the changes in life total for the above sctrl
[state -2, Life measure 1]
type = varset
trigger1 = 1
var(4) = var(5)

[State -2, Life measure 2]
Type = VarSet
Trigger1 = 1
var(5) = life

[State -2, anti-life equation]
type = varset
trigger1 = 1
var(6) = var(4)-var(5)
ignorehitpause = 1

;Alright, here's the value you'll want to use in the ultra states themselves.
;To add damage according to what the ultra value was, you need to use the following
;line in your related hitdefs: damage=[Starting damage]+(var(7)/5),[Block damage]

;Records the ultra var value and stores it beyond the ultra usage.
[State -2, former ultra bar value]
type = varset
trigger1 = var(3)>0 && time = 0
var(7) = var(3)
ignorehitpause = 1

;Resets that recorded value once the ultra is over/ you've been hit out of it.
[State -2, former ultra bar value reset to normal]
type = varset
trigger1 = stateno = 3001 && !animtime || stateno = 3052 && !animtime
trigger2 = movetype = H && prevstateno = 3001 || movetype = H && prevstateno = 3052
var(7) = var(3)
ignorehitpause = 1

Okay, that covers that mess of code. There's the sum of a few days of work which hopefully someone can get some use out of. You may notice that certain things like the glowing circle and bursts of flame when you can use an ultra are missing, but that's because I don't have any captures to use in these cases; if you do happen to run across them later, they can be pretty easily added using the same Explod behavior as the Ultra text itself. Barring any other random acts of coding, I'm stepping back to my own works for the time being. If you can make use of this stuff, just recall to give credit to Bia, Vans, and myself. If you're really thankful, I do remind you of the paypal link on my main site. Hah! (If you can, any donation would be appreciated.)

That's all she wrote for now, so good .\/. to you all, and catch you later.