Black Trigram (흑괘) - Korean Martial Arts Combat Simulator API - v0.7.0
    Preparing search index...

    Class SpeedModifierSystem

    Speed Modifier System class.

    Korean: 속도 변경 시스템 클래스

    Calculates comprehensive speed modifiers from multiple factors including stance, injuries, stamina, and combat state. Integrates with existing body part and movement systems.

    const system = new SpeedModifierSystem();

    const modifiers = system.calculateSpeedModifiers(
    playerState,
    MovementType.RUNNING,
    true // isCrouching
    );

    // Apply to movement physics
    movementPhysics.setMaxSpeed(modifiers.finalSpeed);
    movementPhysics.setAcceleration(modifiers.finalAcceleration);
    Index

    Constructors

    Methods

    • Apply speed modifiers to movement physics system.

      Korean: 속도 변경 적용 (Apply Speed Modifiers)

      Convenience method to directly apply calculated modifiers to a movement physics instance.

      Parameters

      • movementPhysics: {
            setAcceleration: (accel: number) => void;
            setMaxSpeed: (speed: number) => void;
        }

        Movement physics system to update

      • modifiers: SpeedModifierState

        Calculated speed modifier state

      Returns void

    • Private

      Calculate injury-based speed penalty from leg damage.

      Korean: 부상 속도 패널티 계산 (Calculate Injury Penalty)

      Uses NEW InjuryMovementModifier to determine speed reduction based on leg damage severity, torso damage, and pain levels. NOTE: Stance modifier is calculated separately to maintain compatibility with existing SpeedModifierState interface.

      Penalties are progressive and realistic:

      • Leg injuries: 0-100% penalty based on health
      • Torso injuries: 0-30% minor penalty
      • Both legs injured: Additional 20% cumulative penalty
      • Pain overload: -15% when pain ≥ 80

      Parameters

      • bodyPartHealth: BodyPartHealth | undefined

        Current body part health

      • bodyPartMaxHealth: BodyPartMaxHealth | undefined

        Maximum body part health

      • painLevel: number

        Current pain level (0-100)

      Returns number

      Speed penalty as percentage (0.0 to 0.9 max)

    • Calculate comprehensive speed modifiers for player movement.

      Korean: 속도 변경 계산 (Calculate Speed Modifiers)

      Analyzes player state and returns complete speed modifier information including all individual factors and final calculated values.

      Parameters

      • playerState: PlayerState

        Current player state with stance, health, stamina

      • movementType: MovementType = MovementType.WALKING

        Type of movement being performed

      • isCrouching: boolean = false

        Whether player is in crouching stance

      Returns SpeedModifierState

      Complete speed modifier state with all factors

    • Private

      Calculate stamina-based acceleration penalty.

      Korean: 스태미나 가속 패널티 계산 (Calculate Stamina Penalty)

      Stamina affects acceleration rate, making it harder to change direction or speed up when fatigued:

      • High stamina (70-100%): 0% penalty (normal acceleration)
      • Medium stamina (40-70%): -20% penalty
      • Low stamina (10-40%): -50% penalty
      • Depleted stamina (<10%): -75% penalty, cannot run

      Parameters

      • currentStamina: number

        Current stamina points

      • maxStamina: number

        Maximum stamina capacity

      Returns number

      Acceleration penalty as percentage (0.0 to 0.75)

    • Private

      Check if player can run based on stamina level.

      Korean: 달리기 가능 확인 (Can Player Run)

      Parameters

      • currentStamina: number

        Current stamina points

      • maxStamina: number

        Maximum stamina capacity

      Returns boolean

      True if player has enough stamina to run

    • Private

      Get base speed for movement type.

      Korean: 기본 속도 계산 (Get Base Speed)

      Uses archetype-specific walk/run speeds when available, falls back to default values for backwards compatibility.

      Parameters

      • movementType: MovementType

        Type of movement

      • isCrouching: boolean

        Whether player is crouching

      • OptionalphysicalAttributes: PhysicalAttributes

        Player's physical attributes (optional)

      Returns number

      Base speed in m/s

    • Private

      Calculate combat state speed penalty.

      Korean: 전투 상태 속도 패널티 계산 (Get Combat State Penalty)

      Different combat states restrict movement:

      • IDLE: 0% penalty (full movement)
      • ATTACKING: -30% penalty (committed to technique)
      • DEFENDING: -20% penalty (guard up, limited mobility)
      • STUNNED: -100% penalty (cannot move)
      • RECOVERING: -40% penalty (vulnerable, slow movement)
      • COUNTERING: -25% penalty (counter execution)
      • TRANSITIONING: -15% penalty (stance change)

      Parameters

      Returns number

      Speed penalty as percentage (0.0 to 1.0)

    Properties

    BACKWARD_SPEED_MULTIPLIER: 0.75

    Backward speed multiplier (75% of forward speed)

    Korean: 후퇴 속도 배수 (Backward Speed Multiplier)

    BASE_ACCELERATION: 30 = BASE_MOVEMENT_ACCELERATION

    Base acceleration rate (m/s²) Instant-response acceleration for combat movement (e.g., reaches 6 m/s walking speed in 0.2s; 10 m/s sprint speed in 0.33s) Increased from 12.0 to 30.0 for responsive, arcade-style combat feel

    Imported from physicsConstants.ts to maintain consistency across systems.

    Korean: 기본 가속도 (Base Acceleration)

    BASE_RUNNING_SPEED: 10 = 10.0

    Base running speed (m/s) Sprint speed for rapid repositioning - crosses 14m arena in ~1.4s

    Korean: 기본 달리기 속도 (Base Running Speed)

    BASE_WALKING_SPEED: 6 = 6.0

    Base walking speed (m/s) Standard walking pace for combat movement - crosses 14m arena in ~2.3s

    Korean: 기본 걷기 속도 (Base Walking Speed)

    COMBAT_STATE_PENALTIES: Record<CombatState, number> = ...

    Combat state speed penalty multipliers

    Korean: 전투 상태 속도 패널티 (Combat State Speed Penalties)

    CROUCHING_SPEED: 3 = 3.0

    Crouching movement speed (m/s) Defensive low movement for cautious approach

    Korean: 웅크림 이동 속도 (Crouching Movement Speed)

    LATERAL_SPEED: 5 = 5.0

    Lateral movement speed (m/s) Fast side-stepping for combat positioning

    Korean: 측면 이동 속도 (Lateral Movement Speed)