Skip to content

npc.h

QuizRequirement

struct QuizRequirement source
Fields

requiredStoryProgress: s32

numQuestionsUnlocked: s32

NpcBlueprint

struct NpcBlueprint source
Fields

flags: s32

initialAnim: s32

onUpdate: void (*)(struct Npc *)

onRender: void (*)(struct Npc *)

MobileAISettings

struct MobileAISettings source
Fields

moveSpeed: f32

moveTime: s32

waitTime: s32

alertRadius: f32

alertOffsetDist: f32

playerSearchInterval: s32

chaseSpeed: f32

chaseTurnRate: s32

chaseUpdateInterval: s32

chaseRadius: f32

chaseOffsetDist: f32

GuardAISettings

struct GuardAISettings source
Fields

alertRadius: f32

alertOffsetDist: f32

playerSearchInterval: s32

chaseSpeed: f32

chaseTurnRate: s32

chaseUpdateInterval: s32

chaseRadius: f32

chaseOffsetDist: f32

FireBarCallback

typedef FireBarCallback source

FireBarAISettings

struct FireBarAISettings source
Fields

centerPos: Vec3i

rotRate: s32

firstNpc: s32

npcCount: s32

callback: FireBarCallback

FireBarData

struct FireBarData source
Fields

flags: s32

centerPos: Vec3f

rotRate: f32

firstNpc: s32

npcCount: s32

callback: FireBarCallback

soundIndex: s32

lastDeltaYaw: f32

yaw: f32

settings: FireBarAISettings*

NpcSettings

struct NpcSettings source
Fields

defaultAnim: u32

height: s16

radius: s16

otherAI: void*

onInteract: EvtScript*

ai: EvtScript*

onHit: EvtScript*

aux: EvtScript*

onDefeat: EvtScript*

flags: s32

level: s16

actionFlags: s16

ItemDrop

struct ItemDrop source
Fields

item: s16

weight: s16

flagIdx: s16

StatDrop

struct StatDrop source

Describes heart/flower drop chances after defeating an Npc in the overworld.

The algorithm for calculating the number of hearts/flowers from a StatDrop is:

  • If current HP/FP > cutoff, drop 0.
  • Roll generalChance. If it fails, drop 0.
  • Roll chancePerAttempt attempts times. For each success, drop a heart/flower.

NpcData holds a table of StatDrops for each stat (hearts, flowers). All are checked together and the number of hearts/flowers to drop is the total number of successful attempts for each stat.

Each heart/flower is worth 1 HP and 1 FP respectively, if picked up.

cutoff, generalChance, and chancePerAttempt are short fixed-point percentage values. That is, F16(0) is a 0% chance and F16(100) is a 100% chance.

Fields

cutoff: s16% of max HP/FP. If current HP/FP > cutoff, no hearts/flowers can be dropped.

generalChance: s16% chance for any hearts/flowers to be dropped at all from this StatDrop.

attempts: s16Maximum number of hearts/flowers that can be dropped from this StatDrop.

chancePerAttempt: s16% chance for a single heart/flower to be dropped from each attempt.

EnemyDrops

struct EnemyDrops source
Fields

dropFlags: u8

itemDropChance: u8

itemDrops: ItemDrop [8];

heartDrops: StatDrop [8];

flowerDrops: StatDrop [8];

minCoinBonus: s16

maxCoinBonus: s16

TerritoryShape

enum TerritoryShape source

EnemyDetectVolume

struct EnemyDetectVolume source
Fields

skipPlayerDetectChance: s32

shape: enumTerritoryShape

pointX: s32

pointZ: s32

sizeX: s32

sizeZ: s32

halfHeight: f32

detectFlags: s16

EnemyTerritoryWander

struct EnemyTerritoryWander source
Fields

centerPos: Vec3i

wanderSize: VecXZi

moveSpeedOverride: s32

wanderShape: enumTerritoryShape

detectPos: Vec3i

detectSize: VecXZi

detectShape: enumTerritoryShape

isFlying: s32

EnemyTerritoryPatrol

struct EnemyTerritoryPatrol source
Fields

numPoints: s32

points: Vec3i [10];

moveSpeedOverride: s32

detectPos: Vec3i

detectSize: VecXZi

detectShape: enumTerritoryShape

isFlying: s32

EnemyTerritory

EnemyTerritory source

wander

patrol

PADDING

NpcInitialVars

NpcInitialVars source

value

bytes

array

NpcData

struct NpcData source
Fields

id: s32

settings: NpcSettings*

pos: Vec3f

flags: s32

init: EvtScript*

initVarCount: s32

