Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
State machines and itr (Interaction) Studies in LF2
#1
This essay is aimed to provide a detailed explanation regarding how state and itr parameters take effect inside LF2.

This will expand without prior notice.

Before you read on
This essay is a collection of studies which has much deeper knowledge compared to what is hosted on LF-empire site DC tutorial.
This includes research results of Managing playable type: 3, 5 characters, which is highly abstract.
The essay will frequently use terms regarding state machines, and will have a sick amount of pragmatic (and possibly incomprehensible) code and psuedocode.

I would use code similar to this:

Code:
frame XXX

if (some condition)
 do something
 do something
else
 do something else

frame XXX_end

Although a player character and non-player character are designed to be type: 0, there will be a lot of facts which are tested by using non-type: 0 characters.
Because of that there are a lot of possibly unwanted information but I will try to show the final results clearly.

Human States

State: 0

The standing state.

If a character's hit_a parameter is 0, it will run the following check.
If hit_a isn't 0, the parameter will override the whole check. (I assume later examples will also override unless specified)

If the controlling player (including computer, I assume laters samples include computers unless specified) presses A, the system will check if the character is holding a weapon.

If he is holding a weapon, he has 50% chance to go to frame 20 and 50% chance to go to frame 25.
If he holds no weapon, he has 50% chance to go to frame 60 and 50% chance to go to frame 65.

I will explain weapon usage and super punch in details later.

If a character's hit_j parameter is 0, he will go to frame 210 when J is pressed. Otherwise the parameter overrides.

If a character's hit_d parameter is 0, he will go to frame 110 when D is pressed. Otherwise the parameter overrides.

If direction key is pressed, character will go to one of frames 5-8, but the initial frame it goes to is neither random nor fixed.

However, if both of these happen (Left and right are both or neither pressed) (up and down are both or neither pressed), the direction keys are cancelled.
This can be represented by logic condition (up XNOR dn) & (lt XNOR rt)

A character (pragmatically, any object including weapon and projectile) has a hidden "walking counter" that counts from 0 to 5 whenever a tick has begun when the character is in state: 1.
The counter starts at 0 when the character is spawned.
The specific frame when a character goes to when he moves from state: 0 is:

C=0 -> Frame 5
C=1 -> Frame 6
C=2 -> Frame 7
C=3 -> Frame 8
C=4 -> Frame 7
C=5 -> Frame 6

The period of a tick is equal to (walking_frame_rate+1) tu, but exe will crash if walking_frame_rate is set to 0.

There is bad code hidden in lf2 that causes a simultaneous key input of JA and DA to go to frame 210 or 110 respectively, listed by Yinyin here.

If no button is pressed, a hidden standing counter will be incremented. Whenever this character leaves a frame with state: 0, this counter is reset to 0. The counter similar to walking counter except its highest possible number is equal to total tu of walking frames.
For example, if a character has standing frames with wait 3,4,5,9, the counter can go to maximum of (3+4+5+9-4) = 17tu.
Which standing frame the character goes to is determined by the counter.

State: 0 machine (Click to View)
Picking up a weapon is NOT related to state: 0.


State: 1
The walking state, it acts very similar to state: 0 (there are some misconception regarding this state though)

It acts identically as state: 0 regarding A, J and D buttons,

If direction key is held, it will determine if walking should be continued.
If direction key is released, although the character will go to standing, there is a hidden running initiation counter that records the last left/right key pressed and its initial press time.
If the same direction key is pressed quickly after the last key press, it will trigger running.

Also notice a hit_x tag leading to running frame grants the character automatic running.

State: 1 machine (Click to View)
Grabbing a stunned person is NOT related to state: 1.
Picking up a weapon is NOT related to state: 1.

State: 2
The running state, this also has a hidden running timer which maximum number equals to 3. It is very similar to walking counter except with 4 transitions:

C=0 -> Frame 9
C=1 -> Frame 10
C=2 -> Frame 11
C=3 -> Frame 10

If hit_d parameter is 0, character will go to frame 102 (rolling) when D is pressed.

If hit_j parameter is 0, character will go to frame 213 (forward dash) when J is pressed.

