Twilight Princess
Decompilation of The Legend of Zelda: Twilight Princess
Loading...
Searching...
No Matches
d_a_e_yk.cpp File Reference

Classes

class  daE_YK_HIO_c
 Shadow Keese Host Input Output class. More...
 

Functions

static void yk_disappear (e_yk_class *i_this)
 Makes a Shadow Keese disappear with effects and item drops.
 
static void anm_init (e_yk_class *i_this, int i_resIdx, f32 i_morf, u8 i_attr, f32 i_rate)
 Initializes animation parameters for the Shadow Keese.
 
static int daE_YK_Draw (e_yk_class *i_this)
 Renders the Shadow Keese model with environmental lighting.
 
static void * shot_b_sub (void *i_actor, void *param_1)
 Searches for a charged boomerang that can affect the Shadow Keese.
 
static int other_bg_check (e_yk_class *i_this, fopAc_ac_c *i_actorP)
 Checks for line-of-sight obstruction between Shadow Keese and another actor.
 
static int pl_check (e_yk_class *i_this, f32 i_distance, s16 i_angle)
 Checks if the Shadow Keese should target the player.
 
static void damage_check (e_yk_class *i_this)
 Checks for and handles damage to the Shadow Keese.
 
static int path_check (e_yk_class *i_this)
 Checks visibility and accessibility of path points for Shadow Keese navigation.
 
static void fly_move (e_yk_class *i_this)
 Handles movement calculations for Shadow Keese flight.
 
static void e_yk_roof (e_yk_class *i_this)
 Handles Shadow Keese behavior when perched on ceiling.
 
static void e_yk_fight_fly (e_yk_class *i_this)
 Handles the Shadow Keese's behavior when flying towards the player to engage in combat.
 
static void e_yk_fight (e_yk_class *i_this)
 Handles the Shadow Keese's combat behavior when circling around the player.
 
static void e_yk_attack (e_yk_class *i_this)
 Handles Shadow Keese's attack behavior when targeting the player.
 
static void e_yk_fly (e_yk_class *i_this)
 Handles Shadow Keese's normal flying behavior.
 
static void e_yk_return (e_yk_class *i_this)
 Handles Shadow Keese returning to its home position.
 
static void e_yk_path_fly (e_yk_class *i_this)
 Handles Shadow Keese's path-following behavior.
 
static void e_yk_chance (e_yk_class *i_this)
 Handles Shadow Keese's stunned state after being shield-blocked.
 
static void e_yk_wolfbite (e_yk_class *i_this)
 Handles Shadow Keese's behavior when caught and thrown by Wolf Link.
 
static void e_yk_wind (e_yk_class *i_this)
 Handles Shadow Keese's behavior when caught in boomerang wind.
 
static void action (e_yk_class *i_this)
 Main action handler for Shadow Keese - controls state transitions and updates.
 
static int daE_YK_Execute (e_yk_class *i_this)
 Main execution function for the Shadow Keese actor.
 
static int daE_YK_IsDelete (e_yk_class *param_0)
 Checks if the Shadow Keese actor should be deleted.
 
static int daE_YK_Delete (e_yk_class *i_this)
 Handles cleanup when Shadow Keese actor is deleted.
 
static int useHeapInit (fopAc_ac_c *i_this)
 Initializes heap resources for Shadow Keese actor.
 
static int daE_YK_Create (fopAc_ac_c *i_this)
 Creates and initializes a new Shadow Keese actor instance.
 

Variables

static u8 data_80807EF8
 
static daE_YK_HIO_c l_HIO
 
static u8 check_index [255]
 
static actor_method_class l_daE_YK_Method
 
actor_process_profile_definition g_profile_E_YK
 

Detailed Description

Enemy - Shadow Keese

Function Documentation

◆ action()

static void action ( e_yk_class * i_this)
static

Main action handler for Shadow Keese - controls state transitions and updates.

Parameters
i_thisPointer to the Shadow Keese actor instance

Primary state machine controller that:

  1. Updates player tracking info (angle and distance)
  2. Checks for damage
  3. Manages collision flags
  4. Dispatches to appropriate state handler:
    • ROOF: Perched state
    • FIGHT_FLY: Approaching player
    • FIGHT: Combat circling
    • ATTACK: Charging attack
    • RETURN: Returning to home
    • FLY: Free flight
    • PATH_FLY: Following path
    • CHANCE: Stunned
    • WOLFBITE: Caught by Wolf Link
    • WIND: Caught in boomerang wind

