Mook - alexneargarder/Broforce-Docs GitHub Wiki
Mook
Table of Contents
- Unity Lifecycle & Setup
- Combat & Damage
- Methods
- Fields
- _mookDamageEffect
- assasinated
- assasinatedFrame
- canBeAssasinated
- catchFriendlyBullets
- decapitated
- decapitationCounter
- disableCatchFriendBulletsCounter
- disemboweled
- disemboweledFrame
- fallDeathThreshold
- firingPlayerNum
- hasCheckPostDeathEvent
- hasDied
- isBeingThrown
- lastThrewMe
- showElectrifiedFrames
- takeExtraFallDamage
- temporarilyCatchFriendBullets
- Position & Physics
- Methods
- AddParentedDiff
- AddSpeedLeft
- AddSpeedRight
- ApplyFallingGravity
- BackSomersault
- CanBeAffectedByWind
- CanPassThroughBarriers
- CheckForQuicksand
- CheckForQuicksandDeath
- ConstrainToFragileBarriers
- ConstrainToMookBarriers
- DisableGravity
- EnableGravity
- FallOnFace
- FlyDownwards
- FlyInDirection
- FlyInstant
- FlyLeft
- FlyRight
- ForceClimbing
- ForceJumpOutOfBike
- GetEnemyMovement
- GetGroundHeightGround
- IsOnGround
- Jump
- Knock
- Land
- Launch
- OpenParachute
- RollOnto
- RunMovement
- SetPosition
- SetPosition
- ThrowMook
- Tumble
- Fields
- Methods
- Animation & Sprite Systems
- Methods
- AnimateActualIdleDuckingFrames
- AnimateActualIdleFrames
- AnimateActualJumpingFrames
- AnimateAssasinated
- AnimateBackSomersault
- AnimateBackSomersaultTumble
- AnimateDeath
- AnimateDecapitated
- AnimateDisemboweled
- AnimateFrontSomersault
- AnimateFrozen
- AnimateIdle
- AnimateJumping
- AnimateRunning
- AnimateTumbling
- FadeInMysteriously
- SetBackFlyingFrame
- SetForwardFlyingFrame
- ShowDeadElectrifiedFrame
- SquirtDecapitatedBlood
- StartFallingScream
- Fields
- Methods
- Character State & Effects
- Status Effects
- Audio System
- Unit Management
- AI Awareness
Unity Lifecycle & Setup
Methods
protected override void AnimateFallen()
Handles fallen/knocked-down animation states. Sets slow frame rate (0.045), deactivates gun, and displays appropriate fallen sprites based on fallenTime. Shows frames 20-25 while falling (max 5 frames), then frames 25-31 for getting up (max 6 frames). Transitions to running state after frame 6 with gun reactivation and friendly-fire flags reset.
protected override void Awake()
Unity lifecycle method that initializes the Mook enemy. Adds a DisableWhenOffCamera component if not present, sets up random z-offset for visual depth, records spawn time, manages initial off-camera disabling, hides the stand-on platform, caches damage effect component, and initializes firing player tracking.
public override void Disable()
Disables the mook and its AI. Stops AI behavior and optionally disables the DisableWhenOffCamera component unless it has forceExtendDisableRangeToThisObject set.
protected override void OnDestroy()
Unity lifecycle cleanup that updates global mook death counters. Decrements the active dead mooks counter if this mook had died, and increments the total dead mooks in scene counter.
public override void Reenable()
Re-enables the mook and its AI after being disabled. Restores AI functionality and enables the DisableWhenOffCamera component if present.
protected override void RunFallen()
Manages fallen state physics and recovery. Decrements fallen timer and resets animation frame when timer expires. Stops horizontal movement if grounded (within 0.5 units of ground height) to prevent sliding while down.
protected override void Start()
Unity lifecycle method that handles Mook initialization after scene load. For non-door-spawning mooks, it attempts ground placement via raycast or ceiling hanging if possible. Sets initial invulnerability states based on spawn conditions and handles parachute positioning for off-screen spawns.
protected override void Update()
Main update loop handling plasma/shock damage timers, catch-friendly-bullets management, burning effects and fire spreading, blind/scared status effects with vocal sounds, falling scream delays, corpse explosion checks, somersault collision detection with units, string-up panic spreading, gravity disable timer, and discharged scream delays.
Combat & Damage
Methods
public override void BurnInternal(int damage, int direction)
Handles internal fire damage processing by accumulating burn damage. If not already burning and able to panic, initiates panic state with 0.4-2 second burn time based on panic success.
Parameters:
- int damage: Amount of burn damage to add
- int direction: Direction for panic behavior
protected virtual void BurnOthers()
Spreads fire to nearby units and blocks when enemies spread fire is enabled. Raycasts horizontally to find flammable targets within range. Part of fire propagation system for chain reaction effects.
public override bool CatchFriendlyBullets()
Determines whether this mook can catch friendly bullets (typically when controlled by a player).
Returns:
bool
: True if the mook can catch friendly bullets, false otherwise
public override void Damage(int damage, DamageType damageType, float xI, float yI, int direction, MonoBehaviour damageSender, float hitX, float hitY)
Processes damage to the mook with special handling for various damage types. Handles chainsaw impaling with disembowel conversion, propane block achievement tracking, plasma/shock damage accumulation with stun effects, fire damage with panic triggering, assassination mechanics for silent kills, tumbling/somersault triggers from high knockback, and depleted uranium explosion effects. Notifies AI of damage source and manages special death states.
Parameters:
- int damage: The amount of damage to apply
- DamageType damageType: The type of damage being dealt
- float xI: The horizontal knockback force
- float yI: The vertical knockback force
- int direction: The direction of the damage source (-1 or 1)
- MonoBehaviour damageSender: The entity that caused the damage
- float hitX: The X coordinate where the damage hit
- float hitY: The Y coordinate where the damage hit
protected virtual void DamageSelfOnMookCollision()
Applies self-damage when colliding with other mooks at high velocity. Deals 4 knock damage with velocity-based knockback forces (3.33x horizontal velocity). Used during tumbling/somersaulting collisions.
public override void Death(float xI, float yI, DamageObject damage)
Triggers immediate death with randomized minimal knockback and default damage. Plays death sound and applies standard death processing.
public override void Death(float xI, float yI, DamageObject damage)
Processes mook death with knockback and damage information. Handles door unregistration, statistics notification, enemy death events, dead mook counter updates, platform adjustments, hero kill attribution, state cleanup for tumbling/somersaulting, and damage effect death processing. Manages demonstration mode invulnerability.
Parameters:
- float xI: The horizontal knockback force applied on death
- float yI: The vertical knockback force applied on death
- DamageObject damage: The damage object containing information about what killed the mook
public override void DischargePilotingUnit(float x, float y, float xI, float yI, bool stunUnit)
Ejects the mook from a vehicle or mech, killing the mook in the process. Initiates a back somersault animation and sets up a delayed scream effect.
Parameters:
- float x: The X position to discharge the unit at
- float y: The Y position to discharge the unit at
- float xI: The horizontal velocity to apply
- float yI: The vertical velocity to apply
- bool stunUnit: Whether to stun the unit (not used in Mook implementation)
public void ExplodeCorpse()
Causes the mook's corpse to explode violently, dealing area damage. Creates a medium explosion effect, damages nearby units and terrain, and applies burn effects in the area.
protected override void FallDamage(float yI)
Applies fall damage when vertical impact exceeds threshold. Deals 5 base damage (plus max health if extra fall damage enabled), triggers face-fall animation for survivors, and credits kills to the last throwing character. Updates fall death threshold after first impact.
Parameters:
- float yI: The vertical impact velocity (negative values indicate falling)
protected override void FireWeapon(float x, float y, float xSpeed, float ySpeed)
Fires the mook's weapon projectile with muzzle flash effect. Sets gun animation frame, updates gun sprite, creates muzzle flash at specified position, spawns projectile, and plays attack sound.
Parameters:
- float x: The X position to spawn the projectile
- float y: The Y position to spawn the projectile
- float xSpeed: The horizontal velocity of the projectile
- float ySpeed: The vertical velocity of the projectile
public void Gib()
Destroys the mook with gibbing effects and handles death notifications. Manages kill attribution, statistics, and door cleanup on gibbing. Ensures proper credit for kills and special kill types.
Parameters:
- DamageType damageType: Type of damage that caused gibbing.
- float xI: Horizontal force for gib physics.
- float yI: Vertical force for gib physics.
public void Gib()
Gibs the mook with default parameters and no specific force. Convenience method for simple gib calls without physics. Uses normal damage type with zero velocity.
protected override void NotifyDeathType()
Reports the death type to statistics system for tracking. Ensures death type is only reported once per mook. Part of the game's death tracking and achievement system.
public override bool Revive(int playerNum, bool isUnderPlayerControl, TestVanDammeAnim reviveSource)
Revives the mook as a zombie under player control. Resets status effects, disables AI, and slightly randomizes movement speed.
Parameters:
- int playerNum: The player number taking control of the revived mook
- bool isUnderPlayerControl: Whether the mook is under direct player control
- TestVanDammeAnim reviveSource: The unit that revived this mook
Returns:
bool
: True if the mook was successfully revived (requires canBeRevived to be true), false otherwise
protected override void Unrevive()
Reverses revival effects and resets the mook to uncontrolled state. Clears player ownership when revival is cancelled or expires. Returns the mook to standard enemy configuration.
protected override void UseFire()
Handles the mook's attack action when visible and not incapacitated. Fires weapon with speed modifiers for demonstration mode, adds slight vertical spread, and disturbs nearby wildlife. Calculates firing position based on facing direction.
Fields
private MookDamageEffect _mookDamageEffect
Component handling visual damage effects for this mook. Retrieved via GetComponent during initialization and used to propagate damage, death, and gib events for visual feedback.
protected bool assasinated
Protected flag indicating mook is playing assassination death animation. Set to true when killed by assassination attack. Triggers special AnimateAssasinated() behavior. Cleared if mook gains velocity (knocked away) during assassination animation.
public int assasinatedFrame
Specifies which sprite frame to display during assassination death animation. Used when mook is killed by assassination (assasinated = true) to show special death pose. Different mook types can have unique assassination death frames.
public bool canBeAssasinated
Determines if this mook type can be killed by assassination attacks. When true, allows special assassination death animations using assasinatedFrame. Affects how stealth kills and backstab attacks are processed.
protected bool catchFriendlyBullets
Base flag indicating whether this mook can catch friendly bullets. Unlike temporarilyCatchFriendBullets, this represents a permanent ability rather than a temporary state.
protected bool decapitated
Indicates whether this mook has been decapitated. Affects death animations, assassination eligibility, and prevents certain visual effects like face huggers from appearing.
protected float decapitationCounter
Timer tracking time since decapitation. Used to trigger delayed effects like death gargles after 0.3 seconds have passed since decapitation occurred.
protected float disableCatchFriendBulletsCounter
Cooldown timer that prevents catching friendly bullets. When greater than 0, the mook cannot catch bullets even if other flags allow it. Decremented each frame.
protected bool disemboweled
Protected flag indicating mook is playing disemboweled death animation. Set to true for violent deaths. Triggers special animation state showing disemboweledFrame. Cleared if mook gains velocity during animation, transitioning to normal death physics.
public int disemboweledFrame
Specifies which sprite frame to display when mook is disemboweled. Used for gruesome death animations when mook is killed by particularly violent attacks. Works with disemboweled flag to show special death state.
private float fallDeathThreshold = -350f
Velocity threshold for instant death from falling. When vertical velocity (yI) falls below this value (-350f default), the mook takes fatal damage. Temporarily lowered to -430f when hiding.
public int firingPlayerNum = -1
Player number used when this mook fires projectiles. Set to the mook's playerNum during setup and special attacks. Default is -1, typically set to 5 for enemy projectiles.
private bool hasCheckPostDeathEvent
Flag tracking whether the post-death event check has been performed. Used to trigger corpse explosions 1.33 seconds after death based on random chance.
protected bool hasDied
Protected flag preventing multiple death processing. Set to true in Die() and DieAtEndOfFrame() to ensure death logic only runs once. Checked at start of death methods to prevent duplicate death effects, gibbing, or score updates.
public bool isBeingThrown
Flag indicating the mook is currently being thrown by a player. Set to true when thrown, enables temporary bullet catching and tracks the throwing player.
public TestVanDammeAnim lastThrewMe
Tracks the character (TestVanDammeAnim) that last threw this mook. Used for attributing kills when the mook dies from falling damage after being thrown.
public bool showElectrifiedFrames
Determines if this mook type displays special electrocution animations. When true and mook has plasmaDamage or shockCounter > 0, shows electricity visual effects. Used to differentiate mooks that visually react to electrical damage from those that don't.
public bool takeExtraFallDamage
When true, this mook takes additional fall damage equal to their max health. Used for certain enemy types that are particularly vulnerable to falling damage.
protected bool temporarilyCatchFriendBullets
When true, this mook will catch friendly bullets temporarily during special states. Used during somersaults and specific animations to prevent friendly fire damage. Automatically disabled after use.
Position & Physics
Methods
protected override void AddParentedDiff(float xDiff, float yDiff)
Adds positional differences from parent movement with special handling for falling blocks. When alive and parented to a falling block with downward parent movement, triggers a mid-air shake effect, adds upward velocity, stops horizontal movement, and initiates tumbling to simulate being knocked off the falling platform.
Parameters:
- float xDiff: The horizontal position difference to apply.
- float yDiff: The vertical position difference to apply (modified for falling blocks).
protected override void AddSpeedLeft()
Adds leftward movement speed with reduced control during parachute/quicksand states. Movement is disabled while tumbling or back-somersaulting. Parachute and quicksand cap horizontal speed at 40% of maximum.
protected override void AddSpeedRight()
Adds rightward movement speed with reduced control during parachute/quicksand states. Movement is disabled while tumbling or back-somersaulting. Parachute and quicksand cap horizontal speed at 40% of maximum.
protected override void ApplyFallingGravity()
Applies gravity with special conditions for quicksand and disabled gravity. Handles mid-air shake time that temporarily prevents gravity when units are knocked off falling platforms.
public override void BackSomersault(bool forceTumble)
Initiates back-somersault state if capable. Cancels front-somersault and tumbling, enables back tumbling for forced tumbles or high vertical velocity, and resets animation frames.
Parameters:
- bool forceTumble: Forces the mook into tumbling state during somersault
protected override bool CanBeAffectedByWind()
Determines if the mook can be affected by wind forces. Prevents wind effects when hiding in grass for stealth. Maintains concealment by ignoring environmental forces.
Returns:
bool
: True if wind can affect the mook, false when hiding.
protected virtual bool CanPassThroughBarriers()
Determines if the mook can pass through fragile barriers based on specific conditions. Returns true when dead, blast jumping with sufficient horizontal velocity, blinded, scared, or when the AI is alerted. Used by movement constraint methods to allow panic-driven units to break through barriers.
Returns:
bool
: True if the mook should be allowed to pass through barriers, false otherwise.
protected override void CheckForQuicksand()
Checks if the mook is in quicksand and handles state transitions. When entering quicksand or while blind/not panicking in quicksand, stops special movements, triggers panic, and activates standing platform if available.
protected override void CheckForQuicksandDeath()
Checks if the mook should die from being in quicksand. Mooks die after 0.5 seconds in quicksand (compared to 2 seconds for bros).
protected override void ConstrainToFragileBarriers(ref float xIT, float radius)
Constrains movement against fragile barriers unless the mook can pass through them. When constrained, performs raycasts at waist height to detect barriers and stops horizontal movement upon collision. Allows passage when panicking, blind, scared, or alert.
Parameters:
- out float xIT: Reference to horizontal movement delta that will be constrained.
- float radius: Collision radius for barrier detection.
protected override void ConstrainToMookBarriers(ref float xIT, float radius)
Constrains movement against mook-specific barriers only when burning or blind. Under normal conditions, mooks can pass through their own barriers, but status effects cause them to collide with these obstacles.
Parameters:
- out float xIT: Reference to horizontal movement delta that will be constrained.
- float radius: Collision radius for barrier detection.
public void DisableGravity(float time)
Temporarily disables gravity for the mook for a specified duration. Used by special abilities or environmental effects that need to suspend normal physics.
Parameters:
- float time: Duration in seconds to disable gravity.
public void EnableGravity()
Immediately re-enables gravity by resetting the disable timer to zero. Restores normal physics behavior after temporary suspension.
protected virtual void FallOnFace()
Makes the mook fall face-first and become temporarily incapacitated. Sets fallen state with recovery time and appropriate animations. Used for comedic or stunning face-plant landings.
public virtual void FlyDownwards(float time)
Virtual method for downward flying behavior. Base implementation is empty, meant to be overridden by flying enemy types.
Parameters:
- float time: The duration of the flying behavior
public virtual void FlyInDirection(float time, Vector3 forceFlyingVelocity)
Virtual method for directional flying behavior. Base implementation is empty, meant to be overridden by flying enemy types.
Parameters:
- float time: The duration of the flying behavior
- Vector3 forceFlyingVelocity: The velocity vector for the flying direction
public virtual void FlyInstant(float time)
Virtual method for instant flying behavior. Base implementation is empty, meant to be overridden by flying enemy types.
Parameters:
- float time: The duration of the flying behavior
public virtual void FlyLeft(float time)
Virtual method for leftward flying behavior. Base implementation is empty, meant to be overridden by flying enemy types.
Parameters:
- float time: The duration of the flying behavior
public virtual void FlyRight(float time)
Virtual method for rightward flying behavior. Base implementation is empty, meant to be overridden by flying enemy types.
Parameters:
- float time: The duration of the flying behavior
public virtual void ForceClimbing(bool leftClimb, bool rightClimb, bool topClimb)
Virtual method to force the mook into a climbing state. Base implementation is empty, meant to be overridden by climbing-capable enemy types.
Parameters:
- bool leftClimb: Whether the mook should climb on the left side
- bool rightClimb: Whether the mook should climb on the right side
- bool topClimb: Whether the mook should climb on top
public void ForceJumpOutOfBike()
Forces the mook to jump out of a vehicle with increased force. Clears AI actions and adds a wait period after ejection. Used when mooks are ejected from destroyed vehicles.
protected override void GetEnemyMovement()
Overrides enemy movement behavior to handle special movement states. Bypasses normal movement when exiting doors, back somersaulting, back tumbling, or fallen. During door exits, moves the mook toward the exit position until reached.
public override float GetGroundHeightGround()
Calculates ground height using multiple raycasts for mook movement. Uses special ground checking when panicking, burning, blind, scared, or exiting doors with offset raycasts based on movement direction. Falls back to normal ground check for standard states.
Returns:
float
: The Y coordinate of the ground below the mook
public override bool IsOnGround()
Checks if the mook is standing on ground, excluding back somersaulting state. Prevents ground-based behaviors during acrobatic maneuvers by returning false when performing a back somersault regardless of actual ground contact.
Returns:
bool
: True if on ground and not back somersaulting, false otherwise.
protected override void Jump(bool wallJump)
Initiates a jump action with special handling for animation states. Extends base jump functionality to reset reveal animations. Ensures proper state transitions when leaving ground.
Parameters:
- bool wallJump: Whether this is a wall jump.
public override void Knock(DamageType damageType, float xI, float yI, bool forceTumble)
Applies knockback force with potential tumbling based on impact strength. Extends base knockback to add tumbling for strong upward forces. Determines if the mook should enter tumbling state from the impact.
Parameters:
- DamageType damageType: The type of damage causing knockback.
- float xI: Horizontal knockback force.
- float yI: Vertical knockback force.
- bool forceTumble: Whether to force tumbling regardless of force.
protected override void Land()
Handles landing mechanics including damage, bouncing, and state transitions. Complex landing logic for different movement states and impact forces. Manages sound effects, particle effects, and AI state updates.
public virtual void Launch(float xI, float yI)
Launches the mook with specified velocities, setting it into a tumbling state. Clears AI action queue and makes the AI wait before resuming normal behavior.
Parameters:
- float xI: The horizontal launch velocity
- float yI: The vertical launch velocity
public override void OpenParachute()
Activates the parachute if not already deployed. Simply sets the IsParachuteActive flag which triggers parachute physics and animation.
public override void RollOnto(int direction)
Handles being rolled onto by boulders or heavy objects. Knocks the mook away if space available, otherwise crushes them. Determines survival based on adjacent terrain.
Parameters:
- int direction: Direction of the rolling object (-1 left, 1 right).
protected override void RunMovement()
Executes physics-based movement with high-velocity wall impact detection. If moving faster than 300 units/second and hits a wall, triggers wall damage (15 crush damage in 20 unit radius), self-damage (4 knock damage), damage sound, and initiates back somersault. Calls base movement implementation.
public override void SetPosition()
Sets the mook's position with special handling for door-exiting state. Door-exiting mooks use rounded coordinates and fixed Z position of 14, while normal mooks use standard positioning.
Parameters:
- Vector3 pos: The new position vector to set
public override void SetPosition()
Updates the mook's transform position based on current X/Y coordinates. Door-exiting mooks use rounded positions with fixed Z of 14 plus z-offset, while normal mooks use standard transform updates.
public virtual void ThrowMook(bool thrownByBrommando, int throwingPlayerNum)
Handles the mook being thrown by a player character. Clears string-up and dancing states, initiates back-somersault, enables friendly fire catching temporarily, tracks the throwing player, and reduces plasma counter for faster detonation.
Parameters:
- bool thrownByBrommando: Whether the mook was thrown by Brommando (unused)
- int throwingPlayerNum: The player number who threw this mook
public override void Tumble()
Initiates tumbling state if the mook can tumble and isn't already back-somersaulting. Sets tumbling flags for animation and movement handling.
Fields
protected bool alwaysStandOnPlatformLayer
Forces this mook to always stand on platform layer blocks. Set to true during setup when the mook is positioned on a platform layer block, ensuring they maintain proper collision with platforms.
protected int backSomersaultFrames
Protected counter tracking the animation frames during backward tumbling. Reset to 0 when initiating backward tumbling in BackSomersault() or when bouncing with canBackwardTumble. Used internally for animation timing.
public bool backSomersaulting
Indicates whether the mook is currently performing a backward somersault. Set to true by BackSomersault() when canBackSomersault is true. Affects movement physics, animation state, and AI behavior. Prevents other actions while active and is cleared when landing or dying.
protected bool backTumbling
Protected flag indicating the mook is performing a continuous backward tumbling motion. Set to true when backSomersaulting with sufficient force (forceTumble or yI
200f) and canBackwardTumble is true. Affects AI state and prevents actions while tumbling. Reset when landing or transitioning states.
public bool canBackSomersault
Determines if this mook type can perform backward somersaults. When true, enables BackSomersault() behavior including flipping animations and altered physics. Used to differentiate mook capabilities between types.
public bool canBackwardTumble
Determines if this mook can perform continuous backward tumbling when knocked back with force. When true and mook is knocked back hard enough (forceTumble or yI > 200f), sets backTumbling flag for extended tumbling animation. Also affects bouncing behavior when isBouncy is true.
public bool canForwardSomersault
Determines if this mook type can perform forward somersaults. Currently not actively used in code but mirrors canBackSomersault for potential forward flipping animations and movement behaviors.
public bool canHideInGrass
Determines if this mook type can hide in grass terrain. Currently unused in code but likely intended for stealth mechanics where certain mook types could conceal themselves in grass tiles.
public bool canLandOnFace
Determines if this mook type can land face-down when falling. When true and mook hits ground while falling, calls FallOnFace() instead of normal landing recovery. When false, mook bounces up slightly (yI = 80f) and continues normally.
public bool canTumble
Determines if this mook type can perform forward tumbling movements. When true, enables tumbling behavior when knocked with sufficient vertical force (yI > 200f) or when Tumble() is called. Used to differentiate mook types that can tumble from those that cannot.
protected float disableGravityTime
Time remaining to disable gravity for this mook. While greater than 0, gravity is not applied, allowing for suspension effects. Decremented each frame during movement calculations.
protected float fallenTime
Protected timer for how long the mook remains in fallen state. Set to 1f when FallDamage() is called. Decrements each frame and when reaching 0, likely triggers recovery animations or state changes. Prevents actions while greater than 0.
public bool frontSomersaulting
Indicates whether the mook is currently performing a forward somersault. Cleared when BackSomersault() is called. Used by animation system to play appropriate somersault animations and affects movement physics during the somersault motion.
protected bool hasTumbled
Protected flag set to true when Tumble() successfully initiates a tumbling state. Tracks whether the mook has entered tumbling at least once, potentially for achievement tracking or special behavior triggers.
public bool isBouncy
Makes the mook bounce when hitting ground with sufficient downward velocity (yI < -210f). When true, reverses and dampens vertical velocity (yI = 50f - yI * 0.3f) and reduces horizontal velocity by 10%. Can trigger backward tumbling if canBackwardTumble is true and horizontal speed exceeds 90f.
protected float midAirShakeTime
Timer for mid-air screen shake effects. When greater than 0, causes screen shake while the mook is airborne. Decremented each frame and typically set to 0.02f during forceful launches.
private Collider standOnMookPlatform
Collider component that creates a platform other units can stand on when this mook enters certain states. Disabled during initialization, enabled when mook is in quicksand, and lowered by 4 units when mook dies.
public bool tumbling
Indicates whether the mook is currently in a forward tumbling state. Set to true when Tumble() is called and canTumble is true. Used by animation system to play tumbling animations. Cleared when landing, dying, or transitioning to other movement states like backSomersaulting.
Animation & Sprite Systems
Methods
public override void AnimateActualIdleDuckingFrames()
Handles ducking idle animations including reveal and hiding states. Shows special animations when emerging from or hiding in grass. Manages the transition between hidden and revealed states.
public override void AnimateActualIdleFrames()
Animates specific idle frames including special states like choking. Handles tear gas choking animation when stunned by gas effects. Provides visual feedback for status ailments during idle.
protected override void AnimateActualJumpingFrames()
Handles frame animation selection during jumping states. Determines which animation to play based on current movement state. Prioritizes special states like tumbling and somersaulting over normal jumps.
protected virtual void AnimateAssasinated()
Animates the assassination death sequence when killed by stealth attacks. Shows a special death animation with blood effects at specific frames. Continues until all 15 frames are displayed or movement disrupts the animation.
protected void AnimateBackSomersault()
Manages back somersault death animation with tumbling variant. Deactivates weapon, increments somersault frame counter, and either shows directional back flying frames with rotation based on velocity (0.0225 frame rate) or delegates to tumbling animation when back tumbling flag is set.
protected virtual void AnimateBackSomersaultTumble()
Displays rapid tumbling animation during back somersault. Shows frames 9-18 from sprite row 6 with fast frame rate (0.0225) to create spinning effect during uncontrolled backward tumbling motion.
protected override void AnimateDeath()
Complex death animation dispatcher handling multiple death types with velocity thresholds. Priority order: disemboweled (requires low velocity), assassinated (requires low velocity), tumbling, back somersault, front somersault, electrified (plasma/shock damage), then standard death. High velocity cancels special death animations in favor of physics-based animations.
protected virtual void AnimateDecapitated()
Handles decapitation animation showing blood spurting from neck. Deactivates weapon, sets frame rate to 0.044455, displays frames 21-28 on row 32. Triggers death gargle sound after 0.3 seconds (with impossible random check) or bleed sounds, and creates blood particles every 4 frames.
protected virtual void AnimateDisemboweled()
Animates the disembowelment death sequence with gore effects. Similar to assassination but with different timing and 16 total frames. Creates dramatic blood effects during the animation sequence.
protected void AnimateFrontSomersault()
Handles front somersault death animation. Deactivates weapon and displays forward flying frames with rotation based on velocity vector using 0.0225 frame rate. Part of the physics-based death animation system.
protected override void AnimateFrozen()
Shows frozen statue animation when affected by freeze effects. Deactivates weapon, sets frame rate to 0.16, and displays one of three frozen poses (determined at freeze start) with 0-2 frame animation from the frozen sprite sheet position. Uses serialized frozenSpriteSheetFrame coordinates (default 15,13) for sprite location.
protected override void AnimateIdle()
Manages idle animation states including special effect overlays. Checks for electrified states before falling back to normal idle. Handles visual feedback for status effects during idle stance.
protected override void AnimateJumping()
Handles jumping animation with special cases for decapitation, parachutes, and quicksand. Decapitated units use decapitation animation, while units with active parachutes or in quicksand show running animation if affected by status effects (burning/blind/scared) or idle animation otherwise. Falls back to base jumping animation for normal jumps.
protected override void AnimateRunning()
Manages running animation with priority for decapitation and panic states. Decapitated units always show decapitation animation. Units that are burning, blind, or scared display panic running animation using frames 21-28 with faster frame rate (0.044455) and deactivated weapons. Normal running uses base animation.
protected void AnimateTumbling()
Animates the tumbling motion when knocked with significant force. Shows rotating frames to simulate uncontrolled tumbling through the air. Used during knockback when tumbling state is active.
public virtual void FadeInMysteriously()
Virtual method for mysterious fade-in effects. Base implementation is empty, meant to be overridden for special enemy entrance effects.
public virtual void SetBackFlyingFrame(float xF, float yF)
Sets the sprite frame for backwards flying animations based on velocity direction. Calculates the appropriate frame based on the angle of movement and adjusts sprite facing. Used during knockback and thrown animations to display directional flying sprites.
Parameters:
- float xF: The horizontal force/velocity affecting the unit.
- float yF: The vertical force/velocity affecting the unit.
public virtual void SetForwardFlyingFrame(float xF, float yF)
Sets the sprite frame for forward flying animations based on velocity direction. Similar to SetBackFlyingFrame but uses forward-facing sprites on row 12. Used for forward knockback and thrown animations.
Parameters:
- float xF: The horizontal force/velocity affecting the unit.
- float yF: The vertical force/velocity affecting the unit.
protected virtual void ShowDeadElectrifiedFrame()
Displays electrocution death animation frames. Increments plasma frame counter, deactivates weapon, sets fast frame rate (0.033). Shows airborne electrocution sprite (frames 15-16) when above ground or grounded electrocution sprite (frames 17-18) when on ground, both from sprite row 4.
protected virtual void SquirtDecapitatedBlood()
Creates blood particle effects from decapitated neck area. Spawns 3 red blood particles at neck height (Y + 12) with upward velocity bias (130 units/s) and inherits 20% of horizontal and 50% of vertical mook velocity for realistic blood physics.
public virtual void StartFallingScream()
Initiates a delayed scream when the mook starts falling. Sets a 0.03 second delay before the falling scream sound plays.
Fields
protected bool animatingRevealPosition
Indicates the mook is playing a reveal animation when emerging from hiding. During this animation, special frame sequences play and the gun is deactivated. Animation completes at frame 15.
public FlickerFader[] flames
Array of flame visual effects that can be spawned when this mook is on fire. Randomly selected from this array when creating burning effects at the mook's position.
protected int frozenPose
Randomly selected pose (0-2) used when displaying frozen animation. Combined with frozenSpriteSheetFrame to determine the specific sprite to display while frozen.
private Vector2Int frozenSpriteSheetFrame = new Vector2Int(15, 13)
Base sprite sheet coordinates (15, 13) for frozen animation frames. Combined with frozenPose to calculate the final sprite position: x + frozenPose * 3 + frame for horizontal offset.
protected float lastHidingTime
Timestamp of when this mook was last hiding in grass or cover. Used to determine eligibility for forward somersaults (disabled if hidden within last 2 seconds) and updated during hide animations.
protected float strungUpCounter
Animation counter for when the mook is strung up or hanging. Incremented by deltaTime and triggers periodic effects every 0.2 seconds (resets by subtracting 0.5 when threshold reached).
Character State & Effects
Methods
public bool CanAddToStatistics()
Determines if this mook should be counted in game statistics. Always returns true for standard mooks, allowing kill tracking and scoring.
Returns:
bool
: True indicating this mook counts for statistics
public virtual bool CanSpeak()
Checks if the mook can currently produce vocal sounds. Returns false during back-somersault or fallen states, otherwise allows speech and sound effects.
Returns:
bool
: True if the mook can speak/vocalize
public override void Freeze(float time)
Applies freeze status effect with random pose selection. Initializes a random frozen pose (0-2), resets animation frame and counter, sets frame rate to 0.16, then delegates to base freeze implementation for material effects and immobilization.
Parameters:
- float time: Duration in seconds to remain frozen.
public override MookType GetMookType()
Returns the specific type of this mook for identification. Used by game systems to determine mook-specific behaviors. Part of the enemy type identification system.
Returns:
MookType
: The MookType enum value for this mook variant.
public virtual void GrowFromChestBurster()
Virtual method for growing from a chest burster alien. Base implementation is empty, meant to be overridden by appropriate enemy types.
public override bool IsDecapitated()
Checks if the mook has been decapitated. Used by animation and behavior systems to handle special decapitation states and prevent certain actions.
Returns:
bool
: True if the mook is decapitated, false otherwise.
private bool IsHidingInGrass()
Checks if the mook is currently hiding in grass terrain. Queries AI state to determine concealment status. Used for stealth mechanics and animation selection.
Returns:
bool
: True if AI mental state is Hiding, false otherwise.
public virtual void StartEatingCorpse()
Initiates corpse eating behavior for applicable mook types. Virtual method for zombie-type mooks to override with eating logic. Base implementation does nothing as most mooks don't eat corpses.
protected virtual bool UseNormalGroundCheck()
Determines whether to use standard ground detection. Returns false when panicking, burning, blind, scared, or exiting doors - these states use special offset ground checking for erratic movement.
Returns:
bool
: True if normal ground checking should be used
Properties
public override bool IsParachuteActive { get; set; }
Gets or sets the parachute active state. When activated, cancels tumbling and somersaulting states and reduces horizontal velocity by 40% to simulate air resistance.
public bool IsStunned { get; set; }
Gets whether the mook is currently stunned. A mook is considered stunned when the stun timer is greater than zero, preventing normal actions and movement.
Fields
public bool canBeRevived
Indicates whether this mook can be revived after death. Checked during revival attempts to determine if resurrection mechanics should apply to this enemy type.
public bool canWilhelm
Determines if this mook can perform a Wilhelm scream. Set to false when taking certain damage types to prevent the iconic scream sound effect from playing.
public MookType mookType
The type classification of this mook, used to identify different enemy variants and their behaviors.
Status Effects
Methods
public override void Blind()
Blinds the mook for specified duration, disorienting movement and combat. Updates blind timer to maximum of current and new duration, triggers AI blindness, sets firing player to 5 (invalid), and calculates stun vocal delay.
Parameters:
- float time: Blind duration in seconds
public override void Blind()
Applies permanent 9-second blindness effect. Triggers AI blind state, invalidates firing target (sets to player 5), and applies the effect only if alive.
public override bool Inseminate(AlienFaceHugger unit, float xForce, float yForce)
Handles alien face hugger insemination. Triggers panic in the direction the mook is facing for 5 seconds.
Parameters:
- AlienFaceHugger unit: The alien face hugger performing the insemination
- float xForce: The horizontal force applied
- float yForce: The vertical force applied
Returns:
bool
: The result from the base insemination handling
public override bool IsBlind()
Checks if the mook is currently affected by blindness status effect.
Returns:
bool
: True if blind time is greater than 0
public override void Panic(int direction, float time, bool forgetPlayer)
Initiates panic state if not restrained or tumbling and not frozen. Attempts to trigger AI panic behavior and sets minimum 0.1 second blind time to ensure visual feedback even if panic fails.
Parameters:
- bool forgetPlayer: Whether to forget current player target during panic
public override void Panic(int direction, float time, bool forgetPlayer)
Initiates timed panic state if not restrained or tumbling and not frozen. Attempts AI panic and sets blind time to maximum of current blind time or specified duration for extended disorientation.
Parameters:
- float time: Duration of panic/blind effect in seconds
- bool forgetPlayer: Whether to forget current player target
public override void Panic(int direction, float time, bool forgetPlayer)
Initiates directional timed panic if not restrained or tumbling and not frozen. Only triggers AI panic if alive and not already blind, with direction controlling flee direction. Always applies blind duration.
Parameters:
- int direction: Panic flee direction (-1 left, 0 random, 1 right)
- float time: Duration of panic/blind effect in seconds
- bool forgetPlayer: Whether to forget current player target
protected virtual bool PanicAI(int direction, bool forgetPlayer)
Attempts to trigger AI panic state using current walk direction if alive, not tumbling/somersaulting, has AI controller, and not frozen. Returns true if panic was successfully initiated.
Parameters:
- bool forgetPlayer: Whether AI should forget player target
Returns:
bool
: True if panic state was successfully triggered
protected virtual bool PanicAI(int direction, bool forgetPlayer)
Attempts to trigger AI panic in specific direction if alive, not tumbling/somersaulting, has AI controller, and not frozen. Returns success state of panic initiation.
Parameters:
- int direction: Direction to panic (-1 left, 1 right)
- bool forgetPlayer: Whether AI should forget player target
Returns:
bool
: True if panic was successfully triggered
protected virtual void RunBurning()
Updates the burning status effect timer, applying double time reduction when alive. Automatically calls StopBurning when the burn duration expires. Part of the fire damage over time system.
protected virtual void StopBeingBlind()
Ends the blind status effect and restores normal AI behavior. Notifies the enemy AI to stop blind movement patterns, updates animation frame, stops movement, and sets the firing player number to own player number for targeting purposes.
protected override void StopBeingStunned()
Ends the stunned state for the mook. Clears tear gas choking effect and notifies the AI to stop being blind.
protected virtual void StopBurning()
Terminates the burning status effect and applies final burn damage. Notifies AI to stop panicking, resets to idle state, updates animation, and deals either full burn damage or reduced damage (1) if impaled. Uses fizzle damage type for the final damage application.
public override void Stun(float time)
Stuns the mook for specified duration, preventing all actions. Stops movement immediately and calculates vocal delay (0.2-0.7 seconds) for stun sound effects based on stun duration.
Parameters:
- float time: Stun duration in seconds
public override void TearGas(float time)
Applies tear gas effect if mook can be affected by gas. Stops movement, applies stun for specified time with choking flag, and blinds AI for additional 0.5 seconds beyond stun duration.
Parameters:
- float time: Duration of tear gas effect in seconds
public override void Terrify()
Applies a 1-second fear effect that makes the mook cower in place. Sets scaredTime which affects movement and combat behavior.
Fields
public float blindTime
The remaining time in seconds that the mook is blinded. Affects AI behavior and movement capabilities.
public bool canBeSetOnFire = true
Determines if this mook can be ignited by fire damage. When true and mook takes fire damage while alive, applies burn damage over time up to 5x the mook's health.
public bool canBeTearGased
Determines if this mook type is affected by tear gas attacks. When true, TearGas() method will apply stun effect, set tearGasChoking flag, and blind the mook. When false, mook is immune to tear gas effects.
protected float fireSpreadCounter
Protected counter that accumulates time while mook is burning. Increments by deltaTime each frame while on fire. When exceeds fireSpreadRate, triggers BurnOthers() to spread fire to nearby units and resets by subtracting fireSpreadRate. Controls fire propagation timing.
protected float fireSpreadRate = 0.067f
Protected rate at which burning mook spreads fire to others. Default value 0.067f means BurnOthers() is called approximately 15 times per second (1/0.067). Lower values spread fire faster, higher values slower. Works with fireSpreadCounter to control fire propagation timing.
public bool immuneToPlasmaShock
Makes this mook immune to plasma shock stun effects. When true, plasma damage still applies but the mook won't be stunned or stopped by electric/plasma attacks.
protected int plasmaFrame
Animation frame counter for plasma damage effects. Incremented during plasma damage animations and used to alternate between shock animation frames (frame % 2).
protected float scaredTime
The remaining time in seconds that the mook is scared. Affects AI decision-making and combat behavior.
protected bool tearGasChoking
Protected flag indicating mook is currently choking from tear gas. Set to true by TearGas() when canBeTearGased is true. Affects animation states when combined with stunTime > 0. Cleared by Die() method when mook is killed.
public bool willPanicWhenOnFire = true
Controls whether the mook enters panic state when taking fire damage. When true, triggers PanicAI behavior causing the mook to run away from the damage source.
Audio System
Methods
protected override void PlayDeathGargleSound()
Plays death gargling sound effect at 35% volume. Uses sound holder's death gargle sounds at the mook's position with standard pitch. Sets flag to prevent repeated playback of the death gargle sound.
public override void PlayPanicSound()
Plays panic vocalization unless the mook is decapitated or has a face hugger attached. Decapitated units and face hugger victims cannot vocalize panic sounds. Delegates to base implementation for actual sound playback when conditions are met.
Fields
private float dischargedScreamDelay
Timer controlling when falling sound plays after being discharged from a vehicle. Set to 0.2f on discharge, counts down each frame, and triggers fallingSoundSource when reaching zero.
protected AudioSource fallingSoundSource
Audio source playing falling/screaming sounds during somersaults and when discharged from vehicles. Pooled for reuse and cleaned up when landing or dying.
protected bool hasPlayedDeathGargle
Flag preventing multiple death gargle sounds from playing. Set to true after PlayDeathGargleSound is called to ensure the sound only plays once during death animation.
protected float somersaultScreamDelay
Timer controlling delayed falling scream during somersaults. Set to 0.03 seconds when starting a somersault or falling. Counts down while airborne with sufficient downward velocity. When reaching zero, triggers fallingSoundSource to play a falling scream sound effect.
Unit Management
Methods
public override bool IsExitingDoor()
Checks if the mook is currently in the process of exiting a door. Used to prevent interruption of spawn animations and movement. Part of the door spawn system for smooth enemy entrances.
Returns:
bool
: True if currently exiting a door, false otherwise.
public void ReachDoor()
Notifies the mook's damage effect component that it has reached a door, typically for visual effects when entering/exiting doors.
public void RegisterFakeDoorExit(float exitDoorX)
Registers a fake door exit position for the mook to walk toward. Sets exit door coordinates, enables door-exiting state, calculates movement direction, and updates position.
Parameters:
- float exitDoorX: The X coordinate of the door to exit toward
public void RegisterOriginDoor(MookDoor mookDoor)
Registers the door that spawned this mook and sets up exit behavior. Handles door positioning offsets, random direction selection for non-sliding doors, ground alignment via raycast, and automatic exit movement setup.
Parameters:
- MookDoor mookDoor: The door object that spawned this mook
public void SetSpawnState(float _xI, float _yI, bool tumble, bool useParachuteDelay, bool useParachute, bool onFire, bool isAlert)
Configures mook spawn state with various initial conditions. Can apply fire damage (3 damage), tumbling state, parachute settings (delayed or immediate), alert state (faces random player), and physics parameters. Enables off-camera components and handles platform layer collision for special spawns.
Parameters:
- float _xI: Initial horizontal velocity
- float _yI: Initial vertical velocity
- bool tumble: Whether to start tumbling
- bool useParachuteDelay: Whether to enable delayed parachute deployment
- bool useParachute: Whether to immediately open parachute
- bool onFire: Whether to spawn on fire (takes damage)
- bool isAlert: Whether to spawn in alert state tracking a player
public void SetSpawnStateJumping(float _xI, float _yI, bool jumping, bool tumble, bool onFire, bool isAlert, bool panicSound, bool laughSound)
Sets spawn state for jumping/ejected mooks with initial velocity and effects. Forces jump from vehicles if jumping, applies brief invulnerability (0.05s), can set on fire (3 damage), tumbling, alert state (tracks random player), and plays panic or laughter sounds. Always disables ground spawning and enables off-camera rendering.
Parameters:
- float _xI: Initial horizontal velocity
- float _yI: Initial vertical velocity
- bool jumping: Whether mook is jumping from vehicle
- bool tumble: Whether to start tumbling
- bool onFire: Whether to spawn burning
- bool isAlert: Whether to spawn alerted to players
- bool panicSound: Whether to play panic vocalization
- bool laughSound: Whether to play laughter sound
Fields
protected float exitDoorDirection
Direction the mook should move when exiting a door (-1 for left, 1 for right). Calculated as the sign of (exitDoorX - mook's X position) when door exit is initiated.
protected float exitDoorX
X-coordinate of the door this mook is exiting through. The mook will move toward this position when exitingDoor is true, and stops exiting once reaching it.
public bool exitingDoor
Indicates this mook is currently exiting through a door. While true, overrides normal movement to guide the mook toward the exit position, affects rendering layer, and disables certain behaviors.
public MookDoor originDoor
Reference to the MookDoor that spawned this mook. Used to notify the door when the mook dies or is destroyed, allowing proper spawn management and cleanup.
protected float spawnTime
Timestamp when this mook was spawned, set to Time.time during initialization. Can be used to track mook age or implement time-based spawn behaviors.
protected bool startOnGround = true
Indicates whether this mook should start on the ground when spawned. Default is true, but set to false for airborne spawns or special entry animations. Affects initial positioning logic.
public DirectionEnum summonToDirection
Direction indicator used by spawning systems (like WarlockPortal) to specify which direction a summoned mook should face or move when spawned.
AI Awareness
Methods
public override void Alert(float alertX, float alertY)
Alerts this mook to a sound at the specified position if it has an AI controller, is alive, and not incapacitated. Passes the alert to the enemy AI's HearSound method for investigation behavior.
Parameters:
- float alertX: X coordinate of the sound source
- float alertY: Y coordinate of the sound source
public override void Attract(float xTarget, float yTarget)
Attracts this mook to a specific position if it has AI, is alive, and not incapacitated. Used for lures and distractions to draw enemies to locations.
Parameters:
- float xTarget: X coordinate of attraction point
- float yTarget: Y coordinate of attraction point
public override void ForgetPlayer(int deadPlayerNum)
Attempts to make the mook forget about a specific player, typically called when that player dies. Delegates to the enemy AI system if available to remove the player from tracking and targeting lists.
Parameters:
- int deadPlayerNum: The player number to forget.
public override void FullyAlert(float x, float y, int playerNum)
Fully alerts this mook to a confirmed enemy presence if it has AI, is alive, and not incapacitated. Sets the AI to maximum alert state with specific player tracking.
Parameters:
- float x: X coordinate of the enemy
- float y: Y coordinate of the enemy
- int playerNum: Player number to track (0-3)
public override void HearSound(float alertX, float alertY)
Makes this mook hear and investigate a sound if it has AI, is alive, and not incapacitated. For unrevealed enemies, automatically faces toward the sound source. Calls the AI's HearSound method for movement behavior.
Parameters:
- float alertX: X coordinate of the sound
- float alertY: Y coordinate of the sound
public virtual void PerformHearSoundAnimation()
Plays an animation when the mook hears a sound while hiding. Resets the frame counter and sets the animatingRevealPosition flag to trigger the reveal animation sequence.