If hit_a parameter is 0, character will check if he holds a weapon when A is pressed.
If he holds weapon he goes to frame 35 (run_weapon_attack)
If he doesn't hold, he goes to frame 85 (run_attack)

If an opposite direction key against his running direction is pressed, he will go to frame 218 (stop_running)

hit_XX are disabled if a character is holding a heavy weapon via itr kind 2, state: 2 itself doesn't disable hit_XX. For details go the section for itr kind 2.

State: 2 machine (Click to View)
State: 3

State 3 is the "Attack" state, which has NO state machine inserted into it.
It is very similar to State 15 except State 15 does not provoke defense on computer characters.

State: 4

The "Jump state" is an aerial state that takes some well-known and some hidden properties.

If hit_a parameter is 0, character will check if he holds a weapon when A is pressed.
If he holds weapon he goes to frame 30 (jump_weapon_attack)
If he doesn't hold, he goes to frame 80 (jump_attack)
It does not work when character is on ground.

If an opposite direction key to what he's facing is pressed, he changes direction.
It does not work when character is on ground.

There's no J and D state machines here, but a hidden issue that if a character with state: 4 gains velocity in either direction, he will change into falling frame.
This can be presented by the dazed Louis bug, where Louis tried to jump but his armor taking a hit will render him fall to ground instead.

Landing in a frame with state: 4 does not mean character will go to frame 215. Frame 212 is actual cause, that regardless of its state will result in going to 215.

State: 4 machine (Click to View)
State: 5

The dashing state uses y-axis-velocity, direction control and initial direction to interchange between 4 frames, namely 213, 214, 216 and 217.
The 4 frames represent the following:
213: Forward dash 1
214: Forward dash 2
216: Back-facing dash 1
217: Back-facing dash 2

If a character is in frame 213, pressing opposite direction will go to 216, vice versa.
If he is in frame 214, pressing opposite direction will go to 217, vice versa.
If he changes into frame 213 or 216, there's no hidden cooldown and frame countdown is refreshed.

If hit_a parameter is 0 and character is in frame 213 or 216, character will check if he holds a weapon when A is pressed.
If he holds weapon he goes to frame 40 (dash_weapon_attack)
If he doesn't hold, he goes to frame 90 (dash_attack)

Henry and Hunter can use dash backward shoot because there is hit_a: 81 written on frame 214 and 217.

State: 5 machine (Click to View)

State: 6

Rolling/Flipping State: 6 is identical to state: 15, has no effect on computer behavior and has NO state machines in it.

When a player is rolling he can press A to pick a weapon, however it is NOT caused by state: 6, but itr kind: 7.

If a character in state: 6 lands from air, he goes to frame 215. Character in frame 212 landing will also go to frame 215.

State: 7

State 7, the defending state is a well-known state for developing special characters.
Apart from its defense system which is well covered by others, there are something regarding hit_x keys about state: 7.

If a character is in state 7 and frame 110, and takes a blow that doesn't break his defense, he will go to frame 111.

Taking a blow that doesn't break defense outside frame 100 won't change frame.

Breaking defense makes character go to 112, but if character is in air or grabbed into state: 7 frame, his state: 7 frame cannot be broken.

Nonetheless an attack with bdefend >60 can negate state: 7.

If a character in frame 110 (but not necessary in state: 7), he can change his direction if he presses opposite direction key as his current facing.
This only affects frame 110.

frame 110 machine (Click to View)

State: 8

Broken defend State: 8 is identical to state: 15, has no effect on computer behavior and has NO state machines in it.

When a player is in broken_defend frames, hostile character pressing A will go to frame 70 (super_punch), but it is not caused by state: 8 but itr kind: 6 emitted by the frames.


State: 9

Catching, State 9 has no innate state machine.

The catching properties is done by cpoint parameters.

In an experiment, putting state: 0 on frame 121 overrides all cpoint properties, so there's little need for a separate state machine on state 9.

State: 10

Caught, State 10 has no innate state machine.

Object from any team can interact with an object in state: 10.

State: 11

Injured, State 11 has no innate state machine.

Knight and Julian lose innate armor in state 8, 10, 11, 16,
Louis's armor is only effective in frame 0-19 or state: 4, 5 frames.