Also handles:

  • Knockback movement and death
  • Smooth angle interpolation
  • Ground collision offset adjustments

◆ anm_init()

static void anm_init ( e_yk_class * i_this,
int i_resIdx,
f32 i_morf,
u8 i_attr,
f32 i_rate )
static

Initializes animation parameters for the Shadow Keese.

Parameters
i_thisPointer to the Shadow Keese instance
i_resIdxResource index for the animation transform data
i_morfAnimation morph rate
i_attrAnimation play mode
i_rateAnimation play speed

Sets up a new animation on the Shadow Keese's morph model using the specified parameters. Updates the current resource index to track which animation is playing.

◆ daE_YK_Create()

static int daE_YK_Create ( fopAc_ac_c * i_this)
static

Creates and initializes a new Shadow Keese actor instance.

Parameters
i_thisPointer to the actor base class
Returns
Phase step status (cPhs_ERROR_e on failure, phase_step otherwise)

Initialization steps:

  1. Loads "E_YK" resources
  2. Processes actor parameters:
    • Switch condition check
    • Behavior mode
    • Player trigger distance
    • Path index
  3. Initializes heap and model
  4. Sets up path following if path index valid
  5. Configures:
    • Collision spheres and handlers
    • Creature properties
    • Attention flags
    • Bounding box
    • Health and status

Special cases:

  • Adjusts trigger distance for Phantom Zant fights
  • Handles first spawn initialization

◆ daE_YK_Delete()

static int daE_YK_Delete ( e_yk_class * i_this)
static

Handles cleanup when Shadow Keese actor is deleted.

Parameters
i_thisPointer to the Shadow Keese actor instance
Returns
Always returns 1 to indicate successful deletion

Performs cleanup:

  • Deletes resources associated with "E_YK"
  • Resets first spawn flag if this was the first instance
  • Stops animation if heap exists

◆ daE_YK_Draw()

static int daE_YK_Draw ( e_yk_class * i_this)
static

Renders the Shadow Keese model with environmental lighting.

Parameters
i_thisPointer to the Shadow Keese actor instance
Returns
int Always returns 1

Handles the rendering of the Shadow Keese by:

  • Setting up environmental lighting and TEV (Texture Environment) parameters
  • Applying dark material settings appropriate for a shadow creature
  • Drawing the morphing model with current animation state

The function uses the following rendering pipeline:

  1. Gets the J3D model from the morph object
  2. Configures environmental lighting based on current position
  3. Sets up special dark rendering state
  4. Renders the model
  5. Restores normal rendering state

◆ daE_YK_Execute()

static int daE_YK_Execute ( e_yk_class * i_this)
static

Main execution function for the Shadow Keese actor.

Parameters
i_thisPointer to the Shadow Keese actor instance
Returns
int Always returns 1

Handles the main per-frame updates for the Shadow Keese, including:

  • Timer management
  • Action state execution
  • Animation and model updates
  • Particle effect management
  • Collision and targeting setup

The function is skipped if Midna is currently talking.

State-specific behaviors:

  • During WOLFBITE state: Attaches to wolf Link's mouth matrix
  • During normal states: Updates attention targeting and transformation matrix
  • Plays wing flap sounds on specific animation frames
  • Manages shadow and wing particle effects
  • Updates collision sphere position and radius

◆ daE_YK_IsDelete()

static int daE_YK_IsDelete ( e_yk_class * param_0)
static

Checks if the Shadow Keese actor should be deleted.

Parameters
param_0Pointer to the Shadow Keese actor instance
Returns
Always returns 1 to indicate deletion is allowed

◆ damage_check()

static void damage_check ( e_yk_class * i_this)
static

Checks for and handles damage to the Shadow Keese.

Parameters
i_thisPointer to the Shadow Keese actor instance

Processes collision-based damage from various sources:

  • Boomerang: Transitions to WIND state
  • Clawshot/Slingshot: Reduces health by 1
  • Shield Attack: Transitions to CHANCE state with knockback
  • Wolf Bite: Transitions to WOLFBITE state
  • Other attacks: Applies knockback and invulnerability frames

Special handling:

  • Sets invulnerability timer based on attack type
  • Plays appropriate sound effects
  • Handles death state when health reaches 0
  • Manages collision flags and status

◆ e_yk_attack()

