Applies balance effects to player state.
Modifies player stats based on current balance level.
Current player state
Modified player state with balance effects
Applies balance recovery over time.
Balance recovers quickly when not being disrupted, allowing fighters to regain stable footing between exchanges.
Current player state
Time elapsed in milliseconds
Updated player state with recovered balance
Apply stamina cost for recovery animation.
Deducts stamina cost from player state for recovery animations that require stamina (like roll recovery).
Current player state
Type of recovery animation
Updated player state with stamina deducted
Check if player can execute recovery based on stamina.
Some recovery animations (like roll recovery) require stamina. This checks if player has sufficient stamina for the recovery type.
Current player state
Type of recovery animation
True if player has enough stamina
// Roll recovery costs 20 stamina
const canRoll = balanceSystem.canRecoverWithType(player, "roll_recovery");
// Returns: true if player.stamina >= 20
// Normal recoveries have no cost
const canStand = balanceSystem.canRecoverWithType(player, "prone_standup");
// Returns: true (no stamina requirement)
Determines which fall animation to play based on attack and stance.
Calculates fall direction using:
Korean falling techniques (낙법):
Angle of attack in radians (0 = from front)
Attack height: 'high', 'mid', or 'low'
Fall type to use for animation
// Player facing forward (0°), attacked from behind (π)
const fallType = balanceSystem.determineFallType(
player,
Math.PI,
'mid'
);
// Returns: 'forward' (pushed forward by rear attack)
// Low sweep from right side
const fallType = balanceSystem.determineFallType(
player,
Math.PI/2,
'low'
);
// Returns: 'side_right' (swept to the side)
Determines fall type based on player stance when no attack direction available.
Uses stance bias to determine likely fall direction when balance is lost without a specific attack (e.g., from fatigue, leg damage accumulation).
Current trigram stance
Fall type based on stance characteristics
Disrupts balance from combat impact.
Calculates balance loss based on damage amount and body region hit. Leg strikes cause maximum balance disruption.
Current player state
Impact force amount
Optionalregion: BodyRegionBody region affected
Updated player state with reduced balance
Determines balance level from balance value.
Balance value (0-100)
Current balance level
Gets effects for a specific balance level.
Balance level
Effects applied at that level
Get ground state from animation state.
Extracts the ground position type from animation state name. Returns null if not in a ground state.
Current animation state from AnimationStateMachine
Ground state or null if not grounded
Gets color indicator for balance level (for UI).
Balance level
Hex color code
Gets bilingual name for balance level.
Balance level
Korean and English level names
Get damage multiplier during recovery animation.
Some recovery animations (like defensive getup) provide damage reduction. This returns the multiplier to apply to incoming damage.
Type of recovery animation
Current frame in the animation
Damage multiplier (1.0 = normal, 0.5 = 50% reduction)
// Defensive getup has 50% damage reduction
const multiplier = balanceSystem.getRecoveryDamageMultiplier("defensive_getup", 20);
// Returns: 0.5 (50% damage reduction)
// Normal recoveries have no reduction
const normal = balanceSystem.getRecoveryDamageMultiplier("prone_standup", 15);
// Returns: 1.0 (full damage)
Calculates damage multiplier for vulnerable balance state.
Current player state
Damage multiplier (1.0 = normal, >1.0 = increased damage)
Check if player is in a grounded state based on animation state.
Player is considered grounded when in any ground_* animation state (ground_prone, ground_supine, ground_side_left, ground_side_right).
Current animation state from AnimationStateMachine
True if player is on the ground
Checks if player is vulnerable due to balance.
Current player state
True if off-balance or falling
Checks if knockdown should occur, using a provided random function for determinism.
Current player state
Optional random number generator (returns number in [0,1)), defaults to Math.random
True if knockdown should occur
Checks if balance is low enough to trigger fall animation.
Falls occur when balance drops below 20% (FALLING state). This creates realistic knockdown conditions from balance loss.
Current player state
True if fall animation should trigger
Private ReadonlybalanceBalance level effects and thresholds.
Private ReadonlybaseBase balance recovery rate per second.
Private ReadonlymaxMaximum balance value.
Private ReadonlyregionBalance disruption multipliers by body region.
Balance System managing stability and vulnerability.
Balance represents physical stability and center of gravity control. Low balance creates vulnerability windows where opponents can capitalize with increased damage and reduced defensive options.
Example
Korean
균형시스템