initVar: NpcInitialVars

yaw: s32

drops: EnemyDrops

territory: EnemyTerritory

animations: struct { ... }

aiDetectFlags: u8

aiFlags: u32

extraAnimations: u32*

tattle: s32

NpcGroup

struct NpcGroup source

Zero-terminated.

Fields

npcCount: s32

npcs: NpcData*

battle: s16

stage: s16

NpcGroupList

typedef NpcGroupList source

AIStateHandler

typedef AIStateHandler source

Enemy

struct Enemy source
Fields

flags: s32

encounterIndex: s8

encountered: s8

scriptGroup: u8

hitboxIsActive: s8

npcID: s16

spawnPos: s16 [3];

npcSettings: NpcSettings*

initBytecode: EvtScript*

interactBytecode: EvtScript*

aiBytecode: EvtScript*

hitBytecode: EvtScript*

auxBytecode: EvtScript*

defeatBytecode: EvtScript*

initScript: structEvt*

interactScript: structEvt*

aiScript: structEvt*

hitScript: structEvt*

auxScript: structEvt*

defeatScript: structEvt*

initScriptID: s32

interactScriptID: s32

aiScriptID: s32

hitScriptID: s32

auxScriptID: s32

defeatScriptID: s32

varTable: s32 [16];

varTableF: f32 [16];

varTablePtr: void* [16];

aiDetectFlags: u8

aiFlags: u32

aiSuspendTime: s8

instigatorValue: s8

animList: s32*

territory: EnemyTerritory*

drops: EnemyDrops*

tattleMsg: u32

savedNpcYaw: s16

Encounter

struct Encounter source
Fields

count: s32

enemy: Enemy* [16];

battle: s16

stage: s16

encounterID: s16

FieldStatus

struct FieldStatus source
Fields

status: s8

duration: s16

EncounterStatus

struct EncounterStatus source
Fields

flags: s32

firstStrikeType: s8

hitType: s8

hitTier: s8

battleOutcome: s8

battleTriggerCooldown: s8set to 15 after victory, 45 after fleeing

hasMerleeCoinBonus: s8

damageTaken: u8

coinsEarned: s16

instigatorValue: s8

forbidFleeing: s8

scriptedBattle: s8battle started by StartBattle but not by encounter

dropWhackaBump: s8

songID: s32

numEncounters: s8

curAreaIndex: s8

curMapIndex: u8

curEntryIndex: u8

mapID: s8

resetMapEncounterFlags: s8

npcGroupList: s32*

encounterList: Encounter* [24];

curEncounter: Encounter*

curEnemy: Enemy*

fadeOutAmount: s32

substateDelay: s32

fadeOutAccel: s32

battleStartCountdown: s32

dizzyAttack: FieldStatus

unusedAttack1: FieldStatus

unusedAttack2: FieldStatus

unusedAttack3: FieldStatus

defeatFlags: s32 [60][12];

recentMaps: s16 [2];

gCurrentEncounter

extern EncounterStatus gCurrentEncounter source

basic_ai_check_player_dist

s32 basic_ai_check_player_dist( EnemyDetectVolume* arg0, Enemy* arg1, f32 arg2, f32 arg3, s8 arg4 ) source

STUB_npc_callback

void STUB_npc_callback(Npc*) source

The default Npc::onUpdate and Npc::onRender callback.

mtx_ident_mirror_y

void mtx_ident_mirror_y(Matrix4f mtx) source

clear_npcs

void clear_npcs() source

init_npc_list

void init_npc_list() source

Points the current NPC list to the world or battle lists depending on game state.

create_npc_impl

s32 create_npc_impl( NpcBlueprint* blueprint, u32* animList, s32 skipLoadingAnims ) source

create_basic_npc

s32 create_basic_npc(NpcBlueprint* blueprint) source

create_standard_npc

s32 create_standard_npc( NpcBlueprint* blueprint, u32* animList ) source

create_peach_npc

s32 create_peach_npc(NpcBlueprint* blueprint) source

free_npc_by_index

void free_npc_by_index(s32 listIndex) source

free_npc

void free_npc(Npc* npc) source

get_npc_by_index

Npc* get_npc_by_index(s32 listIndex) source

npc_do_world_collision

void npc_do_world_collision(Npc* npc) source

npc_do_other_npc_collision

void npc_do_other_npc_collision(Npc* npc) source

npc_do_player_collision

s32 npc_do_player_collision(Npc* npc) source

Returns true if a collision occurred.

npc_try_apply_gravity

void npc_try_apply_gravity(Npc* npc) source

npc_try_snap_to_ground