static void e_yk_attack ( e_yk_class * i_this)
static

Handles Shadow Keese's attack behavior when targeting the player.

Parameters
i_thisPointer to the Shadow Keese actor instance

State machine with phases:

  1. Initialization:
    • Sets up attack animation at 2x speed
    • Sets initial timer
  2. Targeting:
    • Positions 120 units above player
    • Waits for timer before charging
  3. Charge Attack:
    • Moves at charge speed toward target
    • Checks for shield hits (transitions to CHANCE state if blocked)
    • Times out to phase 3
  4. Recovery:
    • Slows down until returning to normal FIGHT state

Uses HIO-configured charge speed and interpolated movement.

◆ e_yk_chance()

static void e_yk_chance ( e_yk_class * i_this)
static

Handles Shadow Keese's stunned state after being shield-blocked.

Parameters
i_thisPointer to the Shadow Keese actor instance

State machine with phases:

  1. Initialization:
    • Sets up stun animation at 1.5x speed
    • Sets random stun duration (100-130 frames)
    • Plays stun sound effect
  2. Stunned:
    • Bounces off ground with random velocity
    • Applies random rotation
    • Creates smoke effect on ground impact
    • Returns to FIGHT state when timer expires

Applies gravity and smooth rotation interpolation while stunned.

◆ e_yk_fight()

static void e_yk_fight ( e_yk_class * i_this)
static

Handles the Shadow Keese's combat behavior when circling around the player.

Parameters
i_thisPointer to the Shadow Keese actor instance

Controls the Shadow Keese's movement pattern during combat, making it circle around the player while maintaining a certain distance. The keese picks random positions around the player to fly to, creating an erratic flight pattern.

State transitions:

  • Phase 0: Initializes combat animation and timers
  • Phase 1: Handles movement and position updates

The keese will transition to:

  • ACT_ATTACK: When timer expires, initiating an attack on the player
  • ACT_RETURN/ACT_FLY: If player moves out of range (based on mBehaviorMode)
  • ACT_PATH_FLY: If a valid path point is available

Movement is smoothly interpolated using cLib_addCalc2 for position and angle updates. Random factors are used to create unpredictable but controlled movement patterns.

◆ e_yk_fight_fly()

static void e_yk_fight_fly ( e_yk_class * i_this)
static

Handles the Shadow Keese's behavior when flying towards the player to engage in combat.

Parameters
i_thisPointer to the Shadow Keese actor instance

Controls the Shadow Keese's movement when transitioning from passive to combat state. The keese will fly directly towards the player's position while playing appropriate animations.

State transitions:

  • If player moves out of range: Changes to ACT_RETURN or ACT_FLY based on mBehaviorMode
  • If path point is available: Changes to ACT_PATH_FLY
  • If close enough to player: Changes to ACT_FIGHT

Animation phases:

  • Phase 0: Initializes flying animation
  • Phase 1: Maintains flight and plays random vocalizations

◆ e_yk_fly()

static void e_yk_fly ( e_yk_class * i_this)
static

Handles Shadow Keese's normal flying behavior.

Parameters
i_thisPointer to the Shadow Keese actor instance

State machine with phases:

  1. Initialization:
    • Sets up flying animation
  2. Flying:
    • 50% chance to make sound every ~32 frames
    • Picks random point within range of home position
    • Smoothly flies to target point using interpolation
    • Resets timer for next point selection

Transitions to FIGHT_FLY if player comes within trigger range. Uses HIO-configured fly speed and cruise speed.

◆ e_yk_path_fly()

static void e_yk_path_fly ( e_yk_class * i_this)
static

Handles Shadow Keese's path-following behavior.

Parameters
i_thisPointer to the Shadow Keese actor instance

State machine with phases: 0/1. Path Navigation:

  • Updates path point index based on direction
  • Handles path transitions between rooms
  • Manages path direction reversals
  • 50% chance to make sound every ~32 frames

2/3. Point Movement:

  • Sets target to current path point + random offset
  • Moves to target point using interpolation
  • Transitions back to navigation when close enough

Uses HIO-configured fly speed and handles multi-room paths.

◆ e_yk_return()

static void e_yk_return ( e_yk_class * i_this)
static

Handles Shadow Keese returning to its home position.

Parameters
i_thisPointer to the Shadow Keese actor instance