State: 12

Falling, State 12 has a state machine when the object is also a type: 0.
Any non-character with state: 12 frames are not affected.

The state machine is similar to dash system, using y-axis velocity and facing direction to display falling animation.

Any characters being sent to falling frame will either start in 180 or 186.
He will immediately go to frame the machine indicated after 1tu.
The frame which the character will go to is as follows:

Frame 180/186 = velocity_y-10 or lower
Frame 181/187 = velocity_y>-10
Frame 182/188 = velocity_y>0 (can flip)
Frame 183/189 = velocity_y>6
Frame 184/190 = (apparently unused according to rewlf2)
Frame 185/191 = (bounce)
Bounce happens when xspeed is >10 or yspeed >1. The bounce itself has a cap on its speed.

If someone has a large negative yspeed, he will stay in frame 180 for some time before velocity_y exceeds -10.

Putting a dvx tag in falling will not change facing direction of character, but dvy tag will change its frame because y-axis velocity is changed.

Character hitting ground will be set to a fixed x and y-axis velocity which again is affected by gravity, and goes to frame 185 or 191 (forward or backward)

An object with state: 12 is immune to any attack that has less than 41 fall, and will automatically drop weapon, like the effect of wpoint kind 3.

State: 12 machine (Click to View)
Flipping function in frame 183 and 188 are independent of state and type. I once stumbled with a glitch that allowed a type: 3 character to go to frame 108 when she's in frame 188. It appears 183 and 188 are separately hardcoded to allow flipping.

Flipping machine (Click to View)
State: 13

Ice, State: 13 has no innate state machine, although it alters the reaction frame when attacked by an itr.

A detailed explanation of state: 13 is here.

There also seems to be a threshold for ice characters to not break if he lands on ground with too small x-axis and y-axis velocity.

State: 14

Lying, State: 14 has a condition-based state machine which either grants the character blinking status after he leaves the frame, gives a retreating warning to computer characters, or loops the frame every tu if the character has no current health.

The computer-warning part is not explained here but the state machine is as follows:

State: 14 machine (Click to View)
Note that if a character has 0 health is revived by F7, the lying frame countdown will start at when F7 is pressed.



State: 15

Normal action, State 15 has no innate state machine.



State: 16

Stunned, State 11 has no innate state machine.

Only a character with state: 16 can interact with a hostile's itr kind: 1. The hostile will perform a grab if hostile is pressing a direction key and itr collides with state: 16 character's bdy.

A stunned character can trigger a super_punch for the hostile, but it is caused by itr kind: 6.



State: 17

Drinking, State 11 has no innate state machine.

Frame 55-58 responsible for drinking action has NO state machine, if a character presses D in these frames, they stop drinking because there are hit_d: 999 in these frames.



State: 18

The fire state uses y-axis-velocity but has no direction control.
There are 4 frames representing the following:
203: Upward fire 1
204: Upward fire 2
205: Downward fire 1
206: Downward fire 2

Changing frame 203-206 to use state: 15 disables the state machine.

When a type: 0 character is in state: 18 and in frame 203-206, the next frame is determined by current y-axis speed.

If character is going up, next frame will be 203/204, otherwise will be 205/206
The exact frames are not confirmed and it is unknown if non-type: 0 share this property.

A state: 18 character landing will always be directed to frame 185 (forward bouncing)

state: 18 characters are immune to itr held by state: 18, 19 objects and itr with effect 20.

state: 18 characters can hit projectiles (example: soul bomb's explosion and firen's inferno), itr effect: 20 doesn't hit projectiles though.

State: 18 machine (Click to View)
Note that state machine doesn't change frames if characters is rising in frame 203/204 or falling in frame 205/206



State: 19

Firerun, State 19 is a state that allows a z-axis movement based on running_speedz, generates fire smoke and be immune to certain fire attacks. There is no state machine on this though.

state: 19 characters are immune to itr held by state: 18 objects and itr with effect 20.

State: 19 characters attacking state: 3000 projectiles will change their frame to 20 (hit) not 30 (rebounding)

State: 100

Special landing, State 100 changes the mechanism on landing frames, character must be directed to frame 94 if he is landing.

