YesNoOk
avatar

ACCURATE stun damage system (For dizzy stuff) (Read 13182 times)

Started by rednavi, October 24, 2009, 02:07:37 am
Share this topic:
ACCURATE stun damage system (For dizzy stuff)
#1  October 24, 2009, 02:07:37 am
  • avatar
  • ******
    • USA
The next guide will show you how to implement ACCURATE stun damage (So when you hit the enemy too much he ends in a dizzy state) in MUGEN (This is better applied on fullgames but you can also use this workaround on normal compilations but you will have to do alot of changes). Of course the term "accurate" is based on "you will be able to apply stun damage with any value you want with anything from attacks to helpers" so that means you can give any stun damage value to any attack (Hitdef), said value is completelly independant of any other data such as life damage inflicted, hitpauses or hitvels.

Before going further let me tell you two things: first, this workaround can be used to do some other stuff but it wont work at all for a guard gauge damage coding so dont expect to use this for custom guard crush stuff. Second, you MUST NOT need of any "fall.envshake" parameter on any of your hitdefs as these parameters are used on this workaround. If you wish to implement effects that usually need of this parameter you can use other ways (In a fullgame more than anything) such as custom states combined with envshake SCTRL. Anyway don't use those parameters for their normal purpose.

This system is based on the stun damage system from KOF with some extra modifications which were applied on my KOF fullgame, feel free to modify this after you got how this works.


For the whole system to work correctly we will need:

* All the fall.envshake parameters to be unused on all the hitdefs.
* A free float variable for the stun damage dampener (Fvar(9) is used on this guide for that). This requisite is OPTIONAL so if you dont want to use the dampener then you wont need any variable at all.
* Two free int variables, one is used to register the accumulated stun damage on the character (Var(13) here) and another is used to prevent the re-dizzy situations (Var(14) here). You can also use float variables instead of ints.
* A "Stunned/ Dizzy" state (State 5299 in this example) and follow up states to it if needed (States 5300 to 5301 here). This wont be covered by this guide so you decide how this state will look and work like. This guide is just to help you to trigger the changestate to this particular custom state.

Let's begin now, you'll see that this is easy as 1,2,3 very soon (Well, this IS divided into 3 steps :P).


-----------
FIRST STEP:
-----------

Paste this on all the hitdefs that should cause stun damage (At the bottom of them would be better just to be organized):

fall.envshake.time = ceil(38.4615*fvar(9)) ; STUN DMG
fall.envshake.freq = 0.0
fall.envshake.ampl = 0
fall.envshake.phase = 0.0

The "fall.envshake.time" is the only value we're going to use here, the rest must be at 0 to avoid the actual envshake from happening no matter what's the value on the first parameter. If you don't paste this on a hitdef then said attack won't do any stun damage (This should always be ommited on attacks such as throws or hypers).

First of all the example shows a value of "ceil(38.4615*fvar(9))". The common stun damage in this case is 38.4615 which rounded up (Thanks to the ceil) is 39. Before the round-up the value is multiplied by fvar(9) which in my case is my stun damage dampener which makes the value decrease the longer the number of hits the enemy received. If you want to remove the dampener and have a fixed value per hitdef then just remove the whole value and add an int number (In this case just 39).


------------
SECOND STEP:
------------

Paste this on your starting get-hit states (5000,5010,5020,5080 and any custom gethit state that begins a custom state transition where going into dizzy state would be applicable):

; STUN VALUE SUBSTRACTION
[State 5000]
type = VarAdd
trigger1 = time=0 && var(14)=0
var(13) = -(gethitvar(fall.envshake.time))
ignorehitpause = 1
persistent = 0

; CHANGESTATE TO DIZZY
[State 5000]
type = ChangeState
trigger1 = alive && var(13)<=1 && var(14)=0
trigger1 = HitShakeOver
value = 5299
ctrl = 0
ignorehitpause = 1
persistent = 0

The first SCTRL substracts the stun damage from your total value left in var(13) and as you see var(14) must not be active (To prevent re-dizzy).

The second SCTRL changes you to the dizzy state as soon as the hitpausetime is over. The changestate only happens when you no longer have stun damage left on your character (The stun damage works like the life where you start with a max amount of stun damage and lose part of it when you get hit).


-----------
THIRD STEP:
-----------

Now on Statedef -2 paste this:

; RESET STUN VALUE (MAX VALUE IS 1000)
[State -2]
type = VarSet
trigger1 = RoundState<2
trigger2 = movetype = H && var(14)=1 && stateno!=[5299,5301] ; WHEN RE-DIZZY AVOIDER IS ACTIVE
trigger4 = var(13)>1000 ; AVOIDS OVERFLOW
trigger5 = movetype!=H && prevstateno=5301 ; WHEN ON DIZZY STATES (STATE 5301 IS WHEN YOU ARE HITTABLE AGAIN)
var(13) = 1000
ignorehitpause = 1