State machine with phases:

  1. Initialization:
    • Sets up flying animation
    • Resets movement interpolation
  2. Return Flight:
    • Flies directly to home position
    • Transitions to ROOF state when within 100 units
    • Can be interrupted by player proximity (FIGHT_FLY)

Uses HIO-configured fly speed and smooth movement interpolation.

◆ e_yk_roof()

static void e_yk_roof ( e_yk_class * i_this)
static

Handles Shadow Keese behavior when perched on ceiling.

Parameters
i_thisPointer to the Shadow Keese actor instance

State machine with two phases:

  1. Initialization:
    • Sets up perched animation with slight random speed variation
    • Transitions to phase 1
  2. Perched behavior:
    • 50% chance to make sound every ~32 frames
    • Smoothly maintains position at home point
    • Checks for player proximity to trigger combat

Will transition to FIGHT_FLY state if player comes within trigger range. Uses smooth interpolation to maintain position and prevent jittering.

◆ e_yk_wind()

static void e_yk_wind ( e_yk_class * i_this)
static

Handles Shadow Keese's behavior when caught in boomerang wind.

Parameters
i_thisPointer to the Shadow Keese actor instance

State machine with phases:

  1. Initialization:
    • Sets up wind animation
    • Generates random rotation and position offsets
    • Transitions to phase 1
  2. Following Boomerang:
    • Maintains position relative to boomerang using offset
    • Plays spinning sound effect
    • Transitions to phase 2 if boomerang disappears
  3. Recovery:
    • Gradually reduces rotation
    • Waits for timer (0x3c frames)
    • Returns to FIGHT_FLY state

Continuously applies rotation around Y axis while in wind state.

◆ e_yk_wolfbite()

static void e_yk_wolfbite ( e_yk_class * i_this)
static

Handles Shadow Keese's behavior when caught and thrown by Wolf Link.

Parameters
i_thisPointer to the Shadow Keese actor instance

State machine with phases:

  1. Initialization:
    • Sets up caught animation
  2. Being Held:
    • Checks if Wolf Link still has hold
    • When thrown:
      • Sets throw angle based on left/right throw
      • Sets initial throw velocity (40.0f forward, -20.0f vertical)
      • Plays death sound
      • Transitions to phase 2
  3. Flying:
    • Applies gravity (-4.0f/frame)
    • Checks for ground collision
    • On ground hit: Plays impact sounds and transitions to phase 3
  4. Death:
    • Waits for timer (60 frames)
    • Calls yk_disappear and deletes actor

Maintains constant forward speed when bouncing on ground.

◆ fly_move()

static void fly_move ( e_yk_class * i_this)
static

Handles movement calculations for Shadow Keese flight.

Parameters
i_thisPointer to the Shadow Keese actor instance

Calculates and applies movement towards a target position (mPathPntPos):

  1. Calculates direction vector to target
  2. Converts to yaw and pitch angles
  3. Smoothly interpolates current angles towards target angles
  4. Applies speed in resulting direction

Movement characteristics:

  • Turn speed of 2000.0f units
  • Smooth acceleration via mMoveInterpolation (0.0 to 1.0)
  • Movement speed controlled by speedF member
  • Uses matrix transformations for final velocity calculation

◆ other_bg_check()

static int other_bg_check ( e_yk_class * i_this,
fopAc_ac_c * i_actorP )
static

Checks for line-of-sight obstruction between Shadow Keese and another actor.

Parameters
i_thisPointer to the Shadow Keese actor instance
i_actorPPointer to the target actor to check against
Returns
int Returns 1 if line of sight is blocked by background geometry, 0 if clear

Performs a line collision check between:

  • Shadow Keese's eye position
  • Target actor's position + 100 units up

Used to determine if background geometry (walls, terrain, etc.) is blocking the Shadow Keese's view of potential targets. This affects targeting and behavior decisions.

◆ path_check()

static int path_check ( e_yk_class * i_this)
static

Checks visibility and accessibility of path points for Shadow Keese navigation.

Parameters
i_thisPointer to the Shadow Keese actor instance
Returns
int Returns 1 if valid path point found, 0 if no valid points

Performs two main checks:

  1. Line-of-sight check to each path point:
    • Checks for obstacles between keese and path points
    • Marks accessible points in check_index array
  2. Distance-based path point selection:
    • Iteratively checks distances to accessible points
    • Selects closest point within expanding radius
    • Updates path index and direction

Used for path-following behavior to ensure keese can navigate around obstacles and maintain valid flight paths.