There is no state machine added, just altered.

State: 100 machine (Click to View)


State: 301, 400, 401, 1700

State 300 is a state that allows a z-axis movement,
400 causes character to teleport to ~120 pixels in front of nearest enemy,
401 causes character to teleport to ~60 pixels in front of furthest ally,

the first frame of state: 1700 adds 100 "flashing heal" points that is the effect of itr kind: 8, which causes the character to heal up to 100 HP or the difference between red and brown HP, whichever the lower.

Multiple state: 1700 frames do not stack flashing HP, but will set flashing HP to 100. In effect of state: 1700 frame the bar flashes but flashing HP does not start restoring. Only regular restoration occurs.

Flashing HP shares display with healing from Jan's Angel but have independent counter. When both of them are in effect the HP bar will restore HPs with both the rate, but will a distinct interval difference between the two restoration methods.

There is no state machine on these though.

State: 500, 501

Rudolf's Transform should be better explained here:
Rudolf's transform attack


State: 8XXX

Hostage transform, State: 8XXX (8000-8999) will cause character to change into the id: XXX.
This transformation will cause the character to go to frame 0 when id is changed.
The character will try to use frame number with +140 offset.

Transforming into Knight will try to use +140 offset sprites which normally will glitch display.


State: 9995

LouisEX transform, State: 9995 will cause character to change into the id: 50.
This transformation will cause the character to go to frame 0 when id is changed.
This will not give an offset on frame number


State: 9996+

9996 generates a set of LouisEX's armor
9997 causes the object to take a message property.
9998 deletes object
9999 functions exactly like 15

None of these probably ever needs state machine.



Weapon states

State: 1000

Light weapon fly freely in sky in this state.
Whether it will damage others is dependent on if this frame has an itr.

Light weapons in original LF2 have no itr in any state: 1000 frames.

Baseball, milk and beer will not go to frame 0-15 (which have state: 1000) even if they are hit by itr with less than 60 fall.

Others light weapons will go to frame 0-15, which frame it goes to is random.

State: 1001

Held state.
The weapon frame number and action is controlled by the object having wpoint interaction over it.

State: 1002

Weapon thrown in this state.
This is typically directed by a wpoint throw,
but milk, beer and baseball will go to thrown frames even when hit by low fall frames.

State: 1003

Weapon just on ground.
Studies on non-type: 0 characters revealed if a character with weapon type drops to ground, he will go to frame 20, 21 (heavy object) or 70, 60 (light objects).

Therefore state: 1003 does not have state engine, the ground collision is determined by type of object.

State: 1004

Weapon on ground.
Object in this state can have a bdy that interacts with itr kind: 2 of the character, the character links the object via wpoint.

1004 will cause picking character to go to picking_light frame.

State: 2000

Heavy weapon fly freely in sky in this state.
Whether it will damage others is dependent on if this frame has an itr.

Heavy weapons in original LF2 have itr in state: 2000 frames, thus the random stones hitting unlucky characters.

If a heavy weapon is hit by itr with fall: 70+, it will change its frame to 0-5 in random.

State: 2001

Held state.
The weapon frame number and action is controlled by the object having wpoint interaction over it.

State: 2004

Weapon on ground.
Object in this state can have a bdy that interacts with itr kind: 2 of the character, the character links the object via wpoint.

2004 will cause picking character to go to picking_heavy frame.

A study revealed hit_d, hit_j and hit_a of which picking_heavy will lead to will be inherited exactly for the picking_heavy frame.

If picking_heavy has next: 999 and frame 0 has hit_d: 99, when picking a heavy weapon and immediately pressing D, character will go to frame 99 but is incapable to use and commands inscribed in frame 99 (and following frames). Afterwards character goes back to heavy_walking.

To fix it, set frame 117 to have next: 12 (heavy_walking)



Projectile states

States - State 300X - Ball States

itr (interaction)

Kind: 0
The most common interaction, this will cause the following effects:

If the itr is held by type: 0 (Character), 2 (Heavy weapon), 5 (Etc),
Attacker will suffer from hitlag but will not change frame.

If the itr is held by id: 201/202 (Henry's arrow or Rudolf's dart) and it hits a type: 5 object, it will not change frame. (As per saving hostage with arrows and darts)