; RE-DIZZY PREVENTION RESET
[State -2]
type = VarSet
trigger1 = movetype!=H && stateno!=[5299,5301]
var(14) = 0
ignorehitpause = 1

; STUN VALUE RECOVERY ADDITION
[State -2]
type = VarAdd
Triggerall = var(13)<1000 && var(14)=0 && movetype!=H && stateno!=[5299,5301]
trigger1 = (GameTime%5)=0
var(13) = 1
ignorehitpause = 0

; MIN VALUE FIXING
[State -2]
type = Varset
Trigger1 = var(14)=0 && var(13)<1
var(13) = 1
ignorehitpause = 1

The first SCTRL resets the stun damage value to it's maximum (In this case it's 1000) when needed. If you're making a big styled or boss character you most likely gonna give this a higher max value and if you're making a fast/ speed based character who usually has less life than the standard then you should give this a lower max value. In any case if you relace the max value with another number then you must do the same tweaking in the rest of the coding where var(13) max value is getting read (Like in the overflow avoid and value recovery).

The second SCTRL is the one that resets back to 0 the re-dizzy prevention variable. This variable is used so when you get dizzy you wont get dizzied again if your enemy does a combo that should put you on dizzy state under normal circumstances until you got back the control atleast once after getting dizzy. This avoid possible infinites like "enemy get's hit >> enemy is dizzy >> enemy get's hit by a large combo >> enemy get's dizzy again >> repeat". Since this guide wont cover the dizzy custom state itself I recommend to set var(14) to 1 on the very first dizzy state (In this example state 5299).

The third SCTRL is optional and it's a varadd that gives you back stun damage lost over time. In this example you get back one point of stun damage back each 5 ticks as long as you're not getting hit. If you want to make this work like in KOF then you most likely gonna have to modify this a little bit but if you dont care then use this style which is the same my fullgame uses.

The fourth SCTRL is just a safety to prevent setting the var(13) below 1 (In which case it wouldn't matter anyway).


--------------
OPTIONAL STEP:
--------------

This also goes in Statedef -2 if you want to apply this.

If you want to include the stun damage dampener to reduce it's value depending of the number of hits dealt to the enemy you must include the next coding and then tweak it to your likings. Be advised that in my fullgame I use a variable to keep track of the number of hits (Which is independant of the gethivar(hitcount) as I use a more complex system for that) so I adapted this to normal mugen by just using the gethitvar trigger. If you think you have a better way to trigger each dampener then modify it by yourself but I think this does the work.

; MULTIPLIER USED ON THE STUN VALUE
[State -2]
type = varset
trigger1 = enemynear,gethitvar(hitcount) = [0,3]
fvar(9) = 1.0
ignorehitpause = 1
[State -2]
type = varset
trigger1 = enemynear,gethitvar(hitcount) = [4,6]
fvar(9) = 0.85
ignorehitpause = 1
[State -2]
type = varset
trigger1 = enemynear,gethitvar(hitcount) = [7,9]
fvar(9) = 0.75
ignorehitpause = 1
[State -2]
type = varset
trigger1 = enemynear,gethitvar(hitcount) = [10,12]
fvar(9) = 0.65
ignorehitpause = 1
[State -2]
type = varset
trigger1 = enemynear,gethitvar(hitcount) = [13,17]
fvar(9) = 0.5
ignorehitpause = 1
[State -2]
type = varset
trigger1 = enemynear,gethitvar(hitcount) = [18,24]
fvar(9) = 0.4
ignorehitpause = 1
[State -2]
type = varset
trigger1 = enemynear,gethitvar(hitcount) = [25,32]
fvar(9) = 0.25
ignorehitpause = 1
[State -2]
type = varset
trigger1 = enemynear,gethitvar(hitcount) >= 33
fvar(9) = 0.1
ignorehitpause = 1

Remember that if a helper is used for an attack (Has an active hitdef by himself) he must read the player's fvar(9). There are two ways for that to make it work correctly:

The first way is just to use a varset on the helper and later paste the stuff from the first step into the hitdef without changes (Except the values you want to give to the stun damage).

[State helper]
type = varset
trigger1 = 1
fvar(9) = root,fvar(9)
ignorehitpause = 1

The second way saves some space and is about changing the first step's coding in the helper hitdef and include a redirection to the multiplier value like this:

fall.envshake.time = ceil(38.4615*root,fvar(9)) ; STUN DMG MULTIPLIED BY ROOT STUN DMG DAMPENER
fall.envshake.freq = 0.0
fall.envshake.ampl = 0
fall.envshake.phase = 0.0


And that's all, now your character will get dizzied-slash-stunned when he get's to his limits and will end up free to be hit ^^. If you understood this very well, if not your miss :P. And give credit you lazy bitch &gt;_&gt;.

And don't ask damnit, of course this is open source.