s32 npc_try_snap_to_ground(Npc* npc, f32 velocity) source

update_npcs

void update_npcs() source

Updates all NPCs.

npc_get_render_yaw

f32 npc_get_render_yaw(Npc* npc) source

appendGfx_npc

void appendGfx_npc(void* data) source

render_npcs

void render_npcs() source

Renders all NPCs.

npc_move_heading

void npc_move_heading(Npc* npc, f32 speed, f32 yaw) source

get_npc_unsafe

Npc* get_npc_unsafe(s32 npcID) source

get_npc_safe

Npc* get_npc_safe(s32 npcID) source

Returns nullptr if not found.

enable_npc_shadow

void enable_npc_shadow(Npc* npc) source

disable_npc_shadow

void disable_npc_shadow(Npc* npc) source

update_npc_blur

void update_npc_blur(Npc* npc) source

appendGfx_npc_blur

void appendGfx_npc_blur(void* npc) source

npc_enable_collisions

void npc_enable_collisions() source

npc_disable_collisions

void npc_disable_collisions() source

func_8003B1A8

void func_8003B1A8() source

npc_reload_all

void npc_reload_all() source

set_npc_yaw

void set_npc_yaw(Npc* npc, f32 yaw) source

npc_set_palswap_mode_A

void npc_set_palswap_mode_A(Npc* npc, s32 arg1) source

npc_set_palswap_mode_B

void npc_set_palswap_mode_B(Npc* npc, s32 arg1) source

npc_revert_palswap_mode

void npc_revert_palswap_mode(Npc* npc) source

npc_set_palswap_1

void npc_set_palswap_1( Npc* npc, s32 palIndexA, s32 palIndexB, s32 timeHoldA, s32 timeAB ) source

npc_set_palswap_2

void npc_set_palswap_2( Npc* npc, s32 timeHoldB, s32 timeBA, s32 palIndexC, s32 palIndexD ) source

npc_draw_with_palswap

void npc_draw_with_palswap(Npc* npc, s32 arg1, Matrix4f mtx) source

npc_render_without_adjusted_palettes

void npc_render_without_adjusted_palettes( Npc* npc, s32 arg1, Matrix4f mtx ) source

npc_render_with_watt_idle_palettes

void npc_render_with_watt_idle_palettes( Npc*, s32 , Matrix4f mtx ) source

npc_blend_palette_colors

u16 npc_blend_palette_colors( u16 colorA, u16 colorB, s32 lerpAlpha ) source

npc_render_with_single_pal_blending

void npc_render_with_single_pal_blending( Npc*, s32 , s32 , Matrix4f mtx ) source

npc_render_with_double_pal_blending

void npc_render_with_double_pal_blending( Npc*, s32 , Matrix4f mtx ) source

npc_set_decoration

void npc_set_decoration( Npc* npc, s32 idx, s32 decorationType ) source

npc_remove_decoration

void npc_remove_decoration(Npc* npc, s32 idx) source

npc_update_decorations

void npc_update_decorations(Npc* npc) source

npc_reset_current_decoration

void npc_reset_current_decoration(Npc* npc, s32 idx) source

npc_update_decoration_none

void npc_update_decoration_none(Npc* npc, s32 idx) source

npc_remove_decoration_none

void npc_remove_decoration_none(Npc* npc, s32 idx) source

npc_update_decoration_bowser_aura

void npc_update_decoration_bowser_aura(Npc* npc, s32 idx) source

npc_remove_decoration_bowser_aura

void npc_remove_decoration_bowser_aura(Npc* npc, s32 idx) source

npc_update_decoration_sweat

void npc_update_decoration_sweat(Npc* npc, s32 idx) source

npc_remove_decoration_sweat

void npc_remove_decoration_sweat(Npc* npc, s32 idx) source

npc_update_decoration_seeing_stars

void npc_update_decoration_seeing_stars(Npc* npc, s32 idx) source

npc_remove_decoration_seeing_stars

void npc_remove_decoration_seeing_stars(Npc* npc, s32 idx) source

npc_update_decoration_glow_in_front

void npc_update_decoration_glow_in_front(Npc* npc, s32 idx) source

npc_remove_decoration_glow_in_front

void npc_remove_decoration_glow_in_front(Npc* npc, s32 idx) source

npc_update_decoration_glow_behind

void npc_update_decoration_glow_behind(Npc* npc, s32 idx) source

npc_remove_decoration_glow_behind

void npc_remove_decoration_glow_behind(Npc* npc, s32 idx) source

npc_update_decoration_charged

void npc_update_decoration_charged(Npc* npc, s32 idx) source