If the itr is held by type: 1(light weapon), 4(baseball), 6(drink),
Attacker will go to frame 0-15 in random

If the itr is held by type: 3(projectile), it checks for defender's state.
You can see States - State 300X - Ball States for details.

If a defender is type: 3 but is of state 0-15, it is found if defender is hit it will go to frame 20 or 30, depending on type of attacker. If attacker is type: 3 but is of state: 0-15, attacker will suffer from hitshake but will not change frame and will not suffer from hitlag.

State machine before Projectile part (Click to View)
Understanding catching and weapon itrs

Interactions regarding weapons and catching are different in how they are activated.
Allow me to introduce a term: Key-augmented input.

A lot of itr use Key-augmented input,

for instance, you might think itr kind: 2 on punch frames are used to pick up weapons.
The truth is even if a frame has itr kind: 2, if the character does not press A in the frame, he will never pick up a weapon. It can be easily shown if you try to add itr kind: 2 into jump frames. By quickly pressing J+A you can cancel your jump and pick a weapon.

To give an input to a non-type 0 character is tricky for human and extremely difficult for computer, the latter caused of AI glitching whenever a character transforms from type: 0 to another type.



Kind: 1

itr kind: 1 can only be activated if character presses direction key, his itr is overlapping with bdy of a hostile character with state: 16, and pressed direction key matches the x-axis displacement direction between attacker and victim:
Ppressing right when victim is at right side of character will grab him, moving away from enemy or up or down will not cause itr kind: 1 to trigger. Moving Up/Down AND towards enemy triggers itr kind: 1.

It then acts identical to what itr kind: 3 does.

Therefore, putting an enemy into DOP will not immediately cause your character to grab him, you can move out, press A to trigger super_punch or move towards him to grab.

It is proven no matter the type of character of attacker and victim, attacker can still catch victim. There's a rigid restriction on bdy of victim would be prone to any incoming attacks though.



Kind: 2

itr kind: 2 is an augmented weapon-picking interaction. Character must be pressing A key and the itr overlapping with bdy of an object with state 1004 or 2004 to pick a weapon. Character will go to frame 115 if picking state 1004 or frame 116 for state 2004.

Normal punches have itr kind: 2 incorporated in their initial frames, automatically triggering the picking actions.

hit_XX are disabled if a character is holding a heavy weapon via itr kind 2, state: 2 itself doesn't disable hit_XX.

The full list of hit_XX commands:
hit_Fa: -- D>A
hit_Fj: -- D>J
hit_Da: -- DvA
hit_Dj: -- DvJ
hit_Ua: -- D^A
hit_Uj: -- D^J
hit_ja: -- DJA

Kind: 3

itr kind: 3 is an aggressive grab that activates whenever itr collides with bdy of type: 0 character.

It's a stable alternative of itr kind: 1, even usable by uncontrolled objects including projectiles and any weapon, but cannot target anything outside type: 0.


Kind: 4

itr kind: 4 acts as itr kind: 0 only if character is "thrown" into falling frames. Otherwise it will not be counted. Escaping from falling frames resets the flag that enables itr kind: 4.

Escaping include being hit by fire or ice attack, flipping, or unusual means including being caught by an itr kind: 3 with fall: 70.  Anything leads character out of falling frames before dropping to ground will do. Being floated by flute (itr kind: 10) will deactivate itr kind: 4.

When active, itr kind: 4 will hit objects in all teams.



Kind: 5

weapon attacks, implemented by itr kind: 5 is an overloaded itr that activates only if there is a character having a wpoint link with the weapon (simply speaking holding it) and character has attacking parameter equal to 1-4.

The overload progress is as followed:
All itr kind: 5 in a frame is loaded.
attacking parameter determines which set of strength_list should be loaded.
dvx, dvy, fall, vrest, arest, bdefend, injury and effect are read from weapon_strength_list in weapon .dat file

the fall value of active frame of weapon is recorded in another place
itr kind: 5 is treated as itr kind: 0 and takes effect

Apart from some wierd effects by putting weapon with effect: 4 and negative fall,
itr kind: 5 has an unique effect on how it hits an enemy.