◆ pl_check()

static int pl_check ( e_yk_class * i_this,
f32 i_distance,
s16 i_angle )
static

Checks if the Shadow Keese should target the player.

Parameters
i_thisPointer to the Shadow Keese actor instance
i_distanceMaximum distance threshold for targeting
i_angleMaximum angle difference threshold for targeting (1 means any angle)
Returns
int Returns 1 if targeting conditions are met, 0 otherwise

Determines if the Shadow Keese should target the player based on:

  1. Special case: Always returns 1 if distance threshold >= 50000.0f (used in Phantom Zant fights)
  2. Player must be below the keese
  3. Player must be within the specified distance
  4. Player must be within the specified angle range (unless i_angle == 1)
  5. No background geometry blocking line of sight

Used by various states to determine when to transition to combat behaviors.

◆ shot_b_sub()

static void * shot_b_sub ( void * i_actor,
void * param_1 )
static

Searches for a charged boomerang that can affect the Shadow Keese.

Parameters
param_0Pointer to the actor being checked
param_1Unused parameter
Returns
void* Returns the boomerang actor pointer if conditions are met, NULL otherwise

Checks if the given actor is:

  • A valid actor
  • A boomerang (PROC_BOOMERANG)
  • Player is not in a certain state (0x80000)
  • Boomerang is charged
  • Boomerang parameter is 1

Used by the Shadow Keese's wind state to determine if it should be affected by a charged boomerang's wind effect.

◆ useHeapInit()

static int useHeapInit ( fopAc_ac_c * i_this)
static

Initializes heap resources for Shadow Keese actor.

Parameters
i_thisPointer to the actor base class
Returns
1 if initialization successful, 0 if failed

Creates and initializes the morphing model object (mpMorfSO):

  • Uses "E_YK" model data and animation resources
  • Sets up transform animations
  • Configures creature parameters

◆ yk_disappear()

static void yk_disappear ( e_yk_class * i_this)
static

Makes a Shadow Keese disappear with effects and item drops.

Parameters
i_thisPointer to the Shadow Keese actor instance

Plays particle effects and sound when the Shadow Keese disappears. Creates an item drop and handles switch activation if specified in parameters.

Variable Documentation

◆ check_index

u8 check_index[255]
static

◆ data_80807EF8

u8 data_80807EF8
static

◆ g_profile_E_YK

actor_process_profile_definition g_profile_E_YK
extern
Initial value:
= {
7,
sizeof(e_yk_class),
0,
0,
188,
0x10050100,
}
Twilight Keese (Yami Keese)
Definition d_a_e_yk.h:45
static actor_method_class l_daE_YK_Method
Definition d_a_e_yk.cpp:1552
@ PROC_E_YK
Definition d_procname.h:514
actor_method_class g_fopAc_Method
@ fopAc_CULLBOX_CUSTOM_e
Definition f_op_actor.h:70
@ fopAc_ENEMY_e
Definition f_op_actor.h:40
@ fpcLy_CURRENT_e
Definition f_pc_layer_tag.h:9
leafdraw_method_class g_fpcLf_Method
Definition f_pc_leaf.cpp:63
@ fpcPi_CURRENT_e
Definition f_pc_priority.h:8
leafdraw_method_class base
Definition f_op_actor.h:9
process_method_class base
Definition f_pc_leaf.h:12

◆ l_daE_YK_Method

actor_method_class l_daE_YK_Method
static
Initial value:
= {
}
static int daE_YK_Draw(e_yk_class *i_this)
Renders the Shadow Keese model with environmental lighting.
Definition d_a_e_yk.cpp:131
static int daE_YK_Delete(e_yk_class *i_this)
Handles cleanup when Shadow Keese actor is deleted.
Definition d_a_e_yk.cpp:1386
static int daE_YK_IsDelete(e_yk_class *param_0)
Checks if the Shadow Keese actor should be deleted.
Definition d_a_e_yk.cpp:1371
static int daE_YK_Create(fopAc_ac_c *i_this)
Creates and initializes a new Shadow Keese actor instance.
Definition d_a_e_yk.cpp:1449
static int daE_YK_Execute(e_yk_class *i_this)
Main execution function for the Shadow Keese actor.
Definition d_a_e_yk.cpp:1258
int(* process_method_func)(void *)
Definition f_pc_method.h:7

◆ l_HIO

daE_YK_HIO_c l_HIO
static