Paper Mario DX
Paper Mario (N64) modding
 
Loading...
Searching...
No Matches
functions.h File Reference

Go to the source code of this file.

Functions

f32 fabsf (f32 f)
 
f64 fabs (f64 f)
 
f32 cosine (s16 arg0)
 
void nuBoot (void)
 
void boot_idle (void *data)
 
void boot_main (void *data)
 
void is_debug_init (void)
 
void is_debug_panic (const char *message)
 
f32 signF (f32 val)
 
s32 func_8002ACDC (void)
 
void load_obfuscation_shims (void)
 
void * heap_malloc (s32 size)
 
void * _heap_malloc (HeapNode *head, u32 size)
 
void * _heap_malloc_tail (HeapNode *head, u32 size)
 
u32 _heap_free (HeapNode *heapNodeList, void *addrToFree)
 
void * _heap_realloc (HeapNode *heapNodeList, void *addr, u32 newSize)
 
HeapNode_heap_create (HeapNode *addr, u32 size)
 
u32 dma_copy (Addr romStart, Addr romEnd, void *vramDest)
 
f32 rand_float (void)
 
void copy_matrix (Matrix4f src, Matrix4f dest)
 
Shadowget_shadow_by_index (s32 index)
 
s32 get_time_freeze_mode (void)
 
void render_player_model (void)
 
s32 is_picking_up_item (void)
 
f32 integrate_gravity (void)
 
void gravity_use_fall_parms (void)
 
f32 get_clamped_angle_diff (f32, f32)
 
b32 startup_fade_screen_in (s16 subtractAlpha)
 
b32 startup_fade_screen_out (s16 addAlpha)
 
void startup_fade_screen_update (void)
 
u32 get_entity_type (s32 arg0)
 
Entityget_entity_by_index (s32 index)
 
s32 create_entity (EntityBlueprint *bp,...)
 
void entity_shattering_idle (Entity *entity)
 
void show_damage_fx (Actor *actor, f32 x, f32 y, f32 z, s32 damage)
 
b32 entity_raycast_down (f32 *, f32 *, f32 *, f32 *, f32 *, f32 *)
 Mostly used for shadows.
 
void step_game_loop (void)
 
s32 resume_all_group (s32 groupFlags)
 
f32 length2D (f32 x, f32 y)
 
void player_input_to_move_vector (f32 *angle, f32 *magnitude)
 
void game_input_to_move_vector (f32 *x, f32 *y)
 
void exec_ShakeCamX (s32 arg0, s32 arg1, s32 arg2, f32 arg3)
 
void exec_ShakeCam1 (s32 arg0, s32 arg1, s32 arg2)
 
f32 player_get_side_angle (void)
 
void draw_number (s32 value, s32 x, s32 y, s32 variableWidthChars, s32 palette, s32 opacity, u16 style)
 
void set_entity_model_flags (s32 idx, s32 newFlags)
 
void clear_entity_model_flags (s32 idx, s32 newFlags)
 
void exec_entity_model_commandlist (s32 idx)
 
RenderTaskqueue_render_task (RenderTask *task)
 
s32 create_mesh_animator (s16 *animPos, s16 *animBuffer)
 
void load_mesh_animator_tree (s32 index, StaticAnimatorNode **tree)
 
void setup_pause_menu_tab (MenuWindowBP *bpArray, s32 arraySize)
 
s32 draw_ci_image_with_clipping (u8 *raster, s32 width, s32 height, s32 fmt, s32 bitDepth, u16 *palette, s16 posX, s16 posY, u16 clipULx, u16 clipULy, u16 clipLRx, u16 clipRLy, u8 opacity)
 
void render_frame (s32 flag)
 
void clear_windows (void)
 
void update_window_hierarchy (s32 windowIndex, u8 arg1)
 
void get_msg_properties (s32 msgID, s32 *height, s32 *width, s32 *maxLineChars, s32 *numLines, s32 *maxLinesPerPage, s32 *arg6, u16 charset)
 
void replace_window_update (s32 idx, s8 arg1, WindowUpdateFunc pendingFunc)
 
void decode_yay0 (void *src, void *dst)
 
s32 ai_check_player_dist (Enemy *enemy, s32 arg1, f32 arg2, f32 arg3)
 
void pause_init (void)
 
void pause_handle_input (s32 buttonsPressed, s32 buttonsHeld)
 
void pause_cleanup (void)
 
void filemenu_init (s32 mode)
 
void filemenu_cleanup (void)
 
void filemenu_update (void)
 
s32 filemenu_get_exit_mode (void)
 
void filemenu_set_selected (MenuPanel *menu, s32 col, s32 row)
 
void filemenu_set_cursor_alpha (s32 arg0)
 
void filemenu_set_cursor_goal_pos (s32 windowIndex, s32 posX, s32 posY)
 
u8 * filemenu_get_menu_message (s32 idx)
 
void gfx_task_background (void)
 
void update_enemy_shadows (void)
 
void update_hero_shadows (void)
 
void appendGfx_background_texture (void)
 
void appendGfx_enemy_actor (void *)
 
void appendGfx_enemy_actor_blur (void *)
 
void appendGfx_enemy_actor_reflection (void *)
 
void appendGfx_partner_actor (void *)
 
void appendGfx_partner_actor_blur (void *)
 
void appendGfx_partner_actor_reflection (void *)
 
void appendGfx_player_actor (void *)
 
void appendGfx_player_actor_blur (Actor *)
 
void appendGfx_player_actor_reflection (void *)
 
void force_disable_actor_blur (Actor *)
 
void player_handle_floor_collider_type (s32 colliderID)
 
f32 player_fall_distance (void)
 
void func_800E4AD8 (s32 arg0)
 
f32 player_check_collision_below (f32, s32 *colliderID)
 
b32 can_trigger_loading_zone (void)
 
void update_damage_popups (void)
 
void show_action_rating (s32, Actor *, f32, f32, f32)
 
s32 render_with_adjusted_palettes (s32, ActorPart *, s32, Matrix4f, s32)
 
HeapNodegeneral_heap_create (void)
 
void * general_heap_malloc (s32 size)
 
s32 general_heap_free (void *data)
 
s32 integer_log (s32 number, u32 base)
 
void set_battle_stage (s32)
 
void load_battle (s32)
 
void entity_Shadow_init (Shadow *entity)
 
void entity_SaveBlock_idle (Entity *entity)
 
void entity_SaveBlock_pause_game (void)
 
void entity_SaveBlock_resume_game (void)
 
void entity_SaveBlock_save_data (void)
 
void entity_SaveBlock_show_tutorial_message (Entity *entity)
 
void entity_SaveBlock_wait_for_close_tutorial (Entity *entity)
 
void entity_SaveBlock_show_choice_message (void)
 
void entity_SaveBlock_show_result_message (void)
 
void entity_SaveBlock_wait_for_close_result (Entity *entity)
 
void entity_SaveBlock_wait_for_close_choice (Entity *entity)
 
void entity_SaveBlock_init (Entity *entity)
 
void entity_GreenStompSwitch_idle (Entity *entity)
 
void entity_GreenStompSwitch_retract (Entity *entity)
 
void entity_GreenStompSwitch_extend (Entity *entity)
 
void entity_HugeBlueSwitch_idle (Entity *entity)
 
void entity_small_switch_idle (Entity *entity)
 
void entity_RedSwitch_wait_and_reset (Entity *entity)
 
void entity_base_switch_anim_init (Entity *entity)
 
s32 entity_RedSwitch_animate_scale (Entity *entity)
 
void entity_base_switch_start_bound_script (Entity *entity)
 
void entity_base_switch_animate_scale (Entity *entity)
 
void entity_base_switch_init (Entity *entity)
 
f32 entity_block_hit_init_scale (Entity *entity)
 
void entity_block_hit_animate_scale (Entity *entity)
 
s32 entity_block_handle_collision (Entity *entity)
 
void entity_BlueSwitch_init (Entity *entity)
 
void entity_HugeBlueSwitch_init (Entity *entity)
 
s32 dispatch_damage_event_actor_0 (Actor *actor, s32 damageAmount, s32 event)
 
MessagePrintStatemsg_get_printer_for_msg (s32 msgID, s32 *a1)
 
s32 msg_printer_load_msg (s32 msgID, MessagePrintState *printer)
 
void msg_printer_set_origin_pos (MessagePrintState *msgPrintState, s32 x, s32 y)
 
void get_screen_coords (s32 camID, f32 x, f32 y, f32 z, s32 *screenX, s32 *screenY, s32 *screenZ)
 
void parent_collider_to_model (s16 colliderID, s16 modelIndex)
 
void clone_model (u16 srcModelID, u16 newModelID)
 
struct Modelget_model_from_list_index (s32 listIndex)
 
s32 create_model_animator (s16 *animPos)
 
s32 get_model_list_index_from_tree_index (s32 treeIndex)
 
s32 get_transform_group_index (s32)
 
void get_model_center_and_size (u16 modelID, f32 *centerX, f32 *centerY, f32 *centerZ, f32 *sizeX, f32 *sizeY, f32 *sizeZ)
 
HitID collision_main_above (void)
 
void collision_lava_reset_check_additional_overlaps (void)
 
s32 player_test_lateral_overlap (s32, PlayerStatus *, f32 *, f32 *, f32 *, f32, f32)
 
Npcpeach_make_disguise_npc (s32 peachDisguise)
 
void peach_set_disguise_anim (AnimID)
 
s32 draw_box (s32 flags, WindowStyle windowStyle, s32 posX, s32 posY, s32 posZ, s32 width, s32 height, u8 opacity, u8 darkening, f32 scaleX, f32 scaleY, f32 rotX, f32 rotY, f32 rotZ, void(*fpDrawContents)(s32, s32, s32, s32, s32, s32, s32), void *drawContentsArg0, Matrix4f rotScaleMtx, s32 translateX, s32 translateY, Matrix4f outMtx)
 
s32 get_msg_width (s32 msgID, u16 charset)
 
s32 partner_can_open_world_menus (void)
 
s32 disable_player_static_collisions (void)
 
s32 disable_player_input (void)
 
void func_80027088 (s32)
 
void set_time_freeze_mode (s32)
 Time freeze modes: 0: none 1: NPCs move, can't be interacted with 2: NPCs don't move, no partner ability, can't interact, can't use exits 3: NPCs don't more or animate 4: NPCs can move, animations don't update, can use exits.
 
s32 get_map_IDs_by_name (const char *mapName, s16 *areaID, s16 *mapID)
 
void get_map_IDs_by_name_checked (const char *mapName, s16 *areaID, s16 *mapID)
 Same as get_map_IDs_by_name, but will panic if the map doesn't exist.
 
void transform_point (Matrix4f mtx, f32 inX, f32 inY, f32 inZ, f32 inS, f32 *outX, f32 *outY, f32 *outZ, f32 *outW)
 
void try_player_footstep_sounds (s32 arg0)
 
void phys_update_interact_collider (void)
 
void phys_reset_spin_history (void)
 
s32 phys_adjust_cam_on_landing (void)
 
s32 phys_should_player_be_sliding (void)
 
void phys_init_integrator_for_current_state (void)
 
void phys_player_land (void)
 
void phys_main_collision_below (void)
 
void phys_peach_update (void)
 
void check_input_spin (void)
 
void phys_set_player_sliding_check (b32(*funcPtr)(void))
 
void phys_set_landing_adjust_cam_check (s32(*funcPtr)(void))
 
b32 npc_test_move_simple_without_slipping (s32, f32 *, f32 *, f32 *, f32, f32, f32, f32)
 
void update_collider_transform (s16 colliderID)
 
void get_collider_center (s32 colliderID, f32 *x, f32 *y, f32 *z)
 
s32 is_another_trigger_bound (Trigger *, EvtScript *script)
 
Triggercreate_trigger (TriggerBlueprint *def)
 
s32 evt_trigger_on_activate_exec_script (Trigger *trigger)
 
Triggerget_trigger_by_id (s32 triggerID)
 
Actorget_actor (s32 actorID)
 
ActorPartget_actor_part (Actor *actor, s32 partID)
 
s32 add_coins (s32 amt)
 
s32 is_partner_ability_active (s32)
 
s32 count_power_plus (s32)
 
s32 phys_can_player_interact (void)
 
void ai_enemy_play_sound (Npc *npc, s32 arg1, s32 arg2)
 
HitID player_test_move_without_slipping (PlayerStatus *, f32 *, f32 *, f32 *, f32, f32, s32 *)
 Only used for Peach physics.
 
HitID player_test_move_with_slipping (PlayerStatus *playerStatus, f32 *posX, f32 *posY, f32 *posZ, f32 speed, f32 heading)
 
s32 evt_get_variable (Evt *script, Bytecode var)
 
s32 evt_set_variable (Evt *script, Bytecode var, s32 value)
 
f32 evt_get_float_variable (Evt *script, Bytecode var)
 
f32 evt_set_float_variable (Evt *script, Bytecode var, f32 value)
 
s32 evt_get_variable_index (Evt *script, s32 var)
 
void set_script_timescale (Evt *script, f32 timescale)
 
f32 sin_deg (f32 x)
 
f32 cos_deg (f32 x)
 
f32 sin_rad (f32 x)
 
f32 cos_rad (f32 x)
 
s32 round (f32)
 
f32 atan2 (f32 startX, f32 startZ, f32 endX, f32 endZ)
 
f32 clamp_angle (f32 theta)
 
s32 sign (s32 value)
 
b32 check_player_action_debug (void)
 
s32 battle_heap_create (void)
 
s32 test_ray_zones (f32 startX, f32 startY, f32 startZ, f32 dirX, f32 dirY, f32 dirZ, f32 *hitX, f32 *hitY, f32 *hitZ, f32 *hitDepth, f32 *nx, f32 *ny, f32 *nz)
 
s32 test_ray_colliders (s32 ignoreFlags, f32 startX, f32 startY, f32 startZ, f32 dirX, f32 dirY, f32 dirZ, f32 *hitX, f32 *hitY, f32 *hitZ, f32 *hitDepth, f32 *hitNx, f32 *hitNy, f32 *hitNz)
 
s32 test_ray_entities (f32 startX, f32 startY, f32 startZ, f32 dirX, f32 dirY, f32 dirZ, f32 *hitX, f32 *hitY, f32 *hitZ, f32 *hitDepth, f32 *hitNx, f32 *hitNy, f32 *hitNz)
 Test a general ray from a given starting position and direction against all entities.
 
void mem_clear (void *data, s32 numBytes)
 
void startup_set_fade_screen_color (s16 color)
 
void startup_set_fade_screen_alpha (s16 alpha)
 
f32 get_xz_dist_to_player (f32, f32)
 
void func_800E06C0 (s32)
 
void close_status_bar (void)
 
Evtfunc_802C39F8 (Evt *parentScript, Bytecode *nextLine, s32 newState)
 
Evtstart_child_script (Evt *parentScript, EvtScript *source, s32 initialState)
 
Evtrestart_script (Evt *script)
 
void clear_virtual_entity_list (void)
 
void reset_model_animators (void)
 
void init_virtual_entity_list (void)
 
void init_model_animators (void)
 
void play_model_animation (s32, s16 *)
 
s32 heap_free (void *ptr)
 
void load_battle_hit_asset (const char *hitName)
 
void load_data_for_models (struct ModelNode *model, s32 romOffset, s32 size)
 
void load_player_actor (void)
 
void btl_state_update_normal_start (void)
 
void btl_state_draw_normal_start (void)
 
void btl_state_update_begin_turn (void)
 
void btl_state_draw_begin_turn (void)
 
void btl_state_update_begin_player_turn (void)
 
void btl_state_draw_begin_player_turn (void)
 
void btl_state_update_switch_to_player (void)
 
void btl_state_draw_switch_to_player (void)
 
void btl_state_update_begin_partner_turn (void)
 
void btl_state_draw_begin_partner_turn (void)
 
void btl_state_update_switch_to_partner (void)
 
void btl_state_draw_switch_to_partner (void)
 
void btl_state_update_9 (void)
 
void btl_state_draw_9 (void)
 
void btl_state_update_prepare_menu (void)
 
void btl_state_draw_prepare_menu (void)
 
void btl_state_update_end_turn (void)
 
void btl_state_draw_end_turn (void)
 
void btl_state_update_1C (void)
 
void btl_state_draw_1C (void)
 
void btl_state_update_victory (void)
 
void btl_state_draw_victory (void)
 
void btl_state_update_end_training_battle (void)
 
void btl_state_draw_end_training_battle (void)
 
void btl_state_update_end_battle (void)
 
void btl_state_draw_end_battle (void)
 
void btl_state_update_defend (void)
 
void btl_state_draw_defend (void)
 
void btl_state_update_run_away (void)
 
void btl_state_draw_run_away (void)
 
void btl_state_update_defeat (void)
 
void btl_state_draw_defeat (void)
 
void btl_state_update_change_partner (void)
 
void btl_state_draw_change_partner (void)
 
void btl_state_update_player_move (void)
 
void btl_state_draw_player_move (void)
 
void btl_state_update_end_player_turn (void)
 
void btl_state_update_partner_move (void)
 
void btl_state_draw_end_player_turn (void)
 
void btl_state_draw_partner_move (void)
 
void btl_state_update_end_partner_turn (void)
 
void btl_state_draw_end_partner_turn (void)
 
void btl_state_update_next_enemy (void)
 
void btl_state_draw_next_enemy (void)
 
void btl_state_update_enemy_move (void)
 
void btl_state_draw_enemy_move (void)
 
void btl_state_update_first_strike (void)
 
void btl_state_draw_first_stike (void)
 
void btl_state_update_partner_striking_first (void)
 
void btl_state_draw_partner_striking_first (void)
 
void btl_state_update_enemy_striking_first (void)
 
void btl_state_draw_enemy_striking_first (void)
 
void btl_state_update_end_demo_battle (void)
 
void btl_state_draw_end_demo_battle (void)
 
void btl_state_update_player_menu (void)
 
void btl_state_draw_player_menu (void)
 
void btl_state_update_partner_menu (void)
 
void btl_state_draw_partner_menu (void)
 
void btl_state_update_peach_menu (void)
 
void btl_state_draw_peach_menu (void)
 
void btl_state_update_twink_menu (void)
 
void btl_state_draw_twink_menu (void)
 
void btl_state_update_select_target (void)
 
void btl_state_draw_select_target (void)
 
void btl_state_update_22 (void)
 
void btl_state_draw_22 (void)
 
void btl_state_update_celebration (void)
 
void btl_draw_upgrade_windows (s32)
 
void btl_state_draw_celebration (void)
 
void btl_bonk_cleanup (void)
 
void set_actor_anim_by_ref (Actor *, ActorPart *, AnimID)
 
void update_action_ratings (void)
 
void update_health_bars (void)
 
s32 btl_cam_is_moving_done (void)
 
void btl_popup_messages_update (void)
 
void btl_popup_messages_draw_world_geometry (void)
 
void func_80255FD8 (void)
 
void set_actor_glow_pal (Actor *actor, s32 arg1)
 
void btl_set_popup_duration (s32 duration)
 
void switch_to_partner (s32 arg0)
 
s8 get_current_partner_id (void)
 
void delete_trigger (Trigger *toDelete)
 
void kill_script_by_ID (s32 id)
 
void set_script_priority (Evt *script, s32 priority)
 
void set_script_group (Evt *script, s32 groupFlags)
 
void suspend_group_others (Evt *script, s32 groupFlags)
 
void resume_group_others (Evt *script, s32 groupFlags)
 
s32 suspend_all_script (s32 id)
 
s32 resume_all_script (s32 id)
 
s32 create_shadow_type (s32 type, f32 x, f32 y, f32 z)
 
b32 is_point_outside_territory (s32 shape, f32 pointX, f32 pointY, f32 centerX, f32 centerY, f32 sizeX, f32 sizeZ)
 
b32 npc_raycast_down_around (s32, f32 *, f32 *, f32 *, f32 *, f32, f32)
 
b32 npc_raycast_down_sides (s32 ignoreFlags, f32 *posX, f32 *posY, f32 *posZ, f32 *hitDepth)
 
b32 npc_raycast_up (s32, f32 *, f32 *, f32 *, f32 *)
 
HitID npc_raycast_up_corners (s32 ignoreFlags, f32 *posX, f32 *posY, f32 *posZ, f32 *hitDepth, f32 yaw, f32 radius)
 
HitID player_raycast_up_corners (PlayerStatus *, f32 *, f32 *, f32 *, f32 *, f32)
 
HitID player_raycast_below_cam_relative (PlayerStatus *playerStatus, f32 *outX, f32 *outY, f32 *outZ, f32 *outLength, f32 *hitRx, f32 *hitRz, f32 *hitDirX, f32 *hitDirZ)
 
b32 npc_test_move_taller_with_slipping (s32, f32 *, f32 *, f32 *, f32, f32, f32, f32)
 
b32 npc_test_move_simple_with_slipping (s32, f32 *, f32 *, f32 *, f32, f32, f32, f32)
 
s32 npc_test_move_complex_with_slipping (s32, f32 *, f32 *, f32 *, f32, f32, f32, f32)
 
EvtScriptpartner_get_enter_map_script (void)
 
void partner_handle_before_battle (void)
 
void partner_walking_update_player_tracking (Npc *partner)
 
void partner_walking_update_motion (Npc *partner)
 
void enable_partner_ai (void)
 
void partner_walking_enable (Npc *partner, s32 val)
 
void partner_flying_enable (Npc *partner, s32 val)
 
void partner_flying_update_player_tracking (Npc *partner)
 
s32 partner_is_flying (void)
 
void partner_flying_update_motion (Npc *partner)
 
void partner_clear_player_tracking (Npc *partner)
 
void partner_set_tether_distance (f32)
 
void btl_delete_player_actor (Actor *player)
 
s32 cancel_message (MessagePrintState *msgPrintState)
 
void set_message_images (MessageImageData *images)
 
void kill_all_scripts (void)
 
s32 does_script_exist (s32 id)
 
s32 does_script_exist_by_ref (Evt *script)
 
Evtstart_script (EvtScript *source, s32 priority, s32 initialState)
 
Evtstart_script_in_group (EvtScript *source, u8 priority, u8 initialState, u8 groupFlags)
 
f32 get_player_normal_yaw (void)
 
void set_standard_shadow_scale (Shadow *shadow, f32 scale)
 
void set_npc_shadow_scale (Shadow *shadow, f32 height, f32 npcRadius)
 
void set_npc_animation (Npc *npc, u32 animID)
 
void set_peach_shadow_scale (Shadow *shadow, f32 scale)
 
s32 is_block_on_ground (Entity *block)
 
void set_actor_anim (s32 actorID, s32 partID, AnimID animID)
 
void set_actor_anim_rate (s32 actorID, s32 partID, f32 rate)
 
void mdl_group_set_visibility (u16, s32, s32)
 
void init_enter_world_shared (void)
 
s16 update_enter_map_screen_overlay (s16 *progress)
 
s16 update_exit_map_screen_overlay (s16 *progress)
 
void set_screen_overlay_params_front (u8, f32)
 
void set_screen_overlay_params_back (u8, f32)
 
void set_screen_overlay_alpha (s32, f32)
 
void get_screen_overlay_params (s32, u8 *type, f32 *zoom)
 
void set_screen_overlay_color (s32, u8, u8, u8)
 
void set_screen_overlay_center (s32, s32, s32, s32)
 
s32 rand_int (s32)
 
void sort_consumables (void)
 Bubbles up player inventory items such that all ITEM_NONE values are at the bottom.
 
s32 is_ability_active (s32 arg0)
 
s32 is_starting_conversation (void)
 
f32 update_lerp (s32 easing, f32 start, f32 end, s32 elapsed, s32 duration)
 
void sin_cos_deg (f32 rad, f32 *outSinTheta, f32 *outCosTheta)
 
void set_main_pan_u (s32 texPannerID, s32 value)
 
void set_main_pan_v (s32 texPannerID, s32 value)
 
void set_aux_pan_u (s32 texPannerID, s32 value)
 
void set_aux_pan_v (s32 texPannerID, s32 value)
 
void enable_world_fog (void)
 
void set_world_fog_dist (s32 start, s32 end)
 
void set_world_fog_color (s32 r, s32 g, s32 b, s32 a)
 
s32 is_world_fog_enabled (void)
 
void get_world_fog_color (s32 *r, s32 *g, s32 *b, s32 *a)
 
void enable_entity_fog (void)
 
void set_entity_fog_dist (s32 start, s32 end)
 
void set_entity_fog_color (s32 r, s32 g, s32 b, s32 a)
 
struct ModelTransformGroupget_transform_group (s32 index)
 
void mdl_make_transform_group (u16 modelID)
 
void enable_transform_group (u16 modelID)
 
void disable_transform_group (u16 modelID)
 
void set_map_transition_effect (ScreenTransition)
 
void set_tex_panner (struct Model *model, s32 texPannerID)
 
void set_custom_gfx (s32 customGfxIndex, Gfx *pre, Gfx *post)
 
s32 make_item_entity (s32 itemID, f32 x, f32 y, f32 z, s32 itemSpawnMode, s32 pickupDelay, s32 angle, s32 pickupVar)
 
s32 make_item_entity_delayed (s32 itemID, f32 x, f32 y, f32 z, s32 itemSpawnMode, s32 pickupDelay, s32 pickupVar)
 
void set_item_entity_position (s32 itemEntityIndex, f32 x, f32 y, f32 z)
 
ItemEntityget_item_entity (s32 itemEntityIndex)
 
s32 make_item_entity_nodelay (s32 itemID, f32 x, f32 y, f32 z, s32 itemSpawnMode, s32 pickupVar)
 
void set_item_entity_flags (s32 itemEntityIndex, s32 flag)
 
void clear_item_entity_flags (s32 index, s32 flags)
 
s32 create_worker_frontUI (void(*updateFunc)(void), void(*drawFunc)(void))
 
Workerget_worker (s32 idx)
 
Triggerbind_trigger_1 (EvtScript *script, s32 flags, s32 triggerFlagIndex, s32 triggerVar0, s32 triggerVar1, s32 priority)
 
void set_cam_viewport (s16 id, s16 x, s16 y, s16 width, s16 height)
 
void disable_player_shadow (void)
 
void move_player (s32 duration, f32 heading, f32 speed)
 
s32 enable_player_input (void)
 
s32 enable_player_static_collisions (void)
 
b32 check_input_jump (void)
 
b32 check_input_hammer (void)
 
Npcresolve_npc (Evt *script, s32 npcIdOrPtr)
 
void enable_npc_blur (Npc *npc)
 
void disable_npc_blur (Npc *npc)
 
void enable_partner_blur (void)
 
void disable_partner_blur (void)
 
void partner_initialize_data (void)
 
f32 dist2D (f32 ax, f32 ay, f32 bx, f32 by)
 
f32 dist3D (f32 ax, f32 ay, f32 az, f32 bx, f32 by, f32 bz)
 
void add_vec2D_polar (f32 *x, f32 *y, f32 r, f32 theta)
 
enum AuResult bgm_set_track_volumes (s32 playerIndex, s16 trackVolSet)
 
enum AuResult bgm_clear_track_volumes (s32 playerIndex, s16 trackVolSet)
 
enum AuResult bgm_set_variation (s32 playerIndex, s16 arg1)
 
void bgm_quiet_max_volume (void)
 
void bgm_reset_max_volume (void)
 
void bgm_reset_volume (void)
 
s32 bgm_init_music_players (void)
 
s32 bgm_set_song (s32 playerIndex, s32 songID, s32 variation, s32 fadeOutTime, s16 volume)
 
void bgm_set_battle_song (s32, s32)
 
void bgm_push_battle_song (void)
 
s32 bgm_adjust_proximity (s32 playerIndex, s32 arg1, s16 arg2)
 
void func_801491E4 (Matrix4f mtx, s32, s32, s32, s32, s32 alpha)
 
s32 func_8014A964 (s32 playerIndex, s32 songID, s32 variation, s32 fadeInTime, s16 arg4, s16 arg5)
 
void basic_window_update (s32 windowIndex, s32 *flags, s32 *posX, s32 *posY, s32 *posZ, f32 *scaleX, f32 *scaleY, f32 *rotX, f32 *rotY, f32 *rotZ, s32 *darkening, s32 *opacity)
 
void basic_hidden_window_update (s32 windowIndex, s32 *flags, s32 *posX, s32 *posY, s32 *posZ, f32 *scaleX, f32 *scaleY, f32 *rotX, f32 *rotY, f32 *rotZ, s32 *darkening, s32 *opacity)
 
void create_current_pos_target_list (Actor *actor)
 
void create_home_target_list (Actor *actor)
 
void set_actor_yaw (s32 actorID, s32 yaw)
 
void set_part_yaw (s32 actorID, s32 partID, s32 value)
 
void add_part_decoration (ActorPart *part, s32 decorationIndex, s32 decorationType)
 
void add_actor_decoration (Actor *actor, s32 decorationIndex, s32 decorationType)
 
void remove_part_decoration (ActorPart *part, s32 decorationIndex)
 
void remove_actor_decoration (Actor *actor, s32 decorationIndex)
 
s32 player_team_is_ability_active (Actor *actor, s32 ability)
 
void create_part_shadow (s32 actorID, s32 partID)
 
void remove_part_shadow (s32 actorID, s32 partID)
 
void create_part_shadow_by_ref (s32 arg0, ActorPart *part)
 
void spawn_drops (Enemy *enemy)
 
void set_part_pal_adjustment (ActorPart *, s32)
 
char * int_to_string (s32, char *, s32)
 
Evtget_script_by_index (s32 index)
 
Evtget_script_by_id (s32 id)
 
s32 partner_test_enemy_collision (Npc *enemy)
 
s32 get_lava_reset_pos (f32 *x, f32 *y, f32 *z)
 
void start_rumble (s32, s32)
 
void update_locomotion_state (void)
 
void start_rumble_type (u32)
 
void start_falling (void)
 
void start_bounce_a (void)
 
void start_bounce_b (void)
 
void update_input (void)
 
void update_max_rumble_duration (void)
 
void mdl_reset_transform_flags (void)
 
void update_workers (void)
 
void update_triggers (void)
 
void update_scripts (void)
 
void update_messages (void)
 
void update_entities (void)
 
void func_80138198 (void)
 
void bgm_update_music_settings (void)
 
s32 func_8014AD40 (void)
 
void update_ambient_sounds (void)
 
void update_windows (void)
 
void player_render_interact_prompts (void)
 
void func_802C3EE4 (void)
 
void render_screen_overlay_backUI (void)
 
void render_workers_backUI (void)
 
void render_effects_UI (void)
 
void render_window_root (void)
 
void render_messages (void)
 
void render_workers_frontUI (void)
 
void render_screen_overlay_frontUI (void)
 
void render_curtains (void)
 
void fio_init_flash (void)
 
void func_80028838 (void)
 
void clear_screen_overlays (void)
 
void bgm_reset_sequence_players (void)
 
void reset_ambient_sounds (void)
 
void poll_rumble (void)
 
void bgm_pop_song (void)
 
void bgm_push_song (s32 songID, s32 variation)
 
void bgm_pop_battle_song (void)
 
s32 play_ambient_sounds (s32 fadeInTime, s32 fadeOutTime)
 
s32 get_fortress_key_count (void)
 
s32 subtract_fortress_keys (s32 amt)
 
s32 add_star_points (s32 amt)
 
s32 add_star_pieces (s32 amt)
 
s32 make_item_entity_at_player (s32 itemID, s32 arg1, s32 pickupMsgFlags)
 
void set_action_state (s32 actionState)
 
s32 get_collider_flags (s32 colliderID)
 
void suggest_player_anim_always_forward (AnimID anim)
 
void suggest_player_anim_allow_backward (AnimID anim)
 
void subtract_hp (s32 amt)
 
void draw_status_ui (void)
 
void open_status_bar_slowly (void)
 
void suspend_all_group (s32 groupFlags)
 
void kill_script (Evt *instanceToKill)
 
void exec_entity_commandlist (Entity *entity)
 
void show_start_recovery_shimmer (f32 x, f32 y, f32 z, s32 arg3)
 
void show_recovery_shimmer (f32 x, f32 y, f32 z, s32 arg3)
 
void show_next_damage_popup (f32 x, f32 y, f32 z, s32 damageAmount, s32)
 
void add_xz_vec3f (Vec3f *vector, f32 speed, f32 angleDeg)
 
void add_xz_vec3f_copy1 (Vec3f *vector, f32 speed, f32 angleDeg)
 
void add_xz_vec3f_copy2 (Vec3f *vector, f32 speed, f32 angleDeg)
 
void play_movement_dust_effects (s32 var0, f32 xPos, f32 yPos, f32 zPos, f32 angleDeg)
 
void draw_prev_frame_buffer_at_screen_pos (s32, s32, s32, s32, f32)
 
void func_8013A4D0 (void)
 
void btl_draw_ui (void)
 
void btl_restore_world_cameras (void)
 
void btl_popup_messages_draw_ui (void)
 
void btl_cam_set_target_pos (f32, f32, f32)
 
void btl_cam_unfreeze (void)
 
void deduct_current_move_fp (void)
 
void load_partner_actor (void)
 
void dispatch_event_partner (s32)
 
void dispatch_event_player (s32)
 
s32 btl_are_all_enemies_defeated (void)
 
s32 btl_check_enemies_defeated (void)
 
s32 btl_check_player_defeated (void)
 
void btl_show_battle_message (s32 messageIndex, s32 duration)
 
void btl_update_ko_status (void)
 
void reset_actor_turn_info (void)
 
void startup_draw_prim_rect (s16 left, s16 top, s16 right, s16 bottom, u16 r, u16 g, u16 b, u16 a)
 
void startup_draw_prim_rect_COPY (s16 left, s16 top, s16 right, s16 bottom, u16 r, u16 g, u16 b, u16 a)
 
void btl_draw_prim_quad (u8 r, u8 g, u8 b, u8 a, u16 left, u16 top, u16 arg6, u16 arg7)
 
void reset_all_actor_sounds (Actor *)
 
void decrement_status_bar_disabled (void)
 
void increment_status_bar_disabled (void)
 
void btl_delete_actor (Actor *actor)
 
void create_status_debuff (s32, s32)
 
void create_status_static (s32, s32)
 
void create_status_transparent (s32, s32)
 
void remove_status_chill_out (s32)
 
void remove_status_debuff (s32)
 
void remove_status_icon_boost_hammer (s32)
 
void remove_status_icon_boost_jump (s32)
 
void remove_status_icon_boost_partner (s32)
 
void remove_status_icon_danger (s32)
 
void remove_status_icon_peril (s32)
 
void remove_status_icon_surprise (s32)
 
void remove_status_static (s32)
 
void remove_status_transparent (s32)
 
void remove_all_status_icons (s32)
 
s32 create_status_icon_set (void)
 
s32 find_item (s32)
 Search player inventory for itemID and return first matching array index.
 
void enable_background_wave (void)
 
void set_map_change_fade_rate (s16)
 
void load_map_by_IDs (s16 areaID, s16 mapID, s16 loadType)
 
void state_init_startup (void)
 
void state_step_startup (void)
 
void state_drawUI_startup (void)
 
void state_init_logos (void)
 
void state_step_logos (void)
 
void state_drawUI_logos (void)
 
void state_init_title_screen (void)
 
void state_step_title_screen (void)
 
void state_drawUI_title_screen (void)
 
void state_init_enter_demo (void)
 
void state_step_enter_world (void)
 
void state_init_change_map (void)
 
void state_step_change_map (void)
 
void state_drawUI_change_map (void)
 
void state_init_game_over (void)
 
void state_step_game_over (void)
 
void state_drawUI_game_over (void)
 
void state_init_enter_world (void)
 
void state_drawUI_enter_world (void)
 
void state_init_world (void)
 
void state_step_world (void)
 
void state_drawUI_world (void)
 
void state_init_battle (void)
 
void state_step_battle (void)
 
void state_drawUI_battle (void)
 
void state_init_end_battle (void)
 
void state_step_end_battle (void)
 
void state_drawUI_end_battle (void)
 
void state_init_pause (void)
 
void state_step_pause (void)
 
void state_drawUI_pause (void)
 
void state_init_unpause (void)
 
void state_step_unpause (void)
 
void state_drawUI_unpause (void)
 
void state_init_file_select (void)
 
void state_step_file_select (void)
 
void state_drawUI_file_select (void)
 
void state_init_exit_file_select (void)
 
void state_step_exit_file_select (void)
 
void state_drawUI_exit_file_select (void)
 
void state_init_intro (void)
 
void state_step_intro (void)
 
void state_drawUI_intro (void)
 
void state_init_demo (void)
 
void state_step_demo (void)
 
void state_drawUI_demo (void)
 
void btl_set_player_idle_anims (void)
 
void shim_create_audio_system_obfuscated (void)
 
void shim_load_engine_data_obfuscated (void)
 
void shim_general_heap_create_obfuscated (void)
 
void shim_battle_heap_create_obfuscated (void)
 
void appendGfx_ispy_icon (void)
 
void interact_inspect_setup (void)
 
void interact_speech_setup (void)
 
void pulse_stone_notification_setup (void)
 
void appendGfx_speech_bubble (void)
 
void appendGfx_pulse_stone_icon (void)
 
void ispy_notification_setup (void)
 
void initialize_curtains (void)
 
void update_curtains (void)
 
void set_curtain_scale_goal (f32 scale)
 
void set_curtain_scale (f32 scale)
 
void set_curtain_draw_callback (void(*callback)(void))
 
void set_curtain_fade_goal (f32 fade)
 
void set_curtain_fade (f32 fade)
 
void crash_screen_init (void)
 
void crash_screen_set_draw_info (u16 *frameBufPtr, s16 width, s16 height)
 
void basic_ai_wander_init (Evt *script, MobileAISettings *npcAISettings, EnemyDetectVolume *territory)
 
void basic_ai_wander (Evt *script, MobileAISettings *npcAISettings, EnemyDetectVolume *territory)
 
void basic_ai_loiter (Evt *script, MobileAISettings *npcAISettings, EnemyDetectVolume *territory)
 
void basic_ai_found_player_jump_init (Evt *script, MobileAISettings *npcAISettings, EnemyDetectVolume *territory)
 
void basic_ai_found_player_jump (Evt *script, MobileAISettings *npcAISettings, EnemyDetectVolume *territory)
 
void basic_ai_chase_init (Evt *script, MobileAISettings *npcAISettings, EnemyDetectVolume *territory)
 
void basic_ai_chase (Evt *script, MobileAISettings *npcAISettings, EnemyDetectVolume *territory)
 
void basic_ai_lose_player (Evt *script, MobileAISettings *npcAISettings, EnemyDetectVolume *territory)
 
void basic_ai_suspend (Evt *script)
 
s32 create_worker_scene (void(*updateFunc)(void), void(*renderFunc)(void))
 
void init_entity_models (void)
 
f32 phys_get_spin_history (s32 lag, s32 *x, s32 *y, s32 *z)
 
void imgfx_update (u32, ImgFXType, s32, s32, s32, s32, s32)
 
s32 imgfx_appendGfx_component (s32, ImgFXTexture *, u32, Matrix4f)
 
void imgfx_update_cache (void)
 
s32 imgfx_get_free_instances (s32)
 
void free_worker (s32)
 
b32 ai_check_fwd_collisions (Npc *npc, f32 time, f32 *outYaw, f32 *outDistFwd, f32 *outDistCW, f32 *outDistCCW)
 
void basic_ai_loiter_init (Evt *script, MobileAISettings *aiSettings, EnemyDetectVolume *territory)
 
void PatrolAI_LoiterInit (Evt *script, MobileAISettings *aiSettings, EnemyDetectVolume *territory)
 
s32 func_80263230 (Actor *, Actor *)
 
void set_part_glow_pal (ActorPart *, s32)
 
void clear_actor_static_pal_adjustments (Actor *)
 
void set_actor_flash_mode (Actor *actor, s32 arg1)
 
void remove_player_buffs (s32)
 
s32 is_actor_health_bar_visible (Actor *)
 
void sin_cos_rad (f32 rad, f32 *outSinTheta, f32 *outCosTheta)
 
void load_font (s32 font)
 
void load_font_data (Addr offset, u16 size, void *dest)
 
void * load_asset_by_name (const char *assetName, u32 *decompressedSize)
 
Gfx * mdl_get_copied_gfx (s32 copyIndex)
 
void mdl_get_copied_vertices (s32 copyIndex, Vtx **firstVertex, Vtx **copiedVertices, s32 *numCopied)
 
void mdl_draw_hidden_panel_surface (Gfx **arg0, u16 treeIndex)
 
b32 is_point_visible (f32 x, f32 y, f32 z, s32 depthQueryID, f32 *screenX, f32 *screenY)
 
void set_screen_overlay_center_worldpos (s32 idx, s32 posIdx, s32 x, s32 y, s32 z)
 
void * mdl_get_next_texture_address (s32)
 
s32 cancel_current_message (void)
 
void draw_msg (s32 msgID, s32 posX, s32 posY, s32 opacity, s32 palette, u8 style)
 
void mdl_get_shroud_tint_params (u8 *r, u8 *g, u8 *b, u8 *a)
 
s32 entity_base_block_idle (Entity *entity)
 
void add_star_power (s32 amt)
 
s32 entity_can_collide_with_jumping_player (Entity *entity)
 
void entity_base_block_init (Entity *entity)
 
s32 entity_start_script (Entity *entity)
 
void init_item_entity_list (void)
 
void init_script_list (void)
 
void init_entity_data (void)
 
void init_trigger_list (void)
 
void partner_init_after_battle (s32 arg0)
 
void load_map_script_lib (void)
 
void remove_item_entity_by_index (s32 index)
 
void set_entity_commandlist (Entity *entity, s32 *entityScript)
 
s32 is_player_dismounted (void)
 
void func_800EF300 (void)
 
void func_800EF314 (void)
 
void func_800EF43C (void)
 
void func_800EF3E4 (void)
 
void enable_player_shadow (void)
 
s32 get_msg_lines (s32 messageID)
 
void set_window_properties (s32 panelID, s32 posX, s32 posY, s32 width, s32 height, u8, void *drawContents, void *drawContentsArg, s8 parent)
 
void set_window_update (s32 panelID, s32)
 
void set_windows_visible (s32 groupIdx)
 
void partner_disable_input (void)
 
void partner_set_goal_pos (s32 x, s32 z)
 
void close_message (MessagePrintState *msgPrintState)
 
void show_foreground_models_unchecked (void)
 
void hide_foreground_models_unchecked (void)
 
void show_foreground_models (void)
 
void hide_foreground_models (void)
 
void btl_set_state (s32 battleState)
 
void draw_entity_model_A (s32, Mtx *)
 
void draw_entity_model_B (s32, Mtx *, s32, Vec3s *)
 
void draw_entity_model_C (s32, Mtx *)
 
void draw_entity_model_D (s32, Mtx *, s32, Vec3s *)
 
void draw_entity_model_E (s32, Mtx *)
 
void free_entity_model_by_index (s32 idx)
 
void btl_cam_use_preset (s32)
 
void btl_cam_set_params (b16, s16, s16, s16, s32, s32, s32)
 
void btl_cam_set_zoffset (s16)
 
void btl_cam_target_actor (s32)
 
void btl_cam_set_zoom (s16)
 
void btl_cam_move (s16)
 
void btl_cam_disable_clamp_x (void)
 
void initialize_battle (void)
 
void dispatch_event_actor (Actor *, s32)
 
s32 dispatch_damage_event_actor_1 (Actor *actor, s32 damageAmount, s32 event)
 
void reset_battle_status (void)
 
void btl_show_variable_battle_message (s32, s32, s32)
 
s32 btl_is_popup_displayed (void)
 
void btl_cam_use_preset_immediately (s32)
 
s32 inflict_status (Actor *, s32, s32)
 
s32 try_inflict_status (Actor *, s32, s32)
 
s32 inflict_status_set_duration (Actor *actor, s32 statusTypeKey, s32 statusDurationKey, s32 duration)
 
void mdl_set_all_tint_type (s32)
 
void load_model_animator_tree (s32, StaticAnimatorNode **)
 
s32 inflict_partner_ko (Actor *target, s32 statusTypeKey, s32 duration)
 
s32 get_defense (Actor *actor, s32 *defenseTable, s32 elementFlags)
 
void btl_popup_messages_init (void)
 
void remove_all_effects (void)
 
void update_effects (void)
 
void update_cameras (void)
 
void clear_render_tasks (void)
 
void clear_worker_list (void)
 
void clear_printers (void)
 
void clear_item_entity_data (void)
 
void clear_player_data (void)
 
void phys_update_jump (void)
 
void phys_update_falling (void)
 
void check_input_midair_jump (void)
 
void collision_check_player_overlaps (void)
 
void update_player_input (void)
 
void phys_update_action_state (void)
 
void collision_main_lateral (void)
 
void player_surface_spawn_fx (void)
 
void check_input_open_menus (void)
 
void check_input_status_bar (void)
 
void update_player (void)
 
void enforce_hpfp_limits (void)
 
s32 should_collider_allow_interact (s32)
 
void show_coin_counter (void)
 
void hide_coin_counter_immediately (void)
 
void hide_popup_menu (void)
 
void destroy_popup_menu (void)
 
void reset_player_status (void)
 
void player_reset_data (void)
 
void partner_reset_data (void)
 
s32 has_valid_conversation_npc (void)
 
s32 func_800E06D8 (void)
 
void func_800E01DC (void)
 
void collision_lateral_peach (void)
 
void func_800E5520 (void)
 
void clear_world_menus (void)
 
void setup_status_bar_for_battle (void)
 
void enable_status_bar_input (void)
 
void disable_status_bar_input (void)
 
b32 can_control_status_bar (void)
 
void status_bar_respond_to_changes (void)
 
void status_bar_always_show_on (void)
 
void status_bar_always_show_off (void)
 
void star_power_shimmer_start (s32, f32, f32, f32)
 
void star_power_shimmer_init (void)
 
void star_power_shimmer_update (void)
 
void star_power_shimmer_draw (void)
 
void shop_open_item_select_popup (s32 mode)
 
void hide_coin_counter (void)
 
void set_message_text_var (s32 msgID, s32 index)
 
void set_message_int_var (s32 value, s32 index)
 
void open_status_bar_quickly (void)
 
void show_immune_bonk (f32 x, f32 y, f32 z, s32, s32, s32)
 
void show_primary_damage_popup (f32 x, f32 y, f32 z, s32 attack, s32 a)
 
s32 dispatch_damage_event_partner (s32 damageAmount, s32 event, s32 stopMotion)
 
void disable_actor_blur (Actor *)
 
void reset_actor_blur (Actor *)
 
void enable_actor_blur (Actor *)
 
void apply_shock_effect (Actor *)
 
void part_glow_off (s32, ActorPart *, s32 yaw, b32 arg3)
 
void part_flash_off (b32 isNpcSprite, ActorPart *part, s32 yaw, b32 isReflection)
 
void part_flash_on (b32 isNpcSprite, ActorPart *part, s32 yaw, b32 isReflection)
 
void _add_part_decoration (ActorPart *)
 
void _remove_part_decoration (ActorPart *part, s32 decorationIndex)
 
void remove_part_decor_none (ActorPart *, s32)
 
void remove_part_decor_golden_flames (ActorPart *, s32)
 
void remove_part_decor_sweat (ActorPart *, s32)
 
void remove_part_decor_seeing_stars (ActorPart *, s32)
 
void remove_part_decor_red_flames (ActorPart *, s32)
 
void remove_part_decor_smoky_trail (ActorPart *, s32)
 
void remove_part_decor_fiery_trail (ActorPart *, s32)
 
void remove_part_decor_whirlwind (ActorPart *, s32)
 
void remove_part_decor_steam (ActorPart *, s32)
 
void remove_part_decor_sparkles (ActorPart *, s32)
 
void remove_part_decor_bowser_aura (ActorPart *, s32)
 
void remove_part_decor_radiating_stars (ActorPart *, s32)
 
void status_bar_ignore_changes (void)
 
void imgfx_release_instance (u32)
 
void set_script_flags (Evt *script, s32 flags)
 
void clear_script_flags (Evt *script, s32 flags)
 
void disable_player_blur (void)
 
void enable_player_blur (void)
 
void reset_player_blur (void)
 
void force_disable_player_blur (void)
 
void force_disable_player_blur_immediately (void)
 
void func_8023E104 (void)
 
void func_8023E11C (void)
 
void set_goal_pos_to_part (ActorState *state, s32 actorID, s32 partID)
 
void init_encounters_ui (void)
 
void initialize_collision (void)
 
void render_entities (void)
 
void render_player (void)
 
void render_workers_scene (void)
 
void render_effects_scene (void)
 
s32 get_asset_offset (char *, s32 *)
 
void initialize_status_bar (void)
 
void status_bar_start_blinking_fp (void)
 
s32 is_status_bar_visible (void)
 
void status_bar_start_blinking_starpoints (void)
 
void status_bar_stop_blinking_starpoints (void)
 
void status_bar_start_blinking_hp (void)
 
void status_bar_start_blinking_sp (void)
 
void status_bar_stop_blinking_fp (void)
 
void status_bar_stop_blinking_hp (void)
 
void status_bar_stop_blinking_sp (void)
 
void status_bar_start_blinking_sp_bars (s32 numBarsToBlink)
 
void status_bar_draw_number (s32 iconID, s32 x, s32 y, s32 value, s32 numDigits)
 
void status_bar_draw_stat (s32 id, s32 x, s32 y, s32, s32)
 
void set_background_size (s16, s16, s16, s16)
 
void set_background (BackgroundHeader *)
 
void set_max_star_power (s8)
 
void sync_status_bar (void)
 
void create_cameras (void)
 
void func_80045AC0 (void)
 
void func_8005AF84 (void)
 
void npc_follow_init (Npc *, s32, FollowAnims *, f32, f32, s32, s32)
 
void npc_update_npc_tracking (Npc *)
 
void npc_follow_npc (Npc *)
 
void create_encounters (void)
 
void update_encounters_neutral (void)
 
void update_encounters_pre_battle (void)
 
void update_encounters_conversation (void)
 
void update_encounters_post_battle (void)
 
void load_map_bg (char *optAssetName)
 
void reset_background_settings (void)
 
void func_80138188 (void)
 
void func_80266970 (Actor *)
 
void show_actor_health_bar (Actor *)
 
void hide_actor_health_bar (Actor *)
 
void clear_part_pal_adjustment (ActorPart *)
 
void calculate_camera_yinterp_rate (void)
 
void load_tattle_flags (s32)
 
s32 use_consumable (s32 invSlot)
 
void remove_consumable (void)
 
void delete_shadow (s32)
 
void partner_reset_tether_distance (void)
 
void save_tattle_flags (s32)
 
void update_merlee_messages (void)
 
void draw_merlee_messages (void)
 
void show_merlee_message (s16, s16)
 
s32 is_merlee_message_done (void)
 
void close_action_command_instruction_popup (void)
 
void draw_encounters_conversation (void)
 
void draw_encounters_post_battle (void)
 
void draw_encounters_pre_battle (void)
 
void draw_encounters_neutral (void)
 
void show_first_strike_message (void)
 
void entity_upgrade_block_hide_content (s32)
 
s32 lookup_defense (s32 *, s32)
 
s32 lookup_status_chance (s32 *, s32)
 
void peach_check_for_parasol_input (void)
 
void peach_sync_disguise_npc (void)
 
b32 check_conversation_trigger (void)
 
void clear_player_status (void)
 
void clear_entity_models (void)
 
void bind_entity_model_setupGfx (s32 idx, void *setupGfxCallbackArg0, void(*fpSetupGfxCallback)(void *))
 
void clear_animator_list (void)
 
void clear_model_data (void)
 
void init_sprite_shading_data (void)
 
void clear_sprite_shading_data (void)
 
void clear_character_set (void)
 
void clear_trigger_data (void)
 
void clear_script_list (void)
 
void clear_entity_data (b32)
 
void clear_effect_data (void)
 
void clear_saved_variables (void)
 
void clear_area_flags (void)
 
f32 get_player_normal_pitch (void)
 
void partner_kill_ability_script (void)
 
void func_800EF3D4 (s32)
 
void mdl_update_transform_matrices (void)
 
void mdl_group_set_custom_gfx (u16, s32, s32, b32)
 
void backup_map_collision_data (void)
 
void reset_status_bar (void)
 
void btl_save_world_cameras (void)
 
void load_battle_section (void)
 
void btl_update (void)
 
void update_item_entities (void)
 
void restore_map_collision_data (void)
 
void mdl_load_all_textures (struct ModelNode *model, s32 romOffset, s32 size)
 
void mdl_calculate_model_sizes (void)
 

Function Documentation

◆ fabsf()

f32 fabsf ( f32 f)

Referenced by action_update_run(), action_update_sliding(), action_update_use_spinning_flower(), action_update_use_tweester(), action_update_walk(), appendGfx_background_texture(), ArcsinDeg(), atan2(), AvoidPlayerAI_ChaseInit(), basic_ai_chase_init(), basic_ai_check_player_dist(), btl_main_menu_draw(), calculate_line_segment_intersection(), calculate_segment_intersection(), check_conversation_trigger(), clamp_angle(), CleftAI_CanSeePlayer(), collision_main_above(), collision_main_lateral(), create_shading_palette(), Entity_BoardedFloor_update_fragments(), entity_BombableRock_update_fragments(), entity_Chest_idle(), entity_shattering_idle(), entity_Signpost_idle(), entity_Tweester_has_reached_target(), entity_WoodenCrate_update_fragments(), FlyingAI_LosePlayer(), FlyingAI_Wander(), FlyingNoAttackAI_12(), get_clamped_angle_diff(), get_maximum_interp_delta(), GuardAI_ChaseInit(), HoppingAI_Chase(), HoppingAI_Hop(), MagikoopaAI_CanShootSpell(), MeleeHitbox_CanSeePlayer(), npc_do_player_collision(), npc_find_closest(), npc_find_closest_simple(), npc_follow_npc(), npc_get_render_yaw(), npc_raycast_down(), npc_raycast_down_around(), npc_raycast_down_sides(), npc_test_move_complex_with_slipping(), npc_test_move_simple_with_slipping(), npc_test_move_simple_without_slipping(), npc_test_move_taller_with_slipping(), npc_try_apply_gravity(), npc_try_snap_to_ground(), partner_do_player_collision(), partner_flying_follow_player(), partner_flying_update_motion(), partner_get_out(), partner_move_to_goal(), partner_walking_follow_player(), partner_walking_update_motion(), PatrolAI_ChaseInit(), phys_is_on_sloped_ground(), player_check_collision_below(), player_raycast_below(), player_update_sprite(), ProjectileHitbox_GetUsableProjectileID(), SentinelAI_ChaseInit(), SentinelAI_Descend(), sfx_compute_spatialized_sound_params_with_depth(), test_player_entity_aabb(), update_camera_from_controller(), update_camera_interp_pos(), update_encounters_neutral(), and update_unused_lead_amt().

◆ fabs()

◆ cosine()

f32 cosine ( s16 arg0)

Definition at line 353 of file 43F0.c.

353 {
354 s16 temp360;
355 s16 idx;
356
357 temp360 = arg0 % 360;
358
359 if (temp360 < 0) {
360 temp360 += 360;
361 }
362
363 idx = temp360 % 180;
364 if (idx > 90) {
365 idx = 180 - idx;
366 }
367
368 if (temp360 >= 180) {
369 return -sCosineTable[idx];
370 } else {
371 return sCosineTable[idx];
372 }
373}
f32 sCosineTable[]
Definition 43F0.c:8

Referenced by appendGfx_message(), imgfx_appendGfx_mesh(), msg_draw_choice_pointer(), msg_draw_speech_arrow(), msg_update_rewind_arrow(), npc_update_decoration_charged(), part_glow_on(), and SentinelAI_Descend().

◆ nuBoot()

void nuBoot ( void )

◆ boot_idle()

void boot_idle ( void * data)

◆ boot_main()

void boot_main ( void * data)

Definition at line 52 of file main.c.

52 {
53#if VERSION_JP
54 if (osTvType == OS_TV_NTSC) {
55 nuGfxDisplayOff();
56 osViSetMode(&osViModeNtscLan1);
57 osViSetSpecialFeatures(OS_VI_GAMMA_OFF | OS_VI_GAMMA_DITHER_OFF | OS_VI_DIVOT_ON | OS_VI_DITHER_FILTER_ON);
58 nuGfxDisplayOff();
59 } else {
60 PANIC();
61 }
62#else // not VERSION_JP
63 if (osTvType == OS_TV_NTSC) {
64 osViSetMode(&osViModeNtscLan1);
65 osViSetSpecialFeatures(OS_VI_GAMMA_OFF | OS_VI_GAMMA_DITHER_OFF | OS_VI_DIVOT_ON | OS_VI_DITHER_FILTER_ON);
66 } else if (osTvType == OS_TV_MPAL) {
67 osViSetMode(&osViModeMpalLan1);
68 osViSetSpecialFeatures(OS_VI_GAMMA_OFF | OS_VI_GAMMA_DITHER_OFF | OS_VI_DIVOT_ON | OS_VI_DITHER_FILTER_ON);
69 } else {
70 PANIC();
71 }
72
73 nuGfxDisplayOff();
75#endif
76
77#if !VERSION_IQUE
79#endif
80 nuGfxInit();
81 gGameStatusPtr->contBitPattern = nuContInit();
82
83#if !VERSION_IQUE
85#endif
88
89 nuGfxFuncSet((NUGfxFunc) gfxRetrace_Callback);
90 nuGfxPreNMIFuncSet(gfxPreNMI_Callback);
91 nuGfxTaskEndFunc = gfx_task_end_callback;
92 gRandSeed += osGetCount();
93 nuGfxDisplayOn();
94
95 while (TRUE) {}
96}
void is_debug_init(void)
Definition is_debug.c:19
void load_obfuscation_shims(void)
void shim_create_audio_system_obfuscated(void)
void shim_load_engine_data_obfuscated(void)
void crash_screen_init(void)
void gfxPreNMI_Callback(void)
Definition main.c:206
void gfxRetrace_Callback(s32)
Definition main.c:98
void gfx_task_end_callback(void *unk)
Definition main.c:48
#define PANIC()
Definition macros.h:55
GameStatus * gGameStatusPtr
Definition main_loop.c:32
u32 gRandSeed
Definition 43F0.c:28

◆ is_debug_init()

void is_debug_init ( void )

Definition at line 19 of file is_debug.c.

19 {
20 osEPiWriteIo(nuPiCartHandle, (u32) &gISVDbgPrnAdrs->put, 0);
21 osEPiWriteIo(nuPiCartHandle, (u32) &gISVDbgPrnAdrs->get, 0);
22 osEPiWriteIo(nuPiCartHandle, (u32) &gISVDbgPrnAdrs->magic, ASCII_TO_U32('I', 'S', '6', '4'));
23}
#define gISVDbgPrnAdrs
Definition is_debug.c:15
#define ASCII_TO_U32(a, b, c, d)
Definition macros.h:183

Referenced by boot_main().

◆ is_debug_panic()

void is_debug_panic ( const char * message)

Definition at line 93 of file is_debug.c.

93 {
95 *(volatile u32*)0 = 0; // Crash so we can see the crash screen
96}
void crash_screen_set_assert_info(const char *message)

◆ signF()

f32 signF ( f32 val)

Definition at line 556 of file 43F0.c.

556 {
557 f32 sign;
558
559 if (!(val > 0.0f)) {
560 sign = -1.0f;
561 if (!(val < 0.0f)) {
562 sign = 0.0f;
563 }
564 } else {
565 sign = 1.0f;
566 }
567
568 return sign;
569}
s32 sign(s32 val)
Definition 43F0.c:375

Referenced by FireBarAI_Callback().

◆ func_8002ACDC()

s32 func_8002ACDC ( void )

Definition at line 30 of file heap.c.

30 {
31 return 0;
32}

Referenced by state_step_end_battle(), and state_step_unpause().

◆ load_obfuscation_shims()

void load_obfuscation_shims ( void )

Definition at line 22 of file load_obfuscation_shims.c.

22 {
23 s32 (*readFunc)(OSPiHandle*, u32, u32*);
24 s32 (*readFunc2)(OSPiHandle*, u32, u32*);
27 s32 seed;
28 u32 hash;
29 u32 thisInsn;
30 u32 thisInsn2;
31 u32 prevInsn;
32 u8* it;
33
34 // vramDest
35 readFunc = osEPiReadIo;
36 seed = 0x0B112D28;
37 hash = 0;
38 readFunc(nuPiCartHandle, 0xB0000D10, &thisInsn);
39 seed -= thisInsn;
40 prevInsn = 0;
41
42 for (it = battle_heap_create_obfuscated_ROM_START; it < battle_heap_create_obfuscated_ROM_END; it += 4) {
43 readFunc(nuPiCartHandle, (u32)it, &thisInsn);
44 hash += LOWER(thisInsn) + UPPER(thisInsn);
45
46 if (OPCODE(prevInsn) == LUI && (OPCODE(thisInsn) == ADDIU || OPCODE(thisInsn) == LW)) {
47 if (GET_RS(thisInsn) == GET_RT(prevInsn) && GET_RS(thisInsn) == GET_RT(thisInsn)) {
48 hash -= LOWER(thisInsn);
49 hash -= LOWER(prevInsn);
50 }
51 }
52
53 if (OPCODE(thisInsn) == JAL) {
54 hash -= LOWER(thisInsn) + (UPPER(thisInsn) & 0xFC00);
55 }
56
57 prevInsn = thisInsn;
58 }
59 vramDest += seed + 0x2A4EB6 - hash;
60
61 // romStart
62 readFunc2 = osEPiReadIo;
63 seed = 0x18F414AB;
64 hash = 0;
65 readFunc2(nuPiCartHandle, 0xB0000E38, &thisInsn2);
66 seed -= thisInsn2;
67 prevInsn = 0;
68
69 for (it = obfuscation_shims_ROM_START; it < obfuscation_shims_ROM_END; it += 4) {
70 readFunc2(nuPiCartHandle, (u32)it, &thisInsn2);
71 hash += LOWER(thisInsn2) + UPPER(thisInsn2);
72
73 if (OPCODE(prevInsn) == LUI && (OPCODE(thisInsn2) == ADDIU || OPCODE(thisInsn2) == LW)) {
74 if (GET_RS(thisInsn2) == GET_RT(prevInsn) && GET_RS(thisInsn2) == GET_RT(thisInsn2)) {
75 hash -= LOWER(thisInsn2);
76 hash -= LOWER(prevInsn);
77 }
78 }
79
80 if (OPCODE(thisInsn2) == JAL) {
81 hash -= LOWER(thisInsn2) + (UPPER(thisInsn2) & 0xFC00);
82 }
83 prevInsn = thisInsn2;
84 }
85 romStart += seed + 0xED41C - hash;
86
87 dma_copy(romStart, obfuscation_shims_ROM_END, vramDest);
88}
u32 dma_copy(Addr romStart, Addr romEnd, void *vramDest)
Definition 43F0.c:443
s8 obfuscated_obfuscation_shims_VRAM[]
s8 obfuscated_obfuscation_shims_ROM_START[]
#define ADDIU
Definition mips.h:5
#define LOWER(x)
Definition mips.h:8
#define GET_RS(x)
Definition mips.h:11
#define UPPER(x)
Definition mips.h:9
#define JAL
Definition mips.h:4
#define GET_RT(x)
Definition mips.h:12
#define LW
Definition mips.h:7
#define OPCODE(x)
Definition mips.h:10
#define LUI
Definition mips.h:6

Referenced by boot_main(), load_map_by_IDs(), and state_step_battle().

◆ heap_malloc()

void * heap_malloc ( s32 size)

Definition at line 34 of file heap.c.

34 {
36 return general_heap_malloc(size);
37 } else {
38 return _heap_malloc(&heap_battleHead, size);
39 }
40}
#define general_heap_malloc
@ CONTEXT_WORLD
Definition enums.h:3528
void * _heap_malloc(HeapNode *head, u32 size)
Definition 43F0.c:78
HeapNode heap_battleHead

Referenced by add_anim_node(), ALT_clear_hud_element_cache(), ALT_load_entity_model(), clear_virtual_entity_list(), clone_model(), create_actor(), create_encounters(), create_entity(), create_mesh_animator(), create_model_animator(), create_npc_impl(), create_shadow_from_data(), create_trigger(), create_worker_backUI(), create_worker_frontUI(), create_worker_scene(), enable_npc_blur(), evt_handle_allocate_array(), func_802C39F8(), get_asset_offset(), hud_element_create(), imgfx_load_anim(), imgfx_mesh_anim_update(), imgfx_update(), load_asset_by_name(), load_battle_hit_asset(), load_entity_model(), load_map_hit_asset(), load_partner_actor(), load_path_data(), load_player_actor(), make_item_entity(), make_item_entity_at_player(), mdl_create_model(), mdl_make_local_vertex_copy(), mdl_make_transform_group(), msg_copy_to_print_buffer(), npc_follow_init(), reset_model_animators(), show_immune_bonk(), start_child_script(), start_script(), start_script_in_group(), state_init_logos(), state_init_title_screen(), and update_item_entity_collectable().

◆ _heap_malloc()

void * _heap_malloc ( HeapNode * head,
u32 size )

Definition at line 78 of file 43F0.c.

78 {
79 HeapNode* nextHeapNode;
80 HeapNode* pPrevHeapNode = NULL;
81 u32 newBlockSize;
82 u32 curBlockLength;
83 HeapNode* curHeapNode;
84 u32 smallestBlockFound;
85 u16 HeapEntryID;
86 u16 HeapEntryID2;
87
88 // must allocate 16 bytes or more at minimum or fail
89 size = ALIGN16(size);
90 if (!size) {
91 debug_printf("warning: attempt to malloc less than 16 bytes\n");
92 return NULL;
93 }
94
95 smallestBlockFound = 0;
96 nextHeapNode = NULL;
97
98 // find the smallest block we can fit into in the free list
99 for (curHeapNode = head; ; curHeapNode = curHeapNode->next) {
100 if (!curHeapNode->allocated) {
101 curBlockLength = curHeapNode->length;
102 if ((curBlockLength >= size) && (curBlockLength < smallestBlockFound || !smallestBlockFound)) {
103 pPrevHeapNode = curHeapNode;
104 smallestBlockFound = curBlockLength;
105 nextHeapNode = curHeapNode->next;
106 }
107 }
108 if (!curHeapNode->next) {
109 break;
110 }
111 }
112
113 // find out the required block size with header
114 newBlockSize = size + sizeof(HeapNode);
115
116 // if we found a block see if we need to split it up
117 if (smallestBlockFound) {
118 if (smallestBlockFound >= newBlockSize) {
119 // update previous to the proper size for the block being returned
120 pPrevHeapNode->next = (HeapNode*)((u8*)pPrevHeapNode + newBlockSize);
121 pPrevHeapNode->length = size;
122
123 // update the entry id on allocation
124 HeapEntryID = heap_nextMallocID;
125 pPrevHeapNode->allocated = TRUE;
126 heap_nextMallocID = HeapEntryID + 1;
127 pPrevHeapNode->entryID = HeapEntryID;
128
129 // setup the new heap block entry
130 curHeapNode = pPrevHeapNode->next;
131 curHeapNode->next = nextHeapNode;
132 curHeapNode->length = smallestBlockFound - newBlockSize;
133 curHeapNode->allocated = FALSE;
134 } else {
135 // take this entry out of the free linked list and mark as allocated
136 pPrevHeapNode->next = nextHeapNode;
137 pPrevHeapNode->length = smallestBlockFound;
138
139 // update the entry id on allocation
140 // note, usage of a single ID from above will result in wrong code
141 HeapEntryID2 = heap_nextMallocID;
142 pPrevHeapNode->allocated = TRUE;
143 heap_nextMallocID = HeapEntryID2 + 1;
144 pPrevHeapNode->entryID = HeapEntryID2;
145 }
146 return (u8*)pPrevHeapNode + sizeof(HeapNode);
147 }
148 debug_printf("warning: out of memory\n");
149 return NULL;
150}
u16 heap_nextMallocID
Definition 43F0.c:6
struct HeapNode * next
#define ALIGN16(val)
Definition macros.h:20

Referenced by _heap_realloc(), collision_heap_malloc(), general_heap_malloc(), heap_malloc(), imgfx_init(), spr_allocate_components(), spr_init_player_raster_cache(), spr_init_quad_cache(), and spr_load_sprite().

◆ _heap_malloc_tail()

void * _heap_malloc_tail ( HeapNode * head,
u32 size )

Definition at line 152 of file 43F0.c.

152 {
153 HeapNode* curNode;
154 u32 newNodeSize;
155 u32 foundNodeLength;
156 HeapNode* foundNode;
157 HeapNode* nextNode;
158
159 size = ALIGN16(size);
160 foundNode = NULL;
161
162 // make sure we have a size to allocate
163 if (!size) {
164 debug_printf("warning: attempt to malloc less than 16 bytes\n");
165 return NULL;
166 }
167
168 foundNodeLength = 0;
169 nextNode = NULL;
170
171 // find the smallest block we can fit into
172 for (curNode = head; ; curNode = curNode->next) {
173 if (!curNode->allocated) {
174 if (curNode->length >= size) {
175 foundNode = curNode;
176 foundNodeLength = curNode->length;
177 nextNode = curNode->next;
178 }
179 }
180
181 if (!curNode->next) {
182 break;
183 }
184 }
185
186 newNodeSize = size + sizeof(HeapNode);
187 if (foundNodeLength != 0) {
188 curNode = foundNode;
189
190 // we found a block to use, see if we can split it and return a portion
191 // or if we just need to return the whole block
192 if (foundNodeLength >= newNodeSize) {
193 // add a free block before this one
194 // this is where this function differs from heap_malloc, it returns
195 // the end of the block instead of the beginning when splitting it up
196 curNode->next = (HeapNode*)((u8*)curNode + foundNodeLength - size);
197 curNode->length = foundNodeLength - newNodeSize;
198 curNode->allocated = FALSE;
199
200 curNode = curNode->next;
201 curNode->next = nextNode;
202 curNode->length = size;
203 curNode->allocated = TRUE;
204
205 } else {
206 // just return this actual block
207 curNode->next = nextNode;
208 curNode->length = foundNodeLength;
209 curNode->allocated = TRUE;
210 }
211
212 return (u8*)curNode + sizeof(HeapNode);
213 }
214
215 // did not find a block
216 debug_printf("warning: out of memory\n");
217 return NULL;
218}

Referenced by general_heap_malloc_tail(), and spr_load_sprite().

◆ _heap_free()

u32 _heap_free ( HeapNode * heapNodeList,
void * addrToFree )

Definition at line 220 of file 43F0.c.

220 {
221 u32 curNodeLength;
222 HeapNode* nextNode;
223 HeapNode* nodeToFreeHeader;
224 HeapNode* tempNode;
225 HeapNode* outNode;
226
227 // if no address to free then return
228 if (addrToFree == NULL) {
229 return TRUE;
230 }
231
232 // if we are not allocated then ignore this request
233 nodeToFreeHeader = (HeapNode*)((u8*)addrToFree - sizeof(HeapNode));
234 if (!nodeToFreeHeader->allocated) {
235 return TRUE;
236 }
237
238 nextNode = nodeToFreeHeader->next;
239 curNodeLength = nodeToFreeHeader->length;
240 outNode = nextNode;
241
242 // see if the next node after us is allocated, if not then adjust our size
243 // to include it and point nextNode to be the node after as it must be allocated
244 if (nextNode && !nextNode->allocated) {
245 curNodeLength += nextNode->length + sizeof(HeapNode);
246 nextNode = nextNode->next;
247 }
248
249 // walk the full heap node list looking for the block before our current entry
250 tempNode = heapNodeList;
251 while (TRUE) {
252 // get the pointer to the next block, if it matches the block being freed then
253 // exit the search
254 heapNodeList = tempNode->next;
255 if (heapNodeList == nodeToFreeHeader) {
256
257 // we found the node prior to us, if it is not allocated then adjust our total
258 // size to include it and change the header node pointer to point that block
259 if (!tempNode->allocated) {
260 curNodeLength += sizeof(HeapNode) + tempNode->length;
261 nodeToFreeHeader = tempNode;
262 }
263 break;
264 }
265
266 // if the node being freed is before the current node being looked at then we
267 // moved past our current node, bail out. Also bail if we hit the end of the list
268 if (nodeToFreeHeader < tempNode || !heapNodeList) {
269 break;
270 }
271
272 // move to the next node
273 tempNode = tempNode->next;
274 }
275
276 // update the node being free'd with a proper size and pointer to the next node that is
277 // allocated
278 outNode = nodeToFreeHeader;
279 outNode->next = nextNode;
280 outNode->length = curNodeLength;
281 outNode->allocated = FALSE;
282 return FALSE;
283}

Referenced by _heap_realloc(), collision_heap_free(), general_heap_free(), heap_free(), and spr_free_sprite().

◆ _heap_realloc()

void * _heap_realloc ( HeapNode * heapNodeList,
void * addr,
u32 newSize )

Definition at line 285 of file 43F0.c.

285 {
286 u32 newSizeAligned;
287 HeapNode* nextNode;
288 HeapNode* curHeapAlloc;
289 HeapNode* newFreeBlock;
290 u32 newNodeLength;
291 HeapNode* nodeToUpdate;
292
293 curHeapAlloc = (HeapNode*)((u8*)addr - sizeof(HeapNode));
294 newSizeAligned = ALIGN16(newSize);
295
296 // check if the realloc is on an allocated node otherwise fail
297 if (!curHeapAlloc->allocated) {
298 return NULL;
299 }
300
301 nextNode = curHeapAlloc->next;
302 newNodeLength = curHeapAlloc->length;
303
304 // if we have a node after us and it isn't allocated then
305 // adjust the length and next node pointers to include the node after us
306 nodeToUpdate = nextNode;
307 if (nextNode && !nextNode->allocated) {
308 nextNode = nextNode->next;
309 newNodeLength += sizeof(HeapNode) + nodeToUpdate->length;
310 }
311
312 // check if the current block or current + next block (if free) are too small
313 nodeToUpdate = curHeapAlloc;
314 if (newNodeLength < newSizeAligned) {
315 // too small, allocatr a new node, copy data to it then free the current one
316 curHeapAlloc = _heap_malloc(heapNodeList, newSizeAligned);
317 if (curHeapAlloc == NULL) {
318 return NULL;
319 }
320
321 // minor interest note, copy the size of the newly allocated size
322 // instead of just how much data used to be stored, this results in copying
323 // excessive data
324 memcpy(curHeapAlloc, addr, newSizeAligned);
325 _heap_free(heapNodeList, addr);
326 return curHeapAlloc;
327 }
328
329 // see if there is room to add a new free block after us
330 if (newSizeAligned + sizeof(HeapNode) < newNodeLength) {
331 // room for a free block, create it
332 newFreeBlock = (HeapNode*)((u8*)addr + newSizeAligned);
333
334 // update current node
335 nodeToUpdate->next = newFreeBlock;
336 nodeToUpdate->length = newSizeAligned;
337
338 // create new node after the current one
339 nodeToUpdate = newFreeBlock;
340 nodeToUpdate->next = nextNode;
341 nodeToUpdate->length = (newNodeLength - newSizeAligned) - sizeof(HeapNode);
342 nodeToUpdate->allocated = FALSE;
343 } else {
344 // no room, update our next and length
345 nodeToUpdate->next = nextNode;
346 nodeToUpdate->length = newNodeLength;
347 }
348
349 // return the location we were at
350 return addr;
351}
void * _heap_malloc(HeapNode *head, u32 size)
Definition 43F0.c:78
u32 _heap_free(HeapNode *heapNodeList, void *addrToFree)
Definition 43F0.c:220

Referenced by spr_load_npc_extra_anims().

◆ _heap_create()

HeapNode * _heap_create ( HeapNode * addr,
u32 size )

Definition at line 63 of file 43F0.c.

63 {
64 if (size < 32) {
65 return (HeapNode*)-1;
66 } else {
67 HeapNode* heapNode = (HeapNode*)ALIGN16((u32)addr);
68
69 size -= ((u8*)heapNode - (u8*)addr);
70 heapNode->next = NULL;
71 heapNode->length = size - sizeof(HeapNode);
72 heapNode->allocated = 0;
73 heapNode->capacity = size;
74 return heapNode;
75 }
76}

Referenced by battle_heap_create(), battle_heap_create_obfuscated(), collision_heap_create(), general_heap_create(), and spr_init_sprites().

◆ dma_copy()

u32 dma_copy ( Addr romStart,
Addr romEnd,
void * vramDest )

Definition at line 443 of file 43F0.c.

443 {
444 u32 length = romEnd - romStart;
445 s32 i;
446
447 osInvalICache(vramDest, length);
448
449 for (i = 0; i + ROM_CHUNK_SIZE < length; i += ROM_CHUNK_SIZE) {
450 nuPiReadRom((u32)romStart + i, vramDest + i, ROM_CHUNK_SIZE);
451 }
452
453 if (i != length) {
454 nuPiReadRom((u32)romStart + i, vramDest + i, length - i);
455 }
456
457 return length;
458}
#define ROM_CHUNK_SIZE
Definition 43F0.c:57

Referenced by create_partner_npc(), dma_load_msg(), get_asset_offset(), imgfx_load_anim(), imgfx_mesh_anim_update(), load_asset_by_name(), load_battle_section(), load_effect(), load_font_data(), load_map_by_IDs(), load_obfuscation_shims(), load_simple_entity_data(), load_split_entity_data(), load_texture_by_name(), load_texture_impl(), load_texture_variants(), msg_copy_to_print_buffer(), phys_peach_update(), phys_update_action_state(), reload_world_entity_data(), state_init_logos(), state_step_end_battle(), state_step_unpause(), and use_consumable().

◆ rand_float()

f32 rand_float ( void )

Definition at line 503 of file 43F0.c.

503 {
504 return (advance_rng() & 0x7FFF) / 32768.0;
505}
u32 advance_rng(void)
Definition 43F0.c:494

Referenced by entity_shattering_init_pieces().

◆ copy_matrix()

void copy_matrix ( Matrix4f src,
Matrix4f dest )

Definition at line 438 of file 43F0.c.

438 {
439 bcopy(src, dest, sizeof(Matrix4f));
440}
f32 Matrix4f[4][4]

Referenced by animator_node_update_model_transform(), and update_collider_transform().

◆ get_shadow_by_index()

◆ get_time_freeze_mode()

s32 get_time_freeze_mode ( void )

Definition at line 390 of file main_loop.c.

390 {
391 return gTimeFreezeMode;
392}
s32 gTimeFreezeMode
Definition main_loop.c:12

Referenced by entity_Tweester_idle(), state_step_battle(), test_item_entity_position(), and test_item_player_collision().

◆ render_player_model()

void render_player_model ( void )

Definition at line 1495 of file 77480.c.

1495 {
1496 RenderTask task;
1497 RenderTask* rtPtr = &task;
1498 PlayerStatus* playerStatus = &gPlayerStatus;
1499 s32 x, y, z;
1500
1501 if (playerStatus->flags & PS_FLAG_SPRITE_REDRAW) {
1502 playerStatus->flags &= ~PS_FLAG_SPRITE_REDRAW;
1503 get_screen_coords(gCurrentCamID, playerStatus->pos.x, playerStatus->pos.y,
1504 playerStatus->pos.z, &x, &y, &z);
1505 if (!(playerStatus->flags & PS_FLAG_SPINNING)) {
1506 if (playerStatus->curAlpha != playerStatus->prevAlpha) {
1507 if (playerStatus->curAlpha < 254) {
1508 if (playerStatus->animFlags & PA_FLAG_MAP_HAS_SWITCH) {
1510 } else {
1512 }
1513 set_player_imgfx_comp(PLAYER_SPRITE_MAIN, -1, IMGFX_SET_ALPHA, 0, 0, 0, playerStatus->curAlpha, 0);
1514
1515 } else {
1516 playerStatus->renderMode = RENDER_MODE_ALPHATEST;
1518 }
1519 }
1520
1521 playerStatus->prevAlpha = playerStatus->curAlpha;
1522
1523 } else {
1525 playerStatus->prevAlpha = 0;
1526 }
1527
1528 if (!(playerStatus->animFlags & PA_FLAG_INVISIBLE)) {
1529 rtPtr->appendGfxArg = playerStatus;
1530 rtPtr->dist = -z;
1531 rtPtr->renderMode = playerStatus->renderMode;
1532
1533 if (playerStatus->flags & PS_FLAG_SPINNING) {
1535 } else {
1536 rtPtr->appendGfx = appendGfx_player;
1537 }
1538
1539 queue_render_task(rtPtr);
1540 }
1541 }
1542}
void appendGfx_player_spin(void *data)
Only used when speedy spinning.
Definition 77480.c:1601
PlayerStatus gPlayerStatus
Definition 77480.c:39
void appendGfx_player(void *data)
Definition 77480.c:1544
#define queue_render_task
@ IMGFX_SET_ALPHA
Definition enums.h:5123
@ IMGFX_CLEAR
Definition enums.h:5116
@ PS_FLAG_SPINNING
Definition enums.h:3058
@ PS_FLAG_SPRITE_REDRAW
Definition enums.h:3083
@ PA_FLAG_MAP_HAS_SWITCH
Definition enums.h:3119
@ PA_FLAG_INVISIBLE
Definition enums.h:3104
@ RENDER_MODE_SURFACE_XLU_LAYER2
Definition enums.h:3287
@ RENDER_MODE_ALPHATEST
Definition enums.h:3276
@ RENDER_MODE_SURFACE_XLU_LAYER1
Definition enums.h:3282
void get_screen_coords(s32 camID, f32 x, f32 y, f32 z, s32 *screenX, s32 *screenY, s32 *screenZ)
Definition cam_main.c:410
void set_player_imgfx_comp(s32 spriteIdx, s32 compIdx, ImgFXType imgfx, s32 imgfxArg1, s32 imgfxArg2, s32 imgfxArg3, s32 imgfxArg4, s32 flags)
Definition sprite.c:968
@ PLAYER_SPRITE_MAIN
Definition sprite.h:26
void * appendGfxArg
void(* appendGfx)(void *)
s16 gCurrentCamID
Definition cam_main.c:13

Referenced by render_player().

◆ is_picking_up_item()

s32 is_picking_up_item ( void )
Returns
TRUE when "you got X" popup is on-screen

Definition at line 1554 of file item_entity.c.

1554 {
1555#if VERSION_JP
1556 return isPickingUpItem;
1557#else
1558 b32 ret = D_801565A8 != FALSE;
1559
1560 if (isPickingUpItem) {
1561 ret = TRUE;
1562 }
1563 return ret;
1564#endif
1565}
s32 b32
BSS s16 D_801565A8
Definition item_entity.c:45
BSS s16 isPickingUpItem
Definition item_entity.c:42

Referenced by can_open_world_menu(), check_conversation_trigger(), check_input_open_menus(), check_input_status_bar(), entity_Tweester_idle(), func_802BB000_E2D930(), and update_encounters_neutral().

◆ integrate_gravity()

f32 integrate_gravity ( void )

Definition at line 436 of file 7BB60.c.

436 {
437 PlayerStatus* playerStatus = &gPlayerStatus;
438
439 if (playerStatus->flags & PS_FLAG_ENTERING_BATTLE) {
440 playerStatus->gravityIntegrator[2] += playerStatus->gravityIntegrator[3] / 1.7f;
441 playerStatus->gravityIntegrator[1] += playerStatus->gravityIntegrator[2] / 1.7f;
442 playerStatus->gravityIntegrator[0] += playerStatus->gravityIntegrator[1] / 1.7f;
443 } else {
444 #if DX_DEBUG_MENU
445 if (dx_debug_is_cheat_enabled(DEBUG_CHEAT_HIGH_JUMP)) {
446 playerStatus->gravityIntegrator[2] += playerStatus->gravityIntegrator[3];
447 playerStatus->gravityIntegrator[1] += playerStatus->gravityIntegrator[2] * 1.5;
448 playerStatus->gravityIntegrator[0] += playerStatus->gravityIntegrator[1] * 1.5;
449 return playerStatus->gravityIntegrator[0];
450 }
451 #endif
452
453 playerStatus->gravityIntegrator[2] += playerStatus->gravityIntegrator[3];
454 playerStatus->gravityIntegrator[1] += playerStatus->gravityIntegrator[2];
455 playerStatus->gravityIntegrator[0] += playerStatus->gravityIntegrator[1];
456 }
457
458 return playerStatus->gravityIntegrator[0];
459}
f32 gravityIntegrator[4]
@ PS_FLAG_ENTERING_BATTLE
Definition enums.h:3061
PlayerStatus gPlayerStatus
Definition 77480.c:39

Referenced by action_update_hit_fire(), action_update_knockback(), action_update_spin_jump(), action_update_step_up(), action_update_tornado_jump(), handle_jumping_land_on_switch(), phys_update_jump(), and player_fall_distance().

◆ gravity_use_fall_parms()

◆ get_clamped_angle_diff()

◆ startup_fade_screen_in()

b32 startup_fade_screen_in ( s16 subtractAlpha)

Definition at line 13 of file startup_screen_fading.c.

13 {
14 if (gGameStatusPtr->screenColorA == 0) {
15 return TRUE;
16 }
17
18 gGameStatusPtr->screenColorA -= subtractAlpha;
21 }
22
23 return FALSE;
24}

Referenced by state_step_logos(), and state_step_title_screen().

◆ startup_fade_screen_out()

b32 startup_fade_screen_out ( s16 addAlpha)

Definition at line 26 of file startup_screen_fading.c.

26 {
27 if (gGameStatusPtr->screenColorA == 255) {
28 return TRUE;
29 }
30
31 gGameStatusPtr->screenColorA += addAlpha;
32 if (gGameStatusPtr->screenColorA > 255) {
34 }
35
36 return FALSE;
37}

Referenced by state_step_intro(), state_step_logos(), and state_step_title_screen().

◆ startup_fade_screen_update()

◆ get_entity_type()

◆ get_entity_by_index()

Entity * get_entity_by_index ( s32 index)

Definition at line 530 of file entity.c.

530 {
531 return (*gCurrentEntityListPtr)[index & 0xFFF];
532}
BSS EntityList * gCurrentEntityListPtr
Definition entity.c:53

Referenced by action_hammer_end_swing(), action_update_landing_on_switch(), action_update_spin_jump(), action_update_tornado_jump(), action_update_use_spinning_flower(), check_for_interactables(), check_input_jump(), delete_entity(), delete_entity_and_unload_data(), entity_ArrowSign_setupGfx(), entity_base_block_setupGfx(), entity_BlueWarpPipe_setupGfx(), Entity_BoardedFloor_setupGfx(), entity_BombableRock_setupGfx(), entity_Chest_setupGfx(), entity_HeartBlock_create_child_entity(), entity_HeartBlockContent__reset(), entity_HeartBlockContent__setupGfx(), entity_HeartBlockContent_anim_idle(), entity_HeartBlockContent_set_initial_pos(), entity_HiddenPanel_setupGfx(), entity_HitItemBlock_show_inactive(), entity_ItemBlock_replace_with_inactive(), entity_ItemBlock_setupGfx(), entity_MulticoinBlock_spawn_coin(), entity_Padlock_setupGfx(), entity_PinkFlower_idle(), entity_PinkFlower_init(), entity_PinkFlowerLight_idle(), entity_PinkFlowerLight_setupGfx(), entity_SaveBlock_setupGfx(), entity_shattering_setupGfx(), entity_SpinningFlower_setupGfx(), entity_StarBoxLauncher_setupGfx(), entity_SuperBlockContent_attach_to_parent(), entity_SuperBlockContent_setupGfx(), entity_try_partner_interaction_trigger(), entity_Tweester_render_face(), entity_Tweester_render_inner_whirl(), entity_Tweester_render_outer_whirl(), entity_Tweester_setupGfx(), entity_upgrade_block_check_if_inactive(), entity_upgrade_block_hide_content(), entity_WoodenCrate_setupGfx(), func_802BC050_E2E980(), get_entity_type(), interact_inspect_update(), npc_find_standing_on_entity(), phys_player_land(), player_raycast_down(), player_raycast_general(), player_raycast_up_corner(), render_entities(), test_ray_entities(), and update_entities().

◆ create_entity()

s32 create_entity ( EntityBlueprint * bp,
... )

Definition at line 1195 of file entity.c.

1195 {
1196 va_list ap;
1197 f32 x, y, z;
1198 f32 rotY;
1199 s32 listIndex;
1200 Entity* entity;
1201 s32 idx;
1202
1203 va_start(ap, bp);
1204
1206
1207 x = va_arg(ap, s32);
1208 y = va_arg(ap, s32);
1209 z = va_arg(ap, s32);
1210 rotY = va_arg(ap, s32);
1211
1212 for (idx = 0; idx < ARRAY_COUNT(CreateEntityVarArgBuffer); idx++) {
1213 CreateEntityVarArgBuffer[idx] = 0;
1214 }
1215
1216 for (idx = 0; idx < ARRAY_COUNT(CreateEntityVarArgBuffer); idx++) {
1217 s32 arg = va_arg(ap, s32);
1218
1219 if (arg == MAKE_ENTITY_END) {
1220 break;
1221 }
1222 CreateEntityVarArgBuffer[idx] = arg;
1223 }
1224
1225 va_end(ap);
1226
1227 for (listIndex = 0; listIndex < ARRAY_COUNT(*gCurrentEntityListPtr); listIndex++) {
1228 if ((*gCurrentEntityListPtr)[listIndex] == NULL) {
1229 break;
1230 }
1231 }
1232
1233 if (listIndex >= MAX_ENTITIES) {
1234 return -1;
1235 }
1236
1237 (*gCurrentEntityListPtr)[listIndex] = entity = heap_malloc(sizeof(*entity));
1238 mem_clear(entity, sizeof(*entity));
1239 entity->dataBuf.any = NULL;
1240 if (bp->typeDataSize != 0) {
1241 entity->dataBuf.any = heap_malloc(bp->typeDataSize);
1242 mem_clear(entity->dataBuf.any, bp->typeDataSize);
1243 }
1244 entity->type = bp->entityType;
1245 entity->listIndex = listIndex;
1246 entity->boundScript = NULL;
1247 entity->updateMatrixOverride = NULL;
1248 entity->blueprint = bp;
1249 entity->scriptReadPos = bp->updateEntityScript;
1250 entity->scriptDelay = entity->scriptReadPos != NULL ? 1 : 0;
1251 entity->savedReadPos[0] = bp->updateEntityScript;
1252 entity->updateScriptCallback = NULL;
1253 entity->flags = bp->flags | ENTITY_FLAG_CREATED;
1254 entity->collisionFlags = 0;
1255 entity->collisionTimer = 0;
1256 entity->renderSetupFunc = NULL;
1257 entity->pos.x = x;
1258 entity->pos.y = y;
1259 entity->pos.z = z;
1260 entity->rot.x = 0.0f;
1261 entity->rot.y = rotY;
1262 entity->rot.z = 0.0f;
1263 entity->scale.x = 1.0f;
1264 entity->scale.y = 1.0f;
1265 entity->scale.z = 1.0f;
1266 entity->aabb.x = bp->aabbSize[0];
1267 entity->aabb.y = bp->aabbSize[1];
1268 entity->aabb.z = bp->aabbSize[2];
1269 entity->unk_05 = 1;
1270 entity->unk_08 = -1;
1271 entity->alpha = 255;
1272 entity->virtualModelIndex = -1;
1273 entity->shadowIndex = -1;
1274 entity->gfxBaseAddr = NULL;
1275
1277 if (bp->dma.start != 0) {
1278 load_simple_entity_data(entity, bp, listIndex);
1279 }
1280 if (bp->renderCommandList != NULL) {
1283 }
1284 } else {
1285 load_split_entity_data(entity, bp, listIndex);
1286 }
1287
1289 create_entity_shadow(entity, x, y, z);
1290 }
1291
1292 switch (bp->entityType) {
1298 entity->flags |= ENTITY_FLAG_4000;
1299 break;
1300 }
1301
1302 if (bp->fpInit != NULL) {
1303 bp->fpInit(entity);
1304 }
1305
1307 return entity->listIndex;
1308}
#define mem_clear
s32 create_entity_shadow(Entity *entity, f32 x, f32 y, f32 z)
Definition entity.c:1509
void update_entity_transform_matrix(Entity *entity)
Definition entity.c:470
void load_simple_entity_data(Entity *entity, EntityBlueprint *bp, s32 listIndex)
Definition entity.c:1008
void load_area_specific_entity_data(void)
Definition entity.c:772
s32 CreateEntityVarArgBuffer[4]
Definition entity.c:35
void load_split_entity_data(Entity *entity, EntityBlueprint *entityData, s32 listIndex)
Definition entity.c:1045
s32 load_entity_model(EntityModelScript *cmdList)
@ ENTITY_TYPE_SCRIPT_SPRING
Definition enums.h:2584
@ ENTITY_TYPE_BLUE_SWITCH
Definition enums.h:2550
@ ENTITY_TYPE_RED_SWITCH
Definition enums.h:2551
@ ENTITY_TYPE_SIMPLE_SPRING
Definition enums.h:2583
@ ENTITY_TYPE_STAR_BOX_LAUNCHER
Definition enums.h:2586
@ ENTITY_TYPE_SHADOW
Definition enums.h:2544
@ ENTITY_FLAG_HAS_SHADOW
Definition enums.h:2621
@ ENTITY_FLAG_HAS_ANIMATED_MODEL
Definition enums.h:2616
@ ENTITY_FLAG_CREATED
Definition enums.h:2644
@ ENTITY_FLAG_FIXED_SHADOW_SIZE
Definition enums.h:2622
@ ENTITY_FLAG_4000
Definition enums.h:2627
#define MAKE_ENTITY_END
Definition evt.h:107
void exec_entity_model_commandlist(s32 idx)
void * heap_malloc(s32 size)
Definition heap.c:34
#define MAX_ENTITIES
Definition macros.h:94
#define ARRAY_COUNT(arr)
Definition macros.h:40
void(* fpInit)(struct Entity *)
EntityCallback updateMatrixOverride
s16 virtualModelIndex
s8 collisionTimer
EntityCallback updateScriptCallback
void(* renderSetupFunc)(s32)
Evt * boundScript
EntityData dataBuf
s32 * scriptReadPos
void * gfxBaseAddr
Vec3f scale
s32 * savedReadPos[3]
u8 collisionFlags
s16 shadowIndex

Referenced by entity_breakable_block_create_shattering_entity(), entity_HeartBlock_create_child_entity(), entity_ItemBlock_check_if_inactive(), entity_ItemBlock_replace_with_inactive(), entity_MulticoinBlock_check_if_inactive(), entity_MulticoinBlock_idle(), entity_MulticoinBlock_spawn_coin(), entity_Munchlesia_create_child(), entity_PinkFlower_init(), and entity_upgrade_block_check_if_inactive().

◆ entity_shattering_idle()

void entity_shattering_idle ( Entity * entity)

Definition at line 63 of file ShatteringBlock_common.c.

63 {
65 f32 rotSpeed = 0.0f;
66 f32 reboundSpeed = 0.0f;
67 f32 lateralSpeed = 0.0f;
68 f32 angle;
69 s32 i;
70 f32 sinTheta;
71 f32 cosTheta;
72 f32 hitX, hitY, hitZ, hitDepth;
73
74 for (i = 0; i < 24; i++) {
75 switch (data->fragmentRebounds[i]) {
76 case 0:
77 if (data->fragmentFlags[i] & 1) {
78 lateralSpeed = 1.5f;
79 } else {
80 lateralSpeed = 2.4f;
81 }
82 reboundSpeed = 6.0f;
83 rotSpeed = data->fragmentRotSpeed[i];
84 break;
85 case 1:
86 lateralSpeed = 1.2f;
87 reboundSpeed = 3.0f;
88 rotSpeed = data->fragmentRotSpeed[i] >> 2;
89 break;
90 case 2:
91 lateralSpeed = 1.0f;
92 reboundSpeed = 2.0f;
93 rotSpeed = data->fragmentRotSpeed[i] >> 2;
94 if (data->alpha == 0) {
95 data->fragmentRebounds[i]++;
96 }
97 break;
98 case 3:
99 data->fragmentPosY[i] -= 0.3;
100 continue;
101 }
102
103 data->fragmentFallSpeed[i] -= 1.2;
104 if (data->fragmentFallSpeed[i] < -12.2) {
105 data->fragmentFallSpeed[i] = -12.2f;
106 }
107 data->fragmentPosY[i] += data->fragmentFallSpeed[i];
108
109 angle = data->fragmentMoveAngle[i] * 360.0 / 256;
110 sin_cos_rad(DEG_TO_RAD(angle), &sinTheta, &cosTheta);
111 data->fragmentPosX[i] += lateralSpeed * sinTheta;
112 data->fragmentPosZ[i] += lateralSpeed * cosTheta;
113
114 hitX = data->fragmentPosX[i];
115 hitY = data->fragmentPosY[i];
116 hitZ = data->fragmentPosZ[i];
117 if (npc_test_move_taller_with_slipping(COLLISION_IGNORE_ENTITIES, &hitX, &hitY, &hitZ, lateralSpeed, angle, 8.0f, 8.0f)) {
118 data->fragmentPosX[i] = hitX;
119 data->fragmentPosY[i] = hitY;
120 data->fragmentPosZ[i] = hitZ;
121 data->fragmentMoveAngle[i] += 0x80; // inverse yaw
122
123 sin_cos_rad(DEG_TO_RAD(data->fragmentMoveAngle[i] * 360.0 / 256), &sinTheta, &cosTheta);
124 lateralSpeed = 8.0f;
125 data->fragmentPosX[i] += lateralSpeed * sinTheta;
126 data->fragmentPosZ[i] += lateralSpeed * cosTheta;
127 }
128
129 hitX = data->fragmentPosX[i];
130 hitY = data->fragmentPosY[i];
131 hitZ = data->fragmentPosZ[i];
132 hitDepth = fabsf(data->fragmentFallSpeed[i]);
133 if (npc_raycast_down_sides(COLLISION_IGNORE_ENTITIES, &hitX, &hitY, &hitZ, &hitDepth) || hitY < data->originalPosY - 200.0f) {
134 data->fragmentRebounds[i]++;
135 data->fragmentPosY[i] = hitY + fabsf(data->fragmentFallSpeed[i]) * 1.2f;
136 data->fragmentFallSpeed[i] = reboundSpeed;
137 }
138
139 data->fragmentRotX[i] += rotSpeed;
140 data->fragmentRotY[i] -= rotSpeed;
141 }
142
143 data->fadeOutCounter++;
144 if (data->fadeOutCounter >= 10) {
145 data->fadeOutCounter = 10;
146 data->alpha -= 8;
147 if (data->alpha <= 0) {
148 data->alpha = 0;
150 }
151 }
152}
struct ShatteringBlockData * shatteringBlock
#define npc_raycast_down_sides
u16 fragmentFlags[25]
Definition entity.h:93
s8 fragmentRebounds[25]
Definition entity.h:98
f32 fragmentPosY[25]
Definition entity.h:104
u8 fragmentMoveAngle[25]
Definition entity.h:100
u8 fragmentRotY[25]
Definition entity.h:102
f32 fragmentPosX[25]
Definition entity.h:103
f32 fragmentPosZ[25]
Definition entity.h:105
f32 fragmentFallSpeed[25]
Definition entity.h:106
s8 fragmentRotSpeed[25]
Definition entity.h:99
u8 fragmentRotX[25]
Definition entity.h:101
@ COLLISION_IGNORE_ENTITIES
Definition enums.h:4697
b32 npc_test_move_taller_with_slipping(s32, f32 *, f32 *, f32 *, f32, f32, f32, f32)
void exec_entity_commandlist(Entity *entity)
Definition entity.c:313
void sin_cos_rad(f32 rad, f32 *outSinTheta, f32 *outCosTheta)
Definition 43F0.c:705
#define DEG_TO_RAD(deg)
Definition macros.h:138

◆ show_damage_fx()

void show_damage_fx ( Actor * actor,
f32 x,
f32 y,
f32 z,
s32 damage )

Definition at line 2334 of file 190B20.c.

2334 {
2335 BattleStatus* battleStatus = &gBattleStatus;
2336 s32 intensity;
2337
2338 if (damage < 3) {
2339 intensity = DAMAGE_INTENSITY_LIGHT;
2340 } else if (damage < 5) {
2341 intensity = DAMAGE_INTENSITY_MEDIUM;
2342 } else if (damage < 9) {
2343 intensity = DAMAGE_INTENSITY_HEAVY;
2344 } else {
2345 intensity = DAMAGE_INTENSITY_EXTREME;
2346 }
2347
2348 if (battleStatus->curAttackElement & DAMAGE_TYPE_FIRE) {
2349 fx_ring_blast(0, x, y, z, 1.0f, 24);
2350 } else if (battleStatus->curAttackElement & DAMAGE_TYPE_SHOCK) {
2351 apply_shock_effect(actor);
2352 } else if (battleStatus->curAttackElement & DAMAGE_TYPE_WATER) {
2353 fx_water_splash(0, x, y, z, 1.0f, 24);
2354 } else {
2355 fx_firework(0, x, y, z, 1.0, intensity);
2356 }
2357}
@ DAMAGE_INTENSITY_EXTREME
Definition enums.h:3509
@ DAMAGE_INTENSITY_LIGHT
Definition enums.h:3506
@ DAMAGE_INTENSITY_HEAVY
Definition enums.h:3508
@ DAMAGE_INTENSITY_MEDIUM
Definition enums.h:3507
@ DAMAGE_TYPE_SHOCK
Definition enums.h:2856
@ DAMAGE_TYPE_FIRE
Definition enums.h:2852
@ DAMAGE_TYPE_WATER
Definition enums.h:2853
void apply_shock_effect(Actor *)
BattleStatus gBattleStatus
Definition battle.c:11

Referenced by calc_enemy_damage_target(), calc_item_damage_enemy(), calc_partner_damage_enemy(), calc_player_damage_enemy(), dispatch_damage_event_actor(), dispatch_damage_event_partner(), and dispatch_damage_event_player().

◆ entity_raycast_down()

b32 entity_raycast_down ( f32 * x,
f32 * y,
f32 * z,
f32 * hitYaw,
f32 * hitPitch,
f32 * hitLength )

Mostly used for shadows.

Definition at line 1637 of file entity.c.

1637 {
1638 f32 hitX, hitY, hitZ;
1639 f32 hitDepth;
1640 f32 hitNx, hitNy, hitNz;
1641 s32 entityID;
1642 s32 colliderID;
1643 s32 hitID;
1644
1645 hitDepth = 32767.0f;
1646 hitID = NO_COLLIDER;
1647
1648 entityID = test_ray_entities(*x, *y, *z, 0.0f, -1.0f, 0.0f, &hitX, &hitY, &hitZ, &hitDepth, &hitNx, &hitNy, &hitNz);
1649
1650 if ((entityID > NO_COLLIDER) && ((get_entity_type(entityID) != ENTITY_TYPE_PUSH_BLOCK) || (hitNx == 0.0f && hitNz == 0.0f && hitNy == 1.0))) {
1651 hitID = entityID | COLLISION_WITH_ENTITY_BIT;
1652 }
1653
1654 colliderID = test_ray_colliders(COLLIDER_FLAG_IGNORE_PLAYER, *x, *y, *z, 0.0f, -1.0f, 0.0f, &hitX, &hitY, &hitZ, &hitDepth, &hitNx,
1655 &hitNy, &hitNz);
1656 if (colliderID > NO_COLLIDER) {
1657 hitID = colliderID;
1658 }
1659
1660 if (hitID > NO_COLLIDER) {
1661 *y = hitY;
1662 *hitLength = hitDepth;
1663 *hitYaw = -atan2(0.0f, 0.0f, hitNz * 100.0f, hitNy * 100.0f);
1664 *hitPitch = -atan2(0.0f, 0.0f, hitNx * 100.0f, hitNy * 100.0f);
1665 return TRUE;
1666 } else {
1667 *hitLength = 32767.0f;
1668 *hitYaw = 0.0f;
1669 *hitPitch = 0.0f;
1670 return FALSE;
1671 }
1672}
#define atan2
u32 get_entity_type(s32 index)
Definition entity.c:568
@ COLLIDER_FLAG_IGNORE_PLAYER
Definition enums.h:4695
@ ENTITY_TYPE_PUSH_BLOCK
Definition enums.h:2555
s32 test_ray_entities(f32 startX, f32 startY, f32 startZ, f32 dirX, f32 dirY, f32 dirZ, f32 *hitX, f32 *hitY, f32 *hitZ, f32 *hitDepth, f32 *hitNx, f32 *hitNy, f32 *hitNz)
Test a general ray from a given starting position and direction against all entities.
Definition collision.c:947
s32 test_ray_colliders(s32 ignoreFlags, f32 startX, f32 startY, f32 startZ, f32 dirX, f32 dirY, f32 dirZ, f32 *hitX, f32 *hitY, f32 *hitZ, f32 *hitDepth, f32 *hitNx, f32 *hitNy, f32 *hitNz)
Definition collision.c:768
#define COLLISION_WITH_ENTITY_BIT
Definition macros.h:156
#define NO_COLLIDER
Definition macros.h:160

Referenced by entity_switch_fall_down(), is_block_on_ground(), update_entity_shadow_position(), and update_npcs().

◆ step_game_loop()

void step_game_loop ( void )

Definition at line 54 of file main_loop.c.

54 {
56
57 PlayerData* playerData = &gPlayerData;
58 const int MAX_GAME_TIME = 1000*60*60*60 - 1; // 1000 hours minus one frame at 60 fps
59
60#if !VERSION_JP
63#endif
64
66
67 playerData->frameCounter += 2;
68 if (playerData->frameCounter > MAX_GAME_TIME) {
69 playerData->frameCounter = MAX_GAME_TIME;
70 }
71
72#if VERSION_JP
75#endif
76
78
79 if (gGameStepDelayCount != 0) {
81 if (gGameStepDelayCount == 0) {
83 } else {
84 return;
85 }
86 }
87
109
111 switch (SoftResetState) {
112 case 0:
115
116 if (SoftResetOverlayAlpha == 255) {
117 SoftResetState = 1;
118 SoftResetDelay = 3;
119 } else {
121 if (SoftResetOverlayAlpha > 255) {
123 }
124 }
125 break;
126 case 1:
129 if (SoftResetDelay == 0) {
132 gOverrideFlags &= ~GLOBAL_OVERRIDES_SOFT_RESET;
133 }
134 break;
135 }
136 } else {
138 SoftResetState = 0;
139 }
140
143 } else {
144 gOverrideFlags &= ~GLOBAL_OVERRIDES_PREV_DISABLE_BATTLES;
145 }
146
149 } else {
150 gOverrideFlags &= ~GLOBAL_OVERRIDES_PREV_200;
151 }
152
155 } else {
156 gOverrideFlags &= ~GLOBAL_OVERRIDES_PREV_400;
157 }
158
161 } else {
162 gOverrideFlags &= ~GLOBAL_OVERRIDES_PREV_800;
163 }
164
165 // Unused rand_int used to advance the global random seed each visual frame
166 rand_int(1);
167}
#define rand_int
@ GLOBAL_OVERRIDES_SOFT_RESET
Definition enums.h:4323
@ GLOBAL_OVERRIDES_800
Definition enums.h:4329
@ GLOBAL_OVERRIDES_200
Definition enums.h:4327
@ GLOBAL_OVERRIDES_PREV_400
Definition enums.h:4332
@ GLOBAL_OVERRIDES_400
Definition enums.h:4328
@ GLOBAL_OVERRIDES_PREV_200
Definition enums.h:4331
@ GLOBAL_OVERRIDES_DISABLE_BATTLES
Definition enums.h:4326
@ GLOBAL_OVERRIDES_PREV_800
Definition enums.h:4333
@ GLOBAL_OVERRIDES_DISABLE_DRAW_FRAME
Definition enums.h:4321
@ GLOBAL_OVERRIDES_PREV_DISABLE_BATTLES
Definition enums.h:4330
void update_ambient_sounds(void)
Definition ambience.c:32
void mdl_reset_transform_flags(void)
Definition model.c:3755
s32 disable_player_input(void)
Definition 77480.c:990
void update_curtains(void)
Definition curtains.c:220
void update_scripts(void)
void update_triggers(void)
Definition trigger.c:89
void update_entities(void)
Definition entity.c:82
void update_input(void)
Definition input.c:31
void update_max_rumble_duration(void)
Definition rumble.c:34
void bgm_update_music_settings(void)
void update_windows(void)
Definition windows.c:143
void update_workers(void)
Definition worker.c:125
void func_80138198(void)
void update_messages(void)
Definition msg.c:247
void set_game_mode(s32 modeID)
Definition game_modes.c:127
void step_game_mode(void)
Definition game_modes.c:163
@ GAME_MODE_STARTUP
Definition game_modes.h:7
void update_hud_elements(void)
s16 SoftResetOverlayAlpha
Definition main_loop.c:33
s32 gOverrideFlags
Definition main_loop.c:11
BSS s16 SoftResetDelay
Definition main_loop.c:14
GameStatus * gGameStatusPtr
Definition main_loop.c:32
s16 SoftResetState
Definition main_loop.c:34
s8 gGameStepDelayCount
Definition main_loop.c:19
s8 gGameStepDelayAmount
Definition main_loop.c:18
#define profiler_frame_setup()
Definition profiling.h:159
#define profiler_update(which, delta)
Definition profiling.h:157
@ PROFILER_TIME_CONTROLLERS
Definition profiling.h:54
@ PROFILER_TIME_ENTITIES
Definition profiling.h:61
@ PROFILER_TIME_MESSAGES
Definition profiling.h:58
@ PROFILER_TIME_HUD_ELEMENTS
Definition profiling.h:59
@ PROFILER_TIME_TRIGGERS
Definition profiling.h:56
@ PROFILER_TIME_STEP_GAME_MODE
Definition profiling.h:60
@ PROFILER_TIME_WORKERS
Definition profiling.h:55
@ PROFILER_TIME_EVT
Definition profiling.h:57
void sfx_update_env_sound_params(void)
Definition sfx.c:334
void sfx_stop_env_sounds(void)
Definition sfx.c:361
PlayerData gPlayerData
Definition 77480.c:40

Referenced by gfxRetrace_Callback().

◆ resume_all_group()

s32 resume_all_group ( s32 groupFlags)

Definition at line 858 of file script_list.c.

858 {
859 s32 i;
860 Evt* scriptContextPtr;
861
862 for (i = 0; i < MAX_SCRIPTS; i++) {
863 scriptContextPtr = (*gCurrentScriptListPtr)[i];
864 if (scriptContextPtr != NULL) {
865 resume_group_script(scriptContextPtr, groupFlags);
866 }
867 }
868}
#define MAX_SCRIPTS
Definition macros.h:90
void resume_group_script(Evt *script, s32 groupFlags)

Referenced by create_encounters(), evt_handle_resume_all(), set_time_freeze_mode(), start_battle(), update_encounters_conversation(), update_encounters_post_battle(), and update_item_entity_collectable().

◆ length2D()

f32 length2D ( f32 x,
f32 y )

Definition at line 59 of file 43F0.c.

59 {
60 return sqrtf(SQ(x) + SQ(y));
61}
#define sqrtf
#define SQ(x)
Definition macros.h:170

Referenced by ArcsinDeg().

◆ player_input_to_move_vector()

void player_input_to_move_vector ( f32 * angle,
f32 * magnitude )

Definition at line 140 of file 7B440.c.

140 {
141 PlayerStatus* playerStatus = &gPlayerStatus;
142 f32 stickAxisX = playerStatus->stickAxis[0];
143 f32 stickAxisY = -playerStatus->stickAxis[1];
144 f32 maxRadius = 70.0f;
145 f32 magnitude;
146 f32 angle;
147
148 magnitude = dist2D(0.0f, 0.0f, stickAxisX, stickAxisY);
149 if (magnitude >= maxRadius) {
150 magnitude = maxRadius;
151 }
152
153 angle = clamp_angle(atan2(0.0f, 0.0f, stickAxisX, stickAxisY) + gCameras[CAM_DEFAULT].curYaw);
154 if (magnitude == 0.0f) {
155 angle = playerStatus->targetYaw;
156 }
157
158 *outAngle = angle;
159 *outMagnitude = magnitude;
160}
#define clamp_angle
@ CAM_DEFAULT
Definition enums.h:1800
f32 dist2D(f32 ax, f32 ay, f32 bx, f32 by)
Definition 43F0.c:669
Camera gCameras[4]
Definition cam_main.c:17

Referenced by action_update_idle(), action_update_idle_peach(), action_update_land(), action_update_peach_land(), action_update_peach_step_down_land(), action_update_pushing_block(), action_update_run(), action_update_spin(), action_update_step_down_land(), action_update_walk(), collision_main_above(), collision_main_lateral(), and phys_player_land().

◆ game_input_to_move_vector()

void game_input_to_move_vector ( f32 * x,
f32 * y )

Definition at line 162 of file 7B440.c.

162 {
163 f32 stickX = gGameStatusPtr->stickX[0];
164 f32 stickY = -gGameStatusPtr->stickY[0];
165 f32 maxRadius = 70.0f;
166 f32 magnitude;
167 f32 angle;
168
169 magnitude = dist2D(0.0f, 0.0f, stickX, stickY);
170 if (magnitude >= maxRadius) {
171 magnitude = maxRadius;
172 }
173
174 angle = clamp_angle(atan2(0.0f, 0.0f, stickX, stickY) + gCameras[CAM_DEFAULT].curYaw);
175 if (magnitude == 0.0f) {
176 angle = gPlayerStatus.targetYaw;
177 }
178
179 *outAngle = angle;
180 *outMagnitude = magnitude;
181}

Referenced by action_update_use_spinning_flower().

◆ exec_ShakeCamX()

void exec_ShakeCamX ( s32 arg0,
s32 arg1,
s32 arg2,
f32 arg3 )

Definition at line 374 of file cam_api.c.

374 {
375 Evt* script;
376
378 evt_set_variable(script, LVar0, camID);
379 evt_set_variable(script, LVar1, mode);
380 evt_set_variable(script, LVar2, duration);
381 evt_set_float_variable(script, LVar3, magnitude);
382}
EvtScript ShakeCamX
Definition cam_api.c:10
@ EVT_PRIORITY_1
Definition evt.h:152
@ EVT_GROUP_SHAKE_CAM
Definition evt.h:146
f32 evt_set_float_variable(Evt *script, Bytecode var, f32 value)
Definition evt.c:1976
s32 evt_set_variable(Evt *script, Bytecode var, s32 value)
Definition evt.c:1846
Evt * start_script_in_group(EvtScript *source, u8 priority, u8 initialState, u8 groupFlags)
#define LVar2
Definition macros.h:150
#define LVar1
Definition macros.h:149
#define LVar3
Definition macros.h:151
#define LVar0
Definition macros.h:148

Referenced by action_hammer_play_hit_fx(), action_update_hit_lava(), and entity_HiddenPanel_flip_over().

◆ exec_ShakeCam1()

void exec_ShakeCam1 ( s32 arg0,
s32 arg1,
s32 arg2 )

Definition at line 365 of file cam_api.c.

365 {
366 Evt* script;
367
369 script->varTable[0] = camID;
370 script->varTable[1] = mode;
371 script->varTable[2] = duration;
372}
EvtScript ShakeCam1
Definition cam_api.c:3

Referenced by action_update_spin_jump(), action_update_tornado_jump(), and get_overriding_player_anim().

◆ player_get_side_angle()

f32 player_get_side_angle ( void )

Definition at line 1178 of file 7BB60.c.

1178 {
1180
1181 if (deltaYaw < -5.0f && deltaYaw > -175.0f) {
1182 deltaYaw = 0.0f;
1183 } else if (deltaYaw > 5.0f && deltaYaw < 175.0f) {
1184 deltaYaw = 180.0f;
1185 } else {
1186 deltaYaw = PrevPlayerCamRelativeYaw;
1187 }
1188 return clamp_angle(deltaYaw - 90.0f + gCameras[gCurrentCameraID].curYaw);
1189}
f32 get_clamped_angle_diff(f32, f32)
Definition 43F0.c:605
s32 PrevPlayerCamRelativeYaw
Definition 7E9D0.c:31
s32 gCurrentCameraID
Definition cam_math.c:4

Referenced by action_hammer_end_swing(), action_hammer_play_hit_fx(), action_hammer_test_swing_collision(), entity_StarBoxLauncher_check_launch(), parasol_get_npc(), partner_flying_follow_player(), and partner_walking_follow_player().

◆ draw_number()

void draw_number ( s32 value,
s32 x,
s32 y,
s32 variableWidthChars,
s32 palette,
s32 opacity,
u16 style )

Definition at line 2223 of file msg.c.

2223 {
2224 u8 valueStr[24];
2225 s8 digits[24];
2226 s32 digitPosX[24];
2227 s32 i;
2228 s32 count;
2229 s32 posX;
2230 IMG_PTR raster = gMsgNumbers[charset].rasters;
2231 s32 texSize = gMsgNumbers[charset].texSize;
2232
2233#if !VERSION_JP
2234 y -= 2;
2235#endif
2236 if (y < 0 || y > 240) {
2237 return;
2238 }
2239
2240 int_to_string(value, valueStr, 10);
2241
2242 for (i = 0; i < 10; i++) {
2243 u8 digit;
2244 if (valueStr[i] == '\0') {
2245 break;
2246 }
2247
2248 // handle negative numbers
2249 if (valueStr[i] == '-') {
2250 digits[i] = MSG_CHAR_MINUS - MSG_CHAR_DIGIT_0;
2251 continue;
2252 }
2253
2254 digit = valueStr[i] - '0';
2255 if (digit < 10){
2256 digits[i] = digit;
2257 }
2258 }
2259 posX = x;
2260 count = i;
2261
2262 gSPDisplayList(gMainGfxPos++, gMsgDlistInitDrawNumber);
2263
2264 if (style & DRAW_NUMBER_STYLE_ALIGN_RIGHT) {
2265 for (i = count - 1; i >= 0; i--) {
2266 if ((style & DRAW_NUMBER_STYLE_MONOSPACE) || digits[i] < 0) {
2267 posX -= gMsgNumbers[charset].fixedWidth;
2268 } else {
2269 posX -= gMsgNumbers[charset].digitWidth[digits[i]];
2270 }
2271 digitPosX[i] = posX;
2272 }
2273 } else {
2274 for (i = 0; i < count; i++) {
2275 digitPosX[i] = posX;
2276 if ((style & DRAW_NUMBER_STYLE_MONOSPACE) || digits[i] < 0) {
2277 posX += gMsgNumbers[charset].fixedWidth;
2278 } else {
2279 posX += gMsgNumbers[charset].digitWidth[digits[i]];
2280 }
2281 }
2282 }
2283
2284 if (style & DRAW_NUMBER_STYLE_DROP_SHADOW) {
2285 for (i = 0; i < count; i++) {
2286 gDPPipeSync(gMainGfxPos++);
2287 gDPSetRenderMode(gMainGfxPos++, G_RM_XLU_SURF, G_RM_XLU_SURF2);
2288 gDPSetCombineMode(gMainGfxPos++, PM_CC_07, PM_CC_07);
2289 gDPSetPrimColor(gMainGfxPos++, 0, 0, 40, 40, 40, 72);
2290 draw_digit(raster + digits[i] * texSize, charset, digitPosX[i] + 2, y + 2);
2291 gDPPipeSync(gMainGfxPos++);
2292 }
2293 }
2294
2295 if (opacity == 255) {
2296 gDPSetRenderMode(gMainGfxPos++, G_RM_TEX_EDGE, G_RM_TEX_EDGE2);
2297 gDPSetCombineMode(gMainGfxPos++, G_CC_DECALRGBA, G_CC_DECALRGBA);
2298 } else {
2299 gDPSetRenderMode(gMainGfxPos++, G_RM_XLU_SURF, G_RM_XLU_SURF2);
2300 gDPSetCombineMode(gMainGfxPos++, PM_CC_01, PM_CC_01);
2301 gDPSetPrimColor(gMainGfxPos++, 0, 0, 255, 255, 255, opacity);
2302 }
2303
2304 gDPLoadTLUT_pal16(gMainGfxPos++, 0, D_802F4560[palette]);
2305 for (i = 0; i < count; i++) {
2306 posX = digitPosX[i];
2307 if (posX > 0 && posX < 320) {
2308 draw_digit(raster + digits[i] * texSize, charset, posX, y);
2309 }
2310 }
2311 gDPPipeSync(gMainGfxPos++);
2312}
#define IMG_PTR
@ DRAW_NUMBER_STYLE_ALIGN_RIGHT
drawn to the left of posX
Definition enums.h:5392
@ DRAW_NUMBER_STYLE_DROP_SHADOW
Definition enums.h:5395
@ DRAW_NUMBER_STYLE_MONOSPACE
Definition enums.h:5393
@ MSG_CHAR_DIGIT_0
Definition enums.h:5871
@ MSG_CHAR_MINUS
Definition enums.h:5868
char * int_to_string(s32, char *, s32)
Definition 43F0.c:385
void draw_digit(IMG_PTR img, s32 charset, s32 posX, s32 posY)
Definition msg.c:2203
Gfx gMsgDlistInitDrawNumber[]
Definition msg.c:165
MessageNumber gMsgNumbers[]
Definition msg.c:129
PAL_BIN D_802F4560[80][8]
#define PM_CC_07
Definition macros.h:286
#define PM_CC_01
Definition macros.h:280
Gfx * gMainGfxPos
Definition cam_main.c:15

Referenced by btl_menu_moves_draw_content(), coin_counter_draw_content(), draw_shop_items(), filemenu_draw_contents_file_info(), filemenu_draw_contents_file_title(), filemenu_info_draw_message_contents(), filemenu_yesno_draw_prompt_contents(), func_800F4D28(), pause_badges_draw_contents(), pause_partners_draw_movelist(), pause_stats_draw_contents(), popup_menu_draw_menu_contents(), and popup_menu_draw_title_contents().

◆ set_entity_model_flags()

void set_entity_model_flags ( s32 idx,
s32 newFlags )

Definition at line 758 of file entity_model.c.

758 {
759 EntityModel* entityModel = (*gCurrentEntityModelList)[idx & ~BATTLE_ENTITY_ID_BIT];
760
761 if (entityModel != NULL && entityModel->flags) {
762 entityModel->flags |= newFlags;
763 }
764}
s32 flags
Definition entity.h:448

Referenced by show_immune_bonk().

◆ clear_entity_model_flags()

void clear_entity_model_flags ( s32 idx,
s32 newFlags )

Definition at line 766 of file entity_model.c.

766 {
767 EntityModel* entityModel = (*gCurrentEntityModelList)[idx & ~BATTLE_ENTITY_ID_BIT];
768
769 if (entityModel != NULL && entityModel->flags) {
770 entityModel->flags &= ~newFlags;
771 }
772}

Referenced by btl_bonk_update().

◆ exec_entity_model_commandlist()

void exec_entity_model_commandlist ( s32 idx)

Definition at line 172 of file entity_model.c.

172 {
173 EntityModel* entityModel;
174
176 idx &= ~BATTLE_ENTITY_ID_BIT;
177 entityModel = (*gCurrentEntityModelList)[idx];
178 if (entityModel != NULL && (entityModel->flags)) {
179 if (!(entityModel->flags & ENTITY_MODEL_FLAG_HIDDEN)) {
180 if (!(entityModel->flags & ENTITY_MODEL_FLAG_DISABLE_SCRIPT)) {
181 entityModel->flags &= ~ENTITY_MODEL_FLAG_100;
182 entityModel->nextFrameTime -= entityModel->timeScale;
183 if (entityModel->nextFrameTime <= 0.0f) {
184 while (step_entity_model_commandlist(entityModel));
185 }
186 }
187 }
188 }
189 }
190}
s32 step_entity_model_commandlist(EntityModel *entityModel)
@ ENTITY_MODEL_FLAG_DISABLE_SCRIPT
Definition enums.h:5026
@ ENTITY_MODEL_FLAG_HIDDEN
Definition enums.h:5014
#define BATTLE_ENTITY_ID_BIT
Definition macros.h:150
f32 timeScale
Default is 1.0.
Definition entity.h:454
f32 nextFrameTime
Set to 1.0 after each update.
Definition entity.h:453

Referenced by ALT_virtual_entity_create(), btl_bonk_update(), create_entity(), update_entities(), update_shadows(), virtual_entity_create(), virtual_entity_create_at_index(), and virtual_entity_list_update().

◆ queue_render_task()

RenderTask * queue_render_task ( RenderTask * task)

Definition at line 4546 of file model.c.

4546 {
4547 s32 dist = RenderTaskBasePriorities[task->renderMode] - task->dist;
4548 s32 listIdx = RENDER_TASK_LIST_MID;
4549 if (dist >= 3000000) listIdx = RENDER_TASK_LIST_FAR;
4550 else if (dist < 800000) listIdx = RENDER_TASK_LIST_NEAR;
4551
4552 RenderTask* ret = RenderTaskLists[listIdx];
4553
4555
4556 ret = &ret[RenderTaskCount[listIdx]++];
4557
4561 }
4562
4563 ret->appendGfxArg = task->appendGfxArg;
4564 ret->appendGfx = task->appendGfx;
4565 ret->dist = dist;
4566
4567 return ret;
4568}
#define ASSERT(condition)
@ RENDER_TASK_FLAG_20
Definition enums.h:3319
@ RENDER_TASK_FLAG_ENABLED
Definition enums.h:3317
@ RENDER_MODE_CLOUD_NO_ZCMP
Definition enums.h:3311
BSS s32 RenderTaskCount[3]
Definition model.c:1353
BSS RenderTask * RenderTaskLists[3]
Definition model.c:1351
s32 RenderTaskBasePriorities[]
Definition model.c:1256
@ RENDER_TASK_LIST_FAR
Definition model.c:99
@ RENDER_TASK_LIST_NEAR
Definition model.c:97
@ RENDER_TASK_LIST_MID
Definition model.c:98
BSS RenderTask ClearRenderTaskLists[3][0x100]

◆ create_mesh_animator()

s32 create_mesh_animator ( s16 * animPos,
s16 * animBuffer )

Definition at line 366 of file animator.c.

366 {
367 ModelAnimator* animator;
368 s32 i, j;
369
370 for (i = 0; i < ARRAY_COUNT(*gCurrentAnimMeshListPtr); i++) {
371 if ((*gCurrentAnimMeshListPtr)[i] == NULL) {
372 break;
373 }
374 }
375
377
378 (*gCurrentAnimMeshListPtr)[i] = animator = heap_malloc(sizeof(*animator));
379 gAnimCount++;
380
381 ASSERT(animator != NULL);
382
385 animator->baseAddr = NULL;
386 animator->fpRenderCallback = NULL;
387 animator->rootNode = NULL;
388 animator->nextUniqueID = 0;
389 animator->animationBuffer = animBuffer;
390 animator->nextUpdateTime = 1.0f;
391 animator->timeScale = 1.0f;
392 animPos = (s16*)(((s32)animPos & 0xFFFFFF) + (s32)animator->animationBuffer);
393 animator->animReadPos = animPos;
394 animator->savedReadPos = animPos;
395
396 for (j = 0; j < ARRAY_COUNT(animator->nodeCache); j++) {
397 animator->nodeCache[j] = NULL;
398 }
399
400 for (j = 0; j < ARRAY_COUNT(animator->staticNodeIDs); j++) {
401 animator->staticNodeIDs[j] = j + 1;
402 }
403
405 i |= BATTLE_ID_BIT;
406 }
407 return i;
408}
s32 gAnimCount
Definition animator.c:12
BSS AnimatedMeshList * gCurrentAnimMeshListPtr
Definition animator.c:18
@ MODEL_ANIMATOR_FLAG_CAM_2
Definition enums.h:4912
@ MODEL_ANIMATOR_FLAG_CAM_1
Definition enums.h:4911
@ MODEL_ANIMATOR_FLAG_CAM_0
Definition enums.h:4910
@ MODEL_ANIMATOR_FLAG_ENABLED
Definition enums.h:4914
@ MODEL_ANIMATOR_FLAG_UPDATE_PENDING
Definition enums.h:4916
#define BATTLE_ID_BIT
Definition macros.h:148
u8 staticNodeIDs[0x7A]
void(* fpRenderCallback)(void *)
AnimatorNode * rootNode
AnimatorNode * nodeCache[0x7A]

Referenced by load_split_entity_data().

◆ load_mesh_animator_tree()

void load_mesh_animator_tree ( s32 index,
StaticAnimatorNode ** tree )

Definition at line 1198 of file animator.c.

1198 {
1199 s32 indexMasked = index & ~BATTLE_ID_BIT;
1200 ModelAnimator* animator = (*gCurrentAnimMeshListPtr)[indexMasked];
1201 s32 nodeIDs[ARRAY_COUNT(animator->staticNodeIDs)];
1202 s32 i;
1203
1204 if (animator == NULL || animator->flags == 0) {
1205 return;
1206 }
1207
1208 if ((*tree)->vertexStartOffset == 0) {
1209 load_model_animator_tree(indexMasked, tree);
1210 return;
1211 }
1212
1213 gAnimTreeRoot = tree;
1214 animator->staticRoot = tree;
1215 animator->treeIndexPos = 0;
1216 animator->savedTreePos = 0;
1217
1218 for (i = 0; i < ARRAY_COUNT(animator->staticNodes); i++) {
1219 animator->staticNodes[i] = NULL;
1220 }
1221
1222 load_mesh_animator_node(*gAnimTreeRoot, animator, 0, nodeIDs);
1223 animator->flags |= MODEL_ANIMATOR_FLAG_MESH;
1224}
void load_mesh_animator_node(StaticAnimatorNode *node, ModelAnimator *animator, s32 parentNodeID, s32 *treeIndexToNodeIDs)
Definition animator.c:1184
void load_model_animator_tree(s32 index, StaticAnimatorNode **tree)
Definition animator.c:1171
BSS StaticAnimatorNode ** gAnimTreeRoot
Definition animator.c:31
@ MODEL_ANIMATOR_FLAG_MESH
Definition enums.h:4925
StaticAnimatorNode * staticNodes[0x7A]
StaticAnimatorNode ** staticRoot

Referenced by load_split_entity_data().

◆ setup_pause_menu_tab()

void setup_pause_menu_tab ( MenuWindowBP * bpArray,
s32 arraySize )

Definition at line 461 of file windows.c.

461 {
462 s32 i;
463
464 for (i = 0; i < count; i++) {
465 set_window_properties(bp->windowID, bp->pos.x, bp->pos.y, bp->width, bp->height, bp->priority,
466 bp->fpDrawContents, bp->tab, bp->parentID);
467 if (bp->style.defaultStyleID != -1) {
468 gWindowStyles[bp->windowID] = bp->style;
469 }
470 set_window_update(bp->windowID, bp->fpUpdate.i);
471 gWindows[bp->windowID].flags |= bp->extraFlags;
472 bp++;
473 }
474}
WindowStyle gWindowStyles[64]
Definition windows.c:25
void set_window_properties(s32 windowID, s32 posX, s32 posY, s32 width, s32 height, u8 priority, void *fpDrawContents, void *drawContentsArg0, s8 parent)
Definition windows.c:373
Window gWindows[64]
Definition windows.c:23
void set_window_update(s32 windowID, s32 func)
Definition windows.c:434

Referenced by filemenu_choose_name_init(), filemenu_info_init(), filemenu_init(), filemenu_main_init(), filemenu_yesno_init(), pause_badges_init(), pause_init(), pause_items_init(), pause_map_init(), pause_partners_init(), pause_spirits_init(), pause_stats_init(), and pause_tabs_init().

◆ draw_ci_image_with_clipping()

s32 draw_ci_image_with_clipping ( u8 * raster,
s32 width,
s32 height,
s32 fmt,
s32 bitDepth,
u16 * palette,
s16 posX,
s16 posY,
u16 clipULx,
u16 clipULy,
u16 clipLRx,
u16 clipRLy,
u8 opacity )

◆ render_frame()

void render_frame ( s32 flag)

Definition at line 91 of file cam_main.c.

91 {
92 s32 firstCamID;
93 s32 lastCamID;
94 s32 camID;
95
96 if (!isSecondPass) {
99 }
100
101 // first pass: loop uses camIDs from CAM_DEFAULT to CAM_HUD - 1
102 // second pass: loop only uses CAM_HUD
103 if (isSecondPass) {
104 firstCamID = CAM_HUD;
105 lastCamID = ARRAY_COUNT(gCameras);
106 } else {
107 firstCamID = CAM_DEFAULT;
108 lastCamID = CAM_HUD;
109 }
110
111 for (camID = firstCamID; camID < lastCamID; camID++) {
112 Camera* camera = &gCameras[camID];
113
114 if (camera->flags == 0 || (camera->flags & (CAMERA_FLAG_NO_DRAW | CAMERA_FLAG_DISABLED))) {
115 continue;
116 }
117
118 gCurrentCamID = camID;
119
120 if (camera->fpDoPreRender != NULL) {
121 camera->fpDoPreRender(camera);
122 } else {
123 s32 ulx;
124 s32 uly;
125 s32 lrx;
126 s32 lry;
127
128 gSPViewport(gMainGfxPos++, &camera->vp);
129 gSPClearGeometryMode(gMainGfxPos++, G_SHADE | G_CULL_BOTH | G_FOG | G_LIGHTING | G_TEXTURE_GEN |
130 G_TEXTURE_GEN_LINEAR | G_LOD | G_SHADING_SMOOTH);
131 gSPTexture(gMainGfxPos++, 0, 0, 0, G_TX_RENDERTILE, G_OFF);
132 gDPSetCycleType(gMainGfxPos++, G_CYC_1CYCLE);
133 gDPPipelineMode(gMainGfxPos++, G_PM_NPRIMITIVE);
134
135 ulx = camera->viewportStartX;
136 uly = camera->viewportStartY;
137 lrx = ulx + camera->viewportW;
138 lry = uly + camera->viewportH;
139
140 if (ulx < 0) {
141 ulx = 0;
142 }
143 if (uly < 0) {
144 uly = 0;
145 }
146 if (lrx < 1) {
147 lrx = 1;
148 }
149 if (lry < 1) {
150 lry = 1;
151 }
152
153 if (ulx > SCREEN_WIDTH - 1) {
154 ulx = SCREEN_WIDTH - 1;
155 }
156 if (uly > SCREEN_HEIGHT - 1) {
157 uly = SCREEN_HEIGHT - 1;
158 }
159 if (lrx > SCREEN_WIDTH) {
160 lrx = SCREEN_WIDTH;
161 }
162 if (lry > SCREEN_HEIGHT) {
163 lry = SCREEN_HEIGHT;
164 }
165
166 gDPSetScissor(gMainGfxPos++, G_SC_NON_INTERLACE, ulx, uly, lrx, lry);
167 gDPSetTextureLOD(gMainGfxPos++, G_TL_TILE);
168 gDPSetTextureLUT(gMainGfxPos++, G_TT_NONE);
169 gDPSetTextureDetail(gMainGfxPos++, G_TD_CLAMP);
170 gDPSetTexturePersp(gMainGfxPos++, G_TP_PERSP);
171 gDPSetTextureFilter(gMainGfxPos++, G_TF_BILERP);
172 gDPSetTextureConvert(gMainGfxPos++, G_TC_FILT);
173 gDPSetCombineMode(gMainGfxPos++, G_CC_SHADE, G_CC_SHADE);
174 gDPSetCombineKey(gMainGfxPos++, G_CK_NONE);
175 gDPSetAlphaCompare(gMainGfxPos++, G_AC_NONE);
176 gDPSetRenderMode(gMainGfxPos++, G_RM_OPA_SURF, G_RM_OPA_SURF2);
177 gDPSetColorDither(gMainGfxPos++, G_CD_DISABLE);
178 gSPClipRatio(gMainGfxPos++, FRUSTRATIO_2);
179 gDPSetColorImage(gMainGfxPos++, G_IM_FMT_RGBA, G_IM_SIZ_16b, SCREEN_WIDTH,
180 osVirtualToPhysical(nuGfxCfb_ptr));
181 gDPPipeSync(gMainGfxPos++);
182
183 if (!(camera->flags & CAMERA_FLAG_ORTHO)) {
184 gSPPerspNormalize(gMainGfxPos++, camera->perspNorm);
185 }
186
188 gSPMatrix(gMainGfxPos++, &gDisplayContext->camPerspMatrix[gCurrentCamID], G_MTX_NOPUSH | G_MTX_LOAD |
189 G_MTX_PROJECTION);
190 }
191
193 guRotate(camera->mtxBillboard, -camera->curBoomYaw, 0.0f, 1.0f, 0.0f);
194
195 camera->vpAlt.vp.vtrans[0] = camera->vp.vp.vtrans[0] + gGameStatusPtr->altViewportOffset.x;
196 camera->vpAlt.vp.vtrans[1] = camera->vp.vp.vtrans[1] + gGameStatusPtr->altViewportOffset.y;
197
198 if (!(camera->flags & CAMERA_FLAG_ORTHO)) {
199 if (gCurrentCamID != CAM_HUD) {
200 if (!(camera->flags & CAMERA_FLAG_RENDER_ENTITIES)) {
204 }
205 if (!(camera->flags & CAMERA_FLAG_RENDER_MODELS)) {
207 #if DX_DEBUG_MENU
208 if (!dx_debug_should_hide_models()) {
210 }
211 #else
213 #endif
215 }
219 render_npcs();
226 #if DX_DEBUG_MENU
227 dx_debug_draw_collision();
228 #endif
231 } else {
232 guOrthoF(camera->mtxPerspective, 0.0f, SCREEN_WIDTH, -SCREEN_HEIGHT, 0.0f, -1000.0f, 1000.0f, 1.0f);
234 gSPMatrix(gMainGfxPos++, &gDisplayContext->camPerspMatrix[gCurrentCamID], G_MTX_NOPUSH |
235 G_MTX_LOAD | G_MTX_PROJECTION);
238 }
239 } else {
242 }
243
244 if (camera->fpDoPostRender != NULL) {
245 camera->fpDoPostRender(camera);
246 }
247
248 gDPPipeSync(gMainGfxPos++);
249 gDPSetColorImage(gMainGfxPos++, G_IM_FMT_RGBA, G_IM_SIZ_16b, SCREEN_WIDTH,
250 osVirtualToPhysical(nuGfxCfb_ptr));
251 gDPPipeSync(gMainGfxPos++);
252 }
253}
void execute_render_tasks(void)
Definition model.c:4570
Camera gCameras[4]
Definition cam_main.c:17
Gfx * gMainGfxPos
Definition cam_main.c:15
void render_models(void)
Definition model.c:2710
DisplayContext * gDisplayContext
Definition cam_main.c:16
void render_item_entities(void)
s16 gCurrentCamID
Definition cam_main.c:13
u16 * nuGfxCfb_ptr
Definition cam_main.c:14
Vec2b altViewportOffset
Mtx matrixStack[0x200]
#define guOrthoF
#define guMtxF2L
@ CAMERA_FLAG_RENDER_MODELS
Definition enums.h:4726
@ CAMERA_FLAG_DISABLED
Definition enums.h:4720
@ CAMERA_FLAG_NO_DRAW
Definition enums.h:4724
@ CAMERA_FLAG_RENDER_ENTITIES
Definition enums.h:4725
@ CAMERA_FLAG_ORTHO
Definition enums.h:4723
@ CAM_HUD
Definition enums.h:1803
void render_entities(void)
Definition entity.c:338
void render_workers_scene(void)
Definition worker.c:137
void render_effects_scene(void)
Definition effects.c:116
void render_player(void)
Definition 77480.c:1489
void mdl_update_transform_matrices(void)
Definition model.c:2589
void render_transformed_hud_elements(void)
void render_npcs(void)
Renders all NPCs.
Definition npc.c:932
#define GFX_PROFILER_SWITCH(complete, begin)
Definition profiling.h:212
@ PROFILER_TIME_SUB_GFX_HUD_ELEMENTS
Definition profiling.h:67
@ PROFILER_TIME_SUB_GFX_ENTITIES
Definition profiling.h:67
@ PROFILER_TIME_SUB_GFX_WORKERS
Definition profiling.h:67
@ PROFILER_TIME_SUB_GFX_PLAYER
Definition profiling.h:67
@ PROFILER_TIME_SUB_GFX_EFFECTS
Definition profiling.h:67
@ PROFILER_TIME_SUB_GFX_MODELS
Definition profiling.h:67
@ PROFILER_TIME_SUB_GFX_RENDER_TASKS
Definition profiling.h:67
@ PROFILER_TIME_SUB_GFX_NPCS
Definition profiling.h:67
#define GFX_PROFILER_COMPLETE(which)
Definition profiling.h:217
#define GFX_PROFILER_START(which)
Definition profiling.h:216
#define SCREEN_WIDTH
Definition macros.h:109
#define SCREEN_HEIGHT
Definition macros.h:110
Mtx * mtxBillboard
s16 viewportStartX
void(* fpDoPreRender)(struct Camera *)
s16 viewportStartY
void(* fpDoPostRender)(struct Camera *)
Matrix4f mtxPerspective
u16 gMatrixListPos
Definition main_loop.c:45

Referenced by appendGfx_title_screen(), and gfx_draw_frame().

◆ clear_windows()

void clear_windows ( void )

Definition at line 135 of file windows.c.

135 {
136 s32 i;
137
138 for (i = 0; i < ARRAY_COUNT(gWindows); i++) {
139 gWindows[i].flags = 0;
140 }
141}

Referenced by load_engine_data(), state_step_startup(), and state_step_title_screen().

◆ update_window_hierarchy()

void update_window_hierarchy ( s32 windowIndex,
u8 arg1 )

Definition at line 393 of file windows.c.

393 {
394 s32 priorityArray[ARRAY_COUNT(gWindows) + 1];
395 s32 curPriority;
396 s32 i;
397
398 if (priority > ARRAY_COUNT(gWindows)) {
399 priority = ARRAY_COUNT(gWindows);
400 }
401
402 for (i = 0; i < ARRAY_COUNT(priorityArray); i++) {
403 priorityArray[i] = -1;
404 }
405 priorityArray[priority] = windowID;
406
407 for (i = 0; i < ARRAY_COUNT(gWindows); i++) {
408 if (gWindows[i].flags && i != windowID) {
409 curPriority = gWindows[i].priority;
410 if (curPriority >= priority) {
411 curPriority++;
412 }
413 priorityArray[curPriority] = i;
414 }
415 }
416
417 curPriority = 0;
418 for (i = 0; i < ARRAY_COUNT(priorityArray); i++) {
419 s32 windowIdx = priorityArray[i];
420 if (windowIdx != WIN_NONE) {
421 gWindows[windowIdx].priority = curPriority++;
422 }
423 }
424}
s8 flags
Definition demo_api.c:15
@ WIN_NONE
Definition enums.h:5239

Referenced by filemenu_init(), pause_init(), pause_update_tab_active(), pause_update_tab_inactive(), render_windows(), and set_window_properties().

◆ get_msg_properties()

void get_msg_properties ( s32 msgID,
s32 * height,
s32 * width,
s32 * maxLineChars,
s32 * numLines,
s32 * maxLinesPerPage,
s32 * arg6,
u16 charset )

Definition at line 1671 of file msg.c.

1671 {
1672 u8* message;
1673 s32 i;
1674 u16 pageCount;
1675 s32 linesOnPage;
1676 u8 stop;
1677 s32 lineWidth;
1678 s32 charCount;
1679 u16 lineIndex;
1680 s32 msgStyle;
1681 s32 functionCode;
1682 u8 packedScaleY;
1683 f32 scale;
1684 s32 temp;
1685
1686 u16 lineWidths[32];
1687 u16 lineCharNumbers[32];
1688 u16 linesPerPage[32];
1689 s32 lineCount;
1690 u16 varIndex;
1691 u16 font;
1692 u8* buffer;
1693 u16 maxLineWidth;
1694 u16 maxCharsPerLine;
1695 u16 maxLinesOnPage;
1696 u16 spaceCount;
1697 u16 endl;
1698
1699 u8 c;
1700 u8 prevChar;
1701
1702 scale = 1.0f;
1703 c = 0;
1704 lineIndex = 0;
1705 pageCount = 0;
1706 varIndex = 0;
1707 font = 0;
1708 buffer = NULL;
1709 maxLineWidth = 0;
1710 maxCharsPerLine = 0;
1711 maxLinesOnPage = 0;
1712 spaceCount = 0;
1713
1714 if (msgID == MSG_NONE) {
1715 return;
1716 }
1717
1718 if (msgID >= 0) {
1719 buffer = general_heap_malloc(0x400);
1720 dma_load_msg(msgID, buffer);
1721 message = buffer;
1722 } else {
1723 message = (u8*)msgID;
1724 }
1725
1726 if (charset & 1) {
1727 font = 1;
1728 }
1729
1730 i = 0;
1731 stop = FALSE;
1732 lineWidth = 0;
1733 linesOnPage = 0;
1734 charCount = 0;
1735 endl = TRUE;
1736 lineCount = 0;
1737
1738 do {
1739 prevChar = c;
1740 c = message[i++];
1741 switch (c) {
1746 varIndex = c - MSG_CHAR_READ_VARIANT0;
1747 break;
1749 i++;
1750 break;
1751 case MSG_CHAR_READ_WAIT:
1752 case MSG_CHAR_READ_NEXT:
1753 if (linesOnPage != 0) {
1754 linesPerPage[pageCount] = linesOnPage;
1755 pageCount++;
1756 if (pageCount >= 32) {
1757 stop = 1;
1758 }
1759 linesOnPage = 0;
1760 }
1761 break;
1762 case MSG_CHAR_READ_ENDL:
1763 lineWidths[lineIndex] = lineWidth;
1764 lineCharNumbers[lineIndex] = charCount;
1765 lineIndex++;
1766 if (lineIndex >= 32) {
1767 stop = 1;
1768 }
1769 lineWidth = 0;
1770 charCount = 0;
1771 endl = TRUE;
1772 break;
1774 msgStyle = message[i++];
1775 switch (msgStyle) {
1776 case MSG_STYLE_CHOICE:
1777 i += 4;
1778 break;
1779 case MSG_STYLE_POSTCARD:
1780 i++;
1781 break;
1782 case MSG_STYLE_RIGHT:
1783 case MSG_STYLE_LEFT:
1784 case MSG_STYLE_CENTER:
1785 case MSG_STYLE_TATTLE:
1786 case MSG_STYLE_INSPECT:
1787 case MSG_STYLE_SIGN:
1788 case MSG_STYLE_LAMPPOST:
1789 case MSG_STYLE_POPUP:
1790 case MSG_STYLE_B:
1791 break;
1792 }
1793 break;
1794 case MSG_CHAR_READ_END:
1795 lineWidths[lineIndex] = lineWidth;
1796 lineCharNumbers[lineIndex] = charCount;
1797 lineIndex++;
1798 stop = TRUE;
1799 break;
1801 functionCode = message[i++];
1802 switch (functionCode) {
1803 case MSG_READ_FUNC_FONT:
1804 font = message[i++];
1805 break;
1817 break;
1818 default:
1819 stop = TRUE;
1820 break;
1822 i++;
1823 // fallthrough
1824 temp = 4;
1826 i += temp;
1827 // fallthrough
1830 i++;
1831 // fallthrough
1835 i++;
1836 // fallthrough
1842 case MSG_READ_FUNC_DOWN:
1843 case MSG_READ_FUNC_UP:
1855 i++;
1856 break;
1858 if (message[i] == 0) {
1859 stop = TRUE;
1860 }
1861 i++;
1862 break;
1864 if (message[i] == MSG_CHAR_READ_END) {
1865 stop = TRUE;
1866 }
1867 break;
1868 case MSG_READ_FUNC_SIZE:
1869 packedScaleY = message[i + 1];
1870 i += 2;
1871 scale = (f32)(packedScaleY >> 4) + ((packedScaleY & 0xF) * 0.0625f);
1872 break;
1874 scale = 1.0f;
1875 break;
1877 switch (message[i++]) {
1878 case MSG_FX_STATIC:
1879 case MSG_FX_BLUR:
1880 case MSG_FX_DITHER_FADE:
1881 i++;
1882 break;
1883 case MSG_FX_SHAKE:
1884 case MSG_FX_WAVE:
1886 case MSG_FX_RAINBOW:
1887 case MSG_FX_GLOBAL_WAVE:
1889 case MSG_FX_RISE_PRINT:
1890 case MSG_FX_GROW_PRINT:
1891 case MSG_FX_SIZE_JITTER:
1892 case MSG_FX_SIZE_WAVE:
1893 case MSG_FX_DROP_SHADOW:
1894 break;
1895 }
1896 break;
1897 case MSG_READ_FUNC_VAR:
1898 lineWidth += get_msg_width((s32)gMessageMsgVars[message[i++]], 0);
1899 break;
1900 }
1901 break;
1903 break;
1907 spaceCount++;
1908 // fallthrough
1909 default:
1910 if (endl) {
1911 lineCount++;
1912 linesOnPage++;
1913 endl = FALSE;
1914 }
1915
1916#if VERSION_IQUE
1917 if (prevChar >= MSG_CHAR_MULTIBYTE_FIRST && prevChar <= MSG_CHAR_MULTIBYTE_LAST) {
1918 break;
1919 }
1920#endif
1921
1922 lineWidth += msg_get_print_char_width(c, font, varIndex, scale, 0, 1);
1923 charCount++;
1924 break;
1925 }
1926 } while (!stop);
1927
1928 if (buffer != NULL) {
1929 general_heap_free(buffer);
1930 }
1931
1932 for (i = 0; i < lineIndex; i++) {
1933 if (maxLineWidth < lineWidths[i]) {
1934 maxLineWidth = lineWidths[i];
1935 }
1936 if (maxCharsPerLine < lineCharNumbers[i]) {
1937 maxCharsPerLine = lineCharNumbers[i];
1938 }
1939 }
1940
1941 if (pageCount == 0) {
1942 maxLinesOnPage = linesOnPage;
1943 } else {
1944 for (i = 0; i < pageCount; i++) {
1945 if (maxLinesOnPage < linesPerPage[i]) {
1946 maxLinesOnPage = linesPerPage[i];
1947 }
1948 }
1949 }
1950
1951 if (width != NULL) {
1952 *width = maxLineWidth;
1953 }
1954 if (height != NULL) {
1955 *height = lineCount * MsgCharsets[font]->newLineY;
1956 }
1957 if (maxLineChars != NULL) {
1958 *maxLineChars = maxCharsPerLine;
1959 }
1960 if (numLines != NULL) {
1961 *numLines = lineCount;
1962 }
1963 if (maxLinesPerPage != NULL) {
1964 *maxLinesPerPage = maxLinesOnPage;
1965 }
1966 if (numSpaces != NULL) {
1967 *numSpaces = spaceCount;
1968 }
1969}
#define get_msg_width
@ MSG_READ_FUNC_COLOR
Definition enums.h:6086
@ MSG_READ_FUNC_CURSOR
Definition enums.h:6111
@ MSG_READ_FUNC_RESTORE_COLOR
Definition enums.h:6118
@ MSG_READ_FUNC_RESET_GFX
Definition enums.h:6084
@ MSG_READ_FUNC_START_FX
Definition enums.h:6119
@ MSG_READ_FUNC_INPUT_OFF
Definition enums.h:6088
@ MSG_READ_FUNC_VAR
Definition enums.h:6121
@ MSG_READ_FUNC_SET_CANCEL
Definition enums.h:6113
@ MSG_READ_FUNC_DELAY_OFF
Definition enums.h:6090
@ MSG_READ_FUNC_SAVE_COLOR
Definition enums.h:6117
@ MSG_READ_FUNC_VOICE
Definition enums.h:6127
@ MSG_READ_FUNC_SAVE_POS
Definition enums.h:6115
@ MSG_READ_FUNC_CUSTOM_VOICE
Definition enums.h:6125
@ MSG_READ_FUNC_INLINE_IMAGE
Definition enums.h:6102
@ MSG_READ_FUNC_SET_X
Definition enums.h:6097
@ MSG_READ_FUNC_END_FX
Definition enums.h:6120
@ MSG_READ_FUNC_SET_Y
Definition enums.h:6098
@ MSG_READ_FUNC_SCROLL
Definition enums.h:6093
@ MSG_READ_FUNC_DOWN
Definition enums.h:6100
@ MSG_READ_FUNC_YIELD
Definition enums.h:6085
@ MSG_READ_FUNC_NO_SKIP
Definition enums.h:6087
@ MSG_READ_FUNC_SPACING
Definition enums.h:6092
@ MSG_READ_FUNC_RESTORE_POS
Definition enums.h:6116
@ MSG_READ_FUNC_SPEED
Definition enums.h:6096
@ MSG_READ_FUNC_OPTION
Definition enums.h:6114
@ MSG_READ_FUNC_SIZE
Definition enums.h:6094
@ MSG_READ_FUNC_ENABLE_CDOWN_NEXT
Definition enums.h:6124
@ MSG_READ_FUNC_HIDE_IMAGE
Definition enums.h:6106
@ MSG_READ_FUNC_DELAY_ON
Definition enums.h:6091
@ MSG_READ_FUNC_END_CHOICE
Definition enums.h:6112
@ MSG_READ_FUNC_IMAGE
Definition enums.h:6105
@ MSG_READ_FUNC_RIGHT
Definition enums.h:6099
@ MSG_READ_FUNC_ANIM_LOOP
Definition enums.h:6108
@ MSG_READ_FUNC_CENTER_X
Definition enums.h:6122
@ MSG_READ_FUNC_ANIM_DELAY
Definition enums.h:6107
@ MSG_READ_FUNC_ITEM_ICON
Definition enums.h:6104
@ MSG_READ_FUNC_SET_REWIND
Definition enums.h:6123
@ MSG_READ_FUNC_UP
Definition enums.h:6101
@ MSG_READ_FUNC_INPUT_ON
Definition enums.h:6089
@ MSG_READ_FUNC_FONT
Definition enums.h:6081
@ MSG_READ_FUNC_SIZE_RESET
Definition enums.h:6095
@ MSG_READ_FUNC_ANIM_SPRITE
Definition enums.h:6103
@ MSG_READ_FUNC_ANIM_DONE
Definition enums.h:6109
@ MSG_STYLE_POSTCARD
Definition enums.h:6204
@ MSG_STYLE_CENTER
Definition enums.h:6198
@ MSG_STYLE_LEFT
Definition enums.h:6197
@ MSG_STYLE_SIGN
Definition enums.h:6202
@ MSG_STYLE_B
Definition enums.h:6206
@ MSG_STYLE_INSPECT
Definition enums.h:6201
@ MSG_STYLE_LAMPPOST
Definition enums.h:6203
@ MSG_STYLE_POPUP
Definition enums.h:6205
@ MSG_STYLE_RIGHT
Definition enums.h:6196
@ MSG_STYLE_TATTLE
Definition enums.h:6199
@ MSG_STYLE_CHOICE
Definition enums.h:6200
@ MSG_FX_NOISE_OUTLINE
Definition enums.h:6163
@ MSG_FX_RISE_PRINT
Definition enums.h:6170
@ MSG_FX_SIZE_JITTER
Definition enums.h:6172
@ MSG_FX_SHAKE
Definition enums.h:6161
@ MSG_FX_GLOBAL_WAVE
Definition enums.h:6168
@ MSG_FX_GLOBAL_RAINBOW
Definition enums.h:6169
@ MSG_FX_DROP_SHADOW
Definition enums.h:6174
@ MSG_FX_SIZE_WAVE
Definition enums.h:6173
@ MSG_FX_STATIC
Definition enums.h:6164
@ MSG_FX_BLUR
Definition enums.h:6165
@ MSG_FX_DITHER_FADE
Definition enums.h:6167
@ MSG_FX_WAVE
Definition enums.h:6162
@ MSG_FX_RAINBOW
Definition enums.h:6166
@ MSG_FX_GROW_PRINT
Definition enums.h:6171
@ MSG_CHAR_READ_VARIANT2
Definition enums.h:6047
@ MSG_CHAR_READ_PAUSE
Definition enums.h:6044
@ MSG_CHAR_READ_WAIT
Definition enums.h:6043
@ MSG_CHAR_READ_HALF_SPACE
Definition enums.h:6051
@ MSG_CHAR_READ_SPACE
Definition enums.h:6049
@ MSG_CHAR_READ_VARIANT3
Definition enums.h:6048
@ MSG_CHAR_READ_STYLE
Definition enums.h:6054
@ MSG_CHAR_READ_FULL_SPACE
Definition enums.h:6050
@ MSG_CHAR_READ_UNK_CHAR_FA
Definition enums.h:6052
@ MSG_CHAR_READ_NEXT
Definition enums.h:6053
@ MSG_CHAR_READ_VARIANT0
Definition enums.h:6045
@ MSG_CHAR_READ_ENDL
Definition enums.h:6042
@ MSG_CHAR_READ_END
Definition enums.h:6055
@ MSG_CHAR_READ_VARIANT1
Definition enums.h:6046
@ MSG_CHAR_READ_FUNCTION
Definition enums.h:6057
s32 general_heap_free(void *data)
Definition heap.c:18
s32 msg_get_print_char_width(s32 character, s32 charset, s32 variation, f32 msgScale, s32 overrideCharWidth, u8 flags)
Definition msg.c:1578
void dma_load_msg(u32 msgID, void *dest)
Definition msg.c:1396
MessageCharset * MsgCharsets[5]
Definition msg_data.c:865

Referenced by _msg_get_printer_for_msg(), draw_msg(), get_msg_lines(), get_msg_width(), pause_handle_input(), and pause_tutorial_draw_contents().

◆ replace_window_update()

void replace_window_update ( s32 idx,
s8 arg1,
WindowUpdateFunc pendingFunc )

Definition at line 426 of file windows.c.

426 {
427 if (gWindows[windowID].flags & WINDOW_FLAG_INITIALIZED) {
429 gWindows[windowID].fpPending = pendingFunc;
430 gWindows[windowID].originalPriority = priority;
431 }
432}
@ WINDOW_FLAG_FPUPDATE_CHANGED
Definition enums.h:4993
@ WINDOW_FLAG_INITIALIZED
Definition enums.h:4992
@ WINDOW_FLAG_INITIAL_ANIMATION
Definition enums.h:4995
WindowUpdateFunc fpPending
u8 originalPriority

Referenced by pause_tabs_handle_input().

◆ decode_yay0()

◆ ai_check_player_dist()

s32 ai_check_player_dist ( Enemy * enemy,
s32 arg1,
f32 arg2,
f32 arg3 )

Definition at line 515 of file 23680.c.

515 {
516 PlayerStatus* playerStatus = &gPlayerStatus;
517 Npc* npc = get_npc_unsafe(enemy->npcID);
518 f32 posX, posZ;
519
520 if (chance >= 0) {
521 s32 skipCheckForPlayer;
522
523 if (chance != 0) {
524 skipCheckForPlayer = rand_int(chance + 1);
525 } else {
526 skipCheckForPlayer = 0;
527 }
528
529 if (skipCheckForPlayer == 0) {
530 posX = npc->pos.x;
531 posZ = npc->pos.z;
532 add_vec2D_polar(&posX, &posZ, moveSpeed, 270.0f - npc->renderYaw);
533
534 if (dist2D(posX, posZ, playerStatus->pos.x, playerStatus->pos.z) <= radius) {
535 return TRUE;
536 }
537 }
538 }
539
540 return FALSE;
541}
void add_vec2D_polar(f32 *x, f32 *y, f32 r, f32 theta)
Definition 43F0.c:684
s16 npcID
Definition npc.h:300
Npc * get_npc_unsafe(s32 npcID)
Definition npc.c:994
f32 renderYaw
Vec3f pos

Referenced by CleftAI_CanSeePlayer(), and ProjectileHitbox_GetUsableProjectileID().

◆ pause_init()

void pause_init ( void )

Definition at line 605 of file pause_main.c.

605 {
606 s32 posX;
607 s32 x;
608 Window* pauseWindows;
609 MenuPanel** menuPanels;
610 s32 i;
611
612 DMA_COPY_SEGMENT(ui_images_filemenu_pause);
613
614 for (i = 0; i < ARRAY_COUNT(gPauseHudScripts); i++) {
615 gPauseCommonHIDs[i] = hud_element_create(gPauseHudScripts[i]);
616 if (gPauseHudScripts[i] == &HES_AnimatedCursorHand) {
618 } else {
619 hud_element_set_flags(gPauseCommonHIDs[i], HUD_ELEMENT_FLAG_80);
620 }
621 }
622
623 gPauseCursorHID = gPauseCommonHIDs[0];
625 gPauseShownDescMsg = 0;
626 gPauseDescTextPos = 0;
627 gPauseDescTextOffset = 0;
628 gPauseDescTextMaxPos = 0;
629 gPauseShownDescIconScript = 0;
630 gPauseCurrentDescMsg = MSG_NONE;
633
634 menuPanels = gPausePanels;
635 for (i = 0; i < ARRAY_COUNT(gPausePanels); menuPanels++, i++) {
636 if ((*menuPanels)->fpInit) {
637 (*menuPanels)->fpInit(*menuPanels);
638 }
639 }
640
641 posX = 225;
642 for (i = 6; i > 0; i--) {
643 if (!gPausePanels[i]->initialized) {
645 } else {
646 gWindows[WIN_PAUSE_TUTORIAL + i].pos.x = posX + 14;
647 posX -= 45;
648 }
649 }
650 pauseWindows = &gWindows[WIN_PAUSE_TAB_STATS];
651 x = pauseWindows[gPausePanels[0]->col].pos.x;
653
655 for (i = 0; i < ARRAY_COUNT(gPauseTutorialSpriteAnims); i++) {
656 gPauseTutorialSprites[i] = spr_load_npc_sprite(gPauseTutorialSpriteAnims[i][0], gPauseTutorialSpriteAnims[i]);
657 }
658
661 }
662
664}
@ WINDOW_UPDATE_SHOW
Definition enums.h:5310
@ WINDOW_UPDATE_HIDE
Definition enums.h:5311
@ SOUND_MENU_SHOW_CHOICE
Definition enums.h:554
@ WIN_PAUSE_TAB_INVIS
Definition enums.h:5285
@ WIN_PAUSE_CURSOR
Definition enums.h:5286
@ WIN_PAUSE_TAB_STATS
Definition enums.h:5267
@ WIN_PAUSE_TUTORIAL
Definition enums.h:5265
HudScript HES_AnimatedCursorHand
s32 evt_get_variable(Evt *script, Bytecode var)
Definition evt.c:1689
void set_window_update(s32 panelID, s32)
Definition windows.c:434
void update_window_hierarchy(s32 windowIndex, u8 arg1)
Definition windows.c:393
void setup_pause_menu_tab(MenuWindowBP *bpArray, s32 arraySize)
Definition windows.c:461
s32 hud_element_create(HudScript *anim)
Creates a new HUD element and returns its ID.
void hud_element_set_flags(s32 id, s32 flags)
Turns on the given flags.
@ HUD_ELEMENT_FLAG_80
Definition hud_element.h:78
@ HUD_ELEMENT_FLAG_DROP_SHADOW
BSS s8 gPauseMenuCurrentTab
Definition pause_main.c:28
s32 gPauseTutorialSpriteAnims[][4]
Definition pause_main.c:106
BSS HudElemID gPauseCursorHID
Definition pause_main.c:27
BSS HudScript * gPauseCurrentDescIconScript
Definition pause_main.c:26
MenuPanel * gPausePanels[]
Definition pause_main.c:47
BSS s32 gPauseCurrentDescMsg
Definition pause_main.c:25
MenuWindowBP gPauseCommonWindowsBPs[]
Definition pause_main.c:133
void sfx_play_sound(s32 soundID)
Definition sfx.c:517
@ GF_Tutorial_Badges
#define DMA_COPY_SEGMENT(segment)
Definition macros.h:529
s32 spr_load_npc_sprite(s32 animID, u32 *extraAnimList)
Definition sprite.c:1025
void(* fpInit)(struct MenuPanel *)
Window gWindows[64]
Definition windows.c:23

Referenced by state_step_pause().

◆ pause_handle_input()

void pause_handle_input ( s32 buttonsPressed,
s32 buttonsHeld )

Definition at line 718 of file pause_main.c.

718 {
719 s32 height;
720 s32 width;
721 s32 maxLineChars;
722 s32 numLines;
723 s32 i,j;
724 MenuPanel** menuPanels;
725 s32 currentDescMsg = gPauseCurrentDescMsg;
727
729 for (i = 0; i < ARRAY_COUNT(gPauseTutorialSprites); i++) {
730 spr_update_sprite(gPauseTutorialSprites[i], gPauseTutorialSpriteAnims[i][1], 1.0f);
731 }
732 }
733
734 gPausePressedButtons = pressed;
735 gPauseHeldButtons = held;
738 }
739
744 return;
745 }
746
747 if (gPauseCurrentDescIconScript != gPauseShownDescIconScript) {
748 gPauseShownDescIconScript = gPauseCurrentDescIconScript;
749 }
750
751 if (currentDescMsg != gPauseShownDescMsg) {
752 gPauseShownDescMsg = currentDescMsg;
753 gPauseDescTextPos = 0;
754 gPauseDescTextOffset = 0;
755 if (currentDescMsg != 0) {
756 get_msg_properties(currentDescMsg, &height, &width, &maxLineChars, &numLines, NULL, NULL, 0);
757 if (numLines % 2) {
758 numLines++;
759 }
760 gPauseDescTextMaxPos = numLines - 2;
761 if (gPauseDescTextMaxPos < 0) {
762 gPauseDescTextMaxPos = 0;
763 }
764 } else {
765 gPauseDescTextMaxPos = 0;
766 }
767 }
769 gPauseDescTextPos -= 2;
770 if (gPauseDescTextPos < 0) {
771 gPauseDescTextPos = 0;
772 }
773 }
775 gPauseDescTextPos += 2;
776 if (gPauseDescTextPos > gPauseDescTextMaxPos) {
777 gPauseDescTextPos = gPauseDescTextMaxPos;
778 }
779 }
780 gPauseDescTextOffset += pause_interp_text_scroll(gPauseDescTextPos * 16 - gPauseDescTextOffset);
781 if (currentPanel->initialized) {
782 if (currentPanel->fpHandleInput) {
783 currentPanel->fpHandleInput(currentPanel);
784 }
785 }
786 menuPanels = gPausePanels;
787 for (i = 0; i < ARRAY_COUNT(gPausePanels); menuPanels++, i++) {
788 if ((*menuPanels)->initialized) {
789 if ((*menuPanels)->fpUpdate) {
790 (*menuPanels)->fpUpdate(*menuPanels);
791 }
792 }
793 }
794}
@ BUTTON_C_UP
Definition enums.h:2780
@ BUTTON_START
Definition enums.h:2787
@ BUTTON_C_DOWN
Definition enums.h:2779
@ BUTTON_B
Definition enums.h:2789
@ SOUND_MENU_CLOSE
Definition enums.h:697
void get_msg_properties(s32 msgID, s32 *height, s32 *width, s32 *maxLineChars, s32 *numLines, s32 *maxLinesPerPage, s32 *arg6, u16 charset)
Definition msg.c:1671
void enforce_hpfp_limits(void)
Definition inventory.c:463
@ GAME_MODE_UNPAUSE
Definition game_modes.h:18
BSS s32 gPausePressedButtons
Definition pause_main.c:24
s32 pause_interp_text_scroll(s32 deltaBefore)
Definition pause_main.c:437
BSS s32 gPauseHeldButtons
Definition pause_main.c:23
void pause_tutorial_input(s32 *pressed, s32 *held)
Definition pause_main.c:666
s32 spr_update_sprite(s32 spriteInstanceID, s32 animID, f32 timeScale)
Definition sprite.c:1071
void(* fpHandleInput)(struct MenuPanel *)
void(* fpUpdate)(struct MenuPanel *)

Referenced by state_step_pause().

◆ pause_cleanup()

void pause_cleanup ( void )

Definition at line 796 of file pause_main.c.

796 {
797 s32 i;
798 MenuPanel** menuPanels;
799
800 for (i = 0; i < ARRAY_COUNT(gPauseCommonHIDs); i++) {
801 hud_element_free(gPauseCommonHIDs[i]);
802 }
803
805 for (i = 0; i < ARRAY_COUNT(gPauseTutorialSprites); i++) {
806 spr_free_sprite(gPauseTutorialSprites[i]);
807 }
808 }
809
810 menuPanels = gPausePanels;
811 for (i = 0; i < ARRAY_COUNT(gPausePanels); menuPanels++, i++) {
812 if ((*menuPanels)->initialized) {
813 if ((*menuPanels)->fpCleanup) {
814 (*menuPanels)->fpCleanup(*menuPanels);
815 }
816 }
817 }
818
819 for (i = WIN_PAUSE_MAIN; i < WIN_PAUSE_CURSOR; i++)
821
823}
@ WIN_PAUSE_MAIN
Definition enums.h:5262
void hud_element_free(s32 id)
s32 spr_free_sprite(s32 spriteInstanceID)
Definition sprite.c:1177
void(* fpCleanup)(struct MenuPanel *)

Referenced by state_step_unpause().

◆ filemenu_init()

void filemenu_init ( s32 mode)

Definition at line 880 of file filemenu_common.c.

880 {
881 MenuPanel* menu;
882 s32 i;
883
884 DMA_COPY_SEGMENT(ui_images_filemenu_pause);
885
886 for (i = 0; i < ARRAY_COUNT(filemenu_cursorHIDs); i++) {
889 }
890
892 if (mode == 0) {
894 }
896
899
901
902 if (menu->state == FM_MAIN_SELECT_FILE) {
903 for (i = 0; i < ARRAY_COUNT(filemenu_menus); i++) {
904 if (fio_load_game(i)) {
906 gSaveSlotMetadata[i].hasData = TRUE;
909 } else {
910 gSaveSlotMetadata[i].hasData = FALSE;
911 gSaveSlotMetadata[i].validData = FALSE;
912 memset(gSaveSlotMetadata[i].modName, ARRAY_COUNT(gSaveSlotMetadata[i].modName), 0);
913 }
914 }
915
919 }
921 }
922
924
925 for (i = 0; i < ARRAY_COUNT(filemenu_menus); i++) {
926 menu = filemenu_menus[i];
927 if (menu->fpInit != NULL) {
928 menu->fpInit(menu);
929 }
930 }
932}
WindowBackground background
WindowStyleCustom * customStyle
#define DX_MOD_NAME
Creates the version string that appears on the file select menu.
Definition config.h:7
@ WIN_PAUSE_DECRIPTION
Definition enums.h:5263
@ FILE_MENU_MAIN
Definition filemenu.h:18
@ FM_MAIN_SELECT_FILE
Definition filemenu.h:25
MenuWindowBP filemenu_common_windowBPs[]
BSS HudElemID filemenu_cursorHID
HudScript * filemenu_cursor_hudElemScripts[]
MenuPanel * filemenu_menus[]
BSS s8 filemenu_currentMenu
BSS HudElemID filemenu_cursorHIDs[1]
void filemenu_set_selected(MenuPanel *menu, s32 col, s32 row)
b32 fio_load_globals(void)
Definition fio.c:75
b32 fio_load_game(s32 saveSlot)
Definition fio.c:167
SaveGlobals gSaveGlobals
Definition fio.c:20
SaveFileSummary gSaveSlotSummary[4]
SaveSlotMetadata gSaveSlotMetadata[4]
WindowStyle style
SaveFileSummary summary
Definition versioning.h:170
SaveData gCurrentSaveFile
Definition fio.c:21
char modName[28]
Definition versioning.h:145
u32 lastFileSelected
Definition versioning.h:15

Referenced by state_step_file_select().

◆ filemenu_cleanup()

void filemenu_cleanup ( void )

Definition at line 934 of file filemenu_common.c.

934 {
935 MenuPanel* menu;
936 s32 i;
937
938 for (i = 0; i < ARRAY_COUNT(filemenu_cursorHIDs); i++) {
940 }
941
942 for (i = 0; i < ARRAY_COUNT(filemenu_menus); i++) {
943 menu = filemenu_menus[i];
944 if (menu->initialized) {
945 if (menu->fpCleanup != NULL) {
946 menu->fpCleanup(menu);
947 }
948 }
949 }
950
951 for (i = WIN_FILES_MAIN; i < ARRAY_COUNT(gWindows); i++) {
953 }
954
957 filemenu_get_exit_mode(); // part of a conditional that optimized out?
958}
@ WIN_FILES_MAIN
Definition enums.h:5287
s32 filemenu_get_exit_mode()

Referenced by state_step_exit_file_select().

◆ filemenu_update()

void filemenu_update ( void )

Definition at line 260 of file filemenu_common.c.

260 {
261 MenuPanel* menu;
262 s32 i;
263
264 for (i = WIN_FILES_MAIN; i < ARRAY_COUNT(gWindows); i++) {
265 if ((gWindows[i].parent == WIN_NONE || gWindows[i].parent == WIN_FILES_MAIN) &&
267 {
268 break;
269 }
270 }
271
272 if (i >= ARRAY_COUNT(gWindows)) {
275 } else {
278 }
279
280 // B overrides A
282 filemenu_pressedButtons &= ~BUTTON_A;
283 }
285 filemenu_heldButtons &= ~BUTTON_A;
286 }
287
288 // only process inputs for the current menu
290 if (menu->initialized) {
291 if (menu->fpHandleInput != NULL) {
292 menu->fpHandleInput(menu);
293 }
294 }
295
296 // update all menus
297 for (i = 0; i < ARRAY_COUNT(filemenu_menus); i++) {
298 menu = filemenu_menus[i];
299 if (menu->initialized && menu->fpUpdate != NULL) {
300 menu->fpUpdate(menu);
301 }
302 }
303}
u32 pressedButtons[4]
BSS s32 filemenu_pressedButtons
BSS s32 filemenu_heldButtons

Referenced by state_step_file_select().

◆ filemenu_get_exit_mode()

s32 filemenu_get_exit_mode ( void )

Definition at line 960 of file filemenu_common.c.

960 {
963 && filemenu_menus[FILE_MENU_CONFIRM]->selected == 0
964 ) {
965 return 2;
966 }
967
970 ) {
971 return 1;
972 }
973
974 return 0;
975}
@ FILE_MENU_CONFIRM
Definition filemenu.h:19
@ FM_MAIN_OPT_FILE_4
Definition filemenu.h:47

Referenced by filemenu_cleanup(), state_init_exit_file_select(), and state_step_exit_file_select().

◆ filemenu_set_selected()

void filemenu_set_selected ( MenuPanel * menu,
s32 col,
s32 row )

Definition at line 151 of file filemenu_common.c.

151 {
152 menu->col = col;
153 menu->row = row;
154 menu->selected = menu->gridData[(menu->state * menu->numCols * menu->numRows) +
155 (menu->numCols * menu->row) + menu->col];
156}

Referenced by filemenu_choose_name_handle_input(), filemenu_info_handle_input(), filemenu_init(), filemenu_main_handle_input(), and filemenu_yesno_handle_input().

◆ filemenu_set_cursor_alpha()

void filemenu_set_cursor_alpha ( s32 arg0)

Definition at line 158 of file filemenu_common.c.

158 {
161}
s32 filemenu_cursorGoalAlpha
s32 filemenu_cursorGoalAlpha2

Referenced by filemenu_info_draw_message_contents().

◆ filemenu_set_cursor_goal_pos()

void filemenu_set_cursor_goal_pos ( s32 windowIndex,
s32 posX,
s32 posY )

Definition at line 163 of file filemenu_common.c.

163 {
164 Window* window = &gWindows[windowID];
165
167 if (D_80249BB0) {
168 s32 i;
169
170 for (i = WIN_FILES_MAIN; i < ARRAY_COUNT(gWindows); i++) {
171 Window* window = &gWindows[i];
172 s8 parent = window->parent;
173
174 if ((parent == WIN_NONE || parent == WIN_FILES_MAIN) && (window->flags & WINDOW_FLAG_INITIAL_ANIMATION)) {
175 break;
176 }
177 }
178 if (i >= ARRAY_COUNT(gWindows)) {
179 D_80249BB0 = FALSE;
180 }
181 }
186 } else if (!(window->flags & WINDOW_FLAG_INITIAL_ANIMATION) &&
187 (window->parent == WIN_NONE || !(gWindows[window->parent].flags & WINDOW_FLAG_INITIAL_ANIMATION))) {
190 }
191}
s32 D_80249BB0
s32 filemenu_cursor_targetX
s32 filemenu_cursor_targetY
s32 filemenu_cursor_posX
s32 filemenu_cursor_posY
s32 get_game_mode(void)
Definition game_modes.c:123
@ GAME_MODE_END_FILE_SELECT
Definition game_modes.h:20

Referenced by filemenu_draw_contents_choose_name(), filemenu_draw_contents_file_title(), filemenu_draw_contents_option_center(), filemenu_draw_contents_option_left(), filemenu_draw_contents_option_right(), and filemenu_yesno_draw_options_contents().

◆ filemenu_get_menu_message()

◆ gfx_task_background()

void gfx_task_background ( void )

Definition at line 169 of file main_loop.c.

169 {
172
175
176 gDPFullSync(gMainGfxPos++);
177 gSPEndDisplayList(gMainGfxPos++);
178
179 // TODO these << 3 >> 3 shouldn't be necessary. There's almost definitely something we're missing here...
180 ASSERT((s32)((u32)((gMainGfxPos - gDisplayContext->backgroundGfx) << 3) >> 3) < ARRAY_COUNT(
182
183 nuGfxTaskStart(&gDisplayContext->backgroundGfx[0], (u32)(gMainGfxPos - gDisplayContext->backgroundGfx) * 8,
184 NU_GFX_UCODE_F3DEX2, NU_SC_NOSWAPBUFFER);
185}
Gfx backgroundGfx[0x200]
DisplayContext DisplayContexts[2]
Definition main_loop.c:16
void gfx_draw_background(void)
Logic for the drawing the scene background.
void gfx_init_state(void)
s32 gCurrentDisplayContextIndex
Definition main_loop.c:47
DisplayContext * gDisplayContext
Definition cam_main.c:16

Referenced by gfxRetrace_Callback().

◆ update_enemy_shadows()

void update_enemy_shadows ( void )

Definition at line 815 of file actor_rendering.c.

815 {
816 BattleStatus* battleStatus = &gBattleStatus;
817 s32 i;
818
819 for (i = 0; i < ARRAY_COUNT(battleStatus->enemyActors); i++) {
820 update_nonplayer_actor_shadow(FALSE, battleStatus->enemyActors[i]);
821 }
822}
void update_nonplayer_actor_shadow(b32 isPartner, Actor *actor)
struct Actor * enemyActors[24]

Referenced by update_nonplayer_actor_shadows().

◆ update_hero_shadows()

void update_hero_shadows ( void )

Definition at line 824 of file actor_rendering.c.

824 {
827}
void update_player_actor_shadow(void)
struct Actor * partnerActor

Referenced by update_nonplayer_actor_shadows().

◆ appendGfx_background_texture()

void appendGfx_background_texture ( void )
Bug
xh = 2 * bgXOffset + (bgMinX - 1) * 4
Bug
xh = 2 * bgXOffset + (bgMinX - 1) * 4

Definition at line 62 of file background.c.

62 {
64 u16 flags = 0;
65 s32 fogR, fogG, fogB, fogA;
66 u8 r1, g1, b1, a1;
67 u8 r2, g2, b2;
68 u16 blendedR, blendedG, blendedB;
69 s32 i;
70
71 f32 theta, sinTheta, cosTheta, scrollValue, f5, waveOffset;
72
73 s32 bgMinX;
74 s32 bgMinY;
75 s32 bgMaxX;
76 s32 bgMaxY;
77 s32 lineHeight;
78 s32 numLines;
79 s32 extraHeight;
80
81 s32 bgXOffset;
82 s16 texOffsetY;
83
84 u8* newvar;
85
86 enum {
87 BG_BLEND_NONE = 0,
88 BG_BLEND_HAS_FOG = 1,
89 BG_BLEND_SHOULD_LERP = 2,
90 BG_BLEND_SHOULD_BLEND = 4,
91 };
92
94 get_world_fog_color(&fogR, &fogG, &fogB, &fogA);
95 flags = BG_BLEND_HAS_FOG;
97 }
98
99 switch (*gBackgroundTintModePtr) {
100 case ENV_TINT_NONE:
101 case ENV_TINT_SHROUD:
102 mdl_get_shroud_tint_params(&r1, &g1, &b1, &a1);
103 if (a1 != 0) {
104 flags |= BG_BLEND_SHOULD_LERP;
105 }
106 break;
107 case ENV_TINT_DEPTH:
108 case ENV_TINT_REMAP:
109 default:
110 mdl_get_remap_tint_params(&r1, &g1, &b1, &r2, &g2, &b2);
111 if (!(r1 == 255 && g1 == 255 && b1 == 255 && r2 == 0 && g2 == 0 && b2 == 0)) {
112 flags |= BG_BLEND_SHOULD_BLEND;
113 }
114 break;
115 }
116
117 switch (flags) {
118 case BG_BLEND_NONE:
119 gGameStatusPtr->backgroundFlags &= ~BACKGROUND_FLAG_FOG;
120 break;
121 case BG_BLEND_HAS_FOG:
123 break;
124 case BG_BLEND_SHOULD_LERP:
126 fogR = r1;
127 fogG = g1;
128 fogB = b1;
129 fogA = a1;
130 break;
131 case BG_BLEND_HAS_FOG | BG_BLEND_SHOULD_LERP:
133 fogR = (fogR * (255 - a1) + r1 * a1) / 255;
134 fogG = (fogG * (255 - a1) + g1 * a1) / 255;
135 fogB = (fogB * (255 - a1) + b1 * a1) / 255;
136 fogA = (fogA * (255 - a1) + a1 * a1) / 255;
137 break;
138 case BG_BLEND_SHOULD_BLEND:
140 break;
141 }
142
144 switch (*gBackgroundTintModePtr) {
145 case ENV_TINT_NONE:
146 case ENV_TINT_SHROUD:
147 if (fogA == 255) {
148 for (i = 0; i < ARRAY_COUNT(gBackgroundPalette); i++) {
149 gBackgroundPalette[i] = 1;
150 }
151 } else {
152 // lerp from background palette color to fog color based on fog alpha
153 for (i = 0; i < ARRAY_COUNT(gBackgroundPalette); i++) {
154 // NOTE: values after UNPACK range from [0,31], so we need to shift fog color into that range
155 u16 palColor = gGameStatusPtr->backgroundPalette[i];
156 blendedB = blend_background_channel(UNPACK_PAL_B(palColor), fogB >> 3, fogA);
157 blendedG = blend_background_channel(UNPACK_PAL_G(palColor), fogG >> 3, fogA);
158 blendedR = blend_background_channel(UNPACK_PAL_R(palColor), fogR >> 3, fogA);
159 gBackgroundPalette[i] = blendedB << 1 | blendedG << 6 | blendedR << 11 | 1;
160 }
161 }
162 break;
163 case ENV_TINT_DEPTH:
164 case ENV_TINT_REMAP:
165 default:
166 // the background color channels are remapped from [0,255] -> [min,max]
167 for (i = 0; i < ARRAY_COUNT(gBackgroundPalette); i++) {
168 // NOTE: values after UNPACK range from [0,31], so we need to shift other colors into that range
169 u16 palColor = gGameStatusPtr->backgroundPalette[i];
170 blendedB = (b2 >> 3) + ((UNPACK_PAL_B(palColor) * b1 >> 3) >> 5);
171 blendedG = (g2 >> 3) + ((UNPACK_PAL_G(palColor) * g1 >> 3) >> 5);
172 blendedR = (r2 >> 3) + ((UNPACK_PAL_R(palColor) * r1 >> 3) >> 5);
173
174 if (blendedB > 0x1F) {
175 blendedB = 0x1F;
176 }
177 if (blendedG > 0x1F) {
178 blendedG = 0x1F;
179 }
180 if (blendedR > 0x1F) {
181 blendedR = 0x1F;
182 }
183 gBackgroundPalette[i] = blendedB << 1 | blendedG << 6 | blendedR << 11 | 1;
184 }
185 break;
186 }
187 }
188
189 theta = clamp_angle(-cam->curBoomYaw);
190 sinTheta = sin_deg(theta);
191 cosTheta = cos_deg(theta);
192 f5 = cosTheta * cam->lookAt_obj.x - sinTheta * cam->lookAt_obj.z + cam->leadAmount;
193 scrollValue = -f5 * 0.25f;
194 scrollValue += gGameStatusPtr->backgroundMaxX * theta * (1 / 90.0f);
195
196 if (fabsf(scrollValue - gBackroundLastScrollValue) < 0.3f) {
197 scrollValue = gBackroundLastScrollValue;
198 } else {
199 gBackroundLastScrollValue = scrollValue;
200 }
201
202 while (scrollValue < 0.0f) {
203 scrollValue += gGameStatusPtr->backgroundMaxX * 32;
204 }
205
206 bgXOffset = gGameStatusPtr->backgroundXOffset = ((s32)scrollValue) % gGameStatusPtr->backgroundMaxX;
211
212 gDPPipeSync(gMainGfxPos++);
213 gDPSetCycleType(gMainGfxPos++, G_CYC_COPY);
214 gDPSetTexturePersp(gMainGfxPos++, G_TP_NONE);
215 gDPSetTextureLUT(gMainGfxPos++, G_TT_RGBA16);
216 gDPSetCombineMode(gMainGfxPos++, G_CC_DECALRGB, G_CC_DECALRGB);
217 gDPSetRenderMode(gMainGfxPos++, G_RM_NOOP, G_RM_NOOP2);
218 gDPSetTextureFilter(gMainGfxPos++, G_TF_POINT);
219 gDPPipeSync(gMainGfxPos++);
220
222 gDPLoadTLUT_pal256(gMainGfxPos++, gGameStatusPtr->backgroundPalette);
223 } else {
224 gDPLoadTLUT_pal256(gMainGfxPos++, gBackgroundPalette);
225 }
226
228 lineHeight = 2048 / gGameStatusPtr->backgroundMaxX;
229 numLines = gGameStatusPtr->backgroundMaxY / lineHeight;
230 extraHeight = gGameStatusPtr->backgroundMaxY % lineHeight;
231 for (i = 0; i < numLines; i++) {
232 texOffsetY = gBackroundTextureYOffset + lineHeight * i;
233 if (texOffsetY > gGameStatusPtr->backgroundMaxY) {
234 texOffsetY -= gGameStatusPtr->backgroundMaxY;
235 }
236 gDPLoadTextureTile(gMainGfxPos++, gGameStatusPtr->backgroundRaster + bgMaxX * texOffsetY,
237 G_IM_FMT_CI, G_IM_SIZ_8b, bgMaxX, 6,
238 0, 0, 295, 5, 0,
239 G_TX_WRAP, G_TX_WRAP, G_TX_NOMASK, G_TX_NOMASK, G_TX_NOLOD, G_TX_NOLOD);
240
241 gSPTextureRectangle(gMainGfxPos++, bgMinX * 4, (lineHeight * i + bgMinY) * 4,
242 (bgXOffset + bgMinX - 1) * 4, (lineHeight * i + lineHeight - 1 + bgMinY) * 4,
243 G_TX_RENDERTILE, (bgMaxX - bgXOffset) * 32, 0, 4096, 1024);
244 gSPTextureRectangle(gMainGfxPos++, (bgXOffset + bgMinX) * 4, (lineHeight * i + bgMinY) * 4,
245 (bgMaxX + bgMinX - 1) * 4, (lineHeight * i + lineHeight - 1 + bgMinY) * 4,
246 G_TX_RENDERTILE, 0, 0, 4096, 1024);
247 }
248 if (extraHeight != 0) {
249 texOffsetY = gBackroundTextureYOffset + lineHeight * i;
250 if (texOffsetY > gGameStatusPtr->backgroundMaxY) {
251 texOffsetY -= gGameStatusPtr->backgroundMaxY;
252 }
253 gDPLoadTextureTile(gMainGfxPos++, gGameStatusPtr->backgroundRaster + bgMaxX * texOffsetY,
254 G_IM_FMT_CI, G_IM_SIZ_8b, bgMaxX, extraHeight,
255 0, 0, 295, extraHeight - 1, 0,
256 G_TX_WRAP, G_TX_WRAP, G_TX_NOMASK, G_TX_NOMASK, G_TX_NOLOD, G_TX_NOLOD);
257 gSPTextureRectangle(gMainGfxPos++, bgMinX * 4, (lineHeight * i + bgMinY) * 4,
258 (bgXOffset + bgMinX - 1) * 4, (bgMaxY - 1 + bgMinY) * 4,
259 G_TX_RENDERTILE, (bgMaxX - bgXOffset) * 32, 0, 4096, 1024);
260 gSPTextureRectangle(gMainGfxPos++, (bgXOffset + bgMinX) * 4, (lineHeight * i + bgMinY) * 4,
261 (bgMaxX + bgMinX - 1) * 4, (bgMaxY - 1 + bgMinY) * 4,
262 G_TX_RENDERTILE, 0, 0, 4096, 1024);
263 }
264 } else {
265 lineHeight = 6;
266 numLines = gGameStatusPtr->backgroundMaxY / lineHeight;
267 extraHeight = gGameStatusPtr->backgroundMaxY % lineHeight;
268 gBackroundWavePhase += TAU / 60; // 60 frames period
269 for (i = 0; i < numLines; i++) {
270 waveOffset = sin_rad(gBackroundWavePhase + i * (TAU / 15)) * 3.0f;
271 bgXOffset = 2.0f * (gGameStatusPtr->backgroundXOffset + waveOffset);
272 texOffsetY = gBackroundTextureYOffset + lineHeight * i;
273 if (texOffsetY > gGameStatusPtr->backgroundMaxY) {
274 texOffsetY -= gGameStatusPtr->backgroundMaxY;
275 }
276 gDPLoadTextureTile(gMainGfxPos++, gGameStatusPtr->backgroundRaster + bgMaxX * texOffsetY,
277 G_IM_FMT_CI, G_IM_SIZ_8b, bgMaxX, 6,
278 0, 0, 295, 5, 0,
279 G_TX_WRAP, G_TX_WRAP, G_TX_NOMASK, G_TX_NOMASK, G_TX_NOLOD, G_TX_NOLOD);
280
281 gSPTextureRectangle(gMainGfxPos++, bgMinX * 4, (lineHeight * i + bgMinY) * 4,
282 (2 * bgXOffset + (bgMinX - 1)) * 4, (lineHeight * i + lineHeight - 1 + bgMinY) * 4,
283 G_TX_RENDERTILE, bgMaxX * 32 - bgXOffset * 16, 0, 4096, 1024);
284 gSPTextureRectangle(gMainGfxPos++, bgXOffset * 2 + bgMinX * 4, (lineHeight * i + bgMinY) * 4,
285 (bgMaxX + bgMinX - 1) * 4, (lineHeight * i + lineHeight - 1 + bgMinY) * 4,
286 G_TX_RENDERTILE, 0, 0, 4096, 1024);
287 }
288 if (extraHeight != 0) {
289 waveOffset = sin_rad(gBackroundWavePhase + i * (TAU / 15)) * 3.0f;
290 bgXOffset = 2.0f * (gGameStatusPtr->backgroundXOffset + waveOffset);
291 texOffsetY = gBackroundTextureYOffset + lineHeight * i;
292 if (texOffsetY > gGameStatusPtr->backgroundMaxY) {
293 texOffsetY -= gGameStatusPtr->backgroundMaxY;
294 }
295 gDPLoadTextureTile(gMainGfxPos++, gGameStatusPtr->backgroundRaster + bgMaxX * texOffsetY,
296 G_IM_FMT_CI, G_IM_SIZ_8b, bgMaxX, extraHeight,
297 0, 0, 295, extraHeight - 1, 0,
298 G_TX_WRAP, G_TX_WRAP, G_TX_NOMASK, G_TX_NOMASK, G_TX_NOLOD, G_TX_NOLOD);
299 gSPTextureRectangle(gMainGfxPos++, bgMinX * 4, (lineHeight * i + bgMinY) * 4,
300 (2 * bgXOffset + (bgMinX - 1)) * 4, (bgMaxY - 1 + bgMinY) * 4,
301 G_TX_RENDERTILE, bgMaxX * 32 - bgXOffset * 16, 0, 4096, 1024);
302 gSPTextureRectangle(gMainGfxPos++, bgXOffset * 2 + bgMinX * 4, (lineHeight * i + bgMinY) * 4,
303 (bgMaxX + bgMinX - 1) * 4, (bgMaxY - 1 + bgMinY) * 4,
304 G_TX_RENDERTILE, 0, 0, 4096, 1024);
305 }
306 }
307}
s16 gBackroundTextureYOffset
Definition background.c:8
s8 gBackroundWaveEnabled
Definition background.c:7
u16 blend_background_channel(u16 arg0, s32 arg1, s32 alpha)
Definition background.c:58
BSS PAL_BIN gBackgroundPalette[256]
Definition background.c:11
BSS f32 gBackroundLastScrollValue
Definition background.c:12
f32 gBackroundWavePhase
Definition background.c:9
u16 * backgroundPalette
#define sin_deg
#define cos_deg
#define mdl_get_shroud_tint_params
@ BACKGROUND_FLAG_FOG
Definition enums.h:6285
@ ENV_TINT_SHROUD
Definition enums.h:4386
@ ENV_TINT_DEPTH
Definition enums.h:4388
@ ENV_TINT_REMAP
Definition enums.h:4392
@ ENV_TINT_NONE
Definition enums.h:4384
s32 is_world_fog_enabled(void)
Definition model.c:3795
void get_world_fog_color(s32 *r, s32 *g, s32 *b, s32 *a)
Definition model.c:3804
f32 sin_rad(f32 x)
Definition 43F0.c:712
void mdl_get_remap_tint_params(u8 *primR, u8 *primG, u8 *primB, u8 *envR, u8 *envG, u8 *envB)
Definition model.c:3953
#define UNPACK_PAL_B(color)
Definition macros.h:273
#define UNPACK_PAL_R(color)
Definition macros.h:271
#define TAU
Definition macros.h:132
#define UNPACK_PAL_G(color)
Definition macros.h:272
Vec3f lookAt_obj
u8 * gBackgroundTintModePtr
Definition model.c:105

Referenced by gfx_draw_background().

◆ appendGfx_enemy_actor()

void appendGfx_enemy_actor ( void * data)

Definition at line 1375 of file actor_rendering.c.

1375 {
1376 appendGfx_npc_actor(FALSE, (s32) data);
1377}
void appendGfx_npc_actor(s32 isPartner, s32 actorIndex)

Referenced by btl_render_actors().

◆ appendGfx_enemy_actor_blur()

void appendGfx_enemy_actor_blur ( void * data)

Definition at line 677 of file actor_rendering.c.

677 {
678 Actor* actor = data;
679
680 appendGfx_nonplayer_actor_blur(FALSE, actor);
681}
void appendGfx_nonplayer_actor_blur(b32 isPartner, Actor *actor)

Referenced by btl_render_actors().

◆ appendGfx_enemy_actor_reflection()

void appendGfx_enemy_actor_reflection ( void * data)

Definition at line 1383 of file actor_rendering.c.

1383 {
1384 Actor* actor = data;
1385
1387}
void appendGfx_npc_actor_reflection(s32, Actor *)

Referenced by btl_render_actors().

◆ appendGfx_partner_actor()

void appendGfx_partner_actor ( void * data)

Definition at line 1379 of file actor_rendering.c.

1379 {
1380 appendGfx_npc_actor(TRUE, (s32) data);
1381}

Referenced by btl_render_actors().

◆ appendGfx_partner_actor_blur()

void appendGfx_partner_actor_blur ( void * data)

Definition at line 687 of file actor_rendering.c.

687 {
688 Actor* actor = data;
689
691}

Referenced by btl_render_actors().

◆ appendGfx_partner_actor_reflection()

void appendGfx_partner_actor_reflection ( void * data)

Definition at line 1389 of file actor_rendering.c.

Referenced by btl_render_actors().

◆ appendGfx_player_actor()

void appendGfx_player_actor ( void * arg0)

Definition at line 1439 of file actor_rendering.c.

1439 {
1440 BattleStatus* battleStatus = &gBattleStatus;
1441 PlayerData* playerData = &gPlayerData;
1442 Matrix4f mtxRotX, mtxRotY, mtxRotZ, mtxRotation;
1443 Matrix4f mtxScale;
1444 Matrix4f mtxPivotOn, mtxPivotOff, mtxTranslate;
1445 Matrix4f mtxTemp, mtxTransform;
1446
1447 Actor* partner;
1448 Actor* player;
1449 ActorPart* playerParts;
1450 EffectInstance* effect;
1451 f32 playerPosX, playerPosY, playerPosZ, playerYaw;
1452 s32 animChanged, palChanged, decorChanged, cond4;
1453 u32 lastAnim;
1454
1455 player = battleStatus->playerActor;
1456 partner = battleStatus->partnerActor;
1457 playerParts = player->partsTable;
1458
1459 playerPosX = player->curPos.x + player->headOffset.x;
1460 playerPosY = player->curPos.y + player->headOffset.y + player->verticalRenderOffset;
1461 playerPosZ = player->curPos.z + player->headOffset.z;
1462
1463 playerYaw = playerParts->yaw = player->yaw;
1464
1465 player->disableEffect->data.disableX->pos.x = playerPosX +
1466 (player->actorBlueprint->statusIconOffset.x + player->statusIconOffset.x) * player->scalingFactor;
1467 player->disableEffect->data.disableX->pos.y = playerPosY +
1468 (player->actorBlueprint->statusIconOffset.y + player->statusIconOffset.y) * player->scalingFactor;
1469 player->disableEffect->data.disableX->pos.z = playerPosZ;
1470
1472 if (player->disableDismissTimer != 0) {
1473 player->disableDismissTimer--;
1474 player->disableEffect->data.disableX->pos.y = NPC_DISPOSE_POS_Y;
1475 } else {
1476 player->disableEffect->data.disableX->scale = player->scalingFactor * 0.75;
1477 }
1478 } else {
1479 player->disableEffect->data.disableX->pos.y = NPC_DISPOSE_POS_Y;
1480 player->disableDismissTimer = 10;
1481 }
1482
1483 if (battleStatus->waterBlockTurnsLeft != 0) {
1486 {
1487 effect = battleStatus->waterBlockEffect;
1488 effect->data.waterBlock->pos.x = playerPosX;
1489 effect->data.waterBlock->pos.y = playerPosY;
1490 effect->data.waterBlock->pos.z = playerPosZ;
1491 } else {
1492 effect = battleStatus->waterBlockEffect;
1493 effect->data.waterBlock->pos.x = playerPosX;
1494 effect->data.waterBlock->pos.y = NPC_DISPOSE_POS_Y;
1495 effect->data.waterBlock->pos.z = playerPosZ;
1496 }
1497 }
1498 if (battleStatus->cloudNineTurnsLeft != 0) {
1501 {
1502 effect = battleStatus->cloudNineEffect;
1503 effect->data.endingDecals->pos.x = playerPosX;
1504 effect->data.endingDecals->pos.y = playerPosY;
1505 effect->data.endingDecals->pos.z = playerPosZ;
1506 effect->data.endingDecals->scale = player->scalingFactor;
1507 } else {
1508 effect = battleStatus->cloudNineEffect;
1509 effect->data.endingDecals->pos.x = playerPosX;
1510 effect->data.endingDecals->pos.y = NPC_DISPOSE_POS_Y;
1511 effect->data.endingDecals->pos.z = playerPosZ;
1512 }
1513 }
1514 if (player->debuff == STATUS_KEY_FROZEN) {
1515 effect = player->icePillarEffect;
1516 if (player->icePillarEffect != NULL) {
1519 {
1520 effect->data.icePillar->pos.x = playerPosX - 8.0f;
1521 effect->data.icePillar->pos.y = playerPosY;
1522 effect->data.icePillar->pos.z = playerPosZ;
1523 effect->data.icePillar->scale = player->size.y / 24.0;
1524 } else {
1525 effect->data.icePillar->pos.x = NPC_DISPOSE_POS_X;
1526 effect->data.icePillar->pos.y = NPC_DISPOSE_POS_Y;
1527 effect->data.icePillar->pos.z = NPC_DISPOSE_POS_Z;
1528 }
1529 } else {
1530 effect->data.icePillar->pos.x = NPC_DISPOSE_POS_X;
1531 effect->data.icePillar->pos.y = NPC_DISPOSE_POS_Y;
1532 effect->data.icePillar->pos.z = NPC_DISPOSE_POS_Z;
1533 }
1534 } else {
1535 effect = player->icePillarEffect;
1536 if (effect != NULL) {
1537 effect->flags |= FX_INSTANCE_FLAG_DISMISS;
1538 player->icePillarEffect = NULL;
1539 }
1540 }
1541
1544 && (player->flags & ACTOR_FLAG_SHOW_STATUS_ICONS)
1545 ) {
1546 battleStatus->buffEffect->data.partnerBuff->visible = TRUE;
1547 } else {
1548 battleStatus->buffEffect->data.partnerBuff->visible = FALSE;
1549 }
1550
1551 if (player->debuff == STATUS_KEY_SHRINK) {
1552 player->scalingFactor += (0.4 - player->scalingFactor) / 6.0;
1553 } else {
1554 player->scalingFactor += (1.0 - player->scalingFactor) / 6.0;
1555 }
1556
1557 if (player->flags & ACTOR_FLAG_SHOW_STATUS_ICONS) {
1558 if (battleStatus->hammerCharge > 0) {
1559 create_status_icon_boost_hammer(player->hudElementDataIndex);
1560 remove_status_icon_boost_jump(player->hudElementDataIndex);
1561 } else {
1562 remove_status_icon_boost_hammer(player->hudElementDataIndex);
1563 }
1564 if (battleStatus->jumpCharge > 0) {
1565 create_status_icon_boost_jump(player->hudElementDataIndex);
1566 remove_status_icon_boost_hammer(player->hudElementDataIndex);
1567 } else {
1568 remove_status_icon_boost_jump(player->hudElementDataIndex);
1569 }
1570 } else {
1571 enable_status_icon_boost_jump(player->hudElementDataIndex);
1572 enable_status_icon_boost_hammer(player->hudElementDataIndex);
1573 }
1574
1576 if (playerData->curHP <= PERIL_THRESHOLD) {
1577 create_status_icon_peril(player->hudElementDataIndex);
1578 remove_status_icon_danger(player->hudElementDataIndex);
1579 } else if (playerData->curHP <= DANGER_THRESHOLD) {
1580 remove_status_icon_peril(player->hudElementDataIndex);
1581 create_status_icon_danger(player->hudElementDataIndex);
1582 } else {
1583 remove_status_icon_peril(player->hudElementDataIndex);
1584 remove_status_icon_danger(player->hudElementDataIndex);
1585 }
1586 } else {
1587 remove_status_icon_peril(player->hudElementDataIndex);
1588 remove_status_icon_danger(player->hudElementDataIndex);
1589 }
1590
1591 if (player->transparentStatus == STATUS_KEY_TRANSPARENT) {
1592 playerParts->flags |= ACTOR_PART_FLAG_TRANSPARENT;
1593 } else {
1594 playerParts->flags &= ~ACTOR_PART_FLAG_TRANSPARENT;
1595 }
1596
1597 animChanged = FALSE;
1598 palChanged = FALSE;
1599 decorChanged = FALSE;
1600 cond4 = FALSE;
1601 lastAnim = playerParts->curAnimation;
1602
1605 && (partner != NULL))
1606 || (battleStatus->outtaSightActive > 0))
1607 && !(player->flags & ACTOR_FLAG_NO_INACTIVE_ANIM)
1608 && !((partner != NULL) && (partner->flags & ACTOR_FLAG_NO_ATTACK))
1609 ) {
1611 if ((player->debuff != STATUS_KEY_FEAR)
1612 && (player->debuff != STATUS_KEY_PARALYZE)
1613 && (player->debuff != STATUS_KEY_FROZEN)
1614 && (player->debuff != STATUS_KEY_STOP)
1615 ) {
1616 if ((player->transparentStatus != STATUS_KEY_TRANSPARENT) &&
1617 (player->stoneStatus != STATUS_KEY_STONE) &&
1618 ((battleStatus->outtaSightActive > 0) || (gBattleStatus.flags2 & BS_FLAGS2_PLAYER_TURN_USED)))
1619 {
1621 playerParts->curAnimation = get_player_anim_for_status(STATUS_KEY_INACTIVE_BERSERK);
1622 } else if (player->debuff == STATUS_KEY_SLEEP) {
1623 playerParts->curAnimation = get_player_anim_for_status(STATUS_KEY_INACTIVE_SLEEP);
1624 } else if (player->debuff == STATUS_KEY_DIZZY) {
1625 playerParts->curAnimation = get_player_anim_for_status(STATUS_KEY_INACTIVE_DIZZY);
1626 } else {
1627 playerParts->curAnimation = get_player_anim_for_status(STATUS_KEY_INACTIVE);
1628 }
1629 spr_update_player_sprite(PLAYER_SPRITE_MAIN, playerParts->curAnimation, playerParts->animationRate);
1630 animChanged = TRUE;
1631 }
1632 }
1633
1634 if (player->debuff != STATUS_KEY_POISON) {
1636 } else {
1638 }
1639 palChanged = TRUE;
1640
1642 decorChanged = TRUE;
1643 }
1644 }
1645
1646 if (player->stoneStatus == STATUS_KEY_STONE) {
1647 playerParts->curAnimation = get_player_anim_for_status(STATUS_KEY_STONE);
1648 spr_update_player_sprite(PLAYER_SPRITE_MAIN, playerParts->curAnimation, playerParts->animationRate);
1649 animChanged = TRUE;
1650
1651 if (!palChanged) {
1653 }
1655 palChanged = TRUE;
1656 enable_status_debuff(player->hudElementDataIndex);
1657 decorChanged = TRUE;
1658 enable_status_static(player->hudElementDataIndex);
1659 cond4 = TRUE;
1660
1661 enable_status_transparent(player->hudElementDataIndex);
1662 enable_status_chill_out(player->hudElementDataIndex);
1663 }
1664
1665 if ((player->flags & ACTOR_FLAG_USING_IDLE_ANIM) && !animChanged) {
1666 s32 temp = playerParts->curAnimation;
1668 playerParts->curAnimation = get_player_anim_for_status(STATUS_KEY_NORMAL);
1669 }
1670 }
1671
1673 if (!palChanged) {
1675 }
1676 palChanged = TRUE;
1677 }
1678 if (player->debuff == STATUS_KEY_POISON) {
1679 if (!palChanged) {
1681 }
1682 palChanged = TRUE;
1683 }
1684 if (player->debuff == STATUS_KEY_PARALYZE) {
1685 if (!palChanged) {
1687 }
1688 palChanged = TRUE;
1689 }
1690 if (player->staticStatus == STATUS_KEY_STATIC) {
1691 if (!palChanged) {
1693 }
1694 palChanged = TRUE;
1695 }
1696 if (battleStatus->turboChargeTurnsLeft != 0) {
1697 if (!decorChanged) {
1699 }
1700 decorChanged = TRUE;
1701 }
1703 if (!palChanged) {
1705 }
1706 palChanged = TRUE;
1707 }
1708 if (!palChanged) {
1710 }
1711 if (!decorChanged) {
1713 }
1714 if (player->flags & ACTOR_FLAG_USING_IDLE_ANIM) {
1715 if (battleStatus->hustleTurns != 0) {
1716 playerParts->curAnimation = get_player_anim_for_status(STATUS_KEY_HUSTLE);
1717 animChanged = TRUE;
1718 } else if (!animChanged) {
1721 playerParts->curAnimation = get_player_anim_for_status(STATUS_KEY_NORMAL);
1722 }
1723 }
1724
1725 if (player->debuff == STATUS_KEY_FROZEN) {
1726 if (!animChanged) {
1727 playerParts->curAnimation = get_player_anim_for_status(STATUS_KEY_FROZEN);
1728 animChanged = TRUE;
1729 }
1730 } else if (player->debuff != STATUS_KEY_SHRINK) {
1731 if (player->debuff == STATUS_KEY_POISON) {
1732 if (!animChanged) {
1733 playerParts->curAnimation = get_player_anim_for_status(STATUS_KEY_POISON);
1734 animChanged = TRUE;
1735 }
1736 } else if (player->debuff == STATUS_KEY_DIZZY) {
1737 if (!animChanged) {
1738 playerParts->curAnimation = get_player_anim_for_status(STATUS_KEY_DIZZY);
1739 animChanged = TRUE;
1740 }
1741 } else if (player->debuff == STATUS_KEY_SLEEP) {
1742 if (!animChanged) {
1743 playerParts->curAnimation = get_player_anim_for_status(STATUS_KEY_SLEEP);
1744 animChanged = TRUE;
1745 }
1746 } else if (player->debuff == STATUS_KEY_PARALYZE) {
1747 if (!animChanged) {
1748 playerParts->curAnimation = get_player_anim_for_status(STATUS_KEY_PARALYZE);
1749 animChanged = TRUE;
1750 }
1751 } else {
1753 if (!animChanged) {
1754 playerParts->curAnimation = get_player_anim_for_status(STATUS_KEY_BERSERK);
1755 animChanged = TRUE;
1756 }
1757 }
1758 }
1759 }
1761 if (!animChanged) {
1762 playerParts->curAnimation = get_player_anim_for_status(STATUS_KEY_STATIC);
1763 animChanged = TRUE;
1764 }
1765 player->staticStatus = STATUS_KEY_STATIC;
1766 player->staticDuration = 127;
1767 } else if ((player->staticStatus == STATUS_KEY_STATIC) && !animChanged) {
1768 playerParts->curAnimation = get_player_anim_for_status(STATUS_KEY_STATIC);
1769 animChanged = TRUE;
1770 }
1771 if ((player->transparentStatus == STATUS_KEY_TRANSPARENT) || (playerParts->flags & ACTOR_PART_FLAG_TRANSPARENT)) {
1772 if (!animChanged) {
1773 playerParts->curAnimation = get_player_anim_for_status(STATUS_KEY_TRANSPARENT);
1774 animChanged = TRUE;
1775 }
1776 create_status_transparent(player->hudElementDataIndex, STATUS_KEY_TRANSPARENT);
1777 }
1778 if (!animChanged) {
1779 playerParts->curAnimation = get_player_anim_for_status(STATUS_KEY_NORMAL);
1780 }
1781 }
1782
1784 if (!cond4) {
1785 if (player->debuff == STATUS_KEY_POISON) {
1786 create_status_debuff(player->hudElementDataIndex, STATUS_KEY_POISON);
1787 } else if (player->debuff == STATUS_KEY_SLEEP) {
1788 create_status_debuff(player->hudElementDataIndex, STATUS_KEY_SLEEP);
1789 } else if (player->debuff == STATUS_KEY_PARALYZE) {
1790 create_status_debuff(player->hudElementDataIndex, STATUS_KEY_PARALYZE);
1791 } else if (player->debuff == STATUS_KEY_DIZZY) {
1792 create_status_debuff(player->hudElementDataIndex, STATUS_KEY_DIZZY);
1793 } else if (player->debuff == STATUS_KEY_SHRINK) {
1794 create_status_debuff(player->hudElementDataIndex, STATUS_KEY_SHRINK);
1795 } else if (player->debuff == STATUS_KEY_FROZEN) {
1796 create_status_debuff(player->hudElementDataIndex, STATUS_KEY_FROZEN);
1797 }
1798 if (is_ability_active(ABILITY_ZAP_TAP) || (player->staticStatus == STATUS_KEY_STATIC)) {
1799 create_status_static(player->hudElementDataIndex, STATUS_KEY_STATIC);
1800 }
1801 }
1802 if ((player->transparentStatus == STATUS_KEY_TRANSPARENT) || (playerParts->flags & ACTOR_PART_FLAG_TRANSPARENT)) {
1803 create_status_transparent(player->hudElementDataIndex, STATUS_KEY_TRANSPARENT);
1804 }
1805 } else {
1806 enable_status_debuff(player->hudElementDataIndex);
1807 enable_status_static(player->hudElementDataIndex);
1808 enable_status_transparent(player->hudElementDataIndex);
1809 enable_status_chill_out(player->hudElementDataIndex);
1810 }
1811
1812 if (player->debuff != STATUS_KEY_STOP) {
1813 if (!animChanged) {
1814 s32 temp = playerParts->curAnimation;
1816 playerParts->curAnimation = get_player_anim_for_status(STATUS_KEY_NORMAL);
1817 }
1818 }
1819 } else {
1820 playerParts->curAnimation = get_player_anim_for_status(STATUS_KEY_STOP);
1821 create_status_debuff(player->hudElementDataIndex, STATUS_KEY_STOP);
1822 }
1823
1824end:
1825 set_status_icons_properties(player->hudElementDataIndex,
1826 playerPosX, playerPosY, playerPosZ,
1827 player->actorBlueprint->statusIconOffset.x * player->scalingFactor,
1828 player->actorBlueprint->statusIconOffset.y * player->scalingFactor,
1829 player->actorBlueprint->statusTextOffset.x * player->scalingFactor,
1830 player->actorBlueprint->statusTextOffset.y * player->scalingFactor);
1831 set_status_icons_offset(player->hudElementDataIndex,
1832 player->size.y * player->scalingFactor,
1833 player->size.x * player->scalingFactor);
1834
1835 playerPosX += playerParts->palAnimPosOffset[0];
1836 playerPosY += playerParts->palAnimPosOffset[1];
1837
1838 playerParts->curPos.x = playerPosX;
1839 playerParts->curPos.y = playerPosY;
1840 playerParts->curPos.z = playerPosZ;
1841 guTranslateF(mtxTranslate, playerPosX, playerPosY, playerPosZ);
1842
1843 guTranslateF(mtxPivotOn,
1844 -player->rotPivotOffset.x * player->scalingFactor,
1845 -player->rotPivotOffset.y * player->scalingFactor,
1846 -player->rotPivotOffset.z * player->scalingFactor);
1847 guTranslateF(mtxPivotOff,
1848 player->rotPivotOffset.x * player->scalingFactor,
1849 player->rotPivotOffset.y * player->scalingFactor,
1850 player->rotPivotOffset.z * player->scalingFactor);
1851
1852 guRotateF(mtxRotX, player->rot.x, 1.0f, 0.0f, 0.0f);
1853 guRotateF(mtxRotY, player->rot.y, 0.0f, 1.0f, 0.0f);
1854 guRotateF(mtxRotZ, player->rot.z, 0.0f, 0.0f, 1.0f);
1855 guMtxCatF(mtxRotY, mtxRotX, mtxTemp);
1856 guMtxCatF(mtxTemp, mtxRotZ, mtxRotation);
1857
1858 guScaleF(mtxScale,
1859 player->scale.x * SPRITE_WORLD_SCALE_D * player->scalingFactor,
1860 player->scale.y * SPRITE_WORLD_SCALE_D * player->scalingFactor * playerParts->verticalStretch,
1861 player->scale.z * SPRITE_WORLD_SCALE_D);
1862
1863 guMtxCatF(mtxScale, mtxPivotOn, mtxTemp);
1864 guMtxCatF(mtxTemp, mtxRotation, mtxTransform);
1865 guMtxCatF(mtxTransform, mtxPivotOff, mtxTemp);
1866 guMtxCatF(mtxTemp, mtxTranslate, mtxTransform);
1867
1868 if (lastAnim != playerParts->curAnimation) {
1869 spr_update_player_sprite(PLAYER_SPRITE_MAIN, playerParts->curAnimation, playerParts->animationRate);
1870 }
1871 update_part_glow(FALSE, playerParts, clamp_angle(playerYaw + 180.0f), FALSE);
1872 update_part_flash(FALSE, playerParts, clamp_angle(playerYaw + 180.0f), FALSE);
1873 render_with_adjusted_palettes(SPRITE_MODE_PLAYER, playerParts, clamp_angle(playerYaw + 180.0f), mtxTransform, 0);
1874 _add_part_decoration(playerParts);
1875}
void set_actor_pal_adjustment(Actor *actor, s32 arg1)
Definition 190B20.c:2607
void enable_status_transparent(s16)
void enable_status_icon_boost_hammer(s32 iconID)
s32 update_part_glow(b32 isNpcSprite, ActorPart *part, s32 yaw, b32 isReflection)
void _add_part_decoration(ActorPart *actorPart)
s32 render_with_adjusted_palettes(b32 isNpcSprite, ActorPart *part, s32 yaw, Matrix4f mtx, b32 skipAnimation)
void enable_status_chill_out(s32 iconID)
void enable_status_debuff(s16)
void enable_status_icon_boost_jump(s32 iconID)
void create_status_icon_boost_jump(s32 iconID)
void enable_status_static(s32 iconID)
s32 update_part_flash(b32 isNpcSprite, ActorPart *part, s32 yaw, b32 isReflection)
void set_status_icons_properties(s32 iconID, f32 x, f32 y, f32 z, s32 arg, s32 arg2, s32 radius, s32 offsetY)
void create_status_icon_boost_hammer(s32 iconID)
s32 get_player_anim_for_status(s32 animID)
Definition 190B20.c:1965
void set_status_icons_offset(s32 iconID, s32 offsetY, s32 arg2)
void create_status_icon_peril(s32 iconID)
void create_status_icon_danger(s32 iconID)
Vec2b statusIconOffset
struct EffectInstance * disableEffect
struct ActorBlueprint * actorBlueprint
s8 verticalRenderOffset
Vec3s headOffset
f32 scalingFactor
struct ActorPart * partsTable
Vec3f curPos
#define guRotateF
#define guTranslateF
#define guMtxCatF
#define guScaleF
struct DisableXFXData * disableX
Definition effects.h:2529
EffectInstanceDataPtr data
Definition effects.h:2605
@ FX_INSTANCE_FLAG_DISMISS
Definition enums.h:3517
@ GLOW_PAL_OFF
Definition enums.h:2258
@ GLOW_PAL_ON
Definition enums.h:2259
@ BS_FLAGS1_TATTLE_OPEN
Definition enums.h:3566
@ BS_FLAGS1_SHOW_PLAYER_DECORATIONS
Definition enums.h:3567
@ ACTOR_PAL_ADJUST_POISON
Definition enums.h:2245
@ ACTOR_PAL_ADJUST_PARALYZE
Definition enums.h:2246
@ ACTOR_PAL_ADJUST_PLAYER_POISON
Definition enums.h:2251
@ ACTOR_PAL_ADJUST_STATIC
Definition enums.h:2243
@ ACTOR_PAL_ADJUST_PLAYER_DEBUFF
Definition enums.h:2250
@ ACTOR_PAL_ADJUST_BERSERK
Definition enums.h:2247
@ ACTOR_PAL_ADJUST_NONE
Definition enums.h:2241
@ BS_FLAGS2_PLAYER_TURN_USED
Definition enums.h:3604
@ BS_FLAGS2_NO_PLAYER_PAL_ADJUST
Definition enums.h:3616
@ BS_FLAGS2_OVERRIDE_INACTIVE_PLAYER
Definition enums.h:3606
@ BS_FLAGS2_PEACH_BATTLE
Definition enums.h:3609
@ BS_FLAGS2_HIDE_BUFF_COUNTERS
Definition enums.h:3615
@ STATUS_KEY_INACTIVE_DIZZY
Definition enums.h:2220
@ STATUS_KEY_PARALYZE
Definition enums.h:2201
@ STATUS_KEY_INACTIVE_SLEEP
Definition enums.h:2217
@ STATUS_KEY_FROZEN
Definition enums.h:2203
@ STATUS_KEY_TRANSPARENT
Definition enums.h:2210
@ STATUS_KEY_INACTIVE_BERSERK
Definition enums.h:2215
@ STATUS_KEY_STATIC
Definition enums.h:2207
@ STATUS_KEY_FEAR
Definition enums.h:2199
@ STATUS_KEY_SLEEP
Definition enums.h:2202
@ STATUS_KEY_STONE
Definition enums.h:2208
@ STATUS_KEY_STOP
Definition enums.h:2204
@ STATUS_KEY_INACTIVE
Definition enums.h:2214
@ STATUS_KEY_HUSTLE
Definition enums.h:2221
@ STATUS_KEY_SHRINK
Definition enums.h:2206
@ STATUS_KEY_DIZZY
Definition enums.h:2200
@ STATUS_KEY_POISON
Definition enums.h:2205
@ STATUS_KEY_BERSERK
Definition enums.h:2212
@ STATUS_KEY_NORMAL
Definition enums.h:2197
@ ABILITY_BERSERKER
Definition enums.h:457
@ ABILITY_ZAP_TAP
Definition enums.h:455
@ ACTOR_FLAG_NO_INACTIVE_ANIM
Definition enums.h:3345
@ ACTOR_FLAG_SHOW_STATUS_ICONS
Definition enums.h:3343
@ ACTOR_FLAG_NO_ATTACK
Skip attack turn.
Definition enums.h:3339
@ ACTOR_FLAG_USING_IDLE_ANIM
Definition enums.h:3342
@ ACTOR_PART_FLAG_TRANSPARENT
Definition enums.h:3357
void create_status_debuff(s32, s32)
void create_status_transparent(s32, s32)
s32 is_ability_active(s32 arg0)
Definition inventory.c:1736
s32 player_team_is_ability_active(Actor *actor, s32 ability)
Definition 190B20.c:2765
void remove_status_icon_boost_hammer(s32)
void create_status_static(s32, s32)
void remove_status_icon_boost_jump(s32)
void remove_status_icon_peril(s32)
void set_actor_glow_pal(Actor *actor, s32 arg1)
Definition 190B20.c:2654
void remove_status_icon_danger(s32)
#define NPC_DISPOSE_POS_Z
Definition macros.h:165
#define SPRITE_WORLD_SCALE_D
Definition macros.h:144
#define NPC_DISPOSE_POS_X
Definition macros.h:163
#define NPC_DISPOSE_POS_Y
Definition macros.h:164
s32 spr_update_player_sprite(s32 spriteInstanceID, s32 animID, f32 timeScale)
Definition sprite.c:823
@ SPRITE_MODE_PLAYER
Definition sprite.h:33
Vec2b statusIconOffset
Definition battle.h:150
#define PERIL_THRESHOLD
Definition battle.h:267
#define DANGER_THRESHOLD
Definition battle.h:266
struct Actor * playerActor

Referenced by btl_render_actors().

◆ appendGfx_player_actor_blur()

void appendGfx_player_actor_blur ( Actor * actor)

Definition at line 380 of file actor_rendering.c.

380 {
381 Matrix4f mtxRotX, mtxRotY, mtxRotZ, mtxRotation;
382 Matrix4f mtxScale;
383 Matrix4f mtxPivotOn, mtxPivotOff, mtxTranslate;
384 Matrix4f mtxTransform, mtxTemp;
385 s32 strideIdx;
386 s32 drawIdx;
387 s32 yaw;
388 ActorPart* partTable;
389 DecorationTable* decorations;
390 f32 rotX, rotY, rotZ;
391 s32 prevOpacity;
392 s32 opacity;
393 s32 pivotOffsetX;
394 s32 pivotOffsetY;
395 s32 bufPos;
396 s32 blurOpacityBase;
397 s32 opacityLossIncrement;
398 f32 x, y, z;
399
400 partTable = actor->partsTable;
401 decorations = partTable->decorationTable;
402 if (decorations->blurDisableDelay != 0) {
403 decorations->blurDisableDelay--;
404 if (decorations->blurDisableDelay == 0) {
405 actor->flags &= ~ACTOR_FLAG_BLUR_ENABLED;
406 return;
407 }
408 }
409
410 if (!(partTable->flags & ACTOR_PART_FLAG_INVISIBLE) && partTable->idleAnimations != NULL) {
411 bufPos = decorations->blurBufferPos;
412 strideIdx = 0;
413 drawIdx = 0;
414
415 while (TRUE) {
416 bufPos--;
417 strideIdx++;
418 if (bufPos < 0) {
419 bufPos = ARRAY_COUNT(decorations->posX) - 1;
420 }
421 if (bufPos == decorations->blurBufferPos) {
422 break;
423 }
424
425 // only draw every third blur frame
426 if (strideIdx < 3) {
427 continue;
428 }
429
430 strideIdx = 0;
431 drawIdx++;
432
433 if (decorations->blurDrawCount < drawIdx) {
434 break;
435 }
436
437 opacity = partTable->opacity;
438
439 x = decorations->posX[bufPos];
440 y = decorations->posY[bufPos];
441 z = decorations->posZ[bufPos];
442
443 yaw = decorations->yaw[bufPos];
444
445 pivotOffsetX = decorations->rotPivotOffsetX[bufPos];
446 pivotOffsetY = decorations->rotPivotOffsetY[bufPos];
447
448 rotX = decorations->rotX[bufPos] * 2;
449 rotY = decorations->rotY[bufPos] * 2;
450 rotZ = decorations->rotZ[bufPos] * 2;
451
452 blurOpacityBase = 120;
453 opacityLossIncrement = 20;
454 if (opacity < 50) {
455 blurOpacityBase = 50;
456 opacityLossIncrement = 8;
457 } else if (opacity < 100) {
458 blurOpacityBase = 70;
459 opacityLossIncrement = 10;
460 } else if (opacity < 150) {
461 blurOpacityBase = 100;
462 opacityLossIncrement = 15;
463 }
464
465 guTranslateF(mtxTranslate, x, y, z);
466 guTranslateF(mtxPivotOn, -pivotOffsetX, -pivotOffsetY, 0.0f);
467 guTranslateF(mtxPivotOff, pivotOffsetX, pivotOffsetY, 0.0f);
468 guRotateF(mtxRotX, rotX, 1.0f, 0.0f, 0.0f);
469 guRotateF(mtxRotY, rotY, 0.0f, 1.0f, 0.0f);
470 guRotateF(mtxRotZ, rotZ, 0.0f, 0.0f, 1.0f);
471 guMtxCatF(mtxRotX, mtxRotY, mtxTransform);
472 guMtxCatF(mtxTransform, mtxRotZ, mtxRotation);
473 guScaleF(mtxScale, actor->scale.x * SPRITE_WORLD_SCALE_D * actor->scalingFactor,
474 actor->scale.y * SPRITE_WORLD_SCALE_D * actor->scalingFactor * partTable->verticalStretch,
475 actor->scale.z * SPRITE_WORLD_SCALE_D);
476 guMtxCatF(mtxScale, mtxPivotOn, mtxTemp);
477 guMtxCatF(mtxTemp, mtxRotation, mtxTransform);
478 guMtxCatF(mtxTransform, mtxPivotOff, mtxTemp);
479 guMtxCatF(mtxTemp, mtxTranslate, mtxTransform);
480 prevOpacity = partTable->opacity;
481 partTable->opacity = blurOpacityBase - (drawIdx * opacityLossIncrement);
482 render_with_adjusted_palettes(SPRITE_MODE_PLAYER, partTable, clamp_angle(yaw + 180), mtxTransform, 1);
483 partTable->opacity = prevOpacity;
484 }
485 }
486}
u32 * idleAnimations
struct DecorationTable * decorationTable
Vec3f scale
@ ACTOR_PART_FLAG_INVISIBLE
Definition enums.h:3350

Referenced by btl_render_actors().

◆ appendGfx_player_actor_reflection()

void appendGfx_player_actor_reflection ( void * arg0)

Definition at line 1877 of file actor_rendering.c.

1877 {
1878 Matrix4f mtxRotX, mtxRotY, mtxRotZ, mtxRotation, mtxScale;
1879 Matrix4f mtxPivotOn, mtxPivotOff, mtxTranslate;
1880 Matrix4f mtxTemp, mtxTransform, mtxMirror;
1882 ActorPart* part = &player->partsTable[0];
1883 f32 playerYaw = player->yaw;
1884 f32 dx, dy, dz;
1885
1886 dx = player->curPos.x + player->headOffset.x;
1887 dx += part->palAnimPosOffset[0];
1888 dy = player->curPos.y + player->headOffset.y;
1889 dy += part->palAnimPosOffset[1];
1890 dz = player->curPos.z + player->headOffset.z - 5.0f;
1891 part->yaw = playerYaw;
1892
1893 guTranslateF(mtxTranslate, dx, dy, dz - 1.0f);
1894
1895 guTranslateF(mtxPivotOn,
1896 -player->rotPivotOffset.x * player->scalingFactor,
1897 -player->rotPivotOffset.y * player->scalingFactor,
1898 -player->rotPivotOffset.z * player->scalingFactor);
1899 guTranslateF(mtxPivotOff,
1900 player->rotPivotOffset.x * player->scalingFactor,
1901 player->rotPivotOffset.y * player->scalingFactor,
1902 player->rotPivotOffset.z * player->scalingFactor);
1903
1904 guRotateF(mtxRotX, player->rot.x, 1.0f, 0.0f, 0.0f);
1905 guRotateF(mtxRotY, player->rot.y, 0.0f, 1.0f, 0.0f);
1906 guRotateF(mtxRotZ, player->rot.z, 0.0f, 0.0f, 1.0f);
1907 guMtxCatF(mtxRotY, mtxRotX, mtxTemp);
1908 guMtxCatF(mtxTemp, mtxRotZ, mtxRotation);
1909 guScaleF(mtxScale,
1910 player->scale.x * SPRITE_WORLD_SCALE_D * player->scalingFactor,
1911 player->scale.y * SPRITE_WORLD_SCALE_D * player->scalingFactor * part->verticalStretch,
1912 player->scale.z * SPRITE_WORLD_SCALE_D);
1913 mtx_mirror_y(mtxMirror);
1914
1915 guMtxCatF(mtxScale, mtxPivotOn, mtxTemp);
1916 guMtxCatF(mtxTemp, mtxRotation, mtxTemp);
1917 guMtxCatF(mtxTemp, mtxPivotOff, mtxTemp);
1918 guMtxCatF(mtxTemp, mtxTranslate, mtxTransform);
1919 guMtxCatF(mtxTransform, mtxMirror, mtxTransform);
1920
1921 update_part_glow(FALSE, part, clamp_angle(playerYaw + 180.0f), TRUE);
1922 update_part_flash(FALSE, part, clamp_angle(playerYaw + 180.0f), TRUE);
1923 render_with_adjusted_palettes(SPRITE_MODE_PLAYER, part, clamp_angle(playerYaw + 180.0f), mtxTransform, TRUE);
1924}
void mtx_mirror_y(Matrix4f mtx)
s16 palAnimPosOffset[2]
Vec3s rotPivotOffset

Referenced by btl_render_actors().

◆ force_disable_actor_blur()

void force_disable_actor_blur ( Actor * actor)

Definition at line 254 of file actor_rendering.c.

254 {
255 ActorPart* actorPart = actor->partsTable;
256
257 if (actorPart->idleAnimations != NULL && !(actorPart->flags & ACTOR_PART_FLAG_NO_DECORATIONS)) {
258 DecorationTable* decorations = actorPart->decorationTable;
259
260 decorations->blurEnableCount = 0;
261 decorations->blurDisableDelay = 20;
262 }
263}
@ ACTOR_PART_FLAG_NO_DECORATIONS
Definition enums.h:3351

Referenced by force_disable_partner_blur().

◆ player_handle_floor_collider_type()

void player_handle_floor_collider_type ( s32 colliderID)

Definition at line 326 of file 7BB60.c.

326 {
327 PlayerStatus* playerStatus = &gPlayerStatus;
328 PartnerStatus* partnerStatus = &gPartnerStatus;
329
330 if (colliderID > NO_COLLIDER) {
331 s32 surfaceType = get_collider_flags(colliderID) & COLLIDER_FLAGS_SURFACE_TYPE_MASK;
332 switch (surfaceType) {
337 break;
339 if ((*(s32*)(&partnerStatus->partnerActionState) & 0xFF0000FF) != 0x01000009) {
340 if (playerStatus->blinkTimer == 0) {
341 if (playerStatus->actionState != ACTION_STATE_HIT_LAVA) {
342 playerStatus->hazardType = HAZARD_TYPE_LAVA;
344 }
345 } else {
347 }
348 }
349 break;
351 if ((*(s32*)(&partnerStatus->partnerActionState) & 0xFF0000FF) != 0x01000009) {
352 if (playerStatus->blinkTimer == 0) {
353 if (playerStatus->actionState != ACTION_STATE_HIT_FIRE) {
354 playerStatus->hazardType = HAZARD_TYPE_SPIKES;
356 }
357 break;
358 }
360 }
361 break;
362 default:
364 break;
365 }
366 }
367}
void phys_player_land(void)
Definition 7BB60.c:369
@ SURFACE_TYPE_WATER
Definition enums.h:4670
@ SURFACE_TYPE_SLIDE
Definition enums.h:4674
@ SURFACE_TYPE_LAVA
Definition enums.h:4672
@ SURFACE_TYPE_DOCK_WALL
Definition enums.h:4673
@ SURFACE_TYPE_SPIKES
Definition enums.h:4671
@ COLLIDER_FLAGS_SURFACE_TYPE_MASK
Definition enums.h:4692
@ HAZARD_TYPE_LAVA
Definition enums.h:3500
@ HAZARD_TYPE_SPIKES
Definition enums.h:3501
@ ACTION_STATE_HIT_LAVA
Definition enums.h:2451
@ ACTION_STATE_LAND
Definition enums.h:2437
@ ACTION_STATE_KNOCKBACK
Definition enums.h:2450
@ ACTION_STATE_HIT_FIRE
Causes Mario to fly up and take damage. Used for fire bars.
Definition enums.h:2449
s32 get_collider_flags(s32 colliderID)
Definition collision.c:481
void set_action_state(s32 actionState)
Definition 7E9D0.c:209
PartnerStatus gPartnerStatus
Definition partners.c:42

Referenced by handle_jumping_land_on_switch(), phys_update_falling(), and player_jump().

◆ player_fall_distance()

f32 player_fall_distance ( void )

Definition at line 461 of file 7BB60.c.

461 {
462 f32 velocity = integrate_gravity();
463
465 velocity = 0.0f;
466 }
467 return velocity;
468}
f32 integrate_gravity(void)
Definition 7BB60.c:436
b32 check_player_action_debug(void)
Definition 77480.c:1016

Referenced by action_update_hit_fire(), action_update_hit_lava(), action_update_knockback(), action_update_sliding(), action_update_spin_jump(), handle_jumping_land_on_switch(), and phys_update_falling().

◆ func_800E4AD8()

void func_800E4AD8 ( s32 arg0)

Definition at line 978 of file 7BB60.c.

978 {
979 f32 camYaw = gCameras[gCurrentCameraID].curYaw;
980
982}
HitID collision_check_player_intersecting_world(s32 mode, s32 arg1, f32 yaw)
Definition 7BB60.c:755

◆ player_check_collision_below()

f32 player_check_collision_below ( f32 offset,
s32 * colliderID )

Definition at line 470 of file 7BB60.c.

470 {
471 PlayerStatus* playerStatus = &gPlayerStatus;
472 CollisionStatus* collisionStatus = &gCollisionStatus;
473 f32 temp_f4 = playerStatus->colliderHeight * 0.5f;
474 f32 outLength = fabsf(offset) + temp_f4;
475 f32 x = playerStatus->pos.x;
476 f32 y = playerStatus->pos.y + temp_f4;
477 f32 z = playerStatus->pos.z;
478 f32 sp38, sp3C, sp40, sp44;
479 s32 hit = *colliderID = player_raycast_below_cam_relative(&gPlayerStatus, &x, &y, &z, &outLength,
480 &sp38, &sp3C, &sp40, &sp44);
481
482 if (hit <= NO_COLLIDER) {
483 if (offset >= 0.0f && collisionStatus->curCeiling > NO_COLLIDER) {
484 return playerStatus->pos.y;
485 }
486 y = playerStatus->pos.y + offset;
487 } else {
488 collisionStatus->curFloor = hit;
489 collisionStatus->lastTouchedFloor = -1;
490 }
491 return y;
492}
CollisionStatus gCollisionStatus
Definition 7BB60.c:6
HitID player_raycast_below_cam_relative(PlayerStatus *playerStatus, f32 *outX, f32 *outY, f32 *outZ, f32 *outLength, f32 *hitRx, f32 *hitRz, f32 *hitDirX, f32 *hitDirZ)
Definition 77480.c:193

Referenced by action_update_hit_fire(), action_update_hit_lava(), action_update_knockback(), action_update_sliding(), action_update_spin_jump(), action_update_step_up(), action_update_tornado_jump(), action_update_use_munchlesia(), action_update_use_spinning_flower(), handle_jumping_land_on_switch(), phys_update_falling(), and player_jump().

◆ can_trigger_loading_zone()

b32 can_trigger_loading_zone ( void )

Definition at line 22 of file 7BB60.c.

22 {
23 PlayerData* playerData = &gPlayerData;
24 s32 actionState = gPlayerStatusPtr->actionState;
25 PartnerStatus* partnerStatus = &gPartnerStatus;
26
27 if (actionState == ACTION_STATE_IDLE ||
28 actionState == ACTION_STATE_WALK ||
29 actionState == ACTION_STATE_RUN ||
30 actionState == ACTION_STATE_USE_TWEESTER ||
31 actionState == ACTION_STATE_SPIN
32 ) {
33 return TRUE;
34 }
35
36 if (actionState == ACTION_STATE_RIDE) {
37 if (playerData->curPartner == PARTNER_LAKILESTER || playerData->curPartner == PARTNER_BOW) {
38 if (partnerStatus->partnerActionState != PARTNER_ACTION_NONE) {
39 return TRUE;
40 } else {
42 return FALSE;
43 }
44 } else {
45 if (partnerStatus->actingPartner == PARTNER_WATT || partnerStatus->actingPartner == PARTNER_SUSHIE) {
46 return partnerStatus->partnerActionState != PARTNER_ACTION_NONE;
47 }
48 if (partnerStatus->actingPartner == PARTNER_PARAKARRY) {
50 return FALSE;
51 }
52 }
53 }
54 return FALSE;
55}
@ PARTNER_ACTION_NONE
Definition enums.h:2932
@ PA_FLAG_INTERRUPT_USE_PARTNER
forces actions with bow, parakarry, watt, and lakilester to end (sushie not tested)
Definition enums.h:3093
@ PARTNER_LAKILESTER
Definition enums.h:2893
@ PARTNER_WATT
Definition enums.h:2891
@ PARTNER_BOW
Definition enums.h:2894
@ PARTNER_SUSHIE
Definition enums.h:2892
@ PARTNER_PARAKARRY
Definition enums.h:2889
@ ACTION_STATE_RIDE
Definition enums.h:2461
@ ACTION_STATE_IDLE
Definition enums.h:2426
@ ACTION_STATE_USE_TWEESTER
Definition enums.h:2459
@ ACTION_STATE_WALK
Definition enums.h:2427
@ ACTION_STATE_SPIN
Definition enums.h:2454
@ ACTION_STATE_RUN
Definition enums.h:2428
PlayerStatus * gPlayerStatusPtr

◆ update_damage_popups()

void update_damage_popups ( void )

Definition at line 2320 of file 190B20.c.

2320 {
2321 s32 i;
2322
2323 for (i = 0; i < ARRAY_COUNT(gDamageCountEffects); i++) {
2324 if (gDamageCountEffects[i] != NULL) {
2325 gDamageCountTimers[i]--;
2326 if (gDamageCountTimers[i] == 0) {
2328 gDamageCountEffects[i] = NULL;
2329 }
2330 }
2331 };
2332}
s32 gDamageCountTimers[]
Definition 190B20.c:22
EffectInstance * gDamageCountEffects[]
Definition 190B20.c:13
struct DamageIndicatorFXData * damageIndicator
Definition effects.h:2494

Referenced by btl_update().

◆ show_action_rating()

void show_action_rating ( s32 rating,
Actor * actor,
f32 x,
f32 y,
f32 z )

Definition at line 2360 of file 190B20.c.

2360 {
2361 BattleStatus* battleStatus = &gBattleStatus;
2362 Actor* player;
2363 s32 new_var; // TODO required to match
2364 s32 type;
2365
2366 actor->attackResultEffect = actor->attackResultEffect; // TODO required to match
2367 player = battleStatus->playerActor;
2368
2369 if (actor->attackResultEffect == NULL) {
2370 type = 0;
2371 switch (rating) {
2372 case ACTION_RATING_NICE:
2373 type = 0;
2374 actor->actionRatingCombo = 1;
2375 break;
2376 case ACTION_RATING_MISS:
2377 type = 4;
2378 actor->actionRatingCombo = 0;
2379 break;
2381 type = 3;
2382 actor->actionRatingCombo = 0;
2383 break;
2385 type = 2;
2386 actor->actionRatingCombo = 2;
2387 break;
2389 type = 0;
2390 actor->actionRatingCombo = 0;
2391 break;
2393 type = player->actionRatingCombo;
2394 player->actionRatingCombo++;
2395 if (player->actionRatingCombo > 2) {
2396 player->actionRatingCombo = 2;
2397 }
2398 break;
2399 }
2400 actor->attackResultEffect = fx_attack_result_text(type, x, y, z - 10.0f, 12.0f, 90);
2401 actor->actionRatingTime = 80;
2402 new_var = 2; // TODO required to match
2403 } else {
2405 type = actor->actionRatingCombo;
2406 new_var = rating; // TODO required to match
2407 switch (new_var) { // TODO required to match
2408 case ACTION_RATING_NICE:
2409 actor->actionRatingCombo++;
2410 if (actor->actionRatingCombo > 2) {
2411 actor->actionRatingCombo = 2;
2412 }
2413 break;
2414 case ACTION_RATING_MISS:
2415 type = 4;
2416 break;
2418 type = 3;
2419 break;
2421 type = 2;
2422 break;
2424 type = 0;
2425 break;
2427 type = player->actionRatingCombo;
2428 player->actionRatingCombo++;
2429 if (player->actionRatingCombo > 2) {
2430 player->actionRatingCombo = 2;
2431 }
2432 break;
2433 }
2434 actor->attackResultEffect = fx_attack_result_text(type, x, y, z - 10.0f, 12.0f, 90);
2435 actor->actionRatingTime = 80;
2436 }
2437}
struct EffectInstance * attackResultEffect
s8 actionRatingCombo
s8 actionRatingTime
struct AttackResultTextFXData * attackResultText
Definition effects.h:2536
@ ACTION_RATING_SUPER
sets nice hits = 2
Definition enums.h:1982
@ ACTION_RATING_NICE_SUPER_COMBO
'Nice' but becomes 'Super' if nice hits > 2
Definition enums.h:1984
@ ACTION_RATING_NICE_NO_COMBO
clears nice hits
Definition enums.h:1983
@ ACTION_RATING_MISS
clears nice hits
Definition enums.h:1980
@ ACTION_RATING_LUCKY
clears nice hits
Definition enums.h:1981
@ ACTION_RATING_NICE
sets nice hits = 1
Definition enums.h:1979

Referenced by calc_enemy_damage_target(), calc_item_damage_enemy(), calc_partner_damage_enemy(), and calc_player_damage_enemy().

◆ render_with_adjusted_palettes()

s32 render_with_adjusted_palettes ( s32 isNpcSprite,
ActorPart * part,
s32 yaw,
Matrix4f mtx,
s32 skipAnimation )

Definition at line 1926 of file actor_rendering.c.

1926 {
1927 s32 opacity;
1928 s32 sprDrawOpts;
1929
1931 opacity = 255;
1932 sprDrawOpts = 0;
1933 if (part->opacity < 255) {
1934 sprDrawOpts = DRAW_SPRITE_OVERRIDE_ALPHA;
1935 opacity = part->opacity;
1936 }
1937 if (part->flags & ACTOR_PART_FLAG_TRANSPARENT) {
1938 sprDrawOpts = DRAW_SPRITE_OVERRIDE_ALPHA;
1939 opacity = opacity * 120 / 255;
1940 }
1941 if (isNpcSprite == SPRITE_MODE_PLAYER) {
1942 if (opacity == 255) {
1943 spr_draw_player_sprite(PLAYER_SPRITE_MAIN, yaw, 0, NULL, mtx);
1944 } else {
1945 spr_draw_player_sprite(PLAYER_SPRITE_MAIN | sprDrawOpts, yaw, opacity, NULL, mtx);
1946 }
1947 } else {
1948 if (opacity == 255) {
1949 spr_draw_npc_sprite(part->spriteInstanceID, yaw, 0, NULL, mtx);
1950 } else {
1951 spr_draw_npc_sprite(part->spriteInstanceID | sprDrawOpts, yaw, opacity, NULL, mtx);
1952 }
1953 }
1954 return 0;
1955 }
1956
1957 switch (part->decorationTable->paletteAdjustment) {
1959 render_without_adjusted_palettes(isNpcSprite, part, yaw, mtx, skipAnimation);
1960 break;
1962 render_with_sleep_palettes(isNpcSprite, part, yaw, mtx, skipAnimation);
1963 break;
1965 render_with_static_palettes(isNpcSprite, part, yaw, mtx, skipAnimation);
1966 break;
1968 render_with_fear_palettes(isNpcSprite, part, yaw, mtx, skipAnimation);
1969 break;
1971 render_with_poison_palettes(isNpcSprite, part, yaw, mtx, skipAnimation);
1972 break;
1974 render_with_paralyze_palettes(isNpcSprite, part, yaw, mtx, skipAnimation);
1975 break;
1977 render_with_berserk_palettes(isNpcSprite, part, yaw, mtx, skipAnimation);
1978 break;
1980 render_with_watt_idle_palettes(isNpcSprite, part, yaw, mtx, skipAnimation);
1981 break;
1983 render_with_watt_attack_palettes(isNpcSprite, part, yaw, mtx, skipAnimation);
1984 break;
1986 render_with_player_debuff_palettes(isNpcSprite, part, yaw, mtx, skipAnimation, FALSE);
1987 break;
1989 render_with_player_debuff_palettes(isNpcSprite, part, yaw, mtx, skipAnimation, TRUE);
1990 break;
1992 render_with_pal_blending(isNpcSprite, part, yaw, FALSE, mtx, skipAnimation);
1993 break;
1995 render_with_pal_blending(isNpcSprite, part, yaw, TRUE, mtx, skipAnimation);
1996 break;
1998 render_with_palset_blending(isNpcSprite, part, yaw, mtx, skipAnimation);
1999 break;
2000 default:
2001 break;
2002 }
2003 return 0;
2004}
void render_with_watt_idle_palettes(b32 arg0, ActorPart *part, s32 yaw, Matrix4f mtx, b32 skipAnimation)
void render_with_player_debuff_palettes(b32 arg0, ActorPart *part, s32 yaw, Matrix4f mtx, b32 skipAnimation, s32 isPoison)
void render_with_fear_palettes(b32 arg0, ActorPart *part, s32 yaw, Matrix4f mtx, b32 skipAnimation)
void render_without_adjusted_palettes(b32 arg0, ActorPart *part, s32 yaw, Matrix4f mtx, b32 skipAnimation)
void render_with_watt_attack_palettes(b32 arg0, ActorPart *part, s32 yaw, Matrix4f mtx, b32 skipAnimation)
void render_with_sleep_palettes(b32 arg0, ActorPart *part, s32 yaw, Matrix4f mtx, b32 skipAnimation)
void render_with_berserk_palettes(b32 arg0, ActorPart *part, s32 yaw, Matrix4f mtx, b32 skipAnimation)
void render_with_pal_blending(b32 arg0, ActorPart *part, s32 yaw, s32 arg3, Matrix4f mtx, s32 skipAnimation)
void render_with_palset_blending(b32 arg0, ActorPart *part, s32 yaw, Matrix4f mtx, b32 skipAnimation)
void render_with_paralyze_palettes(b32 arg0, ActorPart *part, s32 yaw, Matrix4f mtx, b32 skipAnimation)
void render_with_static_palettes(b32 arg0, ActorPart *part, s32 yaw, Matrix4f mtx, b32 skipAnimation)
void render_with_poison_palettes(b32 arg0, ActorPart *part, s32 yaw, Matrix4f mtx, b32 skipAnimation)
@ ACTOR_PAL_ADJUST_FEAR
Definition enums.h:2244
@ ACTOR_PAL_ADJUST_BLEND_PALETTES_VARYING_INTERVALS
Definition enums.h:2253
@ ACTOR_PAL_ADJUST_WATT_IDLE
Definition enums.h:2248
@ ACTOR_PAL_ADJUST_BLEND_PALSETS
Definition enums.h:2254
@ ACTOR_PAL_ADJUST_WATT_ATTACK
Definition enums.h:2249
@ ACTOR_PAL_ADJUST_BLEND_PALETTES_UNIFORM_INTERVALS
Definition enums.h:2252
@ ACTOR_PAL_ADJUST_SLEEP
Definition enums.h:2242
s32 spr_draw_npc_sprite(s32 spriteInstanceID, s32 yaw, s32 arg2, PAL_PTR *paletteList, Matrix4f mtx)
Definition sprite.c:1105
s32 spr_draw_player_sprite(s32 spriteInstanceID, s32 yaw, s32 alphaIn, PAL_PTR *paletteList, Matrix4f mtx)
Definition sprite.c:872
@ DRAW_SPRITE_OVERRIDE_ALPHA
Definition sprite.h:22

Referenced by appendGfx_npc_actor(), appendGfx_npc_actor_reflection(), appendGfx_player_actor(), appendGfx_player_actor_blur(), and appendGfx_player_actor_reflection().

◆ general_heap_create()

HeapNode * general_heap_create ( void )

◆ general_heap_malloc()

void * general_heap_malloc ( s32 size)

Definition at line 10 of file heap.c.

10 {
11 return _heap_malloc(&heap_generalHead, size);
12}

◆ general_heap_free()

◆ integer_log()

s32 integer_log ( s32 number,
u32 base )

Definition at line 302 of file draw_img_util.c.

302 {
303 f32 fNumber = number;
304 s32 ret = 1;
305
306 while (TRUE) {
307 fNumber /= base;
308 if (fNumber <= 1.0) {
309 return ret;
310 }
311
312 ret++;
313 }
314}

Referenced by draw_adjustable_tiled_image(), and imgfx_appendGfx_mesh_strip().

◆ set_battle_stage()

void set_battle_stage ( s32 stageID)

Definition at line 138 of file battle.c.

138 {
139 gCurrentStageID = stageID;
140}
BSS s32 gCurrentStageID
Definition battle.c:17

Referenced by load_demo_battle(), and update_encounters_pre_battle().

◆ load_battle()

void load_battle ( s32 battleID)

Definition at line 130 of file battle.c.

130 {
131 gCurrentBattleID = battleID;
136}
BSS s32 gBattleSubState
Definition battle.c:14
BSS s32 gLastDrawBattleState
Definition battle.c:12
BSS s32 gCurrentBattleID
Definition battle.c:16
BSS s32 gBattleState
Definition battle.c:10
@ BTL_SUBSTATE_INIT
Definition enums.h:3670
@ BATTLE_STATE_0
Definition enums.h:3630
@ GAME_MODE_BATTLE
Definition game_modes.h:15

Referenced by load_demo_battle(), and update_encounters_pre_battle().

◆ entity_Shadow_init()

void entity_Shadow_init ( Shadow * entity)

Definition at line 5 of file Shadow.c.

5 {
6 shadow->scale.x = 0.1f;
7 shadow->scale.y = 0.1f;
8 shadow->scale.z = 0.1f;
9}

◆ entity_SaveBlock_idle()

void entity_SaveBlock_idle ( Entity * entity)

Definition at line 80 of file SaveBlock.c.

80 {
81 SaveBlockData* data;
82
83 data = entity->dataBuf.saveBlock;
84 data->angle = clamp_angle(data->angle + 6);
86}
struct SaveBlockData * saveBlock
s32 entity_base_block_idle(Entity *entity)
Definition Block.c:195

◆ entity_SaveBlock_pause_game()

void entity_SaveBlock_pause_game ( void )

Definition at line 88 of file SaveBlock.c.

88 {
92}
@ TIME_FREEZE_PARTIAL
Definition enums.h:3465
void set_time_freeze_mode(s32)
Time freeze modes: 0: none 1: NPCs move, can't be interacted with 2: NPCs don't move,...
Definition main_loop.c:358

◆ entity_SaveBlock_resume_game()

void entity_SaveBlock_resume_game ( void )

Definition at line 94 of file SaveBlock.c.

94 {
97}
@ TIME_FREEZE_NONE
Definition enums.h:3464
s32 enable_player_input(void)
Definition 77480.c:998

◆ entity_SaveBlock_save_data()

void entity_SaveBlock_save_data ( void )

Definition at line 99 of file SaveBlock.c.

◆ entity_SaveBlock_show_tutorial_message()

void entity_SaveBlock_show_tutorial_message ( Entity * entity)

Definition at line 106 of file SaveBlock.c.

106 {
109 msg_get_printer_for_msg(MSG_Menus_Tutorial_SaveBlock, &SaveBlockTutorialPrinterClosed);
111 return;
112 }
113
116}
BSS s32 SaveBlockTutorialPrinterClosed
Definition SaveBlock.c:20
MessagePrintState * msg_get_printer_for_msg(s32 msgID, s32 *a1)
Definition msg.c:1424
@ GF_Tutorial_SaveBlock
s32 set_global_flag(s32 index)
Definition vars_access.c:65
s32 get_global_flag(s32 index)
Definition vars_access.c:89

◆ entity_SaveBlock_wait_for_close_tutorial()

void entity_SaveBlock_wait_for_close_tutorial ( Entity * entity)

Definition at line 118 of file SaveBlock.c.

118 {
121 }
122}

◆ entity_SaveBlock_show_choice_message()

void entity_SaveBlock_show_choice_message ( void )

Definition at line 124 of file SaveBlock.c.

124 {
129}
BSS MessagePrintState * SaveBlockResultPrinter
Definition SaveBlock.c:23
BSS MessagePrintState * SaveBlockTutorialPrinter
Definition SaveBlock.c:22
BSS s32 SaveBlockResultPrinterClosed
Definition SaveBlock.c:21

◆ entity_SaveBlock_show_result_message()

void entity_SaveBlock_show_result_message ( void )

Definition at line 131 of file SaveBlock.c.

131 {
132 msg_printer_load_msg(MSG_Menus_SaveComplete, SaveBlockResultPrinter);
134}
@ SOUND_SAVE_CONFIRM
Definition enums.h:561
s32 msg_printer_load_msg(s32 msgID, MessagePrintState *printer)
Definition msg.c:1474

◆ entity_SaveBlock_wait_for_close_result()

void entity_SaveBlock_wait_for_close_result ( Entity * entity)

Definition at line 136 of file SaveBlock.c.

136 {
139 }
140}

◆ entity_SaveBlock_wait_for_close_choice()

void entity_SaveBlock_wait_for_close_choice ( Entity * entity)

Definition at line 142 of file SaveBlock.c.

142 {
146 } else {
148 }
150 }
151}
s32 Entity_SaveBlock_ScriptResume[]
Definition SaveBlock.c:182
void close_message(MessagePrintState *msgPrintState)
Definition msg.c:1568
void set_entity_commandlist(Entity *entity, s32 *entityScript)
Definition entity.c:235

◆ entity_SaveBlock_init()

void entity_SaveBlock_init ( Entity * entity)

Definition at line 153 of file SaveBlock.c.

153 {
154 SaveBlockData* data = entity->dataBuf.saveBlock;
155
158 data->angle = 8;
159}
void entity_SaveBlock_setupGfx(s32 index)
Definition SaveBlock.c:30
void entity_base_block_init(Entity *entity)
Definition Block.c:213

◆ entity_GreenStompSwitch_idle()

void entity_GreenStompSwitch_idle ( Entity * entity)

Definition at line 25 of file Switch.c.

25 {
26 PlayerStatus* playerStatus = &gPlayerStatus;
27 SwitchData* data = entity->dataBuf.swtch;
28
30 if ((playerStatus->actionState == ACTION_STATE_SPIN_POUND)
31 || (playerStatus->actionState == ACTION_STATE_TORNADO_POUND)) {
33 data->greenMotionTimer = 8;
34 }
35 }
36}
struct SwitchData * swtch
s16 greenMotionTimer
Definition entity.h:87
@ ENTITY_COLLISION_PLAYER_TOUCH_FLOOR
Definition enums.h:2648
@ ACTION_STATE_SPIN_POUND
Definition enums.h:2442
@ ACTION_STATE_TORNADO_POUND
Definition enums.h:2444

◆ entity_GreenStompSwitch_retract()

void entity_GreenStompSwitch_retract ( Entity * entity)

Definition at line 38 of file Switch.c.

38 {
39 SwitchData* data = entity->dataBuf.swtch;
40 u16 curTime = data->greenMotionTimer--;
41
42 if (curTime != 0) {
43 entity->pos.y -= 1.8625;
44 return;
45 }
46 entity_start_script(entity);
48 data->greenMotionTimer = 8;
49}
s32 entity_start_script(Entity *entity)
Definition entity.c:560

◆ entity_GreenStompSwitch_extend()

void entity_GreenStompSwitch_extend ( Entity * entity)

Definition at line 51 of file Switch.c.

51 {
52 SwitchData* data = entity->dataBuf.swtch;
53 u16 curTime = data->greenMotionTimer--;
54
55 if (curTime != 0) {
56 entity->pos.y += 1.8625;
57 return;
58 }
60 data->greenMotionTimer = 8;
61}

◆ entity_HugeBlueSwitch_idle()

void entity_HugeBlueSwitch_idle ( Entity * entity)

Definition at line 86 of file Switch.c.

86 {
87 PlayerStatus* playerStatus = &gPlayerStatus;
88
90 if ((playerStatus->actionState == ACTION_STATE_SPIN_POUND)
91 || (playerStatus->actionState == ACTION_STATE_TORNADO_POUND)) {
93 }
94 }
95}

◆ entity_small_switch_idle()

void entity_small_switch_idle ( Entity * entity)

Definition at line 97 of file Switch.c.

97 {
98 SwitchData* data = entity->dataBuf.swtch;
99 PlayerStatus* playerStatus = &gPlayerStatus;
100 PartnerStatus* partnerStatus = &gPartnerStatus;
101
103
105 if (playerStatus->actionState == ACTION_STATE_HAMMER) {
106 if (gPlayerData.hammerLevel < 0) {
107 return;
108 }
110
111 if (data->linkedSwitch == NULL) {
112 return;
113 }
114
116 return;
117 }
118 }
119
120 if (playerStatus->actionState == ACTION_STATE_SPIN_JUMP) {
121 return;
122 }
123
124 if (partnerStatus->actingPartner == PARTNER_PARAKARRY && partnerStatus->partnerActionState != PARTNER_ACTION_NONE) {
125 return;
126 }
127
129 if (!(entity->collisionFlags & ENTITY_COLLISION_PARTNER)) {
130 return;
131 }
132 }
133
135
136 if (data->linkedSwitch == NULL) {
137 return;
138 }
139
141}
void entity_switch_fall_down(Entity *entity)
Definition Switch.c:63
struct Entity * linkedSwitch
Definition entity.h:89
@ ENTITY_COLLISION_PARTNER
Definition enums.h:2655
@ ENTITY_COLLISION_PLAYER_HAMMER
Definition enums.h:2654
@ ACTION_STATE_SPIN_JUMP
Definition enums.h:2441
@ ACTION_STATE_HAMMER
Definition enums.h:2446

◆ entity_RedSwitch_wait_and_reset()

void entity_RedSwitch_wait_and_reset ( Entity * entity)

Definition at line 143 of file Switch.c.

143 {
146 }
147}

◆ entity_base_switch_anim_init()

void entity_base_switch_anim_init ( Entity * entity)

Definition at line 149 of file Switch.c.

149 {
150 SwitchData* data = entity->dataBuf.swtch;
151
152 data->fallVel = 1.0f;
153 data->deltaScaleX = 0.1f;
154 data->deltaScaleY = -0.1f;
155 data->animStateScaleX = 0;
156 data->animStateScaleY = 0;
157}
s8 animStateScaleX
Definition entity.h:83
f32 deltaScaleX
Definition entity.h:80
f32 fallVel
Definition entity.h:79
s8 animStateScaleY
Definition entity.h:84
f32 deltaScaleY
Definition entity.h:81

◆ entity_RedSwitch_animate_scale()

s32 entity_RedSwitch_animate_scale ( Entity * entity)

Definition at line 159 of file Switch.c.

159 {
160 f32 phi_f4;
161 f32 temp_f6;
162 SwitchData* data = entity->dataBuf.swtch;
163 s32 phi_s2 = 0;
164
165 switch (data->animStateScaleX) {
166 case 0:
167 temp_f6 = data->baseScale.z * 0.3;
168 phi_f4 = ((data->baseScale.x + temp_f6) - entity->scale.x) / 4.0;
169 if (phi_f4 < 0.01) {
170 phi_f4 = 0.01f;
171 }
172 data->deltaScaleX += phi_f4;
173 entity->scale.x += data->deltaScaleX;
174 if ((data->baseScale.x + temp_f6) <= entity->scale.x) {
175 data->deltaScaleX = 0.0f;
176 data->animStateScaleX++;
177 }
178 break;
179 case 1:
180 temp_f6 = data->baseScale.z * -0.2;
181 phi_f4 = ((data->baseScale.x + temp_f6) - entity->scale.x) / 6.0;
182 if (phi_f4 > -0.01) {
183 phi_f4 = -0.01f;
184 }
185 data->deltaScaleX += phi_f4;
186 entity->scale.x += data->deltaScaleX;
187 if (entity->scale.x <= (data->baseScale.x + temp_f6)) {
188 data->deltaScaleX = 0.0f;
189 data->animStateScaleX++;
190 }
191 break;
192 case 2:
193 temp_f6 = data->baseScale.z * 0.15;
194 phi_f4 = ((data->baseScale.x + temp_f6) - entity->scale.x) / 4.0;
195 if (phi_f4 < 0.01) {
196 phi_f4 = 0.01f;
197 }
198 data->deltaScaleX += phi_f4;
199 entity->scale.x += data->deltaScaleX;
200 if ((data->baseScale.x + temp_f6) <= entity->scale.x) {
201 data->deltaScaleX = 0.0f;
202 data->animStateScaleX++;
203 }
204 break;
205 case 3:
206 temp_f6 = data->baseScale.z * -0.1;
207 phi_f4 = ((data->baseScale.x + temp_f6) - entity->scale.x) / 6.0;
208 if (phi_f4 > -0.01) {
209 phi_f4 = -0.01f;
210 }
211 data->deltaScaleX += phi_f4;
212 entity->scale.x += data->deltaScaleX;
213 if (entity->scale.x <= (data->baseScale.x + temp_f6)) {
214 data->deltaScaleX = 0.0f;
215 data->animStateScaleX++;
216 }
217 break;
218 case 4:
219 phi_f4 = (data->baseScale.x - entity->scale.x) / 4.0;
220 if (phi_f4 < 0.01) {
221 phi_f4 = 0.01f;
222 }
223 data->deltaScaleX += phi_f4;
224 entity->scale.x += data->deltaScaleX;
225 if (data->baseScale.x <= entity->scale.x) {
226 entity->scale.x = data->baseScale.x;
227 data->deltaScaleX = 0.0f;
228 data->animStateScaleX++;
229 }
230 break;
231 case 5:
232 phi_s2++;
233 break;
234 }
235
236 entity->scale.z = entity->scale.x;
237
238 switch (data->animStateScaleY) {
239 case 0:
240 temp_f6 = data->baseScale.z * -0.5;
241 phi_f4 = ((data->baseScale.y + temp_f6) - entity->scale.y) / 5.0;
242 if (phi_f4 > -0.01) {
243 phi_f4 = -0.01f;
244 }
245 data->deltaScaleY += phi_f4;
246 entity->scale.y += data->deltaScaleY;
247 if (entity->scale.y <= (data->baseScale.y + temp_f6)) {
248 data->deltaScaleY = 0.0f;
249 data->animStateScaleY++;
250 }
251 break;
252 case 1:
253 temp_f6 = data->baseScale.z * 0.1;
254 phi_f4 = ((data->baseScale.y + temp_f6) - entity->scale.y) / 10.0;
255 if (phi_f4 < 0.01) {
256 phi_f4 = 0.01f;
257 }
258 data->deltaScaleY += phi_f4;
259 entity->scale.y += data->deltaScaleY;
260 if ((data->baseScale.y + temp_f6) <= entity->scale.y) {
261 data->deltaScaleY = 0.0f;
262 data->animStateScaleY++;
263 }
264 break;
265 case 2:
266 temp_f6 = data->baseScale.z * -0.3;
267 phi_f4 = ((data->baseScale.y + temp_f6) - entity->scale.y) / 5.0;
268 if (phi_f4 > -0.01) {
269 phi_f4 = -0.01f;
270 }
271 data->deltaScaleY += phi_f4;
272 entity->scale.y += data->deltaScaleY;
273 if (entity->scale.y <= (data->baseScale.y + temp_f6)) {
274 data->deltaScaleY = 0.0f;
275 data->animStateScaleY++;
276 }
277 break;
278 case 3:
279 temp_f6 = data->baseScale.z * 0.0;
280 phi_f4 = ((data->baseScale.y + temp_f6) - entity->scale.y) / 10.0;
281 if (phi_f4 < 0.01) {
282 phi_f4 = 0.01f;
283 }
284 data->deltaScaleY += phi_f4;
285 entity->scale.y += data->deltaScaleY;
286 if ((data->baseScale.y + temp_f6) <= entity->scale.y) {
287 data->deltaScaleY = 0.0f;
288 data->animStateScaleY++;
289 }
290 break;
291 case 4:
292 phi_f4 = (data->baseScale.y - entity->scale.y) / 5.0;
293 if (phi_f4 > -0.01) {
294 phi_f4 = -0.01f;
295 }
296 data->deltaScaleY += phi_f4;
297 entity->scale.y += data->deltaScaleY;
298 if (entity->scale.y <= data->baseScale.y) {
299 entity->scale.y = data->baseScale.y;
300 data->deltaScaleY = 0.0f;
301 data->animStateScaleY++;
302 }
303 break;
304 case 5:
305 phi_s2++;
306 break;
307 }
308
310 if (phi_s2 == 2) {
311 data->animStateScaleX = 0;
312 data->animStateScaleY = 0;
314 }
315}
Vec3f baseScale
Definition entity.h:85

◆ entity_base_switch_start_bound_script()

void entity_base_switch_start_bound_script ( Entity * entity)

Definition at line 317 of file Switch.c.

317 {
318 SwitchData* data = entity->dataBuf.swtch;
320 entity_start_script(entity);
321}
u16 areaFlagIndex
Definition entity.h:86
s32 set_area_flag(s32 index)

◆ entity_base_switch_animate_scale()

void entity_base_switch_animate_scale ( Entity * entity)

Definition at line 323 of file Switch.c.

323 {
324 f32 phi_f4;
325 f32 scaleChange;
326 SwitchData* data = entity->dataBuf.swtch;
327 s32 phi_s2 = 0;
328
329 switch (data->animStateScaleX) {
330 case 0:
331 scaleChange = data->baseScale.z * 0.3;
332 phi_f4 = ((data->baseScale.x + scaleChange) - entity->scale.x) / 4.0;
333 if (phi_f4 < 0.01) {
334 phi_f4 = 0.01f;
335 }
336 data->deltaScaleX += phi_f4;
337 entity->scale.x += data->deltaScaleX;
338 if ((data->baseScale.x + scaleChange) <= entity->scale.x) {
339 data->deltaScaleX = 0.0f;
340 data->animStateScaleX++;
341 }
342 break;
343 case 1:
344 scaleChange = (data->baseScale.z * -0.2);
345 phi_f4 = ((data->baseScale.x + scaleChange) - entity->scale.x) / 6.0;
346 if (phi_f4 > -0.01) {
347 phi_f4 = -0.01f;
348 }
349 data->deltaScaleX += phi_f4;
350 entity->scale.x += data->deltaScaleX;
351 if (entity->scale.x <= (data->baseScale.x + scaleChange)) {
352 data->deltaScaleX = 0.0f;
353 data->animStateScaleX++;
354 }
355 break;
356 case 2:
357 scaleChange = data->baseScale.z * 0.15;
358 phi_f4 = ((data->baseScale.x + scaleChange) - entity->scale.x) / 4.0;
359 if (phi_f4 < 0.01) {
360 phi_f4 = 0.01f;
361 }
362 data->deltaScaleX += phi_f4;
363 entity->scale.x += data->deltaScaleX;
364 if ((data->baseScale.x + scaleChange) <= entity->scale.x) {
365 data->deltaScaleX = 0.0f;
366 data->animStateScaleX++;
367 }
368 break;
369 case 3:
370 scaleChange = data->baseScale.z * -0.1;
371 phi_f4 = ((data->baseScale.x + scaleChange) - entity->scale.x) / 6.0;
372 if (phi_f4 > -0.01) {
373 phi_f4 = -0.01f;
374 }
375 data->deltaScaleX += phi_f4;
376 entity->scale.x += data->deltaScaleX;
377 if (entity->scale.x <= (data->baseScale.x + scaleChange)) {
378 data->deltaScaleX = 0.0f;
379 data->animStateScaleX++;
380 }
381 break;
382 case 4:
383 phi_s2++;
384 break;
385 }
386
387 entity->scale.z = entity->scale.x;
388
389 switch (data->animStateScaleY) {
390 case 0:
391 scaleChange = data->baseScale.z * -0.5;
392 phi_f4 = ((data->baseScale.y + scaleChange) - entity->scale.y) / 5.0;
393 if (phi_f4 > -0.01) {
394 phi_f4 = -0.01f;
395 }
396 data->deltaScaleY += phi_f4;
397 entity->scale.y += data->deltaScaleY;
398 if (entity->scale.y <= (data->baseScale.y + scaleChange)) {
399 data->deltaScaleY = 0.0f;
400 data->animStateScaleY++;
401 }
402 break;
403 case 1:
404 scaleChange = data->baseScale.z * 0.1;
405 phi_f4 = ((data->baseScale.y + scaleChange) - entity->scale.y) / 10.0;
406 if (phi_f4 < 0.01) {
407 phi_f4 = 0.01f;
408 }
409 data->deltaScaleY += phi_f4;
410 entity->scale.y += data->deltaScaleY;
411 if ((data->baseScale.y + scaleChange) <= entity->scale.y) {
412 data->deltaScaleY = 0.0f;
413 data->animStateScaleY++;
414 }
415 break;
416 case 2:
417 scaleChange = data->baseScale.z * -0.3;
418 phi_f4 = ((data->baseScale.y + scaleChange) - entity->scale.y) / 5.0;
419 if (phi_f4 > -0.01) {
420 phi_f4 = -0.01f;
421 }
422 data->deltaScaleY += phi_f4;
423 entity->scale.y += data->deltaScaleY;
424 if (entity->scale.y <= (data->baseScale.y + scaleChange)) {
425 data->deltaScaleY = 0.0f;
426 data->animStateScaleY++;
427 }
428 break;
429 case 3:
430 phi_s2++;
431 break;
432 }
433
435 if (phi_s2 == 2) {
436 data->animStateScaleX = 0;
437 data->animStateScaleY = 0;
439 }
440
441 data->scaleAnimTimer++;
442 if (data->scaleAnimTimer == 10 && data->linkedSwitch == NULL) {
443 fx_cold_breath(0, entity->pos.x, entity->pos.y, entity->pos.z, 1.0f, 60);
444 }
445}
s16 scaleAnimTimer
Definition entity.h:88

◆ entity_base_switch_init()

void entity_base_switch_init ( Entity * entity)

Definition at line 447 of file Switch.c.

447 {
448 PlayerStatus* playerStatus = &gPlayerStatus;
449 SwitchData* data = entity->dataBuf.swtch;
450
451 playerStatus->animFlags |= PA_FLAG_MAP_HAS_SWITCH;
452 data->baseScale.x = 1.0f;
453 data->baseScale.y = 1.0f;
454 data->baseScale.z = 1.0f;
455}

Referenced by entity_BlueSwitch_init(), and entity_HugeBlueSwitch_init().

◆ entity_block_hit_init_scale()

f32 entity_block_hit_init_scale ( Entity * entity)

Definition at line 75 of file Block.c.

75 {
76 s32 type = get_entity_type(entity->listIndex);
78 entity->scale.y = 0.23f;
79 entity->scale.x = 1.04f;
80 entity->scale.z = 1.04f;
81 entity->pos.y += 18.0f;
82 } else {
83 entity->scale.y = 0.46f;
84 entity->scale.x = 2.08f;
85 entity->scale.z = 2.08f;
86 entity->pos.y += 18.0f;
87 }
88}
@ ENTITY_TYPE_HAMMER3_BLOCK_TINY
Definition enums.h:2569
@ ENTITY_TYPE_HAMMER2_BLOCK_TINY
Definition enums.h:2568
@ ENTITY_TYPE_HAMMER1_BLOCK_TINY
Definition enums.h:2567
u32 get_entity_type(s32 arg0)
Definition entity.c:568

◆ entity_block_hit_animate_scale()

void entity_block_hit_animate_scale ( Entity * entity)

Definition at line 90 of file Block.c.

90 {
91 s32 type = get_entity_type(entity->listIndex);
93 entity->scale.x -= 0.09;
94 entity->scale.z -= 0.09;
95 entity->scale.y += 0.045;
96 entity->pos.y -= 3.0f;
97 } else {
98 entity->scale.x -= 0.18;
99 entity->scale.z -= 0.18;
100 entity->scale.y += 0.09;
101 entity->pos.y -= 3.0f;
102 }
104}
s32 entity_base_block_idle(Entity *entity)
Definition Block.c:195

◆ entity_block_handle_collision()

s32 entity_block_handle_collision ( Entity * entity)

Definition at line 334 of file Block.c.

334 {
335 s32 breakBlock;
336 PlayerStatus* playerStatus = &gPlayerStatus;
337
338 if (entity->alpha == 0 && (entity->collisionFlags & ENTITY_COLLISION_PLAYER_TOUCH_FLOOR)) {
339 return FALSE;
340 }
341
343 s32 type = get_entity_type(entity->listIndex);
344 switch (type) {
352 return FALSE;
353 }
354
355 if (playerStatus->flags & PS_FLAG_JUMPING) {
357 }
358 return TRUE;
359 }
360
362 // partner collision means either kooper shell toss or bombette explosion
364 switch (get_entity_type(entity->listIndex)) {
369 return TRUE;
370 }
371 }
373 return TRUE;
374 }
375
376 breakBlock = FALSE;
378 if (playerStatus->actionState == ACTION_STATE_SPIN_JUMP || playerStatus->actionState == ACTION_STATE_TORNADO_JUMP) {
379 return FALSE;
380 }
381
382 if (playerStatus->actionState == ACTION_STATE_SPIN_POUND || playerStatus->actionState == ACTION_STATE_TORNADO_POUND) {
383 breakBlock = TRUE;
384 } else {
385 return TRUE;
386 }
387 } else {
389 return TRUE;
390 }
391 if (!(playerStatus->flags & PS_FLAG_HAMMER_CHECK)) {
392 return TRUE;
393 }
394 }
395
396 switch (get_entity_type(entity->listIndex)) {
405 break;
408 if (breakBlock) {
409 if (gPlayerData.bootsLevel < 1) {
410 breakBlock = FALSE;
411 }
412 } else {
413 if (gPlayerData.hammerLevel > -1) {
414 breakBlock = TRUE;
415 }
416 }
417 if (!breakBlock) {
418 return TRUE;
419 }
422 break;
425 if (breakBlock) {
426 if (gPlayerData.bootsLevel < 2) {
427 breakBlock = FALSE;
428 }
429 } else if (gPlayerData.hammerLevel > 0) {
430 breakBlock = TRUE;
431 }
432 if (!breakBlock) {
433 return TRUE;
434 }
437 break;
440 if (gPlayerData.hammerLevel < 2) {
441 return TRUE;
442 }
445 break;
448 case ENTITY_TYPE_1C:
449 case ENTITY_TYPE_1D:
450 case ENTITY_TYPE_1E:
452 entity_start_script(entity);
454 break;
456 entity_start_script(entity);
457 break;
459 break;
460 }
461
462 return TRUE;
463}
EntityScript Entity_BreakingBlock_Script
Definition Block.c:520
#define sfx_play_sound_at_position
@ PS_FLAG_JUMPING
Definition enums.h:3035
@ PS_FLAG_HAMMER_CHECK
Definition enums.h:3073
@ ENTITY_TYPE_HAMMER1_BLOCK
Definition enums.h:2564
@ ENTITY_TYPE_1E
Definition enums.h:2573
@ ENTITY_TYPE_HEALING_BLOCK_FRAME
Definition enums.h:2574
@ ENTITY_TYPE_SINGLE_TRIGGER_BLOCK
Definition enums.h:2559
@ ENTITY_TYPE_HIDDEN_RED_BLOCK
Definition enums.h:2561
@ ENTITY_TYPE_HAMMER3_BLOCK
Definition enums.h:2566
@ ENTITY_TYPE_1C
Definition enums.h:2571
@ ENTITY_TYPE_HEALING_BLOCK
Definition enums.h:2570
@ ENTITY_TYPE_1D
Definition enums.h:2572
@ ENTITY_TYPE_HAMMER2_BLOCK
Definition enums.h:2565
@ ENTITY_TYPE_INACTIVE_BLOCK
Definition enums.h:2562
@ ENTITY_TYPE_MULTI_COIN_BRICK
Definition enums.h:2557
@ ENTITY_TYPE_BRICK_BLOCK
Definition enums.h:2556
@ ENTITY_TYPE_HIDDEN_YELLOW_BLOCK
Definition enums.h:2560
@ ENTITY_TYPE_RED_BLOCK
Definition enums.h:2563
@ ENTITY_TYPE_MULTI_TRIGGER_BLOCK
Definition enums.h:2554
@ ENTITY_TYPE_YELLOW_BLOCK
Definition enums.h:2558
@ ENTITY_COLLISION_PLAYER_TOUCH_CEILING
Definition enums.h:2650
@ SOUND_SMASH_HAMER_BLOCK_3
Definition enums.h:771
@ SOUND_SMASH_HAMER_BLOCK_1
Definition enums.h:769
@ SOUND_SMASH_HAMER_BLOCK_2
Definition enums.h:770
@ PARTNER_BOMBETTE
Definition enums.h:2888
@ ACTION_STATE_TORNADO_JUMP
Definition enums.h:2443
@ SOUND_SPACE_DEFAULT
Definition enums.h:1737

◆ entity_BlueSwitch_init()

void entity_BlueSwitch_init ( Entity * entity)

Definition at line 457 of file Switch.c.

457 {
458 SwitchData* data = entity->dataBuf.swtch;
459
462 SwitchToLink = entity;
463 return;
464 }
465
467 if (SwitchToLink != NULL) {
469 entity->flags |= ENTITY_FLAG_HIDDEN;
470 return;
471 }
472 } else {
473 SwitchToLink = NULL;
474 }
475}
#define REFLECTED_SWITCH_LINKED
Definition Switch.c:17
void entity_base_switch_init(Entity *entity)
Definition Switch.c:447
BSS Entity * SwitchToLink
Definition Switch.c:23
#define REFLECTED_SWITCH_HIDDEN
Definition Switch.c:16
s32 CreateEntityVarArgBuffer[]
Definition entity.c:35
@ ENTITY_FLAG_HIDDEN
Definition enums.h:2613

◆ entity_HugeBlueSwitch_init()

void entity_HugeBlueSwitch_init ( Entity * entity)

Definition at line 477 of file Switch.c.

477 {
478 SwitchData* data;
479
481 data = entity->dataBuf.swtch;
482 entity->scale.x = 3.0f;
483 entity->scale.y = 3.0f;
484 entity->scale.z = 3.0f;
485 data->baseScale.x = 3.0f;
486 data->baseScale.y = 3.0f;
487 data->baseScale.z = 3.0f;
488}

◆ dispatch_damage_event_actor_0()

s32 dispatch_damage_event_actor_0 ( Actor * actor,
s32 damageAmount,
s32 event )

Definition at line 889 of file 1A5830.c.

889 {
890 return dispatch_damage_event_actor(actor, damageAmount, event, FALSE);
891}
s32 dispatch_damage_event_actor(Actor *actor, s32 damageAmount, s32 originalEvent, s32 stopMotion)
Definition 1A5830.c:821

Referenced by btl_state_update_9().

◆ msg_get_printer_for_msg()

MessagePrintState * msg_get_printer_for_msg ( s32 msgID,
s32 * a1 )

Definition at line 1424 of file msg.c.

1424 {
1425 return _msg_get_printer_for_msg(msgID, donePrintingWriteback, 0);
1426}
MessagePrintState * _msg_get_printer_for_msg(s32 msgID, s32 *donePrintingWriteback, s32 arg2)
Definition msg.c:1428

Referenced by _show_message(), entity_HeartBlock_show_tutorial_message(), entity_SaveBlock_show_choice_message(), entity_SaveBlock_show_tutorial_message(), popup_menu_update(), and update_item_entity_pickup().

◆ msg_printer_load_msg()

s32 msg_printer_load_msg ( s32 msgID,
MessagePrintState * printer )

Definition at line 1474 of file msg.c.

1474 {
1475 s8* buffer;
1476
1477 if (msgID >= 0) {
1478 buffer = load_message_to_buffer(msgID);
1479 } else {
1480 buffer = (s8*) msgID;
1481 }
1482
1483 printer->srcBuffer = buffer;
1484 printer->srcBufferPos = 0;
1485 printer->stateFlags &= ~MSG_STATE_FLAG_40;
1486 return 1;
1487}
s8 * load_message_to_buffer(s32 msgID)
Definition msg.c:1410

Referenced by _show_message(), and entity_SaveBlock_show_result_message().

◆ msg_printer_set_origin_pos()

void msg_printer_set_origin_pos ( MessagePrintState * msgPrintState,
s32 x,
s32 y )

Definition at line 1489 of file msg.c.

1489 {
1490 msgPrintState->initOpenPos.x = x;
1491 msgPrintState->initOpenPos.y = y;
1492
1493 if (msgPrintState->initOpenPos.x < 0) {
1494 msgPrintState->initOpenPos.x = 0;
1495 }
1496 if (msgPrintState->initOpenPos.x > SCREEN_WIDTH) {
1497 msgPrintState->initOpenPos.x = SCREEN_WIDTH;
1498 }
1499 if (msgPrintState->initOpenPos.y < 0) {
1500 msgPrintState->initOpenPos.y = 0;
1501 }
1502 if (msgPrintState->initOpenPos.y > 220) {
1503 msgPrintState->initOpenPos.y = 220;
1504 }
1505}

Referenced by _show_message(), popup_menu_update(), and update_item_entity_pickup().

◆ get_screen_coords()

void get_screen_coords ( s32 camID,
f32 x,
f32 y,
f32 z,
s32 * screenX,
s32 * screenY,
s32 * screenZ )

Definition at line 410 of file cam_main.c.

410 {
411 Camera* camera = &gCameras[camID];
412 f32 tW;
413 f32 tZ;
414 f32 tY;
415 f32 tX;
416
417 transform_point(camera->mtxPerspective, x, y, z, 1.0f, &tX, &tY, &tZ, &tW);
418
419 *screenZ = tZ + 5000.0f;
420 if (*screenZ < 0) {
421 *screenZ = 0;
422 } else if (*screenZ > 10000) {
423 *screenZ = 10000;
424 }
425
426 if (tW < 0.01 && tW > -0.01) {
427 *screenX = 0;
428 *screenY = 0;
429 *screenZ = 0;
430 } else {
431 *screenX = camera->viewportStartX + (s32) ((1.0f + tX / tW) * camera->viewportW * 0.5f);
432 *screenY = camera->viewportStartY + (s32) ((1.0f - tY / tW) * camera->viewportH * 0.5f);
433 }
434}
#define transform_point

Referenced by _show_message(), btl_draw_enemy_health_bars(), btl_state_draw_select_target(), draw_all_status_icons(), draw_encounters_pre_battle(), render_player_model(), sfx_compute_spatialized_sound_params_full(), sfx_compute_spatialized_sound_params_ignore_depth(), sfx_compute_spatialized_sound_params_with_depth(), update_cameras(), and update_encounters_neutral().

◆ parent_collider_to_model()

void parent_collider_to_model ( s16 colliderID,
s16 modelIndex )

Definition at line 320 of file collision.c.

320 {
321 Collider* collider;
322 ColliderTriangle* triangle;
323 s32 i;
324 Vec3f** vertexBuffer;
325 Vec3f** vertexPtr;
326 s32 vertexBufferSize;
327 Vec3f* vertexTable;
328 Vec3f* vertex;
329
330 collider = &gCollisionData.colliderList[colliderID];
331 collider->parentModelIndex = modelIndex;
333
334 vertexBuffer = collision_heap_malloc(collider->numTriangles * sizeof(Vec3f));
335 vertexBufferSize = 0;
336 vertexPtr = vertexBuffer;
337
338 for (i = 0, triangle = collider->triangleTable; i < collider->numTriangles; i++, triangle++) {
339 _add_hit_vert_to_buffer(vertexBuffer, triangle->v1, &vertexBufferSize);
340 _add_hit_vert_to_buffer(vertexBuffer, triangle->v2, &vertexBufferSize);
341 _add_hit_vert_to_buffer(vertexBuffer, triangle->v3, &vertexBufferSize);
342 }
343
344 collider->numVertices = vertexBufferSize;
345 collider->vertexTable = collision_heap_malloc(vertexBufferSize * 2 * sizeof(Vec3f));
346 for (i = 0, vertexTable = collider->vertexTable; i < vertexBufferSize; vertexPtr++, vertexTable += 2, i++) {
347 vertex = *vertexPtr;
348 vertexTable[0].x = vertexTable[1].x = vertex->x;
349 vertexTable[0].y = vertexTable[1].y = vertex->y;
350 vertexTable[0].z = vertexTable[1].z = vertex->z;
351 }
352
353 vertexTable = collider->vertexTable;
354 for (i = 0, triangle = collider->triangleTable; i < collider->numTriangles; triangle++, i++) {
355 triangle->v1 = &vertexTable[_get_hit_vert_index_from_buffer(vertexBuffer, triangle->v1, &vertexBufferSize) * 2];
356 triangle->v2 = &vertexTable[_get_hit_vert_index_from_buffer(vertexBuffer, triangle->v2, &vertexBufferSize) * 2];
357 triangle->v3 = &vertexTable[_get_hit_vert_index_from_buffer(vertexBuffer, triangle->v3, &vertexBufferSize) * 2];
358 }
359
360 collision_heap_free(vertexBuffer);
361}
s32 _get_hit_vert_index_from_buffer(Vec3f **buffer, Vec3f *vert, s32 *bufferSize)
Definition collision.c:378
void collision_heap_free(void *)
Definition heap.c:65
CollisionData gCollisionData
Definition collision.c:35
void _add_hit_vert_to_buffer(Vec3f **buf, Vec3f *vert, s32 *bufSize)
Definition collision.c:363
void * collision_heap_malloc(s32 size)
Definition heap.c:57
Collider * colliderList
Vec3f * vertexTable
struct ColliderTriangle * triangleTable
@ COLLIDER_FLAG_HAS_MODEL_PARENT
Definition enums.h:4700

Referenced by restore_map_collision_data().

◆ clone_model()

void clone_model ( u16 srcModelID,
u16 newModelID )

Definition at line 3620 of file model.c.

3620 {
3622 Model* newModel;
3623 s32 i;
3624
3625 for (i = 0; i < ARRAY_COUNT(*gCurrentModels); i++) {
3626 if ((*gCurrentModels)[i] == NULL) {
3627 break;
3628 }
3629 }
3630
3631 (*gCurrentModels)[i] = newModel = heap_malloc(sizeof(*newModel));
3632 *newModel = *srcModel;
3633 newModel->modelID = newModelID;
3634}
s32 get_model_list_index_from_tree_index(s32 treeIndex)
Definition model.c:3396
Model * get_model_from_list_index(s32 listIndex)
Definition model.c:3314
ModelList * gCurrentModels
Definition model.c:106
u16 modelID
Definition model.h:61
Definition model.h:59

◆ get_model_from_list_index()

◆ create_model_animator()

s32 create_model_animator ( s16 * animPos)

Definition at line 318 of file animator.c.

318 {
319 ModelAnimator* animator;
320 s32 i, j;
321
322 for (i = 0; i < ARRAY_COUNT(*gCurrentAnimMeshListPtr); i++) {
323 if ((*gCurrentAnimMeshListPtr)[i] == NULL) {
324 break;
325 }
326 }
327
329
330 (*gCurrentAnimMeshListPtr)[i] = animator = heap_malloc(sizeof(*animator));
331 gAnimCount++;
332
333 ASSERT(animator != NULL);
334
337 animator->nextUpdateTime = 1.0f;
338 animator->timeScale = 1.0f;
339 animator->animReadPos = animPos;
340
341 if (animPos == NULL) {
343 }
344
345 animator->savedReadPos = animPos;
346 animator->animationBuffer = NULL;
347 animator->baseAddr = NULL;
348 animator->fpRenderCallback = NULL;
349 animator->rootNode = NULL;
350 animator->nextUniqueID = 0;
351
352 for (j = 0; j < ARRAY_COUNT(animator->nodeCache); j++) {
353 animator->nodeCache[j] = NULL;
354 }
355
356 for (j = 0; j < ARRAY_COUNT(animator->staticNodeIDs); j++) {
357 animator->staticNodeIDs[j] = j + 1;
358 }
359
361 i |= BATTLE_ID_BIT;
362 }
363 return i;
364}
AnimScript gAnimScriptDefault
Definition animator.c:48

Referenced by create_shadow_from_data(), and load_split_entity_data().

◆ get_model_list_index_from_tree_index()

s32 get_model_list_index_from_tree_index ( s32 treeIndex)

Definition at line 3396 of file model.c.

3396 {
3397 s32 i;
3398
3399 if (treeIndex < MAX_MODELS) {
3400 u8 modelIndex = (*gCurrentModelTreeNodeInfo)[treeIndex].modelIndex;
3401
3402 if (modelIndex != (u8)-1) {
3403 return modelIndex;
3404 }
3405 }
3406
3407 for (i = 0; i < MAX_MODELS; i++) {
3408 Model* model = get_model_from_list_index(i);
3409
3410 if (model != NULL && model->modelID == treeIndex) {
3411 return i;
3412 }
3413 }
3414 return 0;
3415}
#define MAX_MODELS
Definition macros.h:88

Referenced by animator_node_update_model_transform(), clone_model(), get_model_center_and_size(), hide_foreground_models(), hide_foreground_models_unchecked(), is_model_center_visible(), mdl_draw_hidden_panel_surface(), mdl_make_local_vertex_copy(), mdl_make_transform_group(), mdl_project_tex_coords(), show_foreground_models(), and show_foreground_models_unchecked().

◆ get_transform_group_index()

s32 get_transform_group_index ( s32 modelID)

Definition at line 3417 of file model.c.

3417 {
3418 ModelTransformGroup* group;
3419 s32 i;
3420
3421 for (i = 0; i < MAX_MODEL_TRANSFORM_GROUPS; i++) {
3422 group = get_transform_group(i);
3423
3424 if (group != NULL && group->groupModelID == modelID) {
3425 return i;
3426 }
3427 }
3428
3429 return -1;
3430}
ModelTransformGroup * get_transform_group(s32 index)
Definition model.c:3452
#define MAX_MODEL_TRANSFORM_GROUPS
Definition macros.h:89

Referenced by disable_transform_group(), and enable_transform_group().

◆ get_model_center_and_size()

void get_model_center_and_size ( u16 modelID,
f32 * centerX,
f32 * centerY,
f32 * centerZ,
f32 * sizeX,
f32 * sizeY,
f32 * sizeZ )

Definition at line 3432 of file model.c.

3432 {
3434 ModelNode* node = model->modelNode;
3435 ModelBoundingBox* bb;
3436
3437 *centerX = model->center.x;
3438 *centerY = model->center.y;
3439 *centerZ = model->center.z;
3440
3442
3443 if (bb != NULL) {
3444 *sizeX = bb->halfSizeX;
3445 *sizeY = bb->halfSizeY;
3446 *sizeZ = bb->halfSizeZ;
3447 } else {
3448 *sizeX = *sizeY = *sizeZ = 0.0f;
3449 }
3450}
ModelNodeProperty * get_model_property(ModelNode *node, ModelPropertyKeys key)
Definition model.c:2285
Vec3f center
Definition model.h:69
ModelNode * modelNode
Definition model.h:63
@ MODEL_PROP_KEY_BOUNDING_BOX
Definition model.h:147

◆ collision_main_above()

HitID collision_main_above ( void )

Definition at line 68 of file 7BB60.c.

68 {
69 PlayerStatus* playerStatus = &gPlayerStatus;
70 CollisionStatus* collisionStatus = &gCollisionStatus;
71 HitID hitResult;
72 f32 x, y, z;
73 f32 halfHeight;
74 f32 moveAngle;
75 f32 moveMagnitude;
76 f32 outDepth;
77
78 outDepth = halfHeight = playerStatus->colliderHeight * 0.5f;
79 x = playerStatus->pos.x;
80 y = playerStatus->pos.y + halfHeight;
81 z = playerStatus->pos.z;
82
83 player_input_to_move_vector(&moveAngle, &moveMagnitude);
84
85 if (moveMagnitude != 0.0f) {
86 moveAngle = playerStatus->targetYaw;
87 } else {
88 moveAngle = playerStatus->spriteFacingAngle - 90.0f + gCameras[gCurrentCameraID].curYaw;
89 }
90
91 hitResult = player_raycast_up_corners(playerStatus, &x, &y, &z, &outDepth, moveAngle);
92 collisionStatus->curCeiling = hitResult;
93
94 if (hitResult > NO_COLLIDER) {
95 if (playerStatus->actionState != ACTION_STATE_FALLING
96 && playerStatus->actionState != ACTION_STATE_STEP_DOWN
97 && collisionStatus->curFloor <= NO_COLLIDER
98 ) {
99 if (outDepth <= fabsf(halfHeight + playerStatus->gravityIntegrator[0])) {
100 if ((hitResult & COLLISION_WITH_ENTITY_BIT) && get_entity_type(hitResult) == ENTITY_TYPE_BRICK_BLOCK) {
101 return hitResult;
102 }
103
104 playerStatus->pos.y = y - ((playerStatus->colliderHeight / 5.0f) * 3.0f);
105 if (playerStatus->actionState != ACTION_STATE_TORNADO_JUMP
106 && playerStatus->actionState != ACTION_STATE_SPIN_JUMP
107 ) {
108 playerStatus->gravityIntegrator[0] = 0.0f;
109 playerStatus->gravityIntegrator[1] = 0.0f;
110 playerStatus->gravityIntegrator[2] = 0.0f;
111 playerStatus->gravityIntegrator[3] = 0.0f;
112 }
113 }
114 }
115 }
116
117 return hitResult;
118}
s32 HitID
@ ACTION_STATE_FALLING
Definition enums.h:2435
@ ACTION_STATE_STEP_DOWN
Definition enums.h:2436
void player_input_to_move_vector(f32 *angle, f32 *magnitude)
Definition 7B440.c:140
HitID player_raycast_up_corners(PlayerStatus *, f32 *, f32 *, f32 *, f32 *, f32)
Definition 77480.c:255

Referenced by phys_update_standard().

◆ collision_lava_reset_check_additional_overlaps()

void collision_lava_reset_check_additional_overlaps ( void )

Definition at line 990 of file 7BB60.c.

990 {
991 PlayerStatus* playerStatus = &gPlayerStatus;
992 f32 x, y, z;
993 f32 yaw;
994
995 if (playerStatus->animFlags & PA_FLAG_USING_PEACH_PHYSICS) {
997 return;
998 }
999
1000 yaw = clamp_angle(playerStatus->targetYaw - 30.0);
1001 y = playerStatus->pos.y + (playerStatus->colliderHeight * 0.75f);
1002 x = playerStatus->pos.x;
1003 z = playerStatus->pos.z;
1005 playerStatus->pos.x = x;
1006 playerStatus->pos.z = z;
1007
1008 yaw = clamp_angle(playerStatus->targetYaw + 30.0);
1009 y = playerStatus->pos.y + (playerStatus->colliderHeight * 0.75f);
1010 x = playerStatus->pos.x;
1011 z = playerStatus->pos.z;
1013 playerStatus->pos.x = x;
1014 playerStatus->pos.z = z;
1015
1016 yaw = clamp_angle(playerStatus->targetYaw - 30.0);
1017 x = playerStatus->pos.x;
1018 y = playerStatus->pos.y;
1019 z = playerStatus->pos.z;
1021 playerStatus->pos.x = x;
1022 playerStatus->pos.z = z;
1023
1024 yaw = clamp_angle(playerStatus->targetYaw + 30.0);
1025 x = playerStatus->pos.x;
1026 y = playerStatus->pos.y;
1027 z = playerStatus->pos.z;
1029 playerStatus->pos.x = x;
1030 playerStatus->pos.z = z;
1031
1032 yaw = clamp_angle(playerStatus->targetYaw + 90.0);
1033 x = playerStatus->pos.x;
1034 y = playerStatus->pos.y;
1035 z = playerStatus->pos.z;
1037 playerStatus->pos.x = x;
1038 playerStatus->pos.z = z;
1039 yaw = clamp_angle(playerStatus->targetYaw - 90.0);
1040
1041 x = playerStatus->pos.x;
1042 y = playerStatus->pos.y;
1043 z = playerStatus->pos.z;
1045 playerStatus->pos.x = x;
1046 playerStatus->pos.z = z;
1047
1048 yaw = clamp_angle(playerStatus->targetYaw + 180.0);
1049 x = playerStatus->pos.x;
1050 y = playerStatus->pos.y;
1051 z = playerStatus->pos.z;
1053 playerStatus->pos.x = x;
1054 playerStatus->pos.z = z;
1055}
void collision_lateral_peach(void)
Definition 7BB60.c:1057
@ PLAYER_COLLISION_0
Definition enums.h:4711
@ PA_FLAG_USING_PEACH_PHYSICS
Definition enums.h:3103
s32 player_test_lateral_overlap(s32, PlayerStatus *, f32 *, f32 *, f32 *, f32, f32)
Definition 77480.c:370

Referenced by action_update_use_spinning_flower(), and phys_update_lava_reset().

◆ player_test_lateral_overlap()

s32 player_test_lateral_overlap ( s32 mode,
PlayerStatus * playerStatus,
f32 * x,
f32 * y,
f32 * z,
f32 length,
f32 yaw )

Definition at line 370 of file 77480.c.

370 {
371 f32 sinTheta;
372 f32 cosTheta;
373 f32 hitX;
374 f32 hitY;
375 f32 hitZ;
376 f32 hitDepth;
377 f32 hitNx;
378 f32 hitNy;
379 f32 hitNz;
380 f32 slipDx;
381 f32 slipDz;
382 f32 depthDiff;
383 f32 radius;
384 f32 originalDepth;
385 s32 hitID;
386 f32 height;
387 f32 targetDx;
388 f32 targetDz;
389 f32 dx;
390 f32 dz;
391 s32 ret;
392
393 radius = playerStatus->colliderDiameter * 0.5f;
394 ret = NO_COLLIDER;
395
396 if (!(playerStatus->flags & (PS_FLAG_FALLING | PS_FLAG_JUMPING))) {
397 height = playerStatus->colliderHeight * 0.286f;
398 } else {
399 height = 1.0f;
400 }
401
402 sin_cos_rad(DEG_TO_RAD(yaw), &sinTheta, &cosTheta);
403 cosTheta = -cosTheta;
404 hitDepth = length + radius;
405 hitID = player_raycast_general(mode, *x, *y + height, *z, sinTheta, 0, cosTheta, &hitX, &hitY, &hitZ, &hitDepth, &hitNx, &hitNy, &hitNz);
406
407 if (mode == PLAYER_COLLISION_HAMMER) {
408 targetDx = 0.0f;
409 targetDz = 0.0f;
410 } else {
411 targetDx = length * sinTheta;
412 targetDz = length * cosTheta;
413 }
414
415 if (hitID > NO_COLLIDER) {
416 originalDepth = length + radius;
417 if (hitDepth <= originalDepth) {
418 depthDiff = hitDepth - originalDepth;
419 dx = depthDiff * sinTheta;
420 dz = depthDiff * cosTheta;
421
422 player_get_slip_vector(&slipDx, &slipDz, targetDx, targetDz, hitNx, hitNz);
423 *x += dx + slipDx;
424 *z += dz + slipDz;
425 ret = hitID;
426 }
427 }
428
429 *x += targetDx;
430 *z += targetDz;
431 return ret;
432}
HitID player_raycast_general(s32, f32, f32, f32, f32, f32, f32, f32 *, f32 *, f32 *, f32 *, f32 *, f32 *, f32 *)
Definition 77480.c:434
void player_get_slip_vector(f32 *outX, f32 *outY, f32 x, f32 y, f32 nX, f32 nY)
Definition 77480.c:556
@ PS_FLAG_FALLING
Definition enums.h:3036
@ PLAYER_COLLISION_HAMMER
Definition enums.h:4714

Referenced by action_hammer_end_swing(), action_hammer_test_swing_collision(), check_for_treadmill_overlaps(), collision_check_player_intersecting_world(), collision_check_player_overlaps(), collision_lava_reset_check_additional_overlaps(), collision_main_lateral(), func_800E4404(), and peach_disguise_check_overlaps().

◆ peach_make_disguise_npc()

Npc * peach_make_disguise_npc ( s32 peachDisguise)

Definition at line 573 of file 7E9D0.c.

573 {
574 PlayerStatus* playerStatus = &gPlayerStatus;
575 NpcBlueprint bp;
576 NpcBlueprint* bpPtr = &bp;
577 Npc* npc;
578 f32 yaw;
579
580 if (peachDisguise == PEACH_DISGUISE_NONE) {
581 return NULL;
582 }
583
584 playerStatus->colliderHeight = 37;
585 playerStatus->colliderDiameter = 38;
586 playerStatus->peachDisguise = peachDisguise;
587 gGameStatusPtr->peachDisguise = peachDisguise;
588
591 bpPtr->onUpdate = NULL;
592 bpPtr->onRender = NULL;
593
596
598
599 if (!(playerStatus->spriteFacingAngle >= 90.0f) || !(playerStatus->spriteFacingAngle < 270.0f)) {
600 yaw = 180.0f;
601 } else {
602 yaw = 0.0f;
603 }
604
605 set_npc_yaw(npc, yaw);
606
607 npc->pos.x = playerStatus->pos.x;
608 npc->pos.y = playerStatus->pos.y;
609 npc->pos.z = playerStatus->pos.z;
610
611 return npc;
612}
DisguiseAnims BasicPeachDisguiseAnims[]
Definition 7E9D0.c:464
AnimID * PeachDisguiseExtraAnims[]
Definition 7E9D0.c:499
@ PEACH_DISGUISE_NONE
Definition enums.h:2518
@ NPC_FLAG_FLYING
Definition enums.h:3001
@ NPC_FLAG_IGNORE_WORLD_COLLISION
Definition enums.h:3004
@ NPC_FLAG_IGNORE_PLAYER_COLLISION
Definition enums.h:3006
@ NPC_FLAG_IGNORE_CAMERA_FOR_YAW
Definition enums.h:3016
s32 create_standard_npc(NpcBlueprint *blueprint, AnimID *animList)
Definition npc.c:194
void disable_npc_shadow(Npc *npc)
Definition npc.c:1036
Npc * get_npc_by_index(s32 listIndex)
Definition npc.c:271
void set_npc_yaw(Npc *npc, f32 yaw)
Definition npc.c:1245
void(* onRender)(struct Npc *)
Definition npc.h:89
void(* onUpdate)(struct Npc *)
Definition npc.h:88
s32 initialAnim
Definition npc.h:87
s32 flags
Definition npc.h:86
s32 PeachDisguiseNpcIndex
Definition 7B440.c:4

Referenced by action_update_parasol(), and peach_check_for_parasol_input().

◆ peach_set_disguise_anim()

void peach_set_disguise_anim ( AnimID anim)

Definition at line 506 of file 7E9D0.c.

506 {
507 s32 listIndex = PeachDisguiseNpcIndex;
508
509 if (listIndex >= 0) {
510 get_npc_by_index(listIndex)->curAnim = anim;
511 }
512}
AnimID curAnim

Referenced by action_update_idle_peach(), action_update_step_up_set_peach_anim(), action_update_talk(), action_update_walk_set_peach_anim(), and get_overriding_player_anim().

◆ draw_box()

s32 draw_box ( s32 flags,
WindowStyle windowStyle,
s32 posX,
s32 posY,
s32 posZ,
s32 width,
s32 height,
u8 opacity,
u8 darkening,
f32 scaleX,
f32 scaleY,
f32 rotX,
f32 rotY,
f32 rotZ,
void(*)(s32, s32, s32, s32, s32, s32, s32) fpDrawContents,
void * drawContentsArg0,
Matrix4f rotScaleMtx,
s32 translateX,
s32 translateY,
Matrix4f outMtx )

Definition at line 337 of file draw_box.c.

341{
342 Matrix4f mtx1, mtx2, mtx3;
343 u8 primR, primG, primB, primA, envR, envG, envB, envA;
344 DefaultWindowStyle* defaultStyle = NULL;
345 WindowStyleCustom* customStyle = NULL;
346 WindowCorners* corners;
347 WindowBackground* background;
348 u32 bgWidth, bgHeight;
349 u32 cornerWidth, cornerHeight;
350 s32 masks, maskt;
351 Vtx* quads;
352 s32 idx;
353 s32 i, j;
354 s32 tmem = 0x100;
355 u32 bgScrollOffsetX, bgScrollOffsetY;
356
357 s32 foo;
358 s32 alpha = foo * opacity / 255;
359
360 if (windowStyle.defaultStyleID <= WINDOW_STYLE_MAX && windowStyle.defaultStyleID >= 0) {
361 defaultStyle = &gBoxDefaultStyles[windowStyle.defaultStyleID];
362
363 primR = defaultStyle->color1.r;
364 primG = defaultStyle->color1.g;
365 primB = defaultStyle->color1.b;
366 primA = defaultStyle->color1.a * opacity / 255;
367 envR = defaultStyle->color2.r;
368 envG = defaultStyle->color2.g;
369 envB = defaultStyle->color2.b;
370 envA = defaultStyle->color2.a;
371
372 background = &gBoxBackground[defaultStyle->bgIndex];
373 corners = &gBoxCorners[defaultStyle->cornersIndex];
374 } else {
375 primR = windowStyle.customStyle->color1.r;
376 primG = windowStyle.customStyle->color1.g;
377 primB = windowStyle.customStyle->color1.b;
378 primA = windowStyle.customStyle->color1.a * opacity / 255;
379 envR = windowStyle.customStyle->color2.r;
380 envG = windowStyle.customStyle->color2.g;
381 envB = windowStyle.customStyle->color2.b;
382 envA = windowStyle.customStyle->color2.a;
383
384 customStyle = windowStyle.customStyle;
385 background = &windowStyle.customStyle->background;
386 corners = &windowStyle.customStyle->corners;
387 }
388 {
389 u8* bgImage;
390 u8* cornersImage;
391 s32 bgFmt;
392 s32 bgMasks;
393 s32 bgMaskt;
394 Vec2bu* cornersSizes;
395 u32 cornersFmt;
396 u32 cornersBitDepth;
397 Mtx* sp154;
398
399 bgFmt = background->fmt;
400 cornersImage = corners->imgData;
401
402 bgWidth = background->width;
403 bgImage = background->imgData;
404 bgHeight = background->height;
405
406 bgMasks = INTEGER_LOG2(bgWidth);
407 bgMaskt = INTEGER_LOG2(bgHeight);
408
409 quads = NULL;
410 sp154 = NULL;
411 cornersSizes = (Vec2bu*)&corners->size1;
412 cornersFmt = corners->fmt;
413 cornersBitDepth = corners->bitDepth;
414
415 if (width <= 0 || height <= 0 || opacity == 0 || posX <= -768 || posY <= -768) {
416 return TRUE;
417 }
418
419 if (posX >= SCREEN_WIDTH || posY >= SCREEN_HEIGHT) {
420 return TRUE;
421 }
422
423 if (posX + width >= 768 || posY + height >= 768 || posX + width <= 0 || posY + height <= 0) {
424 return TRUE;
425 }
426
428 quads = gBoxQuadBuffer[gBoxQuadIndex++];
430 gBoxQuadIndex = 0;
431 }
432 }
433
434 gDPPipeSync(gMainGfxPos++);
435 gDPSetCycleType(gMainGfxPos++, G_CYC_2CYCLE);
436 gDPSetBlendColor(gMainGfxPos++, 0, 0, 0, 0);
437 gDPSetFogColor(gMainGfxPos++, 0, 0, 0, darkening);
438 gDPSetRenderMode(gMainGfxPos++, PM_RM_SHROUD, G_RM_XLU_SURF2);
439 if (!(flags & DRAW_FLAG_NO_CLIP)) {
440 gDPSetScissor(gMainGfxPos++, G_SC_NON_INTERLACE, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT);
441 }
442
443 if (defaultStyle != NULL) {
444 Gfx* gfxPos = gMainGfxPos;
445 *gfxPos = gBoxCombineModes[defaultStyle->combineModeIndex + (primA != 255 ? 2 : 0)];
446 } else {
447 Gfx* gfxPos = gMainGfxPos;
448 if (primA != 255) {
449 *gfxPos = customStyle->transparentCombineMode;
450 } else {
451 *gfxPos = customStyle->opaqueCombineMode;
452 }
453 }
454
455 gMainGfxPos++;
456 gDPSetTextureFilter(gMainGfxPos++, G_TF_POINT);
457
458 if (quads != NULL) {
459 gSPViewport(gMainGfxPos++, &gBoxViewport);
460 guFrustumF(mtx1, -80.0f, 80.0f, 60.0f, -60.0f, 160.0f, 480.0f, 1.0f);
463 gSPMatrix(gMainGfxPos++, &gDisplayContext->matrixStack[gMatrixListPos++], G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_PROJECTION);
464 guPositionF(mtx1, rotX, rotY, rotZ, 1.0f, posX + width / 2, posY + height / 2, posZ);
465 if (scaleX != 1.0f || scaleY != 1.0f) {
466 guScaleF(mtx2, scaleX, scaleY, 1.0f);
467 guMtxCatF(mtx2, mtx1, mtx1);
468 }
469 if (rotScaleMtx != 0) {
470 guTranslateF(mtx2, -translateX / 2, -translateY / 2, 0.0f);
471 guMtxCatF(mtx1, mtx2, mtx2);
472 guMtxCatF(mtx2, rotScaleMtx, mtx1);
473 }
474 if (outMtx) {
475 for (i = 0; i < 4; i++) {
476 for (j = 0; j < 4; j++) {
477 outMtx[i][j] = mtx1[i][j];
478 }
479 }
480 }
481 guTranslateF(mtx2, -160.0f, -120.0f, -320.0f);
482 guMtxCatF(mtx1, mtx2, mtx1);
483 gSPClearGeometryMode(gMainGfxPos++, G_CULL_BOTH | G_LIGHTING);
485 gSPSetGeometryMode(gMainGfxPos++, G_CULL_BACK);
486 }
488 gSPMatrix(gMainGfxPos++, &gDisplayContext->matrixStack[gMatrixListPos++], G_MTX_PUSH | G_MTX_LOAD | G_MTX_MODELVIEW);
489 gDPSetTexturePersp(gMainGfxPos++, G_TP_PERSP);
490 gSPPerspNormalize(gMainGfxPos++, 20);
491 } else {
492 gDPSetTexturePersp(gMainGfxPos++, G_TP_NONE);
493 }
494
495 gSPTexture(gMainGfxPos++, 0xFFFF, 0xFFFF, 0, G_TX_RENDERTILE, G_ON);
496 gDPSetTextureLUT(gMainGfxPos++, G_TT_NONE);
497 gDPSetTextureDetail(gMainGfxPos++, G_TD_CLAMP);
498 gDPSetTextureLOD(gMainGfxPos++, G_TL_TILE);
499 gDPSetPrimColor(gMainGfxPos++, 0, 0, primR, primG, primB, primA);
500 gDPSetEnvColor(gMainGfxPos++, envR, envG, envB, envA);
501 if (bgImage != NULL) {
502 switch (background->bitDepth) {
503 case G_IM_SIZ_4b:
504 gDPLoadTextureTile_4b(gMainGfxPos++, bgImage, bgFmt, bgWidth, bgHeight, 0, 0, bgWidth - 1, bgHeight - 1, 0, G_TX_WRAP, G_TX_WRAP, bgMasks, bgMaskt, G_TX_NOLOD, G_TX_NOLOD);
505 break;
506 case G_IM_SIZ_8b:
507 gDPLoadTextureTile(gMainGfxPos++, bgImage, bgFmt, G_IM_SIZ_8b, bgWidth, bgHeight, 0, 0, bgWidth - 1, bgHeight - 1, 0, G_TX_WRAP, G_TX_WRAP, bgMasks, bgMaskt, G_TX_NOLOD, G_TX_NOLOD);
508 break;
509 case G_IM_SIZ_16b:
510 gDPLoadTextureTile(gMainGfxPos++, bgImage, bgFmt, G_IM_SIZ_16b, bgWidth, bgHeight, 0, 0, bgWidth - 1, bgHeight - 1, 0, G_TX_WRAP, G_TX_WRAP, bgMasks, bgMaskt, G_TX_NOLOD, G_TX_NOLOD);
511 break;
512 case G_IM_SIZ_32b:
513 gDPLoadTextureTile(gMainGfxPos++, bgImage, bgFmt, G_IM_SIZ_32b, bgWidth, bgHeight, 0, 0, bgWidth - 1, bgHeight - 1, 0, G_TX_WRAP, G_TX_WRAP, bgMasks, bgMaskt, G_TX_NOLOD, G_TX_NOLOD);
514 break;
515 }
516
518 bgScrollOffsetY = (gGameStatusPtr->frameCounter * 4) & 0x1FF;
519 bgScrollOffsetX = 511 - bgScrollOffsetY;
520 gDPSetTileSize(gMainGfxPos++, G_TX_RENDERTILE,
521 width / 2 * 4 + bgScrollOffsetX,
522 height / 2 * 4 + bgScrollOffsetY,
523 (width / 2 + bgWidth - 1) * 4 + bgScrollOffsetX,
524 (height / 2 + bgHeight - 1) * 4 + bgScrollOffsetY);
525 } else {
526 gDPSetTileSize(gMainGfxPos++, G_TX_RENDERTILE, width / 2 * 4, height / 2 * 4,
527 (width / 2 + bgWidth - 1) * 4, (height / 2 + bgHeight - 1)* 4);
528 }
529 }
530
531 if (cornersImage != NULL) {
532 for (idx = 0; idx < 4; idx++) {
533 cornerWidth = cornersSizes[idx].x;
534 cornerHeight = cornersSizes[idx].y;
535 masks = INTEGER_LOG2(cornerWidth);
536 maskt = INTEGER_LOG2(cornerHeight);
537
538 switch (cornersBitDepth) {
539 case G_IM_SIZ_4b:
540 gDPLoadMultiTile_4b(gMainGfxPos++, cornersImage, tmem, 1, cornersFmt, cornerWidth, cornerHeight, 0, 0, cornerWidth - 1, cornerHeight - 1, 0, G_TX_CLAMP, G_TX_CLAMP, masks, maskt, G_TX_NOLOD, G_TX_NOLOD);
541 cornersImage += cornerWidth * cornerHeight / 2;
542 break;
543 case G_IM_SIZ_8b:
544 gDPLoadMultiTile(gMainGfxPos++, cornersImage, tmem, 1, cornersFmt, G_IM_SIZ_8b, cornerWidth, cornerHeight, 0, 0, cornerWidth - 1, cornerHeight - 1, 0, G_TX_CLAMP, G_TX_CLAMP, masks, maskt, G_TX_NOLOD, G_TX_NOLOD);
545 cornersImage += cornerWidth * cornerHeight;
546 break;
547 case G_IM_SIZ_16b:
548 gDPLoadMultiTile(gMainGfxPos++, cornersImage, tmem, 1, cornersFmt, G_IM_SIZ_16b, cornerWidth, cornerHeight, 0, 0, cornerWidth - 1, cornerHeight - 1, 0, G_TX_CLAMP, G_TX_CLAMP, masks, maskt, G_TX_NOLOD, G_TX_NOLOD);
549 cornersImage += cornerWidth * cornerHeight * 2;
550 break;
551 case G_IM_SIZ_32b:
552 gDPLoadMultiTile(gMainGfxPos++, cornersImage, tmem, 1, cornersFmt, G_IM_SIZ_32b, cornerWidth, cornerHeight, 0, 0, cornerWidth - 1, cornerHeight - 1, 0, G_TX_CLAMP, G_TX_CLAMP, masks, maskt, G_TX_NOLOD, G_TX_NOLOD);
553 cornersImage += cornerWidth * cornerHeight * 4;
554 break;
555 }
556
557 switch(idx) {
558 case 1:
559 gDPSetTileSize(gMainGfxPos++, 1, (width - cornerWidth) * 4, 0, (width - 1) * 4, (cornerHeight - 1) * 4);
560 break;
561 case 2:
562 gDPSetTileSize(gMainGfxPos++, 1, 0, (height - cornerHeight) * 4, (cornerWidth - 1) * 4, (height - 1) * 4);
563 break;
564 case 3:
565 gDPSetTileSize(gMainGfxPos++, 1, (width - cornerWidth) * 4, (height - cornerHeight) * 4, (width - 1) * 4, (height - 1) * 4);
566 break;
567 }
568
569 if (quads != NULL) {
570 switch(idx) {
571 case 0:
572 quads[0].v.ob[0] = -width / 2;
573 quads[0].v.ob[1] = -height / 2;
574 quads[0].v.ob[2] = 0;
575
576 quads[1].v.ob[0] = 0;
577 quads[1].v.ob[1] = -height / 2;
578 quads[1].v.ob[2] = 0;
579
580 quads[2].v.ob[0] = -width / 2;
581 quads[2].v.ob[1] = 0;
582 quads[2].v.ob[2] = 0;
583
584 quads[3].v.ob[0] = 0;
585 quads[3].v.ob[1] = 0;
586 quads[3].v.ob[2] = 0;
587
588 quads[0].v.tc[0] = 0;
589 quads[0].v.tc[1] = 0;
590
591 quads[1].v.tc[0] = (width / 2) * 32;
592 quads[1].v.tc[1] = 0;
593
594 quads[2].v.tc[0] = 0;
595 quads[2].v.tc[1] = (height / 2) * 32;
596
597 quads[3].v.tc[0] = (width / 2) * 32;
598 quads[3].v.tc[1] = (height / 2) * 32;
599 break;
600 case 1:
601 quads[4].v.ob[0] = 0;
602 quads[4].v.ob[1] = -height / 2;
603 quads[4].v.ob[2] = 0;
604
605 quads[5].v.ob[0] = (-width / 2) + width;
606 quads[5].v.ob[1] = -height / 2;
607 quads[5].v.ob[2] = 0;
608
609 quads[6].v.ob[0] = 0;
610 quads[6].v.ob[1] = 0;
611 quads[6].v.ob[2] = 0;
612
613 quads[7].v.ob[0] = (-width / 2) + width;
614 quads[7].v.ob[1] = 0;
615 quads[7].v.ob[2] = 0;
616
617 quads[4].v.tc[0] = (width / 2) * 32;
618 quads[4].v.tc[1] = 0;
619
620 quads[5].v.tc[0] = width * 32;
621 quads[5].v.tc[1] = 0;
622
623 quads[6].v.tc[0] = (width / 2) * 32;
624 quads[6].v.tc[1] = (height / 2) * 32;
625
626 quads[7].v.tc[0] = width * 32;
627 quads[7].v.tc[1] = (height / 2) * 32;
628
629#ifndef SHIFT
630 quads += 4;
631#endif
632 break;
633 case 2:
634 quads[8].v.ob[0] = -width / 2;
635 quads[8].v.ob[1] = 0;
636 quads[8].v.ob[2] = 0;
637
638 quads[9].v.ob[0] = 0;
639 quads[9].v.ob[1] = 0;
640 quads[9].v.ob[2] = 0;
641
642 quads[10].v.ob[0] = -width / 2;
643 quads[10].v.ob[1] = height / 2;
644 quads[10].v.ob[2] = 0;
645
646 quads[11].v.ob[0] = 0;
647 quads[11].v.ob[1] = height / 2;
648 quads[11].v.ob[2] = 0;
649
650 quads[8].v.tc[0] = 0;
651 quads[8].v.tc[1] = (height / 2) * 32;
652
653 quads[9].v.tc[0] = (width / 2) * 32;
654 quads[9].v.tc[1] = (height / 2) * 32;
655
656 quads[10].v.tc[0] = 0;
657 quads[10].v.tc[1] = height * 32;
658
659 quads[11].v.tc[0] = (width / 2) * 32;
660 quads[11].v.tc[1] = height * 32;
661
662#ifndef SHIFT
663 quads += 8;
664#endif
665 break;
666 case 3:
667 quads[12].v.ob[0] = 0;
668 quads[12].v.ob[1] = 0;
669 quads[12].v.ob[2] = 0;
670
671 quads[13].v.ob[0] = (-width / 2) + width;
672 quads[13].v.ob[1] = 0;
673 quads[13].v.ob[2] = 0;
674
675 quads[14].v.ob[0] = 0;
676 quads[14].v.ob[1] = height / 2;
677 quads[14].v.ob[2] = 0;
678
679 quads[15].v.ob[0] = (-width / 2) + width;
680 quads[15].v.ob[1] = height / 2;
681 quads[15].v.ob[2] = 0;
682
683 quads[12].v.tc[0] = (width / 2) * 32;
684 quads[12].v.tc[1] = (height / 2) * 32;
685
686 quads[13].v.tc[0] = width * 32;
687 quads[13].v.tc[1] = (height / 2) * 32;
688
689 quads[14].v.tc[0] = (width / 2) * 32;
690 quads[14].v.tc[1] = height * 32;
691
692 quads[15].v.tc[0] = width * 32;
693 quads[15].v.tc[1] = height * 32;
694
695#ifndef SHIFT
696 quads += 12;
697#endif
698 break;
699 }
700#ifdef SHIFT
701 gSPVertex(gMainGfxPos++, &quads[idx*4], 4, 0);
702#else
703 gSPVertex(gMainGfxPos++, quads, 4, 0);
704#endif
705 gSP2Triangles(gMainGfxPos++, 0, 3, 1, 0, 0, 2, 3, 0);
706 } else {
707 switch (idx) {
708 case 0:
709 gSPScisTextureRectangle(gMainGfxPos++, posX * 4, posY * 4, (posX + width / 2) * 4, (posY + height / 2) * 4, G_TX_RENDERTILE, 0, 0, 0x400, 0x400);
710 break;
711 case 1:
712 gSPScisTextureRectangle(gMainGfxPos++, (posX + width / 2) * 4, posY * 4, (posX + width) * 4, (posY + height / 2) * 4, G_TX_RENDERTILE, (width / 2) * 32, 0, 0x400, 0x400);
713 break;
714 case 2:
715 gSPScisTextureRectangle(gMainGfxPos++, posX * 4, (posY + height / 2) * 4, (posX + width / 2) * 4, (posY + height) * 4, G_TX_RENDERTILE, 0, (height / 2) * 32, 0x400, 0x400);
716 break;
717 case 3:
718 gSPScisTextureRectangle(gMainGfxPos++, (posX + width / 2) * 4, (posY + height / 2) * 4, (posX + width) * 4, (posY + height) * 4, G_TX_RENDERTILE, (width / 2) * 32, (height / 2) * 32, 0x400, 0x400);
719 break;
720 }
721
722 }
723 gDPPipeSync(gMainGfxPos++);
724 }
725 } else if (bgImage != NULL) {
726 if (quads != NULL) {
727 quads[0].v.ob[0] = -width / 2;
728 quads[0].v.ob[1] = -height / 2;
729 quads[0].v.ob[2] = 0;
730
731 quads[1].v.ob[0] = (-width / 2) + width;
732 quads[1].v.ob[1] = -height / 2;
733 quads[1].v.ob[2] = 0;
734
735 quads[2].v.ob[0] = -width / 2;
736 quads[2].v.ob[1] = height / 2;
737 quads[2].v.ob[2] = 0;
738
739 quads[3].v.ob[0] = (-width / 2) + width;
740 quads[3].v.ob[1] = height / 2;
741 quads[3].v.ob[2] = 0;
742
743 quads[0].v.tc[0] = 0;
744 quads[0].v.tc[1] = 0;
745
746 quads[1].v.tc[1] = 0;
747 quads[1].v.tc[0] = width * 32;
748
749 quads[2].v.tc[0] = 0;
750 quads[2].v.tc[1] = height * 32;
751
752 quads[3].v.tc[0] = width * 32;
753 quads[3].v.tc[1] = height * 32;
754
755 gSPVertex(gMainGfxPos++, &quads[0], 4, 0);
756 gSP2Triangles(gMainGfxPos++, 0, 3, 1, 0, 0, 2, 3, 0);
757 } else {
758 gSPScisTextureRectangle(gMainGfxPos++, posX * 4, posY * 4, (posX + width) * 4, (posY + height) * 4, G_TX_RENDERTILE, 0, 0, 0x0400, 0x0400);
759 }
760 gDPPipeSync(gMainGfxPos++);
761 }
762
763 gDPSetTexturePersp(gMainGfxPos++, G_TP_NONE);
764 gDPSetCycleType(gMainGfxPos++, G_CYC_1CYCLE);
765 if(fpDrawContents != NULL) {
766 if (quads != NULL) {
767 void* mdl_address = mdl_get_next_texture_address(width * height * 2);
768 if(mdl_address != 0) {
769 gDPSetColorImage(gMainGfxPos++, G_IM_FMT_RGBA, G_IM_SIZ_16b, width, OS_K0_TO_PHYSICAL(mdl_address));
770 gDPSetScissor(gMainGfxPos++, G_SC_NON_INTERLACE, 0, 0, width, height);
771 gDPSetCycleType(gMainGfxPos++, G_CYC_FILL);
772 gDPSetFillColor(gMainGfxPos++, PACK_FILL_COLOR(primR, primG, primB, 0));
773 gDPSetRenderMode(gMainGfxPos++, G_RM_NOOP, G_RM_NOOP2);
774 gDPFillRectangle(gMainGfxPos++, 0, 0, width - 1, height - 1);
775 gDPPipeSync(gMainGfxPos++);
776 gDPSetScissorFrac(gMainGfxPos++, G_SC_NON_INTERLACE, 4, 4, (width - 1) * 4.0f, (height - 1) * 4.0f);
777 gDPSetCycleType(gMainGfxPos++, G_CYC_1CYCLE);
778
779 fpDrawContents((s32)drawContentsArg0, 0, 0, width, height, opacity, darkening);
780
781 gDPPipeSync(gMainGfxPos++);
782 gDPSetColorImage(gMainGfxPos++, G_IM_FMT_RGBA, G_IM_SIZ_16b, 320, OS_K0_TO_PHYSICAL(nuGfxCfb_ptr));
783 gDPSetScissor(gMainGfxPos++, G_SC_NON_INTERLACE, 0, 0, 320, 240);
784 gSPViewport(gMainGfxPos++, &gBoxViewport);
785 gSPMatrix(gMainGfxPos++, sp154, G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_PROJECTION);
786 gSPTexture(gMainGfxPos++, 0xFFFF, 0xFFFF, 0, G_TX_RENDERTILE, G_ON);
787 gDPSetCycleType(gMainGfxPos++, G_CYC_1CYCLE);
788 gDPSetTextureLUT(gMainGfxPos++, G_TT_NONE);
789 gDPSetCombineMode(gMainGfxPos++, G_CC_DECALRGBA, G_CC_DECALRGBA);
790 gDPSetRenderMode(gMainGfxPos++, G_RM_CLD_SURF, G_RM_NOOP2);
791 gDPSetTexturePersp(gMainGfxPos++, G_TP_PERSP);
792 gDPSetTextureFilter(gMainGfxPos++, G_TF_BILERP);
793 guTranslateF(mtx3, 0.0f, 6.0f, 0.0f);
794 guMtxF2L(mtx3, &gBoxMatrix);
795 guTranslateF(mtx3, 0.0f, -height / 2, 0.0f);
797 gSPMatrix(gMainGfxPos++, &gDisplayContext->matrixStack[gMatrixListPos++], G_MTX_NOPUSH | G_MTX_MUL | G_MTX_MODELVIEW);
798 for (idx = 0; idx < height / 6; idx++) {
799 s32 extraHeight, lineHeight;
800 if (idx == height / 6 - 1) {
801 extraHeight = 0;
802 if (height % 6 != 0) {
803 extraHeight = 1;
804 }
805 } else {
806 extraHeight = 1;
807 }
808 lineHeight = extraHeight + 5;
809 gDPLoadTextureTile(gMainGfxPos++, OS_K0_TO_PHYSICAL(mdl_address), G_IM_FMT_RGBA, G_IM_SIZ_16b, width, 0,
810 0, idx * 6, width - 1, idx * 6 + lineHeight, 0,
811 G_TX_CLAMP, G_TX_CLAMP, 9, 3, G_TX_NOLOD, G_TX_NOLOD);
812 gDPSetTileSize(gMainGfxPos++, G_TX_RENDERTILE, (160 - width / 2) * 4, 0, ((160 - width / 2) + width - 1) * 4, lineHeight * 4);
813 gSPVertex(gMainGfxPos++, &vtx_drawbox1, 4, 0);
814 gSP2Triangles(gMainGfxPos++, 0, 3, 1, 0, 0, 2, 3, 0);
815 gDPPipeSync(gMainGfxPos++);
816 gSPMatrix(gMainGfxPos++, &gBoxMatrix, G_MTX_NOPUSH | G_MTX_MUL | G_MTX_MODELVIEW);
817 }
818 }
819 } else {
820 fpDrawContents((s32)drawContentsArg0, posX, posY, width, height, opacity, darkening);
821 }
822 }
823 if (quads != NULL) {
824 gSPPopMatrix(gMainGfxPos++, G_MTX_MODELVIEW);
825 gDPSetTexturePersp(gMainGfxPos++, G_TP_NONE);
826 gDPPipeSync(gMainGfxPos++);
827 }
828 return FALSE;
829 }
830}
WindowCorners corners
DefaultWindowStyle gBoxDefaultStyles[]
Definition draw_box.c:18
Mtx gBoxMatrix
Definition draw_box.c:326
BSS Vtx gBoxQuadBuffer[21][16]
Definition draw_box.c:16
WindowCorners gBoxCorners[]
Definition draw_box.c:215
#define BOX_QUAD_BUFFER_NUM
Definition draw_box.c:15
#define INTEGER_LOG2(x)
Definition draw_box.c:5
Vp gBoxViewport
Definition draw_box.c:317
s32 gBoxQuadIndex
Definition draw_box.c:315
Color_RGBA8 color1
Definition draw_box.c:11
WindowBackground gBoxBackground[]
Definition draw_box.c:194
Gfx gBoxCombineModes[]
Definition draw_box.c:308
Color_RGBA8 color2
Definition draw_box.c:12
#define guFrustumF
#define guPositionF
@ WINDOW_STYLE_MAX
Definition enums.h:6392
@ DRAW_FLAG_NO_CLIP
Definition enums.h:5004
@ DRAW_FLAG_ROTSCALE
Definition enums.h:5002
@ DRAW_FLAG_CULL_BACK
Definition enums.h:5005
@ DRAW_FLAG_ANIMATED_BACKGROUND
Definition enums.h:5003
void * mdl_get_next_texture_address(s32)
Definition model.c:4507
#define PM_RM_SHROUD
Definition macros.h:278
#define PACK_FILL_COLOR(r, g, b, a)
Definition macros.h:167

◆ get_msg_width()

s32 get_msg_width ( s32 msgID,
u16 charset )

Definition at line 1971 of file msg.c.

1971 {
1972 s32 width;
1973
1974 get_msg_properties(msgID, NULL, &width, NULL, NULL, NULL, NULL, charset);
1975 return width;
1976}
void get_msg_properties(s32 msgID, s32 *height, s32 *width, s32 *maxLineChars, s32 *numLines, s32 *maxLinesPerPage, s32 *numSpaces, u16 charset)
Definition msg.c:1671

◆ partner_can_open_world_menus()

s32 partner_can_open_world_menus ( void )

Definition at line 983 of file partners.c.

983 {
984 if (wPartner != NULL
985 && wPartner->canPlayerOpenMenus != NULL
987 ) {
988 return FALSE;
989 }
990 return TRUE;
991}
BSS WorldPartner * wPartner
Definition partners.c:62
Npc * wPartnerNpc
Definition partners.c:43
PartnerBoolFunc canPlayerOpenMenus
Definition partners.h:21

Referenced by can_open_world_menu(), and should_cancel_open_world_menu().

◆ disable_player_static_collisions()

◆ disable_player_input()

◆ func_80027088()

void func_80027088 ( s32 )

◆ set_time_freeze_mode()

void set_time_freeze_mode ( s32 mode)

Time freeze modes: 0: none 1: NPCs move, can't be interacted with 2: NPCs don't move, no partner ability, can't interact, can't use exits 3: NPCs don't more or animate 4: NPCs can move, animations don't update, can use exits.

Definition at line 358 of file main_loop.c.

358 {
359 switch (mode) {
360 case TIME_FREEZE_NONE:
361 gTimeFreezeMode = mode;
364 break;
366 gTimeFreezeMode = mode;
370 break;
371 case TIME_FREEZE_FULL:
372 gTimeFreezeMode = mode;
376 break;
378 gTimeFreezeMode = mode;
379 gOverrideFlags &= ~GLOBAL_OVERRIDES_800;
382 break;
383 case TIME_FREEZE_EXIT:
384 gTimeFreezeMode = mode;
386 break;
387 }
388}
@ TIME_FREEZE_FULL
Definition enums.h:3466
@ TIME_FREEZE_POPUP_MENU
Definition enums.h:3467
@ TIME_FREEZE_EXIT
Definition enums.h:3468
@ EVT_GROUP_FLAG_MENUS
Definition evt.h:135
@ EVT_GROUP_FLAG_INTERACT
Definition evt.h:134
s32 resume_all_group(s32 groupFlags)
void suspend_all_group(s32 groupFlags)

Referenced by _use_partner_ability(), action_update_parasol(), check_input_open_menus(), entity_HeartBlock_show_tutorial_message(), entity_HeartBlock_wait_for_close_tutorial(), entity_HeartBlockContent__anim_heal(), entity_HeartBlockContent_anim_idle(), entity_HiddenPanel_flip_over(), entity_SaveBlock_pause_game(), entity_SaveBlock_resume_game(), pre_battle(), state_init_file_select(), state_init_pause(), state_step_battle(), state_step_change_map(), state_step_end_battle(), state_step_enter_world(), state_step_exit_file_select(), state_step_unpause(), and update_item_entity_pickup().

◆ get_map_IDs_by_name()

s32 get_map_IDs_by_name ( const char * mapName,
s16 * areaID,
s16 * mapID )

Definition at line 228 of file world.c.

228 {
229 s32 i;
230 s32 j;
231 MapConfig* maps;
232
233 // TODO: Potentially a fake match? Difficult to not set the temp in the for conditional.
234 for (i = 0; (maps = gAreas[i].maps) != NULL; i++) {
235 for (j = 0; j < gAreas[i].mapCount; j++) {
236 if (strcmp(maps[j].id, mapName) == 0) {
237 *areaID = i;
238 *mapID = j;
239 return TRUE;
240 }
241 }
242 }
243
244 return FALSE;
245}
s32 mapCount
Definition map.h:55
MapConfig * maps
Definition map.h:56
AreaConfig gAreas[]
Zero-terminated.
Definition world.c:868

Referenced by get_map_IDs_by_name_checked().

◆ get_map_IDs_by_name_checked()

void get_map_IDs_by_name_checked ( const char * mapName,
s16 * areaID,
s16 * mapID )

Same as get_map_IDs_by_name, but will panic if the map doesn't exist.

Definition at line 247 of file world.c.

247 {
248 ASSERT_MSG(get_map_IDs_by_name(mapName, areaID, mapID), "Map not found: %s", mapName);
249}
#define ASSERT_MSG(condition, msg, args...)
Definition macros.h:66
NODISCARD s32 get_map_IDs_by_name(const char *mapName, s16 *areaID, s16 *mapID)
Definition world.c:228

Referenced by btl_state_update_end_battle(), filemenu_yesno_handle_input(), goto_map(), and state_step_demo().

◆ transform_point()

void transform_point ( Matrix4f mtx,
f32 inX,
f32 inY,
f32 inZ,
f32 inS,
f32 * outX,
f32 * outY,
f32 * outZ,
f32 * outW )

Definition at line 431 of file 43F0.c.

431 {
432 *outX = (mtx[0][0] * inX) + (mtx[1][0] * inY) + (mtx[2][0] * inZ) + mtx[3][0];
433 *outY = (mtx[0][1] * inX) + (mtx[1][1] * inY) + (mtx[2][1] * inZ) + mtx[3][1];
434 *outZ = (mtx[0][2] * inX) + (mtx[1][2] * inY) + (mtx[2][2] * inZ) + mtx[3][2];
435 *outW = (mtx[0][3] * inX) + (mtx[1][3] * inY) + (mtx[2][3] * inZ) + mtx[3][3];
436}

◆ try_player_footstep_sounds()

void try_player_footstep_sounds ( s32 arg0)

Definition at line 1105 of file 7BB60.c.

1105 {
1106 if (gGameStatusPtr->frameCounter % interval == 0) {
1108 s32 soundID, altSoundID;
1109
1110 if (surfaceType == SURFACE_TYPE_FLOWERS || surfaceType == SURFACE_TYPE_HEDGES) {
1111 soundID = SOUND_STEP_CRUNCHY1;
1112 altSoundID = SOUND_STEP_CRUNCHY2;
1113 } else {
1114 soundID = SOUND_STEP_NORMAL1;
1115 altSoundID = SOUND_STEP_NORMAL2;
1116 }
1117
1118 if (FootstepSoundSelector == 0) {
1119 soundID = altSoundID;
1120 }
1121
1124 }
1125}
s16 FootstepSoundSelector
Definition 7BB60.c:12
@ SURFACE_TYPE_HEDGES
used within hedge maze in flo_11
Definition enums.h:4678
@ SURFACE_TYPE_FLOWERS
Definition enums.h:4675
@ SOUND_STEP_NORMAL1
Definition enums.h:759
@ SOUND_STEP_CRUNCHY1
Definition enums.h:761
@ SOUND_STEP_CRUNCHY2
Definition enums.h:762
@ SOUND_STEP_NORMAL2
Definition enums.h:760
void sfx_play_sound_at_player(s32 soundID, s32 arg1)
Definition sfx.c:521

Referenced by action_update_run(), action_update_step_up_peach(), and action_update_walk().

◆ phys_update_interact_collider()

void phys_update_interact_collider ( void )

◆ phys_reset_spin_history()

void phys_reset_spin_history ( void )

Definition at line 95 of file 7E9D0.c.

95 {
96 s32 i;
97
100
101 for (i = 0; i < ARRAY_COUNT(gSpinHistoryPosAngle); i++) {
103 gSpinHistoryPosX[i] = 0;
104 gSpinHistoryPosY[i] = 0;
105 gSpinHistoryPosZ[i] = 0;
106 }
107
108 D_8010C964 = 0;
110}
s32 gSpinHistoryPosY[5]
Definition 7E9D0.c:27
s32 gSpinHistoryPosX[5]
Definition 7E9D0.c:26
void * LastLoadedActionOffset
Definition 7E9D0.c:21
s32 gSpinHistoryBufferPos
Definition 7E9D0.c:24
s16 gSpinHistoryPosAngle[5]
Definition 7E9D0.c:29
s32 D_8010C964
Definition 7E9D0.c:23
s32 gSpinHistoryPosZ[5]
Definition 7E9D0.c:28
PlayerSpinState gPlayerSpinState
Definition 7B440.c:11

Referenced by reset_player_status().

◆ phys_adjust_cam_on_landing()

s32 phys_adjust_cam_on_landing ( void )

Definition at line 46 of file 7E9D0.c.

46 {
48
49 if (LandingAdjustCamCallback != NULL) {
51 }
52
53 if (ret == LANDING_CAM_CHECK_SURFACE) {
55
56 if (surfaceType == SURFACE_TYPE_LAVA) {
59 } else {
60 gCameras[CAM_DEFAULT].moveFlags &= ~CAMERA_MOVE_IGNORE_PLAYER_Y;
61 }
64 } else {
65 gCameras[CAM_DEFAULT].moveFlags &= ~CAMERA_MOVE_NO_INTERP_Y;
66 }
67
68 return ret;
69}
s32(* LandingAdjustCamCallback)(void)
Definition 7E9D0.c:40
@ LANDING_CAM_NEVER_ADJUST
Definition enums.h:6418
@ LANDING_CAM_CHECK_SURFACE
Definition enums.h:6419
@ CAMERA_MOVE_IGNORE_PLAYER_Y
Definition enums.h:4731
@ CAMERA_MOVE_NO_INTERP_Y
Definition enums.h:4732
CollisionStatus gCollisionStatus
Definition 7BB60.c:6

Referenced by action_update_hit_lava(), action_update_jump(), action_update_land(), action_update_peach_land(), action_update_peach_step_down_land(), action_update_step_down_land(), action_update_step_up(), action_update_use_spinning_flower(), entity_CymbalPlant_idle(), phys_main_collision_below(), and phys_player_land().

◆ phys_should_player_be_sliding()

s32 phys_should_player_be_sliding ( void )

Definition at line 839 of file 7BB60.c.

839 {
840 if (PlayerSlidingCallback != NULL) {
841 return PlayerSlidingCallback();
842 }
843 return FALSE;
844}
b32(* PlayerSlidingCallback)(void)
Definition 7BB60.c:837

Referenced by check_input_jump(), and phys_main_collision_below().

◆ phys_init_integrator_for_current_state()

void phys_init_integrator_for_current_state ( void )

Definition at line 272 of file 7BB60.c.

Referenced by initialize_jump().

◆ phys_player_land()

void phys_player_land ( void )

Definition at line 369 of file 7BB60.c.

369 {
370 PlayerStatus* playerStatus = &gPlayerStatus;
371 CollisionStatus* collisionStatus = &gCollisionStatus;
372 f32 moveAngle;
373 f32 moveMagnitude;
374
375 playerStatus->timeInAir = 0;
376 playerStatus->peakJumpTime = 0;
377 playerStatus->flags &= ~PS_FLAG_SCRIPTED_FALL;
378 playerStatus->landPos.x = playerStatus->pos.x;
379 playerStatus->landPos.z = playerStatus->pos.z;
380 playerStatus->flags &= ~PS_FLAG_AIRBORNE;
382 if (!(collisionStatus->curFloor & COLLISION_WITH_ENTITY_BIT)) {
384 }
385
386 collisionStatus->lastTouchedFloor = -1;
387 if (collisionStatus->curFloor & COLLISION_WITH_ENTITY_BIT) {
388 s32 entityType = get_entity_type(collisionStatus->curFloor);
389
390 if (entityType <= ACTION_STATE_FALLING) {
391 if (entityType >= ACTION_STATE_LANDING_ON_SWITCH) {
392 Entity* entity = get_entity_by_index(collisionStatus->curFloor);
393
395 if (playerStatus->actionState != ACTION_STATE_TORNADO_JUMP
396 && playerStatus->actionState != ACTION_STATE_TORNADO_POUND
397 && playerStatus->actionState != ACTION_STATE_SPIN_JUMP
398 && playerStatus->actionState != ACTION_STATE_SPIN_POUND
399 ) {
401 } else {
403 playerStatus->actionSubstate = 11;
404 }
405 return;
406 }
407 }
408 }
409
410 if (playerStatus->flags & PS_FLAG_CUTSCENE_MOVEMENT) {
412 return;
413 }
414
415 if (playerStatus->actionState == ACTION_STATE_LANDING_ON_SWITCH) {
417 return;
418 }
419
420 player_input_to_move_vector(&moveAngle, &moveMagnitude);
421 if (moveMagnitude == 0.0f) {
422 if (playerStatus->actionState != ACTION_STATE_STEP_DOWN) {
424 } else {
426 }
427 return;
428 }
429
430 if (moveMagnitude != 0.0f) {
431 playerStatus->targetYaw = moveAngle;
432 }
434}
@ PS_FLAG_CUTSCENE_MOVEMENT
Definition enums.h:3054
@ SOUND_LAND_SOFTLY
Definition enums.h:765
@ ACTION_STATE_STEP_DOWN_LAND
Definition enums.h:2438
@ ACTION_STATE_BOUNCE_OFF_SWITCH
Small red/blue ! switches.
Definition enums.h:2460
Entity * get_entity_by_index(s32 index)
Definition entity.c:530
void update_locomotion_state(void)
Definition 7E9D0.c:281
s32 phys_adjust_cam_on_landing(void)
Definition 7E9D0.c:46

Referenced by action_update_tornado_jump(), handle_jumping_land_on_switch(), and player_handle_floor_collider_type().

◆ phys_main_collision_below()

void phys_main_collision_below ( void )

Definition at line 863 of file 7BB60.c.

863 {
864 PlayerStatus* playerStatus = &gPlayerStatus;
865 PartnerStatus* partnerStatus = &gPartnerStatus;
866 CollisionStatus* collisionStatus = &gCollisionStatus;
867 f32 collHeightHalf = playerStatus->colliderHeight * 0.5f;
868 f32 playerX = playerStatus->pos.x;
869 f32 playerY = playerStatus->pos.y + collHeightHalf;
870 f32 playerZ = playerStatus->pos.z;
871 f32 outLength = playerStatus->colliderHeight;
872 f32 temp_f24 = (2.0f * playerStatus->colliderHeight) / 7.0f;
873 f32 hitRx, hitRz;
874 f32 hitDirX, hitDirZ;
875 s32 colliderID;
876 s32 cond;
877
878 colliderID = player_raycast_below_cam_relative(playerStatus, &playerX, &playerY, &playerZ, &outLength, &hitRx, &hitRz,
879 &hitDirX, &hitDirZ);
881
882 if (collHeightHalf + (temp_f24 * 0.5f) < outLength) {
883 colliderID = NO_COLLIDER;
884 }
885 if (playerStatus->timeInAir == 0) {
886 collisionStatus->curFloor = colliderID;
887 }
888 if (colliderID > NO_COLLIDER) {
889 playerStatus->groundAnglesXZ.x = hitDirX;
890 playerStatus->groundAnglesXZ.y = hitDirZ;
891 }
892
894 return;
895 }
896
897 if (playerStatus->flags & PS_FLAG_AIRBORNE) {
898 return;
899 }
900
901 if (playerStatus->actionState == ACTION_STATE_SLIDING) {
902 return;
903 }
904
905 if (playerStatus->flags & PS_FLAG_SLIDING) {
907 }
908
909 if (playerStatus->flags & PS_FLAG_SLIDING && phys_should_player_be_sliding()) {
911 }
912
913 if (playerStatus->actionState == ACTION_STATE_SLIDING) {
914 return;
915 }
916
917 if (colliderID > NO_COLLIDER) {
918 s32 surfaceType = get_collider_flags(colliderID) & COLLIDER_FLAGS_SURFACE_TYPE_MASK;
919 switch (surfaceType) {
921 if (partnerStatus->partnerActionState == PARTNER_ACTION_NONE || partnerStatus->actingPartner != PARTNER_BOW) {
922 if (playerStatus->blinkTimer == 0) {
923 if (playerStatus->actionState != ACTION_STATE_HIT_LAVA) {
924 playerStatus->hazardType = HAZARD_TYPE_SPIKES;
926 }
927 } else {
929 }
930 }
931 break;
933 if (partnerStatus->partnerActionState == PARTNER_ACTION_NONE || partnerStatus->actingPartner != PARTNER_BOW) {
934 if (playerStatus->blinkTimer == 0) {
935 if (playerStatus->actionState != ACTION_STATE_HIT_LAVA) {
936 playerStatus->hazardType = HAZARD_TYPE_LAVA;
938 }
939 } else {
941 }
942 }
943 break;
944 default:
945 cond = FALSE;
946 if (collisionStatus->curFloor & COLLISION_WITH_ENTITY_BIT) {
947 cond = get_entity_type(collisionStatus->curFloor) == ENTITY_TYPE_HIDDEN_PANEL;
948 }
949
950 if (playerStatus->actionState != ACTION_STATE_STEP_UP && !cond) {
951 if (!(playerStatus->animFlags & PA_FLAG_USING_PEACH_PHYSICS)) {
952 if (playerY - playerStatus->pos.y < 6.0f) {
953 playerStatus->pos.y = playerY;
954 } else {
956 StepUpLastY = playerY;
957 StepUpLastYaw = playerStatus->targetYaw;
958 }
959 } else {
960 playerStatus->pos.y = playerY;
961 }
963 }
964 break;
965 }
966 } else if (!(playerStatus->flags & PS_FLAG_FLYING)
968 ) {
969 if (outLength <= collHeightHalf + temp_f24 && hitDirX == 0.0f && hitDirZ == 0.0f) {
971 } else {
973 }
975 }
976}
s32 phys_should_player_be_sliding(void)
Definition 7BB60.c:839
void gravity_use_fall_parms(void)
Definition 7BB60.c:302
f32 StepUpLastYaw
Definition 7BB60.c:9
f32 StepUpLastY
Definition 7BB60.c:10
void phys_save_ground_pos(void)
Definition 7BB60.c:1203
@ PS_FLAG_FLYING
Definition enums.h:3037
@ PS_FLAG_AIRBORNE
Definition enums.h:3033
@ PS_FLAG_SLIDING
Definition enums.h:3038
@ ENTITY_TYPE_HIDDEN_PANEL
Definition enums.h:2585
@ ACTION_STATE_USE_SPINNING_FLOWER
Definition enums.h:2457
@ ACTION_STATE_SLIDING
Definition enums.h:2445
@ ACTION_STATE_STEP_UP
Definition enums.h:2462
f32 get_player_normal_pitch(void)
Definition 43F0.c:661

Referenced by phys_update_standard().

◆ phys_peach_update()

void phys_peach_update ( void )

Definition at line 182 of file 7E9D0.c.

182 {
184
185 do {
188 }
189
191
192 if (action->flag) {
194 if (action->dmaStart != NULL && action->dmaStart != LastLoadedActionOffset) {
197 }
198 }
199 action->update();
200 }
202
206 }
207}
#define PLAYER_ACTION_VRAM_DEF
Definition 7E9D0.c:18
void set_action_state(s32 actionState)
Definition 7E9D0.c:209
void peach_sync_disguise_npc(void)
Definition 7E9D0.c:555
void peach_check_for_parasol_input(void)
Definition 7E9D0.c:530
Action PlayerActionsTable[]
Definition actions.c:77
@ PS_FLAG_PAUSED
Definition enums.h:3040
@ PS_FLAG_ACTION_STATE_CHANGED
Definition enums.h:3084
@ ACTION_STATE_TALK
Reading signs doesn't count.
Definition enums.h:2440
b32 check_conversation_trigger(void)
Definition encounter.c:2322
void calculate_camera_yinterp_rate(void)
Definition 7B440.c:183
void * dmaStart
Definition actions.h:8
s8 flag
Definition actions.h:10
void(* update)(void)
Definition actions.h:7
void * dmaEnd
Definition actions.h:9

Referenced by phys_update_action_state().

◆ check_input_spin()

void check_input_spin ( void )

Definition at line 386 of file 7E9D0.c.

386 {
387 PlayerStatus* playerStatus = &gPlayerStatus;
388 PlayerSpinState* spinState = &gPlayerSpinState;
389 PlayerSpinState* temp2 = spinState;
390
391 if (!((playerStatus->flags & (PS_FLAG_NO_STATIC_COLLISION | PS_FLAG_CUTSCENE_MOVEMENT)) ||
392 (playerStatus->animFlags & PA_FLAG_USING_WATT) ||
393 (playerStatus->curButtons & BUTTON_C_DOWN) ||
395
396 s32 actionState = playerStatus->actionState;
397 s32 btnPressed = playerStatus->pressedButtons & Z_TRIG;
398
399 // TODO
400 if (actionState != ACTION_STATE_RIDE) {
401 if (actionState < ACTION_STATE_STEP_UP) {
402 if (actionState < ACTION_STATE_JUMP) {
403 if (actionState >= 0 && !(playerStatus->animFlags & PA_FLAG_SPINNING)) {
404 if (btnPressed || spinState->hasBufferedSpin) {
406 if (spinState->hasBufferedSpin != FALSE) {
407 if (spinState->bufferedStickAxis.x != 0 || spinState->bufferedStickAxis.y != 0) {
408 playerStatus->prevActionState = temp2->prevActionState;
409 } else {
410 playerStatus->prevActionState = ACTION_STATE_IDLE;
411 }
412 }
413 }
414 }
415 }
416 }
417 }
418 }
419}
@ PA_FLAG_SPINNING
Definition enums.h:3107
@ PA_FLAG_USING_WATT
Definition enums.h:3090
@ ABILITY_SLOW_GO
Definition enums.h:447

Referenced by phys_update_action_state().

◆ phys_set_player_sliding_check()

void phys_set_player_sliding_check ( b32(*)(void) funcPtr)

Definition at line 846 of file 7BB60.c.

846 {
847 PlayerSlidingCallback = funcPtr;
848}

Referenced by load_map_by_IDs().

◆ phys_set_landing_adjust_cam_check()

void phys_set_landing_adjust_cam_check ( s32(*)(void) funcPtr)

Definition at line 42 of file 7E9D0.c.

42 {
44}

Referenced by load_map_by_IDs().

◆ npc_test_move_simple_without_slipping()

b32 npc_test_move_simple_without_slipping ( s32 ignoreFlags,
f32 * x,
f32 * y,
f32 * z,
f32 length,
f32 yaw,
f32 height,
f32 radius )

Definition at line 602 of file npc_collision.c.

603 {
604 f32 tempX = *x;
605 f32 tempY = *y + 10.01f;
606 f32 tempZ = *z;
607 s32 hitID = npc_test_move_without_slipping(ignoreFlags, &tempX, &tempY, &tempZ, fabsf(length), yaw, radius * 0.5f);
608
609 *x = tempX;
610 *z = tempZ;
611
612 return hitID > NO_COLLIDER;
613}
s32 npc_test_move_without_slipping(s32 ignoreFlags, f32 *x, f32 *y, f32 *z, f32 length, f32 yaw, f32 radius)

Referenced by AvoidPlayerAI_ChaseInit().

◆ update_collider_transform()

void update_collider_transform ( s16 colliderID)

Definition at line 391 of file collision.c.

391 {
392 Collider* collider;
393 struct Model* model;
394 Matrix4f matrix;
395 s32 i;
396 Vec3f* vertexTable;
397 f32 min_x, min_y, min_z, max_x, max_y, max_z;
398 ColliderTriangle* triangle;
399 f32 e13_y, e21_z, e13_z, e21_y, e21_x, e13_x, normalX, normalY, normalZ, coeff;
400
401 collider = &gCollisionData.colliderList[colliderID];
403
404 if (model->bakedMtx == NULL) {
405 copy_matrix(model->userTransformMtx, matrix);
406 } else {
407 guMtxL2F(matrix, (Mtx*)model->bakedMtx);
408 guMtxCatF(model->userTransformMtx, matrix, matrix);
409 }
410
411 triangle = collider->triangleTable;
412 vertexTable = collider->vertexTable;
413
414 min_x = min_y = min_z = 999999.9f;
415 max_x = max_y = max_z = -999999.9f;
416
417 for (i = 0; i < collider->numVertices; vertexTable += 2, i++) {
418 guMtxXFMF(matrix, vertexTable[1].x, vertexTable[1].y, vertexTable[1].z, &vertexTable[0].x, &vertexTable[0].y, &vertexTable[0].z);
419
420 if (vertexTable[0].x < min_x)
421 min_x = vertexTable[0].x;
422 if (vertexTable[0].x > max_x)
423 max_x = vertexTable[0].x;
424 if (vertexTable[0].y < min_y)
425 min_y = vertexTable[0].y;
426 if (vertexTable[0].y > max_y)
427 max_y = vertexTable[0].y;
428 if (vertexTable[0].z < min_z)
429 min_z = vertexTable[0].z;
430 if (vertexTable[0].z > max_z)
431 max_z = vertexTable[0].z;
432 }
433
434 collider->aabb->min.x = min_x;
435 collider->aabb->min.y = min_y;
436 collider->aabb->min.z = min_z;
437 collider->aabb->max.x = max_x;
438 collider->aabb->max.y = max_y;
439 collider->aabb->max.z = max_z;
440
441 for (i = 0; i < collider->numTriangles; triangle++, i++) {
442 Vec3f* v1 = triangle->v1;
443 Vec3f* v2 = triangle->v2;
444 Vec3f* v3 = triangle->v3;
445
446 triangle->e13.x = v3->x - v1->x;
447 triangle->e13.y = v3->y - v1->y;
448 triangle->e13.z = v3->z - v1->z;
449 triangle->e21.x = v1->x - v2->x;
450 triangle->e21.y = v1->y - v2->y;
451 triangle->e21.z = v1->z - v2->z;
452 triangle->e32.x = v2->x - v3->x;
453 triangle->e32.y = v2->y - v3->y;
454 triangle->e32.z = v2->z - v3->z;
455
456 e13_x = triangle->e13.x;
457 e13_y = triangle->e13.y;
458 e13_z = triangle->e13.z;
459 e21_x = triangle->e21.x;
460 e21_y = triangle->e21.y;
461 e21_z = triangle->e21.z;
462
463 // vector product
464 normalX = e13_y * e21_z - e13_z * e21_y;
465 normalY = e13_z * e21_x - e13_x * e21_z;
466 normalZ = e13_x * e21_y - e13_y * e21_x;
467 coeff = SQ(normalX) + SQ(normalY) + SQ(normalZ);
468
469 if (coeff != 0) {
470 coeff = 1.0f / sqrtf(coeff);
471 } else {
472 coeff = 0.0f;
473 }
474
475 triangle->normal.x = normalX * coeff;
476 triangle->normal.y = normalY * coeff;
477 triangle->normal.z = normalZ * coeff;
478 }
479}
struct Model * get_model_from_list_index(s32 listIndex)
Definition model.c:3314
void copy_matrix(Matrix4f src, Matrix4f dest)
Definition 43F0.c:438
Mtx * bakedMtx
Definition model.h:62
Matrix4f userTransformMtx
Definition model.h:68

Referenced by restore_map_collision_data().

◆ get_collider_center()

void get_collider_center ( s32 colliderID,
f32 * x,
f32 * y,
f32 * z )

Definition at line 497 of file collision.c.

497 {
498 ColliderBoundingBox* aabb = gCollisionData.colliderList[colliderID].aabb;
499
500 *x = (aabb->min.x + aabb->max.x) * 0.5f;
501 *y = (aabb->min.y + aabb->max.y) * 0.5f;
502 *z = (aabb->min.z + aabb->max.z) * 0.5f;
503}

◆ is_another_trigger_bound()

s32 is_another_trigger_bound ( Trigger * trigger,
EvtScript * script )

Definition at line 254 of file trigger.c.

254 {
255 s32 i;
256
257 for (i = 0; i < ARRAY_COUNT(*gCurrentTriggerListPtr); i++) {
258 Trigger* listTrigger = (*gCurrentTriggerListPtr)[i];
259
260 if (listTrigger == NULL || listTrigger == trigger) {
261 continue;
262 }
263
264 if (listTrigger->flags & TRIGGER_ACTIVE) {
265 if (listTrigger->flags & TRIGGER_ACTIVATED) {
266 if (listTrigger->onTriggerEvt == script) {
267 return TRUE;
268 }
269 }
270 }
271 }
272
273 return FALSE;
274}
@ TRIGGER_ACTIVE
Definition enums.h:2673
@ TRIGGER_ACTIVATED
Definition enums.h:2674
EvtScript * onTriggerEvt
BSS TriggerList * gCurrentTriggerListPtr
Definition trigger.c:7

Referenced by evt_trigger_on_activate_exec_script().

◆ create_trigger()

Trigger * create_trigger ( TriggerBlueprint * def)

Definition at line 55 of file trigger.c.

55 {
56 Trigger* trigger;
57 s32 i;
58
59 for (i = 0; i < ARRAY_COUNT(*gCurrentTriggerListPtr); i++) {
60 Trigger* listTrigger = (*gCurrentTriggerListPtr)[i];
61
62 if (listTrigger == NULL) {
63 break;
64 }
65 }
66
68
69 (*gCurrentTriggerListPtr)[i] = trigger = heap_malloc(sizeof(*trigger));
71
72 ASSERT(trigger != NULL);
73
74 trigger->flags = bp->flags | TRIGGER_ACTIVE;
75 trigger->varIndex = bp->varIndex;
76 trigger->location.colliderID = bp->colliderID;
77 trigger->itemList = bp->itemList;
78 trigger->tattleMsg = bp->tattleMsg;
79 trigger->hasPlayerInteractPrompt = bp->hasPlayerInteractPrompt;
80
81 trigger->onActivateFunc = bp->onActivateFunc;
82 if (trigger->onActivateFunc == NULL) {
84 }
85
86 return trigger;
87}
s32(* onActivateFunc)(struct Trigger *)
s32 * itemList
u8 hasPlayerInteractPrompt
union Trigger::@3 location
void default_trigger_on_activate(Trigger *self)
Definition trigger.c:9
s16 gTriggerCount
Definition trigger.c:4

Referenced by bind_trigger(), evt_handle_bind(), and evt_handle_bind_lock().

◆ evt_trigger_on_activate_exec_script()

s32 evt_trigger_on_activate_exec_script ( Trigger * trigger)

Definition at line 981 of file evt.c.

981 {
982 EvtScript* scriptStart;
983 Evt* script;
984
985 if (trigger->runningScript == NULL) {
986 scriptStart = trigger->onTriggerEvt;
987 if (is_another_trigger_bound(trigger, scriptStart)) {
988 return 0;
989 }
990
991 script = start_script(scriptStart, trigger->priority, EVT_FLAG_RUN_IMMEDIATELY);
992 trigger->runningScript = script;
993 trigger->runningScriptID = script->id;
994 script->varTable[0] = trigger->varTable[0];
995 script->varTable[1] = trigger->varTable[1];
996 script->varTable[2] = trigger->varTable[2];
997 script->owner2.trigger = trigger;
998 }
999
1000 if (!does_script_exist(trigger->runningScriptID)) {
1001 trigger->runningScript = NULL;
1002 return 0; // stop calling this function
1003 }
1004
1005 return 1; // keep calling this function every frame
1006}
union Evt::@11 owner2
Initially -1.
Bytecode EvtScript[]
@ EVT_FLAG_RUN_IMMEDIATELY
don't wait for next update_scripts call
Definition evt.h:161
s32 is_another_trigger_bound(Trigger *, EvtScript *script)
Definition trigger.c:254
Evt * start_script(EvtScript *source, s32 priority, s32 initialState)
s32 does_script_exist(s32 id)
s32 runningScriptID
struct Evt * runningScript

Referenced by bind_trigger(), and evt_handle_bind().

◆ get_trigger_by_id()

Trigger * get_trigger_by_id ( s32 triggerID)

Definition at line 276 of file trigger.c.

276 {
277 return (*gCurrentTriggerListPtr)[triggerID];
278}

Referenced by get_trigger_tattle().

◆ get_actor()

Actor * get_actor ( s32 actorID)

Definition at line 155 of file actor_api.c.

155 {
156 Actor* ret = NULL;
157 BattleStatus* battleStatus = &gBattleStatus;
158 s32 actorClass = actorID & ACTOR_CLASS_MASK;
159 u32 idIdx = (u8)actorID;
160
161 switch (actorClass) {
163 ret = battleStatus->playerActor;
164 break;
166 ret = battleStatus->partnerActor;
167 break;
169 ret = battleStatus->enemyActors[idIdx];
170 break;
171 }
172 return ret;
173}
@ ACTOR_CLASS_ENEMY
Definition enums.h:2079
@ ACTOR_CLASS_PLAYER
Definition enums.h:2077
@ ACTOR_CLASS_PARTNER
Definition enums.h:2078
@ ACTOR_CLASS_MASK
Definition enums.h:2080

Referenced by btl_state_draw_select_target(), btl_state_update_first_strike(), btl_state_update_next_enemy(), btl_state_update_partner_striking_first(), btl_state_update_select_target(), calc_enemy_damage_target(), calc_enemy_test_target(), calc_item_check_hit(), calc_item_damage_enemy(), calc_partner_damage_enemy(), calc_partner_test_enemy(), calc_player_damage_enemy(), calc_player_test_enemy(), clear_part_flag_bits(), create_part_shadow(), create_target_list(), get_cam_subject_properties(), remove_part_shadow(), set_actor_anim(), set_actor_anim_rate(), set_actor_current_position(), set_actor_home_position(), set_actor_yaw(), set_goal_pos_to_part(), set_part_absolute_position(), set_part_flag_bits(), set_part_goal_to_actor_part(), and set_part_yaw().

◆ get_actor_part()

ActorPart * get_actor_part ( Actor * actor,
s32 partID )

◆ add_coins()

s32 add_coins ( s32 amt)

Definition at line 2076 of file inventory.c.

2076 {
2077 PlayerData* playerData = &gPlayerData;
2078 s16 newCoins = playerData->coins + amt;
2079
2080 playerData->coins = newCoins;
2081 if (newCoins > 999) {
2082 playerData->coins = 999;
2083 }
2084 if (playerData->coins < 0) {
2085 playerData->coins = 0;
2086 }
2087
2088 if (amt > 0) {
2089 playerData->totalCoinsEarned += amt;
2090 if (playerData->totalCoinsEarned > 99999) {
2091 playerData->totalCoinsEarned = 99999;
2092 }
2093 }
2094 return playerData->coins;
2095}

◆ is_partner_ability_active()

s32 is_partner_ability_active ( s32 ability)

Definition at line 2072 of file inventory.c.

2072 {
2073 return 0;
2074}

Referenced by player_team_is_ability_active().

◆ count_power_plus()

s32 count_power_plus ( s32 damageType)

Definition at line 939 of file 190B20.c.

939 {
940 s32 count;
941 s32 i;
942
944 return 0;
945 }
946
947 count = 0;
948 for (i = 0; i < ARRAY_COUNT(gPlayerData.equippedBadges); i++) {
950
951 if (gMoveTable[moveID].category == MOVE_TYPE_ATTACK_UP && moveID == MOVE_POWER_PLUS) {
953 count++;
954 }
955 }
956 }
957
958 return count;
959}
s16 equippedBadges[64]
@ PEACH_FLAG_IS_PEACH
Definition enums.h:2488
@ BS_FLAGS1_INCLUDE_POWER_UPS
Definition enums.h:3570
@ MOVE_TYPE_ATTACK_UP
Definition enums.h:5218
@ DAMAGE_TYPE_JUMP
Definition enums.h:2858
ItemData gItemTable[]
MoveData gMoveTable[]

Referenced by calc_player_damage_enemy().

◆ phys_can_player_interact()

s32 phys_can_player_interact ( void )

Definition at line 1159 of file 7BB60.c.

1159 {
1160 s32 ret = TRUE;
1161
1165 ret = FALSE;
1166 }
1167 } else {
1168 ret = FALSE;
1169 }
1173 ret = FALSE;
1174 }
1175 return ret;
1176}
@ PARTNER_ACTION_BOMBETTE_2
Definition enums.h:2937

Referenced by check_for_interactables(), func_800E06D8(), should_collider_allow_interact(), should_continue_inspect(), and update_triggers().

◆ ai_enemy_play_sound()

void ai_enemy_play_sound ( Npc * npc,
s32 arg1,
s32 arg2 )

Definition at line 543 of file 23680.c.

543 {
544 Enemy* enemy = get_enemy(npc->npcID);
545 s32 soundFlags = (upperSoundFlags & SOUND_SPACE_PARAMS_MASK) | SOUND_SPACE_FULL;
546
547 if (upperSoundFlags & 1) {
548 soundFlags |= SOUND_PARAM_MUTE;
549 }
550
551 if (enemy->npcSettings->actionFlags & AI_ACTION_20) {
552 soundFlags |= SOUND_PARAM_CLIP_OFFSCREEN_ANY;
553 }
554
555 sfx_play_sound_at_position(soundID, soundFlags, npc->pos.x, npc->pos.y, npc->pos.z);
556}
@ AI_ACTION_20
Definition enums.h:4616
@ SOUND_SPACE_PARAMS_MASK
Definition enums.h:1740
@ SOUND_SPACE_FULL
Definition enums.h:1739
@ SOUND_PARAM_CLIP_OFFSCREEN_ANY
Definition enums.h:1742
@ SOUND_PARAM_MUTE
Definition enums.h:1741
Enemy * get_enemy(s32 npcID)
Looks for an enemy matching the specified npcID.
Definition npc.c:2539
s16 actionFlags
Definition npc.h:156
NpcSettings * npcSettings
Definition npc.h:304
Definition npc.h:294

Referenced by basic_ai_chase(), basic_ai_found_player_jump_init(), basic_ai_loiter(), basic_ai_wander(), CleftAI_Hiding(), ClubbaNappingAI_Sleep(), FlyingAI_Loiter(), FlyingAI_Wander(), FlyingMagikoopaAI_11(), FlyingMagikoopaAI_21(), FlyingMagikoopaAI_23(), GuardAI_Idle(), GuardAI_ReturnHome(), HoppingAI_ChaseInit(), HoppingAI_Hop(), HoppingAI_HopInit(), HoppingAI_Loiter(), LakituAI_Loiter(), LakituAI_Wander(), MagikoopaAI_21(), MagikoopaAI_23(), ParatroopaAI_Windup(), PatrolAI_Loiter(), PatrolAI_Move(), PiranhaPlantAI_01(), PiranhaPlantAI_10(), and SentinelAI_ReturnHome().

◆ player_test_move_without_slipping()

HitID player_test_move_without_slipping ( PlayerStatus * playerStatus,
f32 * x,
f32 * y,
f32 * z,
f32 length,
f32 yaw,
s32 * hasClimbableStep )

Only used for Peach physics.

Definition at line 496 of file 77480.c.

496 {
497 f32 sinTheta;
498 f32 cosTheta;
499 f32 hitX;
500 f32 hitY;
501 f32 hitZ;
502 f32 hitDepth;
503 f32 hitNx;
504 f32 hitNy;
505 f32 hitNz;
506 f32 slipDx;
507 f32 slipDz;
508 f32 depth;
509 f32 radius;
510 f32 depthDiff;
511 f32 height;
512 s32 ret;
513 s32 hitID;
514 f32 targetDx;
515 f32 targetDz;
516 f32 dx, dz;
517
518 radius = playerStatus->colliderDiameter * 0.5f;
519 height = playerStatus->colliderHeight * 0.286f;
520 sin_cos_rad(DEG_TO_RAD(yaw), &sinTheta, &cosTheta);
521
522 depth = length + radius;
523 cosTheta = -cosTheta;
524 hitDepth = depth;
525 dx = radius * sinTheta;
526 ret = NO_COLLIDER;
527
528 hitID = player_raycast_general(PLAYER_COLLISION_0, *x, *y + 0.1, *z, sinTheta, 0, cosTheta, &hitX, &hitY, &hitZ, &hitDepth, &hitNx, &hitNy, &hitNz);
529 if (hitID > NO_COLLIDER && hitDepth <= depth) {
530 *hasClimbableStep = TRUE;
531 }
532
533 depth = length + radius;
534 hitDepth = depth;
535 dz = radius * cosTheta;
536
537 hitID = player_raycast_general(PLAYER_COLLISION_0, *x, *y + height, *z, sinTheta, 0, cosTheta, &hitX, &hitY, &hitZ, &hitDepth, &hitNx, &hitNy, &hitNz);
538
539 targetDx = 0.0f;
540 targetDz = 0.0f;
541
542 if (hitID > NO_COLLIDER && hitDepth <= depth) {
543 depthDiff = hitDepth - depth;
544 dx = depthDiff * sinTheta;
545 dz = depthDiff * cosTheta;
546 player_get_slip_vector(&slipDx, &slipDz, 0.0f, 0.0f, hitNx, hitNz);
547 *x += dx + slipDx;
548 *z += dz + slipDz;
549 ret = hitID;
550 }
551 *x += targetDx;
552 *z += targetDz;
553 return ret;
554}

Referenced by collision_lateral_peach().

◆ player_test_move_with_slipping()

HitID player_test_move_with_slipping ( PlayerStatus * playerStatus,
f32 * posX,
f32 * posY,
f32 * posZ,
f32 speed,
f32 heading )

Definition at line 563 of file 77480.c.

563 {
564 f32 sinTheta;
565 f32 cosTheta;
566 f32 hitX;
567 f32 hitY;
568 f32 hitZ;
569 f32 hitDepth;
570 f32 hitNx;
571 f32 hitNy;
572 f32 hitNz;
573 f32 slipDx;
574 f32 slipDz;
575 f32 radius;
576 f32 height;
577 s32 hitID;
578 f32 targetDx, targetDz;
579 f32 dx, dz;
580 f32 depthDiff;
581 s32 ret = NO_COLLIDER;
582
583 height = 0.0f;
584 if (!(playerStatus->flags & (PS_FLAG_JUMPING | PS_FLAG_FALLING))) {
585 height = 10.01f;
586 }
587 radius = playerStatus->colliderDiameter * 0.5f;
588
589 sin_cos_rad(DEG_TO_RAD(yaw), &sinTheta, &cosTheta);
590 cosTheta = -cosTheta;
591 hitDepth = length + radius;
592
593 targetDx = length * sinTheta;
594 targetDz = length * cosTheta;
595
596 hitID = player_raycast_general(PLAYER_COLLISION_0, *x, *y + height, *z, sinTheta, 0, cosTheta, &hitX, &hitY, &hitZ, &hitDepth, &hitNx, &hitNy, &hitNz);
597 if (hitID > NO_COLLIDER && (depthDiff = hitDepth, depthDiff <= length + radius)) {
598 depthDiff -= (length + radius);
599 dx = depthDiff * sinTheta;
600 dz = depthDiff * cosTheta;
601 player_get_slip_vector(&slipDx, &slipDz, targetDx, targetDz, hitNx, hitNz);
602 *x += dx + slipDx;
603 *z += dz + slipDz;
604 ret = hitID;
605 } else {
606 height = playerStatus->colliderHeight * 0.75;
607 hitID = player_raycast_general(PLAYER_COLLISION_0, *x, *y + height, *z, sinTheta, 0, cosTheta, &hitX, &hitY, &hitZ, &hitDepth, &hitNx, &hitNy, &hitNz);
608 if (hitID > NO_COLLIDER && (depthDiff = hitDepth, depthDiff <= length + radius)) {
609 depthDiff -= (length + radius);
610 dx = depthDiff * sinTheta;
611 dz = depthDiff * cosTheta;
612 player_get_slip_vector(&slipDx, &slipDz, targetDx, targetDz, hitNx, hitNz);
613 *x += dx + slipDx;
614 *z += dz + slipDz;
615 ret = hitID;
616 }
617 }
618
619 *x += targetDx;
620 *z += targetDz;
621 return ret;
622}

Referenced by action_update_sliding(), collision_main_lateral(), and phys_check_interactable_collision().

◆ evt_get_variable()

s32 evt_get_variable ( Evt * script,
Bytecode var )

Definition at line 1689 of file evt.c.

1689 {
1690 s32 wordIdx;
1691 s32 bitIdx;
1692 s32 temp;
1693
1694 if (var <= EVT_LIMIT) {
1695 return var;
1696 } else if (var <= EVT_IGNORE_ARG) {
1697 return var;
1698 } else if (var <= EVT_FIXED_CUTOFF) {
1699 return evt_fixed_var_to_float(var);
1700 } else if (var <= EVT_ARRAY_FLAG_CUTOFF) {
1701 var = EVT_INDEX_OF_ARRAY_FLAG(var);
1702 wordIdx = var / 32;
1703 bitIdx = var % 32;
1704 var = (script->flagArray[wordIdx] & (1 << bitIdx)) != 0;
1705 return var;
1706 } else if (var <= EVT_ARRAY_VAR_CUTOFF) {
1707 var = EVT_INDEX_OF_ARRAY_VAR(var);
1708 var = script->array[var];
1709 if (var > EVT_LIMIT) {
1710 if (var <= EVT_FIXED_CUTOFF){
1711 var = evt_fixed_var_to_float(var);
1712 }
1713 }
1714 } else if (var <= EVT_GAME_BYTE_CUTOFF) {
1715 var = EVT_INDEX_OF_GAME_BYTE(var);
1716 return get_global_byte(var);
1717 } else if (var <= EVT_AREA_BYTE_CUTOFF) {
1718 var = EVT_INDEX_OF_AREA_BYTE(var);
1719 return get_area_byte(var);
1720 } else if (var <= EVT_GAME_FLAG_CUTOFF) {
1721 var = EVT_INDEX_OF_GAME_FLAG(var);
1722 return get_global_flag(var);
1723 } else if (var <= EVT_AREA_FLAG_CUTOFF) {
1724 var = EVT_INDEX_OF_AREA_FLAG(var);
1725 return get_area_flag(var);
1726 } else if (var <= EVT_MAP_FLAG_CUTOFF) {
1727 var = EVT_INDEX_OF_MAP_FLAG(var);
1728 wordIdx = var;
1729 bitIdx = var % 32;
1730 var = (gMapFlags[wordIdx / 32] & (1 << bitIdx)) != 0;
1731 return var;
1732 } else if (var <= EVT_LOCAL_FLAG_CUTOFF) {
1733 var = EVT_INDEX_OF_LOCAL_FLAG(var);
1734 wordIdx = var;
1735 bitIdx = var % 32;
1736 var = (script->varFlags[wordIdx / 32] & (1 << bitIdx)) != 0;
1737 return var;
1738 } else if (var <= EVT_MAP_VAR_CUTOFF) {
1739 var = EVT_INDEX_OF_MAP_VAR(var);
1740 var = gMapVars[var];
1741 if (var > EVT_LIMIT) {
1742 temp = EVT_FIXED_CUTOFF;
1743 if (var <= temp){
1744 var = evt_fixed_var_to_float(var);
1745 }
1746 }
1747 } else if (var <= EVT_LOCAL_VAR_CUTOFF) {
1748 var = EVT_INDEX_OF_LOCAL_VAR(var);
1749 var = script->varTable[var];
1750 if (var > EVT_LIMIT) {
1751 temp = EVT_FIXED_CUTOFF;
1752 if (var <= temp){
1753 var = evt_fixed_var_to_float(var);
1754 }
1755 }
1756 }
1757 return var;
1758}
s32 * flagArray
s32 * array
s32 varFlags[3]
u32 * gMapFlags
Definition script_list.c:9
f32 evt_fixed_var_to_float(Bytecode scriptVar)
Definition evt.c:17
s32 * gMapVars
Definition script_list.c:10
#define EVT_LOCAL_VAR_CUTOFF
Expressions in EVT instructions should be one of the following types:
Definition macros.h:24
#define EVT_INDEX_OF_AREA_BYTE(v)
Definition macros.h:141
#define EVT_ARRAY_VAR_CUTOFF
Definition macros.h:40
#define EVT_MAP_FLAG_CUTOFF
Definition macros.h:30
#define EVT_FIXED_CUTOFF
Definition macros.h:44
#define EVT_LOCAL_FLAG_CUTOFF
Definition macros.h:28
#define EVT_GAME_FLAG_CUTOFF
Definition macros.h:34
#define EVT_AREA_BYTE_CUTOFF
Definition macros.h:36
#define EVT_INDEX_OF_AREA_FLAG(v)
Definition macros.h:140
#define EVT_INDEX_OF_ARRAY_FLAG(v)
Definition macros.h:144
#define EVT_INDEX_OF_LOCAL_VAR(v)
Definition macros.h:136
#define EVT_INDEX_OF_ARRAY_VAR(v)
Definition macros.h:145
#define EVT_INDEX_OF_GAME_BYTE(v)
Definition macros.h:143
#define EVT_GAME_BYTE_CUTOFF
Definition macros.h:38
#define EVT_IGNORE_ARG
Definition macros.h:46
#define EVT_ARRAY_FLAG_CUTOFF
Definition macros.h:42
#define EVT_INDEX_OF_MAP_FLAG(v)
Definition macros.h:139
#define EVT_INDEX_OF_LOCAL_FLAG(v)
Definition macros.h:137
#define EVT_AREA_FLAG_CUTOFF
Definition macros.h:32
#define EVT_INDEX_OF_MAP_VAR(v)
Definition macros.h:138
#define EVT_MAP_VAR_CUTOFF
Definition macros.h:26
#define EVT_INDEX_OF_GAME_FLAG(v)
Definition macros.h:142
#define EVT_LIMIT
Definition macros.h:47
s32 get_global_byte(s32 index)
Get value of saved game byte.
s32 get_area_flag(s32 index)
s32 get_area_byte(s32 index)

Referenced by _npc_jump_to(), _show_message(), appendGfx_piranha_vines(), apply_transform_to_children(), check_input_open_menus(), check_input_status_bar(), evt_handle_add(), evt_handle_allocate_array(), evt_handle_AND(), evt_handle_AND_const(), evt_handle_bind(), evt_handle_bind_lock(), evt_handle_call(), evt_handle_case_equal(), evt_handle_case_equal_AND(), evt_handle_case_equal_OR(), evt_handle_case_greater(), evt_handle_case_greater_equal(), evt_handle_case_less(), evt_handle_case_less_equal(), evt_handle_case_not_equal(), evt_handle_case_range(), evt_handle_divide(), evt_handle_does_script_exist(), evt_handle_end_loop(), evt_handle_exec1(), evt_handle_exec1_get_id(), evt_handle_exec_wait(), evt_handle_get_Nth_float(), evt_handle_get_Nth_word(), evt_handle_goto(), evt_handle_if_AND(), evt_handle_if_equal(), evt_handle_if_greater(), evt_handle_if_greater_equal(), evt_handle_if_less(), evt_handle_if_less_equal(), evt_handle_if_not_AND(), evt_handle_if_not_equal(), evt_handle_jump(), evt_handle_kill(), evt_handle_mod(), evt_handle_multiply(), evt_handle_OR(), evt_handle_OR_const(), evt_handle_resume(), evt_handle_resume_all(), evt_handle_resume_others(), evt_handle_set_array(), evt_handle_set_flag_array(), evt_handle_set_float_buffer_ptr(), evt_handle_set_group(), evt_handle_set_int_buffer_ptr(), evt_handle_set_priority(), evt_handle_set_var(), evt_handle_subtract(), evt_handle_suspend(), evt_handle_suspend_all(), evt_handle_suspend_others(), evt_handle_switch(), evt_handle_wait(), get_spirits_rescued(), gfx_build_knocked_down_player(), goto_map(), load_map_bg(), pause_cleanup(), pause_handle_input(), pause_init(), pause_map_draw_contents(), pause_map_handle_input(), pause_map_init(), pause_map_update(), pause_stats_handle_input(), pause_tutorial_draw_contents(), player_jump(), ProjectileHitbox_GetUsableProjectileID(), Quizmo_CreateReactionEffect(), update_item_entity_pickup(), and update_status_bar().

◆ evt_set_variable()

s32 evt_set_variable ( Evt * script,
Bytecode var,
s32 value )

Definition at line 1846 of file evt.c.

1846 {
1847 s32 flagBitPos;
1848 s32 oldValue;
1849
1850 if (var <= EVT_LIMIT) {
1851 return value;
1852 } else if (var <= EVT_FIXED_CUTOFF) {
1853 return evt_fixed_var_to_float(value);
1854 } else if (var <= EVT_ARRAY_FLAG_CUTOFF) {
1855 var = EVT_INDEX_OF_ARRAY_FLAG(var);
1856 flagBitPos = var % 32;
1857 if (value) {
1858 script->flagArray[var / 32] |= 1 << flagBitPos;
1859 } else {
1860 script->flagArray[var / 32] &= ~(1 << flagBitPos);
1861 }
1862 return value;
1863 } else if (var <= EVT_ARRAY_VAR_CUTOFF) {
1864 var = EVT_INDEX_OF_ARRAY_VAR(var);
1865 oldValue = script->array[var];
1866 script->array[var] = value;
1867 return oldValue;
1868 } else if (var <= EVT_GAME_BYTE_CUTOFF) {
1869 var = EVT_INDEX_OF_GAME_BYTE(var);
1870 oldValue = get_global_byte(var);
1871 set_global_byte(var, value);
1872 return oldValue;
1873 } else if (var <= EVT_AREA_BYTE_CUTOFF) {
1874 var = EVT_INDEX_OF_AREA_BYTE(var);
1875 oldValue = get_area_byte(var);
1876 set_area_byte(var, value);
1877 return oldValue;
1878 } else if (var <= EVT_GAME_FLAG_CUTOFF) {
1879 var = EVT_INDEX_OF_GAME_FLAG(var);
1880 oldValue = get_global_flag(var);
1881 if (value) {
1882 set_global_flag(var);
1883 } else {
1884 clear_global_flag(var);
1885 }
1886 return oldValue;
1887 } else if (var <= EVT_AREA_FLAG_CUTOFF) {
1888 var = EVT_INDEX_OF_AREA_FLAG(var);
1889 oldValue = get_area_flag(var);
1890 if (value) {
1891 set_area_flag(var);
1892 } else {
1893 clear_area_flag(var);
1894 }
1895 return oldValue;
1896 } else if (var <= EVT_MAP_FLAG_CUTOFF) {
1897 var = EVT_INDEX_OF_MAP_FLAG(var);
1898 flagBitPos = var % 32;
1899 if (value) {
1900 gMapFlags[var / 32] |= 1 << flagBitPos;
1901 } else {
1902 gMapFlags[var / 32] &= ~(1 << flagBitPos);
1903 }
1904 return value;
1905 } else if (var <= EVT_LOCAL_FLAG_CUTOFF) {
1906 var = EVT_INDEX_OF_LOCAL_FLAG(var);
1907 flagBitPos = var % 32;
1908 if (value) {
1909 script->varFlags[var / 32] |= 1 << flagBitPos;
1910 } else {
1911 script->varFlags[var / 32] &= ~(1 << flagBitPos);
1912 }
1913 return value;
1914 } else if (var <= EVT_MAP_VAR_CUTOFF) {
1915 var = EVT_INDEX_OF_MAP_VAR(var);
1916 oldValue = gMapVars[var];
1917 gMapVars[var] = value;
1918 return oldValue;
1919 } else if (var <= EVT_LOCAL_VAR_CUTOFF) {
1920 var = EVT_INDEX_OF_LOCAL_VAR(var);
1921 oldValue = script->varTable[var];
1922 script->varTable[var] = value;
1923 return oldValue;
1924 } else {
1925 return value;
1926 }
1927}
s32 clear_area_flag(s32 index)
s8 set_area_byte(s32 index, s32 value)
s32 clear_global_flag(s32 index)
Definition vars_access.c:41
s8 set_global_byte(s32 index, s32 value)
Set value of saved game byte.

Referenced by evt_handle_add(), evt_handle_allocate_array(), evt_handle_AND(), evt_handle_AND_const(), evt_handle_bind(), evt_handle_divide(), evt_handle_does_script_exist(), evt_handle_end_loop(), evt_handle_exec1_get_id(), evt_handle_get_1_word(), evt_handle_get_2_word(), evt_handle_get_3_word(), evt_handle_get_4_word(), evt_handle_get_Nth_word(), evt_handle_mod(), evt_handle_multiply(), evt_handle_OR(), evt_handle_OR_const(), evt_handle_set_const(), evt_handle_set_var(), evt_handle_subtract(), exec_ShakeCamX(), filemenu_yesno_handle_input(), init_enter_world_shared(), load_demo_battle(), state_step_demo(), and update_item_entity_pickup().

◆ evt_get_float_variable()

f32 evt_get_float_variable ( Evt * script,
Bytecode var )

Definition at line 1929 of file evt.c.

1929 {
1930 s32 temp;
1931
1932 if (var <= EVT_LIMIT) {
1933 return var;
1934 } else if (var <= EVT_IGNORE_ARG) {
1935 return var;
1936 } else if (var <= EVT_FIXED_CUTOFF) {
1937 return evt_fixed_var_to_float(var);
1938 } else if (var <= EVT_ARRAY_VAR_CUTOFF) {
1939 var = EVT_INDEX_OF_ARRAY_VAR(var);
1940 return evt_fixed_var_to_float(script->array[var]);
1941 } else if (var <= EVT_GAME_BYTE_CUTOFF) {
1942 var = EVT_INDEX_OF_GAME_BYTE(var);
1944 } else if (var <= EVT_AREA_BYTE_CUTOFF) {
1945 var = EVT_INDEX_OF_AREA_BYTE(var);
1947 } else if (var <= EVT_MAP_FLAG_CUTOFF) {
1948 var = EVT_INDEX_OF_MAP_FLAG(var);
1949 temp = var % 32;
1950 var = gMapFlags[var / 32] & (1 << temp);
1951 if (var) {
1952 return 1.0f;
1953 } else {
1954 return 0.0f;
1955 }
1956 } else if (var <= EVT_LOCAL_FLAG_CUTOFF) {
1957 var = EVT_INDEX_OF_LOCAL_FLAG(var);
1958 temp = var % 32;
1959 var = script->varFlags[var / 32] & (1 << temp);
1960 if (var) {
1961 return 1.0f;
1962 } else {
1963 return 0.0f;
1964 }
1965 } else if (var <= EVT_MAP_VAR_CUTOFF) {
1966 var = EVT_INDEX_OF_MAP_VAR(var);
1967 return evt_fixed_var_to_float(gMapVars[var]);
1968 } else if (var <= EVT_LOCAL_VAR_CUTOFF) {
1969 var = EVT_INDEX_OF_LOCAL_VAR(var);
1970 return evt_fixed_var_to_float(script->varTable[var]);
1971 } else {
1972 return evt_fixed_var_to_float(var);
1973 }
1974}

Referenced by evt_handle_addF(), evt_handle_divideF(), evt_handle_get_1_float(), evt_handle_get_2_float(), evt_handle_get_3_float(), evt_handle_get_4_float(), evt_handle_multiplyF(), evt_handle_set_float(), evt_handle_set_timescale(), evt_handle_subtractF(), evt_handle_wait_seconds(), and make_vine_interpolation().

◆ evt_set_float_variable()

f32 evt_set_float_variable ( Evt * script,
Bytecode var,
f32 value )

Definition at line 1976 of file evt.c.

1976 {
1977 s32 temp;
1978 s32 oldValue;
1979
1980 if (var <= EVT_LIMIT) {
1981 return value;
1982 } else if (var <= EVT_FIXED_CUTOFF) {
1983 return value;
1984 } else if (var <= EVT_ARRAY_VAR_CUTOFF) {
1985 var = EVT_INDEX_OF_ARRAY_VAR(var);
1986 oldValue = script->array[var];
1987 script->array[var] = evt_float_to_fixed_var(value);
1988 return evt_fixed_var_to_float(oldValue);
1989 } else if (var <= EVT_MAP_FLAG_CUTOFF) {
1990 var = EVT_INDEX_OF_MAP_FLAG(var);
1991 temp = var % 32;
1992 if (value) {
1993 gMapFlags[var / 32] |= 1 << temp;
1994 } else {
1995 gMapFlags[var / 32] &= ~(1 << temp);
1996 }
1997 return value;
1998 } else if (var <= EVT_LOCAL_FLAG_CUTOFF) {
1999 var = EVT_INDEX_OF_LOCAL_FLAG(var);
2000 temp = var % 32;
2001 if (value) {
2002 script->varFlags[var / 32] |= 1 << temp;
2003 } else {
2004 script->varFlags[var / 32] &= ~(1 << temp);
2005 }
2006 return value;
2007 } else if (var <= EVT_MAP_VAR_CUTOFF) {
2008 var = EVT_INDEX_OF_MAP_VAR(var);
2009 oldValue = gMapVars[var];
2010 gMapVars[var] = evt_float_to_fixed_var(value);
2011 return evt_fixed_var_to_float(oldValue);
2012 } else if (var <= EVT_LOCAL_VAR_CUTOFF) {
2013 var = EVT_INDEX_OF_LOCAL_VAR(var);
2014 oldValue = script->varTable[var];
2015 script->varTable[var] = evt_float_to_fixed_var(value);
2016 return evt_fixed_var_to_float(oldValue);
2017 } else {
2018 return value;
2019 }
2020}
Bytecode evt_float_to_fixed_var(f32 value)
Definition evt.c:25

Referenced by evt_handle_addF(), evt_handle_divideF(), evt_handle_get_1_float(), evt_handle_get_2_float(), evt_handle_get_3_float(), evt_handle_get_4_float(), evt_handle_get_Nth_float(), evt_handle_multiplyF(), evt_handle_set_float(), evt_handle_subtractF(), and exec_ShakeCamX().

◆ evt_get_variable_index()

s32 evt_get_variable_index ( Evt * script,
s32 var )

Definition at line 1760 of file evt.c.

1760 {
1761 if (EVT_LIMIT >= var) {
1762 return var;
1763 }
1764 if (EVT_IGNORE_ARG >= var) {
1765 return var;
1766 }
1767 if (EVT_FIXED_CUTOFF >= var) {
1768 return var;
1769 }
1770 if (EVT_ARRAY_FLAG_CUTOFF >= var) {
1771 return EVT_INDEX_OF_ARRAY_FLAG(var);
1772 }
1773 if (EVT_ARRAY_VAR_CUTOFF >= var) {
1774 return EVT_INDEX_OF_ARRAY_VAR(var);
1775 }
1776 if (EVT_GAME_BYTE_CUTOFF >= var) {
1777 return EVT_INDEX_OF_GAME_BYTE(var);
1778 }
1779 if (EVT_AREA_BYTE_CUTOFF >= var) {
1780 return EVT_INDEX_OF_AREA_BYTE(var);
1781 }
1782 if (EVT_GAME_FLAG_CUTOFF >= var) {
1783 return EVT_INDEX_OF_GAME_FLAG(var);
1784 }
1785 if (EVT_AREA_FLAG_CUTOFF >= var) {
1786 return EVT_INDEX_OF_AREA_FLAG(var);
1787 }
1788 if (EVT_MAP_FLAG_CUTOFF >= var) {
1789 return EVT_INDEX_OF_MAP_FLAG(var);
1790 }
1791 if (EVT_LOCAL_FLAG_CUTOFF >= var) {
1792 return EVT_INDEX_OF_LOCAL_FLAG(var);
1793 }
1794 if (EVT_MAP_VAR_CUTOFF >= var) {
1795 return EVT_INDEX_OF_MAP_VAR(var);
1796 }
1797 if (EVT_LOCAL_VAR_CUTOFF >= var) {
1798 return EVT_INDEX_OF_LOCAL_VAR(var);
1799 }
1800 return var;
1801}

Referenced by evt_handle_bind(), and evt_handle_bind_lock().

◆ set_script_timescale()

void set_script_timescale ( Evt * script,
f32 timescale )

Definition at line 715 of file script_list.c.

715 {
716 script->timeScale = timescale * GlobalTimeRate;
717}
f32 timeScale
f32 GlobalTimeRate
Definition script_list.c:6

Referenced by evt_handle_set_timescale().

◆ sin_deg()

f32 sin_deg ( f32 x)

Definition at line 726 of file 43F0.c.

726 {
727 return sins(_wrap_trig_lookup_value(DEG_TO_BINANG(theta))) * SHT_MINV;
728}
u16 _wrap_trig_lookup_value(f32 theta)
Definition 43F0.c:694
#define DEG_TO_BINANG(x)
Definition macros.h:136
#define SHT_MINV
Definition macros.h:141

◆ cos_deg()

f32 cos_deg ( f32 x)

Definition at line 730 of file 43F0.c.

730 {
731 return coss(_wrap_trig_lookup_value(DEG_TO_BINANG(theta))) * SHT_MINV;
732}

◆ sin_rad()

f32 sin_rad ( f32 x)

Definition at line 712 of file 43F0.c.

712 {
713 return sins(_wrap_trig_lookup_value(RAD_TO_BINANG(theta))) * SHT_MINV;
714}
#define RAD_TO_BINANG(x)
Definition macros.h:137

Referenced by action_hammer_play_hit_fx(), action_update_hit_lava(), action_update_parasol(), action_update_spin(), action_update_use_spinning_flower(), action_update_use_tweester(), add_part_decor_steam(), add_xz_vec3f(), add_xz_vec3f_copy1(), add_xz_vec3f_copy2(), appendGfx_background_texture(), apply_constraints_to_lead_amount(), btl_state_update_9(), btl_state_update_end_player_turn(), btl_state_update_end_turn(), btl_state_update_partner_menu(), btl_state_update_peach_menu(), btl_state_update_player_menu(), btl_state_update_twink_menu(), btl_state_update_victory(), ChompChainAddPolarPos(), ChompChainGetPolarX(), create_camera_leadplayer_matrix(), Entity_BoardedFloor_update_fragments(), entity_BombableRock_update_fragments(), entity_Chest_close(), entity_Chest_open(), entity_GiantChest_give_equipment(), entity_GiantChest_open(), entity_HeartBlockContent__anim_heal(), entity_HiddenPanel_flip_over(), entity_inactive_block_hit_anim(), entity_inactive_block_recoil_anim(), entity_Padlock_push_player(), entity_StarBoxLauncher_launch(), entity_TrumpetPlant_create_effect(), entity_TrumpetPlant_spawn_coin(), entity_Tweester_move(), entity_WoodenCrate_update_fragments(), func_802BC3E4_E2ED14(), interp_lookat_pos(), npc_do_other_npc_collision(), npc_do_player_collision(), npc_move_heading(), npc_raycast_down_around(), npc_raycast_down_sides(), npc_raycast_up_corners(), play_movement_dust_effects(), player_raycast_up_corners(), sfx_compute_spatialized_sound_params_ignore_depth(), sync_held_position(), unkVtxFunc001(), update_camera_interp_pos(), update_camera_no_interp(), update_camera_unused_ahead(), update_camera_unused_confined(), update_camera_unused_radial(), update_item_entity_collectable(), update_lerp(), update_lerp_battle(), and virtual_entity_move_polar().

◆ cos_rad()

◆ round()

s32 round ( f32 x)

Definition at line 571 of file 43F0.c.

571 {
572 if (!(x >= 0.0f)) {
573 return -(s32)(0.5 - x);
574 } else {
575 return (s32)(0.5 + x);
576 }
577}

Referenced by atan2().

◆ atan2()

f32 atan2 ( f32 startX,
f32 startZ,
f32 endX,
f32 endZ )

Definition at line 616 of file 43F0.c.

616 {
617 f32 dx = endX - startX;
618 f32 dz = endZ - startZ;
619 f32 absXDiff = fabsf(dx);
620 f32 absZDiff = fabsf(dz);
621 f32 ret;
622
623 if (absZDiff < absXDiff) {
624 ret = (absZDiff / absXDiff) * 45.0f;
625 ret *= sAtanFactors[round(2.0f * ret)];
626 if (dx >= 0.0f) {
627 if (dz >= 0.0f) {
628 return ret + 90.0f;
629 } else {
630 return 90.0f - ret;
631 }
632 }
633 if (dz >= 0.0f) {
634 return 270.0f - ret;
635 } else {
636 return ret + 270.0f;
637 }
638 } else {
639 if (absZDiff == 0.0f) {
640 return 0.0f;
641 }
642 ret = (absXDiff / absZDiff) * 45.0f;
643 ret *= sAtanFactors[round(2.0f * ret)];
644 if (dz >= 0.0f) {
645 if (dx >= 0.0f) {
646 return 180.0f - ret;
647 } else {
648 return ret + 180.0f;
649 }
650 } else if (!(dx >= 0.0f)) {
651 return 360.0f - ret;
652 }
653 }
654 return ret;
655}
s32 round(f32 x)
Definition 43F0.c:571
f32 sAtanFactors[]
Definition 43F0.c:30

◆ clamp_angle()

f32 clamp_angle ( f32 theta)

Definition at line 579 of file 43F0.c.

579 {
580 if (fabsf(theta) > 3600.0f) {
581 s32 thetaInt = theta;
582
583 if (thetaInt >= 0) {
584 thetaInt = -(thetaInt / 360 * 360) + thetaInt;
585 } else {
586 thetaInt = -thetaInt;
587 thetaInt = (thetaInt / 360 * 360) - thetaInt;
588 }
589
590 return thetaInt;
591 }
592
593 do {
594 if (theta < 0.0f) {
595 theta += 360.0f;
596 }
597 if (theta >= 360.0f) {
598 theta -= 360.0f;
599 }
600 } while (!(theta >= 0.0f) || !(theta < 360.0f));
601
602 return theta;
603}

◆ sign()

s32 sign ( s32 value)

Definition at line 375 of file 43F0.c.

375 {
376 s32 sign = -1;
377
378 if (val >= 0) {
379 sign = val > 0;
380 }
381 return sign;
382}

Referenced by imgfx_mesh_make_wavy(), pause_interp_text_scroll(), pause_interp_vertical_scroll(), pause_partners_update(), pause_tabs_update(), show_immune_bonk(), sign(), and signF().

◆ check_player_action_debug()

b32 check_player_action_debug ( void )

Definition at line 1016 of file 77480.c.

1016 {
1020 }
1021 return TRUE;
1022 }
1023 return FALSE;
1024}
@ DEBUG_SCRIPTS_NONE
Definition enums.h:4274
@ BUTTON_R
Definition enums.h:2781

Referenced by phys_main_collision_below(), player_fall_distance(), and update_player().

◆ battle_heap_create()

s32 battle_heap_create ( void )

Definition at line 22 of file heap.c.

22 {
24 return -1;
25 } else {
26 return 0;
27 }
28}
#define BATTLE_HEAP_SIZE
Definition macros.h:118

Referenced by battle_heap_create_obfuscated(), state_step_end_battle(), state_step_file_select(), and state_step_pause().

◆ test_ray_zones()

s32 test_ray_zones ( f32 startX,
f32 startY,
f32 startZ,
f32 dirX,
f32 dirY,
f32 dirZ,
f32 * hitX,
f32 * hitY,
f32 * hitZ,
f32 * hitDepth,
f32 * nx,
f32 * ny,
f32 * nz )

Definition at line 866 of file collision.c.

867 {
868 Collider* collider;
869 CollisionData* collisionData;
870 ColliderTriangle* triangle;
871 s32 i, j;
872 s32 colliderID;
873
874 collisionData = &gZoneCollisionData;
875 gCollisionRayDirX = dirX;
876 gCollisionRayDirY = dirY;
877 gCollisionRayDirZ = dirZ;
878 gCollisionRayStartX = startX;
879 gCollisionRayStartY = startY;
880 gCollisionRayStartZ = startZ;
881 gCollisionRayLength = *hitDepth;
882 colliderID = NO_COLLIDER;
883
884 for (i = 0; i < collisionData->numColliders; i++) {
885 collider = &collisionData->colliderList[i];
886
887 if (collider->flags & COLLIDER_FLAG_IGNORE_PLAYER)
888 continue;
889
890 if (collider->numTriangles == 0 || collider->aabb == NULL)
891 continue;
892
893 triangle = collider->triangleTable;
894 for (j = 0; j < collider->numTriangles; j++) {
895 if (test_ray_triangle_down(triangle++, collisionData->vertices)) {
896 colliderID = i;
897 }
898 }
899 }
900
901 if (colliderID > NO_COLLIDER) {
902 *hitX = gCollisionPointX;
903 *hitY = gCollisionPointY;
904 *hitZ = gCollisionPointZ;
905 *hitDepth = gCollisionRayLength;
906 *hitNx = gCollisionNormalX;
907 *hitNy = gCollisionNormalY;
908 *hitNz = gCollisionNormalZ;
909 return colliderID;
910 } else {
911 return colliderID;
912 }
913}
BSS f32 gCollisionNormalY
Definition collision.c:49
BSS f32 gCollisionRayStartZ
Definition collision.c:40
BSS f32 gCollisionNormalX
Definition collision.c:48
CollisionData gZoneCollisionData
Definition collision.c:36
BSS f32 gCollisionNormalZ
Definition collision.c:50
BSS f32 gCollisionPointX
Definition collision.c:44
BSS f32 gCollisionPointZ
Definition collision.c:46
BSS f32 gCollisionRayStartY
Definition collision.c:39
BSS f32 gCollisionRayLength
Definition collision.c:47
BSS f32 gCollisionPointY
Definition collision.c:45
BSS f32 gCollisionRayDirX
Definition collision.c:41
s32 test_ray_triangle_down(ColliderTriangle *triangle, Vec3f *vertices)
Definition collision.c:602
BSS f32 gCollisionRayStartX
Definition collision.c:38
BSS f32 gCollisionRayDirZ
Definition collision.c:43
BSS f32 gCollisionRayDirY
Definition collision.c:42

Referenced by test_ray_zone(), and test_ray_zone_aabb().

◆ test_ray_colliders()

s32 test_ray_colliders ( s32 ignoreFlags,
f32 startX,
f32 startY,
f32 startZ,
f32 dirX,
f32 dirY,
f32 dirZ,
f32 * hitX,
f32 * hitY,
f32 * hitZ,
f32 * hitDepth,
f32 * hitNx,
f32 * hitNy,
f32 * hitNz )

Definition at line 768 of file collision.c.

769 {
770 Collider* collider;
771 CollisionData* collisionData;
772 ColliderTriangle* triangle;
773 s32 i, j;
774 s32 colliderID;
775 f32 min_x, min_y, min_z, max_x, max_y, max_z;
776
777 if (dirX == 0 && dirY == 0 && dirZ == 0) {
778 return 0;
779 }
780
781 collisionData = &gCollisionData;
782 gCollisionRayDirX = dirX;
783 gCollisionRayDirY = dirY;
784 gCollisionRayDirZ = dirZ;
785 gCollisionRayStartX = startX;
786 gCollisionRayStartY = startY;
787 gCollisionRayStartZ = startZ;
788 gCollisionRayLength = *hitDepth;
789 colliderID = NO_COLLIDER;
790
791 if (dirX < 0) {
792 min_x = startX + dirX * gCollisionRayLength;
793 max_x = startX;
794 } else {
795 min_x = startX;
796 max_x = startX + dirX * gCollisionRayLength;
797 }
798
799 if (dirY < 0) {
800 min_y = startY + dirY * gCollisionRayLength;
801 max_y = startY;
802 } else {
803 min_y = startY;
804 max_y = startY + dirY * gCollisionRayLength;
805 }
806
807 if (dirZ < 0) {
808 min_z = startZ + dirZ * gCollisionRayLength;
809 max_z = startZ;
810 } else {
811 min_z = startZ;
812 max_z = startZ + dirZ * gCollisionRayLength;
813 }
814
815 for (i = 0; i < collisionData->numColliders; i++) {
816 collider = &collisionData->colliderList[i];
817
818 if ((collider->flags & ignoreFlags) ||
819 collider->numTriangles == 0 ||
820 max_x < collider->aabb->min.x ||
821 min_x > collider->aabb->max.x ||
822 max_z < collider->aabb->min.z ||
823 min_z > collider->aabb->max.z ||
824 max_y < collider->aabb->min.y ||
825 min_y > collider->aabb->max.y)
826 {
827 continue;
828 }
829
830 triangle = collider->triangleTable;
831 if (gCollisionRayDirX == 0 && gCollisionRayDirZ == 0 && gCollisionRayDirY == -1.0) {
832 for (j = 0; j < collider->numTriangles; j++) {
833 if (test_ray_triangle_down(triangle++, collisionData->vertices)) {
834 colliderID = i;
835 }
836 }
837 } else if (gCollisionRayDirY == 0) {
838 for (j = 0; j < collider->numTriangles; j++) {
839 if (test_ray_triangle_horizontal(triangle++, collisionData->vertices)) {
840 colliderID = i;
841 }
842 }
843 } else {
844 for (j = 0; j < collider->numTriangles; j++) {
845 if (test_ray_triangle_general(triangle++, collisionData->vertices)) {
846 colliderID = i;
847 }
848 }
849 }
850 }
851
852 if (colliderID > NO_COLLIDER) {
853 *hitX = gCollisionPointX;
854 *hitY = gCollisionPointY;
855 *hitZ = gCollisionPointZ;
856 *hitDepth = gCollisionRayLength;
857 *hitNx = gCollisionNormalX;
858 *hitNy = gCollisionNormalY;
859 *hitNz = gCollisionNormalZ;
860 return colliderID;
861 } else {
862 return colliderID;
863 }
864}
s32 test_ray_triangle_general(ColliderTriangle *triangle, Vec3f *vertices)
Definition collision.c:505
s32 test_ray_triangle_horizontal(ColliderTriangle *triangle, Vec3f *vertices)
Definition collision.c:675

Referenced by entity_raycast_down(), npc_raycast_down(), npc_raycast_general(), npc_raycast_up(), npc_raycast_up_corner(), player_raycast_down(), player_raycast_general(), player_raycast_up_corner(), and test_ray_to_wall_center().

◆ test_ray_entities()

s32 test_ray_entities ( f32 startX,
f32 startY,
f32 startZ,
f32 dirX,
f32 dirY,
f32 dirZ,
f32 * hitX,
f32 * hitY,
f32 * hitZ,
f32 * hitDepth,
f32 * hitNx,
f32 * hitNy,
f32 * hitNz )

Test a general ray from a given starting position and direction against all entities.

If one is hit, returns the position and normal of the hit and the length along the ray on the output params. All output params are invalid when a value of NO_COLLIDER is returned.

Parameters
startXorigin x position of the ray
startYorigin y position of the ray
startZorigin z position of the ray
dirXnormalized x direction of the ray
dirYnormalized y direction of the ray
dirZnormalized z direction of the ray
[out]hitXnormalized x position of the hit
[out]hitYnormalized y position of the hit
[out]hitZnormalized z position of the hit
[in,out]hitDepthas input, maximum length of the ray; as output, distance along the ray of the hit
[out]hitNxx normal direction of the hit
[out]hitNyy normal direction of the hit
[out]hitNzz normal direction of the hit
Returns
entity index or NO_COLLIDER is none is hit

Definition at line 947 of file collision.c.

948 {
949 f32 hitDepthDown, hitDepthHoriz;
950 s32 type;
951 s32 i, j;
952 Entity* entity;
953 Matrix4f tempMatrix1;
954 Matrix4f tempMatrix2;
955 Vec3f boxVertices[8];
956 ColliderTriangle entityTriangle;
957 s32 entityIndex;
958 f32 h;
959 f32 aabbX, aabbZ;
960 s32 hasCollision;
961 f32 dist, dist2;
962 ColliderTriangle *triangle = &entityTriangle;
963
964 enum {
965 ENTITY_TEST_ANY = 0,
966 ENTITY_TEST_DOWN = 1,
967 ENTITY_TEST_LATERAL = 2,
968 };
969
970 entityIndex = NO_COLLIDER;
971 type = ENTITY_TEST_ANY;
972 hitDepthDown = hitDepthHoriz = *hitDepth;
973
974 if (dirX == 0 && dirZ == 0 && dirY < 0) {
975 hitDepthHoriz = 0;
976 type = ENTITY_TEST_DOWN;
977 } else if (dirY == 0) {
978 hitDepthDown = 0;
979 type = ENTITY_TEST_LATERAL;
980 }
981
983 triangle->oneSided = TRUE;
984 for (i = 0; i < MAX_ENTITIES; i++) {
985 entity = get_entity_by_index(i);
986
987 if (entity == NULL || (entity->flags & (ENTITY_FLAG_SKIP_UPDATE | ENTITY_FLAG_DISABLE_COLLISION))) {
988 continue;
989 }
990
991 dist = hitDepthHoriz + entity->effectiveSize;
992 if (startX > entity->pos.x + dist || startX < entity->pos.x - dist) {
993 continue;
994 }
995
996 if (startZ > entity->pos.z + dist || startZ < entity->pos.z - dist) {
997 continue;
998 }
999
1000 switch (type) {
1001 case ENTITY_TEST_ANY:
1002 case ENTITY_TEST_DOWN:
1003 dist = entity->pos.y;
1004 dist2 = hitDepthDown + entity->effectiveSize * 2;
1005 if (dist + dist2 < startY || startY < dist - dist2) {
1006 continue;
1007 }
1008 break;
1009 case ENTITY_TEST_LATERAL:
1010 dist = entity->pos.y;
1011 dist2 = entity->effectiveSize * 2;
1012 if (dist + dist2 < startY || startY < dist - dist2) {
1013 continue;
1014 }
1015 break;
1016 }
1017
1018 aabbX = entity->aabb.x / 2;
1019 aabbZ = entity->aabb.z / 2;
1020
1021 boxVertices[1].x = boxVertices[2].x = boxVertices[5].x = boxVertices[6].x = -aabbX;
1022 boxVertices[0].x = boxVertices[3].x = boxVertices[4].x = boxVertices[7].x = aabbX;
1023 boxVertices[0].y = boxVertices[1].y = boxVertices[2].y = boxVertices[3].y = 0;
1024 boxVertices[4].y = boxVertices[5].y = boxVertices[6].y = boxVertices[7].y = entity->aabb.y;
1025 boxVertices[0].z = boxVertices[1].z = boxVertices[4].z = boxVertices[5].z = aabbZ;
1026 boxVertices[2].z = boxVertices[3].z = boxVertices[6].z = boxVertices[7].z = -aabbZ;
1027
1028 guMtxXFMF(entity->inverseTransformMatrix, dirX, dirY, dirZ, &gCollisionRayDirX, &gCollisionRayDirY, &gCollisionRayDirZ);
1029 guMtxXFMF(entity->inverseTransformMatrix, startX - entity->pos.x, startY - entity->pos.y,
1031
1032 for (j = 0; j < 12; j++) {
1033 Vec3f* v1 = triangle->v1 = &boxVertices[gEntityColliderFaces[j].x];
1034 Vec3f* v2 = triangle->v2 = &boxVertices[gEntityColliderFaces[j].y];
1035 Vec3f* v3 = triangle->v3 = &boxVertices[gEntityColliderFaces[j].z];
1036 triangle->e13.x = v3->x - v1->x;
1037 triangle->e13.y = v3->y - v1->y;
1038 triangle->e13.z = v3->z - v1->z;
1039 triangle->e21.x = v1->x - v2->x;
1040 triangle->e21.y = v1->y - v2->y;
1041 triangle->e21.z = v1->z - v2->z;
1042 triangle->e32.x = v2->x - v3->x;
1043 triangle->e32.y = v2->y - v3->y;
1044 triangle->e32.z = v2->z - v3->z;
1045 triangle->normal.x = gEntityColliderNormals[j].x;
1046 triangle->normal.y = gEntityColliderNormals[j].y;
1047 triangle->normal.z = gEntityColliderNormals[j].z;
1048
1049 if (hasCollision = test_ray_triangle_general(&entityTriangle, boxVertices)) {
1050 break;
1051 }
1052 }
1053
1054 if (hasCollision && gCollisionRayLength < *hitDepth) {
1055 entityIndex = i;
1056 *hitDepth = gCollisionRayLength;
1057
1058 switch (type) {
1059 case ENTITY_TEST_ANY:
1060 hitDepthDown = gCollisionRayLength;
1061 hitDepthHoriz = gCollisionRayLength;
1062 break;
1063 case ENTITY_TEST_DOWN:
1064 hitDepthDown = gCollisionRayLength;
1065 break;
1066 case ENTITY_TEST_LATERAL:
1067 hitDepthHoriz = gCollisionRayLength;
1068 break;
1069 }
1070
1071 guRotateF(tempMatrix1, entity->rot.x, 1.0f, 0.0f, 0.0f);
1072 guRotateF(tempMatrix2, entity->rot.z, 0.0f, 0.0f, 1.0f);
1073 guMtxCatF(tempMatrix1, tempMatrix2, tempMatrix1);
1074 guRotateF(tempMatrix2, entity->rot.y, 0.0f, 1.0f, 0.0f);
1075 guMtxCatF(tempMatrix1, tempMatrix2, tempMatrix1);
1076 guTranslateF(tempMatrix2, entity->pos.x, entity->pos.y, entity->pos.z);
1077 guMtxCatF(tempMatrix1, tempMatrix2, tempMatrix1);
1078 guMtxXFMF(tempMatrix1, gCollisionPointX, gCollisionPointY, gCollisionPointZ, hitX, hitY, hitZ);
1079
1081 *hitNx = gCollisionNormalX * h;
1082 *hitNy = gCollisionNormalY * h;
1083 *hitNz = gCollisionNormalZ * h;
1084 }
1085 }
1086
1087 return entityIndex;
1088}
Vec3f gEntityColliderNormals[]
Definition collision.c:63
Vec3s gEntityColliderFaces[]
Definition collision.c:54
Vec3s pos
Definition demo_api.c:17
@ ENTITY_FLAG_SKIP_UPDATE
Definition enums.h:2643
@ ENTITY_FLAG_DISABLE_COLLISION
Definition enums.h:2618
Matrix4f inverseTransformMatrix
f32 effectiveSize

Referenced by entity_raycast_down(), npc_raycast_down(), npc_raycast_general(), npc_raycast_up(), npc_raycast_up_corner(), player_raycast_down(), player_raycast_general(), and player_raycast_up_corner().

◆ mem_clear()

void mem_clear ( void * data,
s32 numBytes )

Definition at line 422 of file 43F0.c.

422 {
423 u8* addressableData = data;
424
425 while (numBytes > 0) {
426 *addressableData++ = 0;
427 numBytes--;
428 }
429}

◆ startup_set_fade_screen_color()

void startup_set_fade_screen_color ( s16 color)

◆ startup_set_fade_screen_alpha()

void startup_set_fade_screen_alpha ( s16 alpha)

◆ get_xz_dist_to_player()

f32 get_xz_dist_to_player ( f32 x,
f32 z )

◆ func_800E06C0()

void func_800E06C0 ( s32 arg0)

Definition at line 1160 of file 77480.c.

1160 {
1161 D_8010C950 = (arg0 == 1);
1162}
s32 D_8010C950
Definition 77480.c:37

Referenced by update_triggers().

◆ close_status_bar()

void close_status_bar ( void )

Definition at line 1451 of file inventory.c.

1451 {
1452 StatusBar* statusBar = &gStatusBar;
1453
1454 if (statusBar->hidden != TRUE) {
1455 statusBar->hidden = TRUE;
1456 statusBar->showTimer = 0;
1457 statusBar->unk_3B = TRUE;
1458 }
1459}
StatusBar gStatusBar
Definition inventory.c:23

Referenced by check_conversation_trigger(), check_input_status_bar(), destroy_popup_menu(), initialize_status_bar(), and shop_close_item_select_popup().

◆ func_802C39F8()

Evt * func_802C39F8 ( Evt * parentScript,
Bytecode * nextLine,
s32 newState )

Definition at line 419 of file script_list.c.

419 {
420 Evt* child;
421 s32 curScriptIndex;
422 s32 i;
423 s32 scriptListCount;
424
425 for (i = 0; i < MAX_SCRIPTS; i++) {
426 if ((*gCurrentScriptListPtr)[i] == NULL) {
427 break;
428 }
429 }
430
431 ASSERT(i < MAX_SCRIPTS);
432 curScriptIndex = i;
433
434 (*gCurrentScriptListPtr)[curScriptIndex] = child = heap_malloc(sizeof(*child));
435 gNumScripts++;
436 ASSERT(child != NULL);
437
438 child->stateFlags = newState | EVT_FLAG_ACTIVE;
439 child->ptrNextLine = nextLine;
440 child->ptrFirstLine = nextLine;
441 child->ptrCurLine = nextLine;
443 child->userData = NULL;
444 child->blockingParent = NULL;
445 child->parentScript = parentScript;
446 child->childScript = NULL;
447 child->priority = parentScript->priority;
448 child->id = UniqueScriptCounter++;
449 child->owner1.actorID = parentScript->owner1.actorID;
450 child->owner2.npcID = parentScript->owner2.npcID;
451 child->loopDepth = -1;
452 child->switchDepth = -1;
453 child->groupFlags = parentScript->groupFlags;
454 child->ptrSavedPos = NULL;
455 child->array = parentScript->array;
456 child->flagArray = parentScript->flagArray;
457 child->timeScale = GlobalTimeRate;
458 child->frameCounter = 0.0f;
459 child->unk_158 = 0;
460
461 scriptListCount = 0;
462
463 for (i = 0; i < ARRAY_COUNT(child->varTable); i++) {
464 child->varTable[i] = parentScript->varTable[i];
465 }
466
467 for (i = 0; i < ARRAY_COUNT(child->varFlags); i++) {
468 child->varFlags[i] = parentScript->varFlags[i];
469 }
470
471 find_script_labels(child);
472 if (IsUpdatingScripts) {
473 scriptListCount = gScriptListCount++;
474 gScriptIndexList[scriptListCount] = curScriptIndex;
475 gScriptIdList[scriptListCount] = child->id;
476 }
477
478 if (UniqueScriptCounter == 0) {
480 }
481
483 return child;
484}
Bytecode * ptrNextLine
u8 stateFlags
struct Evt * parentScript
u8 curOpcode
struct Evt * childScript
u8 groupFlags
struct Evt * blockingParent
s8 switchDepth
s8 loopDepth
s32 unk_158
Bytecode * ptrSavedPos
Bytecode * ptrCurLine
void * userData
f32 frameCounter
Bytecode * ptrFirstLine
union Evt::@10 owner1
Initially -1.
u8 priority
@ EVT_OP_INTERNAL_FETCH
Definition evt.h:10
@ EVT_FLAG_ACTIVE
Definition evt.h:158
s32 UniqueScriptCounter
Definition script_list.c:4
BSS s32 gScriptListCount
Definition script_list.c:17
BSS s32 gScriptIdList[MAX_SCRIPTS]
Definition script_list.c:16
void find_script_labels(Evt *script)
void suspend_frozen_scripts(Evt *script)
BSS s32 gScriptIndexList[MAX_SCRIPTS]
Definition script_list.c:15
s32 IsUpdatingScripts
Definition script_list.c:5
BSS ScriptList * gCurrentScriptListPtr
Definition script_list.c:14
BSS s32 gNumScripts
Definition script_list.c:11

Referenced by evt_handle_child_thread().

◆ start_child_script()

Evt * start_child_script ( Evt * parentScript,
EvtScript * source,
s32 initialState )

Definition at line 350 of file script_list.c.

350 {
351 s32 curScriptIndex;
352 s32 scriptListCount;
353 Evt* child;
354 s32 i;
355
356 for (i = 0; i < MAX_SCRIPTS; i++) {
357 if ((*gCurrentScriptListPtr)[i] == NULL) {
358 break;
359 }
360 }
361
362 ASSERT(i < MAX_SCRIPTS);
363 curScriptIndex = i;
364
365 (*gCurrentScriptListPtr)[curScriptIndex] = child = heap_malloc(sizeof(*child));
366 gNumScripts++;
367 ASSERT(child != NULL);
368
369 parentScript->childScript = child;
370 parentScript->stateFlags |= EVT_FLAG_BLOCKED_BY_CHILD;
372 child->ptrCurLine = child->ptrFirstLine = child->ptrNextLine = (Bytecode*)source;
373
375 child->userData = NULL;
376 child->blockingParent = parentScript;
377 child->childScript = NULL;
378 child->parentScript = NULL;
379 child->priority = parentScript->priority + 1;
380 child->id = UniqueScriptCounter++;
381 child->owner1 = parentScript->owner1;
382 child->owner2 = parentScript->owner2;
383 child->loopDepth = -1;
384 child->switchDepth = -1;
385 child->groupFlags = parentScript->groupFlags;
386 child->ptrSavedPos = NULL;
387 child->array = parentScript->array;
388 child->flagArray = parentScript->flagArray;
389 child->timeScale = GlobalTimeRate;
390 child->frameCounter = 0.0f;
391 child->unk_158 = 0;
392
393 scriptListCount = 0;
394
395 for (i = 0; i < ARRAY_COUNT(child->varTable); i++) {
396 child->varTable[i] = parentScript->varTable[i];
397 }
398
399 for (i = 0; i < ARRAY_COUNT(child->varFlags); i++) {
400 child->varFlags[i] = parentScript->varFlags[i];
401 }
402
403 find_script_labels(child);
404 if (IsUpdatingScripts) {
405 scriptListCount = gScriptListCount++;
406 gScriptIndexList[scriptListCount] = curScriptIndex;
407 gScriptIdList[scriptListCount] = child->id;
408 }
409
411
412 if (UniqueScriptCounter == 0) {
414 }
415
416 return child;
417}
s32 Bytecode
Definition evt.h:7
@ EVT_FLAG_BLOCKED_BY_CHILD
Definition evt.h:160

Referenced by evt_handle_exec_wait().

◆ restart_script()

Evt * restart_script ( Evt * script)

Definition at line 527 of file script_list.c.

527 {
528 Bytecode* ptrFirstLine = script->ptrFirstLine;
529
530 // frameCounter gets set to 0 twice which makes me think a macro is being used here
531 script->loopDepth = -1;
532 script->switchDepth = -1;
533 script->frameCounter = 0;
535
536 script->ptrNextLine = ptrFirstLine;
537 script->ptrCurLine = ptrFirstLine;
538 script->timeScale = 1.0f;
539 script->frameCounter = 0;
540 script->unk_158 = 0;
541
542 script->timeScale = GlobalTimeRate;
543
544 find_script_labels(script);
546
547 return script;
548}

Referenced by btl_cam_move(), and evt_handle_jump().

◆ clear_virtual_entity_list()

void clear_virtual_entity_list ( void )

Definition at line 652 of file virtual_entity.c.

652 {
653 s32 i;
654
657 } else {
659 }
660
661 for (i = 0; i < ARRAY_COUNT(*gCurrentVirtualEntityListPtr); i++) {
662 (*gCurrentVirtualEntityListPtr)[i] = heap_malloc(sizeof(VirtualEntity));
664 (*gCurrentVirtualEntityListPtr)[i]->entityModelIndex = -1;
665 }
666
669}
s32 create_worker_scene(void(*updateFunc)(void), void(*renderFunc)(void))
Definition worker.c:32
VirtualEntityList wWorldVirtualEntityList
Definition script_list.c:46
void virtual_entity_list_render_world(void)
void virtual_entity_list_update(void)
s32 create_worker_backUI(void(*updateFunc)(void), void(*drawFunc)(void))
Definition worker.c:94
VirtualEntityList * gCurrentVirtualEntityListPtr
Definition script_list.c:47
VirtualEntityList bBattleVirtualEntityList
Definition script_list.c:45
void virtual_entity_list_render_UI(void)

Referenced by clear_script_list().

◆ reset_model_animators()

void reset_model_animators ( void )

Definition at line 258 of file model_api.c.

258 {
259 s32 i;
260
263 } else {
265 }
266
267 for (i = 0; i < MAX_ANIMATED_MODELS; i++) {
268 AnimatedModel* model = heap_malloc(sizeof(*model));
269
270 (*gCurrentMeshAnimationListPtr)[i] = model;
272 (*gCurrentMeshAnimationListPtr)[i]->animModelID = -1;
273 }
274
276}
void update_animated_models(void)
Definition model_api.c:7
AnimatedModelList * gCurrentMeshAnimationListPtr
Definition script_list.c:29
AnimatedModelList gBattleMeshAnimationList
Definition script_list.c:27
AnimatedModelList gWorldMeshAnimationList
Definition script_list.c:28
void render_animated_models(void)
Definition model_api.c:19
#define MAX_ANIMATED_MODELS
Definition macros.h:85

Referenced by clear_script_list().

◆ init_virtual_entity_list()

void init_virtual_entity_list ( void )

◆ init_model_animators()

void init_model_animators ( void )

Definition at line 278 of file model_api.c.

Referenced by init_script_list().

◆ play_model_animation()

void play_model_animation ( s32 index,
s16 * animPos )

Definition at line 1101 of file animator.c.

1101 {
1102 ModelAnimator* animator = (*gCurrentAnimMeshListPtr)[index & ~BATTLE_ID_BIT];
1103
1104 if (animator->animationBuffer != NULL) {
1105 animPos = (s16*) (((s32)animPos & 0xFFFFFF) + (s32)animator->animationBuffer); // TODO: array access? / cleanup
1106 }
1107 animator->animReadPos = animPos;
1108 animator->savedReadPos = animPos;
1109 animator->treeIndexPos = 0;
1110 animator->nextUpdateTime = 1.0f;
1111}

Referenced by entity_BellbellPlant_idle(), entity_CymbalPlant_idle(), entity_HitItemBlock_play_anim(), entity_PinkFlower_idle(), entity_ScriptSpring_idle(), entity_SimpleSpring_idle(), entity_TrumpetPlant_idle(), and func_802BC0B8_E2E9E8().

◆ heap_free()

◆ load_battle_hit_asset()

void load_battle_hit_asset ( const char * hitName)

Definition at line 166 of file collision.c.

166 {
167 if (hitName == NULL) {
169 } else {
170 u32 assetSize;
172 void* compressedData = load_asset_by_name(hitName, &assetSize);
173 HitFile* uncompressedData = heap_malloc(assetSize);
174
175 decode_yay0(compressedData, uncompressedData);
176 general_heap_free(compressedData);
177
178 map->hitAssetCollisionOffset = uncompressedData->collisionOffset;
179
180 load_hit_data(0, uncompressedData);
181
182 heap_free(uncompressedData);
183 }
184}
void load_hit_data(s32 idx, HitFile *hit)
Definition collision.c:186
u32 collisionOffset
Definition collision.c:5
void * load_asset_by_name(const char *assetName, u32 *decompressedSize)
Definition world.c:251
s32 heap_free(void *ptr)
Definition heap.c:42
void decode_yay0(void *src, void *dst)
MapSettings * get_current_map_settings(void)
Definition world.c:224
s32 hitAssetCollisionOffset
Definition map.h:20
Fields other than main, entryList, entryCount, background, and tattle are initialised when the map lo...
Definition map.h:18

Referenced by btl_state_update_normal_start().

◆ load_data_for_models()

void load_data_for_models ( struct ModelNode * model,
s32 romOffset,
s32 size )

Definition at line 3318 of file model.c.

3318 {
3319 Matrix4f mtx;
3320
3321 guMtxIdentF(mtx);
3322
3323 if (texturesOffset != 0) {
3324 mdl_load_all_textures(rootModel, texturesOffset, size);
3325 }
3326
3327 *gCurrentModelTreeRoot = rootModel;
3328 TreeIterPos = 0;
3329
3330 if (rootModel != NULL) {
3331 load_model_transforms(rootModel, NULL, mtx, 0);
3332 }
3333}
BSS s32 TreeIterPos
Definition model.c:1336
ModelNode ** gCurrentModelTreeRoot
Definition model.c:1308
void load_model_transforms(ModelNode *model, ModelNode *parent, Matrix4f mdlTxMtx, s32 treeDepth)
Definition model.c:3335
void mdl_load_all_textures(ModelNode *rootModel, s32 romOffset, s32 size)
Definition model.c:2322

Referenced by btl_state_update_normal_start(), and load_map_by_IDs().

◆ load_player_actor()

void load_player_actor ( void )

Definition at line 1208 of file 190B20.c.

1208 {
1209 BattleStatus* battleStatus = &gBattleStatus;
1210 Actor* player;
1211 ActorPart* part;
1212 DecorationTable* decorations;
1213 ActorPartMovement* partMovement;
1214 s32 i;
1215 s32 j;
1216
1217 player = battleStatus->playerActor = heap_malloc(sizeof(*player));
1218
1219 ASSERT(player != NULL);
1220
1221 player->unk_134 = battleStatus->unk_93++;
1222 player->footStepCounter = 0;
1223 player->flags = 0;
1226
1228 player->homePos.x = player->curPos.x = -130.0f;
1229 player->homePos.y = player->curPos.y = 0.0f;
1230 player->homePos.z = player->curPos.z = -10.0f;
1231 } else {
1232 player->homePos.x = player->curPos.x = -95.0f;
1233 player->homePos.y = player->curPos.y = 0.0f;
1234 player->homePos.z = player->curPos.z = 0.0f;
1235 }
1236
1237 player->headOffset.x = 0;
1238 player->headOffset.y = 0;
1239 player->headOffset.z = 0;
1240 player->rot.x = 0.0f;
1241 player->rot.y = 0.0f;
1242 player->rot.z = 0.0f;
1243 player->rotPivotOffset.x = 0;
1244 player->rotPivotOffset.y = 0;
1245 player->rotPivotOffset.z = 0;
1246 player->verticalRenderOffset = 0;
1247 player->yaw = 0.0f;
1249 player->scale.x = 1.0f;
1250 player->scale.y = 1.0f;
1251 player->scale.z = 1.0f;
1252 player->scaleModifier.x = 1.0f;
1253 player->scaleModifier.y = 1.0f;
1254 player->scaleModifier.z = 1.0f;
1255 player->size.x = player->actorBlueprint->size.x;
1256 player->size.y = player->actorBlueprint->size.y;
1257 player->actorID = 0;
1258 player->healthBarPos.x = player->curPos.x;
1259 player->healthBarPos.y = player->curPos.y;
1260 player->healthBarPos.z = player->curPos.z;
1261 player->scalingFactor = 1.0f;
1262 player->attackResultEffect = NULL;
1263 player->actionRatingCombo = 0;
1264 player->actionRatingTime = 0;
1265 player->statusIconOffset.x = 0;
1266 player->statusIconOffset.y = 0;
1267 player->statusTextOffset.x = 0;
1268 player->statusTextOffset.y = 0;
1269 player->idleSource = NULL;
1270 player->takeTurnSource = NULL;
1271 player->handleEventSource = NULL;
1272 player->handlePhaseSource = NULL;
1273 player->idleScript = NULL;
1274 player->takeTurnScript = NULL;
1275 player->handleEventScript = NULL;
1276 player->handlePhaseScript = NULL;
1277 player->turnPriority = 0;
1279 player->debuff = 0;
1280 player->debuffDuration = 0;
1281 player->staticStatus = 0;
1282 player->staticDuration = 0;
1283 player->stoneStatus = 0;
1284 player->stoneDuration = 0;
1285 player->koStatus = 0;
1286 player->koDuration = 0;
1287 player->transparentStatus = 0;
1288 player->transparentDuration = 0;
1289 player->isGlowing = FALSE;
1290 player->unk_21E = 0;
1291 player->disableDismissTimer = 0;
1292 player->attackBoost = 0;
1293 player->defenseBoost = 0;
1294 player->chillOutAmount = 0;
1295 player->chillOutTurns = 0;
1296 player->statusAfflicted = 0;
1297 player->actorTypeData1[0] = bActorSoundTable[player->actorType].walk[0];
1298 player->actorTypeData1[1] = bActorSoundTable[player->actorType].walk[1];
1299 player->actorTypeData1[2] = bActorSoundTable[player->actorType].fly[0];
1300 player->actorTypeData1[3] = bActorSoundTable[player->actorType].fly[1];
1301 player->actorTypeData1[4] = bActorSoundTable[player->actorType].jump;
1302 player->actorTypeData1[5] = bActorSoundTable[player->actorType].hurt;
1303 player->actorTypeData1b[0] = bActorSoundTable[player->actorType].delay[0];
1304 player->actorTypeData1b[1] = bActorSoundTable[player->actorType].delay[1];
1305
1306 for (i = 0; i < ARRAY_COUNT(player->loopingSoundID); i++) {
1307 player->loopingSoundID[i] = 0;
1308 }
1309
1310 part = heap_malloc(sizeof(*part));
1311 player->partsTable = part;
1312
1313 ASSERT(part != NULL)
1314
1315 player->numParts = 1;
1316 part->staticData = bMarioParts;
1317 part->partOffset.x = 0;
1318 part->partOffset.y = 0;
1319 part->partOffset.z = 0;
1320 part->partOffset.x = 12;
1321 part->partOffset.y = 32;
1322 part->partOffset.z = 5;
1323 part->decorationTable = NULL;
1324 part->flags = 0;
1325 part->targetFlags = 0;
1326 part->partOffsetFloat.x = 0.0f;
1327 part->partOffsetFloat.y = 0.0f;
1328 part->partOffsetFloat.z = 0.0f;
1329 part->rotPivotOffset.x = 0;
1330 part->rotPivotOffset.y = 0;
1331 part->rotPivotOffset.z = 0;
1332 part->visualOffset.x = 0;
1333 part->visualOffset.y = 0;
1334 part->visualOffset.z = 0;
1335 part->absolutePos.x = 0.0f;
1336 part->absolutePos.y = 0.0f;
1337 part->absolutePos.z = 0.0f;
1339
1342 } else {
1344 }
1345
1346 part->eventFlags = 0;
1347 part->elementalImmunities = 0;
1348 part->opacity = 255;
1349 part->size.y = player->size.y;
1350 part->size.x = player->size.x;
1351 part->yaw = 0.0f;
1352 part->targetOffset.x = 0;
1353 part->targetOffset.y = 0;
1354 part->targetPriorityOffset = 0;
1355 part->rot.x = 0.0f;
1356 part->rot.y = 0.0f;
1357 part->rot.z = 0.0f;
1358 part->scale.x = 1.0f;
1359 part->scale.y = 1.0f;
1360 part->scale.z = 1.0f;
1361 part->verticalStretch = 1;
1362 part->palAnimPosOffset[0] = 0;
1363 part->palAnimPosOffset[1] = 0;
1364 part->animationRate = 1.0f;
1366 part->nextPart = NULL;
1367 part->partTypeData[0] = bActorSoundTable[player->actorType].walk[0];
1368 part->partTypeData[1] = bActorSoundTable[player->actorType].walk[1];
1369 part->partTypeData[2] = bActorSoundTable[player->actorType].fly[0];
1370 part->partTypeData[3] = bActorSoundTable[player->actorType].fly[1];
1371 part->partTypeData[4] = bActorSoundTable[player->actorType].jump;
1372 part->partTypeData[5] = bActorSoundTable[player->actorType].hurt;
1373 part->actorTypeData2b[0] = bActorSoundTable[player->actorType].delay[0];
1374 part->actorTypeData2b[1] = bActorSoundTable[player->actorType].delay[1];
1375
1376 if (part->idleAnimations != NULL) {
1377 s32 j;
1378
1379 part->decorationTable = heap_malloc(sizeof(*decorations));
1380 decorations = part->decorationTable;
1381
1382 ASSERT(decorations != NULL);
1383
1385 decorations->glowState = GLOW_PAL_OFF;
1386 decorations->flashState = 0;
1387 decorations->flashEnabled = FLASH_PAL_OFF;
1388 decorations->blurUnused = 0;
1389 decorations->blurBufferPos = 0;
1390
1391 for (j = 0; j < ARRAY_COUNT(decorations->posX); j++) {
1392 decorations->posX[j] = player->curPos.x;
1393 decorations->posY[j] = player->curPos.y;
1394 decorations->posZ[j] = player->curPos.z;
1395 }
1396
1397 decorations->blurDrawCount = 3;
1398 decorations->blurEnableCount = 0;
1399 decorations->blurDisableDelay = 0;
1400
1401 for (j = 0; j < ARRAY_COUNT(decorations->effect); j++) {
1402 decorations->effect[j] = NULL;
1403 decorations->type[j] = 0;
1404 }
1405 }
1406
1407 partMovement = part->movement = heap_malloc(sizeof(*partMovement));
1408 ASSERT(partMovement != NULL);
1409
1410 player->shadow.id = create_shadow_type(SHADOW_VARYING_CIRCLE, player->curPos.x, player->curPos.y, player->curPos.z);
1411 player->shadowScale = player->size.x / 24.0;
1413 player->disableEffect = fx_disable_x(0, -142.0f, 34.0f, 1.0f, 0);
1414 player->icePillarEffect = NULL;
1415
1418 player->staticDuration = 127;
1419 }
1420}
s32 bMarioDefenseTable[]
Definition actors.c:128
ActorPartBlueprint bMarioParts[]
Definition actors.c:177
ActorBlueprint bPlayerActorBlueprint
Definition actors.c:158
s32 get_npc_anim_for_status(AnimID *, s32)
Definition 190B20.c:1944
s32 bPlayerStatusTable[]
Definition actors.c:133
struct Evt * handlePhaseScript
struct Evt * takeTurnScript
struct EffectInstance * effect[2]
s8 transparentStatus
struct ActorPartMovement * movement
EvtScript * handleEventSource
Vec2b statusTextOffset
EvtScript * idleSource
s8 disableDismissTimer
f32 shadowScale
s32 elementalImmunities
s32 actorTypeData1[6]
s16 targetPriorityOffset
u8 footStepCounter
struct Evt * idleScript
union Actor::@38 shadow
s32 partTypeData[6]
struct Evt * handleEventScript
Vec3f partOffsetFloat
s16 actorTypeData1b[2]
EvtScript * handlePhaseSource
Vec3f scaleModifier
struct EffectInstance * icePillarEffect
Vec3s healthBarPos
s32 loopingSoundID[2]
s8 chillOutAmount
Vec3f homePos
Vec2bu size
s16 hudElementDataIndex
EvtScript * takeTurnSource
s16 actorTypeData2b[2]
s8 statusAfflicted
s8 staticDuration
s32 * statusTable
s8 debuffDuration
Vec3s rotPivotOffset
s8 transparentDuration
@ DEMO_BTL_FLAG_PARTNER_ACTING
Definition enums.h:3543
@ SHADOW_VARYING_CIRCLE
Definition enums.h:2535
@ FLASH_PAL_OFF
Definition enums.h:2270
s32 create_status_icon_set(void)
s32 create_shadow_type(s32 type, f32 x, f32 y, f32 z)
Definition entity.c:1528
s32 walk[2]
Definition battle.h:235
ActorSounds bActorSoundTable[]
s16 delay[2]
Number of frames to wait between walk/fly sounds. Negative values are in distance.
Definition battle.h:239
s32 fly[2]
Definition battle.h:236
s32 bPeachIdleAnims[]
Definition actors.c:122
u32 bMarioIdleAnims[]
Definition actors.c:53

Referenced by btl_state_update_normal_start().

◆ btl_state_update_normal_start()

void btl_state_update_normal_start ( void )

Definition at line 191 of file btl_states_actions.c.

191 {
192 BattleStatus* battleStatus = &gBattleStatus;
193 EncounterStatus* currentEncounter = &gCurrentEncounter;
194 Battle* battle;
195 Stage* stage;
196 s32 size;
197 StatusBar* statusBar;
198 void* compressedAsset;
199 ModelNode* rootModel;
200 s32 texturesOffset;
201 Actor* actor;
202 Evt* script;
203 s32 enemyNotDone;
204 s32 type;
205 s32 i;
206 s32 j;
207
208 s32* types;
209
210 battle = gCurrentBattlePtr;
211 if (gOverrideBattlePtr != NULL) {
212 battle = gOverrideBattlePtr;
213 }
214
215 if (gCurrentStagePtr == NULL) {
216 stage = battle->stage;
217 } else {
218 stage = gCurrentStagePtr->stage;
219 }
220
221 battleStatus->curStage = stage;
222 switch (gBattleSubState) {
224 #if DX_DEBUG_MENU
225 dx_debug_set_battle_info(gCurrentBattleID << 16 | (gCurrentStageID & 0xFFFF), stage->shape);
226 #endif
227
230 compressedAsset = load_asset_by_name(stage->shape, &size);
231 decode_yay0(compressedAsset, &gMapShapeData);
232 general_heap_free(compressedAsset);
233
234 ASSERT(size <= 0x8000);
235
236 rootModel = gMapShapeData.header.root;
237 texturesOffset = get_asset_offset(stage->texture, &size);
238 if (rootModel != NULL) {
239 load_data_for_models(rootModel, texturesOffset, size);
240 }
242
243 if (stage->bg != NULL) {
244 load_map_bg(stage->bg);
246 }
247
250 }
251
252 battleStatus->controlScript = NULL;
253 battleStatus->camMovementScript = NULL;
254 battleStatus->unk_90 = 0;
255 battleStatus->preUpdateCallback = NULL;
256 battleStatus->initBattleCallback = NULL;
257 battleStatus->curSubmenu = 0;
258 battleStatus->unk_49 = 0;
259 battleStatus->curPartnerSubmenu = 0;
260 battleStatus->unk_4B = 0;
261 battleStatus->totalStarPoints = 0;
262 battleStatus->pendingStarPoints = 0;
263 battleStatus->incrementStarPointDelay = 0;
264 battleStatus->damageTaken = 0;
271 battleStatus->actionCommandMode = AC_MODE_LEARNED;
272 }
273 battleStatus->actionQuality = 0;
274 battleStatus->maxActionQuality = 0;
275 battleStatus->enabledMenusFlags = -1;
276 battleStatus->enabledStarPowersFlags = -1;
277 battleStatus->itemUsesLeft = 0;
278 battleStatus->hammerCharge = 0;
279 battleStatus->jumpCharge = 0;
280 battleStatus->unk_98 = 0;
281 battleStatus->hpDrainCount = 0;
283 if (currentEncounter->forbidFleeing) {
284 gBattleStatus.flags2 &= ~BS_FLAGS2_CAN_FLEE;
285 }
286 battleStatus->endBattleFadeOutRate = 10;
287 battleStatus->waitForState = BATTLE_STATE_0;
288 battleStatus->hammerLossTurns = -1;
289 battleStatus->jumpLossTurns = -1;
290 battleStatus->itemLossTurns = -1;
291 battleStatus->outtaSightActive = 0;
292 battleStatus->waterBlockTurnsLeft = 0;
293 battleStatus->waterBlockAmount = 0;
294 battleStatus->waterBlockEffect = NULL;
295 battleStatus->cloudNineTurnsLeft = 0;
296 battleStatus->cloudNineDodgeChance = 0;
297 battleStatus->cloudNineEffect = NULL;
298 battleStatus->reflectFlags = 0;
299 battleStatus->turboChargeTurnsLeft = 0;
300 battleStatus->turboChargeAmount = 0;
301 battleStatus->stateFreezeCount = 0;
302 battleStatus->merleeAttackBoost = 0;
303 battleStatus->merleeDefenseBoost = 0;
305 battleStatus->unk_433 = -1;
306 battleStatus->hustleTurns = 0;
307 battleStatus->unk_93 = 0;
308 battleStatus->unk_94 = 0;
309 gBattleStatus.flags2 &= ~BS_FLAGS2_PLAYER_TURN_USED;
310 gBattleStatus.flags2 &= ~BS_FLAGS2_PARTNER_TURN_USED;
311 gBattleStatus.flags2 &= ~BS_FLAGS2_OVERRIDE_INACTIVE_PLAYER;
312 gBattleStatus.flags2 &= ~BS_FLAGS2_OVERRIDE_INACTIVE_PARTNER;
313 gBattleStatus.flags2 &= ~BS_FLAGS2_STORED_TURBO_CHARGE_TURN;
314 gBattleStatus.flags2 &= ~BS_FLAGS2_DOING_JUMP_TUTORIAL;
315
316 for (i = 0; i < ARRAY_COUNT(battleStatus->varTable); i++) {
317 battleStatus->varTable[i] = 0;
318 }
319
321 battleStatus->inputBitmask = 0xFFFFF & ~(BUTTON_START | 0xC0);
322 battleStatus->buffEffect = fx_partner_buff(0, 0.0f, 0.0f, 0.0f, 0.0f, 0);
326 battleStatus->camMovementScript = script;
327 battleStatus->camMovementScriptID = script->id;
329 break;
331 statusBar = &gStatusBar;
332 if (does_script_exist(battleStatus->camMovementScriptID)) {
333 break;
334 }
335
336 if (stage->preBattle != NULL) {
337 script = start_script(stage->preBattle, EVT_PRIORITY_A, 0);
338 battleStatus->controlScript = script;
339 battleStatus->controlScriptID = script->id;
340 }
341
342 statusBar->hidden = FALSE;
344
345 for (i = 0; i < ARRAY_COUNT(battleStatus->enemyActors); i++) {
346 battleStatus->enemyActors[i] = NULL;
347 }
348 battleStatus->initialEnemyCount = 0;
349
350 for (i = 0; i < BattleEnemiesCreated; i++) {
351 create_actor(&(*battle->formation)[i]);
353 actor = battleStatus->enemyActors[i];
354
355 while (TRUE) {
356 type = *types;
357 if (type == -1) {
358 battleStatus->initialEnemyCount++;
359 break;
360 } else if (actor->actorType == type) {
361 break;
362 }
363 types++;
364 }
365
366 actor->instigatorValue = 0;
367 if (i == 0) {
368 actor->instigatorValue = currentEncounter->instigatorValue;
369 if (currentEncounter->dizzyAttack.status == STATUS_KEY_DIZZY) {
371 }
372 }
373 }
374
375 if (stage->stageEnemyCount != 0) {
376 if (stage->stageEnemyChance == 0 || (stage->stageEnemyChance > 0 && (rand_int(stage->stageEnemyChance) == 0))) {
378 for (j = 0; i < BattleEnemiesCreated; i++, j++) {
379 create_actor(&(*stage->stageFormation)[j]);
380 actor = battleStatus->enemyActors[i];
381 actor->instigatorValue = 0;
382 if (i == 0) {
383 actor->instigatorValue = 0;
384 if (currentEncounter->dizzyAttack.status == STATUS_KEY_DIZZY) {
386 }
387 }
388
389 }
390 }
391 }
392
394 actor = battleStatus->playerActor;
397 } else {
399 }
400 actor->takeTurnScript = script;
401 actor->takeTurnScriptID = script->id;
402 script->owner1.actorID = ACTOR_PLAYER;
405 break;
407 enemyNotDone = FALSE;
408 for (i = 0; i < BattleEnemiesCreated; i++) {
409 actor = battleStatus->enemyActors[i];
411 enemyNotDone = TRUE;
412 break;
413 } else {
414 actor->takeTurnScript = NULL;
415 }
416 }
417 if (enemyNotDone) {
418 break;
419 }
420
421 actor = battleStatus->playerActor;
423 break;
424 }
425 actor->takeTurnScript = NULL;
426
427 actor = battleStatus->partnerActor;
428 if (actor != NULL) {
430 break;
431 }
432 actor->takeTurnScript = NULL;
433 }
434
435 if (battle->onBattleStart != NULL) {
436 script = start_script(battle->onBattleStart, EVT_PRIORITY_A, 0);
437 battleStatus->controlScript = script;
438 battleStatus->controlScriptID = script->id;
439 }
440 if (battleStatus->darknessMode > BTL_DARKNESS_STATE_NONE) {
443 }
445 currentEncounter->firstStrikeType = FIRST_STRIKE_NONE;
446 }
447
448 switch (currentEncounter->firstStrikeType) {
451 break;
454 break;
455 default:
457 actor = battleStatus->playerActor;
460 } else {
462 }
463 actor->takeTurnScript = script;
464 actor->takeTurnScriptID = script->id;
465 script->owner1.actorID = ACTOR_PLAYER;
466 }
467
468 if (currentEncounter->curEnemy != NULL
469 && currentEncounter->curEnemy->encountered == ENCOUNTER_TRIGGER_SPIN
471 ) {
472 actor = battleStatus->enemyActors[0];
474 actor->takeTurnScript = script;
475 actor->takeTurnScriptID = script->id;
476 script->owner1.enemyID = ACTOR_ENEMY0;
477 }
478
482 break;
483 }
484 break;
486 if (BattleScreenFadeAmt == 0) {
488 break;
489 }
490
492 if (BattleSubStateDelay == 15) {
494 }
495
498 } else {
500 }
501
502 if (BattleScreenFadeAmt < 0) {
504 }
505 break;
507 if (battleStatus->stateFreezeCount == 0) {
510 }
511 break;
512 }
513}
Actor * create_actor(Formation formation)
Definition 190B20.c:1676
@ AC_MODE_NOT_LEARNED
Definition action_cmd.h:60
@ AC_MODE_LEARNED
Definition action_cmd.h:61
BSS Battle * gCurrentBattlePtr
Definition battle.c:19
s32 BattleScreenFadeAmt
Definition 16C8E0.c:49
BSS s32 BattleEnemiesCreated
ShapeFile gMapShapeData
Definition heaps.c:16
EvtScript EVS_Peach_OnActorCreate
StageListRow * gCurrentStagePtr
Definition battle.c:9
BSS s32 BattleSubStateDelay
s32 bActorsIgnoreDuringCount[]
EvtScript EVS_OnBattleInit
Definition camera.c:1171
void btl_set_state(s32 battleState)
EvtScript EVS_Mario_OnActorCreate
s32 takeTurnScriptID
s8 instigatorValue
@ MERLEE_SPELL_NONE
Definition enums.h:1910
@ OVERLAY_NONE
Definition enums.h:2387
@ BS_FLAGS1_ACTORS_VISIBLE
Definition enums.h:3564
@ SCREEN_LAYER_BACK
Definition enums.h:2383
@ DEMO_BTL_FLAG_ENABLED
Definition enums.h:3542
@ BS_FLAGS2_CAN_FLEE
Definition enums.h:3608
@ ENCOUNTER_TRIGGER_SPIN
Definition enums.h:270
@ STATUS_TURN_MOD_DIZZY
Definition enums.h:2232
@ BTL_CAM_DEFAULT
Definition enums.h:4823
@ BTL_SUBSTATE_NORMAL_START_FADE_IN
Definition enums.h:3676
@ BTL_SUBSTATE_NORMAL_START_CREATE_ENEMIES
Definition enums.h:3674
@ BTL_SUBSTATE_NORMAL_START_CHECK_FIRST_STRIKE
Definition enums.h:3675
@ BTL_SUBSTATE_NORMAL_START_INIT
Definition enums.h:3673
@ BTL_SUBSTATE_NORMAL_START_DONE
Definition enums.h:3677
@ BATTLE_STATE_ENEMY_FIRST_STRIKE
Definition enums.h:3634
@ BATTLE_STATE_FIRST_STRIKE
Definition enums.h:3632
@ BATTLE_STATE_BEGIN_TURN
Definition enums.h:3635
@ ABILITY_CHILL_OUT
Definition enums.h:453
@ ABILITY_DIZZY_ATTACK
Definition enums.h:481
@ ACTOR_PLAYER
Definition enums.h:2085
@ ACTOR_ENEMY0
Definition enums.h:2087
@ FIRST_STRIKE_NONE
Definition enums.h:3458
@ FIRST_STRIKE_ENEMY
Definition enums.h:3460
@ FIRST_STRIKE_PLAYER
Definition enums.h:3459
@ BTL_DARKNESS_STATE_NONE
Definition enums.h:6364
@ CAM_TATTLE
Definition enums.h:1802
@ CAM_BATTLE
Definition enums.h:1801
@ EVT_PRIORITY_A
Definition evt.h:153
void load_partner_actor(void)
Definition 190B20.c:1422
void set_screen_overlay_params_back(u8, f32)
void setup_status_bar_for_battle(void)
Definition inventory.c:1472
void set_background(BackgroundHeader *)
Definition background.c:40
void load_battle_hit_asset(const char *hitName)
Definition collision.c:166
void load_data_for_models(struct ModelNode *model, s32 romOffset, s32 size)
Definition model.c:3318
void load_map_bg(char *optAssetName)
Definition background.c:14
s32 get_asset_offset(char *, s32 *)
Definition world.c:273
void btl_cam_use_preset(s32)
Definition camera.c:1919
s32 inflict_status_set_duration(Actor *actor, s32 statusTypeKey, s32 statusDurationKey, s32 duration)
Definition 190B20.c:2581
void load_player_actor(void)
Definition 190B20.c:1208
void set_curtain_scale_goal(f32 scale)
Definition curtains.c:285
EvtScript EVS_PeachEnterStage
EvtScript EVS_ApplyDizzyAttack
EvtScript EVS_MarioEnterStage
ModelNode * root
Definition model.h:174
ShapeFileHeader header
Definition model.h:183
Enemy * curEnemy
Definition npc.h:394
FieldStatus dizzyAttack
Definition npc.h:399
s8 forbidFleeing
Definition npc.h:379
s16 duration
Definition npc.h:362
s8 status
Definition npc.h:360
EncounterStatus gCurrentEncounter
Definition encounter.c:176
s8 instigatorValue
Definition npc.h:378
s8 encountered
Definition npc.h:297
s8 firstStrikeType
Definition npc.h:367
EvtScript * preBattle
Definition battle.h:185
char * texture
Definition battle.h:182
const char * shape
Definition battle.h:183
Stage * stage
Definition battle.h:199
Formation * stageFormation
Definition battle.h:190
Formation * formation
Definition battle.h:198
s32 formationSize
Definition battle.h:197
s32 stageEnemyChance
Definition battle.h:191
Stage * stage
Definition battle.h:208
EvtScript * onBattleStart
Definition battle.h:200
s32 stageEnemyCount
Definition battle.h:189
const char * hit
Definition battle.h:184
char * bg
Definition battle.h:187
Zero-terminated.
Definition battle.h:195
void(* initBattleCallback)(void)
struct Stage * curStage
struct Evt * camMovementScript
struct EffectInstance * waterBlockEffect
void(* preUpdateCallback)(void)
struct EffectInstance * cloudNineEffect
struct Evt * controlScript
struct EffectInstance * buffEffect
s32 gCurrentBattleID
Definition battle.c:16
BackgroundHeader gBackgroundImage
struct Battle * gOverrideBattlePtr
Definition battle.c:18
s32 gCurrentStageID
Definition battle.c:17
s32 gBattleSubState
Definition battle.c:14
StatusBar gStatusBar
Definition inventory.c:23

Referenced by btl_update().

◆ btl_state_draw_normal_start()

void btl_state_draw_normal_start ( void )

◆ btl_state_update_begin_turn()

void btl_state_update_begin_turn ( void )

Definition at line 525 of file btl_states_actions.c.

525 {
526 BattleStatus* battleStatus = &gBattleStatus;
527 PlayerData* playerData = &gPlayerData;
528 Actor* partner = battleStatus->partnerActor;
529 Actor* player = battleStatus->playerActor;
530 Actor* enemy;
531 Actor* enemy1;
532 Actor* enemy2;
533 Evt* script;
534 Evt* script2;
535 s32 cond;
536 u16 id1;
537 u16 id2;
538 s32 numEnemyActors;
539 s32 i;
540 s32 j;
541 s16* enemyIDs;
542
544 battleStatus->flags2 &= ~BS_FLAGS2_PLAYER_TURN_USED;
545 battleStatus->flags2 &= ~BS_FLAGS2_PARTNER_TURN_USED;
546 battleStatus->flags2 &= ~BS_FLAGS2_OVERRIDE_INACTIVE_PLAYER;
547 battleStatus->flags2 &= ~BS_FLAGS2_OVERRIDE_INACTIVE_PARTNER;
548 battleStatus->merleeAttackBoost = 0;
549 battleStatus->merleeDefenseBoost = 0;
550 battleStatus->flags2 &= ~BS_FLAGS2_IS_FIRST_STRIKE;
551
553 player->disableDismissTimer = 0;
554 if (partner != NULL) {
556 partner->disableDismissTimer = 0;
557 }
558
559 if (battleStatus->hustleTurns != 0) {
561 }
562
563 numEnemyActors = 0;
564 for (i = 0; i < ARRAY_COUNT(battleStatus->enemyActors); i++) {
565 enemy = battleStatus->enemyActors[i];
566 if (enemy != NULL) {
567 battleStatus->enemyIDs[numEnemyActors] = i | ACTOR_ENEMY0;
568 numEnemyActors++;
569 }
570 }
571 battleStatus->numEnemyActors = numEnemyActors;
572
573 // sort enemies by x-position or turn priority
574 enemyIDs = battleStatus->enemyIDs;
575 for (i = 0; i < numEnemyActors - 1; i++) {
576 for (j = i + 1; j < numEnemyActors; j++) {
577 id1 = enemyIDs[i];
578 id2 = enemyIDs[j];
579 enemy1 = battleStatus->enemyActors[id1 & 0xFF];
580 enemy2 = battleStatus->enemyActors[id2 & 0xFF];
582 if (enemy1->homePos.x > enemy2->homePos.x) {
583 enemyIDs[i] = id2;
584 enemyIDs[j] = id1;
585 }
586 } else if (enemy1->turnPriority < enemy2->turnPriority) {
587 enemyIDs[i] = id2;
588 enemyIDs[j] = id1;
589 }
590 }
591 }
592 battleStatus->nextEnemyIndex = 0;
593
595
596 // clear rush flags to initialize
597 battleStatus->rushFlags = RUSH_FLAG_NONE;
598 gBattleStatus.flags2 &= ~BS_FLAGS2_HAS_RUSH;
599
600 // set rush flags based on danger/peril status
604 battleStatus->rushFlags |= RUSH_FLAG_MEGA;
605 }
607 if (!(battleStatus->rushFlags & RUSH_FLAG_MEGA)) {
609 battleStatus->rushFlags |= RUSH_FLAG_POWER;
610 }
611 }
612 }
613
615 battleStatus->jumpCharge = 0;
616 }
617
619 battleStatus->hammerCharge = 0;
620 }
621
624 return;
625 }
626
628 for (i = 0; i < ARRAY_COUNT(battleStatus->enemyActors); i++) {
629 enemy = battleStatus->enemyActors[i];
630 if (enemy != NULL && enemy->handleEventSource != NULL) {
631 Evt* script = start_script(enemy->handleEventSource, EVT_PRIORITY_A, 0);
632
633 enemy->handleEventScript = script;
634 script->owner1.actorID = i | ACTOR_ENEMY0;
635 enemy->handleEventScriptID = script->id;
636 enemy->lastEventType = EVENT_DEATH;
637 }
638 }
640 } else {
641 for (i = 0; i < ARRAY_COUNT(battleStatus->enemyActors); i++) {
642 enemy = battleStatus->enemyActors[i];
643 if (enemy != NULL && enemy->handlePhaseSource != NULL) {
644 battleStatus->battlePhase = PHASE_PLAYER_BEGIN;
645 script = start_script(enemy->handlePhaseSource, EVT_PRIORITY_A, 0);
646 enemy->handlePhaseScript = script;
647 enemy->handleBatttlePhaseScriptID = script->id;
648 script->owner1.actorID = i | ACTOR_ENEMY0;
649 }
650 }
651
652 partner = battleStatus->partnerActor;
653 if (partner != NULL) {
654 if (partner->handlePhaseSource != NULL) {
655 battleStatus->battlePhase = PHASE_PLAYER_BEGIN;
656 script = start_script(partner->handlePhaseSource, EVT_PRIORITY_A, 0);
657 partner->handlePhaseScript = script;
658 partner->handleBatttlePhaseScriptID = script->id;
659 script->owner1.actorID = ACTOR_PARTNER;
660 }
661 }
663 }
664 }
665
667 cond = FALSE;
668 for (i = 0; i < ARRAY_COUNT(battleStatus->enemyActors); i++) {
669 enemy = battleStatus->enemyActors[i];
670 if (enemy != NULL && enemy->handlePhaseSource != NULL && does_script_exist(enemy->handleBatttlePhaseScriptID)) {
671 cond = TRUE;
672 }
673 }
674 if (partner != NULL && partner->handlePhaseSource != NULL && does_script_exist(partner->handleBatttlePhaseScriptID)) {
675 cond = TRUE;
676 }
677
678 if (!cond) {
681 }
682 return;
683 }
684 }
685
687 cond = FALSE;
688 for (i = 0; i < ARRAY_COUNT(battleStatus->enemyActors); i++) {
689 enemy = battleStatus->enemyActors[i];
690 if (enemy != NULL && enemy->handleEventSource != NULL && does_script_exist(enemy->handleEventScriptID)) {
691 cond = TRUE;
692 }
693 }
694
695 if (!cond) {
698 }
699 }
700 }
701}
void btl_merlee_on_start_turn(void)
s32 handleEventScriptID
s32 handleBatttlePhaseScriptID
@ BS_FLAGS1_HUSTLED
Definition enums.h:3594
@ BS_FLAGS1_SORT_ENEMIES_BY_POSX
Definition enums.h:3595
@ BS_FLAGS1_JUMP_CHARGED
Definition enums.h:3597
@ BS_FLAGS1_HAMMER_CHARGED
Definition enums.h:3596
@ DEBUG_CONTACT_DIE_IN_BATTLE
Definition enums.h:4269
@ DEBUG_CONTACT_AUTO_FLEE
Definition enums.h:4270
@ RUSH_FLAG_NONE
Definition enums.h:5329
@ RUSH_FLAG_MEGA
Definition enums.h:5330
@ RUSH_FLAG_POWER
Definition enums.h:5331
@ PHASE_PLAYER_BEGIN
Definition enums.h:2066
@ BS_FLAGS2_HAS_RUSH
Definition enums.h:3620
@ BTL_SUBSTATE_BEGIN_TURN_INIT
Definition enums.h:3696
@ BTL_SUBSTATE_BEGIN_TURN_AWAIT_ENEMY_DEATH
Definition enums.h:3698
@ BTL_SUBSTATE_BEGIN_TURN_AWAIT_ENEMY_SCRIPTS
Definition enums.h:3697
@ BATTLE_STATE_RUN_AWAY
Definition enums.h:3654
@ BATTLE_STATE_BEGIN_PLAYER_TURN
Definition enums.h:3637
@ ABILITY_POWER_RUSH
Definition enums.h:466
@ ABILITY_MEGA_RUSH
Definition enums.h:456
@ ACTOR_PARTNER
Definition enums.h:2086
@ EVENT_DEATH
Definition enums.h:2153
s32 btl_check_enemies_defeated(void)
Definition 190B20.c:653

Referenced by btl_update().

◆ btl_state_draw_begin_turn()

void btl_state_draw_begin_turn ( void )

Definition at line 703 of file btl_states_actions.c.

703 {
704}

Referenced by btl_draw_ui().

◆ btl_state_update_begin_player_turn()

void btl_state_update_begin_player_turn ( void )

Definition at line 706 of file btl_states_actions.c.

706 {
707 BattleStatus* battleStatus = &gBattleStatus;
708 PlayerData* playerData = &gPlayerData;
709 Actor* player = battleStatus->playerActor;
710 Actor* partner = battleStatus->partnerActor;
711 ActorPart* part = &player->partsTable[0];
712 Evt* script;
713 s32 i;
714
715 s8 debuffDuration;
716 s32 koDuration;
717 s32 temp;
718
721 btl_cam_move(5);
723 }
724
725 switch (gBattleSubState) {
728 gBattleStatus.flags1 &= ~BS_FLAGS1_PARTNER_ACTING;
730 battleStatus->actionResult = ACTION_RESULT_NONE;
731 battleStatus->blockResult = BLOCK_RESULT_NONE;
732 battleStatus->selectedMoveID = 0;
734 gBattleStatus.flags2 &= ~BS_FLAGS2_IS_FIRST_STRIKE;
735 player->disableDismissTimer = 0;
737
738 if (partner != NULL) {
740 partner->disableDismissTimer = 0;
741 }
742
743 battleStatus->stateFreezeCount = 0;
744 D_8029F254 = FALSE;
745 D_8029F258 = 0;
746
747 if (battleStatus->outtaSightActive == 0) {
749 } else {
750 battleStatus->battlePhase = PHASE_ENEMY_BEGIN;
751 script = start_script(partner->handlePhaseSource, EVT_PRIORITY_A, 0);
752 partner->handlePhaseScript = script;
754 partner->handleBatttlePhaseScriptID = script->id;
755 script->owner1.actorID = ACTOR_PARTNER;
756 }
757 }
758 break;
761 battleStatus->outtaSightActive = 0;
764 }
765 break;
766 }
767
768 switch (gBattleSubState) {
770 if (battleStatus->stateFreezeCount == 0) {
771 if (battleStatus->waterBlockTurnsLeft != 0) {
772 battleStatus->waterBlockTurnsLeft--;
774 if (battleStatus->waterBlockTurnsLeft <= 0) {
776 fx_water_block(FX_WATER_BLOCK_DESTROY, player->curPos.x, player->curPos.y + 18.0f, player->curPos.z + 5.0f, 1.5f, 10);
777 fx_water_splash(0, player->curPos.x - 10.0f, player->curPos.y + 5.0f, player->curPos.z + 5.0f, 1.0f, 24);
778 fx_water_splash(0, player->curPos.x - 15.0f, player->curPos.y + 32.0f, player->curPos.z + 5.0f, 1.0f, 24);
779 fx_water_splash(1, player->curPos.x + 15.0f, player->curPos.y + 22.0f, player->curPos.z + 5.0f, 1.0f, 24);
780 battleStatus->waterBlockEffect = NULL;
784 } else {
786 }
787 } else {
789 }
790 }
791 break;
793 if (!btl_is_popup_displayed()) {
795 }
796 break;
797 }
798
799 switch (gBattleSubState) {
801 if (battleStatus->cloudNineTurnsLeft != 0) {
802 battleStatus->cloudNineTurnsLeft--;
804
805 if (battleStatus->cloudNineTurnsLeft <= 0) {
806 remove_effect(battleStatus->cloudNineEffect);
807 battleStatus->cloudNineEffect = NULL;
810 } else {
812 }
813 } else {
815 }
816 break;
818 if (!btl_is_popup_displayed()) {
820 }
821 break;
822 }
823
824 switch (gBattleSubState) {
826 if (battleStatus->turboChargeTurnsLeft != 0) {
828 gBattleStatus.flags2 &= ~BS_FLAGS2_STORED_TURBO_CHARGE_TURN;
830 } else {
831 battleStatus->turboChargeTurnsLeft--;
833 if (battleStatus->turboChargeTurnsLeft <= 0) {
836 } else {
838 }
839 }
840 } else {
842 }
843 break;
845 if (!btl_is_popup_displayed()) {
847 }
848 break;
849 }
850
852 if (player->debuff == STATUS_KEY_POISON && player->stoneStatus == 0) {
855 }
856
857 // clear rush flags to initialize
858 battleStatus->rushFlags = RUSH_FLAG_NONE;
859 gBattleStatus.flags2 &= ~BS_FLAGS2_HAS_RUSH;
860
861 // set rush flags based on danger/peril status
865 battleStatus->rushFlags |= RUSH_FLAG_MEGA;
866 }
868 if (!(battleStatus->rushFlags & RUSH_FLAG_MEGA)) {
870 battleStatus->rushFlags |= RUSH_FLAG_POWER;
871 }
872 }
873 }
875 }
876
878 if (player->handleEventScript == NULL || !does_script_exist(player->handleEventScriptID)) {
879 player->handleEventScript = NULL;
881 return;
882 }
883
884 D_8029F254 = FALSE;
885 player->disableDismissTimer = 0;
887
889 if (player->debuff != 0) {
890 player->debuffDuration = 1;
891 }
892 if (player->staticStatus != 0) {
893 player->staticDuration = 1;
894 }
895 if (player->stoneStatus != 0) {
896 player->stoneDuration = 1;
897 }
898 if (player->koStatus != 0) {
899 player->koDuration = 1;
900 }
901 if (player->transparentStatus != 0) {
902 player->transparentDuration = 1;
903 }
904 }
905
906 if (player->stoneStatus != 0) {
907 player->stoneDuration--;
908 if (player->stoneDuration <= 0) {
909 player->stoneStatus = 0;
911 }
912 } else {
913 if (!is_ability_active(ABILITY_ZAP_TAP) && player->staticStatus != 0) {
914 player->staticDuration--;
915 if (player->staticDuration <= 0) {
916 player->staticStatus = 0;
918 }
919 }
920 if (player->transparentStatus != 0) {
921 player->transparentDuration--;
923 if (player->transparentDuration <= 0) {
924 player->transparentStatus = 0;
925 part->flags &= ~ACTOR_PART_FLAG_TRANSPARENT;
927 }
928 }
929
930 if (player->debuff != 0) {
931 if (player->debuff < 9) {
932 D_8029F254 = TRUE;
933 }
934 D_8029F258 = 20;
935 player->debuffDuration--;
936 if (player->debuffDuration <= 0) {
937 if (player->debuff == STATUS_KEY_FROZEN) {
940 player->icePillarEffect = NULL;
942 } else {
944 }
945 player->debuff = 0;
946 player->debuffDuration = 0;
948 }
949 }
950
951 debuffDuration = player->debuffDuration;
952 temp = player->koDuration;
953 player->koDuration = debuffDuration;
954 if (debuffDuration > 0) {
955 player->koStatus = STATUS_KEY_DAZE;
956 player->disableEffect->data.disableX->koDuration = player->koDuration;
957 } else if (temp != debuffDuration) {
958 player->koStatus = 0;
959 player->koDuration = 0;
961 }
962 }
963
964 for (i = 0; i < ARRAY_COUNT(battleStatus->enemyActors); i++) {
965 Actor* enemy = battleStatus->enemyActors[i];
966
967 if (enemy != NULL) {
969 if (enemy->chillOutTurns != 0) {
970 enemy->chillOutTurns--;
971 if (enemy->chillOutTurns == 0) {
972 enemy->chillOutAmount = 0;
974 D_8029F258 = 20;
975 }
976 }
977 }
978 }
980 }
981 }
982
985 return;
986 }
987 temp = 1;
988 battleStatus->stateFreezeCount = 0;
989 if (battleStatus->hammerLossTurns >= 0) {
990 battleStatus->hammerLossTurns--;
991 if (battleStatus->hammerLossTurns == -1) {
993 player->takeTurnScript = script;
994 player->takeTurnScriptID = script->id;
995 script->owner1.actorID = ACTOR_PLAYER;
996 script->varTable[0] = temp;
997 temp += 8; // temp here should be named itemSpawnOffsetX
998 script->varTable[10] = BTL_MENU_TYPE_SMASH;
999 battleStatus->stateFreezeCount = 1;
1000 }
1001 }
1002
1003 if (battleStatus->jumpLossTurns >= 0) {
1004 battleStatus->jumpLossTurns--;
1005 if (battleStatus->jumpLossTurns == -1) {
1007 player->takeTurnScript = script;
1008 player->takeTurnScriptID = script->id;
1009 script->owner1.actorID = ACTOR_PLAYER;
1010 script->varTable[0] = temp;
1011 temp += 8;
1012 script->varTable[10] = BTL_MENU_TYPE_JUMP;
1013 battleStatus->stateFreezeCount = 1;
1014 }
1015 }
1016
1017 if (battleStatus->itemLossTurns >= 0) {
1018 battleStatus->itemLossTurns--;
1019 if (battleStatus->itemLossTurns == -1) {
1021 player->takeTurnScript = script;
1022 player->takeTurnScriptID = script->id;
1023 script->owner1.actorID = ACTOR_PLAYER;
1024 script->varTable[0] = temp;
1025 temp += 8;
1026 script->varTable[10] = BTL_MENU_TYPE_ITEMS;
1027 battleStatus->stateFreezeCount = 1;
1028 }
1029 }
1031 }
1032
1034 if (player->handleEventScript == NULL || !does_script_exist(player->handleEventScriptID)) {
1035 player->handleEventScript = NULL;
1036
1038 return;
1039 }
1040
1041 if (D_8029F258 != 0) {
1042 D_8029F258--;
1043 return;
1044 }
1045
1046 if (!D_8029F254) {
1048 } else{
1051 }
1052 }
1053 }
1054}
b32 dispatch_damage_tick_event_player(s32 damageAmount, s32 event)
BSS s32 D_8029F258
BSS b32 D_8029F254
#define remove_effect
s16 turnsLeft
Definition effects.h:2326
@ FX_WATER_BLOCK_DESTROY
Definition effects.h:1540
struct PartnerBuffFXData * partnerBuff
Definition effects.h:2591
BuffData unk_0C[3]
Definition effects.h:2336
@ FX_BUFF_DATA_TURBO_CHARGE
Definition effects.h:2320
@ FX_BUFF_DATA_CLOUD_NINE
Definition effects.h:2319
@ FX_BUFF_DATA_WATER_BLOCK
Definition effects.h:2318
@ BS_FLAGS1_TRIGGER_EVENTS
Definition enums.h:3574
@ BTL_MSG_TURBO_CHARGE_END
Definition enums.h:4100
@ BTL_MSG_CLOUD_NINE_END
Definition enums.h:4098
@ BTL_MSG_WATER_BLOCK_END
Definition enums.h:4096
@ PHASE_ENEMY_BEGIN
Definition enums.h:2068
@ BTL_MENU_TYPE_SMASH
Definition enums.h:4227
@ BTL_MENU_TYPE_JUMP
Definition enums.h:4226
@ BTL_MENU_TYPE_ITEMS
Definition enums.h:4228
@ BS_FLAGS2_STORED_TURBO_CHARGE_TURN
Definition enums.h:3610
@ BS_FLAGS2_PARTNER_TURN_USED
Definition enums.h:3605
@ STATUS_KEY_DAZE
Definition enums.h:2209
@ BTL_SUBSTATE_BEGIN_PLAYER_TURN_CHECK_CLOUD_NINE
Definition enums.h:3714
@ BTL_SUBSTATE_BEGIN_PLAYER_TURN_RESET_STATE
Definition enums.h:3722
@ BTL_SUBSTATE_BEGIN_PLAYER_TURN_AWAIT_WATER_BLOCK
Definition enums.h:3712
@ BTL_SUBSTATE_BEGIN_PLAYER_TURN_TRY_STATUS_RECOVER
Definition enums.h:3720
@ BTL_SUBSTATE_BEGIN_PLAYER_TURN_TRY_COMMAND_RECOVER
Definition enums.h:3711
@ BTL_SUBSTATE_BEGIN_PLAYER_TURN_END_DELAY
Definition enums.h:3721
@ BTL_SUBSTATE_BEGIN_PLAYER_TURN_INIT
Definition enums.h:3710
@ BTL_SUBSTATE_BEGIN_PLAYER_TURN_TRY_STATUS_DAMAGE
Definition enums.h:3719
@ BTL_SUBSTATE_BEGIN_PLAYER_TURN_CHECK_TURBO_CHARGE
Definition enums.h:3716
@ BTL_SUBSTATE_BEGIN_PLAYER_TURN_CHECK_WATER_BLOCK
Definition enums.h:3713
@ BTL_SUBSTATE_BEGIN_PLAYER_TURN_AWAIT_TURBO_CHARGE
Definition enums.h:3717
@ BTL_SUBSTATE_BEGIN_PLAYER_TURN_AWAIT_OUTTA_SIGHT
Definition enums.h:3718
@ BTL_SUBSTATE_BEGIN_PLAYER_TURN_AWAIT_CLOUD_NINE
Definition enums.h:3715
@ BATTLE_STATE_BEGIN_PARTNER_TURN
Definition enums.h:3638
@ BATTLE_STATE_SWITCH_TO_PLAYER
Definition enums.h:3640
@ ABILITY_FEELING_FINE
Definition enums.h:450
@ SOUND_FROZEN_SHATTER
Definition enums.h:722
@ SOUND_DESTROY_WATER_BLOCK
Definition enums.h:1015
@ BLOCK_RESULT_NONE
Definition enums.h:1972
@ ACTION_RESULT_NONE
Definition enums.h:1963
@ EVENT_HIT
Definition enums.h:2132
@ EVENT_32
Definition enums.h:2168
@ EVENT_RECOVER_STATUS
Definition enums.h:2167
void remove_status_debuff(s32)
s32 btl_check_player_defeated(void)
Definition 190B20.c:661
void remove_status_static(s32)
void reset_actor_turn_info(void)
Definition 190B20.c:978
void remove_status_transparent(s32)
void dispatch_event_player(s32)
Definition dmg_player.c:131
void btl_show_battle_message(s32 messageIndex, s32 duration)
void btl_cam_move(s16)
Definition camera.c:1953
s32 btl_cam_is_moving_done(void)
Definition camera.c:1980
s32 btl_is_popup_displayed(void)
void remove_status_chill_out(s32)
EvtScript EVS_PlayerRegainAbility

Referenced by btl_update().

◆ btl_state_draw_begin_player_turn()

void btl_state_draw_begin_player_turn ( void )

Definition at line 1056 of file btl_states_actions.c.

1056 {
1057}

Referenced by btl_draw_ui().

◆ btl_state_update_switch_to_player()

void btl_state_update_switch_to_player ( void )

Definition at line 1059 of file btl_states_actions.c.

1059 {
1061 Actor* partner = gBattleStatus.partnerActor;
1062 s32 i;
1063
1065 gBattleStatus.flags1 &= ~BS_FLAGS1_PARTNER_ACTING;
1067 gBattleStatus.selectedMoveID = MOVE_NONE;
1072 if (partner != NULL) {
1074 }
1075
1076 for (i = 0; i < ARRAY_COUNT(gBattleStatus.enemyActors); i++) {
1077 Actor* enemy = gBattleStatus.enemyActors[i];
1078
1079 if (enemy != NULL) {
1082 }
1083 }
1084
1086 }
1087}
@ BATTLE_STATE_PREPARE_MENU
Definition enums.h:3642
@ ACTOR_FLAG_HEALTH_BAR_HIDDEN
Definition enums.h:3338

Referenced by btl_update().

◆ btl_state_draw_switch_to_player()

void btl_state_draw_switch_to_player ( void )

Definition at line 1089 of file btl_states_actions.c.

1089 {
1090}

Referenced by btl_draw_ui().

◆ btl_state_update_begin_partner_turn()

void btl_state_update_begin_partner_turn ( void )

Definition at line 1092 of file btl_states_actions.c.

1092 {
1093 BattleStatus* battleStatus = &gBattleStatus;
1094 Actor* partner = battleStatus->partnerActor;
1095 Actor* enemy;
1096 Evt* script;
1097 s32 i;
1098
1100 if (partner == NULL) {
1101 D_8029F254 = TRUE;
1104 if (!(partner->flags & ACTOR_FLAG_NO_ATTACK)) {
1106 btl_cam_move(5);
1108 } else {
1110 return;
1111 }
1112 } else {
1114 return;
1115 }
1116 }
1117
1119 if (btl_cam_is_moving_done()) {
1120 D_8029F258 = 0;
1122 partner = battleStatus->partnerActor;
1123 battleStatus->actionResult = ACTION_RESULT_NONE;
1124 battleStatus->blockResult = BLOCK_RESULT_NONE;
1125 D_8029F254 = FALSE;
1129
1130 if (partner->koStatus != 0) {
1131 partner->koDuration--;
1132 D_8029F254 = TRUE;
1133 D_8029F258 = 20;
1134 if (partner->koDuration > 0) {
1135 partner->disableEffect->data.disableX->koDuration = partner->koDuration;
1136 } else {
1137 partner->koStatus = 0;
1139 partner->disableEffect->data.disableX->koDuration = 0;
1141 }
1142 }
1143
1144 for (i = 0; i < ARRAY_COUNT(battleStatus->enemyActors); i++) {
1145 enemy = battleStatus->enemyActors[i];
1146 if (enemy != NULL) {
1148 }
1149 }
1151 }
1152 }
1153
1155 if (partner != NULL) {
1156 if (partner->handleEventScript != NULL && does_script_exist(partner->handleEventScriptID)) {
1157 goto WAITING;
1158 }
1159 partner->handleEventScript = NULL;
1160 }
1161
1162 gBattleStatus.flags2 &= ~BS_FLAGS2_OVERRIDE_INACTIVE_PLAYER;
1164 return;
1165 }
1167 }
1168 WAITING:
1169
1171 if (partner->handlePhaseSource != NULL) {
1172 battleStatus->battlePhase = PHASE_ENEMY_BEGIN;
1173 script = start_script(partner->handlePhaseSource, EVT_PRIORITY_A, 0);
1174 partner->handlePhaseScript = script;
1175 partner->handleBatttlePhaseScriptID = script->id;
1176 script->owner1.actorID = ACTOR_PARTNER;
1177 }
1179 }
1180
1182 if (partner->handlePhaseSource == NULL || !does_script_exist(partner->handleBatttlePhaseScriptID)) {
1184 }
1185 }
1186
1188 if (D_8029F258 != 0) {
1189 D_8029F258--;
1190 return;
1191 }
1192 gBattleStatus.flags2 &= ~BS_FLAGS2_NO_PLAYER_PAL_ADJUST;
1193 if (!D_8029F254) {
1195 } else {
1198 }
1199 }
1200}
@ BS_FLAGS1_PLAYER_IN_BACK
Definition enums.h:3588
@ BS_FLAGS1_PARTNER_ACTING
Definition enums.h:3587
@ BTL_SUBSTATE_BEGIN_PARTNER_TURN_AWAIT_TURN_SCRIPT
Definition enums.h:3728
@ BTL_SUBSTATE_BEGIN_PARTNER_TURN_EXEC_TURN_SCRIPT
Definition enums.h:3727
@ BTL_SUBSTATE_BEGIN_PARTNER_TURN_INIT
Definition enums.h:3725
@ BTL_SUBSTATE_BEGIN_PARTNER_TURN_END_DELAY
Definition enums.h:3729
@ BTL_SUBSTATE_BEGIN_PARTNER_TURN_AWAIT_RECOVER_DONE
Definition enums.h:3726
@ BTL_SUBSTATE_BEGIN_PARTNER_TURN_RESET_STATE
Definition enums.h:3730
@ BATTLE_STATE_SWITCH_TO_PARTNER
Definition enums.h:3641
@ BATTLE_STATE_9
Definition enums.h:3639
@ EVENT_RECOVER_FROM_KO
Definition enums.h:2170
void dispatch_event_partner(s32)
Definition dmg_partner.c:7

Referenced by btl_update().

◆ btl_state_draw_begin_partner_turn()

void btl_state_draw_begin_partner_turn ( void )

Definition at line 1202 of file btl_states_actions.c.

1202 {
1203}

Referenced by btl_draw_ui().

◆ btl_state_update_switch_to_partner()

void btl_state_update_switch_to_partner ( void )

◆ btl_state_draw_switch_to_partner()

void btl_state_draw_switch_to_partner ( void )

Definition at line 1232 of file btl_states_actions.c.

1232 {
1233}

Referenced by btl_draw_ui().

◆ btl_state_update_9()

void btl_state_update_9 ( void )

Definition at line 1235 of file btl_states_actions.c.

1235 {
1236 BattleStatus* battleStatus = &gBattleStatus;
1237 Actor* player = battleStatus->playerActor;
1238 Actor* partner = battleStatus->partnerActor;
1239 Actor* actor;
1240 ActorState* state;
1241 Evt* script;
1242 s32 waitingForScript;
1243 s32 i;
1244
1245 s32 oldKoDuration;
1246
1250 return;
1251 }
1252
1253 if (partner != NULL) {
1256 return;
1257 }
1258 }
1259
1260 player->flags &= ~ACTOR_FLAG_SHOW_STATUS_ICONS;
1262 if (partner != NULL) {
1263 partner->flags &= ~ACTOR_FLAG_SHOW_STATUS_ICONS;
1265 }
1266
1268 D_8029F258 = 0;
1269 gBattleStatus.flags2 &= ~BS_FLAGS2_PLAYER_TURN_USED;
1270 gBattleStatus.flags2 &= ~BS_FLAGS2_PARTNER_TURN_USED;
1271 gBattleStatus.flags2 &= ~BS_FLAGS2_OVERRIDE_INACTIVE_PLAYER;
1272 gBattleStatus.flags2 &= ~BS_FLAGS2_OVERRIDE_INACTIVE_PARTNER;
1273 }
1274
1276 waitingForScript = FALSE;
1277 for (i = 0; i < ARRAY_COUNT(battleStatus->enemyActors); i++) {
1278 actor = battleStatus->enemyActors[i];
1279 if (actor != NULL && actor->handleEventScript != NULL) {
1281 waitingForScript = TRUE;
1282 } else {
1283 actor->handleEventScript = NULL;
1284 }
1285 }
1286 }
1287
1288 if (!waitingForScript) {
1290
1291 for (i = 0; i < ARRAY_COUNT(battleStatus->enemyActors); i++) {
1292 actor = battleStatus->enemyActors[i];
1293 if (actor != NULL) {
1295 actor->flags &= ~ACTOR_FLAG_SKIP_TURN;
1296
1297 if (actor->debuff != 0) {
1298 if (actor->debuff == STATUS_KEY_FEAR
1299 || actor->debuff == STATUS_KEY_DIZZY
1300 || actor->debuff == STATUS_KEY_PARALYZE
1301 || actor->debuff == STATUS_KEY_SLEEP
1302 || actor->debuff == STATUS_KEY_FROZEN
1303 || actor->debuff == STATUS_KEY_STOP
1304 ) {
1305 actor->flags |= ACTOR_FLAG_SKIP_TURN;
1306 }
1307 actor->debuffDuration--;
1308 if (actor->debuffDuration <= 0) {
1309 actor->debuff = 0;
1312 D_8029F258 = 20;
1313 }
1314 }
1315
1316 if (actor->staticStatus != 0) {
1317 actor->staticDuration--;
1318 if (actor->staticDuration <= 0) {
1319 actor->staticStatus = 0;
1321 D_8029F258 = 20;
1322 }
1323 }
1324
1325 if (actor->transparentStatus != 0) {
1326 actor->transparentDuration--;
1327 if (actor->transparentDuration <= 0) {
1328 actor->transparentStatus = 0;
1330 D_8029F258 = 20;
1331 }
1332 }
1333
1334 if (actor->stoneStatus != 0) {
1335 actor->stoneDuration--;
1336 if (actor->stoneDuration <= 0) {
1337 actor->stoneStatus = 0;
1338 D_8029F258 = 20;
1339 }
1340 }
1341
1342 oldKoDuration = actor->koDuration;
1343 actor->koDuration = actor->debuffDuration;
1344 if (actor->koDuration > 0) {
1345 actor->koStatus = STATUS_KEY_DAZE;
1347 } else if (oldKoDuration != actor->koDuration) {
1348 actor->koStatus = 0;
1350 }
1351 if (actor->debuff == STATUS_KEY_POISON) {
1354 D_8029F258 = 20;
1355 }
1356 }
1357 }
1359 }
1360 }
1361
1363 // wait for player HandleEvent script to finish
1364 if(player->handleEventScript != NULL && does_script_exist(player->handleEventScriptID)) {
1365 goto WAITING;
1366 }
1367 player->handleEventScript = NULL;
1368
1369 // wait for partner HandleEvent script to finish
1370 if (partner != NULL) {
1371 if (partner->handleEventScript != NULL && does_script_exist(partner->handleEventScriptID)) {
1372 goto WAITING;
1373 }
1374 partner->handleEventScript = NULL;
1375 }
1376
1377 // wait for all enemy HandleEvent scripts to finish
1378 waitingForScript = FALSE;
1379
1380 for (i = 0; i < ARRAY_COUNT(battleStatus->enemyActors); i++) {
1381 actor = battleStatus->enemyActors[i];
1382 if (actor != NULL && actor->handleEventScript != NULL) {
1384 waitingForScript = TRUE;
1385 } else {
1386 actor->handleEventScript = NULL;
1387 }
1388 }
1389 }
1390
1391 if (waitingForScript) {
1392 goto WAITING;
1393 }
1394
1396 return;
1397 }
1398
1400 if (partner == NULL || !(gBattleStatus.flags1 & BS_FLAGS1_PLAYER_IN_BACK)) {
1404 } else {
1405 player->flags &= ~ACTOR_FLAG_SHOW_STATUS_ICONS;
1406 partner->flags &= ~ACTOR_FLAG_SHOW_STATUS_ICONS;
1409 state = &partner->state;
1410 if (!battleStatus->outtaSightActive) {
1411 partner->state.curPos.x = partner->homePos.x;
1412 partner->state.curPos.z = partner->homePos.z;
1413 partner->state.goalPos.x = player->homePos.x;
1414 partner->state.goalPos.z = player->homePos.z;
1415 } else {
1416 partner->state.curPos.x = partner->homePos.x;
1417 partner->state.curPos.z = partner->homePos.z;
1418 partner->state.goalPos.x = partner->homePos.x;
1419 partner->state.goalPos.z = partner->homePos.z + 5.0f;
1420 partner->homePos.x = player->homePos.x;
1421 partner->homePos.z = player->homePos.z;
1422 }
1423 state->moveTime = 4;
1424 state->angle = 0.0f;
1426 }
1427 }
1428 WAITING:
1429
1431 if (partner->state.moveTime != 0) {
1432 partner->curPos.x += (partner->state.goalPos.x - partner->curPos.x) / partner->state.moveTime;
1433 partner->curPos.z += (partner->state.goalPos.z - partner->curPos.z) / partner->state.moveTime;
1434 player->curPos.x += (partner->state.curPos.x - player->curPos.x) / partner->state.moveTime;
1435 player->curPos.z += (partner->state.curPos.z - player->curPos.z) / partner->state.moveTime;
1436 }
1437 partner->curPos.z -= sin_rad(DEG_TO_RAD(partner->state.angle)) * 16.0f;
1438 partner->yaw = clamp_angle(partner->state.angle);
1439 player->curPos.z += sin_rad(DEG_TO_RAD(partner->state.angle)) * 16.0f;
1440 player->yaw = clamp_angle(partner->state.angle);
1441 partner->state.angle += 90.0f;
1442
1443 if (partner->state.moveTime != 0) {
1444 partner->state.moveTime--;
1445 } else {
1446 partner->curPos.x = partner->state.goalPos.x;
1447 partner->curPos.z = partner->state.goalPos.z;
1448 player->curPos.x = partner->state.curPos.x;
1449 player->curPos.z = partner->state.curPos.z;
1450 if (!battleStatus->outtaSightActive) {
1451 partner->homePos.x = partner->curPos.x;
1452 partner->homePos.z = partner->curPos.z;
1453 player->homePos.x = player->curPos.x;
1454 player->homePos.z = player->curPos.z;
1455 } else {
1456 player->homePos.x = player->curPos.x;
1457 player->homePos.z = player->curPos.z;
1458 }
1460 gBattleStatus.flags1 &= ~BS_FLAGS1_PLAYER_IN_BACK;
1461 }
1462 }
1463
1465 if (D_8029F258 != 0) {
1466 D_8029F258--;
1467 } else {
1468 if (battleStatus->nextMerleeSpellType == MERLEE_SPELL_DEF_BOOST) {
1469 battleStatus->merleeDefenseBoost = 3;
1470 battleStatus->nextMerleeSpellType = MERLEE_SPELL_NONE;
1473 player->takeTurnScript = script;
1474 player->takeTurnScriptID = script->id;
1475 script->owner1.actorID = ACTOR_PLAYER;
1476 }
1477 gBattleStatus.flags1 &= ~BS_FLAGS1_MENU_OPEN;
1478 player->flags &= ~ACTOR_FLAG_SHOW_STATUS_ICONS;
1480 if (partner != NULL) {
1481 partner->flags &= ~ACTOR_FLAG_SHOW_STATUS_ICONS;
1483 }
1485 gBattleStatus.flags2 &= ~BS_FLAGS2_PLAYER_TURN_USED;
1486 gBattleStatus.flags2 &= ~BS_FLAGS2_PARTNER_TURN_USED;
1487 gBattleStatus.flags2 &= ~BS_FLAGS2_OVERRIDE_INACTIVE_PLAYER;
1488 gBattleStatus.flags2 &= ~BS_FLAGS2_OVERRIDE_INACTIVE_PARTNER;
1489 }
1490 }
1491
1493 if (player->takeTurnScript == NULL || (does_script_exist(player->takeTurnScriptID) == 0)) {
1494 player->takeTurnScript = NULL;
1495
1496 for (i = 0; i < ARRAY_COUNT(battleStatus->enemyActors); i++) {
1497 actor = battleStatus->enemyActors[i];
1498 if (actor != NULL && actor->handlePhaseSource != NULL) {
1499 battleStatus->battlePhase = PHASE_PLAYER_END;
1500 script = start_script(actor->handlePhaseSource, EVT_PRIORITY_A, 0);
1501 actor->handlePhaseScript = script;
1502 actor->handleBatttlePhaseScriptID = script->id;
1503 script->owner1.enemyID = i | ACTOR_CLASS_ENEMY;
1504 }
1505 }
1507 }
1508 }
1509
1510 waitingForScript = FALSE;
1512 for (i = 0; i < ARRAY_COUNT(battleStatus->enemyActors); i++) {
1513 actor = battleStatus->enemyActors[i];
1514 if (actor != NULL && actor->handlePhaseSource != NULL && does_script_exist(actor->handleBatttlePhaseScriptID)) {
1515 waitingForScript = TRUE;
1516 }
1517 }
1518 if (!waitingForScript) {
1520 }
1521 }
1522
1525 }
1526}
ActorState state
@ MERLEE_SPELL_DEF_BOOST
Definition enums.h:1912
@ PHASE_MERLEE_DEFENSE_BONUS
Definition enums.h:2071
@ PHASE_PLAYER_END
Definition enums.h:2069
@ BTL_SUBSTATE_9_3
Definition enums.h:3736
@ BTL_SUBSTATE_9_1
Definition enums.h:3734
@ BTL_SUBSTATE_9_4
Definition enums.h:3737
@ BTL_SUBSTATE_9_INIT
Definition enums.h:3733
@ BTL_SUBSTATE_9_2
Definition enums.h:3735
@ BTL_SUBSTATE_9_7
Definition enums.h:3740
@ BTL_SUBSTATE_9_6
Definition enums.h:3739
@ BTL_SUBSTATE_9_5
Definition enums.h:3738
@ BATTLE_STATE_NEXT_ENEMY
Definition enums.h:3650
@ ACTOR_FLAG_SKIP_TURN
Definition enums.h:3336
void dispatch_event_actor(Actor *, s32)
Definition 1A5830.c:103
s32 dispatch_damage_event_actor_0(Actor *actor, s32 damageAmount, s32 event)
Definition 1A5830.c:889
EvtScript EVS_Mario_HandlePhase

Referenced by btl_update().

◆ btl_state_draw_9()

void btl_state_draw_9 ( void )

Definition at line 1528 of file btl_states_actions.c.

1528 {
1529}

Referenced by btl_draw_ui().

◆ btl_state_update_prepare_menu()

void btl_state_update_prepare_menu ( void )

Definition at line 1531 of file btl_states_actions.c.

1531 {
1532 BattleStatus* battleStatus = &gBattleStatus;
1533
1534 battleStatus->lastPlayerMenuSelection[BTL_MENU_IDX_JUMP] = -1;
1535 battleStatus->lastPlayerMenuSelection[BTL_MENU_IDX_SMASH] = -1;
1536 battleStatus->lastPlayerMenuSelection[BTL_MENU_IDX_ITEMS] = -1;
1537 battleStatus->lastPlayerMenuSelection[BTL_MENU_IDX_DIP] = -1;
1544
1545 DMA_COPY_SEGMENT(btl_states_menus);
1546
1547 if (battleStatus->flags1 & BS_FLAGS1_PARTNER_ACTING) {
1552 } else {
1554 }
1555}
@ BATTLE_SUBSTATE_PREPARE_MENU_DIPPING
Definition enums.h:3746
@ BATTLE_STATE_PLAYER_MENU
Definition enums.h:3643
@ BATTLE_STATE_PARTNER_MENU
Definition enums.h:3644
@ BTL_MENU_IDX_PARTNER
Definition enums.h:4216
@ BTL_MENU_IDX_STRATEGY
Definition enums.h:4218
@ BTL_MENU_IDX_SMASH
Definition enums.h:4213
@ BTL_MENU_IDX_STAR_POWER
Definition enums.h:4217
@ BTL_MENU_IDX_JUMP
Definition enums.h:4212
@ BTL_MENU_IDX_DIP
Definition enums.h:4215
@ BTL_MENU_IDX_ABILITY
Definition enums.h:4220
@ BTL_MENU_IDX_ITEMS
Definition enums.h:4214
@ BTL_SUBSTATE_PLAYER_MENU_DIPPING_1
Definition enums.h:3968
s8 lastPlayerMenuSelection[16]
s8 lastPartnerMenuSelection[16]

Referenced by btl_update().

◆ btl_state_draw_prepare_menu()

void btl_state_draw_prepare_menu ( void )

Definition at line 1557 of file btl_states_actions.c.

1557 {
1558}

Referenced by btl_draw_ui().

◆ btl_state_update_end_turn()

void btl_state_update_end_turn ( void )

Definition at line 1560 of file btl_states_actions.c.

1560 {
1561 BattleStatus* battleStatus = &gBattleStatus;
1562 PlayerData* playerData = &gPlayerData;
1563 Actor* player = battleStatus->playerActor;
1564 Actor* partner = battleStatus->partnerActor;
1565 Actor* actor;
1566 Evt* script;
1567 s32 i;
1568
1570 s32 cond = FALSE;
1571
1572 for (i = 0; i < ARRAY_COUNT(battleStatus->enemyActors); i++) {
1573 actor = battleStatus->enemyActors[i];
1574 if (actor != NULL && actor->handleEventScript != NULL) {
1576 cond = TRUE;
1577 } else {
1578 actor->handleEventScript = NULL;
1579 }
1580 }
1581 }
1582
1583 if (!cond) {
1584 for (i = 0; i < ARRAY_COUNT(battleStatus->enemyActors); i++) {
1585 actor = battleStatus->enemyActors[i];
1586 if (actor != NULL && actor->takeTurnScript != NULL) {
1587 if (does_script_exist(actor->takeTurnScriptID)) {
1588 cond = TRUE;
1589 } else {
1590 actor->takeTurnScript = NULL;
1591 }
1592 }
1593 }
1594
1595 if (!cond) {
1598 }
1599 }
1600 }
1601
1607 } else {
1608 player->flags &= ~ACTOR_FLAG_SHOW_STATUS_ICONS;
1609 partner->flags &= ~ACTOR_FLAG_SHOW_STATUS_ICONS;
1612 partner->state.curPos.x = partner->homePos.x;
1613 partner->state.curPos.z = partner->homePos.z;
1614 partner->state.goalPos.x = player->homePos.x;
1615 partner->state.goalPos.z = player->homePos.z;
1616 partner->state.moveTime = 4;
1617 partner->state.angle = 0.0f;
1619 }
1620 }
1621
1623 if (partner->state.moveTime != 0) {
1624 partner->curPos.x += (partner->state.goalPos.x - partner->curPos.x) / partner->state.moveTime;
1625 partner->curPos.z += (partner->state.goalPos.z - partner->curPos.z) / partner->state.moveTime;
1626 player->curPos.x += (partner->state.curPos.x - player->curPos.x) / partner->state.moveTime;
1627 player->curPos.z += (partner->state.curPos.z - player->curPos.z) / partner->state.moveTime;
1628 }
1629 partner->curPos.z -= sin_rad(DEG_TO_RAD(partner->state.angle)) * 16.0f;
1630 partner->yaw = clamp_angle(partner->state.angle);
1631 player->curPos.z += sin_rad(DEG_TO_RAD(partner->state.angle)) * 16.0f;
1632 player->yaw = clamp_angle(partner->state.angle);
1633 partner->state.angle += 90.0f;
1634 if (partner->state.moveTime != 0) {
1635 partner->state.moveTime--;
1636 } else {
1637 partner->curPos.x = partner->state.goalPos.x;
1638 partner->curPos.z = partner->state.goalPos.z;
1639 player->curPos.x = partner->state.curPos.x;
1640 player->curPos.z = partner->state.curPos.z;
1641 partner->homePos.x = partner->curPos.x;
1642 partner->homePos.z = partner->curPos.z;
1643 player->homePos.x = player->curPos.x;
1644 player->homePos.z = player->curPos.z;
1649 } else {
1650 gBattleStatus.flags1 &= ~BS_FLAGS1_PLAYER_IN_BACK;
1651 }
1653 }
1654 }
1655
1657 gBattleStatus.flags2 &= ~BS_FLAGS2_HIDE_BUFF_COUNTERS;
1658 player->disableDismissTimer = 0;
1660 if (partner != NULL) {
1662 partner->disableDismissTimer = 0;
1663 }
1664
1666 gBattleStatus.flags1 &= ~BS_FLAGS1_PLAYER_DEFENDING;
1667 playerData->starPower += SP_PER_SEG;
1668 if (playerData->starPower > playerData->maxStarPower * SP_PER_BAR) {
1669 playerData->starPower = playerData->maxStarPower * SP_PER_BAR;
1670 }
1671
1672 for (i = 0; i < ARRAY_COUNT(battleStatus->enemyActors); i++) {
1673 actor = battleStatus->enemyActors[i];
1674 if (actor != NULL && actor->handlePhaseSource != NULL) {
1675 battleStatus->battlePhase = PHASE_ENEMY_END;
1676 script = start_script(actor->handlePhaseSource, EVT_PRIORITY_A, 0);
1677 actor->handlePhaseScript = script;
1678 actor->handleBatttlePhaseScriptID = script->id;
1679 script->owner1.enemyID = i | ACTOR_ENEMY0;
1680 }
1681 }
1682
1683 if (partner != NULL && partner->handlePhaseSource != NULL) {
1684 battleStatus->battlePhase = PHASE_ENEMY_END;
1685 script = start_script(partner->handlePhaseSource, EVT_PRIORITY_A, 0);
1686 partner->handlePhaseScript = script;
1687 partner->handleBatttlePhaseScriptID = script->id;
1688 script->owner1.actorID = ACTOR_PARTNER;
1689 }
1691 }
1692
1693 // wait for all end turn scripts to finish executing
1695 s32 cond = FALSE;
1696
1697 for (i = 0; i < ARRAY_COUNT(battleStatus->enemyActors); i++) {
1698 actor = battleStatus->enemyActors[i];
1699 if (actor != NULL && actor->handlePhaseSource != NULL && does_script_exist(actor->handleBatttlePhaseScriptID)) {
1700 cond = TRUE;
1701 }
1702 }
1703
1704 if (partner != NULL && partner->handlePhaseSource != NULL && does_script_exist(partner->handleBatttlePhaseScriptID)) {
1705 cond = TRUE;
1706 }
1707
1708 if (!cond) {
1711 }
1712 }
1713
1714 // proceed to next turn
1715 switch (gBattleSubState) {
1719 break;
1720 }
1721}
@ PHASE_ENEMY_END
Definition enums.h:2067
@ BTL_SUBSTATE_END_TURN_PERFORM_SWAP
Definition enums.h:3706
@ BTL_SUBSTATE_END_TURN_CHECK_FOR_SWAP
Definition enums.h:3702
@ BTL_SUBSTATE_END_TURN_AWAIT_SCRIPTS
Definition enums.h:3703
@ BTL_SUBSTATE_END_TURN_INIT
Definition enums.h:3701
@ BTL_SUBSTATE_END_TURN_UNUSED_4
Definition enums.h:3705
@ BTL_SUBSTATE_END_TURN_START_SCRIPTS
Definition enums.h:3707
@ BTL_SUBSTATE_END_TURN_BEGIN_NEXT
Definition enums.h:3704
void btl_set_player_idle_anims(void)
#define SP_PER_SEG
Definition macros.h:103
#define SP_PER_BAR
Definition macros.h:102

Referenced by btl_update().

◆ btl_state_draw_end_turn()

void btl_state_draw_end_turn ( void )

Definition at line 1723 of file btl_states_actions.c.

1723 {
1724}

Referenced by btl_draw_ui().

◆ btl_state_update_1C()

void btl_state_update_1C ( void )

Definition at line 1726 of file btl_states_actions.c.

Referenced by btl_update().

◆ btl_state_draw_1C()

void btl_state_draw_1C ( void )

Definition at line 1731 of file btl_states_actions.c.

1731 {
1732}

Referenced by btl_draw_ui().

◆ btl_state_update_victory()

void btl_state_update_victory ( void )

Definition at line 1734 of file btl_states_actions.c.

1734 {
1735 BattleStatus* battleStatus = &gBattleStatus;
1736 EncounterStatus* currentEncounter = &gCurrentEncounter;
1737 PlayerData* playerData = &gPlayerData;
1738 Actor* player = battleStatus->playerActor;
1739 Actor* partner = battleStatus->partnerActor;
1740 Evt* script;
1741
1742 switch (gBattleSubState) {
1745 if (partner != NULL) {
1747 }
1748
1749 battleStatus->stateFreezeCount = 0;
1750 if (battleStatus->outtaSightActive == 0) {
1752 } else {
1753 if (battleStatus->outtaSightActive > 0) {
1754 D_8029F254 = TRUE;
1755 }
1756 battleStatus->battlePhase = PHASE_ENEMY_BEGIN;
1757 script = start_script(partner->handlePhaseSource, EVT_PRIORITY_A, 0);
1758 partner->handlePhaseScript = script;
1759 partner->handleBatttlePhaseScriptID = script->id;
1760 script->owner1.actorID = ACTOR_PARTNER;
1762 }
1763
1764 break;
1767 battleStatus->outtaSightActive = 0;
1769 }
1770 break;
1771 }
1772
1773 switch (gBattleSubState) {
1776 if (partner != NULL) {
1778 }
1780 gBattleStatus.flags2 &= ~BS_FLAGS2_PLAYER_TURN_USED;
1781 gBattleStatus.flags2 &= ~BS_FLAGS2_PARTNER_TURN_USED;
1782 gBattleStatus.flags2 &= ~BS_FLAGS2_OVERRIDE_INACTIVE_PLAYER;
1783 gBattleStatus.flags2 &= ~BS_FLAGS2_OVERRIDE_INACTIVE_PARTNER;
1784
1785 gBattleStatus.flags1 &= ~BS_FLAGS1_SHOW_PLAYER_DECORATIONS;
1786 if (player->koStatus == STATUS_KEY_DAZE) {
1789 }
1790 player->debuff = 0;
1791 player->staticStatus = 0;
1792 player->stoneStatus = 0;
1793 player->transparentStatus = 0;
1794 player->koStatus = 0;
1795 player->koDuration = 0;
1796 player->disableEffect->data.disableX->koDuration = 0;
1797
1798 if (partner != NULL) {
1799 if (partner->koStatus == STATUS_KEY_DAZE) {
1802 }
1803 partner->debuff = 0;
1804 partner->staticStatus = 0;
1805 partner->stoneStatus = 0;
1806 partner->transparentStatus = 0;
1807 partner->koStatus = 0;
1808 partner->koDuration = 0;
1809 partner->disableEffect->data.disableX->koDuration = 0;
1810 }
1811 break;
1813 if (player->handleEventScript != NULL && does_script_exist(player->handleEventScriptID)) {
1814 break;
1815 }
1816 player->handleEventScript = NULL;
1817
1818 if (partner != NULL) {
1819 if (partner->handleEventScript != NULL && does_script_exist(partner->handleEventScriptID)) {
1820 break;
1821 }
1822 partner->handleEventScript = NULL;
1823 }
1825 break;
1826 }
1827
1829 if (partner == NULL || !(gBattleStatus.flags1 & BS_FLAGS1_PLAYER_IN_BACK)) {
1831 } else {
1832 partner->state.curPos.x = partner->curPos.x;
1833 partner->state.curPos.z = partner->curPos.z;
1834 partner->state.goalPos.x = player->curPos.x;
1835 partner->state.goalPos.z = player->curPos.z;
1836 partner->state.moveTime = 4;
1837 partner->state.angle = 0.0f;
1839 }
1840 }
1841
1843 if (partner->state.moveTime != 0) {
1844 partner->curPos.x += (partner->state.goalPos.x - partner->curPos.x) / partner->state.moveTime;
1845 partner->curPos.z += (partner->state.goalPos.z - partner->curPos.z) / partner->state.moveTime;
1846 player->curPos.x += (partner->state.curPos.x - player->curPos.x) / partner->state.moveTime;
1847 player->curPos.z += (partner->state.curPos.z - player->curPos.z) / partner->state.moveTime;
1848 }
1849 partner->curPos.z += sin_rad(DEG_TO_RAD(partner->state.angle)) * 16.0f;
1850 partner->yaw = clamp_angle(-partner->state.angle);
1851 player->curPos.z -= sin_rad(DEG_TO_RAD(partner->state.angle)) * 16.0f;
1852 player->yaw = clamp_angle(-partner->state.angle);
1853 partner->state.angle += 90.0f;
1854
1855 if (partner->state.moveTime != 0) {
1856 partner->state.moveTime--;
1857 } else {
1858 partner->curPos.x = partner->state.goalPos.x;
1859 partner->curPos.z = partner->state.goalPos.z;
1860 player->curPos.x = partner->state.curPos.x;
1861 player->curPos.z = partner->state.curPos.z;
1862 partner->homePos.x = partner->curPos.x;
1863 partner->homePos.z = partner->curPos.z;
1864 player->homePos.x = player->curPos.x;
1865 player->homePos.z = player->curPos.z;
1867 gBattleStatus.flags1 &= ~BS_FLAGS1_PLAYER_IN_BACK;
1868 }
1869 }
1870
1873 if (battleStatus->nextMerleeSpellType == MERLEE_SPELL_EXP_BOOST) {
1874 if (battleStatus->totalStarPoints == 0) {
1875 battleStatus->nextMerleeSpellType = MERLEE_SPELL_NONE;
1876 playerData->merleeTurnCount = 0;
1877 playerData->merleeCastsLeft++;
1878 } else {
1879 battleStatus->battlePhase = PHASE_MERLEE_EXP_BONUS;
1881 player->takeTurnScript = script;
1882 player->takeTurnScriptID = script->id;
1883 script->owner1.actorID = ACTOR_PLAYER;
1884 }
1885 }
1888 gBattleStatus.flags1 &= ~BS_FLAGS1_MENU_OPEN;
1889 }
1890
1892 if (BattleSubStateDelay != 0) {
1894 } else {
1895 if (player->takeTurnScript == NULL || !does_script_exist(player->takeTurnScriptID)) {
1896 player->takeTurnScript = NULL;
1897 if (battleStatus->nextMerleeSpellType != MERLEE_SPELL_EXP_BOOST) {
1899 } else {
1900 battleStatus->incrementStarPointDelay = 20;
1901 battleStatus->nextMerleeSpellType = MERLEE_SPELL_NONE;
1903 battleStatus->pendingStarPoints = battleStatus->totalStarPoints
1904 + battleStatus->pendingStarPoints + battleStatus->pendingStarPoints;
1905 }
1906 }
1907 }
1908 }
1909
1911 if (battleStatus->pendingStarPoints <= 0) {
1913 gBattleStatus.flags1 &= ~BS_FLAGS1_BATTLE_FLED;
1914 }
1915 if (playerData->battlesWon < 9999) {
1916 playerData->battlesWon++;
1917 }
1919 currentEncounter->battleOutcome = OUTCOME_ENEMY_FLED;
1920 } else {
1921 currentEncounter->battleOutcome = OUTCOME_PLAYER_WON;
1922 }
1925 bgm_set_song(0, -1, 0, 1500, 8);
1926 }
1928 } else {
1930 }
1931 }
1932 }
1933}
@ MERLEE_SPELL_EXP_BOOST
Definition enums.h:1913
@ BS_FLAGS1_DISABLE_CELEBRATION
Definition enums.h:3585
@ BS_FLAGS1_BATTLE_FLED
Definition enums.h:3586
@ BS_FLAGS1_STAR_POINTS_DROPPED
Definition enums.h:3592
@ PHASE_MERLEE_EXP_BONUS
Definition enums.h:2072
@ BS_FLAGS2_DONT_STOP_MUSIC
Definition enums.h:3618
@ BTL_SUBSTATE_VICTORY_DONE
Definition enums.h:3850
@ BTL_SUBSTATE_VICTORY_AWAIT_SWAP
Definition enums.h:3854
@ BTL_SUBSTATE_VICTORY_AWAIT_RECOVER_KO
Definition enums.h:3852
@ BTL_SUBSTATE_VICTORY_CHECK_SWAP
Definition enums.h:3853
@ BTL_SUBSTATE_VICTORY_CHECK_OUTTA_SIGHT
Definition enums.h:3846
@ BTL_SUBSTATE_VICTORY_CHECK_MERLEE
Definition enums.h:3848
@ BTL_SUBSTATE_VICTORY_AWAIT_OUTTA_SIGHT
Definition enums.h:3847
@ BTL_SUBSTATE_VICTORY_RECOVER_STATUS
Definition enums.h:3851
@ BTL_SUBSTATE_VICTORY_AWAIT_MERLEE
Definition enums.h:3849
@ BATTLE_STATE_CELEBRATION
Definition enums.h:3663
@ BATTLE_STATE_END_BATTLE
Definition enums.h:3662
@ OUTCOME_ENEMY_FLED
Definition enums.h:1905
@ OUTCOME_PLAYER_WON
Definition enums.h:1902
s32 bgm_set_song(s32 playerIndex, s32 songID, s32 variation, s32 fadeOutTime, s16 volume)
s8 battleOutcome
Definition npc.h:372

Referenced by btl_update().

◆ btl_state_draw_victory()

void btl_state_draw_victory ( void )

Definition at line 1935 of file btl_states_actions.c.

1935 {
1936}

Referenced by btl_draw_ui().

◆ btl_state_update_end_training_battle()

void btl_state_update_end_training_battle ( void )

Definition at line 1938 of file btl_states_actions.c.

1938 {
1939 BattleStatus* battleStatus = &gBattleStatus;
1940 PlayerData* playerData = &gPlayerData;
1941 EncounterStatus* encounterStatus = &gCurrentEncounter;
1943 Actor* partner = gBattleStatus.partnerActor;
1944 Evt* script;
1945
1946 switch (gBattleSubState) {
1949 if (partner != NULL) {
1951 }
1953 gBattleStatus.flags2 &= ~BS_FLAGS2_PLAYER_TURN_USED;
1954 gBattleStatus.flags2 &= ~BS_FLAGS2_PARTNER_TURN_USED;
1955 gBattleStatus.flags2 &= ~BS_FLAGS2_OVERRIDE_INACTIVE_PLAYER;
1956 gBattleStatus.flags2 &= ~BS_FLAGS2_OVERRIDE_INACTIVE_PARTNER;
1957
1958 if (player->koStatus == STATUS_KEY_DAZE) {
1961 }
1962 player->debuff = 0;
1963 player->staticStatus = 0;
1964 player->stoneStatus = 0;
1965 player->transparentStatus = 0;
1966 player->koStatus = 0;
1967 player->koDuration = 0;
1968 player->disableEffect->data.disableX->koDuration = 0;
1969 if (partner != NULL) {
1970 if (partner->koStatus == STATUS_KEY_DAZE) {
1973 }
1974 partner->debuff = 0;
1975 partner->staticStatus = 0;
1976 partner->stoneStatus = 0;
1977 partner->transparentStatus = 0;
1978 partner->koStatus = 0;
1979 partner->koDuration = 0;
1980 partner->disableEffect->data.disableX->koDuration = 0;
1981 }
1982 break;
1984 if (player->handleEventScript != NULL && does_script_exist(player->handleEventScriptID)) {
1985 break;
1986 }
1987 player->handleEventScript = NULL;
1988
1989 if (partner != NULL) {
1990 if (partner->handleEventScript != NULL && does_script_exist(partner->handleEventScriptID)) {
1991 break;
1992 }
1993 partner->handleEventScript = NULL;
1994 }
1995
1997 break;
1998 }
1999
2000 switch (gBattleSubState) {
2002 battleStatus->stateFreezeCount = 0;
2003 gBattleStatus.flags2 &= ~BS_FLAGS2_PLAYER_TURN_USED;
2004 gBattleStatus.flags2 &= ~BS_FLAGS2_PARTNER_TURN_USED;
2005 gBattleStatus.flags2 &= ~BS_FLAGS2_OVERRIDE_INACTIVE_PLAYER;
2006 gBattleStatus.flags2 &= ~BS_FLAGS2_OVERRIDE_INACTIVE_PARTNER;
2007
2008 if (!battleStatus->outtaSightActive) {
2010 } else {
2011 battleStatus->battlePhase = PHASE_ENEMY_BEGIN;
2012 script = start_script(partner->handlePhaseSource, EVT_PRIORITY_A, 0);
2013 partner->handlePhaseScript = script;
2014 partner->handleBatttlePhaseScriptID = script->id;
2015 script->owner1.actorID = ACTOR_PARTNER;
2017 }
2018 break;
2021 battleStatus->outtaSightActive = FALSE;
2023 }
2024 break;
2025 }
2026
2027 switch (gBattleSubState) {
2032 break;
2034 if (BattleSubStateDelay != 0) {
2036 return;
2037 }
2038 if (playerData->trainingsDone < 9999) {
2039 playerData->trainingsDone++;
2040 }
2041 encounterStatus->battleOutcome = OUTCOME_ENEMY_FLED;
2043 bgm_set_song(0, -1, 0, 1500, 8);
2044 }
2046 break;
2047 }
2048}
@ BTL_SUBSTATE_END_TRAINING_DONE
Definition enums.h:3879
@ BTL_SUBSTATE_END_TRAINING_CHECK_OUTTA_SIGHT
Definition enums.h:3876
@ BTL_SUBSTATE_END_TRAINING_AWAIT_OUTTA_SIGHT
Definition enums.h:3877
@ BTL_SUBSTATE_END_TRAINING_INIT
Definition enums.h:3874
@ BTL_SUBSTATE_END_TRAINING_RESET_CAM
Definition enums.h:3878
@ BTL_SUBSTATE_END_TRAINING_AWAIT_RECOVERING
Definition enums.h:3875

Referenced by btl_update().

◆ btl_state_draw_end_training_battle()

void btl_state_draw_end_training_battle ( void )

Definition at line 2050 of file btl_states_actions.c.

2050 {
2051}

Referenced by btl_draw_ui().

◆ btl_state_update_end_battle()

void btl_state_update_end_battle ( void )

Definition at line 2053 of file btl_states_actions.c.

2053 {
2054 EncounterStatus* encounterStatus = &gCurrentEncounter;
2055 BattleStatus* battleStatus = &gBattleStatus;
2056 Battle* battle = gCurrentBattlePtr;
2057 Stage* stage;
2058 Evt* script;
2059 s32 i;
2060
2061 switch (gBattleSubState) {
2065 BattleScreenFadeAmt = 255;
2066 }
2072 }
2074 break;
2076 if (BattleScreenFadeAmt == 255) {
2078 break;
2079 }
2081 if (BattleScreenFadeAmt > 255) {
2082 BattleScreenFadeAmt = 255;
2083 }
2084 break;
2086 BattleScreenFadeAmt = 255;
2087 gBattleStatus.flags1 &= ~BS_FLAGS1_ACTORS_VISIBLE;
2088 if (gCurrentStagePtr == NULL) {
2089 stage = battle->stage;
2090 } else {
2091 stage = gCurrentStagePtr->stage;
2092 }
2093 if (stage->postBattle == NULL) {
2095 return;
2096 }
2097 script = start_script(stage->postBattle, EVT_PRIORITY_A, 0);
2098 battleStatus->controlScript = script;
2099 battleStatus->controlScriptID = script->id;
2101 break;
2103 if (does_script_exist(battleStatus->controlScriptID)) {
2104 break;
2105 }
2107 // fallthrough
2110 for (i = 0; i < ARRAY_COUNT(battleStatus->enemyActors); i++) {
2111 if (battleStatus->enemyActors[i] != NULL) {
2112 btl_delete_actor(battleStatus->enemyActors[i]);
2113 }
2114 }
2115 if (battleStatus->partnerActor != NULL) {
2116 btl_delete_actor(battleStatus->partnerActor);
2117 }
2118
2119 btl_delete_player_actor(battleStatus->playerActor);
2120
2121 if (battleStatus->nextMerleeSpellType == MERLEE_SPELL_COIN_BOOST) {
2122 encounterStatus->hasMerleeCoinBonus = TRUE;
2123 battleStatus->nextMerleeSpellType = MERLEE_SPELL_NONE;
2124 }
2125
2126 encounterStatus->damageTaken = battleStatus->damageTaken;
2127
2129 encounterStatus->dropWhackaBump = TRUE;
2130 }
2131
2134
2137 }
2138
2139 if (encounterStatus->battleOutcome == OUTCOME_PLAYER_LOST &&
2141 {
2142 s16 areaID;
2143 s16 mapID;
2144
2147 get_map_IDs_by_name_checked("gv_01", &areaID, &mapID);
2148 gGameStatusPtr->areaID = areaID;
2149 gGameStatusPtr->mapID = mapID;
2152 } else {
2155 func_8003E514(1);
2157 }
2158 break;
2159 }
2160}
@ gv_01_ENTRY_0
Definition entrances.h:1286
@ MERLEE_SPELL_COIN_BOOST
Definition enums.h:1914
@ BS_FLAGS1_NO_GAME_OVER
Definition enums.h:3591
@ DEBUG_CONTACT_DIE_ON_TOUCH
Definition enums.h:4268
@ BS_FLAGS2_DROP_WHACKA_BUMP
Definition enums.h:3621
@ BTL_CAM_INTERRUPT
Definition enums.h:4822
@ BTL_SUBSTATE_END_BATTLE_CLEANUP
Definition enums.h:3888
@ BTL_SUBSTATE_END_BATTLE_INIT
Definition enums.h:3884
@ BTL_SUBSTATE_END_BATTLE_EXEC_STAGE_SCRIPT
Definition enums.h:3886
@ BTL_SUBSTATE_END_BATTLE_FADE_OUT
Definition enums.h:3885
@ BTL_SUBSTATE_END_BATTLE_AWAIT_STAGE_SCRIPT
Definition enums.h:3887
@ OUTCOME_PLAYER_LOST
Definition enums.h:1903
void kill_all_scripts(void)
void get_map_IDs_by_name_checked(const char *mapName, s16 *areaID, s16 *mapID)
Same as get_map_IDs_by_name, but will panic if the map doesn't exist.
Definition world.c:247
void decrement_status_bar_disabled(void)
Definition inventory.c:1657
void remove_all_effects(void)
Definition effects.c:278
void set_screen_overlay_center(s32, s32, s32, s32)
void btl_delete_player_actor(Actor *player)
Definition 16C8E0.c:1175
void set_windows_visible(s32 groupIdx)
Definition windows.c:445
void btl_delete_actor(Actor *actor)
Definition 16C8E0.c:1110
void btl_cam_unfreeze(void)
Definition camera.c:2002
@ GAME_MODE_END_BATTLE
Definition game_modes.h:16
@ GAME_MODE_GAME_OVER
Definition game_modes.h:14
u8 damageTaken
Definition npc.h:375
void func_8003E514(s8 arg0)
Definition npc.c:2265
b8 hasMerleeCoinBonus
Definition npc.h:374
s8 dropWhackaBump
Definition npc.h:381
EvtScript * postBattle
Definition battle.h:186
s32 gBattleState
Definition battle.c:10
s32 gLastDrawBattleState
Definition battle.c:12

Referenced by btl_update().

◆ btl_state_draw_end_battle()

void btl_state_draw_end_battle ( void )

Definition at line 2162 of file btl_states_actions.c.

Referenced by btl_draw_ui().

◆ btl_state_update_defend()

void btl_state_update_defend ( void )

Definition at line 2173 of file btl_states_actions.c.

2173 {
2175 Evt* script;
2176
2177 switch (gBattleSubState) {
2182 player->takeTurnScriptID = script->id;
2184 script->owner1.actorID = ACTOR_PLAYER;
2185 break;
2189 }
2190 break;
2191 }
2192}
@ PHASE_USE_DEFEND
Definition enums.h:2063
@ BTL_SUBSTATE_DEFEND_AWAIT_SCRIPT
Definition enums.h:3843
@ BTL_SUBSTATE_DEFEND_INIT
Definition enums.h:3842
@ BATTLE_STATE_END_PLAYER_TURN
Definition enums.h:3652

Referenced by btl_update().

◆ btl_state_draw_defend()

void btl_state_draw_defend ( void )

Definition at line 2194 of file btl_states_actions.c.

2194 {
2195}

Referenced by btl_draw_ui().

◆ btl_state_update_run_away()

void btl_state_update_run_away ( void )

Definition at line 2197 of file btl_states_actions.c.

2197 {
2198 BattleStatus* battleStatus = &gBattleStatus;
2199 PlayerData* playerData = &gPlayerData;
2200 EncounterStatus* currentEncounter = &gCurrentEncounter;
2201 Actor* player = battleStatus->playerActor;
2202 Actor* partner = battleStatus->partnerActor;
2203 Actor* enemy;
2204 s32 enemyCount;
2205 f32 totalEscapeChance;
2206 Evt* script;
2207 s32 i;
2208
2209 switch (gBattleSubState) {
2211 battleStatus->stateFreezeCount = 0;
2212 gBattleStatus.flags1 &= ~BS_FLAGS1_BATTLE_FLED;
2217
2218 playerData->fleeAttempts++;
2221
2222 // calculate average escape chance
2223 enemyCount = 0;
2224 totalEscapeChance = 0.0f;
2225
2226 for (i = 0; i < ARRAY_COUNT(battleStatus->enemyActors); i++) {
2227 enemy = battleStatus->enemyActors[i];
2228 if (enemy != NULL) {
2229 if (!(enemy->flags & ACTOR_FLAG_TARGET_ONLY)) {
2230 if (!(enemy->flags & ACTOR_FLAG_NO_DMG_APPLY)) {
2231 f32 escapeChance = enemy->actorBlueprint->escapeChance;
2232
2233 if (enemy->debuff == STATUS_KEY_FEAR ||
2234 enemy->debuff == STATUS_KEY_DIZZY ||
2235 enemy->debuff == STATUS_KEY_PARALYZE ||
2236 enemy->debuff == STATUS_KEY_SLEEP ||
2237 enemy->debuff == STATUS_KEY_FROZEN ||
2238 enemy->debuff == STATUS_KEY_STOP)
2239 {
2240 escapeChance = 100.0f;
2241 }
2242 totalEscapeChance += escapeChance;
2243 enemyCount++;
2244 }
2245 }
2246 }
2247 }
2248 player->state.varTable[0] = totalEscapeChance / enemyCount;
2249
2251 player->state.varTable[0] = 100;
2252 }
2253
2254 battleStatus->battlePhase = PHASE_RUN_AWAY_START;
2256 player->takeTurnScript = script;
2257 player->takeTurnScriptID = script->id;
2258 script->owner1.actorID = ACTOR_PLAYER;
2259 if (partner != NULL && partner->koStatus == 0) {
2260 script = start_script(partner->takeTurnSource, EVT_PRIORITY_A, 0);
2261 partner->takeTurnScript = script;
2262 partner->takeTurnScriptID = script->id;
2263 script->owner1.actorID = ACTOR_PARTNER;
2264 }
2266 break;
2268 if (does_script_exist(player->takeTurnScriptID) || battleStatus->stateFreezeCount != 0) {
2269 break;
2270 }
2273 } else {
2274 currentEncounter->battleOutcome = OUTCOME_PLAYER_FLED;
2277 } else {
2279 func_8023E104();
2280 D_8029F264 = 0;
2281 D_8029F24C = 0;
2283 // divide reward into 20 increments
2284 RunAwayRewardTotal = battleStatus->totalStarPoints * 100;
2285 RunAwayRewardStep = 20;
2288 }
2289 }
2290 break;
2291 }
2292
2294 if (battleStatus->totalStarPoints != 0) {
2295 s32 deltaSP;
2296 s32 prevSP;
2297
2299 prevSP = battleStatus->totalStarPoints;
2300 battleStatus->totalStarPoints = RunAwayRewardTotal / 100;
2301 deltaSP = prevSP - battleStatus->totalStarPoints;
2302
2303 if (deltaSP > 0) {
2305 }
2306 playerData->starPoints += deltaSP;
2308 if (RunAwayRewardStep == 0 && battleStatus->totalStarPoints != 0) {
2309 playerData->starPoints++;
2310 }
2311 }
2312 if (playerData->starPoints >= 99) {
2313 playerData->starPoints = 99;
2314 }
2315 if (battleStatus->totalStarPoints == 0) {
2316 if (RunAwayRewardStep != 0) {
2318 } else {
2320 func_8023E11C();
2322 }
2323 }
2324 }
2325
2327 playerData->battlesFled++;
2329 bgm_set_song(0, -1, 0, 1500, 8);
2330 }
2332 }
2333
2334 switch (gBattleSubState) {
2336 battleStatus->battlePhase = PHASE_RUN_AWAY_FAIL;
2338 player->takeTurnScript = script;
2339 player->takeTurnScriptID = script->id;
2340 script->owner1.actorID = ACTOR_PLAYER;
2341 if (partner != NULL && partner->koStatus == 0) {
2342 script = start_script(partner->takeTurnSource, EVT_PRIORITY_A, 0);
2343 partner->takeTurnScript = script;
2344 partner->takeTurnScriptID = script->id;
2345 script->owner1.actorID = ACTOR_PARTNER;
2346 }
2348 break;
2350 if (BattleSubStateDelay != 0) {
2352 return;
2353 }
2355 && (partner == NULL || !does_script_exist(partner->takeTurnScriptID))
2356 && battleStatus->stateFreezeCount == 0
2357 ) {
2359 }
2360 break;
2361 }
2362}
BSS s32 RunAwayRewardStep
BSS s32 RunAwayRewardIncrement
BSS s32 RunAwayRewardTotal
BSS s32 D_8029F264
BSS s32 D_8029F24C
@ PHASE_RUN_AWAY_START
Definition enums.h:2060
@ PHASE_RUN_AWAY_FAIL
Definition enums.h:2064
@ BS_FLAGS2_OVERRIDE_INACTIVE_PARTNER
Definition enums.h:3607
@ BTL_CAM_PLAYER_FLEE
Definition enums.h:4846
@ BTL_SUBSTATE_RUN_AWAY_EXEC_SCRIPT
Definition enums.h:3834
@ BTL_SUBSTATE_RUN_AWAY_GIVE_STAR_POINTS
Definition enums.h:3838
@ BTL_SUBSTATE_RUN_AWAY_AWAIT_SCRIPT
Definition enums.h:3835
@ BTL_SUBSTATE_RUN_AWAY_DONE
Definition enums.h:3839
@ BTL_SUBSTATE_RUN_AWAY_AWAIT_POST_FAILURE
Definition enums.h:3837
@ BTL_SUBSTATE_RUN_AWAY_EXEC_POST_FAILURE
Definition enums.h:3836
@ ABILITY_RUNAWAY_PAY
Definition enums.h:459
@ SOUND_COIN_PICKUP
Definition enums.h:922
@ ACTOR_FLAG_TARGET_ONLY
Battle ends even if undefeated. No turn.
Definition enums.h:3334
@ ACTOR_FLAG_NO_DMG_APPLY
Damage is not applied to actor HP.
Definition enums.h:3340
@ OUTCOME_PLAYER_FLED
Definition enums.h:1904
void func_8023E104(void)
Definition 16C8E0.c:150
void status_bar_stop_blinking_starpoints(void)
Definition inventory.c:1648
void btl_cam_target_actor(s32)
Definition camera.c:1926
void status_bar_start_blinking_starpoints(void)
Definition inventory.c:1639
void func_8023E11C(void)
Definition 16C8E0.c:155

Referenced by btl_update().

◆ btl_state_draw_run_away()

void btl_state_draw_run_away ( void )

Definition at line 2364 of file btl_states_actions.c.

2364 {
2365}

Referenced by btl_draw_ui().

◆ btl_state_update_defeat()

void btl_state_update_defeat ( void )

Definition at line 2367 of file btl_states_actions.c.

2367 {
2368 BattleStatus* battleStatus = &gBattleStatus;
2369 EncounterStatus* currentEncounter = &gCurrentEncounter;
2370 Actor* player = battleStatus->playerActor;
2371 Actor* partner = battleStatus->partnerActor;
2372 Evt* script;
2373
2374 switch (gBattleSubState) {
2376 battleStatus->flags1 &= ~BS_FLAGS1_SHOW_PLAYER_DECORATIONS;
2377 gBattleStatus.flags2 &= ~BS_FLAGS2_PLAYER_TURN_USED;
2378 gBattleStatus.flags2 &= ~BS_FLAGS2_PARTNER_TURN_USED;
2379 gBattleStatus.flags2 &= ~BS_FLAGS2_OVERRIDE_INACTIVE_PLAYER;
2380 gBattleStatus.flags2 &= ~BS_FLAGS2_OVERRIDE_INACTIVE_PARTNER;
2381 battleStatus->stateFreezeCount = 0;
2382
2383 if (player->debuff != 0) {
2384 if (player->debuff == STATUS_KEY_FROZEN) {
2387 player->icePillarEffect = NULL;
2388 }
2389 player->debuff = 0;
2390 player->debuffDuration = 0;
2392 player->koStatus = 0;
2393 player->koDuration = 0;
2394 player->disableEffect->data.disableX->koDuration = 0;
2395 }
2396
2399 battleStatus->battlePhase = PHASE_DEATH;
2401 player->takeTurnScript = script;
2402 player->takeTurnScriptID = script->id;
2403 script->owner1.actorID = ACTOR_PLAYER;
2404
2405 if (partner != NULL) {
2406 script = start_script(partner->takeTurnSource, EVT_PRIORITY_A, 0);
2407 partner->takeTurnScript = script;
2408 partner->takeTurnScriptID = script->id;
2409 script->owner1.actorID = ACTOR_PARTNER;
2410 }
2412 break;
2414 if (does_script_exist(player->takeTurnScriptID) || battleStatus->stateFreezeCount != 0) {
2415 break;
2416 }
2417 if (find_item(ITEM_LIFE_SHROOM) >= 0) {
2418 battleStatus->battlePhase = PHASE_USE_LIFE_SHROOM;
2420 player->takeTurnScript = script;
2421 player->takeTurnScriptID = script->id;
2422 script->owner1.actorID = ACTOR_PLAYER;
2424 } else {
2426 }
2427 break;
2429 if (does_script_exist(player->takeTurnScriptID) || battleStatus->stateFreezeCount != 0) {
2430 break;
2431 }
2432 // never reached if life shroom is successful. its item script calls RestorePreDefeatState,
2433 // resetting the state to BATTLE_STATE_ENEMY_MOVE (based on the value of gDefeatedBattleState)
2435 break;
2436 }
2437
2439 currentEncounter->battleOutcome = OUTCOME_PLAYER_LOST;
2441 bgm_set_song(0, -1, 0, 1500, 8);
2442 }
2444 }
2445}
@ PHASE_USE_LIFE_SHROOM
Definition enums.h:2065
@ PHASE_DEATH
Definition enums.h:2061
@ BTL_SUBSTATE_DEFEAT_INIT
Definition enums.h:3857
@ BTL_SUBSTATE_DEFEAT_CHECK_LIFE_SHROOM
Definition enums.h:3858
@ BTL_SUBSTATE_DEFEAT_DONE
Definition enums.h:3860
@ BTL_SUBSTATE_DEFEAT_AWAIT_LIFE_SHROOM
Definition enums.h:3859
s32 find_item(s32)
Search player inventory for itemID and return first matching array index.
Definition inventory.c:264

Referenced by btl_update().

◆ btl_state_draw_defeat()

void btl_state_draw_defeat ( void )

Definition at line 2447 of file btl_states_actions.c.

2447 {
2448}

Referenced by btl_draw_ui().

◆ btl_state_update_change_partner()

void btl_state_update_change_partner ( void )

Definition at line 2460 of file btl_states_actions.c.

2460 {
2461 BattleStatus* battleStatus = &gBattleStatus;
2462 Actor* player = battleStatus->playerActor;
2463 Actor* partner = battleStatus->partnerActor;
2464 ActorState* state = &player->state;
2465 PlayerData* playerData = &gPlayerData;
2466 Actor* enemyActor;
2467 Evt* script;
2468 s32 i;
2469
2470 switch (gBattleSubState) {
2472 player->flags &= ~ACTOR_FLAG_SHOW_STATUS_ICONS;
2473 partner->flags &= ~ACTOR_FLAG_SHOW_STATUS_ICONS;
2474 battleStatus->stateFreezeCount = 0;
2477 btl_cam_set_target_pos(-89.0, 40.0, -99.0);
2478 btl_cam_set_zoom(372);
2480 gBattleStatus.flags1 &= ~BS_FLAGS1_MENU_OPEN;
2481
2482 for (i = 0; i < ARRAY_COUNT(battleStatus->enemyActors); i++) {
2483 enemyActor = battleStatus->enemyActors[i];
2484 if (enemyActor != NULL) {
2485 enemyActor->flags &= ~ACTOR_FLAG_HEALTH_BAR_HIDDEN;
2486 enemyActor->flags &= ~ACTOR_FLAG_SHOW_STATUS_ICONS;
2487 }
2488 }
2489
2490 battleStatus->lastPartnerMenuSelection[BTL_MENU_IDX_MAIN] = -1;
2493
2495 if (BattleSubStateDelay != 0) {
2497 break;
2498 }
2501 battleStatus->controlScript = script;
2502 battleStatus->controlScriptID = script->id;
2503 script->owner1.actorID = ACTOR_PARTNER;
2504 state->unk_18.x = partner->curPos.x;
2505 state->unk_18.y = 0.0f;
2506 state->unk_18.z = partner->curPos.z;
2508 break;
2510 if (does_script_exist(battleStatus->controlScriptID)) {
2511 break;
2512 }
2513 btl_delete_actor(partner);
2514 playerData->curPartner = battleStatus->unk_1AC;
2516 partner = battleStatus->partnerActor;
2517 partner->scale.x = 0.1f;
2518 partner->scale.y = 0.1f;
2519 partner->scale.z = 0.1f;
2520 partner->state.goalPos.x = state->unk_18.x;
2521 partner->state.goalPos.y = partner->curPos.y;
2522 partner->state.goalPos.z = state->unk_18.z;
2523 partner->curPos.x = player->curPos.x;
2524 partner->curPos.y = player->curPos.y + 25.0f;
2525 partner->curPos.z = player->curPos.z;
2527 break;
2529 partner = battleStatus->partnerActor;
2530 if (partner != NULL) {
2531 if (does_script_exist(partner->takeTurnScriptID)) {
2532 break;
2533 }
2534 partner->takeTurnScript = NULL;
2535 }
2536
2538 battleStatus->controlScript = script;
2539 battleStatus->controlScriptID = script->id;
2540 script->owner1.actorID = ACTOR_PARTNER;
2542 break;
2544 if (does_script_exist(battleStatus->controlScriptID)) {
2545 break;
2546 }
2547 partner = battleStatus->partnerActor;
2548 if (partner != NULL) {
2549 if (partner->handlePhaseSource != NULL) {
2550 battleStatus->battlePhase = PHASE_PLAYER_BEGIN;
2551 script = start_script(partner->handlePhaseSource, EVT_PRIORITY_A, 0);
2552 partner->handlePhaseScript = script;
2553 partner->handleBatttlePhaseScriptID = script->id;
2554 script->owner1.actorID = ACTOR_PARTNER;
2555 }
2556 }
2558 break;
2560 partner = battleStatus->partnerActor;
2561 if (partner != NULL) {
2562 if (partner->handlePhaseSource != NULL && does_script_exist(partner->handleBatttlePhaseScriptID)) {
2563 break;
2564 }
2565 }
2568 break;
2570 if (battleStatus->stateFreezeCount != 0) {
2571 break;
2572 }
2573 gBattleStatus.flags2 &= ~BS_FLAGS2_OVERRIDE_INACTIVE_PARTNER;
2577 } else {
2579 }
2580 } else {
2583 } else {
2585 }
2586 }
2587 break;
2588 }
2589}
@ BTL_CAM_REPOSITION
Definition enums.h:4840
@ BTL_SUBSTATE_CHANGE_PARTNER_EXEC_PUT_AWAY
Definition enums.h:3866
@ BTL_SUBSTATE_CHANGE_PARTNER_EXEC_PHASE
Definition enums.h:3869
@ BTL_SUBSTATE_CHANGE_PARTNER_INIT
Definition enums.h:3865
@ BTL_SUBSTATE_CHANGE_PARTNER_DONE
Definition enums.h:3871
@ BTL_SUBSTATE_CHANGE_PARTNER_LOAD_NEW_PARTNER
Definition enums.h:3867
@ BTL_SUBSTATE_CHANGE_PARTNER_EXEC_BRING_OUT
Definition enums.h:3868
@ BTL_SUBSTATE_CHANGE_PARTNER_AWAIT_PHASE
Definition enums.h:3870
@ BATTLE_STATE_END_PARTNER_TURN
Definition enums.h:3653
@ ABILITY_QUICK_CHANGE
Definition enums.h:462
@ BTL_MENU_IDX_MAIN
Definition enums.h:4211
void btl_cam_set_zoom(s16)
Definition camera.c:1984
void btl_cam_set_target_pos(f32, f32, f32)
Definition camera.c:1962
void btl_cam_set_zoffset(s16)
Definition camera.c:1996
void deduct_current_move_fp(void)
Definition 190B20.c:961
EvtScript BtlPutPartnerAway
Definition 16C8E0.c:51
EvtScript BtlBringPartnerOut
Definition 16C8E0.c:77

Referenced by btl_update().

◆ btl_state_draw_change_partner()

void btl_state_draw_change_partner ( void )

Definition at line 2591 of file btl_states_actions.c.

2591 {
2592}

Referenced by btl_draw_ui().

◆ btl_state_update_player_move()

void btl_state_update_player_move ( void )

Definition at line 2594 of file btl_states_actions.c.

2594 {
2595 BattleStatus* battleStatus = &gBattleStatus;
2596 Actor* player = battleStatus->playerActor;
2597 Actor* partner = battleStatus->partnerActor;
2598 s32 messageIndex;
2599 Actor* actor;
2600 Evt* script;
2601 s32 enemyNotDone;
2602 s8 tipIndex;
2603 s32 i;
2604
2606 battleStatus->stateFreezeCount = 0;
2607 battleStatus->actionResult = ACTION_RESULT_NONE;
2608 battleStatus->blockResult = BLOCK_RESULT_NONE;
2609 battleStatus->lastAttackDamage = 0;
2610 battleStatus->curDamageSource = DMG_SRC_DEFAULT;
2611 gBattleStatus.flags1 &= ~BS_FLAGS1_AUTO_SUCCEED_ACTION;
2612 gBattleStatus.flags1 &= ~BS_FLAGS1_MENU_OPEN;
2614 player->flags &= ~ACTOR_FLAG_SHOW_STATUS_ICONS;
2615 if (partner != NULL) {
2616 partner->flags &= ~ACTOR_FLAG_SHOW_STATUS_ICONS;
2617 }
2619 gBattleStatus.flags1 &= ~BS_FLAGS1_SHOW_PLAYER_DECORATIONS;
2620 player->statusAfflicted = 0;
2622 gBattleStatus.flags1 &= ~BS_FLAGS1_YIELD_TURN;
2623
2624 for (i = 0; i < ARRAY_COUNT(battleStatus->enemyActors); i++) {
2625 actor = battleStatus->enemyActors[i];
2626 if (actor != NULL) {
2627 actor->statusAfflicted = 0;
2628 }
2629 }
2630
2631 for (i = 0; i < ARRAY_COUNT(battleStatus->enemyActors); i++) {
2632 actor = battleStatus->enemyActors[i];
2633 if (actor != NULL) {
2634 actor->flags &= ~ACTOR_FLAG_HEALTH_BAR_HIDDEN;
2635 actor->flags &= ~ACTOR_FLAG_SHOW_STATUS_ICONS;
2636 }
2637 }
2638
2639 if (battleStatus->moveCategory == BTL_MENU_TYPE_JUMP || battleStatus->moveCategory == BTL_MENU_TYPE_SMASH) {
2640 if (battleStatus->nextMerleeSpellType == MERLEE_SPELL_ATK_BOOST) {
2641 battleStatus->merleeAttackBoost = 3;
2642 battleStatus->nextMerleeSpellType = MERLEE_SPELL_NONE;
2643 battleStatus->battlePhase = PHASE_MERLEE_ATTACK_BONUS;
2645 player->takeTurnScript = script;
2646 player->takeTurnScriptID = script->id;
2647 script->owner1.actorID = ACTOR_PLAYER;
2651 } else {
2653 gBattleStatus.flags1 &= ~BS_FLAGS1_MENU_OPEN;
2654 }
2655 } else {
2657 gBattleStatus.flags1 &= ~BS_FLAGS1_MENU_OPEN;
2658 }
2659 }
2660
2661 switch (gBattleSubState) {
2663 if (player->takeTurnScript != NULL && does_script_exist(player->takeTurnScriptID)) {
2664 break;
2665 }
2666 player->takeTurnScript = NULL;
2668 if (battleStatus->selectedMoveID != MOVE_NONE) {
2669 tipIndex = gMoveTable[battleStatus->selectedMoveID].actionTip;
2670 if (tipIndex >= 0) {
2672 }
2673 }
2674 }
2677 break;
2679 if (BattleSubStateDelay != 0) {
2681 } else {
2683 }
2684 break;
2685 }
2686
2687 switch (gBattleSubState) {
2689 gBattleStatus.flags1 &= ~BS_FLAGS1_4000;
2690 gBattleStatus.flags1 &= ~BS_FLAGS1_10000;
2693 reset_all_actor_sounds(player);
2694 battleStatus->battlePhase = PHASE_EXECUTE_ACTION;
2697 } else {
2699 }
2700 player->takeTurnScript = script;
2702 player->takeTurnScriptID = script->id;
2703 script->owner1.actorID = ACTOR_PLAYER;
2704 break;
2706 // wait for player battle phase script to finish
2708 if (player->takeTurnScript != NULL && does_script_exist(player->takeTurnScriptID)) {
2709 break;
2710 }
2711 player->takeTurnScript = NULL;
2712 }
2713
2714 gBattleStatus.flags1 &= ~BS_FLAGS1_EXECUTING_MOVE;
2715
2716 // wait for player battle event script to finish
2717 if (player->handleEventScript != NULL && does_script_exist(player->handleEventScriptID)) {
2718 break;
2719 }
2720 player->handleEventScript = NULL;
2721
2722 // wait for partner battle event script to finish
2723 if (partner != NULL) {
2724 if (partner->handleEventScript != NULL && does_script_exist(partner->handleEventScriptID)) {
2725 break;
2726 }
2727 partner->handleEventScript = NULL;
2728 }
2729
2730 // wait for all enemy battle phase scripts to finish
2731 enemyNotDone = FALSE;
2732 for (i = 0; i < ARRAY_COUNT(battleStatus->enemyActors); i++) {
2733 actor = battleStatus->enemyActors[i];
2734 if (actor != NULL && actor->takeTurnScript != NULL) {
2735 if (does_script_exist(actor->takeTurnScriptID)) {
2736 enemyNotDone = TRUE;
2737 } else {
2738 actor->takeTurnScript = NULL;
2739 }
2740 }
2741 }
2742 if (enemyNotDone) {
2743 break;
2744 }
2745
2746 // wait for all enemy battle event scripts to finish
2747 enemyNotDone = FALSE;
2748 for (i = 0; i < ARRAY_COUNT(battleStatus->enemyActors); i++) {
2749 actor = battleStatus->enemyActors[i];
2750 if (actor != NULL && actor->handleEventScript != NULL) {
2752 enemyNotDone = TRUE;
2753 } else {
2754 actor->handleEventScript = NULL;
2755 }
2756 }
2757 }
2758 if (enemyNotDone) {
2759 break;
2760 }
2761
2762 for (i = 0; i < ARRAY_COUNT(battleStatus->enemyActors); i++) {
2763 actor = battleStatus->enemyActors[i];
2764 if (actor != NULL) {
2765 actor->flags &= ~ACTOR_FLAG_HEALTH_BAR_HIDDEN;
2766 }
2767 }
2768
2769 if (battleStatus->stateFreezeCount != 0) {
2770 break;
2771 }
2772
2775 break;
2776 }
2777
2780 gBattleStatus.flags2 &= ~BS_FLAGS2_OVERRIDE_INACTIVE_PLAYER;
2782 return;
2783 }
2784
2785 if ((battleStatus->moveCategory == BTL_MENU_TYPE_SMASH)
2786 && (battleStatus->selectedMoveID != MOVE_SMASH_CHARGE0)
2787 && (battleStatus->selectedMoveID != MOVE_SMASH_CHARGE)
2788 && (battleStatus->selectedMoveID != MOVE_SUPER_SMASH_CHARGE)
2789 ) {
2790 gBattleStatus.flags1 &= ~BS_FLAGS1_HAMMER_CHARGED;
2791 }
2792
2793 if ((battleStatus->moveCategory == BTL_MENU_TYPE_JUMP)
2794 && (battleStatus->selectedMoveID != MOVE_JUMP_CHARGE0)
2795 && (battleStatus->selectedMoveID != MOVE_JUMP_CHARGE)
2796 && (battleStatus->selectedMoveID != MOVE_SUPER_JUMP_CHARGE)
2797 ) {
2798 gBattleStatus.flags1 &= ~BS_FLAGS1_JUMP_CHARGED;
2799 }
2800
2802 battleStatus->jumpCharge = 0;
2803 }
2805 battleStatus->hammerCharge = 0;
2806 }
2807
2808 for (i = 0; i < ARRAY_COUNT(battleStatus->enemyActors); i++) {
2809 actor = battleStatus->enemyActors[i];
2810 if (actor != NULL && !(actor->flags & ACTOR_FLAG_NO_DMG_APPLY)) {
2812 }
2813 }
2814
2816
2817 enemyNotDone = FALSE;
2818 for (i = 0; i < ARRAY_COUNT(battleStatus->enemyActors); i++) {
2819 actor = battleStatus->enemyActors[i];
2820 if (actor != NULL) {
2821 if (actor->statusAfflicted != 0) {
2822 enemyNotDone = TRUE;
2823 break;
2824 }
2825 }
2826 }
2827
2828 if (!enemyNotDone) {
2830 } else {
2832 switch (actor->statusAfflicted) {
2833 case 4:
2834 messageIndex = BTL_MSG_ENEMY_DAZED;
2835 break;
2836 case 6:
2837 messageIndex = BTL_MSG_ENEMY_ASLEEP;
2838 break;
2839 case 7:
2840 messageIndex = BTL_MSG_ENEMY_FROZEN;
2841 break;
2842 case 9:
2843 messageIndex = BTL_MSG_ENEMY_POISONED;
2844 break;
2845 case 10:
2846 messageIndex = BTL_MSG_ENEMY_SHRUNK;
2847 break;
2848 case 5:
2849 messageIndex = BTL_MSG_ENEMY_PARALYZED;
2850 break;
2851 case 11:
2852 messageIndex = BTL_MSG_ENEMY_ELECTRIFIED;
2853 break;
2854 case 8:
2855 messageIndex = BTL_MSG_ENEMY_CANT_MOVE;
2856 break;
2857 default:
2858 messageIndex = 0;
2860 break;
2861 }
2863 btl_show_battle_message(messageIndex, 60);
2864 for (i = 0; i < ARRAY_COUNT(battleStatus->enemyActors); i++) {
2865 actor = battleStatus->enemyActors[i];
2866 if (actor != NULL) {
2867 actor->statusAfflicted = 0;
2868 }
2869 }
2871 }
2872 break;
2874 if (!btl_is_popup_displayed()) {
2876 btl_cam_move(15);
2879 }
2880 break;
2882 if (BattleSubStateDelay != 0) {
2884 } else {
2886 }
2887 break;
2888 }
2889
2890 switch (gBattleSubState) {
2892 if (player->statusAfflicted != 0) {
2894 switch (player->statusAfflicted) {
2895 case 4:
2896 messageIndex = BTL_MSG_PLAYER_DAZED;
2897 break;
2898 case 6:
2899 messageIndex = BTL_MSG_PLAYER_ASLEEP;
2900 break;
2901 case 7:
2902 messageIndex = BTL_MSG_PLAYER_FROZEN;
2903 break;
2904 case 9:
2905 messageIndex = BTL_MSG_PLAYER_POISONED;
2906 break;
2907 case 10:
2908 messageIndex = BTL_MSG_PLAYER_SHRUNK;
2909 break;
2910 case 5:
2911 messageIndex = BTL_MSG_PLAYER_PARALYZED;
2912 break;
2913 case 11:
2914 messageIndex = BTL_MSG_PLAYER_CHARGED;
2915 break;
2916 default:
2917 messageIndex = 0;
2919 break;
2920 }
2921 btl_show_battle_message(messageIndex, 60);
2922 player->statusAfflicted = 0;
2923 player->disableDismissTimer = 0;
2926
2927 } else {
2929 }
2930 break;
2932 if (!btl_is_popup_displayed()) {
2934 btl_cam_move(15);
2937 }
2938 break;
2940 if (BattleSubStateDelay != 0) {
2942 } else {
2944 }
2945 break;
2946 }
2947
2949 if (player->takeTurnScript == NULL || !does_script_exist(player->takeTurnScriptID)) {
2950 player->takeTurnScript = NULL;
2952 }
2953 }
2954}
@ MERLEE_SPELL_ATK_BOOST
Definition enums.h:1911
@ BS_FLAGS1_10000
Definition enums.h:3584
@ BS_FLAGS1_YIELD_TURN
Definition enums.h:3589
@ BS_FLAGS1_EXECUTING_MOVE
Definition enums.h:3577
@ BTL_MSG_PLAYER_FROZEN
Definition enums.h:4069
@ BTL_MSG_PLAYER_POISONED
Definition enums.h:4070
@ BTL_MSG_PLAYER_PARALYZED
Definition enums.h:4072
@ BTL_MSG_ENEMY_ASLEEP
Definition enums.h:4076
@ BTL_MSG_PLAYER_CHARGED
Definition enums.h:4073
@ BTL_MSG_PLAYER_ASLEEP
Definition enums.h:4068
@ BTL_MSG_ENEMY_POISONED
Definition enums.h:4078
@ BTL_MSG_PLAYER_SHRUNK
Definition enums.h:4071
@ BTL_MSG_ENEMY_CANT_MOVE
Definition enums.h:4082
@ BTL_MSG_ENEMY_PARALYZED
Definition enums.h:4080
@ BTL_MSG_ENEMY_FROZEN
Definition enums.h:4077
@ BTL_MSG_ENEMY_DAZED
Definition enums.h:4075
@ BTL_MSG_FIRST_ACTION_TIP
Definition enums.h:4103
@ BTL_MSG_ENEMY_ELECTRIFIED
Definition enums.h:4081
@ BTL_MSG_ENEMY_SHRUNK
Definition enums.h:4079
@ BTL_MSG_PLAYER_DAZED
Definition enums.h:4067
@ PHASE_MERLEE_ATTACK_BONUS
Definition enums.h:2070
@ PHASE_EXECUTE_ACTION
Definition enums.h:2058
@ BTL_CAM_VIEW_ENEMIES
Definition enums.h:4824
@ BTL_CAM_PLAYER_STATUS_AFFLICTED
Definition enums.h:4854
@ BTL_SUBSTATE_PLAYER_MOVE_EXECUTE_MOVE
Definition enums.h:3789
@ BTL_SUBSTATE_PLAYER_MOVE_POST_PLAYER_STATUS_POPUP
Definition enums.h:3795
@ BTL_SUBSTATE_PLAYER_MOVE_SHOW_TIP_DELAY
Definition enums.h:3788
@ BTL_SUBSTATE_PLAYER_MOVE_AWAIT_PLAYER_STATUS_POPUP
Definition enums.h:3794
@ BTL_SUBSTATE_PLAYER_MOVE_AWAIT_DONE
Definition enums.h:3796
@ BTL_SUBSTATE_PLAYER_MOVE_CHECK_PLAYER_STATUS
Definition enums.h:3793
@ BTL_SUBSTATE_PLAYER_MOVE_POST_ENEMY_STATUS_POPUP
Definition enums.h:3792
@ BTL_SUBSTATE_PLAYER_MOVE_INIT
Definition enums.h:3786
@ BTL_SUBSTATE_PLAYER_MOVE_BEGIN_SHOW_TIP
Definition enums.h:3787
@ BTL_SUBSTATE_PLAYER_MOVE_AWAIT_ENEMY_STATUS_POPUP
Definition enums.h:3791
@ BTL_SUBSTATE_PLAYER_MOVE_HANDLE_RESULTS
Definition enums.h:3790
@ BATTLE_STATE_END_DEMO_BATTLE
Definition enums.h:3665
@ DMG_SRC_DEFAULT
Definition enums.h:1988
@ SOUND_INFLICT_KO
Definition enums.h:1545
void reset_all_actor_sounds(Actor *)
Definition 190B20.c:2938
void btl_update_ko_status(void)
Definition 190B20.c:2869
void close_action_command_instruction_popup(void)
void increment_status_bar_disabled(void)
Definition inventory.c:1665
EvtScript EVS_Peach_HandlePhase
s8 moveCategory
0 = jump, 1 = hammer, 5 = partner, ...

Referenced by btl_update().

◆ btl_state_draw_player_move()

void btl_state_draw_player_move ( void )

Definition at line 2956 of file btl_states_actions.c.

2956 {
2957}

Referenced by btl_draw_ui().

◆ btl_state_update_end_player_turn()

void btl_state_update_end_player_turn ( void )

Definition at line 2959 of file btl_states_actions.c.

2959 {
2960 BattleStatus* battleStatus = &gBattleStatus;
2961 Actor* player = battleStatus->playerActor;
2962 Actor* partner = battleStatus->partnerActor;
2963 Evt* script;
2964
2966 if (battleStatus->moveCategory == BTL_MENU_TYPE_ITEMS && battleStatus->itemUsesLeft >= 2) {
2968 } else if (
2973 ) {
2975 } else if (player->stoneStatus == STATUS_KEY_STONE || battleStatus->outtaSightActive) {
2977 } else {
2978 s32 prevHPDrainCount = 0;
2979 s32 hpRecovery = 0;
2980 s32 fpRecovery = 0;
2981
2983 prevHPDrainCount = battleStatus->hpDrainCount;
2984 battleStatus->hpDrainCount = 0;
2985 }
2986
2987 if (rand_int(100) < 50) {
2988 hpRecovery = is_ability_active(ABILITY_CRAZY_HEART) * 3;
2989 }
2990 if (rand_int(100) < 50) {
2992 }
2993 if (rand_int(100) < 50) {
2995 }
2996
2997 if (prevHPDrainCount + hpRecovery + fpRecovery == 0) {
2999 } else {
3000 battleStatus->battlePhase = PHASE_PLAYER_HAPPY;
3002 player->takeTurnScript = script;
3003 player->takeTurnScriptID = script->id;
3004 script->owner1.actorID = ACTOR_PLAYER;
3006 script->varTable[10] += battleStatus->hpDrainCount;
3007 battleStatus->hpDrainCount = 0;
3008 }
3009 script->varTable[10] = prevHPDrainCount;
3010 script->varTable[11] = hpRecovery;
3011 script->varTable[12] = fpRecovery;
3012
3013 if (script->varTable[10] > 99) {
3014 script->varTable[10] = 99;
3015 }
3016 if (script->varTable[11] > 99) {
3017 script->varTable[11] = 99;
3018 }
3019 if (script->varTable[12] > 99) {
3020 script->varTable[12] = 99;
3021 }
3022
3023 gBattleStatus.flags2 &= ~BS_FLAGS2_HAS_DRAINED_HP;
3025 }
3026 }
3027 }
3028
3029 switch (gBattleSubState) {
3031 if (player->takeTurnScript != NULL && does_script_exist(player->takeTurnScriptID)) {
3032 break;
3033 }
3034 player->takeTurnScript = NULL;
3035
3038 } else {
3039 player->state.curPos.x = player->homePos.x;
3040 player->state.curPos.z = player->homePos.z;
3041 player->state.goalPos.x = partner->homePos.x;
3042 player->state.goalPos.z = partner->homePos.z;
3043 player->state.moveTime = 4;
3044 player->state.angle = 0.0f;
3046 }
3047 break;
3048 }
3049
3051 if (player->state.moveTime != 0) {
3052 player->curPos.x += (player->state.goalPos.x - player->curPos.x) / player->state.moveTime;
3053 player->curPos.z += (player->state.goalPos.z - player->curPos.z) / player->state.moveTime;
3054 partner->curPos.x += (player->state.curPos.x - partner->curPos.x) / player->state.moveTime;
3055 partner->curPos.z += (player->state.curPos.z - partner->curPos.z) / player->state.moveTime;
3056 }
3057 player->curPos.z += sin_rad(DEG_TO_RAD(player->state.angle)) * 16.0f;
3058 player->yaw = clamp_angle(-player->state.angle);
3059 partner->curPos.z -= sin_rad(DEG_TO_RAD(player->state.angle)) * 16.0f;
3060 partner->yaw = clamp_angle(-player->state.angle);
3061 player->state.angle += 90.0f;
3062
3063 if (player->state.moveTime != 0) {
3064 player->state.moveTime--;
3065 } else {
3066 player->curPos.x = player->state.goalPos.x;
3067 player->curPos.z = player->state.goalPos.z;
3068 partner->curPos.x = player->state.curPos.x;
3069 partner->curPos.z = player->state.curPos.z;
3070 player->homePos.x = player->curPos.x;
3071 player->homePos.z = player->curPos.z;
3072 partner->homePos.x = partner->curPos.x;
3073 partner->homePos.z = partner->curPos.z;
3076 }
3077 }
3078
3081 if (battleStatus->moveCategory == BTL_MENU_TYPE_ITEMS && battleStatus->itemUsesLeft >= 2) {
3083 btl_cam_move(10);
3084 gBattleStatus.flags2 &= ~BS_FLAGS2_PLAYER_TURN_USED;
3085 } else {
3087 }
3088
3089 if (battleStatus->unk_94 < 0) {
3090 battleStatus->unk_94 = 0;
3091 battleStatus->itemUsesLeft = 0;
3093 return;
3094 }
3095
3096 if (battleStatus->itemUsesLeft != 0) {
3097 battleStatus->itemUsesLeft--;
3098 if (battleStatus->itemUsesLeft != 0) {
3099 // double or triple dip has not run out yet, let the player choose another item
3102 return;
3103 }
3104
3106 if (battleStatus->hustleTurns != 0) {
3107 battleStatus->hustleTurns--;
3108 }
3109 }
3110
3111 if (battleStatus->hustleTurns != 0 && (gBattleStatus.flags1 & BS_FLAGS1_HUSTLED)) {
3112 gBattleStatus.flags2 &= ~BS_FLAGS2_PLAYER_TURN_USED;
3114 return;
3115 } else {
3116 gBattleStatus.flags1 &= ~BS_FLAGS1_HUSTLED;
3118 return;
3119 }
3120 }
3121
3123 if (battleStatus->hustleTurns != 0) {
3124 battleStatus->hustleTurns--;
3125 }
3126 }
3127
3128 if (battleStatus->hustleTurns != 0 && (gBattleStatus.flags1 & BS_FLAGS1_HUSTLED)) {
3129 gBattleStatus.flags2 &= ~BS_FLAGS2_PLAYER_TURN_USED;
3131 } else {
3132 gBattleStatus.flags1 &= ~BS_FLAGS2_HAS_DRAINED_HP;
3135 } else {
3137 }
3138 }
3139 }
3140 }
3141}
@ PHASE_PLAYER_HAPPY
Definition enums.h:2073
@ BS_FLAGS2_HAS_DRAINED_HP
Definition enums.h:3619
@ BTL_SUBSTATE_END_PLAYER_TURN_AWAIT_HAPPY
Definition enums.h:3827
@ BTL_SUBSTATE_END_PLAYER_TURN_AWAIT_SWAP
Definition enums.h:3828
@ BTL_SUBSTATE_END_PLAYER_TURN_DONE
Definition enums.h:3829
@ BTL_SUBSTATE_END_PLAYER_TURN_CHECK_HAPPY
Definition enums.h:3826
@ BATTLE_STATE_END_TURN
Definition enums.h:3636
@ ABILITY_HAPPY_HEART
Definition enums.h:454
@ ABILITY_CRAZY_HEART
Definition enums.h:467
@ ABILITY_HAPPY_FLOWER
Definition enums.h:488

Referenced by btl_update().

◆ btl_state_update_partner_move()

void btl_state_update_partner_move ( void )

Definition at line 3146 of file btl_states_actions.c.

3146 {
3147 BattleStatus* battleStatus = &gBattleStatus;
3148 PlayerData* playerData = &gPlayerData;
3149 Actor* player = battleStatus->playerActor;
3150 Actor* partner = battleStatus->partnerActor;
3151 Actor* enemyActor;
3152 Evt* script;
3153 s8 switchCondition;
3154 s32 enemyFound;
3155 s32 messageIndex;
3156 s32 i;
3157
3158 switch (gBattleSubState) {
3160 if (partner == NULL) {
3162 break;
3163 }
3164 battleStatus->stateFreezeCount = 0;
3165 battleStatus->actionResult = ACTION_RESULT_NONE;
3166 battleStatus->blockResult = BLOCK_RESULT_NONE;
3167 battleStatus->curDamageSource = DMG_SRC_DEFAULT;
3168 gBattleStatus.flags1 &= ~BS_FLAGS1_AUTO_SUCCEED_ACTION;
3169 gBattleStatus.flags1 &= ~BS_FLAGS1_MENU_OPEN;
3171 partner->statusAfflicted = 0;
3172 partner->flags &= ~ACTOR_FLAG_SHOW_STATUS_ICONS;
3173 player->flags &= ~ACTOR_FLAG_SHOW_STATUS_ICONS;
3177 gBattleStatus.flags1 &= ~BS_FLAGS1_YIELD_TURN;
3178
3179 for (i = 0; i < ARRAY_COUNT(battleStatus->enemyActors); i++) {
3180 enemyActor = battleStatus->enemyActors[i];
3181 if (enemyActor != NULL) {
3182 enemyActor->statusAfflicted = 0;
3183 }
3184 }
3187 break;
3189 for (i = 0; i < ARRAY_COUNT(battleStatus->enemyActors); i++) {
3190 enemyActor = battleStatus->enemyActors[i];
3191 if (enemyActor != NULL) {
3192 enemyActor->flags &= ~ACTOR_FLAG_HEALTH_BAR_HIDDEN;
3193 enemyActor->flags &= ~ACTOR_FLAG_SHOW_STATUS_ICONS;
3194 }
3195 }
3196
3200 reset_all_actor_sounds(partner);
3201 battleStatus->battlePhase = PHASE_EXECUTE_ACTION;
3202 script = start_script(partner->takeTurnSource, EVT_PRIORITY_A, 0);
3203 partner->takeTurnScript = script;
3204 partner->takeTurnScriptID = script->id;
3205 script->owner1.actorID = ACTOR_PARTNER;
3207 break;
3210 if (partner->takeTurnScript != NULL && does_script_exist(partner->takeTurnScriptID)) {
3211 break;
3212 }
3213 partner->takeTurnScript = NULL;
3214 }
3215 gBattleStatus.flags1 &= ~BS_FLAGS1_EXECUTING_MOVE;
3216
3217 if (partner->handleEventScript != NULL && does_script_exist(partner->handleEventScriptID)) {
3218 break;
3219 }
3220 partner->handleEventScript = NULL;
3221
3222 if (player->handleEventScript != NULL && does_script_exist(player->handleEventScriptID)) {
3223 break;
3224 }
3225 player->handleEventScript = NULL;
3226
3227 enemyFound = FALSE;
3228 for (i = 0; i < ARRAY_COUNT(battleStatus->enemyActors); i++) {
3229 enemyActor = battleStatus->enemyActors[i];
3230 if (enemyActor != NULL && enemyActor->takeTurnScript != NULL) {
3231 if (does_script_exist(enemyActor->takeTurnScriptID)) {
3232 enemyFound = TRUE;
3233 } else {
3234 enemyActor->takeTurnScript = NULL;
3235 }
3236 }
3237 }
3238 if (enemyFound) {
3239 break;
3240 }
3241
3242 enemyFound = FALSE;
3243 for (i = 0; i < ARRAY_COUNT(battleStatus->enemyActors); i++) {
3244 enemyActor = battleStatus->enemyActors[i];
3245 if (enemyActor != NULL && enemyActor->handleEventScript != NULL) {
3246 if (does_script_exist(enemyActor->handleEventScriptID)) {
3247 enemyFound = TRUE;
3248 } else {
3249 enemyActor->handleEventScript = NULL;
3250 }
3251 }
3252 }
3253 if (enemyFound) {
3254 break;
3255 }
3256
3257 for (i = 0; i < ARRAY_COUNT(battleStatus->enemyActors); i++) {
3258 enemyActor = battleStatus->enemyActors[i];
3259 if (enemyActor != NULL) {
3260 enemyActor->flags &= ~ACTOR_FLAG_HEALTH_BAR_HIDDEN;
3261 }
3262 }
3263
3264 if (battleStatus->stateFreezeCount != 0) {
3265 break;
3266 }
3267
3270 break;
3271 }
3273 if (playerData->curPartner == PARTNER_GOOMBARIO
3274 && battleStatus->moveCategory == BTL_MENU_TYPE_CHANGE_PARTNER
3275 && battleStatus->selectedMoveID != MOVE_CHARGE) {
3276 partner->isGlowing = FALSE;
3277 gBattleStatus.flags1 &= ~BS_FLAGS1_GOOMBARIO_CHARGED;
3278 }
3280 return;
3281 }
3282
3283 for (i = 0; i < ARRAY_COUNT(battleStatus->enemyActors); i++) {
3284 enemyActor = battleStatus->enemyActors[i];
3285 if (enemyActor != NULL) {
3286 if (!(enemyActor->flags & ACTOR_FLAG_NO_DMG_APPLY)) {
3288 }
3289 }
3290 }
3291
3293
3297 partner->statusAfflicted = 0;
3298 partner->disableDismissTimer = 0;
3301 } else {
3303 }
3304 break;
3306 if (btl_is_popup_displayed()) {
3307 break;
3308 }
3310 btl_cam_move(15);
3313 break;
3315 if (BattleSubStateDelay != 0) {
3317 } else {
3319 }
3320 break;
3321 }
3322
3323 switch (gBattleSubState) {
3325 enemyFound = FALSE;
3326 for (i = 0; i < ARRAY_COUNT(battleStatus->enemyActors); i++) {
3327 enemyActor = battleStatus->enemyActors[i];
3328 if (enemyActor != NULL) {
3329 if (enemyActor->statusAfflicted != 0) {
3330 enemyFound = TRUE;
3331 break;
3332 }
3333 }
3334 }
3335
3336 if (!enemyFound) {
3338 } else {
3340 switchCondition = enemyActor->statusAfflicted - 4;
3341 switch (switchCondition) {
3342 case 0:
3343 messageIndex = BTL_MSG_ENEMY_DAZED;
3344 break;
3345 case 2:
3346 messageIndex = BTL_MSG_ENEMY_ASLEEP;
3347 break;
3348 case 3:
3349 messageIndex = BTL_MSG_ENEMY_FROZEN;
3350 break;
3351 case 5:
3352 messageIndex = BTL_MSG_ENEMY_POISONED;
3353 break;
3354 case 6:
3355 messageIndex = BTL_MSG_ENEMY_SHRUNK;
3356 break;
3357 case 1:
3358 messageIndex = BTL_MSG_ENEMY_PARALYZED;
3359 break;
3360 case 7:
3361 messageIndex = BTL_MSG_ENEMY_ELECTRIFIED;
3362 break;
3363 case 4:
3364 messageIndex = BTL_MSG_ENEMY_CANT_MOVE;
3365 break;
3366 default:
3367 messageIndex = 0;
3369 break;
3370 }
3371
3373 btl_show_battle_message(messageIndex, 60);
3374
3375 for (i = 0; i < ARRAY_COUNT(battleStatus->enemyActors); i++) {
3376 enemyActor = battleStatus->enemyActors[i];
3377 if (enemyActor != NULL) {
3378 enemyActor->statusAfflicted = 0;
3379 }
3380 }
3382 }
3383 break;
3385 if (btl_is_popup_displayed() == FALSE) {
3387 btl_cam_move(15);
3390 }
3391 break;
3393 if (BattleSubStateDelay != 0) {
3395 } else {
3397 }
3398 break;
3399 }
3400
3402 if (partner->takeTurnScript != NULL && does_script_exist(partner->takeTurnScriptID)) {
3403 return;
3404 }
3405 partner->takeTurnScript = NULL;
3407 }
3408}
@ BTL_MSG_PARTNER_INJURED
Definition enums.h:4092
@ BTL_MENU_TYPE_CHANGE_PARTNER
Definition enums.h:4231
@ BTL_CAM_PARTNER_INJURED
Definition enums.h:4875
@ BTL_SUBSTATE_PARTNER_MOVE_EXECUTE_MOVE
Definition enums.h:3800
@ BTL_SUBSTATE_PARTNER_MOVE_AWAIT_ENEMY_STATUS_POPUP
Definition enums.h:3805
@ BTL_SUBSTATE_PARTNER_MOVE_AWAIT_PARTNER_STATUS_POPUP
Definition enums.h:3802
@ BTL_SUBSTATE_PARTNER_MOVE_DONE
Definition enums.h:3807
@ BTL_SUBSTATE_PARTNER_MOVE_POST_ENEMY_STATUS_POPUP
Definition enums.h:3806
@ BTL_SUBSTATE_PARTNER_MOVE_POST_PARTNER_STATUS_POPUP
Definition enums.h:3803
@ BTL_SUBSTATE_PARTNER_MOVE_HANDLE_RESULTS
Definition enums.h:3801
@ BTL_SUBSTATE_PARTNER_MOVE_CHECK_ENEMY_STATUS
Definition enums.h:3804
@ BTL_SUBSTATE_PARTNER_MOVE_INIT
Definition enums.h:3799
@ PARTNER_GOOMBARIO
Definition enums.h:2886
s32 btl_are_all_enemies_defeated(void)
Definition 190B20.c:636

Referenced by btl_update().

◆ btl_state_draw_end_player_turn()

void btl_state_draw_end_player_turn ( void )

Definition at line 3143 of file btl_states_actions.c.

3143 {
3144}

Referenced by btl_draw_ui().

◆ btl_state_draw_partner_move()

void btl_state_draw_partner_move ( void )

Definition at line 3410 of file btl_states_actions.c.

3410 {
3411}

Referenced by btl_draw_ui().

◆ btl_state_update_end_partner_turn()

void btl_state_update_end_partner_turn ( void )

Definition at line 3413 of file btl_states_actions.c.

3413 {
3414 BattleStatus* battleStatus = &gBattleStatus;
3415
3417 battleStatus->flags2 |= BS_FLAGS2_PARTNER_TURN_USED;
3419 return;
3420 }
3421 battleStatus->flags1 &= ~BS_FLAGS1_PARTNER_ACTING;
3422 battleStatus->flags2 &= ~BS_FLAGS2_OVERRIDE_INACTIVE_PARTNER;
3423
3424 if (battleStatus->unk_94 < 0) {
3425 battleStatus->unk_94 = 0;
3427 } else {
3429 }
3430 }
3431}

Referenced by btl_update().

◆ btl_state_draw_end_partner_turn()

void btl_state_draw_end_partner_turn ( void )

Definition at line 3433 of file btl_states_actions.c.

3433 {
3434}

Referenced by btl_draw_ui().

◆ btl_state_update_next_enemy()

void btl_state_update_next_enemy ( void )

Definition at line 3436 of file btl_states_actions.c.

3436 {
3437 BattleStatus* battleStatus = &gBattleStatus;
3439 Actor* partner = gBattleStatus.partnerActor;
3440 Actor* enemy;
3441 s32 skipEnemy;
3442 s32 i;
3443
3444 switch (gBattleSubState) {
3447 i = battleStatus->nextEnemyIndex;
3448 if (i >= battleStatus->numEnemyActors) {
3449 // all enemies have been exhausted
3450 battleStatus->nextEnemyIndex = 0;
3452 return;
3453 }
3454
3455 // find the next eligible enemy
3456 while (TRUE) {
3457 if (battleStatus->enemyIDs[i] >= 0) {
3458 u16 enemyID = battleStatus->enemyIDs[i];
3459
3460 enemy = battleStatus->enemyActors[enemyID & 0xFF];
3461 if (enemy != NULL) {
3463 break;
3464 }
3465 }
3466 }
3467 i++;
3468 if (i >= battleStatus->numEnemyActors) {
3469 i = 0;
3470 }
3471 if (i == 0) {
3472 battleStatus->nextEnemyIndex = 0;
3474 return;
3475 }
3476 }
3477
3478 battleStatus->activeEnemyActorID = battleStatus->enemyIDs[i++];
3479 battleStatus->curTurnEnemy = enemy;
3480 battleStatus->nextEnemyIndex = i;
3481
3482 skipEnemy = FALSE;
3483
3484 if (enemy->debuff == STATUS_KEY_SLEEP) {
3485 skipEnemy = TRUE;
3486 }
3487 if (enemy->debuff == STATUS_KEY_FEAR) {
3488 skipEnemy = TRUE;
3489 }
3490 if (enemy->debuff == STATUS_KEY_DIZZY) {
3491 skipEnemy = TRUE;
3492 }
3493 if (enemy->debuff == STATUS_KEY_PARALYZE) {
3494 skipEnemy = TRUE;
3495 }
3496 if (enemy->debuff == STATUS_KEY_FROZEN) {
3497 skipEnemy = TRUE;
3498 }
3499 if (enemy->debuff == STATUS_KEY_STOP) {
3500 skipEnemy = TRUE;
3501 }
3502 if (enemy->stoneStatus == STATUS_KEY_STONE) {
3503 skipEnemy = TRUE;
3504 }
3505 if (enemy->flags & ACTOR_FLAG_SKIP_TURN) {
3506 skipEnemy = TRUE;
3507 }
3508
3509 if (skipEnemy) {
3510 // reset state to fetch next enemy
3512 return;
3513 }
3514
3515 battleStatus->stateFreezeCount = 0;
3516 gBattleStatus.flags1 &= ~BS_FLAGS1_MENU_OPEN;
3517 gBattleStatus.flags1 &= ~BS_FLAGS1_BATTLE_FLED;
3518 gBattleStatus.flags1 &= ~BS_FLAGS1_AUTO_SUCCEED_ACTION;
3519 gBattleStatus.flags1 &= ~BS_FLAGS1_PARTNER_ACTING;
3520
3521 player->flags &= ~ACTOR_FLAG_SHOW_STATUS_ICONS;
3523
3524 if (partner != NULL) {
3525 partner->flags &= ~ACTOR_FLAG_SHOW_STATUS_ICONS;
3527 }
3528
3529 gBattleStatus.flags2 &= ~BS_FLAGS2_PLAYER_TURN_USED;
3530 gBattleStatus.flags2 &= ~BS_FLAGS2_PARTNER_TURN_USED;
3532
3533 D_8029F244 = enemy->unk_134;
3534 if (enemy->handlePhaseSource != NULL) {
3535 Evt* onTurnChanceScript;
3536
3537 battleStatus->battlePhase = PHASE_ENEMY_BEGIN;
3538 onTurnChanceScript = start_script(enemy->handlePhaseSource, EVT_PRIORITY_A, 0);
3539 enemy->handlePhaseScript = onTurnChanceScript;
3540 enemy->handleBatttlePhaseScriptID = onTurnChanceScript->id;
3541 onTurnChanceScript->owner1.actorID = battleStatus->activeEnemyActorID;
3542 }
3544 break;
3546 if (battleStatus->stateFreezeCount == 0) {
3547 enemy = get_actor(battleStatus->activeEnemyActorID);
3548
3549 if (enemy == NULL || enemy->unk_134 != D_8029F244) {
3551 } else {
3552 if (enemy->handlePhaseSource == NULL || !does_script_exist(enemy->handleBatttlePhaseScriptID)) {
3553 if (battleStatus->unk_94 < 0) {
3554 battleStatus->unk_94 = 0;
3556 } else {
3558 }
3559 }
3560 }
3561 }
3562 break;
3563 }
3564}
BSS u8 D_8029F244
@ BTL_SUBSTATE_NEXT_ENEMY_DONE
Definition enums.h:3812
@ BTL_SUBSTATE_NEXT_ENEMY_UNUSED_1
Definition enums.h:3811
@ BTL_SUBSTATE_NEXT_ENEMY_INIT
Definition enums.h:3810
@ BATTLE_STATE_ENEMY_MOVE
Definition enums.h:3651
Actor * get_actor(s32 actorID)
Definition actor_api.c:155
struct Actor * curTurnEnemy

Referenced by btl_update().

◆ btl_state_draw_next_enemy()

void btl_state_draw_next_enemy ( void )

Definition at line 3566 of file btl_states_actions.c.

3566 {
3567}

Referenced by btl_draw_ui().

◆ btl_state_update_enemy_move()

void btl_state_update_enemy_move ( void )

Definition at line 3569 of file btl_states_actions.c.

3569 {
3570 BattleStatus* battleStatus = &gBattleStatus;
3572 Actor* partner = gBattleStatus.partnerActor;
3573 Actor* enemy;
3574 s32 i;
3575
3576 Evt* script;
3577 s32 messageIndex;
3578 s32 waitingForEnemyScript;
3579
3580 switch (gBattleSubState) {
3583 gBattleStatus.flags1 &= ~BS_FLAGS1_MENU_OPEN;
3584 gBattleStatus.flags1 &= ~BS_FLAGS1_YIELD_TURN;
3585 player->flags &= ~ACTOR_FLAG_SHOW_STATUS_ICONS;
3586 if (partner != NULL) {
3587 partner->flags &= ~ACTOR_FLAG_SHOW_STATUS_ICONS;
3588 }
3589 battleStatus->stateFreezeCount = 0;
3590 battleStatus->lastAttackDamage = 0;
3591 battleStatus->actionQuality = 0;
3592 battleStatus->actionResult = ACTION_RESULT_NONE;
3593 battleStatus->blockResult = BLOCK_RESULT_NONE;
3594 battleStatus->curDamageSource = DMG_SRC_DEFAULT;
3597 player->statusAfflicted = 0;
3598 if (partner != NULL) {
3599 partner->statusAfflicted = 0;
3600 }
3601
3603 for (i = 0; i < ARRAY_COUNT(battleStatus->enemyActors); i++) {
3604 enemy = battleStatus->enemyActors[i];
3605 if (enemy != NULL) {
3606 enemy->flags &= ~ACTOR_FLAG_HEALTH_BAR_HIDDEN;
3607 }
3608 }
3609
3610 for (i = 0; i < ARRAY_COUNT(battleStatus->enemyActors); i++) {
3611 enemy = battleStatus->enemyActors[i];
3612 if (enemy != NULL) {
3613 if (!(enemy->flags & ACTOR_FLAG_NO_DMG_APPLY)) {
3614 enemy->flags &= ~ACTOR_FLAG_SHOW_STATUS_ICONS;
3615 }
3616 }
3617 }
3618
3619 enemy = battleStatus->curTurnEnemy;
3620 if (!(enemy->flags & ACTOR_FLAG_NO_ATTACK)) {
3622 battleStatus->battlePhase = PHASE_EXECUTE_ACTION;
3623 script = start_script(enemy->takeTurnSource, EVT_PRIORITY_A, 0);
3624 enemy->takeTurnScript = script;
3625 enemy->takeTurnScriptID = script->id;
3626 script->owner1.actorID = battleStatus->activeEnemyActorID;
3627 }
3629 break;
3631 if (player->takeTurnScript != NULL && does_script_exist(player->takeTurnScriptID)) {
3632 break;
3633 }
3634 player->takeTurnScript = NULL;
3635
3636 if (player->handleEventScript != NULL && does_script_exist(player->handleEventScriptID)) {
3637 break;
3638 }
3639 player->handleEventScript = NULL;
3640
3641 if (partner != NULL) {
3642 if (partner->handleEventScript != NULL && does_script_exist(partner->handleEventScriptID)) {
3643 break;
3644 }
3645 partner->handleEventScript = NULL;
3646 }
3647
3648 waitingForEnemyScript = FALSE;
3649 for (i = 0; i < ARRAY_COUNT(battleStatus->enemyActors); i++) {
3650 enemy = battleStatus->enemyActors[i];
3651 if (enemy != NULL && enemy->handleEventScript != NULL) {
3653 waitingForEnemyScript = TRUE;
3654 } else {
3655 enemy->handleEventScript = NULL;
3656 }
3657 }
3658 }
3659
3660 if (waitingForEnemyScript) {
3661 break;
3662 }
3663
3665 return;
3666 }
3667
3668 for (i = 0; i < ARRAY_COUNT(battleStatus->enemyActors); i++) {
3669 enemy = battleStatus->enemyActors[i];
3670 if (enemy != NULL && enemy->takeTurnScript != NULL) {
3671 if (does_script_exist(enemy->takeTurnScriptID)) {
3672 waitingForEnemyScript = TRUE;
3673 } else {
3674 enemy->takeTurnScript = NULL;
3675 }
3676 }
3677 }
3678
3679 if (waitingForEnemyScript && !(gBattleStatus.flags1 & BS_FLAGS1_YIELD_TURN)) {
3680 break;
3681 }
3682
3683 gBattleStatus.flags1 &= ~BS_FLAGS1_EXECUTING_MOVE;
3684 gBattleStatus.flags2 &= ~BS_FLAGS2_IGNORE_DARKNESS;
3686 return;
3687 }
3688
3689 if (battleStatus->stateFreezeCount != 0) {
3690 break;
3691 }
3692
3695 } else {
3697 if (player->statusAfflicted != 0) {
3699 if (partner != NULL) {
3701 }
3703
3704 switch (player->statusAfflicted) {
3705 case STATUS_KEY_DIZZY:
3706 messageIndex = BTL_MSG_PLAYER_DAZED;
3707 break;
3708 case STATUS_KEY_SLEEP:
3709 messageIndex = BTL_MSG_PLAYER_ASLEEP;
3710 break;
3711 case STATUS_KEY_FROZEN:
3712 messageIndex = BTL_MSG_PLAYER_FROZEN;
3713 break;
3714 case STATUS_KEY_POISON:
3715 messageIndex = BTL_MSG_PLAYER_POISONED;
3716 break;
3717 case STATUS_KEY_SHRINK:
3718 messageIndex = BTL_MSG_PLAYER_SHRUNK;
3719 break;
3721 messageIndex = BTL_MSG_PLAYER_PARALYZED;
3722 break;
3723 default:
3724 messageIndex = 0;
3726 break;
3727 }
3728 btl_show_battle_message(messageIndex, 60);
3729 player->statusAfflicted = 0;
3731 break;
3732 } else {
3734 break;
3735 }
3736 }
3737 break;
3739 if (!btl_is_popup_displayed()) {
3741 btl_cam_move(15);
3744 }
3745 break;
3747 if (BattleSubStateDelay != 0) {
3749 } else {
3751 break;
3752 }
3753 break;
3754 }
3755
3756 switch (gBattleSubState) {
3758 if (partner != NULL) {
3759 if (partner->statusAfflicted == STATUS_KEY_DAZE) {
3764 partner->statusAfflicted = 0;
3766 } else {
3768 }
3769 } else {
3771 }
3772 break;
3774 if (!btl_is_popup_displayed()) {
3776 btl_cam_move(15);
3779 }
3780 break;
3782 if (BattleSubStateDelay != 0) {
3784 } else {
3786 }
3787 break;
3788 }
3789
3792 }
3793}
@ BS_FLAGS2_IGNORE_DARKNESS
Definition enums.h:3614
@ BTL_SUBSTATE_ENEMY_MOVE_AWAIT_PLAYER_POPUP_DONE
Definition enums.h:3818
@ BTL_SUBSTATE_ENEMY_MOVE_EXECUTE
Definition enums.h:3815
@ BTL_SUBSTATE_ENEMY_MOVE_POST_PARTNER_POPUP_DELAY
Definition enums.h:3822
@ BTL_SUBSTATE_ENEMY_MOVE_UNUSED_1
Definition enums.h:3816
@ BTL_SUBSTATE_ENEMY_MOVE_AWAIT_PARTNER_POPUP_DONE
Definition enums.h:3821
@ BTL_SUBSTATE_ENEMY_MOVE_POST_PLAYER_POPUP_DELAY
Definition enums.h:3819
@ BTL_SUBSTATE_ENEMY_MOVE_AWAIT_SCRIPTS
Definition enums.h:3817
@ BTL_SUBSTATE_ENEMY_MOVE_DONE
Definition enums.h:3823
@ BTL_SUBSTATE_ENEMY_MOVE_CHECK_PARTNER
Definition enums.h:3820

Referenced by btl_update().

◆ btl_state_draw_enemy_move()

void btl_state_draw_enemy_move ( void )

Definition at line 3795 of file btl_states_actions.c.

3795 {
3796}

Referenced by btl_draw_ui().

◆ btl_state_update_first_strike()

void btl_state_update_first_strike ( void )

Definition at line 3798 of file btl_states_actions.c.

3798 {
3799 PlayerData* playerData = &gPlayerData;
3800 BattleStatus* battleStatus = &gBattleStatus;
3801 EncounterStatus* encounterStatus = &gCurrentEncounter;
3803 Actor* partner = gBattleStatus.partnerActor;
3804 Evt* script;
3805 Actor* enemy;
3806 s32 enemyNotDone;
3807 s32 i;
3808
3809 switch (gBattleSubState) {
3811 D_8029F254 = FALSE;
3813 if (playerData->playerFirstStrikes < 9999) {
3814 playerData->playerFirstStrikes++;
3815 }
3816
3817 // clear rush flags to initialize
3818 battleStatus->rushFlags = RUSH_FLAG_NONE;
3819 gBattleStatus.flags2 &= ~BS_FLAGS2_HAS_RUSH;
3820
3821 // set rush flags based on danger/peril status
3825 battleStatus->rushFlags |= RUSH_FLAG_MEGA;
3826 }
3828 if (!(battleStatus->rushFlags & RUSH_FLAG_MEGA)) {
3830 battleStatus->rushFlags |= RUSH_FLAG_POWER;
3831 }
3832 }
3833 }
3834
3835 // setup dummy 'menu selection' for player move
3836 switch (encounterStatus->hitType) {
3838 battleStatus->moveCategory = BTL_MENU_TYPE_JUMP;
3839 battleStatus->selectedMoveID = MOVE_FIRST_STRIKE_JUMP;
3840 battleStatus->moveArgument = encounterStatus->hitTier;
3841 battleStatus->curTargetListFlags = gMoveTable[MOVE_FIRST_STRIKE_JUMP].flags;
3842 break;
3844 battleStatus->moveCategory = BTL_MENU_TYPE_SMASH;
3845 battleStatus->selectedMoveID = MOVE_FIRST_STRIKE_HAMMER;
3846 battleStatus->moveArgument = encounterStatus->hitTier;
3847 battleStatus->curTargetListFlags = gMoveTable[MOVE_FIRST_STRIKE_HAMMER].flags;
3848 break;
3851 return;
3852 }
3853 // let the enemy know a first strike is coming
3854 enemy = get_actor(ACTOR_ENEMY0);
3855 if (enemy->handleEventSource != NULL) {
3858 enemy->handleEventScript = script;
3859 enemy->handleEventScriptID = script->id;
3860 script->owner1.actorID = enemy->actorID;
3861 }
3863 break;
3865 enemy = get_actor(ACTOR_ENEMY0);
3866 if (enemy->handleEventSource != NULL) {
3868 break;
3869 } else {
3870 enemy->handleEventScript = NULL;
3871 }
3872 }
3873
3874 func_80263230(player, enemy);
3875 battleStatus->stateFreezeCount = 0;
3876 battleStatus->lastAttackDamage = 0;
3877 battleStatus->curDamageSource = DMG_SRC_DEFAULT;
3878 gBattleStatus.flags1 &= ~BS_FLAGS1_MENU_OPEN;
3880 gBattleStatus.flags1 &= ~BS_FLAGS1_PARTNER_ACTING;
3885 // begin the partner turn script
3886 battleStatus->battlePhase = PHASE_FIRST_STRIKE;
3888 player->takeTurnScript = script;
3889 player->takeTurnScriptID = script->id;
3890 script->owner1.actorID = ACTOR_PLAYER;
3893 break;
3895 if (BattleSubStateDelay != 0) {
3897 } else {
3898 D_8029F254 = TRUE;
3899 }
3900
3901 // wait for player move script
3903 if (player->takeTurnScript != NULL && does_script_exist(player->takeTurnScriptID)) {
3904 break;
3905 }
3906 player->takeTurnScript = NULL;
3907 }
3908
3909 gBattleStatus.flags1 &= ~BS_FLAGS1_EXECUTING_MOVE;
3910
3911 // wait for player handle event script
3912 if (player->handleEventScript != NULL && does_script_exist(player->handleEventScriptID)) {
3913 break;
3914 }
3915 player->handleEventScript = NULL;
3916
3917 // wait for partner handle event script
3918 if (partner != NULL) {
3919 if (partner->handleEventScript != NULL && does_script_exist(partner->handleEventScriptID)) {
3920 break;
3921 }
3922 partner->handleEventScript = NULL;
3923 }
3924
3925 // wait for all enemy turn scripts
3926 enemyNotDone = FALSE;
3927 for (i = 0; i < ARRAY_COUNT(battleStatus->enemyActors); i++) {
3928 enemy = battleStatus->enemyActors[i];
3929 if (enemy != NULL && enemy->takeTurnScript != NULL) {
3930 if (does_script_exist(enemy->takeTurnScriptID)) {
3931 enemyNotDone = TRUE;
3932 } else {
3933 enemy->takeTurnScript = NULL;
3934 }
3935 }
3936 }
3937 if (enemyNotDone) {
3938 break;
3939 }
3940
3941 // wait for all enemy handle event scripts
3942 enemyNotDone = FALSE;
3943 for (i = 0; i < ARRAY_COUNT(battleStatus->enemyActors); i++) {
3944 enemy = battleStatus->enemyActors[i];
3945 if (enemy != NULL && enemy->handleEventScript != NULL) {
3947 enemyNotDone = TRUE;
3948 } else {
3949 enemy->handleEventScript = NULL;
3950 }
3951 }
3952 }
3953 if (enemyNotDone) {
3954 break;
3955 }
3956
3957 for (i = 0; i < ARRAY_COUNT(battleStatus->enemyActors); i++) {
3958 enemy = battleStatus->enemyActors[i];
3959 if (enemy != NULL) {
3960 enemy->flags &= ~ACTOR_FLAG_HEALTH_BAR_HIDDEN;
3961 }
3962 }
3963
3964 if (battleStatus->stateFreezeCount == 0) {
3967 Actor* target;
3968
3970 return;
3971 }
3972
3973 target = get_actor(player->targetActorID);
3974 if (target != NULL) {
3975 if (target->handleEventSource != NULL) {
3978 target->handleEventScript = script;
3979 target->handleEventScriptID = script->id;
3980 script->owner1.actorID = target->actorID;
3981 }
3982 }
3984 } else {
3986 }
3987 }
3988 break;
3990 enemyNotDone = FALSE;
3991 for (i = 0; i < ARRAY_COUNT(battleStatus->enemyActors); i++) {
3992 enemy = battleStatus->enemyActors[i];
3993 if (enemy != NULL && enemy->handleEventScript != NULL) {
3995 enemyNotDone = TRUE;
3996 } else {
3997 enemy->handleEventScript = NULL;
3998 }
3999 }
4000 }
4001 if (enemyNotDone) {
4002 break;
4003 }
4004 if (player->takeTurnScript == NULL || !does_script_exist(player->takeTurnScriptID)) {
4005 player->takeTurnScript = NULL;
4007 }
4008 break;
4009 }
4010}
void btl_merlee_on_first_strike(void)
s16 targetActorID
@ PHASE_FIRST_STRIKE
Definition enums.h:2059
@ BS_FLAGS2_IS_FIRST_STRIKE
Definition enums.h:3617
@ ENCOUNTER_TRIGGER_JUMP
Definition enums.h:269
@ ENCOUNTER_TRIGGER_HAMMER
Definition enums.h:271
@ ENCOUNTER_TRIGGER_PARTNER
Definition enums.h:273
@ BTL_CAM_MIDPOINT_CLOSE
Definition enums.h:4831
@ BTL_SUBSTATE_FIRST_STRIKE_AWAIT_ENEMY_READY
Definition enums.h:3681
@ BTL_SUBSTATE_FIRST_STRIKE_AWAIT_SCRIPTS
Definition enums.h:3682
@ BTL_SUBSTATE_FIRST_STRIKE_AWAIT_ENEMY_DONE
Definition enums.h:3683
@ BTL_SUBSTATE_FIRST_STRIKE_INIT
Definition enums.h:3680
@ BATTLE_STATE_PARTNER_FIRST_STRIKE
Definition enums.h:3633
@ EVENT_BEGIN_FIRST_STRIKE
Definition enums.h:2173
@ EVENT_END_FIRST_STRIKE
Definition enums.h:2171
s32 func_80263230(Actor *, Actor *)
Definition 190B20.c:558

Referenced by btl_update().

◆ btl_state_draw_first_stike()

void btl_state_draw_first_stike ( void )

Definition at line 4012 of file btl_states_actions.c.

4012 {
4013 if (D_802809F6 == -1 && D_8029F254) {
4014 if (BattleScreenFadeAmt == 0) {
4016 } else {
4018 BattleScreenFadeAmt -= 20;
4019 } else {
4020 BattleScreenFadeAmt -= 50;
4021 }
4022
4023 if (BattleScreenFadeAmt < 0) {
4025 }
4027 }
4028 }
4029}
s16 D_802809F6
Definition 16C8E0.c:12

Referenced by btl_draw_ui().

◆ btl_state_update_partner_striking_first()

void btl_state_update_partner_striking_first ( void )

Definition at line 4031 of file btl_states_actions.c.

4031 {
4032 PlayerData* playerData = &gPlayerData;
4033 BattleStatus* battleStatus = &gBattleStatus;
4034 Actor* player = battleStatus->playerActor;
4035 Actor* partner = battleStatus->partnerActor;
4036 Actor* actor;
4037 s32 enemyNotDone;
4038 SelectableTarget* target;
4039 Evt* script;
4040 s32 level;
4041 s32 i;
4042
4043 switch (gBattleSubState) {
4045 D_8029F254 = FALSE;
4046 // setup dummy 'menu selection' for partner move
4047 level = partner->actorBlueprint->level;
4048 switch (playerData->curPartner) {
4049 case PARTNER_KOOPER:
4051 battleStatus->moveArgument = 0;
4052 battleStatus->selectedMoveID = level + MOVE_SHELL_TOSS1;
4053 battleStatus->curTargetListFlags = gMoveTable[battleStatus->selectedMoveID].flags;
4054 break;
4055 case PARTNER_BOMBETTE:
4057 battleStatus->moveArgument = 0;
4058 battleStatus->selectedMoveID = level + MOVE_BODY_SLAM1;
4059 battleStatus->curTargetListFlags = gMoveTable[battleStatus->selectedMoveID].flags;
4060 break;
4061 }
4062 // let the enemy know a first strike is coming
4063 actor = get_actor(ACTOR_ENEMY0);
4064 if (actor->handleEventSource != NULL) {
4067 actor->handleEventScript = script;
4068 actor->handleEventScriptID = script->id;
4069 script->owner1.actorID = actor->actorID;
4070 }
4072 break;
4075 target = &partner->targetData[partner->targetIndexList[0]];
4076 partner->targetActorID = target->actorID;
4077 partner->targetPartID = target->partID;
4078 battleStatus->stateFreezeCount = 0;
4079 battleStatus->lastAttackDamage = 0;
4080 battleStatus->curDamageSource = DMG_SRC_DEFAULT;
4081 gBattleStatus.flags1 &= ~BS_FLAGS1_MENU_OPEN;
4088 // begin the partner turn script
4089 battleStatus->battlePhase = PHASE_FIRST_STRIKE;
4090 script = start_script(partner->takeTurnSource, EVT_PRIORITY_A, 0);
4091 partner->takeTurnScript = script;
4092 partner->takeTurnScriptID = script->id;
4093 script->owner1.actorID = ACTOR_PARTNER;
4096 break;
4098 if (BattleSubStateDelay != 0) {
4100 } else {
4101 D_8029F254 = TRUE;
4102 }
4103 // wait for partner move script
4104 if (partner->takeTurnScript != NULL && does_script_exist(partner->takeTurnScriptID)) {
4105 break;
4106 }
4107 partner->takeTurnScript = NULL;
4108 // wait for partner handle event script
4109 if (partner->handleEventScript != NULL && does_script_exist(partner->handleEventScriptID)) {
4110 break;
4111 }
4112 partner->handleEventScript = NULL;
4113 // wait for player handle event script
4114 if (player->handleEventScript != NULL && does_script_exist(player->handleEventScriptID)) {
4115 break;
4116 }
4117 player->handleEventScript = NULL;
4118
4119 // wait for all enemy turn scripts
4120 enemyNotDone = FALSE;
4121 for (i = 0; i < ARRAY_COUNT(battleStatus->enemyActors); i++) {
4122 actor = battleStatus->enemyActors[i];
4123 if (actor != NULL && actor->takeTurnScript != NULL) {
4124 if (does_script_exist(actor->takeTurnScriptID)) {
4125 enemyNotDone = TRUE;
4126 } else {
4127 actor->takeTurnScript = NULL;
4128 }
4129 }
4130 }
4131 if (enemyNotDone) {
4132 break;
4133 }
4134
4135 // wait for all enemy handle event scripts
4136 enemyNotDone = FALSE;
4137 for (i = 0; i < ARRAY_COUNT(battleStatus->enemyActors); i++) {
4138 actor = battleStatus->enemyActors[i];
4139 if (actor != NULL && actor->handleEventScript != NULL) {
4141 enemyNotDone = TRUE;
4142 } else {
4143 actor->handleEventScript = NULL;
4144 }
4145 }
4146 }
4147 if (enemyNotDone) {
4148 break;
4149 }
4150
4151 for (i = 0; i < ARRAY_COUNT(battleStatus->enemyActors); i++) {
4152 actor = battleStatus->enemyActors[i];
4153 if (actor != NULL) {
4154 actor->flags &= ~ACTOR_FLAG_HEALTH_BAR_HIDDEN;
4155 }
4156 }
4157
4158 if (battleStatus->stateFreezeCount == 0) {
4161 return;
4162 }
4163
4164 actor = get_actor(partner->targetActorID);
4165 if (actor != NULL) {
4166 if (actor->handleEventSource != NULL) {
4169 actor->handleEventScript = script;
4170 actor->handleEventScriptID = script->id;
4171 script->owner1.actorID = actor->actorID;
4172 }
4173 }
4175 }
4176 break;
4178 enemyNotDone = FALSE;
4179 for (i = 0; i < ARRAY_COUNT(battleStatus->enemyActors); i++) {
4180 actor = battleStatus->enemyActors[i];
4181 if (actor != NULL && actor->handleEventScript != NULL) {
4183 enemyNotDone = TRUE;
4184 } else {
4185 actor->handleEventScript = NULL;
4186 }
4187 }
4188 }
4189 if (!enemyNotDone) {
4191 }
4192 break;
4193 }
4194}
struct SelectableTarget targetData[24]
s8 targetIndexList[24]
@ BTL_SUBSTATE_PARTNER_FIRST_STRIKE_AWAIT_ENEMY_DONE
Definition enums.h:3689
@ BTL_SUBSTATE_PARTNER_FIRST_STRIKE_AWAIT_ENEMY_READY
Definition enums.h:3687
@ BTL_SUBSTATE_PARTNER_FIRST_STRIKE_AWAIT_SCRIPTS
Definition enums.h:3688
@ BTL_SUBSTATE_PARTNER_FIRST_STRIKE_INIT
Definition enums.h:3686
@ PARTNER_KOOPER
Definition enums.h:2887
void create_current_pos_target_list(Actor *actor)
Definition 190B20.c:472

Referenced by btl_update().

◆ btl_state_draw_partner_striking_first()

void btl_state_draw_partner_striking_first ( void )

Definition at line 4196 of file btl_states_actions.c.

4196 {
4197 if (D_8029F254) {
4198 if (BattleScreenFadeAmt == 0) {
4200 } else {
4201 BattleScreenFadeAmt -= 20;
4202 if (BattleScreenFadeAmt < 0) {
4204 }
4205
4207 }
4208 }
4209}

Referenced by btl_draw_ui().

◆ btl_state_update_enemy_striking_first()

void btl_state_update_enemy_striking_first ( void )

Definition at line 4211 of file btl_states_actions.c.

4211 {
4212 PlayerData* playerData = &gPlayerData;
4213 BattleStatus* battleStatus = &gBattleStatus;
4214 Actor* player = battleStatus->playerActor;
4215 Actor* partner = battleStatus->partnerActor;
4216 Evt* script;
4217 Actor* actor;
4218 u16* enemyIDs;
4219 s16 activeEnemyActorID;
4220 s32 nextEnemyIdx;
4221 s32 count;
4222 s32 flags;
4223 s32 waitingForScript;
4224 s32 i;
4225 s32 j;
4226
4227 switch (gBattleSubState) {
4229 battleStatus->stateFreezeCount = 0;
4230 battleStatus->lastAttackDamage = 0;
4231 battleStatus->curDamageSource = DMG_SRC_DEFAULT;
4232 playerData->enemyFirstStrikes++;
4233 battleStatus->flags1 &= ~BS_FLAGS1_MENU_OPEN;
4234 D_8029F254 = FALSE;
4235 player->flags &= ~ACTOR_FLAG_SHOW_STATUS_ICONS;
4236 if (partner != NULL) {
4237 partner->flags &= ~ACTOR_FLAG_SHOW_STATUS_ICONS;
4238 }
4239 battleStatus->flags2 |= BS_FLAGS2_IS_FIRST_STRIKE;
4240 battleStatus->flags2 |= BS_FLAGS2_IGNORE_DARKNESS;
4241 count = 0;
4242
4243 for (i = 0; i < ARRAY_COUNT(battleStatus->enemyActors); i++) {
4244 actor = battleStatus->enemyActors[i];
4245 if (actor != NULL) {
4246 battleStatus->enemyIDs[count] = i | ACTOR_ENEMY0;
4247 count++;
4248 }
4249 }
4250
4251 battleStatus->numEnemyActors = count;
4252
4253 enemyIDs = battleStatus->enemyIDs;
4254 for (i = 0; i < count - 1; i++) {
4255 for (j = i + 1; j < count; j++) {
4256 s32 iVal = enemyIDs[i];
4257 s32 jVal = enemyIDs[j];
4258
4259 if (battleStatus->enemyActors[iVal & 0xFF]->turnPriority <
4260 battleStatus->enemyActors[jVal & 0xFF]->turnPriority)
4261 {
4262 enemyIDs[i] = jVal;
4263 enemyIDs[j] = iVal;
4264 }
4265 }
4266 }
4267
4268 battleStatus->nextEnemyIndex = 0;
4269 nextEnemyIdx = 0;
4271
4272 while (TRUE) {
4273 actor = battleStatus->enemyActors[battleStatus->enemyIDs[nextEnemyIdx] & 0xFF];
4274 if (actor == NULL || (actor->flags & flags)) {
4275 nextEnemyIdx++;
4276 if (nextEnemyIdx >= battleStatus->numEnemyActors) {
4277 nextEnemyIdx = 0;
4278 }
4279 } else {
4280 break;
4281 }
4282 }
4283
4284 activeEnemyActorID = battleStatus->enemyIDs[nextEnemyIdx];
4285 nextEnemyIdx++;
4286 battleStatus->curTurnEnemy = actor;
4287 battleStatus->activeEnemyActorID = activeEnemyActorID;
4288 if (nextEnemyIdx >= battleStatus->numEnemyActors) {
4289 nextEnemyIdx = 0;
4290 }
4291 battleStatus->nextEnemyIndex = nextEnemyIdx;
4293 actor = battleStatus->curTurnEnemy;
4295 battleStatus->battlePhase = PHASE_FIRST_STRIKE;
4296 script = start_script(actor->takeTurnSource, EVT_PRIORITY_A, 0);
4297 actor->takeTurnScript = script;
4299 actor->takeTurnScriptID = script->id;
4301 script->owner1.actorID = battleStatus->activeEnemyActorID;
4302 break;
4304 if (BattleSubStateDelay != 0) {
4306 } else {
4307 D_8029F254 = TRUE;
4308 }
4309
4310 // wait for current enemy TakeTurn script to finish
4311 actor = battleStatus->curTurnEnemy;
4312 if (actor->takeTurnScript != NULL && does_script_exist(actor->takeTurnScriptID)) {
4313 break;
4314 }
4315 actor->takeTurnScript = NULL;
4316
4317 // wait for player HandleEvent script to finish (may have been triggered by enemy Take Turn)
4318 if (player->handleEventScript != NULL && does_script_exist(player->handleEventScriptID)) {
4319 break;
4320 }
4321 player->handleEventScript = NULL;
4322
4323 // wait for partner HandleEvent script to finish (may have been triggered by enemy Take Turn)
4324 if (partner != NULL) {
4325 if (partner->handleEventScript != NULL && does_script_exist(partner->handleEventScriptID)) {
4326 break;
4327 }
4328 partner->handleEventScript = NULL;
4329 }
4330
4331 // wait for all enemy TakeTurn scripts to finish
4332 waitingForScript = FALSE;
4333
4334 for (i = 0; i < ARRAY_COUNT(battleStatus->enemyActors); i++) {
4335 actor = battleStatus->enemyActors[i];
4336 if (actor != NULL && actor->takeTurnScript != NULL) {
4337 if (does_script_exist(actor->takeTurnScriptID)) {
4338 waitingForScript = TRUE;
4339 } else {
4340 actor->takeTurnScript = NULL;
4341 }
4342 }
4343 }
4344
4345 if (waitingForScript) {
4346 break;
4347 }
4348
4349 // wait for all enemy HandleEvent scripts to finish
4350 waitingForScript = FALSE;
4351
4352 for (i = 0; i < ARRAY_COUNT(battleStatus->enemyActors); i++) {
4353 actor = battleStatus->enemyActors[i];
4354 if (actor != NULL && actor->handleEventScript != NULL) {
4356 waitingForScript = TRUE;
4357 } else {
4358 actor->handleEventScript = NULL;
4359 }
4360 }
4361 }
4362
4363 if (waitingForScript) {
4364 break;
4365 }
4366
4367 // reset state
4368 gBattleStatus.flags2 &= ~BS_FLAGS2_IGNORE_DARKNESS;
4369 for (i = 0; i < ARRAY_COUNT(battleStatus->enemyActors); i++) {
4370 actor = battleStatus->enemyActors[i];
4371 if (actor != NULL) {
4372 actor->flags &= ~ACTOR_FLAG_HEALTH_BAR_HIDDEN;
4373 }
4374 }
4375
4376 if (battleStatus->stateFreezeCount == 0) {
4378 return;
4379 }
4381 }
4382 break;
4383 }
4384}
@ BTL_SUBSTATE_ENEMY_FIRST_STRIKE_INIT
Definition enums.h:3692
@ BTL_SUBSTATE_ENEMY_FIRST_STRIKE_AWAIT_SCRIPTS
Definition enums.h:3693

Referenced by btl_update().

◆ btl_state_draw_enemy_striking_first()

void btl_state_draw_enemy_striking_first ( void )

Definition at line 4386 of file btl_states_actions.c.

4386 {
4387 if (D_8029F254) {
4388 if (BattleScreenFadeAmt == 0) {
4390 } else {
4391 BattleScreenFadeAmt -= 20;
4392 if (BattleScreenFadeAmt < 0) {
4394 }
4395
4397 }
4398 }
4399}

Referenced by btl_draw_ui().

◆ btl_state_update_end_demo_battle()

void btl_state_update_end_demo_battle ( void )

Definition at line 4401 of file btl_states_actions.c.

4401 {
4402 BattleStatus* battleStatus = &gBattleStatus;
4403 Battle* battle = gCurrentBattlePtr;
4404 Stage* stage;
4405 s32 i;
4406
4407 switch (gBattleSubState) {
4410 if (D_802809F6 == -1) {
4411 if (DemoBattleBeginDelay != 0) {
4413 break;
4414 }
4415 }
4417 break;
4419 switch (D_802809F6) {
4420 case 255:
4422 return;
4423 case -1:
4424 if (BattleScreenFadeAmt == 255) {
4426 return;
4427 }
4428 BattleScreenFadeAmt += 50;
4429 if (BattleScreenFadeAmt > 255) {
4430 BattleScreenFadeAmt = 255;
4431 }
4432 return;
4433 }
4434 break;
4436 BattleScreenFadeAmt = 255;
4437 gBattleStatus.flags1 &= ~BS_FLAGS1_ACTORS_VISIBLE;
4438 if (gCurrentStagePtr == NULL) {
4439 stage = battle->stage;
4440 } else {
4441 stage = gCurrentStagePtr->stage;
4442 }
4443
4444 if (stage->postBattle == NULL) {
4446 } else {
4447 battleStatus->controlScript = start_script(stage->postBattle, EVT_PRIORITY_A, 0);
4448 battleStatus->controlScriptID = battleStatus->controlScript->id;
4450 }
4451 break;
4453 if (does_script_exist(battleStatus->controlScriptID)) {
4454 break;
4455 }
4457 //fallthrough
4460
4461 for (i = 0; i < ARRAY_COUNT(battleStatus->enemyActors); i++) {
4462 Actor* enemy = battleStatus->enemyActors[i];
4463
4464 if (enemy != NULL) {
4465 btl_delete_actor(enemy);
4466 }
4467 }
4468
4469 if (battleStatus->partnerActor != NULL) {
4470 btl_delete_actor(battleStatus->partnerActor);
4471 }
4472
4473 btl_delete_player_actor(battleStatus->playerActor);
4476
4479 }
4480
4481 if (D_802809F6 != -1) {
4483 }
4484
4488 break;
4489 }
4490}
s16 DemoBattleBeginDelay
Definition 16C8E0.c:13
@ BTL_SUBSTATE_END_DEMO_BATTLE_EXEC_STAGE_SCRIPT
Definition enums.h:3914
@ BTL_SUBSTATE_END_DEMO_BATTLE_CLEANUP
Definition enums.h:3916
@ BTL_SUBSTATE_END_DEMO_BATTLE_FADE_OUT
Definition enums.h:3913
@ BTL_SUBSTATE_END_DEMO_BATTLE_AWAIT_STAGE_SCRIPT
Definition enums.h:3915
@ BTL_SUBSTATE_END_DEMO_BATTLE_INIT
Definition enums.h:3912
@ WINDOW_GROUP_ALL
Definition enums.h:5322
#define LAST_DEMO_SCENE_IDX
Definition macros.h:112

Referenced by btl_update().

◆ btl_state_draw_end_demo_battle()

void btl_state_draw_end_demo_battle ( void )

Definition at line 4492 of file btl_states_actions.c.

Referenced by btl_draw_ui().

◆ btl_state_update_player_menu()

void btl_state_update_player_menu ( void )

Definition at line 2237 of file btl_states_menus.c.

2237 {
2238 BattleStatus* battleStatus = &gBattleStatus;
2239 PlayerData* playerData = &gPlayerData;
2240 Actor* playerActor = battleStatus->playerActor;
2241 Actor* partnerActor = battleStatus->partnerActor;
2242 PopupMenu* popup = &D_802ACCD0;
2243 MoveData* moveData;
2244 s32 entryIdx, initialPos;
2245 s32 i;
2246 s32 submenuResult;
2247 s32 jumpTargetCount, hammerTargetCount, jumpChance;
2248 ItemData* itemData;
2249 s32 starBeamLevel;
2250 s32 currentSubmenu;
2251 s32 currentSubmenu2;
2252 IconHudScriptPair* hudScriptPair;
2254
2255 switch (gBattleSubState) {
2257 battleStatus->moveCategory = BTL_MENU_TYPE_INVALID;
2258 battleStatus->selectedMoveID = 0;
2259 battleStatus->curAttackElement = 0;
2260 if (!can_switch_to_player()) {
2262 return;
2263 }
2265 btl_cam_move(10);
2266 if (!(battleStatus->flags1 & BS_FLAGS1_PLAYER_IN_BACK)) {
2268 } else {
2270 partnerActor->state.curPos.x = partnerActor->homePos.x;
2271 partnerActor->state.curPos.z = partnerActor->homePos.z;
2272 partnerActor->state.goalPos.x = playerActor->homePos.x;
2273 partnerActor->state.goalPos.z = playerActor->homePos.z;
2274 partnerActor->state.moveTime = 4;
2275 partnerActor->state.angle = 0.0f;
2276 }
2277 break;
2279 if (partnerActor->state.moveTime != 0) {
2280 partnerActor->curPos.x += (partnerActor->state.goalPos.x - partnerActor->curPos.x) / partnerActor->state.moveTime;
2281 partnerActor->curPos.z += (partnerActor->state.goalPos.z - partnerActor->curPos.z) / partnerActor->state.moveTime;
2282 playerActor->curPos.x += (partnerActor->state.curPos.x - playerActor->curPos.x) / partnerActor->state.moveTime;
2283 playerActor->curPos.z += (partnerActor->state.curPos.z - playerActor->curPos.z) / partnerActor->state.moveTime;
2284 }
2285 partnerActor->curPos.z -= sin_rad(DEG_TO_RAD(partnerActor->state.angle)) * 16.0f;
2286 partnerActor->yaw = clamp_angle(-partnerActor->state.angle);
2287 playerActor->curPos.z += sin_rad(DEG_TO_RAD(partnerActor->state.angle)) * 16.0f;
2288 playerActor->yaw = clamp_angle(-partnerActor->state.angle);
2289 partnerActor->state.angle += 90.0f;
2290 if (partnerActor->state.moveTime != 0) {
2291 partnerActor->state.moveTime--;
2292 } else {
2293 partnerActor->curPos.x = partnerActor->state.goalPos.x;
2294 partnerActor->curPos.z = partnerActor->state.goalPos.z;
2295 playerActor->curPos.x = partnerActor->state.curPos.x;
2296 playerActor->curPos.z = partnerActor->state.curPos.z;
2297 partnerActor->homePos.x = partnerActor->curPos.x;
2298 partnerActor->homePos.z = partnerActor->curPos.z;
2299 playerActor->homePos.x = playerActor->curPos.x;
2300 playerActor->homePos.z = playerActor->curPos.z;
2302 battleStatus->flags1 &= ~BS_FLAGS1_PLAYER_IN_BACK;
2303 }
2304 break;
2305 }
2306
2307 switch (gBattleSubState) {
2310 playerActor->flags &= ~ACTOR_FLAG_USING_IDLE_ANIM;
2311 playerActor->flags |= ACTOR_FLAG_SHOW_STATUS_ICONS;
2312 if (partnerActor != NULL) {
2313 partnerActor->flags |= ACTOR_FLAG_USING_IDLE_ANIM;
2314 partnerActor->flags |= ACTOR_FLAG_SHOW_STATUS_ICONS;
2315 }
2322 break;
2323 }
2324
2325 entryIdx = 0;
2326 initialPos = 2;
2327 if (battleStatus->lastPlayerMenuSelection[BTL_MENU_IDX_MAIN] < 0) {
2328 battleStatus->lastPlayerMenuSelection[BTL_MENU_IDX_MAIN] = 0;
2329 }
2330
2331 // strategies menu category
2333 BattleMenu_OptionEnabled[entryIdx] = TRUE;
2337 BattleMenu_TitleMessages[entryIdx] = MSG_Menus_EndTraining_Centered;
2338 }
2339 battle_menu_isMessageDisabled[entryIdx] = 0;
2340 if (!(battleStatus->enabledMenusFlags & BTL_MENU_ENABLED_STRATEGIES)) {
2342 BattleMenu_OptionEnabled[entryIdx] = FALSE;
2344 }
2346 initialPos = entryIdx;
2347 }
2348 entryIdx++;
2349
2350 // items menu category
2351 if (battleStatus->menuStatus[0] >= 0) {
2354 BattleMenu_OptionEnabled[entryIdx] = TRUE;
2356
2357 if(battleStatus->menuStatus[0] == 0) {
2359 BattleMenu_OptionEnabled[entryIdx] = FALSE;
2361 }
2362
2363 if (!(battleStatus->enabledMenusFlags & BTL_MENU_ENABLED_ITEMS)) {
2365 BattleMenu_OptionEnabled[entryIdx] = FALSE;
2367 }
2368
2369 if (battleStatus->itemLossTurns >= 0) {
2371 BattleMenu_OptionEnabled[entryIdx] = FALSE;
2373 }
2374
2376 initialPos = entryIdx;
2377 }
2378
2379 entryIdx++;
2380 }
2381
2382 // jump menu category
2385 BattleMenu_OptionEnabled[entryIdx] = TRUE;
2387
2388 if (battleStatus->menuStatus[1] <= 0) {
2390 BattleMenu_OptionEnabled[entryIdx] = FALSE;
2392 }
2393 if (!(battleStatus->enabledMenusFlags & BTL_MENU_ENABLED_JUMP)) {
2395 BattleMenu_OptionEnabled[entryIdx] = FALSE;
2397 }
2398 if (battleStatus->jumpLossTurns >= 0) {
2400 BattleMenu_OptionEnabled[entryIdx] = FALSE;
2402 }
2404 initialPos = entryIdx;
2405 }
2406 entryIdx++;
2407
2408 // hammer menu category
2409 if (playerData->hammerLevel >= 0) {
2412 BattleMenu_OptionEnabled[entryIdx] = TRUE;
2414 if (battleStatus->menuStatus[2] <= 0) {
2416 BattleMenu_OptionEnabled[entryIdx] = FALSE;
2418 }
2419 if (!(battleStatus->enabledMenusFlags & BTL_MENU_ENABLED_SMASH)) {
2421 BattleMenu_OptionEnabled[entryIdx] = FALSE;
2423 }
2424 if (battleStatus->hammerLossTurns >= 0) {
2426 BattleMenu_OptionEnabled[entryIdx] = FALSE;
2428 }
2430 initialPos = entryIdx;
2431 }
2432 entryIdx++;
2433 }
2434
2435 // star powers menu category
2436 if (playerData->maxStarPower != 0) {
2439 BattleMenu_OptionEnabled[entryIdx] = TRUE;
2441 battle_menu_isMessageDisabled[entryIdx] = 0;
2442 if (!(battleStatus->enabledMenusFlags & BTL_MENU_ENABLED_STAR_POWERS)) {
2444 BattleMenu_OptionEnabled[entryIdx] = FALSE;
2446 }
2448 initialPos = entryIdx;
2449 }
2450 entryIdx++;
2451 }
2452
2453 BattleMenu_NumOptions = entryIdx;
2454 D_802AD0A8 = 0;
2455 D_802AD0B0 = initialPos;
2456 D_802AD100 = 2 - initialPos;
2457 if (can_switch_to_partner()) {
2459 } else {
2461 }
2463 D_802ACC60 = 8;
2466 break;
2468 if (battleStatus->hustleTurns != 0) {
2469 set_actor_anim(ACTOR_PLAYER, 0, ANIM_Mario1_ThinkingRun);
2470 } else {
2472 }
2473 submenuResult = btl_main_menu_update();
2474 if (BattleMenu_SwapDelay != 0) {
2477 if (can_switch_to_partner() && battleStatus->hustleTurns != 1) {
2482 } else if (partnerActor != NULL && !(partnerActor->flags & BS_FLAGS1_YIELD_TURN) && battleStatus->hustleTurns != 1) {
2485 }
2486 break;
2487 }
2488
2489 if (D_802ACC60 != 0) {
2490 D_802ACC60--;
2491 break;
2492 }
2493
2494 if (submenuResult == 0) {
2495 break;
2496 }
2497
2498 set_actor_anim(ACTOR_PLAYER, 0, ANIM_Mario1_Walk);
2499 battleStatus->lastPlayerMenuSelection[BTL_MENU_IDX_MAIN] = battleStatus->curSubmenu = battle_menu_submenuIDs[submenuResult - 1];
2500 for (i = 0; i < ARRAY_COUNT(battleStatus->submenuMoves); i++) {
2501 battleStatus->submenuMoves[i] = 0;
2502 battleStatus->submenuIcons[i] = 0;
2503 battleStatus->submenuStatus[i] = 0;
2504 }
2505
2506 switch (battleStatus->curSubmenu) {
2509 battleStatus->submenuIcons[0] = ITEM_PARTNER_ATTACK;
2510 battleStatus->submenuStatus[0] = 1;
2511 for (i = 0; i < ARRAY_COUNT(playerData->invItems); i++) {
2512 if (playerData->invItems[i] == ITEM_NONE) {
2513 continue;
2514 }
2515 itemData = &gItemTable[playerData->invItems[i]];
2516
2517 battleStatus->moveCategory = BTL_MENU_TYPE_ITEMS;
2518 battleStatus->moveArgument = playerData->invItems[i];
2519 battleStatus->curTargetListFlags = itemData->targetFlags;
2520 create_current_pos_target_list(playerActor);
2521 }
2522 entryIdx = 1;
2523 for (i = 0; i < ARRAY_COUNT(playerData->equippedBadges); i++) {
2524 if (playerData->equippedBadges[i] != 0) {
2525 s32 moveID = gItemTable[playerData->equippedBadges[i]].moveID;
2526 moveData = &gMoveTable[moveID];
2527 if (moveData->category == BattleMenu_CategoryForSubmenu[battleStatus->curSubmenu]) {
2528 s32 cost = moveData->costFP;
2529 battleStatus->submenuMoves[entryIdx] = moveID;
2530 battleStatus->submenuIcons[entryIdx] = playerData->equippedBadges[i];
2531 battleStatus->submenuStatus[entryIdx] = 1;
2532
2534 cost -= 2 * player_team_is_ability_active(playerActor, ABILITY_FLOWER_FANATIC);
2535
2536 if (playerData->curFP < cost) {
2537 battleStatus->submenuStatus[entryIdx] = 0;
2538 }
2539 entryIdx++;
2540 }
2541 }
2542 }
2543 battleStatus->submenuMoveCount = entryIdx;
2544 if (entryIdx == 1) {
2545 battleStatus->submenuMoveCount = 0;
2546 }
2547 break;
2550 if (battleStatus->submenuMoveCount == 1) {
2551 battleStatus->submenuMoveCount = 0;
2552 }
2553 if (battleStatus->actionCommandMode == AC_MODE_TUTORIAL) {
2554 battleStatus->submenuMoveCount = 0;
2555 }
2556 break;
2557 case BTL_MENU_TYPE_JUMP:
2559 if (battleStatus->submenuMoveCount == 1) {
2560 battleStatus->submenuMoveCount = 0;
2561 }
2562 if (battleStatus->actionCommandMode == AC_MODE_TUTORIAL) {
2563 battleStatus->submenuMoveCount = 0;
2564 }
2565 break;
2567 battleStatus->submenuMoves[0] = MOVE_FOCUS;
2568 battleStatus->submenuIcons[0] = ITEM_PARTNER_ATTACK;
2569 battleStatus->submenuStatus[0] = 1;
2570 entryIdx = 1;
2571 initialPos = 8;
2572 for (i = 0; i < playerData->maxStarPower; i++) {
2573 moveData = &gMoveTable[MOVE_REFRESH + i];
2574 battleStatus->submenuMoves[entryIdx] = MOVE_REFRESH + i;
2575 battleStatus->submenuIcons[entryIdx] = 0;
2577 battleStatus->moveArgument = MOVE_REFRESH + i;
2578 battleStatus->curTargetListFlags = moveData->flags;
2579 create_current_pos_target_list(playerActor);
2580 battleStatus->submenuStatus[entryIdx] = 1;
2581 if (playerActor->targetListLength == 0) {
2582 battleStatus->submenuStatus[entryIdx] = -2;
2583 }
2584 if (playerData->starPower / SP_PER_BAR < moveData->costFP) {
2585 battleStatus->submenuStatus[entryIdx] = 0;
2586 }
2588 battleStatus->submenuStatus[entryIdx] = -1;
2589 }
2590 entryIdx++;
2591 }
2592 starBeamLevel = playerData->starBeamLevel;
2593 if (starBeamLevel == 1) {
2594 moveData = &gMoveTable[MOVE_STAR_BEAM];
2595 battleStatus->submenuMoves[entryIdx] = MOVE_STAR_BEAM;
2596 battleStatus->submenuIcons[entryIdx] = 0;
2598 battleStatus->moveArgument = MOVE_REFRESH + i;
2599 battleStatus->curTargetListFlags = moveData->flags;
2600 create_current_pos_target_list(playerActor);
2601 battleStatus->submenuStatus[entryIdx] = starBeamLevel;
2602 if (playerActor->targetListLength == 0) {
2603 battleStatus->submenuStatus[entryIdx] = -2;
2604 }
2605 if (playerData->starPower / SP_PER_BAR < moveData->costFP) {
2606 battleStatus->submenuStatus[entryIdx] = 0;
2607 }
2609 battleStatus->submenuStatus[entryIdx] = -1;
2610 }
2611 entryIdx++;
2612 }
2613 if (playerData->starBeamLevel == 2) {
2614 moveData = &gMoveTable[MOVE_PEACH_BEAM];
2615 battleStatus->submenuMoves[entryIdx] = MOVE_PEACH_BEAM;
2616 battleStatus->submenuIcons[entryIdx] = 0;
2618 battleStatus->moveArgument = MOVE_REFRESH + i;
2619 battleStatus->curTargetListFlags = moveData->flags;
2620 create_current_pos_target_list(playerActor);
2621 battleStatus->submenuStatus[entryIdx] = 1;
2622 if (playerActor->targetListLength == 0) {
2623 battleStatus->submenuStatus[entryIdx] = -2;
2624 }
2625 if (playerData->starPower / SP_PER_BAR < moveData->costFP) {
2626 battleStatus->submenuStatus[entryIdx] = 0;
2627 }
2629 battleStatus->submenuStatus[entryIdx] = -1;
2630 }
2631 entryIdx++;
2632 }
2633 battleStatus->submenuMoveCount = entryIdx;
2634 break;
2635 }
2636
2637 currentSubmenu = battleStatus->curSubmenu;
2638 if (currentSubmenu == BTL_MENU_TYPE_STAR_POWERS) {
2642 break;
2643 } else if (currentSubmenu == BTL_MENU_TYPE_STRATEGIES) {
2648 break;
2649 } else {
2651 battleStatus->moveCategory = currentSubmenu;
2652 battleStatus->moveArgument = 0;
2653 battleStatus->selectedMoveID = 0;
2655 break;
2656 }
2657 } else {
2658 if (battleStatus->submenuMoveCount == 0) {
2659 if (currentSubmenu != BTL_MENU_TYPE_ITEMS) {
2661 break;
2662 } else {
2666 break;
2667 }
2668 }
2669
2670 initialPos = 0;
2671 if (currentSubmenu == BTL_MENU_TYPE_JUMP) {
2672 if (battleStatus->lastPlayerMenuSelection[BTL_MENU_IDX_JUMP] < 0) {
2673 battleStatus->lastPlayerMenuSelection[BTL_MENU_IDX_JUMP] = 0;
2674 }
2675 initialPos = battleStatus->lastPlayerMenuSelection[BTL_MENU_IDX_JUMP];
2676 }
2677 if (battleStatus->curSubmenu == BTL_MENU_TYPE_SMASH) {
2678 if (battleStatus->lastPlayerMenuSelection[BTL_MENU_IDX_SMASH] < 0) {
2680 }
2681 initialPos = battleStatus->lastPlayerMenuSelection[BTL_MENU_IDX_SMASH];
2682 }
2683 if (battleStatus->curSubmenu == BTL_MENU_TYPE_ITEMS) {
2684 if (battleStatus->lastPlayerMenuSelection[BTL_MENU_IDX_ITEMS] < 0) {
2686 }
2687 initialPos = battleStatus->lastPlayerMenuSelection[BTL_MENU_IDX_ITEMS];
2688 }
2689
2690 for (i = 0; i < battleStatus->submenuMoveCount; i++) {
2691 moveData = &gMoveTable[battleStatus->submenuMoves[i]];
2692 itemData = &gItemTable[battleStatus->submenuIcons[i]];
2693 hudScriptPair = &gItemHudScripts[itemData->hudElemID];
2694
2696 if (battleStatus->submenuStatus[i] == 0) {
2698 }
2699 if (battleStatus->submenuStatus[i] == -1) {
2700 battleStatus->submenuStatus[i] = 0;
2702 }
2703 if (battleStatus->submenuStatus[i] == -2) {
2704 battleStatus->submenuStatus[i] = 0;
2706 }
2707 if (battleStatus->submenuStatus[i] == -3) {
2708 battleStatus->submenuStatus[i] = 0;
2710 }
2711 battle_menu_moveOptionIconScripts[i] = hudScriptPair->enabled;
2712 if (battleStatus->submenuStatus[i] == 0) {
2713 battle_menu_moveOptionIconScripts[i] = hudScriptPair->disabled;
2714 }
2715
2721
2725 }
2729 }
2730
2732 BattleMenu_Moves_OptionEnabled[i] = battleStatus->submenuStatus[i];
2733 battle_menu_moveOptionNames[i] = moveData->nameMsg;
2735
2736 }
2738 D_802AD4A8 = initialPos;
2740 func_802A2684();
2742 break;
2743 }
2744 break;
2746 submenuResult = btl_submenu_moves_update();
2747 if (submenuResult == -1) {
2749 } else if (submenuResult == 0) {
2750 } else if (submenuResult == 255) {
2751 func_802A1050();
2752 D_802ACC60 = 8;
2757 } else {
2758 battleStatus->unk_49 = BattleMenu_Moves_OptionIndices[submenuResult - 1];
2759 battleStatus->selectedMoveID = battleStatus->submenuMoves[battleStatus->unk_49];
2760 if (battleStatus->curSubmenu == BTL_MENU_TYPE_JUMP) {
2762 }
2763 if (battleStatus->curSubmenu == BTL_MENU_TYPE_SMASH) {
2765 }
2766 currentSubmenu2 = battleStatus->curSubmenu;
2767 if (battleStatus->curSubmenu == BTL_MENU_TYPE_ITEMS) {
2769 if (battleStatus->curSubmenu == currentSubmenu2) {
2773 break;
2774 }
2775 }
2776 func_802A27D0();
2777 func_802A1030();
2779 }
2780 break;
2782 submenuResult = btl_submenu_moves_update();
2783 if ((battleStatus->curButtonsPressed & BUTTON_B) && submenuResult == 0) {
2784 func_802A2AB8();
2785 func_802A1098();
2787 break;
2788 }
2789 if (btl_main_menu_update() == 0) {
2790 break;
2791 }
2794 battleStatus->selectedMoveID = battleStatus->submenuMoves[battleStatus->unk_49];
2795 battleStatus->curTargetListFlags = gMoveTable[battleStatus->submenuMoves[battleStatus->unk_49]].flags;
2796 currentSubmenu = battleStatus->curSubmenu;
2797 switch (currentSubmenu) {
2798 case BTL_MENU_TYPE_JUMP:
2799 battleStatus->moveCategory = BTL_MENU_TYPE_JUMP;
2800 battleStatus->moveArgument = playerData->bootsLevel;
2802 break;
2804 battleStatus->moveCategory = BTL_MENU_TYPE_SMASH;
2805 battleStatus->moveArgument = playerData->hammerLevel;
2807 break;
2811 battleStatus->moveCategory = BTL_MENU_TYPE_DEFEND;
2813 break;
2814 }
2815 break;
2818 if (btl_main_menu_update() == 0) {
2819 break;
2820 }
2822 break;
2824 func_802A2AB8();
2825 func_802A1098();
2827 break;
2829 func_802A27E4();
2831 break;
2833 if (btl_submenu_moves_update() != -1) {
2835 }
2836 break;
2840 } else {
2842 }
2843 ShowingErrorMessage = TRUE;
2845 break;
2847 if (btl_is_popup_displayed()) {
2848 break;
2849 }
2850 ShowingErrorMessage = FALSE;
2851 D_802ACC60 = 0;
2854 break;
2856 func_802A1030();
2858 break;
2860 submenuResult = btl_main_menu_update();
2861 if ((battleStatus->curButtonsPressed & BUTTON_B) && submenuResult == 0) {
2862 func_802A1078();
2864 } else if (submenuResult != 0) {
2867 switch (battleStatus->curSubmenu) {
2868 case BTL_MENU_TYPE_JUMP:
2869 battleStatus->moveCategory = BTL_MENU_TYPE_JUMP;
2870 battleStatus->moveArgument = playerData->bootsLevel;
2871 battleStatus->selectedMoveID = playerData->bootsLevel + MOVE_JUMP1;
2872 battleStatus->curTargetListFlags = gMoveTable[battleStatus->selectedMoveID].flags;
2874 break;
2876 battleStatus->moveCategory = BTL_MENU_TYPE_SMASH;
2877 battleStatus->moveArgument = playerData->hammerLevel;
2878 battleStatus->selectedMoveID = playerData->hammerLevel + MOVE_HAMMER1;
2879 battleStatus->curTargetListFlags = gMoveTable[battleStatus->selectedMoveID].flags;
2881 break;
2882 default:
2883 goto CASE_C; // TODO find better match
2884 }
2885 }
2886 break;
2887 CASE_C:
2889 if (btl_main_menu_update() == 0) {
2890 break;
2891 }
2892 D_802ACC60 = 8;
2895 break;
2897 func_802A1078();
2899 break;
2902 break;
2904 if (battleStatus->selectedMoveID == MOVE_DOUBLE_DIP) {
2905 battleStatus->itemUsesLeft = 2;
2906 }
2907 if (battleStatus->selectedMoveID == MOVE_TRIPLE_DIP) {
2908 battleStatus->itemUsesLeft = 3;
2909 }
2910 entryIdx = 0;
2911 for (i = 0; i < ARRAY_COUNT(playerData->invItems); i++) {
2912 if (playerData->invItems[i] == ITEM_NONE) {
2913 continue;
2914 }
2915 itemData = &gItemTable[playerData->invItems[i]];
2916 hudScriptPair = &gItemHudScripts[itemData->hudElemID];
2917 if (!(itemData->typeFlags & ITEM_TYPE_FLAG_BATTLE_USABLE)) {
2918 continue;
2919 }
2920 battleStatus->moveCategory = BTL_MENU_TYPE_ITEMS;
2921 battleStatus->moveArgument = playerData->invItems[i];
2922 battleStatus->curTargetListFlags = itemData->targetFlags;
2923 create_current_pos_target_list(playerActor);
2924 popup->ptrIcon[entryIdx] = hudScriptPair->enabled;
2925 popup->userIndex[entryIdx] = playerData->invItems[i];
2926 popup->enabled[entryIdx] = TRUE;
2927 popup->nameMsg[entryIdx] = itemData->nameMsg;
2928 popup->descMsg[entryIdx] = itemData->shortDescMsg;
2929 if (playerActor->targetListLength == 0) {
2930 popup->ptrIcon[entryIdx] = hudScriptPair->disabled;
2931 popup->enabled[entryIdx] = 0;
2932 }
2933 entryIdx++;
2934 }
2935 popup->dipMode = 0;
2936 popup->titleNumber = 0;
2937 if (battleStatus->selectedMoveID == MOVE_DOUBLE_DIP) {
2938 popup->dipMode = 1;
2939 popup->titleNumber = battleStatus->itemUsesLeft;
2940 }
2941 if (battleStatus->selectedMoveID == MOVE_TRIPLE_DIP) {
2942 popup->dipMode = 2;
2943 popup->titleNumber = battleStatus->itemUsesLeft;
2944 }
2945 if (battleStatus->lastPlayerMenuSelection[BTL_MENU_IDX_DIP] < 0) {
2946 battleStatus->lastPlayerMenuSelection[BTL_MENU_IDX_DIP] = 0;
2947 }
2949 popup->numEntries = entryIdx;
2950 initialPos = battleStatus->lastPlayerMenuSelection[BTL_MENU_IDX_DIP];
2951 popup->initialPos = initialPos;
2953 func_800F52BC();
2955 break;
2957 if (popup->result != POPUP_RESULT_CHOOSING) {
2958 if (popup->result == POPUP_RESULT_CANCEL) {
2959 func_802A2910();
2960 battleStatus->selectedMoveID = 0;
2961 battleStatus->itemUsesLeft = 0;
2965 } else {
2968 battleStatus->unk_1AA = popup->userIndex[popup->result - 1];
2969 battleStatus->moveCategory = BTL_MENU_TYPE_ITEMS;
2970 battleStatus->moveArgument = battleStatus->unk_1AA;
2972 battleStatus->curAttackElement = 0;
2973 battleStatus->lastPlayerMenuSelection[BTL_MENU_IDX_DIP] = popup->result - 1;
2975 func_802A27D0();
2976 func_802A1030();
2978 }
2979 }
2980 break;
2982 if ((battleStatus->curButtonsPressed & BUTTON_B) && popup->result == POPUP_RESULT_CHOOSING) {
2983 func_800F16CC();
2984 func_802A2C58();
2985 func_802A1098();
2986 battleStatus->selectedMoveID = 0;
2988 } else {
2990 if (btl_main_menu_update()) {
2992 }
2993 }
2994 break;
2997 if (btl_main_menu_update() != 0) {
2999 }
3000 break;
3002 func_800F16CC();
3003 func_802A2C58();
3004 func_802A1098();
3007 break;
3010 func_802A27E4();
3012 break;
3014 entryIdx = 0;
3015 for (i = 0; i < ARRAY_COUNT(playerData->invItems); i++) {
3016 if (playerData->invItems[i] == ITEM_NONE) {
3017 continue;
3018 }
3019 itemData = &gItemTable[playerData->invItems[i]];
3020 hudScriptPair = &gItemHudScripts[itemData->hudElemID];
3021 if (!(itemData->typeFlags & ITEM_TYPE_FLAG_BATTLE_USABLE)) {
3022 continue;
3023 }
3024 battleStatus->moveCategory = BTL_MENU_TYPE_ITEMS;
3025 battleStatus->moveArgument = playerData->invItems[i];
3026 battleStatus->curTargetListFlags = itemData->targetFlags;
3027 create_current_pos_target_list(playerActor);
3028 popup->ptrIcon[entryIdx] = hudScriptPair->enabled;
3029
3030 popup->userIndex[entryIdx] = playerData->invItems[i];
3031 popup->enabled[entryIdx] = 1;
3032 popup->nameMsg[entryIdx] = itemData->nameMsg;
3033 popup->descMsg[entryIdx] = itemData->shortDescMsg;
3034 if (playerActor->targetListLength == 0) {
3035 popup->ptrIcon[entryIdx] = hudScriptPair->disabled;
3036 popup->enabled[entryIdx] = 0;
3037 }
3038 entryIdx++;
3039 }
3040 if (battleStatus->lastPlayerMenuSelection[BTL_MENU_IDX_DIP] < 0) {
3041 battleStatus->lastPlayerMenuSelection[BTL_MENU_IDX_DIP] = 0;
3042 }
3043 initialPos = battleStatus->lastPlayerMenuSelection[BTL_MENU_IDX_DIP];
3045 popup->numEntries = entryIdx;
3046 popup->dipMode = 0;
3047 popup->titleNumber = 0;
3048 popup->initialPos = initialPos;
3050 func_800F52BC();
3052 break;
3054 if (popup->result != POPUP_RESULT_CHOOSING) {
3055 if (popup->result == POPUP_RESULT_CANCEL) {
3056 func_802A1050();
3057 D_802ACC60 = 8;
3062 } else {
3065 battleStatus->unk_1AA = popup->userIndex[popup->result - 1];
3066 battleStatus->moveCategory = BTL_MENU_TYPE_ITEMS;
3067 battleStatus->moveArgument = battleStatus->unk_1AA;
3068 battleStatus->selectedMoveID = MOVE_ITEMS;
3070 battleStatus->curAttackElement = 0;
3071 battleStatus->lastPlayerMenuSelection[BTL_MENU_IDX_DIP] = popup->result - 1;
3073 func_802A1030();
3075 }
3076 }
3077 break;
3079 if ((battleStatus->curButtonsPressed & BUTTON_B) && popup->result == POPUP_RESULT_CHOOSING) {
3080 func_800F16CC();
3081 func_802A1098();
3083 } else {
3084 if (btl_main_menu_update() != 0) {
3086 }
3087 }
3088 break;
3090 if (btl_main_menu_update() != 0) {
3092 }
3093 break;
3095 func_800F16CC();
3096 func_802A1098();
3098 break;
3102 break;
3104 for (i = 0; i < battleStatus->submenuMoveCount; i++) {
3105 moveData = &gMoveTable[battleStatus->submenuMoves[i]];
3107
3108 if (battleStatus->submenuStatus[i] == 0) {
3110 }
3111
3112 if (battleStatus->submenuStatus[i] == -1) {
3113 battleStatus->submenuStatus[i] = 0;
3115 }
3116 if (battleStatus->submenuStatus[i] == -2) {
3117 battleStatus->submenuStatus[i] = 0;
3119 }
3120 if (!(battleStatus->enabledStarPowersFlags & (1 << i))) {
3121 battleStatus->submenuStatus[i] = 0;
3123 }
3124
3125 battle_menu_moveOptionIconScripts[i] = battle_menu_StarPowerMovesHudScripts[2 * STAR_POWER_INDEX(battleStatus->submenuMoves[i]) + 0];
3126 if (battleStatus->submenuStatus[i] == 0) {
3127 battle_menu_moveOptionIconScripts[i] = battle_menu_StarPowerMovesHudScripts[2 * STAR_POWER_INDEX(battleStatus->submenuMoves[i]) + 1];
3128 }
3133 BattleMenu_Moves_OptionEnabled[i] = battleStatus->submenuStatus[i];
3134 battle_menu_moveOptionNames[i] = moveData->nameMsg;
3138 }
3139 if (battleStatus->lastPlayerMenuSelection[BTL_MENU_IDX_STAR_POWER] < 0) {
3141 }
3142 initialPos = battleStatus->lastPlayerMenuSelection[BTL_MENU_IDX_STAR_POWER];
3144 D_802AD4A8 = initialPos;
3146 func_802A2684();
3148 break;
3150 submenuResult = btl_submenu_moves_update();
3151 if (submenuResult == -1) {
3153 } else if (submenuResult == 0) {
3154 } else if (submenuResult == 255) {
3155 func_802A1050();
3156 D_802ACC60 = 8;
3161 } else {
3162 battleStatus->unk_49 = BattleMenu_Moves_OptionIndices[submenuResult - 1];
3164 func_802A27D0();
3165 func_802A1030();
3167 }
3168 break;
3170 submenuResult = btl_submenu_moves_update();
3171 if ((battleStatus->curButtonsPressed & BUTTON_B) && submenuResult == 0) {
3172 func_802A2AB8();
3173 func_802A1098();
3175 } else if (btl_main_menu_update() != 0) {
3179 battleStatus->selectedMoveID = battleStatus->submenuMoves[battleStatus->unk_49];
3180 battleStatus->curTargetListFlags = gMoveTable[battleStatus->submenuMoves[battleStatus->unk_49]].flags;
3181 battleStatus->moveArgument = battleStatus->unk_49;
3182 if (playerData->starBeamLevel == 2 && battleStatus->moveArgument == 8) {
3183 battleStatus->moveArgument++;
3184 }
3186 }
3187 break;
3190 if (btl_main_menu_update() != 0) {
3192 }
3193 break;
3195 func_802A2AB8();
3196 func_802A1098();
3198 break;
3200 func_802A27E4();
3202 break;
3204 if (btl_submenu_moves_update() != -1) {
3206 }
3207 break;
3209 if (!can_switch_to_player()) {
3210 battleStatus->itemUsesLeft = 1;
3212 } else {
3213 entryIdx = 0;
3214 for (i = 0; i < ARRAY_COUNT(playerData->invItems); i++) {
3215 if (playerData->invItems[i] == ITEM_NONE) {
3216 continue;
3217 }
3218 itemData = &gItemTable[playerData->invItems[i]];
3219 hudScriptPair = &gItemHudScripts[itemData->hudElemID];
3220 if (!(itemData->typeFlags & ITEM_TYPE_FLAG_BATTLE_USABLE)) {
3221 continue;
3222 }
3223
3224 battleStatus->moveCategory = BTL_MENU_TYPE_ITEMS;
3225 battleStatus->moveArgument = playerData->invItems[i];
3226 battleStatus->curTargetListFlags = itemData->targetFlags;
3227 create_current_pos_target_list(playerActor);
3228 popup->ptrIcon[entryIdx] = hudScriptPair->enabled;
3229 popup->userIndex[entryIdx] = playerData->invItems[i];
3230 popup->enabled[entryIdx] = TRUE;
3231 popup->nameMsg[entryIdx] = itemData->nameMsg;
3232 popup->descMsg[entryIdx] = itemData->shortDescMsg;
3233 if (playerActor->targetListLength == 0) {
3234 popup->ptrIcon[entryIdx] = hudScriptPair->disabled;
3235 popup->enabled[entryIdx] = FALSE;
3236 }
3237 entryIdx++;
3238 }
3239 if (entryIdx == 0) {
3240 battleStatus->itemUsesLeft = 1;
3242 } else {
3244 if (battleStatus->selectedMoveID == MOVE_DOUBLE_DIP) {
3246 popup->dipMode = 1;
3247 popup->titleNumber = battleStatus->itemUsesLeft;
3248 }
3249 if (battleStatus->selectedMoveID == MOVE_TRIPLE_DIP) {
3251 popup->dipMode = 2;
3252 popup->titleNumber = battleStatus->itemUsesLeft;
3253 }
3254 if (battleStatus->lastPlayerMenuSelection[BTL_MENU_IDX_DIP] < 0) {
3255 battleStatus->lastPlayerMenuSelection[BTL_MENU_IDX_DIP] = 0;
3256 }
3257 popup->numEntries = entryIdx;
3258 initialPos = battleStatus->lastPlayerMenuSelection[BTL_MENU_IDX_DIP];
3259 popup->initialPos = initialPos;
3261 func_800F52BC();
3263 }
3264 }
3265 break;
3267 if (popup->result != POPUP_RESULT_CHOOSING) {
3268 if (popup->result == POPUP_RESULT_CANCEL) {
3269 battleStatus->itemUsesLeft = 1;
3271 } else {
3274 battleStatus->unk_1AA = popup->userIndex[popup->result - 1];
3275 battleStatus->moveCategory = BTL_MENU_TYPE_ITEMS;
3276 battleStatus->moveArgument = battleStatus->unk_1AA;
3278 battleStatus->curAttackElement = 0;
3279 battleStatus->lastPlayerMenuSelection[BTL_MENU_IDX_DIP] = popup->result - 1;
3281 D_802ACC60 = 5;
3283 }
3284 }
3285 break;
3287 if (D_802ACC60 != 0) {
3288 D_802ACC60--;
3289 } else {
3291 }
3292 break;
3294 if (D_802ACC60 != 0) {
3295 D_802ACC60--;
3296 } else {
3298 }
3299 break;
3301 func_800F16CC();
3302 D_802ACC60 = 5;
3304 break;
3307 break;
3309 if (playerData->bootsLevel >= 0) {
3310 battleStatus->curTargetListFlags = gMoveTable[MOVE_BERSERKER_JUMP].flags;
3311 create_current_pos_target_list(playerActor);
3312 jumpTargetCount = playerActor->targetListLength;
3313 } else {
3314 jumpTargetCount = 0;
3315 }
3316
3317 if (playerData->hammerLevel >= 0) {
3318 battleStatus->curTargetListFlags = gMoveTable[MOVE_BERSERKER_HAMMER].flags;
3319 create_current_pos_target_list(playerActor);
3320 hammerTargetCount = playerActor->targetListLength;
3321 } else {
3322 hammerTargetCount = 0;
3323 }
3324
3325 if (jumpTargetCount <= 0 && hammerTargetCount <= 0) {
3326 battleStatus->moveCategory = BTL_MENU_TYPE_DO_NOTHING;
3327 battleStatus->waitForState = BATTLE_STATE_0;
3329 } else {
3330 jumpChance = 50;
3331 if (jumpTargetCount <= 0) {
3332 jumpChance = 0;
3333 }
3334 if (hammerTargetCount <= 0) {
3335 jumpChance = 101;
3336 }
3337 if (rand_int(100) < jumpChance) {
3338 battleStatus->selectedMoveID = MOVE_BERSERKER_JUMP;
3339 battleStatus->moveCategory = BTL_MENU_TYPE_JUMP;
3340 battleStatus->curTargetListFlags = gMoveTable[MOVE_BERSERKER_JUMP].flags;
3341 battleStatus->moveArgument = playerData->bootsLevel;
3342 create_current_pos_target_list(playerActor);
3343 } else {
3344 battleStatus->selectedMoveID = MOVE_BERSERKER_HAMMER;
3345 battleStatus->moveCategory = BTL_MENU_TYPE_SMASH;
3346 battleStatus->curTargetListFlags = gMoveTable[MOVE_BERSERKER_HAMMER].flags;
3347 battleStatus->moveArgument = playerData->hammerLevel;
3348 create_current_pos_target_list(playerActor);
3349 }
3351 }
3352 break;
3354 entryIdx = 0;
3356
3357 // add 'Change Member' command
3358 if (battleStatus->changePartnerAllowed >= 0) {
3361 D_802AD640[entryIdx] = battle_menu_PartnerHudScripts[playerData->curPartner];
3362 D_802AD690[entryIdx] = 1;
3363 D_802AD6C0[entryIdx] = MSG_Menus_Action_ChangePartner;
3364 if (battleStatus->changePartnerAllowed <= 0) {
3366 D_802AD690[entryIdx] = 0;
3367 D_802AD6A8[entryIdx] = 0;
3368 }
3369 entryIdx++;
3370 }
3371
3372 // add 'Do Nothing' command
3375 D_802AD690[entryIdx] = 1;
3377 D_802AD6C0[entryIdx] = MSG_Menus_Action_DoNothing;
3378 entryIdx++;
3379
3380 // add 'Run Away' command
3383 D_802AD690[entryIdx] = 1;
3385 D_802AD6C0[entryIdx] = MSG_Menus_Action_RunAway;
3388 D_802AD690[entryIdx] = 0;
3389 D_802AD6A8[entryIdx] = 1;
3390 }
3391 entryIdx++;
3392
3393 if (battleStatus->lastPlayerMenuSelection[BTL_MENU_IDX_STRATEGY] < 0) {
3395 }
3396 initialPos = battleStatus->lastPlayerMenuSelection[BTL_MENU_IDX_STRATEGY];
3397 D_802AD66C = entryIdx;
3398 StratsMenuLastPos = initialPos;
3399 func_802A45D8();
3401 break;
3403 submenuResult = btl_update_strats_menu();
3404 if (submenuResult == -1) {
3406 } else if (submenuResult == 0) {
3407 } else if (submenuResult == 255) {
3408 func_802A1050();
3409 D_802ACC60 = 8;
3414 } else {
3415 battleStatus->curSubmenu = D_802AD678[submenuResult - 1];
3416 battleStatus->lastPlayerMenuSelection[BTL_MENU_IDX_STRATEGY] = submenuResult - 1;
3417 if (battleStatus->curSubmenu == 5) { // change partner
3421 } else {
3422 func_802A4718();
3423 func_802A1030();
3425 }
3426 }
3427 break;
3429 submenuResult = btl_update_strats_menu();
3430 if ((battleStatus->curButtonsPressed & BUTTON_B) && submenuResult == 0) {
3431 func_802A48FC();
3432 func_802A1098();
3434 } else if (btl_main_menu_update() != 0) {
3437 switch (battleStatus->curSubmenu) {
3438 case 3:
3441 battleStatus->moveCategory = BTL_MENU_TYPE_RUN_AWAY;
3442 battleStatus->selectedMoveID = MOVE_UNUSED_39;
3444 break;
3445 case 9:
3446 battleStatus->hustleTurns = 0;
3447 gBattleStatus.flags1 &= ~BS_FLAGS1_HUSTLED;
3451 break;
3452 case 4:
3455 battleStatus->selectedMoveID = MOVE_UNUSED_DEFEND_PLUS;
3456 battleStatus->moveCategory = BTL_MENU_TYPE_DEFEND;
3458 break;
3459 case 10:
3463 break;
3464 }
3465 }
3466 break;
3469 if (btl_main_menu_update() != 0) {
3470 D_802ACC60 = 8;
3473 }
3474 break;
3476 func_802A48FC();
3477 func_802A1098();
3479 break;
3481 func_802A472C();
3483 break;
3485 if (btl_update_strats_menu() != -1) {
3487 }
3488 break;
3490 entryIdx = 0;
3491 for (i = 1; i < ARRAY_COUNT(playerData->partners); i++) {
3492 s32 partnerId = PartnerIDFromMenuIndex[i];
3493 if (playerData->partners[partnerId].enabled) {
3494 prop = &gPartnerPopupProperties[partnerId];
3495 popup->ptrIcon[entryIdx] = battle_menu_PartnerHudScripts[partnerId];
3496 popup->userIndex[entryIdx] = partnerId;
3497 popup->enabled[entryIdx] = 1;
3498 popup->nameMsg[entryIdx] = prop->nameMsg;
3499 popup->descMsg[entryIdx] = prop->battleDescMsg;
3500 popup->value[entryIdx] = playerData->partners[partnerId].level;
3501 if (playerData->curPartner == partnerId) {
3502 popup->enabled[entryIdx] = 0;
3503 popup->ptrIcon[entryIdx] = battle_menu_DisabledPartnerHudScripts[partnerId];
3504 }
3505 entryIdx++;
3506 }
3507 }
3508 if (battleStatus->lastPlayerMenuSelection[BTL_MENU_IDX_PARTNER] < 0) {
3510 }
3512 popup->numEntries = entryIdx;
3513 popup->initialPos = MenuIndexFromPartnerID[playerData->curPartner] - 1;
3514 popup->dipMode = 0;
3515 popup->titleNumber = 0;
3517 func_800F52BC();
3519 break;
3521 if (popup->result == POPUP_RESULT_INVALID) {
3523 } else if (popup->result != POPUP_RESULT_CHOOSING) {
3524 if (popup->result == POPUP_RESULT_CANCEL) {
3525 func_802A47E0();
3529 } else {
3532 battleStatus->unk_1AC = popup->userIndex[popup->result - 1];
3534 battleStatus->selectedMoveID = MOVE_UNUSED_37;
3535 battleStatus->curTargetListFlags = TARGET_FLAG_2;
3536 battleStatus->moveArgument = battleStatus->unk_1AC;
3537 battleStatus->lastPlayerMenuSelection[BTL_MENU_IDX_PARTNER] = popup->result - 1;
3539 func_802A4718();
3540 func_802A1030();
3542 }
3543 }
3544 break;
3546 if ((battleStatus->curButtonsPressed & BUTTON_B) && popup->result == POPUP_RESULT_CHOOSING) {
3547 func_800F16CC();
3548 func_802A4A10();
3549 func_802A1098();
3551 } else {
3553 if (btl_main_menu_update() != 0) {
3557 }
3558 }
3559 break;
3562 if (btl_main_menu_update() != 0) {
3564 }
3565 break;
3567 func_800F16CC();
3568 func_802A4A10();
3569 func_802A1098();
3571 break;
3574 func_802A472C();
3576 break;
3580 if (popup->result != POPUP_RESULT_INVALID) {
3584 }
3585 break;
3586 }
3587}
PartnerPopupProperties gPartnerPopupProperties[]
Definition 5B320.c:331
@ AC_MODE_TUTORIAL
Definition action_cmd.h:62
BSS s32 battle_menu_moveOptionDisplayCostReductionColors[24]
BSS s32 BattleMenu_TitleMessages[6]
void create_battle_popup_menu(PopupMenu *popup)
void func_802A2684(void)
void btl_main_menu_destroy(void)
HudScript * battle_menu_DisabledPartnerHudScripts[]
BSS s32 battle_menu_moveOptionBPCosts[24]
BSS s32 D_802AD4A8
BSS s32 battle_menu_moveOptionNames[24]
HudScript * battle_menu_PartnerHudScripts[]
IconHudScriptPair gItemHudScripts[]
s32 can_switch_to_partner(void)
BSS s32 D_802AD6A8[6]
IconHudScriptPair battle_menu_FleeHudScripts
BSS HudScript * battle_menu_moveOptionIconScripts[24]
BSS s32 BattleMenu_Moves_OptionCount
void btl_init_menu_items(void)
Definition 190B20.c:601
void func_802A1078(void)
s32 btl_submenu_moves_update(void)
BSS s32 D_802AD678[6]
s32 btl_update_strats_menu(void)
BSS s8 ShowingErrorMessage
BSS s8 BattleMenu_CurPos
BSS s32 battle_menu_moveOptionActive
BSS s32 D_802AD0A8
BSS s32 D_802ACC60
void btl_main_menu_init(void)
s32 btl_main_menu_update(void)
BSS s32 battle_menu_submenuIDs[6]
IconHudScriptPair battle_menu_DoNothingHudScripts
BSS s32 BattleMenu_Moves_OptionIndices[24]
IconHudScriptPair battle_menu_StarPowerHudScripts
void func_802A1098(void)
s32 BattleMenu_CenteredMessages[]
BSS s32 D_802AD0B0
void func_802A45D8(void)
void btl_check_can_change_partner(void)
Definition 190B20.c:566
void btl_init_menu_hammer(void)
Definition 190B20.c:765
void func_802A4A10(void)
IconHudScriptPair battle_menu_JumpHudScripts[]
IconHudScriptPair battle_menu_StrategiesHudScript
IconHudScriptPair battle_menu_ItemHudScripts
BSS s8 BattleMenu_Moves_OptionCantUseMessages[24]
void func_802A2910(void)
BSS s32 BattleMenu_UsingSpiritsSubmenu
void func_800F52BC(void)
BSS s32 D_802AD100
BSS s32 BattleMenu_OptionEnabled[6]
BSS s32 BattleMenu_Moves_OptionEnabled[24]
BSS s32 D_802AD690[6]
BSS s32 BattleMenu_NumOptions
BSS s32 BattleMenu_SwapDelay
BSS s32 StratsMenuLastPos
BSS s32 D_802AD66C
s32 BattleMenu_LeftJustMessages[]
s32 BattleMenu_CategoryForSubmenu[]
s32 can_switch_to_player(void)
s32 MenuIndexFromPartnerID[]
Definition 5B320.c:316
BSS s32 D_802AD658[5]
HudScript * battle_menu_StarPowerMovesHudScripts[]
void btl_state_update_player_menu(void)
void func_802A47E0(void)
void func_802A48FC(void)
BSS s32 BattleMenu_Moves_OptionDescMessages[24]
BSS s32 D_802AD6C0[5]
BSS HudScript * BattleMenu_HudScripts[6]
void func_802A2AB8(void)
BSS s32 BattleMenu_ShowSwapIcons
void func_802A472C(void)
s32 get_player_anim_for_status(s32 animID)
Definition 190B20.c:1965
void func_802A2C58(void)
BSS s32 battle_menu_isMessageDisabled[6]
void func_802A1050(void)
void func_802A1030(void)
void func_802A4718(void)
void func_802A27E4(void)
BSS s32 battle_menu_moveOptionDisplayCosts[24]
void btl_init_menu_boots(void)
Definition 190B20.c:671
void func_800F16CC(void)
BSS s8 BattleMenu_HomePos
BSS s8 BattleMenu_Moves_OptionSortPriority[24]
BSS PopupMenu D_802ACCD0
BSS s32 battle_menu_moveOptionDisplayCostReductions[24]
IconHudScriptPair battle_menu_HammerHudScripts[]
void func_802A27D0(void)
BSS HudScript * D_802AD640[6]
PartnerData partners[12]
s8 targetListLength
s16 invItems[10]
@ BUTTON_Z
Definition enums.h:2788
@ BS_FLAGS1_TUTORIAL_BATTLE
Definition enums.h:3593
@ BS_FLAGS1_MENU_OPEN
Definition enums.h:3565
@ BTL_MSG_CANT_SWITCH
Definition enums.h:4139
@ BTL_MSG_CANT_MOVE
Definition enums.h:4140
@ BTL_MSG_NO_JUMP_TARGET
Definition enums.h:4126
@ BTL_MSG_NO_ITEM_TARGET
Definition enums.h:4128
@ BTL_MSG_CANT_SELECT_NOW
Definition enums.h:4131
@ BTL_MSG_CANT_SELECT_NOW_ALT
Definition enums.h:4143
@ BTL_MSG_NO_HAMMER_TARGET
Definition enums.h:4127
@ POPUP_MENU_DOUBLE_DIP
Definition enums.h:3145
@ POPUP_MENU_USE_ITEM
Definition enums.h:3131
@ POPUP_MENU_TRIPLE_DIP
Definition enums.h:3146
@ POPUP_MENU_SWITCH_PARTNER
Definition enums.h:3132
@ WINDOW_UPDATE_9
Definition enums.h:5318
@ BTL_MENU_TYPE_INVALID
Definition enums.h:4225
@ BTL_MENU_TYPE_RUN_AWAY
Definition enums.h:4229
@ BTL_MENU_TYPE_STAR_POWERS
Definition enums.h:4234
@ BTL_MENU_TYPE_DEFEND
Definition enums.h:4230
@ BTL_MENU_TYPE_STRATEGIES
Definition enums.h:4233
@ BTL_MENU_TYPE_DO_NOTHING
Definition enums.h:4235
@ BS_FLAGS2_NO_TARGET_AVAILABLE
Definition enums.h:3613
@ STATUS_KEY_THINKING
Definition enums.h:2224
@ ITEM_TYPE_FLAG_BATTLE_USABLE
Definition enums.h:1835
@ TARGET_FLAG_PRIMARY_ONLY
Definition enums.h:1863
@ TARGET_FLAG_2
Definition enums.h:1850
@ POPUP_RESULT_CANCEL
Definition enums.h:3178
@ POPUP_RESULT_CHOOSING
Definition enums.h:3177
@ POPUP_RESULT_INVALID
Definition enums.h:3175
@ BATTLE_STATE_DEFEND
Definition enums.h:3655
@ BATTLE_STATE_PLAYER_MOVE
Definition enums.h:3648
@ BATTLE_STATE_SELECT_TARGET
Definition enums.h:3647
@ BATTLE_STATE_CHANGE_PARTNER
Definition enums.h:3659
@ ABILITY_FLOWER_SAVER
Definition enums.h:460
@ ABILITY_FLOWER_FANATIC
Definition enums.h:474
@ SOUND_PARTNER_SWAP_BATTLE_POS
Definition enums.h:560
@ SOUND_MENU_ERROR
Definition enums.h:933
@ BTL_MENU_ENABLED_SMASH
Definition enums.h:4242
@ BTL_MENU_ENABLED_ITEMS
Definition enums.h:4243
@ BTL_MENU_ENABLED_STAR_POWERS
Definition enums.h:4246
@ BTL_MENU_ENABLED_JUMP
Definition enums.h:4241
@ BTL_MENU_ENABLED_STRATEGIES
Definition enums.h:4245
@ BTL_SUBSTATE_PLAYER_MENU_STRATEGIES_4
Definition enums.h:3980
@ BTL_SUBSTATE_PLAYER_MENU_CHANGE_MEMBER_3
Definition enums.h:3947
@ BTL_SUBSTATE_PLAYER_MENU_ITEMS_5
Definition enums.h:3957
@ BTL_SUBSTATE_PLAYER_MENU_MAIN_SHOW_CANT_SWAP
Definition enums.h:3930
@ BTL_SUBSTATE_PLAYER_MENU_BERSERKER_CHOOSE
Definition enums.h:3975
@ BTL_SUBSTATE_PLAYER_MENU_STRATEGIES_2
Definition enums.h:3978
@ BTL_SUBSTATE_PLAYER_MENU_DIPPING_5
Definition enums.h:3972
@ BTL_SUBSTATE_PLAYER_MENU_MAIN_AWAIT_CANT_SWAP
Definition enums.h:3931
@ BTL_SUBSTATE_PLAYER_MENU_STAR_SPIRITS_7
Definition enums.h:3966
@ BTL_SUBSTATE_PLAYER_MENU_DIPPING_TARGET_CANCEL
Definition enums.h:3942
@ BTL_SUBSTATE_PLAYER_MENU_ITEMS_1
Definition enums.h:3953
@ BTL_SUBSTATE_PLAYER_MENU_CHANGE_MEMBER_4
Definition enums.h:3948
@ BTL_SUBSTATE_PLAYER_MENU_CHANGE_MEMBER_2
Definition enums.h:3946
@ BTL_SUBSTATE_PLAYER_MENU_UNKNOWN_3
Definition enums.h:3940
@ BTL_SUBSTATE_PLAYER_MENU_STAR_SPIRITS_4
Definition enums.h:3963
@ BTL_SUBSTATE_PLAYER_MENU_DIPPING_4
Definition enums.h:3971
@ BTL_SUBSTATE_PLAYER_MENU_CHOOSE_CATEGORY
Definition enums.h:3923
@ BTL_SUBSTATE_PLAYER_MENU_ITEMS_4
Definition enums.h:3956
@ BTL_SUBSTATE_PLAYER_MENU_CREATE_MAIN_MENU
Definition enums.h:3986
@ BTL_SUBSTATE_PLAYER_MENU_MAIN_MENU_10
Definition enums.h:3932
@ BTL_SUBSTATE_PLAYER_MENU_DIPPING_TARGET_CHOSEN
Definition enums.h:3943
@ BTL_SUBSTATE_PLAYER_MENU_CHANGE_MEMBER_1
Definition enums.h:3945
@ BTL_SUBSTATE_PLAYER_MENU_MOVE_TARGET_CHOSEN
Definition enums.h:3928
@ BTL_SUBSTATE_PLAYER_MENU_MAIN_MENU_13
Definition enums.h:3935
@ BTL_SUBSTATE_PLAYER_MENU_DIPPING_3
Definition enums.h:3970
@ BTL_SUBSTATE_PLAYER_MENU_STAR_SPIRITS_6
Definition enums.h:3965
@ BTL_SUBSTATE_PLAYER_MENU_MOVE_CHOOSE_TARGET
Definition enums.h:3925
@ BTL_SUBSTATE_PLAYER_MENU_PERFORM_SWAP
Definition enums.h:3985
@ BTL_SUBSTATE_PLAYER_MENU_MAIN_MENU_2
Definition enums.h:3924
@ BTL_SUBSTATE_PLAYER_MENU_UNKNOWN_4
Definition enums.h:3941
@ BTL_SUBSTATE_PLAYER_MENU_MAIN_MENU_7
Definition enums.h:3929
@ BTL_SUBSTATE_PLAYER_MENU_STAR_SPIRITS_2
Definition enums.h:3961
@ BTL_SUBSTATE_PLAYER_MENU_DIPPING_CHOOSE_TARGET
Definition enums.h:3939
@ BTL_SUBSTATE_PLAYER_MENU_DIPPING_2
Definition enums.h:3969
@ BTL_SUBSTATE_PLAYER_MENU_ITEMS_6
Definition enums.h:3958
@ BTL_SUBSTATE_PLAYER_MENU_UNKNOWN_1
Definition enums.h:3938
@ BTL_SUBSTATE_PLAYER_MENU_STRATEGIES_3
Definition enums.h:3979
@ BTL_SUBSTATE_PLAYER_MENU_CHANGE_MEMBER_7
Definition enums.h:3951
@ BTL_SUBSTATE_PLAYER_MENU_STAR_SPIRITS_5
Definition enums.h:3964
@ BTL_SUBSTATE_PLAYER_MENU_CHANGE_MEMBER_6
Definition enums.h:3950
@ BTL_SUBSTATE_PLAYER_MENU_MAIN_MENU_4
Definition enums.h:3926
@ BTL_SUBSTATE_PLAYER_MENU_STRATEGIES_8
Definition enums.h:3983
@ BTL_SUBSTATE_PLAYER_MENU_MOVE_TARGET_CANCEL
Definition enums.h:3927
@ BTL_SUBSTATE_PLAYER_MENU_STRATEGIES_6
Definition enums.h:3982
@ BTL_SUBSTATE_PLAYER_MENU_MAIN_MENU_12
Definition enums.h:3934
@ BTL_SUBSTATE_PLAYER_MENU_BUILD_STRATEGIES
Definition enums.h:3977
@ BTL_SUBSTATE_PLAYER_MENU_INIT
Definition enums.h:3921
@ BTL_SUBSTATE_PLAYER_MENU_CHANGE_MEMBER_5
Definition enums.h:3949
@ BTL_SUBSTATE_PLAYER_MENU_STRATEGIES_5
Definition enums.h:3981
@ BTL_SUBSTATE_PLAYER_MENU_MAIN_MENU_14
Definition enums.h:3936
@ BTL_SUBSTATE_PLAYER_MENU_MAIN_MENU_11
Definition enums.h:3933
@ BTL_SUBSTATE_PLAYER_MENU_ITEMS_3
Definition enums.h:3955
@ BTL_SUBSTATE_PLAYER_MENU_DIPPING_6
Definition enums.h:3973
@ BTL_SUBSTATE_PLAYER_MENU_ITEMS_2
Definition enums.h:3954
@ BTL_SUBSTATE_PLAYER_MENU_STAR_SPIRITS_1
Definition enums.h:3960
@ BTL_SUBSTATE_PLAYER_MENU_STAR_SPIRITS_3
Definition enums.h:3962
@ WIN_BTL_STRATS_MENU
Definition enums.h:5246
@ WIN_BTL_STRATS_TITLE
Definition enums.h:5247
void btl_show_variable_battle_message(s32, s32, s32)
void hide_popup_menu(void)
void destroy_popup_menu(void)
void set_actor_anim(s32 actorID, s32 partID, AnimID animID)
Definition 190B20.c:1005
void btl_set_state(s32 battleState)
s32 userIndex[32]
s32 nameMsg[32]
HudScript * disabled
s32 titleNumber
HudScript * ptrIcon[32]
b32 enabled[32]
s32 value[32]
HudScript * enabled
s32 descMsg[32]
s16 cancelTargetMenuSubstate
s16 submenuIcons[24]
s8 menuStatus[4]
-1 = automatically pick the first move, 0 = disabled, 1 = enabled
s16 acceptTargetMenuSubstate
s32 PartnerIDFromMenuIndex[12]
Definition 5B320.c:300

Referenced by btl_state_update_player_menu(), btl_state_update_select_target(), and btl_update().

◆ btl_state_draw_player_menu()

void btl_state_draw_player_menu ( void )

Definition at line 3589 of file btl_states_menus.c.

3589 {
3590 switch (gBattleSubState) {
3593 break;
3621 break;
3627 break;
3630 break;
3633 break;
3636 break;
3639 break;
3640 }
3641}
void btl_main_menu_draw(void)

Referenced by btl_draw_ui().

◆ btl_state_update_partner_menu()

void btl_state_update_partner_menu ( void )

Definition at line 3643 of file btl_states_menus.c.

3643 {
3644 BattleStatus* battleStatus = &gBattleStatus;
3645 PlayerData* playerData = &gPlayerData;
3646 Actor* playerActor = battleStatus->playerActor;
3647 Actor* partnerActor = battleStatus->partnerActor;
3648 PopupMenu* popupMenu = &D_802ACCD0;
3649 s32 entryIdx;
3650 s32 i;
3651 s32 popupIndex;
3652 s32 initialPos;
3653 MoveData* moveData;
3654 PartnerPopupProperties* popupProps;
3655
3657 battleStatus->moveCategory = BTL_MENU_TYPE_INVALID;
3658 battleStatus->selectedMoveID = MOVE_NONE;
3659 battleStatus->curAttackElement = 0;
3660 if (!can_switch_to_partner()) {
3662 } else {
3664 battleStatus->flags1 |= BS_FLAGS1_MENU_OPEN;
3667 if (battleStatus->flags1 & BS_FLAGS1_PLAYER_IN_BACK) {
3669 } else {
3671 partnerActor->state.curPos.x = partnerActor->homePos.x;
3672 partnerActor->state.curPos.z = partnerActor->homePos.z;
3673 partnerActor->state.goalPos.x = playerActor->homePos.x;
3674 partnerActor->state.goalPos.z = playerActor->homePos.z;
3675 partnerActor->state.moveTime = 4;
3676 partnerActor->state.angle = 0.0f;
3677 }
3678 }
3679 }
3681 if (partnerActor->state.moveTime != 0) {
3682 partnerActor->curPos.x += (partnerActor->state.goalPos.x - partnerActor->curPos.x) / partnerActor->state.moveTime;
3683 partnerActor->curPos.z += (partnerActor->state.goalPos.z - partnerActor->curPos.z) / partnerActor->state.moveTime;
3684 playerActor->curPos.x += (partnerActor->state.curPos.x - playerActor->curPos.x) / partnerActor->state.moveTime;
3685 playerActor->curPos.z += (partnerActor->state.curPos.z - playerActor->curPos.z) / partnerActor->state.moveTime;
3686 }
3687 partnerActor->curPos.z += sin_rad(DEG_TO_RAD(partnerActor->state.angle)) * 16.0f;
3688 partnerActor->yaw = clamp_angle(-partnerActor->state.angle);
3689 playerActor->curPos.z -= sin_rad(DEG_TO_RAD(partnerActor->state.angle)) * 16.0f;
3690 playerActor->yaw = clamp_angle(-partnerActor->state.angle);
3691 partnerActor->state.angle += 90.0f;
3692 if (partnerActor->state.moveTime != 0) {
3693 partnerActor->state.moveTime--;
3694 } else {
3696 partnerActor->curPos.x = partnerActor->state.goalPos.x;
3697 partnerActor->curPos.z = partnerActor->state.goalPos.z;
3698 playerActor->curPos.x = partnerActor->state.curPos.x;
3699 playerActor->curPos.z = partnerActor->state.curPos.z;
3700 partnerActor->homePos.x = partnerActor->curPos.x;
3701 partnerActor->homePos.z = partnerActor->curPos.z;
3702 playerActor->homePos.x = playerActor->curPos.x;
3703 playerActor->homePos.z = playerActor->curPos.z;
3705 }
3706 }
3707 switch (gBattleSubState) {
3709 partnerActor->flags |= ACTOR_FLAG_SHOW_STATUS_ICONS;
3710 partnerActor->flags &= ~ACTOR_FLAG_USING_IDLE_ANIM;
3711 playerActor->flags |= ACTOR_FLAG_USING_IDLE_ANIM;
3712 playerActor->flags |= ACTOR_FLAG_SHOW_STATUS_ICONS;
3715 entryIdx = 0;
3716 initialPos = 1;
3717 if (battleStatus->lastPartnerMenuSelection[BTL_MENU_IDX_MAIN] < 0) {
3719 }
3722
3723 // strategies menu category
3725 BattleMenu_OptionEnabled[entryIdx] = TRUE;
3726 battle_menu_isMessageDisabled[entryIdx] = 0;
3729 if (!(battleStatus->enabledMenusFlags & BTL_MENU_ENABLED_STRATEGIES)) {
3730 BattleMenu_OptionEnabled[entryIdx] = FALSE;
3733 }
3734 if (battleStatus->lastPartnerMenuSelection[entryIdx] == BTL_MENU_TYPE_STRATEGIES) {
3735 initialPos = entryIdx;
3736 }
3737 entryIdx++;
3738
3739 // abilities menu category
3742 BattleMenu_OptionEnabled[entryIdx] = TRUE;
3744 if (battleStatus->menuStatus[3] <= 0) {
3746 BattleMenu_OptionEnabled[entryIdx] = FALSE;
3748 }
3749 if (!(battleStatus->enabledMenusFlags & BTL_MENU_ENABLED_ABILITIES)) {
3751 BattleMenu_OptionEnabled[entryIdx] = FALSE;
3753 }
3755 initialPos = entryIdx;
3756 }
3757 entryIdx++;
3758
3759 // focus menu category
3760 if (playerData->maxStarPower != 0 && is_ability_active(ABILITY_GROUP_FOCUS)) {
3762 BattleMenu_OptionEnabled[entryIdx] = TRUE;
3763 battle_menu_isMessageDisabled[entryIdx] = 0;
3766 if (!(battleStatus->enabledMenusFlags & BTL_MENU_ENABLED_PARTNER_FOCUS)) {
3767 BattleMenu_OptionEnabled[entryIdx] = FALSE;
3770 }
3772 initialPos = entryIdx;
3773 }
3774 entryIdx++;
3775 }
3776
3777 BattleMenu_NumOptions = entryIdx;
3778 D_802AD0A8 = 1;
3779 D_802AD0B0 = initialPos;
3780 D_802AD100 = 2 - initialPos;
3781 if (can_switch_to_player()) {
3783 } else {
3785 }
3787 D_802ACC60 = 8;
3790 return;
3795 entryIdx = btl_main_menu_update();
3796
3797 if (BattleMenu_SwapDelay != 0) {
3800 if (can_switch_to_player()) {
3805 } else {
3808 }
3809 break;
3810 }
3811
3812 if (D_802ACC60 != 0) {
3813 D_802ACC60--;
3814 } else if (entryIdx != 0) {
3816 battleStatus->lastPartnerMenuSelection[BTL_MENU_IDX_MAIN] = battleStatus->curPartnerSubmenu = battle_menu_submenuIDs[entryIdx - 1];
3817 if (battleStatus->curPartnerSubmenu == 7) {
3821 } else if (battleStatus->curPartnerSubmenu == 6) {
3825 } else if (battleStatus->curPartnerSubmenu == 8) {
3829 } else if (battleStatus->curPartnerSubmenu == 2) {
3833 } else if (battleStatus->curPartnerSubmenu == 5) {
3837 } else {
3840 func_802A1030();
3842 }
3843 }
3844 break;
3846 entryIdx = btl_main_menu_update();
3847 if ((battleStatus->curButtonsPressed & BUTTON_B) && entryIdx == 0) {
3848 func_802A1078();
3850 return;
3851 }
3852 if (entryIdx != 0) {
3854 battleStatus->selectedMoveID = MOVE_FOCUS;
3855 battleStatus->moveArgument = 0;
3856 battleStatus->curTargetListFlags = gMoveTable[MOVE_FOCUS].flags;
3858 return;
3859 }
3860 break;
3862 if (btl_main_menu_update() != 0) {
3863 D_802ACC60 = 8;
3866 }
3867 break;
3869 func_802A1078();
3871 break;
3874 break;
3876 if (can_switch_to_player() == 0) {
3878 } else {
3880 }
3881 ShowingErrorMessage = TRUE;
3883 break;
3885 if (btl_is_popup_displayed()) {
3886 break;
3887 }
3888 D_802ACC60 = 0;
3889 ShowingErrorMessage = FALSE;
3892 break;
3894 for (i = 0; i < battleStatus->submenuMoveCount; i++) {
3895 moveData = &gMoveTable[battleStatus->submenuMoves[i]];
3896
3898 if (battleStatus->submenuStatus[i] == 0) {
3900 }
3901 if (battleStatus->submenuStatus[i] == -1) {
3902 battleStatus->submenuStatus[i] = 0;
3904 }
3905 if (battleStatus->submenuStatus[i] == -2) {
3906 battleStatus->submenuStatus[i] = 0;
3908 }
3910 if (battleStatus->submenuStatus[i] == 0) {
3912 }
3913 BattleMenu_Moves_OptionIndices[i] = battleStatus->submenuMoves[i];
3914 BattleMenu_Moves_OptionEnabled[i] = battleStatus->submenuStatus[i];
3915 battle_menu_moveOptionNames[i] = moveData->nameMsg;
3920
3926 }
3930 }
3931 }
3932 if (battleStatus->lastPartnerMenuSelection[BTL_MENU_IDX_ABILITY] < 0) {
3934 }
3937 initialPos = battleStatus->lastPartnerMenuSelection[BTL_MENU_IDX_ABILITY];
3938 D_802AD4A8 = initialPos;
3939 func_802A2684();
3941 break;
3943 entryIdx = btl_submenu_moves_update();
3944 if (entryIdx == -1) {
3946 } else if (entryIdx != 0) {
3947 if (entryIdx == 255) {
3948 func_802A1050();
3949 D_802ACC60 = 8;
3954 } else {
3955 battleStatus->unk_4B = entryIdx - 1;
3956 func_802A27D0();
3957 func_802A1030();
3959 }
3960 }
3961 break;
3963 entryIdx = btl_submenu_moves_update();
3964 if ((battleStatus->curButtonsPressed & BUTTON_B) && entryIdx == 0) {
3965 func_802A2AB8();
3966 func_802A1098();
3968 } else if (btl_main_menu_update() != 0) {
3969 battleStatus->moveCategory = BTL_MENU_TYPE_ABILITY;
3970 battleStatus->selectedMoveID = BattleMenu_Moves_OptionIndices[battleStatus->unk_4B];
3971 battleStatus->curTargetListFlags = gMoveTable[battleStatus->selectedMoveID].flags;
3976 }
3977 break;
3980 if (btl_main_menu_update() != 0) {
3982 }
3983 break;
3985 func_802A2AB8();
3986 func_802A1098();
3988 break;
3990 func_802A27E4();
3992 break;
3994 if (btl_submenu_moves_update() != -1) {
3996 }
3997 break;
3999 popupIndex = 0;
4000 for (i = 0; i < ARRAY_COUNT(playerData->invItems); i++) {
4001 ItemData* item;
4002 HudScript** hudScript;
4003 if (playerData->invItems[i] == ITEM_NONE) {
4004 continue;
4005 }
4006 item = &gItemTable[playerData->invItems[i]];
4007 hudScript = &gItemHudScripts[item->hudElemID].enabled;
4008
4009 if (!(item->typeFlags & ITEM_TYPE_FLAG_BATTLE_USABLE)) {
4010 continue;
4011 }
4012 popupMenu->ptrIcon[popupIndex] = hudScript[0];
4013 popupMenu->userIndex[popupIndex] = playerData->invItems[i];
4014 popupMenu->enabled[popupIndex] = TRUE;
4015 popupMenu->nameMsg[popupIndex] = item->nameMsg;
4016 popupMenu->descMsg[popupIndex] = item->shortDescMsg;
4017 popupIndex++;
4018 }
4019 if (battleStatus->lastPartnerMenuSelection[BTL_MENU_IDX_PARTNER_ITEM] < 0) {
4021 }
4022 popupMenu->popupType = POPUP_MENU_USE_ITEM;
4023 popupMenu->numEntries = popupIndex;
4024 popupMenu->dipMode = 0;
4025 popupMenu->titleNumber = 0;
4026 initialPos = battleStatus->lastPartnerMenuSelection[BTL_MENU_IDX_PARTNER_ITEM];
4027 popupMenu->initialPos = initialPos;
4028 create_battle_popup_menu(popupMenu);
4029 func_800F52BC();
4031 break;
4033 if (popupMenu->result != POPUP_RESULT_CHOOSING) {
4034 if (popupMenu->result == POPUP_RESULT_CANCEL) {
4035 func_802A1050();
4036 D_802ACC60 = 8;
4041 } else {
4044 battleStatus->unk_1AA = popupMenu->userIndex[popupMenu->result - 1];
4045 battleStatus->moveCategory = BTL_MENU_TYPE_ITEMS;
4046 battleStatus->moveArgument = battleStatus->unk_1AA;
4048 battleStatus->curAttackElement = 0;
4049 battleStatus->lastPartnerMenuSelection[BTL_MENU_IDX_PARTNER_ITEM] = popupMenu->result - 1;
4051 func_802A1030();
4053 }
4054 }
4055 break;
4057 if ((battleStatus->curButtonsPressed & BUTTON_B) && popupMenu->result == POPUP_RESULT_CHOOSING) {
4058 func_800F16CC();
4059 func_802A1098();
4061 } else if (btl_main_menu_update() != 0) {
4063 }
4064 break;
4066 if (btl_main_menu_update() != 0) {
4068 }
4069 break;
4071 func_800F16CC();
4072 func_802A1098();
4074 break;
4078 break;
4080 popupIndex = 0;
4081 for (i = 1; i < ARRAY_COUNT(PartnerIDFromMenuIndex); i++) {
4082 s32 partnerId = PartnerIDFromMenuIndex[i];
4083 if (playerData->partners[partnerId].enabled) {
4084 popupProps = &gPartnerPopupProperties[partnerId];
4085 popupMenu->ptrIcon[popupIndex] = battle_menu_PartnerHudScripts[partnerId];
4086 popupMenu->userIndex[popupIndex] = partnerId;
4087 popupMenu->enabled[popupIndex] = 1;
4088 popupMenu->nameMsg[popupIndex] = popupProps->nameMsg;
4089 popupMenu->descMsg[popupIndex] = popupProps->battleDescMsg;
4090 popupMenu->value[popupIndex] = playerData->partners[partnerId].level;
4091 if (playerData->curPartner == partnerId) {
4092 popupMenu->enabled[popupIndex] = 0;
4093 popupMenu->ptrIcon[popupIndex] = battle_menu_DisabledPartnerHudScripts[partnerId];
4094 }
4095 popupIndex++;
4096 }
4097 }
4098 if (battleStatus->lastPartnerMenuSelection[BTL_MENU_IDX_PARTNER] < 0) {
4100 }
4102 popupMenu->numEntries = popupIndex;
4103 popupMenu->initialPos = MenuIndexFromPartnerID[playerData->curPartner] - 1;
4104 popupMenu->dipMode = 0;
4105 popupMenu->titleNumber = 0;
4106 create_battle_popup_menu(popupMenu);
4107 func_800F52BC();
4109 break;
4111 if (popupMenu->result == POPUP_RESULT_INVALID) {
4113 } else if (popupMenu->result != POPUP_RESULT_CHOOSING) {
4114 if (popupMenu->result == POPUP_RESULT_CANCEL) {
4115 func_802A1050();
4116 D_802ACC60 = 8;
4121 } else {
4124 battleStatus->unk_1AC = popupMenu->userIndex[popupMenu->result - 1];
4126 battleStatus->selectedMoveID = MOVE_UNUSED_37;
4127 battleStatus->curTargetListFlags = TARGET_FLAG_2;
4128 battleStatus->moveArgument = battleStatus->unk_1AC;
4129 battleStatus->lastPartnerMenuSelection[BTL_MENU_IDX_PARTNER] = popupMenu->result - 1;
4131 func_802A1030();
4133 }
4134 }
4135 break;
4137 if ((battleStatus->curButtonsPressed & BUTTON_B) && (popupMenu->result == POPUP_RESULT_CHOOSING)) {
4138 func_800F16CC();
4139 func_802A1098();
4141 } else if (btl_main_menu_update() != 0) {
4145 }
4146 break;
4148 if (btl_main_menu_update() != 0) {
4150 }
4151 break;
4153 func_800F16CC();
4154 func_802A1098();
4156 break;
4160 break;
4162 if (popupMenu->result != POPUP_RESULT_INVALID) {
4164 }
4165 break;
4167 entryIdx = 1;
4168 battleStatus->submenuMoves[0] = MOVE_FOCUS;
4169 battleStatus->submenuMoveCount = entryIdx;
4170 battleStatus->submenuIcons[0] = ITEM_PARTNER_ATTACK;
4171 battleStatus->submenuStatus[0] = 1;
4172 for (i = 0; i < battleStatus->submenuMoveCount; i++) {
4173 moveData = &gMoveTable[battleStatus->submenuMoves[i]];
4174 battle_menu_moveOptionIconScripts[i] = battle_menu_StarPowerMovesHudScripts[2 * STAR_POWER_INDEX(battleStatus->submenuMoves[i]) + 0];
4175 if (battleStatus->submenuStatus[i] == 0) {
4176 battle_menu_moveOptionIconScripts[i] = battle_menu_StarPowerMovesHudScripts[2 * STAR_POWER_INDEX(battleStatus->submenuMoves[i]) + 1];
4177 }
4182 BattleMenu_Moves_OptionEnabled[i] = battleStatus->submenuStatus[i];
4183 battle_menu_moveOptionNames[i] = moveData->nameMsg;
4187 }
4188 if (battleStatus->lastPartnerMenuSelection[BTL_MENU_IDX_STAR_POWER] < 0) {
4190 }
4193 initialPos = battleStatus->lastPartnerMenuSelection[BTL_MENU_IDX_STAR_POWER];
4194 D_802AD4A8 = initialPos;
4195 func_802A2684();
4197 break;
4199 entryIdx = btl_submenu_moves_update();
4200 if (entryIdx != 0) {
4201 if (entryIdx == 255) {
4202 func_802A1050();
4203 D_802ACC60 = 8;
4208 } else {
4209 battleStatus->unk_4B = BattleMenu_Moves_OptionIndices[entryIdx - 1];
4210 func_802A27D0();
4211 func_802A1030();
4213 }
4214 }
4215 break;
4217 entryIdx = btl_submenu_moves_update();
4218 if ((battleStatus->curButtonsPressed & BUTTON_B) && (entryIdx == 0)) {
4219 func_802A2AB8();
4220 func_802A1098();
4222 } else if (btl_main_menu_update() != 0) {
4226 battleStatus->selectedMoveID = battleStatus->submenuMoves[battleStatus->unk_4B];
4227 battleStatus->curTargetListFlags = gMoveTable[battleStatus->submenuMoves[battleStatus->unk_4B]].flags;
4228 battleStatus->moveArgument = battleStatus->unk_4B;
4231 }
4232 break;
4235 if (btl_main_menu_update() != 0) {
4237 }
4238 break;
4240 func_802A2AB8();
4241 func_802A1098();
4243 break;
4245 func_802A27E4();
4247 break;
4249 popupIndex = 0;
4251
4252 // add 'Change Member' command
4253 if (battleStatus->changePartnerAllowed >= 0) {
4256 D_802AD640[popupIndex] = battle_menu_PartnerHudScripts[playerData->curPartner];
4257 D_802AD690[popupIndex] = 1;
4258 D_802AD6C0[popupIndex] = MSG_Menus_Action_ChangePartner;
4259 if (battleStatus->changePartnerAllowed <= 0) {
4261 D_802AD690[popupIndex] = 0;
4262 D_802AD6A8[popupIndex] = 0;
4263 }
4264 popupIndex++;
4265 }
4266
4267 // add 'Do Nothing' command
4270 D_802AD690[popupIndex] = 1;
4272 D_802AD6C0[popupIndex] = MSG_Menus_Action_DoNothing;
4273 popupIndex++;
4274
4275 if (battleStatus->lastPartnerMenuSelection[BTL_MENU_IDX_STRATEGY] < 0) {
4277 }
4278 D_802AD66C = popupIndex;
4279 initialPos = battleStatus->lastPartnerMenuSelection[BTL_MENU_IDX_STRATEGY];
4280 StratsMenuLastPos = initialPos;
4281 func_802A45D8();
4283 break;
4285 entryIdx = btl_update_strats_menu();
4286 if (entryIdx == 0) {
4287 } else if (entryIdx == 255) {
4288 func_802A1050();
4289 D_802ACC60 = 8;
4294 } else {
4295 battleStatus->curPartnerSubmenu = D_802AD678[entryIdx - 1];
4296 battleStatus->lastPartnerMenuSelection[BTL_MENU_IDX_STRATEGY] = entryIdx - 1;
4297 if (battleStatus->curPartnerSubmenu == 5) { // change partner
4301 } else {
4302 func_802A4718();
4303 func_802A1030();
4305 }
4306 }
4307 break;
4309 entryIdx = btl_update_strats_menu();
4310 if ((battleStatus->curButtonsPressed & BUTTON_B) && entryIdx == 0) {
4311 func_802A48FC();
4312 func_802A1098();
4314 } else if (btl_main_menu_update() != 0) {
4317 entryIdx = battleStatus->curPartnerSubmenu;
4318 switch (entryIdx) {
4319 case 9:
4323 break;
4324 case 3:
4327 battleStatus->moveCategory = entryIdx;
4328 battleStatus->selectedMoveID = MOVE_UNUSED_39;
4330 break;
4331 case 10:
4335 break;
4336 }
4337 }
4338 break;
4341 if (btl_main_menu_update() != 0) {
4342 D_802ACC60 = 8;
4345 }
4346 break;
4348 func_802A48FC();
4349 func_802A1098();
4351 break;
4353 func_802A472C();
4355 break;
4357 popupIndex = 0;
4358 for (i = 1; i < ARRAY_COUNT(PartnerIDFromMenuIndex); i++) {
4359 s32 partnerId = PartnerIDFromMenuIndex[i];
4360 if (playerData->partners[partnerId].enabled) {
4361 popupProps = &gPartnerPopupProperties[partnerId];
4362 popupMenu->ptrIcon[popupIndex] = battle_menu_PartnerHudScripts[partnerId];
4363 popupMenu->userIndex[popupIndex] = partnerId;
4364 popupMenu->enabled[popupIndex] = 1;
4365 popupMenu->nameMsg[popupIndex] = popupProps->nameMsg;
4366 popupMenu->descMsg[popupIndex] = popupProps->battleDescMsg;
4367 popupMenu->value[popupIndex] = playerData->partners[partnerId].level;
4368 if (playerData->curPartner == partnerId) {
4369 popupMenu->enabled[popupIndex] = 0;
4370 popupMenu->ptrIcon[popupIndex] = battle_menu_DisabledPartnerHudScripts[partnerId];
4371 }
4372 popupIndex++;
4373 }
4374 }
4375 if (battleStatus->lastPartnerMenuSelection[BTL_MENU_IDX_PARTNER] < 0) {
4377 }
4379 popupMenu->numEntries = popupIndex;
4380 popupMenu->initialPos = MenuIndexFromPartnerID[playerData->curPartner] - 1;
4381 popupMenu->dipMode = 0;
4382 popupMenu->titleNumber = 0;
4383 create_battle_popup_menu(popupMenu);
4384 func_800F52BC();
4386 break;
4388 if (popupMenu->result == POPUP_RESULT_INVALID) {
4390 } else if (popupMenu->result != POPUP_RESULT_CHOOSING) {
4391 if (popupMenu->result == POPUP_RESULT_CANCEL) {
4392 func_802A47E0();
4396 } else {
4399 battleStatus->unk_1AC = popupMenu->userIndex[popupMenu->result - 1];
4401 battleStatus->selectedMoveID = MOVE_UNUSED_37;
4402 battleStatus->curTargetListFlags = TARGET_FLAG_2;
4403 battleStatus->moveArgument = battleStatus->unk_1AC;
4404 battleStatus->lastPartnerMenuSelection[BTL_MENU_IDX_PARTNER] = popupMenu->result - 1;
4406 func_802A4718();
4407 func_802A1030();
4409 }
4410 }
4411 break;
4413 if ((battleStatus->curButtonsPressed & BUTTON_B) && popupMenu->result == POPUP_RESULT_CHOOSING) {
4414 func_800F16CC();
4415 func_802A4A10();
4416 func_802A1098();
4418 } else {
4420 if (btl_main_menu_update() != 0) {
4424 }
4425 }
4426 break;
4429 if (btl_main_menu_update() != 0) {
4431 }
4432 break;
4434 func_800F16CC();
4435 func_802A4A10();
4436 func_802A1098();
4438 break;
4441 func_802A472C();
4443 break;
4447 if (popupMenu->result != POPUP_RESULT_INVALID) {
4451 }
4452 break;
4453 }
4454}
void btl_state_update_partner_menu(void)
AnimID BattleMenu_PartnerThinkAnims[]
HudScript * battle_menu_PartnerMoveHudScripts[10][10]
void btl_init_menu_partner(void)
Definition 190B20.c:857
AnimID BattleMenu_PartnerIdleAnims[]
@ BTL_MENU_TYPE_ABILITY
Definition enums.h:4232
@ BTL_MENU_TYPE_PARTNER_FOCUS
Definition enums.h:4237
@ BTL_SUBSTATE_PARTNER_MENU_UNUSED_CHANGE_PARTNER_5
Definition enums.h:4034
@ BTL_SUBSTATE_PARTNER_MENU_MAIN_MENU_1
Definition enums.h:3992
@ BTL_SUBSTATE_PARTNER_MENU_MAIN_MENU_2
Definition enums.h:3993
@ BTL_SUBSTATE_PARTNER_MENU_MAIN_SHOW_CANT_SWAP
Definition enums.h:3998
@ BTL_SUBSTATE_PARTNER_MENU_STRATEGIES_2
Definition enums.h:4046
@ BTL_SUBSTATE_PARTNER_MENU_ABILITIES_6
Definition enums.h:4006
@ BTL_SUBSTATE_PARTNER_MENU_ITEMS_3
Definition enums.h:4025
@ BTL_SUBSTATE_PARTNER_MENU_NONE
Definition enums.h:3990
@ BTL_SUBSTATE_PARTNER_MENU_ABILITIES_2
Definition enums.h:4002
@ BTL_SUBSTATE_PARTNER_MENU_STRATEGIES_3
Definition enums.h:4047
@ BTL_SUBSTATE_PARTNER_MENU_CHANGE_PARTNER_3
Definition enums.h:4017
@ BTL_SUBSTATE_PARTNER_MENU_MAIN_AWAIT_CANT_SWAP
Definition enums.h:3999
@ BTL_SUBSTATE_PARTNER_MENU_STRATEGIES_1
Definition enums.h:4045
@ BTL_SUBSTATE_PARTNER_MENU_FOCUS_4
Definition enums.h:4041
@ BTL_SUBSTATE_PARTNER_MENU_FOCUS_5
Definition enums.h:4042
@ BTL_SUBSTATE_PARTNER_MENU_MAIN_MENU_3
Definition enums.h:3994
@ BTL_SUBSTATE_PARTNER_MENU_FOCUS_3
Definition enums.h:4040
@ BTL_SUBSTATE_PARTNER_MENU_CHANGE_PARTNER_7
Definition enums.h:4021
@ BTL_SUBSTATE_PARTNER_MENU_ITEMS_2
Definition enums.h:4024
@ BTL_SUBSTATE_PARTNER_MENU_ABILITIES_1
Definition enums.h:4001
@ BTL_SUBSTATE_PARTNER_MENU_ITEMS_4
Definition enums.h:4026
@ BTL_SUBSTATE_PARTNER_MENU_CHANGE_PARTNER_5
Definition enums.h:4019
@ BTL_SUBSTATE_PARTNER_MENU_CHANGE_PARTNER_4
Definition enums.h:4018
@ BTL_SUBSTATE_PARTNER_MENU_FOCUS_2
Definition enums.h:4039
@ BTL_SUBSTATE_PARTNER_MENU_CHANGE_PARTNER_2
Definition enums.h:4016
@ BTL_SUBSTATE_PARTNER_MENU_CHANGE_PARTNER_1
Definition enums.h:4015
@ BTL_SUBSTATE_PARTNER_MENU_UNUSED_CHANGE_PARTNER_6
Definition enums.h:4035
@ BTL_SUBSTATE_PARTNER_MENU_ABILITIES_4
Definition enums.h:4004
@ BTL_SUBSTATE_PARTNER_MENU_UNUSED_CHANGE_PARTNER_7
Definition enums.h:4036
@ BTL_SUBSTATE_PARTNER_MENU_FOCUS_6
Definition enums.h:4043
@ BTL_SUBSTATE_PARTNER_MENU_ABILITIES_3
Definition enums.h:4003
@ BTL_SUBSTATE_PARTNER_MENU_UNUSED_CHANGE_PARTNER_4
Definition enums.h:4033
@ BTL_SUBSTATE_PARTNER_MENU_MAIN_MENU_4
Definition enums.h:3995
@ BTL_SUBSTATE_PARTNER_MENU_MAIN_MENU_6
Definition enums.h:3997
@ BTL_SUBSTATE_PARTNER_MENU_CHANGE_PARTNER_6
Definition enums.h:4020
@ BTL_SUBSTATE_PARTNER_MENU_UNUSED_CHANGE_PARTNER_2
Definition enums.h:4031
@ BTL_SUBSTATE_PARTNER_MENU_12D
Definition enums.h:4052
@ BTL_SUBSTATE_PARTNER_MENU_STRATEGIES_6
Definition enums.h:4050
@ BTL_SUBSTATE_PARTNER_MENU_FOCUS_1
Definition enums.h:4038
@ BTL_SUBSTATE_PARTNER_MENU_UNUSED_CHANGE_PARTNER_3
Definition enums.h:4032
@ BTL_SUBSTATE_PARTNER_MENU_INIT_MENU
Definition enums.h:4053
@ BTL_SUBSTATE_PARTNER_MENU_ABILITIES_5
Definition enums.h:4005
@ BTL_SUBSTATE_PARTNER_MENU_STRATEGIES_5
Definition enums.h:4049
@ BTL_SUBSTATE_PARTNER_MENU_STRATEGIES_4
Definition enums.h:4048
@ BTL_SUBSTATE_PARTNER_MENU_MAIN_MENU_5
Definition enums.h:3996
@ BTL_SUBSTATE_PARTNER_MENU_ITEMS_6
Definition enums.h:4028
@ BTL_SUBSTATE_PARTNER_MENU_ABILITIES_7
Definition enums.h:4007
@ BTL_SUBSTATE_PARTNER_MENU_ITEMS_1
Definition enums.h:4023
@ BTL_SUBSTATE_PARTNER_MENU_UNUSED_CHANGE_PARTNER_1
Definition enums.h:4030
@ BTL_SUBSTATE_PARTNER_MENU_ITEMS_5
Definition enums.h:4027
@ ABILITY_GROUP_FOCUS
Definition enums.h:489
@ BTL_MENU_ENABLED_PARTNER_FOCUS
Definition enums.h:4247
@ BTL_MENU_ENABLED_ABILITIES
Definition enums.h:4244
@ BTL_MENU_IDX_PARTNER_ITEM
Definition enums.h:4221
s32 HudScript[]
Definition hud_element.h:9

Referenced by btl_state_update_partner_menu(), btl_state_update_select_target(), and btl_update().

◆ btl_state_draw_partner_menu()

void btl_state_draw_partner_menu ( void )

Definition at line 4456 of file btl_states_menus.c.

4456 {
4457 switch (gBattleSubState) {
4460 break;
4497 break;
4500 break;
4503 break;
4506 break;
4509 break;
4510 }
4511}
@ BTL_SUBSTATE_PARTNER_MENU_UNKNOWN_5
Definition enums.h:4013
@ BTL_SUBSTATE_PARTNER_MENU_UNKNOWN_1
Definition enums.h:4009
@ BTL_SUBSTATE_PARTNER_MENU_UNKNOWN_4
Definition enums.h:4012
@ BTL_SUBSTATE_PARTNER_MENU_UNKNOWN_3
Definition enums.h:4011
@ BTL_SUBSTATE_PARTNER_MENU_UNKNOWN_2
Definition enums.h:4010

Referenced by btl_draw_ui().

◆ btl_state_update_peach_menu()

void btl_state_update_peach_menu ( void )

Definition at line 4520 of file btl_states_menus.c.

4520 {
4521 BattleStatus* battleStatus = &gBattleStatus;
4522 Actor* player = battleStatus->playerActor;
4523 Actor* partner = battleStatus->partnerActor;
4524 s32 selectedOption;
4525 s32 initialPos;
4526 s32 entryIdx;
4527
4528 switch (gBattleSubState) {
4531 btl_cam_move(10);
4534 break;
4535 }
4536 player->state.curPos.x = player->homePos.x;
4537 player->state.curPos.z = player->homePos.z;
4539 player->state.goalPos.x = partner->homePos.x;
4540 player->state.goalPos.z = partner->homePos.z;
4541 player->state.moveTime = 4;
4542 player->state.angle = 0.0f;
4543 break;
4545 if (player->state.moveTime != 0) {
4546 player->curPos.x += (player->state.goalPos.x - player->curPos.x) / player->state.moveTime;
4547 player->curPos.z += (player->state.goalPos.z - player->curPos.z) / player->state.moveTime;
4548 partner->curPos.x += (player->state.curPos.x - partner->curPos.x) / player->state.moveTime;
4549 partner->curPos.z += (player->state.curPos.z - partner->curPos.z) / player->state.moveTime;
4550 }
4551
4552 player->curPos.z -= sin_rad(DEG_TO_RAD(player->state.angle)) * 16.0f;
4553 player->yaw = clamp_angle(-player->state.angle);
4554 partner->curPos.z += sin_rad(DEG_TO_RAD(player->state.angle)) * 16.0f;
4555 partner->yaw = clamp_angle(-player->state.angle);
4556 player->state.angle += 90.0f;
4557
4558 if (player->state.moveTime != 0) {
4559 player->state.moveTime--;
4560 break;
4561 }
4562
4563 player->curPos.x = player->state.goalPos.x;
4564 player->curPos.z = player->state.goalPos.z;
4565 partner->curPos.x = player->state.curPos.x;
4566 partner->curPos.z = player->state.curPos.z;
4567 player->homePos.x = player->curPos.x;
4568 player->homePos.z = player->curPos.z;
4569 partner->homePos.x = partner->curPos.x;
4570 partner->homePos.z = partner->curPos.z;
4571 gBattleStatus.flags1 &= ~BS_FLAGS1_PLAYER_IN_BACK;
4574 player->flags &= ~ACTOR_FLAG_USING_IDLE_ANIM;
4576 if (partner != NULL) {
4579 }
4580
4581 entryIdx = 0;
4582 battleStatus->selectedMoveID = MOVE_NONE;
4584 BattleMenu_OptionEnabled[entryIdx] = TRUE;
4585 battle_menu_isMessageDisabled[entryIdx] = 0;
4587 BattleMenu_TitleMessages[entryIdx] = D_802AB728[entryIdx];
4588 if (!(battleStatus->enabledMenusFlags & BTL_MENU_ENABLED_STAR_POWERS)) {
4589 BattleMenu_OptionEnabled[entryIdx] = FALSE;
4592 }
4593
4594 initialPos = 0;
4595 entryIdx++;
4596
4599 } else {
4601 }
4602 BattleMenu_NumOptions = entryIdx;
4603 D_802AD0A8 = 0;
4604 D_802AD0B0 = initialPos;
4605 D_802AD100 = 2 - initialPos;
4606
4608 D_802ACC60 = 8;
4610 break;
4612 set_actor_anim(ACTOR_PLAYER, 0, ANIM_Peach2_Delighted);
4613 selectedOption = btl_main_menu_update();
4614 if (D_802ACC60 != 0) {
4615 D_802ACC60--;
4616 break;
4617 }
4618 if (selectedOption != 0) {
4619 set_actor_anim(ACTOR_PLAYER, 0, ANIM_Peach1_Walk);
4620 battleStatus->curSubmenu = battle_menu_submenuIDs[selectedOption - 1];
4621 func_802A1030();
4622 D_802ACC60 = 8;
4625 }
4626 break;
4628 if (btl_main_menu_update() != 0) {
4631 battleStatus->curTargetListFlags = gMoveTable[MOVE_PEACH_FOCUS].flags;
4633 battleStatus->selectedMoveID = MOVE_PEACH_FOCUS;
4634 battleStatus->moveArgument = STAR_POWER_INDEX(MOVE_PEACH_FOCUS);
4636 }
4637 break;
4639 func_802A1050();
4643 break;
4646 break;
4649 ShowingErrorMessage = TRUE;
4651 break;
4653 if (btl_is_popup_displayed()) {
4654 break;
4655 }
4656 ShowingErrorMessage = FALSE;
4657 D_802ACC60 = 0;
4659 break;
4660 }
4661}
s32 btl_menu_show_switch_to_twink(void)
IconHudScriptPair battle_menu_PeachStarPowerHudScripts
s32 D_802AB728[]
void btl_state_update_peach_menu(void)
@ BTL_SUBSTATE_PEACH_MENU_TARGET_CHOSEN
Definition enums.h:3757
@ BTL_SUBSTATE_PEACH_MENU_TARGET_CANCEL
Definition enums.h:3756
@ BTL_SUBSTATE_PEACH_MENU_CHOOSE_CATEGORY
Definition enums.h:3753
@ BTL_SUBSTATE_PEACH_CREATE_MAIN_MENU
Definition enums.h:3763
@ BTL_SUBSTATE_PEACH_MENU_SHOW_CANT_SWITCH
Definition enums.h:3760
@ BTL_SUBSTATE_PEACH_MENU_PERFORM_SWAP
Definition enums.h:3762
@ BTL_SUBSTATE_PEACH_MENU_AWAIT_CANT_SWITCH_POPUP
Definition enums.h:3761
@ BTL_SUBSTATE_PEACH_MENU_CHOOSE_TARGET
Definition enums.h:3754
@ BTL_SUBSTATE_PEACH_MENU_INIT
Definition enums.h:3752

Referenced by btl_state_update_peach_menu(), btl_state_update_select_target(), and btl_update().

◆ btl_state_draw_peach_menu()

void btl_state_draw_peach_menu ( void )

Definition at line 4663 of file btl_states_menus.c.

4663 {
4664 switch (gBattleSubState) {
4667 break;
4670 break;
4673 break;
4676 break;
4679 break;
4684 break;
4685 }
4686}
@ BTL_SUBSTATE_PEACH_MENU_UNUSED_6
Definition enums.h:3758
@ BTL_SUBSTATE_PEACH_MENU_UNUSED_7
Definition enums.h:3759
@ BTL_SUBSTATE_PEACH_MENU_UNUSED_3
Definition enums.h:3755

Referenced by btl_draw_ui().

◆ btl_state_update_twink_menu()

void btl_state_update_twink_menu ( void )

Definition at line 4695 of file btl_states_menus.c.

4695 {
4696 BattleStatus* battleStatus = &gBattleStatus;
4697 Actor* player = battleStatus->playerActor;
4698 Actor* partner = battleStatus->partnerActor;
4699 s32 s1;
4700 s32 selection;
4701 s32 var_v0_2;
4702 s32 shouldSkipTurn;
4703 s32 initialPos;
4704 s32 entryIdx;
4705
4706 switch (gBattleSubState) {
4708 shouldSkipTurn = FALSE;
4709 if (player->debuff == STATUS_KEY_SLEEP) {
4710 shouldSkipTurn = TRUE;
4711 }
4712 if (player->debuff == STATUS_KEY_FEAR) {
4713 shouldSkipTurn = TRUE;
4714 }
4715 if (player->debuff == STATUS_KEY_DIZZY) {
4716 shouldSkipTurn = TRUE;
4717 }
4718 if (player->debuff == STATUS_KEY_PARALYZE) {
4719 shouldSkipTurn = TRUE;
4720 }
4721 if (player->debuff == STATUS_KEY_FROZEN) {
4722 shouldSkipTurn = TRUE;
4723 }
4724 if (player->debuff == STATUS_KEY_STOP) {
4725 shouldSkipTurn = TRUE;
4726 }
4727 if (player->stoneStatus == STATUS_KEY_STONE) {
4728 shouldSkipTurn = TRUE;
4729 }
4730 if (player->koStatus == STATUS_KEY_DAZE) {
4731 shouldSkipTurn = TRUE;
4732 }
4733
4734 if (shouldSkipTurn) {
4736 break;
4737 }
4738
4740 btl_cam_move(10);
4742 player->state.curPos.x = player->homePos.x;
4743 player->state.curPos.z = player->homePos.z;
4744 player->state.goalPos.x = partner->homePos.x;
4745 player->state.goalPos.z = partner->homePos.z;
4747 player->state.moveTime = 4;
4748 player->state.angle = 0.0f;
4749 break;
4750 }
4752 break;
4754 if (player->state.moveTime != 0) {
4755 player->curPos.x += (player->state.goalPos.x - player->curPos.x) / player->state.moveTime;
4756 player->curPos.z += (player->state.goalPos.z - player->curPos.z) / player->state.moveTime;
4757 partner->curPos.x += (player->state.curPos.x - partner->curPos.x) / player->state.moveTime;
4758 partner->curPos.z += (player->state.curPos.z - partner->curPos.z) / player->state.moveTime;
4759 }
4760 player->curPos.z += sin_rad(DEG_TO_RAD(player->state.angle)) * 16.0f;
4761 player->yaw = clamp_angle(-player->state.angle);
4762 partner->curPos.z -= sin_rad(DEG_TO_RAD(player->state.angle)) * 16.0f;
4763 partner->yaw = clamp_angle(-player->state.angle);
4764 player->state.angle += 90.0f;
4765 if (player->state.moveTime != 0) {
4766 player->state.moveTime--;
4767 break;
4768 }
4769 player->curPos.x = player->state.goalPos.x;
4770 player->curPos.z = player->state.goalPos.z;
4771 partner->curPos.x = player->state.curPos.x;
4772 partner->curPos.z = player->state.curPos.z;
4773 player->homePos.x = player->curPos.x;
4774 player->homePos.z = player->curPos.z;
4775 partner->homePos.x = partner->curPos.x;
4776 partner->homePos.z = partner->curPos.z;
4780 player->flags &= ~ACTOR_FLAG_USING_IDLE_ANIM;
4782 if (partner != NULL) {
4785 }
4786
4787 entryIdx = 0;
4788 battleStatus->selectedMoveID = MOVE_NONE;
4790 BattleMenu_OptionEnabled[entryIdx] = TRUE;
4791 battle_menu_isMessageDisabled[entryIdx] = 0;
4793 BattleMenu_TitleMessages[entryIdx] = D_802AB734[entryIdx];
4794 if (!(battleStatus->enabledMenusFlags & BTL_MENU_ENABLED_STAR_POWERS)) {
4795 BattleMenu_OptionEnabled[entryIdx] = FALSE;
4798 }
4799
4800 initialPos = 0;
4801 entryIdx++;
4802
4805 } else {
4807 }
4808 BattleMenu_NumOptions = entryIdx;
4809 D_802AD0A8 = 0;
4810 D_802AD0B0 = initialPos;
4811 D_802AD100 = 2 - initialPos;
4812
4814 D_802ACC60 = 8;
4816 break;
4818 set_actor_anim(ACTOR_PARTNER, 0, ANIM_Twink_Idle);
4819 selection = btl_main_menu_update();
4820 if (D_802ACC60 != 0) {
4821 D_802ACC60--;
4822 break;
4823 }
4824 if (selection != 0) {
4825 set_actor_anim(ACTOR_PARTNER, 0, ANIM_Twink_Angry);
4826 battleStatus->curSubmenu = battle_menu_submenuIDs[selection - 1];
4827 func_802A1030();
4828 D_802ACC60 = 8;
4831 }
4832 break;
4834 if (btl_main_menu_update() != 0) {
4838 battleStatus->selectedMoveID = MOVE_TWINK_DASH;
4839 battleStatus->moveArgument = 0;
4840 battleStatus->curTargetListFlags = gMoveTable[MOVE_TWINK_DASH].flags;
4842 }
4843 break;
4845 func_802A1050();
4849 break;
4852 break;
4855 ShowingErrorMessage = TRUE;
4857 break;
4859 if (btl_is_popup_displayed()) {
4860 break;
4861 }
4862 ShowingErrorMessage = FALSE;
4863 D_802ACC60 = 0;
4865 break;
4866 }
4867}
IconHudScriptPair battle_menu_TwinkStarPowerHudScripts
s32 btl_menu_show_switch_to_peach(void)
s32 D_802AB734[]
void btl_state_update_twink_menu(void)
@ BTL_SUBSTATE_TWINK_MENU_CREATE_MAIN_MENU
Definition enums.h:3777
@ BTL_SUBSTATE_TWINK_MENU_AWAIT_CANT_SWITCH_POPUP
Definition enums.h:3775
@ BTL_SUBSTATE_TWINK_MENU_TARGET_CANCEL
Definition enums.h:3770
@ BTL_SUBSTATE_TWINK_MENU_INIT
Definition enums.h:3766
@ BTL_SUBSTATE_TWINK_MENU_PERFORM_SWAP
Definition enums.h:3776
@ BTL_SUBSTATE_TWINK_MENU_CHOOSE_TARGET
Definition enums.h:3768
@ BTL_SUBSTATE_TWINK_MENU_TARGET_CHOSEN
Definition enums.h:3771
@ BTL_SUBSTATE_TWINK_MENU_CHOOSE_CATEGORY
Definition enums.h:3767
@ BTL_SUBSTATE_TWINK_MENU_SHOW_CANT_SWITCH
Definition enums.h:3774

Referenced by btl_state_update_select_target(), btl_state_update_twink_menu(), and btl_update().

◆ btl_state_draw_twink_menu()

void btl_state_draw_twink_menu ( void )

Definition at line 4869 of file btl_states_menus.c.

4869 {
4870 switch (gBattleSubState) {
4873 break;
4876 break;
4879 break;
4882 break;
4885 break;
4890 break;
4891 }
4892}
@ BTL_SUBSTATE_TWINK_MENU_UNUSED_3
Definition enums.h:3769
@ BTL_SUBSTATE_TWINK_MENU_UNUSED_6
Definition enums.h:3772
@ BTL_SUBSTATE_TWINK_MENU_UNUSED_7
Definition enums.h:3773

Referenced by btl_draw_ui().

◆ btl_state_update_select_target()

void btl_state_update_select_target ( void )

Definition at line 4894 of file btl_states_menus.c.

4894 {
4895 BattleStatus* battleStatus = &gBattleStatus;
4896 Actor* actor;
4897 s32 targetListLength;
4898 s32 selectedTargetIndex;
4899 HudElemID hid;
4900 s8* targetIndexList;
4901 SelectableTarget* target;
4902 s32 i;
4903
4905 actor = battleStatus->playerActor;
4906 } else {
4907 actor = battleStatus->partnerActor;
4908 }
4909 targetListLength = actor->targetListLength;
4910 selectedTargetIndex = actor->selectedTargetIndex;
4911
4912 actor->flags &= ~ACTOR_FLAG_SHOW_STATUS_ICONS;
4913 targetIndexList = actor->targetIndexList;
4914 switch (gBattleSubState) {
4918 gBattleStatus.flags1 &= ~BS_FLAGS1_MENU_OPEN;
4919
4920 // prepare the action command tip for the selected move
4922 if (battleStatus->selectedMoveID != MOVE_NONE) {
4923 s8 actionTip = gMoveTable[battleStatus->selectedMoveID].actionTip;
4924
4925 if (actionTip >= 0) {
4927 }
4928 }
4929 }
4930
4931 // create the target list
4933 targetListLength = actor->targetListLength;
4934 if (battleStatus->curTargetListFlags & TARGET_FLAG_SELECT_ONE) {
4935 targetIndexList = actor->targetIndexList;
4936 for (i = 0; i < targetListLength; i++) {
4937 target = &actor->targetData[targetIndexList[i]];
4939 actor->selectedTargetIndex = i;
4940 break;
4941 }
4942 }
4943 }
4944
4945 // when TARGET_FLAG_OVERRIDE is set, skip selecting a target and begin executing the move
4946 if (battleStatus->curTargetListFlags & TARGET_FLAG_OVERRIDE) {
4951 } else {
4953 }
4955 } else {
4959 } else {
4961 }
4963 }
4964 break;
4965 }
4966
4967 // if the target list is empty, skip selecting a target and begin executing the move
4968 if (targetListLength == 0) {
4973 } else {
4975 }
4977 } else {
4981 } else {
4983 }
4985 }
4986 break;
4987 }
4988
4989 // create the HUD elements for the target pointers
4990 for (i = 0; i < targetListLength; i++) {
4994 hud_element_set_render_pos(hid, 0, -100);
4995 }
4997 break;
4999 // animate the target name sliding into view
5004 }
5005 }
5006
5007 if (battleStatus->curButtonsPressed & BUTTON_B) {
5010 break;
5011 }
5012
5013 if (battleStatus->curButtonsPressed & BUTTON_A) {
5015 D_802ACC60 = 8;
5018 break;
5019 }
5020
5022 if (battleStatus->curButtonsDown & (BUTTON_Z | BUTTON_R)) {
5023 gBattleStatus.flags1 &= ~BS_FLAGS1_MENU_OPEN;
5024 break;
5025 }
5026
5027 if (battleStatus->curTargetListFlags & TARGET_FLAG_SELECT_ONE) {
5028 s32 oldSelectedTargetIndex = selectedTargetIndex;
5029
5030 if (battleStatus->curButtonsHeld & BUTTON_STICK_LEFT) {
5031 selectedTargetIndex--;
5032 }
5033 if (battleStatus->curButtonsHeld & BUTTON_STICK_RIGHT) {
5034 selectedTargetIndex++;
5035 }
5036 if (selectedTargetIndex < 0) {
5037 selectedTargetIndex = targetListLength - 1;
5038 }
5039 if (selectedTargetIndex >= targetListLength) {
5040 selectedTargetIndex = 0;
5041 }
5042 if (selectedTargetIndex != oldSelectedTargetIndex) {
5043 s32 actorFlags;
5044
5045 target = &actor->targetData[targetIndexList[selectedTargetIndex]];
5046 actorFlags = get_actor(target->actorID)->flags;
5048
5049 if (actorFlags & ACTOR_FLAG_UPSIDE_DOWN) {
5051 } else {
5053 }
5055 }
5056 actor->selectedTargetIndex = selectedTargetIndex;
5057 }
5058 break;
5060 gBattleStatus.flags1 &= ~BS_FLAGS1_MENU_OPEN;
5061 target = &actor->targetData[targetIndexList[actor->selectedTargetIndex]];
5062 actor->targetActorID = target->actorID;
5063 actor->targetPartID = target->partID;
5064
5065 // free the HUD elements for the target pointers
5066 for (i = 0; i < targetListLength; i++) {
5068 }
5069
5070 // begin executing the move
5075 } else {
5077 }
5079 } else {
5083 } else {
5085 }
5087 }
5088 break;
5090 // free the HUD elements for the target pointers
5091 for (i = 0; i < targetListLength; i++) {
5093 }
5094
5097
5098 if (battleStatus->itemUsesLeft != 0) {
5103 } else {
5105 }
5111 } else {
5113 }
5114 } else {
5119 } else {
5121 }
5122 }
5123 break;
5124 }
5125}
HudScript HES_HandPointDownLoop
Definition 5B320.c:173
HudScript HES_HandPointLeftLoop
Definition 5B320.c:234
BSS s32 BattleMenu_TargetHudElems[MAX_ENEMY_ACTORS]
BSS s32 BattleMenu_TargetNameOffsetX
BSS s32 BattleMenu_TargetPointerAlpha
s8 selectedTargetIndex
s32 HudElemID
@ BUTTON_A
Definition enums.h:2790
@ BUTTON_STICK_LEFT
Definition enums.h:2793
@ BUTTON_STICK_RIGHT
Definition enums.h:2794
@ BTL_MSG_ACTION_TIP_PRESS_BEFORE_LANDING
Definition enums.h:4104
@ TARGET_FLAG_OVERRIDE
Definition enums.h:1871
@ TARGET_FLAG_SELECT_ONE
Definition enums.h:1849
@ BTL_SUBSTATE_SELECT_TARGET_INIT
Definition enums.h:3780
@ BTL_SUBSTATE_SELECT_TARGET_CHOOSE
Definition enums.h:3781
@ BTL_SUBSTATE_SELECT_TARGET_DONE
Definition enums.h:3782
@ BTL_SUBSTATE_SELECT_TARGET_CANCEL
Definition enums.h:3783
@ BATTLE_STATE_PARTNER_MOVE
Definition enums.h:3649
@ SOUND_MENU_BACK
Definition enums.h:701
@ SOUND_MENU_CHANGE_SELECTION
Definition enums.h:698
@ SOUND_MENU_NEXT
Definition enums.h:700
@ ACTOR_FLAG_UPSIDE_DOWN
HP bar offset below actor (e.g. Swooper when upside-down).
Definition enums.h:3331
@ ACTOR_PART_FLAG_DEFAULT_TARGET
Definition enums.h:3353
ActorPart * get_actor_part(Actor *actor, s32 partID)
Definition 190B20.c:1191
void hud_element_set_script(s32 id, HudScript *anim)
void hud_element_set_render_depth(s32 id, s32 z)
void hud_element_set_render_pos(s32 id, s32 x, s32 y)

Referenced by btl_update().

◆ btl_state_draw_select_target()

void btl_state_draw_select_target ( void )

Definition at line 5127 of file btl_states_menus.c.

5127 {
5128 BattleStatus* battleStatus = &gBattleStatus;
5129 PlayerData* playerData = &gPlayerData;
5130 s32 msgID;
5131 s32 msgX;
5132 s32 msgY;
5133 s32 targetListLength;
5134 s32 currentPartner;
5135 s32 actorID;
5136 SelectableTarget* target;
5137 Actor* choosingActor;
5138 Actor* enemyActor;
5139 s32 id;
5140 s32 i;
5141 s32 nameWidth;
5142 s32 xOffset, yOffset;
5143 f32 targetX, targetY, targetZ;
5144 s32 screenX, screenY, screenZ;
5145 s32 selectedTargetIndex;
5146 s8* targetIndexList;
5147 s32* tmpPtr; // TODO required to match and CURSED
5148
5150 choosingActor = battleStatus->playerActor;
5151 } else {
5152 choosingActor = battleStatus->partnerActor;
5153 }
5154
5155 targetListLength = choosingActor->targetListLength;
5156 target = choosingActor->targetData;
5157 selectedTargetIndex = choosingActor->selectedTargetIndex;
5158 targetIndexList = choosingActor->targetIndexList;
5159
5161
5162 if (targetListLength == 0) {
5163 return;
5164 }
5165
5166 // draw target pointers
5167 if (battleStatus->curTargetListFlags & TARGET_FLAG_SELECT_ONE) {
5168 target = &choosingActor->targetData[targetIndexList[selectedTargetIndex]];
5169 enemyActor = get_actor(target->actorID);
5171 targetX = target->truePos.x;
5172 targetY = target->truePos.y;
5173 targetZ = target->truePos.z;
5174
5175 // select target pointer style based on target actor orientation
5176 if (enemyActor->flags & ACTOR_FLAG_UPSIDE_DOWN) {
5177 xOffset = 16;
5178 yOffset = 2;
5181 }
5182 } else {
5183 xOffset = 5;
5184 yOffset = -11;
5187 }
5188 }
5189
5190 get_screen_coords(CAM_BATTLE, targetX, targetY, targetZ, &screenX, &screenY, &screenZ);
5191 hud_element_set_render_pos(id, screenX + xOffset, screenY + yOffset);
5193 } else {
5194 for (i = 0; i < targetListLength; i++) {
5195 target = &choosingActor->targetData[targetIndexList[i]];
5196 enemyActor = get_actor(target->actorID);
5198 targetX = target->truePos.x;
5199 targetY = target->truePos.y;
5200 targetZ = target->truePos.z;
5201
5202 // select target pointer style based on target actor orientation
5203 if (enemyActor->flags & ACTOR_FLAG_UPSIDE_DOWN) {
5204 xOffset = 16;
5205 yOffset = 2;
5208 }
5209 } else {
5210 xOffset = 5;
5211 yOffset = -11;
5214 }
5215 }
5216
5217 get_screen_coords(CAM_BATTLE, targetX, targetY, targetZ, &screenX, &screenY, &screenZ);
5218 hud_element_set_render_pos(id, screenX + xOffset, screenY + yOffset);
5220 }
5221 }
5222
5223 currentPartner = playerData->curPartner;
5224 screenX = 52;
5225 screenY = 64;
5227 currentPartner = PARTNER_TWINK;
5228 }
5229
5230 // get target name width
5231 if ((battleStatus->curTargetListFlags & TARGET_FLAG_SELECT_ONE) || targetListLength == 1) {
5232 actorID = target->actorID;
5233 if (actorID == ACTOR_PLAYER) {
5234 nameWidth = get_msg_width(MSG_Menus_Battle_TargetMario, 0) + 10;
5235 } else if (actorID == ACTOR_PARTNER) {
5236 nameWidth = get_msg_width(PartnerNameMessages[currentPartner], 0) + 10;
5237 } else {
5238 target = &choosingActor->targetData[targetIndexList[selectedTargetIndex]];
5239 enemyActor = get_actor(target->actorID);
5240 msgID = get_actor_part(enemyActor, target->partID)->staticData->overrideNameMsg;
5241 if (msgID == MSG_NONE) {
5242 msgID = bActorNames[enemyActor->actorType];
5243 }
5244 nameWidth = get_msg_width(msgID, 0) + 10;
5245 }
5246 } else {
5247 target = &choosingActor->targetData[targetIndexList[selectedTargetIndex]];
5248 actorID = target->actorID;
5249 if (actorID == ACTOR_PLAYER) {
5250 nameWidth = get_msg_width(MSG_Menus_Battle_TargetMario, 0) + 10;
5251 } else if (actorID == ACTOR_PARTNER) {
5252 nameWidth = get_msg_width(PartnerNameMessages[currentPartner], 0) + 10;
5253 } else {
5254 nameWidth = get_msg_width(MSG_Menus_Battle_TargetAllEnemies, 0) + 10;
5255 }
5256 }
5257
5258 // draw target name box
5259 draw_box(0, WINDOW_STYLE_4, screenX + BattleMenu_TargetNameOffsetX, screenY, 0, nameWidth, 20, 255, 0,
5260 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, NULL, NULL, NULL, SCREEN_WIDTH, SCREEN_HEIGHT, NULL);
5261
5262 // draw target name text
5263 screenX += 4;
5264 screenY += 2;
5265 if ((battleStatus->curTargetListFlags & TARGET_FLAG_SELECT_ONE) || targetListLength == 1) {
5266 actorID = target->actorID;
5267 if (actorID == ACTOR_PLAYER) {
5268 draw_msg(MSG_Menus_Battle_TargetMario, screenX + BattleMenu_TargetNameOffsetX, screenY, 255, MSG_PAL_36, 0);
5269 } else if (actorID == ACTOR_PARTNER) {
5270 draw_msg(PartnerNameMessages[currentPartner], screenX + BattleMenu_TargetNameOffsetX, screenY, 255, MSG_PAL_36, 0);
5271 } else {
5272 target = &choosingActor->targetData[targetIndexList[selectedTargetIndex]];
5273 enemyActor = get_actor(target->actorID);
5274 msgID = get_actor_part(enemyActor, target->partID)->staticData->overrideNameMsg;
5275 if (msgID == MSG_NONE) {
5276 msgID = bActorNames[enemyActor->actorType];
5277 }
5278 draw_msg(msgID, screenX + *tmpPtr, screenY, 255, MSG_PAL_36, 0); // TODO required to match
5279 }
5280 } else {
5281 target = &choosingActor->targetData[targetIndexList[selectedTargetIndex]];
5282 actorID = target->actorID;
5283 if (actorID == ACTOR_PLAYER) {
5284 draw_msg(MSG_Menus_Battle_TargetMario, screenX + BattleMenu_TargetNameOffsetX, screenY, 255, MSG_PAL_36, 0);
5285 } else if (actorID == ACTOR_PARTNER) {
5286 draw_msg(PartnerNameMessages[currentPartner], screenX + BattleMenu_TargetNameOffsetX, screenY, 255, MSG_PAL_36, 0);
5287 } else {
5288 draw_msg(MSG_Menus_Battle_TargetAllEnemies, screenX + BattleMenu_TargetNameOffsetX, screenY, 255, MSG_PAL_36, 0);
5289 }
5290 }
5291}
s32 PartnerNameMessages[]
#define draw_msg
#define draw_box
@ WINDOW_STYLE_4
Definition enums.h:6373
@ MSG_PAL_36
Definition enums.h:5458
@ PARTNER_TWINK
Definition enums.h:2896
void hud_element_set_alpha(s32 id, s32 opacity)
HudScript * hud_element_get_script(s32 id)
s32 bActorNames[]

Referenced by btl_draw_ui().

◆ btl_state_update_22()

void btl_state_update_22 ( void )

Definition at line 5293 of file btl_states_menus.c.

5293 {
5294}

Referenced by btl_update().

◆ btl_state_draw_22()

void btl_state_draw_22 ( void )

Definition at line 5296 of file btl_states_menus.c.

5296 {
5297}

Referenced by btl_draw_ui().

◆ btl_state_update_celebration()

void btl_state_update_celebration ( void )

Definition at line 488 of file level_up.c.

488 {
489 BattleStatus* battleStatus = &gBattleStatus;
490 PlayerData* playerData = &gPlayerData;
491 Actor* player = battleStatus->playerActor;
492 Actor* partner = battleStatus->partnerActor;
493 s8 currentSubmenu;
494 s32 newSubmenu;
495 HudElemID hid;
496 s32 x, y, z;
497 s32 width;
498 s32 itemHudElemID;
499
500 Evt* takeTurnScript;
501 Evt* script;
502
503 s32 tensDigit;
504 s32 onesDigit;
505
506 s32 deltaSP;
507 s32 prevSP;
508
509 s32 i;
510 s32 j;
511
512 HudScript* new_var;
513
514 switch (gBattleSubState) {
516 if (battleStatus->pendingStarPoints <= 0) {
517 player->flags &= ~ACTOR_FLAG_SHOW_STATUS_ICONS;
518 EndBattleRewardTotal = battleStatus->totalStarPoints * 100;
519 pendingLevelUps = 0;
520 D_8029FB50 = 0;
521 bFadeToBlackAmt = 0;
525
526 prevSP = playerData->starPoints + battleStatus->totalStarPoints;
527 if (prevSP > 99) {
528 bgm_set_song(0, SONG_LEVEL_UP, 0, 250, 8);
529 } else {
530 bgm_set_song(0, SONG_BATTLE_END, 0, 250, 8);
531 }
532
539 }
540 break;
542 if (CelebrateSubstateTime != 0) {
544 } else if (btl_cam_is_moving_done()) {
545 DMA_COPY_SEGMENT(starpoint);
547 EndBattleRewardsDone = FALSE;
548 // divide reward into 20 increments
551 player->takeTurnScript = script;
553 player->takeTurnScriptID = script->id;
554 script->owner1.actorID = ACTOR_PLAYER;
556 }
557 break;
559 if (CelebrateSubstateTime == 0) {
560 if (battleStatus->totalStarPoints != 0) {
561 // determine the remaining star point reward after this step and give the difference to the player
563 prevSP = battleStatus->totalStarPoints;
564 battleStatus->totalStarPoints = EndBattleRewardTotal / 100;
565 deltaSP = prevSP - battleStatus->totalStarPoints;
566 if (deltaSP > 0) {
568 }
569
570 playerData->starPoints += deltaSP;
571 bFadeToBlackAmt++; // ??
572 if (EndBattleRewardStep == 0 && battleStatus->totalStarPoints != 0) {
573 playerData->starPoints++;
574 }
575 }
576 if (playerData->level >= 27) {
577 playerData->starPoints = 0;
578 }
579 if (playerData->starPoints >= 100) {
580 pendingLevelUps = 1;
581 playerData->starPoints -= 100;
582 }
583 if (playerData->level + pendingLevelUps == 27) {
584 playerData->starPoints = 0;
585 }
586 if (battleStatus->totalStarPoints == 0) {
587 if (EndBattleRewardStep == 0) {
590 if (partner != NULL) {
592 }
593 battleStatus->battlePhase = PHASE_CELEBRATE;
595 player->takeTurnScript = script;
596 player->takeTurnScriptID = script->id;
597 script->owner1.actorID = ACTOR_PLAYER;
598 if (partner != NULL) {
599 script = start_script(partner->takeTurnSource, EVT_PRIORITY_A, 0);
600 partner->takeTurnScript = script;
601 partner->takeTurnScriptID = script->id;
602 script->owner1.actorID = ACTOR_PARTNER;
603 }
606 } else {
608 }
609 }
610 } else {
612 }
613 break;
615 if (CelebrateSubstateTime == 0) {
616 if (pendingLevelUps == 0) {
618 } else {
620 }
621 break;
622 }
624 break;
626 if (CelebrateStateTime >= 99) {
627 playerData->level++;
629 btl_cam_move(5);
630 DMA_COPY_SEGMENT(level_up);
634 }
635 break;
643 mdl_set_shroud_tint_params(0, 0, 0, 0);
644 break;
646 if (CelebrateSubstateTime == 18) {
647 playerData->curHP = playerData->curMaxHP;
648 playerData->curFP = playerData->curMaxFP;
649 x = player->curPos.x + 0.0f;
650 y = player->curPos.y + 35.0f;
651 z = player->curPos.z;
652 fx_recover(0, x, y, z, playerData->curHP);
653 x = player->curPos.x + 20.0f;
654 y = player->curPos.y + 25.0f;
655 z = player->curPos.z;
656 fx_recover(1, x, y, z, playerData->curFP);
657 playerData->starPower = playerData->maxStarPower * SP_PER_BAR;
658 }
659
660 if (CelebrateSubstateTime != 0) {
662 if (CelebrateSubstateTime < 10) {
663 mdl_set_shroud_tint_params(0, 0, 0, ((10 - CelebrateSubstateTime) * 16) & 0xF0);
664 }
665 } else {
667 LevelUpStatEmblemIDs[0] = hid;
668 hud_element_set_render_pos(hid, 310, 140);
670
672 LevelUpStatEmblemIDs[1] = hid;
673 hud_element_set_render_pos(hid, 158, 340);
675
677 LevelUpStatEmblemIDs[3] = hid;
678 hud_element_set_render_pos(hid, 158, 340);
680
682 LevelUpStatEmblemIDs[2] = hid;
683 hud_element_set_render_pos(hid, 6, 140);
685
688 hud_element_set_render_pos(hid, 160, 317);
690
691 for (i = 1; i < ARRAY_COUNT(LevelUpStatTextIDs[LVL_UP_FP]); i++) {
694 hud_element_set_render_pos(hid, 160, 317);
696 }
697
700 hud_element_set_render_pos(hid, 312, 117);
702
703 for (i = 1; i < ARRAY_COUNT(LevelUpStatTextIDs[LVL_UP_HP]); i++) {
706 hud_element_set_render_pos(hid, 312, 117);
708 }
709
712 hud_element_set_render_pos(hid, 8, 117);
714
715 for (i = 1; i < ARRAY_COUNT(LevelUpStatTextIDs[LVL_UP_BP]); i++) {
718 hud_element_set_render_pos(hid, 8, 117);
720 }
721
722 CantLevelUpStat[MENU_HP] = FALSE;
723 CantLevelUpStat[MENU_FP] = FALSE;
724 CantLevelUpStat[MENU_BP] = FALSE;
725
726 if (playerData->hardMaxFP != 50) {
727 // current FP
728 tensDigit = playerData->curMaxFP / 10;
729 onesDigit = playerData->curMaxFP % 10;
732 if (tensDigit != 0) {
734 }
735 hud_element_get_render_pos(hid, &x, &y);
736 hud_element_set_render_pos(hid, x - 14, y + 46);
737
741 hud_element_get_render_pos(hid, &x, &y);
742 hud_element_set_render_pos(hid, x - 8, y + 46);
743
747 hud_element_get_render_pos(hid, &x, &y);
748 hud_element_set_render_pos(hid, x - 3, y + 46);
749
750 // upgraded FP
751 tensDigit = (playerData->curMaxFP + 5) / 10;
752 onesDigit = (playerData->curMaxFP + 5) % 10;
755 if (tensDigit != 0) {
757 }
758 hud_element_get_render_pos(hid, &x, &y);
759 hud_element_set_render_pos(hid, x + 3, y + 46);
760
764 hud_element_get_render_pos(hid, &x, &y);
765 hud_element_set_render_pos(hid, x + 10, y + 46);
766 } else {
767 // upgraded FP only
769 tensDigit = playerData->curMaxFP / 10;
770 onesDigit = playerData->curMaxFP % 10;
772 if (tensDigit != 0) {
774 }
775 hud_element_get_render_pos(hid, &x, &y);
776 hud_element_set_render_pos(hid, x - 6, y + 46);
777
781 hud_element_get_render_pos(hid, &x, &y);
782 hud_element_set_render_pos(hid, x + 2, y + 46);
783 CantLevelUpStat[MENU_FP] = TRUE;
784 }
785
788 itemHudElemID = gItemTable[ITEM_FP_PLUS_A].hudElemID;
789 hud_element_set_script(hid, gItemHudScripts[itemHudElemID].enabled);
791 hud_element_set_scale(hid, 0.5f);
792 hud_element_get_render_pos(hid, &x, &y);
793 hud_element_set_render_pos(hid, x + 17, y + 46);
794 }
795
796 if (playerData->hardMaxHP != 50) {
797 // current HP
798 tensDigit = playerData->curMaxHP / 10;
799 onesDigit = playerData->curMaxHP % 10;
800
803 if (tensDigit != 0) {
805 }
806 hud_element_get_render_pos(hid, &x, &y);
807 hud_element_set_render_pos(hid, x - 14, y + 46);
808
812 hud_element_get_render_pos(hid, &x, &y);
813 hud_element_set_render_pos(hid, x - 8, y + 46);
814
818 hud_element_get_render_pos(hid, &x, &y);
819 hud_element_set_render_pos(hid, x - 3, y + 46);
820
821 tensDigit = (playerData->curMaxHP + 5) / 10;
822 onesDigit = (playerData->curMaxHP + 5) % 10;
823
826 if (tensDigit != 0) {
828 }
829 hud_element_get_render_pos(hid, &x, &y);
830 hud_element_set_render_pos(hid, x + 3, y + 46);
831
835 hud_element_get_render_pos(hid, &x, &y);
836 hud_element_set_render_pos(hid, x + 10, y + 46);
837 } else {
838 tensDigit = playerData->curMaxHP / 10;
839 onesDigit = playerData->curMaxHP % 10;
840
843 if (tensDigit != 0) {
845 }
846 hud_element_get_render_pos(hid, &x, &y);
847 hud_element_set_render_pos(hid, x - 6, y + 46);
848
852 hud_element_get_render_pos(hid, &x, &y);
853 hud_element_set_render_pos(hid, x + 2, y + 46);
854 CantLevelUpStat[MENU_HP] = TRUE;
855 }
856
859 itemHudElemID = gItemTable[ITEM_HP_PLUS_A].hudElemID;
860 hud_element_set_script(hid, gItemHudScripts[itemHudElemID].enabled);
862 hud_element_set_scale(hid, 0.5f);
863 hud_element_get_render_pos(hid, &x, &y);
864 hud_element_set_render_pos(hid, x + 17, y + 46);
865 }
866
867 if (playerData->maxBP != 30) {
868 tensDigit = playerData->maxBP / 10;
869 onesDigit = playerData->maxBP % 10;
870
873 if (tensDigit != 0) {
875 }
876 hud_element_get_render_pos(hid, &x, &y);
877 hud_element_set_render_pos(hid, x - 14, y + 46);
878
882 hud_element_get_render_pos(hid, &x, &y);
883 hud_element_set_render_pos(hid, x - 8, y + 46);
884
888 hud_element_get_render_pos(hid, &x, &y);
889 hud_element_set_render_pos(hid, x - 3, y + 46);
890
891 tensDigit = (playerData->maxBP + 3) / 10;
892 onesDigit = (playerData->maxBP + 3) % 10;
893
896 if (tensDigit != 0) {
898 }
899 hud_element_get_render_pos(hid, &x, &y);
900 hud_element_set_render_pos(hid, x + 3, y + 46);
901
905 hud_element_get_render_pos(hid, &x, &y);
906 hud_element_set_render_pos(hid, x + 10, y + 46);
907 } else {
911 hud_element_get_render_pos(hid, &x, &y);
912 hud_element_set_render_pos(hid, x - 6, y + 46);
913
917 hud_element_get_render_pos(hid, &x, &y);
918 hud_element_set_render_pos(hid, x + 2, y + 46);
919 CantLevelUpStat[MENU_BP] = TRUE;
920 }
921
924 hud_element_set_render_pos(hid, 156, 13);
925 hud_element_set_tint(hid, 255, 255, 255);
927 hud_element_set_transform_rotation(hid, 0.0f, 0.0f, 180.0f);
928 hud_element_set_transform_scale(hid, 1.0f, 1.5f, 1.0f);
929 hud_element_set_alpha(hid, 200);
931
935 battleStatus->curSubmenu = 1;
936
939 }
940 break;
942 hid = LevelUpStatEmblemIDs[0];
943 hud_element_get_render_pos(hid, &x, &y);
944 x -= 20;
946
947 for (i = 0; i < ARRAY_COUNT(LevelUpStatTextIDs[LVL_UP_HP]); i++) {
949 hud_element_get_render_pos(hid, &x, &y);
950 x -= 20;
952 }
953
954 hid = LevelUpStatEmblemIDs[1];
955 hud_element_get_render_pos(hid, &x, &y);
956 y -= 20;
958
959 hid = LevelUpStatEmblemIDs[3];
960 hud_element_get_render_pos(hid, &x, &y);
961 y -= 20;
963
964 for (i = 0; i < ARRAY_COUNT(LevelUpStatTextIDs[LVL_UP_FP]); i++) {
966 hud_element_get_render_pos(hid, &x, &y);
967 y -= 20;
969 }
970
971 hid = LevelUpStatEmblemIDs[2];
972 hud_element_get_render_pos(hid, &x, &y);
973 x += 20;
975
976 for (i = 0; i < ARRAY_COUNT(LevelUpStatTextIDs[LVL_UP_BP]); i++) {
978 hud_element_get_render_pos(hid, &x, &y);
979 x += 20;
981 }
982
984 if (CelebrateSubstateTime == 0) {
985 hud_element_set_tint(hid, 128, 128, 128);
986#if VERSION_JP
987 x = 32;
988 y = 186;
990#else
991 x = 20;
992 y = 186;
994#endif
997 }
998 break;
1000 if (battleStatus->curButtonsPressed & BUTTON_A) {
1001 if (!CantLevelUpStat[battleStatus->curSubmenu]) {
1005 } else {
1008 }
1009 break;
1010 }
1011
1012 newSubmenu = currentSubmenu = battleStatus->curSubmenu;
1013 if (battleStatus->curButtonsHeld & BUTTON_STICK_LEFT) {
1014 newSubmenu--;
1015 }
1016 if (battleStatus->curButtonsHeld & BUTTON_STICK_RIGHT) {
1017 newSubmenu++;
1018 }
1019 if (newSubmenu < 0) {
1020 newSubmenu = 0;
1021 }
1022 if (newSubmenu > 2) {
1023 newSubmenu = 2;
1024 }
1025 if (newSubmenu != currentSubmenu) {
1027 battleStatus->curSubmenu = newSubmenu;
1028 }
1029
1031 if (CelebrateStateTime > 100) {
1032 fx_confetti(3, 0.0f, 100.0f, 0.0f, 1.0f, 120);
1034 }
1035 break;
1039
1040 switch (battleStatus->curSubmenu) {
1041 case 0:
1042 playerData->hardMaxHP += 5;
1043 playerData->curMaxHP += 5;
1044 playerData->curHP += 5;
1045 if (playerData->curMaxHP > 75) {
1046 playerData->curMaxHP = 75;
1047 }
1048 if (playerData->curHP > playerData->curMaxHP) {
1049 playerData->curHP = playerData->curMaxHP;
1050 }
1051 player->maxHP = playerData->curMaxHP;
1052 player->curHP = playerData->curHP;
1053 break;
1054 case 1:
1055 playerData->hardMaxFP += 5;
1056 playerData->curMaxFP += 5;
1057 playerData->curFP += 5;
1058 if (playerData->curMaxFP > 75) {
1059 playerData->curMaxFP = 75;
1060 }
1061 if (playerData->curFP > playerData->curMaxFP) {
1062 playerData->curFP = playerData->curMaxFP;
1063 }
1064 break;
1065 case 2:
1066 playerData->maxBP += 3;
1067 if (playerData->maxBP > 30) {
1068 playerData->maxBP = 30;
1069 }
1070 break;
1071 }
1072
1073 set_actor_anim(0, 0, ANIM_MarioB1_AdjustCap);
1074
1075 if (partner != NULL) {
1076 script = start_script(partner->takeTurnSource, EVT_PRIORITY_A, 0);
1077 partner->takeTurnScript = script;
1078 partner->takeTurnScriptID = script->id;
1079 script->owner1.actorID = ACTOR_PARTNER;
1080 }
1082 bgm_set_song(0, -1, 0, 2000, 8);
1083 }
1084 bFadeToBlackAmt = 0;
1086 break;
1088 if ((gGameStatusPtr->frameCounter % 2) != 0) {
1089 switch (battleStatus->curSubmenu) {
1090 case 0:
1092 break;
1093 case 1:
1096 break;
1097 case 2:
1099 break;
1100 }
1101 } else {
1102 switch (battleStatus->curSubmenu) {
1103 case 0:
1105 break;
1106 case 1:
1109 break;
1110 case 2:
1112 break;
1113 }
1114 }
1115 if (bFadeToBlackAmt == 255) {
1117 break;
1118 }
1119 bFadeToBlackAmt += 10;
1120 if (bFadeToBlackAmt > 255) {
1121 bFadeToBlackAmt = 255;
1122 }
1123 break;
1129
1130 for (i = 0; i < ARRAY_COUNT(LevelUpStatTextIDs); i++) {
1131 for (j = 0; j < ARRAY_COUNT(LevelUpStatTextIDs[LVL_UP_FP]); j++) {
1133 }
1134 }
1135
1137 mdl_set_shroud_tint_params(0, 0, 0, 0);
1140 break;
1142 width = get_msg_width(MSG_Menus_CantIncrease, 0) + 31;
1143 x = 160 - (width / 2);
1144 y = 80;
1149 break;
1153 }
1154 if (CelebrateSubstateTime != 0) {
1156 break;
1157 }
1160 break;
1162 if (battleStatus->curButtonsPressed & (BUTTON_A | BUTTON_B)) {
1163 CelebrateStateTime = 99;
1164#if VERSION_JP
1166#endif
1167 }
1168 if (CelebrateStateTime >= 99) {
1170 bgm_set_song(0, -1, 0, 1500, 8);
1171 }
1172 bFadeToBlackAmt = 0;
1173 btl_cam_set_params(TRUE, 270, 100, 8, 0, 0x2400, 100);
1174 set_actor_anim(0, 0, ANIM_MarioB1_AdjustCap);
1175 if (partner != NULL) {
1177 }
1180 break;
1181 }
1182 break;
1184 if (CelebrateSubstateTime != 0) {
1186 if (CelebrateSubstateTime == 0) {
1187 set_actor_anim(0, 0, ANIM_Mario1_Walk);
1188 }
1189 } else {
1190 player->yaw = 0.0f;
1191 if (partner != NULL) {
1192 partner->yaw = 0.0f;
1193 }
1194
1195 player->curPos.x += 4.0f;
1196 if (partner != NULL) {
1197 partner->curPos.x += 4.0f;
1198 }
1199 }
1200 if (bFadeToBlackAmt == 255) {
1202 break;
1203 }
1204 bFadeToBlackAmt += 20;
1205 if (bFadeToBlackAmt > 255) {
1206 bFadeToBlackAmt = 255;
1207 }
1208 break;
1210 if (does_script_exist(player->takeTurnScriptID)) {
1212 }
1213 if (partner != NULL && does_script_exist(partner->takeTurnScriptID)) {
1215 }
1218 break;
1219 }
1221}
s32 D_80284154[]
Definition level_up.c:162
IconHudScriptPair gItemHudScripts[]
HudScript HES_level_up_small_blue_arrow
Definition level_up.c:485
BSS s32 EndBattleRewardTotal
Definition level_up.c:57
@ LVL_UP_BONUS
Definition level_up.c:45
@ LVL_UP_TITLE
Definition level_up.c:39
@ LVL_UP_NEXT_ONES
Definition level_up.c:44
@ LVL_UP_ARROW
Definition level_up.c:42
@ LVL_UP_CUR_TENS
Definition level_up.c:40
@ LVL_UP_CUR_ONES
Definition level_up.c:41
@ LVL_UP_NEXT_TENS
Definition level_up.c:43
BSS HudElemID LevelUpSelectTextID
Definition level_up.c:51
BSS s32 EndBattleRewardIncrement
Definition level_up.c:58
BSS HudElemID LevelUpStatEmblemIDs[4]
Definition level_up.c:48
HudScript HES_ProjectorBeam
HudScript HES_level_up_select_one_to_upgrade
Definition level_up.c:487
HudScript HES_level_up_leaves
Definition level_up.c:415
HudScript HES_level_up_badge
Definition level_up.c:416
HudScript * level_up_small_digit_scripts[3][10]
Definition level_up.c:238
BSS Evt * LevelUpScriptPtr
Definition level_up.c:61
EvtScript EVS_ShowLevelUp
Definition level_up.c:459
HudScript HES_level_up_small_red_arrow
Definition level_up.c:462
s32 bFadeToBlackAmt
Definition level_up.c:160
BSS HudElemID LevelUpSpotlightID
Definition level_up.c:50
HudScript HES_level_up_heart
Definition level_up.c:412
BSS s32 CelebrateSubstateTime
Definition level_up.c:53
BSS HudElemID LevelUpStatTextIDs[3][7]
Definition level_up.c:49
void draw_content_cant_increase_popup(void *data, s32 posX, s32 posY)
Definition level_up.c:1515
HudScript HES_level_up_flower
Definition level_up.c:414
BSS s32 D_8029FB50
Definition level_up.c:54
EvtScript EVS_ShowStarpoints
Definition level_up.c:351
BSS s32 pendingLevelUps
Definition level_up.c:59
BSS s32 EndBattleRewardsDone
Definition level_up.c:60
@ LVL_UP_FP
Definition level_up.c:32
@ LVL_UP_HP
Definition level_up.c:33
@ LVL_UP_BP
Definition level_up.c:34
@ MENU_HP
Definition level_up.c:25
@ MENU_FP
Definition level_up.c:26
@ MENU_BP
Definition level_up.c:27
BSS s32 LevelUpSelectTextVelX
Definition level_up.c:65
BSS s32 CantLevelUpStat[3]
Definition level_up.c:56
void draw_content_level_up_textbox(void *data, s32 posX, s32 posY)
Definition level_up.c:1475
HudScript HES_level_up_small_green_arrow
Definition level_up.c:439
BSS s32 EndBattleRewardStep
Definition level_up.c:55
BSS s32 CelebrateStateTime
Definition level_up.c:63
BSS s32 LevelUpSelectTextOffsetX
Definition level_up.c:64
HudScript * HES_LevelUpDigits[3][10]
Definition level_up.c:199
BSS s32 LevelUpScriptID
Definition level_up.c:62
HudScript * levelup_stat_scripts[3]
Definition level_up.c:193
@ WINDOW_PRIORITY_10
Definition enums.h:3184
@ WINDOW_PRIORITY_20
Definition enums.h:3186
@ PHASE_CELEBRATE
Definition enums.h:2062
@ SONG_LEVEL_UP
Definition enums.h:424
@ SONG_BATTLE_END
Definition enums.h:421
@ BS_FLAGS2_AWARDING_STAR_POINTS
Definition enums.h:3603
@ BTL_CAM_VICTORY
Definition enums.h:4844
@ SOUND_ID_TRIGGER_CHANGE_SOUND
Definition enums.h:532
@ BTL_SUBSTATE_CELEBRATE_LEVEL_UP_CREATE_HUD
Definition enums.h:3897
@ BTL_SUBSTATE_CELEBRATE_LEVEL_UP_UPGRADE
Definition enums.h:3900
@ BTL_SUBSTATE_CELEBRATE_INIT
Definition enums.h:3891
@ BTL_SUBSTATE_CELEBRATE_DONE
Definition enums.h:3907
@ BTL_SUBSTATE_CELEBRATE_LEVEL_UP_BEGIN
Definition enums.h:3896
@ BTL_SUBSTATE_CELEBRATE_LEVEL_UP_DESTROY_HUD
Definition enums.h:3902
@ BTL_SUBSTATE_CELEBRATE_LEVEL_UP_SHOW_HUD
Definition enums.h:3898
@ BTL_SUBSTATE_CELEBRATE_LEVEL_UP_INVALID_DELAY
Definition enums.h:3904
@ BTL_SUBSTATE_CELEBRATE_LOAD_STAR_POINTS
Definition enums.h:3892
@ BTL_SUBSTATE_CELEBRATE_LEVEL_UP_CHOOSE
Definition enums.h:3899
@ BTL_SUBSTATE_CELEBRATE_LEVEL_UP_INVALID
Definition enums.h:3903
@ BTL_SUBSTATE_CELEBRATE_WALK_AWAY
Definition enums.h:3906
@ BTL_SUBSTATE_CELEBRATE_TALLY_STAR_POINTS
Definition enums.h:3893
@ BTL_SUBSTATE_CELEBRATE_POST_STAR_POINTS
Definition enums.h:3894
@ BTL_SUBSTATE_CELEBRATE_SKIPPABLE_END_DELAY
Definition enums.h:3905
@ BTL_SUBSTATE_CELEBRATE_LEVEL_UP_LOAD
Definition enums.h:3895
@ BTL_SUBSTATE_CELEBRATE_LEVEL_UP_FADE_OUT
Definition enums.h:3901
@ ABILITY_FP_PLUS
Definition enums.h:448
@ ABILITY_HP_PLUS
Definition enums.h:440
@ SOUND_LRAW_CHEERING
Definition enums.h:1151
@ SOUND_JINGLE_WON_BATTLE
Definition enums.h:709
@ SOUND_STAR_POINT_PICKUP
Definition enums.h:926
@ SOUND_LOOP_CHEERING
Definition enums.h:1589
@ WIN_BTL_POPUP
Definition enums.h:5249
@ WIN_BTL_DESC_BOX
Definition enums.h:5248
void btl_cam_set_params(b16, s16, s16, s16, s32, s32, s32)
Definition camera.c:1939
void mdl_set_all_tint_type(s32)
Definition model.c:4519
void kill_script_by_ID(s32 id)
void set_window_properties(s32 panelID, s32 posX, s32 posY, s32 width, s32 height, u8, void *drawContents, void *drawContentsArg, s8 parent)
Definition windows.c:373
void hud_element_get_render_pos(s32 id, s32 *x, s32 *y)
void hud_element_set_scale(s32 index, f32 scale)
void hud_element_create_transform_B(s32 id)
void hud_element_set_tint(s32 id, s32 r, s32 g, s32 b)
void hud_element_set_transform_rotation(s32 id, f32 x, f32 y, f32 z)
void hud_element_set_transform_rotation_pivot(s32 id, s32 dx, s32 dy)
void hud_element_clear_flags(s32 id, s32 flags)
Turns off the given flags.
void hud_element_set_transform_scale(s32 id, f32 x, f32 y, f32 z)
@ HUD_ELEMENT_FLAG_DISABLED
Definition hud_element.h:72
@ HUD_ELEMENT_FLAG_FILTER_TEX
Definition hud_element.h:86
void mdl_set_shroud_tint_params(u8 r, u8 g, u8 b, u8 a)
Definition model.c:3905

Referenced by btl_update().

◆ btl_draw_upgrade_windows()

void btl_draw_upgrade_windows ( s32 phase)

Definition at line 1223 of file level_up.c.

1223 {
1224 BattleStatus* battleStatus = &gBattleStatus;
1225 s32 x;
1226 s32 y;
1227 s32 d1;
1228 s32 d2;
1229 s32 d3;
1230
1231 switch (phase) {
1232 case 0: // before choice
1233 d1 = 100;
1234 d2 = 100;
1235 d3 = 100;
1236 break;
1237 case 1: // choosing
1238 switch (battleStatus->curSubmenu) {
1239 case MENU_HP:
1240 d1 = 0;
1241 d2 = 100;
1242 d3 = 100;
1243 break;
1244 case MENU_FP:
1245 d1 = 100;
1246 d2 = 0;
1247 d3 = 100;
1248 break;
1249 default:
1250 d1 = 100;
1251 d2 = 100;
1252 d3 = 0;
1253 break;
1254 }
1255 break;
1256 default: // after choice
1257 d1 = 100;
1258 d2 = 100;
1259 d3 = 100;
1260 break;
1261 }
1262
1264 draw_box(0, WINDOW_STYLE_15, x - 22, y - 22, 0, 44, 44, 255, d1, 1.0f, 1.0f, 0.0f, 0.0f, 0.0f, NULL, NULL, NULL,
1267 draw_box(0, WINDOW_STYLE_15, x - 22, y - 22, 0, 44, 44, 255, d2, 1.0f, 1.0f, 0.0f, 0.0f, 0.0f, NULL, NULL, NULL,
1270 draw_box(0, WINDOW_STYLE_15, x - 22, y - 22, 0, 44, 44, 255, d3, 1.0f, 1.0f, 0.0f, 0.0f, 0.0f, NULL, NULL, NULL,
1272}
@ WINDOW_STYLE_15
Definition enums.h:6384

Referenced by btl_state_draw_celebration().

◆ btl_state_draw_celebration()

void btl_state_draw_celebration ( void )

Definition at line 1274 of file level_up.c.

1274 {
1275 BattleStatus* battleStatus = &gBattleStatus;
1276 s32 rotZ;
1277 s32 id;
1278 s32 i;
1279 s32 j;
1280
1281 switch (gBattleSubState) {
1284 id = LevelUpStatEmblemIDs[0];
1285 hud_element_set_tint(id, 128, 128, 128);
1287 id = LevelUpStatEmblemIDs[3];
1288 hud_element_set_tint(id, 128, 128, 128);
1290 id = LevelUpStatEmblemIDs[1];
1291 hud_element_set_tint(id, 128, 128, 128);
1293 id = LevelUpStatEmblemIDs[2];
1294 hud_element_set_tint(id, 128, 128, 128);
1296
1297 for (j = 0; j < ARRAY_COUNT(LevelUpStatTextIDs); j++) {
1298 for (i = 0; i < ARRAY_COUNT(LevelUpStatTextIDs[LVL_UP_FP]); i++) {
1299 id = LevelUpStatTextIDs[j][i];
1300
1301 hud_element_set_tint(id, 128, 128, 128);
1303 }
1304 }
1305 break;
1309 switch (battleStatus->curSubmenu) {
1310 case 0:
1311 rotZ = 152;
1312 hud_element_set_tint(LevelUpStatEmblemIDs[0], 255, 255, 255);
1313 hud_element_set_tint(LevelUpStatEmblemIDs[3], 128, 128, 128);
1314 hud_element_set_tint(LevelUpStatEmblemIDs[1], 128, 128, 128);
1315 hud_element_set_tint(LevelUpStatEmblemIDs[2], 128, 128, 128);
1316
1317 for (i = 0; i < ARRAY_COUNT(LevelUpStatTextIDs[LVL_UP_FP]); i++) {
1319
1320 hud_element_set_tint(id, 128, 128, 128);
1321 }
1322
1323 for (i = 0; i < ARRAY_COUNT(LevelUpStatTextIDs[LVL_UP_HP]); i++) {
1325
1326 hud_element_set_tint(id, 255, 255, 255);
1327 }
1328
1329 for (i = 0; i < ARRAY_COUNT(LevelUpStatTextIDs[LVL_UP_BP]); i++) {
1331
1332 hud_element_set_tint(id, 128, 128, 128);
1333 }
1334
1335 id = LevelUpStatEmblemIDs[0];
1338 }
1339 id = LevelUpStatEmblemIDs[3];
1342 }
1343 id = LevelUpStatEmblemIDs[1];
1346 }
1347 id = LevelUpStatEmblemIDs[2];
1350 }
1351 break;
1352 case 1:
1353 rotZ = 180;
1354 hud_element_set_tint(LevelUpStatEmblemIDs[0], 128, 128, 128);
1355 hud_element_set_tint(LevelUpStatEmblemIDs[3], 255, 255, 255);
1356 hud_element_set_tint(LevelUpStatEmblemIDs[1], 255, 255, 255);
1357 hud_element_set_tint(LevelUpStatEmblemIDs[2], 128, 128, 128);
1358
1359 for (i = 0; i < ARRAY_COUNT(LevelUpStatTextIDs[LVL_UP_FP]); i++) {
1361
1362 hud_element_set_tint(id, 255, 255, 255);
1363 }
1364
1365 for (i = 0; i < ARRAY_COUNT(LevelUpStatTextIDs[LVL_UP_HP]); i++) {
1367
1368 hud_element_set_tint(id, 128, 128, 128);
1369 }
1370
1371 for (i = 0; i < ARRAY_COUNT(LevelUpStatTextIDs[LVL_UP_BP]); i++) {
1373
1374 hud_element_set_tint(id, 128, 128, 128);
1375 }
1376 break;
1377 case 2:
1378 default:
1379 rotZ = 208;
1380 hud_element_set_tint(LevelUpStatEmblemIDs[0], 128, 128, 128);
1381 hud_element_set_tint(LevelUpStatEmblemIDs[3], 128, 128, 128);
1382 hud_element_set_tint(LevelUpStatEmblemIDs[1], 128, 128, 128);
1383 hud_element_set_tint(LevelUpStatEmblemIDs[2], 255, 255, 255);
1384
1385 for (i = 0; i < ARRAY_COUNT(LevelUpStatTextIDs[LVL_UP_FP]); i++) {
1387
1388 hud_element_set_tint(id, 128, 128, 128);
1389 }
1390
1391 for (i = 0; i < ARRAY_COUNT(LevelUpStatTextIDs[LVL_UP_HP]); i++) {
1393
1394 hud_element_set_tint(id, 128, 128, 128);
1395 }
1396
1397 for (i = 0; i < ARRAY_COUNT(LevelUpStatTextIDs[LVL_UP_BP]); i++) {
1399
1400 hud_element_set_tint(id, 255, 255, 255);
1401 }
1402 break;
1403 }
1404
1410
1411 for (j = 0; j < ARRAY_COUNT(LevelUpStatTextIDs); j++) {
1412 for (i = 0; i < ARRAY_COUNT(LevelUpStatTextIDs[LVL_UP_FP]); i++) {
1414 }
1415 }
1416
1417 func_80144218(-1);
1418 id = LevelUpSpotlightID;
1419 hud_element_set_transform_rotation(id, 0.0f, 0.0f, rotZ);
1420 func_80144238(id);
1421 break;
1429
1430 for (j = 0; j < ARRAY_COUNT(LevelUpStatTextIDs); j++) {
1431 for (i = 0; i < ARRAY_COUNT(LevelUpStatTextIDs[LVL_UP_FP]); i++) {
1433 }
1434 }
1435
1437 break;
1440 break;
1442 if (bFadeToBlackAmt != 0) {
1444 }
1445 break;
1446 }
1447
1448 switch (gBattleSubState) {
1454 if (LevelUpSelectTextOffsetX > 200) {
1456 LevelUpSelectTextVelX = -LevelUpSelectTextVelX / 3; // rebounding
1457 }
1461 break;
1465 if (LevelUpSelectTextOffsetX > 500) {
1467 }
1471 break;
1472 }
1473}
void btl_draw_upgrade_windows(s32 phase)
Definition level_up.c:1223
HudScript HES_level_up_heart_copy
Definition level_up.c:413
void func_80144238(s32 id)
void hud_element_draw_clipped(s32 id)
void func_80144218(s32 id)

Referenced by btl_draw_ui().

◆ btl_bonk_cleanup()

void btl_bonk_cleanup ( void )

Definition at line 536 of file popup_messages.c.

536 {
537 s32 i;
538
539 for (i = 0; i < ARRAY_COUNT(popupMessages); i++) {
540 PopupMessage* popup = &popupMessages[i];
541
542 if (popup->active != 0 && (popup->active & 0x10)) {
543 BonkData* bonkData = popup->data.bonk;
544 s32 j;
545
546 for (j = 0; j < popup->messageIndex; j++, bonkData++) {
547 if (bonkData->alive) {
548 bonkData->startupTime = 0;
549 bonkData->moveTime = 1;
550 bonkData->holdTime = 20;
551 }
552 }
553 }
554 }
555}
union PopupMessage::@39 data
BSS PopupMessage popupMessages[32]

Referenced by btl_update().

◆ set_actor_anim_by_ref()

void set_actor_anim_by_ref ( Actor * actor,
ActorPart * part,
AnimID anim )

Definition at line 1047 of file 190B20.c.

1047 {
1048 if ((s32) anim >= 0) {
1049 switch (actor->actorID & ACTOR_CLASS_MASK) {
1050 case ACTOR_CLASS_PLAYER:
1051 if (part->curAnimation != anim) {
1052 part->curAnimation = anim;
1054 }
1055 break;
1057 case ACTOR_CLASS_ENEMY:
1058 if (part->curAnimation != anim) {
1059 part->curAnimation = anim;
1062 }
1063 break;
1064 }
1065 }
1066}
s32 spr_get_notify_value(s32 spriteIndex)
Definition sprite.c:1173

◆ update_action_ratings()

void update_action_ratings ( void )

Definition at line 2443 of file 190B20.c.

2443 {
2444 BattleStatus* battleStatus = &gBattleStatus;
2445 Actor* actor;
2446 s32 i;
2447
2448 for (i = 0; i < ARRAY_COUNT(battleStatus->enemyActors); i++) {
2449 actor = gBattleStatus.enemyActors[i];
2450 if (actor != NULL) {
2451 if (actor->actionRatingTime == 60) {
2452 if (actor->attackResultEffect != NULL) {
2454 }
2455 }
2456 if (actor->actionRatingTime == 5) {
2457 if (actor->attackResultEffect != NULL) {
2459 actor->attackResultEffect = NULL;
2460 }
2461 }
2462 if (actor->actionRatingTime > 0) {
2463 actor->actionRatingTime--;
2464 }
2465 }
2466 }
2467
2468 actor = battleStatus->playerActor;
2469 if (actor != NULL) {
2470 if (actor->actionRatingTime == 60) {
2471 if (actor->attackResultEffect != NULL) {
2473 }
2474 }
2475 if (actor->actionRatingTime == 5) {
2476 if (actor->attackResultEffect != NULL) {
2478 actor->attackResultEffect = NULL;
2479 }
2480 }
2481 if (actor->actionRatingTime > 0) {
2482 actor->actionRatingTime--;
2483 }
2484 }
2485
2486 actor = battleStatus->partnerActor;
2487 if (actor != NULL) {
2488 if (actor->actionRatingTime == 60) {
2489 if (actor->attackResultEffect != NULL) {
2491 }
2492 }
2493 if (actor->actionRatingTime == 5) {
2494 if (actor->attackResultEffect != NULL) {
2496 actor->attackResultEffect = NULL;
2497 }
2498 }
2499 if (actor->actionRatingTime > 0) {
2500 actor->actionRatingTime--;
2501 }
2502 }
2503}

Referenced by btl_update().

◆ update_health_bars()

void update_health_bars ( void )

Definition at line 2515 of file 190B20.c.

2515 {
2516 s32 i;
2517
2518 for (i = 0; i < ARRAY_COUNT(gBattleStatus.enemyActors); i++) {
2519 Actor* enemy = gBattleStatus.enemyActors[i];
2520
2521 if (enemy != NULL) {
2522 if (enemy->healthBarHideTime > 0) {
2523 enemy->healthBarHideTime--;
2524 if (enemy->healthBarHideTime == 0) {
2525 enemy->flags &= ~ACTOR_FLAG_HEALTH_BAR_HIDDEN;
2526 }
2527 }
2528 }
2529 }
2530}
s8 healthBarHideTime

Referenced by btl_update().

◆ btl_cam_is_moving_done()

s32 btl_cam_is_moving_done ( void )

Definition at line 1980 of file camera.c.

1980 {
1981 return BattleCam_DoneMoving;
1982}

Referenced by btl_state_update_begin_partner_turn(), btl_state_update_begin_player_turn(), and btl_state_update_celebration().

◆ btl_popup_messages_update()

void btl_popup_messages_update ( void )

Definition at line 294 of file popup_messages.c.

294 {
295 s32 i;
296
297 for (i = 0; i < ARRAY_COUNT(popupMessages); i++) {
298 PopupMessage* popup = &popupMessages[i];
299 if (popup->active && popup->updateFunc != NULL) {
300 popup->updateFunc(popup);
301 }
302 }
303}
PopupMessageCallback updateFunc

Referenced by btl_update().

◆ btl_popup_messages_draw_world_geometry()

void btl_popup_messages_draw_world_geometry ( void )

Definition at line 305 of file popup_messages.c.

305 {
306 s32 i;
307
308 for (i = 0; i < ARRAY_COUNT(popupMessages); i++) {
309 PopupMessage* popup = &popupMessages[i];
310 if (popup->active && popup->renderWorldFunc != NULL) {
311 popup->renderWorldFunc(popup);
312 }
313 }
314}
PopupMessageCallback renderWorldFunc

Referenced by btl_render_actors().

◆ func_80255FD8()

void func_80255FD8 ( void )

Definition at line 829 of file actor_rendering.c.

829 {
830}

Referenced by btl_render_actors().

◆ set_actor_glow_pal()

void set_actor_glow_pal ( Actor * actor,
s32 arg1 )

Definition at line 2654 of file 190B20.c.

2654 {
2655 for (ActorPart* part = actor->partsTable; part != NULL; part = part->nextPart) {
2657 && (part->idleAnimations != NULL)
2658 && !(part->flags & ACTOR_PART_FLAG_NO_DECORATIONS)
2659 ) {
2660 set_part_glow_pal(part, glowState);
2661 }
2662 }
2663}
void set_part_glow_pal(ActorPart *part, s32 glowState)
Definition 190B20.c:2642
@ ACTOR_PART_FLAG_USE_ABSOLUTE_POSITION
Definition enums.h:3361

Referenced by appendGfx_npc_actor(), appendGfx_player_actor(), and btl_delete_actor().

◆ btl_set_popup_duration()

void btl_set_popup_duration ( s32 duration)

Definition at line 629 of file popup_messages.c.

629 {
631
632 if (ActionCommandTipVisible && popup != NULL) {
633 popup->duration = duration;
634 }
635}
PopupMessage * bPopupMessage
BSS b16 ActionCommandTipVisible

Referenced by action_command_free(), and update().

◆ switch_to_partner()

void switch_to_partner ( s32 arg0)

Definition at line 906 of file partners.c.

906 {
907 PlayerStatus* playerStatus = &gPlayerStatus;
908
909 if (wCurrentPartnerId != partnerID) {
910 D_8010CFE0 = 1;
911 NextPartnerID = partnerID;
912
913 if (wCurrentPartnerId != PARTNER_NONE && partnerID != PARTNER_NONE) {
915 } else if (partnerID == PARTNER_NONE) {
917 } else {
919 wSavedPartnerPosX = playerStatus->pos.x;
920 wSavedPartnerPosY = playerStatus->pos.y;
921 wSavedPartnerPosZ = playerStatus->pos.z;
922 }
923 }
924}
@ PARTNER_NONE
Definition enums.h:2885
@ PARTNER_CMD_PUT_AWAY
Definition enums.h:2949
@ PARTNER_CMD_TAKE_OUT
Definition enums.h:2951
@ PARTNER_CMD_SWITCH
Definition enums.h:2948
f32 wSavedPartnerPosZ
Definition partners.c:341
BSS s32 NextPartnerCommand
Definition partners.c:61
BSS s32 NextPartnerID
Definition partners.c:60
f32 wSavedPartnerPosX
Definition partners.c:339
f32 wSavedPartnerPosY
Definition partners.c:340
BSS s32 wCurrentPartnerId
Definition partners.c:57
BSS s32 D_8010CFE0
Definition partners.c:59

Referenced by check_input_open_menus().

◆ get_current_partner_id()

s8 get_current_partner_id ( void )

Definition at line 1101 of file 7BB60.c.

1101 {
1102 return gPlayerData.curPartner;
1103}

Referenced by collision_main_lateral(), and entity_try_partner_interaction_trigger().

◆ delete_trigger()

void delete_trigger ( Trigger * toDelete)

Definition at line 239 of file trigger.c.

239 {
240 s32 i;
241
242 for (i = 0; i < ARRAY_COUNT(*gCurrentTriggerListPtr); i++) {
243 if ((*gCurrentTriggerListPtr)[i] == toDelete) {
244 break;
245 }
246 }
247
250 (*gCurrentTriggerListPtr)[i] = NULL;
251 }
252}

Referenced by evt_handle_unbind().

◆ kill_script_by_ID()

void kill_script_by_ID ( s32 id)

◆ set_script_priority()

void set_script_priority ( Evt * script,
s32 priority )

Definition at line 711 of file script_list.c.

711 {
712 script->priority = priority;
713}

Referenced by evt_handle_set_priority().

◆ set_script_group()

void set_script_group ( Evt * script,
s32 groupFlags )

Definition at line 727 of file script_list.c.

727 {
728 script->groupFlags = groupFlags;
729}

Referenced by evt_handle_set_group().

◆ suspend_group_others()

void suspend_group_others ( Evt * script,
s32 groupFlags )

Definition at line 870 of file script_list.c.

870 {
871 s32 i;
872 Evt* scriptContextPtr;
873
874 for (i = 0; i < MAX_SCRIPTS; i++) {
875 scriptContextPtr = (*gCurrentScriptListPtr)[i];
876 if (scriptContextPtr != NULL && scriptContextPtr != script) {
877 suspend_group_script(scriptContextPtr, groupFlags);
878 }
879 }
880}
void suspend_group_script(Evt *script, s32 groupFlags)

Referenced by evt_handle_suspend_others().

◆ resume_group_others()

void resume_group_others ( Evt * script,
s32 groupFlags )

Definition at line 882 of file script_list.c.

882 {
883 s32 i;
884 Evt* scriptContextPtr;
885
886 for (i = 0; i < MAX_SCRIPTS; i++) {
887 scriptContextPtr = (*gCurrentScriptListPtr)[i];
888 if (scriptContextPtr != NULL && scriptContextPtr != script) {
889 resume_group_script(scriptContextPtr, groupFlags);
890 }
891 }
892}

Referenced by evt_handle_resume_others().

◆ suspend_all_script()

s32 suspend_all_script ( s32 id)

Definition at line 798 of file script_list.c.

798 {
799 s32 i;
800
801 for (i = 0; i < MAX_SCRIPTS; i++) {
802 Evt* scriptContextPtr = (*gCurrentScriptListPtr)[i];
803
804 if (scriptContextPtr != NULL && scriptContextPtr->id == id) {
806 }
807 }
808}
@ EVT_GROUP_NOT_BATTLE
Definition evt.h:147

Referenced by evt_handle_suspend(), partner_suspend_ability_script(), start_battle(), update_encounters_neutral(), and update_encounters_pre_battle().

◆ resume_all_script()

s32 resume_all_script ( s32 id)

Definition at line 810 of file script_list.c.

810 {
811 s32 i;
812 Evt* scriptContextPtr;
813
814 for (i = 0; i < MAX_SCRIPTS; i++) {
815 scriptContextPtr = (*gCurrentScriptListPtr)[i];
816 if (scriptContextPtr != NULL && scriptContextPtr->id == id) {
817 resume_group_script(scriptContextPtr, EVT_GROUP_NOT_BATTLE);
818 }
819 }
820}

Referenced by evt_handle_resume(), partner_resume_ability_script(), update_encounters_conversation(), and update_encounters_post_battle().

◆ create_shadow_type()

s32 create_shadow_type ( s32 type,
f32 x,
f32 y,
f32 z )

Definition at line 1528 of file entity.c.

1528 {
1529 s32 isFixedSize = FALSE;
1531 s32 shadowIndex;
1532
1533 switch (type) {
1535 isFixedSize = TRUE;
1537 bp = &CircularShadowA;
1538 break;
1540 isFixedSize = TRUE;
1542 bp = &SquareShadow;
1543 break;
1545 isFixedSize = TRUE;
1547 bp = &CircularShadowB;
1548 break;
1549 }
1550
1551 shadowIndex = create_shadow_from_data(bp, x, y, z);
1552
1553 if (isFixedSize) {
1555 }
1556
1557 return shadowIndex;
1558}
Shadow * get_shadow_by_index(s32 index)
Definition entity.c:534
s32 create_shadow_from_data(ShadowBlueprint *bp, f32 x, f32 y, f32 z)
Definition entity.c:1310
ShadowBlueprint SquareShadow
Definition Shadow.c:124
ShadowBlueprint CircularShadowB
Definition Shadow.c:115
ShadowBlueprint CircularShadowA
Definition Shadow.c:106
@ SHADOW_FIXED_ALT_CIRCLE
Definition enums.h:2540
@ SHADOW_FIXED_CIRCLE
Definition enums.h:2537
@ SHADOW_VARYING_SQUARE
Definition enums.h:2536
@ SHADOW_FIXED_SQUARE
Definition enums.h:2538
@ SHADOW_VARYING_ALT_CIRCLE
Definition enums.h:2539

Referenced by create_actor(), create_entity_shadow(), create_npc_impl(), create_part_shadow(), create_part_shadow_by_ref(), load_partner_actor(), load_player_actor(), make_item_entity(), make_item_entity_at_player(), and player_reset_data().

◆ is_point_outside_territory()

b32 is_point_outside_territory ( s32 shape,
f32 pointX,
f32 pointY,
f32 centerX,
f32 centerY,
f32 sizeX,
f32 sizeZ )

Definition at line 412 of file 23680.c.

412 {
413 f32 dist1;
414 f32 dist2;
415
416 switch (shape) {
417 case SHAPE_CYLINDER:
418 dist1 = dist2D(centerX, centerZ, pointX, pointZ);
419 return (sizeX < dist1);
420 case SHAPE_RECT:
421 dist1 = dist2D(centerX, 0, pointX, 0);
422 dist2 = dist2D(0, centerZ, 0, pointZ);
423 return ((sizeX < dist1) || (sizeZ < dist2));
424 default:
425 return FALSE;
426 }
427}
@ SHAPE_CYLINDER
Definition npc.h:197
@ SHAPE_RECT
Definition npc.h:197

Referenced by basic_ai_check_player_dist(), basic_ai_wander(), CleftAI_Tackle(), FlyingAI_Wander(), FlyingAI_WanderInit(), FlyingMagikoopaAI_15(), HoppingAI_HopInit(), LakituAI_Wander(), and PiranhaPlantAI_10().

◆ npc_raycast_down_around()

b32 npc_raycast_down_around ( s32 ignoreFlags,
f32 * posX,
f32 * posY,
f32 * posZ,
f32 * hitDepth,
f32 yaw,
f32 radius )

Definition at line 76 of file npc_collision.c.

76 {
77 f32 startX;
78 f32 startY;
79 f32 startZ;
80 f32 depth;
81 f32 x;
82 f32 y;
83 f32 z;
84 f32 originalDepth;
85 f32 hitYBehindLeft;
86 s32 hasCollision;
87 f32 cosTheta;
88 s32 colliderID;
89 f32 deltaX,deltaZ;
90 f32 theta, sinTheta, minDepth, hitYAhead, hitYBehindRight;
91
92 hasCollision = FALSE;
93 x = *posX;
94 y = *posY;
95 z = *posZ;
96 NpcHitQueryAheadY = *posY;
99 radius /= 2.5;
100 hitYBehindLeft = hitYBehindRight = hitYAhead = -32767.0f;
101 minDepth = fabsf(*hitDepth);
102
103 theta = DEG_TO_RAD(clamp_angle(yaw + 0.0f));
104 sinTheta = sin_rad(theta);
105 cosTheta = cos_rad(theta);
106 deltaX = radius * sinTheta;
107 deltaZ = -radius * cosTheta;
108
109 startX = x + deltaX;
110 startY = y;
111 startZ = z + deltaZ;
112 originalDepth = depth = minDepth;
113
114 colliderID = npc_raycast_down(ignoreFlags, &startX, &startY, &startZ, &depth);
115 if (colliderID > NO_COLLIDER) {
116 if (depth <= minDepth) {
117 hitYAhead = startY;
118 NpcHitQueryColliderID = colliderID;
119 NpcHitQueryAheadCollider = colliderID;
120 NpcHitQueryAheadY = hitYAhead;
121 minDepth = depth;
122 hasCollision = TRUE;
123 }
124 }
125
126 theta = DEG_TO_RAD(clamp_angle(yaw + 120.0f));
127 sinTheta = sin_rad(theta);
128 cosTheta = cos_rad(theta);
129 deltaX = radius * sinTheta;
130 deltaZ = -radius * cosTheta;
131
132 startX = x + deltaX;
133 startY = y;
134 startZ = z + deltaZ;
135 depth = originalDepth;
136
137 colliderID = npc_raycast_down(ignoreFlags, &startX, &startY, &startZ, &depth);
138 if (colliderID > NO_COLLIDER) {
139 if (depth <= minDepth) {
140 hitYBehindRight = startY;
141 NpcHitQueryColliderID = colliderID;
142 NpcHitQueryBehindCollider = colliderID;
143 NpcHitQueryBehindRightY = hitYBehindRight;
144 minDepth = depth;
145 hasCollision = TRUE;
146 }
147 }
148
149 theta = DEG_TO_RAD(clamp_angle(yaw - 120.0f));
150 sinTheta = sin_rad(theta);
151 cosTheta = cos_rad(theta);
152 deltaX = radius * sinTheta;
153 deltaZ = -radius * cosTheta;
154
155 startX = x + deltaX;
156 startY = y;
157 startZ = z + deltaZ;
158 depth = originalDepth;
159
160 colliderID = npc_raycast_down(ignoreFlags, &startX, &startY, &startZ, &depth);
161 if (colliderID > NO_COLLIDER) {
162 if (depth <= minDepth) {
163 hitYBehindLeft = startY;
164 NpcHitQueryColliderID = colliderID;
165 NpcHitQueryBehindCollider = colliderID;
166 NpcHitQueryBehindLeftY = hitYBehindLeft;
167 minDepth = depth;
168 hasCollision = TRUE;
169 }
170 }
171
172 if (hasCollision) {
173 *posY = MAX(hitYBehindRight, hitYAhead);
174 if (*posY < hitYBehindLeft) {
175 *posY = hitYBehindLeft;
176 }
177 *hitDepth = minDepth;
178 return TRUE;
179 }
180
181 *posY = startY;
182 return FALSE;
183}
f32 cos_rad(f32 x)
Definition 43F0.c:716
s32 NpcHitQueryBehindLeftY
HitID npc_raycast_down(s32 ignoreFlags, f32 *startX, f32 *startY, f32 *startZ, f32 *hitDepth)
s32 NpcHitQueryColliderID
s32 NpcHitQueryBehindRightY
s32 NpcHitQueryAheadCollider
s32 NpcHitQueryAheadY
s32 NpcHitQueryBehindCollider

Referenced by func_80262130(), npc_try_apply_gravity(), npc_try_snap_to_ground(), partner_flying_follow_player(), partner_flying_update_motion(), partner_get_out(), partner_move_to_goal(), partner_walking_follow_player(), test_for_water_level(), update_item_entity_collectable(), and update_riding_physics().

◆ npc_raycast_down_sides()

b32 npc_raycast_down_sides ( s32 ignoreFlags,
f32 * posX,
f32 * posY,
f32 * posZ,
f32 * hitDepth )

Definition at line 186 of file npc_collision.c.

186 {
187 f32 startX;
188 f32 startY;
189 f32 startZ;
190 f32 depth;
191 f32 x;
192 f32 y;
193 f32 z;
194 f32 originalDepth;
195 f32 hitYUnused;
196 s32 hasCollision;
197 f32 cosTheta;
198 s32 colliderID;
199 f32 deltaX,deltaZ;
200 f32 yaw;
201 f32 theta, sinTheta, minDepth, hitYAhead, hitYBehind, radius;
202
203 hasCollision = FALSE;
204
205 x = *posX;
206 y = *posY;
207 z = *posZ;
208
212
213 hitYUnused = hitYBehind = hitYAhead = -32767.0f;
214 yaw = 0.0f;
215
216 minDepth = fabsf(*hitDepth);
217 theta = DEG_TO_RAD(clamp_angle(yaw));
218 sinTheta = sin_rad(theta);
219 cosTheta = cos_rad(theta);
220
221 radius = 10.0f;
222
223 deltaX = radius * sinTheta;
224 deltaZ = -radius * cosTheta;
225
226 startX = x + deltaX;
227 startY = y;
228 startZ = z + deltaZ;
229 originalDepth = depth = minDepth;
230
231 colliderID = npc_raycast_down(ignoreFlags, &startX, &startY, &startZ, &depth);
232 if (colliderID > NO_COLLIDER) {
233 if (depth <= minDepth) {
234 hitYAhead = startY;
235 NpcHitQueryColliderID = colliderID;
236 NpcHitQueryAheadCollider = colliderID;
237 NpcHitQueryAheadY = hitYAhead;
238 minDepth = depth;
239 hasCollision = TRUE;
240 }
241 }
242
243 theta = DEG_TO_RAD(clamp_angle(yaw + 180.0f));
244 sinTheta = sin_rad(theta);
245 cosTheta = cos_rad(theta);
246 deltaX = radius * sinTheta;
247 deltaZ = -radius * cosTheta;
248
249 startX = x + deltaX;
250 startY = y;
251 startZ = z + deltaZ;
252 depth = originalDepth;
253
254 colliderID = npc_raycast_down(ignoreFlags, &startX, &startY, &startZ, &depth);
255 if (colliderID > NO_COLLIDER) {
256 if (depth <= minDepth) {
257 hitYBehind = startY;
258 NpcHitQueryColliderID = colliderID;
259 NpcHitQueryBehindCollider = colliderID;
260 NpcHitQueryBehindRightY = hitYBehind;
261 minDepth = depth;
262 hasCollision = TRUE;
263 }
264 }
265
266 if (hasCollision) {
267 *posY = MAX(hitYBehind, hitYAhead);
268 if (*posY < hitYUnused) {
269 *posY = hitYUnused;
270 }
271 *hitDepth = minDepth;
272 return TRUE;
273 }
274
275 return FALSE;
276}

◆ npc_raycast_up()

b32 npc_raycast_up ( s32 ignoreFlags,
f32 * startX,
f32 * startY,
f32 * startZ,
f32 * hitDepth )

Definition at line 278 of file npc_collision.c.

278 {
279 f32 cHitX;
280 f32 cHitY;
281 f32 cHitZ;
282 f32 cHitDepth;
283 f32 cHitNx;
284 f32 cHitNy;
285 f32 cHitNz;
286 f32 eHitX;
287 f32 eHitY;
288 f32 eHitZ;
289 f32 eHitDepth;
290 f32 eHitNx;
291 f32 eHitNy;
292 f32 eHitNz;
293 s32 entityID;
294 s32 colliderID;
295 f32 sx, sy, sz;
296 s32 ret;
297
298 eHitDepth = cHitDepth = *hitDepth;
299 sx = *startX;
300 sy = *startY;
301 sz = *startZ;
302 ret = test_ray_colliders(ignoreFlags, sx, sy, sz, 0.0f, 1.0f, 0.0f, &cHitX, &cHitY, &cHitZ, &cHitDepth, &cHitNx, &cHitNy, &cHitNz);
303 colliderID = ret;
304 if (!(ignoreFlags & COLLISION_IGNORE_ENTITIES)) {
305 entityID = test_ray_entities(sx, sy, sz, 0.0f, 1.0f, 0.0f, &eHitX, &eHitY, &eHitZ, &eHitDepth, &eHitNx, &eHitNy, &eHitNz);
306 ret = entityID | COLLISION_WITH_ENTITY_BIT;
307 if (entityID > NO_COLLIDER) {
308 cHitDepth = eHitDepth;
309 cHitX = eHitX;
310 cHitY = eHitY;
311 cHitZ = eHitZ;
312 cHitNx = eHitNx;
313 cHitNy = eHitNy;
314 cHitNz = eHitNz;
315 } else {
316 ret = colliderID;
317 }
318 }
319
320 if (ret <= NO_COLLIDER) {
321 return FALSE;
322 } else {
323 *hitDepth = cHitDepth;
324 *startX = cHitX;
325 *startY = cHitY;
326 *startZ = cHitZ;
328 return TRUE;
329 }
330}

Referenced by partner_flying_update_motion(), and update_item_entity_collectable().

◆ npc_raycast_up_corners()

HitID npc_raycast_up_corners ( s32 ignoreFlags,
f32 * posX,
f32 * posY,
f32 * posZ,
f32 * hitDepth,
f32 yaw,
f32 radius )

Definition at line 376 of file npc_collision.c.

376 {
377 f32 startX;
378 f32 startY;
379 f32 startZ;
380 f32 depth;
381 f32 theta;
382 f32 deltaZ;
383 f32 deltaX;
384 f32 x,y,z;
385 s32 ret;
386 s32 hitID;
387
388 theta = DEG_TO_RAD(yaw);
389 deltaX = radius * sin_rad(theta);
390 deltaZ = -radius * cos_rad(theta);
391
392 x = *posX;
393 y = *posY;
394 z = *posZ;
395
396 depth = *hitDepth;
397 startX = x + deltaX;
398 startY = y;
399 startZ = z + deltaZ;
400
401 ret = NO_COLLIDER;
402 hitID = npc_raycast_up_corner(ignoreFlags, &startX, &startY, &startZ, &depth);
403
404 if (hitID <= NO_COLLIDER) {
405 startX = x - deltaX;
406 startY = y;
407 startZ = z - deltaZ;
408 hitID = npc_raycast_up_corner(ignoreFlags, &startX, &startY, &startZ, &depth);
409 }
410
411 if (hitID <= NO_COLLIDER) {
412 startX = x + deltaZ;
413 startY = y;
414 startZ = z + deltaX;
415 hitID = npc_raycast_up_corner(ignoreFlags, &startX, &startY, &startZ, &depth);
416 }
417
418 if (hitID <= NO_COLLIDER) {
419 startX = x - deltaZ;
420 startY = y;
421 startZ = z - deltaX;
422 hitID = npc_raycast_up_corner(ignoreFlags, &startX, &startY, &startZ, &depth);
423 }
424
425 if (hitID > NO_COLLIDER) {
426 *posX = startX;
427 *posY = startY;
428 *posZ = startZ;
429 *hitDepth = depth;
430 ret = hitID;
431 }
432
433 if (ret <= NO_COLLIDER) {
434 *posX = startX;
435 *posY = startY;
436 *posZ = startZ;
437 *hitDepth = 0;
438 }
439
440 return ret;
441}
HitID npc_raycast_up_corner(s32 ignoreFlags, f32 *x, f32 *y, f32 *z, f32 *length)

Referenced by update_riding_physics().

◆ player_raycast_up_corners()

HitID player_raycast_up_corners ( PlayerStatus * player,
f32 * posX,
f32 * posY,
f32 * posZ,
f32 * hitDepth,
f32 yaw )

Definition at line 255 of file 77480.c.

255 {
256 f32 startX;
257 f32 startY;
258 f32 startZ;
259 f32 depth;
260 f32 theta;
261 f32 deltaZ;
262 f32 deltaX;
263 f32 x,y,z;
264 s32 ret;
265 s32 hitID;
266 f32 radius;
267
268 radius = player->colliderDiameter * 0.3f;
269 theta = DEG_TO_RAD(yaw);
270 deltaX = radius * sin_rad(theta);
271 deltaZ = -radius * cos_rad(theta);
272
273 x = *posX;
274 y = *posY;
275 z = *posZ;
276
277 depth = *hitDepth;
278 startX = x + deltaX;
279 startY = y;
280 startZ = z + deltaZ;
281
282 ret = NO_COLLIDER;
283 hitID = player_raycast_up_corner(&startX, &startY, &startZ, &depth);
284
285 if (hitID <= NO_COLLIDER) {
286 startX = x - deltaX;
287 startY = y;
288 startZ = z - deltaZ;
289 hitID = player_raycast_up_corner(&startX, &startY, &startZ, &depth);
290 }
291
292 if (hitID <= NO_COLLIDER) {
293 startX = x + deltaZ;
294 startY = y;
295 startZ = z + deltaX;
296 hitID = player_raycast_up_corner(&startX, &startY, &startZ, &depth);
297 }
298
299 if (hitID <= NO_COLLIDER) {
300 startX = x - deltaZ;
301 startY = y;
302 startZ = z - deltaX;
303 hitID = player_raycast_up_corner(&startX, &startY, &startZ, &depth);
304 }
305
306 if (hitID > NO_COLLIDER) {
307 *posX = startX;
308 *posY = startY;
309 *posZ = startZ;
310 *hitDepth = depth;
311 ret = hitID;
312 }
313
314 if (ret <= NO_COLLIDER) {
315 *posX = startX;
316 *posY = startY;
317 *posZ = startZ;
318 *hitDepth = 0;
319 }
320
321 return ret;
322}
HitID player_raycast_up_corner(f32 *x, f32 *y, f32 *z, f32 *length)
Definition 77480.c:324

Referenced by collision_main_above().

◆ player_raycast_below_cam_relative()

HitID player_raycast_below_cam_relative ( PlayerStatus * playerStatus,
f32 * outX,
f32 * outY,
f32 * outZ,
f32 * outLength,
f32 * hitRx,
f32 * hitRz,
f32 * hitDirX,
f32 * hitDirZ )

Definition at line 193 of file 77480.c.

194 {
195 f32 yaw = 0.0f;
196
197 if (playerStatus->spriteFacingAngle >= 90.0f && playerStatus->spriteFacingAngle < 270.0f) {
198 yaw = 180.0f;
199 }
200
201 return player_raycast_below(yaw - 90.0f + gCameras[gCurrentCameraID].curYaw, playerStatus->colliderDiameter,
202 outX, outY, outZ, outLength, hitRx, hitRz, hitDirX, hitDirZ);
203}
HitID player_raycast_below(f32 yaw, f32 diameter, f32 *outX, f32 *outY, f32 *outZ, f32 *outLength, f32 *hitRx, f32 *hitRz, f32 *hitDirX, f32 *hitDirZ)
Definition 77480.c:71

Referenced by action_update_sliding(), action_update_state_23(), action_update_step_down(), can_dismount(), phys_main_collision_below(), player_check_collision_below(), test_dismount_height(), test_mounting_height_adjustment(), update_current_floor(), and update_riding_physics().

◆ npc_test_move_taller_with_slipping()

b32 npc_test_move_taller_with_slipping ( s32 ignoreFlags,
f32 * x,
f32 * y,
f32 * z,
f32 length,
f32 yaw,
f32 height,
f32 radius )

Definition at line 566 of file npc_collision.c.

567 {
568 f32 xTemp = *x;
569 f32 yTemp = *y + height - 1.0f;
570 f32 zTemp = *z;
571 s32 ret;
572
573 radius *= 0.5f;
574 if (npc_test_move_with_slipping(ignoreFlags, &xTemp, &yTemp, &zTemp, fabsf(length), yaw, radius) <= NO_COLLIDER) {
575 xTemp = *x;
576 yTemp = *y + 10.01f;
577 zTemp = *z;
578 ret = npc_test_move_with_slipping(ignoreFlags, &xTemp, &yTemp, &zTemp, fabsf(length), yaw, radius) > NO_COLLIDER;
579 *x = xTemp;
580 *z = zTemp;
581 } else {
582 ret = TRUE;
583 *x = xTemp;
584 *z = zTemp;
585 }
586 return ret;
587}
HitID npc_test_move_with_slipping(s32 ignoreFlags, f32 *x, f32 *y, f32 *z, f32 length, f32 yaw, f32 radius)

Referenced by apply_riding_static_collisions(), blast_affect_entities(), check_conversation_trigger(), Entity_BoardedFloor_update_fragments(), entity_BombableRock_update_fragments(), entity_shattering_idle(), entity_WoodenCrate_update_fragments(), FlyingMagikoopaAI_15(), npc_do_world_collision(), partner_flying_follow_player(), test_first_strike(), test_first_strike(), update_encounters_neutral(), update_riding_physics(), and update_riding_physics().

◆ npc_test_move_simple_with_slipping()

b32 npc_test_move_simple_with_slipping ( s32 ignoreFlags,
f32 * x,
f32 * y,
f32 * z,
f32 length,
f32 yaw,
f32 height,
f32 radius )

Definition at line 589 of file npc_collision.c.

590 {
591 f32 tempX = *x;
592 f32 tempY = *y + 10.01f;
593 f32 tempZ = *z;
594 s32 hitID = npc_test_move_with_slipping(ignoreFlags, &tempX, &tempY, &tempZ, fabsf(length), yaw, radius * 0.5f);
595
596 *x = tempX;
597 *z = tempZ;
598
599 return hitID > NO_COLLIDER;
600}

Referenced by ai_check_fwd_collisions(), apply_riding_static_collisions(), basic_ai_chase(), basic_ai_check_player_dist(), basic_ai_loiter(), basic_ai_wander(), CleftAI_Tackle(), HoppingAI_Chase(), HoppingAI_Hop(), HoppingAI_HopInit(), npc_do_world_collision(), PiranhaPlantAI_10(), UnkNpcAIFunc12(), and update_item_entity_collectable().

◆ npc_test_move_complex_with_slipping()

s32 npc_test_move_complex_with_slipping ( s32 ignoreFlags,
f32 * x,
f32 * y,
f32 * z,
f32 length,
f32 yaw,
f32 height,
f32 radius )

Definition at line 618 of file npc_collision.c.

619 {
620 f32 startX;
621 f32 startY;
622 f32 startZ;
623 s32 ret = 0;
624 s32 hitID;
625
626 radius *= 0.5f;
627 startX = *x;
628 startY = *y + height - 1.0f;
629 startZ = *z;
630 if (npc_test_move_with_slipping(ignoreFlags, &startX, &startY, &startZ, fabsf(length), yaw, radius) > NO_COLLIDER) {
631 *x = startX;
632 *z = startZ;
633 ret = 4;
634 }
635
636 startX = *x;
637 startY = *y + 20.0f;
638 startZ = *z;
639 if (npc_test_move_with_slipping(ignoreFlags, &startX, &startY, &startZ, fabsf(length), yaw, radius) > NO_COLLIDER) {
640 *x = startX;
641 *z = startZ;
642 ret = 3;
643 }
644
645 startX = *x;
646 startY = *y + 15.01f;
647 startZ = *z;
648 if (npc_test_move_with_slipping(ignoreFlags, &startX, &startY, &startZ, fabsf(length), yaw, radius) > NO_COLLIDER) {
649 *x = startX;
650 *z = startZ;
651 ret = 2;
652 }
653
654 startX = *x;
655 startY = *y + 10.01f;
656 startZ = *z;
657 hitID = npc_test_move_with_slipping(ignoreFlags, &startX, &startY, &startZ, fabsf(length), yaw, radius);
658 *x = startX;
659 *z = startZ;
660 if (hitID > NO_COLLIDER) {
661 ret = 1;
662 }
663
664 return ret;
665}

Referenced by apply_riding_static_collisions(), npc_do_world_collision(), update_item_entity_collectable(), and update_riding_physics().

◆ partner_get_enter_map_script()

EvtScript * partner_get_enter_map_script ( void )

Definition at line 1058 of file partners.c.

1058 {
1059 WorldPartner* partner = wPartner;
1060
1061 if (partner == NULL) {
1062 return NULL;
1063 }
1064 return partner->onEnterMap;
1065}
EvtScript * onEnterMap
Definition partners.h:24

◆ partner_handle_before_battle()

void partner_handle_before_battle ( void )

Definition at line 1067 of file partners.c.

1067 {
1069 s32* scriptID = &wPartnerCurrentScriptID;
1070
1071 if (does_script_exist(*scriptID)) {
1072 kill_script_by_ID(*scriptID);
1073 }
1074
1075 if (wPartner->preBattle != NULL) {
1077 }
1078 }
1079}
BSS s32 wPartnerCurrentScriptID
Definition partners.c:58
PartnerFunc preBattle
Definition partners.h:22

Referenced by update_encounters_pre_battle().

◆ partner_walking_update_player_tracking()

void partner_walking_update_player_tracking ( Npc * partner)

Definition at line 1175 of file partners.c.

1175 {
1176 PlayerStatus* playerStatus = &gPlayerStatus;
1177 s32 isPlayerJumping;
1178 PlayerPathElement* currentSnapshot;
1179
1180 if (playerStatus->flags & (PS_FLAG_FALLING | PS_FLAG_JUMPING)) {
1181 isPlayerJumping = (playerStatus->actionState == ACTION_STATE_LAND || playerStatus->actionState == ACTION_STATE_STEP_DOWN) ^ 1;
1182 } else {
1183 isPlayerJumping = FALSE;
1184 }
1185 currentSnapshot = &gPlayerMoveHistory[gPlayerMoveHistoryIndex];
1186 if ((!currentSnapshot->isJumping || !isPlayerJumping) &&
1187 ((currentSnapshot->pos.x != playerStatus->pos.x) || (currentSnapshot->pos.y != playerStatus->pos.y)
1188 || (currentSnapshot->pos.z != playerStatus->pos.z))) {
1192 }
1193 currentSnapshot = &gPlayerMoveHistory[gPlayerMoveHistoryIndex];
1194 currentSnapshot->pos.x = playerStatus->pos.x;
1195 currentSnapshot->pos.y = playerStatus->pos.y;
1196 currentSnapshot->pos.z = playerStatus->pos.z;
1197 currentSnapshot->isJumping = isPlayerJumping;
1198 }
1199 }
1200}
BSS PlayerPathElement gPlayerMoveHistory[40]
Definition partners.c:46
BSS s32 gPlayerMoveHistoryIndex
Definition partners.c:47
BSS s32 D_8010CFBC
Definition partners.c:48

◆ partner_walking_update_motion()

void partner_walking_update_motion ( Npc * partner)

Definition at line 1202 of file partners.c.

1202 {
1203 PlayerStatus* playerStatus = &gPlayerStatus;
1204 PartnerStatus* partnerStatus = &gPartnerStatus;
1205
1207 || partnerStatus->inputDisabledCount != 0 || partnerStatus->partnerAction_unk_2) {
1208 if (!(playerStatus->animFlags & PA_FLAG_OPENED_HIDDEN_PANEL)) {
1210 }
1211 if (partnerStatus->pressedButtons & (BUTTON_Z | BUTTON_B | BUTTON_C_LEFT | BUTTON_C_DOWN)) {
1212 partnerStatus->partnerAction_unk_2 = FALSE;
1213 }
1214 }
1215
1216 if (wPartnerFollowState != 50 && fabsf(partner->pos.y - playerStatus->pos.y) > 1000.0f) {
1217 partner->pos.x = playerStatus->pos.x;
1218 partner->pos.y = playerStatus->pos.y;
1219 partner->pos.z = playerStatus->pos.z;
1220 partner->jumpVel = 0.0f;
1221 partner->jumpScale = 0.0f;
1222 partner->flags = partner->flags & ~PA_FLAG_OPENED_HIDDEN_PANEL;
1223 }
1224
1226 wSavedPartnerPosX = partner->pos.x;
1227 wSavedPartnerPosY = partner->pos.y;
1228 wSavedPartnerPosZ = partner->pos.z;
1229}
@ BUTTON_C_LEFT
Definition enums.h:2778
@ PA_FLAG_OPENED_HIDDEN_PANEL
Definition enums.h:3102
void partner_walking_follow_player(Npc *partner)
Definition partners.c:1231
PartnerStatus gPartnerStatus
Definition partners.c:42
BSS s16 wPartnerFollowState
Definition partners.c:51
void partner_do_player_collision(Npc *partner)
Definition partners.c:2495
f32 jumpScale
f32 jumpVel
s32 flags

◆ enable_partner_ai()

void enable_partner_ai ( void )

Definition at line 2390 of file partners.c.

2390 {
2393
2394 if (!wPartner->isFlying) {
2396 } else {
2398 }
2399}
void partner_clear_player_tracking(Npc *partner)
Definition partners.c:2436
void partner_walking_enable(Npc *partner, s32 val)
Definition partners.c:1133
void partner_flying_enable(Npc *partner, s32 val)
Definition partners.c:1706

Referenced by action_update_use_spinning_flower(), entity_CymbalPlant_idle(), and func_802BC32C_E2EC5C().

◆ partner_walking_enable()

void partner_walking_enable ( Npc * partner,
s32 val )

Definition at line 1133 of file partners.c.

1133 {
1134 PlayerStatus* playerStatus = &gPlayerStatus;
1136 s32 i;
1137
1138 partner->pos.x = wSavedPartnerPosX;
1139 partner->pos.y = wSavedPartnerPosY;
1140 partner->pos.z = wSavedPartnerPosZ;
1141
1142 for (i = 0; i < ARRAY_COUNT(gPlayerMoveHistory); i++, it++) {
1143 it->pos.x = playerStatus->pos.x;
1144 it->pos.y = playerStatus->pos.y;
1145 it->pos.z = playerStatus->pos.z;
1146 it->isJumping = FALSE;
1147 }
1148
1150 D_8010CFBC = 0;
1151 D_8010CFCA = val ? 2 : 0;
1153
1154 if (D_8010CFC4 == 1 || D_8010CFC4 == 3) {
1155 D_8010CFC4 = 0;
1156 D_8010CFCA = 0;
1158 } else if (D_8010CFC4 == 2) {
1159 D_8010CFCA = 0;
1161 }
1162
1163 D_8010CFCE = 0;
1164 D_8010CFCC = 0;
1165 wPartnerMoveTime = 16;
1166 wPartnerTetherDistance = 40.0f;
1168 func_800EA5B8(partner);
1170 partner->jumpVel = 0.0f;
1172 partner->jumpScale = 1.8f;
1173}
@ NPC_FLAG_TOUCHES_GROUND
Definition enums.h:3020
@ NPC_FLAG_GRAVITY
Definition enums.h:3007
BSS s16 D_8010CFCC
Definition partners.c:53
PartnerAnimations gPartnerAnimations[]
Definition partners.c:343
void func_800EA5B8(Npc *partner)
Definition partners.c:576
BSS s32 D_8010CFC4
Definition partners.c:50
BSS s16 D_8010CFCA
Definition partners.c:52
s32 wPartnerMoveTime
Definition partners.c:161
BSS f32 wPartnerTetherDistance
Definition partners.c:49
BSS s16 D_8010CFCE
Definition partners.c:54
s32 collisionChannel

Referenced by enable_partner_ai().

◆ partner_flying_enable()

void partner_flying_enable ( Npc * partner,
s32 val )

Definition at line 1706 of file partners.c.

1706 {
1707 PlayerStatus* playerStatus = &gPlayerStatus;
1709 s32 i;
1710
1711 partner->pos.x = wSavedPartnerPosX;
1712 partner->pos.y = wSavedPartnerPosY;
1713 partner->pos.z = wSavedPartnerPosZ;
1714
1715 for (i = 0; i < ARRAY_COUNT(gPlayerMoveHistory); i++, it++) {
1716 it->pos.x = wSavedPartnerPosX;
1717 it->pos.y = wSavedPartnerPosY;
1718 it->pos.z = wSavedPartnerPosZ;
1719 it->isJumping = FALSE;
1720 }
1721
1723 D_8010CFBC = 0;
1724
1725 if (!val) {
1727 D_8010CFCA = 0;
1728 } else if (D_8010CFC4 == 0) {
1730 D_8010CFCA = 2;
1731 } else if (D_8010CFC4 == 1 || D_8010CFC4 == 3) {
1732 D_8010CFC4 = 0;
1734 D_8010CFCA = 0;
1735 } else if (D_8010CFC4 == 2) {
1737 D_8010CFCA = 0;
1738 }
1739
1740 D_8010CFCE = 0;
1741 D_8010CFCC = 0;
1742 wPartnerMoveTime = 16;
1743 wPartnerTetherDistance = 40.0f;
1745 func_800EA5B8(partner);
1748 partner->flags &= ~NPC_FLAG_GRAVITY;
1749}

Referenced by enable_partner_ai().

◆ partner_flying_update_player_tracking()

void partner_flying_update_player_tracking ( Npc * partner)

Definition at line 1751 of file partners.c.

1751 {
1752 PlayerStatus* playerStatus = &gPlayerStatus;
1753 PlayerPathElement* currentSnapshot;
1754 f32 effectiveY;
1755 s32 isPlayerJumping = FALSE;
1756
1757 effectiveY = playerStatus->pos.y;
1758 if ((playerStatus->actionState == ACTION_STATE_HIT_LAVA) || (playerStatus->actionState == ACTION_STATE_HIT_FIRE)) {
1759 effectiveY = playerStatus->lastGoodPos.y + partner->collisionHeight + 5;
1760 }
1761 currentSnapshot = &gPlayerMoveHistory[gPlayerMoveHistoryIndex];
1762 if ((!currentSnapshot->isJumping || !isPlayerJumping) && (currentSnapshot->pos.x != playerStatus->pos.x || currentSnapshot->pos.y != effectiveY
1763 || currentSnapshot->pos.z != playerStatus->pos.z)) {
1767 }
1768 currentSnapshot = &gPlayerMoveHistory[gPlayerMoveHistoryIndex];
1769 currentSnapshot->pos.x = playerStatus->pos.x;
1770 currentSnapshot->pos.y = effectiveY;
1771 currentSnapshot->pos.z = playerStatus->pos.z;
1772 currentSnapshot->isJumping = isPlayerJumping;
1773 }
1774 }
1775}
s16 collisionHeight

◆ partner_is_flying()

s32 partner_is_flying ( void )

Definition at line 572 of file partners.c.

572 {
573 return !wPartner->isFlying;
574}

◆ partner_flying_update_motion()

void partner_flying_update_motion ( Npc * partner)

Definition at line 1777 of file partners.c.

1777 {
1778 PlayerStatus* playerStatus = &gPlayerStatus;
1779 PartnerStatus* partnerStatus = &gPartnerStatus;
1780 f32 x, y, z, hitDepth;
1781 f32 var_f0;
1782 f32 var_f2;
1783
1786 partnerStatus->inputDisabledCount ||
1787 partnerStatus->partnerAction_unk_2)
1788 {
1789 if (!(playerStatus->animFlags & PA_FLAG_OPENED_HIDDEN_PANEL) || D_800F8020 == 0) {
1791 }
1792 if (partnerStatus->pressedButtons & (BUTTON_B | BUTTON_Z | BUTTON_C_DOWN | BUTTON_C_LEFT)) {
1793 partnerStatus->partnerAction_unk_2 = FALSE;
1794 }
1795 }
1796 if (wPartnerFollowState != 50 && fabsf(partner->pos.y - playerStatus->pos.y) > 1000.0f) {
1797 partner->pos.x = playerStatus->pos.x;
1798 partner->pos.y = playerStatus->pos.y;
1799 partner->pos.z = playerStatus->pos.z;
1800 partner->jumpVel = 0.0f;
1801 partner->jumpScale = 0.0f;
1802 partner->flags &= ~NPC_FLAG_JUMPING;
1803 }
1804
1805 D_800F8020 = 0;
1806 x = partner->pos.x;
1807 y = partner->pos.y + (partner->collisionHeight * 0.5f);
1808 z = partner->pos.z;
1809
1810 hitDepth = partner->collisionHeight * 0.5f;
1811 if (npc_raycast_up(0, &x, &y, &z, &hitDepth)) {
1812 D_800F8020 = 1;
1813 wSavedPartnerPosX = partner->pos.x;
1814 wSavedPartnerPosY = partner->pos.y;
1815 wSavedPartnerPosZ = partner->pos.z;
1816 } else {
1818 if (wPartnerFollowState != 50) {
1819 x = partner->pos.x;
1820 y = partner->pos.y;
1821 z = partner->pos.z;
1822 hitDepth = 1000.0f;
1823 if (npc_raycast_down_around(COLLIDER_FLAG_IGNORE_PLAYER, &x, &y, &z, &hitDepth, partner->yaw, partner->collisionDiameter) == 0) {
1824 y = playerStatus->pos.y;
1825 }
1826
1827 if (partner->pos.y <= y + partner->collisionHeight + 2.0f) {
1828 if (playerStatus->curSpeed != 0.0f) {
1829 D_800F84F8 = ((y + (partner->collisionHeight / 2) + 2.0f) - partner->pos.y) * 0.125f;
1830 } else {
1831 if (y < playerStatus->pos.y) {
1832 var_f0 = playerStatus->pos.y + 10.0f - partner->pos.y;
1833 } else {
1834 var_f0 = y + 10.0f - partner->pos.y;
1835 }
1836 var_f2 = 0.25f;
1837 D_800F84F8 = var_f0 * var_f2;
1838 }
1839 } else {
1840 if (playerStatus->pos.y + playerStatus->colliderHeight < y) {
1841 D_800F84F8 = (y + partner->collisionHeight - partner->pos.y) * 0.125f;
1842 if (partner->pos.y + D_800F84F8 <= y + partner->collisionHeight) {
1843 D_800F84F8 = (y + partner->collisionHeight - partner->pos.y) * 0.25f;
1844 }
1845 } else {
1846 var_f0 = (playerStatus->pos.y + playerStatus->colliderHeight + 5.0f) - partner->pos.y;
1847 var_f2 = 0.0625f;
1848 D_800F84F8 = var_f0 * var_f2;
1849 }
1850 }
1851 partner->pos.y += D_800F84F8;
1852 }
1853 wSavedPartnerPosX = partner->pos.x;
1854 wSavedPartnerPosY = partner->pos.y;
1855 wSavedPartnerPosZ = partner->pos.z;
1856 }
1857}
b32 npc_raycast_down_around(s32, f32 *, f32 *, f32 *, f32 *, f32, f32)
b32 npc_raycast_up(s32, f32 *, f32 *, f32 *, f32 *)
s32 D_800F8020
Definition partners.c:158
f32 D_800F84F8
Definition partners.c:495
void partner_flying_follow_player(Npc *)
Definition partners.c:1859
s16 collisionDiameter

◆ partner_clear_player_tracking()

◆ partner_set_tether_distance()

void partner_set_tether_distance ( f32 dist)

Definition at line 2401 of file partners.c.

2401 {
2403}

◆ btl_delete_player_actor()

void btl_delete_player_actor ( Actor * player)

Definition at line 1175 of file 16C8E0.c.

1175 {
1176 ActorPart* partsTable;
1177 ActorPartMovement* movement;
1178 DecorationTable* decorations;
1179 s32 i;
1180
1181 for (i = 0; i < 2; i++) {
1182 remove_actor_decoration(player, i);
1183 }
1184
1185 if (player->idleScript != NULL) {
1187 }
1188 if (player->handleEventScript != NULL) {
1190 }
1191 if (player->takeTurnScript != NULL) {
1193 }
1194
1195 partsTable = player->partsTable;
1196 decorations = partsTable->decorationTable;
1197 movement = partsTable->movement;
1198
1199 delete_shadow(player->shadow.id);
1202
1203 if (player->attackResultEffect != NULL) {
1205 }
1206
1207 heap_free(movement);
1208 heap_free(decorations);
1209 heap_free(partsTable);
1210 heap_free(player);
1211}
s32 idleScriptID
void remove_actor_decoration(Actor *actor, s32 decorationIndex)
Definition 190B20.c:2754
void delete_shadow(s32)
Definition entity.c:626
void remove_all_status_icons(s32)

Referenced by btl_state_update_end_battle(), and btl_state_update_end_demo_battle().

◆ cancel_message()

s32 cancel_message ( MessagePrintState * msgPrintState)

Definition at line 1507 of file msg.c.

1507 {
1508 if (!(msgPrintState->stateFlags & MSG_STATE_FLAG_2)) {
1509 return FALSE;
1510 }
1511
1512 msgPrintState->stateFlags |= MSG_STATE_FLAG_1;
1513 return TRUE;
1514}
@ MSG_STATE_FLAG_1
Definition enums.h:6238
@ MSG_STATE_FLAG_2
Definition enums.h:6239

Referenced by cancel_current_message().

◆ set_message_images()

void set_message_images ( MessageImageData * images)

Definition at line 1516 of file msg.c.

1516 {
1517 *gMsgVarImages = images;
1518}
MessageImageDataList gMsgVarImages
Definition msg.c:90

◆ kill_all_scripts()

void kill_all_scripts ( void )

Definition at line 675 of file script_list.c.

675 {
676 s32 i;
677 Evt* scriptContextPtr;
678
679 for (i = 0; i < MAX_SCRIPTS; i++) {
680 scriptContextPtr = (*gCurrentScriptListPtr)[i];
681 if (scriptContextPtr != NULL) {
682 kill_script(scriptContextPtr);
683 }
684 }
685}

Referenced by btl_state_update_end_battle(), and btl_state_update_end_demo_battle().

◆ does_script_exist()

s32 does_script_exist ( s32 id)

Definition at line 687 of file script_list.c.

687 {
688 s32 i;
689 Evt* scriptContextPtr;
690
691 for (i = 0; i < MAX_SCRIPTS; i++) {
692 scriptContextPtr = (*gCurrentScriptListPtr)[i];
693 if (scriptContextPtr != NULL && scriptContextPtr->id == id) {
694 return TRUE;
695 }
696 }
697 return FALSE;
698}

Referenced by _use_partner_ability(), btl_state_update_9(), btl_state_update_begin_partner_turn(), btl_state_update_begin_player_turn(), btl_state_update_begin_turn(), btl_state_update_celebration(), btl_state_update_change_partner(), btl_state_update_defeat(), btl_state_update_defend(), btl_state_update_end_battle(), btl_state_update_end_demo_battle(), btl_state_update_end_player_turn(), btl_state_update_end_training_battle(), btl_state_update_end_turn(), btl_state_update_enemy_move(), btl_state_update_enemy_striking_first(), btl_state_update_first_strike(), btl_state_update_next_enemy(), btl_state_update_normal_start(), btl_state_update_partner_move(), btl_state_update_partner_striking_first(), btl_state_update_player_move(), btl_state_update_run_away(), btl_state_update_victory(), create_encounters(), evt_handle_does_script_exist(), evt_trigger_on_activate_exec_script(), evt_trigger_on_activate_lock(), partner_handle_after_battle(), partner_handle_before_battle(), partner_kill_ability_script(), partner_resume_ability_script(), partner_suspend_ability_script(), state_step_change_map(), state_step_enter_world(), state_step_game_over(), state_step_intro(), update_encounters_conversation(), update_encounters_post_battle(), update_entities(), and update_item_entity_collectable().

◆ does_script_exist_by_ref()

s32 does_script_exist_by_ref ( Evt * script)

Definition at line 700 of file script_list.c.

700 {
701 s32 i;
702
703 for (i = 0; i < MAX_SCRIPTS; i++) {
704 if (script == (*gCurrentScriptListPtr)[i]) {
705 return TRUE;
706 }
707 }
708 return FALSE;
709}

◆ start_script()

Evt * start_script ( EvtScript * source,
s32 priority,
s32 initialState )

Definition at line 217 of file script_list.c.

217 {
218 Evt* newScript;
219 s32 scriptListCount;
220 s32 curScriptIndex;
221 s32 i;
222
223 for (i = 0; i < MAX_SCRIPTS; i++) {
224 if ((*gCurrentScriptListPtr)[i] == NULL) {
225 break;
226 }
227 }
228
229 ASSERT(i < MAX_SCRIPTS);
230 curScriptIndex = i;
231
232 (*gCurrentScriptListPtr)[curScriptIndex] = newScript = heap_malloc(sizeof(*newScript));
233 gNumScripts++;
234 ASSERT(newScript != NULL);
235
236 newScript->stateFlags = flags | EVT_FLAG_ACTIVE;
237 newScript->curOpcode = EVT_OP_INTERNAL_FETCH;
238 newScript->priority = priority;
239 newScript->id = UniqueScriptCounter++;
240 newScript->ptrNextLine = (Bytecode*)source;
241 newScript->ptrFirstLine = (Bytecode*)source;
242 newScript->ptrCurLine = (Bytecode*)source;
243 newScript->userData = NULL;
244 newScript->blockingParent = NULL;
245 newScript->childScript = NULL;
246 newScript->parentScript = NULL;
247 newScript->owner1.actorID = -1;
248 newScript->owner2.npcID = -1;
249 newScript->loopDepth = -1;
250 newScript->switchDepth = -1;
251 newScript->groupFlags = EVT_GROUP_NOT_BATTLE;
252 newScript->ptrSavedPos = NULL;
253 newScript->frameCounter = 0.0f;
254 newScript->unk_158 = 0;
255 newScript->timeScale = GlobalTimeRate;
256
257 scriptListCount = 0;
258
259 for (i = 0; i < ARRAY_COUNT(newScript->varTable); i++) {
260 newScript->varTable[i] = 0;
261 }
262
263 for (i = 0; i < ARRAY_COUNT(newScript->varFlags); i++) {
264 newScript->varFlags[i] = 0;
265 }
266
267 find_script_labels(newScript);
268
270 scriptListCount = gScriptListCount++;
271 gScriptIndexList[scriptListCount] = curScriptIndex;
272 gScriptIdList[scriptListCount] = newScript->id;
273 }
274
275 suspend_frozen_scripts(newScript);
276
277 if (UniqueScriptCounter == 0) {
279 }
280
281 return newScript;
282}

Referenced by _use_partner_ability(), bind_enemy_ai(), bind_enemy_aux(), bind_enemy_interact(), btl_cam_use_preset_impl(), btl_state_update_9(), btl_state_update_begin_partner_turn(), btl_state_update_begin_player_turn(), btl_state_update_begin_turn(), btl_state_update_celebration(), btl_state_update_change_partner(), btl_state_update_defeat(), btl_state_update_defend(), btl_state_update_end_battle(), btl_state_update_end_demo_battle(), btl_state_update_end_player_turn(), btl_state_update_end_training_battle(), btl_state_update_end_turn(), btl_state_update_enemy_move(), btl_state_update_enemy_striking_first(), btl_state_update_first_strike(), btl_state_update_next_enemy(), btl_state_update_normal_start(), btl_state_update_partner_move(), btl_state_update_partner_striking_first(), btl_state_update_player_move(), btl_state_update_run_away(), btl_state_update_victory(), calc_enemy_damage_target(), calc_item_damage_enemy(), calc_partner_damage_enemy(), calc_player_damage_enemy(), create_actor(), create_encounters(), dispatch_event_actor(), dispatch_event_partner(), dispatch_event_partner_continue_turn(), dispatch_event_player(), dispatch_event_player_continue_turn(), entity_Chest_adjust_camera(), entity_Chest_reset_camera(), evt_trigger_on_activate_exec_script(), evt_trigger_on_activate_lock(), FireBarAI_Callback(), func_80048E34(), load_partner_actor(), partner_handle_after_battle(), shop_owner_begin_speech(), shop_owner_buy_dialog(), shop_owner_continue_speech(), shop_owner_continue_speech_with_quantity(), shop_owner_end_speech(), shop_owner_reset_speech(), start_battle(), start_rumble_type(), update_encounters_neutral(), update_encounters_post_battle(), update_entities(), and use_consumable().

◆ start_script_in_group()

Evt * start_script_in_group ( EvtScript * source,
u8 priority,
u8 initialState,
u8 groupFlags )

Definition at line 284 of file script_list.c.

284 {
285 Evt* newScript;
286 s32 scriptListCount;
287 s32 curScriptIndex;
288 s32 i;
289
290 for (i = 0; i < MAX_SCRIPTS; i++) {
291 if ((*gCurrentScriptListPtr)[i] == NULL) {
292 break;
293 }
294 }
295
296 ASSERT(i < MAX_SCRIPTS);
297 curScriptIndex = i;
298
299 (*gCurrentScriptListPtr)[curScriptIndex] = newScript = heap_malloc(sizeof(*newScript));
300 gNumScripts++;
301 ASSERT(newScript != NULL);
302
303 newScript->stateFlags = flags | EVT_FLAG_ACTIVE;
304 newScript->curOpcode = EVT_OP_INTERNAL_FETCH;
305 newScript->priority = priority;
306 newScript->id = UniqueScriptCounter++;
307 newScript->ptrNextLine = (Bytecode*)source;
308 newScript->ptrFirstLine = (Bytecode*)source;
309 newScript->ptrCurLine = (Bytecode*)source;
310 newScript->userData = NULL;
311 newScript->blockingParent = NULL;
312 newScript->childScript = NULL;
313 newScript->parentScript = NULL;
314 newScript->owner1.actorID = -1;
315 newScript->owner2.npcID = -1;
316 newScript->loopDepth = -1;
317 newScript->switchDepth = -1;
318 newScript->groupFlags = groupFlags;
319 newScript->ptrSavedPos = NULL;
320 newScript->frameCounter = 0.0f;
321 newScript->unk_158 = 0;
322 newScript->timeScale = GlobalTimeRate;
323
324 scriptListCount = 0;
325
326 for (i = 0; i < ARRAY_COUNT(newScript->varTable); i++) {
327 newScript->varTable[i] = 0;
328 }
329 for (i = 0; i < ARRAY_COUNT(newScript->varFlags); i++) {
330 newScript->varFlags[i] = 0;
331 }
332
333 find_script_labels(newScript);
334
336 scriptListCount = gScriptListCount++;
337 gScriptIndexList[scriptListCount] = curScriptIndex;
338 gScriptIdList[scriptListCount] = newScript->id;
339 }
340
341 suspend_frozen_scripts(newScript);
342
343 if (UniqueScriptCounter == 0) {
345 }
346
347 return newScript;
348}

Referenced by evt_handle_exec1(), evt_handle_exec1_get_id(), evt_handle_thread(), exec_ShakeCam1(), exec_ShakeCamX(), load_map_by_IDs(), and update_encounters_post_battle().

◆ get_player_normal_yaw()

f32 get_player_normal_yaw ( void )

Definition at line 657 of file 43F0.c.

Referenced by player_raycast_down(), and update_player_shadow().

◆ set_standard_shadow_scale()

void set_standard_shadow_scale ( Shadow * shadow,
f32 scale )

Definition at line 1674 of file entity.c.

1674 {
1676 shadow->scale.x = 0.13 - (height / 2600.0f);
1677 } else {
1678 shadow->scale.x = 0.12 - (height / 3600.0f);
1679 }
1680
1681 if (shadow->scale.x < 0.01) {
1682 shadow->scale.x = 0.01f;
1683 }
1684 shadow->scale.z = shadow->scale.x;
1685}
Vec3f scale

Referenced by make_item_entity(), make_item_entity_at_player(), update_item_entities(), update_nonplayer_actor_shadow(), update_player_actor_shadow(), and update_player_shadow().

◆ set_npc_shadow_scale()

void set_npc_shadow_scale ( Shadow * shadow,
f32 height,
f32 npcRadius )

Definition at line 1687 of file entity.c.

1687 {
1689 shadow->scale.x = 0.13 - (height / 2600.0f);
1690 } else {
1691 shadow->scale.x = 0.12 - (height / 3600.0f);
1692 }
1693
1694 if (shadow->scale.x < 0.01) {
1695 shadow->scale.x = 0.01f;
1696 }
1697
1698 if (npcRadius > 60.0f) {
1699 shadow->scale.z = shadow->scale.x * 2.0f;
1700 } else {
1701 shadow->scale.z = shadow->scale.x;
1702 }
1703}

Referenced by update_npcs().

◆ set_npc_animation()

void set_npc_animation ( Npc * npc,
u32 animID )

Definition at line 18 of file npc_api.c.

18 {
19 PlayerData* playerData = &gPlayerData;
20
21 if (PARTNER_ANIM_STILL <= animID && animID <= PARTNER_ANIM_HURT) {
22 npc->curAnim = gPartnerAnimations[playerData->curPartner].anims[animID - PARTNER_ANIM_STILL];
23 } else if (ENEMY_ANIM_IDLE <= animID && animID <= ENEMY_ANIM_F) {
24 npc->curAnim = get_enemy(npc->npcID)->animList[animID - ENEMY_ANIM_IDLE];
25 } else {
26 npc->curAnim = animID;
27 }
28}
@ PARTNER_ANIM_STILL
Definition enums.h:3414
@ PARTNER_ANIM_HURT
Definition enums.h:3422
@ ENEMY_ANIM_F
Definition enums.h:3454
@ ENEMY_ANIM_IDLE
Definition enums.h:3439
s32 * animList
Definition npc.h:341
PartnerAnimations gPartnerAnimations[12]
Definition partners.c:343

Referenced by _show_message().

◆ set_peach_shadow_scale()

void set_peach_shadow_scale ( Shadow * shadow,
f32 scale )

Definition at line 1705 of file entity.c.

1705 {
1706 PlayerStatus* playerStatus = &gPlayerStatus;
1707 f32 phi_f2 = 0.12f;
1708
1710 switch (playerStatus->anim) {
1711 case ANIM_Peach2_Carried:
1712 case ANIM_Peach2_Thrown:
1713 case ANIM_Peach2_Land:
1714 case ANIM_Peach3_TiedSideways:
1715 shadow->scale.x = 0.26f - (scale / 2600.0f);
1716 if (shadow->scale.x < 0.01) {
1717 shadow->scale.x = 0.01f;
1718 }
1719 shadow->scale.z = 0.13f - (scale / 2600.0f);
1720 if (shadow->scale.z < 0.01) {
1721 shadow->scale.z = 0.01f;
1722 }
1723 return;
1724 }
1725
1726 phi_f2 = 0.16f;
1727 }
1728
1729 shadow->scale.x = phi_f2 - (scale / 3600.0f);
1730 if (shadow->scale.x < 0.01) {
1731 shadow->scale.x = 0.01f;
1732 }
1733 shadow->scale.z = shadow->scale.x;
1734}

Referenced by update_player_shadow().

◆ is_block_on_ground()

s32 is_block_on_ground ( Entity * block)

Definition at line 1736 of file entity.c.

1736 {
1737 f32 x = block->pos.x;
1738 f32 y = block->pos.y;
1739 f32 z = block->pos.z;
1740 f32 hitYaw;
1741 f32 hitPitch;
1742 f32 hitLength;
1743 s32 ret;
1744
1745 entity_raycast_down(&x, &y, &z, &hitYaw, &hitPitch, &hitLength);
1746
1747 ret = hitLength;
1748 if (ret == 32767) {
1749 ret = FALSE;
1750 }
1751
1752 return ret;
1753}
b32 entity_raycast_down(f32 *x, f32 *y, f32 *z, f32 *hitYaw, f32 *hitPitch, f32 *hitLength)
Mostly used for shadows.
Definition entity.c:1637

Referenced by entity_base_block_idle(), entity_ItemBlock_replace_with_inactive(), and entity_shattering_init_pieces().

◆ set_actor_anim()

void set_actor_anim ( s32 actorID,
s32 partID,
AnimID animID )

Definition at line 1005 of file 190B20.c.

1005 {
1006 if ((s32) animID >= 0) {
1007 Actor* actor = get_actor(actorID);
1008 ActorPart* part;
1009
1010 switch (actorID & ACTOR_CLASS_MASK) {
1011 case ACTOR_CLASS_PLAYER:
1012 part = &actor->partsTable[0];
1013 if (part->curAnimation != animID) {
1014 part->curAnimation = animID;
1016 }
1017 break;
1019 if (partID != 0) {
1020 part = get_actor_part(actor, partID);
1021
1022 if (part == NULL) {
1023 part = &actor->partsTable[0];
1024 }
1025 } else {
1026 part = &actor->partsTable[0];
1027 }
1028
1029 if (part->curAnimation != animID) {
1030 part->curAnimation = animID;
1031 spr_update_sprite(part->spriteInstanceID, animID, part->animationRate);
1033 }
1034 break;
1035 case ACTOR_CLASS_ENEMY:
1036 part = get_actor_part(actor, partID);
1037 if (part->curAnimation != animID) {
1038 part->curAnimation = animID;
1039 spr_update_sprite(part->spriteInstanceID, animID, part->animationRate);
1041 }
1042 break;
1043 }
1044 }
1045}
ActorPart * get_actor_part(Actor *actor, s32 partID)
Definition 190B20.c:1191

Referenced by btl_set_player_idle_anims(), btl_state_update_celebration(), btl_state_update_partner_menu(), btl_state_update_peach_menu(), btl_state_update_player_menu(), and btl_state_update_twink_menu().

◆ set_actor_anim_rate()

void set_actor_anim_rate ( s32 actorID,
s32 partID,
f32 rate )

Definition at line 1068 of file 190B20.c.

1068 {
1069 Actor* actor = get_actor(actorID);
1070 ActorPart* part;
1071
1072 switch (actorID & ACTOR_CLASS_MASK) {
1074 if (partID != 0) {
1075 part = get_actor_part(actor, partID);
1076 if (part != NULL) {
1077 part->animationRate = rate;
1078 return;
1079 }
1080 }
1081 actor->partsTable[0].animationRate = rate;
1082 break;
1083 case ACTOR_CLASS_PLAYER:
1084 case ACTOR_CLASS_ENEMY:
1085 part = get_actor_part(actor, partID);
1086 part->animationRate = rate;
1087 break;
1088 }
1089}

◆ mdl_group_set_visibility()

void mdl_group_set_visibility ( u16 treeIndex,
s32 flags,
s32 mode )

Definition at line 3636 of file model.c.

3636 {
3637 s32 maxGroupIndex = -1;
3638 s32 minGroupIndex;
3639 s32 modelIndex = (*gCurrentModelTreeNodeInfo)[treeIndex].modelIndex;
3640 s32 siblingIndex;
3641 s32 i;
3642
3643 if (modelIndex < MAX_MODELS - 1) {
3644 minGroupIndex = maxGroupIndex = modelIndex;
3645 } else {
3646 s32 treeDepth = (*gCurrentModelTreeNodeInfo)[treeIndex].treeDepth;
3647 for (i = treeIndex - 1; i >= 0; i--) {
3648 if ((*gCurrentModelTreeNodeInfo)[i].treeDepth <= treeDepth) {
3649 break;
3650 }
3651
3652 siblingIndex = (*gCurrentModelTreeNodeInfo)[i].modelIndex;
3653
3654 if (siblingIndex < MAX_MODELS - 1) {
3655 if (maxGroupIndex == -1) {
3656 maxGroupIndex = siblingIndex;
3657 }
3658 minGroupIndex = siblingIndex;
3659 }
3660 }
3661 }
3662
3663 if (mode < 2) {
3664 for (i = minGroupIndex; i <= maxGroupIndex; i++) {
3665 Model* model = (*gCurrentModels)[i];
3666 if (mode != MODEL_GROUP_HIDDEN) {
3667 model->flags &= ~flags;
3668 } else {
3669 model->flags |= flags;
3670 }
3671 }
3672 } else {
3673 for (i = 0; i < minGroupIndex; i++) {
3674 Model* model = (*gCurrentModels)[i];
3675 if (mode == MODEL_GROUP_OTHERS_VISIBLE) {
3676 model->flags &= ~flags;
3677 } else {
3678 model->flags |= flags;
3679 }
3680 }
3681 for (i = maxGroupIndex + 1; i < MAX_MODELS; i++) {
3682 Model* model = (*gCurrentModels)[i];
3683 if (model != NULL) {
3684 if (mode == MODEL_GROUP_OTHERS_VISIBLE) {
3685 model->flags &= ~flags;
3686 } else {
3687 model->flags |= flags;
3688 }
3689 }
3690 }
3691 }
3692}
@ MODEL_GROUP_OTHERS_VISIBLE
Definition enums.h:4378
@ MODEL_GROUP_HIDDEN
Definition enums.h:4375
ModelTreeInfoList * gCurrentModelTreeNodeInfo
Definition model.c:107
u16 flags
Definition model.h:60

◆ init_enter_world_shared()

void init_enter_world_shared ( void )

Definition at line 32 of file state_map_transitions.c.

32 {
37 nuContRmbForceStopEnd();
39
41
44}
s16 update_exit_map_screen_overlay(s16 *progress)
@ GB_Unused_EVT_01
copied from GameStatus->unk_A9 by Function_80035E54 during save file load
BSS s16 gMapTransitionState
BSS s16 gMapTransitionStateTime
BSS s16 gMapTransitionAlpha
@ ENTER_WORLD_LOAD_MAP
s32 gOverrideFlags
Definition main_loop.c:11
s32 gTimeFreezeMode
Definition main_loop.c:12

Referenced by state_init_enter_demo(), and state_init_enter_world().

◆ update_enter_map_screen_overlay()

s16 update_enter_map_screen_overlay ( s16 * progress)

Definition at line 629 of file screen_overlays.c.

629 {
630 u8 fadeInType = OVERLAY_SCREEN_COLOR;
631 s32 fadeRate = STANDARD_FADE_RATE;
632 u8 ret = FALSE;
633
634 switch (CurrentScreenTransition) {
637 fadeRate = FAST_FADE_RATE;
638 break;
640 fadeInType = OVERLAY_VIEWPORT_COLOR;
641 fadeRate = FAST_FADE_RATE;
642 break;
648 fadeInType = OVERLAY_VIEWPORT_COLOR;
649 fadeRate = SLOW_FADE_RATE;
650 break;
656 fadeInType = OVERLAY_VIEWPORT_COLOR;
657 break;
660 fadeInType = OVERLAY_VIEWPORT_MARIO;
661 break;
663 fadeInType = OVERLAY_VIEWPORT_STAR;
664 fadeRate = SLOW_FADE_RATE;
665 break;
667 fadeInType = OVERLAY_VIEWPORT_MARIO;
668 fadeRate = SLOW_FADE_RATE;
669 break;
674 fadeRate = VERY_SLOW_FADE_RATE;
675 break;
676 }
677
679 set_screen_overlay_params_front(fadeInType, *progress);
680 }
681
682 if (*progress == 0) {
683 ret = TRUE;
684 }
685
686 *progress -= fadeRate;
687
688 if (*progress < 0) {
689 *progress = 0;
690 }
691
692 return ret;
693}
@ OVERLAY_VIEWPORT_STAR
Definition enums.h:2393
@ OVERLAY_BLUR
Definition enums.h:2400
@ OVERLAY_VIEWPORT_MARIO
Definition enums.h:2392
@ OVERLAY_VIEWPORT_COLOR
Definition enums.h:2389
@ TRANSITION_SLOW_BLUR_MOTION
Definition enums.h:2378
@ TRANSITION_END_PEACH_INTERLUDE
Definition enums.h:2374
@ TRANSITION_AFTER_SAVE_PROMPT
Definition enums.h:2373
@ TRANSITION_END_CHAPTER_INTERRUPTED
Definition enums.h:2377
@ TRANSITION_BEGIN_OR_END_CHAPTER
Definition enums.h:2368
@ TRANSITION_GET_STAR_CARD
Definition enums.h:2376
@ TRANSITION_MARIO_BLACK
Definition enums.h:2372
@ TRANSITION_END_DEMO_SCENE_BLACK
Definition enums.h:2364
@ TRANSITION_ENTER_WORLD
Definition enums.h:2370
@ TRANSITION_END_DEMO_SCENE_WHITE
Definition enums.h:2365
@ TRANSITION_BEGIN_OR_END_GAME
Definition enums.h:2366
@ TRANSITION_MARIO_WHITE
Definition enums.h:2371
@ TRANSITION_PEACH_CAPTURED
Definition enums.h:2375
@ TRANSITION_OUTRO_END_SCENE
Definition enums.h:2367
@ TRANSITION_TOY_TRAIN
Definition enums.h:2363
@ TRANSITION_STANDARD
Definition enums.h:2362
@ TRANSITION_SLOW_FADE_TO_WHITE
Definition enums.h:2369
void set_screen_overlay_params_front(u8 type, f32 zoom)
void set_screen_overlay_center(s32 layer, s32 arg1, s32 screenPosX, s32 screenPosY)
void set_screen_overlay_color(s32 layer, u8 r, u8 g, u8 b)
ScreenTransition CurrentScreenTransition
@ SLOW_FADE_RATE
@ STANDARD_FADE_RATE
@ FAST_FADE_RATE
@ VERY_SLOW_FADE_RATE

Referenced by state_step_change_map(), and state_step_enter_world().

◆ update_exit_map_screen_overlay()

s16 update_exit_map_screen_overlay ( s16 * progress)

Definition at line 506 of file screen_overlays.c.

506 {
507 u8 overlayColor;
508 u8 fadeOutType = OVERLAY_SCREEN_COLOR;
509 u8 r = 0;
510 u8 g = 0;
511 u8 b = 0;
512 s16 t = 0;
513 s32 fadeRate = STANDARD_FADE_RATE;
514
515 switch (CurrentScreenTransition) {
517 fadeOutType = OVERLAY_VIEWPORT_COLOR;
518 break;
520 fadeOutType = OVERLAY_SCREEN_COLOR;
521 break;
523 fadeOutType = OVERLAY_VIEWPORT_COLOR;
524 fadeRate = FAST_FADE_RATE;
525 break;
527 r = g = b = 208;
528 fadeOutType = OVERLAY_VIEWPORT_COLOR;
529 fadeRate = SLOWER_FADE_RATE;
532 }
533 break;
536 fadeOutType = OVERLAY_VIEWPORT_COLOR;
537 fadeRate = SLOW_FADE_RATE;
538 break;
540 r = g = b = 208;
541 fadeOutType = OVERLAY_VIEWPORT_COLOR;
542 break;
546 }
547 r = g = b = 208;
548 fadeOutType = OVERLAY_VIEWPORT_COLOR;
549 fadeRate = SLOW_FADE_RATE;
550 break;
553 r = g = b = 208;
554 fadeOutType = OVERLAY_VIEWPORT_COLOR;
555 fadeRate = SLOW_FADE_RATE;
556 break;
558 r = g = b = 208;
559 fadeOutType = OVERLAY_VIEWPORT_COLOR;
560 fadeRate = FAST_FADE_RATE;
561 break;
564 fadeOutType = OVERLAY_VIEWPORT_MARIO;
565 break;
567 r = g = b = 208;
569 fadeOutType = OVERLAY_VIEWPORT_MARIO;
570 fadeRate = SLOW_FADE_RATE;
571 break;
574 fadeOutType = OVERLAY_VIEWPORT_MARIO;
575 fadeRate = SLOW_FADE_RATE;
576 break;
579 r = g = b = 208;
580 fadeOutType = OVERLAY_VIEWPORT_STAR;
581 fadeRate = SLOW_FADE_RATE;
582 break;
585 fadeOutType = OVERLAY_VIEWPORT_STAR;
586 fadeRate = SLOW_FADE_RATE;
587 break;
592 *progress = 255;
593 return 1;
594 }
595
597 overlayColor = ((255 - *progress) * 208) / 255;
598 set_screen_overlay_color(SCREEN_LAYER_FRONT, overlayColor, overlayColor, overlayColor);
599 set_screen_overlay_params_front(fadeOutType, 255.0f);
600 if (*progress == 255) {
601 return 1;
602 }
603
604 *progress += fadeRate;
605 if (*progress > 255) {
606 *progress = 255;
607 }
608 } else {
609 set_screen_overlay_color(t, r, g, b);
610
611 if (t == 0) {
612 set_screen_overlay_params_front(fadeOutType, *progress);
613 } else {
614 set_screen_overlay_params_back(fadeOutType, *progress);
615 }
616
617 if (*progress == 255) {
618 return 1;
619 }
620
621 *progress += fadeRate;
622 if (*progress > 255) {
623 *progress = 255;
624 }
625 }
626 return 0;
627}
@ DEMO_STATE_CHANGE_MAP
Definition enums.h:3536
void set_screen_overlay_params_back(u8 type, f32 zoom)
void set_screen_overlay_alpha(s32 layer, f32 alpha)
@ SLOWER_FADE_RATE

Referenced by init_enter_world_shared(), state_step_change_map(), and state_step_exit_file_select().

◆ set_screen_overlay_params_front()

◆ set_screen_overlay_params_back()

void set_screen_overlay_params_back ( u8 type,
f32 zoom )

◆ set_screen_overlay_alpha()

void set_screen_overlay_alpha ( s32 layer,
f32 alpha )

Definition at line 439 of file screen_overlays.c.

439 {
440 switch (layer) {
443 ScreenOverlays[layer].alpha = alpha;
444 break;
445 }
446}
ScreenOverlay ScreenOverlays[2]

Referenced by draw_encounters_pre_battle(), and update_exit_map_screen_overlay().

◆ get_screen_overlay_params()

void get_screen_overlay_params ( s32 layer,
u8 * type,
f32 * zoom )

Definition at line 368 of file screen_overlays.c.

368 {
369 switch (layer) {
373 break;
377 break;
378 }
379}

Referenced by btl_update(), and create_target_list().

◆ set_screen_overlay_color()

◆ set_screen_overlay_center()

void set_screen_overlay_center ( s32 layer,
s32 arg1,
s32 screenPosX,
s32 screenPosY )

Definition at line 392 of file screen_overlays.c.

392 {
393 switch (layer) {
396 switch (arg1) {
397 case 0:
398 ScreenOverlays[layer].screenPos[0][0] = screenPosX;
399 ScreenOverlays[layer].screenPos[0][1] = screenPosY;
400 break;
401 case 1:
402 ScreenOverlays[layer].screenPos[1][0] = screenPosX;
403 ScreenOverlays[layer].screenPos[1][1] = screenPosY;
404 break;
405 }
406 break;
407 }
408}
s32 screenPos[2][2]
Definition overlay.h:9

Referenced by btl_state_update_end_battle(), draw_encounters_pre_battle(), update_enter_map_screen_overlay(), and update_exit_map_screen_overlay().

◆ rand_int()

s32 rand_int ( s32 max)

Definition at line 531 of file 43F0.c.

531 {
532 s32 ret = 0;
533
534 max = abs(max);
535
536 if (max != 0) {
537 switch (max) {
538 case 1:
539 // due to the off-by-one input of 1000 and the > operator being used,
540 // there is a 501/1001 chance of returning 0 and a 500/1001 chance of returning 1
541 // (assuming statistical randomness of rand_int_internal).
542 ret = rand_int_internal(1000) > 500;
543 break;
544 default:
545 ret = rand_int_internal(max);
546 break;
547 case 100:
548 ret = rand_int_internal(1009) / 10;
549 break;
550 }
551 }
552
553 return ret;
554}
s32 rand_int_internal(u32 max)
Definition 43F0.c:508

◆ sort_consumables()

void sort_consumables ( void )

Bubbles up player inventory items such that all ITEM_NONE values are at the bottom.

Definition at line 410 of file inventory.c.

410 {
411 s32 i, j;
412
413 for (i = ARRAY_COUNT(gPlayerData.invItems) - 2; i >= 0; i--) {
414 // leave ITEM_NONE at the end of the list alone
415 if (gPlayerData.invItems[i] == ITEM_NONE) {
416 continue;
417 }
418 // swap any other ITEM_NONE to the end of the list
419 for (j = ARRAY_COUNT(gPlayerData.invItems) - 1; i < j; j--) {
420 if (gPlayerData.invItems[j] == ITEM_NONE) {
422 gPlayerData.invItems[i] = ITEM_NONE;
423 break;
424 }
425 }
426 }
427}

Referenced by add_item(), remove_consumable(), remove_item(), and update_item_entity_pickup().

◆ is_ability_active()

s32 is_ability_active ( s32 arg0)

Definition at line 1736 of file inventory.c.

1736 {
1737 PlayerData* playerData = &gPlayerData;
1738 s32 attackFXArray[6];
1739 s32 attackFXIndex;
1740 s32 badgeItemID;
1741 s32 badgeMoveID;
1742 s32 ret;
1743 s32 i;
1744
1745 ret = 0;
1746 attackFXIndex = 0;
1747
1748 for (i = 0; i < ARRAY_COUNT(attackFXArray); i++) {
1749 attackFXArray[i] = 0;
1750 }
1751
1753 return 0;
1754 }
1755
1756 for (i = 0; i < ARRAY_COUNT(playerData->equippedBadges); i++) {
1757 badgeItemID = playerData->equippedBadges[i];
1758 if (badgeItemID == ITEM_NONE)
1759 continue;
1760
1761 badgeMoveID = gItemTable[badgeItemID].moveID;
1762
1763 switch (ability) {
1765 if (badgeMoveID == MOVE_DODGE_MASTER) {
1766 ret++;
1767 }
1768 break;
1770 if (badgeMoveID == MOVE_SPIKE_SHIELD) {
1771 ret++;
1772 }
1773 break;
1775 if (badgeMoveID == MOVE_FIRST_ATTACK) {
1776 ret++;
1777 }
1778 break;
1779 case ABILITY_HP_PLUS:
1780 if (badgeMoveID == MOVE_HP_PLUS) {
1781 ret++;
1782 }
1783 break;
1784 case ABILITY_DOUBLE_DIP:
1785 if (badgeMoveID == MOVE_DOUBLE_DIP) {
1786 ret++;
1787 }
1788 break;
1790 if (badgeMoveID == MOVE_MYSTERY_SCROLL) {
1791 ret++;
1792 }
1793 if (playerData->hasActionCommands) {
1794 ret++;
1795 }
1796 break;
1798 if (badgeMoveID == MOVE_FIRE_SHIELD) {
1799 ret++;
1800 }
1801 break;
1803 if (badgeMoveID == MOVE_PRETTY_LUCKY) {
1804 ret++;
1805 }
1806 break;
1807 case ABILITY_HP_DRAIN:
1808 if (badgeMoveID == MOVE_HP_DRAIN) {
1809 ret++;
1810 }
1811 break;
1813 if (badgeMoveID == MOVE_ALLOR_NOTHING) {
1814 ret++;
1815 }
1816 break;
1817 case ABILITY_SLOW_GO:
1818 if (badgeMoveID == MOVE_SLOW_GO) {
1819 ret++;
1820 }
1821 break;
1822 case ABILITY_FP_PLUS:
1823 if (badgeMoveID == MOVE_FP_PLUS) {
1824 ret++;
1825 }
1826 break;
1827 case ABILITY_ICE_POWER:
1828 if (badgeMoveID == MOVE_ICE_POWER) {
1829 ret++;
1830 }
1831 break;
1833 if (badgeMoveID == MOVE_FEELING_FINE) {
1834 ret++;
1835 }
1836 break;
1837 case ABILITY_ATTACK_FX:
1838 if (badgeMoveID == MOVE_ATTACK_FX_A) {
1839 attackFXArray[attackFXIndex++] = 1;
1840 ret = -1;
1841 }
1842 if (badgeMoveID == MOVE_ATTACK_FX_D) {
1843 attackFXArray[attackFXIndex++] = 2;
1844 ret = -1;
1845 }
1846 if (badgeMoveID == MOVE_ATTACK_FX_B) {
1847 attackFXArray[attackFXIndex++] = 3;
1848 ret = -1;
1849 }
1850 if (badgeMoveID == MOVE_ATTACK_FX_E) {
1851 attackFXArray[attackFXIndex++] = 4;
1852 ret = -1;
1853 }
1854 if (badgeMoveID == MOVE_ATTACK_FX_C) {
1855 attackFXArray[attackFXIndex++] = 5;
1856 ret = -1;
1857 }
1858 if (badgeMoveID == MOVE_ATTACK_FX_F) {
1859 attackFXArray[attackFXIndex++] = 6;
1860 ret = -1;
1861 }
1862 break;
1864 if (badgeMoveID == MOVE_MONEY_MONEY) {
1865 ret++;
1866 }
1867 break;
1868 case ABILITY_CHILL_OUT:
1869 if (badgeMoveID == MOVE_CHILL_OUT_BADGE) {
1870 ret++;
1871 }
1872 break;
1874 if (badgeMoveID == MOVE_HAPPY_HEART) {
1875 ret++;
1876 }
1877 break;
1878 case ABILITY_ZAP_TAP:
1879 if (badgeMoveID == MOVE_ZAP_TAP) {
1880 ret++;
1881 }
1882 break;
1883 case ABILITY_MEGA_RUSH:
1884 if (badgeMoveID == MOVE_MEGA_RUSH) {
1885 ret++;
1886 }
1887 break;
1888 case ABILITY_BERSERKER:
1889 if (badgeMoveID == MOVE_BERSERKER) {
1890 ret++;
1891 }
1892 break;
1893 case ABILITY_RIGHT_ON:
1894 if (badgeMoveID == MOVE_RIGHT_ON) {
1895 ret++;
1896 }
1897 break;
1899 if (badgeMoveID == MOVE_RUNAWAY_PAY) {
1900 ret++;
1901 }
1902 break;
1904 if (badgeMoveID == MOVE_FLOWER_SAVER) {
1905 ret++;
1906 }
1907 break;
1908 case ABILITY_PAY_OFF:
1909 if (badgeMoveID == MOVE_PAY_OFF) {
1910 ret++;
1911 }
1912 break;
1914 if (badgeMoveID == MOVE_DEFEND_PLUS) {
1915 ret++;
1916 }
1917 break;
1918 case ABILITY_POWER_PLUS:
1919 if (badgeMoveID == MOVE_POWER_PLUS) {
1920 ret++;
1921 }
1922 break;
1923 case ABILITY_REFUND:
1924 if (badgeMoveID == MOVE_REFUND) {
1925 ret++;
1926 }
1927 break;
1928 case ABILITY_POWER_RUSH:
1929 if (badgeMoveID == MOVE_POWER_RUSH) {
1930 ret++;
1931 }
1932 break;
1934 if (badgeMoveID == MOVE_CRAZY_HEART) {
1935 ret++;
1936 }
1937 break;
1938 case ABILITY_LAST_STAND:
1939 if (badgeMoveID == MOVE_LAST_STAND) {
1940 ret++;
1941 }
1942 break;
1943 case ABILITY_CLOSE_CALL:
1944 if (badgeMoveID == MOVE_CLOSE_CALL) {
1945 ret++;
1946 }
1947 break;
1949 if (badgeMoveID == MOVE_P_UP_D_DOWN) {
1950 ret++;
1951 }
1952 break;
1953 case ABILITY_LUCKY_DAY:
1954 if (badgeMoveID == MOVE_LUCKY_DAY) {
1955 ret++;
1956 }
1957 break;
1959 if (badgeMoveID == MOVE_MEGA_HP_DRAIN) {
1960 ret++;
1961 }
1962 break;
1964 if (badgeMoveID == MOVE_P_DOWN_D_UP) {
1965 ret++;
1966 }
1967 break;
1969 if (badgeMoveID == MOVE_FLOWER_FANATIC) {
1970 ret++;
1971 }
1972 break;
1974 if (badgeMoveID == MOVE_SPEEDY_SPIN) {
1975 ret++;
1976 }
1977 break;
1979 if (badgeMoveID == MOVE_SPIN_ATTACK) {
1980 ret++;
1981 }
1982 break;
1983 case ABILITY_I_SPY:
1984 if (badgeMoveID == MOVE_I_SPY) {
1985 ret++;
1986 }
1987 break;
1989 if (badgeMoveID == MOVE_BUMP_ATTACK) {
1990 ret++;
1991 }
1992 break;
1994 if (badgeMoveID == MOVE_QUICK_CHANGE) {
1995 ret++;
1996 }
1997 break;
1999 if (badgeMoveID == MOVE_HEART_FINDER) {
2000 ret++;
2001 }
2002 break;
2004 if (badgeMoveID == MOVE_FLOWER_FINDER) {
2005 ret++;
2006 }
2007 break;
2009 if (badgeMoveID == MOVE_DIZZY_ATTACK) {
2010 ret++;
2011 }
2012 break;
2014 if (badgeMoveID == MOVE_UNUSED_FINAL_GOOMPA) {
2015 ret++;
2016 }
2017 break;
2019 if (badgeMoveID == MOVE_UNUSED_FINAL_BOBOMB) {
2020 ret++;
2021 }
2022 break;
2023 case ABILITY_DEEP_FOCUS:
2024 if (badgeMoveID == MOVE_DEEP_FOCUS) {
2025 ret++;
2026 }
2027 break;
2029 if (badgeMoveID == MOVE_SUPER_FOCUS) {
2030 ret++;
2031 }
2032 break;
2033 case ABILITY_KAIDEN:
2034 if (badgeMoveID == MOVE_KAIDEN) {
2035 ret++;
2036 }
2037 break;
2039 if (badgeMoveID == MOVE_DAMAGE_DODGE) {
2040 ret++;
2041 }
2042 break;
2044 if (badgeMoveID == MOVE_HAPPY_FLOWER) {
2045 ret++;
2046 }
2047 break;
2049 if (badgeMoveID == MOVE_GROUP_FOCUS) {
2050 ret++;
2051 }
2052 break;
2053 case ABILITY_PEEKABOO:
2054 if (badgeMoveID == MOVE_PEEKABOO) {
2055 ret++;
2056 }
2057 break;
2059 if (badgeMoveID == MOVE_HEALTHY_HEALTHY) {
2060 ret++;
2061 }
2062 break;
2063 }
2064 }
2065
2066 if (ret < 0) {
2067 ret = attackFXArray[rand_int(attackFXIndex - 1)];
2068 }
2069 return ret;
2070}
@ ABILITY_DEEP_FOCUS
Definition enums.h:484
@ ABILITY_BUMP_ATTACK
Definition enums.h:478
@ ABILITY_ATTACK_FX
Definition enums.h:451
@ ABILITY_FLOWER_FINDER
Definition enums.h:480
@ ABILITY_P_DOWN_D_UP
Definition enums.h:473
@ ABILITY_MEGA_HP_DRAIN
Definition enums.h:472
@ ABILITY_DOUBLE_DIP
Definition enums.h:441
@ ABILITY_PAY_OFF
Definition enums.h:461
@ ABILITY_SPIN_ATTACK
Definition enums.h:476
@ ABILITY_MONEY_MONEY
Definition enums.h:452
@ ABILITY_REFUND
Definition enums.h:465
@ ABILITY_PEEKABOO
Definition enums.h:490
@ ABILITY_POWER_PLUS
Definition enums.h:464
@ ABILITY_CLOSE_CALL
Definition enums.h:469
@ ABILITY_HEALTHY_HEALTHY
Definition enums.h:491
@ ABILITY_HEART_FINDER
Definition enums.h:479
@ ABILITY_DEFEND_PLUS
Definition enums.h:463
@ ABILITY_FINAL_GOOMPA
Definition enums.h:482
@ ABILITY_I_SPY
Definition enums.h:477
@ ABILITY_DAMAGE_DODGE
Definition enums.h:487
@ ABILITY_SPIKE_SHIELD
Definition enums.h:438
@ ABILITY_KAIDEN
Definition enums.h:486
@ ABILITY_LAST_STAND
Definition enums.h:468
@ ABILITY_P_UP_D_DOWN
Definition enums.h:470
@ ABILITY_FIRE_SHIELD
Definition enums.h:443
@ ABILITY_DODGE_MASTER
Definition enums.h:436
@ ABILITY_FINAL_BOBOMB
Definition enums.h:483
@ ABILITY_ICE_POWER
Definition enums.h:449
@ ABILITY_LUCKY_DAY
Definition enums.h:471
@ ABILITY_SUPER_FOCUS
Definition enums.h:485
@ ABILITY_ALL_OR_NOTHING
Definition enums.h:446
@ ABILITY_PRETTY_LUCKY
Definition enums.h:444
@ ABILITY_RIGHT_ON
Definition enums.h:458
@ ABILITY_HP_DRAIN
Definition enums.h:445
@ ABILITY_MYSTERY_SCROLL
Definition enums.h:442
@ ABILITY_FIRST_ATTACK
Definition enums.h:439
@ ABILITY_SPEEDY_SPIN
Definition enums.h:475

Referenced by action_command_init_status(), action_hammer_play_hit_fx(), action_update_run(), action_update_spin(), action_update_walk(), adjust_action_command_difficulty(), appendGfx_player_actor(), btl_menu_strats_draw_content(), btl_state_update_begin_player_turn(), btl_state_update_begin_turn(), btl_state_update_celebration(), btl_state_update_end_player_turn(), btl_state_update_first_strike(), btl_state_update_normal_start(), btl_state_update_partner_menu(), btl_state_update_player_move(), btl_state_update_run_away(), btl_state_update_select_target(), calc_enemy_damage_target(), calc_player_damage_enemy(), check_block_input(), check_input_spin(), enforce_hpfp_limits(), entity_HiddenPanel_set_ispy_notification(), get_coin_drop_amount(), inflict_status(), is_actor_health_bar_visible(), is_actortype_health_bar_visible(), load_player_actor(), player_team_is_ability_active(), show_first_strike_message(), spawn_drops(), update_encounters_neutral(), update_encounters_pre_battle(), and update_locomotion_state().

◆ is_starting_conversation()

s32 is_starting_conversation ( void )

Definition at line 2817 of file encounter.c.

2817 {
2819
2821 ret = TRUE;
2822 }
2823 return ret;
2824}
s32 gEncounterState
Definition encounter.c:174
EncounterStatus gCurrentEncounter
Definition encounter.c:176
@ ENCOUNTER_TRIGGER_CONVERSATION
Definition enums.h:272
@ ENCOUNTER_STATE_PRE_BATTLE
Definition enums.h:6296

Referenced by partner_use_ability(), phys_update_jump(), should_continue_pulse_stone(), and test_item_entity_position().

◆ update_lerp()

f32 update_lerp ( s32 easing,
f32 start,
f32 end,
s32 elapsed,
s32 duration )

Definition at line 734 of file 43F0.c.

734 {
735 s32 timeLeft;
736 f32 absMag;
737
738 if (duration == 0) {
739 return end;
740 }
741
742 switch (easing) {
743 case EASING_LINEAR:
744 return start + (end - start) * elapsed / duration;
746 return start + SQ(elapsed) * (end - start) / SQ(duration);
747 case EASING_CUBIC_IN:
748 return start + CUBE(elapsed) * (end - start) / CUBE(duration);
750 return start + QUART(elapsed) * (end - start) / QUART(duration);
752 return end - ((end - start) * cos_rad(((f32)elapsed / duration) * PI_D * 4.0) * (duration - elapsed) *
753 (duration - elapsed)) / SQ((f32)duration);
755 return end - ((end - start) * cos_rad((((f32)SQ(elapsed) / duration) * PI_D * 4.0) / 15.0) * (duration - elapsed) *
756 (duration - elapsed)) / SQ((f32)duration);
758 timeLeft = duration - elapsed;
759 return start + (end - start) - ((SQ(timeLeft) * (end - start))) / SQ(duration);
760 case EASING_CUBIC_OUT:
761 timeLeft = duration - elapsed;
762 return start + (end - start) - ((CUBE(timeLeft) * (end - start))) / CUBE(duration);
764 timeLeft = duration - elapsed;
765 return start + (end - start) - ((QUART(timeLeft) * (end - start))) / QUART(duration);
767 absMag = cos_rad((((f32)SQ(elapsed) / duration) * PI_D * 4.0) / 40.0) * (duration - elapsed) *
768 (duration - elapsed) / SQ((f32)duration);
769 if (absMag < 0.0f) {
770 absMag = -absMag;
771 }
772 return end - (end - start) * absMag;
774 return start + (end - start) * (1.0 - cos_rad(((f32)elapsed * PI_D) / (f32)duration)) * 0.5;
775 case EASING_SIN_OUT:
776 return start + (end - start) * sin_rad(((f32)elapsed * (PI_D / 2)) / (f32)duration);
777 case EASING_COS_IN:
778 return start + (end - start) * (1.0 - cos_rad(((f32)elapsed * (PI_D / 2)) / (f32)duration));
779 }
780
781 return 0.0f;
782}
f32 sin_rad(f32 theta)
Definition 43F0.c:712
f32 cos_rad(f32 theta)
Definition 43F0.c:716
@ EASING_SIN_OUT
Definition enums.h:521
@ EASING_COS_IN
Definition enums.h:522
@ EASING_CUBIC_IN
Definition enums.h:512
@ EASING_CUBIC_OUT
Definition enums.h:515
@ EASING_QUARTIC_IN
Definition enums.h:513
@ EASING_COS_BOUNCE
Definition enums.h:519
@ EASING_COS_SLOW_OVERSHOOT
Definition enums.h:517
@ EASING_QUADRATIC_IN
Definition enums.h:511
@ EASING_COS_IN_OUT
Definition enums.h:520
@ EASING_QUARTIC_OUT
Definition enums.h:516
@ EASING_QUADRATIC_OUT
Definition enums.h:514
@ EASING_LINEAR
Definition enums.h:510
@ EASING_COS_FAST_OVERSHOOT
Definition enums.h:518
#define PI_D
Definition macros.h:131
#define QUART(x)
Definition macros.h:172
#define CUBE(x)
Definition macros.h:171

Referenced by appendGfx_message(), FlyingMagikoopaAI_17(), msg_update_rewind_arrow(), sfx_compute_spatialized_sound_params_full(), and update_riding_physics().

◆ sin_cos_deg()

void sin_cos_deg ( f32 rad,
f32 * outSinTheta,
f32 * outCosTheta )

Definition at line 719 of file 43F0.c.

719 {
720 u16 binang = _wrap_trig_lookup_value(DEG_TO_BINANG(theta));
721
722 *outSinTheta = sins(binang) * SHT_MINV;
723 *outCosTheta = coss(binang) * SHT_MINV;
724}

◆ set_main_pan_u()

void set_main_pan_u ( s32 texPannerID,
s32 value )

Definition at line 3815 of file model.c.

3815 {
3816 texPannerMainU[texPannerID] = value;
3817}
BSS s32 texPannerMainU[MAX_TEX_PANNERS]
Definition model.c:1340

◆ set_main_pan_v()

void set_main_pan_v ( s32 texPannerID,
s32 value )

Definition at line 3819 of file model.c.

3819 {
3820 texPannerMainV[texPannerID] = value;
3821}
BSS s32 texPannerMainV[MAX_TEX_PANNERS]
Definition model.c:1341

◆ set_aux_pan_u()

void set_aux_pan_u ( s32 texPannerID,
s32 value )

Definition at line 3823 of file model.c.

3823 {
3824 texPannerAuxU[texPannerID] = value;
3825}
BSS s32 texPannerAuxU[MAX_TEX_PANNERS]
Definition model.c:1342

◆ set_aux_pan_v()

void set_aux_pan_v ( s32 texPannerID,
s32 value )

Definition at line 3827 of file model.c.

3827 {
3828 texPannerAuxV[texPannerID] = value;
3829}
BSS s32 texPannerAuxV[MAX_TEX_PANNERS]
Definition model.c:1343

◆ enable_world_fog()

void enable_world_fog ( void )

Definition at line 3775 of file model.c.

3775 {
3776 gFogSettings->enabled = TRUE;
3777}
s32 enabled
Definition model.c:112
BSS FogSettings * gFogSettings
Definition model.c:1339

◆ set_world_fog_dist()

void set_world_fog_dist ( s32 start,
s32 end )

Definition at line 3783 of file model.c.

3783 {
3784 gFogSettings->startDistance = start;
3786}
s32 endDistance
Definition model.c:115
s32 startDistance
Definition model.c:114

◆ set_world_fog_color()

void set_world_fog_color ( s32 r,
s32 g,
s32 b,
s32 a )

Definition at line 3788 of file model.c.

3788 {
3789 gFogSettings->color.r = r;
3790 gFogSettings->color.g = g;
3791 gFogSettings->color.b = b;
3792 gFogSettings->color.a = a;
3793}
Color4i color
Definition model.c:113

◆ is_world_fog_enabled()

s32 is_world_fog_enabled ( void )

Definition at line 3795 of file model.c.

3795 {
3796 return gFogSettings->enabled;
3797}

Referenced by appendGfx_background_texture(), and tattle_cam_pre_render().

◆ get_world_fog_color()

void get_world_fog_color ( s32 * r,
s32 * g,
s32 * b,
s32 * a )

Definition at line 3804 of file model.c.

3804 {
3805 *r = gFogSettings->color.r;
3806 *g = gFogSettings->color.g;
3807 *b = gFogSettings->color.b;
3808 *a = gFogSettings->color.a;
3809}

Referenced by appendGfx_background_texture(), and tattle_cam_pre_render().

◆ enable_entity_fog()

void enable_entity_fog ( void )

Definition at line 793 of file entity_model.c.

793 {
795}
BSS s32 entity_fog_enabled

◆ set_entity_fog_dist()

void set_entity_fog_dist ( s32 start,
s32 end )

Definition at line 801 of file entity_model.c.

801 {
804}
BSS s32 entity_fog_dist_max
BSS s32 entity_fog_dist_min

◆ set_entity_fog_color()

void set_entity_fog_color ( s32 r,
s32 g,
s32 b,
s32 a )

Definition at line 806 of file entity_model.c.

806 {
807 entity_fog_red = r;
809 entity_fog_blue = b;
811}
BSS s32 entity_fog_blue
BSS s32 entity_fog_red
BSS s32 entity_fog_green
BSS s32 entity_fog_alpha

◆ get_transform_group()

struct ModelTransformGroup * get_transform_group ( s32 index)

Definition at line 3452 of file model.c.

3452 {
3453 return (*gCurrentTransformGroups)[index];
3454}
ModelTransformGroupList * gCurrentTransformGroups
Definition model.c:1309

Referenced by disable_transform_group(), enable_transform_group(), and get_transform_group_index().

◆ mdl_make_transform_group()

void mdl_make_transform_group ( u16 modelID)

Definition at line 3513 of file model.c.

3513 {
3514 TreeIterPos = 0;
3515 mtg_FoundModelNode = NULL;
3516 mtg_SearchModelID = modelID;
3517 mtg_MaxChild = 0;
3518 mtg_MinChild = 0;
3520
3521 if (mtg_FoundModelNode != NULL) {
3522 ModelTransformGroup* newMtg;
3523 ModelNode* node;
3524 ModelNodeProperty* prop;
3525 ModelBoundingBox* bb;
3526 f32 x, y, z;
3527 s32 i;
3528
3529 for (i = 0; i < ARRAY_COUNT(*gCurrentTransformGroups); i++) {
3530 if ((*gCurrentTransformGroups)[i] == NULL) {
3531 break;
3532 }
3533 }
3534
3535 (*gCurrentTransformGroups)[i] = newMtg = heap_malloc(sizeof(*newMtg));
3537 newMtg->groupModelID = modelID;
3540 newMtg->matrixFreshness = 0;
3541 newMtg->bakedMtx = NULL;
3543 guMtxIdent(&newMtg->savedMtx);
3545 guMtxIdentF(newMtg->userTransformMtx);
3546
3547 node = newMtg->baseModelNode;
3548
3549 if (node->type != SHAPE_TYPE_GROUP) {
3551 } else {
3553
3554 if (prop != NULL) {
3555 // GROUP_INFO properties always come in pairs, with the second giving the render mode
3556 prop++;
3557 }
3558 }
3559
3560 if (prop != NULL) {
3561 newMtg->renderMode = prop->data.s;
3562 } else {
3564 }
3565
3567 if (bb != NULL) {
3568 x = (bb->minX + bb->maxX) * 0.5f;
3569 y = (bb->minY + bb->maxY) * 0.5f;
3570 z = (bb->minZ + bb->maxZ) * 0.5f;
3571 } else {
3572 x = y = z = 0.0f;
3573 }
3574
3575 if (newMtg->bakedMtx != NULL) {
3576 guMtxXFML(newMtg->bakedMtx, x, y, z, &x, &y, &z);
3577 }
3578
3579 newMtg->center.x = x;
3580 newMtg->center.y = y;
3581 newMtg->center.z = z;
3582 enable_transform_group(modelID);
3583 }
3584}
@ TRANSFORM_GROUP_FLAG_VALID
Definition enums.h:5079
@ TRANSFORM_GROUP_FLAG_IGNORE_MATRIX
Definition enums.h:5084
@ RENDER_MODE_SURFACE_OPA
Definition enums.h:3264
void func_8011B1D8(ModelNode *node)
Definition model.c:3457
void enable_transform_group(u16 modelID)
Definition model.c:3586
BSS u16 mtg_MaxChild
Definition model.c:1349
BSS ModelNode * mtg_FoundModelNode
Definition model.c:1347
BSS u16 mtg_SearchModelID
Definition model.c:1346
BSS u16 mtg_MinChild
Definition model.c:1348
ModelNode * baseModelNode
Definition model.h:83
s32 type
Definition model.h:52
ModelNodePropertyData data
Definition model.h:35
Matrix4f userTransformMtx
Definition model.h:86
@ SHAPE_TYPE_GROUP
Definition model.h:153
@ MODEL_PROP_KEY_GROUP_INFO
Definition model.h:146
@ MODEL_PROP_KEY_RENDER_MODE
Definition model.h:142

◆ enable_transform_group()

void enable_transform_group ( u16 modelID)

Definition at line 3586 of file model.c.

3586 {
3588 s32 i;
3589
3590 group->flags &= ~TRANSFORM_GROUP_FLAG_INACTIVE;
3591
3592 for (i = group->minChildModelIndex; i <= group->maxChildModelIndex; i++) {
3593 Model* model = get_model_from_list_index(i);
3594
3596
3597 if (model->bakedMtx != NULL) {
3599 }
3600 }
3601}
@ MODEL_FLAG_TRANSFORM_GROUP_MEMBER
Definition enums.h:4359
@ MODEL_FLAG_MATRIX_DIRTY
Definition enums.h:4368
s32 get_transform_group_index(s32 modelID)
Definition model.c:3417

Referenced by mdl_make_transform_group().

◆ disable_transform_group()

void disable_transform_group ( u16 modelID)

Definition at line 3603 of file model.c.

3603 {
3605 s32 i;
3606
3608
3609 for (i = group->minChildModelIndex; i <= group->maxChildModelIndex; i++) {
3610 Model* model = get_model_from_list_index(i);
3611
3612 model->flags &= ~MODEL_FLAG_TRANSFORM_GROUP_MEMBER;
3613
3614 if (model->bakedMtx != NULL) {
3616 }
3617 }
3618}
@ TRANSFORM_GROUP_FLAG_INACTIVE
Definition enums.h:5081

◆ set_map_transition_effect()

void set_map_transition_effect ( ScreenTransition transition)

◆ set_tex_panner()

void set_tex_panner ( struct Model * model,
s32 texPannerID )

Definition at line 3811 of file model.c.

3811 {
3812 model->texPannerID = texPannerID;
3813}
u8 texPannerID
Definition model.h:70

◆ set_custom_gfx()

void set_custom_gfx ( s32 customGfxIndex,
Gfx * pre,
Gfx * post )

Definition at line 3843 of file model.c.

3843 {
3844 (*gCurrentCustomModelGfxPtr)[customGfxIndex * 2] = pre;
3845 (*gCurrentCustomModelGfxPtr)[customGfxIndex * 2 + 1] = post;
3846}

◆ make_item_entity()

s32 make_item_entity ( s32 itemID,
f32 x,
f32 y,
f32 z,
s32 itemSpawnMode,
s32 pickupDelay,
s32 angle,
s32 pickupVar )

Definition at line 390 of file item_entity.c.

390 {
391 s32 i;
392 s32 id;
393 ItemEntity* item;
394 f32 hitDepth;
395 Shadow* shadow;
396
397 if (pickupFlagIndex <= EVT_GAME_FLAG_CUTOFF) {
398 pickupFlagIndex = EVT_INDEX_OF_GAME_FLAG(pickupFlagIndex);
399 }
400
401 if (pickupFlagIndex > 0) {
402 switch (itemSpawnMode) {
417 if (get_global_flag(pickupFlagIndex) != 0) {
418 return -1;
419 }
420 break;
421 }
422 }
423
424 for (i = 0; i < MAX_ITEM_ENTITIES; i++) {
425 if (gCurrentItemEntities[i] == NULL) {
426 break;
427 }
428 }
429
431
432 id = i;
433 gCurrentItemEntities[id] = item = heap_malloc(sizeof(*item));
435 ASSERT(item != NULL);
436
437 item->renderGroup = (itemID & 0xF0000) >> 16;
438 if (item->renderGroup == VIS_GROUP_5) {
439 item->renderGroup = -1;
440 }
441
442 item->spawnType = itemSpawnMode;
444 item->pos.x = x;
445 item->pos.y = y;
446 item->pos.z = z;
447
448 itemID &= 0xFFFF;
449
451 item->flags |= ITEM_ENTITY_FLAG_10;
453 item->pickupMsgFlags = 0;
454 item->boundVar = pickupFlagIndex;
455 item->itemID = itemID;
456 item->physicsData = NULL;
457 item->pickupDelay = pickupDelay;
458 item->scale = 1.0f;
459 item->spawnAngle = angle;
460 item->shadowIndex = -1;
461 item->nextUpdate = 1;
462 item->lastPos.x = -9999;
463 item->lastPos.y = -9999;
464 item->lastPos.z = -9999;
466
468 if (gItemTable[itemID].typeFlags & ITEM_TYPE_FLAG_ENTITY_FULLSIZE) {
470 item->flags &= ~ITEM_ENTITY_RESIZABLE;
471 }
472
475 }
477
478 switch (item->spawnType) {
481 break;
485 break;
488 break;
493 break;
499 break;
504 break;
509 break;
515 break;
520 break;
526 break;
533 break;
536 break;
542 break;
547 break;
552 break;
557 break;
565 break;
572 break;
579 break;
583 item->scale = 0.8f;
585 break;
591 item->scale = 0.8f;
593 break;
599 item->scale = 0.8f;
601 break;
605 item->scale = 0.8f;
607 break;
612 item->scale = 0.8f;
614 break;
619 break;
626 break;
633 break;
634 }
635
636 switch (item->spawnType) {
642 item->shadowIndex = create_shadow_type(SHADOW_VARYING_CIRCLE, item->pos.x, item->pos.y, item->pos.z);
643 shadow = get_shadow_by_index(item->shadowIndex);
644
646 shadow->flags |= ENTITY_FLAG_HIDDEN;
647 }
648
649 x = item->pos.x;
650 y = item->pos.y + 12.0f;
651 z = item->pos.z;
652 hitDepth = 1000.0f;
653 npc_raycast_down_sides(COLLIDER_FLAG_IGNORE_NPC, &x, &y, &z, &hitDepth);
654 shadow->pos.x = x;
655 shadow->pos.y = y;
656 shadow->pos.z = z;
658 shadow->rot.y = 0.0f;
660 set_standard_shadow_scale(shadow, hitDepth * 0.5f);
661 break;
662 }
663
664 if (item->pickupDelay != 0) {
665 hide_item_entity(item);
666 }
667
668 item_entity_load(item);
669
670 if (item->itemID == ITEM_COIN) {
673 }
674
675 if (item->itemID == ITEM_STAR_PIECE) {
676 item->flags &= ~ITEM_ENTITY_FLAG_JUST_SPAWNED;
677 }
678
679 return id;
680}
struct ItemEntityPhysicsData * physicsData
Vec3f playerGroundTraceAngles
@ ITEM_ENTITY_FLAG_1000
Definition enums.h:2706
@ ITEM_ENTITY_FLAG_CAM1
Definition enums.h:2696
@ ITEM_ENTITY_FLAG_NO_MOTION
Definition enums.h:2722
@ ITEM_ENTITY_FLAG_800000
Definition enums.h:2717
@ ITEM_ENTITY_FLAG_CAM0
Definition enums.h:2695
@ ITEM_ENTITY_FLAG_10
Definition enums.h:2699
@ ITEM_ENTITY_FLAG_8000
Definition enums.h:2709
@ ITEM_ENTITY_RESIZABLE
Definition enums.h:2708
@ ITEM_ENTITY_FLAG_NO_GRAVITY
Definition enums.h:2707
@ ITEM_ENTITY_FLAG_SAVE_ON_RECEIPT
Definition enums.h:2725
@ ITEM_ENTITY_FLAG_ODD_SPAWN_PARITY
Definition enums.h:2711
@ ITEM_ENTITY_FLAG_ANGLE_RELATIVE_VELOCITY
Definition enums.h:2724
@ ITEM_ENTITY_FLAG_FULLSIZE
Definition enums.h:2712
@ ITEM_ENTITY_FLAG_CAM2
Definition enums.h:2697
@ ITEM_ENTITY_FLAG_400000
Definition enums.h:2716
@ ITEM_ENTITY_FLAG_SAVE_ON_TOUCH
Definition enums.h:2704
@ ITEM_ENTITY_FLAG_TOSS_LOWER
Definition enums.h:2710
@ ITEM_ENTITY_FLAG_JUST_SPAWNED
Definition enums.h:2701
@ ITEM_ENTITY_FLAG_TOSS_HIGHER
Definition enums.h:2718
@ ITEM_ENTITY_FLAG_SAVE_ON_INIT
Definition enums.h:2705
@ ITEM_ENTITY_FLAG_NEVER_VANISH
Definition enums.h:2703
@ ITEM_ENTITY_FLAG_INVISIBLE
Definition enums.h:2714
@ ITEM_PHYSICS_STATE_INIT
Definition enums.h:2730
@ ITEM_SPAWN_MODE_FALL
Definition enums.h:2305
@ ITEM_SPAWN_MODE_TOSS_SPAWN_ALWAYS_SMALL
Definition enums.h:2317
@ ITEM_SPAWN_MODE_FIXED_NEVER_VANISH
Definition enums.h:2308
@ ITEM_SPAWN_MODE_FIXED_SPAWN_ALWAYS
Definition enums.h:2307
@ ITEM_SPAWN_MODE_FIXED
Definition enums.h:2309
@ ITEM_SPAWN_MODE_TOSS_FADE3
Definition enums.h:2316
@ ITEM_SPAWN_MODE_DECORATION
Definition enums.h:2292
@ ITEM_SPAWN_MODE_INVISIBLE
Definition enums.h:2293
@ ITEM_SPAWN_MODE_ITEM_BLOCK_ITEM
Definition enums.h:2301
@ ITEM_SPAWN_MODE_FALL_SPAWN_ONCE
Definition enums.h:2306
@ ITEM_SPAWN_MODE_FIXED_SPAWN_ALWAYS_NEVER_VANISH
Definition enums.h:2310
@ ITEM_SPAWN_MODE_TOSS_FADE1
Definition enums.h:2314
@ ITEM_SPAWN_MODE_TOSS_SPAWN_ONCE
Definition enums.h:2298
@ ITEM_SPAWN_MODE_ITEM_BLOCK_SPAWN_ALWAYS
Definition enums.h:2311
@ ITEM_SPAWN_MODE_BATTLE_REWARD
Definition enums.h:2295
@ ITEM_SPAWN_MODE_TOSS_SPAWN_ALWAYS
Definition enums.h:2294
@ ITEM_SPAWN_MODE_TOSS_SPAWN_ALWAYS_NEVER_VANISH
Definition enums.h:2300
@ ITEM_SPAWN_MODE_TOSS
Definition enums.h:2297
@ ITEM_SPAWN_MODE_TOSS_SPAWN_ONCE_NEVER_VANISH
Definition enums.h:2299
@ ITEM_SPAWN_MODE_TOSS_NEVER_VANISH
Definition enums.h:2296
@ ITEM_SPAWN_MODE_TOSS_FADE2
Definition enums.h:2315
@ ITEM_SPAWN_MODE_TOSS_HIGHER_NEVER_VANISH
Definition enums.h:2313
@ ITEM_SPAWN_MODE_FALL_NEVER_VANISH
Definition enums.h:2304
@ ITEM_SPAWN_MODE_UNKNOWN_1B
Definition enums.h:2318
@ ITEM_SPAWN_MODE_FALL_SPAWN_ALWAYS
Definition enums.h:2303
@ ITEM_SPAWN_MODE_KEY
Definition enums.h:2291
@ ITEM_SPAWN_MODE_ITEM_BLOCK_COIN
Definition enums.h:2312
@ ITEM_SPAWN_MODE_ITEM_BLOCK_BADGE
Definition enums.h:2302
@ ITEM_TYPE_FLAG_ENTITY_FULLSIZE
Definition enums.h:1843
@ VIS_GROUP_5
Definition enums.h:2285
@ COLLIDER_FLAG_IGNORE_NPC
Definition enums.h:4696
void set_standard_shadow_scale(Shadow *shadow, f32 scale)
Definition entity.c:1674
Shadow * get_shadow_by_index(s32 index)
Definition entity.c:534
#define MAX_ITEM_ENTITIES
Definition item_entity.c:16
void item_entity_load(ItemEntity *item)
SparkleScript SparkleScript_Coin
BSS s32 ItemEntityAlternatingSpawn
Definition item_entity.c:33
BSS s16 ItemSpawnWithinPlayerPickupDelay
Definition item_entity.c:43
BSS ItemEntity ** gCurrentItemEntities
Definition item_entity.c:41
s32 ItemEntitiesCreated
Definition item_entity.c:30
void sparkle_script_update(ItemEntity *item)
void sparkle_script_init(ItemEntity *item, SparkleScript *script)
void hide_item_entity(ItemEntity *item)

Referenced by entity_ItemBlock_spawn_item(), entity_TrumpetPlant_spawn_coin(), entity_WoodenCrate_shatter(), make_item_entity_delayed(), make_item_entity_nodelay(), and spawn_drops().

◆ make_item_entity_delayed()

s32 make_item_entity_delayed ( s32 itemID,
f32 x,
f32 y,
f32 z,
s32 itemSpawnMode,
s32 pickupDelay,
s32 pickupVar )

Definition at line 686 of file item_entity.c.

686 {
687 return make_item_entity(itemID, x, y, z, itemSpawnMode, pickupDelay, -1, pickupVar);
688}
s32 make_item_entity(s32 itemID, f32 x, f32 y, f32 z, s32 itemSpawnMode, s32 pickupDelay, s32 angle, s32 pickupFlagIndex)

Referenced by update_item_entity_pickup().

◆ set_item_entity_position()

void set_item_entity_position ( s32 itemEntityIndex,
f32 x,
f32 y,
f32 z )

Definition at line 1567 of file item_entity.c.

1567 {
1568 ItemEntity* item = gCurrentItemEntities[itemEntityIndex];
1569
1570 item->pos.x = x;
1571 item->pos.y = y;
1572 item->pos.z = z;
1573}

Referenced by entity_GiantChest_open().

◆ get_item_entity()

ItemEntity * get_item_entity ( s32 itemEntityIndex)

◆ make_item_entity_nodelay()

s32 make_item_entity_nodelay ( s32 itemID,
f32 x,
f32 y,
f32 z,
s32 itemSpawnMode,
s32 pickupVar )

Definition at line 682 of file item_entity.c.

682 {
683 return make_item_entity(itemID, x, y, z, itemSpawnMode, 0, -1, pickupVar);
684}

Referenced by entity_GiantChest_give_equipment(), entity_HiddenPanel_flip_over(), entity_MulticoinBlock_spawn_coin(), and entity_Munchlesia_init().

◆ set_item_entity_flags()

void set_item_entity_flags ( s32 itemEntityIndex,
s32 flag )

Definition at line 1530 of file item_entity.c.

1530 {
1531 ItemEntity* item = gCurrentItemEntities[index];
1532
1533 item->flags |= flags;
1534#if !VERSION_JP
1536 D_801565A8 = TRUE;
1537 }
1538#endif
1539}
@ ITEM_ENTITY_FLAG_CANT_COLLECT
Definition enums.h:2715

Referenced by check_for_item_collision().

◆ clear_item_entity_flags()

void clear_item_entity_flags ( s32 index,
s32 flags )

Definition at line 1541 of file item_entity.c.

1541 {
1542 ItemEntity* item = gCurrentItemEntities[index];
1543
1544 item->flags &= ~flags;
1545}

◆ create_worker_frontUI()

s32 create_worker_frontUI ( void(*)(void) updateFunc,
void(*)(void) drawFunc )

Definition at line 63 of file worker.c.

63 {
64 Worker* worker;
65 s32 i;
66
67 for (i = 0; i < MAX_WORKERS; i++) {
68 Worker* lastWorker = (*gCurrentWorkerListPtr)[i];
69 if (lastWorker == NULL) {
70 break;
71 }
72 }
74
75 (*gCurrentWorkerListPtr)[i] = worker = heap_malloc(sizeof(*worker));
76 ASSERT(worker != NULL);
77
79 worker->update = updateFunc;
80 if (updateFunc == NULL) {
82 }
83 worker->draw = drawFunc;
84 if (drawFunc == NULL) {
86 }
87
90 }
91 return i;
92}
@ WORKER_FLAG_FRONT_UI
Definition enums.h:2772
@ WORKER_FLAG_1
Definition enums.h:2770
@ WORKER_FLAG_SKIP_DRAW_UNTIL_UPDATE
Definition enums.h:2771
#define MAX_WORKERS
Definition macros.h:95
void(* draw)(void)
void(* update)(void)
void worker_delegate_do_nothing(void)
Definition worker.c:7

Referenced by clear_item_entity_data(), create_action_command_ui_worker(), create_battle_popup_menu(), create_shop_popup_menu(), create_standard_popup_menu(), and partner_reset_data().

◆ get_worker()

Worker * get_worker ( s32 idx)

Definition at line 186 of file worker.c.

186 {
187 return (*gCurrentWorkerListPtr)[idx & ~BATTLE_ENTITY_ID_BIT];
188}
BSS WorkerList * gCurrentWorkerListPtr
Definition worker.c:5

Referenced by partner_reset_data().

◆ bind_trigger_1()

Trigger * bind_trigger_1 ( EvtScript * script,
s32 flags,
s32 triggerFlagIndex,
s32 triggerVar0,
s32 triggerVar1,
s32 priority )

Definition at line 751 of file script_list.c.

752 {
753 return bind_trigger(script, flags, triggerFlagIndex, triggerVar0, triggerVar1, priority, 1);
754}
Trigger * bind_trigger(EvtScript *script, s32 flags, s32 triggerFlagIndex, s32 triggerVar0, s32 triggerVar1, s32 priority, s32 arg6)

◆ set_cam_viewport()

void set_cam_viewport ( s16 id,
s16 x,
s16 y,
s16 width,
s16 height )

Definition at line 373 of file cam_main.c.

373 {
374 Camera* camera = &gCameras[id];
375
376 camera->viewportW = width;
377 camera->viewportH = height;
378 camera->viewportStartX = x;
379 camera->viewportStartY = y;
380
381 camera->vp.vp.vscale[0] = 2.0f * camera->viewportW;
382 camera->vp.vp.vscale[1] = 2.0f * camera->viewportH;
383 camera->vp.vp.vscale[2] = 0x1FF;
384 camera->vp.vp.vscale[3] = 0;
385
386 camera->vp.vp.vtrans[0] = 4 * (s16) ((u16) camera->viewportStartX + (camera->viewportW / 2));
387 camera->vp.vp.vtrans[1] = (s16) ((u16) camera->viewportStartY + (camera->viewportH / 2));
388 camera->vp.vp.vtrans[1] = 4 * camera->vp.vp.vtrans[1];
389 camera->vp.vp.vtrans[2] = 0x1FF;
390 camera->vp.vp.vtrans[3] = 0;
391
392 camera->vpAlt.vp.vscale[0] = 2.0f * camera->viewportW;
393 camera->vpAlt.vp.vscale[1] = 2.0f * camera->viewportH;
394 camera->vpAlt.vp.vscale[2] = 0x1FF;
395 camera->vpAlt.vp.vscale[3] = 0;
396
397 camera->vpAlt.vp.vtrans[0] = gGameStatusPtr->altViewportOffset.x + 4 * (s16) ((u16) camera->viewportStartX + (camera->viewportW / 2));
398 camera->vpAlt.vp.vtrans[1] = gGameStatusPtr->altViewportOffset.y + 4 * (s16) ((u16) camera->viewportStartY + (camera->viewportH / 2));
399 camera->vpAlt.vp.vtrans[2] = 0x200;
400 camera->vpAlt.vp.vtrans[3] = 0;
401}

Referenced by hud_element_setup_cam(), initialize_next_camera(), load_map_by_IDs(), state_init_file_select(), state_init_logos(), state_init_title_screen(), and state_step_demo().

◆ disable_player_shadow()

void disable_player_shadow ( void )

◆ move_player()

void move_player ( s32 duration,
f32 heading,
f32 speed )

◆ enable_player_input()

◆ enable_player_static_collisions()

s32 enable_player_static_collisions ( void )

Definition at line 980 of file 77480.c.

980 {
981 PlayerStatus* playerStatus = &gPlayerStatus;
982
983 playerStatus->enableCollisionOverlapsCheck--;
984 if (playerStatus->enableCollisionOverlapsCheck == 0) {
985 playerStatus->flags &= ~PS_FLAG_NO_STATIC_COLLISION;
986 }
987 return playerStatus->enableCollisionOverlapsCheck;
988}

Referenced by action_update_parasol(), action_update_use_munchlesia(), action_update_use_spinning_flower(), action_update_use_tweester(), entity_HiddenPanel_flip_over(), entity_StarBoxLauncher_launch(), pre_battle(), pre_battle(), and pre_battle().

◆ check_input_jump()

b32 check_input_jump ( void )

Definition at line 344 of file 7E9D0.c.

344 {
345 PlayerStatus* playerStatus = &gPlayerStatus;
346 CollisionStatus* collisionStatus = &gCollisionStatus;
347 s32 surfaceType;
348
349 if (!(playerStatus->pressedButtons & BUTTON_A)) {
350 return FALSE;
351 }
352
354 if ((surfaceType == SURFACE_TYPE_SLIDE) && phys_should_player_be_sliding()) {
355 return FALSE;
356 }
357
358 if (collisionStatus->touchingWallTrigger != 0 ||
361 {
362 return FALSE;
363 }
364
365 if ((collisionStatus->curInspect != -1) && (collisionStatus->curInspect & COLLISION_WITH_ENTITY_BIT)) {
366 Entity* entity = get_entity_by_index(collisionStatus->curInspect);
367
369 if ((entity->boundScriptBytecode == NULL) || (entity->flags & ENTITY_FLAG_4000)) {
370 if (entity->type == ENTITY_TYPE_PINK_FLOWER ||
371 entity->type == ENTITY_TYPE_BELLBELL_PLANT ||
373 {
374 return FALSE;
375 }
376 } else {
377 return FALSE;
378 }
379 }
380 }
381
383 return TRUE;
384}
@ ENTITY_TYPE_TRUMPET_PLANT
Definition enums.h:2591
@ ENTITY_TYPE_BELLBELL_PLANT
Definition enums.h:2590
@ ENTITY_TYPE_PINK_FLOWER
Definition enums.h:2594
@ PA_FLAG_SPEECH_PROMPT_AVAILABLE
(...) prompt
Definition enums.h:3096
@ PA_FLAG_INTERACT_PROMPT_AVAILABLE
! prompt
Definition enums.h:3095
@ ENTITY_FLAG_SHOWS_INSPECT_PROMPT
Definition enums.h:2625
s32 phys_should_player_be_sliding(void)
Definition 7BB60.c:839
EvtScript * boundScriptBytecode

Referenced by action_update_idle(), action_update_land(), action_update_pushing_block(), action_update_run(), action_update_spin(), action_update_step_down(), action_update_step_down_land(), and action_update_walk().

◆ check_input_hammer()

b32 check_input_hammer ( void )

Definition at line 321 of file 7E9D0.c.

321 {
322 PlayerStatus* playerStatus = &gPlayerStatus;
323 PlayerData* playerData = &gPlayerData;
324
325 if (playerStatus->pressedButtons & BUTTON_B) {
326 if (playerStatus->flags & PS_FLAG_FALLING) {
327 return FALSE;
328 }
329
331 return FALSE;
332 }
333
334 if (playerData->hammerLevel == -1) {
335 return FALSE;
336 }
337
339 return TRUE;
340 }
341 return FALSE;
342}
@ PARTNER_ACTION_USE
Definition enums.h:2933

Referenced by action_update_idle(), action_update_run(), action_update_spin(), and action_update_walk().

◆ resolve_npc()

Npc * resolve_npc ( Evt * script,
s32 npcIdOrPtr )

Definition at line 8 of file npc_api.c.

8 {
9 if (npcIdOrPtr == NPC_SELF) {
10 return get_npc_safe(script->owner2.npcID);
11 } else if (npcIdOrPtr >= EVT_LIMIT) {
12 return get_npc_safe(npcIdOrPtr);
13 } else {
14 return (Npc*) npcIdOrPtr;
15 }
16}
@ NPC_SELF
Definition enums.h:2526
Npc * get_npc_safe(s32 npcID)
Definition npc.c:1009

Referenced by _npc_jump_to(), and _show_message().

◆ enable_npc_blur()

void enable_npc_blur ( Npc * npc)

Definition at line 1066 of file npc.c.

1066 {
1067 if (!(npc->flags & NPC_FLAG_MOTION_BLUR)) {
1068 NpcMotionBlur* motionBlur;
1069 s32 i;
1070
1072
1073 motionBlur = heap_malloc(sizeof(*motionBlur));
1074 npc->blur.motion = motionBlur;
1075 ASSERT(motionBlur != NULL);
1076 motionBlur->unused = 0;
1077 motionBlur->index = 0;
1078
1079 for (i = 0; i < ARRAY_COUNT(motionBlur->posX); i++) {
1080 motionBlur->posX[i] = npc->pos.x;
1081 motionBlur->posY[i] = npc->pos.y;
1082 motionBlur->posZ[i] = npc->pos.z;
1083 }
1084 }
1085}
s8 index
Current blur ring buffer index.
Ring buffer of an NPC's position over the past 20 frames.
@ NPC_FLAG_MOTION_BLUR
Definition enums.h:3018
union Npc::@0 blur

Referenced by partner_put_away().

◆ disable_npc_blur()

void disable_npc_blur ( Npc * npc)

Definition at line 1087 of file npc.c.

1087 {
1088 if (npc->flags & NPC_FLAG_MOTION_BLUR) {
1089 npc->flags &= ~NPC_FLAG_MOTION_BLUR;
1090
1091 heap_free(npc->blur.motion);
1092 npc->blur.motion = NULL;
1093 }
1094}

Referenced by free_npc(), free_npc_by_index(), partner_put_away(), pre_battle(), pre_battle(), and pre_battle().

◆ enable_partner_blur()

void enable_partner_blur ( void )

Definition at line 265 of file actor_rendering.c.

265 {
267}
void enable_actor_blur(Actor *actor)

◆ disable_partner_blur()

void disable_partner_blur ( void )

Definition at line 269 of file actor_rendering.c.

269 {
271}
void disable_actor_blur(Actor *actor)

◆ partner_initialize_data()

void partner_initialize_data ( void )

Definition at line 1032 of file partners.c.

1032 {
1033 PartnerStatus* partnerStatus = &gPartnerStatus;
1034
1036 D_8010CFE0 = 0;
1038 D_8010CFC4 = 0;
1039 partnerStatus->actingPartner = 0;
1040 partnerStatus->inputDisabledCount = 0;
1041 partnerStatus->shouldResumeAbility = FALSE;
1042 partnerStatus->partnerActionState = 0;
1043 partnerStatus->unk_358 = 0;
1044 partnerStatus->partnerAction_unk_2 = FALSE;
1045 wPartner = NULL;
1049}
@ PARTNER_CMD_NONE
Definition enums.h:2945

Referenced by state_step_startup().

◆ dist2D()

f32 dist2D ( f32 ax,
f32 ay,
f32 bx,
f32 by )

◆ dist3D()

f32 dist3D ( f32 ax,
f32 ay,
f32 az,
f32 bx,
f32 by,
f32 bz )

Definition at line 676 of file 43F0.c.

676 {
677 f32 xDiff = bx - ax;
678 f32 yDiff = by - ay;
679 f32 zDiff = bz - az;
680
681 return sqrtf(SQ(xDiff) + SQ(yDiff) + SQ(zDiff));
682}

Referenced by update_triggers().

◆ add_vec2D_polar()

◆ bgm_set_track_volumes()

enum AuResult bgm_set_track_volumes ( s32 playerIndex,
s16 trackVolSet )

Definition at line 286 of file e0b30_len_b80.c.

286 {
287 MusicSettings* musicSetting = &gMusicSettings[playerIndex];
288
289 if (!(musicSetting->flags & MUSIC_SETTINGS_FLAG_1)) {
290 return AU_RESULT_OK;
291 }
292
293 return snd_song_set_track_volumes(musicSetting->songName, trackVolSet);
294}
AuResult snd_song_set_track_volumes(s32 songName, MusicTrackVols trackVolSet)
Definition 30450.c:684
MusicSettings gMusicSettings[2]
@ MUSIC_SETTINGS_FLAG_1
Definition enums.h:4659
@ AU_RESULT_OK
Definition enums.h:1756

◆ bgm_clear_track_volumes()

enum AuResult bgm_clear_track_volumes ( s32 playerIndex,
s16 trackVolSet )

Definition at line 296 of file e0b30_len_b80.c.

296 {
297 MusicSettings* musicSetting = &gMusicSettings[playerIndex];
298
299 if (!(musicSetting->flags & MUSIC_SETTINGS_FLAG_1)) {
300 return AU_RESULT_OK;
301 }
302
303 return snd_song_clear_track_volumes(musicSetting->songName, trackVolSet);
304}
AuResult snd_song_clear_track_volumes(s32 songName, MusicTrackVols trackVolSet)
Definition 30450.c:704

◆ bgm_set_variation()

enum AuResult bgm_set_variation ( s32 playerIndex,
s16 arg1 )

Definition at line 306 of file e0b30_len_b80.c.

306 {
307 MusicSettings* musicSetting = &gMusicSettings[playerIndex];
308
309 if (!(musicSetting->flags & MUSIC_SETTINGS_FLAG_1)) {
310 return AU_RESULT_OK;
311 }
312
313 return snd_set_song_variation(musicSetting->songName, arg1);
314}
AuResult snd_set_song_variation(s32 songName, s32 variation)
Definition 30450.c:628

◆ bgm_quiet_max_volume()

void bgm_quiet_max_volume ( void )

Definition at line 323 of file e0b30_len_b80.c.

323 {
324 MusicMaxVolume = 4;
325}
BSS s16 MusicMaxVolume

Referenced by state_step_pause().

◆ bgm_reset_max_volume()

void bgm_reset_max_volume ( void )

Definition at line 327 of file e0b30_len_b80.c.

327 {
328 MusicMaxVolume = 8;
329}

Referenced by state_step_unpause().

◆ bgm_reset_volume()

void bgm_reset_volume ( void )

Definition at line 76 of file e0b30_len_b80.c.

76 {
79}
BSS s16 MusicTargetVolume

Referenced by state_step_startup().

◆ bgm_init_music_players()

s32 bgm_init_music_players ( void )

Definition at line 316 of file e0b30_len_b80.c.

316 {
317 bgm_set_song(0, -1, 0, 250, 8);
318 bgm_set_song(1, -1, 0, 250, 8);
319
320 return 1;
321}
s32 bgm_set_song(s32 playerIndex, s32 songID, s32 variation, s32 fadeOutTime, s16 volume)

Referenced by state_step_startup().

◆ bgm_set_song()

s32 bgm_set_song ( s32 playerIndex,
s32 songID,
s32 variation,
s32 fadeOutTime,
s16 volume )

Definition at line 222 of file e0b30_len_b80.c.

222 {
223 gMusicSettings[playerIndex].flags &= ~MUSIC_SETTINGS_FLAG_8;
224
225 return _bgm_set_song(playerIndex, songID, variation, fadeOutTime, volume);
226}
s32 _bgm_set_song(s32 playerIndex, s32 songID, s32 variation, s32 fadeOutTime, s16 volume)

Referenced by bgm_init_music_players(), bgm_push_battle_song(), bgm_push_song(), btl_state_update_celebration(), btl_state_update_defeat(), btl_state_update_end_training_battle(), btl_state_update_run_away(), btl_state_update_victory(), state_init_exit_file_select(), state_init_title_screen(), and state_step_title_screen().

◆ bgm_set_battle_song()

void bgm_set_battle_song ( s32 songID,
s32 variation )

Definition at line 425 of file e0b30_len_b80.c.

425 {
426 MusicSettings* musicSetting = gMusicSettings;
427
428 musicSetting->battleSongID = songID;
429 musicSetting->battleVariation = variation;
430}

Referenced by update_encounters_pre_battle().

◆ bgm_push_battle_song()

void bgm_push_battle_song ( void )

Definition at line 410 of file e0b30_len_b80.c.

410 {
411 MusicSettings* musicSetting = gMusicSettings;
412
415 snd_ambient_pause(0, 250);
416 musicSetting->savedSongID = musicSetting->songID;
417 musicSetting->savedVariation = musicSetting->variation;
418 musicSetting->savedSongName = musicSetting->songName;
419 musicSetting->flags |= MUSIC_SETTINGS_FLAG_4;
420 bgm_set_song(0, musicSetting->battleSongID, musicSetting->battleVariation, 500, 8);
421 }
422 }
423}
AuResult snd_ambient_pause(s32 index, s32 fadeOutTime)
Definition 30450.c:305
@ MUSIC_SETTINGS_FLAG_4
Definition enums.h:4661
@ DEMO_STATE_NONE
Definition enums.h:3534
@ GLOBAL_OVERRIDES_DONT_RESUME_SONG_AFTER_BATTLE
Definition enums.h:4335

Referenced by update_encounters_pre_battle().

◆ bgm_adjust_proximity()

s32 bgm_adjust_proximity ( s32 playerIndex,
s32 arg1,
s16 arg2 )

Definition at line 261 of file e0b30_len_b80.c.

261 {
262 MusicSettings* musicSetting = &gMusicSettings[playerIndex];
263
264 if (!(musicSetting->flags & MUSIC_SETTINGS_FLAG_1)) {
265 return FALSE;
266 }
267
268 if (!(musicSetting->flags & MUSIC_SETTINGS_FLAG_ENABLE_PROXIMITY_MIX)) {
269 return FALSE;
270 }
271
272 switch (state) {
274 bgm_set_proximity_mix_far(musicSetting->songName, mix);
275 break;
277 bgm_set_proximity_mix_near(musicSetting->songName, mix);
278 break;
280 bgm_set_proximity_mix_full(musicSetting->songName, mix);
281 break;
282 }
283 return TRUE;
284}
void bgm_set_proximity_mix_full(s32 songName, s32 mix)
Definition 30450.c:797
void bgm_set_proximity_mix_near(s32 songName, s32 mix)
Definition 30450.c:793
void bgm_set_proximity_mix_far(s32 songName, s32 mix)
Definition 30450.c:789
@ MUSIC_SETTINGS_FLAG_ENABLE_PROXIMITY_MIX
Definition enums.h:4660
@ MUSIC_PROXIMITY_NEAR
Definition enums.h:1784
@ MUSIC_PROXIMITY_FULL
Definition enums.h:1785
@ MUSIC_PROXIMITY_FAR
Definition enums.h:1783

◆ func_801491E4()

void func_801491E4 ( Matrix4f mtx,
s32 arg1,
s32 arg2,
s32 arg3,
s32 arg4,
s32 alpha )

Definition at line 415 of file sprite_shading.c.

415 {
416 gDPSetPrimColor(gMainGfxPos++, 0, 0, 0, 0, 0, alpha);
417
418 if (alpha == 255) {
419 gDPSetCombineMode(gMainGfxPos++, PM_CC_WINDOW_5, G_CC_PASS2);
420 } else {
421 gDPSetCombineMode(gMainGfxPos++, PM_CC_02, G_CC_PASS2);
422 }
423}
#define PM_CC_WINDOW_5
Definition macros.h:445
#define PM_CC_02
Definition macros.h:281

Referenced by appendGfx_item_entity(), and render_item_entities().

◆ func_8014A964()

s32 func_8014A964 ( s32 playerIndex,
s32 songID,
s32 variation,
s32 fadeInTime,
s16 arg4,
s16 arg5 )

Definition at line 228 of file e0b30_len_b80.c.

228 {
229 MusicSettings* musicSetting;
230 s32 mapSongVariation;
231
233 return 1;
234 }
235
236 musicSetting = &gMusicSettings[playerIndex];
237
239 au_song_stop(musicSetting->songName);
240 musicSetting->flags &= ~MUSIC_SETTINGS_FLAG_1;
241 return 1;
242 }
243
244 mapSongVariation = bgm_get_map_default_variation(songID);
245 if (mapSongVariation >= 0) {
246 variation = mapSongVariation;
247 }
248
249 musicSetting->fadeInTime = fadeInTime;
250 musicSetting->fadeStartVolume = fadeStartVolume;
251 musicSetting->fadeEndVolume = fadeEndVolume;
252 musicSetting->songID = songID;
253 musicSetting->variation = variation;
254 musicSetting->flags |= MUSIC_SETTINGS_FLAG_20;
255 musicSetting->state = 1;
256 musicSetting->flags &= ~MUSIC_SETTINGS_FLAG_ENABLE_PROXIMITY_MIX;
257
258 return 1;
259}
AuResult au_song_stop(s32 songName)
Definition 30450.c:483
s32 bgm_get_map_default_variation(s32 songID)
If the given song ID is present in SongsUsingVariationFlag, returns the current map's songVariation &...
@ MUSIC_SETTINGS_FLAG_20
Definition enums.h:4664

◆ basic_window_update()

void basic_window_update ( s32 windowIndex,
s32 * flags,
s32 * posX,
s32 * posY,
s32 * posZ,
f32 * scaleX,
f32 * scaleY,
f32 * rotX,
f32 * rotY,
f32 * rotZ,
s32 * darkening,
s32 * opacity )

Definition at line 161 of file windows.c.

162 {
163 Window* window = &gWindows[windowID];
164 s32 counter = window->updateCounter;
165
166 if (counter == 0) {
167 window->flags &= ~WINDOW_FLAG_HIDDEN;
168 }
169
170 if (counter <= 4) {
171 *flags = gWindowAppearFlags[counter];
172 *scaleX = (f32)gWindowAppearScales[counter] * 0.01;
173 *scaleY = (f32)gWindowAppearScales[counter] * 0.01;
174 *rotZ = (4 - counter) * 3;
175 } else {
177 *scaleX = 1.0f;
178 *scaleY = 1.0f;
179 *rotZ = 0.0f;
180 window->flags &= ~WINDOW_FLAG_INITIAL_ANIMATION;
181 }
182}
u8 gWindowAppearScales[]
Definition windows.c:121
u8 gWindowAppearFlags[]
Definition windows.c:122

Referenced by draw_shop_items(), func_800F16CC(), pause_tabs_update(), popup_menu_update(), show_coin_counter(), and update_item_entity_pickup().

◆ basic_hidden_window_update()

void basic_hidden_window_update ( s32 windowIndex,
s32 * flags,
s32 * posX,
s32 * posY,
s32 * posZ,
f32 * scaleX,
f32 * scaleY,
f32 * rotX,
f32 * rotY,
f32 * rotZ,
s32 * darkening,
s32 * opacity )

Definition at line 184 of file windows.c.

185 {
186 Window* window = &gWindows[windowID];
187 s32 counter = window->updateCounter;
188
189 if (counter <= 9) {
190 *flags = gWindowDisappearFlags[counter];
191 *scaleX = (f32)gWindowDisappearScales[counter] * 0.01;
192 *scaleY = (f32)gWindowDisappearScales[counter] * 0.01;
193 *rotZ = -counter;
194 } else {
196 *scaleX = 0.0f;
197 *scaleY = 0.0f;
198 *rotZ = 0.0f;
199 window->flags &= ~WINDOW_FLAG_INITIAL_ANIMATION;
200 window->flags |= WINDOW_FLAG_HIDDEN;
201 }
202}
@ WINDOW_FLAG_HIDDEN
Updated but not rendered.
Definition enums.h:4994
u8 gWindowDisappearScales[]
Definition windows.c:123
u8 gWindowDisappearFlags[]
Definition windows.c:124

Referenced by draw_shop_items(), hide_popup_menu(), update_coin_counter(), and update_item_entity_pickup().

◆ create_current_pos_target_list()

void create_current_pos_target_list ( Actor * actor)

◆ create_home_target_list()

void create_home_target_list ( Actor * actor)

Definition at line 476 of file 190B20.c.

476 {
477 create_target_list(actor, TRUE);
478}

◆ set_actor_yaw()

void set_actor_yaw ( s32 actorID,
s32 yaw )

Definition at line 1091 of file 190B20.c.

1091 {
1092 get_actor(actorID)->yaw = yaw;
1093}

◆ set_part_yaw()

void set_part_yaw ( s32 actorID,
s32 partID,
s32 value )

Definition at line 1095 of file 190B20.c.

1095 {
1096 get_actor_part(get_actor(actorID), partID)->yaw = value;
1097}

◆ add_part_decoration()

void add_part_decoration ( ActorPart * part,
s32 decorationIndex,
s32 decorationType )

Definition at line 2727 of file 190B20.c.

2727 {
2728 if ((part->idleAnimations) && !(part->flags & ACTOR_PART_FLAG_NO_DECORATIONS)) {
2729 DecorationTable* decorations = part->decorationTable;
2730
2731 _remove_part_decoration(part, decorationIndex);
2732 decorations->type[decorationIndex] = decorationType;
2733 decorations->changed[decorationIndex] = TRUE;
2734 decorations->state[decorationIndex] = 0;
2736 }
2737}
void _remove_part_decoration(ActorPart *part, s32 decorationIndex)
void _add_part_decoration(ActorPart *)

Referenced by add_actor_decoration().

◆ add_actor_decoration()

void add_actor_decoration ( Actor * actor,
s32 decorationIndex,
s32 decorationType )

Definition at line 2739 of file 190B20.c.

2739 {
2740 for (ActorPart* part = actor->partsTable; part != NULL; part = part->nextPart) {
2742 && part->idleAnimations
2743 && !(part->flags & ACTOR_PART_FLAG_NO_DECORATIONS)
2744 ) {
2745 add_part_decoration(part, decorationIndex, decorationType);
2746 }
2747 }
2748}
void add_part_decoration(ActorPart *part, s32 decorationIndex, s32 decorationType)
Definition 190B20.c:2727

◆ remove_part_decoration()

void remove_part_decoration ( ActorPart * part,
s32 decorationIndex )

Definition at line 2750 of file 190B20.c.

2750 {
2751 _remove_part_decoration(part, decorationIndex);
2752}

Referenced by remove_actor_decoration().

◆ remove_actor_decoration()

void remove_actor_decoration ( Actor * actor,
s32 decorationIndex )

Definition at line 2754 of file 190B20.c.

2754 {
2755 for (ActorPart* part = actor->partsTable; part != NULL; part = part->nextPart) {
2757 && part->idleAnimations != NULL
2758 && !(part->flags & ACTOR_PART_FLAG_NO_DECORATIONS)
2759 ) {
2760 remove_part_decoration(part, decorationIndex);
2761 }
2762 }
2763}
void remove_part_decoration(ActorPart *part, s32 decorationIndex)
Definition 190B20.c:2750

Referenced by btl_delete_actor(), and btl_delete_player_actor().

◆ player_team_is_ability_active()

s32 player_team_is_ability_active ( Actor * actor,
s32 ability )

Definition at line 2765 of file 190B20.c.

2765 {
2766 s32 actorClass = actor->actorID & ACTOR_CLASS_MASK;
2767 s32 hasAbility = FALSE;
2768
2769 switch (actorClass) {
2770 case ACTOR_CLASS_PLAYER:
2772 hasAbility = is_ability_active(ability);
2773 }
2774 break;
2776 hasAbility = is_partner_ability_active(ability);
2777 break;
2778 case ACTOR_CLASS_ENEMY:
2779 break;
2780 }
2781
2782 return hasAbility;
2783}
s32 is_partner_ability_active(s32)
Definition inventory.c:2072

Referenced by appendGfx_player_actor(), btl_init_menu_boots(), btl_init_menu_hammer(), btl_init_menu_partner(), btl_state_update_change_partner(), btl_state_update_partner_menu(), btl_state_update_player_menu(), calc_enemy_damage_target(), calc_enemy_test_target(), calc_partner_test_enemy(), calc_player_damage_enemy(), calc_player_test_enemy(), and deduct_current_move_fp().

◆ create_part_shadow()

void create_part_shadow ( s32 actorID,
s32 partID )

Definition at line 2785 of file 190B20.c.

2785 {
2786 ActorPart* part = get_actor_part(get_actor(actorID), partID);
2787
2788 part->flags &= ~ACTOR_PART_FLAG_NO_SHADOW;
2790 part->shadowScale = part->size.x / 24.0;
2791}

◆ remove_part_shadow()

void remove_part_shadow ( s32 actorID,
s32 partID )

Definition at line 2793 of file 190B20.c.

2793 {
2794 ActorPart* part = get_actor_part(get_actor(actorID), partID);
2795
2798}
@ ACTOR_PART_FLAG_NO_SHADOW
Definition enums.h:3352

◆ create_part_shadow_by_ref()

void create_part_shadow_by_ref ( s32 arg0,
ActorPart * part )

◆ spawn_drops()

void spawn_drops ( Enemy * enemy)

Definition at line 8 of file 23680.c.

8 {
10 EnemyDrops* drops = enemy->drops;
11 Npc* npc = get_npc_unsafe(enemy->npcID);
13 s32 pickupDelay;
14 s32 availableRenderTasks;
15 s32 availableShadows;
16 s32 itemToDrop;
17 f32 x, y, z;
18 f32 threshold;
19 f32 chance;
20 f32 attempts;
21 f32 fraction;
22 s32 minCoinBonus;
23 s32 maxCoinBonus;
24 s32 spawnCounter;
25 s32 dropCount;
26 s32 totalWeight;
27 s32 curWeight;
28 s32 angle;
29 s32 angleMult;
30 s32 i, j;
31
32 availableShadows = 0;
33 for (i = 0; i < MAX_SHADOWS; i++) {
34 if (get_shadow_by_index(i) == NULL) {
35 availableShadows++;
36 }
37 }
38
39 spawnCounter = 0;
40 availableRenderTasks = 256 - 10 - gLastRenderTaskCount;
41 angle = clamp_angle(camera->curYaw + 90.0f);
42 x = npc->pos.x;
43 y = npc->pos.y + (npc->collisionHeight / 2);
44 z = npc->pos.z;
45
46 angleMult = 0;
47 pickupDelay = 0;
48
49 // try dropping items
50
51 dropCount = drops->itemDropChance;
52 if (drops->itemDropChance > rand_int(100)) {
53 totalWeight = 0;
54
55 for (i = 0; i < ARRAY_COUNT(drops->itemDrops); i++) {
56 if (drops->itemDrops[i].item != ITEM_NONE) {
57 totalWeight += drops->itemDrops[i].weight;
58 } else {
59 break;
60 }
61 }
62
63 curWeight = 0;
64 dropCount = rand_int(totalWeight);
65 itemToDrop = ITEM_NONE;
66
67 for (i = 0; i < ARRAY_COUNT(drops->itemDrops); i++) {
68 if (drops->itemDrops[i].item == ITEM_NONE) {
69 break;
70 }
71
72 curWeight += drops->itemDrops[i].weight;
73 if (drops->itemDrops[i].flagIdx > 0) {
75 continue;
76 }
77 }
78
79 if (curWeight >= dropCount) {
80 itemToDrop = drops->itemDrops[i].item;
81 break;
82 }
83 }
84
85 if (itemToDrop != ITEM_NONE) {
86 make_item_entity(itemToDrop, x, y, z, ITEM_SPAWN_MODE_BATTLE_REWARD, pickupDelay, angle + angleMult * 360, 0);
87 spawnCounter++;
88 pickupDelay += 2;
89 angle += 30.0;
90 if (spawnCounter >= 12) {
91 angleMult++;
92 angle = angleMult * 8;
93 spawnCounter = 0;
94 }
95
96 if (drops->itemDrops[i].flagIdx >= 0) {
98 }
99 }
100 }
101
102 if (encounter->dropWhackaBump) {
103 encounter->dropWhackaBump = FALSE;
104 make_item_entity(ITEM_WHACKAS_BUMP, x, y, z, ITEM_SPAWN_MODE_BATTLE_REWARD, pickupDelay, angle + angleMult * 360, 0);
105 spawnCounter++;
106 pickupDelay += 2;
107 angle += 30.0;
108 if (spawnCounter >= 12) {
109 angleMult++;
110 angle = angleMult * 8;
111 spawnCounter = 0;
112 }
113 }
114
115 // determine number of hearts to drop
116
117 dropCount = 0;
118 itemToDrop = ITEM_NONE;
119 fraction = gPlayerData.curHP / (f32) gPlayerData.curMaxHP;
120
121 for (i = 0; i < ARRAY_COUNT(drops->heartDrops); i++) {
122 attempts = drops->heartDrops[i].cutoff;
123 threshold = drops->heartDrops[i].generalChance;
124 attempts /= 32767.0f;
125 threshold /= 32767.0f;
126
127 if (fraction <= attempts && rand_int(100) <= threshold * 100.0f) {
128 attempts = drops->heartDrops[i].attempts;
129 chance = drops->heartDrops[i].chancePerAttempt;
130 chance /= 32767.0f;
131 for (j = 0; j < attempts; j++) {
132 if (rand_int(100) <= chance * 100.0f) {
133 dropCount++;
134 }
135 }
136 break;
137 }
138 }
139
141 dropCount += 1 + rand_int(2);
142 }
143 if (enemy->flags & ENEMY_FLAG_NO_DROPS) {
144 dropCount = 0;
145 }
146
147 // spawn as many of the heart drops as possible
148
149 if (dropCount != 0) {
150 itemToDrop = ITEM_HEART;
151 }
152
153 if (dropCount * 2 > availableRenderTasks) {
154 dropCount = availableRenderTasks / 2;
155 }
156 availableRenderTasks -= 2 * dropCount;
157 if (dropCount > availableShadows) {
158 dropCount = availableShadows;
159 }
160
161 availableShadows -= dropCount;
162
163 for (i = 0; i < dropCount; i++) {
164 make_item_entity(itemToDrop, x, y, z, ITEM_SPAWN_MODE_BATTLE_REWARD, pickupDelay, angle + (angleMult * 360), 0);
165 spawnCounter++;
166 pickupDelay += 2;
167 angle += 30.0;
168 if (spawnCounter >= 12) {
169 spawnCounter = 0;
170 angleMult++;
171 angle = angleMult * 8;
172 }
173 }
174
175 // determine number of flowers to drop
176
177 dropCount = 0;
178 itemToDrop = ITEM_NONE;
179
180 if (gPlayerData.curMaxFP > 0) {
181 fraction = gPlayerData.curFP / (f32) gPlayerData.curMaxFP;
182 } else {
183 fraction = 0.0;
184 }
185
186 for (i = 0; i < ARRAY_COUNT(drops->flowerDrops); i++) {
187 attempts = drops->flowerDrops[i].cutoff;
188 threshold = drops->flowerDrops[i].generalChance;
189 attempts /= 32767.0f;
190 threshold /= 32767.0f;
191
192 if (fraction <= attempts && rand_int(100) <= threshold * 100.0f) {
193 attempts = drops->flowerDrops[i].attempts;
194 chance = drops->flowerDrops[i].chancePerAttempt;
195 chance /= 32767.0f;
196 for (j = 0; j < attempts; j++) {
197 if (rand_int(100) <= chance * 100.0f) {
198 dropCount++;
199 }
200 }
201 break;
202 }
203 }
204
206 dropCount += 1 + rand_int(2);
207 }
208 if (enemy->flags & ENEMY_FLAG_NO_DROPS) {
209 dropCount = 0;
210 }
211
212 // spawn as many of the flower drops as possible
213
214 if (dropCount != 0) {
215 itemToDrop = ITEM_FLOWER_POINT;
216 }
217
218 if (dropCount * 2 > availableRenderTasks) {
219 dropCount = availableRenderTasks / 2;
220 }
221 availableRenderTasks -= 2 * dropCount;
222 if (dropCount > availableShadows) {
223 dropCount = availableShadows;
224 }
225
226 availableShadows -= dropCount;
227
228 for (i = 0; i < dropCount; i++) {
229 make_item_entity(itemToDrop, x, y, z, ITEM_SPAWN_MODE_BATTLE_REWARD, pickupDelay, angle + (angleMult * 360), 0);
230 spawnCounter++;
231 pickupDelay += 2;
232 angle += 30.0;
233 if (spawnCounter >= 12) {
234 spawnCounter = 0;
235 angleMult++;
236 angle = angleMult * 8;
237 }
238 }
239
240 // determine number of coins to drop
241
242 itemToDrop = ITEM_COIN;
243
244 //TODO maybe use an ASSERT here and forgo the odd support for reversing min/max
245 if (drops->maxCoinBonus < drops->minCoinBonus) {
246 // swap if max < min
247 maxCoinBonus = drops->minCoinBonus;
248 minCoinBonus = drops->maxCoinBonus;
249 } else {
250 minCoinBonus = drops->minCoinBonus;
251 maxCoinBonus = drops->maxCoinBonus;
252 }
253
254 if (minCoinBonus < 0) {
255 dropCount = rand_int(maxCoinBonus - minCoinBonus) + minCoinBonus;
256 } else {
257 dropCount = maxCoinBonus - minCoinBonus;
258 if (dropCount != 0) {
259 dropCount = rand_int(dropCount) + minCoinBonus;
260 } else {
261 dropCount = minCoinBonus;
262 }
263 }
264
265 if (dropCount < 0) {
266 dropCount = 0;
267 }
268 dropCount = dropCount + encounter->coinsEarned;
269
271 dropCount += encounter->damageTaken / 2;
272 encounter->damageTaken = 0;
273 }
274 if (encounter->hasMerleeCoinBonus) {
275 encounter->hasMerleeCoinBonus = FALSE;
276 dropCount *= 3;
277 }
279 dropCount *= 2;
280 }
281 if (dropCount > 20) {
282 dropCount = 20;
283 }
284 if (enemy->flags & ENEMY_FLAG_NO_DROPS) {
285 dropCount = 0;
286 }
287 if (dropCount * 2 > availableRenderTasks) {
288 dropCount = availableRenderTasks / 2;
289 }
290
291 // spawn as many of the coin drops as possible
292
293 availableRenderTasks -= 2 * dropCount;
294
295 if (dropCount > availableShadows) {
296 dropCount = availableShadows;
297 }
298
299 for (i = 0; i < dropCount; i++) {
300 make_item_entity(itemToDrop, x, y, z, ITEM_SPAWN_MODE_BATTLE_REWARD, pickupDelay, angle + (angleMult * 360), 0);
301 spawnCounter++;
302 pickupDelay += 2;
303 angle = angle + 30.0;
304 if (spawnCounter >= 12) {
305 spawnCounter = 0;
306 angleMult++;
307 angle = angleMult * 8;
308 }
309 }
310}
s32 gLastRenderTaskCount
Definition model.c:636
@ ENEMY_FLAG_NO_DROPS
Definition enums.h:4543
s32 make_item_entity(s32 itemID, f32 x, f32 y, f32 z, s32 itemSpawnMode, s32 pickupDelay, s32 angle, s32 pickupVar)
StatDrop heartDrops[8]
Definition npc.h:190
s16 coinsEarned
Definition npc.h:377
s32 flags
Definition npc.h:295
s16 item
Definition npc.h:160
EnemyDrops * drops
Definition npc.h:343
StatDrop flowerDrops[8]
Definition npc.h:191
s16 flagIdx
Definition npc.h:162
s16 chancePerAttempt
% chance for a single heart/flower to be dropped from each attempt.
Definition npc.h:183
ItemDrop itemDrops[8]
Definition npc.h:189
u8 itemDropChance
Definition npc.h:188
s16 generalChance
% chance for any hearts/flowers to be dropped at all from this StatDrop.
Definition npc.h:181
s16 weight
Definition npc.h:161
s16 attempts
Maximum number of hearts/flowers that can be dropped from this StatDrop.
Definition npc.h:182
s16 maxCoinBonus
Definition npc.h:193
s16 cutoff
% of max HP/FP. If current HP/FP > cutoff, no hearts/flowers can be dropped.
Definition npc.h:180
s16 minCoinBonus
Definition npc.h:192
@ GF_SpawnedItemDrop_00
comes from the third u16 in the selected item entry for enemy's drop table
#define MAX_SHADOWS
Definition macros.h:93

◆ set_part_pal_adjustment()

void set_part_pal_adjustment ( ActorPart * part,
s32 palAdjust )

Definition at line 2595 of file 190B20.c.

2595 {
2596 if (part->idleAnimations != NULL && !(part->flags & ACTOR_PART_FLAG_NO_DECORATIONS)) {
2597 DecorationTable* decorations = part->decorationTable;
2598
2599 if (decorations->paletteAdjustment != palAdjust) {
2600 decorations->paletteAdjustment = palAdjust;
2601 decorations->palAnimState = 0;
2602 decorations->resetPalAdjust = TRUE;
2603 }
2604 }
2605}

Referenced by set_actor_pal_adjustment().

◆ int_to_string()

char * int_to_string ( s32 integer,
char * dest,
s32 base )

Definition at line 385 of file 43F0.c.

385 {
386 u8 string[40]; // Even for binary this is a little long: 34 would suffice
387 s32 i = ARRAY_COUNT(string) - 2;
388 s32 negative = FALSE;
389 s64 longInteger = integer;
390
391 // handle negative integers
392 if (longInteger < 0) {
393 negative = TRUE;
394 longInteger *= -1;
395 }
396
397 // null-terminate string
398 string[ARRAY_COUNT(string) - 1] = '\0';
399
400 // extract digits, filling string from the back
401 while (TRUE) {
402 string[i] = sIntegerDigits[longInteger % base];
403 longInteger /= base;
404 if (longInteger == 0 || i == 0) {
405 break;
406 }
407 i--;
408 }
409
410 // Add - to negatives
411 if (negative) {
412 i--;
413 string[i] = '-';
414 }
415
416 // copy only populated part of string
417 strcpy(dest, &string[i]);
418
419 return dest;
420}
u8 sIntegerDigits[]
Definition 43F0.c:21

Referenced by draw_number(), and set_message_int_var().

◆ get_script_by_index()

Evt * get_script_by_index ( s32 index)

Definition at line 894 of file script_list.c.

894 {
895 return (*gCurrentScriptListPtr)[index];
896}

Referenced by dispatch_event_actor(), and func_802C73B8().

◆ get_script_by_id()

Evt * get_script_by_id ( s32 id)

Definition at line 898 of file script_list.c.

898 {
899 s32 i;
900 Evt* scriptContextPtr;
901
902 for (i = 0; i < MAX_SCRIPTS; i++) {
903 if ((*gCurrentScriptListPtr)[i] != NULL) {
904 scriptContextPtr = (*gCurrentScriptListPtr)[i];
905 if (scriptContextPtr->id == id) {
906 return scriptContextPtr;
907 }
908 }
909 }
910 return 0;
911}

Referenced by update_encounters_neutral().

◆ partner_test_enemy_collision()

s32 partner_test_enemy_collision ( Npc * enemy)

Definition at line 1051 of file partners.c.

1051 {
1053 return wPartner->testFirstStrike(wPartnerNpc, enemy);
1054 }
1055 return FALSE;
1056}
PartnerTesHitFunc testFirstStrike
Definition partners.h:19

Referenced by update_encounters_neutral().

◆ get_lava_reset_pos()

s32 get_lava_reset_pos ( f32 * x,
f32 * y,
f32 * z )

Definition at line 597 of file map_api.c.

597 {
598 Vec4f *temp_v0;
599 s32 temp_a0;
600 LavaReset* lavaReset = gLavaResetList;
601
602 if (LastSafeFloor == -1) {
604 *outX = temp_v0->x;
605 *outY = temp_v0->y;
606 *outZ = temp_v0->z;
607 return -1;
608 }
609
610 while (TRUE) {
611 if (lavaReset->colliderID == -1) {
612 break;
613 }
614
615 if (lavaReset->colliderID == LastSafeFloor) {
616 *outX = lavaReset->pos.x;
617 *outY = lavaReset->pos.y;
618 *outZ = lavaReset->pos.z;
619 return 1;
620 }
621 lavaReset++;
622 }
623 return 0;
624}
s32 LastSafeFloor
Definition script_list.c:24
LavaReset * gLavaResetList
Definition script_list.c:23
EntryList * entryList
Definition map.h:24

Referenced by action_update_hit_lava().

◆ start_rumble()

void start_rumble ( s32 freq,
s32 nframes )

Definition at line 15 of file rumble.c.

15 {
17 if (rumbleMaxDuration != 0) {
18#if !VERSION_JP
19 s32 maxFrames = rumbleMaxDuration * 2;
20
21 if (nframes > maxFrames) {
22 nframes = maxFrames;
23 }
24#endif
25
26 if (nuContRmbCheck(0) == 0) {
27 nuContRmbModeSet(0, 2);
28 nuContRmbStart(0, freq, nframes);
29 }
30 }
31 }
32}
u16 rumbleMaxDuration
Definition rumble.c:7

Referenced by action_hammer_play_hit_fx(), action_update_hit_lava(), action_update_spin_jump(), action_update_tornado_jump(), and entity_CymbalPlant_idle().

◆ update_locomotion_state()

void update_locomotion_state ( void )

Definition at line 281 of file 7E9D0.c.

281 {
282 PlayerStatus* playerStatus = &gPlayerStatus;
283
285 SQ(playerStatus->stickAxis[0]) + SQ(playerStatus->stickAxis[1]) > SQ(55))
286 {
288 } else {
290 }
291}

Referenced by action_update_land(), action_update_step_down_land(), action_update_step_up(), and phys_player_land().

◆ start_rumble_type()

void start_rumble_type ( u32 type)

Definition at line 3098 of file 190B20.c.

3098 {
3099 if (bCurRumbleScript != 0) {
3101 }
3102
3103 switch (type) {
3104 case BTL_RUMBLE_STOP:
3105 break;
3106 case BTL_RUMBLE_LONG:
3108 break;
3109 case BTL_RUMBLE_HIT_MIN:
3111 break;
3114 break;
3117 break;
3120 break;
3121 case BTL_RUMBLE_HIT_MAX:
3123 break;
3130 break;
3131 }
3132}
EvtScript EVS_BattleRumble_Long
Definition 190B20.c:3030
EvtScript EVS_BattleRumble_HitLight
Definition 190B20.c:3044
EvtScript EVS_BattleRumble_PlayerMin
Definition 190B20.c:3068
EvtScript EVS_BattleRumble_HitHeavy
Definition 190B20.c:3050
EvtScript EVS_BattleRumble_HitMin
Definition 190B20.c:3038
EvtScript EVS_BattleRumble_HitMax
Definition 190B20.c:3062
EvtScript EVS_BattleRumble_HitExtreme
Definition 190B20.c:3056
s32 bCurRumbleScript
Definition 190B20.c:44
@ BTL_RUMBLE_PLAYER_MIN
Definition enums.h:4258
@ BTL_RUMBLE_HIT_HEAVY
Definition enums.h:4255
@ BTL_RUMBLE_STOP
Definition enums.h:4251
@ BTL_RUMBLE_PLAYER_HEAVY
Definition enums.h:4260
@ BTL_RUMBLE_HIT_MIN
Definition enums.h:4253
@ BTL_RUMBLE_HIT_LIGHT
Definition enums.h:4254
@ BTL_RUMBLE_PLAYER_MAX
Definition enums.h:4262
@ BTL_RUMBLE_PLAYER_EXTREME
Definition enums.h:4261
@ BTL_RUMBLE_HIT_MAX
Definition enums.h:4257
@ BTL_RUMBLE_HIT_EXTREME
Definition enums.h:4256
@ BTL_RUMBLE_LONG
Definition enums.h:4252
@ BTL_RUMBLE_PLAYER_LIGHT
Definition enums.h:4259

◆ start_falling()

void start_falling ( void )

Definition at line 293 of file 7E9D0.c.

293 {
294 PlayerStatus* playerStatus = &gPlayerStatus;
295
298}
#define LOAD_INTEGRATOR_FALL(ptr)
Definition macros.h:190

Referenced by action_update_use_spinning_flower().

◆ start_bounce_a()

void start_bounce_a ( void )

Definition at line 300 of file 7E9D0.c.

300 {
301 PlayerStatus* playerStatus = &gPlayerStatus;
302
304 playerStatus->gravityIntegrator[0] = 10.0f;
305 playerStatus->gravityIntegrator[1] = -2.0f;
306 playerStatus->gravityIntegrator[2] = 0.8f;
307 playerStatus->gravityIntegrator[3] = -0.75f;
308}
@ ACTION_STATE_BOUNCE
Used with Kooper.
Definition enums.h:2431

Referenced by update_encounters_neutral().

◆ start_bounce_b()

void start_bounce_b ( void )

Definition at line 310 of file 7E9D0.c.

310 {
311 PlayerStatus* playerStatus = &gPlayerStatus;
312
314 playerStatus->gravityIntegrator[0] = 8.0f;
315 playerStatus->gravityIntegrator[1] = -1.0f;
316 playerStatus->gravityIntegrator[2] = 0;
317 playerStatus->gravityIntegrator[3] = 0;
318 playerStatus->flags |= PS_FLAG_SCRIPTED_FALL;
319}
@ PS_FLAG_SCRIPTED_FALL
Definition enums.h:3071

◆ update_input()

void update_input ( void )

Definition at line 31 of file input.c.

31 {
32 OSContPad* contData = &D_8009A5B8;
33 s16 handleInput = FALSE;
34 s16 cond1;
35 s32 buttons;
36 s16 stickX;
37 s16 stickY;
38
40 handleInput = TRUE;
41 nuContDataGet(contData, 0);
42 }
43
46 && (contData->button & (BUTTON_A | BUTTON_B | BUTTON_Z | BUTTON_START))
47 && handleInput
48 ) {
50 }
51 contData->button = gGameStatusPtr->demoButtonInput;
52 contData->stick_x = gGameStatusPtr->demoStickX;
53 contData->stick_y = gGameStatusPtr->demoStickY;
54 handleInput = TRUE;
55 }
56
57 if (!handleInput) {
58 return;
59 }
60
61 stickX = contData->stick_x;
62 stickY = contData->stick_y;
63 if (stickX > 0) {
64 stickX -= 4;
65 if (stickX < 0) {
66 stickX = 0;
67 }
68 }
69 if (stickX < 0) {
70 stickX += 4;
71 if (stickX > 0) {
72 stickX = 0;
73 }
74 }
75
76 if (stickY > 0) {
77 stickY -= 4;
78 if (stickY < 0) {
79 stickY = 0;
80 }
81 }
82 if (stickY < 0) {
83 stickY += 4;
84 if (stickY > 0) {
85 stickY = 0;
86 }
87 }
88
89 gGameStatusPtr->stickX[0] = stickX;
90 gGameStatusPtr->stickY[0] = stickY;
91
92 buttons = contData->button;
93 cond1 = FALSE;
94 if (stickX > 0x20) {
95 cond1 = TRUE;
96 buttons |= BUTTON_STICK_RIGHT;
98 D_8009A6A0 = stickX;
99 } else if (D_8009A6A4 == 0) {
100 if (D_8009A6A0 < stickX) {
101 D_8009A6A0 = stickX;
102 }
103 } else {
104 if (D_8009A6A0 > stickX) {
105 D_8009A6A0 = stickX;
106 }
107 }
108 }
109
110 if (stickX < -0x20) {
111 cond1 = TRUE;
112 buttons |= BUTTON_STICK_LEFT;
114 D_8009A6A0 = stickX;
115 } else if (D_8009A6A4 == 0) {
116 if (D_8009A6A0 > stickX) {
117 D_8009A6A0 = stickX;
118 }
119 } else {
120 if (D_8009A6A0 < stickX)
121 {
122 D_8009A6A0 = stickX;
123 }
124 }
125 }
126
127 if (!cond1) {
128 D_8009A6A4 = 0;
129 D_8009A6A0 = stickX;
130 }
131
132 cond1 = FALSE;
133 if (stickY > 0x20) {
134 cond1 = TRUE;
135 buttons |= BUTTON_STICK_UP;
137 D_8009A6A2 = stickY;
138 } else if (D_8009A6A6 == 0) {
139 if (D_8009A6A2 < stickY) {
140 D_8009A6A2 = stickY;
141 }
142 } else {
143 if (D_8009A6A2 > stickY) {
144 D_8009A6A2 = stickY;
145 }
146 }
147 }
148
149 if (stickY < -0x20) {
150 cond1 = TRUE;
151 buttons |= BUTTON_STICK_DOWN;
153 D_8009A6A2 = stickY;
154 } else if (D_8009A6A6 == 0) {
155 if (D_8009A6A2 > stickY) {
156 D_8009A6A2 = stickY;
157 }
158 } else {
159 if (D_8009A6A2 < stickY) {
160 D_8009A6A2 = stickY;
161 }
162 }
163 }
164
165 if (!cond1) {
166 D_8009A6A6 = 0;
167 D_8009A6A2 = stickY;
168 }
169
170 if (stickX > 0x20) {
171 if (D_8009A6A4 == 1 && stickX - D_8009A6A0 > 0x10) {
172 buttons &= ~BUTTON_STICK_RIGHT;
173 D_8009A6A4 = 0;
174 }
175 if (D_8009A6A0 - stickX > 0x10) {
176 D_8009A6A4 = 1;
177 }
178 }
179
180 if (stickX < -0x20) {
181 if (D_8009A6A4 == 1 && D_8009A6A0 - stickX > 0x10) {
182 buttons &= ~BUTTON_STICK_LEFT;
183 D_8009A6A4 = 0;
184 }
185 if (stickX - D_8009A6A0 > 0x10) {
186 D_8009A6A4 = 1;
187 }
188 }
189
190 if (stickY > 0x20) {
191 if (D_8009A6A6 == 1 && stickY - D_8009A6A2 > 0x10) {
192 buttons &= ~BUTTON_STICK_UP;
193 D_8009A6A6 = 0;
194 }
195 if (D_8009A6A2 - stickY > 0x10) {
196 D_8009A6A6 = 1;
197 }
198 }
199
200 if (stickY < -0x20) {
201 if (D_8009A6A6 == 1 && D_8009A6A2 - stickY > 0x10) {
202 buttons &= ~BUTTON_STICK_DOWN;
203 D_8009A6A6 = 0;
204 }
205 if (stickY - D_8009A6A2 > 0x10) {
206 D_8009A6A6 = 1;
207 }
208 }
209
210 gGameStatusPtr->curButtons[0] = buttons;
213
214 if (gGameStatusPtr->curButtons[0] == 0) {
216 } else if (gGameStatusPtr->prevButtons[0] != gGameStatusPtr->curButtons[0]) {
222 } else {
223 if (gGameStatusPtr->unk_60 >= 0) {
225 if (gGameStatusPtr->unk_60 != 0) {
227 } else {
230 }
231 } else {
233 if (gGameStatusPtr->unk_58 != 0) {
235 } else {
238 }
239 }
240 }
241
243}
@ BUTTON_STICK_UP
Definition enums.h:2791
@ BUTTON_STICK_DOWN
Definition enums.h:2792
BSS s16 D_8009A6A4
Definition input.c:7
OSContPad D_8009A5B8
Definition input.c:4
BSS s16 D_8009A6A2
Definition input.c:6
BSS s16 D_8009A6A0
Definition input.c:5
BSS s16 D_8009A6A6
Definition input.c:8

Referenced by step_game_loop().

◆ update_max_rumble_duration()

void update_max_rumble_duration ( void )

Definition at line 34 of file rumble.c.

34 {
38 }
39
40 if (rumbleMaxDuration != 0) {
42 }
43}
s32 rumbleButtons
Definition rumble.c:8
void reset_max_rumble_duration(void)
Definition rumble.c:45

Referenced by step_game_loop().

◆ mdl_reset_transform_flags()

void mdl_reset_transform_flags ( void )

Definition at line 3755 of file model.c.

3755 {
3756 s32 i;
3757
3758 for (i = 0; i < ARRAY_COUNT(*gCurrentModels); i++) {
3759 Model* model = (*gCurrentModels)[i];
3760
3761 if (model != NULL) {
3762 model->flags &= ~MODEL_FLAG_HAS_TRANSFORM;
3763 }
3764 }
3765
3766 for (i = 0; i < ARRAY_COUNT(*gCurrentTransformGroups); i++) {
3767 ModelTransformGroup* transformGroup = (*gCurrentTransformGroups)[i];
3768
3769 if (transformGroup != NULL) {
3770 transformGroup->flags &= ~TRANSFORM_GROUP_FLAG_HAS_TRANSFORM;
3771 }
3772 }
3773}

Referenced by step_game_loop().

◆ update_workers()

void update_workers ( void )

Definition at line 125 of file worker.c.

125 {
126 s32 i;
127
128 for (i = 0; i < MAX_WORKERS; i++) {
129 Worker* worker = (*gCurrentWorkerListPtr)[i];
130 if (worker != NULL) {
131 worker->flags &= ~WORKER_FLAG_SKIP_DRAW_UNTIL_UPDATE;
132 worker->update();
133 }
134 }
135}

Referenced by step_game_loop().

◆ update_triggers()

void update_triggers ( void )

Definition at line 89 of file trigger.c.

89 {
90 CollisionStatus* collisionStatus = &gCollisionStatus;
91 Trigger* listTrigger;
92 s32 i;
93
94 collisionStatus->touchingWallTrigger = 0;
95
96 for (i = 0; i < ARRAY_COUNT(*gCurrentTriggerListPtr); i++) {
97 listTrigger = (*gCurrentTriggerListPtr)[i];
98
99 if (listTrigger == NULL) {
100 continue;
101 }
102
103 if (!(listTrigger->flags & TRIGGER_ACTIVE)) {
104 continue;
105 }
106
107 if (listTrigger->flags & TRIGGER_FORCE_ACTIVATE) {
108 listTrigger->flags |= TRIGGER_ACTIVATED;
109 continue;
110 }
111
112 if (listTrigger->flags & TRIGGER_WALL_PUSH) {
113 if (listTrigger->location.colliderID == collisionStatus->curWall) {
114 func_800E06C0(1);
115 }
116 if (listTrigger->location.colliderID == collisionStatus->pushingAgainstWall) {
117 func_800E06C0(0);
118 } else {
119 continue;
120 }
121 }
122
123 if (listTrigger->flags & TRIGGER_FLOOR_TOUCH) {
124 if (listTrigger->location.colliderID != collisionStatus->curFloor) {
125 continue;
126 }
127 }
128
129 if (listTrigger->flags & TRIGGER_FLOOR_ABOVE) {
130 if (listTrigger->location.colliderID != collisionStatus->floorBelow) {
131 continue;
132 }
133 }
134
135 if (listTrigger->flags & TRIGGER_WALL_PRESS_A) {
136 if (listTrigger->location.colliderID == collisionStatus->curWall) {
137 collisionStatus->touchingWallTrigger = 1;
138 }
139 if ((listTrigger->location.colliderID != collisionStatus->curInspect) || !phys_can_player_interact()) {
140 continue;
141 }
142 }
143
144 if (listTrigger->flags & TRIGGER_WALL_TOUCH) {
145 if (listTrigger->location.colliderID != collisionStatus->curWall) {
146 continue;
147 }
148 }
149
150 if (listTrigger->flags & TRIGGER_FLOOR_JUMP) {
151 if (listTrigger->location.colliderID != collisionStatus->lastTouchedFloor) {
152 continue;
153 }
154 }
155
156 if (listTrigger->flags & TRIGGER_FLOOR_PRESS_A) {
157 if ((listTrigger->location.colliderID != collisionStatus->curFloor) ||
159 continue;
160 }
161 }
162
163 if (listTrigger->flags & TRIGGER_WALL_HAMMER) {
164 if (listTrigger->location.colliderID != collisionStatus->lastWallHammered) {
165 continue;
166 }
167 }
168
169 if (listTrigger->flags & TRIGGER_CEILING_TOUCH) {
170 if (listTrigger->location.colliderID != collisionStatus->curCeiling) {
171 continue;
172 }
173 }
174
175 if (listTrigger->flags & TRIGGER_FLAG_2000) {
176 if (listTrigger->location.colliderID != collisionStatus->unk_0C) {
177 continue;
178 }
179 }
180
181 if (listTrigger->flags & TRIGGER_FLAG_4000) {
182 if (listTrigger->location.colliderID != collisionStatus->unk_0E) {
183 continue;
184 }
185 }
186
187 if (listTrigger->flags & TRIGGER_FLAG_8000) {
188 if (listTrigger->location.colliderID != collisionStatus->unk_10) {
189 continue;
190 }
191 }
192
193 if (listTrigger->flags & TRIGGER_POINT_BOMB) {
194 BombTrigger* bombPos;
195 f32 dist;
196
197 if (collisionStatus->bombetteExploded < 0) {
198 continue;
199 }
200
201 bombPos = listTrigger->location.blast;
202 dist = dist3D(bombPos->pos.x, bombPos->pos.y, bombPos->pos.z,
203 collisionStatus->bombetteExplosionPos.x, collisionStatus->bombetteExplosionPos.y,
204 collisionStatus->bombetteExplosionPos.z);
205
206 if ((bombPos->diameter * 0.5f) + 50.0f < dist) {
207 continue;
208 }
209 }
210
211 if (listTrigger->flags & TRIGGER_GAME_FLAG_SET && get_global_flag(listTrigger->varIndex) == 0) {
212 continue;
213 }
214
215 if (listTrigger->flags & TRIGGER_AREA_FLAG_SET && get_area_flag(listTrigger->varIndex) == 0) {
216 continue;
217 }
218
219 listTrigger->flags |= TRIGGER_ACTIVATED;
220 }
221
222 for (i = 0; i < ARRAY_COUNT(*gCurrentTriggerListPtr); i++) {
223 listTrigger = (*gCurrentTriggerListPtr)[i];
224
225 if (listTrigger == NULL) {
226 continue;
227 }
228
229 if (listTrigger->flags & TRIGGER_ACTIVE) {
230 if (listTrigger->flags & TRIGGER_ACTIVATED) {
231 if (listTrigger->onActivateFunc(listTrigger) == 0) {
232 listTrigger->flags &= ~TRIGGER_ACTIVATED;
233 }
234 }
235 }
236 }
237}
@ TRIGGER_FLAG_8000
Definition enums.h:2685
@ TRIGGER_AREA_FLAG_SET
Definition enums.h:2687
@ TRIGGER_FORCE_ACTIVATE
Definition enums.h:2675
@ TRIGGER_FLOOR_JUMP
Definition enums.h:2679
@ TRIGGER_FLAG_4000
Definition enums.h:2684
@ TRIGGER_FLOOR_ABOVE
Definition enums.h:2689
@ TRIGGER_GAME_FLAG_SET
Definition enums.h:2686
@ TRIGGER_WALL_HAMMER
Definition enums.h:2682
@ TRIGGER_WALL_PRESS_A
Definition enums.h:2678
@ TRIGGER_CEILING_TOUCH
Definition enums.h:2688
@ TRIGGER_WALL_PUSH
Definition enums.h:2676
@ TRIGGER_FLOOR_PRESS_A
Definition enums.h:2681
@ TRIGGER_FLOOR_TOUCH
Definition enums.h:2677
@ TRIGGER_POINT_BOMB
Definition enums.h:2690
@ TRIGGER_FLAG_2000
Definition enums.h:2683
@ TRIGGER_WALL_TOUCH
Definition enums.h:2680
s32 phys_can_player_interact(void)
Definition 7BB60.c:1159
f32 dist3D(f32 ax, f32 ay, f32 az, f32 bx, f32 by, f32 bz)
Definition 43F0.c:676
void func_800E06C0(s32)
Definition 77480.c:1160

Referenced by step_game_loop().

◆ update_scripts()

void update_scripts ( void )

Definition at line 550 of file script_list.c.

550 {
551 s32 i;
552
554 return;
555 }
556
557 IsUpdatingScripts = TRUE;
558 sort_scripts();
559
560 for (i = 0; i < gScriptListCount; i++) {
561 Evt* script = (*gCurrentScriptListPtr)[gScriptIndexList[i]];
562
563 if (script != NULL &&
564 script->id == gScriptIdList[i] &&
565 script->stateFlags != 0 &&
567 {
568 s32 stop = FALSE;
569 s32 status;
570
571 script->frameCounter += script->timeScale;
572
573 do {
574 if (script->frameCounter < 1.0) {
575 // Continue to next script
576 break;
577 };
578
579 script->frameCounter -= 1.0;
580 status = evt_execute_next_command(script);
581 if (status == EVT_CMD_RESULT_ERROR) {
582 stop = TRUE;
583 break;
584 }
585 } while (status != EVT_CMD_RESULT_YIELD);
586
587 if (stop) {
588 break;
589 }
590 }
591 }
592 IsUpdatingScripts = FALSE;
593}
@ DEBUG_SCRIPTS_NO_UPDATE
Definition enums.h:4275
@ EVT_CMD_RESULT_YIELD
Definition evt.h:123
@ EVT_CMD_RESULT_ERROR
Definition evt.h:125
@ EVT_FLAG_PAUSED
paused through suspend_group_script / resume_group_script
Definition evt.h:159
@ EVT_FLAG_SUSPENDED
doesn't affect child
Definition evt.h:163
void sort_scripts(void)
Definition script_list.c:71
s32 evt_execute_next_command(Evt *script)
Definition evt.c:1350

Referenced by step_game_loop().

◆ update_messages()

void update_messages ( void )

Definition at line 247 of file msg.c.

247 {
248 s32 i;
249
251 if (gMsgGlobalWaveCounter >= 360) {
253 }
254
255 for (i = 0; i < ARRAY_COUNT(gMessagePrinters); i++) {
256 if (gMessagePrinters[i].stateFlags & MSG_STATE_FLAG_2) {
257 _update_message(&gMessagePrinters[i]);
258 }
259 }
260
261 gMsgBGScrollAmtX += 12;
262 gMsgBGScrollAmtY -= 12;
263 if (gMsgBGScrollAmtX >= 2048) {
264 gMsgBGScrollAmtX -= 2048;
265 }
266 if (gMsgBGScrollAmtY < 0) {
267 gMsgBGScrollAmtY += 2048;
268 }
269}
u16 gMsgGlobalWaveCounter
Definition msg.c:89
s32 gMsgBGScrollAmtY
Definition msg.c:91
s32 _update_message(MessagePrintState *printer)
Definition msg.c:271
s32 gMsgBGScrollAmtX
Definition msg.c:88

Referenced by step_game_loop().

◆ update_entities()

void update_entities ( void )

Definition at line 82 of file entity.c.

82 {
83 s32 i;
84
85 D_801512BC = 0;
88
89 for (i = 0; i < MAX_ENTITIES; i++) {
90 Entity* entity = get_entity_by_index(i);
91
92 if (entity != NULL) {
94
95 if (!(entity->flags & ENTITY_FLAG_SKIP_UPDATE)) {
97 entity->flags &= ~ENTITY_FLAG_BOUND_SCRIPT_DIRTY;
98 if (!(entity->flags & ENTITY_FLAG_8000)) {
99 entity->flags |= ENTITY_FLAG_2000000;
100 }
102 }
103
104 if (entity->flags & ENTITY_FLAG_2000000) {
105 if (does_script_exist(entity->boundScript->id)) {
108 } else {
110 }
111
114 }
115
118 }
119 continue;
120 } else {
121 entity->flags &= ~ENTITY_FLAG_2000000;
122 }
123 }
124
125 if (entity->collisionTimer == 0) {
127
128 if (entity->collisionFlags) {
129 EntityCallback handleCollision = entity->blueprint->fpHandleCollision;
130
131 if (handleCollision != NULL && handleCollision(entity) != 0) {
132 entity->collisionTimer = 10;
134 }
135 }
136 } else {
137 entity->collisionTimer--;
139 if (entity->collisionTimer == 0) {
141 } else {
143 }
144 } else if (entity->collisionTimer == 0) {
145 entity->flags &= ~ENTITY_FLAG_DETECTED_COLLISION;
146 entity->flags &= ~ENTITY_FLAG_PARTNER_COLLISION;
147 entity->collisionFlags = 0;
148 }
149 }
150
153 }
154
156 if (entity->updateScriptCallback != NULL) {
157 entity->updateScriptCallback(entity);
158 }
159
160 if (entity->scriptReadPos != NULL) {
161 if (entity->scriptDelay != 0) {
162 entity->scriptDelay--;
163 if (entity->scriptDelay == 0) {
164 while (step_entity_commandlist(entity));
165 }
166 }
167 }
168 }
169
172 }
173
174 if (!(entity->flags & ENTITY_FLAG_DISABLE_COLLISION)) {
176 }
177
180 } else {
182 }
183
184 if (entity->shadowIndex >= 0) {
186 }
187
189 delete_entity(entity->listIndex);
190 }
191
194 }
195 }
196 }
197 }
198
201}
s32(* EntityCallback)(struct Entity *)
void update_entity_shadow_position(Entity *entity)
Definition entity.c:1560
void update_shadows(void)
Definition entity.c:203
void delete_entity(s32 entityIndex)
Definition entity.c:578
void update_entity_inverse_rotation_matrix(Entity *entity)
Definition entity.c:517
s32 step_entity_commandlist(Entity *entity)
Definition entity.c:241
s32 entity_get_collision_flags(Entity *entity)
Definition entity.c:634
void delete_entity_and_unload_data(s32 entityIndex)
Definition entity.c:601
s32 entity_updateCounter
Definition entity.c:49
s32 D_801512BC
Definition entity.c:39
HiddenPanelsData gCurrentHiddenPanels
Definition entity.c:36
s32 entity_numEntities
Definition entity.c:42
@ ENTITY_FLAG_8000
Definition enums.h:2628
@ ENTITY_FLAG_DETECTED_COLLISION
Definition enums.h:2629
@ ENTITY_FLAG_CONTINUOUS_COLLISION
Definition enums.h:2619
@ ENTITY_FLAG_2000000
Definition enums.h:2638
@ ENTITY_FLAG_BOUND_SCRIPT_DIRTY
Definition enums.h:2637
@ ENTITY_FLAG_SKIP_UPDATE_TRANSFORM_MATRIX
Definition enums.h:2617
@ ENTITY_FLAG_PENDING_INSTANCE_DELETE
Definition enums.h:2642
@ ENTITY_FLAG_ALWAYS_FACE_CAMERA
Definition enums.h:2626
@ ENTITY_FLAG_PENDING_FULL_DELETE
Definition enums.h:2639
void update_model_animator(s32)
Definition animator.c:482
EntityCallback fpHandleCollision

Referenced by step_game_loop().

◆ func_80138198()

void func_80138198 ( void )

Definition at line 473 of file screen_overlays.c.

473 {
474}

Referenced by step_game_loop().

◆ bgm_update_music_settings()

void bgm_update_music_settings ( void )

Definition at line 82 of file e0b30_len_b80.c.

82 {
84 s32 i = 0;
85 s16 state2 = 2;
86 s16 flag4 = MUSIC_SETTINGS_FLAG_4;
87 s32 flags;
88
89 for (i; i < ARRAY_COUNT(gMusicSettings); i++, music++) {
90 switch (music->state) {
91 case 0:
92 break;
93 case 1:
94 if (music->flags & MUSIC_SETTINGS_FLAG_1) {
95 if (music->fadeOutTime < 250) {
96 if (!(music->flags & MUSIC_SETTINGS_FLAG_4)) {
97 if (au_song_stop(music->songName) == AU_RESULT_OK) {
98 music->state = state2;
99 }
100 } else {
101 if (func_80055AF0(music->songName) == AU_RESULT_OK) {
102 music->state = state2;
103 }
104 }
105 } else if (!(music->flags & MUSIC_SETTINGS_FLAG_4)) {
106 if (snd_set_song_variation_fade_time(music->songName, music->fadeOutTime, 0) == 0) {
107 music->state = state2;
108 }
109 } else {
110 if (func_80055BB8(music->songName, 250) == AU_RESULT_OK) {
111 music->state = state2;
112 }
113 }
114 } else {
115 if (music->flags & MUSIC_SETTINGS_FLAG_4) {
117 }
118 music->flags &= ~flag4;
119 music->state = 5;
120 }
121 break;
122 case 2:
123 flags = music->flags;
124 music->flags &= ~flag4;
127 music->flags &= ~MUSIC_SETTINGS_FLAG_1;
128 music->state = 3;
129 }
130 } else {
131 music->state = 5;
132 }
133 break;
134 case 3:
135 music->state = 4;
136 break;
137 case 4:
138 music->state = 5;
139 break;
140 case 5:
141 if (!(music->flags & MUSIC_SETTINGS_FLAG_8)) {
142 if (music->songID < 0) {
143 music->state = 0;
144 } else {
145 music->songName = au_song_load(music->songID, i);
146 if (music->songName > 0xFFFFU) {
147 if ((music->flags & MUSIC_SETTINGS_FLAG_20)) {
149 music->fadeInTime, music->fadeStartVolume, music->fadeEndVolume);
150 music->flags &= ~MUSIC_SETTINGS_FLAG_20;
151 } else {
153 }
154 if (au_song_start_variation(music->songName, music->variation) == 0) {
156 music->state = 0;
157 }
158 }
159 }
160 } else {
161 if (music->flags & MUSIC_SETTINGS_FLAG_10) {
162 music->state = 0;
164 } else if (func_80055B28(music->savedSongName) == 0) {
165 music->songID = music->savedSongID;
166 music->variation = music->savedVariation;
167 music->songName = music->savedSongName;
168 music->state = 0;
170 music->flags &= ~MUSIC_SETTINGS_FLAG_8;
171 }
172 }
173 break;
174 }
175 }
177}
AuResult func_80055AF0(s32 songName)
Definition 30450.c:540
AuResult au_song_load(s32 songID, s32 playerIndex)
Definition 30450.c:436
AuResult au_song_is_playing(s32 songName)
Definition 30450.c:491
AuResult func_80055BB8(s32 songName, s32 fadeTime)
Definition 30450.c:579
AuResult snd_set_song_variation_fade(s32 songName, s32 variation, s32 fadeInTime, s32 startVolume, s32 endVolume)
Definition 30450.c:495
AuResult func_80055B28(s32 songName)
Definition 30450.c:551
AuResult snd_set_song_variation_fade_time(s32 songName, s32 fadeTime, s32 variation)
Definition 30450.c:529
AuResult au_song_start_variation(s32 songName, s32 variation)
Definition 30450.c:466
void bgm_update_volume(void)
void bgm_set_target_volume(s16 volume)
BSS s16 MusicDefaultVolume
@ MUSIC_SETTINGS_FLAG_10
Definition enums.h:4663
@ MUSIC_SETTINGS_FLAG_8
Definition enums.h:4662

Referenced by step_game_loop().

◆ func_8014AD40()

s32 func_8014AD40 ( void )

Definition at line 359 of file e0b30_len_b80.c.

359 {
360 MusicSettings* settings = gMusicSettings;
361 s32 i;
362
363 for (i = 0; i < ARRAY_COUNT(gMusicSettings); i++, settings++) {
364 if (!(settings->flags & MUSIC_SETTINGS_FLAG_1)) {
365 continue;
366 }
367
368 if (au_song_is_playing(settings->songName)) {
369 return TRUE;
370 }
371 }
372 return FALSE;
373}

◆ update_ambient_sounds()

void update_ambient_sounds ( void )

Definition at line 32 of file ambience.c.

32 {
33 AmbientSoundSettings* ambientSoundState = &AmbientSoundData;
34 s32 error;
35
36 switch (ambientSoundState->fadeState) {
38 break;
40 if (ambientSoundState->flags & 1) {
41 if (ambientSoundState->fadeTime < 250) {
42 error = snd_ambient_stop_quick(0);
43 } else {
44 error = snd_ambient_stop_slow(0, ambientSoundState->fadeTime);
45 }
46
47 if (error != AU_RESULT_OK) {
48 return;
49 }
50 }
51 ambientSoundState->fadeState = AMBIENT_SOUND_FADE_IN;
52 break;
54 if (ambientSoundState->flags & 1) {
56 return;
57 }
58 ambientSoundState->flags &= ~1;
59 }
60 if (ambientSoundState->soundID < 0) {
61 ambientSoundState->fadeState = AMBIENT_SOUND_IDLE;
62 } else if (snd_load_ambient(ambientSoundState->soundID) == AU_RESULT_OK) {
63 if (snd_ambient_play(0, 0) == AU_RESULT_OK) {
64 ambientSoundState->fadeState = AMBIENT_SOUND_IDLE;
65 ambientSoundState->flags |= 1;
66 }
67 }
68 break;
69 }
70}
AuResult snd_load_ambient(s32 ambSoundID)
Definition 30450.c:272
AuResult snd_ambient_stop_slow(s32 index, s32 fadeOutTime)
Definition 30450.c:295
AuResult snd_ambient_stop_quick(s32 index)
Definition 30450.c:285
AuResult snd_ambient_play(s32 index, s32 fadeInTime)
Definition 30450.c:276
AuResult snd_ambient_is_stopped(s32 index)
Definition 30450.c:325
AmbientSoundSettings AmbientSoundData
Definition ambience.c:26
@ AMBIENT_SOUND_FADE_OUT
Definition ambience.c:14
@ AMBIENT_SOUND_IDLE
Definition ambience.c:13
@ AMBIENT_SOUND_FADE_IN
Definition ambience.c:15

Referenced by step_game_loop().

◆ update_windows()

void update_windows ( void )

Definition at line 143 of file windows.c.

143 {
144 s32 i;
145
146 for (i = 0; i < ARRAY_COUNT(gWindows); i++) {
147 u8 flags = gWindows[i].flags;
148
149 if (!flags || (flags & WINDOW_FLAG_DISABLED)) {
150 continue;
151 }
152
154 gWindows[i].flags = flags & ~WINDOW_FLAG_FPUPDATE_CHANGED;
156 gWindows[i].updateCounter = 0;
157 }
158 }
159}
@ WINDOW_FLAG_DISABLED
Not updated or rendered.
Definition enums.h:4997
WindowUpdateFunc fpUpdate

Referenced by step_game_loop().

◆ player_render_interact_prompts()

void player_render_interact_prompts ( void )

Definition at line 1028 of file 77480.c.

1028 {
1033}
void render_interact_prompt(void)
Definition 77480.c:1316
void render_conversation_prompt(void)
Definition 77480.c:1149
void render_pulse_stone_icon(void)
Definition 77480.c:1100
void render_ispy_icon(void)
Definition 77480.c:1051

Referenced by gfx_draw_frame().

◆ func_802C3EE4()

void func_802C3EE4 ( void )

Definition at line 596 of file script_list.c.

596 {
597 s32 temp;
598 s32 i;
599
600 for (i = 0; i < gScriptListCount; i++) {
601 temp = (s32) (*gCurrentScriptListPtr)[gScriptIndexList[i]];
602 temp = *((s32*) temp);
603 if (temp == gScriptIdList[i]) {
604 temp = 1;
605 }
606 }
607}

Referenced by gfx_draw_frame().

◆ render_screen_overlay_backUI()

void render_screen_overlay_backUI ( void )

Definition at line 485 of file screen_overlays.c.

485 {
487 && screen_overlay_backZoom != -1.0f
489 ) {
491 }
492}
@ CONTEXT_PAUSE
Definition enums.h:3530
void _render_transition_stencil(u8 stencilType, f32 progress, ScreenOverlay *overlay)

Referenced by gfx_draw_frame().

◆ render_workers_backUI()

void render_workers_backUI ( void )

Definition at line 163 of file worker.c.

163 {
164 s32 i;
165
166 for (i = 0; i < MAX_WORKERS; i++) {
167 Worker* worker = (*gCurrentWorkerListPtr)[i];
168 if (worker != NULL && !(worker->flags & WORKER_FLAG_SKIP_DRAW_UNTIL_UPDATE)) {
169 if (worker->flags & WORKER_FLAG_BACK_UI) {
170 worker->draw();
171 }
172 }
173 }
174}
@ WORKER_FLAG_BACK_UI
Definition enums.h:2773

Referenced by gfx_draw_frame().

◆ render_effects_UI()

void render_effects_UI ( void )

Definition at line 140 of file effects.c.

140 {
141 s32 cond = TRUE;
142 s32 i;
143
144 for (i = 0; i < ARRAY_COUNT(gEffectInstances); i++) {
145 EffectInstance* effectInstance = gEffectInstances[i];
146
147 if (effectInstance != NULL) {
148 if (effectInstance->flags & FX_INSTANCE_FLAG_ENABLED) {
149 if (effectInstance->flags & FX_INSTANCE_FLAG_HAS_UPDATED) {
150 void (*renderUI)(EffectInstance* effect);
151
152 if (gGameStatusPtr->context != CONTEXT_WORLD && !(effectInstance->flags & FX_INSTANCE_FLAG_BATTLE)) {
153 continue;
154 }
155
157 continue;
158 }
159
160 renderUI = effectInstance->shared->renderUI;
161 if (renderUI != stub_effect_delegate) {
162 if (cond) {
163 Camera* camera = &gCameras[gCurrentCameraID];
164
165 gDPPipeSync(gMainGfxPos++);
166 gSPViewport(gMainGfxPos++, &camera->vp);
167 gSPClearGeometryMode(gMainGfxPos++, G_ZBUFFER | G_SHADE | G_CULL_BOTH | G_FOG |
168 G_LIGHTING | G_TEXTURE_GEN | G_TEXTURE_GEN_LINEAR | G_LOD |
169 G_SHADING_SMOOTH | G_CLIPPING | 0x40F9FA);
170 gSPSetGeometryMode(gMainGfxPos++, G_ZBUFFER | G_SHADE | G_CULL_BACK | G_SHADING_SMOOTH);
171 gDPSetScissor(gMainGfxPos++, G_SC_NON_INTERLACE,
172 camera->viewportStartX,
173 camera->viewportStartY,
174 camera->viewportStartX + camera->viewportW,
175 camera->viewportStartY + camera->viewportH);
176 gSPClipRatio(gMainGfxPos++, FRUSTRATIO_2);
177
178 cond = FALSE;
179 if (!(camera->flags & CAMERA_FLAG_ORTHO)) {
180 gSPPerspNormalize(gMainGfxPos++, camera->perspNorm);
182 G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_PROJECTION);
183 }
184 }
185
186 renderUI(effectInstance);
187 }
188 }
189 }
190 }
191 }
192}
EffectInstance * gEffectInstances[96]
Definition effects.c:11
void stub_effect_delegate(EffectInstance *effect)
Used for unbound function points in effect structs.
Definition effects.c:30
struct EffectSharedData * shared
Definition effects.h:2606
@ FX_INSTANCE_FLAG_BATTLE
Definition enums.h:3515
@ FX_INSTANCE_FLAG_ENABLED
Definition enums.h:3514
@ FX_INSTANCE_FLAG_HAS_UPDATED
Definition enums.h:3516
void(* renderUI)(EffectInstance *effectInst)
Definition effects.h:2665

Referenced by gfx_draw_frame().

◆ render_window_root()

void render_window_root ( void )

Definition at line 347 of file windows.c.

347 {
348 s32 priorityArray[ARRAY_COUNT(gWindows)];
349 s32 i;
350
351 for (i = 0; i < ARRAY_COUNT(gWindows); i++) {
352 priorityArray[i] = WIN_NONE;
353 }
354
355 for (i = 0; i < ARRAY_COUNT(gWindows); i++) {
356 if (gWindows[i].flags != 0) {
357 priorityArray[gWindows[i].priority] = i;
358 }
359 }
360
361 gSPLoadGeometryMode(gMainGfxPos++, 0);
362 gSPSetGeometryMode(gMainGfxPos++, G_ZBUFFER | G_SHADE | G_CULL_BOTH | G_SHADING_SMOOTH);
363 gDPPipelineMode(gMainGfxPos++, G_PM_NPRIMITIVE);
364 gDPSetCombineMode(gMainGfxPos++, G_CC_SHADE, G_CC_SHADE);
365 gDPSetAlphaCompare(gMainGfxPos++, G_AC_NONE);
366 gSPSetOtherMode(gMainGfxPos++, G_SETOTHERMODE_H, G_MDSFT_ALPHADITHER, 16, G_AD_DISABLE | G_CD_DISABLE | G_CK_NONE | G_TC_FILT | G_TF_BILERP | G_TT_NONE | G_TL_TILE | G_TD_CLAMP | G_TP_NONE);
367 gSPClipRatio(gMainGfxPos++, FRUSTRATIO_2);
368 gDPSetColorImage(gMainGfxPos++, G_IM_FMT_RGBA, G_IM_SIZ_16b, SCREEN_WIDTH, osVirtualToPhysical(nuGfxCfb_ptr));
369 gDPPipeSync(gMainGfxPos++);
370 render_windows(priorityArray, WIN_NONE, 0, 0, 0, 255, 0, NULL);
371}
void render_windows(s32 *windowsArray, s32 parent, s32 flags, s32 baseX, s32 baseY, s32 opacity, s32 darkening, f32(*rotScaleMtx)[4])
Definition windows.c:217

Referenced by gfx_draw_frame().

◆ render_messages()

void render_messages ( void )

Definition at line 568 of file msg.c.

568 {
569 Mtx* matrix = &gMessageWindowProjMatrix[gCurrentDisplayContextIndex];
570 s32 i;
571
572 for (i = 0; i < ARRAY_COUNT(gMessagePrinters); i++) {
573 if (gMessagePrinters[i].stateFlags & MSG_STATE_FLAG_2) {
574 gSPViewport(gMainGfxPos++, &D_8014C280);
575 guOrtho(matrix, 0.0f, 319.0f, -240.0f, 0.0f, -500.0f, 500.0f, 1.0f);
576 gSPMatrix(gMainGfxPos++, OS_K0_TO_PHYSICAL(matrix), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_PROJECTION);
577 gDPPipeSync(gMainGfxPos++);
578 gDPSetCycleType(gMainGfxPos++, G_CYC_1CYCLE);
579 gSPClearGeometryMode(gMainGfxPos++, G_SHADE | G_CULL_BOTH | G_FOG | G_LIGHTING | G_TEXTURE_GEN |
580 G_TEXTURE_GEN_LINEAR | G_LOD | G_SHADING_SMOOTH);
581 gSPSetGeometryMode(gMainGfxPos++, G_SHADE | G_SHADING_SMOOTH);
582 break;
583 }
584 }
585
586 for (i = 0; i < ARRAY_COUNT(gMessagePrinters); i++) {
587 if (gMessagePrinters[i].stateFlags & MSG_STATE_FLAG_2) {
588 draw_message_window(&gMessagePrinters[i]);
589
590 if (gMessagePrinters[i].windowState == MSG_WINDOW_STATE_WAITING) {
591 if (!(gMessagePrinters[i].stateFlags & MSG_STATE_FLAG_8000) &&
592 !(gMessagePrinters[i].stateFlags & MSG_STATE_FLAG_40))
593 {
595 }
596 } else if (gMessagePrinters[i].windowState == MSG_WINDOW_STATE_C) {
598 } else if (gMessagePrinters[i].windowState == MSG_WINDOW_STATE_WAITING_FOR_CHOICE ||
599 gMessagePrinters[i].windowState == MSG_WINDOW_STATE_SCROLLING_BACK ||
600 gMessagePrinters[i].stateFlags & MSG_STATE_FLAG_10000 ||
601 gMessagePrinters[i].stateFlags & MSG_STATE_FLAG_20000)
602 {
603 msg_draw_choice_pointer(&gMessagePrinters[i]);
604 }
605 }
606 }
607}
@ MSG_STATE_FLAG_10000
Definition enums.h:6251
@ MSG_STATE_FLAG_40
Definition enums.h:6243
@ MSG_STATE_FLAG_20000
Definition enums.h:6252
@ MSG_STATE_FLAG_8000
Definition enums.h:6250
@ MSG_WINDOW_STATE_WAITING
Definition enums.h:6271
@ MSG_WINDOW_STATE_WAITING_FOR_CHOICE
Definition enums.h:6273
@ MSG_WINDOW_STATE_C
Definition enums.h:6278
@ MSG_WINDOW_STATE_SCROLLING_BACK
Definition enums.h:6274
void msg_draw_rewind_arrow(s32)
Definition msg.c:2145
Vp D_8014C280
Definition msg.c:34
void msg_update_rewind_arrow(s32)
Definition msg.c:2061
void draw_message_window(MessagePrintState *printer)
Definition msg_draw.c:137
void msg_draw_choice_pointer(MessagePrintState *printer)
Definition msg.c:2159
s32 gCurrentDisplayContextIndex
Definition main_loop.c:47

Referenced by gfx_draw_frame().

◆ render_workers_frontUI()

void render_workers_frontUI ( void )

Definition at line 150 of file worker.c.

150 {
151 s32 i;
152
153 for (i = 0; i < MAX_WORKERS; i++) {
154 Worker* worker = (*gCurrentWorkerListPtr)[i];
155 if (worker != NULL && !(worker->flags & WORKER_FLAG_SKIP_DRAW_UNTIL_UPDATE)) {
156 if (worker->flags & WORKER_FLAG_FRONT_UI) {
157 worker->draw();
158 }
159 }
160 }
161}

Referenced by gfx_draw_frame().

◆ render_screen_overlay_frontUI()

void render_screen_overlay_frontUI ( void )

◆ render_curtains()

void render_curtains ( void )

Definition at line 223 of file curtains.c.

223 {
226 }
227
230 }
231
232 if (gCurtainScale < 1.9) {
233 Matrix4f m;
234 f32 scale;
235 s8 rgb;
236
237 gDPPipeSync(gMainGfxPos++);
238 gDPSetColorImage(gMainGfxPos++, G_IM_FMT_RGBA, G_IM_SIZ_16b, SCREEN_WIDTH, osVirtualToPhysical(nuGfxCfb_ptr));
239 gSPDisplayList(gMainGfxPos++, &TheaterInitGfx);
240
241 guFrustumF(m, -80.0f, 80.0f, -60.0f, 60.0f, 160.0f, 640.0f, 1.0f);
242 guMtxF2L(m, &D_8009BAA8[0]);
243
244 gSPMatrix(gMainGfxPos++, &D_8009BAA8[0], G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_PROJECTION);
245
246 scale = gCurtainScale - 0.01;
247 if (scale < 1.0f) {
248 scale = 1.0f;
249 }
250
251 guPositionF(m, 0.0f, 0.0f, 0.0f, scale * 0.1, 0.0f, 0.0f, -320.0f);
252
253 guMtxF2L(m, &D_8009BAA8[1]);
254
255 gSPMatrix(gMainGfxPos++, &D_8009BAA8[1], G_MTX_PUSH | G_MTX_LOAD | G_MTX_MODELVIEW);
256 rgb = 255.0f - (gCurtainFade * 255.0f);
257 gDPSetPrimColor(gMainGfxPos++, 0, 0, rgb, rgb, rgb, 255);
258 gSPDisplayList(gMainGfxPos++, &TheaterGfx);
259 gSPPopMatrix(gMainGfxPos++, G_MTX_MODELVIEW);
260 gDPPipeSync(gMainGfxPos++);
261 }
262
263 if (gCurtainDrawCallback != NULL) {
264 gCurtainDrawCallback();
265 }
266
267 if (!(gGameStatusPtr->contBitPattern & 1)) {
271 s32 alpha = ((gGameStatusPtr->frameCounter) % 0x18) << 5;
272
273 if (alpha > 255) {
274 alpha = 255;
275 }
276
277 gSPDisplayList(gMainGfxPos++, &TheaterInitGfx);
278 gSPDisplayList(gMainGfxPos++, &NoControllerSetupTexGfx);
279 gDPSetPrimColor(gMainGfxPos++, 0, 0, 0xFF, 0x20, 0x10, alpha);
280 gSPDisplayList(gMainGfxPos++, &NoControllerGfx);
281 }
282 }
283}
Gfx NoControllerGfx[]
Definition curtains.c:199
Gfx TheaterGfx[]
Definition curtains.c:139
Gfx NoControllerSetupTexGfx[]
Definition curtains.c:178
Gfx TheaterInitGfx[]
Definition curtains.c:156
BSS f32 gCurtainFadeGoal
Definition curtains.c:208
BSS f32 gCurtainScale
Definition curtains.c:205
BSS Mtx D_8009BAA8[2]
Definition curtains.c:210
BSS f32 gCurtainScaleGoal
Definition curtains.c:206
BSS f32 gCurtainFade
Definition curtains.c:207
Color_RGB8 rgb
Definition demo_api.c:16
@ GAME_MODE_TITLE_SCREEN
Definition game_modes.h:9
@ GAME_MODE_INTRO
Definition game_modes.h:21

Referenced by gfx_draw_frame().

◆ fio_init_flash()

void fio_init_flash ( void )

Definition at line 232 of file fio.c.

232 {
233 osFlashInit();
234}

Referenced by load_engine_data().

◆ func_80028838()

void func_80028838 ( void )

Definition at line 23 of file input.c.

23 {
25 D_8009A6A0 = 0;
26 D_8009A6A2 = 0;
27 D_8009A6A4 = 0;
28 D_8009A6A6 = 0;
29}
void func_800287F0(void)
Definition input.c:10

Referenced by load_engine_data().

◆ clear_screen_overlays()

void clear_screen_overlays ( void )

Definition at line 448 of file screen_overlays.c.

448 {
449 ScreenOverlay* it;
450 s32 i;
451
456
457 for (it = &ScreenOverlays[0], i = 0; i < ARRAY_COUNT(ScreenOverlays); i++, it++) {
458 it->color.b = 0;
459 it->color.g = 0;
460 it->color.r = 0;
461 it->screenPos[1][1] = 0;
462 it->screenPos[1][0] = 0;
463 it->screenPos[0][1] = 0;
464 it->screenPos[0][0] = 0;
465 it->alpha = 255.0f;
466 }
467}

Referenced by load_engine_data(), state_step_demo(), state_step_intro(), and state_step_startup().

◆ bgm_reset_sequence_players()

void bgm_reset_sequence_players ( void )

Definition at line 63 of file e0b30_len_b80.c.

63 {
64 s32 i;
65
66 for (i = 0; i < ARRAY_COUNT(gMusicSettings); i++) {
68 }
69
74}
void func_800561A4(s32 arg0)
Definition 30450.c:849
BSS s16 MusicCurrentVolume
MusicSettings BlankMusicSettings

Referenced by load_engine_data().

◆ reset_ambient_sounds()

void reset_ambient_sounds ( void )

Definition at line 28 of file ambience.c.

28 {
30}
AmbientSoundSettings DefaultAmbientSoundData
Definition ambience.c:18

Referenced by load_engine_data().

◆ poll_rumble()

void poll_rumble ( void )

Definition at line 10 of file rumble.c.

10 {
11 nuContRmbCheck(0);
12 nuContRmbModeSet(0, 2);
13}

Referenced by load_engine_data().

◆ bgm_pop_song()

void bgm_pop_song ( void )

Definition at line 375 of file e0b30_len_b80.c.

375 {
376 MusicSettings* musicSetting = gMusicSettings;
377
379 musicSetting->flags |= MUSIC_SETTINGS_FLAG_8;
380 _bgm_set_song(0, musicSetting->savedSongID, musicSetting->savedVariation, 0, 8);
381 }
382}

◆ bgm_push_song()

void bgm_push_song ( s32 songID,
s32 variation )

Definition at line 384 of file e0b30_len_b80.c.

384 {
385 MusicSettings* musicSetting = gMusicSettings;
386
388 musicSetting->savedSongID = musicSetting->songID;
389 musicSetting->savedVariation = musicSetting->variation;
390 musicSetting->savedSongName = musicSetting->songName;
391 musicSetting->flags |= MUSIC_SETTINGS_FLAG_4;
392 bgm_set_song(0, songID, variation, 500, 8);
393 }
394}

◆ bgm_pop_battle_song()

void bgm_pop_battle_song ( void )

Definition at line 396 of file e0b30_len_b80.c.

396 {
397 MusicSettings* musicSetting = gMusicSettings;
398
401 gOverrideFlags &= ~GLOBAL_OVERRIDES_DONT_RESUME_SONG_AFTER_BATTLE;
402 } else {
403 musicSetting->flags |= MUSIC_SETTINGS_FLAG_8;
404 _bgm_set_song(0, musicSetting->savedSongID, musicSetting->savedVariation, 0, 8);
405 snd_ambient_resume(0, 250);
406 }
407 }
408}
AuResult snd_ambient_resume(s32 index, s32 fadeInTime)
Definition 30450.c:315

Referenced by update_encounters_post_battle().

◆ play_ambient_sounds()

s32 play_ambient_sounds ( s32 fadeInTime,
s32 fadeOutTime )

Definition at line 72 of file ambience.c.

72 {
74
77 state->flags &= ~1;
78 return 1;
79 }
80
81 if (state->soundID == soundID) {
82 return 2;
83 }
84
85 state->soundID = soundID;
86 state->fadeTime = fadeTime;
88 return 1;
89}

◆ get_fortress_key_count()

s32 get_fortress_key_count ( void )

◆ subtract_fortress_keys()

s32 subtract_fortress_keys ( s32 amt)

◆ add_star_points()

s32 add_star_points ( s32 amt)

Definition at line 2097 of file inventory.c.

2097 {
2098 PlayerData* playerData = &gPlayerData;
2099 s8 newSP = playerData->starPoints + amt;
2100
2101 // TODO: probably a macro!
2102 playerData->starPoints = newSP;
2103 if (newSP > 100) {
2104 playerData->starPoints = 100;
2105 }
2106
2107 // TODO: probably a macro!
2108 newSP = playerData->starPoints;
2109 if (newSP < 0) {
2110 playerData->starPoints = 0;
2111 }
2112 return gPlayerData.starPoints;
2113}

◆ add_star_pieces()

s32 add_star_pieces ( s32 amt)

Definition at line 2115 of file inventory.c.

2115 {
2116 PlayerData* playerData = &gPlayerData;
2117 s32 newSP = playerData->starPieces;
2118
2119 newSP += amt;
2120 if (newSP > MAX_STAR_PIECES) {
2121 newSP = MAX_STAR_PIECES;
2122 }
2123 if (newSP < 0) {
2124 newSP = 0;
2125 }
2126 playerData->starPieces = newSP;
2127
2128 if (amt > 0) {
2129 playerData->starPiecesCollected += amt;
2130 }
2131
2132 return playerData->starPieces;
2133}
u16 starPiecesCollected
#define MAX_STAR_PIECES
Definition macros.h:100

◆ make_item_entity_at_player()

s32 make_item_entity_at_player ( s32 itemID,
s32 arg1,
s32 pickupMsgFlags )

Definition at line 690 of file item_entity.c.

690 {
691 PlayerStatus* playerStatus = &gPlayerStatus;
692 ItemEntity* item;
693 Shadow* shadow;
694 s32 i;
695 f32 posX;
696 f32 posY;
697 f32 posZ;
698 f32 depth;
699 s32 id;
700
701 for (i = 0; i < MAX_ITEM_ENTITIES; i++) {
702 if (gCurrentItemEntities[i] == NULL) {
703 break;
704 }
705 }
707 id = i;
708
709 gCurrentItemEntities[id] = item = heap_malloc(sizeof(*item));
711 ASSERT(item != NULL);
712
713 itemID &= 0xFFFF;
714 item->renderGroup = -1;
716 item->flags |= ITEM_ENTITY_FLAG_10;
718 if (category != ITEM_TYPE_CONSUMABLE) {
720 }
721 item->pickupMsgFlags = pickupMsgFlags;
724 item->boundVar = 0;
725 item->pos.x = playerStatus->pos.x;
726 item->pos.y = playerStatus->pos.y;
727 item->pos.z = playerStatus->pos.z;
728
729 item->shadowIndex = -1;
730 item->nextUpdate = 1;
731 item->lastPos.x = -9999;
732 item->lastPos.y = -9999;
733 item->lastPos.z = -9999;
734 item->scale = 1.0f;
735 item->itemID = itemID;
736 item->physicsData = NULL;
737 item->pickupDelay = 0;
738 item->spawnAngle = 0;
740
741 if (gItemTable[itemID].typeFlags & ITEM_TYPE_FLAG_ENTITY_FULLSIZE) {
743 }
744
747 }
749
750 item->shadowIndex = create_shadow_type(SHADOW_VARYING_CIRCLE, item->pos.x, item->pos.y, item->pos.z);
751 shadow = get_shadow_by_index(item->shadowIndex);
752 shadow->flags |= ENTITY_FLAG_HIDDEN;
753
754 posX = item->pos.x;
755 posY = item->pos.y + 12.0f;
756 posZ = item->pos.z;
757 depth = 1000.0f;
758 npc_raycast_down_sides(COLLIDER_FLAG_IGNORE_NPC, &posX, &posY, &posZ, &depth);
759 shadow->pos.x = posX;
760 shadow->pos.y = posY;
761 shadow->pos.z = posZ;
762
764 shadow->rot.y = 0.0f;
766 set_standard_shadow_scale(shadow, depth * 0.5f);
767
768 item_entity_load(item);
769 if (item->itemID == ITEM_COIN) {
772 }
773 return id;
774}
@ ITEM_PICKUP_STATE_INIT
Definition enums.h:2741
@ ITEM_ENTITY_FLAG_4000000
Definition enums.h:2720
@ ITEM_ENTITY_FLAG_2000000
Definition enums.h:2719
@ ITEM_SPAWN_AT_PLAYER
Definition enums.h:2319
@ ITEM_TYPE_CONSUMABLE
Definition enums.h:1827

◆ set_action_state()

void set_action_state ( s32 actionState)

Definition at line 209 of file 7E9D0.c.

209 {
210 PlayerStatus* playerStatus = &gPlayerStatus;
211 PlayerData* playerData = &gPlayerData;
212 PlayerSpinState* spinState = &gPlayerSpinState;
213
214 if (playerStatus->flags & PS_FLAG_SPECIAL_JUMP) {
215 playerStatus->flags &= ~PS_FLAG_SPECIAL_JUMP;
217 }
218
219 if (playerStatus->animFlags & PA_FLAG_8BIT_MARIO) {
220 if (actionState >= ACTION_STATE_IDLE && actionState < ACTION_STATE_TALK) {
221 playerStatus->prevActionState = playerStatus->actionState;
222 playerStatus->actionState = actionState;
223 playerStatus->flags |= PS_FLAG_ACTION_STATE_CHANGED;
224 }
225 return;
226 }
227
228 if (actionState == ACTION_STATE_HIT_FIRE || actionState == ACTION_STATE_HIT_LAVA) {
229 s8 partner;
230
231 if (playerStatus->hazardType == HAZARD_TYPE_FIRE_BAR) {
232 actionState = ACTION_STATE_HIT_FIRE;
233 }
234
235 // Whilst Sushie, Lakilester, or Parakarry's ability is active, hazards have no effect.
236 partner = playerData->curPartner;
237
238 if (partner == PARTNER_SUSHIE || partner == PARTNER_LAKILESTER || partner == PARTNER_PARAKARRY) {
241 playerStatus->flags |= PS_FLAG_HIT_FIRE;
242 return;
243 }
244 }
245 }
246
247 if (actionState == ACTION_STATE_SLIDING) {
248 playerStatus->flags |= PS_FLAG_SLIDING;
249 playerStatus->moveFrames = 0;
250 playerStatus->flags &= ~PS_FLAG_CUTSCENE_MOVEMENT;
251 }
252
253 playerStatus->prevActionState = playerStatus->actionState;
254 if (actionState == ACTION_STATE_USE_TWEESTER) {
255 playerStatus->prevActionState = ACTION_STATE_IDLE;
256 }
257
258 if (actionState == ACTION_STATE_ENEMY_FIRST_STRIKE) {
260 }
261 playerStatus->actionState = actionState;
262 playerStatus->flags |= PS_FLAG_ACTION_STATE_CHANGED;
263
264 if (playerStatus->actionState == ACTION_STATE_SPIN) {
265 return;
266 }
267
268 playerStatus->flags &= ~PS_FLAG_SPINNING;
269 playerStatus->animFlags &= ~PA_FLAG_SPINNING;
270
271 if (spinState->spinSoundID != 0) {
272 sfx_stop_sound(spinState->spinSoundID);
273 }
274
275 if (playerStatus->specialDecorationEffect != NULL) {
276 playerStatus->specialDecorationEffect->data.spin->timeLeft = 10;
277 playerStatus->specialDecorationEffect = NULL;
278 }
279}
struct EffectInstance * specialDecorationEffect
struct SpinFXData * spin
Definition effects.h:2534
s32 timeLeft
Definition effects.h:1207
@ PS_FLAG_SPECIAL_JUMP
Definition enums.h:3046
@ PS_FLAG_HIT_FIRE
Definition enums.h:3050
@ HAZARD_TYPE_FIRE_BAR
Definition enums.h:3502
@ PA_FLAG_8BIT_MARIO
Definition enums.h:3105
@ ACTION_STATE_ENEMY_FIRST_STRIKE
Definition enums.h:2455
void sfx_stop_sound(s32 soundID)
Definition sfx.c:507

Referenced by action_hammer_end_swing(), action_update_first_strike(), action_update_hit_fire(), action_update_hit_lava(), action_update_idle(), action_update_idle_peach(), action_update_knockback(), action_update_land(), action_update_launch(), action_update_parasol(), action_update_peach_land(), action_update_peach_step_down_land(), action_update_pushing_block(), action_update_raise_arms(), action_update_run(), action_update_sliding(), action_update_spin(), action_update_spin_jump(), action_update_state_23(), action_update_step_down(), action_update_step_up(), action_update_step_up_peach(), action_update_tornado_jump(), action_update_use_munchlesia(), action_update_use_spinning_flower(), action_update_use_tweester(), action_update_walk(), check_input_hammer(), check_input_jump(), check_input_midair_jump(), check_input_open_menus(), check_input_spin(), check_player_action_debug(), collision_lateral_peach(), end_outta_sight_cleanup(), entity_CymbalPlant_idle(), entity_ScriptSpring_idle(), entity_SimpleSpring_set_jump_params(), entity_TriggerBlock_disable_player_input(), entity_Tweester_idle(), entity_WoodenCrate_idle(), func_802BB000_E2D930(), func_802BC274_E2EBA4(), func_802BC3A0_E2ECD0(), handle_jumping_launch(), move_player(), peach_check_for_parasol_input(), peach_force_disguise_action(), phys_main_collision_below(), phys_peach_update(), phys_player_land(), phys_update_action_state(), phys_update_jump(), player_handle_floor_collider_type(), post_battle(), post_battle(), pre_battle(), pre_battle(), pre_battle(), pre_battle(), pre_battle(), pre_battle(), reset_player_status(), start_bounce_a(), start_bounce_b(), start_falling(), update_encounters_conversation(), update_encounters_neutral(), update_encounters_post_battle(), update_item_entity_pickup(), and update_locomotion_state().

◆ get_collider_flags()

◆ suggest_player_anim_always_forward()

◆ suggest_player_anim_allow_backward()

◆ subtract_hp()

void subtract_hp ( s32 amt)

Definition at line 2204 of file inventory.c.

2204 {
2205 PlayerData* playerData = &gPlayerData;
2206 s32 newHP = playerData->curHP;
2207
2208 if (amt > 0) {
2209 newHP -= amt;
2210 }
2211 if (amt < 0 || newHP < 1) {
2212 newHP = 1;
2213 }
2214 playerData->curHP = newHP;
2215}

Referenced by action_update_hit_fire(), action_update_hit_lava(), and func_802BC274_E2EBA4().

◆ draw_status_ui()

void draw_status_ui ( void )

Definition at line 1422 of file inventory.c.

1422 {
1425
1426 #if DX_DEBUG_MENU
1427 dx_debug_menu_main();
1428 #endif
1429}
void update_coin_counter(void)
Definition inventory.c:1317
void update_status_bar(void)
Definition inventory.c:718

Referenced by btl_draw_ui(), state_drawUI_change_map(), state_drawUI_enter_world(), and state_drawUI_world().

◆ open_status_bar_slowly()

void open_status_bar_slowly ( void )

Definition at line 1431 of file inventory.c.

1431 {
1432 StatusBar* statusBar = &gStatusBar;
1433
1434 if (statusBar->hidden) {
1435 statusBar->showTimer = 210;
1436 statusBar->hidden = FALSE;
1437 statusBar->unk_3B = TRUE;
1438 }
1439}

Referenced by action_update_hit_fire(), action_update_hit_lava(), and check_input_status_bar().

◆ suspend_all_group()

void suspend_all_group ( s32 groupFlags)

Definition at line 846 of file script_list.c.

846 {
847 s32 i;
848 Evt* scriptContextPtr;
849
850 for (i = 0; i < MAX_SCRIPTS; i++) {
851 scriptContextPtr = (*gCurrentScriptListPtr)[i];
852 if (scriptContextPtr != NULL) {
853 suspend_group_script(scriptContextPtr, groupFlags);
854 }
855 }
856}

Referenced by evt_handle_suspend_all(), set_time_freeze_mode(), suspend_frozen_scripts(), update_encounters_neutral(), and update_encounters_pre_battle().

◆ kill_script()

void kill_script ( Evt * instanceToKill)

Definition at line 609 of file script_list.c.

609 {
610 Evt* childScript;
611 Evt* blockingParent;
612 s32 j;
613 s32 i;
614
615 for (i = 0; i < MAX_SCRIPTS; i++) {
616 if ((*gCurrentScriptListPtr)[i] == instanceToKill) {
617 break;
618 }
619 }
620
621 if (i >= MAX_SCRIPTS) {
622 return;
623 }
624
625 childScript = instanceToKill->childScript;
626 if (childScript != NULL) {
627 kill_script(childScript);
628 }
629
630 for (j = 0; j < MAX_SCRIPTS; j++) {
631 Evt* tempScriptInstance = (*gCurrentScriptListPtr)[j];
632 if (tempScriptInstance != NULL) {
633 if (tempScriptInstance->parentScript == instanceToKill) {
634 kill_script(tempScriptInstance);
635 }
636 }
637 }
638
639 blockingParent = instanceToKill->blockingParent;
640 if (blockingParent != NULL) {
641 blockingParent->childScript = NULL;
642 blockingParent->stateFlags &= ~EVT_FLAG_BLOCKED_BY_CHILD;
643
644 for (j = 0; j < ARRAY_COUNT(blockingParent->varTable); j++) {
645 blockingParent->varTable[j] = instanceToKill->varTable[j];
646 }
647
648 for (j = 0; j < ARRAY_COUNT(blockingParent->varFlags); j++) {
649 blockingParent->varFlags[j] = instanceToKill->varFlags[j];
650 }
651 }
652
653 if (instanceToKill->userData != NULL) {
654 heap_free(instanceToKill->userData);
655 instanceToKill->userData = NULL;
656 }
657
659 (*gCurrentScriptListPtr)[i] = NULL;
660 gNumScripts--;
661}

Referenced by evt_handle_end_child_thread(), evt_handle_end_thread(), evt_handle_return(), func_802C3C10(), kill_all_scripts(), kill_script(), and kill_script_by_ID().

◆ exec_entity_commandlist()

void exec_entity_commandlist ( Entity * entity)

Definition at line 313 of file entity.c.

313 {
314 while (step_entity_commandlist(entity));
315}

Referenced by action_update_use_spinning_flower(), entity_base_switch_animate_scale(), entity_BellbellPlant_idle(), entity_block_handle_collision(), entity_BlueWarpPipe_check_if_active(), entity_BlueWarpPipe_enter_pipe_update(), entity_BlueWarpPipe_idle(), entity_BlueWarpPipe_rise_up(), entity_BlueWarpPipe_wait_for_player_to_get_off(), entity_BlueWarpPipe_wait_player_move_to_center(), Entity_BoardedFloor_idle(), Entity_BoardedFloor_update_fragments(), entity_BombableRock_idle(), entity_BombableRock_update_fragments(), entity_Chest_idle(), entity_Chest_open(), entity_GiantChest_await_got_item(), entity_GiantChest_open(), entity_GreenStompSwitch_extend(), entity_GreenStompSwitch_idle(), entity_GreenStompSwitch_retract(), entity_HeartBlock_show_tutorial_message(), entity_HeartBlock_wait_for_close_tutorial(), entity_HeartBlockContent__anim_heal(), entity_HeartBlockContent_anim_idle(), entity_HiddenPanel_flip_over(), entity_HiddenPanel_idle(), entity_HugeBlueSwitch_idle(), entity_inactive_block_hit_anim(), entity_inactive_block_recoil_anim(), entity_ItemBlock_check_if_inactive(), entity_MulticoinBlock_idle(), entity_Padlock_idle(), entity_PinkFlower_idle(), entity_RedSwitch_animate_scale(), entity_RedSwitch_wait_and_reset(), entity_SaveBlock_show_tutorial_message(), entity_SaveBlock_wait_for_close_choice(), entity_SaveBlock_wait_for_close_result(), entity_SaveBlock_wait_for_close_tutorial(), entity_ScriptSpring_idle(), entity_shattering_idle(), entity_SimpleSpring_idle(), entity_small_switch_idle(), entity_StarBoxLauncher_check_launch(), entity_StarBoxLauncher_launch(), entity_TrumpetPlant_idle(), entity_WoodenCrate_idle(), entity_WoodenCrate_update_fragments(), func_802BB0A0_E2D9D0(), func_802BC050_E2E980(), and func_802BC99C_E312EC().

◆ show_start_recovery_shimmer()

void show_start_recovery_shimmer ( f32 x,
f32 y,
f32 z,
s32 arg3 )

Definition at line 4 of file fx_api.c.

4 {
5 fx_stars_shimmer(1, x, y, z, amt + 30, amt + 30, (amt / 2) + 10, 30);
6}

◆ show_recovery_shimmer()

void show_recovery_shimmer ( f32 x,
f32 y,
f32 z,
s32 arg3 )

Definition at line 8 of file fx_api.c.

8 {
9 fx_stars_shimmer(2, x, y, z, amt + 30, amt + 30, (amt / 2) + 10, 30);
10}

◆ show_next_damage_popup()

void show_next_damage_popup ( f32 x,
f32 y,
f32 z,
s32 damageAmount,
s32 angle )

Definition at line 2295 of file 190B20.c.

2295 {
2296 s32 i;
2297
2298 for (i = 0; i < ARRAY_COUNT(gDamageCountEffects); i++) {
2299 if (gDamageCountEffects[i] == NULL) {
2300 break;
2301 }
2302 }
2303
2304 if (i > ARRAY_COUNT(gDamageCountEffects) - 1) {
2305 i = 0;
2307 gDamageCountEffects[i] = NULL;
2308 }
2309
2310 if (angle == 0) {
2311 angle = -55;
2312 } else {
2313 angle = 55;
2314 }
2315
2316 fx_damage_indicator(0, posX, posY, posZ, 10.0f, angle, damageAmt, &gDamageCountEffects[i]);
2317 gDamageCountTimers[i] = 40;
2318}

Referenced by calc_enemy_damage_target(), calc_item_damage_enemy(), calc_partner_damage_enemy(), calc_player_damage_enemy(), dispatch_damage_event_actor(), dispatch_damage_event_partner(), and dispatch_damage_event_player().

◆ add_xz_vec3f()

void add_xz_vec3f ( Vec3f * vector,
f32 speed,
f32 angleDeg )

Definition at line 1139 of file 190B20.c.

1139 {
1140 f32 angleRad = DEG_TO_RAD(angleDeg);
1141 f32 sinAngleRad = sin_rad(angleRad);
1142 f32 cosAngleRad = cos_rad(angleRad);
1143
1144 vector->x += speed * sinAngleRad;
1145 vector->z += -speed * cosAngleRad;
1146}

◆ add_xz_vec3f_copy1()

void add_xz_vec3f_copy1 ( Vec3f * vector,
f32 speed,
f32 angleDeg )

Definition at line 1148 of file 190B20.c.

1148 {
1149 f32 angleRad = DEG_TO_RAD(angleDeg);
1150 f32 sinAngleRad = sin_rad(angleRad);
1151 f32 cosAngleRad = cos_rad(angleRad);
1152
1153 vector->x += speed * sinAngleRad;
1154 vector->z += -speed * cosAngleRad;
1155}

◆ add_xz_vec3f_copy2()

void add_xz_vec3f_copy2 ( Vec3f * vector,
f32 speed,
f32 angleDeg )

Definition at line 1157 of file 190B20.c.

1157 {
1158 f32 angleRad = DEG_TO_RAD(angleDeg);
1159 f32 sinAngleRad = sin_rad(angleRad);
1160 f32 cosAngleRad = cos_rad(angleRad);
1161
1162 vector->x += speed * sinAngleRad;
1163 vector->z += -speed * cosAngleRad;
1164}

◆ play_movement_dust_effects()

void play_movement_dust_effects ( s32 var0,
f32 xPos,
f32 yPos,
f32 zPos,
f32 angleDeg )

Definition at line 1166 of file 190B20.c.

1166 {
1167 f32 theta;
1168 f32 sinTheta;
1169 f32 cosTheta;
1170
1171 if (var0 == 2) {
1172 fx_landing_dust(0, xPos, yPos + 0.0f, zPos, D_802938A4);
1173 } else if (var0 == 1) {
1174 D_802938A8 = 4;
1175 } else if (D_802938A8++ >= 4) {
1176 D_802938A8 = 0;
1177 theta = DEG_TO_RAD(clamp_angle(-angleDeg));
1178 sinTheta = sin_rad(theta);
1179 cosTheta = cos_rad(theta);
1180 fx_walking_dust(
1181 0,
1182 xPos + (sinTheta * 24.0f * 0.2f),
1183 yPos + 1.5f,
1184 zPos + (cosTheta * 24.0f * 0.2f),
1185 sinTheta,
1186 cosTheta
1187 );
1188 }
1189}
f32 D_802938A4
Definition 190B20.c:9
s16 D_802938A8
Definition 190B20.c:11

◆ draw_prev_frame_buffer_at_screen_pos()

void draw_prev_frame_buffer_at_screen_pos ( s32 x1,
s32 y1,
s32 x2,
s32 y2,
f32 alpha )

Definition at line 78 of file screen_render_util.c.

78 {
79 s32 minX;
80 s32 minY;
81 s32 maxX;
82 s32 maxY;
83
84 maxX = x2;
85 maxY = y2;
86 if (maxX < x1) {
87 minX = maxX;
88 maxX = x1;
89 } else {
90 minX = x1;
91 }
92 if (maxY < y1) {
93 minY = maxY;
94 maxY = y1;
95 } else {
96 minY = y1;
97 }
98 if (minX < maxX && minY < maxY) {
99 if (minX < 0) {
100 minX = 0;
101 }
102 if (minY < 0) {
103 minY = 0;
104 }
105 if (maxX < 0) {
106 maxX = 0;
107 }
108 if (maxY < 0) {
109 maxY = 0;
110 }
111 if (minX >= SCREEN_WIDTH) {
112 minX = SCREEN_WIDTH - 1;
113 }
114 if (minY >= SCREEN_HEIGHT) {
115 minY = SCREEN_HEIGHT - 1;
116 }
117 if (maxX >= SCREEN_WIDTH) {
118 maxX = SCREEN_WIDTH - 1;
119 }
120 if (maxY >= SCREEN_HEIGHT) {
121 maxY = SCREEN_HEIGHT - 1;
122 }
123 if (minX != maxX && minY != maxY) {
124 appendGfx_draw_prev_frame_buffer(minX, minY, maxX, maxY, alpha);
125 }
126 }
127}
void appendGfx_draw_prev_frame_buffer(s32 x1, s32 y1, s32 x2, s32 y2, f32 alpha)

◆ func_8013A4D0()

void func_8013A4D0 ( void )

Definition at line 266 of file imgfx.c.

266 {
267 s32 i;
268
270 imgfx_vtxCount = 0;
272
273 (*ImgFXInstances)[0].flags |= IMGFX_FLAG_VALID;
274
275 for (i = 1; i < ARRAY_COUNT(*ImgFXInstances); i++) {
276 if (((*ImgFXInstances)[i].flags & IMGFX_FLAG_VALID) && (*ImgFXInstances)[i].lastAnimCmd != IMGFX_SET_ANIM) {
278 }
279 }
280
281 for (i = 1; i < ARRAY_COUNT(*ImgFXInstances); i++) {
282 if ((*ImgFXInstances)[i].flags & IMGFX_FLAG_VALID && (*ImgFXInstances)[i].colorBuf != NULL) {
283 if ((*ImgFXInstances)[i].lastColorCmd == IMGFX_COLOR_BUF_SET_MULTIPLY) {
284 continue;
285 }
286 if ((*ImgFXInstances)[i].lastColorCmd == IMGFX_COLOR_BUF_SET_MODULATE) {
287 continue;
288 }
289 general_heap_free((*ImgFXInstances)[i].colorBuf);
290 (*ImgFXInstances)[i].colorBuf = NULL;
291 (*ImgFXInstances)[i].colorBufCount = 0;
292 }
293 }
294}
@ IMGFX_COLOR_BUF_SET_MULTIPLY
Definition enums.h:5127
@ IMGFX_COLOR_BUF_SET_MODULATE
Definition enums.h:5128
@ IMGFX_SET_ANIM
Definition enums.h:5121
@ IMGFX_FLAG_VALID
Definition enums.h:5092
u16 imgfx_vtxCount
Definition imgfx.c:125
BSS Vtx * ImgFXVtxBuffers[2]
Definition imgfx.c:116
BSS ImgFXInstanceList * ImgFXInstances
Definition imgfx.c:118
BSS Vtx * imgfx_vtxBuf
Definition imgfx.c:117
void imgfx_init_instance(ImgFXState *state)
Definition imgfx.c:452
void imgfx_cache_instance_data(ImgFXState *state)
Definition imgfx.c:420

Referenced by spr_update_player_raster_cache().

◆ btl_draw_ui()

void btl_draw_ui ( void )

Definition at line 486 of file 16C8E0.c.

486 {
487 s32 changed = FALSE;
488 s32 state;
489
490 state = gBattleState;
492 state = gLastDrawBattleState;
494 changed = TRUE;
495 } else {
496 switch (state) {
501 return;
502 case BATTLE_STATE_0:
503 return;
504 }
505 }
506
509
510 if (!changed) {
511 switch (state) {
514 break;
517 break;
520 break;
521 case BATTLE_STATE_9:
523 break;
526 break;
529 break;
532 break;
535 break;
538 break;
541 break;
544 break;
547 break;
550 break;
553 break;
556 break;
559 break;
562 break;
565 break;
568 break;
571 break;
574 break;
577 break;
580 break;
583 break;
586 break;
589 break;
592 break;
595 break;
596 case BATTLE_STATE_28:
598 break;
601 break;
604 break;
605 case BATTLE_STATE_34:
607 break;
610 break;
613 break;
614 }
615 }
618}
void btl_update_starpoints_display(void)
Definition 16C8E0.c:948
void btl_draw_enemy_health_bars(void)
Definition 16C8E0.c:859
@ BATTLE_STATE_END_TRAINING_BATTLE
Definition enums.h:3660
@ BATTLE_STATE_28
Definition enums.h:3658
@ BATTLE_STATE_DEFEAT
Definition enums.h:3657
@ BATTLE_STATE_PEACH_MENU
Definition enums.h:3645
@ BATTLE_STATE_34
Definition enums.h:3664
@ BATTLE_STATE_NORMAL_START
Definition enums.h:3631
@ BATTLE_STATE_NEGATIVE_1
Definition enums.h:3629
@ BATTLE_STATE_TWINK_MENU
Definition enums.h:3646
@ BATTLE_STATE_VICTORY
Definition enums.h:3656
void btl_state_draw_switch_to_partner(void)
void btl_state_draw_twink_menu(void)
void btl_state_draw_9(void)
void btl_popup_messages_draw_ui(void)
void btl_state_draw_partner_striking_first(void)
void btl_state_draw_prepare_menu(void)
void btl_state_draw_select_target(void)
void btl_state_draw_1C(void)
void btl_state_draw_begin_player_turn(void)
void btl_state_draw_defend(void)
void btl_state_draw_end_player_turn(void)
void btl_state_draw_celebration(void)
Definition level_up.c:1274
void btl_state_draw_victory(void)
void btl_state_draw_end_demo_battle(void)
void btl_state_draw_end_turn(void)
void btl_state_draw_partner_move(void)
void btl_state_draw_22(void)
void btl_state_draw_peach_menu(void)
void btl_state_draw_begin_partner_turn(void)
void btl_state_draw_player_move(void)
void btl_state_draw_end_partner_turn(void)
void btl_state_draw_begin_turn(void)
void btl_state_draw_enemy_move(void)
void btl_state_draw_player_menu(void)
void btl_state_draw_switch_to_player(void)
void btl_state_draw_next_enemy(void)
void btl_state_draw_normal_start(void)
void btl_state_draw_run_away(void)
void btl_state_draw_partner_menu(void)
void btl_state_draw_end_training_battle(void)
void btl_state_draw_defeat(void)
void btl_state_draw_end_battle(void)
void btl_state_draw_change_partner(void)
void btl_state_draw_enemy_striking_first(void)
void btl_state_draw_first_stike(void)
void draw_status_ui(void)
Definition inventory.c:1422

Referenced by state_drawUI_battle().

◆ btl_restore_world_cameras()

void btl_restore_world_cameras ( void )

Definition at line 1085 of file 16C8E0.c.

1085 {
1086 PlayerStatus* playerStatus = &gPlayerStatus;
1087 PlayerData* playerData = &gPlayerData;
1088 s32 i;
1089
1090 for (i = 0; i < ARRAY_COUNT(gCameras); i++) {
1092 }
1093
1095 playerStatus->pos.x = SavedWorldPlayerPosX;
1096 playerStatus->pos.y = SavedWorldPlayerPosY;
1097 playerStatus->pos.z = SavedWorldPlayerPosZ;
1098
1101 } else {
1102 gOverrideFlags &= ~GLOBAL_OVERRIDES_ENABLE_FLOOR_REFLECTION;
1103 }
1104
1106 playerData->curPartner = bSavedPartner;
1107 }
1108}
BSS f32 SavedWorldPlayerPosX
Definition 16C8E0.c:23
BSS f32 SavedWorldPlayerPosY
Definition 16C8E0.c:24
BSS s32 bSavedOverrideFlags
Definition 16C8E0.c:17
BSS s32 bSavedPartner
Definition 16C8E0.c:16
BSS f32 SavedWorldPlayerPosZ
Definition 16C8E0.c:25
BSS Camera SavedWorldCameras[ARRAY_COUNT(gCameras)]
Definition 16C8E0.c:22
@ GLOBAL_OVERRIDES_ENABLE_FLOOR_REFLECTION
Definition enums.h:4325

Referenced by state_step_end_battle().

◆ btl_popup_messages_draw_ui()

void btl_popup_messages_draw_ui ( void )

Definition at line 316 of file popup_messages.c.

316 {
317 s32 i;
318
319 for (i = 0; i < ARRAY_COUNT(popupMessages); i++) {
320 PopupMessage* popup = &popupMessages[i];
321 if (popup->active && popup->renderUIFunc != NULL) {
322 popup->renderUIFunc(popup);
323 }
324 }
325}
PopupMessageCallback renderUIFunc

Referenced by btl_draw_ui().

◆ btl_cam_set_target_pos()

void btl_cam_set_target_pos ( f32 x,
f32 y,
f32 z )

Definition at line 1962 of file camera.c.

1962 {
1963 if (!BattleCam_IsFrozen) {
1964 BattleCam_PosX = x;
1965 BattleCam_PosY = y;
1966 BattleCam_PosZ = z;
1967 }
1968}
s8 BattleCam_IsFrozen
Definition camera.c:37

Referenced by btl_cam_use_preset_impl(), and btl_state_update_change_partner().

◆ btl_cam_unfreeze()

void btl_cam_unfreeze ( void )

Definition at line 2002 of file camera.c.

2002 {
2003 BattleCam_IsFrozen = FALSE;
2004}

Referenced by btl_state_update_end_battle().

◆ deduct_current_move_fp()

void deduct_current_move_fp ( void )

Definition at line 961 of file 190B20.c.

961 {
962 BattleStatus* battleStatus = &gBattleStatus;
963 PlayerData* playerData = &gPlayerData;
964 Actor* actor = battleStatus->playerActor;
965 s32 fpCost = gMoveTable[battleStatus->selectedMoveID].costFP;
966
967 if (fpCost != 0) {
970 if (fpCost < 1) {
971 fpCost = 1;
972 }
973 }
974
975 playerData->curFP -= fpCost;
976}
s32 player_team_is_ability_active(Actor *actor, s32 ability)
Definition 190B20.c:2765

Referenced by btl_state_update_change_partner(), and btl_state_update_partner_move().

◆ load_partner_actor()

void load_partner_actor ( void )

Definition at line 1422 of file 190B20.c.

1422 {
1423 PlayerData* playerData = &gPlayerData;
1424 BattleStatus* battleStatus = &gBattleStatus;
1425 Actor* partnerActor;
1426 ActorBlueprint* actorBP;
1427 Evt* takeTurnScript;
1428 s32 partCount;
1429 s32 currentPartner;
1430 PartnerDMAData* partnerData;
1431 f32 x;
1432 f32 y;
1433 f32 z;
1434 ActorPart* part;
1435 s32 i;
1436 s32 i2;
1437
1438 currentPartner = playerData->curPartner;
1439 battleStatus->partnerActor = NULL;
1440
1441 if (currentPartner != PARTNER_NONE) {
1442 partnerData = &bPartnerDmaTable[currentPartner];
1443 actorBP = partnerData->ActorBlueprint;
1444
1445 ASSERT(actorBP != NULL);
1446
1447 nuPiReadRom(partnerData->dmaStart, partnerData->dmaDest, partnerData->dmaEnd - partnerData->dmaStart);
1449 x = -95.0f;
1450 y = partnerData->y;
1451 z = 0.0f;
1453 } else {
1454 x = -130.0f;
1455 y = partnerData->y;
1456 z = -10.0f;
1457 }
1458 partCount = actorBP->partCount;
1459 battleStatus->partnerActor = heap_malloc(sizeof(*partnerActor));
1460 partnerActor = battleStatus->partnerActor;
1461
1462 ASSERT(partnerActor != NULL);
1463
1464 actorBP->level = playerData->partners[playerData->curPartner].level;
1465 partnerActor->unk_134 = battleStatus->unk_93++;
1466 partnerActor->footStepCounter = 0;
1467 partnerActor->actorBlueprint = actorBP;
1468 partnerActor->actorType = actorBP->type;
1469 partnerActor->flags = actorBP->flags;
1470 partnerActor->homePos.x = partnerActor->curPos.x = x;
1471 partnerActor->homePos.y = partnerActor->curPos.y = y;
1472 partnerActor->homePos.z = partnerActor->curPos.z = z;
1473 partnerActor->headOffset.x = 0;
1474 partnerActor->headOffset.y = 0;
1475 partnerActor->headOffset.z = 0;
1476 partnerActor->curHP = actorBP->maxHP;
1477 partnerActor->numParts = partCount;
1478 partnerActor->idleSource = NULL;
1479 partnerActor->takeTurnSource = actorBP->initScript;
1480 partnerActor->handleEventSource = NULL;
1481 partnerActor->handlePhaseSource = NULL;
1482 partnerActor->idleScript = NULL;
1483 partnerActor->takeTurnScript = NULL;
1484 partnerActor->handleEventScript = NULL;
1485 partnerActor->handlePhaseScript = NULL;
1486 partnerActor->turnPriority = 0;
1487 partnerActor->enemyIndex = 0;
1488 partnerActor->yaw = 0.0f;
1489 partnerActor->rot.x = 0.0f;
1490 partnerActor->rot.y = 0.0f;
1491 partnerActor->rot.z = 0.0f;
1492 partnerActor->rotPivotOffset.x = 0;
1493 partnerActor->rotPivotOffset.y = 0;
1494 partnerActor->rotPivotOffset.z = 0;
1495 partnerActor->scale.x = 1.0f;
1496 partnerActor->scale.y = 1.0f;
1497 partnerActor->scale.z = 1.0f;
1498 partnerActor->scaleModifier.x = 1.0f;
1499 partnerActor->scaleModifier.y = 1.0f;
1500 partnerActor->scaleModifier.z = 1.0f;
1501 partnerActor->verticalRenderOffset = 0;
1502 partnerActor->size.x = actorBP->size.x;
1503 partnerActor->size.y = actorBP->size.y;
1504 partnerActor->healthBarPos.x = partnerActor->homePos.x;
1505 partnerActor->healthBarPos.y = partnerActor->homePos.y;
1506 partnerActor->healthBarPos.z = partnerActor->homePos.z;
1507 partnerActor->scalingFactor = 1.0f;
1508 partnerActor->attackResultEffect = NULL;
1509 partnerActor->actionRatingCombo = 0;
1510 partnerActor->actionRatingTime = 0;
1511 partnerActor->statusIconOffset.x = 0;
1512 partnerActor->statusIconOffset.y = 0;
1513 partnerActor->statusTextOffset.x = 0;
1514 partnerActor->statusTextOffset.y = 0;
1515 partnerActor->renderMode = RENDER_MODE_ALPHATEST;
1516 partnerActor->actorID = ACTOR_PARTNER;
1517 partnerActor->statusTable = actorBP->statusTable;
1518 partnerActor->debuff = 0;
1519 partnerActor->debuffDuration = 0;
1520 partnerActor->staticStatus = 0;
1521 partnerActor->staticDuration = 0;
1522 partnerActor->stoneStatus = 0;
1523 partnerActor->stoneDuration = 0;
1524 partnerActor->koStatus = 0;
1525 partnerActor->koDuration = 0;
1526 partnerActor->transparentStatus = 0;
1527 partnerActor->transparentDuration = 0;
1528 partnerActor->isGlowing = FALSE;
1529 partnerActor->unk_21E = 0;
1530 partnerActor->disableDismissTimer = 0;
1531 partnerActor->attackBoost = 0;
1532 partnerActor->defenseBoost = 0;
1533 partnerActor->chillOutAmount = 0;
1534 partnerActor->chillOutTurns = 0;
1535 partnerActor->statusAfflicted = 0;
1536 partnerActor->actorTypeData1[0] = bActorSoundTable[partnerActor->actorType].walk[0];
1537 partnerActor->actorTypeData1[1] = bActorSoundTable[partnerActor->actorType].walk[1];
1538 partnerActor->actorTypeData1[2] = bActorSoundTable[partnerActor->actorType].fly[0];
1539 partnerActor->actorTypeData1[3] = bActorSoundTable[partnerActor->actorType].fly[1];
1540 partnerActor->actorTypeData1[4] = bActorSoundTable[partnerActor->actorType].jump;
1541 partnerActor->actorTypeData1[5] = bActorSoundTable[partnerActor->actorType].hurt;
1542 partnerActor->actorTypeData1b[0] = bActorSoundTable[partnerActor->actorType].delay[0];
1543 partnerActor->actorTypeData1b[1] = bActorSoundTable[partnerActor->actorType].delay[1];
1544
1545 for (i2 = 0; i2 < ARRAY_COUNT(partnerActor->loopingSoundID); i2++) {
1546 partnerActor->loopingSoundID[i2] = 0;
1547 }
1548
1549 part = heap_malloc(sizeof(*part));
1550 partnerActor->partsTable = part;
1551
1552 ASSERT(part != NULL);
1553
1554 for (i = 0; i < partCount; i++) {
1556 part->decorationTable = NULL;
1558
1560 part->targetFlags = 0;
1561
1565
1566 part->visualOffset.x = 0;
1567 part->visualOffset.y = 0;
1568 part->visualOffset.z = 0;
1569 part->absolutePos.x = 0.0f;
1570 part->absolutePos.y = 0.0f;
1571 part->absolutePos.z = 0.0f;
1577 part->size.y = partnerActor->size.y;
1578 part->size.x = partnerActor->size.x;
1579 part->yaw = 0.0f;
1582 part->targetPriorityOffset = 0;
1583 part->rotPivotOffset.x = 0;
1584 part->rotPivotOffset.y = 0;
1585 part->rotPivotOffset.z = 0;
1586 part->rot.x = 0.0f;
1587 part->rot.y = 0.0f;
1588 part->rot.z = 0.0f;
1589 part->scale.x = 1.0f;
1590 part->scale.y = 1.0f;
1591 part->scale.z = 1.0f;
1592 part->verticalStretch = 1;
1593 part->palAnimPosOffset[0] = 0;
1594 part->palAnimPosOffset[1] = 0;
1595 part->partTypeData[0] = bActorSoundTable[partnerActor->actorType].walk[0];
1596 part->partTypeData[1] = bActorSoundTable[partnerActor->actorType].walk[1];
1597 part->partTypeData[2] = bActorSoundTable[partnerActor->actorType].fly[0];
1598 part->partTypeData[3] = bActorSoundTable[partnerActor->actorType].fly[1];
1599 part->partTypeData[4] = bActorSoundTable[partnerActor->actorType].jump;
1600 part->partTypeData[5] = bActorSoundTable[partnerActor->actorType].hurt;
1601 part->actorTypeData2b[0] = bActorSoundTable[partnerActor->actorType].delay[0];
1602 part->actorTypeData2b[1] = bActorSoundTable[partnerActor->actorType].delay[1];
1603
1604 if (part->idleAnimations != NULL) {
1605 DecorationTable* decorations;
1606 s32 j;
1607
1608 part->decorationTable = heap_malloc(sizeof(*decorations));
1609 decorations = part->decorationTable;
1610
1611 ASSERT(decorations != NULL);
1612
1614 decorations->glowState = GLOW_PAL_OFF;
1615 decorations->flashState = 0;
1616 decorations->flashEnabled = FLASH_PAL_OFF;
1617 decorations->blurUnused = 0;
1618 decorations->blurBufferPos = 0;
1619
1620 for (j = 0; j < ARRAY_COUNT(decorations->posX); j++) {
1621 decorations->posX[j] = partnerActor->curPos.x;
1622 decorations->posY[j] = partnerActor->curPos.y;
1623 decorations->posZ[j] = partnerActor->curPos.z;
1624 }
1625
1626 decorations->blurDrawCount = 3;
1627 decorations->blurEnableCount = 0;
1628 decorations->blurDisableDelay = 0;
1629
1630 for (j = 0; j < ARRAY_COUNT(decorations->effect); j++) {
1631 decorations->effect[j] = NULL;
1632 decorations->type[j] = 0;
1633 }
1634 }
1635
1637 part->movement = heap_malloc(sizeof(*part->movement));
1638 ASSERT(part->movement != NULL);
1639 }
1640
1641 part->animationRate = 1.0f;
1642 part->curAnimation = 0;
1643 part->spriteInstanceID = -1;
1644
1645 if (part->idleAnimations != NULL) {
1648 }
1649
1650 if (i + 1 >= partCount) {
1651 part->nextPart = NULL;
1652 continue;
1653 }
1654
1655 part->nextPart = heap_malloc(sizeof(*part->nextPart));
1656 part = part->nextPart;
1657 if (part == NULL) {
1658 PANIC();
1659 }
1660
1661 part->nextPart = NULL;
1662 }
1663
1664 partnerActor->shadow.id = create_shadow_type(SHADOW_VARYING_CIRCLE, partnerActor->curPos.x, partnerActor->curPos.y, partnerActor->curPos.z);
1665 partnerActor->shadowScale = partnerActor->size.x / 24.0;
1667 partnerActor->disableEffect = fx_disable_x(0, -142.0f, 34.0f, 1.0f, 0);
1668 partnerActor->icePillarEffect = NULL;
1669
1670 takeTurnScript = start_script(partnerActor->takeTurnSource, EVT_PRIORITY_A, 0);
1671 partnerActor->takeTurnScriptID = takeTurnScript->id;
1672 takeTurnScript->owner1.actorID = ACTOR_PARTNER;
1673 }
1674}
PartnerDMAData bPartnerDmaTable[]
Definition partner_dma.c:26
struct ActorBlueprint * ActorBlueprint
@ ACTOR_PART_FLAG_SKIP_MOVEMENT_ALLOC
Definition enums.h:3366
@ SPRITE_ID_TAIL_ALLOCATE
Definition sprite.h:14
struct ActorPartBlueprint * partsData
Definition battle.h:137
EvtScript * initScript
Definition battle.h:138
s32 * statusTable
Definition battle.h:139

Referenced by btl_state_update_change_partner(), and btl_state_update_normal_start().

◆ dispatch_event_partner()

void dispatch_event_partner ( s32 lastEventType)

Definition at line 7 of file dmg_partner.c.

7 {
8 BattleStatus* battleStatus = &gBattleStatus;
9 Actor* partnerActor = battleStatus->partnerActor;
10 Evt* handleEventScript = partnerActor->handleEventScript;
11 s32 onHitID = partnerActor->handleEventScriptID;
12 Evt* script;
13
14 partnerActor->lastEventType = lastEventType;
16 partnerActor->handleEventScript = script;
17 partnerActor->handleEventScriptID = script->id;
18 script->owner1.actorID = ACTOR_PARTNER;
19
20 if (partnerActor->takeTurnScript != NULL) {
22 partnerActor->takeTurnScript = NULL;
23 }
24
25 if (handleEventScript != NULL) {
26 kill_script_by_ID(onHitID);
27 }
28}

Referenced by btl_state_update_begin_partner_turn(), btl_state_update_end_training_battle(), btl_state_update_victory(), calc_enemy_damage_target(), dispatch_damage_event_partner(), and dispatch_event_general().

◆ dispatch_event_player()

void dispatch_event_player ( s32 eventType)

Definition at line 131 of file dmg_player.c.

131 {
133 Evt* oldOnHitScript;
134 s32 oldOnHitID;
135 Evt* eventScript;
136
137 player->lastEventType = eventType;
138
139 oldOnHitScript = player->handleEventScript;
140 oldOnHitID = player->handleEventScriptID;
141
143 player->handleEventScript = eventScript;
144 player->handleEventScriptID = eventScript->id;
145 eventScript->owner1.actor = NULL;
146
147 if (player->takeTurnScript != NULL) {
149 player->takeTurnScript = NULL;
150 }
151
152 if (oldOnHitScript != NULL) {
153 kill_script_by_ID(oldOnHitID);
154 }
155}
EvtScript EVS_Player_HandleEvent

Referenced by btl_state_update_begin_player_turn(), btl_state_update_end_training_battle(), btl_state_update_victory(), calc_enemy_damage_target(), dispatch_damage_event_player(), and dispatch_event_general().

◆ btl_are_all_enemies_defeated()

s32 btl_are_all_enemies_defeated ( void )

Definition at line 636 of file 190B20.c.

636 {
637 BattleStatus* battleStatus = &gBattleStatus;
638 Actor* enemy;
639 s32 enemiesStillAlive = FALSE;
640 s32 i;
641
642 for (i = 0; i < ARRAY_COUNT(battleStatus->enemyActors); i++) {
643 enemy = battleStatus->enemyActors[i];
644 if (enemy != NULL) {
646 enemiesStillAlive = TRUE;
647 }
648 }
649 }
650 return !enemiesStillAlive;
651}

Referenced by btl_check_enemies_defeated(), and btl_state_update_partner_move().

◆ btl_check_enemies_defeated()

◆ btl_check_player_defeated()

◆ btl_show_battle_message()

void btl_show_battle_message ( s32 messageIndex,
s32 duration )

Definition at line 576 of file popup_messages.c.

576 {
578
579 if (popup != NULL) {
582 popup->unk_00 = FALSE;
583 popup->renderWorldFunc = NULL;
584 popup->messageIndex = messageIndex;
585 popup->duration = duration;
587 popup->needsInit = TRUE;
588 popup->data.bonk = NULL;
590 bPopupMessage = popup;
594#if !VERSION_JP
596#endif
597 }
598}
@ BTL_MSG_STATE_INIT
Definition enums.h:4149
BSS s16 BattleMessage_CurBoxOffsetY
BSS s16 BattleMessage_CurBoxPosY
PopupMessage * btl_create_popup(void)
BSS b16 BattleMessage_BoxPosLocked
void btl_update_message_popup(void *popup)
BSS s16 BattlePopupMessageVar
void btl_show_message_popup(void *popup)

Referenced by btl_main_menu_update(), btl_state_update_begin_player_turn(), btl_state_update_enemy_move(), btl_state_update_partner_move(), btl_state_update_player_move(), and btl_state_update_select_target().

◆ btl_update_ko_status()

void btl_update_ko_status ( void )

Definition at line 2869 of file 190B20.c.

2869 {
2870 BattleStatus* battleStatus = &gBattleStatus;
2871 Actor* player = battleStatus->playerActor;
2872 Actor* partner = battleStatus->partnerActor;
2873 s32 koDuration = player->koDuration;
2874 s32 i;
2875
2876 player->koDuration = player->debuffDuration;
2877 if (player->koDuration > 0) {
2878 player->koStatus = STATUS_KEY_DAZE;
2879 player->disableEffect->data.disableX->koDuration = player->koDuration;
2880
2881 if (koDuration == 0) {
2883 }
2884 }
2885
2886 if (partner != NULL) {
2887 if (partner->koDuration < partner->debuffDuration) {
2888 partner->koStatus = STATUS_KEY_DAZE;
2889 partner->koDuration = partner->debuffDuration;
2890 }
2891
2892 if (partner->koDuration > 0) {
2893 partner->koStatus = STATUS_KEY_DAZE;
2894 partner->disableEffect->data.disableX->koDuration = partner->koDuration;
2895 }
2896 }
2897
2898 for (i = 0; i < ARRAY_COUNT(battleStatus->enemyActors); i++) {
2899 Actor* enemy = battleStatus->enemyActors[i];
2900
2901 if (enemy != NULL) {
2902 enemy->koDuration = enemy->debuffDuration;
2903 if (enemy->koDuration > 0) {
2904 enemy->koStatus = STATUS_KEY_DAZE;
2906 }
2907 }
2908 }
2909}

Referenced by btl_state_update_enemy_move(), btl_state_update_partner_move(), and btl_state_update_player_move().

◆ reset_actor_turn_info()

void reset_actor_turn_info ( void )

Definition at line 978 of file 190B20.c.

978 {
979 BattleStatus* battleStatus = &gBattleStatus;
980 Actor* actor;
981 s32 i;
982
983 for (i = 0; i < ARRAY_COUNT(battleStatus->enemyActors); i++) {
984 actor = battleStatus->enemyActors[i];
985 if (actor != NULL) {
986 actor->hpChangeCounter = 0;
987 actor->damageCounter = 0;
988 actor->actionRatingCombo = 0;
989 }
990
991 }
992 actor = battleStatus->playerActor;
993 actor->hpChangeCounter = 0;
994 actor->damageCounter = 0;
995 actor->actionRatingCombo = 0;
996
997 actor = battleStatus->partnerActor;
998 if (actor != NULL) {
999 actor->hpChangeCounter = 0;
1000 actor->damageCounter = 0;
1001 actor->actionRatingCombo = 0;
1002 }
1003}
s16 damageCounter
s16 hpChangeCounter

Referenced by btl_state_update_9(), btl_state_update_begin_partner_turn(), btl_state_update_begin_player_turn(), btl_state_update_enemy_move(), btl_state_update_enemy_striking_first(), btl_state_update_first_strike(), btl_state_update_partner_move(), btl_state_update_partner_striking_first(), btl_state_update_player_move(), btl_state_update_switch_to_partner(), and btl_state_update_switch_to_player().

◆ startup_draw_prim_rect()

void startup_draw_prim_rect ( s16 left,
s16 top,
s16 right,
s16 bottom,
u16 r,
u16 g,
u16 b,
u16 a )

Definition at line 822 of file 43F0.c.

822 {
823 u16 temp;
824
825 if (right < left) {
826 temp = right;
827 right = left;
828 left = temp;
829 }
830
831 if (bottom < top) {
832 temp = bottom;
833 bottom = top;
834 top = temp;
835 }
836
837 appendGfx_startup_prim_rect(r, g, b, a, left, top, right, bottom);
838}
void appendGfx_startup_prim_rect(u8 r, u8 g, u8 b, u8 a, u16 left, u16 top, u16 right, u16 bottom)
Definition 43F0.c:784

Referenced by state_drawUI_startup().

◆ startup_draw_prim_rect_COPY()

void startup_draw_prim_rect_COPY ( s16 left,
s16 top,
s16 right,
s16 bottom,
u16 r,
u16 g,
u16 b,
u16 a )

Definition at line 804 of file 43F0.c.

804 {
805 u16 temp;
806
807 if (right < left) {
808 temp = right;
809 right = left;
810 left = temp;
811 }
812
813 if (bottom < top) {
814 temp = bottom;
815 bottom = top;
816 top = temp;
817 }
818
819 appendGfx_startup_prim_rect(r, g, b, a, left, top, right, bottom);
820}

Referenced by draw_mash_meter().

◆ btl_draw_prim_quad()

void btl_draw_prim_quad ( u8 r,
u8 g,
u8 b,
u8 a,
u16 left,
u16 top,
u16 arg6,
u16 arg7 )

Definition at line 2931 of file 190B20.c.

2931 {
2932 u16 right = left + arg6;
2933 u16 bottom = top + arg7;
2934
2935 btl_appendGfx_prim_quad(r, g, b, a, left, top, right, bottom);
2936}
void btl_appendGfx_prim_quad(u8 r, u8 g, u8 b, u8 a, u16 left, u16 top, u16 right, u16 bottom)
Definition 190B20.c:2911

Referenced by btl_draw_enemy_health_bars(), and btl_main_menu_draw().

◆ reset_all_actor_sounds()

void reset_all_actor_sounds ( Actor * actor)

Definition at line 2938 of file 190B20.c.

2938 {
2939 ActorPart* partIt = &actor->partsTable[0];
2940
2941 actor->actorTypeData1[0] = bActorSoundTable[actor->actorType].walk[0];
2942 actor->actorTypeData1[1] = bActorSoundTable[actor->actorType].walk[1];
2943 actor->actorTypeData1[2] = bActorSoundTable[actor->actorType].fly[0];
2944 actor->actorTypeData1[3] = bActorSoundTable[actor->actorType].fly[1];
2945 actor->actorTypeData1[4] = bActorSoundTable[actor->actorType].jump;
2946 actor->actorTypeData1[5] = bActorSoundTable[actor->actorType].hurt;
2947 actor->actorTypeData1b[0] = bActorSoundTable[actor->actorType].delay[0];
2948 actor->actorTypeData1b[1] = bActorSoundTable[actor->actorType].delay[1];
2949
2950 while (partIt != NULL) {
2951 partIt->partTypeData[0] = actor->actorTypeData1[0];
2952 partIt->partTypeData[1] = actor->actorTypeData1[1];
2953 partIt->partTypeData[2] = actor->actorTypeData1[2];
2954 partIt->partTypeData[3] = actor->actorTypeData1[3];
2955 partIt->partTypeData[4] = actor->actorTypeData1[4];
2956 partIt->partTypeData[5] = actor->actorTypeData1[5];
2957 partIt->actorTypeData2b[0] = actor->actorTypeData1b[0];
2958 partIt->actorTypeData2b[1] = actor->actorTypeData1b[1];
2959 partIt = partIt->nextPart;
2960 }
2961}

Referenced by btl_state_update_enemy_move(), btl_state_update_partner_move(), and btl_state_update_player_move().

◆ decrement_status_bar_disabled()

void decrement_status_bar_disabled ( void )

◆ increment_status_bar_disabled()

void increment_status_bar_disabled ( void )

◆ btl_delete_actor()

void btl_delete_actor ( Actor * actor)

Definition at line 1110 of file 16C8E0.c.

1110 {
1111 ActorPart* part;
1112 ActorPart* actorPartTemp;
1113 BattleStatus* battleStatus;
1114 s32 i;
1115
1116 // TODO hard-coded
1117 for (i = 0; i < 2; i++) {
1118 remove_actor_decoration(actor, i);
1119 }
1120 if (actor->idleScript != NULL) {
1122 }
1123 if (actor->handleEventScript != NULL) {
1125 }
1126 if (actor->takeTurnScript != NULL) {
1128 }
1130
1131 part = actor->partsTable;
1132
1133 while (part != NULL) {
1134 if (!(part->flags & ACTOR_PART_FLAG_NO_SHADOW)) {
1136 }
1137
1138 if (part->idleAnimations != NULL) {
1139 set_npc_imgfx_all(part->spriteInstanceID, IMGFX_CLEAR, 0, 0, 0, 0, 0);
1140
1142
1144 heap_free(part->movement);
1145 }
1146
1147 if (!(part->flags & ACTOR_PART_FLAG_NO_DECORATIONS)) {
1149 }
1150 }
1151 actorPartTemp = part->nextPart;
1152 heap_free(part);
1153 part = actorPartTemp;
1154 }
1155
1156 delete_shadow(actor->shadow.id);
1159
1160 if (actor->attackResultEffect != NULL) {
1162 }
1163
1164 battleStatus = &gBattleStatus;
1165 for (i = 0; i < ARRAY_COUNT(battleStatus->enemyActors); i++) {
1166 if (battleStatus->enemyActors[i] == actor) {
1167 battleStatus->enemyActors[i] = NULL;
1168 break;
1169 }
1170 }
1171
1172 heap_free(actor);
1173}
void set_npc_imgfx_all(s32 spriteIdx, ImgFXType imgfxType, s32 imgfxArg1, s32 imgfxArg2, s32 imgfxArg3, s32 imgfxArg4, s32 imgfxArg5)
Definition sprite.c:1253

Referenced by btl_state_update_change_partner(), btl_state_update_end_battle(), and btl_state_update_end_demo_battle().

◆ create_status_debuff()

void create_status_debuff ( s32 iconID,
s32 statusID )

Definition at line 1054 of file status_icons.c.

1054 {
1055 HudStatusIcon* statusIcon = &D_800A0F44[iconID];
1056
1057 statusIcon->flags &= ~STATUS_ICON_FLAG_DEBUFF;
1058 if (statusIcon->status1.active != statusID) {
1059 remove_status_debuff(iconID);
1060 statusIcon->status1.active = statusID;
1062 }
1063}
void remove_status_debuff(s32 iconID)
@ STATUS_ICON_TASK_LOAD
BSS HudStatusIcon * D_800A0F44
HudComplexStatusIcon status1

Referenced by appendGfx_npc_actor(), appendGfx_player_actor(), and inflict_status().

◆ create_status_static()

void create_status_static ( s32 iconID,
s32 statusID )

Definition at line 1084 of file status_icons.c.

1084 {
1085 HudStatusIcon* statusIcon = &D_800A0F44[iconID];
1086
1087 statusIcon->flags &= ~STATUS_ICON_FLAG_STATIC;
1088 if (statusIcon->status2.active != statusID) {
1089 remove_status_static(iconID);
1090 statusIcon->status2.active = statusID;
1091 statusIcon->status2.activeTask = 1;
1092 }
1093}
HudComplexStatusIcon status2
void remove_status_static(s32 iconID)

Referenced by appendGfx_npc_actor(), appendGfx_player_actor(), and inflict_status().

◆ create_status_transparent()

void create_status_transparent ( s32 iconID,
s32 statusID )

Definition at line 1114 of file status_icons.c.

1114 {
1115 HudStatusIcon* statusIcon = &D_800A0F44[iconID];
1116
1117 statusIcon->flags &= ~STATUS_ICON_FLAG_TRANSPARENT;
1118 if (statusIcon->status3.active != statusID) {
1120 statusIcon->status3.active = statusID;
1121 statusIcon->status3.activeTask = 1;
1122 }
1123}
void remove_status_transparent(s32 iconID)
HudComplexStatusIcon status3

Referenced by appendGfx_npc_actor(), appendGfx_player_actor(), and inflict_status().

◆ remove_status_chill_out()

void remove_status_chill_out ( s32 iconID)

Definition at line 1154 of file status_icons.c.

1154 {
1155 HudStatusIcon* statusIcon = &D_800A0F44[iconID];
1156
1157 if (statusIcon->status4.active && !statusIcon->status4.removing) {
1158 statusIcon->status4.removing = statusIcon->status4.active;
1159 statusIcon->status4.removingTask = TRUE;
1160 statusIcon->status4.active = FALSE;
1161 statusIcon->status4.activeTask = FALSE;
1162 statusIcon->status4.frameCounter = 10;
1163 statusIcon->status4.removingElementHID = statusIcon->status4.activeElementHID;
1164 }
1165}
HudElemID removingElementHID
HudComplexStatusIcon status4
HudElemID activeElementHID

Referenced by btl_state_update_begin_player_turn(), and remove_all_status_icons().

◆ remove_status_debuff()

void remove_status_debuff ( s32 iconID)

Definition at line 1065 of file status_icons.c.

1065 {
1066 HudStatusIcon* statusIcon = &D_800A0F44[iconID];
1067
1068 if (statusIcon->status1.active && !statusIcon->status1.removing) {
1069 statusIcon->status1.removing = statusIcon->status1.active;
1071 statusIcon->status1.active = 0;
1073 statusIcon->status1.frameCounter = 10;
1074 statusIcon->status1.removingElementHID = statusIcon->status1.activeElementHID;
1075 }
1076}
@ STATUS_ICON_TASK_NONE

Referenced by btl_state_update_9(), btl_state_update_begin_player_turn(), btl_state_update_defeat(), create_status_debuff(), and remove_all_status_icons().

◆ remove_status_icon_boost_hammer()

void remove_status_icon_boost_hammer ( s32 iconID)

Definition at line 1219 of file status_icons.c.

1219 {
1220 HudStatusIcon* statusIcon = &D_800A0F44[iconID];
1221
1222 if (statusIcon->boostHammer.active) {
1223 HudElemID hid = statusIcon->boostHammer.activeElementID;
1224 statusIcon->boostHammer.active = FALSE;
1225 statusIcon->boostHammer.removing = FALSE;
1226 statusIcon->prevIndexBoostHammer = hid;
1228 }
1229}
s32 prevIndexBoostHammer
HudSimpleStatusIcon boostHammer
HudScript HES_BoostHammerEnd

Referenced by appendGfx_player_actor(), and remove_all_status_icons().

◆ remove_status_icon_boost_jump()

void remove_status_icon_boost_jump ( s32 iconID)

Definition at line 1187 of file status_icons.c.

1187 {
1188 HudStatusIcon* statusIcon = &D_800A0F44[iconID];
1189
1190 if (statusIcon->boostJump.active) {
1191 HudElemID hid = statusIcon->boostJump.activeElementID;
1192 statusIcon->boostJump.active = FALSE;
1193 statusIcon->boostJump.removing = TRUE;
1194 statusIcon->prevIndexBoostJump = hid;
1196 }
1197}
HudSimpleStatusIcon boostJump
HudScript HES_BoostJumpEnd

Referenced by appendGfx_player_actor(), and remove_all_status_icons().

◆ remove_status_icon_boost_partner()

void remove_status_icon_boost_partner ( s32 iconID)

Definition at line 1251 of file status_icons.c.

1251 {
1252 HudStatusIcon* statusIcon = &D_800A0F44[iconID];
1253
1254 if (statusIcon->boostPartner.active) {
1255 statusIcon->boostPartner.active = FALSE;
1257 }
1258}
HudSimpleStatusIcon boostPartner

Referenced by remove_all_status_icons().

◆ remove_status_icon_danger()

void remove_status_icon_danger ( s32 iconID)

Definition at line 1338 of file status_icons.c.

1338 {
1339 HudStatusIcon* statusIcon = &D_800A0F44[iconID];
1340
1341 if (statusIcon->danger.active) {
1342 statusIcon->danger.active = FALSE;
1344 }
1345}
HudSimpleStatusIcon danger

Referenced by appendGfx_player_actor(), and remove_all_status_icons().

◆ remove_status_icon_peril()

void remove_status_icon_peril ( s32 iconID)

Definition at line 1309 of file status_icons.c.

1309 {
1310 HudStatusIcon* statusIcon = &D_800A0F44[iconID];
1311
1312 if (statusIcon->peril.active) {
1313 statusIcon->peril.active = FALSE;
1315 }
1316}
HudSimpleStatusIcon peril

Referenced by appendGfx_player_actor(), and remove_all_status_icons().

◆ remove_status_icon_surprise()

void remove_status_icon_surprise ( s32 iconID)

Definition at line 1280 of file status_icons.c.

1280 {
1281 HudStatusIcon* statusIcon = &D_800A0F44[iconID];
1282
1283 if (statusIcon->surprise.active) {
1284 statusIcon->surprise.active = FALSE;
1286 }
1287}
HudSimpleStatusIcon surprise

Referenced by remove_all_status_icons().

◆ remove_status_static()

void remove_status_static ( s32 iconID)

Definition at line 1095 of file status_icons.c.

1095 {
1096 HudStatusIcon* statusIcon = &D_800A0F44[iconID];
1097
1098 if (statusIcon->status2.active && !statusIcon->status2.removing) {
1099 statusIcon->status2.removing = statusIcon->status2.active;
1100 statusIcon->status2.removingTask = TRUE;
1101 statusIcon->status2.active = FALSE;
1102 statusIcon->status2.activeTask = FALSE;
1103 statusIcon->status2.frameCounter = 10;
1104 statusIcon->status2.removingElementHID = statusIcon->status2.activeElementHID;
1105 }
1106}

Referenced by btl_state_update_9(), btl_state_update_begin_player_turn(), calc_item_damage_enemy(), create_status_static(), remove_all_status_icons(), and remove_player_buffs().

◆ remove_status_transparent()

void remove_status_transparent ( s32 iconID)

Definition at line 1125 of file status_icons.c.

1125 {
1126 HudStatusIcon* statusIcon = &D_800A0F44[iconID];
1127
1128 if (statusIcon->status3.active && !statusIcon->status3.removing) {
1129 statusIcon->status3.removing = statusIcon->status3.active;
1130 statusIcon->status3.removingTask = TRUE;
1131 statusIcon->status3.active = FALSE;
1132 statusIcon->status3.activeTask = FALSE;
1133 statusIcon->status3.frameCounter = 10;
1134 statusIcon->status3.removingElementHID = statusIcon->status3.activeElementHID;
1135 }
1136}

Referenced by btl_state_update_9(), btl_state_update_begin_player_turn(), calc_item_damage_enemy(), create_status_transparent(), remove_all_status_icons(), and remove_player_buffs().

◆ remove_all_status_icons()

void remove_all_status_icons ( s32 iconID)

Definition at line 1015 of file status_icons.c.

1015 {
1016 HudStatusIcon* statusIcon = &D_800A0F44[iconID];
1017
1018 remove_status_debuff(iconID);
1019 remove_status_static(iconID);
1028 statusIcon->flags = 0;
1029}
void remove_status_icon_surprise(s32 iconID)
void remove_status_icon_boost_jump(s32 iconID)
void remove_status_icon_boost_partner(s32 iconID)
void remove_status_icon_peril(s32 iconID)
void remove_status_chill_out(s32 iconID)
void remove_status_icon_boost_hammer(s32 iconID)
void remove_status_icon_danger(s32 iconID)

Referenced by btl_delete_actor(), and btl_delete_player_actor().

◆ create_status_icon_set()

s32 create_status_icon_set ( void )

Definition at line 957 of file status_icons.c.

957 {
958 s32 i;
959 HudStatusIcon* icon;
960
961 for (icon = D_800A0F44, i = 0; i < MAX_ICONS; icon++, i++) {
962 if (icon->flags == 0) {
963 break;
964 }
965 }
966
967 ASSERT(i < MAX_ICONS);
968
970
973 }
974
975 icon->worldPos.x = 0;
976 icon->worldPos.y = 0;
977 icon->worldPos.z = 0;
978
979 icon->status1Radius = 0;
980 icon->status1OffsetY = 0;
981 icon->status2Radius = 0;
982 icon->status2OffsetY = 0;
983 icon->status3Radius = 0;
984 icon->status3OffsetY = 0;
985 icon->status4Radius = 0;
986 icon->status4OffsetY = 0;
987 icon->status1.active = 0;
988 icon->status1.removing = 0;
989 icon->status1.activeTask = 0;
990 icon->status1.removingTask = 0;
991 icon->status2.active = 0;
992 icon->status2.removing = 0;
993 icon->status2.activeTask = 0;
994 icon->status2.removingTask = 0;
995 icon->status3.active = 0;
996 icon->status3.removing = 0;
997 icon->status3.activeTask = 0;
998 icon->status3.removingTask = 0;
999 icon->status4.active = 0;
1000 icon->status4.removing = 0;
1001 icon->status4.activeTask = 0;
1002 icon->status4.removingTask = 0;
1003 icon->boostJump.active = 0;
1004 icon->boostJump.removing = 0;
1005 icon->boostHammer.active = 0;
1006 icon->boostHammer.removing = 0;
1007 icon->boostPartner.active = 0;
1008 icon->surprise.active = 0;
1009 icon->peril.active = 0;
1010 icon->danger.active = 0;
1011
1012 return i;
1013}
#define MAX_ICONS
Definition status_icons.c:6
@ STATUS_ICON_FLAG_BATTLE
@ STATUS_ICON_FLAG_USED
Definition status_icons.c:9

Referenced by create_actor(), load_partner_actor(), and load_player_actor().

◆ find_item()

s32 find_item ( s32 itemID)

Search player inventory for itemID and return first matching array index.

Returns
the index of the given item in the player's inventory, or -1 if not found

Definition at line 264 of file inventory.c.

264 {
265 s32 idx;
266
267 // handle key items
268 if (item_is_key(itemID)) {
269 for (idx = 0; idx < ARRAY_COUNT(gPlayerData.keyItems); idx++) {
270 if (gPlayerData.keyItems[idx] == itemID) {
271 break;
272 }
273 }
274
275 if (idx >= ARRAY_COUNT(gPlayerData.keyItems)) {
276 return -1;
277 }
278 return idx;
279 }
280
281 // handle badges
282 if (item_is_badge(itemID)) {
283 for (idx = 0; idx < ARRAY_COUNT(gPlayerData.badges); idx++) {
284 if (gPlayerData.badges[idx] == itemID) {
285 break;
286 }
287 }
288
289 if (idx >= ARRAY_COUNT(gPlayerData.badges)) {
290 return -1;
291 }
292 return idx;
293 }
294
295 // handle consumables
296 for (idx = 0; idx < ARRAY_COUNT(gPlayerData.invItems); idx++) {
297 if (gPlayerData.invItems[idx] == itemID) {
298 break;
299 }
300 }
301
302 if (idx == ARRAY_COUNT(gPlayerData.invItems)) {
303 return -1;
304 }
305 return idx;
306}
s16 badges[128]
s16 keyItems[32]

Referenced by btl_state_update_defeat().

◆ enable_background_wave()

void enable_background_wave ( void )

Definition at line 309 of file background.c.

309 {
311}

Referenced by EnableBackgroundWave().

◆ set_map_change_fade_rate()

void set_map_change_fade_rate ( s16 fadeRate)

Definition at line 11 of file state_map_transitions.c.

11 {
12 gMapTransitionFadeRate = fadeRate;
13}
BSS s16 gMapTransitionFadeRate

◆ load_map_by_IDs()

void load_map_by_IDs ( s16 areaID,
s16 mapID,
s16 loadType )

Definition at line 53 of file world.c.

53 {
54 s32 skipLoadingAssets = 0;
55 MapConfig* mapConfig;
56 MapSettings* mapSettings;
57 char texStr[17];
58 s32 decompressedSize;
59
61 gOverrideFlags &= ~GLOBAL_OVERRIDES_40;
62 gOverrideFlags &= ~GLOBAL_OVERRIDES_ENABLE_FLOOR_REFLECTION;
63
68
69#if !VERSION_IQUE
71#endif
73
74#if VERSION_JP
76#endif
80
81 switch (loadType) {
82 case LOAD_FROM_MAP:
85 break;
88 areaID = gGameStatusPtr->areaID;
89 mapID = gGameStatusPtr->mapID;
90 gGameStatusPtr->prevArea = areaID;
92 break;
93 }
94
95 gGameStatusPtr->mapShop = NULL;
96
97 ASSERT_MSG(areaID < ARRAY_COUNT(gAreas) - 1, "Invalid area ID %d", areaID);
98 ASSERT_MSG(mapID < gAreas[areaID].mapCount, "Invalid map ID %d in %s", mapID, gAreas[areaID].id);
99 mapConfig = &gAreas[areaID].maps[mapID];
100
101 #if DX_DEBUG_MENU
102 dx_debug_set_map_info(mapConfig->id, gGameStatus.entryID);
103 #endif
104
105 sprintf(wMapShapeName, "%s_shape", mapConfig->id);
106 sprintf(wMapHitName, "%s_hit", mapConfig->id);
107 strcpy(texStr, mapConfig->id);
108 texStr[3] = '\0';
109 sprintf(wMapTexName, "%s_tex", texStr);
110
111 gMapConfig = mapConfig;
112 if (mapConfig->bgName != NULL) {
113 strcpy(wMapBgName, mapConfig->bgName);
114 }
116
117 if (mapConfig->dmaStart != NULL) {
118 dma_copy(mapConfig->dmaStart, mapConfig->dmaEnd, mapConfig->dmaDest);
119 }
120
121 gMapSettings = *mapConfig->settings;
122
123 mapSettings = &gMapSettings;
124 if (mapConfig->init != NULL) {
125 skipLoadingAssets = mapConfig->init();
126 }
127
128 if (!skipLoadingAssets) {
129 ShapeFile* shapeFile = &gMapShapeData;
130 void* yay0Asset = load_asset_by_name(wMapShapeName, &decompressedSize);
131
132 decode_yay0(yay0Asset, shapeFile);
133 general_heap_free(yay0Asset);
134
135 mapSettings->modelTreeRoot = shapeFile->header.root;
136 mapSettings->modelNameList = shapeFile->header.modelNames;
137 mapSettings->colliderNameList = shapeFile->header.colliderNames;
138 mapSettings->zoneNameList = shapeFile->header.zoneNames;
139 }
140
141 if (mapConfig->bgName != NULL) {
143 }
144
145#if !VERSION_IQUE
147#endif
149
157 clear_npcs();
163
166 }
167
168 if (!skipLoadingAssets) {
171 }
172
175 clear_entity_data(TRUE);
182
184
185 sfx_set_reverb_mode(WorldReverbModeMapping[*(s32*)mapConfig->unk_1C & 0x3]);
187
188 if (!skipLoadingAssets) {
189 s32 texturesOffset = get_asset_offset(wMapTexName, &decompressedSize);
190
191 if (mapSettings->modelTreeRoot != NULL) {
192 load_data_for_models(mapSettings->modelTreeRoot, texturesOffset, decompressedSize);
193 }
194 }
195
196 if (mapSettings->background != NULL) {
197 set_background(mapSettings->background);
198 } else {
199 set_background_size(296, 200, 12, 20);
200 }
201
207
209 set_cam_viewport(CAM_DEFAULT, 12, 20, 296, 200);
210 } else {
211 set_cam_viewport(CAM_DEFAULT, 29, 28, 262, 162);
212 }
213
215 gGameStatusPtr->unk_90 = 1000;
216 gGameStatusPtr->unk_92 = 1000;
218}
struct Shop * mapShop
@ LOAD_FROM_MAP
Definition enums.h:3559
@ LOAD_FROM_FILE_SELECT
Definition enums.h:3560
@ INTRO_PART_NONE
Definition enums.h:3555
@ PLAYER_SPRITES_MARIO_WORLD
Definition enums.h:6345
@ EVT_PRIORITY_0
Definition evt.h:151
@ EVT_GROUP_NEVER_PAUSE
Definition evt.h:142
void clear_script_list(void)
void clear_item_entity_data(void)
void create_cameras(void)
Definition cam_main.c:255
void clear_animator_list(void)
Definition animator.c:222
void partner_reset_data(void)
Definition partners.c:1000
void clear_render_tasks(void)
Definition model.c:4534
void clear_model_data(void)
Definition model.c:2364
void clear_trigger_data(void)
Definition trigger.c:13
void clear_sprite_shading_data(void)
void clear_entity_data(b32)
Definition entity.c:787
void phys_set_player_sliding_check(b32(*funcPtr)(void))
Definition 7BB60.c:846
void clear_printers(void)
Definition msg.c:196
void initialize_collision(void)
Definition collision.c:111
void player_reset_data(void)
Definition 77480.c:811
void reset_battle_status(void)
Definition battle.c:100
void clear_player_status(void)
Definition 77480.c:807
void clear_effect_data(void)
Definition effects.c:41
void clear_worker_list(void)
Definition worker.c:10
void set_background_size(s16, s16, s16, s16)
Definition background.c:50
void shim_general_heap_create_obfuscated(void)
void clear_area_flags(void)
Definition vars_access.c:26
void func_80138188(void)
void clear_entity_models(void)
void reset_background_settings(void)
Definition background.c:33
void initialize_status_bar(void)
Definition inventory.c:483
void set_cam_viewport(s16 id, s16 x, s16 y, s16 width, s16 height)
Definition cam_main.c:373
void phys_set_landing_adjust_cam_check(s32(*funcPtr)(void))
Definition 7E9D0.c:42
void hud_element_clear_cache(void)
char ** modelNames
Definition model.h:176
char ** colliderNames
Definition model.h:177
char ** zoneNames
Definition model.h:178
void clear_npcs(void)
Definition npc.c:60
void clear_encounter_status(void)
Definition npc.c:2223
void sfx_clear_env_sounds(s16 playSounds)
Definition sfx.c:313
void sfx_set_reverb_mode(s32 arg0)
Definition sfx.c:352
void sfx_reset_door_sounds(void)
Definition sfx.c:299
void reset_max_rumble_duration(void)
Definition rumble.c:45
char * id
Definition map.h:42
char ** modelNameList
Definition map.h:27
char ** colliderNameList
Definition map.h:28
MapInit init
Return TRUE to skip normal asset (shape/hit/bg/tex) loading.
Definition map.h:48
EvtScript * main
Definition map.h:23
char ** zoneNameList
Definition map.h:29
MapSettings * settings
Definition map.h:43
char * bgName
Definition map.h:47
char unk_1C[0x2]
Definition map.h:49
void * dmaEnd
Definition map.h:45
void * dmaDest
Definition map.h:46
BackgroundHeader * background
Definition map.h:31
void * dmaStart
Definition map.h:44
struct ModelNode * modelTreeRoot
Definition map.h:19
void spr_init_sprites(s32 playerSpriteSet)
Definition sprite.c:764
void surface_set_walk_effect(s32 effect)
Select the type of surface effect spawned by the player while moving The effect is reset between maps...
Definition surfaces.c:18
@ SURFACE_WALK_FX_STANDARD
Definition surfaces.h:7
GameStatus gGameStatus
Definition main_loop.c:21
void load_map_hit_asset(void)
Definition collision.c:117
void fio_deserialize_state(void)
Load game data from gCurrentSaveFile Performs version checking and supports potential migration betwe...
Definition versioning.c:36
BSS MapConfig * gMapConfig
Definition world.c:23
void * load_asset_by_name(const char *assetName, u32 *decompressedSize)
Definition world.c:251
ShapeFile gMapShapeData
Definition heaps.c:16
s32 WorldReverbModeMapping[]
Definition world.c:31
void load_map_script_lib(void)
Definition world.c:49
char wMapHitName[0x18]
Definition world.c:26
BSS MapSettings gMapSettings
Definition world.c:24
char wMapTexName[0x18]
Definition world.c:28
s32 get_asset_offset(char *assetName, s32 *compressedSize)
Definition world.c:273
char wMapBgName[0x14]
Definition world.c:29
char wMapShapeName[0x18]
Definition world.c:27

Referenced by state_step_change_map(), state_step_enter_world(), state_step_game_over(), and state_step_intro().

◆ state_init_startup()

void state_init_startup ( void )

◆ state_step_startup()

void state_step_startup ( void )

Definition at line 14 of file state_startup.c.

14 {
15 s32 i;
16
17 if (gGameStatus.startupState != 0) {
19 return;
20 }
21
35
51 clear_entity_data(FALSE);
54 clear_npcs();
68
69 for (i = 0; i < ARRAY_COUNT(gGameStatus.unk_50); i++) {
70 gGameStatus.unk_50[i] = 4;
71 gGameStatus.unk_48[i] = 15;
72 }
73
75
76 if (gSaveGlobals.useMonoSound == 0) {
79 } else {
82 }
83
84 gOverrideFlags &= ~GLOBAL_OVERRIDES_DISABLE_DRAW_FRAME;
85
86 #if DX_QUICK_LAUNCH
87 // immediately jump into the world using last-used save file
91 gOverrideFlags &= ~GLOBAL_OVERRIDES_DISABLE_RENDER_WORLD;
92 return;
93 }
94 #endif
95
96 #if DX_SKIP_LOGOS
97 // go right to the story book or file select
98 #if DX_SKIP_STORY
100 set_curtain_fade(0.0f);
102 #else
103 set_curtain_scale(1.0f);
104 set_curtain_fade(0.3f);
107 #endif
108 #else
109 // use vanilla startup process
111 #endif
112}
void audio_set_stereo(void)
Definition 30450.c:839
void audio_set_mono(void)
Definition 30450.c:844
b8 keepUsingPartnerOnMapChange
@ SOUND_OUT_MONO
Definition enums.h:277
@ SOUND_OUT_STEREO
Definition enums.h:278
@ INTRO_PART_0
Definition enums.h:3551
void clear_saved_variables(void)
Definition vars_access.c:5
void clear_screen_overlays(void)
void initialize_curtains(void)
Definition curtains.c:212
void set_curtain_fade(f32 fade)
Definition curtains.c:302
void bgm_reset_volume(void)
HeapNode * general_heap_create(void)
Definition heap.c:6
s32 bgm_init_music_players(void)
void set_curtain_scale(f32 scale)
Definition curtains.c:289
void clear_windows(void)
Definition windows.c:135
void clear_player_data(void)
Definition inventory.c:55
void partner_initialize_data(void)
Definition partners.c:1032
@ GAME_MODE_LOGOS
Definition game_modes.h:8
@ GAME_MODE_ENTER_WORLD
Definition game_modes.h:11
void hud_element_set_aux_cache(void *base, s32 size)
void init_encounter_status(void)
Definition npc.c:2190
void sfx_clear_sounds(void)
Definition sfx.c:304
s32 useMonoSound
Definition versioning.h:14

◆ state_drawUI_startup()

void state_drawUI_startup ( void )

Definition at line 114 of file state_startup.c.

114 {
115 startup_draw_prim_rect(0, 0, SCREEN_WIDTH - 1, SCREEN_HEIGHT - 1, 0, 0, 0, 255);
116}
void startup_draw_prim_rect(s16 left, s16 top, s16 right, s16 bottom, u16 r, u16 g, u16 b, u16 a)
Definition 43F0.c:822

◆ state_init_logos()

void state_init_logos ( void )

Definition at line 66 of file state_logos.c.

66 {
67 s8* romStart;
68 s8* romEnd;
69
76
77 romEnd = logos_ROM_END;
78 romStart = logos_ROM_START;
79 gLogosImages = heap_malloc(romEnd - romStart);
80 dma_copy(romStart, romEnd, gLogosImages);
81
83 gLogosImage3 = gLogosImages + 0x7000;
84 gLogosImage2 = gLogosImages + 0x15000;
85
86 nuContRmbForceStop();
92 gCameras[CAM_DEFAULT].vfov = 25.0f;
93 set_cam_viewport(CAM_DEFAULT, 12, 28, 296, 184);
94
95 gCameras[CAM_DEFAULT].params.basic.skipRecalc = FALSE;
96 gCameras[CAM_DEFAULT].params.basic.pitch = 0;
97 gCameras[CAM_DEFAULT].params.basic.dist = 40;
98 gCameras[CAM_DEFAULT].params.basic.fovScale = 100;
99
101 gCameras[CAM_DEFAULT].lookAt_eye.y = 1000.0f;
102 gCameras[CAM_DEFAULT].lookAt_eye.z = 1500.0f;
103
107
111
113
118
125 clear_npcs();
128 clear_entity_data(TRUE);
133}
@ CAM_UPDATE_NO_INTERP
Definition enums.h:4760
@ GLOBAL_OVERRIDES_DISABLE_RENDER_WORLD
Definition enums.h:4320
void startup_set_fade_screen_alpha(s16 alpha)
void startup_fade_screen_update(void)
void startup_set_fade_screen_color(s16 color)
#define CAM_NEAR_CLIP
Definition macros.h:121
#define CAM_FAR_CLIP
Definition macros.h:122
BSS u8 * gLogosImages
Definition state_logos.c:61
BSS u8 * gLogosImage2
Definition state_logos.c:64
BSS u8 * gLogosImage1
Definition state_logos.c:63
BSS u8 * gLogosImage3
Definition state_logos.c:62
@ LOGOS_STATE_N64_FADE_IN
Definition state_logos.c:23
s16 bgColor[3]
Vec3f lookAt_obj_target
Vec3f lookAt_eye

◆ state_step_logos()

void state_step_logos ( void )

Definition at line 135 of file state_logos.c.

135 {
136 int pressedButtons = gGameStatusPtr->pressedButtons[0];
138 if (startup_fade_screen_out(10)) {
139 set_curtain_scale(1.0f);
140 set_curtain_fade(0.0f);
142 }
143 } else {
154 && (pressedButtons & (BUTTON_START | BUTTON_Z | BUTTON_A))
155 ) {
158 }
159
160 switch (gGameStatusPtr->startupState) {
162 if (startup_fade_screen_in(10)) {
165 }
166 break;
168 if (gGameStatusPtr->logoTime == 0) {
171 }
173 break;
175 if (startup_fade_screen_out(10)) {
177#if VERSION_JP
179#endif
180 }
181 break;
183 if (startup_fade_screen_in(10)) {
186 }
187 break;
189 if (gGameStatusPtr->logoTime == 0) {
191#if VERSION_JP
193#else
195#endif
196 }
198 break;
200 if (startup_fade_screen_out(10)) {
202 }
203 break;
205 if (startup_fade_screen_in(10)) {
208 }
209 break;
211 if (gGameStatusPtr->logoTime == 0) {
215 }
217 break;
219 if (gGameStatusPtr->logoTime == 0) {
224 } else {
226 }
227 break;
229 if (startup_fade_screen_out(10)) {
232 }
233 break;
235 if (gGameStatusPtr->logoTime == 0) {
237 } else {
239 }
240 break;
243 gLogosImages = NULL;
247 break;
248 }
249 }
250 update_npcs();
253}
void set_curtain_draw_callback(void(*callback)(void))
b32 startup_fade_screen_in(s16 subtractAlpha)
void set_curtain_fade_goal(f32 fade)
Definition curtains.c:298
void update_cameras(void)
Definition cam_main.c:19
b32 startup_fade_screen_out(s16 addAlpha)
void update_npcs(void)
Updates all NPCs.
Definition npc.c:617
#define N64_FADE_IN_TIME
Definition state_logos.c:19
@ LOGOS_STATE_NINTENDO_HOLD
Definition state_logos.c:27
@ LOGOS_STATE_NINTENDO_FADE_OUT
Definition state_logos.c:28
@ LOGOS_STATE_IS_FADE_OUT
Definition state_logos.c:32
@ LOGOS_STATE_NINTENDO_FADE_IN
Definition state_logos.c:26
@ LOGOS_STATE_IS_HOLD_1
Definition state_logos.c:30
@ LOGOS_STATE_CLEANUP
Definition state_logos.c:34
@ LOGOS_STATE_N64_FADE_OUT
Definition state_logos.c:25
@ LOGOS_STATE_N64_HOLD
Definition state_logos.c:24
@ LOGOS_STATE_CURTAINS_APPEAR
Definition state_logos.c:33
@ LOGOS_STATE_IS_HOLD_2
Definition state_logos.c:31
@ LOGOS_STATE_IS_FADE_IN
Definition state_logos.c:29

◆ state_drawUI_logos()

void state_drawUI_logos ( void )

Definition at line 255 of file state_logos.c.

255 {
257}
void appendGfx_intro_logos(void)

◆ state_init_title_screen()

void state_init_title_screen ( void )

Definition at line 122 of file state_title_screen.c.

122 {
123 s32 titleDataSize;
124 void* titleDataDst;
125 void* titleData;
126
127 gOverrideFlags = 0;
137 titleData = load_asset_by_name("title_data", &titleDataSize);
138 titleDataDst = TitleScreen_ImgList = heap_malloc(titleDataSize);
139 decode_yay0(titleData, titleDataDst);
140 general_heap_free(titleData);
141
145#if VERSION_JP
147#endif
148
154 gCameras[CAM_DEFAULT].vfov = 25.0f;
155 set_cam_viewport(CAM_DEFAULT, 12, 28, 296, 184);
156
157 gCameras[CAM_DEFAULT].params.basic.skipRecalc = FALSE;
158 gCameras[CAM_DEFAULT].params.basic.pitch = 0;
159 gCameras[CAM_DEFAULT].params.basic.dist = 40;
160 gCameras[CAM_DEFAULT].params.basic.fovScale = 100;
161
163 gCameras[CAM_DEFAULT].lookAt_eye.y = 1000.0f;
164 gCameras[CAM_DEFAULT].lookAt_eye.z = 1500.0f;
165
169
173
175
180
187 clear_npcs();
190 clear_entity_data(TRUE);
194 gOverrideFlags &= ~GLOBAL_OVERRIDES_DISABLE_DRAW_FRAME;
196 load_map_bg("title_bg");
198 bgm_set_song(0, SONG_MAIN_THEME, 0, 500, 8);
200}
@ SONG_MAIN_THEME
Definition enums.h:388
void set_game_mode_render_frontUI(void(*fn)(void))
Definition game_modes.c:154
void appendGfx_title_screen(void)
#define COPYRIGHT_WIDTH
BSS s32 * TitleScreen_ImgList_CopyrightPalette
BSS s32 * TitleScreen_ImgList_PressStart
BSS TitleDataStruct * TitleScreen_ImgList
BSS u8(* TitleScreen_ImgList_Copyright)[144]
BSS s16 TitleScreen_TimeLeft
BSS s32 * TitleScreen_ImgList_Logo
@ TITLE_STATE_INIT

◆ state_step_title_screen()

void state_step_title_screen ( void )

Definition at line 202 of file state_title_screen.c.

202 {
203 s32 temp;
204 u32 pressedButtons = gGameStatusPtr->pressedButtons[0];
205
206 set_curtain_scale(1.0f);
207 set_curtain_fade(0.0f);
208
209 if (TitleScreen_TimeLeft > 0) {
211 }
212
213 switch (gGameStatusPtr->startupState) {
214 case TITLE_STATE_INIT:
220 break;
222 if (TitleScreen_AppearDelay != 0) {
224 break;
225 }
228 }
229 gOverrideFlags &= ~GLOBAL_OVERRIDES_DISABLE_DRAW_FRAME;
230 if (startup_fade_screen_in(6) != 0) {
233 }
234 }
236 break;
237 case TITLE_STATE_HOLD:
238
239 #if DX_SKIP_DEMO && DX_SKIP_STORY
240 // play neither demo nor story
242 #elif DX_SKIP_DEMO
243 // only the story may play
244 if (TitleScreen_TimeLeft == 120) {
245 bgm_set_song(0, -1, 0, 3900, 8);
246 }
247 if (TitleScreen_TimeLeft == 0) {
250 return;
251 }
252 #elif DX_SKIP_STORY
253 // only the demo may play
254 if (TitleScreen_TimeLeft == 0) {
257 return;
258 }
259 #else
260 // allow either demo or story to play
261 if (PlayIntroNext && TitleScreen_TimeLeft == 120) {
262 bgm_set_song(0, -1, 0, 3900, 8);
263 }
264 if (TitleScreen_TimeLeft == 0) {
266 if (!PlayIntroNext) {
268 } else {
270 }
271 PlayIntroNext ^= 1;
272 return;
273 }
274 #endif
275 if (pressedButtons & (BUTTON_A | BUTTON_START)) {
279 bgm_set_song(0, SONG_FILE_SELECT, 0, 500, 8);
280 return;
281 }
282 break;
288 } else {
290 }
292 break;
297 }
298 if (startup_fade_screen_out(10) != 0) {
303 }
304 }
311 } else {
313 }
314 } else {
318 }
319 break;
320 case TITLE_STATE_EXIT:
323 break;
324 }
330 clear_npcs();
333 clear_entity_data(TRUE);
335 gOverrideFlags &= ~GLOBAL_OVERRIDES_DISABLE_DRAW_FRAME;
336 gOverrideFlags &= ~GLOBAL_OVERRIDES_DISABLE_RENDER_WORLD;
338
339 switch (TitleScreenNextState) {
340 case NEXT_STATE_INTRO:
343 break;
344 case NEXT_STATE_DEMO:
346 break;
349 gGameStatusPtr->mapID = 0xB; //TODO hardcoded map IDs
352 break;
353 }
354 return;
355 }
356
358 update_npcs();
360 }
361}
@ SONG_FILE_SELECT
Definition enums.h:387
@ AREA_KMR
Definition enums.h:2960
@ SOUND_FILE_MENU_IN
Definition enums.h:710
@ GAME_MODE_DEMO
Definition game_modes.h:22
@ GAME_MODE_FILE_SELECT
Definition game_modes.h:19
s16 TitleScreenNextState
s32 PlayIntroNext
@ NEXT_STATE_INTRO
@ NEXT_STATE_DEMO
@ NEXT_STATE_FILE_SELECT
BSS s16 TitleScreen_AppearDelay
@ TITLE_STATE_EXIT
@ TITLE_STATE_HOLD
@ TITLE_STATE_DISMISS
@ TITLE_STATE_BEGIN_DISMISS
@ TITLE_STATE_APPEAR

◆ state_drawUI_title_screen()

void state_drawUI_title_screen ( void )

Definition at line 363 of file state_title_screen.c.

363 {
364 switch (gGameStatusPtr->startupState) {
365 case TITLE_STATE_INIT:
367 PressStart_IsVisible = FALSE;
369 break;
370 case TITLE_STATE_HOLD:
373 }
375 break;
379 break;
380 }
381}
b32 PressStart_IsVisible
s32 PressStart_BlinkCounter
s32 PressStart_Alpha
void title_screen_draw_press_start(void)
@ TITLE_STATE_UNUSED

◆ state_init_enter_demo()

void state_init_enter_demo ( void )

Definition at line 21 of file state_map_transitions.c.

21 {
24}
BSS s16 gLoadedFromFileSelect
void init_enter_world_shared(void)

◆ state_step_enter_world()

void state_step_enter_world ( void )

Definition at line 46 of file state_map_transitions.c.

46 {
47 switch (gMapTransitionState) {
49 if (gMapTransitionStateTime != 0) {
51 break;
52 }
53
56
59 } else {
61 }
62
67 }
71 break;
77
78 if (gMapTransitionStateTime != 0) {
80 break;
81 }
83 gOverrideFlags &= ~GLOBAL_OVERRIDES_DISABLE_DRAW_FRAME;
85 }
86 break;
92
96 }
99 }
100 break;
101 }
102}
s16 update_enter_map_screen_overlay(s16 *progress)
void update_effects(void)
Definition effects.c:60
void load_map_by_IDs(s16 areaID, s16 mapID, s16 loadType)
Definition world.c:53
void update_player(void)
Definition 77480.c:625
@ GAME_MODE_WORLD
Definition game_modes.h:12
void update_encounters(void)
Definition npc.c:2269
@ ENTER_WORLD_FADE_IN
@ ENTER_WORLD_AWAIT_MAIN

◆ state_init_change_map()

void state_init_change_map ( void )

◆ state_step_change_map()

void state_step_change_map ( void )

Definition at line 132 of file state_map_transitions.c.

132 {
133 switch (gMapTransitionState) {
134 case CHANGE_MAP_INIT:
135 update_npcs();
139
142 }
143 break;
144 case CHANGE_MAP_DELAY:
146 nuContRmbForceStop();
149 break;
153 }
154
155 if (gMapTransitionStateTime != 0) {
157 } else {
162 nuContRmbForceStopEnd();
165 }
169 }
170 break;
173 update_npcs();
176
177 if (gMapTransitionStateTime != 0) {
180 gOverrideFlags &= ~GLOBAL_OVERRIDES_DISABLE_DRAW_FRAME;
182 }
183 break;
185 update_npcs();
189
193 }
196 }
197 break;
198 }
199}
@ CHANGE_MAP_FADE_IN
@ CHANGE_MAP_AWAIT_MAIN
@ CHANGE_MAP_DELAY
@ CHANGE_MAP_LOAD_MAP

◆ state_drawUI_change_map()

void state_drawUI_change_map ( void )

Definition at line 201 of file state_map_transitions.c.

◆ state_init_game_over()

void state_init_game_over ( void )

◆ state_step_game_over()

void state_step_game_over ( void )

Definition at line 221 of file state_map_transitions.c.

221 {
222 switch (gMapTransitionState) {
223 case GAME_OVER_INIT:
225 nuContRmbForceStop();
228 break;
230 if (gMapTransitionStateTime != 0) {
232 } else {
236 nuContRmbForceStopEnd();
238 }
239 break;
242 update_npcs();
244 gOverrideFlags &= ~GLOBAL_OVERRIDES_DISABLE_DRAW_FRAME;
246 break;
247 }
248 return;
251 if (gMapTransitionAlpha < 0) {
256 }
257 update_npcs();
261 break;
262 }
263
265}
@ GAME_OVER_LOAD_MAP
@ GAME_OVER_FADE_IN
@ GAME_OVER_AWAIT_MAIN

◆ state_drawUI_game_over()

void state_drawUI_game_over ( void )

Definition at line 267 of file state_map_transitions.c.

267 {
268}

◆ state_init_enter_world()

void state_init_enter_world ( void )

Definition at line 26 of file state_map_transitions.c.

26 {
30}
void set_map_transition_effect(ScreenTransition)

◆ state_drawUI_enter_world()

void state_drawUI_enter_world ( void )

Definition at line 104 of file state_map_transitions.c.

104 {
105 // startupState is being used as a timer here
106 if (gGameStatusPtr->startupState == 2) {
108 }
109}

◆ state_init_world()

void state_init_world ( void )

Definition at line 10 of file state_world.c.

10 {
12
13#ifdef DX_QUICK_LAUNCH_BATTLE
15 dx_debug_begin_battle_with_IDs(DX_QUICK_LAUNCH_BATTLE);
16 }
17#endif
18}
void state_world_draw_aux_ui(void)
Definition state_world.c:41

◆ state_step_world()

void state_step_world ( void )

Definition at line 20 of file state_world.c.

◆ state_drawUI_world()

void state_drawUI_world ( void )

Definition at line 35 of file state_world.c.

35 {
39}
void imgfx_update_cache(void)
Definition imgfx.c:332
void draw_encounter_ui(void)
Definition npc.c:2293

◆ state_init_battle()

void state_init_battle ( void )

Definition at line 32 of file state_battle.c.

32 {
33 D_800A0900 = 5;
34}
BSS s8 D_800A0900

◆ state_step_battle()

void state_step_battle ( void )

Definition at line 36 of file state_battle.c.

36 {
37 u32 currentBattleSelection;
38 u32 currentBattleIndex;
39
40 if (D_800A0900 == 5) {
41 if (nuGfxCfb[1] != nuGfxCfb_ptr) {
42 return;
43 }
44 D_800A0900--;
46 nuContRmbForceStop();
47 }
48
49 if (D_800A0900 >= 0) {
50 if (D_800A0900 > 0) {
51 D_800A0900--;
52 return;
53 }
54
55 D_800A0900 = -1;
56 nuGfxSetCfb(bFrameBuffers, 2);
57 nuContRmbForceStopEnd();
62
63#if !VERSION_IQUE
65#endif
67
69
70 currentBattleSelection = UNPACK_BTL_AREA(gCurrentBattleID);
71 currentBattleIndex = UNPACK_BTL_INDEX(gCurrentBattleID);
72
74 (currentBattleSelection == BTL_AREA_KKJ && currentBattleIndex == 0)) {
77 } else {
79 }
80
92 clear_npcs();
95 DMA_COPY_SEGMENT(battle_code);
100 gPlayerStatusPtr->animFlags &= ~PA_FLAG_PULSE_STONE_VISIBLE;
103 gOverrideFlags &= ~GLOBAL_OVERRIDES_DISABLE_DRAW_FRAME;
104
105 if (D_800A0900 >= 0) {
106 return;
107 }
108 }
109
111 btl_update();
112 update_npcs();
116}
@ CONTEXT_BATTLE
Definition enums.h:3529
@ PLAYER_SPRITES_PEACH_BATTLE
Definition enums.h:6351
@ PLAYER_SPRITES_MARIO_BATTLE
Definition enums.h:6350
void btl_update(void)
Definition 16C8E0.c:254
void load_battle_section(void)
Definition battle.c:112
void reset_status_bar(void)
Definition inventory.c:1682
void backup_map_collision_data(void)
Definition collision.c:80
void shim_battle_heap_create_obfuscated(void)
void btl_save_world_cameras(void)
Definition 16C8E0.c:1069
s32 get_time_freeze_mode(void)
Definition main_loop.c:390
void initialize_battle(void)
Definition 16C8E0.c:160
u16 ** nuGfxCfb
Definition main_loop.c:13
void func_8003B1A8(void)
Definition npc.c:1204
#define UNPACK_BTL_AREA(battleID)
Definition macros.h:152
#define UNPACK_BTL_INDEX(battleID)
Definition macros.h:153
@ BTL_AREA_KKJ
Definition battle.h:49
u16 * bFrameBuffers[]
BSS s32 D_800A0904
BSS s32 D_800A0908

◆ state_drawUI_battle()

void state_drawUI_battle ( void )

Definition at line 118 of file state_battle.c.

118 {
120 if (D_800A0900 < 0) {
121 btl_draw_ui();
122 }
123}
void btl_draw_ui(void)
Definition 16C8E0.c:486

◆ state_init_end_battle()

void state_init_end_battle ( void )

Definition at line 125 of file state_battle.c.

125 {
127 nuContRmbForceStop();
128 D_800A0900 = 5;
129}

◆ state_step_end_battle()

void state_step_end_battle ( void )

Definition at line 131 of file state_battle.c.

131 {
132 PlayerStatus* playerStatus = &gPlayerStatus;
133 PlayerData* playerData = &gPlayerData;
134 MapSettings* mapSettings;
135 MapConfig* mapConfig;
136
137 if (D_800A0900 >= 0) {
138 D_800A0900--;
139 if (D_800A0900 == 0) {
140 D_800A0900 = -1;
141 nuGfxSetCfb(bFrameBuffers, 3);
142 gOverrideFlags &= ~GLOBAL_OVERRIDES_DISABLE_DRAW_FRAME;
143 nuContRmbForceStopEnd();
145 mapSettings = get_current_map_settings();
152 gGameStatusPtr->peachFlags &= ~PEACH_FLAG_IS_PEACH;
167
170 playerStatus->animFlags = D_800A0904;
172 } else {
173 void* mapShape;
174 u32 sizeTemp;
175
178 mapShape = load_asset_by_name(wMapShapeName, &sizeTemp);
179 decode_yay0(mapShape, &gMapShapeData);
180 general_heap_free(mapShape);
183
184 if (mapConfig->dmaStart != NULL) {
185 dma_copy(mapConfig->dmaStart, mapConfig->dmaEnd, mapConfig->dmaDest);
186 }
187
188 load_map_bg(mapConfig->bgName);
189 if (mapSettings->background != NULL) {
190 set_background(mapSettings->background);
191 } else {
192 set_background_size(296, 200, 12, 20);
193 }
194
195 mdl_load_all_textures(mapSettings->modelTreeRoot, get_asset_offset(wMapTexName, &sizeTemp), sizeTemp);
198
199 playerStatus->animFlags = D_800A0904;
200 if (D_800A0908 != 0) {
202 }
204 }
205 }
206 }
207}
void init_item_entity_list(void)
void func_8005AF84(void)
Definition collision.c:105
void init_entity_models(void)
void init_entity_data(void)
Definition entity.c:840
void init_trigger_list(void)
Definition trigger.c:45
void mdl_calculate_model_sizes(void)
Definition model.c:2455
void mdl_load_all_textures(struct ModelNode *model, s32 romOffset, s32 size)
Definition model.c:2322
void init_script_list(void)
void load_map_script_lib(void)
Definition world.c:49
s32 battle_heap_create(void)
Definition heap.c:22
void restore_map_collision_data(void)
Definition collision.c:135
void btl_restore_world_cameras(void)
Definition 16C8E0.c:1085
s32 func_8002ACDC(void)
Definition heap.c:30
void init_sprite_shading_data(void)
void partner_init_after_battle(s32 arg0)
Definition partners.c:926
void init_hud_element_list(void)
void reset_animator_list(void)
Definition animator.c:252
void init_model_data(void)
Definition model.c:2431
void init_worker_list(void)
Definition worker.c:24
void npc_reload_all(void)
Definition npc.c:1207
void init_npc_list(void)
Points the current NPC list to the world or battle lists depending on game state.
Definition npc.c:77
char wMapShapeName[]
Definition world.c:27
AreaConfig gAreas[29]
Zero-terminated.
Definition world.c:868
char wMapTexName[]
Definition world.c:28
ShapeFile gMapShapeData
Definition heaps.c:16

◆ state_drawUI_end_battle()

void state_drawUI_end_battle ( void )

Definition at line 209 of file state_battle.c.

209 {
210}

◆ state_init_pause()

void state_init_pause ( void )

Definition at line 51 of file state_pause.c.

51 {
57}
@ WINDOW_GROUP_PAUSE
Definition enums.h:5324
BSS s16 StepPauseAlpha
Definition state_pause.c:44
BSS s8 StepPauseState
Definition state_pause.c:43

◆ state_step_pause()

void state_step_pause ( void )

Definition at line 61 of file state_pause.c.

61 {
62 switch (StepPauseState) {
63 case 0:
68 if (nuGfxCfb[1] == nuGfxCfb_ptr) {
72 gGameStatusPtr->backgroundFlags &= ~BACKGROUND_RENDER_STATE_MASK;
74
75 }
76 break;
77 case 2:
78 if (StepPauseDelay >= 0) {
79 if (StepPauseDelay != 0) {
81 }
82
83 if (StepPauseDelay == 0) {
84 StepPauseDelay = -1;
85 nuGfxSetCfb(pause_frameBuffers, 2);
92 nuContRmbForceStop();
101 hud_element_set_aux_cache(D_80200000, 0x38000); // TODO shiftability (what should this symbol be?)
106 clear_npcs();
107 clear_entity_data(FALSE);
112 nuPiReadRomOverlay(&PauseOverlaySegment);
113 pause_init();
114 gOverrideFlags &= ~GLOBAL_OVERRIDES_DISABLE_DRAW_FRAME;
115 }
116
117 if (StepPauseDelay >= 0) {
118 break;
119 }
120 }
121
122 if (StepPauseDelay >= -10) {
123 pause_handle_input(0, 0);
125 } else {
127 }
128 StepPauseAlpha = 0;
129 break;
130 }
131}
s16 savedBackgroundDarkness
@ BACKGROUND_RENDER_STATE_BEGIN_PAUSED
Definition enums.h:6286
void bgm_quiet_max_volume(void)
void pause_handle_input(s32 buttonsPressed, s32 buttonsHeld)
Definition pause_main.c:718
void pause_init(void)
Definition pause_main.c:605
s32 sfx_get_reverb_mode(void)
Definition sfx.c:357
NUPiOverlaySegment PauseOverlaySegment
Definition state_pause.c:30
BSS s8 StepPauseDelay
Definition state_pause.c:42
u16 * pause_frameBuffers[]
Definition state_pause.c:26
BSS s32 SavedReverbMode
Definition state_pause.c:45
Addr D_80200000

◆ state_drawUI_pause()

void state_drawUI_pause ( void )

Definition at line 133 of file state_pause.c.

133 {
134}

◆ state_init_unpause()

void state_init_unpause ( void )

Definition at line 136 of file state_pause.c.

136 {
137 if (StepPauseAlpha > 0) {
138 StepPauseState = 0;
139 } else {
140 StepPauseState = 1;
141 }
142 StepPauseDelay = 4;
143}

◆ state_step_unpause()

void state_step_unpause ( void )

Definition at line 145 of file state_pause.c.

145 {
146 MapSettings* mapSettings;
147 MapConfig* mapConfig;
148 void* mapShape;
149 u32 assetSize;
150
151 switch (StepPauseState) {
152 case 0:
153 case 1:
154 if (StepPauseDelay == 4) {
156 }
157
158 if (StepPauseDelay >= 0) {
159 if (StepPauseDelay != 0) {
161 }
162
163 if (StepPauseDelay == 0) {
164 StepPauseDelay = -1;
167 gOverrideFlags &= ~GLOBAL_OVERRIDES_DISABLE_DRAW_FRAME;
168 mapSettings = get_current_map_settings();
171 gGameStatusPtr->backgroundFlags &= ~BACKGROUND_RENDER_STATE_MASK;
174 nuContRmbForceStopEnd();
192 mapShape = load_asset_by_name(wMapShapeName, &assetSize);
193 decode_yay0(mapShape, &gMapShapeData);
194 general_heap_free(mapShape);
197
198 if (mapConfig->dmaStart != NULL) {
199 dma_copy(mapConfig->dmaStart, mapConfig->dmaEnd, mapConfig->dmaDest);
200 }
201
202 load_map_bg(mapConfig->bgName);
203 if (mapSettings->background != NULL) {
204 set_background(mapSettings->background);
205 } else {
206 set_background_size(296, 200, 12, 20);
207 }
208
215 StepPauseState = 3;
218
220 update_npcs();
223
224 StepPauseAlpha -= 20;
225 if (StepPauseAlpha < 0) {
226 StepPauseAlpha = 0;
227 }
228 }
229 }
230 break;
231 case 3:
233 update_npcs();
236
237 if (StepPauseAlpha == 0) {
238 StepPauseState = 4;
239 } else {
240 StepPauseAlpha -= 20;
241 if (StepPauseAlpha < 0) {
242 StepPauseAlpha = 0;
243 }
244 }
245 break;
246 case 4:
249 update_npcs();
254 break;
255 }
256}
void bgm_reset_max_volume(void)
void pause_cleanup(void)
Definition pause_main.c:796
void status_bar_respond_to_changes(void)
Definition inventory.c:1519
u8 ReflectWallPrevAlpha
Definition state_pause.c:48
u8 ReflectFloorPrevAlpha
Definition state_pause.c:49
ShapeFile gMapShapeData
Definition heaps.c:16

◆ state_drawUI_unpause()

void state_drawUI_unpause ( void )

Definition at line 258 of file state_pause.c.

258 {
259}

◆ state_init_file_select()

void state_init_file_select ( void )

Definition at line 48 of file state_file_select.c.

48 {
49 D_800A0931 = 0;
50 D_800A0932 = 0;
56 mdl_load_all_textures(NULL, 0, 0);
57
62 gCameras[CAM_DEFAULT].vfov = 25.0f;
63 set_cam_viewport(CAM_DEFAULT, 12, 28, 296, 184);
64
65 gCameras[CAM_DEFAULT].params.basic.skipRecalc = FALSE;
66 gCameras[CAM_DEFAULT].params.basic.pitch = 0;
67 gCameras[CAM_DEFAULT].params.basic.dist = 40;
68 gCameras[CAM_DEFAULT].params.basic.fovScale = 100;
69
73
77
81
83
88
90}
@ GLOBAL_OVERRIDES_WINDOWS_OVER_CURTAINS
Definition enums.h:4334
BSS s8 D_800A0931

◆ state_step_file_select()

void state_step_file_select ( void )

Definition at line 92 of file state_file_select.c.

92 {
93 switch (D_800A0931) {
94 case 0:
95 D_800A0931 = 1;
96 break;
97 case 1:
99 D_800A0930 = 1;
100 D_800A0931 = 2;
101 break;
102 case 2:
103 if (D_800A0930 >= 0) {
104 D_800A0930--;
105 if (D_800A0930 == 0) {
106 D_800A0930 = -1;
108 nuPiReadRomOverlay(&D_8007798C);
109 filemenu_init(0);
110 }
111 }
112
113 if (D_800A0930 < 0) {
115 }
116 break;
117 }
118}
@ WINDOW_GROUP_FILES
Definition enums.h:5325
void filemenu_update(void)
void filemenu_init(s32 mode)
NUPiOverlaySegment D_8007798C
BSS s8 D_800A0930

◆ state_drawUI_file_select()

void state_drawUI_file_select ( void )

Definition at line 120 of file state_file_select.c.

120 {
121}

◆ state_init_exit_file_select()

void state_init_exit_file_select ( void )

Definition at line 123 of file state_file_select.c.

123 {
124 D_800A0931 = 0;
125 D_800A0932 = 0;
126 D_800A0930 = 0;
127
128 if (filemenu_get_exit_mode() == 0) {
130 } else {
132 gOverrideFlags &= ~GLOBAL_OVERRIDES_WINDOWS_OVER_CURTAINS;
133 bgm_set_song(0, -1, 0, 1000, 8);
134 }
135 gOverrideFlags &= ~GLOBAL_OVERRIDES_40;
136}
s32 filemenu_get_exit_mode(void)

◆ state_step_exit_file_select()

void state_step_exit_file_select ( void )

Definition at line 138 of file state_file_select.c.

138 {
139 s32 exitMode = filemenu_get_exit_mode();
140 s32 flagSum;
141 s32 i;
142
143 switch (D_800A0931) {
144 case 0:
145 flagSum = 0;
146
147 for (i = 44; i < ARRAY_COUNT(gWindows); i++) {
148 Window* window = &gWindows[i];
149
150 if (window->parent == WIN_FILES_MAIN || window->parent == WIN_NONE) {
151 flagSum += window->flags & WINDOW_FLAG_INITIAL_ANIMATION;
152 }
153 }
154
155 if (flagSum == 0) {
156 D_800A0931 = 1;
157 }
158 break;
159 case 1:
160 if (exitMode == 0 || update_exit_map_screen_overlay(&D_800A0932) != 0) {
161 D_800A0931 = 2;
162 }
163 break;
164 case 2:
167 D_800A0931 = 3;
168 case 3:
170 if (exitMode == 0) {
172 gOverrideFlags &= ~GLOBAL_OVERRIDES_WINDOWS_OVER_CURTAINS;
173 } else {
174 D_800A0930 = 10;
175 D_800A0931 = 4;
176 }
177 break;
178 case 4:
179 if (D_800A0930 > 0) {
180 D_800A0930--;
181 } else {
183 D_800A0930 = 10;
184 D_800A0931 = 5;
185 }
186 break;
187 case 5:
188 if (D_800A0930 > 0) {
189 D_800A0930--;
190 } else {
191 D_800A0931 = 6;
192 }
193 break;
194 case 6:
196 break;
197 }
198}
void filemenu_cleanup(void)

◆ state_drawUI_exit_file_select()

void state_drawUI_exit_file_select ( void )

Definition at line 200 of file state_file_select.c.

200 {
201}

◆ state_init_intro()

void state_init_intro ( void )

Definition at line 26 of file state_intro.c.

26 {
28
31
32 switch (gGameStatusPtr->introPart) {
33 case INTRO_PART_0:
35
40 IntroFadeColorR = 208;
41 IntroFadeColorG = 208;
42 IntroFadeColorB = 208;
43 D_800A0964 = 0;
44
45 // hos_05 (Star Sanctuary)
47 gGameStatusPtr->mapID = 5; //TODO hard-coded map ID
49 break;
50 case INTRO_PART_1:
52
60 D_800A0964 = 0;
61
62 // hos_04 (Outside the Sanctuary)
64 gGameStatusPtr->mapID = 4; //TODO hard-coded map ID
66 break;
67 default:
70
72
75
77 if (IntroMessageIdx >= 4) {
78 // both hos_04 and hos_05 have an IntroMessage array of length 4
80 }
81
82 D_800A0964 = 3;
83 break;
84 }
85
88
90}
@ INTRO_PART_1
Definition enums.h:3552
@ AREA_HOS
Definition enums.h:2965
BSS s16 IntroFadeColorB
Definition state_intro.c:22
BSS s16 IntroOverlayDelta
Definition state_intro.c:19
BSS s16 IntroFadeColorG
Definition state_intro.c:21
BSS s16 IntroOverlayAlpha
Definition state_intro.c:17
BSS s16 IntroFadeColorR
Definition state_intro.c:20
BSS s32 IntroOverlayType
Definition state_intro.c:23
@ INTRO_INIT
Definition state_intro.c:8
BSS s32 D_800A0964
Definition state_intro.c:24
BSS s16 IntroFrontFadeAlpha
Definition state_intro.c:18
u8 IntroMessageIdx

Referenced by state_step_intro().

◆ state_step_intro()

void state_step_intro ( void )

Definition at line 92 of file state_intro.c.

92 {
93 PlayerData* playerData = &gPlayerData;
94 u32 pressedButtons = gGameStatusPtr->pressedButtons[0];
95 s32 i;
96
97 #if DX_SKIP_STORY
98 // immediately quit out of the state when skipping story
99 pressedButtons = BUTTON_START;
100 #endif
101
103 if (D_800A0964 == 0 && pressedButtons & (BUTTON_A | BUTTON_B | BUTTON_START | BUTTON_Z)) {
104 D_800A0964 = 1;
105 }
106
110 {
113 return;
114 }
115
119 {
122 return;
123 }
124 }
125
126 switch (gGameStatusPtr->startupState) {
127 case INTRO_INIT:
135 }
136 } else {
138 if (IntroOverlayAlpha >= 255) {
139 IntroOverlayAlpha = 255;
142 }
143 }
144 break;
148 // this condition is always true, likely leftover from an earlier version
151 }
152 break;
153 case INTRO_ENABLE_DRAW_FRAME: // unused
155 if (IntroEnableDrawFrameDelay <= 0) {
156 gOverrideFlags &= ~GLOBAL_OVERRIDES_DISABLE_DRAW_FRAME;
158 }
159 break;
160 case INTRO_LOAD_MAP:
166
182 clear_entity_data(FALSE);
185 clear_npcs();
194 return;
195 }
196
197 playerData->curHP = 10;
198 playerData->curMaxHP = 10;
199 playerData->hardMaxHP = 10;
200 playerData->curFP = 5;
201 playerData->curMaxFP = 5;
202 playerData->hardMaxFP = 5;
203 playerData->maxBP = 2;
204 playerData->bootsLevel = 0;
205 playerData->hammerLevel = -1;
206 playerData->level = 0;
207
208 for (i = 0; i < ARRAY_COUNT(playerData->partners); i++) {
209 playerData->partners[i].enabled = FALSE;
210 }
211
212 playerData->curPartner = PARTNER_NONE;
216 break;
217 case INTRO_AWAIT_MAIN:
220 }
222 gOverrideFlags &= ~GLOBAL_OVERRIDES_DISABLE_DRAW_FRAME;
223 gCameras[CAM_DEFAULT].flags &= ~CAMERA_FLAG_DISABLED;
224 gOverrideFlags &= ~GLOBAL_OVERRIDES_DISABLE_RENDER_WORLD;
227 update_npcs();
233 break;
234 }
235 return;
236 case INTRO_FADE_IN:
239 update_npcs();
240 if (IntroOverlayAlpha == 0) {
243 } else {
245 if (IntroOverlayAlpha < 0) {
247 }
248 }
249 break;
250 }
251
255}
@ OVERLAY_INTRO_2
Definition enums.h:2403
@ OVERLAY_INTRO_1
Definition enums.h:2402
@ INTRO_PART_100
Definition enums.h:3554
BSS s32 IntroEnableDrawFrameDelay
Definition state_intro.c:16
void state_init_intro(void)
Definition state_intro.c:26
@ INTRO_ENABLE_DRAW_FRAME
Definition state_intro.c:13
@ INTRO_DISABLE_DRAW_FRAME
Definition state_intro.c:9
@ INTRO_AWAIT_MAIN
Definition state_intro.c:11
@ INTRO_LOAD_MAP
Definition state_intro.c:10
@ INTRO_FADE_IN
Definition state_intro.c:12

◆ state_drawUI_intro()

void state_drawUI_intro ( void )

Definition at line 257 of file state_intro.c.

257 {
258}

◆ state_init_demo()

void state_init_demo ( void )

◆ state_step_demo()

void state_step_demo ( void )

Definition at line 161 of file state_demo.c.

161 {
162 PlayerData* playerData = &gPlayerData;
164 s16 mode = demoSceneData->sceneType;
165 s16 mapID;
166 s16 areaID;
167
169 mode = DEMO_SCENE_DONE;
170 }
172 mode = DEMO_SCENE_EXIT;
173 }
174
175 switch (mode) {
176 case DEMO_SCENE_DONE:
183 break;
184 case DEMO_SCENE_EXIT:
185 if (gGameStatusPtr->startupState != 0) {
187 }
188
189 if (gGameStatusPtr->startupState == 0) {
198 gOverrideFlags &= ~GLOBAL_OVERRIDES_DISABLE_DRAW_FRAME;
213 clear_entity_data(FALSE);
216 clear_npcs();
225 }
226 return;
227 case DEMO_SCENE_WORLD:
228 get_map_IDs_by_name_checked(demoSceneData->mapName, &areaID, &mapID);
229 gGameStatusPtr->areaID = areaID;
230 gGameStatusPtr->mapID = mapID;
231 gGameStatusPtr->entryID = demoSceneData->index;
233 playerData->curPartner = demoSceneData->partnerID;
234 set_cam_viewport(CAM_DEFAULT, 29, 20, -262, 177);
235 evt_set_variable(NULL, GB_StoryProgress, demoSceneData->storyProgress);
236
237 if (gGameStatusPtr->nextDemoScene == 0) {
239 } else {
241 }
242
244 break;
245 case DEMO_SCENE_PEACH:
246 get_map_IDs_by_name_checked(demoSceneData->mapName, &areaID, &mapID);
247 gGameStatusPtr->areaID = areaID;
248 gGameStatusPtr->mapID = mapID;
249 gGameStatusPtr->entryID = demoSceneData->index;
251 playerData->curPartner = demoSceneData->partnerID;
252 set_cam_viewport(CAM_DEFAULT, 29, 20, -262, 177);
253 evt_set_variable(NULL, GB_StoryProgress, demoSceneData->storyProgress);
254
255 if (gGameStatusPtr->nextDemoScene == 0) {
257 } else {
259 }
260
262 break;
264 load_demo_battle(demoSceneData->index);
265 break;
266 }
267
271 }
272}
void enable_sounds(void)
Definition 30450.c:861
void load_demo_battle(u32 index)
Definition battle.c:191
@ DEMO_STATE_4
Definition enums.h:3537
@ DEMO_STATE_DONE
Definition enums.h:3538
@ GAME_MODE_ENTER_DEMO_WORLD
Definition game_modes.h:10
@ GB_StoryProgress
DemoSceneData DemoScenes[]
Definition state_demo.c:25
char * mapName
Definition state_demo.c:14
@ DEMO_SCENE_PEACH
Definition state_demo.c:19
@ DEMO_SCENE_BATTLE
Definition state_demo.c:20
@ DEMO_SCENE_EXIT
Definition state_demo.c:22
@ DEMO_SCENE_WORLD
Definition state_demo.c:18
@ DEMO_SCENE_DONE
Definition state_demo.c:21

◆ state_drawUI_demo()

void state_drawUI_demo ( void )

Definition at line 274 of file state_demo.c.

274 {
275
276}

◆ btl_set_player_idle_anims()

void btl_set_player_idle_anims ( void )

Definition at line 40 of file player_events.c.

40 {
41 BattleStatus* battleStatus = &gBattleStatus;
42 ActorPart* actorPart = &battleStatus->playerActor->partsTable[0];
43
44 if (battleStatus->flags2 & BS_FLAGS2_PEACH_BATTLE) {
46 set_actor_anim(0, 0, ANIM_Peach1_Walk);
47 } else if (!battleStatus->outtaSightActive) {
49 }
50}

Referenced by btl_state_update_end_turn().

◆ shim_create_audio_system_obfuscated()

void shim_create_audio_system_obfuscated ( void )

Definition at line 9 of file obfuscation_shims.c.

Referenced by boot_main().

◆ shim_load_engine_data_obfuscated()

void shim_load_engine_data_obfuscated ( void )

Definition at line 14 of file obfuscation_shims.c.

Referenced by boot_main().

◆ shim_general_heap_create_obfuscated()

void shim_general_heap_create_obfuscated ( void )

Definition at line 19 of file obfuscation_shims.c.

Referenced by load_map_by_IDs().

◆ shim_battle_heap_create_obfuscated()

void shim_battle_heap_create_obfuscated ( void )

Definition at line 24 of file obfuscation_shims.c.

Referenced by state_step_battle().

◆ appendGfx_ispy_icon()

void appendGfx_ispy_icon ( void )

Definition at line 34 of file i_spy.c.

34 {
35 Matrix4f matrix1;
36 Matrix4f matrix2;
37 ImgFXTexture ifxImg;
38 s32 flashPhase;
39
42 guRotateF(matrix2, -gCameras[gCurrentCameraID].curYaw, 0.0f, 1.0f, 0.0f);
43 guMtxCatF(matrix1, matrix2, matrix1);
45 guMtxCatF(matrix1, matrix2, matrix2);
47
49 gSPDisplayList(gMainGfxPos++, ispy_icon_gfx);
50
51 if (ISpyPtr->time < 47) {
53 }
54
55 flashPhase = ISpyPtr->flashCount;
56 flashPhase = flashPhase % 12;
57 switch (flashPhase) {
58 case 0:
59 case 1:
60 case 2:
61 case 3:
62 ifxImg.palette = ispy_icon_1_pal;
63 break;
64 case 4:
65 case 5:
66 case 6:
67 case 7:
68 ifxImg.palette = ispy_icon_2_pal;
69 break;
70 case 8:
71 case 9:
72 case 10:
73 case 11:
74 ifxImg.palette = ispy_icon_3_pal;
75 break;
76 }
77 imgfx_update(0, IMGFX_SET_ALPHA, 255, 255, 255, ISpyPtr->alpha, 0);
78
79 ifxImg.raster = ispy_icon_img;
80 ifxImg.width = ispy_icon_img_width;
81 ifxImg.height = ispy_icon_img_height;
82 ifxImg.xOffset = -28;
83 ifxImg.yOffset = 46;
84 ifxImg.alpha = 255;
85
86 imgfx_appendGfx_component(0, &ifxImg, 0, matrix2);
87 gSPPopMatrix(gMainGfxPos++, 0);
88 }
89}
@ PA_FLAG_ISPY_VISIBLE
The I Spy icon is being shown.
Definition enums.h:3099
s32 imgfx_appendGfx_component(s32, ImgFXTexture *, u32, Matrix4f)
Definition imgfx.c:703
void imgfx_update(u32, ImgFXType, s32, s32, s32, s32, s32)
Definition imgfx.c:486
Vec3f pos
Definition i_spy.c:5
ISpyNotification * ISpyPtr
Definition i_spy.c:30

Referenced by render_ispy_icon().

◆ interact_inspect_setup()

void interact_inspect_setup ( void )

Definition at line 43 of file inspect_icon.c.

43 {
44 PlayerStatus* playerStatus = &gPlayerStatus;
45 f32 new_var;
46
47 if (playerStatus->animFlags & PA_FLAG_INTERACT_PROMPT_AVAILABLE) {
49 D_8010C950 = -1;
50 InspectIconPtr->pos.x = playerStatus->pos.x;
51 InspectIconPtr->pos.y = playerStatus->pos.y + playerStatus->colliderHeight +
52 (!(playerStatus->animFlags & PA_FLAG_USING_PEACH_PHYSICS) ? 8.0f : 2.0f);
53 InspectIconPtr->pos.z = playerStatus->pos.z;
54 InspectIconPtr->scale = 0.4f;
59 InspectIconPtr->alpha = 255;
60 }
61}
void interact_inspect_update(void)
InspectIconData * InspectIconPtr
@ INSPECT_ICON_APPEAR
s32 D_8010C950
Definition 77480.c:37
void(* InteractNotificationCallback)(void)
Definition 77480.c:36

Referenced by check_for_interactables().

◆ interact_speech_setup()

void interact_speech_setup ( void )

Definition at line 25 of file speech_bubble.c.

25 {
26 PlayerStatus* playerStatus = &gPlayerStatus;
27 SpeechBubbleData* temp;
28 Npc* npc;
29
31 npc = playerStatus->encounteredNPC;
34 SpeechBubblePtr->pos.x = npc->pos.x;
35 SpeechBubblePtr->pos.z = npc->pos.z;
38 SpeechBubblePtr->scale = 0.1f;
41 temp = SpeechBubblePtr;
42 temp->state = 0;
43 temp->scale = 0.4f;
46}
void interact_speech_update(void)
SpeechBubbleData * SpeechBubblePtr
void(* TalkNotificationCallback)(void)
Definition 77480.c:35

Referenced by check_for_conversation_prompt().

◆ pulse_stone_notification_setup()

void pulse_stone_notification_setup ( void )

Definition at line 71 of file pulse_stone.c.

71 {
72 PlayerStatus* playerStatus = &gPlayerStatus;
73
75 PulseStonePtr->pos.x = playerStatus->pos.x;
76 PulseStonePtr->pos.y = playerStatus->pos.y + playerStatus->colliderHeight + 8.0f;
77 PulseStonePtr->pos.z = playerStatus->pos.z;
80}
@ PA_FLAG_PULSE_STONE_VISIBLE
The pulse stone icon is being shown.
Definition enums.h:3097
void pulse_stone_notification_update(void)
PulseStoneData * PulseStonePtr
Definition pulse_stone.c:27
void(* PulseStoneNotificationCallback)(void)
Definition 77480.c:34

Referenced by check_for_pulse_stone().

◆ appendGfx_speech_bubble()

void appendGfx_speech_bubble ( void )

Definition at line 48 of file speech_bubble.c.

48 {
49 ImgFXTexture ifxImg;
50 Matrix4f mtxTemp, mtxTransform;
51
54 guRotateF(mtxTransform, SpeechBubblePtr->yaw - gCameras[gCurrentCameraID].curYaw, 0.0f, 1.0f, 0.0f);
55 guMtxCatF(mtxTemp, mtxTransform, mtxTemp);
57 guMtxCatF(mtxTemp, mtxTransform, mtxTransform);
59
61 G_MTX_PUSH | G_MTX_LOAD | G_MTX_MODELVIEW);
62 gSPDisplayList(gMainGfxPos++, &speech_bubble_gfx);
63
64 ifxImg.raster = speech_bubble_img;
65 ifxImg.palette = speech_bubble_pal;
66 ifxImg.width = speech_bubble_img_width;
67 ifxImg.height = speech_bubble_img_height;
68 ifxImg.xOffset = -16;
69 ifxImg.yOffset = 26;
70 ifxImg.alpha = 255;
74 imgfx_appendGfx_component(0, &ifxImg, IMGFX_FLAG_40, mtxTransform);
75
76 gSPPopMatrix(gMainGfxPos++, G_MTX_MODELVIEW);
77 }
78}
@ IMGFX_SET_COLOR
Definition enums.h:5122
@ IMGFX_FLAG_40
Definition enums.h:5098
@ IMGFX_FLAG_400
Definition enums.h:5102

Referenced by render_conversation_prompt().

◆ appendGfx_pulse_stone_icon()

void appendGfx_pulse_stone_icon ( void )

Definition at line 82 of file pulse_stone.c.

82 {
83 PlayerStatus* playerStatus = &gPlayerStatus;
84 Matrix4f sp18, sp58;
85 ImgFXTexture ifxImg;
86 s32 pingDelay;
87 s32 dx, dy;
88
89 if (playerStatus->animFlags & PA_FLAG_PULSE_STONE_VISIBLE) {
91 guRotateF(sp58, -gCameras[gCurrentCameraID].curYaw, 0.0f, 1.0f, 0.0f);
92 guMtxCatF(sp18, sp58, sp18);
94 guMtxCatF(sp18, sp58, sp58);
96
98 G_MTX_PUSH | G_MTX_LOAD | G_MTX_MODELVIEW);
99 gSPDisplayList(gMainGfxPos++, pulse_stone_icon_gfx);
100
101 dx = abs((gGameStatusPtr->mapID % 7) - 2);
102 dy = gGameStatusPtr->mapID / 7;
103
104 switch (dx + dy) {
105 case 0:
106 pingDelay = 4;
107 break;
108 case 1:
109 pingDelay = 8;
110 break;
111 case 2:
112 pingDelay = 16;
113 break;
114 case 3:
115 pingDelay = 32;
116 break;
117 case 4:
118 pingDelay = 64;
119 break;
120 case 5:
121 pingDelay = 128;
122 break;
123 default:
124 pingDelay = -1;
126 break;
127 }
128
129 ifxImg.palette = pulse_stone_icon_1_pal;
130 if (pingDelay >= 0) {
132 if (PulseStonePtr->pingTime >= pingDelay + 2) {
135 }
136 if (PulseStonePtr->pingTime < 2) {
137 ifxImg.palette = pulse_stone_icon_2_pal;
138 } else {
139 ifxImg.palette = pulse_stone_icon_1_pal;
140 }
141 }
142
143 ifxImg.raster = pulse_stone_icon_img;
144 ifxImg.width = pulse_stone_icon_img_width;
145 ifxImg.height = pulse_stone_icon_img_height;
146 ifxImg.xOffset = -28;
147 ifxImg.yOffset = 46;
148 ifxImg.alpha = 255;
149 imgfx_appendGfx_component(0, &ifxImg, 0, sp58);
150 gSPPopMatrix(gMainGfxPos++, G_MTX_MODELVIEW);
151 }
152}
@ SOUND_PULSE_STONE
Definition enums.h:646

Referenced by render_pulse_stone_icon().

◆ ispy_notification_setup()

void ispy_notification_setup ( void )

Definition at line 91 of file i_spy.c.

91 {
92 mem_clear(ISpyPtr, sizeof(*ISpyPtr));
93
97
98 ISpyPtr->alpha = 255;
99
102}
void ispy_notification_update(void)
Definition i_spy.c:104
void(* ISpyNotificationCallback)(void)
Definition 77480.c:33

Referenced by check_for_ispy().

◆ initialize_curtains()

void initialize_curtains ( void )

Definition at line 212 of file curtains.c.

212 {
213 gCurtainDrawCallback = NULL;
214 gCurtainScale = 2.0f;
215 gCurtainScaleGoal = 2.0f;
216 gCurtainFade = 0.0f;
217 gCurtainFadeGoal = 0.0f;
218}

Referenced by load_engine_data(), and state_step_startup().

◆ update_curtains()

void update_curtains ( void )

Definition at line 220 of file curtains.c.

220 {
221}

Referenced by step_game_loop().

◆ set_curtain_scale_goal()

void set_curtain_scale_goal ( f32 scale)

◆ set_curtain_scale()

void set_curtain_scale ( f32 scale)

Definition at line 289 of file curtains.c.

289 {
290 gCurtainScaleGoal = scale;
291 gCurtainScale = scale;
292}

Referenced by state_step_logos(), state_step_startup(), and state_step_title_screen().

◆ set_curtain_draw_callback()

void set_curtain_draw_callback ( void(*)(void) callback)

◆ set_curtain_fade_goal()

void set_curtain_fade_goal ( f32 fade)

Definition at line 298 of file curtains.c.

298 {
299 gCurtainFadeGoal = fade;
300}

Referenced by state_init_intro(), state_step_intro(), and state_step_logos().

◆ set_curtain_fade()

void set_curtain_fade ( f32 fade)

Definition at line 302 of file curtains.c.

302 {
303 gCurtainFadeGoal = fade;
304 gCurtainFade = fade;
305}

Referenced by state_step_logos(), state_step_startup(), and state_step_title_screen().

◆ crash_screen_init()

void crash_screen_init ( void )

Definition at line 455 of file crash_screen.c.

455 {
457 gCrashScreen.height = 16;
458 gCrashScreen.frameBuf = (u16*)((osMemSize | 0xA0000000) - ((SCREEN_WIDTH * SCREEN_HEIGHT) * 2));
459 osCreateMesgQueue(&gCrashScreen.queue, &gCrashScreen.mesg, 1);
460 osCreateThread(&gCrashScreen.thread, 2, crash_screen_thread_entry, NULL,
461 gCrashScreen.stack + sizeof(gCrashScreen.stack), 0x80);
462 osStartThread(&gCrashScreen.thread);
463
464 // gCrashScreencharToGlyph is hard to modify, so we'll just do it here
465 u8 chars[] =
466 "_[]<>"
467 "|{};,"
468 "\"#$&'"
469 "/=@\\`"
470 "abcde"
471 "fghij"
472 "klmno"
473 "pqrst"
474 "uvwxy"
475 "z";
476 s32 i;
477 for (i = 0; i < ARRAY_COUNT(chars); i++) {
478 gCrashScreencharToGlyph[chars[i]] = GLYPH(0, 9) + i;
479 }
480}
char stack[0x800]
OSThread thread
BSS CrashScreen gCrashScreen
void crash_screen_thread_entry(void *unused)
#define GLYPH(x, y)
OSMesgQueue queue
u8 gCrashScreencharToGlyph[128]

Referenced by boot_main().

◆ crash_screen_set_draw_info()

void crash_screen_set_draw_info ( u16 * frameBufPtr,
s16 width,
s16 height )

Definition at line 449 of file crash_screen.c.

449 {
450 gCrashScreen.frameBuf = (u16*)((u32)frameBufPtr | 0xA0000000);
451 gCrashScreen.width = width;
452 gCrashScreen.height = height;
453}

Referenced by gfx_draw_frame().

◆ basic_ai_wander_init()

void basic_ai_wander_init ( Evt * script,
MobileAISettings * npcAISettings,
EnemyDetectVolume * territory )

Definition at line 567 of file 23680.c.

567 {
568 Enemy* enemy = script->owner1.enemy;
569 Npc* npc = get_npc_unsafe(enemy->npcID);
570
571 // chose a random direction and move time
572 npc->duration = (npcAISettings->moveTime / 2) + rand_int((npcAISettings->moveTime / 2) + 1);
573 npc->yaw = clamp_angle(npc->yaw + rand_int(60) - 30.0f);
575 script->functionTemp[1] = 0;
576
577 if (enemy->territory->wander.moveSpeedOverride < 0) {
578 npc->moveSpeed = npcAISettings->moveSpeed;
579 } else {
580 npc->moveSpeed = enemy->territory->wander.moveSpeedOverride / 32767.0;
581 }
582
583 enemy->aiFlags &= ~AI_FLAG_NEEDS_HEADING;
584 enemy->aiFlags &= ~AI_FLAG_OUTSIDE_TERRITORY;
585 script->AI_TEMP_STATE = AI_STATE_WANDER;
586}
@ ENEMY_ANIM_INDEX_WALK
Definition enums.h:3427
@ AI_STATE_WANDER
Definition enums.h:4581
s32 moveTime
Definition npc.h:94
f32 moveSpeed
Definition npc.h:93
s32 moveSpeedOverride
Definition npc.h:213
u32 aiFlags
Definition npc.h:332
EnemyTerritoryWander wander
Definition npc.h:232
EnemyTerritory * territory
Definition npc.h:342
f32 moveSpeed
s16 duration

Referenced by HoppingAI_HopInit(), and StoneChompAI_HopInit().

◆ basic_ai_wander()

void basic_ai_wander ( Evt * script,
MobileAISettings * npcAISettings,
EnemyDetectVolume * territory )

Definition at line 588 of file 23680.c.

588 {
589 Enemy* enemy = script->owner1.enemy;
590 Npc* npc = get_npc_unsafe(enemy->npcID);
591 s32 stillWithinTerritory = FALSE;
592 f32 x, y, z;
593 EffectInstance* sp34;
594 f32 yaw;
595
596 // search for the player
597 if (aiSettings->playerSearchInterval >= 0) {
598 if (script->functionTemp[1] <= 0) {
599 script->functionTemp[1] = aiSettings->playerSearchInterval;
600 if (basic_ai_check_player_dist(territory, enemy, aiSettings->alertRadius, aiSettings->alertOffsetDist, 0)) {
601 x = npc->pos.x;
602 y = npc->pos.y;
603 z = npc->pos.z;
604 yaw = atan2(npc->pos.x, npc->pos.z, gPlayerStatusPtr->pos.x, gPlayerStatusPtr->pos.z);
605 if (!npc_test_move_simple_with_slipping(npc->collisionChannel, &x, &y, &z, aiSettings->chaseSpeed, yaw, npc->collisionHeight, npc->collisionDiameter)) {
606 npc->yaw = yaw;
608 fx_emote(EMOTE_EXCLAMATION, npc, 0, npc->collisionHeight, 1.0f, 2.0f, -20.0f, 15, &sp34);
609 enemy->aiFlags &= ~AI_FLAG_NEEDS_HEADING;
610 enemy->aiFlags &= ~AI_FLAG_OUTSIDE_TERRITORY;
611
613 script->AI_TEMP_STATE = AI_STATE_ALERT_INIT;
614 } else {
615 script->AI_TEMP_STATE = AI_STATE_CHASE_INIT;
616 }
617 return;
618 }
619 }
620 }
621 script->functionTemp[1]--;
622 }
623
624 // check if we've wandered beyond the boundary of the territory
626 enemy->territory->wander.centerPos.x,
627 enemy->territory->wander.centerPos.z,
628 npc->pos.x,
629 npc->pos.z,
632 && npc->moveSpeed < dist2D(enemy->territory->wander.centerPos.x, enemy->territory->wander.centerPos.z, npc->pos.x, npc->pos.z)
633 ) {
634 if (!(enemy->aiFlags & AI_FLAG_OUTSIDE_TERRITORY)) {
636 }
637
638 if (enemy->aiFlags & AI_FLAG_NEEDS_HEADING) {
639 npc->yaw = clamp_angle(atan2(npc->pos.x, npc->pos.z, enemy->territory->wander.centerPos.x, enemy->territory->wander.centerPos.z));
640 enemy->aiFlags &= ~AI_FLAG_NEEDS_HEADING;
641 }
642
643 // if current heading is deflected by a wall, recalculate yaw to continue pursuing centerPos
644 x = npc->pos.x;
645 y = npc->pos.y;
646 z = npc->pos.z;
647 if (npc_test_move_simple_with_slipping(npc->collisionChannel, &x, &y, &z, 2.0 * npc->moveSpeed, npc->yaw, npc->collisionHeight, npc->collisionDiameter)) {
648 yaw = clamp_angle(atan2(npc->pos.x, npc->pos.z, enemy->territory->wander.centerPos.x, enemy->territory->wander.centerPos.z));
649 enemy->aiFlags &= ~AI_FLAG_NEEDS_HEADING;
650 ai_check_fwd_collisions(npc, 5.0f, &yaw, NULL, NULL, NULL);
651 npc->yaw = yaw;
652 }
653 stillWithinTerritory = TRUE;
654 } else if (enemy->aiFlags & AI_FLAG_OUTSIDE_TERRITORY) {
655 enemy->aiFlags &= ~AI_FLAG_OUTSIDE_TERRITORY;
656 enemy->aiFlags &= ~AI_FLAG_NEEDS_HEADING;
657 }
658
659 // perform the motion
660 if (enemy->territory->wander.wanderSize.x | enemy->territory->wander.wanderSize.z | stillWithinTerritory) {
661 if (!npc->turnAroundYawAdjustment) {
662 npc_move_heading(npc, npc->moveSpeed, npc->yaw);
663 } else {
664 return;
665 }
666 }
667
668 // decide to loiter or continue wandering
669 if (aiSettings->moveTime > 0) {
670 npc->duration--;
671 if (npc->duration <= 0) {
672 script->AI_TEMP_STATE = AI_STATE_LOITER_INIT;
673 script->functionTemp[1] = rand_int(1000) % 3 + 2;
674 if (aiSettings->unk_AI_2C <= 0 || aiSettings->waitTime <= 0) {
675 script->AI_TEMP_STATE = AI_STATE_WANDER_INIT;
676 }
677 }
678 }
679}
void ai_enemy_play_sound(Npc *npc, s32 soundID, s32 upperSoundFlags)
Definition 23680.c:543
b32 is_point_outside_territory(s32 shape, f32 centerX, f32 centerZ, f32 pointX, f32 pointZ, f32 sizeX, f32 sizeZ)
Definition 23680.c:412
b32 basic_ai_check_player_dist(EnemyDetectVolume *territory, Enemy *enemy, f32 radius, f32 fwdPosOffset, s8 useWorldYaw)
Definition 23680.c:429
@ EMOTE_EXCLAMATION
Definition enums.h:495
@ AI_FLAG_NEEDS_HEADING
Definition enums.h:4574
@ AI_FLAG_OUTSIDE_TERRITORY
Definition enums.h:4573
@ AI_STATE_WANDER_INIT
Definition enums.h:4580
@ AI_STATE_LOITER_INIT
Definition enums.h:4586
@ AI_STATE_CHASE_INIT
Definition enums.h:4591
@ AI_STATE_ALERT_INIT
Definition enums.h:4589
@ SOUND_AI_ALERT_A
Definition enums.h:1078
@ AI_ACTION_JUMP_WHEN_SEE_PLAYER
Definition enums.h:4611
@ SOUND_PARAM_MORE_QUIET
Definition enums.h:1746
b32 ai_check_fwd_collisions(Npc *npc, f32 time, f32 *outYaw, f32 *outDistFwd, f32 *outDistCW, f32 *outDistCCW)
Definition 25AF0.c:22
b32 npc_test_move_simple_with_slipping(s32, f32 *, f32 *, f32 *, f32, f32, f32, f32)
VecXZi wanderSize
Definition npc.h:212
enum TerritoryShape wanderShape
Definition npc.h:214
void npc_move_heading(Npc *npc, f32 speed, f32 yaw)
Definition npc.c:985
s16 turnAroundYawAdjustment

◆ basic_ai_loiter()

void basic_ai_loiter ( Evt * script,
MobileAISettings * npcAISettings,
EnemyDetectVolume * territory )

Definition at line 691 of file 23680.c.

691 {
692 Enemy* enemy = script->owner1.enemy;
693 Npc* npc = get_npc_unsafe(enemy->npcID);
694 f32 x, y, z;
695 f32 yaw;
696 EffectInstance* emoteTemp;
697
698 if (aiSettings->playerSearchInterval >= 0) {
699 if (basic_ai_check_player_dist(territory, enemy, aiSettings->chaseRadius, aiSettings->chaseOffsetDist, 0)) {
700 x = npc->pos.x;
701 y = npc->pos.y;
702 z = npc->pos.z;
703 yaw = atan2(npc->pos.x, npc->pos.z, gPlayerStatusPtr->pos.x, gPlayerStatusPtr->pos.z);
704 if (!npc_test_move_simple_with_slipping(npc->collisionChannel, &x, &y, &z, aiSettings->chaseSpeed, yaw, npc->collisionHeight, npc->collisionDiameter)) {
705 npc->yaw = yaw;
707 fx_emote(EMOTE_EXCLAMATION, npc, 0, npc->collisionHeight, 1.0f, 2.0f, -20.0f, 15, &emoteTemp);
709 script->AI_TEMP_STATE = AI_STATE_ALERT_INIT;
710 } else {
711 script->AI_TEMP_STATE = AI_STATE_CHASE_INIT;
712 }
713 return;
714 }
715 }
716 }
717
718 // look around randomly
719 if (npc->turnAroundYawAdjustment == 0) {
720 npc->duration--;
721 if (npc->duration <= 0) {
722 script->functionTemp[1]--;
723 if (script->functionTemp[1]) {
725 npc->yaw = clamp_angle(npc->yaw + 180.0f);
726 }
727 npc->duration = (aiSettings->waitTime / 2) + rand_int(aiSettings->waitTime / 2 + 1);
728 return;
729 }
730 script->AI_TEMP_STATE = AI_STATE_WANDER_INIT;
731 }
732 }
733}
@ AI_ACTION_LOOK_AROUND_DURING_LOITER
Definition enums.h:4615

◆ basic_ai_found_player_jump_init()

void basic_ai_found_player_jump_init ( Evt * script,
MobileAISettings * npcAISettings,
EnemyDetectVolume * territory )

Definition at line 735 of file 23680.c.

735 {
736 Enemy* enemy = script->owner1.enemy;
737 Npc* npc = get_npc_unsafe(enemy->npcID);
738
741 npc->jumpVel = 10.0f;
742 npc->jumpScale = 2.5f;
743 npc->moveToPos.y = npc->pos.y;
744 npc->flags |= NPC_FLAG_JUMPING;
745 script->AI_TEMP_STATE = AI_STATE_ALERT;
746}
@ ENEMY_ANIM_INDEX_JUMP
Definition enums.h:3430
@ AI_STATE_ALERT
Definition enums.h:4590
@ SOUND_AI_FOUND_PLAYER_JUMP
Definition enums.h:1289
@ NPC_FLAG_JUMPING
Definition enums.h:3009
Vec3f moveToPos

◆ basic_ai_found_player_jump()

void basic_ai_found_player_jump ( Evt * script,
MobileAISettings * npcAISettings,
EnemyDetectVolume * territory )

Definition at line 748 of file 23680.c.

748 {
749 Npc* npc = get_npc_unsafe(script->owner1.enemy->npcID);
750 s32 done = FALSE;
751
752 if (npc->jumpVel <= 0.0) {
753 if (npc->pos.y <= npc->moveToPos.y) {
754 npc->pos.y = npc->moveToPos.y;
755 done = TRUE;
756 }
757 }
758
759 if (!done) {
760 npc->pos.y += npc->jumpVel;
761 npc->jumpVel -= npc->jumpScale;
762 } else {
763 npc->jumpVel = 0.0f;
764 npc->flags &= ~NPC_FLAG_JUMPING;
765 script->AI_TEMP_STATE = AI_STATE_CHASE_INIT;
766 }
767}

◆ basic_ai_chase_init()

void basic_ai_chase_init ( Evt * script,
MobileAISettings * npcAISettings,
EnemyDetectVolume * territory )

Definition at line 769 of file 23680.c.

769 {
770 Enemy* enemy = script->owner1.enemy;
771 Npc* npc = get_npc_unsafe(enemy->npcID);
772 s32 skipTurnAround = FALSE;
773
777 {
778 skipTurnAround = TRUE;
779 }
780
781 if (!skipTurnAround) {
782 f32 angle = atan2(npc->pos.x, npc->pos.z, gPlayerStatusPtr->pos.x, gPlayerStatusPtr->pos.z);
783 f32 deltaAngleToPlayer = get_clamped_angle_diff(npc->yaw, angle);
784
785 if (npcAISettings->chaseTurnRate < fabsf(deltaAngleToPlayer)) {
786 angle = npc->yaw;
787 if (deltaAngleToPlayer < 0.0f) {
788 angle += -npcAISettings->chaseTurnRate;
789 } else {
790 angle += npcAISettings->chaseTurnRate;
791 }
792 }
793 npc->yaw = clamp_angle(angle);
794 npc->duration = (npcAISettings->chaseUpdateInterval / 2) + rand_int((npcAISettings->chaseUpdateInterval / 2) + 1);
795 } else {
796 npc->duration = 0;
797 }
798
800 npc->moveSpeed = npcAISettings->chaseSpeed;
801 script->AI_TEMP_STATE = AI_STATE_CHASE;
802}
@ ENEMY_ANIM_INDEX_CHASE
Definition enums.h:3429
@ AI_STATE_CHASE
Definition enums.h:4592
@ ACTION_STATE_HOP
Released A before apex of jump.
Definition enums.h:2432
f32 chaseSpeed
Definition npc.h:99
s32 chaseTurnRate
Definition npc.h:100
s32 chaseUpdateInterval
Definition npc.h:101

Referenced by HoppingAI_ChaseInit(), and StoneChompAI_ChaseInit().

◆ basic_ai_chase()

void basic_ai_chase ( Evt * script,
MobileAISettings * npcAISettings,
EnemyDetectVolume * territory )

Definition at line 804 of file 23680.c.

804 {
805 Enemy* enemy = script->owner1.enemy;
806 Npc* npc = get_npc_unsafe(enemy->npcID);
807 EffectInstance* sp28;
808 f32 x, y, z;
809
810 if (!basic_ai_check_player_dist(territory, enemy, aiSettings->chaseRadius, aiSettings->chaseOffsetDist, 1)) {
811 fx_emote(EMOTE_QUESTION, npc, 0, npc->collisionHeight, 1.0f, 2.0f, -20.0f, 15, &sp28);
813 npc->duration = 20;
814 script->AI_TEMP_STATE = AI_STATE_LOSE_PLAYER;
815 return;
816 }
817
818 if (enemy->npcSettings->actionFlags & AI_ACTION_04) {
819 if (dist2D(npc->pos.x, npc->pos.z, gPlayerStatusPtr->pos.x, gPlayerStatusPtr->pos.z) > (npc->moveSpeed * 5.0)) {
820 x = npc->pos.x;
821 y = npc->pos.y;
822 z = npc->pos.z;
823 if (npc_test_move_simple_with_slipping(npc->collisionChannel, &x, &y, &z, 1.0f, npc->yaw, npc->collisionHeight, npc->collisionDiameter)) {
824 fx_emote(EMOTE_QUESTION, npc, 0, npc->collisionHeight, 1.0f, 2.0f, -20.0f, 0xC, &sp28);
826 npc->duration = 15;
827 script->AI_TEMP_STATE = AI_STATE_LOSE_PLAYER;
828 return;
829 }
830 }
831 }
832
834 npc_move_heading(npc, npc->moveSpeed, npc->yaw);
835
836 if (npc->moveSpeed > 8.0 && !(gGameStatusPtr->frameCounter % 5)) {
838 }
839
840 if (npc->duration > 0) {
841 npc->duration--;
842 } else {
843 script->AI_TEMP_STATE = AI_STATE_CHASE_INIT;
844 }
845}
@ EMOTE_QUESTION
Definition enums.h:497
@ ENEMY_ANIM_INDEX_IDLE
Definition enums.h:3426
@ AI_STATE_LOSE_PLAYER
Definition enums.h:4593
@ SOUND_SMALL_NPC_STEP
Definition enums.h:1480
@ SURFACE_INTERACT_RUN
Definition enums.h:4684
@ AI_ACTION_04
Definition enums.h:4613
void npc_surface_spawn_fx(Npc *npc, SurfaceInteractMode mode)
Definition surfaces.c:394

◆ basic_ai_lose_player()

void basic_ai_lose_player ( Evt * script,
MobileAISettings * npcAISettings,
EnemyDetectVolume * territory )

Definition at line 847 of file 23680.c.

847 {
848 Enemy* enemy = script->owner1.enemy;
849 Npc* npc = get_npc_unsafe(enemy->npcID);
850
851 npc->duration--;
852 if (npc->duration == 0) {
853 // turn to face home position
854 npc->yaw = clamp_angle(atan2(npc->pos.x, npc->pos.z, enemy->territory->wander.centerPos.x, enemy->territory->wander.centerPos.z));
855 script->AI_TEMP_STATE = AI_STATE_WANDER_INIT;
856 }
857}

◆ basic_ai_suspend()

void basic_ai_suspend ( Evt * script)

Definition at line 13 of file 25AF0.c.

13 {
14 Enemy* enemy = script->owner1.enemy;
15
16 get_npc_unsafe(enemy->npcID);
17 if (enemy->aiSuspendTime == 0) {
18 script->functionTemp[0] = script->functionTemp[1];
19 }
20}
s8 aiSuspendTime
Definition npc.h:333

◆ create_worker_scene()

s32 create_worker_scene ( void(*)(void) updateFunc,
void(*)(void) renderFunc )

Definition at line 32 of file worker.c.

32 {
33 Worker* worker;
34 s32 i;
35
36 for (i = 0; i < MAX_WORKERS; i++) {
37 Worker* lastWorker = (*gCurrentWorkerListPtr)[i];
38 if (lastWorker == NULL) {
39 break;
40 }
41 }
43
44 (*gCurrentWorkerListPtr)[i] = worker = heap_malloc(sizeof(*worker));
45 ASSERT(worker != NULL);
46
48 worker->update = updateFunc;
49 if (updateFunc == NULL) {
51 }
52 worker->draw = renderFunc;
53 if (renderFunc == NULL) {
55 }
56
59 }
60 return i;
61}

Referenced by clear_encounter_status(), clear_item_entity_data(), clear_virtual_entity_list(), func_80045AC0(), init_encounter_status(), initialize_battle(), and reset_model_animators().

◆ init_entity_models()

void init_entity_models ( void )

Definition at line 74 of file entity_model.c.

74 {
75 s32 i;
76
79 } else {
81 }
82
85 entity_fog_red = 10;
87 entity_fog_blue = 10;
91}
BSS EntityModelList * gCurrentEntityModelList
BSS EntityModelList gBattleEntityModelList
s32 gEntityModelCount
BSS EntityModelList gWorldEntityModelList

Referenced by state_step_end_battle(), and state_step_unpause().

◆ phys_get_spin_history()

f32 phys_get_spin_history ( s32 lag,
s32 * x,
s32 * y,
s32 * z )

Definition at line 82 of file 7E9D0.c.

82 {
83 s32 idx = gSpinHistoryBufferPos - lag;
84
85 if (idx < 0) {
87 }
88
89 *x = gSpinHistoryPosX[idx];
90 *y = gSpinHistoryPosY[idx];
91 *z = gSpinHistoryPosZ[idx];
92 return gSpinHistoryPosAngle[idx];
93}

Referenced by appendGfx_player_spin().

◆ imgfx_update()

void imgfx_update ( u32 idx,
ImgFXType type,
s32 imgfxArg1,
s32 imgfxArg2,
s32 imgfxArg3,
s32 imgfxArg4,
s32 flags )

Definition at line 486 of file imgfx.c.

486 {
487 ImgFXState* state = &(*ImgFXInstances)[idx];
488 s32 oldFlags;
489 u8 r, g, b, a;
490
491 if (!(state->flags & IMGFX_FLAG_VALID) || (idx >= MAX_IMGFX_INSTANCES)) {
492 return;
493 }
494
495 switch (type) {
496 case IMGFX_CLEAR:
497 case IMGFX_RESET:
498 oldFlags = state->flags;
500 imgfx_init_instance(state);
501 state->flags = oldFlags;
502 state->lastAnimCmd = IMGFX_CLEAR;
503 state->lastColorCmd = IMGFX_CLEAR;
506 state->ints.raw[0][0] = -1;
507 state->ints.raw[1][0] = -1;
508
509 state->flags &= IMGFX_FLAG_VALID;
510 if (flags != 0) {
511 state->flags |= flags;
512 } else {
513 state->flags |= 0; // required to match
514 }
515 return;
516 case IMGFX_UNK_1:
517 state->lastAnimCmd = IMGFX_CLEAR;
519 state->ints.raw[0][0] = -1;
520 return;
521 case IMGFX_UNK_2:
522 state->lastColorCmd = IMGFX_CLEAR;
524 state->ints.raw[1][0] = -1;
525 return;
527 if (state->colorBuf != NULL) {
528 heap_free(state->colorBuf);
529 }
530 state->colorBufCount = imgfxArg1 * 4;
531 state->colorBuf = heap_malloc(state->colorBufCount);
532 return;
533 case IMGFX_OVERLAY:
535 if (type == state->lastColorCmd
536 && imgfxArg1 == (s32) state->ints.overlay.pattern
537 && imgfxArg2 == state->ints.overlay.alpha
538 ) {
539 // no paramaters have changed
540 return;
541 }
542 break;
543 case IMGFX_SET_ANIM:
544 if (state->lastAnimCmd == type
545 && state->ints.anim.type == imgfxArg1
546 && state->ints.anim.interval == imgfxArg2
547 && state->ints.anim.step == imgfxArg3
548 ) {
549 // no paramaters have changed
550 return;
551 }
552 break;
553 default:
554 if (type != IMGFX_HOLOGRAM && state->lastColorCmd == IMGFX_HOLOGRAM) {
556 state->subdivX = 1;
557 state->subdivY = 1;
558 }
559 break;
560 }
561
562 if (type != IMGFX_SET_ANIM && state->lastAnimCmd == IMGFX_SET_ANIM) {
563 state->lastAnimCmd = IMGFX_CLEAR;
564 }
565
566 if (type == IMGFX_SET_WAVY || type == IMGFX_SET_ANIM) {
567 state->lastAnimCmd = type;
568 state->ints.args.anim[0] = imgfxArg1;
569 state->ints.args.anim[1] = imgfxArg2;
570 state->ints.args.anim[2] = imgfxArg3;
571 state->ints.args.anim[3] = imgfxArg4;
572 } else if (type >= IMGFX_SET_COLOR && type <= IMGFX_OVERLAY_XLU) {
573 state->lastColorCmd = type;
574 state->ints.args.color[0] = imgfxArg1;
575 state->ints.args.color[1] = imgfxArg2;
576 state->ints.args.color[2] = imgfxArg3;
577 state->ints.args.color[3] = imgfxArg4;
578 }
579
580 state->flags &= IMGFX_FLAG_VALID;
581 if (flags != 0) {
582 state->flags |= flags;
583 }
585
586 switch (type) {
587 case IMGFX_RESET:
590 break;
591 case IMGFX_SET_WAVY:
592 state->subdivX = 4;
593 state->subdivY = 4;
595 imgfx_wavy_init(state);
596 break;
597 case IMGFX_SET_ANIM:
600 state->floats.anim.curFrame = 0.0f;
601 state->floats.anim.curIdx = 0.0f;
602 state->flags |= IMGFX_FLAG_200;
603 break;
604 case IMGFX_SET_COLOR:
605 case IMGFX_SET_ALPHA:
606 case IMGFX_SET_TINT:
607 if (imgfxArg1 >= 255 && imgfxArg2 >= 255 && imgfxArg3 >= 255 && imgfxArg4 >= 255) {
608 // no color + no transparency
610 } else if (imgfxArg4 >= 255) {
611 // some color + no transparency
613 } else if (imgfxArg1 >= 255 && imgfxArg2 >= 255 && imgfxArg3 >= 255) {
614 // no color + transparency
616 } else {
617 // some color + transparency
619 }
620 break;
623 if (imgfxArg4 == 255.0) {
625 } else {
627 }
628 break;
630 if (imgfxArg1 < state->colorBufCount) {
631 // unpack and store color
632 r = (imgfxArg2 & 0xFF000000) >> 24;
633 g = (imgfxArg2 & 0xFF0000) >> 16;
634 b = (imgfxArg2 & 0xFF00) >> 8;
635 a = (imgfxArg2 & 0xFF);
636 state->colorBuf[imgfxArg1].r = r;
637 state->colorBuf[imgfxArg1].g = g;
638 state->colorBuf[imgfxArg1].b = b;
639 state->colorBuf[imgfxArg1].a = a;
640
642
643 if (a == 255) {
645 } else {
647 }
648 }
649 break;
651 if (imgfxArg1 < state->colorBufCount) {
652 // unpack and store color
653 r = (imgfxArg2 & 0xFF000000) >> 24;
654 g = (imgfxArg2 & 0xFF0000) >> 16;
655 b = (imgfxArg2 & 0xFF00) >> 8;
656 a = (imgfxArg2 & 0xFF);
657 state->colorBuf[imgfxArg1].r = r;
658 state->colorBuf[imgfxArg1].g = g;
659 state->colorBuf[imgfxArg1].b = b;
660 state->colorBuf[imgfxArg1].a = a;
661
663
664 if (a == 255) {
666 } else {
668 }
669 }
670 break;
671 case IMGFX_HOLOGRAM:
673 break;
674 case IMGFX_FILL_COLOR:
676 break;
677 case IMGFX_OVERLAY:
679 state->meshType = IMGFX_MESH_STRIP;
680 if (imgfxArg2 >= 255) {
682 } else {
684 }
685 state->floats.overlay.posX = 0.0f;
686 state->floats.overlay.posY = 0.0f;
687 break;
688 case IMGFX_CLEAR:
689 break;
690 }
691}
@ IMGFX_RENDER_MULTIPLY_RGBA
Definition enums.h:5163
@ IMGFX_RENDER_HOLOGRAM
Definition enums.h:5172
@ IMGFX_RENDER_MULTIPLY_SHADE_RGB
Definition enums.h:5166
@ IMGFX_RENDER_OVERLAY_RGBA
Definition enums.h:5175
@ IMGFX_RENDER_MODULATE_PRIM_RGBA
Definition enums.h:5165
@ IMGFX_RENDER_MULTIPLY_RGB
Definition enums.h:5161
@ IMGFX_RENDER_ANIM
Definition enums.h:5171
@ IMGFX_RENDER_DEFAULT
Definition enums.h:5160
@ IMGFX_RENDER_MULTIPLY_SHADE_RGBA
Definition enums.h:5168
@ IMGFX_RENDER_OVERLAY_RGB
Definition enums.h:5174
@ IMGFX_RENDER_MODULATE_PRIM_RGB
Definition enums.h:5164
@ IMGFX_RENDER_MULTIPLY_ALPHA
Definition enums.h:5162
@ IMGFX_RENDER_MODULATE_SHADE_RGB
Definition enums.h:5169
@ IMGFX_RENDER_MODULATE_SHADE_RGBA
Definition enums.h:5170
@ IMGFX_RENDER_COLOR_FILL
Definition enums.h:5173
@ IMGFX_RESET
Definition enums.h:5119
@ IMGFX_HOLOGRAM
Definition enums.h:5129
@ IMGFX_OVERLAY_XLU
Definition enums.h:5132
@ IMGFX_OVERLAY
Definition enums.h:5131
@ IMGFX_SET_WAVY
Definition enums.h:5120
@ IMGFX_ALLOC_COLOR_BUF
Definition enums.h:5133
@ IMGFX_FILL_COLOR
Definition enums.h:5130
@ IMGFX_SET_CREDITS_FADE
Definition enums.h:5126
@ IMGFX_SET_TINT
Definition enums.h:5124
@ IMGFX_SET_WHITE_FADE
Definition enums.h:5125
@ IMGFX_UNK_2
Definition enums.h:5118
@ IMGFX_UNK_1
Definition enums.h:5117
@ IMGFX_MESH_STRIP
Definition enums.h:5188
@ IMGFX_MESH_GRID_WAVY
Definition enums.h:5185
@ IMGFX_MESH_ANIMATED
Definition enums.h:5186
@ IMGFX_MESH_DEFAULT
Definition enums.h:5184
@ IMGFX_FLAG_200
Definition enums.h:5101
s8 lastAnimCmd
Definition imgfx.c:73
void imgfx_wavy_init(ImgFXState *state)
Definition imgfx.c:1797
u8 subdivY
Definition imgfx.c:72
u8 subdivX
Definition imgfx.c:71
s32 flags
Definition imgfx.c:81
struct ImgFXIntVars::@170 args
struct ImgFXIntVars::@171 anim
struct ImgFXFloatVars::@176 anim
struct ImgFXIntVars::@173 color
s8 lastColorCmd
Definition imgfx.c:74
u8 renderType
Definition imgfx.c:70
ImgFXIntVars ints
Definition imgfx.c:83
u16 colorBufCount
Definition imgfx.c:86
u8 meshType
Definition imgfx.c:69
s32 raw[2][4]
Definition imgfx.c:11
ImgFXFloatVars floats
Definition imgfx.c:84
struct ImgFXFloatVars::@178 overlay
Color_RGBA8 * colorBuf
Definition imgfx.c:85
struct ImgFXIntVars::@175 overlay
#define MAX_IMGFX_INSTANCES
Definition macros.h:98

Referenced by appendGfx_interact_prompt(), appendGfx_ispy_icon(), appendGfx_speech_bubble(), render_hud_element(), set_npc_imgfx_comp(), and set_player_imgfx_comp().

◆ imgfx_appendGfx_component()

s32 imgfx_appendGfx_component ( s32 idx,
ImgFXTexture * ifxImg,
u32 flagBits,
Matrix4f mtx )

Definition at line 703 of file imgfx.c.

703 {
704 ImgFXState* state = &(*ImgFXInstances)[idx];
705 s32 ret = 0;
706
707 if (ifxImg->alpha == 0) {
708 return 0;
709 }
710
711 state->arrayIdx = idx;
712 state->flags |= flagBits;
722
723 if (idx < 0 || idx >= MAX_IMGFX_INSTANCES) {
724 return 0;
725 }
726
727 if (idx >= MAX_IMGFX_INSTANCES || state == NULL) {
728 return 0;
729 }
730
731 imgfx_make_mesh(state);
732 imgfx_appendGfx_mesh(state, mtx);
733
734 if (state->flags & IMGFX_FLAG_ANIM_DONE) {
735 state->ints.raw[0][0] = -1;
736 state->ints.raw[1][0] = -1;
737 state->lastAnimCmd = IMGFX_CLEAR;
738 state->meshType = 0;
742 ret = 1;
743 } else if (state->flags & IMGFX_FLAG_4000) {
744 ret = 2;
745 } else if (state->flags & IMGFX_FLAG_20000) {
746 state->lastAnimCmd = IMGFX_CLEAR;
747 state->lastColorCmd = IMGFX_CLEAR;
750 state->ints.raw[0][0] = -1;
751 state->ints.raw[1][0] = -1;
752 state->flags &= IMGFX_FLAG_VALID;
753 ret = 1;
754 }
755 return ret;
756}
@ IMGFX_FLAG_ANIM_DONE
Definition enums.h:5104
@ IMGFX_FLAG_LOOP_ANIM
Definition enums.h:5099
@ IMGFX_FLAG_20000
Definition enums.h:5109
@ IMGFX_FLAG_REVERSE_ANIM
Definition enums.h:5100
@ IMGFX_FLAG_800
Definition enums.h:5103
@ IMGFX_FLAG_4000
Definition enums.h:5106
ImgFXWorkingTexture * ImgFXCurrentTexturePtr
Definition imgfx.c:123
void imgfx_appendGfx_mesh(ImgFXState *state, Matrix4f mtx)
Definition imgfx.c:795
u8 arrayIdx
Definition imgfx.c:68
void imgfx_make_mesh(ImgFXState *state)
Definition imgfx.c:758

Referenced by appendGfx_entity_model(), appendGfx_interact_prompt(), appendGfx_ispy_icon(), appendGfx_pulse_stone_icon(), appendGfx_speech_bubble(), draw_coin_sparkles(), draw_entity_model_E(), gfx_build_knocked_down_player(), render_hud_element(), and spr_appendGfx_component().

◆ imgfx_update_cache()

void imgfx_update_cache ( void )

Definition at line 332 of file imgfx.c.

332 {
334}
void imgfx_update_cache_impl(void)
Definition imgfx.c:309

Referenced by state_drawUI_world().

◆ imgfx_get_free_instances()

s32 imgfx_get_free_instances ( s32 count)

Definition at line 337 of file imgfx.c.

337 {
338 s32 numAssigned;
339 s32 foundAny;
340 s32 iPrev;
341 s32 firstIdx;
342 s32 i;
343
344 numAssigned = 0;
345 for (i = 1; i < ARRAY_COUNT(*ImgFXInstances); i++) {
346 if (!((*ImgFXInstances)[i].flags & IMGFX_FLAG_VALID)) {
347 numAssigned++;
348 }
349 }
350
351 if (numAssigned < count) {
352 return -1;
353 }
354
355 firstIdx = 0;
356 foundAny = FALSE;
357 numAssigned = 0;
358 iPrev = -1;
359 for (i = 1; i < ARRAY_COUNT(*ImgFXInstances); i++) {
360 if ((*ImgFXInstances)[i].flags & IMGFX_FLAG_VALID) {
361 continue;
362 }
363
364 if (!foundAny) {
365 firstIdx = i;
366 foundAny = TRUE;
367 } else {
368 (*ImgFXInstances)[iPrev].nextIdx = i;
369 }
370
371 (*ImgFXInstances)[i].arrayIdx = i;
373 numAssigned++;
374 (*ImgFXInstances)[i].flags |= IMGFX_FLAG_VALID;
375 iPrev = i;
376 if (numAssigned == count) {
377 (*ImgFXInstances)[i].nextIdx = -1;
378 break;
379 }
380 }
381
382 return firstIdx;
383}

Referenced by hud_element_create_transform_A(), spr_load_npc_sprite(), and spr_update_player_sprite().

◆ free_worker()

void free_worker ( s32 idx)

Definition at line 176 of file worker.c.

176 {
178 idx &= ~BATTLE_ENTITY_ID_BIT;
179 if ((*gCurrentWorkerListPtr)[idx] != NULL) {
181 (*gCurrentWorkerListPtr)[idx] = NULL;
182 }
183 }
184}

Referenced by popup_menu_update().

◆ ai_check_fwd_collisions()

b32 ai_check_fwd_collisions ( Npc * npc,
f32 time,
f32 * outYaw,
f32 * outDistFwd,
f32 * outDistCW,
f32 * outDistCCW )

Definition at line 22 of file 25AF0.c.

22 {
23 f32 x1, y1, z1;
24 f32 x2, y2, z2;
25 f32 x3, y3, z3;
26 f32 fwdHitDist = -1.0f;
27 f32 cwHitDist = -1.0f;
28 f32 ccwHitDist = -1.0f;
29 f32 yaw;
30 b32 fwdHit;
31
32 x1 = npc->pos.x;
33 y1 = npc->pos.y;
34 z1 = npc->pos.z;
35 yaw = *outYaw;
36
38 &x1, &y1, &z1,
39 npc->moveSpeed * time,
40 yaw,
41 npc->collisionHeight,
43
44 if (fwdHit) {
45 fwdHitDist = dist2D(npc->pos.x, npc->pos.z, x1, z1);
46
47 x2 = npc->pos.x;
48 y2 = npc->pos.y;
49 z2 = npc->pos.z;
51 &x2, &y2, &z2, npc->moveSpeed * time,
52 clamp_angle(yaw + 35.0f),
53 npc->collisionHeight,
54 npc->collisionDiameter) != 0) {
55 cwHitDist = dist2D(npc->pos.x, npc->pos.z, x2, z2);
56 }
57
58 x3 = npc->pos.x;
59 y3 = npc->pos.y;
60 z3 = npc->pos.z;
62 &x3, &y3, &z3,
63 npc->moveSpeed * time,
64 clamp_angle(yaw - 35.0f),
65 npc->collisionHeight,
66 npc->collisionDiameter) != 0) {
67 ccwHitDist = dist2D(npc->pos.x, npc->pos.z, x3, z3);
68 }
69
70 if ((cwHitDist < fwdHitDist && ccwHitDist < cwHitDist) || (ccwHitDist < fwdHitDist && cwHitDist < ccwHitDist)) {
71 yaw = npc->yaw;
72 } else if ((fwdHitDist < cwHitDist && ccwHitDist < fwdHitDist) || (ccwHitDist < cwHitDist && fwdHitDist < ccwHitDist)) {
73 yaw = npc->yaw + 35.0f;
74 } else if ((fwdHitDist < ccwHitDist && cwHitDist < fwdHitDist) || (cwHitDist < ccwHitDist && fwdHitDist < cwHitDist)) {
75 yaw = npc->yaw - 35.0f;
76 }
77 }
78
79 if (outYaw != NULL) {
80 *outYaw = clamp_angle(yaw);
81 }
82 if (outDistFwd != NULL) {
83 *outDistFwd = fwdHitDist;
84 }
85 if (outDistCW != NULL) {
86 *outDistCW = cwHitDist;
87 }
88 if (outDistCCW != NULL) {
89 *outDistCCW = ccwHitDist;
90 }
91 return fwdHit;
92}

Referenced by basic_ai_wander(), ClubbaNappingAI_ReturnHome(), ShyGuyPatrolAI_15(), ShyGuyPatrolAI_16(), ShyGuyWanderAI_15(), and ShyGuyWanderAI_16().

◆ basic_ai_loiter_init()

void basic_ai_loiter_init ( Evt * script,
MobileAISettings * aiSettings,
EnemyDetectVolume * territory )

Definition at line 681 of file 23680.c.

681 {
682 Enemy* enemy = script->owner1.enemy;
683 Npc* npc = get_npc_unsafe(enemy->npcID);
684
685 npc->duration = (aiSettings->waitTime / 2) + rand_int((aiSettings->waitTime / 2) + 1);
686 npc->yaw = clamp_angle(npc->yaw + rand_int(180) - 90.0f);
688 script->AI_TEMP_STATE = AI_STATE_LOITER;
689}
@ AI_STATE_LOITER
Definition enums.h:4587
s32 waitTime
Definition npc.h:95

◆ PatrolAI_LoiterInit()

void PatrolAI_LoiterInit ( Evt * script,
MobileAISettings * aiSettings,
EnemyDetectVolume * territory )

Definition at line 96 of file States_PatrolAI.inc.c.

96 {
97 Enemy* enemy = script->owner1.enemy;
98 Npc* npc = get_npc_unsafe(enemy->npcID);
99
100 npc->duration = (aiSettings->waitTime / 2) + rand_int((aiSettings->waitTime / 2) + 1);
101 npc->yaw = clamp_angle(npc->yaw + rand_int(180) - 90.0f);
103 script->AI_TEMP_STATE = AI_STATE_LOITER;
104}

◆ func_80263230()

s32 func_80263230 ( Actor * actor,
Actor * targetActor )

Definition at line 558 of file 190B20.c.

558 {
559 return func_80263064(actor, targetActor, FALSE);
560}
s32 func_80263064(Actor *actor, Actor *targetActor, b32 unused)
Definition 190B20.c:480

Referenced by btl_state_update_first_strike(), and dispatch_damage_event_actor().

◆ set_part_glow_pal()

void set_part_glow_pal ( ActorPart * part,
s32 glowState )

Definition at line 2642 of file 190B20.c.

2642 {
2643 if (part->idleAnimations != NULL && !(part->flags & ACTOR_PART_FLAG_NO_DECORATIONS)) {
2644 DecorationTable* decorations = part->decorationTable;
2645
2646 if (decorations->glowState != glowState) {
2647 decorations->glowState = glowState;
2648 decorations->glowUnk1 = 0;
2649 decorations->glowStateChanged = TRUE;
2650 }
2651 }
2652}

Referenced by set_actor_glow_pal().

◆ clear_actor_static_pal_adjustments()

void clear_actor_static_pal_adjustments ( Actor * actor)

Definition at line 2624 of file 190B20.c.

2624 {
2625 for (ActorPart* part = actor->partsTable; part != NULL; part = part->nextPart) {
2626 DecorationTable* decorations = part->decorationTable;
2627
2628 if (!(part->flags & ACTOR_PART_FLAG_USE_ABSOLUTE_POSITION)
2629 && !(part->flags & ACTOR_PART_FLAG_INVISIBLE)
2630 && (part->idleAnimations != NULL)
2631 && !(part->flags & ACTOR_PART_FLAG_NO_DECORATIONS)
2632 ) {
2635 ) {
2637 }
2638 }
2639 }
2640}

◆ set_actor_flash_mode()

void set_actor_flash_mode ( Actor * actor,
s32 arg1 )

Definition at line 2696 of file 190B20.c.

2696 {
2697 for (ActorPart* part = actor->partsTable; part != NULL; part = part->nextPart) {
2699 && part->decorationTable != NULL
2700 && !(part->flags & ACTOR_PART_FLAG_NO_DECORATIONS)
2701 && part->idleAnimations != NULL
2702 ) {
2703 set_part_flash_mode(part, flashState);
2704 }
2705 }
2706}
void set_part_flash_mode(ActorPart *part, s32 flashState)
Definition 190B20.c:2684

Referenced by calc_enemy_damage_target(), calc_item_damage_enemy(), calc_partner_damage_enemy(), calc_player_damage_enemy(), dispatch_damage_event_actor(), dispatch_damage_event_partner(), and dispatch_damage_event_player().

◆ remove_player_buffs()

void remove_player_buffs ( s32 buffs)

Definition at line 2806 of file 190B20.c.

2806 {
2807 BattleStatus* battleStatus = &gBattleStatus;
2808 Actor* player = battleStatus->playerActor;
2809 Actor* partner = battleStatus->partnerActor;
2810 ActorPart* playerActorParts = player->partsTable;
2811
2812 if (buffs & PLAYER_BUFF_JUMP_CHARGE) {
2813 battleStatus->jumpCharge = 0;
2814 battleStatus->flags1 &= ~BS_FLAGS1_JUMP_CHARGED;
2815 }
2816 if (buffs & PLAYER_BUFF_HAMMER_CHARGE) {
2817 battleStatus->hammerCharge = 0;
2818 battleStatus->flags1 &= ~BS_FLAGS1_HAMMER_CHARGED;
2819 }
2820 if (buffs & PLAYER_BUFF_STONE) {
2821 player->stoneDuration = 0;
2822 player->stoneStatus = 0;
2823 }
2824 if (buffs & PLAYER_BUFF_HUSTLE) {
2825 battleStatus->hustleTurns = 0;
2826 battleStatus->flags1 &= ~BS_FLAGS1_HUSTLED;
2827 }
2828 if (buffs & PLAYER_BUFF_STATIC && (player->staticStatus != 0)) {
2829 player->staticDuration = 0;
2830 player->staticStatus = 0;
2832 }
2833 if (buffs & PLAYER_BUFF_TRANSPARENT && (player->transparentStatus != 0)) {
2834 player->transparentDuration = 0;
2835 player->transparentStatus = 0;
2836 playerActorParts->flags &= ~ACTOR_PART_FLAG_TRANSPARENT;
2838 }
2839 if (buffs & PLAYER_BUFF_WATER_BLOCK && (battleStatus->waterBlockTurnsLeft != 0)) {
2840 battleStatus->waterBlockTurnsLeft = 0;
2843
2844 fx_water_block(FX_WATER_BLOCK_DESTROY, player->curPos.x, player->curPos.y + 18.0f, player->curPos.z + 5.0f, 1.5f, 10);
2845 fx_water_splash(0, player->curPos.x - 10.0f, player->curPos.y + 5.0f, player->curPos.z + 5.0f, 1.0f, 24);
2846 fx_water_splash(0, player->curPos.x - 15.0f, player->curPos.y + 32.0f, player->curPos.z + 5.0f, 1.0f, 24);
2847 fx_water_splash(1, player->curPos.x + 15.0f, player->curPos.y + 22.0f, player->curPos.z + 5.0f, 1.0f, 24);
2848
2849 battleStatus->waterBlockEffect = NULL;
2851 }
2852 if (buffs & PLAYER_BUFF_TURBO_CHARGE && (battleStatus->turboChargeTurnsLeft != 0)) {
2853 battleStatus->turboChargeTurnsLeft = 0;
2855 }
2856 if (buffs & PLAYER_BUFF_CLOUD_NINE && (battleStatus->cloudNineTurnsLeft != 0)) {
2857 battleStatus->cloudNineTurnsLeft = 0;
2859 remove_effect(battleStatus->cloudNineEffect);
2860 battleStatus->cloudNineEffect = NULL;
2861 }
2862
2863 if (partner != NULL && (buffs & PLAYER_BUFF_PARTNER_GLOWING)) {
2864 partner->isGlowing = FALSE;
2865 gBattleStatus.flags1 &= ~BS_FLAGS1_GOOMBARIO_CHARGED;
2866 }
2867}
@ PLAYER_BUFF_PARTNER_GLOWING
Definition enums.h:2808
@ PLAYER_BUFF_JUMP_CHARGE
Definition enums.h:2799
@ PLAYER_BUFF_WATER_BLOCK
Definition enums.h:2807
@ PLAYER_BUFF_STONE
Definition enums.h:2801
@ PLAYER_BUFF_TURBO_CHARGE
Definition enums.h:2806
@ PLAYER_BUFF_CLOUD_NINE
Definition enums.h:2805
@ PLAYER_BUFF_TRANSPARENT
Definition enums.h:2804
@ PLAYER_BUFF_STATIC
Definition enums.h:2803
@ PLAYER_BUFF_HAMMER_CHARGE
Definition enums.h:2800
@ PLAYER_BUFF_HUSTLE
Definition enums.h:2802

◆ is_actor_health_bar_visible()

s32 is_actor_health_bar_visible ( Actor * actor)

Definition at line 503 of file 181810.c.

503 {
504 BattleStatus* battleStatus = &gBattleStatus;
505 s32 flags;
506
508 return TRUE;
509 }
510
512 if (actor->flags & ACTOR_FLAG_TYPE_CHANGED) {
513 flags |= battleStatus->tattleFlags[actor->actorType / 8];
514 }
515
516 return (flags >> (actor->actorType % 8)) & 1;
517}
@ ACTOR_FLAG_TYPE_CHANGED
Indicates actors type has changed, triggers recheck for if HP bar should be shown based on tattle sta...
Definition enums.h:3332
@ GB_Tattles_00

Referenced by btl_draw_enemy_health_bars().

◆ sin_cos_rad()

◆ load_font()

void load_font ( s32 font)

Definition at line 225 of file msg.c.

225 {
226 if (font != D_80155C98) {
227 if (font == 0) {
228#if VERSION_JP
229 load_font_data(charset_kana_OFFSET, 0x5710, MsgCharImgKana);
230 load_font_data(charset_latin_OFFSET, 0xBD0, MsgCharImgLatin);
231 load_font_data(charset_kanji_OFFSET, 0x34F0, MsgCharImgTitle); // huh
232 load_font_data(charset_buttons_OFFSET, 0x460, MsgCharImgSubtitle); // what
233 load_font_data(charset_menu_kana_OFFSET, 0x37F8, MsgCharImgMenuKana);
234 load_font_data(charset_menu_latin_OFFSET, 0x798, MsgCharImgMenuLatin);
235#else
237#endif
239 } else if (font == 1) {
243 }
244 }
245}
unsigned char charset_standard_pal_OFFSET[]
unsigned char charset_standard_OFFSET[]
unsigned char charset_subtitle_pal_OFFSET[]
unsigned char charset_subtitle_OFFSET[]
unsigned char charset_title_OFFSET[]
IMG_BIN MsgCharImgSubtitle[]
Definition msg_img.c:92
IMG_BIN MsgCharImgTitle[]
Definition msg_img.c:90
void load_font_data(Addr offset, u16 size, void *dest)
Definition msg.c:218
IMG_BIN MsgCharImgNormal[]
Definition msg_img.c:91
IMG_BIN MsgCharImgLatin[]
IMG_BIN MsgCharImgMenuKana[]
IMG_BIN MsgCharImgMenuLatin[]
IMG_BIN MsgCharImgKana[]

Referenced by clear_printers().

◆ load_font_data()

void load_font_data ( Addr offset,
u16 size,
void * dest )

Definition at line 218 of file msg.c.

218 {
219#endif
220 u8* base = charset_ROM_START + (s32) offset;
221
222 dma_copy(base, base + size, dest);
223}

Referenced by filemenu_draw_char(), load_font(), and msg_draw_char().

◆ load_asset_by_name()

void * load_asset_by_name ( const char * assetName,
u32 * decompressedSize )

Definition at line 251 of file world.c.

251 {
252 AssetHeader firstHeader;
253 AssetHeader* assetTableBuffer;
254 AssetHeader* curAsset;
255 void* ret;
256
257 dma_copy((u8*) ASSET_TABLE_FIRST_ENTRY, (u8*) ASSET_TABLE_FIRST_ENTRY + sizeof(AssetHeader), &firstHeader);
258 assetTableBuffer = heap_malloc(firstHeader.offset);
259 curAsset = &assetTableBuffer[0];
260 dma_copy((u8*) ASSET_TABLE_FIRST_ENTRY, (u8*) ASSET_TABLE_FIRST_ENTRY + firstHeader.offset, assetTableBuffer);
261 while (strcmp(curAsset->name, assetName) != 0) {
262 ASSERT_MSG(strcmp(curAsset->name, "end_data") != 0, "Asset not found: %s", assetName);
263 curAsset++;
264 }
265 *decompressedSize = curAsset->decompressedLength;
266 ret = general_heap_malloc(curAsset->compressedLength);
267 dma_copy((u8*) ASSET_TABLE_FIRST_ENTRY + curAsset->offset,
268 (u8*) ASSET_TABLE_FIRST_ENTRY + curAsset->offset + curAsset->compressedLength, ret);
269 heap_free(assetTableBuffer);
270 return ret;
271}
char name[16]
Definition world.c:34
u32 decompressedLength
Definition world.c:37
u32 offset
Definition world.c:35
#define ASSET_TABLE_FIRST_ENTRY
Definition world.c:21
u32 compressedLength
Definition world.c:36

Referenced by btl_state_update_normal_start(), load_battle_hit_asset(), load_map_bg(), load_map_by_IDs(), load_map_hit_asset(), pause_partners_load_portrait(), state_init_title_screen(), state_step_end_battle(), and state_step_unpause().

◆ mdl_get_copied_gfx()

Gfx * mdl_get_copied_gfx ( s32 copyIndex)

Definition at line 4084 of file model.c.

4084 {
4085 ModelLocalVertexCopy* mlvc = (*gCurrentModelLocalVtxBuffers)[copyIndex];
4086 s32 selector = mlvc->selector;
4087 Gfx* gfxCopy = mlvc->gfxCopy[selector];
4088
4089 mlvc->selector++;
4090 if (mlvc->selector > ARRAY_COUNT(mlvc->gfxCopy) - 1) {
4091 mlvc->selector = 0;
4092 }
4093
4094 return gfxCopy;
4095}
Gfx * gfxCopy[2]
Definition model.h:105

Referenced by build_gfx_blue_stars(), build_gfx_green_stars(), build_gfx_pink_stars(), build_gfx_star(), build_gfx_yellow_stars(), unkAngleFunc002(), and unkAngleFunc003().

◆ mdl_get_copied_vertices()

void mdl_get_copied_vertices ( s32 copyIndex,
Vtx ** firstVertex,
Vtx ** copiedVertices,
s32 * numCopied )

Definition at line 4075 of file model.c.

4075 {
4076 ModelLocalVertexCopy* mlvc = (*gCurrentModelLocalVtxBuffers)[copyIndex];
4077 s32 selector = mlvc->selector;
4078
4079 *firstVertex = mlvc->minVertexAddr;
4080 *copiedVertices = mlvc->vtxCopy[selector];
4081 *numCopied = mlvc->numVertices;
4082}
Vtx * vtxCopy[2]
Definition model.h:106

Referenced by build_gfx_blue_stars(), build_gfx_green_stars(), build_gfx_pink_stars(), build_gfx_star(), build_gfx_yellow_stars(), unkAngleFunc002(), and unkAngleFunc003().

◆ mdl_draw_hidden_panel_surface()

void mdl_draw_hidden_panel_surface ( Gfx ** arg0,
u16 treeIndex )

Definition at line 4484 of file model.c.

4484 {
4486 Model copied = *model;
4487 Gfx* oldGfxPos;
4488 s32 flag;
4489
4490 if (*arg0 == gMainGfxPos) {
4491 flag = 1;
4492 }
4493
4494 oldGfxPos = gMainGfxPos;
4495 gMainGfxPos = *arg0;
4496
4498 appendGfx_model(&copied);
4499
4500 *arg0 = gMainGfxPos;
4501
4502 if (flag == 0) {
4503 gMainGfxPos = oldGfxPos;
4504 }
4505}
@ MODEL_FLAG_HAS_LOCAL_VERTEX_COPY
Definition enums.h:4363
@ MODEL_FLAG_VALID
Definition enums.h:4356
void appendGfx_model(void *data)
Definition model.c:1368

◆ is_point_visible()

b32 is_point_visible ( f32 x,
f32 y,
f32 z,
s32 depthQueryID,
f32 * screenX,
f32 * screenY )

Definition at line 4385 of file model.c.

4385 {
4386 Camera* camera = &gCameras[gCurrentCameraID];
4387 f32 outX;
4388 f32 outY;
4389 f32 outZ;
4390 f32 outW;
4391
4392 s32 depthExponent;
4393 s32 depthMantissa;
4394 u32 shiftedMantissa, mantissaBias;
4395 u32 decodedDepth;
4396 s32 scaledDepth;
4397
4398 // If an invalid depth query id was provided, return false.
4399 if (depthQueryID >= ARRAY_COUNT(DepthCopyBuffer)) {
4400 return FALSE;
4401 }
4402 // Transform the point into clip space.
4403 transform_point(camera->mtxPerspective, x, y, z, 1.0f, &outX, &outY, &outZ, &outW);
4404 if (outW == 0.0f) {
4405 *screenX = 0.0f;
4406 *screenY = 0.0f;
4407 return TRUE;
4408 }
4409 // Perform the perspective divide (divide xyz by w) to convert to normalized device coords.
4410 // Normalized device coords have a range of (-1, 1) on each axis.
4411 outW = 1.0f / outW;
4412 outX *= outW;
4413 outY *= -outW;
4414 outZ *= outW;
4415 // Perform the viewport transform for x and y (convert normalized device coords to viewport coords).
4416 // Viewport coords have a range of (0, Width) for x and (0, Height) for y.
4417 outX = (outX * camera->viewportW + camera->viewportW) * 0.5;
4418 outX += camera->viewportStartX;
4419 outY = (outY * camera->viewportH + camera->viewportH) * 0.5;
4420 outY += camera->viewportStartY;
4421 // Convert depth from (-1, 1) to (0, 1).
4422 outZ = (outZ + 1.0f) * 0.5;
4423 // Write out the calculated x and y values.
4424 *screenX = outX;
4425 *screenY = outY;
4426 // If a depth query wasn't requested, simply check if the point is within the view frustum.
4427 if (depthQueryID < 0) {
4428 return outZ > 0.0f;
4429 }
4430 if (outX >= 0.0f && outY >= 0.0f && outX < 320.0f && outY < 240.0f) {
4431 gDPPipeSync(gMainGfxPos++);
4432 // Load a 4x1 pixel tile of the depth buffer
4433 gDPLoadTextureTile(gMainGfxPos++, osVirtualToPhysical(&nuGfxZBuffer[(s32) outY * SCREEN_WIDTH]), G_IM_FMT_RGBA, G_IM_SIZ_16b, SCREEN_WIDTH, 1,
4434 (s32) outX, 0, (s32) outX + 3, 0,
4435 0,
4436 G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMIRROR | G_TX_WRAP,
4437 9, G_TX_NOMASK,
4438 G_TX_NOLOD, G_TX_NOLOD);
4439 gDPPipeSync(gMainGfxPos++);
4440 // Set the current color image to the buffer where copied depth values are stored.
4441 gDPSetColorImage(gMainGfxPos++, G_IM_FMT_RGBA, G_IM_SIZ_16b, SCREEN_WIDTH, DepthCopyBuffer);
4442 gDPPipeSync(gMainGfxPos++);
4443 // Set up 1 cycle mode and all other relevant othermode params.
4444 // One cycle mode must be used here because only one pixel is copied, and copy mode only supports multiples of 4 pixels.
4445 gDPSetCycleType(gMainGfxPos++, G_CYC_1CYCLE);
4446 gDPSetRenderMode(gMainGfxPos++, G_RM_OPA_SURF, G_RM_OPA_SURF2);
4447 gDPSetCombineMode(gMainGfxPos++, G_CC_DECALRGBA, G_CC_DECALRGBA);
4448 gDPSetTextureFilter(gMainGfxPos++, G_TF_POINT);
4449 gDPSetTexturePersp(gMainGfxPos++, G_TP_NONE);
4450 gSPTexture(gMainGfxPos++, 0xFFFF, 0xFFFF, 0, G_TX_RENDERTILE, G_ON);
4451 gDPSetTextureLUT(gMainGfxPos++, G_TT_NONE);
4452 gDPSetTextureDetail(gMainGfxPos++, G_TD_CLAMP);
4453 gDPSetTextureLOD(gMainGfxPos++, G_TL_TILE);
4454 // Adjust the scissor to only draw to the specified pixel.
4455 gDPSetScissor(gMainGfxPos++, G_SC_NON_INTERLACE, depthQueryID, 0, depthQueryID + 1, 1);
4456 // Draw a texrect to copy one pixel of the loaded depth tile to the output buffer.
4457 gSPTextureRectangle(gMainGfxPos++, depthQueryID << 2, 0 << 2, (depthQueryID + 1) << 2, 1 << 2, G_TX_RENDERTILE, (s32) outX << 5, 0, 1 << 10, 1 << 10);
4458 // Sync and swap the color image back to the current framebuffer.
4459 gDPPipeSync(gMainGfxPos++);
4460 gDPSetColorImage(gMainGfxPos++, G_IM_FMT_RGBA, G_IM_SIZ_16b, SCREEN_WIDTH, osVirtualToPhysical(nuGfxCfb_ptr));
4461 gDPPipeSync(gMainGfxPos++);
4462 // Reconfigure the frame's normal scissor.
4463 gDPSetScissor(gMainGfxPos++, G_SC_NON_INTERLACE, camera->viewportStartX, camera->viewportStartY, camera->viewportStartX + camera->viewportW, camera->viewportStartY + camera->viewportH);
4464
4465 // The following code will use last frame's depth value, since the copy that was just written won't be executed until the current frame is drawn.
4466
4467 // Extract the exponent and mantissa from the depth buffer value.
4468 depthExponent = DepthCopyBuffer[depthQueryID] >> DEPTH_EXPONENT_SHIFT;
4469 depthMantissa = (DepthCopyBuffer[depthQueryID] & (DEPTH_MANTISSA_MASK | DEPTH_DZ_MASK)) >> DEPTH_MANTISSA_SHIFT;
4470 // Convert the exponent and mantissa into a fixed-point value.
4471 shiftedMantissa = depthMantissa << DepthFloatLookupTable[depthExponent].shift;
4472 mantissaBias = DepthFloatLookupTable[depthExponent].bias;
4473 // Remove the 3 fractional bits of precision.
4474 decodedDepth = (shiftedMantissa + mantissaBias) >> 3;
4475 // Convert the calculated screen depth into viewport depth.
4476 scaledDepth = outZ * MAX_VIEWPORT_DEPTH;
4477 if (decodedDepth < scaledDepth) {
4478 return FALSE;
4479 }
4480 }
4481 return outZ > 0.0f;
4482}
u16 * nuGfxZBuffer
Definition main.c:46
#define DEPTH_MANTISSA_SHIFT
Definition model.c:610
#define DEPTH_MANTISSA_MASK
Definition model.c:606
DepthFloatFactors DepthFloatLookupTable[]
Definition model.c:619
#define MAX_VIEWPORT_DEPTH
Definition model.c:634
#define DEPTH_EXPONENT_SHIFT
Definition model.c:609
BSS u16 DepthCopyBuffer[16]
Definition model.c:1350
#define DEPTH_DZ_MASK
Definition model.c:607

◆ set_screen_overlay_center_worldpos()

void set_screen_overlay_center_worldpos ( s32 idx,
s32 posIdx,
s32 x,
s32 y,
s32 z )

Definition at line 410 of file screen_overlays.c.

410 {
411 Camera* camera = &gCameras[gCurrentCameraID];
412 f32 tx, ty, tz, tw;
413
414 switch (layer) {
417 transform_point(camera->mtxPerspective, worldPosX, worldPosY, worldPosZ, 1.0f, &tx, &ty, &tz, &tw);
418 tw = 1.0f / tw;
419 tx *= tw;
420 ty *= -tw;
421 tz *= tw;
422 tx = (((tx * camera->viewportW) + camera->viewportW) * 0.5) + camera->viewportStartX;
423 ty = (((ty * camera->viewportH) + camera->viewportH) * 0.5) + camera->viewportStartY;
424
425 switch (posIdx) {
426 case 0:
427 ScreenOverlays[layer].screenPos[0][0] = tx;
428 ScreenOverlays[layer].screenPos[0][1] = ty;
429 break;
430 case 1:
431 ScreenOverlays[layer].screenPos[1][0] = tx;
432 ScreenOverlays[layer].screenPos[1][1] = ty;
433 break;
434 }
435 break;
436 }
437}

◆ mdl_get_next_texture_address()

void * mdl_get_next_texture_address ( s32 size)

Definition at line 4507 of file model.c.

4507 {
4508 u32 offset = TextureHeapPos - TextureHeapBase + 0x3F;
4509
4510 offset = (offset >> 6) << 6;
4511
4513 return NULL;
4514 } else {
4515 return TextureHeapBase + offset;
4516 }
4517}
#define BATTLE_TEXTURE_MEMORY_SIZE
Definition model.c:103
void * TextureHeapBase
Definition model.c:566
#define WORLD_TEXTURE_MEMORY_SIZE
Definition model.c:102
BSS void * TextureHeapPos
Definition model.c:1344

Referenced by draw_box().

◆ cancel_current_message()

s32 cancel_current_message ( void )

Definition at line 312 of file msg_api.c.

312 {
314 return 0;
315}
s32 cancel_message(MessagePrintState *msgPrintState)
Definition msg.c:1507
MessagePrintState * gCurrentPrintContext
Definition script_list.c:38

Referenced by pre_battle().

◆ draw_msg()

void draw_msg ( s32 msgID,
s32 posX,
s32 posY,
s32 opacity,
s32 palette,
u8 style )

Definition at line 1987 of file msg.c.

1987 {
1988 MessagePrintState stackPrinter;
1989 MessagePrintState* printer;
1990 u16 bufferPos;
1991 s8* mallocSpace;
1992 s32 charset;
1993 u16 flags;
1994 s32 width;
1995
1996 flags = 0;
1997 bufferPos = 0;
1998 mallocSpace = NULL;
1999 charset = 0;
2000
2001 if (msgID != 0) {
2002 if (style & DRAW_MSG_STYLE_MENU) {
2003 flags = 2;
2004 charset = 1;
2005 }
2006
2007 if (opacity < 0xFF) {
2008 flags |= 1;
2009 }
2010
2011 printer = &stackPrinter;
2012 initialize_printer(printer, 1, 0);
2013
2014 if (msgID < 0) {
2015 printer->srcBuffer = (u8*)msgID;
2016 } else {
2017 mallocSpace = general_heap_malloc(0x400);
2018 dma_load_msg(msgID, mallocSpace);
2019 printer->srcBuffer = mallocSpace;
2020 get_msg_properties((s32) printer->srcBuffer, 0, &width, 0, 0, 0, 0, charset);
2021 printer->msgWidth = width;
2022 }
2023
2024 if (palette >= 0) {
2025 printer->printBuffer[bufferPos++] = MSG_CHAR_PRINT_FUNCTION;
2026 printer->printBuffer[bufferPos++] = MSG_PRINT_FUNC_COLOR;
2027 printer->printBuffer[bufferPos++] = palette;
2028 printer->printBufferPos += 3;
2029 }
2030
2031 if (style & DRAW_MSG_STYLE_WAVY) {
2032 printer->printBuffer[bufferPos++] = MSG_CHAR_PRINT_FUNCTION;
2033 printer->printBuffer[bufferPos++] = MSG_PRINT_FUNC_START_FX;
2034 printer->printBuffer[bufferPos++] = MSG_FX_GLOBAL_WAVE;
2035 printer->printBufferPos += 3;
2036 }
2037
2038 if (style & DRAW_MSG_STYLE_RAINBOW) {
2039 printer->printBuffer[bufferPos++] = MSG_CHAR_PRINT_FUNCTION;
2040 printer->printBuffer[bufferPos++] = MSG_PRINT_FUNC_START_FX;
2041 printer->printBuffer[bufferPos++] = MSG_FX_GLOBAL_RAINBOW;
2042 printer->printBufferPos += 3;
2043 }
2044
2045 if (style & DRAW_MSG_STYLE_DROP_SHADOW) {
2046 printer->printBuffer[bufferPos++] = MSG_CHAR_PRINT_FUNCTION;
2047 printer->printBuffer[bufferPos++] = MSG_PRINT_FUNC_START_FX;
2048 printer->printBuffer[bufferPos++] = MSG_FX_DROP_SHADOW;
2049 printer->printBufferPos += 3;
2050 }
2051
2052 msg_copy_to_print_buffer(printer, 10000, 1);
2053 appendGfx_message(printer, (s16)posX, (s16)posY, 0, 0, flags, opacity & 0xFF);
2054
2055 if (mallocSpace != NULL) {
2056 general_heap_free(mallocSpace);
2057 }
2058 }
2059}
@ DRAW_MSG_STYLE_DROP_SHADOW
Definition enums.h:5387
@ DRAW_MSG_STYLE_MENU
Definition enums.h:5384
@ DRAW_MSG_STYLE_RAINBOW
Definition enums.h:5386
@ DRAW_MSG_STYLE_WAVY
Definition enums.h:5385
@ MSG_PRINT_FUNC_COLOR
Definition enums.h:6133
@ MSG_PRINT_FUNC_START_FX
Definition enums.h:6155
@ MSG_CHAR_PRINT_FUNCTION
Definition enums.h:6076
void appendGfx_message(MessagePrintState *, s16, s16, u16, u16, u16, u8)
Definition msg_draw.c:213
void initialize_printer(MessagePrintState *printer, s32 arg1, s32 arg2)
Definition msg.c:1303
void msg_copy_to_print_buffer(MessagePrintState *printer, s32 arg1, s32 arg2)
Definition msg.c:642

◆ mdl_get_shroud_tint_params()

void mdl_get_shroud_tint_params ( u8 * r,
u8 * g,
u8 * b,
u8 * a )

Definition at line 3912 of file model.c.

3912 {
3913 *r = ShroudTintR;
3914 *g = ShroudTintG;
3915 *b = ShroudTintB;
3916 *a = ShroudTintAmt;
3917}
u8 ShroudTintR
Definition model.c:569
u8 ShroudTintAmt
Definition model.c:568
u8 ShroudTintB
Definition model.c:571
u8 ShroudTintG
Definition model.c:570

◆ entity_base_block_idle()

s32 entity_base_block_idle ( Entity * entity)

Definition at line 195 of file Block.c.

195 {
196 BlockData* data = entity->dataBuf.block;
197 s32 ret = 0;
198
199 if (is_block_on_ground(entity) != 0) {
200 if (entity->flags & ENTITY_FLAG_200000) {
201 ret = 1;
203 if (data->item != -1) {
204 ItemEntity* itemEntity = get_item_entity(data->item);
205 itemEntity->pos.y = entity->pos.y + 4.0f;
206 }
207 }
208 }
209
210 return ret;
211}
void entity_base_block_update_slow_sinking(Entity *entity)
Definition Block.c:106
struct BlockData * block
s16 item
Definition entity.h:119
@ ENTITY_FLAG_200000
Definition enums.h:2634
ItemEntity * get_item_entity(s32 itemEntityIndex)
s32 is_block_on_ground(Entity *block)
Definition entity.c:1736

Referenced by entity_block_hit_animate_scale(), entity_BrickBlock_idle(), entity_HeartBlock_idle(), entity_ItemBlock_idle(), entity_MulticoinBlock_idle(), entity_SaveBlock_idle(), and entity_upgrade_block_idle().

◆ add_star_power()

void add_star_power ( s32 amt)

Definition at line 2145 of file inventory.c.

2145 {
2146 PlayerData* playerData = &gPlayerData;
2147 StatusBar* statusBar = &gStatusBar;
2148 s32 maxPower;
2149 s32 newPower;
2150
2152 statusBar->shimmerTime = 60;
2153
2154 if (playerData->starPower < 0) {
2155 statusBar->shimmerLimit = (playerData->starPower + 31) / SP_PER_SEG;
2156 } else {
2157 statusBar->shimmerLimit = playerData->starPower / SP_PER_SEG;
2158 }
2159
2160 playerData->starPower += amt;
2161
2162 maxPower = playerData->maxStarPower * SP_PER_BAR;
2163 if (playerData->starPower > maxPower) {
2164 playerData->starPower = maxPower;
2165 }
2166
2168}
@ STATUS_SHIMMER_BEGIN
Definition inventory.c:16

◆ entity_can_collide_with_jumping_player()

s32 entity_can_collide_with_jumping_player ( Entity * entity)

Definition at line 11 of file Shadow.c.

11 {
14 ) {
15 return TRUE;
16 }
17 return FALSE;
18}

Referenced by entity_HeartBlockContent_anim_idle().

◆ entity_base_block_init()

void entity_base_block_init ( Entity * entity)

Definition at line 213 of file Block.c.

213 {
214 BlockData* data = entity->dataBuf.block;
215
216 data->item = -1;
217 data->initialY = entity->pos.y;
218 data->sinkingTimer = -1;
219 entity->flags &= ~ENTITY_FLAG_200000;
220}
f32 initialY
Definition entity.h:121
s16 sinkingTimer
Definition entity.h:118

Referenced by entity_HeartBlock_create_child_entity(), entity_init_Hammer1Block_normal(), entity_ItemBlock_init(), entity_ItemlessBlock_init(), entity_MulticoinBlock_init(), entity_SaveBlock_init(), and entity_upgrade_block_init().

◆ entity_start_script()

◆ init_item_entity_list()

void init_item_entity_list ( void )

Definition at line 274 of file item_entity.c.

274 {
277 } else {
279 }
280
281 isPickingUpItem = FALSE;
282#if !VERSION_JP
283 D_801565A8 = FALSE;
284#endif
287}
BSS ItemEntity * BattleItemEntities[256]
Definition item_entity.c:40
BSS ItemEntity * WorldItemEntities[256]
Definition item_entity.c:39

Referenced by state_step_end_battle(), and state_step_unpause().

◆ init_script_list()

void init_script_list ( void )

Definition at line 182 of file script_list.c.

182 {
187 } else {
191 }
192
193 gNumScripts = 0;
194 IsUpdatingScripts = FALSE;
195
198}
void init_model_animators(void)
Definition model_api.c:278
void init_virtual_entity_list(void)
BSS u32 * gMapFlags
Definition script_list.c:9
BSS u32 gWorldMapFlags[MAX_MAPFLAGS]
Definition script_list.c:58
BSS u32 gBattleMapFlags[MAX_MAPFLAGS]
Definition script_list.c:59
BSS u32 gBattleMapVars[MAX_MAPVARS]
Definition script_list.c:62
BSS u32 gWorldMapVars[MAX_MAPVARS]
Definition script_list.c:61
BSS ScriptList gBattleScriptList
Definition script_list.c:13
BSS ScriptList gWorldScriptList
Definition script_list.c:12
BSS s32 * gMapVars
Definition script_list.c:10

Referenced by state_step_end_battle(), and state_step_unpause().

◆ init_entity_data()

void init_entity_data ( void )

Definition at line 840 of file entity.c.

840 {
845 } else {
846 s32 i;
847
848 for (i = 0; i < ARRAY_COUNT(bEntityBlueprint); i++) {
849 bEntityBlueprint[i] = 0;
850 }
853 }
858}
EntityList * get_entity_list(void)
Definition entity.c:538
#define WORLD_ENTITY_HEAP_BOTTOM
Definition entity.c:17
BSS EntityBlueprint * bEntityBlueprint[4]
Definition entity.c:62
s32 gEntityHeapBottom
Definition entity.c:46
s32 gEntityHeapBase
Definition entity.c:43
#define WORLD_ENTITY_HEAP_BASE
Definition entity.c:18
s32 entity_numShadows
Definition entity.c:47
void reload_world_entity_data(void)
Definition entity.c:860
Addr BattleEntityHeapBottom
ShadowList * get_shadow_list(void)
Definition entity.c:549

Referenced by state_step_end_battle(), and state_step_unpause().

◆ init_trigger_list()

void init_trigger_list ( void )

Definition at line 45 of file trigger.c.

45 {
48 } else {
50 }
51
52 gTriggerCount = 0;
53}
BSS TriggerList bTriggerList
Definition trigger.c:6
BSS TriggerList wTriggerList
Definition trigger.c:5

Referenced by state_step_end_battle(), and state_step_unpause().

◆ partner_init_after_battle()

void partner_init_after_battle ( s32 arg0)

Definition at line 926 of file partners.c.

926 {
927 PlayerStatus* playerStatus = &gPlayerStatus;
928 PartnerStatus* partnerStatus = &gPartnerStatus;
929
930 if (wCurrentPartnerId != partnerID) {
931 D_8010CFE0 = 1;
932 NextPartnerID = partnerID;
933 partnerStatus->partnerActionState = 0;
934 partnerStatus->shouldResumeAbility = FALSE;
935
936 if (wCurrentPartnerId != PARTNER_NONE && partnerID != PARTNER_NONE) {
938 } else if (partnerID == PARTNER_NONE) {
940 } else {
942 wSavedPartnerPosX = playerStatus->pos.x;
943 wSavedPartnerPosY = playerStatus->pos.y;
944 wSavedPartnerPosZ = playerStatus->pos.z;
945 }
946 }
947}
@ PARTNER_CMD_INSTA_SWITCH
Definition enums.h:2947

Referenced by state_step_end_battle().

◆ load_map_script_lib()

void load_map_script_lib ( void )

Definition at line 49 of file world.c.

49 {
50 DMA_COPY_SEGMENT(world_script_api);
51}

Referenced by load_map_by_IDs(), state_step_end_battle(), and state_step_unpause().

◆ remove_item_entity_by_index()

void remove_item_entity_by_index ( s32 index)

Definition at line 1287 of file item_entity.c.

1287 {
1288 ItemEntity* item = gCurrentItemEntities[index];
1289
1290 switch (item->spawnType) {
1298 break;
1299 }
1300
1302 gCurrentItemEntities[index] = NULL;
1303 isPickingUpItem = FALSE;
1304}

Referenced by entity_GiantChest_await_got_item().

◆ set_entity_commandlist()

void set_entity_commandlist ( Entity * entity,
s32 * entityScript )

◆ is_player_dismounted()

s32 is_player_dismounted ( void )

◆ func_800EF300()

void func_800EF300 ( void )

Definition at line 2382 of file partners.c.

2382 {
2384}

Referenced by action_update_use_spinning_flower(), entity_CymbalPlant_idle(), and func_802BC050_E2E980().

◆ func_800EF314()

void func_800EF314 ( void )

Definition at line 2386 of file partners.c.

2386 {
2388}

◆ func_800EF43C()

void func_800EF43C ( void )

Definition at line 2430 of file partners.c.

2430 {
2432 D_8010CFCA = 0;
2433 D_8010CFCE = 0;
2434}

◆ func_800EF3E4()

void func_800EF3E4 ( void )

Definition at line 2418 of file partners.c.

2418 {
2420 D_8010CFCA = 0;
2421 wPartnerMoveTime = 10;
2422 D_8010CFCE = 0;
2423}

Referenced by entity_Chest_idle().

◆ enable_player_shadow()

void enable_player_shadow ( void )

Definition at line 964 of file 77480.c.

964 {
965 get_shadow_by_index(gPlayerStatus.shadowID)->flags &= ~ENTITY_FLAG_HIDDEN;
966}

Referenced by func_802BC3A0_E2ECD0().

◆ get_msg_lines()

s32 get_msg_lines ( s32 messageID)

Definition at line 1979 of file msg.c.

1979 {
1980 s32 numLines;
1981
1982 get_msg_properties(msgID, NULL, NULL, NULL, &numLines, NULL, NULL, 0);
1983 return numLines;
1984}

Referenced by btl_menu_moves_show_error(), btl_message_popup_draw_content(), btl_show_message_popup(), btl_submenu_moves_update(), draw_content_pickup_item_header(), draw_merlee_message(), draw_merlee_message_string(), func_800F4C1C(), func_801363A0(), and popup_menu_update().

◆ set_window_properties()

void set_window_properties ( s32 panelID,
s32 posX,
s32 posY,
s32 width,
s32 height,
u8 priority,
void * drawContents,
void * drawContentsArg,
s8 parent )

Definition at line 373 of file windows.c.

373 {
374 Window* window = &gWindows[windowID];
375 u8 priorityCopy = priority;
376
378 window->pos.x = posX;
379 window->pos.y = posY;
380 window->width = width;
381 window->fpUpdate.i = 0;
382 window->parent = parent;
383 window->height = height;
384 window->fpDrawContents = fpDrawContents;
385 window->drawContentsArg0 = drawContentsArg0;
386 if (parent >= 0) {
388 }
389 update_window_hierarchy(windowID, priorityCopy);
390 window->originalPriority = priority;
391}
@ WINDOW_FLAG_HAS_CHILDREN
Definition enums.h:4996
void * drawContentsArg0
void(* fpDrawContents)(void)
void update_window_hierarchy(s32 windowID, u8 priority)
Definition windows.c:393

Referenced by btl_show_message_popup(), btl_state_update_celebration(), btl_submenu_moves_update(), btl_update_strats_menu(), draw_merlee_message(), func_801363A0(), popup_menu_update(), setup_pause_menu_tab(), and show_coin_counter().

◆ set_window_update()

◆ set_windows_visible()

void set_windows_visible ( s32 groupIdx)

Definition at line 445 of file windows.c.

445 {
446 u8 min = gWindowGroups[groupIdx].min;
447 u8 max = gWindowGroups[groupIdx].max;
448 s32 i;
449
450 for (i = 0; i < ARRAY_COUNT(gWindows); i++) {
452 if (i < min || i > max) {
454 } else {
455 gWindows[i].flags &= ~WINDOW_FLAG_DISABLED;
456 }
457 }
458 }
459}
WindowGroup gWindowGroups[]
Definition windows.c:128

Referenced by btl_state_update_end_battle(), btl_state_update_end_demo_battle(), initialize_battle(), state_init_pause(), state_step_exit_file_select(), state_step_file_select(), and state_step_unpause().

◆ partner_disable_input()

void partner_disable_input ( void )

Definition at line 2489 of file partners.c.

2489 {
2490 PartnerStatus* partnerStatus = &gPartnerStatus;
2491
2492 partnerStatus->inputDisabledCount++;
2493}

Referenced by check_input_open_menus(), SentinelAI_Descend(), start_battle(), update_encounters_neutral(), and update_item_entity_pickup().

◆ partner_set_goal_pos()

void partner_set_goal_pos ( s32 x,
s32 z )

Definition at line 2409 of file partners.c.

2409 {
2412}
s32 wPartnerMoveGoalZ
Definition partners.c:160
s32 wPartnerMoveGoalX
Definition partners.c:159

Referenced by func_800EF414().

◆ close_message()

void close_message ( MessagePrintState * msgPrintState)

Definition at line 1568 of file msg.c.

1568 {
1569 msgPrintState->stateFlags &= ~MSG_STATE_FLAG_40;
1570}

Referenced by _show_message(), and entity_SaveBlock_wait_for_close_choice().

◆ show_foreground_models_unchecked()

void show_foreground_models_unchecked ( void )

Definition at line 2978 of file 190B20.c.

2978 {
2979 Stage* stage = gBattleStatus.curStage;
2980
2981 if (stage != NULL && stage->foregroundModelList != NULL) {
2982 s32* idList = stage->foregroundModelList;
2983 while (*idList != STAGE_MODEL_LIST_END) {
2984 s32 id = *idList++;
2985 if (id >= 0) {
2987 model->flags &= ~MODEL_FLAG_HIDDEN;
2988 }
2989 }
2990 }
2991}
s32 get_model_list_index_from_tree_index(s32 treeIndex)
Definition model.c:3396
s32 * foregroundModelList
Definition battle.h:188
#define STAGE_MODEL_LIST_END
Definition battle.h:8

Referenced by tattle_cam_post_render().

◆ hide_foreground_models_unchecked()

void hide_foreground_models_unchecked ( void )

Definition at line 2963 of file 190B20.c.

2963 {
2964 Stage* stage = gBattleStatus.curStage;
2965
2966 if (stage != NULL && stage->foregroundModelList != NULL) {
2967 s32* idList = stage->foregroundModelList;
2968 while (*idList != STAGE_MODEL_LIST_END) {
2969 s32 id = *idList++;
2970 if (id >= 0) {
2972 model->flags |= MODEL_FLAG_HIDDEN;
2973 }
2974 }
2975 }
2976}
@ MODEL_FLAG_HIDDEN
Definition enums.h:4357

Referenced by tattle_cam_pre_render().

◆ show_foreground_models()

void show_foreground_models ( void )

Definition at line 3011 of file 190B20.c.

3011 {
3012 Stage* stage = gBattleStatus.curStage;
3013
3014 if (stage != NULL && stage->foregroundModelList != NULL) {
3015 s32* idList = stage->foregroundModelList;
3016 while (*idList != STAGE_MODEL_LIST_END) {
3017 s32 id = *idList++;
3018 if (id < 0) {
3019 break;
3020 } else {
3022 model->flags &= ~MODEL_FLAG_HIDDEN;
3023 }
3024 }
3025 }
3026}

◆ hide_foreground_models()

void hide_foreground_models ( void )

Definition at line 2993 of file 190B20.c.

2993 {
2994 Stage* stage = gBattleStatus.curStage;
2995
2996 if (stage != NULL && stage->foregroundModelList != NULL) {
2997 s32* idList = stage->foregroundModelList;
2998 while (*idList != STAGE_MODEL_LIST_END) {
2999 s32 id = *idList++;
3000 if (id < 0) {
3001 break;
3002 } else {
3004 model->flags |= MODEL_FLAG_HIDDEN;
3005 }
3006
3007 }
3008 }
3009}

◆ btl_set_state()

void btl_set_state ( s32 battleState)

Definition at line 166 of file btl_states_actions.c.

166 {
168 gBattleState = battleState;
170
172 if (flags) {
173 switch (battleState) {
175 battleState = BATTLE_STATE_TWINK_MENU;
176 break;
178 battleState = BATTLE_STATE_PEACH_MENU;
179 break;
182 break;
184 battleState = BATTLE_STATE_BEGIN_PLAYER_TURN;
185 break;
186 }
187 gBattleState = battleState;
188 }
189}

Referenced by btl_check_enemies_defeated(), btl_check_player_defeated(), btl_state_update_1C(), btl_state_update_9(), btl_state_update_begin_partner_turn(), btl_state_update_begin_player_turn(), btl_state_update_begin_turn(), btl_state_update_celebration(), btl_state_update_change_partner(), btl_state_update_defeat(), btl_state_update_defend(), btl_state_update_end_battle(), btl_state_update_end_demo_battle(), btl_state_update_end_partner_turn(), btl_state_update_end_player_turn(), btl_state_update_end_training_battle(), btl_state_update_end_turn(), btl_state_update_enemy_move(), btl_state_update_enemy_striking_first(), btl_state_update_first_strike(), btl_state_update_next_enemy(), btl_state_update_normal_start(), btl_state_update_partner_menu(), btl_state_update_partner_move(), btl_state_update_partner_striking_first(), btl_state_update_peach_menu(), btl_state_update_player_menu(), btl_state_update_player_move(), btl_state_update_prepare_menu(), btl_state_update_run_away(), btl_state_update_select_target(), btl_state_update_switch_to_partner(), btl_state_update_switch_to_player(), btl_state_update_twink_menu(), btl_state_update_victory(), btl_update(), and load_battle_section().

◆ draw_entity_model_A()

void draw_entity_model_A ( s32 modelIdx,
Mtx * transformMtx )

Definition at line 405 of file entity_model.c.

405 {
406 EntityModel* model;
407 RenderTask rt;
408 RenderTask* rtPtr = &rt;
409 Camera* camera = &gCameras[gCurrentCamID];
410 Matrix4f mtx;
411 f32 x, y, z, w;
412 f32 inX, inY, inZ;
413
414 if ((gGameStatusPtr->context == CONTEXT_WORLD) || (modelIdx & BATTLE_ENTITY_ID_BIT)) {
415 modelIdx &= ~BATTLE_ENTITY_ID_BIT;
416 model = (*gCurrentEntityModelList)[modelIdx];
417
418 if (model != NULL) {
419 if (model->flags != 0) {
420 if (!(model->flags & ENTITY_MODEL_FLAG_100)) {
421 if (!(model->flags & ENTITY_MODEL_FLAG_HIDDEN)) {
422 if (!(model->flags & ENTITY_MODEL_FLAG_40) && (model->flags & (1 << gCurrentCamID))) {
423 model->transform = *transformMtx;
424 model->vertexArray = NULL;
425 guMtxL2F(mtx, transformMtx);
426 inX = mtx[3][0];
427 inY = mtx[3][1];
428 inZ = mtx[3][2];
429 transform_point(camera->mtxPerspective, inX, inY, inZ, 1.0f, &x, &y, &z, &w);
430 rtPtr->renderMode = model->renderMode;
431 rtPtr->appendGfxArg = model;
432 rtPtr->appendGfx = (void(*)(void*))appendGfx_entity_model;
433 rtPtr->dist = ((u32)(model->flags & 0xF000) >> 8) + inZ;
434 queue_render_task(rtPtr);
435 }
436 }
437 }
438 }
439 }
440 }
441}
void appendGfx_entity_model(EntityModel *model)
@ ENTITY_MODEL_FLAG_100
Definition enums.h:5017
@ ENTITY_MODEL_FLAG_40
Definition enums.h:5015
Mtx transform
Definition entity.h:460
Vec3s * vertexArray
Definition entity.h:462
s8 renderMode
Definition entity.h:449

Referenced by btl_bonk_render(), render_entities(), render_shadows(), and virtual_entity_list_render_world().

◆ draw_entity_model_B()

void draw_entity_model_B ( s32 modelIdx,
Mtx * transformMtx,
s32 vertexSegment,
Vec3s * vertexArray )

Definition at line 443 of file entity_model.c.

443 {
444 EntityModel* model;
445 RenderTask rt;
446 RenderTask* rtPtr = &rt;
447 Camera* camera = &gCameras[gCurrentCamID];
448 Matrix4f mtx;
449 f32 x, y, z, w;
450 f32 inX, inY, inZ;
451
452 if ((gGameStatusPtr->context == CONTEXT_WORLD) || (modelIdx & BATTLE_ENTITY_ID_BIT)) {
453 modelIdx &= ~BATTLE_ENTITY_ID_BIT;
454 model = (*gCurrentEntityModelList)[modelIdx];
455
456 if (model != NULL) {
457 if (model->flags != 0) {
458 if (!(model->flags & ENTITY_MODEL_FLAG_100)) {
459 if (!(model->flags & ENTITY_MODEL_FLAG_HIDDEN)) {
460 if (model->flags & (1 << gCurrentCamID)) {
461 model->transform = *transformMtx;
462 D_80154374 = vertexSegment;
463 model->vertexArray = vertexArray;
464 guMtxL2F(mtx, transformMtx);
465 inX = mtx[3][0];
466 inY = mtx[3][1];
467 inZ = mtx[3][2];
468 transform_point(camera->mtxPerspective, inX, inY, inZ, 1.0f, &x, &y, &z, &w);
469 rtPtr->renderMode = model->renderMode;
470 rtPtr->appendGfxArg = model;
471 rtPtr->appendGfx = (void(*)(void*))appendGfx_entity_model;
472 rtPtr->dist = ((u32)(model->flags & 0xF000) >> 8) + inZ;
473 queue_render_task(rtPtr);
474 }
475 }
476 }
477 }
478 }
479 }
480}
BSS s32 D_80154374

Referenced by render_entities(), and render_shadows().

◆ draw_entity_model_C()

void draw_entity_model_C ( s32 modelIdx,
Mtx * transformMtx )

Definition at line 482 of file entity_model.c.

482 {
483 EntityModel* model;
484 RenderTask rt;
485 RenderTask* rtPtr = &rt;
486
487 if ((gGameStatusPtr->context == CONTEXT_WORLD) || (modelIdx & BATTLE_ENTITY_ID_BIT)) {
488 modelIdx &= ~BATTLE_ENTITY_ID_BIT;
489 model = (*gCurrentEntityModelList)[modelIdx];
490
491 if (model != NULL) {
492 if (model->flags != 0) {
493 if (!(model->flags & ENTITY_MODEL_FLAG_100)) {
494 if (!(model->flags & ENTITY_MODEL_FLAG_HIDDEN)) {
495 if (!(model->flags & ENTITY_MODEL_FLAG_40) && (model->flags & (1 << gCurrentCamID))) {
497 model->transform = *transformMtx;
498 model->vertexArray = NULL;
499 rtPtr->renderMode = model->renderMode;
500 rtPtr->appendGfxArg = model;
501 rtPtr->appendGfx = (void(*)(void*))appendGfx_entity_model;
502 rtPtr->dist = (u32)(model->flags & 0xF000) >> 8;
503 queue_render_task(rtPtr);
504 }
505 }
506 }
507 }
508 }
509 }
510}
@ ENTITY_MODEL_FLAG_REFLECT
Definition enums.h:5018

◆ draw_entity_model_D()

void draw_entity_model_D ( s32 modelIdx,
Mtx * transformMtx,
s32 arg2,
Vec3s * vertexArray )

Definition at line 512 of file entity_model.c.

512 {
513 EntityModel* model;
514 RenderTask rt;
515 RenderTask* rtPtr = &rt;
516
517 if ((gGameStatusPtr->context == CONTEXT_WORLD) || (modelIdx & BATTLE_ENTITY_ID_BIT)) {
518 modelIdx &= ~BATTLE_ENTITY_ID_BIT;
519 model = (*gCurrentEntityModelList)[modelIdx];
520
521 if (model != NULL) {
522 if (model->flags != 0) {
523 if (!(model->flags & ENTITY_MODEL_FLAG_100)) {
524 if (!(model->flags & ENTITY_MODEL_FLAG_HIDDEN)) {
525 if (model->flags & (1 << gCurrentCamID)) {
527 model->transform = *transformMtx;
528 D_80154374 = arg2;
529 model->vertexArray = vertexArray;
530 rtPtr->renderMode = model->renderMode;
531 rtPtr->appendGfxArg = model;
532 rtPtr->appendGfx = (void(*)(void*))appendGfx_entity_model;
533 rtPtr->dist = (u32)(model->flags & 0xF000) >> 8;
534 queue_render_task(rtPtr);
535 }
536 }
537 }
538 }
539 }
540 }
541}

◆ draw_entity_model_E()

void draw_entity_model_E ( s32 modelIdx,
Mtx * transformMtx )

Definition at line 543 of file entity_model.c.

543 {
544 EntityModel* model = (*gCurrentEntityModelList)[modelIdx & ~BATTLE_ENTITY_ID_BIT];
545 Matrix4f mtx;
546 Matrix4f mtx2;
547 ImgFXTexture ifxImg;
548 Matrix4f imgfxMtx;
549
550 if (model == NULL) {
551 return;
552 }
553 if (model->flags == 0) {
554 return;
555 }
556 if (model->flags & ENTITY_MODEL_FLAG_100) {
557 return;
558 }
559 if (model->flags & ENTITY_MODEL_FLAG_HIDDEN) {
560 return;
561 }
562 if (model->flags & ENTITY_MODEL_FLAG_40) {
563 return;
564 }
565 if (!(model->flags & ENTITY_MODEL_FLAG_CAM3)) {
566 return;
567 }
568
569 model->transform = *transformMtx;
570 model->vertexArray = NULL;
572 gSPMatrix(gMainGfxPos++, &gDisplayContext->matrixStack[gMatrixListPos++], G_MTX_PUSH | G_MTX_LOAD | G_MTX_MODELVIEW);
573 if (!(model->flags & ENTITY_MODEL_FLAG_USE_IMAGE)) {
575 case FALSE:
576 switch (model->renderMode) {
578 gSPDisplayList(gMainGfxPos++, Gfx_RM1_SURFACE_OPA);
579 break;
581 gSPDisplayList(gMainGfxPos++, Gfx_RM1_DECAL_OPA);
582 break;
584 gSPDisplayList(gMainGfxPos++, Gfx_RM1_INTERSECTING_OPA);
585 break;
587 gSPDisplayList(gMainGfxPos++, Gfx_RM1_ALPHATEST);
588 break;
592 gSPDisplayList(gMainGfxPos++, Gfx_RM1_SURFACE_XLU);
593 break;
595 gSPDisplayList(gMainGfxPos++, Gfx_RM1_SURFACE_XLU_NO_AA);
596 break;
599 gSPDisplayList(gMainGfxPos++, Gfx_RM1_DECAL_XLU);
600 break;
603 gSPDisplayList(gMainGfxPos++, Gfx_RM1_DECAL_XLU_NO_AA);
604 break;
606 gSPDisplayList(gMainGfxPos++, Gfx_RM1_INTERSECTING_XLU);
607 break;
609 gSPDisplayList(gMainGfxPos++, Gfx_RM1_PASS_THROUGH);
610 break;
612 gSPDisplayList(gMainGfxPos++, Gfx_RM1_ALPHATEST_ONESIDED);
613 break;
616 gSPDisplayList(gMainGfxPos++, Gfx_RM1_SURFACE_OPA_NO_ZB);
617 break;
620 gSPDisplayList(gMainGfxPos++, Gfx_RM1_ALPHATEST_NO_ZB);
621 break;
624 gSPDisplayList(gMainGfxPos++, Gfx_RM1_SURFACE_XLU_NO_ZB);
625 break;
627 gSPDisplayList(gMainGfxPos++, Gfx_RM1_CLOUD_NO_ZCMP);
628 break;
629 }
630 break;
631 case TRUE:
632 switch (model->renderMode) {
634 gSPDisplayList(gMainGfxPos++, Gfx_RM3_SURFACE_OPA);
635 break;
637 gSPDisplayList(gMainGfxPos++, Gfx_RM3_DECAL_OPA);
638 break;
640 gSPDisplayList(gMainGfxPos++, Gfx_RM3_INTERSECTING_OPA);
641 break;
643 gSPDisplayList(gMainGfxPos++, Gfx_RM3_ALPHATEST);
644 break;
646 gSPDisplayList(gMainGfxPos++, Gfx_RM3_SURFACE_XLU);
647 break;
649 gSPDisplayList(gMainGfxPos++, Gfx_RM3_DECAL_XLU);
650 break;
652 gSPDisplayList(gMainGfxPos++, Gfx_RM3_INTERSECTING_XLU);
653 break;
654 }
657 break;
658 }
659 gSPClearGeometryMode(gMainGfxPos++, G_LIGHTING);
661 gDPSetCombineMode(gMainGfxPos++, G_CC_MODULATEIA, G_CC_MODULATEIA);
662 } else {
663 gDPSetCombineMode(gMainGfxPos++, PM_CC_42, PM_CC2_MULTIPLY_SHADE);
664 }
665 if (model->vertexArray != NULL) {
667 }
668 gSPDisplayList(gMainGfxPos++, model->gfx.displayList);
669 gSPPopMatrix(gMainGfxPos++, G_MTX_MODELVIEW);
670 gDPPipeSync(gMainGfxPos++);
671 if (!(model->flags & ENTITY_MODEL_FLAG_REFLECT)) {
672 return;
673 }
674
675 guMtxL2F(mtx, &model->transform);
677 guMtxCatF(mtx, mtx2, mtx);
678 guMtxF2L(mtx, &model->transform);
680 gSPMatrix(gMainGfxPos++, &gDisplayContext->matrixStack[gMatrixListPos++], G_MTX_PUSH | G_MTX_LOAD | G_MTX_MODELVIEW);
681 gSPDisplayList(gMainGfxPos++, model->gfx.displayList);
682 } else {
683 SpriteRasterInfo* imageData;
684
685 gDPPipeSync(gMainGfxPos++);
686 gSPClearGeometryMode(gMainGfxPos++, G_ZBUFFER | G_SHADE | G_CULL_BOTH | G_FOG | G_LIGHTING | G_TEXTURE_GEN | G_TEXTURE_GEN_LINEAR | G_LOD | G_SHADING_SMOOTH);
687 gSPSetGeometryMode(gMainGfxPos++, G_ZBUFFER | G_SHADE | G_LIGHTING | G_SHADING_SMOOTH);
688 gSPSetLights1(gMainGfxPos++, D_8014C268);
689 gSPTexture(gMainGfxPos++, -1, -1, 0, G_TX_RENDERTILE, G_ON);
690 gDPSetAlphaCompare(gMainGfxPos++, G_AC_NONE);
691 gSPSetOtherMode(gMainGfxPos++, G_SETOTHERMODE_H, G_MDSFT_ALPHADITHER, 18, G_AD_DISABLE | G_CD_DISABLE | G_CK_NONE | G_TC_FILT | G_TF_BILERP | G_TT_NONE | G_TL_TILE | G_TD_CLAMP | G_TP_PERSP | G_CYC_1CYCLE);
692
693 imageData = model->gfx.imageData;
694 ifxImg.raster = imageData->raster;
695 ifxImg.palette = imageData->defaultPal;
696 ifxImg.width = imageData->width;
697 ifxImg.height = imageData->height;
698 ifxImg.xOffset = -imageData->width / 2;
699 ifxImg.yOffset = imageData->height / 2;
700 ifxImg.alpha = 255;
701 guMtxL2F(imgfxMtx, &model->transform);
702 imgfx_appendGfx_component(0, &ifxImg, 0, imgfxMtx);
703 }
704
705 gSPPopMatrix(gMainGfxPos++, G_MTX_MODELVIEW);
706 gDPPipeSync(gMainGfxPos++);
707}
Gfx Gfx_RM3_SURFACE_OPA[]
Definition model.c:1067
void make_entity_model_mtx_flipZ(Matrix4f mtx)
Gfx Gfx_RM3_DECAL_XLU[]
Definition model.c:1117
Gfx Gfx_RM3_DECAL_OPA[]
Definition model.c:1077
Gfx Gfx_RM1_SURFACE_XLU[]
Definition model.c:686
Gfx Gfx_RM1_DECAL_XLU[]
Definition model.c:696
Gfx Gfx_RM1_ALPHATEST_ONESIDED[]
Definition model.c:746
Lights1 D_8014C268
Definition entity_model.c:8
Gfx Gfx_RM1_SURFACE_XLU_NO_AA[]
Definition model.c:756
Gfx Gfx_RM1_DECAL_OPA[]
Definition model.c:654
Gfx Gfx_RM1_ALPHATEST[]
Definition model.c:676
Gfx Gfx_RM1_INTERSECTING_XLU[]
Definition model.c:706
Gfx Gfx_RM1_SURFACE_OPA[]
Definition model.c:643
Gfx Gfx_RM3_INTERSECTING_XLU[]
Definition model.c:1127
Gfx Gfx_RM1_ALPHATEST_NO_ZB[]
Definition model.c:810
Gfx Gfx_RM3_INTERSECTING_OPA[]
Definition model.c:1087
Gfx Gfx_RM1_CLOUD_NO_ZCMP[]
Definition model.c:844
Gfx Gfx_RM3_ALPHATEST[]
Definition model.c:1097
Gfx Gfx_RM1_SURFACE_OPA_NO_ZB[]
Definition model.c:800
Gfx Gfx_RM1_DECAL_XLU_NO_AA[]
Definition model.c:766
Gfx Gfx_RM1_PASS_THROUGH[]
Definition model.c:779
Gfx Gfx_RM1_SURFACE_XLU_NO_ZB[]
Definition model.c:820
Gfx Gfx_RM1_INTERSECTING_OPA[]
Definition model.c:665
Gfx Gfx_RM3_SURFACE_XLU[]
Definition model.c:1107
@ ENTITY_MODEL_FLAG_FOG_DISABLED
Definition enums.h:5020
@ ENTITY_MODEL_FLAG_USE_IMAGE
Definition enums.h:5019
@ ENTITY_MODEL_FLAG_CAM3
Definition enums.h:5012
@ RENDER_MODE_ALPHATEST_ONESIDED
Definition enums.h:3278
@ RENDER_MODE_SURFACE_OPA_NO_ZB
Definition enums.h:3267
@ RENDER_MODE_DECAL_OPA
Definition enums.h:3268
@ RENDER_MODE_SURFACE_XLU_LAYER3
Definition enums.h:3299
@ RENDER_MODE_DECAL_XLU_NO_AA
Definition enums.h:3293
@ RENDER_MODE_SURFACE_XLU_NO_AA
Definition enums.h:3284
@ RENDER_MODE_INTERSECTING_XLU
Definition enums.h:3303
@ RENDER_MODE_PASS_THROUGH
Definition enums.h:3306
@ RENDER_MODE_DECAL_XLU
Definition enums.h:3291
@ RENDER_MODE_SHADOW
Definition enums.h:3297
@ RENDER_MODE_SURFACE_XLU_NO_ZB
Definition enums.h:3285
@ RENDER_MODE_SURFACE_XLU_NO_ZB_BEHIND
Definition enums.h:3310
@ RENDER_MODE_SURFACE_OPA_NO_ZB_BEHIND
Definition enums.h:3308
@ RENDER_MODE_DECAL_XLU_AHEAD
Definition enums.h:3295
@ RENDER_MODE_ALPHATEST_NO_ZB_BEHIND
Definition enums.h:3309
@ RENDER_MODE_INTERSECTING_OPA
Definition enums.h:3272
@ RENDER_MODE_ALPHATEST_NO_ZB
Definition enums.h:3279
#define PM_CC2_MULTIPLY_SHADE
Definition macros.h:312
#define PM_CC_42
Definition macros.h:471
#define VIRTUAL_TO_PHYSICAL(addr)
Definition macros.h:47
union EntityModel::@43 gfx

Referenced by virtual_entity_list_render_UI().

◆ free_entity_model_by_index()

void free_entity_model_by_index ( s32 idx)

Definition at line 727 of file entity_model.c.

727 {
728 s32 index = idx & ~BATTLE_ENTITY_ID_BIT;
729 EntityModel* entityModel = (*gCurrentEntityModelList)[index];
730
731 if (entityModel != NULL && entityModel->flags) {
732 if (entityModel->flags & ENTITY_MODEL_FLAG_USE_IMAGE) {
733 heap_free(entityModel->gfx.imageData);
734 }
735 {
736 s32* modelCount = &gEntityModelCount;
738 (*gCurrentEntityModelList)[index] = NULL;
739 (*modelCount)--;
740 }
741 }
742}

Referenced by btl_bonk_update(), delete_entity(), delete_entity_and_unload_data(), delete_shadow(), free_entity_model_by_ref(), and virtual_entity_delete_by_index().

◆ btl_cam_use_preset()

◆ btl_cam_set_params()

void btl_cam_set_params ( b16 skipRecalc,
s16 boomLength,
s16 vfovScale,
s16 boomPitch,
s32 boomYaw,
s32 boomZOffset,
s32 zoomPercent )

Definition at line 1939 of file camera.c.

1939 {
1940 Camera* camera = &gCameras[CAM_BATTLE];
1941
1942 if (!BattleCam_IsFrozen) {
1943 camera->params.basic.skipRecalc = skipRecalc;
1944 camera->params.basic.dist = boomLength;
1945 camera->params.basic.fovScale = vfovScale;
1946 camera->params.basic.pitch = boomPitch;
1947 camera->params.basic.yaw = boomYaw;
1948 camera->params.basic.offsetY = boomZOffset * 256;
1949 camera->params.basic.zoomPercent = zoomPercent;
1950 }
1951}

Referenced by btl_state_update_celebration().

◆ btl_cam_set_zoffset()

void btl_cam_set_zoffset ( s16 zOffset)

Definition at line 1996 of file camera.c.

1996 {
1997 if (!BattleCam_IsFrozen) {
1998 BattleCam_BoomOffsetY = zOffset;
1999 }
2000}

Referenced by btl_state_update_change_partner().

◆ btl_cam_target_actor()

void btl_cam_target_actor ( s32 actorID)

◆ btl_cam_set_zoom()

void btl_cam_set_zoom ( s16 zoom)

Definition at line 1984 of file camera.c.

1984 {
1985 if (!BattleCam_IsFrozen) {
1986 BattleCam_BoomLength = zoom;
1987 }
1988}

Referenced by btl_state_update_change_partner().

◆ btl_cam_move()

◆ btl_cam_disable_clamp_x()

void btl_cam_disable_clamp_x ( void )

Definition at line 2006 of file camera.c.

2006 {
2007 BattleCam_ClampPosX = FALSE;
2008}

◆ initialize_battle()

void initialize_battle ( void )

Definition at line 160 of file 16C8E0.c.

160 {
161 PlayerData* playerData = &gPlayerData;
162 BattleStatus* battleStatus = &gBattleStatus;
163 Camera* tattleCam = &gCameras[CAM_TATTLE];
164 HudElemID hid;
165 s32 i;
166
171 gOverrideFlags &= ~GLOBAL_OVERRIDES_ENABLE_FLOOR_REFLECTION;
173 gOverrideFlags &= ~GLOBAL_OVERRIDES_ENABLE_FLOOR_REFLECTION;
174
175 for (i = 0; i < ARRAY_COUNT(battleStatus->pushInputBuffer); i++) {
176 battleStatus->pushInputBuffer[i] = 0;
177 }
178
179 battleStatus->inputBufferPos = 0;
180 battleStatus->holdInputBufferPos = 0;
181 battleStatus->waitForState = BATTLE_STATE_0;
182
183 for (i = 0; i < ARRAY_COUNT(battleStatus->enemyActors); i++) {
184 battleStatus->enemyActors[i] = NULL;
185 }
186
187 battleStatus->playerActor = NULL;
188 battleStatus->partnerActor = NULL;
189
190 for (i = 0; i < ARRAY_COUNT(battleStatus->lastPlayerMenuSelection); i++) {
191 battleStatus->lastPlayerMenuSelection[i] = -1;
192 battleStatus->lastPartnerMenuSelection[i] = -1;
193 }
194
195 for (i = 0; i < ARRAY_COUNT(battleStatus->tattleFlags); i++) {
196 battleStatus->tattleFlags[i] = 0;
197 }
198
202 } else {
203 gBattleStatus.flags2 &= ~BS_FLAGS2_PEACH_BATTLE;
204 }
205
212
213 for (i = 0; i < ARRAY_COUNT(BtlStarPointTensHIDs); i++) {
217 }
218
219 for (i = 0; i < ARRAY_COUNT(BtlStarPointShinesHIDs); i++) {
223 }
224
225 for (i = 0; i < ARRAY_COUNT(BtlStarPointOnesHIDs); i++) {
229 }
230
233
234 if (playerData->battlesCount < 9999) {
235 playerData->battlesCount++;
236 }
237
238 bSavedPartner = playerData->curPartner;
240 playerData->curPartner = PARTNER_TWINK;
241 }
242}
HudScript HES_ItemStarPoint
void tattle_cam_pre_render(Camera *)
Definition 16C8E0.c:722
HudScript HES_StatusSPShine
void btl_render_actors(void)
Definition 16C8E0.c:620
HudScript HES_HPBar
BSS HudElemID HPBarHID
Definition 16C8E0.c:26
void tattle_cam_post_render(Camera *)
Definition 16C8E0.c:855
BSS HudElemID BtlStarPointTensHIDs[10]
Definition 16C8E0.c:27
HudScript HES_SmallStarPoint
BSS HudElemID BtlStarPointOnesHIDs[10]
Definition 16C8E0.c:29
BSS HudElemID BtlStarPointShinesHIDs[10]
Definition 16C8E0.c:28
void create_action_command_ui_worker(void)
Definition action_cmd.c:531
@ WINDOW_GROUP_BATTLE
Definition enums.h:5323
void btl_popup_messages_init(void)
s32 pushInputBuffer[64]

Referenced by state_step_battle().

◆ dispatch_event_actor()

void dispatch_event_actor ( Actor * actor,
s32 event )

Definition at line 103 of file 1A5830.c.

103 {
104 Evt* handleEventScript = actor->handleEventScript;
105 s32 onHitID = actor->handleEventScriptID;
106
107 if (actor->handleEventSource != NULL) {
108 Evt* newScript;
109
110 actor->lastEventType = event;
112 actor->handleEventScript = newScript;
113 actor->handleEventScriptID = newScript->id;
114 newScript->owner1.actorID = actor->actorID;
115 }
116
117 if (actor->takeTurnScript != NULL) {
120 actor->takeTurnScript = NULL;
121 }
122
123 if (handleEventScript != NULL) {
124 kill_script_by_ID(onHitID);
125 }
126}
Evt * get_script_by_index(s32 index)

Referenced by btl_state_update_9(), calc_enemy_damage_target(), calc_item_damage_enemy(), calc_partner_damage_enemy(), calc_partner_test_enemy(), calc_player_damage_enemy(), calc_player_test_enemy(), dispatch_damage_event_actor(), and dispatch_event_general().

◆ dispatch_damage_event_actor_1()

s32 dispatch_damage_event_actor_1 ( Actor * actor,
s32 damageAmount,
s32 event )

Definition at line 893 of file 1A5830.c.

893 {
894 return dispatch_damage_event_actor(actor, damageAmount, event, TRUE);
895}

Referenced by calc_enemy_damage_target().

◆ reset_battle_status()

void reset_battle_status ( void )

Definition at line 100 of file battle.c.

100 {
105 gCurrentBattlePtr = NULL;
107 gCurrentStagePtr = NULL;
108 gCurrentStageID = 0;
109 gOverrideBattlePtr = NULL;
110}
BSS Battle * gOverrideBattlePtr
Definition battle.c:18
BSS StageListRow * gCurrentStagePtr
Definition battle.c:9

Referenced by load_demo_battle(), load_map_by_IDs(), state_step_demo(), state_step_intro(), and state_step_startup().

◆ btl_show_variable_battle_message()

void btl_show_variable_battle_message ( s32 messageIndex,
s32 duration,
s32 varValue )

Definition at line 601 of file popup_messages.c.

601 {
603
604 if (popup != NULL) {
607 popup->unk_00 = FALSE;
608 popup->renderWorldFunc = NULL;
609 popup->messageIndex = messageIndex;
610 popup->duration = duration;
612 popup->needsInit = TRUE;
613 popup->data.bonk = NULL;
614 BattlePopupMessageVar = varValue;
615 bPopupMessage = popup;
619#if !VERSION_JP
621#endif
622 }
623}

Referenced by btl_state_update_partner_menu(), btl_state_update_peach_menu(), btl_state_update_player_menu(), and btl_state_update_twink_menu().

◆ btl_is_popup_displayed()

◆ btl_cam_use_preset_immediately()

void btl_cam_use_preset_immediately ( s32 preset)

Definition at line 1912 of file camera.c.

1912 {
1913 if (!BattleCam_IsFrozen) {
1914 BattleCam_SetImmediately = TRUE;
1916 }
1917}

◆ inflict_status()

s32 inflict_status ( Actor * target,
s32 statusTypeKey,
s32 duration )

Definition at line 2084 of file 190B20.c.

2084 {
2085 BattleStatus* battleStatus = &gBattleStatus;
2086 EffectInstance* effect;
2087
2088 switch (statusTypeKey) {
2089 case STATUS_KEY_FEAR:
2090 case STATUS_KEY_DIZZY:
2092 case STATUS_KEY_SLEEP:
2093 case STATUS_KEY_FROZEN:
2094 case STATUS_KEY_STOP:
2095 case STATUS_KEY_POISON:
2096 case STATUS_KEY_SHRINK:
2098 !is_ability_active(ABILITY_BERSERKER) && battleStatus->hustleTurns == 0)) {
2099
2100 if (target->actorID != ACTOR_PARTNER) {
2101 if (target->debuff != statusTypeKey) {
2102 target->statusAfflicted = statusTypeKey;
2103 }
2104 target->disableEffect->data.disableX->koDuration = 0;
2105 target->debuff = statusTypeKey;
2106 target->debuffDuration = duration;
2107 if ((s8)duration > 9) {
2108 target->debuffDuration = 9;
2109 }
2110
2111 switch (statusTypeKey) {
2112 case STATUS_KEY_FROZEN:
2113 if (target->actorID != ACTOR_PARTNER) {
2114 effect = target->icePillarEffect;
2115 if (effect != NULL) {
2117 }
2118 target->icePillarEffect = fx_ice_pillar(0, target->curPos.x, target->curPos.y,
2119 target->curPos.z, 1.0f, 0);
2121 }
2122 return TRUE;
2123 case STATUS_KEY_SLEEP:
2126 return TRUE;
2130 return TRUE;
2131 case STATUS_KEY_DIZZY:
2133 return TRUE;
2134 case STATUS_KEY_FEAR:
2137 return TRUE;
2138 case STATUS_KEY_POISON:
2141 return TRUE;
2142 case STATUS_KEY_SHRINK:
2144 return TRUE;
2145 }
2146 }
2147 return TRUE;
2148 } else {
2149 return FALSE;
2150 }
2151 break;
2152 case STATUS_KEY_STATIC:
2153 if (target->actorID != ACTOR_PARTNER) {
2154 target->staticStatus = statusTypeKey;
2155 target->staticDuration = duration;
2156 if ((s8)duration > 9) {
2157 target->staticDuration = 9;
2158 }
2162 }
2163 return TRUE;
2164 case STATUS_KEY_STONE:
2165 if (target->actorID != ACTOR_PARTNER) {
2166 target->stoneStatus = STATUS_KEY_STONE;
2167 target->stoneDuration = duration;
2168 if ((s8)duration > 9) {
2169 target->stoneDuration = 9;
2170 }
2172 }
2173 return TRUE;
2174 case STATUS_KEY_DAZE:
2175 if (target->koStatus < statusTypeKey) {
2176 target->koStatus = STATUS_KEY_DAZE;
2177 target->koDuration = duration;
2178 if ((s8)duration > 9) {
2179 target->koDuration = 9;
2180 }
2182 }
2183 return TRUE;
2185 if (target->actorID != ACTOR_PARTNER) {
2187 target->transparentDuration = duration;
2188 if ((s8)duration > 9) {
2189 target->transparentDuration = 9;
2190 }
2193 }
2194 return TRUE;
2195 case 0:
2196 case STATUS_KEY_NORMAL:
2197 case STATUS_KEY_DEFAULT:
2198 default:
2199 return TRUE;
2200 }
2201}
void set_actor_pal_adjustment(Actor *actor, s32 palAdjust)
Definition 190B20.c:2607
@ STATUS_KEY_DEFAULT
Definition enums.h:2198

Referenced by calc_item_damage_enemy(), dispatch_damage_event_partner(), inflict_partner_ko(), inflict_status_set_duration(), and try_inflict_status().

◆ try_inflict_status()

s32 try_inflict_status ( Actor * actor,
s32 statusTypeKey,
s32 statusKey )

Definition at line 2532 of file 190B20.c.

2532 {
2533 BattleStatus* battleStatus = &gBattleStatus;
2534 s32 chance;
2535 s32 duration;
2536
2537 if (battleStatus->statusChance == STATUS_KEY_IGNORE_RES) {
2538 duration = battleStatus->statusDuration;
2539 duration += lookup_status_duration_mod(actor->statusTable, statusKey);
2540 return inflict_status_set_duration(actor, statusTypeKey, statusKey, duration);
2541 }
2542
2543 duration = 0;
2544
2545 if (actor->statusTable != NULL) {
2546 if (!(battleStatus->curAttackStatus & STATUS_FLAG_RIGHT_ON)) {
2547 chance = lookup_status_chance(actor->statusTable, statusTypeKey);
2548 } else {
2549 chance = lookup_status_chance(actor->statusTable, statusTypeKey);
2550 if (chance != 0) {
2551 chance = 100;
2552 }
2553 }
2554
2555 if (chance > 0) {
2556 chance = (chance * battleStatus->statusChance) / 100;
2557 if (chance > 0 && chance >= rand_int(100)) {
2558 duration = 3;
2559 duration += lookup_status_duration_mod(actor->statusTable, statusKey);
2560 }
2561 }
2562 } else {
2563 duration = 3;
2564 }
2565
2566 if (duration > 0) {
2567 if (battleStatus->curAttackStatus < 0) {
2568 duration = battleStatus->statusDuration;
2569 duration += lookup_status_duration_mod(actor->statusTable, statusKey);
2570 inflict_status(actor, statusTypeKey, duration);
2571 } else {
2572 inflict_status(actor, statusTypeKey, duration);
2573
2574 }
2575 } else {
2576 duration = 0;
2577 }
2578 return duration;
2579}
s32 lookup_status_duration_mod(s32 *statusTable, s32 statusKey)
Definition 190B20.c:2065
s32 inflict_status(Actor *target, s32 statusTypeKey, s32 duration)
Definition 190B20.c:2084
s32 inflict_status_set_duration(Actor *actor, s32 statusTypeKey, s32 statusDurationKey, s32 duration)
Definition 190B20.c:2581
s32 lookup_status_chance(s32 *statusTable, s32 statusKey)
Definition 190B20.c:2046
@ STATUS_FLAG_RIGHT_ON
Definition enums.h:2829
#define STATUS_KEY_IGNORE_RES
Definition macros.h:226

Referenced by calc_enemy_damage_target().

◆ inflict_status_set_duration()

s32 inflict_status_set_duration ( Actor * actor,
s32 statusTypeKey,
s32 statusDurationKey,
s32 duration )

Definition at line 2581 of file 190B20.c.

2581 {
2582 s32 statusDuration = 0;
2583
2584 if (actor->statusTable == NULL || lookup_status_chance(actor->statusTable, statusTypeKey) > 0) {
2585 statusDuration = duration;
2586 }
2587
2588 if (statusDuration > 0) {
2589 return inflict_status(actor, statusTypeKey, statusDuration);
2590 } else {
2591 return 0;
2592 }
2593}

Referenced by btl_state_update_normal_start(), and try_inflict_status().

◆ mdl_set_all_tint_type()

void mdl_set_all_tint_type ( s32 tintType)

Definition at line 4519 of file model.c.

4519 {
4520 ModelList* modelList = gCurrentModels;
4521 Model* model;
4522 s32 type = tintType; // weirdness here and the next line needed to match
4523 s32 i = tintType;
4524
4525 for (i = 0; i < ARRAY_COUNT(*modelList); i++) {
4526 model = (*modelList)[i];
4527
4528 if (model != NULL) {
4530 }
4531 }
4532}
@ CUSTOM_GFX_NONE
Definition enums.h:4419
void set_mdl_custom_gfx_set(Model *model, s32 customGfxIndex, u32 tintType)
Definition model.c:3831
Model * ModelList[256]
Definition model.h:94

Referenced by btl_state_update_celebration().

◆ load_model_animator_tree()

void load_model_animator_tree ( s32 index,
StaticAnimatorNode ** tree )

Definition at line 1171 of file animator.c.

1171 {
1172 ModelAnimator* animator = (*gCurrentAnimMeshListPtr)[index & ~BATTLE_ID_BIT];
1173 s32 nodeIDs[ARRAY_COUNT(animator->staticNodeIDs)];
1174
1175 if (animator == NULL || animator->flags == 0) {
1176 return;
1177 }
1178
1179 gAnimTreeRoot = tree;
1180 load_model_animator_node(*tree, animator, 0, nodeIDs);
1181 set_animator_tree_to_node_map(animator, nodeIDs, ARRAY_COUNT(animator->staticNodeIDs));
1182}
void set_animator_tree_to_node_map(ModelAnimator *animator, s32 *nodeIDs, s32 count)
Definition animator.c:1032
void load_model_animator_node(StaticAnimatorNode *node, ModelAnimator *animator, s32 parentNodeID, s32 *treeIndexToNodeIDs)
Definition animator.c:1132

Referenced by create_shadow_from_data(), load_mesh_animator_tree(), and load_split_entity_data().

◆ inflict_partner_ko()

s32 inflict_partner_ko ( Actor * target,
s32 statusTypeKey,
s32 duration )

Definition at line 2203 of file 190B20.c.

2203 {
2204 if (statusTypeKey == STATUS_KEY_DAZE) {
2205 if (statusTypeKey != target->koStatus) {
2206 inflict_status(target, STATUS_KEY_DAZE, duration);
2208 } else {
2209 target->koDuration += duration;
2210 if (target->koDuration > 9) {
2211 target->koDuration = 9;
2212 }
2213 }
2214 }
2215
2216 return TRUE;
2217}

Referenced by calc_enemy_damage_target().

◆ get_defense()

s32 get_defense ( Actor * actor,
s32 * defenseTable,
s32 elementFlags )

Definition at line 2219 of file 190B20.c.

2219 {
2220 s32 elemDefense;
2221 s32 minDefense = 255;
2222
2223 if (defenseTable != NULL) {
2224
2225 #define CHECK_DEFENSE(element) \
2226 if (elementFlags & DAMAGE_TYPE_##element) { \
2227 elemDefense = lookup_defense(defenseTable, ELEMENT_##element); \
2228 if (elemDefense < minDefense) { \
2229 minDefense = elemDefense; \
2230 } \
2231 } \
2232
2233 CHECK_DEFENSE(FIRE);
2234 CHECK_DEFENSE(WATER);
2235 CHECK_DEFENSE(ICE);
2236 CHECK_DEFENSE(MAGIC);
2237 CHECK_DEFENSE(SMASH);
2238 CHECK_DEFENSE(JUMP);
2239 CHECK_DEFENSE(COSMIC);
2240 CHECK_DEFENSE(BLAST);
2241 CHECK_DEFENSE(SHOCK);
2242 CHECK_DEFENSE(QUAKE);
2243 CHECK_DEFENSE(THROW);
2244
2245 #undef CHECK_DEFENSE
2246 }
2247
2248 // If no element flags were set, fall back to normal defense.
2249 if (minDefense == 255) {
2250 elemDefense = lookup_defense(defenseTable, ELEMENT_NORMAL);
2251 if (elemDefense < 255) {
2252 minDefense = elemDefense;
2253 }
2254 }
2255
2256 if (elementFlags & DAMAGE_TYPE_IGNORE_DEFENSE) {
2257 if (minDefense == 99) {
2258 // Immune
2259 minDefense = 999;
2260 } else if (minDefense > 0) {
2261 minDefense = 0;
2262 }
2263 }
2264
2265 return minDefense;
2266}
#define CHECK_DEFENSE(element)
s32 lookup_defense(s32 *defenseTable, s32 elementKey)
Definition 190B20.c:2027
@ ELEMENT_NORMAL
Definition enums.h:2115
@ DAMAGE_TYPE_IGNORE_DEFENSE
Definition enums.h:2877

Referenced by calc_enemy_damage_target(), calc_item_damage_enemy(), calc_partner_damage_enemy(), and calc_player_damage_enemy().

◆ btl_popup_messages_init()

void btl_popup_messages_init ( void )

Definition at line 271 of file popup_messages.c.

271 {
272 s32 i;
273
274 for (i = 0; i < ARRAY_COUNT(popupMessages); i++) {
275 PopupMessage* popup = &popupMessages[i];
276 popup->active = FALSE;
277 popup->data.bonk = NULL;
278 }
279}

Referenced by initialize_battle().

◆ remove_all_effects()

void remove_all_effects ( void )

Definition at line 278 of file effects.c.

278 {
279 s32 i;
280
281 for (i = 0; i < ARRAY_COUNT(gEffectInstances); i++) {
282 EffectInstance* effect = gEffectInstances[i];
283
284 if (effect != NULL && effect->flags & FX_INSTANCE_FLAG_BATTLE) {
285 if (effect->data.any != NULL) {
286 general_heap_free(effect->data.any);
287 }
288 general_heap_free(effect);
289 gEffectInstances[i] = NULL;
290 }
291 }
292}

Referenced by btl_state_update_end_battle(), and btl_state_update_end_demo_battle().

◆ update_effects()

void update_effects ( void )

Definition at line 60 of file effects.c.

60 {
62 EffectSharedData* sharedData;
63 s32 i;
64
65 // reset free delay for each EffectSharedData touched in previous update
66 for (i = 0, sharedData = gEffectSharedData; i < ARRAY_COUNT(gEffectSharedData); i++, sharedData++) {
67 if (sharedData->flags & FX_SHARED_DATA_LOADED) {
68 if (!(sharedData->flags & FX_SHARED_DATA_CAN_FREE)) {
69 sharedData->flags |= FX_SHARED_DATA_CAN_FREE;
70 sharedData->freeDelay = 3;
71 }
72 }
73 }
74
75 // update each EffectInstances
76 for (i = 0; i < ARRAY_COUNT(gEffectInstances); i++) {
77 EffectInstance* effectInstance = gEffectInstances[i];
78
79 if (effectInstance != NULL && (effectInstance->flags & FX_INSTANCE_FLAG_ENABLED)) {
80 effectInstance->shared->flags &= ~FX_SHARED_DATA_CAN_FREE;
81
83 if (effectInstance->flags & FX_INSTANCE_FLAG_BATTLE) {
84 effectInstance->shared->update(effectInstance);
85 effectInstance->flags |= FX_INSTANCE_FLAG_HAS_UPDATED;
86 }
87 } else {
88 if (!(effectInstance->flags & FX_INSTANCE_FLAG_BATTLE)) {
89 effectInstance->shared->update(effectInstance);
90 effectInstance->flags |= FX_INSTANCE_FLAG_HAS_UPDATED;
91 }
92 }
93 }
94 }
95
96 // free any EffectSharedData which haven't been used recently
97 for (i = 0, sharedData = gEffectSharedData; i < ARRAY_COUNT(gEffectSharedData); i++, sharedData++) {
98 if (sharedData->flags & FX_SHARED_DATA_LOADED) {
99 if (sharedData->flags & FX_SHARED_DATA_CAN_FREE) {
100 if (sharedData->freeDelay != 0) {
101 sharedData->freeDelay--;
102 } else {
103 if (sharedData->graphics != NULL) {
104 general_heap_free(sharedData->graphics);
105 sharedData->graphics = NULL;
106 }
107 sharedData->flags = 0;
108 osUnmapTLB(i);
109 }
110 }
111 }
112 }
113 }
114}
BSS EffectSharedData gEffectSharedData[15]
Definition effects.c:10
@ FX_SHARED_DATA_LOADED
Definition enums.h:3521
@ FX_SHARED_DATA_CAN_FREE
Definition enums.h:3522
void(* update)(EffectInstance *effectInst)
Definition effects.h:2663

Referenced by state_step_battle(), state_step_change_map(), state_step_enter_world(), state_step_game_over(), state_step_intro(), state_step_pause(), state_step_unpause(), and state_step_world().

◆ update_cameras()

void update_cameras ( void )

Definition at line 19 of file cam_main.c.

19 {
20 s32 sx, sy, sz;
21 s32 camID;
22
23 for (camID = 0; camID < ARRAY_COUNT(gCameras); camID++) {
24 Camera* cam = &gCameras[camID];
25
26 if (cam->flags == 0 || cam->flags & CAMERA_FLAG_DISABLED) {
27 continue;
28 }
29
30 gCurrentCamID = camID;
31
32 switch (cam->updateMode) {
33 default:
36 break;
39 break;
42 break;
45 break;
48 break;
51 break;
54 break;
55 }
56
57 guLookAtReflectF(cam->mtxViewPlayer, &gDisplayContext->lookAt, cam->lookAt_eye.x, cam->lookAt_eye.y, cam->lookAt_eye.z, cam->lookAt_obj.x, cam->lookAt_obj.y, cam->lookAt_obj.z, 0, 1.0f, 0);
58
59 if (!(cam->flags & CAMERA_FLAG_ORTHO)) {
60 if (cam->flags & CAMERA_FLAG_LEAD_PLAYER) {
62 }
63
64 guPerspectiveF(cam->mtxPerspective, &cam->perspNorm, cam->vfov, (f32) cam->viewportW / (f32) cam->viewportH, (f32) cam->nearClip, (f32) cam->farClip, 1.0f);
65
66 if (cam->flags & CAMERA_FLAG_SHAKING) {
68 }
69
70 if (cam->flags & CAMERA_FLAG_LEAD_PLAYER) {
72 }
73
75 } else {
76 f32 w = cam->viewportW;
77 f32 h = cam->viewportH;
78
79 guOrthoF(cam->mtxPerspective, -w * 0.5, w * 0.5, -h * 0.5, h * 0.5, -1000.0f, 1000.0f, 1.0f);
80 }
81
82 get_screen_coords(CAM_DEFAULT, cam->targetPos.x, cam->targetPos.y, cam->targetPos.z, &sx, &sy, &sz);
83 cam->targetScreenCoords.x = sx;
84 cam->targetScreenCoords.y = sy;
85 cam->targetScreenCoords.z = sz;
86 }
87
89}
void get_screen_coords(s32 camID, f32 x, f32 y, f32 z, s32 *screenX, s32 *screenY, s32 *screenZ)
Definition cam_main.c:410
void update_camera_zone_interp(Camera *camera)
void update_camera_no_interp(Camera *)
void update_camera_unused_radial(Camera *)
void create_camera_leadplayer_matrix(Camera *)
Definition cam_math.c:476
void update_camera_unused_confined(Camera *)
void update_camera_unused_leading(Camera *)
void update_camera_minimal(Camera *)
void update_camera_interp_pos(Camera *)
#define guPerspectiveF
@ CAMERA_FLAG_LEAD_PLAYER
Definition enums.h:4721
@ CAMERA_FLAG_SHAKING
Definition enums.h:4722
@ CAM_UPDATE_MINIMAL
Definition enums.h:4740
@ CAM_UPDATE_UNUSED_RADIAL
Definition enums.h:4764
@ CAM_UPDATE_FROM_ZONE
Definition enums.h:4754
@ CAM_UPDATE_UNUSED_CONFINED
Definition enums.h:4769
@ CAM_UPDATE_INTERP_POS
Definition enums.h:4746
@ CAM_UPDATE_UNUSED_LEADING
Definition enums.h:4774
Vec3s targetScreenCoords
Matrix4f mtxViewLeading
Vec3f targetPos
Matrix4f mtxViewShaking
Matrix4f mtxViewPlayer

Referenced by state_step_battle(), state_step_change_map(), state_step_enter_world(), state_step_game_over(), state_step_intro(), state_step_logos(), state_step_title_screen(), and state_step_world().

◆ clear_render_tasks()

void clear_render_tasks ( void )

Definition at line 4534 of file model.c.

4534 {
4535 s32 i;
4536
4537 for (i = 0; i < ARRAY_COUNT(ClearRenderTaskLists); i++) {
4539 }
4540
4541 for (i = 0; i < ARRAY_COUNT(RenderTaskCount); i++) {
4542 RenderTaskCount[i] = 0;
4543 }
4544}

Referenced by load_engine_data(), load_map_by_IDs(), state_init_logos(), state_init_title_screen(), state_step_demo(), state_step_intro(), state_step_startup(), and state_step_title_screen().

◆ clear_worker_list()

void clear_worker_list ( void )

Definition at line 10 of file worker.c.

10 {
11 s32 i;
12
15 } else {
17 }
18
19 for (i = 0; i < MAX_WORKERS; i++) {
20 (*gCurrentWorkerListPtr)[i] = NULL;
21 }
22}
BSS WorkerList gWorldWorkerList
Definition worker.c:3
BSS WorkerList gBattleWorkerList
Definition worker.c:4

Referenced by load_demo_battle(), load_engine_data(), load_map_by_IDs(), state_init_logos(), state_init_title_screen(), state_step_battle(), state_step_demo(), state_step_intro(), state_step_pause(), and state_step_startup().

◆ clear_printers()

void clear_printers ( void )

Definition at line 196 of file msg.c.

196 {
197 s32 i;
198
199 for (i = 0; i < ARRAY_COUNT(gMessagePrinters); i++) {
200 initialize_printer(&gMessagePrinters[i], 0, 0);
201 }
202
205
206 for (i = 0; i < ARRAY_COUNT(gMessageMsgVars); i++) {
207 gMessageMsgVars[i][0] = 0;
208 }
209
210 D_80151338 = NULL;
212 load_font(0);
213}
Gfx * D_80151338
Definition msg.c:93
void load_font(s32 font)
Definition msg.c:225

Referenced by load_demo_battle(), load_engine_data(), load_map_by_IDs(), state_init_title_screen(), state_step_demo(), state_step_intro(), and state_step_startup().

◆ clear_item_entity_data()

void clear_item_entity_data ( void )

Definition at line 243 of file item_entity.c.

243 {
244 s32 i;
245
248 } else {
250 }
251
252 for (i = 0; i < MAX_ITEM_ENTITIES; i++) {
253 gCurrentItemEntities[i] = NULL;
254 }
255
261
264 }
265
268 isPickingUpItem = FALSE;
269#if !VERSION_JP
270 D_801565A8 = FALSE;
271#endif
272}
s32 create_worker_frontUI(void(*updateFunc)(void), void(*drawFunc)(void))
Definition worker.c:63
BSS s16 CoinSparkleCenterY
Definition item_entity.c:36
BSS s16 CoinSparkleCenterZ
Definition item_entity.c:37
void draw_item_entities(void)
void draw_ui_item_entities(void)
BSS s16 CoinSparkleCenterX
Definition item_entity.c:35
BSS s32 ItemEntityRenderGroup
Definition item_entity.c:34

Referenced by load_demo_battle(), load_engine_data(), load_map_by_IDs(), state_step_battle(), state_step_demo(), state_step_intro(), state_step_pause(), and state_step_startup().

◆ clear_player_data()

void clear_player_data ( void )

Definition at line 55 of file inventory.c.

55 {
56 PlayerData* playerData = &gPlayerData;
57 s32 i;
58
59 ShowingCoinCounter = FALSE;
60 HidingCoinCounter = FALSE;
61
62 playerData->curHP = 10;
63 playerData->curMaxHP = 10;
64 playerData->hardMaxHP = 10;
65 playerData->curFP = 5;
66 playerData->curMaxFP = 5;
67 playerData->hardMaxFP = 5;
68 playerData->maxBP = 3;
69 playerData->level = 1;
70 playerData->bootsLevel = 0;
71 playerData->hammerLevel = -1;
72 playerData->hasActionCommands = FALSE;
73 playerData->coins = 0;
74 playerData->starPieces = 0;
75 playerData->starPoints = 0;
76 playerData->unused_011 = 0;
77 playerData->unused_288 = 0;
78
80 playerData->merleeCastsLeft = 0;
81 playerData->merleeTurnCount = -1;
82
83 playerData->maxStarPower = 0;
84 playerData->starPower = 0;
85 playerData->starBeamLevel = 0;
86
87 playerData->curPartner = PARTNER_NONE;
88
89 for (i = 0; i < ARRAY_COUNT(playerData->partners); i++) {
90 playerData->partners[i].enabled = FALSE;
91 playerData->partners[i].level = PARTNER_RANK_NORMAL;
92 playerData->partners[i].unk_02[0] = 0;
93 playerData->partners[i].unk_02[1] = 0;
94 playerData->partners[i].unk_02[2] = 0;
95 }
96
97 for (i = 0; i < ARRAY_COUNT(playerData->keyItems); i++) {
98 playerData->keyItems[i] = ITEM_NONE;
99 }
100
101 for (i = 0; i < ARRAY_COUNT(playerData->badges); i++) {
102 playerData->badges[i] = ITEM_NONE;
103 }
104
105 for (i = 0; i < ARRAY_COUNT(playerData->invItems); i++) {
106 playerData->invItems[i] = ITEM_NONE;
107 }
108
109 for (i = 0; i < ARRAY_COUNT(playerData->equippedBadges); i++) {
110 playerData->equippedBadges[i] = ITEM_NONE;
111 }
112
113 for (i = 0; i < ARRAY_COUNT(playerData->storedItems); i++) {
114 playerData->storedItems[i] = ITEM_NONE;
115 }
116
117 playerData->actionCommandAttempts = 0;
118 playerData->actionCommandSuccesses = 0;
119 playerData->hitsTaken = 0;
120 playerData->hitsBlocked = 0;
121 playerData->playerFirstStrikes = 0;
122 playerData->enemyFirstStrikes = 0;
123 playerData->powerBounces = 0;
124 playerData->battlesCount = 0;
125 playerData->battlesWon = 0;
126 playerData->fleeAttempts = 0;
127 playerData->battlesFled = 0;
128 playerData->trainingsDone = 0;
129 playerData->walkingStepsTaken = 0;
130 playerData->runningStepsTaken = 0;
131 playerData->idleFrameCounter = 0;
132 playerData->totalCoinsEarned = 0;
133 playerData->frameCounter = 0;
134 playerData->quizzesAnswered = 0;
135 playerData->quizzesCorrect = 0;
136
137 for (i = 0; i < ARRAY_COUNT(playerData->partnerUnlockedTime); i++) {
138 playerData->partnerUnlockedTime[i] = 0;
139 playerData->partnerUsedTime[i] = 0;
140 }
141
142 playerData->droTreeHintTime = 0;
143 playerData->starPiecesCollected = 0;
144 playerData->jumpGamePlays = 0;
145 playerData->jumpGameTotal = 0;
146 playerData->jumpGameRecord = 0;
147 playerData->smashGamePlays = 0;
148 playerData->smashGameTotal = 0;
149 playerData->smashGameRecord = 0;
150}
s16 storedItems[32]
s32 partnerUsedTime[12]
u16 actionCommandSuccesses
s32 partnerUnlockedTime[12]
u16 actionCommandAttempts
@ PARTNER_RANK_NORMAL
Definition enums.h:2018
BSS b16 HidingCoinCounter
Definition inventory.c:21
BSS b16 ShowingCoinCounter
Definition inventory.c:20

Referenced by filemenu_yesno_handle_input(), load_demo_battle(), load_engine_data(), state_init_title_screen(), state_step_demo(), state_step_intro(), and state_step_startup().

◆ phys_update_jump()

void phys_update_jump ( void )

Definition at line 199 of file 7BB60.c.

199 {
200 PlayerStatus* playerStatus = &gPlayerStatus;
201
202 if (playerStatus->timeInAir != 0) {
203 switch (playerStatus->actionState) {
206 return;
209 return;
212 playerStatus->pos.y += playerStatus->gravityIntegrator[0];
213 if (playerStatus->gravityIntegrator[0] <= 0.0f) {
216 playerStatus->gravityIntegrator[0] = 0.154343f;
217 playerStatus->gravityIntegrator[1] = -0.35008f;
218 playerStatus->gravityIntegrator[2] = 0.0f;
219 playerStatus->gravityIntegrator[3] = 0.0f;
220 } else {
222 }
225 }
226 return;
227 case ACTION_STATE_HOP:
228 playerStatus->gravityIntegrator[0] -= 4.5;
229 playerStatus->pos.y += playerStatus->gravityIntegrator[0];
230 if (playerStatus->gravityIntegrator[0] <= 0.0f) {
235 }
236 return;
239 return;
240 default:
241 if (!(playerStatus->curButtons & BUTTON_A)) {
245 if (playerStatus->flags & PS_FLAG_ENTERING_BATTLE) {
246 playerStatus->gravityIntegrator[1] *= 0.5f;
247 playerStatus->gravityIntegrator[2] *= 0.5f;
248 playerStatus->gravityIntegrator[3] *= 0.5f;
249 }
250 }
251 break;
252 }
253 }
254
256 if (playerStatus->gravityIntegrator[0] <= 0.0f) {
261 }
262
263 if (playerStatus->gravityIntegrator[0] > playerStatus->maxJumpSpeed) {
264 playerStatus->gravityIntegrator[0] = playerStatus->maxJumpSpeed;
265 }
266 playerStatus->pos.y += playerStatus->gravityIntegrator[0];
267}
void handle_jumping_launch(void)
Definition 7BB60.c:166
void handle_jumping_land_on_switch(void)
Definition 7BB60.c:120
void record_jump_apex(void)
Definition 7BB60.c:18
@ ACTION_STATE_LAUNCH
Shy Guy Toybox jack-in-the-boxes.
Definition enums.h:2433
s32 is_starting_conversation(void)
Definition encounter.c:2817

Referenced by phys_update_standard().

◆ phys_update_falling()

void phys_update_falling ( void )

Definition at line 316 of file 7BB60.c.

316 {
319 ) {
320 s32 colliderID;
323 }
324}
void player_handle_floor_collider_type(s32 colliderID)
Definition 7BB60.c:326
f32 player_fall_distance(void)
Definition 7BB60.c:461
f32 player_check_collision_below(f32 offset, s32 *colliderID)
Definition 7BB60.c:470

Referenced by phys_update_standard().

◆ check_input_midair_jump()

void check_input_midair_jump ( void )

Definition at line 1079 of file 7BB60.c.

1079 {
1083 && gPlayerStatus.timeInAir < 18
1085 ) {
1086 switch (gPlayerData.bootsLevel) {
1087 case 0:
1088 break;
1089 case 1:
1092 break;
1093 case 2:
1096 break;
1097 }
1098 }
1099}

Referenced by phys_update_standard().

◆ collision_check_player_overlaps()

void collision_check_player_overlaps ( void )

Definition at line 813 of file 7BB60.c.

813 {
814 PlayerStatus* playerStatus = &gPlayerStatus;
815 f32 overlapPush = playerStatus->overlapPushAmount;
816
817 if (overlapPush != 0.0f) {
818 f32 x = playerStatus->pos.x;
819 f32 y = playerStatus->pos.y;
820 f32 z = playerStatus->pos.z;
821
822 player_test_lateral_overlap(PLAYER_COLLISION_0, &gPlayerStatus, &x, &y, &z, overlapPush, playerStatus->overlapPushYaw);
823
824 overlapPush -= playerStatus->runSpeed / 10.0f;
825 playerStatus->pos.x = x;
826 playerStatus->pos.y = y;
827 playerStatus->pos.z = z;
828
829 if (overlapPush < 0.0f) {
830 overlapPush = 0.0f;
831 }
832
833 playerStatus->overlapPushAmount = overlapPush;
834 }
835}

Referenced by phys_update_standard().

◆ update_player_input()

void update_player_input ( void )

Definition at line 22 of file 7B440.c.

22 {
23 PlayerStatus* playerStatus = &gPlayerStatus;
24 s32 inputBufPos = playerStatus->inputBufPos;
25
26 playerStatus->stickAxis[0] = gGameStatusPtr->stickX[0];
27 playerStatus->stickAxis[1] = gGameStatusPtr->stickY[0];
28 playerStatus->curButtons = gGameStatusPtr->curButtons[0];
30 playerStatus->heldButtons = gGameStatusPtr->heldButtons[0];
31
32 inputBufPos++;
33 if (inputBufPos >= 10) {
34 inputBufPos = 0;
35 }
36
37 playerStatus->stickXBuffer[inputBufPos] = playerStatus->stickAxis[0];
38 playerStatus->stickYBuffer[inputBufPos] = playerStatus->stickAxis[1];
39 playerStatus->curButtonsBuffer[inputBufPos] = playerStatus->curButtons;
40 playerStatus->pressedButtonsBuffer[inputBufPos] = playerStatus->pressedButtons;
41 playerStatus->heldButtonsBuffer[inputBufPos] = playerStatus->heldButtons;
42 playerStatus->inputBufPos = inputBufPos;
43
45 playerStatus->stickAxis[0] = 0;
46 playerStatus->stickAxis[1] = 0;
47 playerStatus->curButtons = 0;
48 playerStatus->pressedButtons = 0;
49 playerStatus->heldButtons = 0;
50 }
51
52 if (playerStatus->animFlags & PA_FLAG_FORCE_USE_PARTNER) {
54 playerStatus->pressedButtons |= 4;
55 }
56}
s32 pressedButtonsBuffer[10]
s32 heldButtonsBuffer[10]
s32 curButtonsBuffer[10]
@ PA_FLAG_FORCE_USE_PARTNER
triggers partner use when set
Definition enums.h:3094
@ PA_FLAG_PARTNER_USAGE_FORCED
Definition enums.h:3115

Referenced by update_player().

◆ phys_update_action_state()

void phys_update_action_state ( void )

Definition at line 112 of file 7E9D0.c.

112 {
113 PlayerStatus* playerStatus = &gPlayerStatus;
114 PlayerSpinState* playerSpinState = &gPlayerSpinState;
115
116 if (!(playerStatus->flags & PS_FLAG_ENTERING_BATTLE)) {
117 playerStatus->flags &= ~PS_FLAG_TIME_STOPPED;
118 }
119
120 if (playerStatus->animFlags & PA_FLAG_USING_PEACH_PHYSICS) {
122 return;
123 }
124
125 if (playerStatus->camResetDelay != 0) {
126 playerStatus->camResetDelay--;
127 if (playerStatus->camResetDelay == 0) {
129 }
130 }
131
132 // if midair, look for velocity inflection
133 if (playerStatus->timeInAir != 0) {
134 if (playerStatus->gravityIntegrator[0] <= 0.0f && LastMidairPlayerVelY > 0.0f) {
135 playerStatus->peakJumpTime = playerStatus->timeInAir;
136 }
137 LastMidairPlayerVelY = playerStatus->gravityIntegrator[0];
138 }
139
141
142 if (playerSpinState->stopSoundTimer != 0) {
143 playerSpinState->stopSoundTimer--;
144 if (playerSpinState->stopSoundTimer == 0) {
145 playerStatus->animFlags &= ~PA_FLAG_SPINNING;
146 if (playerSpinState->spinSoundID != 0) {
147 sfx_stop_sound(playerSpinState->spinSoundID);
148 }
149 }
150 }
151
152 do {
153 s32 actionState = playerStatus->actionState;
154
155 if (actionState == ACTION_STATE_IDLE || actionState == ACTION_STATE_WALK || actionState == ACTION_STATE_RUN) {
156 s32 cond;
157
158 if (!(playerStatus->flags & PS_FLAG_INPUT_DISABLED)) {
160 } else {
161 cond = FALSE;
162 }
163
164 if ((gPartnerStatus.partnerActionState == PARTNER_ACTION_NONE) && !(playerStatus->flags & PS_FLAG_PAUSED) && cond) {
166 }
168 }
169
171
172 if (playerStatus->flags & PS_FLAG_ACTION_STATE_CHANGED) {
173 if (action->dmaStart != NULL && action->dmaStart != LastLoadedActionOffset) {
176 }
177 }
178 action->update();
179 } while (playerStatus->flags & PS_FLAG_ACTION_STATE_CHANGED);
180}
void check_input_spin(void)
Definition 7E9D0.c:386
void phys_peach_update(void)
Definition 7E9D0.c:182
f32 LastMidairPlayerVelY
Definition 7E9D0.c:34
@ CAMERA_MOVE_ACCEL_INTERP_Y
Definition enums.h:4733

Referenced by phys_update_lava_reset(), phys_update_standard(), and update_player().

◆ collision_main_lateral()

void collision_main_lateral ( void )

Definition at line 494 of file 7BB60.c.

494 {
495 PlayerStatus* playerStatus = &gPlayerStatus;
496 CollisionStatus* collisionStatus = &gCollisionStatus;
497 f32 playerX, playerY, playerZ;
498 f32 test1X, test1Y, test1Z;
499 f32 test2X, test2Y, test2Z;
500 f32 yaw;
501 f32 yaw2;
502 f32 speed;
503 f32 sinTheta;
504 f32 cosTheta;
505 s32 result;
506 s32 test1;
507 s32 test2;
508 f32 xBump;
509 f32 zBump;
510
512 if (playerStatus->flags & PS_FLAG_CUTSCENE_MOVEMENT) {
513 speed = playerStatus->curSpeed;
514 if (playerStatus->flags & PS_FLAG_ENTERING_BATTLE) {
515 speed *= 0.5f;
516 }
517 add_vec2D_polar(&playerStatus->pos.x, &playerStatus->pos.z, speed, playerStatus->heading);
518 return;
519 }
520
521 switch (playerStatus->actionState) {
524 playerStatus->spriteFacingAngle - 90.0f + gCameras[gCurrentCameraID].curYaw);
525 break;
528 playerStatus->pos.x += playerStatus->pushVel.x;
529 playerStatus->pos.y += playerStatus->pushVel.y;
530 playerStatus->pos.z += playerStatus->pushVel.z;
531
532 if (playerStatus->pushVel.x != 0.0f ||
533 playerStatus->pushVel.y != 0.0f ||
534 playerStatus->pushVel.z != 0.0f)
535 {
536 gCameras[CAM_DEFAULT].targetPos.x = playerStatus->pos.x;
537 gCameras[CAM_DEFAULT].targetPos.y = playerStatus->pos.y;
538 gCameras[CAM_DEFAULT].targetPos.z = playerStatus->pos.z;
539 if (playerStatus->curAlpha != 128) {
541 atan2(0.0f, 0.0f, playerStatus->pushVel.x, playerStatus->pushVel.z));
542 }
543 }
544 }
545 break;
548 playerStatus->pos.x += playerStatus->pushVel.x;
549 playerStatus->pos.y += playerStatus->pushVel.y;
550 playerStatus->pos.z += playerStatus->pushVel.z;
551 if (playerStatus->pushVel.x != 0.0f ||
552 playerStatus->pushVel.y != 0.0f ||
553 playerStatus->pushVel.z != 0.0f)
554 {
555 gCameras[CAM_DEFAULT].targetPos.x = playerStatus->pos.x;
556 gCameras[CAM_DEFAULT].targetPos.y = playerStatus->pos.y;
557 gCameras[CAM_DEFAULT].targetPos.z = playerStatus->pos.z;
558 }
559 if (playerStatus->pushVel.x != 0.0f ||
560 playerStatus->pushVel.y != 0.0f ||
561 playerStatus->pushVel.z != 0.0f)
562 {
564 playerStatus->spriteFacingAngle - 90.0f + gCameras[gCurrentCameraID].curYaw);
565 }
566 break;
568 playerStatus->pos.x += playerStatus->pushVel.x;
569 playerStatus->pos.y += playerStatus->pushVel.y;
570 playerStatus->pos.z += playerStatus->pushVel.z;
571 if (playerStatus->pushVel.x != 0.0f ||
572 playerStatus->pushVel.y != 0.0f ||
573 playerStatus->pushVel.z != 0.0f)
574 {
575 gCameras[CAM_DEFAULT].targetPos.x = playerStatus->pos.x;
576 gCameras[CAM_DEFAULT].targetPos.y = playerStatus->pos.y;
577 gCameras[CAM_DEFAULT].targetPos.z = playerStatus->pos.z;
578 }
579
580 playerX = playerStatus->pos.x;
581 playerY = playerStatus->pos.y;
582 playerZ = playerStatus->pos.z;
583 if (playerStatus->curSpeed != 0.0f) {
584 yaw = playerStatus->targetYaw;
585 } else {
586 yaw = playerStatus->spriteFacingAngle - 90.0f + gCameras[gCurrentCameraID].curYaw;
587 }
588 collisionStatus->curWall =
589 player_test_move_with_slipping(playerStatus, &playerX, &playerY, &playerZ,
590 playerStatus->colliderDiameter * 0.5f, yaw);
591
592 if (playerStatus->pushVel.x != 0.0f ||
593 playerStatus->pushVel.y != 0.0f ||
594 playerStatus->pushVel.z != 0.0f)
595 {
597 playerStatus->spriteFacingAngle - 90.0f + gCameras[gCurrentCameraID].curYaw);
598 }
599 break;
600 default:
601 if (!(playerStatus->flags & PS_FLAG_FLYING)) {
602 speed = 0.0f;
603 if (!(playerStatus->flags & (PS_FLAG_SCRIPTED_FALL | PS_FLAG_INPUT_DISABLED))) {
604 player_input_to_move_vector(&yaw, &speed);
605 if (!(playerStatus->animFlags & PA_FLAG_SPINNING)) {
606 speed *= 0.03125f;
607 if (!(playerStatus->flags & (PS_FLAG_FALLING | PS_FLAG_JUMPING))) {
608 speed *= 0.25;
609 }
610 if (playerStatus->actionState == ACTION_STATE_LAUNCH) {
611 speed *= 1.5;
612 }
613 if (playerStatus->flags & PS_FLAG_ENTERING_BATTLE) {
614 speed *= 0.5f;
615 }
616 }
617 sin_cos_rad(DEG_TO_RAD(yaw), &sinTheta, &cosTheta);
618
619 if (playerStatus->actionState == ACTION_STATE_PUSHING_BLOCK) {
620 if (fabsf(sinTheta) > fabsf(cosTheta)) {
621 xBump = speed * sinTheta;
622 zBump = 0.0f;
623 } else {
624 xBump = 0.0f;
625 zBump = -speed * cosTheta;
626 }
627 } else if (!(playerStatus->animFlags & PA_FLAG_SPINNING)) {
628 xBump = speed * sinTheta;
629 zBump = -speed * cosTheta;
630 } else {
631 xBump = 0.0f;
632 zBump = 0.0f;
633 }
634
635 sin_cos_rad(DEG_TO_RAD(playerStatus->targetYaw), &sinTheta, &cosTheta);
636 speed = playerStatus->curSpeed;
637 if (playerStatus->flags & PS_FLAG_ENTERING_BATTLE) {
638 speed *= 0.5f;
639 }
640 playerX = xBump + (speed * sinTheta);
641 playerZ = zBump - (speed * cosTheta);
642 yaw = atan2(0.0f, 0.0f, playerX, playerZ);
643 speed = sqrtf(SQ(playerX) + SQ(playerZ));
644 if (playerStatus->flags & (PS_FLAG_FALLING | PS_FLAG_JUMPING)) {
645 if (speed > playerStatus->runSpeed) {
646 speed = playerStatus->runSpeed;
647 }
648 }
649 }
650
651 playerStatus->pos.x += playerStatus->pushVel.x;
652 playerStatus->pos.z += playerStatus->pushVel.z;
653 if (playerStatus->timeInAir == 0) {
654 playerStatus->pos.y += playerStatus->pushVel.y;
655 }
656
657 if (
658 playerStatus->pushVel.x != 0.0f ||
659 playerStatus->pushVel.y != 0.0f ||
660 playerStatus->pushVel.z != 0.0f)
661 {
662 gCameras[CAM_DEFAULT].targetPos.x = playerStatus->pos.x;
663 gCameras[CAM_DEFAULT].targetPos.y = playerStatus->pos.y;
664 gCameras[CAM_DEFAULT].targetPos.z = playerStatus->pos.z;
665 }
666
667 playerX = playerStatus->pos.x;
668 playerY = playerStatus->pos.y;
669 playerZ = playerStatus->pos.z;
670 result = player_test_move_with_slipping(playerStatus, &playerX, &playerY, &playerZ,
671 playerStatus->colliderDiameter * 0.5f, playerStatus->targetYaw);
672 if (speed == 0.0f && result <= NO_COLLIDER) {
673 yaw2 = playerStatus->spriteFacingAngle - 90.0f + gCameras[gCurrentCameraID].curYaw;
674 sin_cos_rad(DEG_TO_RAD(yaw2 + 180.0f), &sinTheta, &cosTheta);
675 playerX = playerStatus->pos.x + (sinTheta * playerStatus->colliderDiameter * 0.5f);
676 playerY = playerStatus->pos.y;
677 playerZ = playerStatus->pos.z - (cosTheta * playerStatus->colliderDiameter * 0.5f);
678 result = player_test_move_with_slipping(playerStatus, &playerX, &playerY, &playerZ,
679 playerStatus->colliderDiameter, yaw2);
680 }
681 collisionStatus->curWall = result;
682 if (!(playerStatus->flags & PS_FLAG_MOVEMENT_LOCKED) && playerStatus->actionState != ACTION_STATE_HAMMER) {
683 if (speed == 0.0f) {
685 playerStatus->spriteFacingAngle - 90.0f + gCameras[gCurrentCameraID].curYaw);
686 break;
687 }
688
689 playerX = playerStatus->pos.x;
690 playerZ = playerStatus->pos.z;
691 playerY = playerStatus->pos.y;
692 yaw2 = yaw;
693
694 if (speed > 4.0f) {
695 result = player_test_move_with_slipping(playerStatus, &playerX, &playerY, &playerZ, 4.0f, yaw2);
696 if (result <= NO_COLLIDER) {
697 result = player_test_move_with_slipping(playerStatus, &playerX, &playerY, &playerZ, speed - 4.0f, yaw2);
698 }
699 collisionStatus->pushingAgainstWall = result;
700 } else {
701 collisionStatus->pushingAgainstWall =
702 player_test_move_with_slipping(playerStatus, &playerX, &playerY, &playerZ, speed, yaw2);
703 }
704
705 test1X = playerX;
706 test1Y = playerY;
707 test1Z = playerZ;
708 yaw = clamp_angle(yaw2 - 35.0);
709 test1 = player_test_lateral_overlap(PLAYER_COLLISION_0, playerStatus, &test1X, &test1Y, &test1Z, 0.0f, yaw);
710 test2X = playerX;
711 test2Z = playerY;
712 test2Y = playerZ;
713 yaw = clamp_angle(yaw2 + 35.0);
714 test2 = player_test_lateral_overlap(PLAYER_COLLISION_0, playerStatus, &test2X, &test2Z, &test2Y, 0.0f, yaw);
715
716 if (test1 <= NO_COLLIDER) {
717 if (test2 <= NO_COLLIDER) {
718 playerStatus->pos.x = playerX;
719 playerStatus->pos.z = playerZ;
720 } else {
721 playerStatus->pos.x = test1X;
722 playerStatus->pos.z = test1Z;
723 }
724 } else if (test2 <= NO_COLLIDER) {
725 playerStatus->pos.x = test2X;
726 playerStatus->pos.z = test2Y;
727 }
728
729 if (playerStatus->enableCollisionOverlapsCheck == 0) {
730 if (playerStatus->animFlags & PA_FLAG_SPINNING) {
731 yaw2 = playerStatus->targetYaw;
732 } else {
733 yaw2 = playerStatus->spriteFacingAngle - 90.0f + gCameras[gCurrentCameraID].curYaw;
734 }
737 }
738 }
739 }
740 }
741 break;
751 break;
752 }
753}
s8 get_current_partner_id(void)
Definition 7BB60.c:1101
@ PS_FLAG_MOVEMENT_LOCKED
Definition enums.h:3069
@ PLAYER_COLLISION_1
Definition enums.h:4712
@ ACTION_STATE_PUSHING_BLOCK
Definition enums.h:2448
@ ACTION_STATE_USE_SPRING
Definition enums.h:2466
@ ACTION_STATE_USE_SNEAKY_PARASOL
Definition enums.h:2453
HitID player_test_move_with_slipping(PlayerStatus *playerStatus, f32 *posX, f32 *posY, f32 *posZ, f32 speed, f32 heading)
Definition 77480.c:563

Referenced by phys_update_lava_reset(), phys_update_standard(), and update_player().

◆ player_surface_spawn_fx()

void player_surface_spawn_fx ( void )

Definition at line 42 of file surfaces.c.

42 {
43 s32 surfaceType = SURFACE_TYPE_DEFAULT;
44
46 surfaceType = PrevSurfaceType;
47 }
48
50
52 surfaceType = PrevSurfaceType;
53 }
54
57 }
58
60
61 switch (surfaceType) {
64 break;
67 break;
70 break;
73 break;
76 break;
77 default:
79 break;
80 }
81}
@ SURFACE_TYPE_DEFAULT
Definition enums.h:4669
@ SURFACE_TYPE_SNOW
Definition enums.h:4677
@ SURFACE_TYPE_CLOUD
used with clouds in flo_19 and flo_21
Definition enums.h:4676
void player_surface_spawn_water_fx(void)
Definition surfaces.c:348
void player_surface_spawn_cloud_fx(void)
Definition surfaces.c:240
void player_surface_spawn_hedges_fx(void)
Definition surfaces.c:322
BSS s32 PrevTimeInAir
Definition surfaces.c:11
void player_surface_spawn_flower_fx(void)
Definition surfaces.c:195
BSS s32 LandedTimeInAir
Definition surfaces.c:12
void player_surface_spawn_snow_fx(void)
Definition surfaces.c:294
s32 PrevSurfaceType
Definition surfaces.c:14
void player_surface_spawn_basic_fx(void)
Definition surfaces.c:83

Referenced by player_jump(), and update_player().

◆ check_input_open_menus()

void check_input_open_menus ( void )

Definition at line 191 of file menus.c.

191 {
192 static s16 SwappedWorldMenus;
193
194 PartnerStatus* partnerStatus;
195 PlayerStatus* playerStatus;
196 PlayerData* playerData;
197 PopupMenu* popup;
198 s32 flags;
199 s32 numEntries;
200 s32 pressedButtons;
201 s32 currentButtons;
202 s8* partnerActionState;
203
204 partnerStatus = &gPartnerStatus;
205 playerStatus = &gPlayerStatus;
206 playerData = &gPlayerData;
207 popup = &WorldPopupMenu;
208
212 ) {
213 return;
214 }
215
216 if (partnerStatus->partnerActionState != PARTNER_ACTION_NONE &&
217 (partnerStatus->actingPartner == PARTNER_SUSHIE ||
218 partnerStatus->actingPartner == PARTNER_LAKILESTER ||
219 partnerStatus->actingPartner == PARTNER_BOW))
220 {
221 currentButtons = partnerStatus->curButtons;
222 pressedButtons = partnerStatus->pressedButtons;
223 } else {
224 currentButtons = playerStatus->curButtons;
225 pressedButtons = playerStatus->pressedButtons;
226 }
227 partnerActionState = &partnerStatus->partnerActionState;
228
229 // prevent opening popup menus during the epilogue
231 currentButtons &= ~(BUTTON_C_LEFT | BUTTON_C_RIGHT);
232 pressedButtons &= ~(BUTTON_C_LEFT | BUTTON_C_RIGHT);
233 }
234
235 switch (WorldMenuState) {
237 if (can_open_world_menu(currentButtons, pressedButtons)) {
239 if (pressedButtons & BUTTON_C_RIGHT) {
241 }
242 if (pressedButtons & BUTTON_START) {
244 }
245 SwappedWorldMenus = FALSE;
246block_17:
247 switch (WorldMenuType) {
249 if (playerStatus->flags & PS_FLAG_NO_CHANGE_PARTNER) {
251 if (SwappedWorldMenus) {
253 playerStatus->flags &= ~PS_FLAG_PAUSED;
254 gOverrideFlags &= ~GLOBAL_OVERRIDES_40;
256 }
257 } else {
258 numEntries = setup_partner_popup(popup);
259 if (numEntries == 0) {
260 return;
261 }
262 popup->numEntries = numEntries;
264 popup->initialPos = MenuIndexFromPartnerID[playerData->curPartner] - 1;
265 break;
266 }
267 return;
269 numEntries = setup_item_popup(popup);
270 if (numEntries == 0) {
271 return;
272 }
274 popup->numEntries = numEntries;
275 popup->initialPos = 0;
276 break;
277 }
278 playerStatus->flags |= PS_FLAG_PAUSED;
281 WorldMenuDelay = 3;
284 }
285 break;
287 flags = ~PS_FLAG_PAUSED;
288 if (!should_cancel_open_world_menu() || is_picking_up_item() || OpenMenuDisableCount < playerStatus->inputDisabledCount != 0) {
289 playerStatus->flags &= flags;
293 if (SwappedWorldMenus) {
295 playerStatus->flags &= ~PS_FLAG_PAUSED;
296 gOverrideFlags &= ~GLOBAL_OVERRIDES_40;
298 }
299 } else {
301 if (WorldMenuDelay == 0) {
304 }
305 }
306 break;
311 WorldMenuDelay = 10;
313 return;
314 }
317 if (*partnerActionState == PARTNER_ACTION_NONE) {
319 }
321 break;
323 if (popup->result != POPUP_RESULT_INVALID) {
324 WorldPopupResult = popup->result;
327 WorldMenuDelay = 15;
329 }
330 }
331 break;
334 if (WorldMenuDelay != 0) {
335 break;
336 }
342 if ((setup_partner_popup(popup) == 0) || (setup_item_popup(popup) == 0)) {
344 } else {
345 // swap to other menu
346 switch (WorldMenuType) {
349 break;
352 break;
353 }
354 SwappedWorldMenus = TRUE;
355 goto block_17; // TODO required to match
356 }
357 }
358
360 switch (WorldMenuType) {
363 break;
366#ifndef VERSION_JP
368#endif
369 break;
370 }
371 }
373 playerStatus->flags &= ~PS_FLAG_PAUSED;
374 gOverrideFlags &= ~GLOBAL_OVERRIDES_40;
376 break;
379 if (WorldMenuDelay == 0) {
382 playerStatus->flags &= ~PS_FLAG_PAUSED;
383 gOverrideFlags &= ~GLOBAL_OVERRIDES_40;
386 }
387 break;
388 }
389}
void create_standard_popup_menu(PopupMenu *popup)
@ BUTTON_C_RIGHT
Definition enums.h:2777
@ STORY_INTRO
Definition enums.h:10
@ STORY_EPILOGUE
Definition enums.h:234
@ PS_FLAG_NO_CHANGE_PARTNER
Definition enums.h:3041
@ POPUP_RESULT_SWAP_MENU
Definition enums.h:3176
@ SOUND_MENU_OPEN
Definition enums.h:696
@ GLOBAL_OVERRIDES_CANT_PICK_UP_ITEMS
Definition enums.h:4338
@ GLOBAL_OVERRIDES_40
Definition enums.h:4324
void partner_disable_input(void)
Definition partners.c:2489
void switch_to_partner(s32 arg0)
Definition partners.c:906
s32 is_picking_up_item(void)
s32 use_consumable(s32 invSlot)
Definition partners.c:479
@ GAME_MODE_PAUSE
Definition game_modes.h:17
void reset_outta_sight_alpha_on_menu_close(void)
Definition menus.c:37
BSS s16 WorldMenuState
Definition menus.c:33
b32 should_cancel_open_world_menu(void)
Definition menus.c:49
BSS s16 OpenMenuDisableCount
Definition menus.c:32
@ WORLD_MENU_STATE_CLOSE
Definition menus.c:17
@ WORLD_MENU_STATE_UNPAUSE
Definition menus.c:18
@ WORLD_MENU_STATE_HOLD
Definition menus.c:16
@ WORLD_MENU_STATE_NONE
Definition menus.c:13
@ WORLD_MENU_STATE_OPEN
Definition menus.c:15
@ WORLD_MENU_STATE_DELAY
Definition menus.c:14
BSS s16 WorldPopupResult
Definition menus.c:31
b32 can_open_world_menu(s32 currentButtons, s32 pressedButtons)
Definition menus.c:81
s32 MenuIndexFromPartnerID[]
Definition 5B320.c:316
s32 setup_item_popup(PopupMenu *menu)
Definition menus.c:162
@ WORLD_MENU_USE_ITEM
Definition menus.c:23
@ WORLD_MENU_PAUSE
Definition menus.c:24
@ WORLD_MENU_CHANGE_PARTNER
Definition menus.c:22
BSS s16 WorldMenuDelay
Definition menus.c:30
s32 setup_partner_popup(PopupMenu *menu)
Definition menus.c:135
BSS PopupMenu WorldPopupMenu
Definition menus.c:28
BSS s16 WorldMenuType
Definition menus.c:29
void partner_enable_input(void)
Definition partners.c:2480

Referenced by update_player().

◆ check_input_status_bar()

void check_input_status_bar ( void )

Definition at line 391 of file menus.c.

391 {
392 PlayerStatus* playerStatus = &gPlayerStatus;
393 s32 pressedButtons;
394
396 if (playerStatus->actionState != ACTION_STATE_RIDE) {
397 pressedButtons = playerStatus->pressedButtons;
398 } else {
399 pressedButtons = gGameStatusPtr->pressedButtons[0];
400 }
401
402 if (!is_status_bar_visible()) {
403 if (!(playerStatus->curButtons & (Z_TRIG | R_TRIG))
404 && (pressedButtons & BUTTON_C_UP)
406 ) {
408#if VERSION_JP
410#else
411 if (!is_picking_up_item()) {
413 }
414#endif
415 }
416 } else if (!(playerStatus->curButtons & (Z_TRIG | R_TRIG))
417 && (pressedButtons & BUTTON_C_UP)
419 ) {
421#if VERSION_JP
423#else
424 if (!is_picking_up_item()) {
426 }
427#endif
428 }
429 }
430}
@ SOUND_LOWER_STATUS_BAR
Definition enums.h:550
@ SOUND_RAISE_STATUS_BAR
Definition enums.h:551
b32 can_control_status_bar(void)
Definition inventory.c:1492
void close_status_bar(void)
Definition inventory.c:1451
s32 is_status_bar_visible(void)
Definition inventory.c:1537
void open_status_bar_slowly(void)
Definition inventory.c:1431

Referenced by update_player().

◆ update_player()

void update_player ( void )

Definition at line 625 of file 77480.c.

625 {
626 PlayerStatus* playerStatus = &gPlayerStatus;
627 CollisionStatus* collisionStatus = &gCollisionStatus;
628
629 #if DX_DEBUG_MENU
630 if (dx_debug_is_cheat_enabled(DEBUG_CHEAT_SPEED_MODE)) {
632 gPlayerStatus.runSpeed = 12.0f;
633 }
634 #endif
635
637
638 if ((playerStatus->timeInAir > 100) || (playerStatus->pos.y < -2000.0f)) {
639 if (!(playerStatus->animFlags & PA_FLAG_NO_OOB_RESPAWN)) {
640 playerStatus->timeInAir = 0;
641 playerStatus->pos.x = playerStatus->lastGoodPos.x;
642 playerStatus->pos.y = playerStatus->lastGoodPos.y;
643 playerStatus->pos.z = playerStatus->lastGoodPos.z;
644
645 if (playerStatus->animFlags & PA_FLAG_RIDING_PARTNER) {
646 Npc* partner;
647
649 partner = get_npc_unsafe(NPC_PARTNER);
650 partner->pos.x = playerStatus->lastGoodPos.x;
651 partner->pos.y = playerStatus->lastGoodPos.y + playerStatus->colliderHeight;
652 partner->pos.z = playerStatus->lastGoodPos.z;
653 partner->moveToPos.y = playerStatus->lastGoodPos.y;
654 } else {
655 playerStatus->timeInAir = 10;
656 }
657 }
658 }
659
660 collisionStatus->curWall = NO_COLLIDER;
661 collisionStatus->lastWallHammered = NO_COLLIDER;
662 collisionStatus->curInspect = NO_COLLIDER;
663 collisionStatus->floorBelow = TRUE;
664
666 playerStatus->flags &= ~PS_FLAG_SPECIAL_LAND;
668
669 if (playerStatus->flags & PS_FLAG_NO_STATIC_COLLISION) {
673 }
674 } else if (playerStatus->actionState != ACTION_STATE_HIT_LAVA) {
676 } else {
678 }
679
680 if (playerStatus->flags & PS_FLAG_CUTSCENE_MOVEMENT) {
681 playerStatus->moveFrames--;
682 if (playerStatus->moveFrames <= 0) {
683 playerStatus->moveFrames = 0;
684 playerStatus->flags &= ~PS_FLAG_CUTSCENE_MOVEMENT;
685 }
686 }
687
688 if (!(playerStatus->animFlags & PA_FLAG_USING_PEACH_PHYSICS)) {
690 }
691
693
694 gGameStatus.playerPos.x = playerStatus->pos.x;
695 gGameStatus.playerPos.y = playerStatus->pos.y;
696 gGameStatus.playerPos.z = playerStatus->pos.z;
697 gGameStatus.playerYaw = playerStatus->curYaw;
698
700 if (!(playerStatus->animFlags & PA_FLAG_USING_PEACH_PHYSICS)) {
702 }
703
705
710
711 playerStatus->pushVel.x = 0.0f;
712 playerStatus->pushVel.y = 0.0f;
713 playerStatus->pushVel.z = 0.0f;
714 playerStatus->flags &= ~PS_FLAG_SLIDING;
715 playerStatus->animFlags &= ~PA_FLAG_FORCE_USE_PARTNER;
716}
void phys_update_lava_reset(void)
Definition 77480.c:793
b32 check_player_action_debug(void)
Definition 77480.c:1016
void update_partner_timers(void)
Definition 77480.c:1329
void phys_update_standard(void)
Definition 77480.c:737
void update_player_blink(void)
Definition 77480.c:924
void check_for_pulse_stone(void)
unavoidable use of hardcoded map and area IDs
Definition 77480.c:1063
void check_for_conversation_prompt(void)
Definition 77480.c:1124
void update_player_shadow(void)
Definition 77480.c:1686
void player_update_sprite(void)
Definition 77480.c:1347
void check_for_ispy(void)
Definition 77480.c:1035
void check_for_interactables(void)
Definition 77480.c:1207
@ NPC_PARTNER
Definition enums.h:2528
@ PA_FLAG_NO_OOB_RESPAWN
Definition enums.h:3121
@ PA_FLAG_DISMOUNTING_ALLOWED
Definition enums.h:3123
void phys_update_action_state(void)
Definition 7E9D0.c:112
void check_input_open_menus(void)
Definition menus.c:191
void update_player_input(void)
Definition 7B440.c:22
void check_input_status_bar(void)
Definition menus.c:391
void collision_main_lateral(void)
Definition 7BB60.c:494
void player_surface_spawn_fx(void)
Definition surfaces.c:42

Referenced by state_step_change_map(), state_step_enter_world(), state_step_game_over(), state_step_intro(), state_step_pause(), state_step_unpause(), and state_step_world().

◆ enforce_hpfp_limits()

void enforce_hpfp_limits ( void )

Definition at line 463 of file inventory.c.

463 {
464 PlayerData* playerData = &gPlayerData;
465
466 playerData->curMaxHP = playerData->hardMaxHP + (is_ability_active(ABILITY_HP_PLUS) * 5);
467 if (playerData->curMaxHP > 75) {
468 playerData->curMaxHP = 75;
469 }
470 if (playerData->curHP > playerData->curMaxHP) {
471 playerData->curHP = playerData->curMaxHP;
472 }
473
474 playerData->curMaxFP = playerData->hardMaxFP + (is_ability_active(ABILITY_FP_PLUS) * 5);
475 if (playerData->curMaxFP > 75) {
476 playerData->curMaxFP = 75;
477 }
478 if (playerData->curFP > playerData->curMaxFP) {
479 playerData->curFP = playerData->curMaxFP;
480 }
481}
s32 is_ability_active(s32 ability)
Definition inventory.c:1736

Referenced by pause_badges_handle_input(), and pause_handle_input().

◆ should_collider_allow_interact()

s32 should_collider_allow_interact ( s32 colliderID)
Returns
TRUE if colliderID is bound to an interaction trigger (press A) and the player can use it.

Definition at line 281 of file trigger.c.

281 {
282 s32 i;
283
285 return FALSE;
286 }
287
288 for (i = 0; i < ARRAY_COUNT(*gCurrentTriggerListPtr); i++) {
289 Trigger* trigger = (*gCurrentTriggerListPtr)[i];
290
291 if (trigger != NULL
292 && trigger->hasPlayerInteractPrompt != 0
293 && trigger->location.colliderID == colliderID
294 && trigger->flags & TRIGGER_WALL_PRESS_A
295 ) {
296 return TRUE;
297 }
298 }
299 return FALSE;
300}

Referenced by check_for_interactables(), func_800E06D8(), and should_continue_inspect().

◆ show_coin_counter()

void show_coin_counter ( void )

Definition at line 1358 of file inventory.c.

1358 {
1359 StatusBar* statusBar = &gStatusBar;
1360 HudElemID hid;
1361
1362 // if a coin counter is already visible, dispose of previous counter and reset state
1365 if (statusBar->iconIndex12 > -1) {
1368 statusBar->iconIndex12 = -1;
1369 }
1370 statusBar->coinCounterHideDelay = 0;
1371 statusBar->coinCountDisposeTime = 0;
1372 ShowingCoinCounter = FALSE;
1373 HidingCoinCounter = FALSE;
1374 }
1375
1376 if (statusBar->coinCounterHideDelay == 0) {
1381 hud_element_set_tint(hid, 255, 255, 255);
1384 hud_element_set_tint(hid, 255, 255, 255);
1385 statusBar->coinCounterHideDelay = 0;
1386
1387 if (statusBar->prevIgnoreChanges < 0) {
1388 statusBar->prevIgnoreChanges = statusBar->ignoreChanges;
1389 }
1390
1391 statusBar->ignoreChanges = TRUE;
1392 ShowingCoinCounter = TRUE;
1393 }
1394}
s8 coinCountDisposeTime
HudElemID coinCountTimesHID
HudElemID coinCountIconHID
HudElemID iconIndex12
s8 coinCounterHideDelay
@ WINDOW_PRIORITY_21
Definition enums.h:3187
@ WIN_CURRENCY_COUNTER
Definition enums.h:5260
void basic_window_update(s32 windowIndex, s32 *flags, s32 *posX, s32 *posY, s32 *posZ, f32 *scaleX, f32 *scaleY, f32 *rotX, f32 *rotY, f32 *rotZ, s32 *darkening, s32 *opacity)
Definition windows.c:161
HudScript HES_StatusCoin
HudScript HES_MenuTimes
void coin_counter_draw_content(UNK_TYPE arg0, s32 posX, s32 posY)
Definition inventory.c:1298

◆ hide_coin_counter_immediately()

void hide_coin_counter_immediately ( void )

Definition at line 1404 of file inventory.c.

1404 {
1405 StatusBar* statusBar = &gStatusBar;
1406
1407 if (ShowingCoinCounter && (statusBar->coinCounterHideDelay == 0)) {
1408 statusBar->coinCounterHideDelay = 1;
1409 }
1410}

◆ hide_popup_menu()

void hide_popup_menu ( void )

Definition at line 150 of file 8a860_len_3f30.c.

150 {
151 if (PopupNotBattle) {
152 switch (gPopupMenu->popupType) {
166 break;
171 break;
172 }
174 } else {
175 switch (gPopupMenu->popupType) {
189 break;
194 break;
195 }
196 }
197
201 }
204 }
208 }
211}
BSS s32 D_8010D644
BSS s8 D_8010D692
BSS s8 PopupNotBattle
BSS s32 gPopupState
BSS PopupMenu * gPopupMenu
@ POPUP_MENU_TRADE_FOR_BADGE
Definition enums.h:3134
@ POPUP_MENU_READ_DIARY_PAGE
Definition enums.h:3141
@ POPUP_MENU_SELL_ITEM
Definition enums.h:3136
@ POPUP_MENU_CHECK_ITEM
Definition enums.h:3137
@ POPUP_MENU_POST_OFFICE
Definition enums.h:3144
@ POPUP_MENU_TAKE_FROM_CHEST
Definition enums.h:3140
@ POPUP_MENU_USEKEY
Definition enums.h:3143
@ POPUP_MENU_CLAIM_ITEM
Definition enums.h:3138
@ POPUP_MENU_READ_LETTER
Definition enums.h:3139
@ POPUP_MENU_UPGRADE_PARTNER
Definition enums.h:3135
@ POPUP_MENU_THROW_AWAY_ITEM
Definition enums.h:3133
@ POPUP_MENU_READ_POSTCARD
Definition enums.h:3142
@ POPUP_STATE_10
Definition enums.h:3152
@ WIN_POPUP_DESC
Definition enums.h:5259
@ WIN_POPUP_CONTENT
Definition enums.h:5254
@ WIN_POPUP_COST
Definition enums.h:5256
@ WIN_POPUP_PROMPT
Definition enums.h:5261
@ WIN_PARTNER_COST
Definition enums.h:5258
void basic_hidden_window_update(s32 windowIndex, s32 *flags, s32 *posX, s32 *posY, s32 *posZ, f32 *scaleX, f32 *scaleY, f32 *rotX, f32 *rotY, f32 *rotZ, s32 *darkening, s32 *opacity)
Definition windows.c:184

Referenced by btl_state_update_partner_menu(), btl_state_update_player_menu(), check_input_open_menus(), shop_update_item_select_popup(), and update_item_entity_pickup().

◆ destroy_popup_menu()

void destroy_popup_menu ( void )

Definition at line 213 of file 8a860_len_3f30.c.

213 {
219
223 }
224
228 }
229
232 }
233
236 }
237
247 }
249 }
250
252}
BSS HudElemID PopupMenu_TitleIconHID
BSS HudElemID PopupMenu_CursorHID
BSS HudElemID PopupMenu_EmptybarHID
@ POPUP_TYPE_SWITCH_PARTNER
@ POPUP_TYPE_USE_KEY
@ POPUP_TYPE_TRADE_FOR_BADGE
@ POPUP_TYPE_USE_ITEM
@ POPUP_TYPE_THROW_AWAY_ITEM
@ POPUP_TYPE_UPGRADE_PARTNER
@ POPUP_TYPE_SELL_ITEM
BSS HudElemID PopupMenu_DownArrowHID
BSS HudElemID PopupMenu_EntryIconHID
BSS HudElemID PopupMenu_PartnerLevelHID
BSS HudElemID PopupMenu_TimesHID
BSS HudElemID PopupMenu_UpArrowHID
BSS s8 PopupMenu_WasStatusBarIgnoringChanges
@ POPUP_STATE_MINUS_4
Definition enums.h:3167

Referenced by btl_state_update_partner_menu(), btl_state_update_player_menu(), check_input_open_menus(), popup_menu_update(), shop_close_item_select_popup(), and update_item_entity_pickup().

◆ reset_player_status()

void reset_player_status ( void )

Definition at line 58 of file 7B440.c.

58 {
59 PlayerStatus* playerStatus = &gPlayerStatus;
60 MapSettings* mapSettings;
61
71 D_800F7B44 = 0;
73 PlayerNormalPitch = 0.0f;
74 playerStatus->availableDisguiseType = 1;
75 playerStatus->renderMode = RENDER_MODE_ALPHATEST;
76
77 playerStatus->curAlpha = 255;
78 playerStatus->prevAlpha = 255;
79 gGameStatusPtr->peachFlags &= ~PEACH_FLAG_BLOCK_NEXT_DISGUISE;
80 gGameStatusPtr->peachFlags &= ~PEACH_FLAG_DEPRESSED;
81
83 playerStatus->colliderHeight = 55;
84 playerStatus->colliderDiameter = 38;
86
90 }
91 } else {
92 playerStatus->colliderHeight = 37;
93 playerStatus->colliderDiameter = 26;
95 }
96
97 playerStatus->walkSpeed = DefaultWalkSpeed;
98 playerStatus->runSpeed = DefaultRunSpeed;
99 playerStatus->maxJumpSpeed = DefaultJumpSpeed;
100
102
103 playerStatus->curSpeed = 0.0f;
104 playerStatus->targetYaw = 0.0f;
105 playerStatus->overlapPushAmount = 0.0f;
106 playerStatus->overlapPushYaw = 0.0f;
107 playerStatus->anim = 0;
108 playerStatus->timeInAir = 0;
109 playerStatus->pos.x = 0.0f;
110 playerStatus->pos.y = 0.0f;
111 playerStatus->pos.z = 0.0f;
112 playerStatus->curYaw = 0.0f;
113 playerStatus->flipYaw[CAM_DEFAULT] = 0.0f;
114 playerStatus->flipYaw[CAM_BATTLE] = 0.0f;
115 playerStatus->flipYaw[CAM_TATTLE] = 0.0f;
116 playerStatus->flipYaw[CAM_HUD] = 0.0f;
117
118 ASSERT_MSG(gGameStatusPtr->areaID < ARRAY_COUNT(gAreas) - 1, "Invalid area ID %d", gGameStatusPtr->areaID);
120 ASSERT_MSG(gGameStatusPtr->mapID < area->mapCount, "Invalid map ID %d in %s", gGameStatusPtr->mapID, area->id);
121 mapSettings = area->maps[gGameStatusPtr->mapID].settings;
122
123 if (mapSettings->entryList != NULL) {
124 if (gGameStatusPtr->entryID < mapSettings->entryCount) {
125 playerStatus->pos.x = (*mapSettings->entryList)[gGameStatusPtr->entryID].x;
126 playerStatus->pos.y = (*mapSettings->entryList)[gGameStatusPtr->entryID].y;
127 playerStatus->pos.z = (*mapSettings->entryList)[gGameStatusPtr->entryID].z;
128 playerStatus->curYaw = (*mapSettings->entryList)[gGameStatusPtr->entryID].yaw;
129 }
130 }
131
132 gCameras[CAM_DEFAULT].targetPos.x = playerStatus->pos.x;
133 gCameras[CAM_DEFAULT].targetPos.y = playerStatus->pos.y;
134 gCameras[CAM_DEFAULT].targetPos.z = playerStatus->pos.z;
135
138}
s32 PeachDisguiseReapplyDelay
Definition 7E9D0.c:22
Entity * TweesterTouchingPartner
Definition 7B440.c:5
s32 PrevPlayerDirection
Definition 7B440.c:7
f32 PlayerNormalPitch
Definition 7B440.c:10
PlayerSpinState gPlayerSpinState
Definition 7B440.c:11
f32 DefaultWalkSpeed
Definition 7B440.c:16
f32 PlayerNormalYaw
Definition 7B440.c:9
f32 DefaultJumpSpeed
Definition 7B440.c:18
s32 PlayerRunStateTime
Definition 7B440.c:8
f32 DefaultRunSpeed
Definition 7B440.c:17
s32 PeachDisguiseNpcIndex
Definition 7B440.c:4
s8 availableDisguiseType
set in main map scripts
@ PEACH_FLAG_DISGUISED
Definition enums.h:2489
@ PEACH_BAKING_NONE
Definition enums.h:2496
void phys_reset_spin_history(void)
Definition 7E9D0.c:95
s32 entryCount
Definition map.h:25
char * id
"area_xxx"
Definition map.h:57
s32 D_800F7B44
Definition 7E9D0.c:32

Referenced by player_reset_data().

◆ player_reset_data()

void player_reset_data ( void )

Definition at line 811 of file 77480.c.

811 {
812 PlayerStatus* playerStatus = &gPlayerStatus;
813
814 mem_clear(playerStatus, sizeof(PlayerStatus));
815 playerStatus->flags = PS_FLAG_HAS_REFLECTION;
817 playerStatus->shadowID = create_shadow_type(SHADOW_VARYING_CIRCLE, playerStatus->pos.x, playerStatus->pos.y,
818 playerStatus->pos.z);
825}
void clear_pulse_stone_icon(void)
Definition 77480.c:1106
void clear_interact_prompt(void)
Definition 77480.c:1322
void clear_conversation_prompt(void)
Definition 77480.c:1155
void clear_ispy_icon(void)
Definition 77480.c:1057
@ PS_FLAG_HAS_REFLECTION
Definition enums.h:3034
void reset_player_status(void)
Definition 7B440.c:58
void clear_world_menus(void)
Definition menus.c:131
void func_800E5520(void)
Definition 7E9D0.c:36

Referenced by load_map_by_IDs().

◆ partner_reset_data()

void partner_reset_data ( void )

Definition at line 1000 of file partners.c.

1000 {
1001 PlayerStatus* playerStatus = &gPlayerStatus;
1002 s32 currentPartner = gPlayerData.curPartner;
1003
1006
1007 D_8010CFE0 = 1;
1009 wCurrentPartnerId = currentPartner;
1010
1014 }
1015
1016 wPartner = NULL;
1017 wSavedPartnerPosX = playerStatus->pos.x;
1018 wSavedPartnerPosY = playerStatus->pos.y;
1019 wSavedPartnerPosZ = playerStatus->pos.z;
1020
1023 } else {
1025 wPartnerNpc->scale.x = 1.0f;
1026 wPartnerNpc->scale.y = 1.0f;
1027 wPartnerNpc->scale.z = 1.0f;
1029 }
1030}
@ PARTNER_CMD_INIT
Definition enums.h:2946
@ PARTNER_CMD_RESET
Definition enums.h:2954
Worker * get_worker(s32 idx)
Definition worker.c:186
void create_partner_npc(void)
Definition partners.c:581
void _use_partner_ability(void)
Definition partners.c:625
Vec3f scale

Referenced by load_map_by_IDs().

◆ has_valid_conversation_npc()

s32 has_valid_conversation_npc ( void )

Definition at line 1111 of file 77480.c.

1111 {
1112 PlayerStatus* playerStatus = &gPlayerStatus;
1113 Npc* npc = playerStatus->encounteredNPC;
1114 s32 ret = FALSE;
1115 s32 cond;
1116
1117 if (npc != NULL && !(npc->flags & NPC_FLAG_USE_INSPECT_ICON)) {
1118 cond = !(playerStatus->flags & PS_FLAG_INPUT_DISABLED) && (playerStatus->flags & PS_FLAG_HAS_CONVERSATION_NPC);
1119 ret = cond;
1120 }
1121 return ret;
1122}
@ PS_FLAG_HAS_CONVERSATION_NPC
Definition enums.h:3074
@ NPC_FLAG_USE_INSPECT_ICON
Definition enums.h:3026

Referenced by check_for_conversation_prompt(), and should_continue_pulse_stone().

◆ func_800E06D8()

s32 func_800E06D8 ( void )

Definition at line 1164 of file 77480.c.

1164 {
1165 PlayerStatus* playerStatus = &gPlayerStatus;
1166 s32 currentWall;
1167
1168 if (playerStatus->timeInAir != 0 || playerStatus->inputDisabledCount != 0) {
1169 return FALSE;
1170 }
1172 return FALSE;
1173 }
1174 if (playerStatus->flags & PS_FLAG_HAS_CONVERSATION_NPC
1175 && !(playerStatus->flags & PS_FLAG_INPUT_DISABLED)
1176 && playerStatus->encounteredNPC != NULL
1178 ) {
1179 playerStatus->interactingWithID = NO_COLLIDER;
1180 return TRUE;
1181 }
1182
1183 currentWall = gCollisionStatus.curWall;
1184 if (!(currentWall & COLLISION_WITH_ENTITY_BIT)) {
1185 if (!should_collider_allow_interact(currentWall)) {
1186 return FALSE;
1187 }
1188 } else if (!phys_can_player_interact()) {
1189 playerStatus->interactingWithID = NO_COLLIDER;
1190 return FALSE;
1191 } else if (get_entity_type(currentWall) == ENTITY_TYPE_PUSH_BLOCK) {
1192 return FALSE;
1193 }
1194
1195 if (playerStatus->interactingWithID == currentWall) {
1196 if (playerStatus->flags & PS_FLAG_INTERACTED) {
1197 return FALSE;
1198 }
1199 } else {
1200 playerStatus->flags &= ~PS_FLAG_INTERACTED;
1201 }
1202 playerStatus->interactingWithID = NO_COLLIDER;
1203
1204 return TRUE;
1205}
@ PS_FLAG_INTERACTED
Definition enums.h:3077
s32 should_collider_allow_interact(s32)
Definition trigger.c:281

Referenced by should_continue_pulse_stone().

◆ func_800E01DC()

void func_800E01DC ( void )

Definition at line 1008 of file 77480.c.

1008 {
1009 PlayerStatus* playerStatus = &gPlayerStatus;
1010
1011 if (playerStatus->animFlags & PA_FLAG_INTERACT_PROMPT_AVAILABLE) {
1012 playerStatus->flags |= PS_FLAG_INTERACTED;
1013 }
1014}

◆ collision_lateral_peach()

void collision_lateral_peach ( void )

Definition at line 1057 of file 7BB60.c.

1057 {
1058 PlayerStatus* playerStatus = &gPlayerStatus;
1059 s32 climbableStep = FALSE;
1060 f32 yaw = playerStatus->targetYaw;
1061 f32 x = playerStatus->pos.x;
1062 f32 y = playerStatus->pos.y;
1063 f32 z = playerStatus->pos.z;
1064 HitID wall = player_test_move_without_slipping(&gPlayerStatus, &x, &y, &z, 0, yaw, &climbableStep);
1065
1066 playerStatus->pos.x = x;
1067 playerStatus->pos.z = z;
1068
1069 // If there was a climbable step in this direction, but no wall, we can climb up it
1070 if (climbableStep
1071 && wall <= NO_COLLIDER
1072 && playerStatus->actionState != ACTION_STATE_STEP_UP_PEACH
1073 && playerStatus->curSpeed != 0.0f
1074 ) {
1076 }
1077}
@ ACTION_STATE_STEP_UP_PEACH
Definition enums.h:2452
HitID player_test_move_without_slipping(PlayerStatus *, f32 *, f32 *, f32 *, f32, f32, s32 *)
Only used for Peach physics.
Definition 77480.c:496

Referenced by collision_lava_reset_check_additional_overlaps(), and phys_update_standard().

◆ func_800E5520()

void func_800E5520 ( void )

Definition at line 36 of file 7E9D0.c.

36 {
37 D_8010C9B0 = 0;
38}
s16 D_8010C9B0
Definition 7E9D0.c:25

Referenced by player_reset_data().

◆ clear_world_menus()

void clear_world_menus ( void )

Definition at line 131 of file menus.c.

Referenced by player_reset_data().

◆ setup_status_bar_for_battle()

void setup_status_bar_for_battle ( void )

Definition at line 1472 of file inventory.c.

1472 {
1473 StatusBar* statusBar = &gStatusBar;
1474
1475 statusBar->drawPosY = 0;
1476 statusBar->ignoreChanges = FALSE;
1477 statusBar->showTimer = 210;
1478 statusBar->hidden = FALSE;
1479 statusBar->unk_3B = TRUE;
1480 statusBar->unk_3C = FALSE;
1481}

Referenced by btl_state_update_normal_start().

◆ enable_status_bar_input()

void enable_status_bar_input ( void )

Definition at line 1483 of file inventory.c.

1483 {
1485}

◆ disable_status_bar_input()

void disable_status_bar_input ( void )

Definition at line 1487 of file inventory.c.

1487 {
1489}

◆ can_control_status_bar()

b32 can_control_status_bar ( void )

Definition at line 1492 of file inventory.c.

1492 {
1494 return FALSE;
1495 }
1496
1497 if (gStatusBar.alwaysShown) {
1498 return FALSE;
1499 }
1500
1502 return FALSE;
1503 }
1504
1505 return TRUE;
1506}

Referenced by check_input_status_bar().

◆ status_bar_respond_to_changes()

void status_bar_respond_to_changes ( void )

Definition at line 1519 of file inventory.c.

1519 {
1520 gStatusBar.ignoreChanges = FALSE;
1521}

Referenced by destroy_popup_menu(), shop_close_item_select_popup(), and state_step_unpause().

◆ status_bar_always_show_on()

void status_bar_always_show_on ( void )

Definition at line 1529 of file inventory.c.

1529 {
1530 gStatusBar.alwaysShown = TRUE;
1531}

Referenced by shop_open_item_select_popup().

◆ status_bar_always_show_off()

void status_bar_always_show_off ( void )

Definition at line 1533 of file inventory.c.

1533 {
1534 gStatusBar.alwaysShown = FALSE;
1535}

Referenced by draw_shop_items(), and shop_close_item_select_popup().

◆ star_power_shimmer_start()

void star_power_shimmer_start ( s32 emitterIdx,
f32 x,
f32 y,
f32 scale )

Definition at line 51 of file status_star_shimmer.c.

51 {
52 ShimmerEmitter* emitter = &ShimmerEmitters[emitterIdx];
53 ShimmerParticle* particle = &emitter->particles[0];
54 s32 numParticles = ARRAY_COUNT(emitter->particles);
55 s32 j;
56
57 if (emitterIdx < ARRAY_COUNT(ShimmerEmitters)) {
58 particle->alive = TRUE;
59 particle->pos.x = x;
60 particle->pos.y = y;
61 particle->scale = scale;
62 particle->timeLeft = 40;
63 particle->lifetime = 0;
64 particle = &emitter->particles[1];
65
66 for (j = 1; j < numParticles; j++, particle++) {
67 particle->animTime = (s32) (-((f32) j) * 0.0f) - 1;
68 }
69 }
70}
BSS ShimmerEmitter ShimmerEmitters[1]
ShimmerParticle particles[1+56]

Referenced by update_status_bar().

◆ star_power_shimmer_init()

void star_power_shimmer_init ( void )

Definition at line 72 of file status_star_shimmer.c.

72 {
73 s32 i;
74
75 for (i = 0; i < ARRAY_COUNT(ShimmerEmitters); i++) {
76 ShimmerEmitters[i].particles[0].alive = FALSE;
77 }
78}

Referenced by initialize_status_bar().

◆ star_power_shimmer_update()

void star_power_shimmer_update ( void )

Definition at line 80 of file status_star_shimmer.c.

80 {
81 ShimmerEmitter* emitter;
82 ShimmerParticle* particle;
83 s32 emitterTimeLeft;
84 f32 emitterX;
85 f32 emitterY;
86 s32 i, j;
87
88 for (i = 0; i < ARRAY_COUNT(ShimmerEmitters); i++, emitter++) {
89 emitter = &ShimmerEmitters[i];
90
91 if (!emitter->particles[0].alive) {
92 continue;
93 }
94
95 emitter->particles[0].timeLeft--;
96 emitter->particles[0].lifetime++;
97
98 if (emitter->particles[0].timeLeft < 0) {
99 emitter->particles[0].alive = FALSE;
100 continue;
101 }
102
103 emitterTimeLeft = emitter->particles[0].timeLeft;
104 emitterX = emitter->particles[0].pos.x;
105 emitterY = emitter->particles[0].pos.y;
106
107 particle = &emitter->particles[1];
108 for (j = 1; j < ARRAY_COUNT(emitter->particles); j++, particle++) {
109 particle->animTime++;
110 if (particle->animTime >= ARRAY_COUNT(AnimatedScale)) {
111 if (emitterTimeLeft < 30) {
112 particle->animTime = -31;
113 } else {
114 particle->animTime = 0;
115 }
116 }
117
118 if (particle->animTime < 0) {
119 continue;
120 }
121
122 if (particle->animTime == 0) {
123 f32 initialVelX = InitialVelocities[j - 1].x;
124 f32 initialVelY = InitialVelocities[j - 1].y;
125 s8 t = 127;
126
127 particle->vel.x = initialVelX * 0.1;
128 particle->vel.y = -initialVelY * 0.1;
129 particle->pos.x = emitterX;
130 particle->pos.y = emitterY;
131 particle->scale = 1.0f;
132 particle->rgba.r = rand_int(t);
133 particle->rgba.g = rand_int(t - particle->rgba.r);
134 particle->rgba.b = rand_int(t - particle->rgba.g - particle->rgba.r);
135 particle->rgba.a = 255;
136 particle->rgba.r += 128;
137 particle->rgba.g += 128;
138 particle->rgba.b += 128;
139 }
140
141 particle->pos.x += particle->vel.x;
142 particle->pos.y += particle->vel.y;
143 particle->vel.x *= 0.92;
144 particle->vel.y *= 0.92;
145 particle->scale = (f32) AnimatedScale[particle->animTime] * 0.04;
146 }
147 }
148}
u8 AnimatedScale[]
Vec2b InitialVelocities[56]

Referenced by update_status_bar().

◆ star_power_shimmer_draw()

void star_power_shimmer_draw ( void )

Definition at line 151 of file status_star_shimmer.c.

151 {
152 Matrix4f viewMtx, transformMtx;
153 ShimmerEmitter* emitter;
154 ShimmerParticle* particle;
155 f32 emitterScale;
156 s32 i, j;
157
158 gDPPipeSync(gMainGfxPos++);
159 gSPSegment(gMainGfxPos++, 0x00, 0x00000000);
160 gDPSetScissor(gMainGfxPos++, G_SC_NON_INTERLACE, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT);
161 gSPViewport(gMainGfxPos++, &ShimmerViewport);
162
163 guOrthoF(viewMtx, 0.0f, SCREEN_WIDTH, SCREEN_HEIGHT, 0.0f, -100.0f, 100.0f, 1.0f);
165
166 gSPMatrix(gMainGfxPos++, &gDisplayContext->matrixStack[gMatrixListPos++], G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_PROJECTION);
167 gSPDisplayList(gMainGfxPos++, D_80109710); // setup texture
168 gDPSetEnvColor(gMainGfxPos++, 127, 127, 127, 127);
169
170 for (i = 0; i < ARRAY_COUNT(ShimmerEmitters); i++, emitter++) {
171 emitter = &ShimmerEmitters[i];
172
173 if (emitter->particles[0].alive) {
174 emitterScale = emitter->particles[0].scale;
175
176 particle = &emitter->particles[1];
177 for (j = 1; j < ARRAY_COUNT(emitter->particles); j++, particle++) {
178 if (particle->animTime >= 0) {
179 guPositionF(transformMtx, 0.0f, 0.0f, gGameStatusPtr->frameCounter * 10, particle->scale * emitterScale,
180 particle->pos.x, particle->pos.y, 0.0f);
182
184 G_MTX_PUSH | G_MTX_MUL | G_MTX_MODELVIEW);
185 gDPSetPrimColor(gMainGfxPos++, 0, 80 - particle->animTime, particle->rgba.r, particle->rgba.g, particle->rgba.b, particle->rgba.a);
186 gSPDisplayList(gMainGfxPos++, D_801097D8); // draw particle
187 gSPPopMatrix(gMainGfxPos++, G_MTX_MODELVIEW);
188 }
189 }
190 }
191 }
192}
Vp ShimmerViewport

Referenced by update_status_bar().

◆ shop_open_item_select_popup()

void shop_open_item_select_popup ( s32 mode)

Definition at line 382 of file shops.c.

382 {
384 s16* itemArray;
385 s32 numItemSlots;
386 s32 popupType;
387 s32 numEntries;
388 s32 i;
389
390 switch (mode) {
391 case ITEM_POPUP_SELL:
392 popupType = POPUP_MENU_SELL_ITEM;
393 numItemSlots = ARRAY_COUNT(gPlayerData.invItems);
394 itemArray = gPlayerData.invItems;
395 break;
396 case ITEM_POPUP_CHECK:
397 popupType = POPUP_MENU_CHECK_ITEM;
398 numItemSlots = ARRAY_COUNT(gPlayerData.invItems);
399 itemArray = gPlayerData.invItems;
400 break;
401 case ITEM_POPUP_CLAIM:
402 default:
403 popupType = POPUP_MENU_CLAIM_ITEM;
404 numItemSlots = ARRAY_COUNT(gPlayerData.storedItems);
405 itemArray = gPlayerData.storedItems;
406 break;
407 }
408
409 numEntries = 0;
410
411 for (i = 0; i < numItemSlots; i++) {
412 s32 itemID = itemArray[i];
413 if (itemID == ITEM_NONE) {
414 continue;
415 }
416 ItemData* itemData = &gItemTable[itemID];
417
418 menu->ptrIcon[numEntries] = gItemHudScripts[itemData->hudElemID].enabled;
419 menu->userIndex[numEntries] = i;
420 menu->enabled[numEntries] = TRUE;
421 menu->nameMsg[numEntries] = itemData->nameMsg;
422 menu->descMsg[numEntries] = itemData->shortDescMsg;
423 menu->value[numEntries] = shop_get_sell_price(itemID);
424 numEntries++;
425 }
426
427 menu->popupType = popupType;
428 menu->numEntries = numEntries;
429 menu->initialPos = 0;
434}
void status_bar_ignore_changes(void)
Definition inventory.c:1508
void open_status_bar_quickly(void)
Definition inventory.c:1441
void status_bar_always_show_on(void)
Definition inventory.c:1529
PopupMenu itemSelectMenu
s32 shop_get_sell_price(s32 itemID)
Definition shops.c:463
@ ITEM_POPUP_CLAIM
Definition shops.c:379
@ ITEM_POPUP_CHECK
Definition shops.c:378
@ ITEM_POPUP_SELL
Definition shops.c:377
void create_shop_popup_menu(PopupMenu *popup)

◆ hide_coin_counter()

void hide_coin_counter ( void )

Definition at line 1396 of file inventory.c.

1396 {
1397 StatusBar* statusBar = &gStatusBar;
1398
1399 if (ShowingCoinCounter && (statusBar->coinCounterHideDelay == 0)) {
1400 statusBar->coinCounterHideDelay = 60;
1401 }
1402}

◆ set_message_text_var()

void set_message_text_var ( s32 msgID,
s32 index )

Definition at line 1520 of file msg.c.

1520 {
1521 u8* mallocSpace = NULL;
1522 s32 i;
1523 u8* msgVars;
1524
1525 if (msgID >= 0) {
1526 mallocSpace = general_heap_malloc(0x400);
1527 dma_load_msg(msgID, mallocSpace);
1528 msgID = (s32)mallocSpace;
1529 }
1530
1531 i = 0;
1532 msgVars = gMessageMsgVars[index];
1533 while (TRUE) {
1534 msgVars[i] = ((u8*)msgID)[i];
1535 if (((u8*)msgID)[i] == MSG_CHAR_READ_END) {
1536 break;
1537 }
1538
1539 if (++i >= 32) {
1540 msgVars[i - 1] = MSG_CHAR_READ_END;
1541 break;
1542 }
1543 }
1544
1545 if (mallocSpace != NULL) {
1546 general_heap_free(mallocSpace);
1547 }
1548}

Referenced by btl_message_popup_draw_content(), btl_show_message_popup(), draw_content_pickup_item_header(), func_801363A0(), shop_owner_buy_dialog(), and shop_owner_continue_speech_with_quantity().

◆ set_message_int_var()

void set_message_int_var ( s32 value,
s32 index )

Definition at line 1550 of file msg.c.

1550 {
1551 s8 strBuffer[ARRAY_COUNT(gMessageMsgVars[index])];
1552 s8* bufferIt;
1553 s32 i;
1554
1555 int_to_string(value, strBuffer, 10);
1556
1557 for (i = 0, bufferIt = strBuffer; i < ARRAY_COUNT(gMessageMsgVars[index]) - 1; i++) {
1558 s8 thisChar = bufferIt[i];
1559
1560 if (thisChar == 0) {
1561 break;
1562 }
1563 gMessageMsgVars[index][i] = thisChar - '0' + MSG_CHAR_DIGIT_0;
1564 }
1565 gMessageMsgVars[index][i] = MSG_CHAR_READ_END;
1566}

Referenced by btl_message_popup_draw_content(), btl_show_message_popup(), popup_menu_draw_menu_contents(), shop_owner_buy_dialog(), and shop_owner_continue_speech_with_quantity().

◆ open_status_bar_quickly()

void open_status_bar_quickly ( void )

Definition at line 1441 of file inventory.c.

1441 {
1442 StatusBar* statusBar = &gStatusBar;
1443
1444 if (statusBar->hidden) {
1445 statusBar->showTimer = 105;
1446 statusBar->hidden = FALSE;
1447 statusBar->unk_3B = TRUE;
1448 }
1449}

Referenced by create_standard_popup_menu(), and shop_open_item_select_popup().

◆ show_immune_bonk()

void show_immune_bonk ( f32 x,
f32 y,
f32 z,
s32 numStars,
s32 startupTime,
s32 animDir )

Definition at line 349 of file popup_messages.c.

349 {
350 BattleStatus* battleStatus = &gBattleStatus;
351 PopupMessage* popup;
352 BonkData* bonkData;
353 f32 timescale;
354 f32 baseScale;
355 s32 bonkPosIdx;
356 b32 hasShortLifetime;
357 s32 sign;
358 s32 i;
359
360 popup = btl_create_popup();
361 if (popup == NULL) {
362 // unable to create popup
363 return;
364 }
365
366 if (numStars < 1) {
367 numStars = 1;
368 baseScale = 0.4f;
369 timescale = 0.7f;
370 hasShortLifetime = TRUE;
371 } else {
372 baseScale = 1.0f;
373 timescale = 1.0f;
374 hasShortLifetime = FALSE;
375 }
376
377 if (battleStatus->flags1 & (BS_FLAGS1_NICE_HIT | BS_FLAGS1_SUPER_HIT)) {
378 baseScale *= 2.0;
379 }
380
381 if (animDir < 0) {
382 sign = -1;
383 } else {
384 sign = 1;
385 }
386
387 animDir = abs(animDir) % 5;
388
389 battleStatus->unk_90 = 0;
392 popup->unk_00 = FALSE;
393 popup->renderUIFunc = NULL;
394 popup->messageIndex = 1;
395 popup->active |= 0x10;
396 bonkData = popup->data.bonk = heap_malloc(numStars * sizeof(*popup->data.bonk));
397 ASSERT (popup->data.bonk != NULL);
398
399 for (i = 0; i < numStars; i++) {
400 bonkData->alive = TRUE;
404 bonkData->pos.x = x;
405 bonkData->pos.y = y;
406 bonkData->pos.z = z;
407 bonkPosIdx = animDir % 8;
408 animDir++;
409
410 bonkData->accel.x = BonkAnimAccel[bonkPosIdx].x * timescale * sign ;
411 bonkData->accel.y = BonkAnimAccel[bonkPosIdx].y * timescale;
412 bonkData->accel.z = BonkAnimAccel[bonkPosIdx].z * timescale;
413 bonkData->vel.x = 2.0 * bonkData->accel.x;
414 bonkData->vel.y = 2.0 * bonkData->accel.y;
415 bonkData->vel.z = 2.0 * bonkData->accel.z;
416
417 bonkData->scale = BonkAnimScale[i % 8].x * baseScale;
418 bonkData->rotY = clamp_angle(180.0f - gCameras[CAM_BATTLE].curYaw);
419 bonkData->rotZ = 0;
420 bonkData->rotVelZ = sign * 107;
421
422 bonkData->startupTime = startupTime;
423 bonkData->moveTime = 14;
424 bonkData->holdTime = 240;
425 if (hasShortLifetime) {
426 bonkData->holdTime = 10;
427 }
428
429 bonkData->alpha = 255.0f;
430 bonkData++;
431 }
432}
@ BS_FLAGS1_SUPER_HIT
Definition enums.h:3578
@ BS_FLAGS1_NICE_HIT
Definition enums.h:3575
s32 sign(s32 value)
Definition 43F0.c:375
void set_entity_model_flags(s32 idx, s32 newFlags)
void bind_entity_model_setupGfx(s32 idx, void *setupGfxCallbackArg0, void(*fpSetupGfxCallback)(void *))
Vec3f BonkAnimScale[]
void btl_bonk_setup_gfx(void *data)
void btl_bonk_update(void *data)
s32 entityModelIndex
Vec3f BonkAnimAccel[]
EntityModelScript * BonkModelScripts[]
void btl_bonk_render(void *data)

Referenced by calc_enemy_damage_target(), calc_item_damage_enemy(), calc_partner_damage_enemy(), and calc_player_damage_enemy().

◆ show_primary_damage_popup()

void show_primary_damage_popup ( f32 x,
f32 y,
f32 z,
s32 attack,
s32 a )

Definition at line 2269 of file 190B20.c.

2269 {
2270 s32 i;
2271
2272 for (i = 0; i < 1; i++) {
2273 if (gDamageCountEffects[i] == NULL) {
2274 break;
2275 }
2276 }
2277
2278 if (i > 0) {
2279 i = 0;
2281 gDamageCountEffects[i] = NULL;
2282 }
2283
2284 if (angle == 0) {
2285 angle = -55;
2286 } else {
2287 angle = 55;
2288 }
2289
2290 fx_damage_indicator(0, posX, posY, posZ, 10.0f, angle, damageAmt, &gDamageCountEffects[i]);
2291 gDamageCountTimers[i] = 40;
2292}

Referenced by calc_enemy_damage_target(), calc_item_damage_enemy(), calc_partner_damage_enemy(), and calc_player_damage_enemy().

◆ dispatch_damage_event_partner()

s32 dispatch_damage_event_partner ( s32 damageAmount,
s32 event,
s32 stopMotion )

Definition at line 909 of file dmg_partner.c.

909 {
910 BattleStatus* battleStatus = &gBattleStatus;
911 Actor* partner = battleStatus->partnerActor;
912 ActorState* state = &partner->state;
913 s32 hpChange;
914 s32 flagCheck;
915
916 battleStatus->curAttackDamage = damageAmount;
917
918 hpChange = (s16)damageAmount;
919 partner->hpChangeCounter += hpChange;
920
921 hpChange = partner->hpChangeCounter;
922 partner->curHP = 127;
923 partner->damageCounter += hpChange;
924 partner->hpChangeCounter -= hpChange;
925 battleStatus->lastAttackDamage = 0;
926 partner->curHP -= hpChange;
927
928 if (partner->curHP <= 0) {
929 event = EVENT_DEATH;
930 battleStatus->lastAttackDamage += partner->curHP;
931 partner->curHP = 0;
932 }
933
934 battleStatus->lastAttackDamage += hpChange;
935 partner->lastDamageTaken = battleStatus->lastAttackDamage;
936 battleStatus->curDamageSource = DMG_SRC_DEFAULT;
938 if (event == EVENT_HIT_COMBO) {
939 event = EVENT_HIT;
940 }
941 if (event == EVENT_ZERO_DAMAGE) {
942 event = EVENT_IMMUNE;
943 }
944 }
945
946 if (battleStatus->lastAttackDamage > 0) {
948
949 inflict_status(partner, STATUS_KEY_DAZE, battleStatus->lastAttackDamage);
950 }
951
952 if (!stopMotion) {
954 }
955
956 show_next_damage_popup(state->goalPos.x, state->goalPos.y, state->goalPos.z,
957 battleStatus->lastAttackDamage, 1);
958 show_damage_fx(partner, state->goalPos.x, state->goalPos.y, state->goalPos.z,
959 battleStatus->lastAttackDamage);
960
961 if (battleStatus->lastAttackDamage > 0) {
962 set_actor_flash_mode(partner, 1);
963 }
964
966
969 return flagCheck;
970}
s16 lastDamageTaken
void dispatch_event_partner(s32 lastEventType)
Definition dmg_partner.c:7
@ EVENT_IMMUNE
Definition enums.h:2146
@ EVENT_ZERO_DAMAGE
Definition enums.h:2144
@ EVENT_HIT_COMBO
Definition enums.h:2131
void set_actor_flash_mode(Actor *actor, s32 arg1)
Definition 190B20.c:2696
void show_damage_fx(Actor *actor, f32 x, f32 y, f32 z, s32 damage)
Definition 190B20.c:2334
s32 inflict_status(Actor *, s32, s32)
Definition 190B20.c:2084
void set_goal_pos_to_part(ActorState *state, s32 actorID, s32 partID)
Definition actor_api.c:44
void show_next_damage_popup(f32 x, f32 y, f32 z, s32 damageAmount, s32)
Definition 190B20.c:2295

Referenced by dispatch_damage_event_partner_0(), and dispatch_damage_event_partner_1().

◆ disable_actor_blur()

void disable_actor_blur ( Actor * actor)

Definition at line 223 of file actor_rendering.c.

223 {
224 ActorPart* actorPart = actor->partsTable;
225
226 if ((actorPart->idleAnimations != NULL) && !(actorPart->flags & ACTOR_PART_FLAG_NO_DECORATIONS)) {
227 DecorationTable* decorations = actorPart->decorationTable;
228
229 if (decorations->blurEnableCount != 0) {
230 decorations->blurEnableCount--;
231 if (decorations->blurEnableCount == 0) {
232 decorations->blurDisableDelay = 20;
233 }
234 }
235 }
236}

Referenced by disable_partner_blur().

◆ reset_actor_blur()

void reset_actor_blur ( Actor * actor)

Definition at line 238 of file actor_rendering.c.

238 {
239 ActorPart* actorPart = actor->partsTable;
240
241 if ((actorPart->idleAnimations != NULL) && !(actorPart->flags & ACTOR_PART_FLAG_NO_DECORATIONS)) {
242 DecorationTable* decorations = actorPart->decorationTable;
243
244 if (decorations->blurEnableCount != 0) {
245 decorations->blurEnableCount--;
246 if (decorations->blurEnableCount == 0) {
247 actor->flags &= ~ACTOR_FLAG_BLUR_ENABLED;
248 decorations->blurDisableDelay = 1;
249 }
250 }
251 }
252}

Referenced by reset_partner_blur().

◆ enable_actor_blur()

void enable_actor_blur ( Actor * actor)

Definition at line 189 of file actor_rendering.c.

189 {
190 ActorPart* partsTable = actor->partsTable;
191 DecorationTable* decorations = partsTable->decorationTable;
192 s32 i, j;
193 s32 numParts;
194
195 decorations->blurDisableDelay = 0;
196 decorations->blurEnableCount++;
198 partsTable = actor->partsTable;
199 numParts = actor->numParts;
200
201 for (i = 0; i < numParts; i++) {
202 if (partsTable->idleAnimations != NULL && !(partsTable->flags & ACTOR_PART_FLAG_NO_DECORATIONS)) {
203 decorations = partsTable->decorationTable;
204 decorations->blurUnused = 0;
205 decorations->blurBufferPos = 0;
206 for (j = 0; j < ARRAY_COUNT(decorations->posX); j++) {
207 decorations->posX[j] = partsTable->curPos.x;
208 decorations->posY[j] = partsTable->curPos.y;
209 decorations->posZ[j] = partsTable->curPos.z;
210 decorations->yaw[j] = actor->yaw;
211 decorations->rotPivotOffsetX[j] = (s32)(actor->rotPivotOffset.x * actor->scalingFactor);
212 decorations->rotPivotOffsetY[j] = (s32)(actor->rotPivotOffset.y * actor->scalingFactor);
213
214 decorations->rotX[j] = clamp_angle(actor->rot.x) * 0.5f;
215 decorations->rotY[j] = clamp_angle(actor->rot.y) * 0.5f;
216 decorations->rotZ[j] = clamp_angle(actor->rot.z) * 0.5f;
217 }
218 }
219 partsTable = partsTable->nextPart;
220 }
221}
@ ACTOR_FLAG_BLUR_ENABLED
Definition enums.h:3344

Referenced by enable_partner_blur().

◆ apply_shock_effect()

void apply_shock_effect ( Actor * actor)

Definition at line 2060 of file popup_messages.c.

2060 {
2061 ActorPart* part = actor->partsTable;
2062
2063 while (part != NULL) {
2064 if (!(part->flags & ACTOR_PART_FLAG_INVISIBLE)
2065 && part->idleAnimations != NULL
2067 ) {
2068 f32 x = part->curPos.x;
2069 f32 y = part->curPos.y + (actor->size.y / 10);
2070 f32 z = part->curPos.z;
2071 s32 f1 = (part->size.x + (part->size.x / 4)) * actor->scalingFactor;
2072 s32 f2 = (part->size.y - 2) * actor->scalingFactor;
2073
2074 if (actor->flags & ACTOR_FLAG_HALF_HEIGHT) {
2075 y -= actor->size.y / 2;
2076 }
2077
2078 fx_flashing_box_shockwave(0, x, y, z, f1, f2);
2079 }
2080 part = part->nextPart;
2081 }
2082}
@ ACTOR_FLAG_HALF_HEIGHT
Definition enums.h:3335
@ ACTOR_PART_FLAG_SKIP_SHOCK_EFFECT
Definition enums.h:3365

Referenced by calc_enemy_damage_target(), calc_item_damage_enemy(), calc_partner_damage_enemy(), calc_partner_test_enemy(), calc_player_damage_enemy(), and show_damage_fx().

◆ part_glow_off()

void part_glow_off ( s32 isNpcSprite,
ActorPart * part,
s32 yaw,
b32 arg3 )

Definition at line 3348 of file actor_rendering.c.

3348 {
3349 if (part->decorationTable->glowStateChanged) {
3350 part->decorationTable->glowStateChanged = FALSE;
3351 if (isNpcSprite == SPRITE_MODE_PLAYER) {
3353 } else {
3354 set_npc_imgfx_all(part->spriteInstanceID, IMGFX_CLEAR, 0, 0, 0, 0, 0);
3355 }
3356 }
3357}
void set_player_imgfx_all(s32 animID, ImgFXType imgfxType, s32 arg2, s32 arg3, s32 arg4, s32 arg5, s32 arg6)
Definition sprite.c:994

Referenced by update_part_glow().

◆ part_flash_off()

void part_flash_off ( b32 isNpcSprite,
ActorPart * part,
s32 yaw,
b32 isReflection )

Definition at line 3428 of file actor_rendering.c.

3428 {
3429 DecorationTable* decorations = part->decorationTable;
3430
3431 if (decorations->flashStateChanged) {
3432 decorations->flashStateChanged = FALSE;
3433 }
3434 decorations->flashEnabled = FLASH_PAL_OFF;
3435}

Referenced by update_part_flash().

◆ part_flash_on()

void part_flash_on ( b32 isNpcSprite,
ActorPart * part,
s32 yaw,
b32 isReflection )

Definition at line 3437 of file actor_rendering.c.

3437 {
3438 DecorationTable* decorations = part->decorationTable;
3439
3440 if (decorations->flashStateChanged) {
3441 switch (get_flash_damage_intensity(part)) {
3443 decorations->flashFramesLeft = 1;
3444 decorations->flashMode = FLASH_MODE_LIGHT;
3445 break;
3447 decorations->flashFramesLeft = 8;
3448 decorations->flashMode = FLASH_MODE_MEDIUM;
3449 break;
3451 default:
3452 decorations->flashFramesLeft = 14;
3453 decorations->flashMode = FLASH_MODE_HEAVY;
3454 break;
3455 }
3456 decorations->flashEnabled = FLASH_PAL_OFF;
3457 decorations->flashStateChanged = FALSE;
3458 }
3459
3460 if (decorations->flashMode == FLASH_MODE_DISPOSE) {
3461 decorations->flashEnabled = FLASH_PAL_OFF;
3463 }
3464
3465 switch (decorations->flashMode) {
3466 case FLASH_MODE_LIGHT:
3467 switch (decorations->flashFramesLeft) {
3468 case 0:
3469 decorations->flashEnabled = FLASH_PAL_ON;
3470 decorations->flashMode = FLASH_MODE_DISPOSE;
3471 break;
3472 default:
3473 decorations->flashEnabled = FLASH_PAL_OFF;
3474 if (!isReflection) {
3475 decorations->flashFramesLeft--;
3476 }
3477 break;
3478 }
3479 break;
3480 case FLASH_MODE_MEDIUM:
3481 switch (decorations->flashFramesLeft) {
3482 case 1:
3483 case 2:
3484 case 5:
3485 case 6:
3486 decorations->flashEnabled = FLASH_PAL_ON;
3487 break;
3488 case 3:
3489 case 4:
3490 case 7:
3491 case 8:
3492 decorations->flashEnabled = FLASH_PAL_OFF;
3493 break;
3494 case 0:
3495 decorations->flashMode = FLASH_MODE_DISPOSE;
3496 break;
3497 }
3498 if (!isReflection) {
3499 decorations->flashFramesLeft--;
3500 }
3501 break;
3502 case FLASH_MODE_HEAVY:
3503 switch (decorations->flashFramesLeft) {
3504 case 1:
3505 case 2:
3506 case 5:
3507 case 6:
3508 case 9:
3509 case 10:
3510 case 13:
3511 case 14:
3512 decorations->flashEnabled = FLASH_PAL_OFF;
3513 break;
3514 case 3:
3515 case 4:
3516 case 7:
3517 case 8:
3518 case 11:
3519 case 12:
3520 decorations->flashEnabled = FLASH_PAL_ON;
3521 break;
3522 case 0:
3523 decorations->flashMode = FLASH_MODE_DISPOSE;
3524 break;
3525 }
3526 if (!isReflection) {
3527 decorations->flashFramesLeft--;
3528 }
3529 break;
3530 }
3531}
void clear_part_flash_mode(ActorPart *part)
Definition 190B20.c:2708
s32 get_flash_damage_intensity(ActorPart *part)
@ FLASH_MODE_MEDIUM
Definition enums.h:2264
@ FLASH_MODE_HEAVY
Definition enums.h:2265
@ FLASH_MODE_DISPOSE
Definition enums.h:2266
@ FLASH_MODE_LIGHT
Definition enums.h:2263
@ FLASH_PAL_ON
Definition enums.h:2271

Referenced by update_part_flash().

◆ _add_part_decoration()

void _add_part_decoration ( ActorPart * actorPart)

Definition at line 3533 of file actor_rendering.c.

3533 {
3534 DecorationTable* decorations;
3535 s32 i;
3536
3537 if (actorPart->flags & ACTOR_PART_FLAG_NO_DECORATIONS) {
3538 return;
3539 }
3540
3541 decorations = actorPart->decorationTable;
3542 for (i = 0; i < ARRAY_COUNT(decorations->type); i++) {
3543 switch (decorations->type[i]) {
3545 add_part_decor_none(actorPart, i);
3546 break;
3548 add_part_decor_golden_flames(actorPart, i);
3549 break;
3551 add_part_decor_sweat(actorPart, i);
3552 break;
3554 add_part_decor_seeing_stars(actorPart, i);
3555 break;
3557 add_part_decor_red_flames(actorPart, i);
3558 break;
3560 add_part_decor_smoky_trail(actorPart, i);
3561 break;
3563 add_part_decor_fiery_trail(actorPart, i);
3564 break;
3566 add_part_decor_whirlwind(actorPart, i);
3567 break;
3569 add_part_decor_steam(actorPart, i);
3570 break;
3572 add_part_decor_sparkles(actorPart, i);
3573 break;
3575 add_part_decor_bowser_aura(actorPart, i);
3576 break;
3578 add_part_decor_radiating_stars(actorPart, i);
3579 break;
3580 }
3581 }
3582}
void add_part_decor_steam(ActorPart *, s32)
void add_part_decor_sparkles(ActorPart *, s32)
void add_part_decor_fiery_trail(ActorPart *, s32)
void add_part_decor_golden_flames(ActorPart *, s32)
void add_part_decor_radiating_stars(ActorPart *, s32)
void add_part_decor_seeing_stars(ActorPart *, s32)
void add_part_decor_sweat(ActorPart *, s32)
void add_part_decor_smoky_trail(ActorPart *, s32)
void add_part_decor_bowser_aura(ActorPart *, s32)
void add_part_decor_whirlwind(ActorPart *, s32)
void add_part_decor_none(ActorPart *, s32)
void add_part_decor_red_flames(ActorPart *, s32)
@ ACTOR_DECORATION_NONE
Definition enums.h:2043
@ ACTOR_DECORATION_SEEING_STARS
Definition enums.h:2046
@ ACTOR_DECORATION_GREY_SMOKE_TRAIL
Definition enums.h:2048
@ ACTOR_DECORATION_RED_FLAMES
Definition enums.h:2047
@ ACTOR_DECORATION_WHIRLWIND
Definition enums.h:2050
@ ACTOR_DECORATION_RADIAL_STAR_EMITTER
Definition enums.h:2054
@ ACTOR_DECORATION_BOWSER_AURA
Definition enums.h:2053
@ ACTOR_DECORATION_SWEAT
Definition enums.h:2045
@ ACTOR_DECORATION_STEAM_EMITTER
Definition enums.h:2051
@ ACTOR_DECORATION_GOLDEN_FLAMES
Definition enums.h:2044
@ ACTOR_DECORATION_SPARKLES
Definition enums.h:2052
@ ACTOR_DECORATION_FIRE_SMOKE_TRAIL
Definition enums.h:2049

Referenced by add_part_decoration(), appendGfx_npc_actor(), and appendGfx_player_actor().

◆ _remove_part_decoration()

void _remove_part_decoration ( ActorPart * part,
s32 decorationIndex )

Definition at line 3584 of file actor_rendering.c.

3584 {
3585 DecorationTable* decorations = part->decorationTable;
3586
3587 switch (decorations->type[idx]) {
3589 remove_part_decor_none(part, idx);
3590 break;
3593 break;
3595 remove_part_decor_sweat(part, idx);
3596 break;
3599 break;
3602 break;
3605 break;
3608 break;
3610 remove_part_decor_whirlwind(part, idx);
3611 break;
3613 remove_part_decor_steam(part, idx);
3614 break;
3616 remove_part_decor_sparkles(part, idx);
3617 break;
3620 break;
3623 break;
3624 }
3625
3626 decorations->type[idx] = ACTOR_DECORATION_NONE;
3627}
void remove_part_decor_bowser_aura(ActorPart *part, s32 idx)
void remove_part_decor_sweat(ActorPart *part, s32 idx)
void remove_part_decor_none(ActorPart *part, s32 idx)
void remove_part_decor_steam(ActorPart *part, s32 idx)
void remove_part_decor_red_flames(ActorPart *part, s32 idx)
void remove_part_decor_seeing_stars(ActorPart *part, s32 idx)
void remove_part_decor_radiating_stars(ActorPart *part, s32 idx)
void remove_part_decor_sparkles(ActorPart *part, s32 idx)
void remove_part_decor_golden_flames(ActorPart *part, s32 idx)
void remove_part_decor_whirlwind(ActorPart *part, s32 idx)
void remove_part_decor_smoky_trail(ActorPart *part, s32 idx)
void remove_part_decor_fiery_trail(ActorPart *part, s32 idx)

Referenced by add_part_decoration(), and remove_part_decoration().

◆ remove_part_decor_none()

void remove_part_decor_none ( ActorPart * part,
s32 idx )

Definition at line 3632 of file actor_rendering.c.

3632 {
3633}

Referenced by _remove_part_decoration().

◆ remove_part_decor_golden_flames()

void remove_part_decor_golden_flames ( ActorPart * part,
s32 idx )

Definition at line 3665 of file actor_rendering.c.

3665 {
3666 part->decorationTable->effect[idx]->data.aura->fadeTime = 5;
3667}
s32 fadeTime
Definition effects.h:999
struct AuraFXData * aura
Definition effects.h:2523

Referenced by _remove_part_decoration().

◆ remove_part_decor_sweat()

void remove_part_decor_sweat ( ActorPart * part,
s32 idx )

Definition at line 3692 of file actor_rendering.c.

3692 {
3693}

Referenced by _remove_part_decoration().

◆ remove_part_decor_seeing_stars()

void remove_part_decor_seeing_stars ( ActorPart * part,
s32 idx )

Definition at line 3714 of file actor_rendering.c.

3714 {
3716}

Referenced by _remove_part_decoration().

◆ remove_part_decor_red_flames()

void remove_part_decor_red_flames ( ActorPart * part,
s32 idx )

Definition at line 3754 of file actor_rendering.c.

3754 {
3755 part->decorationTable->effect[idx]->data.aura->fadeTime = 5;
3756}

Referenced by _remove_part_decoration().

◆ remove_part_decor_smoky_trail()

void remove_part_decor_smoky_trail ( ActorPart * part,
s32 idx )

Definition at line 3776 of file actor_rendering.c.

3776 {
3778}

Referenced by _remove_part_decoration().

◆ remove_part_decor_fiery_trail()

void remove_part_decor_fiery_trail ( ActorPart * part,
s32 idx )

Definition at line 3800 of file actor_rendering.c.

3800 {
3802}

Referenced by _remove_part_decoration().

◆ remove_part_decor_whirlwind()

void remove_part_decor_whirlwind ( ActorPart * part,
s32 idx )

Definition at line 3822 of file actor_rendering.c.

3822 {
3824}

Referenced by _remove_part_decoration().

◆ remove_part_decor_steam()

void remove_part_decor_steam ( ActorPart * part,
s32 idx )

Definition at line 3852 of file actor_rendering.c.

3852 {
3853}

Referenced by _remove_part_decoration().

◆ remove_part_decor_sparkles()

void remove_part_decor_sparkles ( ActorPart * part,
s32 idx )

Definition at line 3882 of file actor_rendering.c.

3882 {
3883}

Referenced by _remove_part_decoration().

◆ remove_part_decor_bowser_aura()

void remove_part_decor_bowser_aura ( ActorPart * part,
s32 idx )

Definition at line 3919 of file actor_rendering.c.

3919 {
3920 part->decorationTable->effect[idx]->data.aura->fadeTime = 5;
3921}

Referenced by _remove_part_decoration().

◆ remove_part_decor_radiating_stars()

void remove_part_decor_radiating_stars ( ActorPart * part,
s32 idx )

Definition at line 3947 of file actor_rendering.c.

3947 {
3949}

Referenced by _remove_part_decoration().

◆ status_bar_ignore_changes()

void status_bar_ignore_changes ( void )

Definition at line 1508 of file inventory.c.

1508 {
1510}

Referenced by create_standard_popup_menu(), and shop_open_item_select_popup().

◆ imgfx_release_instance()

void imgfx_release_instance ( u32 idx)

Definition at line 385 of file imgfx.c.

385 {
386 if (idx < MAX_IMGFX_INSTANCES) {
387 (*ImgFXInstances)[idx].flags = 0;
388 (*ImgFXInstances)[idx].nextIdx = -1;
389 }
390}

Referenced by hud_element_free_transform(), imgfx_release_instance_chain(), and spr_free_sprite().

◆ set_script_flags()

void set_script_flags ( Evt * script,
s32 flags )

Definition at line 913 of file script_list.c.

913 {
914 Evt* childScript = script->childScript;
915 s32 i;
916
917 script->stateFlags |= flags;
918 if (childScript != NULL) {
919 set_script_flags(childScript, flags);
920 }
921
922 for (i = 0; i < MAX_SCRIPTS; i++) {
923 Evt* scriptContextPtr = (*gCurrentScriptListPtr)[i];
924
925 if (scriptContextPtr != NULL && scriptContextPtr->parentScript == script) {
927 }
928 }
929}
void set_script_flags(Evt *script, s32 flags)

Referenced by set_script_flags(), and update_encounters_neutral().

◆ clear_script_flags()

void clear_script_flags ( Evt * script,
s32 flags )

Definition at line 931 of file script_list.c.

931 {
932 Evt* childScript = script->childScript;
933 s32 i;
934
935 script->stateFlags &= ~flags;
936 if (childScript != NULL) {
937 clear_script_flags(childScript, flags);
938 }
939
940 for (i = 0; i < MAX_SCRIPTS; i++) {
941 Evt* scriptContextPtr = (*gCurrentScriptListPtr)[i];
942
943 if (scriptContextPtr != NULL && scriptContextPtr->parentScript == script) {
944 clear_script_flags(scriptContextPtr, flags);
945 }
946 }
947}
void clear_script_flags(Evt *script, s32 flags)

Referenced by clear_script_flags(), and update_encounters_neutral().

◆ disable_player_blur()

void disable_player_blur ( void )

Definition at line 307 of file actor_rendering.c.

307 {
308 Actor* playerActor = gBattleStatus.playerActor;
309 ActorPart* partsTable = playerActor->partsTable;
310 DecorationTable* decorations = partsTable->decorationTable;
311
312 if (decorations->blurEnableCount != 0) {
313 decorations->blurEnableCount--;
314 if (decorations->blurEnableCount == 0) {
315 decorations->blurDisableDelay = 20;
316 }
317 }
318}

◆ enable_player_blur()

void enable_player_blur ( void )

Definition at line 281 of file actor_rendering.c.

281 {
282 Actor* playerActor = gBattleStatus.playerActor;
283 ActorPart* partsTable = playerActor->partsTable;
284 DecorationTable* decorations = partsTable->decorationTable;
285 s32 i;
286
287 decorations->blurDisableDelay = 0;
288 decorations->blurEnableCount++;
289 playerActor->flags |= ACTOR_FLAG_BLUR_ENABLED;
290 decorations->blurUnused = 0;
291 decorations->blurBufferPos = 0;
292
293 for (i = 0; i < ARRAY_COUNT(decorations->posX); i++) {
294 decorations->posX[i] = partsTable->curPos.x;
295 decorations->posY[i] = partsTable->curPos.y;
296 decorations->posZ[i] = partsTable->curPos.z;
297 decorations->yaw[i] = playerActor->yaw;
298 decorations->rotPivotOffsetX[i] = playerActor->rotPivotOffset.x * playerActor->scalingFactor;
299 decorations->rotPivotOffsetY[i] = playerActor->rotPivotOffset.y * playerActor->scalingFactor;
300
301 decorations->rotX[i] = clamp_angle(playerActor->rot.x) * 0.5f;
302 decorations->rotY[i] = clamp_angle(playerActor->rot.y) * 0.5f;
303 decorations->rotZ[i] = clamp_angle(playerActor->rot.z) * 0.5f;
304 }
305}

◆ reset_player_blur()

void reset_player_blur ( void )

Definition at line 320 of file actor_rendering.c.

320 {
321 Actor* playerActor = gBattleStatus.playerActor;
322 ActorPart* partsTable = playerActor->partsTable;
323 DecorationTable* decorations = partsTable->decorationTable;
324
325 if (decorations->blurEnableCount != 0) {
326 decorations->blurEnableCount--;
327 if (decorations->blurEnableCount == 0) {
328 playerActor->flags &= ~ACTOR_FLAG_BLUR_ENABLED;
329 decorations->blurDisableDelay = 1;
330 }
331 }
332}

◆ force_disable_player_blur()

void force_disable_player_blur ( void )

Definition at line 334 of file actor_rendering.c.

334 {
335 Actor* playerActor = gBattleStatus.playerActor;
336 ActorPart* partsTable = playerActor->partsTable;
337 DecorationTable* decorations = partsTable->decorationTable;
338
339 decorations->blurEnableCount = 0;
340 decorations->blurDisableDelay = 20;
341}

◆ force_disable_player_blur_immediately()

void force_disable_player_blur_immediately ( void )

Definition at line 343 of file actor_rendering.c.

343 {
344 Actor* playerActor = gBattleStatus.playerActor;
345 ActorPart* partsTable = playerActor->partsTable;
346 DecorationTable* decorations = partsTable->decorationTable;
347
348 playerActor->flags &= ~ACTOR_FLAG_BLUR_ENABLED;
349 decorations->blurEnableCount = 0;
350 decorations->blurDisableDelay = 1;
351}

◆ func_8023E104()

void func_8023E104 ( void )

Definition at line 150 of file 16C8E0.c.

150 {
151 D_802809F4 = 1;
152 D_802809F5 = 0;
153}
s8 D_802809F4
Definition 16C8E0.c:10
s8 D_802809F5
Definition 16C8E0.c:11

Referenced by btl_state_update_run_away().

◆ func_8023E11C()

void func_8023E11C ( void )

Definition at line 155 of file 16C8E0.c.

155 {
156 D_802809F4 = 0;
157 D_802809F5 = 0;
158}

Referenced by btl_state_update_run_away().

◆ set_goal_pos_to_part()

void set_goal_pos_to_part ( ActorState * state,
s32 actorID,
s32 partID )

Definition at line 44 of file actor_api.c.

44 {
45 s32 actorClass = actorID & ACTOR_CLASS_MASK;
46 Actor* actor = get_actor(actorID);
47 ActorPart* part;
48
49 switch (actorClass) {
51 part = get_actor_part(actor, 0);
52 state->goalPos.x = actor->curPos.x + part->partOffset.x * actor->scalingFactor;
53 state->goalPos.y = actor->curPos.y + part->partOffset.y * actor->scalingFactor;
54 state->goalPos.z = actor->curPos.z + 10.0f;
55 if (actor->stoneStatus == STATUS_KEY_STONE) {
56 state->goalPos.y -= actor->scalingFactor * 5.0f;
57 }
58 break;
61 part = get_actor_part(actor, partID);
63 state->goalPos.x = actor->curPos.x + (part->partOffset.x + part->targetOffset.x) * actor->scalingFactor;
64 if (!(actor->flags & ACTOR_FLAG_UPSIDE_DOWN)) {
65 state->goalPos.y = actor->curPos.y + (part->partOffset.y + part->targetOffset.y) * actor->scalingFactor;
66 } else {
67 state->goalPos.y = actor->curPos.y + (-part->partOffset.y - part->targetOffset.y) * actor->scalingFactor;
68 }
69 state->goalPos.z = actor->curPos.z + part->partOffset.z + 10.0f;
70 } else {
71 state->goalPos.x = part->absolutePos.x + part->targetOffset.x;
72 if (!(actor->flags & ACTOR_FLAG_UPSIDE_DOWN)) {
73 state->goalPos.y = part->absolutePos.y + part->targetOffset.y * actor->scalingFactor;
74 } else {
75 state->goalPos.y = part->absolutePos.y - part->targetOffset.y * actor->scalingFactor;
76 }
77 state->goalPos.z = part->absolutePos.z + 10.0f;
78 }
79 break;
80 }
81}
Actor * get_actor(s32 actorID)
Definition actor_api.c:155

Referenced by dispatch_damage_event_partner(), and dispatch_damage_event_player().

◆ init_encounters_ui()

void init_encounters_ui ( void )

Definition at line 2814 of file encounter.c.

2814 {
2815}

Referenced by draw_encounter_ui().

◆ initialize_collision()

void initialize_collision ( void )

◆ render_entities()

void render_entities ( void )

Definition at line 338 of file entity.c.

338 {
339 s32 i;
340
341 for (i = 0; i < MAX_ENTITIES; i++) {
342 Entity* entity = get_entity_by_index(i);
343
344 if (entity != NULL) {
350 entity->pos.x,
351 entity->pos.z) > 200.0f
352 ) {
353 continue;
354 }
355
358 continue;
359 }
360 } else if (gEntityHideMode == ENTITY_HIDE_MODE_2) {
362 continue;
363 }
364 }
365 }
366
367 if (!(entity->flags & ENTITY_FLAG_HIDDEN)) {
369 if (D_8014AFB0 == 255) {
370 if (entity->renderSetupFunc != NULL) {
372 entity->virtualModelIndex,
373 (void*)(u32) entity->listIndex,
374 (void (*)(void*)) entity->renderSetupFunc
375 );
376 }
377 } else {
379 entity->virtualModelIndex,
380 (void*)(u32) entity->listIndex,
382 );
383 }
384
385 if (entity->gfxBaseAddr == NULL) {
387 } else {
389 &entity->transformMatrix,
390 entity->vertexSegment,
391 entity->gfxBaseAddr);
392 }
393 } else {
394 if (D_8014AFB0 == 255) {
395 if (entity->renderSetupFunc != NULL) {
397 entity->virtualModelIndex,
398 (void*)(u32) entity->listIndex,
399 (void (*)(void*)) entity->renderSetupFunc
400 );
401 } else {
403 }
404 } else {
406 }
407
408 if (entity->gfxBaseAddr == NULL) {
410 } else {
412 &entity->transformMatrix,
413 entity->vertexSegment,
414 entity->gfxBaseAddr);
415 }
416 }
417 }
418 }
419 }
420
422}
s32 gEntityHideMode
Definition entity.c:37
void render_shadows(void)
Definition entity.c:424
s32 D_8014AFB0
Definition entity.c:33
void func_8010FE44(void *arg0)
Definition entity.c:327
EntityModel * get_entity_model(s32 idx)
@ ENTITY_HIDE_MODE_1
Definition enums.h:2661
@ ENTITY_HIDE_MODE_0
Definition enums.h:2660
@ ENTITY_HIDE_MODE_2
Definition enums.h:2662
@ ENTITY_FLAG_IGNORE_DISTANCE_CULLING
Definition enums.h:2632
@ ENTITY_FLAG_DRAW_IF_CLOSE_HIDE_MODE2
Definition enums.h:2631
@ ENTITY_FLAG_DRAW_IF_CLOSE_HIDE_MODE1
Definition enums.h:2614
void draw_entity_model_A(s32, Mtx *)
void draw_entity_model_B(s32, Mtx *, s32, Vec3s *)
void render_animated_model_with_vertices(s32 animatorID, Mtx *rootTransform, s32 segment, void *baseAddr)
Definition animator.c:795
ModelAnimator * set_animator_render_callback(s32 animModelID, void *callbackArg, void(*callbackFunc)(void *))
Definition animator.c:1045
void render_animated_model(s32 animatorID, Mtx *rootTransform)
Definition animator.c:765
void(* fpSetupGfxCallback)(void *)
Definition entity.h:463
s16 vertexSegment
Mtx transformMatrix

Referenced by render_frame().

◆ render_player()

void render_player ( void )

Definition at line 1489 of file 77480.c.

1489 {
1492 }
1493}
void render_player_model(void)
Definition 77480.c:1495

Referenced by render_frame().

◆ render_workers_scene()

void render_workers_scene ( void )

Definition at line 137 of file worker.c.

137 {
138 s32 i;
139
140 for (i = 0; i < MAX_WORKERS; i++) {
141 Worker* worker = (*gCurrentWorkerListPtr)[i];
142 if (worker != NULL && !(worker->flags & WORKER_FLAG_SKIP_DRAW_UNTIL_UPDATE)) {
143 if (!(worker->flags & WORKER_FLAG_FRONT_UI)) {
144 worker->draw();
145 }
146 }
147 }
148}

Referenced by render_frame().

◆ render_effects_scene()

void render_effects_scene ( void )

Definition at line 116 of file effects.c.

116 {
117 s32 i;
118
119 for (i = 0; i < ARRAY_COUNT(gEffectInstances); i++) {
120 EffectInstance* effectInstance = gEffectInstances[i];
121
122 if (effectInstance != NULL) {
123 if (effectInstance->flags & FX_INSTANCE_FLAG_ENABLED) {
124 if (effectInstance->flags & FX_INSTANCE_FLAG_HAS_UPDATED) {
126 if (effectInstance->flags & FX_INSTANCE_FLAG_BATTLE) {
127 effectInstance->shared->renderScene(effectInstance);
128 }
129 } else {
130 if (!(effectInstance->flags & FX_INSTANCE_FLAG_BATTLE)) {
131 effectInstance->shared->renderScene(effectInstance);
132 }
133 }
134 }
135 }
136 }
137 }
138}
void(* renderScene)(EffectInstance *effectInst)
Definition effects.h:2664

Referenced by render_frame().

◆ get_asset_offset()

s32 get_asset_offset ( char * assetName,
s32 * compressedSize )

Definition at line 273 of file world.c.

273 {
274 AssetHeader firstHeader;
275 AssetHeader* assetTableBuffer;
276 AssetHeader* curAsset;
277 s32 ret;
278
279 dma_copy((u8*) ASSET_TABLE_FIRST_ENTRY, (u8*) ASSET_TABLE_FIRST_ENTRY + sizeof(AssetHeader), &firstHeader);
280 assetTableBuffer = heap_malloc(firstHeader.offset);
281 curAsset = &assetTableBuffer[0];
282 dma_copy((u8*) ASSET_TABLE_FIRST_ENTRY, (u8*) ASSET_TABLE_FIRST_ENTRY + firstHeader.offset, assetTableBuffer);
283 while (strcmp(curAsset->name, assetName) != 0) {
284 ASSERT_MSG(strcmp(curAsset->name, "end_data") != 0, "Asset not found: %s", assetName);
285 curAsset++;
286 }
287 *compressedSize = curAsset->compressedLength;
288 ret = ASSET_TABLE_FIRST_ENTRY + curAsset->offset;
289 heap_free(assetTableBuffer);
290 return ret;
291}

Referenced by btl_state_update_normal_start(), load_map_by_IDs(), and state_step_end_battle().

◆ initialize_status_bar()

void initialize_status_bar ( void )

Definition at line 483 of file inventory.c.

483 {
484 StatusBar* statusBar = &gStatusBar;
485 PlayerData* playerData = &gPlayerData;
486 HudElemID hid;
487
488 statusBar->drawPosX = 12;
489 ShowingCoinCounter = FALSE;
490 HidingCoinCounter = FALSE;
491 statusBar->drawPosY = FULLY_RETRACTED_Y;
492 statusBar->hidden = FALSE;
493 statusBar->showTimer = 210;
494 statusBar->unk_3B = FALSE;
495 statusBar->ignoreChanges = FALSE;
496 statusBar->openInputDisabled = FALSE;
497 statusBar->alwaysShown = FALSE;
498 statusBar->hpBlinking = BLINK_OFF;
499 statusBar->hpBlinkAnimTime = 0;
500 statusBar->hpBlinkTimeLeft = 0;
501 statusBar->fpBlinking = BLINK_OFF;
502 statusBar->fpBlinkAnimTime = 0;
503 statusBar->fpBlinkTimeLeft = 0;
504 statusBar->starPowerBlinking = BLINK_OFF;
505 statusBar->starPowerBlinkCounter = 0;
506 statusBar->coinsBlinking = BLINK_OFF;
507 statusBar->coinsBlinkAnimTime = 0;
508 statusBar->coinsBlinkTimeLeft = 0;
509 statusBar->disabled = 0;
510 statusBar->starpointsBlinking = BLINK_OFF;
511 statusBar->displayHP = playerData->curHP;
512 statusBar->displayFP = playerData->curFP;
513 statusBar->displayCoins = playerData->coins;
514 statusBar->displayStarpoints = playerData->starPoints;
515 statusBar->displayStarPower = playerData->starPower;
516 statusBar->starpointsBlinkAnimTime = 0;
517 statusBar->prevIgnoreChanges = -1;
518 statusBar->unk_3C = FALSE;
519 statusBar->shimmerState = STATUS_SHIMMER_OFF;
520 statusBar->shimmerTime = 0;
521 statusBar->shimmerLimit = 0;
522 statusBar->powBarsToBlink = 0;
523 statusBar->coinCounterHideDelay = 0;
524 statusBar->coinCountDisposeTime = 0;
525 statusBar->iconIndex12 = -1;
526
528
529#if VERSION_PAL
530 switch (gCurrentLanguage) {
531 case LANGUAGE_EN:
532 hid = statusBar->hpIconHIDs[0] = hud_element_create(&HES_StatusHP);
533 break;
534 case LANGUAGE_DE:
535 hid = statusBar->hpIconHIDs[0] = hud_element_create(&HES_StatusHP_de);
536 break;
537 case LANGUAGE_FR:
538 hid = statusBar->hpIconHIDs[0] = hud_element_create(&HES_StatusHP_fr);
539 break;
540 case LANGUAGE_ES:
541 hid = statusBar->hpIconHIDs[0] = hud_element_create(&HES_StatusHP_es);
542 break;
543 }
544
547#else
548 statusBar->hpIconHIDs[0] = hid = hud_element_create(&HES_StatusHP);
551#endif
552
553 statusBar->hpIconHIDs[1] = hid = hud_element_create(&HES_StatusHeart);
556
557#if VERSION_PAL
558 switch (gCurrentLanguage) {
559 case LANGUAGE_EN:
560 hid = statusBar->fpIconHIDs[0] = hud_element_create(&HES_StatusFP);
561 break;
562 case LANGUAGE_DE:
563 hid = statusBar->fpIconHIDs[0] = hud_element_create(&HES_StatusFP_de);
564 break;
565 case LANGUAGE_FR:
566 hid = statusBar->fpIconHIDs[0] = hud_element_create(&HES_StatusFP_fr);
567 break;
568 case LANGUAGE_ES:
569 hid = statusBar->fpIconHIDs[0] = hud_element_create(&HES_StatusFP_es);
570 break;
571 }
572
575#else
576 statusBar->fpIconHIDs[0] = hid = hud_element_create(&HES_StatusFP);
579#endif
580
581 statusBar->fpIconHIDs[1] = hid = hud_element_create(&HES_StatusFlower);
584
585 statusBar->coinIconHID = hid = hud_element_create(&HES_StatusCoin);
588
592
596
600
601 statusBar->hpTimesHID = hid = hud_element_create(&HES_StatusTimes);
604
605 statusBar->fpTimesHID = hid = hud_element_create(&HES_StatusTimes);
608
609 statusBar->spTimesHID = hid = hud_element_create(&HES_StatusTimes);
612
616
620
622}
HudElemID spShineHID
HudElemID spTimesHID
HudElemID hpTimesHID
s8 starPowerBlinkCounter
s8 starpointsBlinkAnimTime
s16 displayStarpoints
HudElemID hpIconHIDs[2]
HudElemID coinIconHID
HudElemID coinTimesHID
HudElemID coinSparkleHID
HudElemID starIconHID
HudElemID fpIconHIDs[2]
HudElemID spIconHID
HudElemID fpTimesHID
@ LANGUAGE_DE
Definition enums.h:6400
@ LANGUAGE_ES
Definition enums.h:6402
@ LANGUAGE_EN
Definition enums.h:6399
@ LANGUAGE_FR
Definition enums.h:6401
void star_power_shimmer_init(void)
#define FULLY_RETRACTED_Y
Definition inventory.c:7
HudScript HES_StatusHP_de
HudScript HES_StatusHP
HudScript HES_StatusFP_de
HudScript HES_StatusStar1
HudScript HES_StatusFP
@ BLINK_OFF
Definition inventory.c:10
HudScript HES_StatusSPShine
void close_status_bar(void)
Definition inventory.c:1451
HudScript HES_StatusStarPoint
HudScript HES_StatusHP_es
HudScript HES_StatusCoinSparkle
HudScript HES_StatusFP_fr
HudScript HES_StatusTimes
@ STATUS_SHIMMER_OFF
Definition inventory.c:15
HudScript HES_StatusHP_fr
HudScript HES_StatusFP_es
HudScript HES_StatusHeart
HudScript HES_StatusFlower

Referenced by load_demo_battle(), and load_map_by_IDs().

◆ status_bar_start_blinking_fp()

void status_bar_start_blinking_fp ( void )

Definition at line 1564 of file inventory.c.

1564 {
1565 StatusBar* statusBar = &gStatusBar;
1566
1568 statusBar->fpBlinkTimeLeft = 120;
1569 }
1570
1571 if (statusBar->fpBlinking != BLINK_ON) {
1572 statusBar->fpBlinking = BLINK_ON;
1573 statusBar->fpBlinkAnimTime = 0;
1574 }
1575}
@ BLINK_ON
Definition inventory.c:11

Referenced by btl_menu_moves_draw_content(), and update_status_bar().

◆ is_status_bar_visible()

s32 is_status_bar_visible ( void )

Definition at line 1537 of file inventory.c.

1537 {
1538 return !gStatusBar.hidden;
1539}

Referenced by check_input_status_bar().

◆ status_bar_start_blinking_starpoints()

void status_bar_start_blinking_starpoints ( void )

Definition at line 1639 of file inventory.c.

1639 {
1640 StatusBar* statusBar = &gStatusBar;
1641
1642 if (statusBar->starpointsBlinking != BLINK_ON) {
1643 statusBar->starpointsBlinking = BLINK_ON;
1644 statusBar->starpointsBlinkAnimTime = 0;
1645 }
1646}

Referenced by btl_state_update_run_away().

◆ status_bar_stop_blinking_starpoints()

void status_bar_stop_blinking_starpoints ( void )

Definition at line 1648 of file inventory.c.

1648 {
1649 StatusBar* statusBar = &gStatusBar;
1650
1651 if (statusBar->starpointsBlinking != BLINK_OFF) {
1652 statusBar->starpointsBlinking = BLINK_OFF;
1653 statusBar->starpointsBlinkAnimTime = 0;
1654 }
1655}

Referenced by btl_state_update_run_away().

◆ status_bar_start_blinking_hp()

void status_bar_start_blinking_hp ( void )

Definition at line 1541 of file inventory.c.

1541 {
1542 StatusBar* statusBar = &gStatusBar;
1543
1545 statusBar->hpBlinkTimeLeft = 120;
1546 }
1547
1548 if (statusBar->hpBlinking != BLINK_ON) {
1549 statusBar->hpBlinking = BLINK_ON;
1550 statusBar->hpBlinkAnimTime = 0;
1551 }
1552}

Referenced by update_status_bar().

◆ status_bar_start_blinking_sp()

void status_bar_start_blinking_sp ( void )

Definition at line 1609 of file inventory.c.

1609 {
1610 PlayerData* playerData = &gPlayerData;
1611 StatusBar* statusBar = &gStatusBar;
1612
1613 statusBar->powBarsToBlink = playerData->maxStarPower;
1614 if (statusBar->starPowerBlinking != BLINK_ON) {
1615 statusBar->starPowerBlinking = BLINK_ON;
1616 statusBar->starPowerBlinkCounter = 0;
1617 }
1618}

◆ status_bar_stop_blinking_fp()

void status_bar_stop_blinking_fp ( void )

Definition at line 1577 of file inventory.c.

1577 {
1578 StatusBar* statusBar = &gStatusBar;
1579
1580 if (statusBar->fpBlinking != BLINK_OFF) {
1581 statusBar->fpBlinking = BLINK_OFF;
1582 statusBar->fpBlinkAnimTime = 0;
1583 }
1584}

Referenced by btl_menu_moves_draw_content(), btl_submenu_moves_update(), and update_status_bar().

◆ status_bar_stop_blinking_hp()

void status_bar_stop_blinking_hp ( void )

Definition at line 1554 of file inventory.c.

1554 {
1555 StatusBar* statusBar = &gStatusBar;
1556
1557 if (statusBar->hpBlinking != BLINK_OFF) {
1558 statusBar->hpBlinking = BLINK_OFF;
1559 statusBar->hpBlinkAnimTime = 0;
1560 statusBar->hpBlinkTimeLeft = 0;
1561 }
1562}

Referenced by update_status_bar().

◆ status_bar_stop_blinking_sp()

void status_bar_stop_blinking_sp ( void )

Definition at line 1620 of file inventory.c.

1620 {
1621 StatusBar* statusBar = &gStatusBar;
1622
1623 if (statusBar->starPowerBlinking != BLINK_OFF) {
1624 statusBar->starPowerBlinking = BLINK_OFF;
1625 statusBar->starPowerBlinkCounter = 0;
1626 }
1627}

Referenced by btl_menu_moves_draw_content(), and btl_submenu_moves_update().

◆ status_bar_start_blinking_sp_bars()

void status_bar_start_blinking_sp_bars ( s32 numBarsToBlink)

Definition at line 1629 of file inventory.c.

1629 {
1630 StatusBar* statusBar = &gStatusBar;
1631
1632 statusBar->powBarsToBlink = numBarsToBlink;
1633 if (statusBar->starPowerBlinking != BLINK_ON) {
1634 statusBar->starPowerBlinking = BLINK_ON;
1635 statusBar->starPowerBlinkCounter = 0;
1636 }
1637}

Referenced by btl_menu_moves_draw_content().

◆ status_bar_draw_number()

void status_bar_draw_number ( s32 iconID,
s32 x,
s32 y,
s32 value,
s32 numDigits )

Definition at line 624 of file inventory.c.

624 {
625 s8 digits[4];
626 s32 drawX, drawY;
627 b32 keepDrawing;
628 s32 digit;
629 s32 i;
630
632 drawX = startX + 8;
633 drawY = startY + 8;
634 hud_element_set_render_pos(iconID, drawX, drawY - 1);
636 hud_element_draw_next(iconID);
637
638 // Write each digit of the input number into the digits array
639 for (i = 0; i < numDigits; i++) {
640 digit = value % 10;
641 digits[(numDigits - i) - 1] = digit;
642 value /= 10;
643 }
644
645 drawX += 13;
646 keepDrawing = FALSE;
647
648 for (i = 0; i < numDigits; i++, drawX += 8) {
649 digit = digits[i];
650
651 // Once we have encountered our first non-zero digit, we need to keep drawing the remaining digits
652 if (digit != 0 || keepDrawing || (i == numDigits - 1)) {
653 keepDrawing = TRUE;
655 hud_element_set_render_pos(iconID, drawX, drawY);
657 hud_element_draw_next(iconID);
658 }
659 }
660}
void hud_element_draw_next(s32 id)
HudScript * TimesHudScript
Definition partners.c:146
HudScript * DigitHudScripts[10]
Definition partners.c:142

Referenced by update_status_bar().

◆ status_bar_draw_stat()

void status_bar_draw_stat ( s32 id,
s32 x,
s32 y,
s32 currentValue,
s32 maxValue )

Definition at line 662 of file inventory.c.

662 {
663 s8 digits[4];
664 b32 keepDrawing;
665 s32 digit;
666 s32 numDigits = 2;
667 s32 drawX;
668 s32 drawY;
669 s32 i = 0;
670 s32 baseX = startX + 8;
671 s32 baseY = startY + 8;
672
674 hud_element_set_render_pos(id, baseX + 14, baseY + 1);
677
678 for (i = 0; i < numDigits; i++) {
679 s32 num = currentValue % 10;
680 digits[numDigits - i - 1] = num;
681 currentValue /= 10;
682 }
683
684 drawX = baseX;
685 drawY = baseY;
686 keepDrawing = FALSE;
687 for (i = 0; i < numDigits; i++, drawX += 8) {
688 digit = digits[i];
689 if (digit != 0 || keepDrawing || i == numDigits - 1) {
690 keepDrawing = TRUE;
692 hud_element_set_render_pos(id, drawX, drawY);
695 }
696 }
697
698 for (i = 0; i < numDigits; i++) {
699 digits[numDigits - i - 1] = maxValue % 10;
700 maxValue /= 10;
701 }
702
703 drawX = baseX + 26;
704 drawY = baseY;
705 keepDrawing = FALSE;
706 for (i = 0; i < numDigits; i++, drawX += 8) {
707 digit = digits[i];
708 if (digit != 0 || keepDrawing || i == numDigits - 1) {
709 keepDrawing = TRUE;
711 hud_element_set_render_pos(id, drawX, drawY);
714 }
715 }
716}
HudScript * SlashHudScript
Definition partners.c:147

Referenced by update_status_bar().

◆ set_background_size()

void set_background_size ( s16 startX,
s16 startY,
s16 sizeX,
s16 sizeY )

Definition at line 50 of file background.c.

50 {
51 gGameStatusPtr->backgroundFlags &= ~BACKGROUND_FLAG_TEXTURE;
56}

Referenced by load_map_by_IDs(), state_step_end_battle(), and state_step_unpause().

◆ set_background()

◆ set_max_star_power()

void set_max_star_power ( s8 newMax)

Definition at line 2140 of file inventory.c.

2140 {
2141 gPlayerData.maxStarPower = newMax;
2142 gPlayerData.starPower = newMax * SP_PER_BAR;
2143}

◆ sync_status_bar()

void sync_status_bar ( void )

Definition at line 1671 of file inventory.c.

1671 {
1672 PlayerData* playerData = &gPlayerData;
1673 StatusBar* statusBar = &gStatusBar;
1674
1675 statusBar->displayHP = playerData->curHP;
1676 statusBar->displayFP = playerData->curFP;
1677 statusBar->displayStarPower = playerData->starPower;
1678 statusBar->displayCoins = playerData->coins;
1679 statusBar->displayStarpoints = playerData->starPoints;
1680}

◆ create_cameras()

void create_cameras ( void )

Definition at line 255 of file cam_main.c.

255 {
256 CameraInitData camData;
257 CameraInitData* camDataPtr = &camData;
258 s32 i;
259
260 CamLengthScale = 1.0f;
261
262 for (i = 0; i < ARRAY_COUNT(gCameras); i++) {
263 gCameras[i].flags = 0;
264 }
265
266 camDataPtr->flags = CAMERA_FLAG_DISABLED;
267 camDataPtr->updateMode = CAM_UPDATE_MINIMAL;
268 camDataPtr->viewWidth = 160;
269 camDataPtr->viewHeight = 120;
270 camDataPtr->viewStartX = 0;
271 camDataPtr->viewStartY = 0;
272 camDataPtr->nearClip = 8;
273 camDataPtr->farClip = 16384;
274 camDataPtr->vfov = 50;
275 initialize_next_camera(camDataPtr);
276
277 camDataPtr->flags = CAMERA_FLAG_DISABLED;
278 camDataPtr->updateMode = CAM_UPDATE_MINIMAL;
279 camDataPtr->viewWidth = 160;
280 camDataPtr->viewHeight = 120;
281 camDataPtr->viewStartX = 160;
282 camDataPtr->viewStartY = 0;
283 camDataPtr->nearClip = 8;
284 camDataPtr->farClip = 16384;
285 camDataPtr->vfov = 50;
286 initialize_next_camera(camDataPtr);
287
288 camDataPtr->flags = CAMERA_FLAG_DISABLED;
289 camDataPtr->updateMode = CAM_UPDATE_MINIMAL;
290 camDataPtr->viewWidth = 160;
291 camDataPtr->viewHeight = 120;
292 camDataPtr->viewStartX = 0;
293 camDataPtr->viewStartY = 120;
294 camDataPtr->nearClip = 8;
295 camDataPtr->farClip = 16384;
296 camDataPtr->vfov = 50;
297 initialize_next_camera(camDataPtr);
298
299 camDataPtr->flags = CAMERA_FLAG_DISABLED;
300 camDataPtr->updateMode = CAM_UPDATE_MINIMAL;
301 camDataPtr->viewWidth = 160;
302 camDataPtr->viewHeight = 120;
303 camDataPtr->viewStartX = 160;
304 camDataPtr->viewStartY = 120;
305 camDataPtr->nearClip = 8;
306 camDataPtr->farClip = 16384;
307 camDataPtr->vfov = 50;
308 initialize_next_camera(camDataPtr);
309}
f32 CamLengthScale
Definition cam_main.c:12
Camera * initialize_next_camera(CameraInitData *initData)
Definition cam_main.c:311

Referenced by load_demo_battle(), load_engine_data(), load_map_by_IDs(), state_init_logos(), state_init_title_screen(), state_step_demo(), state_step_intro(), state_step_startup(), and state_step_title_screen().

◆ func_80045AC0()

void func_80045AC0 ( void )

Definition at line 125 of file status_icons.c.

125 {
126 s32 i;
127
128 for (i = 0; i < ARRAY_COUNT(D_800A0BC0); i++) {
129 PopupMessage* popup = &D_800A0BC0[i];
130 popup->active = FALSE;
131 popup->data.icons = NULL;
132 }
133
136}
BSS PopupMessage D_800A0BC0[32]
void func_80045BC8(void)
void init_all_status_icons(void)

Referenced by clear_encounter_status(), and init_encounter_status().

◆ func_8005AF84()

void func_8005AF84 ( void )

Definition at line 105 of file collision.c.

105 {
106}

Referenced by state_step_end_battle(), and state_step_unpause().

◆ npc_follow_init()

void npc_follow_init ( Npc * npc,
s32 targetNpcID,
FollowAnims * anims,
f32 walkSpeed,
f32 runSpeed,
s32 idleRadius,
s32 walkRadius )

Definition at line 38 of file npc_follow.c.

38 {
39 PlayerStatus* playerStatus = &gPlayerStatus;
40 NpcFollowData* followData;
41 s32 i;
42
43 npc->blur.followData = followData = heap_malloc(sizeof(*followData));
44 ASSERT(followData != NULL);
45
46 for (i = 0; i < ARRAY_COUNT(followData->moveHistory); i++) {
47 followData->moveHistory[i].pos.x = playerStatus->pos.x;
48 followData->moveHistory[i].pos.y = playerStatus->pos.y;
49 followData->moveHistory[i].pos.z = playerStatus->pos.z;
50 followData->moveHistory[i].isAirborne = FALSE;
51 }
52 followData->lastPointIdx = 0;
53 followData->targetPointIdx = 0;
55 followData->targetNpcID = targetNpcID;
56 followData->anims = anims;
57 followData->walkSpeed = walkSpeed;
58 followData->runSpeed = runSpeed;
59 followData->idleRadius = idleRadius;
60 followData->walkRadius = walkRadius;
61 npc->curAnim = followData->anims->idle;
62 npc->jumpVel = 0.0f;
63 npc->flags |= NPC_FLAG_GRAVITY;
64 npc->flags &= ~NPC_FLAG_IGNORE_PLAYER_COLLISION;
66}
NpcHistoryPoint moveHistory[40]
FollowAnims * anims
@ NPC_FOLLOW_STATE_RUN
Definition npc_follow.c:4

◆ npc_update_npc_tracking()

void npc_update_npc_tracking ( Npc * npc)

Definition at line 68 of file npc_follow.c.

68 {
69 NpcFollowData* followData = npc->blur.followData;
70 f32 x, y, z;
71 s32 airborne;
72 s32 isAirborne;
73 NpcHistoryPoint* historyPoint;
74
75 get_npc_pos(followData->targetNpcID, &x, &y, &z, &airborne);
76 historyPoint = &followData->moveHistory[followData->lastPointIdx];
77 isAirborne = airborne != FALSE;
78
79 if (historyPoint->isAirborne && isAirborne) {
80 return;
81 }
82
83 if (!isAirborne && dist2D(npc->pos.x, npc->pos.z, x, z) <= followData->idleRadius && !historyPoint->isAirborne) {
84 return;
85 }
86
87 historyPoint = &followData->moveHistory[followData->lastPointIdx];
88 if (historyPoint->pos.x != x || historyPoint->pos.y != y || historyPoint->pos.z != z) {
89 if (followData->targetPointIdx != followData->lastPointIdx + 1) {
90 followData->lastPointIdx++;
91 if (followData->lastPointIdx >= ARRAY_COUNT(followData->moveHistory)) {
92 followData->lastPointIdx = 0;
93 }
94 historyPoint = &followData->moveHistory[followData->lastPointIdx];
95 historyPoint->pos.x = x;
96 historyPoint->pos.y = y;
97 historyPoint->pos.z = z;
98 historyPoint->isAirborne = isAirborne;
99 }
100 }
101}
void get_npc_pos(s32 npcID, f32 *outX, f32 *outY, f32 *outZ, s32 *outAirborne)
Definition npc_follow.c:10

◆ npc_follow_npc()

void npc_follow_npc ( Npc * npc)

Definition at line 103 of file npc_follow.c.

103 {
104 NpcFollowData* followData = npc->blur.followData;
105 f32 x, y, z;
106 s32 airborne;
107 f32 currentX, currentY, currentZ;
108 f32 dist;
109 NpcHistoryPoint* historyPoint;
110 f32 targetX, targetY, targetZ;
111 f32 theta;
112 f32 yaw;
113
114 get_npc_pos(followData->targetNpcID, &x, &y, &z, &airborne);
115
116 switch (followData->followState) {
118 historyPoint = &followData->moveHistory[followData->targetPointIdx];
119 targetX = historyPoint->pos.x;
120 targetY = historyPoint->pos.y;
121 targetZ = historyPoint->pos.z;
122 currentX = npc->pos.x;
123 currentY = npc->pos.y;
124 currentZ = npc->pos.z;
125 npc->moveSpeed = followData->walkSpeed;
126
127 dist = dist2D(npc->pos.x, npc->pos.z, x, z);
128 if (dist >= followData->walkRadius) {
129 npc->moveSpeed = followData->runSpeed;
130 }
131
132 npc->curAnim = followData->anims->run;
133 if (!(npc->flags & NPC_FLAG_GROUNDED)) {
134 npc->curAnim = followData->anims->fall;
135 }
136
137 while (TRUE) {
138 dist = dist2D(currentX, currentZ, targetX, targetZ);
139 yaw = atan2(currentX, currentZ, targetX, targetZ);
140 if (dist > npc->moveSpeed) {
141 dist = dist2D(currentX, currentZ, x, z);
142 if (dist > followData->walkRadius) {
143 break;
144 }
145
146 if (dist > followData->idleRadius) {
147 npc->moveSpeed = dist - followData->idleRadius;
148 if (npc->moveSpeed > followData->walkSpeed) {
149 npc->moveSpeed = followData->walkSpeed;
150 } else {
151 npc->moveSpeed += 1.0;
152 }
153 break;
154 }
155 }
156
157 if (followData->targetPointIdx == followData->lastPointIdx) {
158 npc->moveSpeed = 0.0f;
159 yaw = npc->yaw;
160 npc->curAnim = followData->anims->idle;
161 break;
162 }
163
164 dist = dist2D(npc->pos.x, npc->pos.z, x, z);
165 if (dist <= followData->idleRadius) {
166 npc->moveSpeed = 0.0f;
167 yaw = npc->yaw;
168 npc->curAnim = followData->anims->idle;
170 break;
171 }
172
173 followData->targetPointIdx++;
174 if (followData->targetPointIdx >= ARRAY_COUNT(followData->moveHistory)) {
175 followData->targetPointIdx = 0;
176 }
177 historyPoint = &followData->moveHistory[followData->targetPointIdx];
178 targetX = historyPoint->pos.x;
179 targetZ = historyPoint->pos.z;
180 if (npc->flags & NPC_FLAG_GROUNDED) {
181 if (historyPoint->isAirborne) {
183 break;
184 }
185 }
186 }
187
188 if (!(npc->flags & NPC_FLAG_GROUNDED)) {
189 npc->moveSpeed *= 0.5f;
190 }
191 npc->yaw = yaw;
192 npc_move_heading(npc, npc->moveSpeed, yaw);
195 }
196 break;
198 if (followData->targetPointIdx != followData->lastPointIdx) {
199 followData->targetPointIdx++;
200 if (followData->targetPointIdx >= ARRAY_COUNT(followData->moveHistory)) {
201 followData->targetPointIdx = 0;
202 }
203 historyPoint = &followData->moveHistory[followData->targetPointIdx];
204 targetX = historyPoint->pos.x;
205 targetY = historyPoint->pos.y;
206 targetZ = historyPoint->pos.z;
207 npc->moveToPos.x = targetX;
208 npc->moveToPos.y = targetY;
209 npc->moveToPos.z = targetZ;
210 npc->duration = 0;
211 npc->jumpScale = 2.0f;
212 npc->moveSpeed = followData->runSpeed;
213 npc->planarFlyDist = dist2D(npc->pos.x, npc->pos.z, npc->moveToPos.x, npc->moveToPos.z);
214 npc->yaw = atan2(npc->pos.x, npc->pos.z, npc->moveToPos.x, npc->moveToPos.z);
215 dist = npc->planarFlyDist;
216 currentY = npc->moveToPos.y - npc->pos.y;
217 if (npc->planarFlyDist < currentY) {
218 dist = currentY;
219 }
220 if (dist < followData->idleRadius) {
221 npc->jumpVel = 0.0f;
222 npc->flags |= NPC_FLAG_GRAVITY;
223 npc->yaw = atan2(npc->pos.x, npc->pos.z, x, z);
224 followData->followState = NPC_FOLLOW_STATE_RUN;
225 return;
226 }
227 npc->duration = dist / npc->moveSpeed;
228 if (npc->duration < 10) {
229 npc->duration = 10;
230 }
231 npc->moveSpeed = npc->planarFlyDist / npc->duration;
232 npc->jumpVel = (currentY + (npc->jumpScale * npc->duration * npc->duration * 0.5f)) / npc->duration;
233 npc->curAnim = followData->anims->jump;
234 npc->flags &= ~NPC_FLAG_GRAVITY;
236 }
237 break;
239 npc->jumpVel -= npc->jumpScale;
240 npc->pos.y += npc->jumpVel;
241 if (npc->jumpVel <= 0.0f) {
242 npc->curAnim = followData->anims->fall;
243 }
244 npc_move_heading(npc, npc->moveSpeed, npc->yaw);
245 if (npc->jumpVel <= 0.0f) {
246 currentX = npc->pos.x;
247 dist = fabsf(npc->jumpVel) + 8.0;
248 currentY = npc->pos.y + dist;
249 currentZ = npc->pos.z;
250 if (npc_raycast_down_sides(npc->collisionChannel, &currentX, &currentY, &currentZ, &dist) != 0 &&
251 dist <= fabsf(npc->jumpVel) + 8.0)
252 {
253 npc->curAnim = followData->anims->land;
254 npc->jumpVel = 0.0f;
255 npc->pos.y = currentY;
256 npc->flags |= NPC_FLAG_GRAVITY;
257 npc->yaw = atan2(currentX, currentZ, x, z);
258 followData->followState = NPC_FOLLOW_STATE_RUN;
259 }
260 }
261 break;
263 historyPoint = &followData->moveHistory[followData->targetPointIdx];
264 targetX = historyPoint->pos.x;
265 targetY = historyPoint->pos.y;
266 targetZ = historyPoint->pos.z;
267 currentX = npc->pos.x;
268 currentY = npc->pos.y;
269 currentZ = npc->pos.z;
270 dist = dist2D(npc->pos.x, npc->pos.z, x, z);
271 if (dist <= followData->idleRadius) {
272 break;
273 }
274
275 while (TRUE) {
276 if (historyPoint->isAirborne) {
277 break;
278 }
279
280 yaw = atan2(npc->pos.x, npc->pos.z, targetX, targetZ);
281 if (fabsf(get_clamped_angle_diff(yaw, atan2(npc->pos.x, npc->pos.z, x, z))) < 90.0f) {
282 break;
283 }
284
285 if (followData->targetPointIdx == followData->lastPointIdx) {
286 break;
287 }
288
289 followData->targetPointIdx++;
290 if (followData->targetPointIdx >= ARRAY_COUNT(followData->moveHistory)) {
291 followData->targetPointIdx = 0;
292 }
293 historyPoint = &followData->moveHistory[followData->targetPointIdx];
294 targetX = historyPoint->pos.x;
295 targetZ = historyPoint->pos.z;
296 continue;
297 }
298
299 if (!historyPoint->isAirborne) {
300 followData->followState = NPC_FOLLOW_STATE_RUN;
301 return;
302 }
303
304 while (TRUE) {
305 if (!historyPoint->isAirborne) {
306 break;
307 }
308
309 yaw = atan2(npc->pos.x, npc->pos.z, targetX, targetZ);
310 if (fabsf(get_clamped_angle_diff(yaw, atan2(npc->pos.x, npc->pos.z, x, z))) < 90.0f) {
311 break;
312 }
313
314 if (followData->targetPointIdx == followData->lastPointIdx) {
315 break;
316 }
317
318 followData->targetPointIdx++;
319 if (followData->targetPointIdx >= ARRAY_COUNT(followData->moveHistory)) {
320 followData->targetPointIdx = 0;
321 }
322 historyPoint = &followData->moveHistory[followData->targetPointIdx];
323 targetX = historyPoint->pos.x;
324 targetZ = historyPoint->pos.z;
325 }
327 break;
328 }
329}
@ NPC_FLAG_COLLDING_FORWARD_WITH_WORLD
Definition enums.h:3012
@ NPC_FLAG_GROUNDED
Definition enums.h:3010
@ NPC_FOLLOW_STATE_JUMP
Definition npc_follow.c:5
@ NPC_FOLLOW_STATE_IDLE
Definition npc_follow.c:7
@ NPC_FOLLOW_STATE_FALL
Definition npc_follow.c:6
f32 planarFlyDist

◆ create_encounters()

void create_encounters ( void )

Definition at line 2461 of file encounter.c.

2461 {
2462 EncounterStatus* currentEncounter = &gCurrentEncounter;
2463 NpcBlueprint sp10;
2464 NpcBlueprint* bp = &sp10;
2465 NpcGroup* groupList = (NpcGroup*)(currentEncounter->npcGroupList);
2466 s32 groupNpcCount;
2467 s32 mapID = currentEncounter->mapID;
2468
2469 Npc* newNpc;
2470 s32 newNpcIndex;
2471 s32 npcCount;
2472
2473 NpcSettings* npcSettings;
2474 NpcData* npcData;
2475 Enemy* enemy;
2476 Encounter* encounter;
2477 Evt* script;
2478
2479 s32 totalNpcCount;
2480
2481 s32 cond1;
2482 s32 cond2;
2483 s32 i;
2484 s32 k;
2485 s32 e;
2486
2487 switch (gEncounterSubState) {
2489 if (currentEncounter->resetMapEncounterFlags != 1) {
2490 // check for current map among most recently visited
2491 for (i = 0; i < ARRAY_COUNT(currentEncounter->recentMaps); i++) {
2492 if (currentEncounter->recentMaps[i] == mapID) {
2493 break;
2494 }
2495 }
2496 // current map not found in recent: reset all defeat flags
2497 if (i >= ARRAY_COUNT(currentEncounter->recentMaps)) {
2498 for (k = 0; k < ARRAY_COUNT(currentEncounter->defeatFlags[mapID]); k++) {
2499 currentEncounter->defeatFlags[mapID][k] = FALSE;
2500 }
2501 }
2502 // add current map to recent maps, pushing out the least recent
2503 for (i = 0; i < ARRAY_COUNT(currentEncounter->recentMaps) - 1; i++) {
2504 currentEncounter->recentMaps[i] = currentEncounter->recentMaps[i + 1];
2505 }
2506 currentEncounter->recentMaps[i] = mapID;
2507 }
2508
2509 e = 0;
2510 totalNpcCount = 0;
2511 while (TRUE) {
2512 if (groupList->npcCount == 0) {
2513 break;
2514 }
2515
2516 npcData = groupList->npcs;
2517 groupNpcCount = groupList->npcCount;
2518
2519 encounter = heap_malloc(sizeof(*encounter));
2520
2521 currentEncounter->encounterList[e] = encounter;
2522 ASSERT(encounter != NULL);
2523 encounter->count = groupNpcCount;
2524 encounter->battle = groupList->battle;
2525 encounter->stage = groupList->stage - 1;
2526 encounter->encounterID = totalNpcCount;
2527 for (i = 0; i < groupNpcCount; i++) {
2528 if (get_defeated(mapID, encounter->encounterID + i)) {
2529 npcData++;
2530 encounter->enemy[i] = NULL;
2531 continue;
2532 }
2533
2534 enemy = encounter->enemy[i] = heap_malloc(sizeof(*enemy));
2535 ASSERT (enemy != NULL);
2536
2537 for (k = 0; k < ARRAY_COUNT(enemy->varTable); k++) {
2538 enemy->varTable[k] = 0;
2539 }
2540 enemy->encounterIndex = e;
2541 enemy->npcID = npcData->id;
2542 npcSettings = enemy->npcSettings = npcData->settings;
2543 enemy->drops = &npcData->drops;
2544 if ((*(s16*)(&npcData->drops) & 0xFF00) != 0x8000) { //TODO s16?
2545 enemy->drops = &DefaultEnemyDrops;
2546 }
2547 enemy->encountered = 0;
2548 if ((s32) npcData->init < EVT_LIMIT) {
2549 enemy->initBytecode = npcData->init;
2550 } else {
2551 enemy->initBytecode = NULL;
2552 }
2553 enemy->interactBytecode = npcSettings->onInteract;
2554 enemy->aiBytecode = npcSettings->ai;
2555 enemy->hitBytecode = npcSettings->onHit;
2556 enemy->auxBytecode = npcSettings->aux;
2557 enemy->defeatBytecode = npcSettings->onDefeat;
2558 enemy->initScript = NULL;
2559 enemy->interactScript = NULL;
2560 enemy->aiScript = NULL;
2561 enemy->hitScript = NULL;
2562 enemy->auxScript = NULL;
2563 enemy->defeatScript = NULL;
2564 enemy->interactScriptID = 0;
2565 enemy->aiScriptID = 0;
2566 enemy->hitScriptID = 0;
2567 enemy->auxScriptID = 0;
2568 enemy->defeatScriptID = 0;
2569 enemy->hitboxIsActive = FALSE;
2570 enemy->instigatorValue = 0;
2571 enemy->aiDetectFlags = npcData->aiDetectFlags;
2572
2573 enemy->aiFlags = npcData->aiFlags;
2574 enemy->unk_DC = 0;
2575 enemy->aiSuspendTime = 0;
2576 enemy->unk_B8 = (EvtScript*)npcSettings->unk_24; // ??
2577 enemy->unk_BC = NULL;
2578 enemy->unk_C0 = 0;
2579 enemy->unk_C4 = 0;
2580
2581 enemy->animList = (s32*)&npcData->animations;
2582 enemy->territory = &npcData->territory;
2583
2584 enemy->flags = npcSettings->flags;
2585 enemy->flags |= npcData->flags;
2586 enemy->unk_64 = NULL;
2587 enemy->tattleMsg = npcData->tattle;
2588 if (npcData->initVarCount != 0) {
2589 if (npcData->initVarCount == 1) {
2590 enemy->varTable[0] = npcData->initVar.value;
2591 } else {
2592 s32* initialVars = npcData->initVar.array;
2593 for (k = 0; k < npcData->initVarCount; k++) {
2594 enemy->varTable[k] = *initialVars++;
2595 }
2596 }
2597 }
2598
2599 // create the new NPC
2600 bp->flags = 0;
2601 if (npcSettings->defaultAnim == 0) {
2602 bp->initialAnim = enemy->animList[0];
2603 } else {
2604 bp->initialAnim = npcSettings->defaultAnim;
2605 }
2606 bp->onUpdate = NULL;
2607 bp->onRender = NULL;
2608 if (!(enemy->flags & ENEMY_FLAG_USE_PLAYER_SPRITE)) {
2609 newNpcIndex = create_standard_npc(bp, npcData->extraAnimations);
2610 } else {
2611 newNpcIndex = create_peach_npc(bp);
2612 }
2613
2614 newNpc = get_npc_by_index(newNpcIndex);
2615 newNpc->npcID = npcData->id;
2616 newNpc->collisionDiameter = npcSettings->radius;
2617 newNpc->collisionHeight = npcSettings->height;
2618 enemy->spawnPos[0] = newNpc->pos.x = npcData->pos.x;
2619 enemy->spawnPos[1] = newNpc->pos.y = npcData->pos.y;
2620 enemy->spawnPos[2] = newNpc->pos.z = npcData->pos.z;
2621 newNpc->unk_96 = 0;
2622 newNpc->planarFlyDist = 0.0f;
2623 newNpc->homePos.x = newNpc->pos.x;
2624 newNpc->homePos.y = newNpc->pos.y;
2625 newNpc->homePos.z = newNpc->pos.z;
2626 set_npc_yaw(newNpc, npcData->yaw);
2627 enemy->savedNpcYaw = 12345;
2628 if (newNpc->collisionDiameter >= 24.0) {
2629 newNpc->shadowScale = newNpc->collisionDiameter / 24.0;
2630 } else {
2631 newNpc->shadowScale = 1.0f;
2632 }
2635 }
2638 }
2641 }
2642 if (enemy->flags & ENEMY_FLAG_FLYING) {
2643 newNpc->flags |= NPC_FLAG_FLYING;
2644 }
2645 if (enemy->flags & ENEMY_FLAG_GRAVITY) {
2646 newNpc->flags |= NPC_FLAG_GRAVITY;
2647 }
2648 if (!(enemy->flags & ENEMY_FLAG_PASSIVE)) {
2650 }
2651 if (enemy->flags & ENEMY_FLAG_HAS_NO_SPRITE) {
2652 newNpc->flags |= NPC_FLAG_HAS_NO_SPRITE;
2653 }
2654 if (enemy->flags & ENEMY_FLAG_NO_SHADOW_RAYCAST) {
2656 }
2657 if (enemy->flags & ENEMY_FLAG_USE_INSPECT_ICON) {
2659 }
2662 }
2665 }
2667 if (enemy->flags & ENEMY_FLAG_PASSIVE) {
2669 }
2670 if (npcSettings->otherAI != NULL) {
2671 script = start_script(npcSettings->otherAI, EVT_PRIORITY_A, 0);
2672 enemy->aiScript = script;
2673 enemy->aiScriptID = script->id;
2674 script->owner1.enemy = enemy;
2675 script->owner2.npcID = enemy->npcID;
2676 script->groupFlags = enemy->scriptGroup;
2677 }
2678
2679 npcData++;
2680 }
2681 groupList++;
2682 e++;
2683 totalNpcCount += groupNpcCount;
2684 }
2685 currentEncounter->numEncounters = e;
2687 break;
2688
2690 cond2 = FALSE;
2691 for (e = 0; e < currentEncounter->numEncounters; e++) {
2692 encounter = currentEncounter->encounterList[e];
2693 if (encounter == NULL) {
2694 continue;
2695 }
2696 for (i = 0; i < encounter->count; i++) {
2697 enemy = encounter->enemy[i];
2698 if (enemy == NULL) {
2699 continue;
2700 }
2701 if (enemy->aiScript != NULL) {
2702 if (does_script_exist(enemy->aiScriptID)) {
2703 cond2 = TRUE;
2704 }
2705 }
2706 }
2707 }
2708 if (!cond2) {
2709 for (e = 0; e < currentEncounter->numEncounters; e++) {
2710 encounter = currentEncounter->encounterList[e];
2711 if (encounter == NULL) {
2712 continue;
2713 }
2714 for (i = 0; i < encounter->count; i++) {
2715 enemy = encounter->enemy[i];
2716 if (enemy == NULL) {
2717 continue;
2718 }
2719 if (enemy->initBytecode != NULL) {
2720 script = start_script(enemy->initBytecode, EVT_PRIORITY_A, 0);
2721 enemy->initScript = script;
2722 enemy->initScriptID = script->id;
2723 script->owner1.enemy = enemy;
2724 script->owner2.npcID = enemy->npcID;
2725 script->groupFlags = enemy->scriptGroup;
2726 }
2727 }
2728 }
2730 }
2731 break;
2732
2734 cond1 = FALSE;
2735
2736 for (e = 0; e < currentEncounter->numEncounters; e++) {
2737 encounter = currentEncounter->encounterList[e];
2738 if (encounter == NULL) {
2739 continue;
2740 }
2741 for (i = 0; i < encounter->count; i++) {
2742 enemy = encounter->enemy[i];
2743 if (enemy == NULL) {
2744 continue;
2745 }
2746 if (enemy->initScript != NULL) {
2747 if (does_script_exist(enemy->initScriptID)) {
2748 cond1 = TRUE;
2749 } else {
2750 enemy->initScript = NULL;
2751 }
2752 }
2753 }
2754 }
2755
2756 if (cond1) {
2757 break;
2758 }
2759
2760 for (e = 0; e < currentEncounter->numEncounters; e++) {
2761 encounter = currentEncounter->encounterList[e];
2762 if (encounter == NULL) {
2763 continue;
2764 }
2765 for (i = 0; i < encounter->count; i++) {
2766 enemy = encounter->enemy[i];
2767 if (enemy == NULL) {
2768 continue;
2769 }
2770 if (!(enemy->flags & ENEMY_FLAG_DISABLE_AI)) {
2771 if (enemy->aiBytecode != NULL) {
2772 script = start_script(enemy->aiBytecode, EVT_PRIORITY_A, 0);
2773 enemy->aiScript = script;
2774 enemy->aiScriptID = script->id;
2775 enemy->unk_C8 = 100;
2776 script->owner1.enemy = enemy;
2777 script->owner2.npcID = enemy->npcID;
2778 script->groupFlags = enemy->scriptGroup;
2779 }
2780 }
2781 }
2782 }
2783
2784 for (e = 0; e < currentEncounter->numEncounters; e++) {
2785 encounter = currentEncounter->encounterList[e];
2786 if (encounter == NULL) {
2787 continue;
2788 }
2789 for (i = 0; i < encounter->count; i++) {
2790 enemy = encounter->enemy[i];
2791 if (enemy == NULL) {
2792 continue;
2793 }
2794 if (!(enemy->flags & ENEMY_FLAG_DISABLE_AI)) {
2795 if (enemy->auxBytecode != NULL) {
2796 script = start_script(enemy->auxBytecode, EVT_PRIORITY_A, 0);
2797 enemy->auxScript = script;
2798 enemy->auxScriptID = script->id;
2799 script->owner1.enemy = enemy;
2800 script->owner2.npcID = enemy->npcID;
2801 script->groupFlags = enemy->scriptGroup;
2802 }
2803 }
2804 }
2805 }
2808 EncounterStateChanged = TRUE;
2810 break;
2811 }
2812}
s32 get_defeated(s32 mapID, s32 encounterID)
Definition encounter.c:202
b32 EncounterStateChanged
Definition encounter.c:24
s32 gEncounterSubState
Definition encounter.c:175
EnemyDrops DefaultEnemyDrops
Definition encounter.c:83
@ ENEMY_FLAG_DISABLE_AI
Definition enums.h:4525
@ ENEMY_FLAG_FLYING
Definition enums.h:4531
@ ENEMY_FLAG_RAYCAST_TO_INTERACT
Definition enums.h:4536
@ ENEMY_FLAG_IGNORE_ENTITY_COLLISION
Definition enums.h:4530
@ ENEMY_FLAG_HAS_NO_SPRITE
Definition enums.h:4534
@ ENEMY_FLAG_PASSIVE
Definition enums.h:4520
@ ENEMY_FLAG_GRAVITY
Definition enums.h:4532
@ ENEMY_FLAG_USE_PLAYER_SPRITE
Definition enums.h:4537
@ ENEMY_FLAG_USE_INSPECT_ICON
Definition enums.h:4535
@ ENEMY_FLAG_NO_SHADOW_RAYCAST
Definition enums.h:4533
@ ENEMY_FLAG_DONT_UPDATE_SHADOW_Y
Definition enums.h:4527
@ ENEMY_FLAG_IGNORE_PLAYER_COLLISION
Definition enums.h:4529
@ ENEMY_FLAG_IGNORE_WORLD_COLLISION
Definition enums.h:4528
@ ENCOUNTER_STATE_NEUTRAL
Definition enums.h:6295
@ ENCOUNTER_SUBSTATE_NEUTRAL
Definition enums.h:6308
@ ENCOUNTER_SUBSTATE_CREATE_RUN_INIT_SCRIPT
Definition enums.h:6303
@ ENCOUNTER_SUBSTATE_CREATE_RUN_AI
Definition enums.h:6304
@ ENCOUNTER_SUBSTATE_CREATE_INIT
Definition enums.h:6302
@ NPC_FLAG_IGNORE_ENTITY_COLLISION
Definition enums.h:3013
@ NPC_FLAG_HAS_NO_SPRITE
Definition enums.h:3022
@ NPC_FLAG_RAYCAST_TO_INTERACT
Definition enums.h:3027
@ NPC_FLAG_NO_SHADOW_RAYCAST
Definition enums.h:3003
@ NPC_FLAG_DONT_UPDATE_SHADOW_Y
Definition enums.h:3008
@ EVT_GROUP_HOSTILE_NPC
Definition evt.h:144
@ EVT_GROUP_FLAG_BATTLE
Definition evt.h:138
@ EVT_GROUP_PASSIVE_NPC
Definition evt.h:143
s8 resetMapEncounterFlags
Definition npc.h:389
EvtScript * ai
Definition npc.h:149
EvtScript * onDefeat
Definition npc.h:152
s16 height
Definition npc.h:145
struct Evt * interactScript
Definition npc.h:312
s32 unk_C0
Definition npc.h:338
NpcInitialVars initVar
Definition npc.h:250
u8 aiDetectFlags
Definition npc.h:275
s16 battle
Definition npc.h:285
EnemyDrops drops
Definition npc.h:252
EvtScript * aux
Definition npc.h:151
EnemyTerritory territory
Definition npc.h:253
s16 savedNpcYaw
Definition npc.h:346
s16 radius
Definition npc.h:146
struct NpcData::@52 animations
s32 * array
Definition npc.h:240
s32 interactScriptID
Definition npc.h:318
s16 encounterID
Definition npc.h:355
u32 aiFlags
Definition npc.h:276
struct Evt * hitScript
Definition npc.h:314
s16 recentMaps[2]
Definition npc.h:404
EvtScript * hitBytecode
Definition npc.h:308
s8 encounterIndex
Definition npc.h:296
s32 yaw
Definition npc.h:251
s8 instigatorValue
Definition npc.h:334
u8 scriptGroup
Definition npc.h:298
s32 auxScriptID
Definition npc.h:321
s32 initScriptID
Definition npc.h:317
Encounter * encounterList[24]
Definition npc.h:392
s32 create_peach_npc(NpcBlueprint *blueprint)
Definition npc.c:198
s32 initVarCount
Definition npc.h:249
s32 id
Definition npc.h:244
s32 * npcGroupList
Definition npc.h:391
EvtScript * onInteract
Definition npc.h:148
void * otherAI
Definition npc.h:147
s16 stage
Definition npc.h:286
s32 unk_24
Definition npc.h:154
struct Evt * defeatScript
Definition npc.h:316
EvtScript * initBytecode
Definition npc.h:305
s8 numEncounters
Definition npc.h:384
Enemy * enemy[16]
Definition npc.h:352
s16 spawnPos[3]
Definition npc.h:301
s32 unk_DC
Definition npc.h:345
NpcData * npcs
Definition npc.h:284
s32 unk_C4
Definition npc.h:339
s32 count
Definition npc.h:351
s8 hitboxIsActive
Definition npc.h:299
AnimID * extraAnimations
Definition npc.h:277
s32 flags
Definition npc.h:247
s32 value
Definition npc.h:238
EvtScript * interactBytecode
Definition npc.h:306
s32 aiScriptID
Definition npc.h:319
struct Evt * initScript
Definition npc.h:311
u8 aiDetectFlags
Definition npc.h:330
s32 defeatScriptID
Definition npc.h:322
EvtScript * init
Definition npc.h:248
s16 stage
Definition npc.h:354
Vec3f pos
Definition npc.h:246
struct Evt * auxScript
Definition npc.h:315
EvtScript * unk_B8
Definition npc.h:336
NpcSettings * settings
Definition npc.h:245
s32 defeatFlags[60][12]
Definition npc.h:403
s32 unk_C8
Definition npc.h:340
s32 npcCount
Definition npc.h:283
u32 tattleMsg
Definition npc.h:344
s32 tattle
Definition npc.h:278
s16 battle
Definition npc.h:353
void * unk_64
Definition npc.h:323
EvtScript * onHit
Definition npc.h:150
EvtScript * defeatBytecode
Definition npc.h:310
EvtScript * aiBytecode
Definition npc.h:307
struct Evt * unk_BC
Definition npc.h:337
s32 flags
Definition npc.h:153
AnimID defaultAnim
Definition npc.h:144
struct Evt * aiScript
Definition npc.h:313
EvtScript * auxBytecode
Definition npc.h:309
s32 hitScriptID
Definition npc.h:320
Definition npc.h:243
Zero-terminated.
Definition npc.h:282
s16 unk_96
f32 shadowScale
Vec3s homePos

Referenced by update_encounters().

◆ update_encounters_neutral()

void update_encounters_neutral ( void )

Definition at line 481 of file encounter.c.

481 {
482 EncounterStatus* currentEncounter = &gCurrentEncounter;
483 PlayerStatus* playerStatus = &gPlayerStatus;
484 Camera* camera = &gCameras[gCurrentCameraID];
485 s32 screenX, screenY, screenZ;
486 f32 npcX, npcY, npcZ;
487 f32 npcYaw;
488 f32 testX, testY, testZ;
489 f32 x, y, z;
490 s32 e;
491 f32 playerX, playerY, playerZ;
492 f32 playerYaw;
493 Encounter* encounter;
494 Evt* script;
495 Npc* npc;
496 f32 distance;
497 f32 colHeight;
498 f32 colRadius;
499 f32 hammerDir;
500
501 s32 triggeredBattle;
502 s32 cond2;
503 s32 firstStrikeType;
504 s32 suspendTime;
505
506 Enemy* enemy;
507 Enemy* currentEnemy;
508 s32 i;
509
510 f32 playerJumpColHeight = 37.0f;
511 f32 playerColRadius = 14.0f;
512 f32 playerColHeight = 18.0f;
513
514 f32 dx, dz;
515 f32 angle1, angle2;
516
517 if (currentEncounter->hitType == ENCOUNTER_TRIGGER_CONVERSATION) {
518 goto START_BATTLE;
519 }
520
521 currentEncounter->songID = -1;
522 currentEncounter->unk_18 = -1;
523 currentEncounter->hitType = 0;
524 currentEncounter->forbidFleeing = FALSE;
525 currentEncounter->dropWhackaBump = FALSE;
526 currentEncounter->flags &= ~ENCOUNTER_FLAG_THUMBS_UP;
527 currentEncounter->flags &= ~ENCOUNTER_FLAG_CANT_SKIP_WIN_DELAY;
528 currentEncounter->flags &= ~ENCOUNTER_FLAG_SKIP_FLEE_DROPS;
529
530 playerX = playerStatus->pos.x;
531 playerY = playerStatus->pos.y;
532 playerZ = playerStatus->pos.z;
533 playerYaw = playerStatus->spriteFacingAngle;
534
535 if (playerYaw < 180.0f) {
536 playerYaw = clamp_angle(camera->curYaw - 90.0f);
537 } else {
538 playerYaw = clamp_angle(camera->curYaw + 90.0f);
539 }
540
541 if (currentEncounter->battleTriggerCooldown != 0) {
543 currentEncounter->battleTriggerCooldown--;
544 }
545 if (playerStatus->blinkTimer != 0) {
546 if (!(playerStatus->flags & PS_FLAG_INPUT_DISABLED)) {
547 playerStatus->blinkTimer = currentEncounter->battleTriggerCooldown;
548 } else {
549 playerStatus->blinkTimer = 1;
550 }
551 }
552 }
553
554 for (e = 0; e < currentEncounter->numEncounters; e++) {
555 encounter = currentEncounter->encounterList[e];
556 if (encounter == NULL) {
557 continue;
558 }
559 for (i = 0; i < encounter->count; i++) {
560 enemy = encounter->enemy[i];
561 if (enemy == NULL || (enemy->flags & ENEMY_FLAG_DISABLE_AI)) {
562 continue;
563 }
564 npc = get_npc_unsafe(enemy->npcID);
565 if (enemy->aiSuspendTime != 0) {
567 enemy->aiSuspendTime--;
568 suspendTime = enemy->aiSuspendTime;
569 } else {
570 suspendTime = 0;
571 }
572
573 if (suspendTime & 1) {
575 enemy->flags |= ENEMY_FLAG_SUSPENDED;
576 } else {
577 npc->flags &= ~NPC_FLAG_SUSPENDED;
578 enemy->flags &= ~ENEMY_FLAG_SUSPENDED;
579 }
580
581 script = get_script_by_id(enemy->auxScriptID);
582 if (script != NULL) {
584 }
585 script = get_script_by_id(enemy->aiScriptID);
586 if (script != NULL) {
588 }
589
591 script = get_script_by_id(enemy->auxScriptID);
592 if (script != NULL) {
594 }
595 script = get_script_by_id(enemy->aiScriptID);
596 if (script != NULL) {
598 }
599 }
600 } else if (!(enemy->flags & ENEMY_FLAG_ACTIVE_WHILE_OFFSCREEN)) {
601 get_screen_coords(gCurrentCameraID, npc->pos.x, npc->pos.y, npc->pos.z, &screenX, &screenY, &screenZ);
602 if ((screenX < -160 || screenX > 480 || screenY < -120 || screenY > 360 || screenZ < 0) && !(enemy->flags & ENEMY_FLAG_PASSIVE)) {
604 enemy->flags |= ENEMY_FLAG_SUSPENDED;
605 script = get_script_by_id(enemy->auxScriptID);
606 if (script != NULL) {
608 }
609 script = get_script_by_id(enemy->aiScriptID);
610 if (script != NULL) {
612 }
613 } else {
614 npc->flags &= ~NPC_FLAG_SUSPENDED;
615 enemy->flags &= ~ENEMY_FLAG_SUSPENDED;
616 script = get_script_by_id(enemy->auxScriptID);
617 if (script != NULL) {
619 }
620 script = get_script_by_id(enemy->aiScriptID);
621 if (script != NULL) {
623 }
624 }
625 } else {
626 npc->flags &= ~NPC_FLAG_SUSPENDED;
627 enemy->flags &= ~ENEMY_FLAG_SUSPENDED;
628 script = get_script_by_id(enemy->auxScriptID);
629 if (script != NULL) {
631 }
632 script = get_script_by_id(enemy->aiScriptID);
633 if (script != NULL) {
635 }
636 }
637
638 if (enemy->flags & ENEMY_FLAG_SUSPENDED) {
639 continue;
640 }
641 if (enemy->flags & ENEMY_FLAG_PASSIVE) {
643 if (npc == playerStatus->encounteredNPC) {
644 enemy->savedNpcYaw = npc->yaw;
645 npc->yaw = atan2(npc->pos.x, npc->pos.z, playerStatus->pos.x, playerStatus->pos.z);
646 script = get_script_by_id(enemy->aiScriptID);
647 if (script != NULL) {
649 }
650 } else {
651 if (enemy->savedNpcYaw != 12345) {
652 npc->yaw = enemy->savedNpcYaw;
653 enemy->savedNpcYaw = 12345;
654 }
655 script = get_script_by_id(enemy->aiScriptID);
656 if (script != NULL) {
658 }
659 }
660 } else {
661 script = get_script_by_id(enemy->aiScriptID);
662 if (script != NULL) {
664 }
665 }
666 }
667
668 if (currentEncounter->battleTriggerCooldown != 0
670 || (playerStatus->flags & PS_FLAG_ARMS_RAISED)
673 || (enemy->flags & ENEMY_FLAG_PASSIVE)
676 ) {
677 continue;
678 }
679
681 currentEncounter->hitType = ENCOUNTER_TRIGGER_PARTNER;
683 currentEncounter->curEncounter = encounter;
684 currentEncounter->curEnemy = enemy;
685 currentEncounter->firstStrikeType = FIRST_STRIKE_PLAYER;
686 goto START_BATTLE;
687 }
688
689 npcX = npc->pos.x;
690 npcY = npc->pos.y;
691 npcZ = npc->pos.z;
692 npcYaw = npc->yaw;
693 colHeight = npc->collisionHeight;
694 colRadius = npc->collisionDiameter / 2;
695
696 if (enemy->unk_DC != 0) {
697 npcYaw = npc->yawCamOffset;
698 if (npcYaw < 180.0f) {
699 npcYaw = clamp_angle(camera->curYaw - 90.0f);
700 } else {
701 npcYaw = clamp_angle(camera->curYaw + 90.0f);
702 }
703
704 add_vec2D_polar(&npcX, &npcZ, enemy->unk_DC, npcYaw);
705 }
706
707 dx = npcX - playerX;
708 dz = npcZ - playerZ;
709 distance = sqrtf(SQ(dx) + SQ(dz));
710
711 switch (playerStatus->actionState) {
713 x = playerX;
714 y = playerY;
715 z = playerZ;
716 if (clamp_angle(playerStatus->spriteFacingAngle) < 180.0f) {
717 hammerDir = clamp_angle(camera->curYaw - 90.0f);
718 if (playerStatus->trueAnimation & SPRITE_ID_BACK_FACING) {
719 hammerDir = clamp_angle(hammerDir + 30.0f);
720 }
721 } else {
722 hammerDir = clamp_angle(camera->curYaw + 90.0f);
723 if (playerStatus->trueAnimation & SPRITE_ID_BACK_FACING) {
724 hammerDir = clamp_angle(hammerDir - 30.0f);
725 }
726 }
727 add_vec2D_polar(&x, &z, 24.0f, hammerDir);
728 dx = npcX - x;
729 dz = npcZ - z;
730 distance = sqrtf(SQ(dx) + SQ(dz));
731 if (enemy->flags & ENEMY_FLAG_IGNORE_HAMMER) {
732 break;
733 }
734 if (!(playerStatus->flags & PS_FLAG_HAMMER_CHECK)) {
735 break;
736 }
737 if (distance >= playerColRadius + colRadius || y > npcY + colHeight || npcY > y + playerColHeight) {
738 break;
739 }
740
741 testX = npcX;
742 testY = npcY;
743 testZ = npcZ;
744
745 if (npc_test_move_taller_with_slipping(COLLIDER_FLAG_IGNORE_PLAYER, &testX, &testY, &testZ, distance, atan2(npcX, npcZ, playerX, playerZ), colHeight, colRadius * 2.0f)) {
746 testX = playerX;
747 testY = playerY;
748 testZ = playerZ;
749 if (npc_test_move_taller_with_slipping(COLLIDER_FLAG_IGNORE_PLAYER, &testX, &testY, &testZ, distance, atan2(playerX, playerZ, npcX, npcZ), colHeight, colRadius * 2.0f)) {
750 break;
751 }
752 }
753 if (enemy->hitboxIsActive) {
754 npcX = enemy->unk_10.x;
755 npcY = enemy->unk_10.y;
756 npcZ = enemy->unk_10.z;
757 }
758
759 angle1 = fabsf(get_clamped_angle_diff(atan2(playerX, playerZ, npcX, npcZ), playerYaw));
760 angle2 = fabsf(get_clamped_angle_diff(atan2(npcX, npcZ, playerX, playerZ), npcYaw));
761 triggeredBattle = FALSE;
762 if (angle1 >= 90.0f && angle2 >= 90.0f) {
763 triggeredBattle = FALSE;
764 }
765 if (angle1 < 90.0f && angle2 >= 90.0f) {
766 triggeredBattle = TRUE;
767 }
768 if (angle1 >= 90.0f && angle2 < 90.0f) {
769 triggeredBattle = FALSE;
770 }
771 if (angle1 < 90.0f && angle2 < 90.0f) {
772 triggeredBattle = TRUE;
773 }
774 if (triggeredBattle) {
775 sfx_play_sound_at_position(SOUND_HIT_PLAYER_NORMAL, SOUND_SPACE_DEFAULT, playerStatus->pos.x, playerStatus->pos.y, playerStatus->pos.z);
776 currentEncounter->hitType = ENCOUNTER_TRIGGER_HAMMER;
777 currentEncounter->hitTier = gPlayerData.hammerLevel;
779 currentEncounter->curEncounter = encounter;
780 currentEncounter->curEnemy = enemy;
781 currentEncounter->firstStrikeType = FIRST_STRIKE_PLAYER;
782 goto START_BATTLE;
783 }
784 break;
795 x = playerX;
796 z = playerZ;
797 if (!(enemy->flags & ENEMY_FLAG_IGNORE_JUMP)) {
798 if (distance >= playerColRadius + colRadius) {
799 continue;
800 }
801 if (playerY > npcY + colHeight || npcY > playerY + playerJumpColHeight) {
802 continue;
803 }
804
805 testX = npcX;
806 testY = npcY;
807 testZ = npcZ;
808 if (npc_test_move_taller_with_slipping(COLLIDER_FLAG_IGNORE_PLAYER, &testX, &testY, &testZ, distance, atan2(npcX, npcZ, playerX, playerZ), colHeight, colRadius * 2.0f)) {
809 testX = playerX;
810 testY = playerY;
811 testZ = playerZ;
812 if (npc_test_move_taller_with_slipping(COLLIDER_FLAG_IGNORE_PLAYER, &testX, &testY, &testZ, distance, atan2(playerX, playerZ, npcX, npcZ), colHeight, colRadius * 2.0f)) {
813 break;
814 }
815 }
816 triggeredBattle = FALSE;
817 if (npcY + colHeight < playerY + playerJumpColHeight * 0.5f) {
818 if (playerStatus->actionState == ACTION_STATE_FALLING ||
819 playerStatus->actionState == ACTION_STATE_STEP_DOWN ||
820 playerStatus->actionState == ACTION_STATE_LAND ||
821 playerStatus->actionState == ACTION_STATE_STEP_DOWN_LAND ||
822 playerStatus->actionState == ACTION_STATE_SPIN_JUMP ||
823 playerStatus->actionState == ACTION_STATE_SPIN_POUND ||
824 playerStatus->actionState == ACTION_STATE_TORNADO_JUMP ||
825 playerStatus->actionState == ACTION_STATE_TORNADO_POUND) {
826 triggeredBattle = TRUE;
827 }
828 }
829 if (playerY + playerJumpColHeight < npcY + colHeight * 0.5f) {
830 triggeredBattle = FALSE;
831 }
832 if (triggeredBattle) {
833 if (gPlayerData.bootsLevel < 0) {
834 currentEncounter->hitType = ENCOUNTER_TRIGGER_NONE;
836 currentEncounter->curEncounter = encounter;
837 currentEncounter->curEnemy = enemy;
838 currentEncounter->firstStrikeType = FIRST_STRIKE_NONE;
839 currentEncounter->hitTier = 0;
840 goto START_BATTLE;
841 }
842 currentEncounter->hitType = ENCOUNTER_TRIGGER_JUMP;
843 switch (playerStatus->actionState) {
850 currentEncounter->hitTier = 0;
851 break;
854 currentEncounter->hitTier = 1;
855 break;
858 currentEncounter->hitTier = 2;
859 break;
860 }
861 sfx_play_sound_at_position(SOUND_HIT_PLAYER_NORMAL, SOUND_SPACE_DEFAULT, playerStatus->pos.x, playerStatus->pos.y, playerStatus->pos.z);
863 currentEncounter->curEncounter = encounter;
864 currentEncounter->curEnemy = enemy;
865 currentEncounter->firstStrikeType = FIRST_STRIKE_PLAYER;
866 goto START_BATTLE;
867 }
868 }
869 break;
870 }
871
872 if (enemy->flags & ENEMY_FLAG_IGNORE_TOUCH) {
873 continue;
874 }
875
876 dx = npcX - playerX;
877 dz = npcZ - playerZ;
878 distance = sqrtf(SQ(dx) + SQ(dz));
879
880 if (distance >= (playerColRadius + colRadius) * 0.8) {
881 continue;
882 }
883 if (npcY + colHeight < playerY) {
884 continue;
885 }
886 if (playerY + playerJumpColHeight < npcY) {
887 continue;
888 }
889
890 testX = npcX;
891 testY = npcY;
892 testZ = npcZ;
893 if (npc_test_move_taller_with_slipping(COLLIDER_FLAG_IGNORE_PLAYER, &testX, &testY, &testZ, distance, atan2(npcX, npcZ, playerX, playerZ), colHeight, colRadius * 2.0f)) {
894 testX = playerX;
895 testY = playerY;
896 testZ = playerZ;
897 if (npc_test_move_taller_with_slipping(COLLIDER_FLAG_IGNORE_PLAYER, &testX, &testY, &testZ, distance, atan2(playerX, playerZ, npcX, npcZ), colHeight, colRadius * 2.0f)) {
898 continue;
899 }
900 }
901 triggeredBattle = FALSE;
903 triggeredBattle = !currentEncounter->scriptedBattle;
904 }
906 triggeredBattle = TRUE;
907 }
908 if ((playerStatus->animFlags & PA_FLAG_SPINNING) && !(enemy->flags & ENEMY_FLAG_IGNORE_SPIN) && triggeredBattle) {
909 sfx_play_sound_at_position(SOUND_HIT_PLAYER_NORMAL, SOUND_SPACE_DEFAULT, playerStatus->pos.x, playerStatus->pos.y, playerStatus->pos.z);
910 testX = playerStatus->pos.x + ((npc->pos.x - playerStatus->pos.x) * 0.5f);
911 testY = playerStatus->pos.y + (((npc->pos.y + npc->collisionHeight) - (playerStatus->pos.y + playerStatus->colliderHeight)) * 0.5f);
912 testZ = playerStatus->pos.z + ((npc->pos.z - playerStatus->pos.z) * 0.5f);
913 fx_damage_stars(FX_DAMAGE_STARS_3, testX, testY, testZ, 0.0f, -1.0f, 0.0f, 3);
914 currentEncounter->hitType = ENCOUNTER_TRIGGER_SPIN;
917 currentEncounter->curEncounter = encounter;
918 currentEncounter->curEnemy = enemy;
919 currentEncounter->firstStrikeType = FIRST_STRIKE_NONE;
920 } else {
921 currentEncounter->hitType = ENCOUNTER_TRIGGER_NONE;
922 playerStatus->animFlags &= ~PA_FLAG_DIZZY_ATTACK_ENCOUNTER;
924 currentEncounter->curEncounter = encounter;
925 currentEncounter->curEnemy = enemy;
926 testX = playerStatus->pos.x + ((npc->pos.x - playerStatus->pos.x) * 0.5f);
927 testY = playerStatus->pos.y + (((npc->pos.y + npc->collisionHeight) - (playerStatus->pos.y + playerStatus->colliderHeight)) * 0.5f);
928 testZ = playerStatus->pos.z + ((npc->pos.z - playerStatus->pos.z) * 0.5f);
929 fx_damage_stars(FX_DAMAGE_STARS_3, testX, testY, testZ, 0.0f, -1.0f, 0.0f, 3);
930 // if the hitbox is active, trigger a first strike
931 firstStrikeType = FIRST_STRIKE_NONE;
932 if (enemy->hitboxIsActive) {
934 firstStrikeType = FIRST_STRIKE_NONE;
935 } else {
936 firstStrikeType = FIRST_STRIKE_ENEMY;
937 }
938 }
939 // cancel the first strike if bump attack is applicable
941 && (gPlayerData.level >= enemy->npcSettings->level)
942 && !(enemy->flags & ENEMY_FLAG_PROJECTILE))
943 && !currentEncounter->scriptedBattle
944 ) {
945 firstStrikeType = FIRST_STRIKE_NONE;
946 }
947 currentEncounter->firstStrikeType = firstStrikeType;
948 }
949 goto START_BATTLE;
950 }
951 }
952
953START_BATTLE:
954 switch (currentEncounter->hitType) {
955 case 0:
956 break;
958 currentEnemy = enemy = currentEncounter->curEnemy;
959 if (enemy->aiScript != NULL) {
961 }
962 if (enemy->auxScript != NULL) {
964 }
965 encounter = currentEncounter->curEncounter;
966 for (i = 0; i < encounter->count; i++) {
967 enemy = encounter->enemy[i];
968 if (enemy == NULL) {
969 continue;
970 }
971 if ((enemy->flags & ENEMY_FLAG_ENABLE_HIT_SCRIPT) && enemy != currentEncounter->curEnemy) {
972 continue;
973 }
974 if (enemy->flags & ENEMY_FLAG_DISABLE_AI) {
975 continue;
976 }
977 if ((currentEnemy->flags & ENEMY_FLAG_PROJECTILE) && enemy != currentEncounter->curEnemy) {
978 continue;
979 }
980
981 if (enemy->hitBytecode != NULL) {
983 script = start_script(enemy->hitBytecode, EVT_PRIORITY_A, 0);
984 enemy->hitScript = script;
985 enemy->hitScriptID = script->id;
986 script->owner1.enemy = enemy;
987 script->owner2.npcID = enemy->npcID;
988 script->groupFlags = enemy->scriptGroup;
989 }
990 }
993 if (playerStatus->actionState != ACTION_STATE_TORNADO_JUMP &&
994 playerStatus->actionState != ACTION_STATE_TORNADO_POUND &&
995 playerStatus->actionState != ACTION_STATE_SPIN_JUMP &&
996 playerStatus->actionState != ACTION_STATE_SPIN_POUND) {
997 playerStatus->flags |= PS_FLAG_ENTERING_BATTLE;
998 }
1001 npc = get_npc_unsafe(enemy->npcID);
1003 }
1004 currentEncounter->scriptedBattle = FALSE;
1005 currentEncounter->fadeOutAmount = 0;
1006 currentEncounter->substateDelay = 0;
1008 EncounterStateChanged = TRUE;
1010 break;
1012 currentEnemy = enemy = currentEncounter->curEnemy;
1013 if (enemy->aiScript != NULL) {
1015 }
1016 if (enemy->auxScript != NULL) {
1018 }
1019 encounter = currentEncounter->curEncounter;
1020 for (i = 0; i < encounter->count; i++) {
1021 enemy = encounter->enemy[i];
1022 if (enemy == NULL) {
1023 continue;
1024 }
1025 if ((enemy->flags & ENEMY_FLAG_ENABLE_HIT_SCRIPT) && enemy != currentEncounter->curEnemy) {
1026 continue;
1027 }
1028 if (enemy->flags & ENEMY_FLAG_DISABLE_AI) {
1029 continue;
1030 }
1031 if ((currentEnemy->flags & ENEMY_FLAG_PROJECTILE) && enemy != currentEncounter->curEnemy) {
1032 continue;
1033 }
1034
1035 if (enemy->hitBytecode != NULL) {
1037 script = start_script(enemy->hitBytecode, EVT_PRIORITY_A, 0);
1038 enemy->hitScript = script;
1039 enemy->hitScriptID = script->id;
1040 script->owner1.enemy = enemy;
1041 script->owner2.npcID = enemy->npcID;
1042 script->groupFlags = enemy->scriptGroup;
1043 }
1044 }
1047 currentEncounter->scriptedBattle = FALSE;
1048 currentEncounter->fadeOutAmount = 0;
1049 currentEncounter->substateDelay = 0;
1051 EncounterStateChanged = TRUE;
1053 playerStatus->flags |= PS_FLAG_ENTERING_BATTLE;
1054 break;
1056 currentEnemy = enemy = currentEncounter->curEnemy;
1057 if (enemy->aiScript != NULL) {
1059 }
1060 if (enemy->auxScript != NULL) {
1062 }
1063 encounter = currentEncounter->curEncounter;
1064
1065 cond2 = FALSE;
1066 for (i = 0; i < encounter->count; i++) {
1067 enemy = encounter->enemy[i];
1068 enemy = encounter->enemy[i];
1069 if (enemy == NULL) {
1070 continue;
1071 }
1072 if ((enemy->flags & ENEMY_FLAG_ENABLE_HIT_SCRIPT) && enemy != currentEncounter->curEnemy) {
1073 continue;
1074 }
1075 if (enemy->flags & ENEMY_FLAG_DISABLE_AI) {
1076 continue;
1077 }
1078 if ((currentEnemy->flags & ENEMY_FLAG_PROJECTILE) && enemy != currentEncounter->curEnemy) {
1079 continue;
1080 }
1081 if (enemy->hitBytecode != NULL) {
1083 script = start_script(enemy->hitBytecode, EVT_PRIORITY_A, 0);
1084 enemy->hitScript = script;
1085 enemy->hitScriptID = script->id;
1086 script->owner1.enemy = enemy;
1087 script->owner2.npcID = enemy->npcID;
1088 script->groupFlags = enemy->scriptGroup;
1089 npc = get_npc_unsafe(enemy->npcID);
1090 cond2 = TRUE;
1091 testX = playerStatus->pos.x + ((npc->pos.x - playerStatus->pos.x) * 0.5f);
1092 testY = playerStatus->pos.y + (((npc->pos.y + npc->collisionHeight) - (playerStatus->pos.y + playerStatus->colliderHeight)) * 0.5f);
1093 testZ = playerStatus->pos.z + ((npc->pos.z - playerStatus->pos.z) * 0.5f);
1094 fx_damage_stars(FX_DAMAGE_STARS_3, testX, testY, testZ, 0.0f, -1.0f, 0.0f, 3);
1095 } else if (!(enemy->flags & ENEMY_FLAG_PASSIVE)) {
1096 npc = get_npc_unsafe(enemy->npcID);
1097 cond2 = TRUE;
1098 testX = playerStatus->pos.x + ((npc->pos.x - playerStatus->pos.x) * 0.5f);
1099 testY = playerStatus->pos.y + (((npc->pos.y + npc->collisionHeight) - (playerStatus->pos.y + playerStatus->colliderHeight)) * 0.5f);
1100 testZ = playerStatus->pos.z + ((npc->pos.z - playerStatus->pos.z) * 0.5f);
1101 fx_damage_stars(FX_DAMAGE_STARS_3, testX, testY, testZ, 0.0f, -1.0f, 0.0f, 3);
1102 }
1103 }
1106 playerStatus->flags |= PS_FLAG_ENTERING_BATTLE;
1107 if (cond2) {
1109 }
1110 currentEncounter->fadeOutAmount = 0;
1111 currentEncounter->substateDelay = 0;
1112 currentEncounter->scriptedBattle = FALSE;
1115 EncounterStateChanged = TRUE;
1117 break;
1119 currentEnemy = enemy = currentEncounter->curEnemy;
1120 if (enemy->aiScript != NULL) {
1122 }
1123 if (enemy->auxScript != NULL) {
1125 }
1126 encounter = currentEncounter->curEncounter;
1127 for (i = 0; i < encounter->count; i++) {
1128 enemy = encounter->enemy[i];
1129 if (enemy == NULL) {
1130 continue;
1131 }
1132 if ((enemy->flags & ENEMY_FLAG_ENABLE_HIT_SCRIPT) && enemy != currentEncounter->curEnemy) {
1133 continue;
1134 }
1135 if (enemy->flags & ENEMY_FLAG_DISABLE_AI) {
1136 continue;
1137 }
1138 if ((currentEnemy->flags & ENEMY_FLAG_PROJECTILE) && enemy != currentEncounter->curEnemy) {
1139 continue;
1140 }
1141 if (enemy->hitBytecode != NULL) {
1143 script = start_script(enemy->hitBytecode, EVT_PRIORITY_A, 0);
1144 enemy->hitScript = script;
1145 enemy->hitScriptID = script->id;
1146 script->owner1.enemy = enemy;
1147 script->owner2.npcID = enemy->npcID;
1148 script->groupFlags = enemy->scriptGroup;
1149 npc = get_npc_unsafe(enemy->npcID);
1150 testX = playerStatus->pos.x + ((npc->pos.x - playerStatus->pos.x) * 0.5f);
1151 testY = playerStatus->pos.y + (((npc->pos.y + npc->collisionHeight) - (playerStatus->pos.y + playerStatus->colliderHeight)) * 0.5f);
1152 testZ = playerStatus->pos.z + ((npc->pos.z - playerStatus->pos.z) * 0.5f);
1153 fx_damage_stars(FX_DAMAGE_STARS_3, testX, testY, testZ, 0.0f, -1.0f, 0.0f, 3);
1154 } else if (!(enemy->flags & ENEMY_FLAG_PASSIVE)) {
1155 npc = get_npc_unsafe(enemy->npcID);
1156 testX = playerStatus->pos.x + ((npc->pos.x - playerStatus->pos.x) * 0.5f);
1157 testY = playerStatus->pos.y + (((npc->pos.y + npc->collisionHeight) - (playerStatus->pos.y + playerStatus->colliderHeight)) * 0.5f);
1158 testZ = playerStatus->pos.z + ((npc->pos.z - playerStatus->pos.z) * 0.5f);
1159 fx_damage_stars(FX_DAMAGE_STARS_3, npc->pos.x, npc->pos.y + npc->collisionHeight, npc->pos.z, 0.0f, -1.0f, 0.0f, 3);
1160 }
1161 }
1164 currentEncounter->fadeOutAmount = 0;
1165 currentEncounter->substateDelay = 0;
1166 currentEncounter->scriptedBattle = FALSE;
1167 playerStatus->flags |= PS_FLAG_ENTERING_BATTLE;
1170 EncounterStateChanged = TRUE;
1172 break;
1175 enemy = currentEncounter->curEnemy;
1176 if (enemy != NULL && enemy->aiScript != NULL) {
1178 }
1179 enemy = currentEncounter->curEnemy;
1180 if (enemy->interactBytecode != NULL) {
1182 script = start_script(enemy->interactBytecode, EVT_PRIORITY_A, 0);
1183 enemy->interactScript = script;
1184 enemy->interactScriptID = script->id;
1185 script->owner1.enemy = enemy;
1186 script->owner2.npcID = enemy->npcID;
1187 script->groupFlags = enemy->scriptGroup;
1188 }
1192 currentEncounter->fadeOutAmount = 0;
1193 currentEncounter->substateDelay = 0;
1194 func_800EF3D4(1);
1196 EncounterStateChanged = TRUE;
1198 break;
1200 currentEnemy = enemy = currentEncounter->curEnemy;
1201 if (enemy->aiScript != NULL) {
1203 }
1204 if (enemy->auxScript != NULL) {
1206 }
1207 encounter = currentEncounter->curEncounter;
1208
1209 for (i = 0; i < encounter->count; i++) {
1210 enemy = encounter->enemy[i];
1211 if (enemy == NULL) {
1212 continue;
1213 }
1214 if ((enemy->flags & ENEMY_FLAG_ENABLE_HIT_SCRIPT) && enemy != currentEncounter->curEnemy) {
1215 continue;
1216 }
1217 if (enemy->flags & ENEMY_FLAG_DISABLE_AI) {
1218 continue;
1219 }
1220 if ((currentEnemy->flags & ENEMY_FLAG_PROJECTILE) && enemy != currentEncounter->curEnemy) {
1221 continue;
1222 }
1223 if (enemy->hitBytecode != NULL) {
1225 script = start_script(enemy->hitBytecode, EVT_PRIORITY_A, 0);
1226 enemy->hitScript = script;
1227 enemy->hitScriptID = script->id;
1228 script->owner1.enemy = enemy;
1229 script->owner2.npcID = enemy->npcID;
1230 script->groupFlags = enemy->scriptGroup;
1231 npc = get_npc_unsafe(enemy->npcID);
1232 testX = npc->pos.x;
1233 testY = npc->pos.y + npc->collisionHeight;
1234 testZ = npc->pos.z;
1235 fx_damage_stars(FX_DAMAGE_STARS_3, testX, testY, testZ, 0.0f, -1.0f, 0.0f, 3);
1236 } else if (!(enemy->flags & ENEMY_FLAG_PASSIVE)) {
1237 npc = get_npc_unsafe(enemy->npcID);
1238 testX = npc->pos.x;
1239 testY = npc->pos.y + npc->collisionHeight;
1240 testZ = npc->pos.z;
1241 fx_damage_stars(FX_DAMAGE_STARS_3, testX, testY, testZ, 0.0f, -1.0f, 0.0f, 3);
1242 }
1243 }
1246 currentEncounter->fadeOutAmount = 0;
1247 currentEncounter->substateDelay = 0;
1248 currentEncounter->scriptedBattle = FALSE;
1249 playerStatus->flags |= PS_FLAG_ENTERING_BATTLE;
1252 EncounterStateChanged = TRUE;
1254 break;
1255 }
1256}
AnimID trueAnimation
Encoding back-facing sprite.
@ FX_DAMAGE_STARS_3
Definition effects.h:359
@ DEBUG_CONTACT_CANT_TOUCH
Definition enums.h:4267
@ ENCOUNTER_SUBSTATE_CONVERSATION_INIT
Definition enums.h:6319
@ PS_FLAG_ARMS_RAISED
Definition enums.h:3063
@ ENCOUNTER_TRIGGER_NONE
Definition enums.h:268
@ ENEMY_FLAG_IGNORE_HAMMER
Definition enums.h:4546
@ ENEMY_FLAG_DO_NOT_AUTO_FACE_PLAYER
Definition enums.h:4542
@ ENEMY_FLAG_IGNORE_PARTNER
Definition enums.h:4548
@ ENEMY_FLAG_ENABLE_HIT_SCRIPT
Definition enums.h:4523
@ ENEMY_FLAG_PROJECTILE
Definition enums.h:4526
@ ENEMY_FLAG_DONT_SUSPEND_SCRIPTS
Definition enums.h:4539
@ ENEMY_FLAG_IGNORE_SPIN
Definition enums.h:4549
@ ENEMY_FLAG_SUSPENDED
Definition enums.h:4551
@ ENEMY_FLAG_IGNORE_TOUCH
Definition enums.h:4544
@ ENEMY_FLAG_IGNORE_JUMP
Definition enums.h:4545
@ ENEMY_FLAG_ACTIVE_WHILE_OFFSCREEN
Definition enums.h:4541
@ PA_FLAG_DIZZY_ATTACK_ENCOUNTER
Definition enums.h:3109
@ ENCOUNTER_SUBSTATE_PRE_BATTLE_INIT
Definition enums.h:6312
@ SOUND_NONE
Definition enums.h:547
@ SOUND_HIT_PLAYER_NORMAL
Definition enums.h:719
@ ENCOUNTER_STATE_CONVERSATION
Definition enums.h:6297
@ NPC_FLAG_SUSPENDED
Definition enums.h:3029
void func_800EF3D4(s32)
Definition partners.c:2414
s32 suspend_all_script(s32 id)
void set_script_flags(Evt *script, s32 flags)
void clear_script_flags(Evt *script, s32 flags)
s32 partner_test_enemy_collision(Npc *enemy)
Definition partners.c:1051
void start_bounce_a(void)
Definition 7E9D0.c:300
Evt * get_script_by_id(s32 id)
s8 scriptedBattle
battle started by StartBattle but not by encounter
Definition npc.h:380
s8 battleTriggerCooldown
set to 15 after victory, 45 after fleeing
Definition npc.h:373
Vec3s unk_10
Definition npc.h:302
s32 fadeOutAmount
Definition npc.h:395
s16 level
Definition npc.h:155
s32 substateDelay
Definition npc.h:396
Encounter * curEncounter
Definition npc.h:393
@ SPRITE_ID_BACK_FACING
Definition sprite.h:13
s16 yawCamOffset
void fx_damage_stars(s32, f32, f32, f32, f32, f32, f32, s32)

Referenced by update_encounters().

◆ update_encounters_pre_battle()

void update_encounters_pre_battle ( void )

Definition at line 1261 of file encounter.c.

1261 {
1262 EncounterStatus* currentEncounter = &gCurrentEncounter;
1263 PlayerData* playerData = &gPlayerData;
1264 Encounter* encounter;
1265 Enemy* enemy;
1266 s32 i;
1267 s32 j;
1268
1269 switch (gEncounterSubState) {
1271 currentEncounter->fadeOutAmount = 0;
1272 currentEncounter->substateDelay = 1;
1273 currentEncounter->fadeOutAccel = 1;
1274 currentEncounter->unk_08 = -1;
1275 HasPreBattleSongPushed = FALSE;
1276 D_80077C40 = FALSE;
1278
1279 // suspend all ai scripts
1280 for (i = 0; i < currentEncounter->numEncounters; i++) {
1281 encounter = currentEncounter->encounterList[i];
1282
1283 if (encounter != NULL) {
1284 for (j = 0; j < encounter->count; j++) {
1285 enemy = encounter->enemy[j];
1286 if (enemy != NULL && !(enemy->flags & ENEMY_FLAG_DISABLE_AI)) {
1287 if (enemy->aiScript != NULL) {
1289 }
1290 if (enemy->auxScript != NULL) {
1292 }
1293 }
1294 }
1295 }
1296 }
1297
1298 // try skip-on-contact
1299 enemy = currentEncounter->curEnemy;
1300 if ((enemy->flags & ENEMY_FLAG_SKIP_BATTLE) && !currentEncounter->scriptedBattle) {
1301 currentEncounter->substateDelay = 0;
1302 currentEncounter->battleStartCountdown = 0;
1305 return;
1306 }
1307
1308 // try kill-on-contact
1310 currentEncounter->substateDelay = 0;
1311 currentEncounter->battleStartCountdown = 10;
1314 return;
1315 }
1316
1317 // try first attack kill
1318 enemy = currentEncounter->curEnemy;
1319 if (currentEncounter->hitType != ENCOUNTER_TRIGGER_NONE
1320 && currentEncounter->hitType != ENCOUNTER_TRIGGER_SPIN
1322 && (playerData->level >= enemy->npcSettings->level)
1323 && !(enemy->flags & ENEMY_FLAG_PROJECTILE)
1324 && !currentEncounter->scriptedBattle
1325 ) {
1326 currentEncounter->substateDelay = 0;
1327 currentEncounter->battleStartCountdown = 10;
1328 D_80077C40 = TRUE;
1330 return;
1331 }
1332
1333 // try bump attack kill
1334 enemy = currentEncounter->curEnemy;
1336 && (playerData->level >= enemy->npcSettings->level)
1337 && !(enemy->flags & ENEMY_FLAG_PROJECTILE)
1338 && !(currentEncounter->scriptedBattle)
1339 ) {
1340 currentEncounter->substateDelay = 0;
1341 currentEncounter->battleStartCountdown = 10;
1342 D_80077C40 = TRUE;
1344 return;
1345 }
1346
1347 // try spin attack kill
1348 enemy = currentEncounter->curEnemy;
1349 if (currentEncounter->hitType == ENCOUNTER_TRIGGER_SPIN
1351 && playerData->level >= enemy->npcSettings->level
1352 && !(enemy->flags & ENEMY_FLAG_PROJECTILE)
1353 && !currentEncounter->scriptedBattle
1354 ) {
1355 currentEncounter->substateDelay = 0;
1356 currentEncounter->battleStartCountdown = 10;
1357 D_80077C40 = TRUE;
1359 return;
1360 }
1361
1362 // start battle music
1363 if (currentEncounter->songID < 0) {
1364 switch (currentEncounter->firstStrikeType) {
1365 case FIRST_STRIKE_NONE:
1367 break;
1370 break;
1371 case FIRST_STRIKE_ENEMY:
1373 break;
1374 }
1375 } else {
1376 bgm_set_battle_song(currentEncounter->songID, FIRST_STRIKE_NONE);
1377 }
1380
1381 currentEncounter->battleStartCountdown = 10;
1383 // fallthrough
1385 // wait for screen to fade out
1386 if (currentEncounter->fadeOutAmount != 255) {
1387 break;
1388 }
1389 // delay before loading the battle
1390 if (currentEncounter->battleStartCountdown != 0) {
1391 currentEncounter->battleStartCountdown--;
1392 break;
1393 }
1394
1395 // kill all enemy hit scripts
1396 encounter = currentEncounter->curEncounter;
1397 for (i = 0; i < encounter->count; i++) {
1398 enemy = encounter->enemy[i];
1399 if (enemy != NULL &&
1400 ((!(enemy->flags & ENEMY_FLAG_ENABLE_HIT_SCRIPT) || enemy == currentEncounter->curEnemy)) &&
1401 !(enemy->flags & ENEMY_FLAG_DISABLE_AI) &&
1402 enemy->hitScript != NULL)
1403 {
1405 enemy->hitScript = NULL;
1406 }
1407 }
1408
1410 currentEncounter->dizzyAttack.status = 0;
1411 currentEncounter->dizzyAttack.duration = 0;
1412
1413 enemy = currentEncounter->curEnemy;
1414 currentEncounter->instigatorValue = enemy->instigatorValue;
1415
1417 currentEncounter->dizzyAttack.status = 4;
1418 currentEncounter->dizzyAttack.duration = 3;
1419 }
1420
1426 set_battle_stage(encounter->stage);
1427 load_battle(encounter->battle);
1428 currentEncounter->unk_07 = 1;
1429 currentEncounter->unk_08 = 0;
1430 currentEncounter->hasMerleeCoinBonus = FALSE;
1431 currentEncounter->damageTaken = 0;
1432 currentEncounter->coinsEarned = 0;
1433 currentEncounter->fadeOutAccel = 0;
1434 currentEncounter->fadeOutAmount = 255;
1436
1437 // prepare to resume after battle
1439 EncounterStateChanged = TRUE;
1441 break;
1443 if (currentEncounter->battleStartCountdown != 0) {
1444 currentEncounter->battleStartCountdown--;
1445 break;
1446 }
1447
1448 encounter = currentEncounter->curEncounter;
1449 for (i = 0; i < encounter->count; i++) {
1450 enemy = encounter->enemy[i];
1451 if (enemy != NULL &&
1452 (!(enemy->flags & ENEMY_FLAG_ENABLE_HIT_SCRIPT) || enemy == currentEncounter->curEnemy) &&
1453 !(enemy->flags & ENEMY_FLAG_DISABLE_AI) &&
1454 (enemy->hitScript != 0))
1455 {
1457 enemy->hitScript = NULL;
1458 }
1459 }
1460
1461 currentEncounter->unk_08 = 1;
1462 currentEncounter->unk_07 = 1;
1463 currentEncounter->battleOutcome = OUTCOME_PLAYER_WON;
1464 currentEncounter->hasMerleeCoinBonus = FALSE;
1465 currentEncounter->damageTaken = 0;
1466 currentEncounter->coinsEarned = 0;
1467
1468 currentEncounter->fadeOutAccel = 0;
1469 currentEncounter->fadeOutAmount = 0;
1471 EncounterStateChanged = TRUE;
1473 break;
1475 currentEncounter->battleOutcome = OUTCOME_SKIP;
1476 currentEncounter->unk_08 = 1;
1477
1478 currentEncounter->fadeOutAmount = 0;
1479 currentEncounter->fadeOutAccel = 0;
1481 EncounterStateChanged = TRUE;
1483 break;
1484 }
1485}
s8 HasPreBattleSongPushed
Definition encounter.c:178
void set_battle_formation(Battle *)
Definition battle.c:142
b32 D_80077C40
Definition encounter.c:22
@ SONG_NORMAL_BATTLE
Definition enums.h:284
@ ENCOUNTER_SUBSTATE_POST_BATTLE_INIT
Definition enums.h:6324
@ ENEMY_FLAG_SKIP_BATTLE
Definition enums.h:4540
@ ENCOUNTER_SUBSTATE_PRE_BATTLE_AUTO_WIN
Definition enums.h:6314
@ ENCOUNTER_SUBSTATE_PRE_BATTLE_LOAD
Definition enums.h:6313
@ ENCOUNTER_SUBSTATE_PRE_BATTLE_SKIP
Definition enums.h:6315
@ SOUND_SPEEDY_SPIN_ATTACK
Definition enums.h:1553
@ SOUND_SPEEDY_SPIN
Definition enums.h:1551
@ SOUND_SPIN_ATTACK
Definition enums.h:1552
@ SOUND_SPIN
Definition enums.h:1550
@ OUTCOME_SKIP
Definition enums.h:1906
@ ENCOUNTER_STATE_POST_BATTLE
Definition enums.h:6298
void set_battle_stage(s32)
Definition battle.c:138
void partner_handle_before_battle(void)
Definition partners.c:1067
void load_battle(s32)
Definition battle.c:130
void bgm_set_battle_song(s32, s32)
void bgm_push_battle_song(void)
char unk_07
Definition npc.h:370
s32 fadeOutAccel
Definition npc.h:397
s32 battleStartCountdown
Definition npc.h:398

Referenced by update_encounters().

◆ update_encounters_conversation()

void update_encounters_conversation ( void )

Definition at line 2263 of file encounter.c.

2263 {
2264 EncounterStatus* encounter = &gCurrentEncounter;
2265 PlayerStatus* playerStatus = &gPlayerStatus;
2266 Enemy* currentEnemy;
2267 s32 flag;
2268
2269 switch (gEncounterSubState) {
2271 currentEnemy = encounter->curEnemy;
2272 flag = FALSE;
2273
2274 if (currentEnemy->interactScript != NULL) {
2275 if (does_script_exist(currentEnemy->interactScriptID)) {
2276 flag = TRUE;
2277 } else {
2278 currentEnemy->interactScript = NULL;
2279 }
2280 }
2281
2282 if (currentEnemy->hitScript != NULL) {
2283 if (does_script_exist(currentEnemy->hitScriptID)) {
2284 flag = TRUE;
2285 } else {
2286 currentEnemy->hitScript = NULL;
2287 }
2288 }
2289
2290 if (!flag) {
2292 }
2293 break;
2296
2297 currentEnemy = encounter->curEnemy;
2298 if (currentEnemy != NULL && currentEnemy->aiScript != NULL) {
2299 resume_all_script(currentEnemy->aiScriptID);
2300 }
2301
2304
2305 if (playerStatus->actionState == ACTION_STATE_TALK) {
2307 }
2308
2309 func_800EF3D4(0);
2310 encounter->hitType = 0;
2313 EncounterStateChanged = TRUE;
2315 break;
2316 }
2317}
@ ENCOUNTER_SUBSTATE_CONVERSATION_END
Definition enums.h:6320
s32 resume_all_script(s32 id)

Referenced by update_encounters().

◆ update_encounters_post_battle()

void update_encounters_post_battle ( void )

Definition at line 1619 of file encounter.c.

1619 {
1620 EncounterStatus* currentEncounter = &gCurrentEncounter;
1621 PlayerStatus* playerStatus = &gPlayerStatus;
1622 PlayerData* playerData = &gPlayerData;
1623 PartnerStatus* partnerStatus = &gPartnerStatus;
1624 Encounter* encounter;
1625 Evt* script;
1626 Enemy* enemy;
1627 s32 i, j;
1628 s32 hasDefeatScript;
1629 Npc* npc;
1630
1631 switch (gEncounterSubState) {
1633 if (currentEncounter->unk_08 == 0) {
1634 return;
1635 }
1636
1637 currentEncounter->unk_08 = 0;
1639 currentEncounter->scriptedBattle = FALSE;
1641 currentEncounter->dizzyAttack.status = 0;
1642 currentEncounter->unusedAttack1.status = 0;
1643 currentEncounter->unusedAttack2.status = 0;
1644 currentEncounter->unusedAttack3.status = 0;
1645 currentEncounter->dizzyAttack.duration = 0;
1646 currentEncounter->unusedAttack1.duration = 0;
1647 currentEncounter->unusedAttack2.duration = 0;
1648 currentEncounter->unusedAttack3.duration = 0;
1649 if (HasPreBattleSongPushed == TRUE) {
1651 }
1652 currentEncounter->fadeOutAccel = 1;
1653 currentEncounter->battleStartCountdown = 0;
1655 gPlayerStatus.flags &= ~PS_FLAG_ENTERING_BATTLE;
1656 if (currentEncounter->hitType == ENCOUNTER_TRIGGER_SPIN) {
1658 }
1659 currentEncounter->hitType = 0;
1660 if (!D_80077C40) {
1662 }
1664 if (partnerStatus->shouldResumeAbility) {
1666 } else if (!LastBattleStartedBySpin
1670 ) {
1672 }
1673 switch (currentEncounter->battleOutcome) {
1674 case OUTCOME_PLAYER_WON:
1676 break;
1679 break;
1682 break;
1683 case OUTCOME_SKIP:
1685 break;
1686 case OUTCOME_ENEMY_FLED:
1688 break;
1689 }
1690 break;
1692 if (currentEncounter->hasMerleeCoinBonus) {
1693 if (get_coin_drop_amount(currentEncounter->curEnemy) != 0) {
1697 } else {
1698 playerData->merleeTurnCount = 0;
1699 playerData->merleeCastsLeft++;
1700 }
1701 }
1703 break;
1705 // fade screen in and wait for merlee bonus to finish (if applicable)
1706 if (currentEncounter->hasMerleeCoinBonus) {
1707 if (get_coin_drop_amount(currentEncounter->curEnemy) != 0) {
1708 currentEncounter->fadeOutAccel += 4;
1709 currentEncounter->fadeOutAmount -= currentEncounter->fadeOutAccel;
1710 if (currentEncounter->fadeOutAmount < 0) {
1711 currentEncounter->fadeOutAmount = 0;
1712 }
1714 break;
1715 }
1716 }
1717 }
1718 // start defeat scripts for current enemy
1719 encounter = currentEncounter->curEncounter;
1720 for (i = 0; i < encounter->count; i++) {
1721 enemy = encounter->enemy[i];
1722 if (enemy == NULL) {
1723 continue;
1724 }
1725 if ((enemy->flags & ENEMY_FLAG_ENABLE_HIT_SCRIPT) && enemy != currentEncounter->curEnemy) {
1726 continue;
1727 }
1728 if (enemy->flags & ENEMY_FLAG_DISABLE_AI) {
1729 continue;
1730 }
1731 if (enemy->defeatBytecode != NULL) {
1733 enemy->defeatScript = script;
1734 enemy->defeatScriptID = script->id;
1735 script->owner1.enemy = enemy;
1736 script->owner2.npcID = enemy->npcID;
1738 currentEncounter->battleStartCountdown = 1;
1739 } else {
1741 enemy->defeatScript = script;
1742 enemy->defeatScriptID = script->id;
1743 script->owner1.enemy = enemy;
1744 script->owner2.npcID = enemy->npcID;
1746 }
1747 }
1748 if (!(currentEncounter->flags & ENCOUNTER_FLAG_THUMBS_UP)
1750 && currentEncounter->battleStartCountdown == 0
1752 ) {
1753 suggest_player_anim_allow_backward(ANIM_Mario1_ThumbsUp);
1754 }
1756 break;
1758 if (currentEncounter->fadeOutAmount == 0) {
1760 } else {
1761 currentEncounter->fadeOutAccel += 4;
1762 currentEncounter->fadeOutAmount -= currentEncounter->fadeOutAccel;
1763 if (currentEncounter->fadeOutAmount < 0) {
1764 currentEncounter->fadeOutAmount = 0;
1765 }
1766 }
1767 break;
1769 // wait for all defeat scripts to finish
1770 hasDefeatScript = FALSE;
1771 encounter = currentEncounter->curEncounter;
1772 for (i = 0; i < encounter->count; i++) {
1773 enemy = encounter->enemy[i];
1774 if (enemy == NULL) {
1775 continue;
1776 }
1777 if ((enemy->flags & ENEMY_FLAG_ENABLE_HIT_SCRIPT) && enemy != currentEncounter->curEnemy) {
1778 continue;
1779 }
1780 if (enemy->flags & ENEMY_FLAG_DISABLE_AI) {
1781 continue;
1782 }
1783 if (does_script_exist(enemy->defeatScriptID)) {
1784 hasDefeatScript = TRUE;
1785 } else {
1786 enemy->defeatScript = NULL;
1787 }
1788 }
1789 // kill defeated enemies
1790 if (!hasDefeatScript) {
1791 if (!(currentEncounter->flags & ENCOUNTER_FLAG_THUMBS_UP)
1793 && currentEncounter->battleStartCountdown == 1
1794 ) {
1795 suggest_player_anim_allow_backward(ANIM_Mario1_ThumbsUp);
1796 }
1797 encounter = currentEncounter->curEncounter;
1798 for (i = 0; i < encounter->count; i++) {
1799 enemy = encounter->enemy[i];
1800 enemy = encounter->enemy[i];
1801 if (enemy == NULL) {
1802 continue;
1803 }
1804 if (enemy->flags & ENEMY_FLAG_DO_NOT_KILL) {
1805 continue;
1806 }
1807 if ((enemy->flags & ENEMY_FLAG_ENABLE_HIT_SCRIPT) && enemy != currentEncounter->curEnemy) {
1808 continue;
1809 }
1810 if (!(enemy->flags & ENEMY_FLAG_PASSIVE)) {
1811 if (!(enemy->flags & ENEMY_FLAG_FLED)) {
1812 set_defeated(currentEncounter->mapID, encounter->encounterID + i);
1813 }
1814 }
1815 kill_enemy(enemy);
1816 }
1817
1818 currentEncounter->substateDelay = 0;
1819 if (!(currentEncounter->flags & ENCOUNTER_FLAG_THUMBS_UP)
1821 && currentEncounter->battleStartCountdown == 1
1822 ) {
1823 currentEncounter->substateDelay = 30;
1824 }
1826 }
1827 break;
1829 if (!(currentEncounter->flags & ENCOUNTER_FLAG_CANT_SKIP_WIN_DELAY)) {
1830 if (gGameStatusPtr->stickX[0] != 0 || gGameStatusPtr->stickY[0] != 0) {
1831 currentEncounter->substateDelay = 0;
1832 }
1833 }
1834 if (currentEncounter->substateDelay != 0) {
1835 currentEncounter->substateDelay--;
1836 break;
1837 }
1838
1839 for (i = 0; i < currentEncounter->numEncounters; i++) {
1840 encounter = currentEncounter->encounterList[i];
1841 if (encounter == NULL) {
1842 continue;
1843 }
1844 for (j = 0; j < encounter->count; j++) {
1845 enemy = encounter->enemy[j];
1846 if (enemy == NULL || (enemy->flags & ENEMY_FLAG_DISABLE_AI)) {
1847 continue;
1848 }
1849 if (enemy->aiScript != NULL) {
1851 }
1852 if (enemy->auxScript != NULL) {
1854 }
1855 }
1856 }
1857
1858 currentEncounter->battleTriggerCooldown = 15;
1862 suggest_player_anim_allow_backward(ANIM_Mario1_Idle);
1863 }
1867 EncounterStateChanged = TRUE;
1869 break;
1871 encounter = currentEncounter->curEncounter;
1872 for (i = 0; i < encounter->count; i++) {
1873 enemy = encounter->enemy[i];
1874 if (enemy == NULL) {
1875 continue;
1876 }
1877 if ((enemy->flags & ENEMY_FLAG_ENABLE_HIT_SCRIPT) && enemy != currentEncounter->curEnemy) {
1878 continue;
1879 }
1880 if (enemy->flags & ENEMY_FLAG_DISABLE_AI) {
1881 continue;
1882 }
1883
1884 if (enemy->defeatBytecode != NULL) {
1885 script = start_script(enemy->defeatBytecode, EVT_PRIORITY_A, 0);
1886 enemy->defeatScript = script;
1887 enemy->defeatScriptID = script->id;
1888 enemy->aiFlags |= AI_FLAG_1;
1889 script->owner1.enemy = enemy;
1890 script->owner2.npcID = enemy->npcID;
1891 script->groupFlags = enemy->scriptGroup;
1892 }
1893 }
1895 break;
1897 if (currentEncounter->fadeOutAmount == 0) {
1899 } else {
1900 currentEncounter->fadeOutAccel += 4;
1901 currentEncounter->fadeOutAmount -= currentEncounter->fadeOutAccel;
1902 if (currentEncounter->fadeOutAmount < 0) {
1903 currentEncounter->fadeOutAmount = 0;
1904 }
1905 }
1906 break;
1908 encounter = currentEncounter->curEncounter;
1909 hasDefeatScript = FALSE;
1910 for (i = 0; i < encounter->count; i++) {
1911 enemy = encounter->enemy[i];
1912 if (enemy == NULL) {
1913 continue;
1914 }
1915 if (!(enemy->flags & ENEMY_FLAG_DISABLE_AI)) {
1916 if (does_script_exist(enemy->defeatScriptID)) {
1917 hasDefeatScript = TRUE;
1918 } else {
1919 enemy->defeatScript = NULL;
1920 }
1921 }
1922 }
1923 if (!hasDefeatScript) {
1924 for (i = 0; i < currentEncounter->numEncounters; i++) {
1925 encounter = currentEncounter->encounterList[i];
1926 if (encounter == NULL) {
1927 continue;
1928 }
1929 for (j = 0; j < encounter->count; j++) {
1930 enemy = encounter->enemy[j];
1931 if (enemy == NULL || (enemy->flags & ENEMY_FLAG_DISABLE_AI)) {
1932 continue;
1933 }
1934 if (enemy->aiScript != NULL) {
1936 }
1937 if (enemy->auxScript != NULL) {
1939 }
1940 }
1941 }
1942
1943 enemy = currentEncounter->curEnemy;
1944 encounter = currentEncounter->curEncounter;
1945 if (!(enemy->flags & ENEMY_FLAG_NO_DELAY_AFTER_FLEE)) {
1946 enemy->aiSuspendTime = 45;
1947 playerStatus->blinkTimer = 45;
1948 for (j = 0; j < encounter->count; j++) {
1949 enemy = encounter->enemy[j];
1950 if (enemy == NULL) {
1951 continue;
1952 }
1953 if (enemy->flags & ENEMY_FLAG_DISABLE_AI) {
1954 continue;
1955 }
1956 if (enemy->flags & ENEMY_FLAG_ENABLE_HIT_SCRIPT) {
1957 continue;
1958 }
1959 enemy->aiSuspendTime = 45;
1960 playerStatus->blinkTimer = 45;
1961 }
1962 }
1963
1964 enemy = currentEncounter->curEnemy;
1965 if (!(currentEncounter->flags & ENCOUNTER_FLAG_SKIP_FLEE_DROPS)) {
1967 enemy->defeatScript = script;
1968 enemy->defeatScriptID = script->id;
1969 script->owner1.enemy = enemy;
1970 script->owner2.npcID = enemy->npcID;
1971 script->groupFlags = enemy->scriptGroup;
1972 }
1973
1974 currentEncounter->battleTriggerCooldown = 45;
1975 playerStatus->blinkTimer = 45;
1980 currentEncounter->substateDelay = 15;
1981 } else {
1982 currentEncounter->substateDelay = 0;
1983 }
1985 }
1986 break;
1988 if (currentEncounter->substateDelay != 0) {
1989 currentEncounter->substateDelay--;
1990 if (gGameStatusPtr->curButtons[0] == 0 && gGameStatusPtr->stickX[0] == 0 && gGameStatusPtr->stickY[0] == 0) {
1991 break;
1992 }
1993 }
1994 if (!PendingPartnerAbilityResume && playerStatus->anim == ANIM_MarioB3_Hustled) {
1995 suggest_player_anim_allow_backward(ANIM_Mario1_Idle);
1996 }
1999 EncounterStateChanged = TRUE;
2001 break;
2003 suggest_player_anim_allow_backward(ANIM_MarioW2_LayingDown);
2004 encounter = currentEncounter->curEncounter;
2005 for (i = 0; i < encounter->count; i++) {
2006 enemy = encounter->enemy[i];
2007 if (enemy == NULL) {
2008 continue;
2009 }
2010 if ((enemy->flags & ENEMY_FLAG_ENABLE_HIT_SCRIPT) && enemy != currentEncounter->curEnemy) {
2011 continue;
2012 }
2013
2014 if (enemy->flags & ENEMY_FLAG_DISABLE_AI) {
2015 continue;
2016 }
2017
2018 if (enemy->defeatBytecode != NULL) {
2019 script = start_script(enemy->defeatBytecode, EVT_PRIORITY_A, 0);
2020 enemy->defeatScript = script;
2021 enemy->defeatScriptID = script->id;
2022 script->owner1.enemy = enemy;
2023 script->owner2.npcID = enemy->npcID;
2024 script->groupFlags = enemy->scriptGroup;
2025 }
2026 }
2028 break;
2030 if (currentEncounter->fadeOutAmount == 0) {
2032 } else {
2033 currentEncounter->fadeOutAccel += 4;
2034 currentEncounter->fadeOutAmount -= currentEncounter->fadeOutAccel;
2035 if (currentEncounter->fadeOutAmount < 0) {
2036 currentEncounter->fadeOutAmount = 0;
2037 }
2038 }
2039 break;
2041 hasDefeatScript = FALSE;
2042 encounter = currentEncounter->curEncounter;
2043 for (i = 0; i < encounter->count; i++) {
2044 enemy = encounter->enemy[i];
2045 if (enemy == NULL) {
2046 continue;
2047 }
2048 if (!(enemy->flags & ENEMY_FLAG_DISABLE_AI)) {
2049 if (does_script_exist(enemy->defeatScriptID)) {
2050 hasDefeatScript = TRUE;
2051 } else {
2052 enemy->defeatScript = NULL;
2053 }
2054 }
2055 }
2056 if (!hasDefeatScript) {
2057 for (i = 0; i < currentEncounter->numEncounters; i++) {
2058 encounter = currentEncounter->encounterList[i];
2059 if (encounter == NULL) {
2060 continue;
2061 }
2062 for (j = 0; j < encounter->count; j++) {
2063 enemy = encounter->enemy[j];
2064 if (enemy == NULL || (enemy->flags & ENEMY_FLAG_DISABLE_AI)) {
2065 continue;
2066 }
2067 if (enemy->aiScript != NULL) {
2069 }
2070 if (enemy->auxScript != NULL) {
2072 }
2073 }
2074 }
2078 currentEncounter->substateDelay = 15;
2080 }
2081 break;
2083 if (currentEncounter->substateDelay != 0) {
2084 currentEncounter->substateDelay--;
2085 if (gGameStatusPtr->curButtons[0] == 0 && gGameStatusPtr->stickX[0] == 0 && gGameStatusPtr->stickY[0] == 0) {
2086 break;
2087 }
2088 }
2091 EncounterStateChanged = TRUE;
2093 break;
2095 // resume all ai scripts
2096 for (i = 0; i < currentEncounter->numEncounters; i++) {
2097 encounter = currentEncounter->encounterList[i];
2098 if (encounter == NULL) {
2099 continue;
2100 }
2101 for (j = 0; j < encounter->count; j++) {
2102 enemy = encounter->enemy[j];
2103 if (enemy == NULL || (enemy->flags & ENEMY_FLAG_DISABLE_AI)) {
2104 continue;
2105 }
2106 if (enemy->aiScript != NULL) {
2108 }
2109 if (enemy->auxScript != NULL) {
2111 }
2112 }
2113 }
2119 EncounterStateChanged = TRUE;
2121 break;
2123 encounter = currentEncounter->curEncounter;
2124 for (i = 0; i < encounter->count; i++) {
2125 enemy = encounter->enemy[i];
2126 if (enemy == NULL) {
2127 continue;
2128 }
2129 if ((enemy->flags & ENEMY_FLAG_ENABLE_HIT_SCRIPT) && enemy != currentEncounter->curEnemy) {
2130 continue;
2131 }
2132
2133 if (enemy->flags & ENEMY_FLAG_DISABLE_AI) {
2134 continue;
2135 }
2136
2137 if (enemy->defeatBytecode != NULL) {
2138 script = start_script(enemy->defeatBytecode, EVT_PRIORITY_A, 0);
2139 enemy->defeatScript = script;
2140 enemy->defeatScriptID = script->id;
2141 script->owner1.enemy = enemy;
2142 script->owner2.npcID = enemy->npcID;
2143 script->groupFlags = enemy->scriptGroup;
2144 }
2145 }
2147 break;
2149 if (currentEncounter->fadeOutAmount == 0) {
2151 } else {
2152 currentEncounter->fadeOutAccel += 4;
2153 currentEncounter->fadeOutAmount -= currentEncounter->fadeOutAccel;
2154 if (currentEncounter->fadeOutAmount < 0) {
2155 currentEncounter->fadeOutAmount = 0;
2156 }
2157 }
2158 break;
2160 hasDefeatScript = FALSE;
2161 encounter = currentEncounter->curEncounter;
2162 for (i = 0; i < encounter->count; i++) {
2163 enemy = encounter->enemy[i];
2164 if (enemy == NULL) {
2165 continue;
2166 }
2167 if (!(enemy->flags & ENEMY_FLAG_DISABLE_AI)) {
2168 if (does_script_exist(enemy->defeatScriptID)) {
2169 hasDefeatScript = TRUE;
2170 } else {
2171 enemy->defeatScript = NULL;
2172 }
2173 }
2174 }
2175 if (!hasDefeatScript) {
2176 for (i = 0; i < currentEncounter->numEncounters; i++) {
2177 encounter = currentEncounter->encounterList[i];
2178 if (encounter == NULL) {
2179 continue;
2180 }
2181 for (j = 0; j < encounter->count; j++) {
2182 enemy = encounter->enemy[j];
2183 if (enemy == NULL || (enemy->flags & ENEMY_FLAG_DISABLE_AI)) {
2184 continue;
2185 }
2186 if (enemy->aiScript != NULL) {
2188 }
2189 if (enemy->auxScript != NULL) {
2191 }
2192 }
2193 }
2194
2195 enemy = currentEncounter->curEnemy;
2196 if (!(enemy->flags & ENEMY_FLAG_DO_NOT_KILL)) {
2197 encounter = currentEncounter->curEncounter;
2198 enemy->aiSuspendTime = 45;
2199 playerStatus->blinkTimer = 45;
2200 for (j = 0; j < encounter->count; j++) {
2201 enemy = encounter->enemy[j];
2202 if (enemy == NULL) {
2203 continue;
2204 }
2205 if (enemy->flags & ENEMY_FLAG_DISABLE_AI) {
2206 continue;
2207 }
2208 if (enemy->flags & ENEMY_FLAG_ENABLE_HIT_SCRIPT) {
2209 continue;
2210 }
2211 enemy->aiSuspendTime = 45;
2212 playerStatus->blinkTimer = 45;
2213 }
2214 }
2215
2216 currentEncounter->battleTriggerCooldown = 45;
2222 EncounterStateChanged = TRUE;
2224 }
2225 break;
2226 }
2227
2228 for (i = 0; i < currentEncounter->numEncounters; i++) {
2229 encounter = currentEncounter->encounterList[i];
2230 if (encounter == NULL) {
2231 continue;
2232 }
2233 for (j = 0; j < encounter->count; j++) {
2234 enemy = encounter->enemy[j];
2235 if (enemy == NULL || (enemy->flags & ENEMY_FLAG_DISABLE_AI)) {
2236 continue;
2237 }
2238
2239 npc = get_npc_unsafe(enemy->npcID);
2240 if (enemy->aiSuspendTime != 0) {
2241 if (enemy->aiSuspendTime & 1) {
2242 npc->flags |= NPC_FLAG_SUSPENDED;
2243 enemy->flags |= ENEMY_FLAG_SUSPENDED;
2244 } else {
2245 npc->flags &= ~NPC_FLAG_SUSPENDED;
2246 enemy->flags &= ~ENEMY_FLAG_SUSPENDED;
2247 }
2248 }
2249 }
2250 }
2251}
s8 LastBattleStartedBySpin
Definition encounter.c:180
void setup_status_bar_for_world(void)
Definition inventory.c:1461
s32 get_coin_drop_amount(Enemy *enemy)
Definition 23680.c:312
BSS s32 MerleeDropCoinsEvtID
Definition encounter.c:188
void set_defeated(s32 mapID, s32 encounterID)
Definition encounter.c:210
EvtScript EVS_NpcDefeat
Definition encounter.c:65
s8 PendingPartnerAbilityResume
Definition encounter.c:179
BSS Evt * MerleeDropCoinsEvt
Definition encounter.c:187
EvtScript EVS_MerleeDropCoins
Definition encounter.c:26
EvtScript EVS_FleeBattleDrops
Definition encounter.c:77
void partner_handle_after_battle(void)
Definition partners.c:1081
@ ENCOUNTER_FLAG_SKIP_FLEE_DROPS
Definition enums.h:4988
@ ENCOUNTER_FLAG_THUMBS_UP
Mario will do a 'thumbs up' animation after winning.
Definition enums.h:4986
@ ENCOUNTER_FLAG_CANT_SKIP_WIN_DELAY
Definition enums.h:4987
@ AI_FLAG_1
Definition enums.h:4568
@ ENCOUNTER_SUBSTATE_POST_BATTLE_WON_FADE_IN
Definition enums.h:6325
@ ENCOUNTER_SUBSTATE_POST_BATTLE_LOST_RESUME
Definition enums.h:6336
@ ENCOUNTER_SUBSTATE_POST_BATTLE_LOST_FADE_IN
Definition enums.h:6335
@ ENCOUNTER_SUBSTATE_POST_BATTLE_SKIP
Definition enums.h:6338
@ ENCOUNTER_SUBSTATE_POST_BATTLE_FLED_RESUME
Definition enums.h:6332
@ ENCOUNTER_SUBSTATE_POST_BATTLE_WON_KILL
Definition enums.h:6326
@ ENCOUNTER_SUBSTATE_POST_BATTLE_FLED_INIT
Definition enums.h:6330
@ ENCOUNTER_SUBSTATE_POST_BATTLE_WON_RESUME
Definition enums.h:6327
@ ENCOUNTER_SUBSTATE_POST_BATTLE_ENEMY_FLED_INIT
Definition enums.h:6339
@ ENCOUNTER_SUBSTATE_POST_BATTLE_LOST_DELAY
Definition enums.h:6337
@ ENCOUNTER_SUBSTATE_POST_BATTLE_FLED_FADE_IN
Definition enums.h:6331
@ ENCOUNTER_SUBSTATE_POST_BATTLE_LOST_INIT
Definition enums.h:6334
@ ENCOUNTER_SUBSTATE_POST_BATTLE_ENEMY_FLED_FADE_IN
Definition enums.h:6340
@ ENCOUNTER_SUBSTATE_POST_BATTLE_PLAY_NPC_DEFEAT
Definition enums.h:6329
@ ENCOUNTER_SUBSTATE_POST_BATTLE_ENEMY_FLED_RESUME
Definition enums.h:6341
@ ENCOUNTER_SUBSTATE_POST_BATTLE_FLED_DELAY
Definition enums.h:6333
@ ENCOUNTER_SUBSTATE_POST_BATTLE_WON_CHECK_MERLEE
Definition enums.h:6328
@ ENEMY_FLAG_DO_NOT_KILL
Definition enums.h:4522
@ ENEMY_FLAG_NO_DELAY_AFTER_FLEE
Definition enums.h:4538
@ ENEMY_FLAG_FLED
Definition enums.h:4524
void bgm_pop_battle_song(void)
void suggest_player_anim_allow_backward(AnimID anim)
Definition 77480.c:894
FieldStatus unusedAttack3
Definition npc.h:402
FieldStatus unusedAttack1
Definition npc.h:400
void kill_enemy(Enemy *enemy)
Definition npc.c:2373
FieldStatus unusedAttack2
Definition npc.h:401

Referenced by update_encounters().

◆ load_map_bg()

void load_map_bg ( char * optAssetName)

Definition at line 14 of file background.c.

14 {
15 if (optAssetName != NULL) {
16 UNK_PTR compressedData;
17 u32 assetSize;
18 char* assetName = optAssetName;
19
21 // Use sunny Flower Fields bg rather than cloudy
22 if (strcmp(assetName, gCloudyFlowerFieldsBg) == 0) {
23 assetName = gSunnyFlowerFieldsBg;
24 }
25 }
26
27 compressedData = load_asset_by_name(assetName, &assetSize);
28 decode_yay0(compressedData, &gBackgroundImage);
29 general_heap_free(compressedData);
30 }
31}
char gCloudyFlowerFieldsBg[]
Definition background.c:5
char gSunnyFlowerFieldsBg[]
Definition background.c:6
@ STORY_CH6_DESTROYED_PUFF_PUFF_MACHINE
Definition enums.h:191
#define UNK_PTR
Definition types.h:7

Referenced by btl_state_update_normal_start(), load_map_by_IDs(), state_init_title_screen(), state_step_end_battle(), and state_step_unpause().

◆ reset_background_settings()

◆ func_80138188()

void func_80138188 ( void )

Definition at line 469 of file screen_overlays.c.

469 {
471}

Referenced by load_demo_battle(), and load_map_by_IDs().

◆ func_80266970()

void func_80266970 ( Actor * target)

Definition at line 2439 of file 190B20.c.

2439 {
2440 target->actionRatingCombo = 0;
2441}

Referenced by calc_enemy_damage_target(), calc_item_damage_enemy(), calc_partner_damage_enemy(), and calc_player_damage_enemy().

◆ show_actor_health_bar()

void show_actor_health_bar ( Actor * target)

◆ hide_actor_health_bar()

void hide_actor_health_bar ( Actor * target)

Definition at line 2510 of file 190B20.c.

2510 {
2511 target->healthBarHideTime = 0;
2512 target->flags &= ~ACTOR_FLAG_HEALTH_BAR_HIDDEN;
2513}

◆ clear_part_pal_adjustment()

void clear_part_pal_adjustment ( ActorPart * part)

Definition at line 2618 of file 190B20.c.

2618 {
2619 if (part->idleAnimations != NULL && !(part->flags & ACTOR_PART_FLAG_NO_DECORATIONS)) {
2621 }
2622}

Referenced by calc_enemy_damage_target(), calc_partner_damage_enemy(), and calc_player_damage_enemy().

◆ calculate_camera_yinterp_rate()

void calculate_camera_yinterp_rate ( void )

Definition at line 183 of file 7B440.c.

183 {
185 f32 x = shadow->rot.x + 180.0;
186 f32 z = shadow->rot.z + 180.0;
187 Camera* camera = &gCameras[CAM_DEFAULT];
188 f32 rate;
189
190 if (x != 0.0f || z != 0.0f) {
191 switch (gPlayerStatus.actionState) {
194 rate = 32.0f;
195 camera->yinterpRate = rate;
196 break;
198 case ACTION_STATE_RUN:
199 if (camera->targetScreenCoords.y < 130) {
200 camera->yinterpRate = 3.0f;
201 break;
202 }
203 rate = 3.0f;
204 if (PlayerYInterpUpdateDelay++ <= 10) {
205 return;
206 }
208 camera->yinterpRate -= 2.0f;
209 if (camera->yinterpRate < rate) {
210 camera->yinterpRate = rate;
211 }
212 break;
214 rate = 3.0f;
215 camera->yinterpRate = rate;
216 break;
217 default:
218 rate = 3.0f;
220 camera->yinterpRate -= 2.0f;
221 if (camera->yinterpRate < rate) {
222 camera->yinterpRate = rate;
223 }
224 break;
225 }
226 } else {
227 switch (gPlayerStatus.actionState) {
229 case ACTION_STATE_RUN:
232 rate = 7.2f;
233 break;
234 default:
235 rate = 24.0f;
236 break;
237 }
238
239 camera->yinterpRate = rate;
240 }
241}
BSS s32 PlayerYInterpUpdateDelay
Definition 7B440.c:13
f32 yinterpRate

Referenced by phys_peach_update(), and phys_update_action_state().

◆ load_tattle_flags()

void load_tattle_flags ( s32 actorType)

Definition at line 571 of file 181810.c.

571 {
572 BattleStatus* battleStatus = &gBattleStatus;
573 u8* types;
574 s32 gb;
575 s32 i = 0;
576 s32 j;
577 s32 k;
578
579 while (TRUE) {
580 types = ActorTypesLists[i];
581 if (types == NULL) {
582 break;
583 }
584
585 for (j = 0; types[j] != ACTOR_TYPE_LIST_END; j++) {
586 if (actorType == types[j]) {
587 for (k = 0; types[k] != ACTOR_TYPE_LIST_END; k++) {
588 actorType = types[k];
589
591 gb |= 1 << (actorType % 8);
592 battleStatus->tattleFlags[actorType / 8] |= gb;
593 }
594 return;
595 }
596 }
597 i++;
598 }
599
601 gb |= 1 << (actorType % 8);
602 battleStatus->tattleFlags[actorType / 8] |= gb;
603}
#define ACTOR_TYPE_LIST_END
Definition 181810.c:14
u8 * ActorTypesLists[]
Definition 181810.c:100

◆ use_consumable()

s32 use_consumable ( s32 invSlot)

Definition at line 479 of file partners.c.

479 {
480 Evt* script;
481
482 D_8010CD20 = invSlot;
483 invSlot = gPlayerData.invItems[invSlot];
486 script->varTable[10] = invSlot;
487 return script->id;
488}
UseItemStruct UseItemDmaArgs
Definition partners.c:470
EvtScript * main
Definition partners.c:125
BSS s32 D_8010CD20
Definition partners.c:477

Referenced by check_input_open_menus().

◆ remove_consumable()

void remove_consumable ( void )

Definition at line 490 of file partners.c.

490 {
491 gPlayerData.invItems[D_8010CD20] = ITEM_NONE;
493}
void sort_consumables(void)
Bubbles up player inventory items such that all ITEM_NONE values are at the bottom.
Definition inventory.c:410

◆ delete_shadow()

void delete_shadow ( s32 shadowIndex)

Definition at line 626 of file entity.c.

626 {
627 Shadow* shadow = get_shadow_by_index(shadowIndex);
628
630 heap_free((*gCurrentShadowListPtr)[shadowIndex]);
631 (*gCurrentShadowListPtr)[shadowIndex] = NULL;
632}
s16 entityModelID
void free_entity_model_by_index(s32 idx)

Referenced by btl_delete_actor(), btl_delete_player_actor(), free_npc(), free_npc_by_index(), remove_item_entity_by_index(), remove_item_entity_by_reference(), remove_part_shadow(), and update_shadows().

◆ partner_reset_tether_distance()

void partner_reset_tether_distance ( void )

Definition at line 2405 of file partners.c.

2405 {
2406 wPartnerTetherDistance = 40.0f;
2407}

Referenced by check_for_interactables(), and interact_inspect_dismiss().

◆ save_tattle_flags()

void save_tattle_flags ( s32 actorType)

Definition at line 535 of file 181810.c.

535 {
536 BattleStatus* battleStatus = &gBattleStatus;
537 u8* types;
538 s32 gb;
539 s32 i = 0;
540 s32 j;
541 s32 k;
542
543 while (TRUE) {
544 types = ActorTypesLists[i];
545 if (types == NULL) {
546 break;
547 }
548
549 for (j = 0; types[j] != ACTOR_TYPE_LIST_END; j++) {
550 if (actorType == types[j]) {
551 for (k = 0; types[k] != ACTOR_TYPE_LIST_END; k++) {
552 actorType = types[k];
553
555 gb |= 1 << (actorType % 8);
557 battleStatus->tattleFlags[actorType / 8] |= gb;
558 }
559 return;
560 }
561 }
562 i++;
563 }
564
566 gb |= 1 << (actorType % 8);
568 battleStatus->tattleFlags[actorType / 8] |= gb;
569}

◆ update_merlee_messages()

void update_merlee_messages ( void )

Definition at line 150 of file status_icons.c.

150 {
151 s32 i;
152
153 for (i = 0; i < ARRAY_COUNT(D_800A0BC0); i++) {
154 PopupMessage* popup = &D_800A0BC0[i];
155 if (popup->active && popup->updateFunc != NULL) {
156 popup->updateFunc(popup);
157 }
158 }
159}

Referenced by update_encounters().

◆ draw_merlee_messages()

void draw_merlee_messages ( void )

Definition at line 172 of file status_icons.c.

172 {
173 s32 i;
174
175 for (i = 0; i < ARRAY_COUNT(D_800A0BC0); i++) {
176 PopupMessage* popup = &D_800A0BC0[i];
177 if (popup->active && popup->renderUIFunc != NULL) {
178 popup->renderUIFunc(popup);
179 }
180 }
181}

Referenced by draw_encounter_ui().

◆ show_merlee_message()

void show_merlee_message ( s16 messageIndex,
s16 duration )

Definition at line 205 of file status_icons.c.

205 {
207
208 if (popup != NULL) {
211 popup->needsInit = TRUE;
212 popup->unk_00 = 0;
213 popup->renderWorldFunc = NULL;
214 popup->messageIndex = messageIndex;
215 popup->duration = duration;
217 D_800A0F40 = 1;
218 }
219}
void draw_merlee_message(void *popup)
PopupMessage * get_current_merlee_message(void)
void update_merlee_message(void *popup)
BSS s32 D_800A0F40

◆ is_merlee_message_done()

s32 is_merlee_message_done ( void )

Definition at line 331 of file status_icons.c.

331 {
332 return D_800A0F40;
333}

◆ close_action_command_instruction_popup()

void close_action_command_instruction_popup ( void )

Definition at line 645 of file popup_messages.c.

645 {
647
648 if (popup != NULL
651 ) {
652 popup->duration = 0;
653 }
654}
@ BTL_MSG_LAST_ACTION_TIP
Definition enums.h:4125

Referenced by action_command_free(), and btl_state_update_player_move().

◆ draw_encounters_conversation()

void draw_encounters_conversation ( void )

Definition at line 2319 of file encounter.c.

2319 {
2320}

Referenced by draw_encounter_ui().

◆ draw_encounters_post_battle()

void draw_encounters_post_battle ( void )

Definition at line 2253 of file encounter.c.

2253 {
2254 EncounterStatus* currentEncounter = &gCurrentEncounter;
2255 s32 ret = currentEncounter->fadeOutAccel;
2256
2257 if (ret != 0) {
2260 }
2261}

Referenced by draw_encounter_ui().

◆ draw_encounters_pre_battle()

void draw_encounters_pre_battle ( void )

Definition at line 1487 of file encounter.c.

1487 {
1488 EncounterStatus* encounter = &gCurrentEncounter;
1489 PlayerStatus* playerStatus = &gPlayerStatus;
1490
1491#if DX_DEBUG_MENU
1492 Npc* npc = NULL;
1493 if (encounter->curEnemy->npcID != (s16) DX_DEBUG_DUMMY_ID) {
1494 npc = get_npc_unsafe(encounter->curEnemy->npcID);
1495 }
1496#else
1497 Npc* npc = get_npc_unsafe(encounter->curEnemy->npcID);
1498#endif
1499
1500 if (encounter->substateDelay != 0) {
1501 f32 playerX, playerY, playerZ;
1502 f32 otherX, otherY, otherZ;
1503 s32 pScreenX, pScreenY, pScreenZ;
1504 s32 oScreenX, oScreenY, oScreenZ;
1505
1506 if (encounter->fadeOutAmount != 255) {
1507 encounter->fadeOutAccel++;
1508 if (encounter->fadeOutAccel > 10) {
1509 encounter->fadeOutAccel = 10;
1510 }
1511
1512 encounter->fadeOutAmount += encounter->fadeOutAccel;
1513 if (encounter->fadeOutAmount > 255) {
1514 encounter->fadeOutAmount = 255;
1515 }
1516
1517 playerX = playerStatus->pos.x;
1518 playerY = playerStatus->pos.y;
1519 playerZ = playerStatus->pos.z;
1520
1521 #if DX_DEBUG_MENU
1522 if (npc != NULL) {
1523 otherX = npc->pos.x;
1524 otherY = npc->pos.y;
1525 otherZ = npc->pos.z;
1526 } else {
1527 otherX = playerX;
1528 otherY = playerY;
1529 otherZ = playerZ;
1530 }
1531 #else
1532 otherX = npc->pos.x;
1533 otherY = npc->pos.y;
1534 otherZ = npc->pos.z;
1535 #endif
1536 if (otherY < -990.0f) {
1537 otherX = playerX;
1538 otherY = playerY;
1539 otherZ = playerZ;
1540 }
1541
1546 get_screen_coords(gCurrentCameraID, playerX, playerY + 20.0f, playerZ, &pScreenX, &pScreenY, &pScreenZ);
1547 get_screen_coords(gCurrentCameraID, otherX, otherY + 15.0f, otherZ, &oScreenX, &oScreenY, &oScreenZ);
1548 set_screen_overlay_center(SCREEN_LAYER_BACK, 0, (pScreenX - oScreenX) / 2 + oScreenX,
1549 (pScreenY - oScreenY) / 2 + oScreenY);
1550 } else {
1554 get_screen_coords(gCurrentCameraID, playerX, playerY + 20.0f, playerZ, &pScreenX, &pScreenY, &pScreenZ);
1555 get_screen_coords(gCurrentCameraID, otherX, otherY + 15.0f, otherZ, &oScreenX, &oScreenY, &oScreenZ);
1556 set_screen_overlay_center(SCREEN_LAYER_FRONT, 0, (pScreenX - oScreenX) / 2 + oScreenX,
1557 (pScreenY - oScreenY) / 2 + oScreenY);
1558 }
1559 }
1560 }
1561}
@ OVERLAY_START_BATTLE
Definition enums.h:2398
void set_screen_overlay_alpha(s32, f32)

Referenced by draw_encounter_ui().

◆ draw_encounters_neutral()

void draw_encounters_neutral ( void )

Definition at line 1258 of file encounter.c.

1258 {
1259}

Referenced by draw_encounter_ui().

◆ show_first_strike_message()

void show_first_strike_message ( void )

Definition at line 1563 of file encounter.c.

1563 {
1564 EncounterStatus* currentEncounter = &gCurrentEncounter;
1565 s32 posX;
1566 s32 width;
1567 s32 xOffset;
1568 s32 screenWidthHalf;
1569
1570 if (currentEncounter->substateDelay == 0) {
1572 return;
1573 }
1574
1576 xOffset = gFirstStrikeMessagePos;
1577 if (xOffset > 0) {
1578 if (xOffset < 1600) {
1579 xOffset = 0;
1580 } else {
1581 xOffset -= 1600;
1582 }
1583 }
1584
1585 screenWidthHalf = SCREEN_WIDTH / 2;
1586
1587 switch (currentEncounter->firstStrikeType) {
1589 switch (currentEncounter->hitType) {
1592 width = get_msg_width(MSG_Menus_PlayerFirstStrike, 0) + 24;
1593 posX = (xOffset + screenWidthHalf) - (width / 2);
1594 draw_box(0, WINDOW_STYLE_20, posX, 69, 0, width, 28, 255, 0, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, NULL, 0, NULL,
1596 draw_msg(MSG_Menus_PlayerFirstStrike, posX + 11, 75, 0xFF, MSG_PAL_STANDARD, 0);
1597 break;
1599 width = get_msg_width(MSG_Menus_PartnerFirstStrike, 0) + 24;
1600 posX = (xOffset + screenWidthHalf) - (width / 2);
1601 draw_box(0, WINDOW_STYLE_20, posX, 69, 0, width, 28, 255, 0, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, NULL, 0, NULL,
1603 draw_msg(MSG_Menus_PartnerFirstStrike, posX + 11, 75, 0xFF, MSG_PAL_STANDARD, 0);
1604 break;
1605 }
1606 break;
1607 case FIRST_STRIKE_ENEMY:
1609 width = get_msg_width(MSG_Menus_EnemyFirstStrike, 0) + 24;
1610 posX = (xOffset + screenWidthHalf) - (width / 2);
1611 draw_box(0, WINDOW_STYLE_4, posX, 69, 0, width, 28, 255, 0, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, NULL, 0, NULL,
1613 draw_msg(MSG_Menus_EnemyFirstStrike, posX + 11, 75, 0xFF, MSG_PAL_STANDARD, 0);
1614 }
1615 break;
1616 }
1617}
s16 gFirstStrikeMessagePos
Definition encounter.c:181
@ WINDOW_STYLE_20
Definition enums.h:6389
@ MSG_PAL_STANDARD
Definition enums.h:5414

Referenced by draw_first_strike_ui().

◆ entity_upgrade_block_hide_content()

void entity_upgrade_block_hide_content ( s32 entityIndex)

Definition at line 40 of file SuperBlock.c.

40 {
41 Entity* entity = get_entity_by_index(entityIndex);
42 BlockData* data = entity->dataBuf.block;
43
44 if (data->childEntityIndex >= 0) {
45 Entity* childEntity = get_entity_by_index(data->childEntityIndex);
46 SuperBlockContentData* childEntityData = childEntity->dataBuf.superBlockContent;
47 childEntityData->isHidden = TRUE;
48 }
49}
struct SuperBlockContentData * superBlockContent
s16 childEntityIndex
Definition entity.h:120

◆ lookup_defense()

s32 lookup_defense ( s32 * defenseTable,
s32 elementKey )

Definition at line 2027 of file 190B20.c.

2027 {
2028 s32 normalDefense = 0;
2029
2030 while (defenseTable[DICTIONARY_KEY] != ELEMENT_END) {
2031 if (defenseTable[DICTIONARY_KEY] == ELEMENT_NORMAL) {
2032 normalDefense = defenseTable[DICTIONARY_VALUE];
2033 }
2034
2035 if (defenseTable[DICTIONARY_KEY] == elementKey) {
2036 normalDefense = defenseTable[DICTIONARY_VALUE];
2037 break;
2038 }
2039 defenseTable += DICTIONARY_SIZE;
2040 }
2041
2042 // Fall back to normal defense if given element is not specified in table
2043 return normalDefense;
2044}
@ ELEMENT_END
Definition enums.h:2114
@ DICTIONARY_KEY
Definition enums.h:5233
@ DICTIONARY_SIZE
Definition enums.h:5235
@ DICTIONARY_VALUE
Definition enums.h:5234

Referenced by get_defense().

◆ lookup_status_chance()

s32 lookup_status_chance ( s32 * statusTable,
s32 statusKey )

Definition at line 2046 of file 190B20.c.

2046 {
2047 s32 defaultChance = 0;
2048
2049 while (statusTable[DICTIONARY_KEY] != STATUS_END) {
2050 if (statusTable[DICTIONARY_KEY] == STATUS_KEY_DEFAULT) {
2051 defaultChance = statusTable[DICTIONARY_VALUE];
2052 }
2053
2054 if (statusTable[DICTIONARY_KEY] == statusKey) {
2055 defaultChance = statusTable[DICTIONARY_VALUE];
2056 break;
2057 }
2058 statusTable += DICTIONARY_SIZE;
2059 }
2060
2061 // Fall back to normal chance if given element is not specified in table
2062 return defaultChance;
2063}
@ STATUS_END
Definition enums.h:2196

Referenced by inflict_status_set_duration(), and try_inflict_status().

◆ peach_check_for_parasol_input()

void peach_check_for_parasol_input ( void )

Definition at line 530 of file 7E9D0.c.

530 {
531 PlayerStatus* playerStatus = &gPlayerStatus;
532 s32 actionState = playerStatus->actionState;
533 Npc* disguiseNpc;
534
535 if (actionState == ACTION_STATE_IDLE || actionState == ACTION_STATE_WALK || actionState == ACTION_STATE_RUN) {
536 if (PeachDisguiseReapplyDelay != 0) {
538 if (PeachDisguiseReapplyDelay == 0) {
540 playerStatus->animFlags |= PA_FLAG_INVISIBLE;
542
544 if (disguiseNpc != NULL) {
545 disguiseNpc->flags &= ~NPC_FLAG_IGNORE_CAMERA_FOR_YAW;
546 }
547 }
548 }
551 }
552 }
553}
s32 PeachDisguiseReapplyDelay
Definition 7E9D0.c:22
Npc * peach_make_disguise_npc(s32 peachDisguise)
Definition 7E9D0.c:573
@ PEACH_FLAG_HAS_PARASOL
Definition enums.h:2490

Referenced by phys_peach_update().

◆ peach_sync_disguise_npc()

void peach_sync_disguise_npc ( void )

Definition at line 555 of file 7E9D0.c.

555 {
556 PlayerStatus* playerStatus = &gPlayerStatus;
557
558 if (PeachDisguiseNpcIndex >= 0) {
560
562 npc->renderYaw = playerStatus->spriteFacingAngle;
563 } else {
564 npc->yaw = playerStatus->targetYaw;
565 }
566
567 npc->pos.x = playerStatus->pos.x;
568 npc->pos.y = playerStatus->pos.y;
569 npc->pos.z = playerStatus->pos.z;
570 }
571}

Referenced by action_update_parasol(), and phys_peach_update().

◆ check_conversation_trigger()

b32 check_conversation_trigger ( void )

Definition at line 2322 of file encounter.c.

2322 {
2323 PlayerStatus* playerStatus = &gPlayerStatus;
2324 Camera* camera = &gCameras[gCurrentCameraID];
2325 EncounterStatus* encounterStatus = &gCurrentEncounter;
2326 f32 npcX, npcY, npcZ;
2327 f32 angle;
2328 f32 deltaX, deltaZ;
2329 Encounter* resultEncounter;
2330 f32 playerX, playerY, playerZ;
2331 f32 playerHeight;
2332 f32 playerRadius;
2333 f32 length;
2334 f32 npcHeight;
2335 f32 npcRadius;
2336 Encounter* encounter;
2337 Npc* resultNpc;
2338 Npc* npc;
2339 Enemy* resultEnemy;
2340 Enemy* enemy;
2341 f32 minLength;
2342 s32 i, j;
2343 f32 yaw;
2344
2345 playerStatus->encounteredNPC = NULL;
2346 playerStatus->flags &= ~PS_FLAG_HAS_CONVERSATION_NPC;
2347 playerHeight = playerStatus->colliderHeight;
2348 playerRadius = playerStatus->colliderDiameter / 2;
2349 playerX = playerStatus->pos.x;
2350 playerY = playerStatus->pos.y;
2351 playerZ = playerStatus->pos.z;
2352
2354 return FALSE;
2355 }
2356
2357 resultEncounter = NULL;
2358 resultNpc = NULL;
2359 resultEnemy = NULL;
2360 minLength = 65535.0f;
2361
2362 for (i = 0; i < encounterStatus->numEncounters; i++) {
2363 encounter = encounterStatus->encounterList[i];
2364
2365 if (encounter == NULL) {
2366 continue;
2367 }
2368
2369 for (j = 0; j < encounter->count; j++) {
2370 enemy = encounter->enemy[j];
2371
2372 if (enemy == NULL) {
2373 continue;
2374 }
2375
2377 continue;
2378 }
2379
2380 if (!(enemy->flags & ENEMY_FLAG_PASSIVE)) {
2381 continue;
2382 }
2383
2384 if ((enemy->flags & ENEMY_FLAG_CANT_INTERACT) || enemy->interactBytecode == NULL) {
2385 continue;
2386 }
2387
2388 npc = get_npc_unsafe(enemy->npcID);
2389
2390 npcX = npc->pos.x;
2391 npcY = npc->pos.y;
2392 npcZ = npc->pos.z;
2393 deltaX = npcX - playerX;
2394 deltaZ = npcZ - playerZ;
2395 npcHeight = npc->collisionHeight;
2396 npcRadius = npc->collisionDiameter;
2397 length = sqrtf(SQ(deltaX) + SQ(deltaZ));
2398
2399 // check cylinder-cylinder overlap
2400 if ((playerRadius + npcRadius <= length) ||
2401 (npcY + npcHeight < playerY) ||
2402 (playerY + playerHeight < npcY)) {
2403 continue;
2404 }
2405
2406 if (clamp_angle(playerStatus->spriteFacingAngle) < 180.0f) {
2407 angle = clamp_angle(camera->curYaw - 120.0f);
2408 if (playerStatus->trueAnimation & SPRITE_ID_BACK_FACING) {
2409 angle = clamp_angle(angle + 60.0f);
2410 }
2411 } else {
2412 angle = clamp_angle(camera->curYaw + 120.0f);
2413 if (playerStatus->trueAnimation & SPRITE_ID_BACK_FACING) {
2414 angle = clamp_angle(angle - 60.0f);
2415 }
2416 }
2417
2418 yaw = atan2(playerX, playerZ, npcX, npcZ);
2419 if (fabsf(get_clamped_angle_diff(angle, yaw)) > 90.0f) {
2420 continue;
2421 }
2422
2423 // only allow interact if line of sight exists
2424 // @bug? flag combination does not make sense
2426 f32 x = npcX;
2427 f32 y = npcY;
2428 f32 z = npcZ;
2429 yaw = atan2(npcX, npcZ, playerX, playerZ);
2430
2431 if (npc_test_move_taller_with_slipping(0, &x, &y, &z, length, yaw, npcHeight, 2.0f * npcRadius)) {
2432 continue;
2433 }
2434 }
2435
2436 if (length < minLength) {
2437 minLength = length;
2438 resultEncounter = encounter;
2439 resultNpc = npc;
2440 resultEnemy = enemy;
2441 }
2442 }
2443 }
2444
2445 if (!(playerStatus->animFlags & PA_FLAG_8BIT_MARIO) && resultNpc != NULL && !is_picking_up_item()) {
2446 playerStatus->encounteredNPC = resultNpc;
2447 playerStatus->flags |= PS_FLAG_HAS_CONVERSATION_NPC;
2448 if (playerStatus->pressedButtons & BUTTON_A) {
2452 encounterStatus->curEncounter = resultEncounter;
2453 encounterStatus->curEnemy = resultEnemy;
2454 encounterStatus->firstStrikeType = FIRST_STRIKE_PLAYER;
2455 return TRUE;
2456 }
2457 }
2458 return FALSE;
2459}
@ ENEMY_FLAG_CANT_INTERACT
Definition enums.h:4547

Referenced by phys_peach_update(), and phys_update_action_state().

◆ clear_player_status()

void clear_player_status ( void )

◆ clear_entity_models()

void clear_entity_models ( void )

◆ bind_entity_model_setupGfx()

void bind_entity_model_setupGfx ( s32 idx,
void * setupGfxCallbackArg0,
void(*)(void *) fpSetupGfxCallback )

Definition at line 774 of file entity_model.c.

774 {
775 EntityModel* entityModel = (*gCurrentEntityModelList)[idx & ~BATTLE_ENTITY_ID_BIT];
776
777 entityModel->fpSetupGfxCallback = fpSetupGfxCallback;
778 entityModel->setupGfxCallbackArg0 = setupGfxCallbackArg0;
779}
void * setupGfxCallbackArg0
Definition entity.h:464

Referenced by render_entities(), render_shadows(), and show_immune_bonk().

◆ clear_animator_list()

void clear_animator_list ( void )

Definition at line 222 of file animator.c.

222 {
223 s32 i;
224
227 for (i = 0; i < ARRAY_COUNT(D_801533C0); i++) {
228 D_801533C0[i].ttl = -1;
229 }
230
231 for (i = 0; i < ARRAY_COUNT(D_801536C0); i++) {
232 D_801536C0[i].ttl = -1;
233 }
234 } else {
236 }
237
238 for (i = 0; i < ARRAY_COUNT(*gCurrentAnimMeshListPtr); i++) {
239 (*gCurrentAnimMeshListPtr)[i] = NULL;
240 }
241
242 gAnimModelFogR = 10;
243 gAnimModelFogG = 10;
244 gAnimModelFogB = 10;
245 gAnimModelFogA = 10;
246 gAnimModelFogStart = 800;
247 gAnimCount = 0;
249 gAnimModelFogEnd = 1000;
250}
BSS s32 gAnimModelFogR
Definition animator.c:20
BSS s32 gAnimModelFogG
Definition animator.c:21
BSS AnimatedMeshVertexCopyList D_801536C0
Definition animator.c:15
BSS AnimatedMeshList D_801539C0
Definition animator.c:16
BSS AnimatedMeshList D_80153A00
Definition animator.c:17
BSS s32 gAnimModelFogEnd
Definition animator.c:25
BSS s32 gAnimModelFogA
Definition animator.c:23
BSS s32 gAnimModelFogStart
Definition animator.c:24
BSS s32 gAnimModelFogB
Definition animator.c:22
BSS AnimatedMeshVertexCopyList D_801533C0
Definition animator.c:14
BSS s32 gAnimModelFogEnabled
Definition animator.c:19

Referenced by load_demo_battle(), load_engine_data(), load_map_by_IDs(), state_init_logos(), state_init_title_screen(), state_step_battle(), state_step_demo(), state_step_intro(), state_step_pause(), state_step_startup(), and state_step_title_screen().

◆ clear_model_data()

void clear_model_data ( void )

Definition at line 2364 of file model.c.

2364 {
2365 s32 i;
2366
2376 ShroudTintAmt = 0;
2377 ShroudTintR = 0;
2378 ShroudTintG = 0;
2379 ShroudTintB = 0;
2381 } else {
2391 }
2392
2393 for (i = 0; i < ARRAY_COUNT(*gCurrentModels); i++) {
2394 (*gCurrentModels)[i] = 0;
2395 }
2396
2397 for (i = 0; i < ARRAY_COUNT(*gCurrentTransformGroups); i++) {
2398 (*gCurrentTransformGroups)[i] = 0;
2399 }
2400
2401 for (i = 0; i < ARRAY_COUNT(*gCurrentCustomModelGfxPtr); i++) {
2402 (*gCurrentCustomModelGfxPtr)[i] = 0;
2403 (*gCurrentCustomModelGfxBuildersPtr)[i] = 0;
2404 }
2405
2406 *gCurrentModelTreeRoot = NULL;
2407
2408 for (i = 0; i < ARRAY_COUNT(*gCurrentModelTreeNodeInfo); i++) {
2409 (*gCurrentModelTreeNodeInfo)[i].modelIndex = -1;
2410 (*gCurrentModelTreeNodeInfo)[i].treeDepth = 0;
2411 (*gCurrentModelTreeNodeInfo)[i].textureID = 0;
2412 }
2413
2415 gFogSettings->enabled = FALSE;
2416 gFogSettings->color.r = 10;
2417 gFogSettings->color.g = 10;
2418 gFogSettings->color.b = 10;
2419 gFogSettings->color.a = 0;
2421 gFogSettings->endDistance = 1000;
2422
2423 for (i = 0; i < ARRAY_COUNT(texPannerAuxV); i++) {
2424 texPannerAuxV[i] = 0;
2425 texPannerAuxU[i] = 0;
2426 texPannerMainV[i] = 0;
2427 texPannerMainU[i] = 0;
2428 }
2429}
ModelCustomGfxList * gCurrentCustomModelGfxPtr
Definition model.c:1310
BSS s8 bBackgroundTintMode
Definition model.c:1335
BSS ModelTreeInfoList wModelTreeNodeInfo
Definition model.c:1331
BSS s8 wBackgroundTintMode
Definition model.c:1334
BSS ModelNode * bModelTreeRoot
Definition model.c:1330
BSS ModelTransformGroupList bTransformGroups
Definition model.c:1318
BSS ModelTreeInfoList bModelTreeNodeInfo
Definition model.c:1332
BSS ModelLocalVertexCopyList bModelLocalVtxBuffers
Definition model.c:1326
BSS FogSettings bFogSettings
Definition model.c:1338
BSS ModelNode * wModelTreeRoot
Definition model.c:1329
u8 * gBackgroundTintModePtr
Definition model.c:105
BSS ModelList wModelList
Definition model.c:1314
BSS ModelCustomGfxBuilderList bCustomModelGfxBuilders
Definition model.c:1324
ModelCustomGfxBuilderList * gCurrentCustomModelGfxBuildersPtr
Definition model.c:1307
BSS ModelCustomGfxList bCustomModelGfx
Definition model.c:1321
BSS FogSettings wFogSettings
Definition model.c:1337
BSS ModelLocalVertexCopyList wModelLocalVtxBuffers
Definition model.c:1325
BSS ModelCustomGfxBuilderList wCustomModelGfxBuilders
Definition model.c:1323
BSS ModelList bModelList
Definition model.c:1315
BSS ModelTransformGroupList wTransformGroups
Definition model.c:1317
BSS ModelLocalVertexCopyList * gCurrentModelLocalVtxBuffers
Definition model.c:1327
BSS ModelCustomGfxList wCustomModelGfx
Definition model.c:1320

Referenced by load_demo_battle(), load_engine_data(), load_map_by_IDs(), state_step_battle(), state_step_demo(), state_step_intro(), state_step_pause(), and state_step_startup().

◆ init_sprite_shading_data()

void init_sprite_shading_data ( void )

Definition at line 39 of file sprite_shading.c.

39 {
43 } else {
46 }
47}
BSS SpriteShadingProfile wSpriteShadingProfileAux
BSS SpriteShadingProfile wSpriteShadingProfile
BSS SpriteShadingProfile bSpriteShadingProfile
SpriteShadingProfile * gSpriteShadingProfile
SpriteShadingProfile * gAuxSpriteShadingProfile
BSS SpriteShadingProfile bSpriteShadingProfileAux

Referenced by clear_sprite_shading_data(), state_step_end_battle(), and state_step_unpause().

◆ clear_sprite_shading_data()

void clear_sprite_shading_data ( void )

Definition at line 20 of file sprite_shading.c.

Referenced by load_demo_battle(), load_engine_data(), load_map_by_IDs(), state_step_battle(), state_step_demo(), state_step_intro(), state_step_pause(), and state_step_startup().

◆ clear_character_set()

void clear_character_set ( void )

Definition at line 192 of file msg.c.

192 {
193 D_80155C98 = -1;
194}

Referenced by load_engine_data().

◆ clear_trigger_data()

void clear_trigger_data ( void )

Definition at line 13 of file trigger.c.

13 {
14 CollisionStatus* collisionStatus = &gCollisionStatus;
15 s32 i;
16
19 } else {
21 }
22
23 for (i = 0; i < ARRAY_COUNT(*gCurrentTriggerListPtr); i++) {
24 (*gCurrentTriggerListPtr)[i] = NULL;
25 }
26
27 gTriggerCount = 0;
28 collisionStatus->pushingAgainstWall = NO_COLLIDER;
29 collisionStatus->curFloor = NO_COLLIDER;
30 collisionStatus->lastTouchedFloor = NO_COLLIDER;
31 collisionStatus->curCeiling = NO_COLLIDER;
32 collisionStatus->curInspect = NO_COLLIDER;
33 collisionStatus->unk_0C = -1;
34 collisionStatus->unk_0E = -1;
35 collisionStatus->unk_10 = -1;
36 collisionStatus->curWall = NO_COLLIDER;
37 collisionStatus->lastWallHammered = NO_COLLIDER;
38 collisionStatus->touchingWallTrigger = 0;
39 collisionStatus->bombetteExploded = -1;
40 collisionStatus->bombetteExplosionPos.x = 0.0f;
41 collisionStatus->bombetteExplosionPos.y = 0.0f;
42 collisionStatus->bombetteExplosionPos.z = 0.0f;
43}

Referenced by load_demo_battle(), load_engine_data(), load_map_by_IDs(), state_step_battle(), state_step_demo(), state_step_intro(), state_step_pause(), and state_step_startup().

◆ clear_script_list()

void clear_script_list ( void )

Definition at line 149 of file script_list.c.

149 {
150 s32 i;
151
156 } else {
160 }
161
162 for (i = 0; i < MAX_SCRIPTS; i++) {
163 (*gCurrentScriptListPtr)[i] = NULL;
164 }
165
166 gNumScripts = 0;
168 IsUpdatingScripts = FALSE;
169
170 for (i = 0; i < MAX_MAPVARS; i++) {
171 gMapVars[i] = 0;
172 }
173
174 for (i = 0; i < MAX_MAPFLAGS; i++) {
175 gMapFlags[i] = 0;
176 }
177
180}
void clear_virtual_entity_list(void)
void reset_model_animators(void)
Definition model_api.c:258
#define MAX_MAPFLAGS
Definition macros.h:82
#define MAX_MAPVARS
Definition macros.h:81

Referenced by load_demo_battle(), load_engine_data(), load_map_by_IDs(), state_init_demo(), state_init_logos(), state_init_title_screen(), state_step_battle(), state_step_demo(), state_step_intro(), state_step_pause(), and state_step_startup().

◆ clear_entity_data()

void clear_entity_data ( b32 arg0)

Definition at line 787 of file entity.c.

787 {
788 s32 i;
789
790 D_801516FC = 1;
794 D_80151304 = 0;
795
798 }
799
803 if (!arg0) {
804 D_80151344 = 0;
805 }
806 D_8014AFB0 = 255;
807
810 for (i = 0; i < MAX_ENTITIES; i++) {
811 wEntityBlueprint[i] = NULL;
812 }
813 } else {
815 for (i = 0; i < ARRAY_COUNT(bEntityBlueprint); i++) {
816 bEntityBlueprint[i] = NULL;
817 }
818 }
819
823 } else {
826 }
827
830
831 for (i = 0; i < MAX_ENTITIES; i++) {
832 (*gCurrentEntityListPtr)[i] = NULL;
833 }
834
835 for (i = 0; i < MAX_SHADOWS; i++) {
836 (*gCurrentShadowListPtr)[i] = NULL;
837 }
838}
BSS s32 bEntityDataLoadedSize
Definition entity.c:59
s32 isAreaSpecificEntityDataLoaded
Definition entity.c:48
s32 D_80151304
Definition entity.c:40
s32 D_80151344
Definition entity.c:41
BSS s32 wEntityDataLoadedSize
Definition entity.c:58
BSS s32 D_801516FC
Definition entity.c:63
BSS EntityBlueprint * wEntityBlueprint[MAX_ENTITIES+2]
Definition entity.c:61

Referenced by load_demo_battle(), load_engine_data(), load_map_by_IDs(), state_init_logos(), state_init_title_screen(), state_step_battle(), state_step_demo(), state_step_intro(), state_step_pause(), state_step_startup(), and state_step_title_screen().

◆ clear_effect_data()

void clear_effect_data ( void )

Definition at line 41 of file effects.c.

41 {
42 s32 i;
43
44 for (i = 0; i < ARRAY_COUNT(gEffectSharedData); i++) {
46 }
47
48 for (i = 0; i < ARRAY_COUNT(gEffectInstances); i++) {
49 gEffectInstances[i] = NULL;
50 }
51
52 osUnmapTLBAll();
53 osMapTLB(EFFECT_GLOBALS_TLB_IDX, OS_PM_4K, effect_globals_VRAM, (s32)&gEffectGlobals & 0xFFFFFF, -1, -1);
54 DMA_COPY_SEGMENT(effect_globals);
55}
Addr gEffectGlobals
#define EFFECT_GLOBALS_TLB_IDX
Definition effects.c:8

Referenced by load_demo_battle(), load_engine_data(), load_map_by_IDs(), state_init_logos(), state_init_title_screen(), state_step_demo(), state_step_intro(), and state_step_startup().

◆ clear_saved_variables()

void clear_saved_variables ( void )

Definition at line 5 of file vars_access.c.

5 {
6 SaveData* saveFile = &gCurrentSaveFile;
7 s32 i;
8
9 for (i = 0; i < ARRAY_COUNT(saveFile->globalFlags); i++) {
10 saveFile->globalFlags[i] = 0;
11 }
12
13 for (i = 0; i < ARRAY_COUNT(saveFile->globalBytes); i++) {
14 saveFile->globalBytes[i] = 0;
15 }
16
17 for (i = 0; i < ARRAY_COUNT(saveFile->areaFlags); i++) {
18 saveFile->areaFlags[i] = 0;
19 }
20
21 for (i = 0; i < ARRAY_COUNT(saveFile->areaBytes); i++) {
22 saveFile->areaBytes[i] = 0;
23 }
24}
s32 areaFlags[8]
Definition versioning.h:162
s32 globalFlags[64]
Definition versioning.h:160
s8 globalBytes[512]
Definition versioning.h:161
s8 areaBytes[16]
Definition versioning.h:163

Referenced by filemenu_yesno_handle_input(), load_engine_data(), state_init_demo(), state_step_demo(), state_step_intro(), and state_step_startup().

◆ clear_area_flags()

void clear_area_flags ( void )

Definition at line 26 of file vars_access.c.

26 {
27 SaveData* saveFile = &gCurrentSaveFile;
28 s32 i;
29
31 for (i = 0; i < ARRAY_COUNT(saveFile->areaFlags); i++) {
32 saveFile->areaFlags[i] = 0;
33 }
34
35 for (i = 0; i < ARRAY_COUNT(saveFile->areaBytes); i++) {
36 saveFile->areaBytes[i] = 0;
37 }
38 }
39}

Referenced by load_map_by_IDs().

◆ get_player_normal_pitch()

f32 get_player_normal_pitch ( void )

Definition at line 661 of file 43F0.c.

661 {
662 f32 traceNormalX = gGameStatusPtr->playerGroundTraceNormal.x;
663 f32 traceNormalZ = gGameStatusPtr->playerGroundTraceNormal.z;
664 f32 sqrt = sqrtf(SQ(traceNormalX) + SQ(traceNormalZ));
665
666 return atan2(0.0f, 0.0f, sqrt, -gGameStatusPtr->playerGroundTraceNormal.y);
667}

Referenced by phys_main_collision_below(), player_raycast_down(), and update_riding_physics().

◆ partner_kill_ability_script()

void partner_kill_ability_script ( void )

Definition at line 1109 of file partners.c.

◆ func_800EF3D4()

void func_800EF3D4 ( s32 arg0)

◆ mdl_update_transform_matrices()

void mdl_update_transform_matrices ( void )

Definition at line 2589 of file model.c.

2589 {
2590 Matrix4f tempModelMtx;
2591 Matrix4f tempGroupMtx;
2592 f32 mX, mY, mZ;
2593 f32 mtgX, mtgY, mtgZ;
2594 Model* model;
2595 Mtx* curMtx;
2596 ModelBoundingBox* bb;
2598 s32 i;
2599
2600 for (i = 0; i < ARRAY_COUNT(*gCurrentModels); i++) {
2601 model = (*gCurrentModels)[i];
2602 if (model != NULL && (model->flags != 0) && !(model->flags & MODEL_FLAG_INACTIVE)) {
2603 if (!(model->flags & MODEL_FLAG_MATRIX_DIRTY)) {
2604 if (model->matrixFreshness != 0) {
2605 // matrix was recalculated recently and stored on the matrix stack
2606 // since DisplayContexts alternate, we can fetch the previous matrix from the other context
2607 model->matrixFreshness--;
2608 if (model->matrixFreshness == 0) {
2609 // since it hasn't changed in a few frames, cache the matrix
2610 model->savedMtx = *model->finalMtx;
2611 }
2612 // copy matrix from previous DisplayContext stack to current one
2613 curMtx = model->finalMtx;
2615 *model->finalMtx = *curMtx;
2616 } else {
2617 // transform matrix is not changed, have gfx build with saved matrix
2618 model->finalMtx = &model->savedMtx;
2619 }
2620 } else {
2621 // first frame with dirty matrix, need to recalculate it
2622 model->flags &= ~MODEL_FLAG_MATRIX_DIRTY;
2623 model->matrixFreshness = 2;
2624
2625 // write matrix to the matrix stack
2627 if (model->bakedMtx == NULL || (model->flags & MODEL_FLAG_TRANSFORM_GROUP_MEMBER)) {
2628 guMtxF2L(model->userTransformMtx, curMtx);
2629 } else {
2630 guMtxL2F(tempModelMtx, model->bakedMtx);
2631 guMtxCatF(model->userTransformMtx, tempModelMtx, tempModelMtx);
2632 guMtxF2L(tempModelMtx, curMtx);
2633 }
2634 model->flags &= ~MODEL_FLAG_IGNORE_MATRIX;
2635
2636 // recalculate the center of the model with transformation applied
2638 mX = (bb->minX + bb->maxX) * 0.5f;
2639 mY = (bb->minY + bb->maxY) * 0.5f;
2640 mZ = (bb->minZ + bb->maxZ) * 0.5f;
2641 guMtxXFML(curMtx, mX, mY, mZ, &mX, &mY, &mZ);
2642 model->center.x = mX;
2643 model->center.y = mY;
2644 model->center.z = mZ;
2645
2646 // point matrix for gfx building to our matrix on the stack
2647 model->finalMtx = curMtx;
2648
2649 // disable bounds culling for models with dynamic transformations
2650 model->flags &= ~MODEL_FLAG_DO_BOUNDS_CULLING;
2651 }
2652 }
2653 }
2654
2655 for (i = 0; i < ARRAY_COUNT((*gCurrentTransformGroups)); i++) {
2656 mtg = (*gCurrentTransformGroups)[i];
2657 if (mtg != NULL && mtg->flags != 0 && !(mtg->flags & TRANSFORM_GROUP_FLAG_INACTIVE)) {
2659 if (mtg->matrixFreshness != 0) {
2660 // matrix was recalculated recently and stored on the matrix stack
2661 // since DisplayContexts alternate, we can fetch the previous matrix from the other context
2662 mtg->matrixFreshness--;
2663 if (mtg->matrixFreshness == 0) {
2664 // since it hasn't changed in a few frames, cache the matrix
2665 mtg->savedMtx = *mtg->finalMtx;
2666 }
2667 // copy matrix from previous DisplayContext stack to current one
2668 curMtx = mtg->finalMtx;
2670 *mtg->finalMtx = *curMtx;
2671 } else {
2672 // transform matrix is not changed, have gfx build with saved matrix
2673 mtg->finalMtx = &mtg->savedMtx;
2674 }
2675 } else {
2676 // first frame with dirty matrix, need to recalculate it
2677 mtg->flags &= ~TRANSFORM_GROUP_FLAG_MATRIX_DIRTY;
2678 mtg->matrixFreshness = 2;
2679
2680 // write matrix to the matrix stack
2682 if (mtg->bakedMtx == NULL) {
2683 guMtxF2L(mtg->userTransformMtx, curMtx);
2684 } else {
2685 guMtxL2F(tempGroupMtx, mtg->bakedMtx);
2686 guMtxCatF(mtg->userTransformMtx, tempGroupMtx, tempGroupMtx);
2687 guMtxF2L(tempGroupMtx, curMtx);
2688 }
2689 mtg->flags &= ~TRANSFORM_GROUP_FLAG_IGNORE_MATRIX;
2690
2691 // recalculate the center of the transform group with transformation applied
2693 mtgX = (bb->minX + bb->maxX) * 0.5f;
2694 mtgY = (bb->minY + bb->maxY) * 0.5f;
2695 mtgZ = (bb->minZ + bb->maxZ) * 0.5f;
2696 guMtxXFML(curMtx, mtgX, mtgY, mtgZ, &mtgX, &mtgY, &mtgZ);
2697 mtg->center.x = mtgX;
2698 mtg->center.y = mtgY;
2699 mtg->center.z = mtgZ;
2700
2701 // point matrix for gfx building to our matrix on the stack
2702 mtg->finalMtx = curMtx;
2703 }
2704 }
2705 }
2706
2708}
@ TRANSFORM_GROUP_FLAG_MATRIX_DIRTY
Definition enums.h:5083
@ MODEL_FLAG_INACTIVE
Definition enums.h:4358
void build_custom_gfx(void)
Definition model.c:3853
u8 matrixFreshness
Definition model.h:73
Mtx * finalMtx
Definition model.h:65
Mtx savedMtx
Definition model.h:67

Referenced by render_frame().

◆ mdl_group_set_custom_gfx()

void mdl_group_set_custom_gfx ( u16 groupModelID,
s32 customGfxIndex,
s32 tintType,
b32 invertSelection )

Definition at line 3694 of file model.c.

3694 {
3695 s32 maxGroupIndex = -1;
3696 s32 i;
3697 s32 minGroupIndex;
3698 s32 modelIndex = (*gCurrentModelTreeNodeInfo)[groupModelID].modelIndex;
3699 s32 siblingIndex;
3700 s32 maskLow, maskHigh, packed;
3701
3702 if (modelIndex < MAX_MODELS - 1) {
3703 minGroupIndex = maxGroupIndex = modelIndex;
3704 } else {
3705 s32 treeDepth = (*gCurrentModelTreeNodeInfo)[groupModelID].treeDepth;
3706 for (i = groupModelID - 1; i >= 0; i--) {
3707 if ((*gCurrentModelTreeNodeInfo)[i].treeDepth <= treeDepth) {
3708 break;
3709 }
3710
3711 siblingIndex = (*gCurrentModelTreeNodeInfo)[i].modelIndex;
3712
3713 if (siblingIndex < MAX_MODELS - 1) {
3714 if (maxGroupIndex == -1) {
3715 maxGroupIndex = siblingIndex;
3716 }
3717 minGroupIndex = siblingIndex;
3718 }
3719 }
3720 }
3721
3722 maskLow = maskHigh = 0;
3723
3724 if (customGfxIndex < 0) {
3725 maskLow = 0xF;
3726 customGfxIndex = 0;
3727 }
3728
3729 if (tintType < 0) {
3730 maskHigh = 0xF0;
3731 tintType = 0;
3732 }
3733
3734 packed = customGfxIndex + (tintType << 4);
3735
3736 if (!invertSelection) {
3737 for (i = minGroupIndex; i <= maxGroupIndex; i++) {
3738 Model* model = (*gCurrentModels)[i];
3739 model->customGfxIndex = (model->customGfxIndex & (maskLow + maskHigh)) + packed;
3740 }
3741 } else {
3742 for (i = 0; i < minGroupIndex; i++) {
3743 Model* model = (*gCurrentModels)[i];
3744 model->customGfxIndex = (model->customGfxIndex & (maskLow + maskHigh)) + packed;
3745 }
3746 for (i = maxGroupIndex + 1; i < MAX_MODELS; i++) {
3747 Model* model = (*gCurrentModels)[i];
3748 if (model != NULL) {
3749 model->customGfxIndex = (model->customGfxIndex & (maskLow + maskHigh)) + packed;
3750 }
3751 }
3752 }
3753}
u8 customGfxIndex
Definition model.h:71

◆ backup_map_collision_data()

void backup_map_collision_data ( void )

Definition at line 80 of file collision.c.

80 {
81 CollisionData* collisionData;
82 Collider* collider;
83 ColliderBackupEntry* backupEntry;
84 s32 i;
85
86 collisionData = &gCollisionData;
88 for (i = 0, backupEntry = gCollisionDataBackup; i < collisionData->numColliders; i++, backupEntry++) {
89 collider = &collisionData->colliderList[i];
90 backupEntry->flags = collider->flags;
91 backupEntry->parentModelIndex = collider->parentModelIndex;
92 }
93
94 collisionData = &gZoneCollisionData;
96 for (i = 0, backupEntry = gCollisionDataZoneBackup; i < collisionData->numColliders; i++, backupEntry++) {
97 collider = &collisionData->colliderList[i];
98 backupEntry->flags = collider->flags;
99 backupEntry->parentModelIndex = collider->parentModelIndex;
100 }
101
103}
BSS ColliderBackupEntry * gCollisionDataZoneBackup
Definition collision.c:52
BSS ColliderBackupEntry * gCollisionDataBackup
Definition collision.c:51

Referenced by state_step_battle(), and state_step_pause().

◆ reset_status_bar()

void reset_status_bar ( void )

Definition at line 1682 of file inventory.c.

1682 {
1683 PlayerData* playerData = &gPlayerData;
1684 StatusBar* statusBar = &gStatusBar;
1685 s32 i;
1686
1687 statusBar->drawPosX = 12;
1688 statusBar->drawPosY = FULLY_RETRACTED_Y;
1689 statusBar->hidden = 0;
1690 statusBar->showTimer = 210;
1691 statusBar->unk_3B = FALSE;
1692 statusBar->ignoreChanges = FALSE;
1693 statusBar->openInputDisabled = FALSE;
1694 statusBar->alwaysShown = FALSE;
1695 statusBar->hpBlinking = BLINK_OFF;
1696 statusBar->hpBlinkAnimTime = 0;
1697 statusBar->hpBlinkTimeLeft = 0;
1698 statusBar->fpBlinking = BLINK_OFF;
1699 statusBar->fpBlinkAnimTime = 0;
1700 statusBar->fpBlinkTimeLeft = 0;
1701 statusBar->coinsBlinking = BLINK_OFF;
1702 statusBar->coinsBlinkAnimTime = 0;
1703 statusBar->coinsBlinkTimeLeft = 0;
1704 statusBar->starPowerBlinking = BLINK_OFF;
1705 statusBar->starPowerBlinkCounter = 0;
1706 statusBar->disabled = 0;
1707 statusBar->starpointsBlinking = BLINK_OFF;
1708 statusBar->starpointsBlinkAnimTime = 0;
1709 statusBar->prevIgnoreChanges = -1;
1710 statusBar->displayHP = playerData->curHP;
1711 statusBar->displayFP = playerData->curFP;
1712 statusBar->displayCoins = playerData->coins;
1713 statusBar->displayStarpoints = playerData->starPoints;
1714 statusBar->displayStarPower = playerData->starPower;
1715 statusBar->unk_3C = FALSE;
1716
1717 for (i = 0; i < ARRAY_COUNT(statusBar->hpIconHIDs); i++) {
1718 copy_world_hud_element_ref_to_battle(statusBar->hpIconHIDs[i], statusBar->hpIconHIDs[i]);
1719 }
1720
1721 for (i = 0; i < ARRAY_COUNT(statusBar->fpIconHIDs); i++) {
1722 copy_world_hud_element_ref_to_battle(statusBar->fpIconHIDs[i], statusBar->fpIconHIDs[i]);
1723 }
1724
1734}
void copy_world_hud_element_ref_to_battle(s32 worldID, s32 battleID)

Referenced by state_step_battle(), and state_step_pause().

◆ btl_save_world_cameras()

void btl_save_world_cameras ( void )

Definition at line 1069 of file 16C8E0.c.

1069 {
1070 PlayerStatus* playerStatus = &gPlayerStatus;
1071 s32 i;
1072
1073 for (i = 0; i < ARRAY_COUNT(gCameras); i++) {
1075 }
1076
1077 SavedWorldPlayerPosX = playerStatus->pos.x;
1078 SavedWorldPlayerPosY = playerStatus->pos.y;
1079 SavedWorldPlayerPosZ = playerStatus->pos.z;
1080 playerStatus->pos.x = NPC_DISPOSE_POS_X;
1081 playerStatus->pos.y = NPC_DISPOSE_POS_Y;
1082 playerStatus->pos.z = NPC_DISPOSE_POS_Z;
1083}

Referenced by state_step_battle().

◆ load_battle_section()

void load_battle_section ( void )

Definition at line 112 of file battle.c.

112 {
114 s32 battleIdx = UNPACK_BTL_INDEX(gCurrentBattleID);
115
116 dma_copy(battleArea->dmaStart, battleArea->dmaEnd, battleArea->dmaDest);
117
118 gCurrentBattlePtr = &(*battleArea->battles)[battleIdx];
119
120 if (gCurrentStageID < 0) {
121 gCurrentStagePtr = NULL;
122 } else {
123 gCurrentStagePtr = &(*battleArea->stages)[gCurrentStageID];
124 }
125
128}
BattleArea gBattleAreas[]
Definition battle.c:51
void * dmaDest
Definition battle.h:217
BattleList * battles
Definition battle.h:218
StageList * stages
Definition battle.h:219
void * dmaEnd
Definition battle.h:216
void * dmaStart
Definition battle.h:215

Referenced by state_step_battle().

◆ btl_update()

void btl_update ( void )

Definition at line 254 of file 16C8E0.c.

254 {
255 BattleStatus* battleStatus = &gBattleStatus;
256 PlayerData* playerData = &gPlayerData;
257 Actor* partner = battleStatus->partnerActor;
258 f32 outAngle;
259 f32 outMagnitude;
260 s32 cond;
261
262 if (battleStatus->inputBitmask != -1) {
264 s32 inputBitmask = battleStatus->inputBitmask;
265
266 battleStatus->curButtonsDown = gGameStatusPtr->curButtons[1] & inputBitmask;
267 battleStatus->curButtonsPressed = gGameStatusPtr->pressedButtons[1] & inputBitmask;
268 battleStatus->curButtonsHeld = gGameStatusPtr->heldButtons[1] & inputBitmask;
269 battleStatus->stickX = gGameStatusPtr->stickX[1];
270 battleStatus->stickY = gGameStatusPtr->stickY[1];
271 } else {
272 s32 inputBitmask2 = battleStatus->inputBitmask;
273
274 battleStatus->curButtonsDown = gGameStatusPtr->curButtons[0] & inputBitmask2;
275 battleStatus->curButtonsPressed = gGameStatusPtr->pressedButtons[0] & inputBitmask2;
276 battleStatus->curButtonsHeld = gGameStatusPtr->heldButtons[0] & inputBitmask2;
277 battleStatus->stickX = gGameStatusPtr->stickX[0];
278 battleStatus->stickY = gGameStatusPtr->stickY[0];
279 }
280 }
281
282 get_stick_input_radial(&outAngle, &outMagnitude);
283 battleStatus->stickAngle = outAngle;
284 battleStatus->stickMagnitude = outMagnitude;
285 battleStatus->pushInputBuffer[battleStatus->inputBufferPos] = battleStatus->curButtonsPressed;
286 battleStatus->holdInputBuffer[battleStatus->inputBufferPos] = battleStatus->curButtonsDown;
287
288 battleStatus->inputBufferPos++;
289 if (battleStatus->inputBufferPos >= ARRAY_COUNT(battleStatus->pushInputBuffer)) {
290 battleStatus->inputBufferPos = 0;
291 }
292
293 if (battleStatus->preUpdateCallback != NULL) {
294 battleStatus->preUpdateCallback();
295 }
296
297 cond = TRUE;
298 if (battleStatus->waitForState == BATTLE_STATE_0 || battleStatus->waitForState != gBattleState) {
299 switch (gBattleState) {
301 case BATTLE_STATE_0:
302 return;
305 cond = FALSE;
306 break;
309 break;
312 break;
313 case BATTLE_STATE_9:
315 break;
318 break;
321 break;
324 break;
327 break;
330 break;
333 break;
336 break;
339 break;
342 break;
345 break;
348 break;
351 break;
354 break;
357 break;
360 break;
363 break;
366 break;
369 break;
372 break;
375 break;
378 break;
381 break;
384 break;
387 break;
388 case BATTLE_STATE_28:
390 break;
393 break;
396 break;
397 case BATTLE_STATE_34:
399 break;
402 break;
405 cond = FALSE;
406 break;
407 }
408 }
409
410 battleStatus->unk_90++;
411 if (battleStatus->unk_90 == 40) {
413 }
414
420
421 if (battleStatus->darknessMode != BTL_DARKNESS_STATE_LOCKED) {
422 u8 paramType;
423 f32 paramAmount;
424
425 get_screen_overlay_params(SCREEN_LAYER_BACK, &paramType, &paramAmount);
426
427 if (battleStatus->darknessMode > BTL_DARKNESS_STATE_NONE) {
429 if (partner == NULL) {
431 } else if (playerData->curPartner == PARTNER_WATT) {
432 paramAmount -= 10.0f;
433 if (paramAmount < 0.0f) {
434 paramAmount = 0.0f;
435 }
437 } else {
438 paramAmount += 10.0f;
439 if (paramAmount > 215.0f) {
440 paramAmount = 215.0f;
441 }
443 }
444 } else if (battleStatus->darknessMode < BTL_DARKNESS_STATE_NONE) {
445 paramAmount -= 10.0f;
446 if (paramAmount < 0.0f) {
447 paramAmount = 0.0f;
450 } else {
452 }
453 }
454
455 if (cond || D_802809F6 != -1) {
456 if (D_802809F6 == -1) {
458 u8 paramType;
459 f32 paramAmount;
460
461 get_screen_overlay_params(SCREEN_LAYER_FRONT, &paramType, &paramAmount);
462 if (paramType == (u8) OVERLAY_NONE) {
463 D_802809F6 = 0;
465 }
466 }
467 } else if (D_802809F6 == 255) {
470 }
471 } else {
472 D_802809F6 += 10;
473 if (D_802809F6 > 255) {
474 D_802809F6 = 255;
475 }
476
481 }
482 }
483 }
484}
void update_nonplayer_actor_shadows(void)
Definition 16C8E0.c:247
void get_stick_input_radial(f32 *angle, f32 *magnitude)
Definition 16C8E0.c:116
s16 D_802809F6
Definition 16C8E0.c:12
@ BTL_DARKNESS_STATE_LOCKED
Definition enums.h:6362
void btl_state_update_end_battle(void)
void btl_state_update_end_turn(void)
void btl_state_update_end_training_battle(void)
void btl_state_update_partner_menu(void)
void btl_state_update_prepare_menu(void)
void btl_state_update_end_player_turn(void)
void btl_state_update_enemy_move(void)
void btl_state_update_peach_menu(void)
void btl_state_update_first_strike(void)
void btl_state_update_enemy_striking_first(void)
void btl_state_update_celebration(void)
Definition level_up.c:488
void btl_state_update_22(void)
void btl_state_update_normal_start(void)
void update_damage_popups(void)
Definition 190B20.c:2320
void btl_state_update_begin_player_turn(void)
void btl_bonk_cleanup(void)
void btl_state_update_defeat(void)
void btl_state_update_next_enemy(void)
void btl_state_update_1C(void)
void btl_state_update_victory(void)
void btl_state_update_9(void)
void btl_state_update_partner_striking_first(void)
void btl_state_update_change_partner(void)
void btl_state_update_partner_move(void)
void btl_state_update_begin_partner_turn(void)
void btl_state_update_player_menu(void)
void btl_state_update_switch_to_player(void)
void update_health_bars(void)
Definition 190B20.c:2515
void btl_state_update_begin_turn(void)
void btl_popup_messages_update(void)
void btl_state_update_defend(void)
void get_screen_overlay_params(s32, u8 *type, f32 *zoom)
void update_action_ratings(void)
Definition 190B20.c:2443
void btl_state_update_end_partner_turn(void)
void btl_state_update_end_demo_battle(void)
void btl_state_update_player_move(void)
void btl_state_update_select_target(void)
void btl_state_update_run_away(void)
void btl_state_update_twink_menu(void)
void btl_state_update_switch_to_partner(void)
s32 holdInputBuffer[64]

Referenced by state_step_battle().

◆ update_item_entities()

void update_item_entities ( void )

Definition at line 824 of file item_entity.c.

824 {
825 ItemEntity* item;
826 f32 x, y, z, hitDepth;
827 s32 i;
828
830 return;
831 }
832
833 for (i = 0; i < MAX_ITEM_ENTITIES; i++) {
834 item = gCurrentItemEntities[i];
835
836 if (item != NULL && item->flags != 0) {
837 if (item->itemID == ITEM_COIN) {
838 if (rand_int(100) > 90) {
843 }
845 }
846
847 item_entity_update(item);
848
849 switch (item->spawnType) {
852 break;
856 break;
863 break;
866 break;
867 }
868
869 item = gCurrentItemEntities[i];
870 if (item != NULL) {
871 s32 xs, ys, zs;
872
873 switch (item->spawnType) {
879 xs = item->pos.x;
880 ys = item->pos.y;
881 zs = item->pos.z;
882
883 if (xs != item->lastPos.x || ys != item->lastPos.y || zs != item->lastPos.z) {
884 Shadow* shadow = get_shadow_by_index(item->shadowIndex);
885
886 x = item->pos.x;
887 y = item->pos.y + 12.0f;
888 z = item->pos.z;
889 hitDepth = 1000.0f;
890 npc_raycast_down_sides(COLLIDER_FLAG_IGNORE_NPC, &x, &y, &z, &hitDepth);
891
892 shadow->pos.x = x;
893 shadow->pos.y = y;
894 shadow->pos.z = z;
896 shadow->rot.y = 0.0f;
898 set_standard_shadow_scale(shadow, hitDepth * 0.5f);
899 }
900 break;
901 }
902 item->lastPos.x = item->pos.x;
903 item->lastPos.y = item->pos.y;
904 item->lastPos.z = item->pos.z;
905 }
906 }
907 }
908}
void update_item_entity_pickup(ItemEntity *)
void update_item_entity_collectable(ItemEntity *)
void update_item_entity_no_pickup(ItemEntity *)
void item_entity_update(ItemEntity *)
void update_item_entity_stationary(ItemEntity *)

Referenced by state_step_battle(), and state_step_world().

◆ restore_map_collision_data()

void restore_map_collision_data ( void )

Definition at line 135 of file collision.c.

135 {
136 CollisionData* collisionData;
137 Collider* collider;
138 ColliderBackupEntry* backupEntry;
139 s32 i;
140
142
143 collisionData = &gCollisionData;
144 for (i = 0, backupEntry = gCollisionDataBackup; i < collisionData->numColliders; i++, backupEntry++) {
145 collider = &collisionData->colliderList[i];
146 collider->flags = backupEntry->flags;
147 collider->parentModelIndex = backupEntry->parentModelIndex;
148
149 if (collider->flags != -1 && collider->flags & COLLIDER_FLAG_HAS_MODEL_PARENT) {
152 }
153 }
154
155 collisionData = &gZoneCollisionData;
156 for (i = 0, backupEntry = gCollisionDataZoneBackup; i < collisionData->numColliders; i++, backupEntry++) {
157 collider = &collisionData->colliderList[i];
158 collider->flags = backupEntry->flags;
159 collider->parentModelIndex = backupEntry->parentModelIndex;
160 }
161
164}
void load_map_hit_asset(void)
Definition collision.c:117
void update_collider_transform(s16 colliderID)
Definition collision.c:391
void parent_collider_to_model(s16 colliderID, s16 modelIndex)
Definition collision.c:320

Referenced by state_step_end_battle(), and state_step_unpause().

◆ mdl_load_all_textures()

void mdl_load_all_textures ( struct ModelNode * model,
s32 romOffset,
s32 size )

Definition at line 2322 of file model.c.

2322 {
2323 s32 baseOffset = 0;
2324
2325 // textures are loaded to the upper half of the texture heap when not in the world
2327 baseOffset = WORLD_TEXTURE_MEMORY_SIZE;
2328 }
2329
2330 TextureHeapPos = TextureHeapBase + baseOffset;
2331
2332 if (rootModel != NULL && romOffset != 0 && size != 0) {
2333 s32 i;
2334
2335 for (i = 0; i < ARRAY_COUNT(TextureHandles); i++) {
2336 TextureHandles[i].gfx = NULL;
2337 }
2338
2339 TreeIterPos = 0;
2340 if (rootModel != NULL) {
2341 load_next_model_textures(rootModel, romOffset, size);
2342 }
2343 }
2344}
TextureHandle TextureHandles[128]
Definition model.c:1355
void load_next_model_textures(ModelNode *model, s32 romOffset, s32 texSize)
Definition model.c:2299
Gfx * gfx
Definition model.h:120

Referenced by load_data_for_models(), state_init_file_select(), and state_step_end_battle().

◆ mdl_calculate_model_sizes()

void mdl_calculate_model_sizes ( void )

Definition at line 2455 of file model.c.

2455 {
2456 s32 i;
2457
2458 for (i = 0; i < ARRAY_COUNT(*gCurrentModels); i++) {
2459 Model* model = (*gCurrentModels)[i];
2460
2461 if (model != NULL) {
2463
2464 bb->halfSizeX = (bb->maxX - bb->minX) * 0.5;
2465 bb->halfSizeY = (bb->maxY - bb->minY) * 0.5;
2466 bb->halfSizeZ = (bb->maxZ - bb->minZ) * 0.5;
2468 }
2469 }
2470}

Referenced by state_step_end_battle(), and state_step_unpause().