I mentioned the fall in active frame is recorded, this value will determine if weapon can hit characters with state: 12 (which is immune to attacks under 41 fall)

The fall in weapon_strength_list is the actual fall value given to victim.

For instance, Sickle has fall: 70 in weapon_strength_list, but fall: 20 in on_hand frame. It will never hit anyone in state: 12, unless fall in itr kind: 5 frames are changed to 70.



Kind: 6

Any character that emits itr kind: 6 does not directly affect other characters, but if other character has an bdy that collides an itr kind: 6 box and is in state 0 or 1, doesn't hold weapon and has next: 0, pressing A will trigger frame 70 (super_punch) instead of 60 or 65.



Kind: 7

Itr kind: 7 is similar to itr kind: 2 except character does not go to picking_light frame, and only light weapons (state 1004) can be picked.



Kind: 8

Itr kind: 8 only triggers when itr box collides with a bdy of type: 0.
It will set "flashing HP" of the victim character by amount of injury (victim heal for that amount over time)
The attacker will teleport to the same x and z-axis position of victim and go to frame indicated by dvx value of itr.

Itr kind: 8 will attack (heal) character of any team.

Flashing HP of itr kind: 8 and state: 1700 won't stack with each other.

An itr kind: 8 with injury NOT 100 HP, regardless of if the amount is less then current flashing HP amount, will set flashing HP value to new amount. If you are trying to use itr kind: 8 with injury: 0 tag to make some triggered moves, this will kill off flashing HP of detected character!

Kind: 9

Itr kind: 9 will cause all type: 3 objects to join attacker's side and make them go frame 30.
This itr when hitting a bdy of type: 0, will deplete all its health (red HP reduced to zero).
STM had test showing that health of object is actually "set" to zero, therefore if an character has negative health hits someone with itr kind: 9, his health is increased although unseen.



Kind: 10

Itr kind: 10 is Flute (Sonata of Death) which puts type: 0characters into a floating state that looks like falling frames but has a consistent damage and dropping ground damage. The exact falling frame is dependent on y-axis velocity of victim.

Weapons also are pushed upwards but do not suffer damage as type: 0 do.

Type: 3 and 5 are immune to this.

In floating state, victim is always facing the front side until victim is no longer pushed by itr kind: 10/11 and is hit from the back.



Kind: 11

Itr kind: 11 is an assisting flute that only takes effect if victim is already in float state.



Kind: 14

Itr kind: 14 is a blocking itr that disallows any object with bdy to move towards the itr area.



Kind: 15

Itr kind: 15 is a wind itr that sucks objects except type: 3 and 5. Character will continue his actions until return to standby state, and system will treat character as in-air and direct him to frame 212.

Weapons will go to on_sky (possibly throwing) frames, but will not further reset frames until it has been hit or drops ground.

If a baseball or drink is already in effect of state: 15, and its itr took effect earlier, its itr will not occur again (precisely the object stays in in_sky frames) until a different itr affects it.



Kind: 16

Itr kind: 16 is a wind itr that sucks weapons and causes a freezing effect to type: 0 without determining bdefend values. There is also no hitlag regarding itr kind: 16.
Reply
Thanks given by: STM1993 , Nyamaiku , A-Man , AmadisLFE , Silverthorn
#2
Radical! Thanks a bunch for researching! Would you mind if I updated the mainsite-pages with your texts accordingly?

» Gallery | » Sprites | » devArt

  [Image: style5,Blue-spc-Phoenix.png]
» Want your project on the Mainsite? Just follow the instructions in this thread!
Reply
Thanks given by:
#3
You can update the info freely.
Reply
Thanks given by:
#4
(09-08-2017, 05:27 PM)rewlf2 Wrote:  You can update the info freely.
Awesome, thanks! States-page is now updated accordingly: http://lf-empire.de/lf2-empire/data-chan...182-states

» Gallery | » Sprites | » devArt

  [Image: style5,Blue-spc-Phoenix.png]
» Want your project on the Mainsite? Just follow the instructions in this thread!
Reply
Thanks given by: STM1993 , A-Man




Users browsing this thread: 1 Guest(s)