YesNoOk
avatar

How do you make a stun system using vars? (Read 11000 times)

Started by primordialgunna, September 08, 2024, 12:31:30 am
Share this topic:
How do you make a stun system using vars?
#1  September 08, 2024, 12:31:30 am
  • *
    • USA
    • https://maid3n.neocities.org
How do you make a stun system with a visible stun bar?
I identify as High/Low. So don’t get it mixed up.
Re: How do you make a stun system using vars?
#2  September 08, 2024, 04:41:47 pm
  • ****
  • Formerly DeathScythe
    • Brazil
    • lyricasky.neocities.org
I made a stun system a while ago for my game, it didn't have a bar but is very easy to add it after you get the system working.

For my game, I implemented the stun in a helper, and in the player, which means, this is for you to get stunned, not to make the opponent get stunned. I think it is easier this way. If you want to use this in the character rather than in a helper, just remove all Root redirects, and place everything in -2.
I used 3 vars here, but you can use only 2, the decider is optional.

; var(46):= Stun Points Decider
; var(47):= Stun Points
; var(48):= Stun Timer

This goes in the character's statedef -2:

Code:
[State 0, ChangeState] ;Stun/Dizzy
type = ChangeState
trigger1 = (StateNo != [1115310,1115316]) && StateNo != 1115300
trigger1 = NumHelper(696969) && MoveType = H && !GetHitVar(Guarded)
trigger1 = Helper(696969), var(47) >= 75
trigger1 = Alive
value = 1115310
ignorehitpause = 1

Then you need to create the stun states and animations.
I'll post mine, is a bit long, so I'll hide it in spoilers.

Spoiler, click to toggle visibilty

Now for the system.
Everytime you see var(20), it is for Custom Combo, you can delete these if your characters doesn't have it.

Code:
;Stun/Dizzy System

; Reset the decider whenever the opponent is not attacking
[State 0, Stun Points Decider Reset]
type = VarSet
triggerAll = var(46) > 0 && NumEnemy
trigger1 = EnemyNear, MoveType != A && (EnemyNear, StateNo != [200,4999])
trigger2 = EnemyNear, var(20)
var(46) = 0
ignorehitpause = 1

; Decide how many points to add to the stun
[State 0, Stun Points Decider]
type = Null
triggerAll = NumEnemy
triggerAll = EnemyNear, MoveType = A && !EnemyNear, var(20) && var(46) = 0
trigger1 = (EnemyNear, StateNo = [200,209]) || (EnemyNear, StateNo = [230,239]) || (EnemyNear, StateNo = [400,409]) || (EnemyNear, StateNo = [430,439]) || (EnemyNear, StateNo = [600,609]) || (EnemyNear, StateNo = [630,639])
trigger1 = var(46) := 3 + (Random%2)
trigger2 = (EnemyNear, StateNo = [210,219]) || (EnemyNear, StateNo = [240,249]) || (EnemyNear, StateNo = [410,419]) || (EnemyNear, StateNo = [440,449]) || (EnemyNear, StateNo = [610,619]) || (EnemyNear, StateNo = [640,649])
trigger2 = var(46) := 8 + (Random%2)
trigger3 = (EnemyNear, StateNo = [220,229]) || (EnemyNear, StateNo = [250,259]) || (EnemyNear, StateNo = [420,429]) || (EnemyNear, StateNo = [450,459]) || (EnemyNear, StateNo = [620,629]) || (EnemyNear, StateNo = [650,659])
trigger3 = var(46) := 12 + (Random%2)
trigger4 = EnemyNear, StateNo = [1000,2999]
trigger4 = var(46) := 16 + (Random%3)
trigger5 = EnemyNear, StateNo = [3000,4999]
trigger5 = var(46) := 18 + (Random%3)
ignorehitpause = 1

; Reset stun points when you're not being hit or if stun is activated
[State 0, Stun Points Reset]
type = Null
trigger1 = (Root, StateNo = 1115300) && var(47) >= 75
trigger1 = var(47):= -25
trigger2 = var(48) = 0
trigger2 = var(47):= 0
ignorehitpause = 1

; Actually adds the stun points
[State 0, Stun Points Add]
type = VarAdd
trigger1 = var(47) < 75 && NumEnemy
trigger1 = !EnemyNear, var(20)
trigger1 = var(3) = 1
var(47) = Ceil(var(46) / ifElse((Root, GetHitVar(HitCount) > 1), (Root, GetHitVar(HitCount) * 2), 1))
ignorehitpause = 1

; Set timer once you're stunned
[State 0, Stun Points Timer Set]
type = VarSet
trigger1 = Root, MoveType = H
var(48) = 180
ignorehitpause = 1

; Decrease timer
[State 0, Stun Points Timer Count]
type = VarAdd
trigger1 = var(48) > 0 && Root, MoveType != H
var(48) = -1
ignorehitpause = 1

; Helper animation (like stars floating over the head) when char is stunned
[State 0, Helper]
type = Helper
trigger1 = !NumHelper(1115369) && RoundState = 2
trigger1 = (Root, StateNo = [1115310,1115316])
helpertype = normal
name = "Stars Birds"
ID = 1115369
stateno = 1115369
postype = p1
ignorehitpause = 1

To add a bar, just make explods and scale one of them according to var(47)
You can check this thread wich explains it better:
https://mugenguild.com/forum/topics/custom-bars-141757.0.html
Last Edit: September 08, 2024, 04:45:00 pm by Lyrica