npc_remove_decoration_charged

void npc_remove_decoration_charged(Npc* npc, s32 idx) source

npc_find_closest

Npc* npc_find_closest(f32 x, f32 y, f32 z, f32 radius) source

Finds the closest NPC to a given point within radius. Ignores Y position.

NPCs with NPC_FLAG_PARTNER set are ignored. See also npc_find_closest_simple, which requires that NPC_FLAG_PARTNER be set.

Returns nullptr if there are no NPCs within radius.

npc_find_closest_simple

Npc* npc_find_closest_simple( f32 x, f32 y, f32 z, f32 radius ) source

Finds the closest simple-hitbox NPC to a given point within radius. Ignores Y position.

Only NPCs with NPC_FLAG_PARTNER set are considered. See also npc_find_closest, which requires that NPC_FLAG_PARTNER be unset.

Returns nullptr if there are no NPCs within radius.

npc_get_collider_below

s32 npc_get_collider_below(Npc* npc) source

npc_imgfx_update

void npc_imgfx_update(Npc* npc) source

npc_set_imgfx_params

void npc_set_imgfx_params( Npc* npc, s32 arg1, s32 arg2, s32 arg3, s32 arg4, s32 arg5, s32 arg6 ) source

npc_surface_spawn_fx

void npc_surface_spawn_fx( Npc* npc, SurfaceInteractMode mode ) source

spawn_default_surface_effects

void spawn_default_surface_effects( Npc* npc, SurfaceInteractMode mode ) source

spawn_flower_surface_effects

void spawn_flower_surface_effects( Npc* npc, SurfaceInteractMode mode ) source

spawn_cloud_surface_effects

void spawn_cloud_surface_effects( Npc* npc, SurfaceInteractMode mode ) source

spawn_snow_surface_effects

void spawn_snow_surface_effects( Npc* npc, SurfaceInteractMode mode ) source

spawn_hedge_surface_effects

void spawn_hedge_surface_effects( Npc* npc, SurfaceInteractMode mode ) source

spawn_water_surface_effects

void spawn_water_surface_effects( Npc* npc, SurfaceInteractMode mode ) source

COPY_set_defeated

void COPY_set_defeated(s32 mapID, s32 encounterID) source

Duplicate of set_defeated().

init_encounter_status

void init_encounter_status() source

clear_encounter_status

void clear_encounter_status() source

func_8003E50C

void func_8003E50C() source

func_8003E514

void func_8003E514(s8 arg0) source

update_encounters

void update_encounters() source

draw_encounter_ui

void draw_encounter_ui() source

draw_first_strike_ui

void draw_first_strike_ui() source

npc_render_worker_do_nothing

void npc_render_worker_do_nothing() source

make_npcs

void make_npcs(s32 flags, s32 mapID, s32* npcGroupList) source

kill_encounter

void kill_encounter(Enemy* enemy) source

kill_enemy

void kill_enemy(Enemy* enemy) source

bind_enemy_ai

s32 bind_enemy_ai(Enemy* enemy, EvtScript* aiScriptBytecode) source

Binds the specified AI script to the specified enemy.

bind_enemy_aux

s32 bind_enemy_aux( Enemy* enemy, EvtScript* auxScriptBytecode ) source

Binds the specified auxiliary script to the specified enemy.

bind_enemy_interact

s32 bind_enemy_interact( Enemy* enemy, EvtScript* interactScriptBytecode ) source

Binds the specified interact script to the specified enemy.

bind_npc_ai

void bind_npc_ai(s32 npcID, EvtScript* npcAiBytecode) source

Binds the specified AI script to the NPC matching npcID.

bind_npc_aux

void bind_npc_aux(s32 npcID, EvtScript* npcAuxBytecode) source

Binds the specified auxiliary script to the NPC matching npcID.

bind_npc_interact

void bind_npc_interact( s32 npcID, EvtScript* npcInteractBytecode ) source

Binds the specified interact script to the NPC matching npcID.

get_enemy

Enemy* get_enemy(s32 npcID) source

Looks for an enemy matching the specified npcID, which is the ID of the NPC bound to the desired enemy. Returns a pointer to the Enemy struct if one is found. If one is not found, a panic occurs.

get_enemy_safe

Enemy* get_enemy_safe(s32 npcID) source

Same as get_enemy(), except it always returns a value. Takes npcID, the ID of the NPC bound to the desired enemy. Returns a pointer to the Enemy struct if one is found, or nullptr otherwise.

set_npc_sprite

void set_npc_sprite(Npc* npc, s32 anim, u32* extraAnimList) source