6#include "sprite/player.h"
11#define WORLD_ENTITY_HEAP_BOTTOM (s32) WorldEntityHeapBottom
12#define WORLD_ENTITY_HEAP_BASE (s32) WorldEntityHeapBase
13#define entity_jan_iwa_VRAM (void*) entity_jan_iwa_VRAM
14#define entity_sbk_omo_VRAM (void*) entity_sbk_omo_VRAM
15#define entity_default_VRAM (void*) entity_default_VRAM
17#define WORLD_ENTITY_HEAP_BOTTOM 0x80250000
18#define WORLD_ENTITY_HEAP_BASE 0x80267FF0
19#define entity_jan_iwa_VRAM (void*) 0x802BAE00
20#define entity_sbk_omo_VRAM (void*) 0x802BAE00
21#define entity_default_VRAM (void*) 0x802BAE00
125 if (
entity->collisionTimer == 0) {
128 if (
entity->collisionFlags) {
132 entity->collisionTimer = 10;
139 if (
entity->collisionTimer == 0) {
144 }
else if (
entity->collisionTimer == 0) {
147 entity->collisionFlags = 0;
161 if (
entity->scriptDelay != 0) {
163 if (
entity->scriptDelay == 0) {
184 if (
entity->shadowIndex >= 0) {
211 if (shadow !=
NULL) {
242 s32* args =
entity->scriptReadPos;
255 entity->scriptReadPos = (s32*)*args;
262 entity->scriptReadPos = args;
267 entity->scriptDelay = *args++;
268 entity->updateScriptCallback = (s32 (*)(
Entity*)) *args++;
269 entity->scriptReadPos = args++;
279 entity->scriptReadPos = args;
286 entity->scriptReadPos = args++;
291 entity->scriptReadPos = args++;
295 entity->flags &= ~*args++;
296 entity->scriptReadPos = args++;
301 entity->scriptReadPos = args++;
306 entity->scriptReadPos = args++;
332 s32 alpha = (s32)data;
372 entity->virtualModelIndex,
379 entity->virtualModelIndex,
397 entity->virtualModelIndex,
430 if (shadow !=
NULL) {
434 if (shadow->
alpha <= 20) {
450 if (shadow->
alpha <= 20) {
574 return entity->blueprint->entityType;
591 if (
entity->shadowIndex >= 0) {
616 if (
entity->shadowIndex >= 0) {
631 (*gCurrentShadowListPtr)[shadowIndex] =
NULL;
685 switch (entityType) {
708 switch (entityType) {
768 entity->collisionTimer = 0;
832 (*gCurrentEntityListPtr)[i] =
NULL;
836 (*gCurrentShadowListPtr)[i] =
NULL;
921 if ((s32)
node->displayList != -1) {
927 if ((s32)
node->sibling != -1) {
933 if ((s32)
node->child != -1) {
939 if ((s32)
node->vtxList != -1) {
986 }
else if (
bp == blueprint) {
1015 entity->vertexSegment = 0xA;
1023 if (
totalSize + ((
bp->dma.end -
bp->dma.start) >> 2) > 0x5FFCU) {
1059 entity->vertexSegment = 0xA;
1097 if ((
totalLoaded + ((dmaList[0].end - dmaList[0].start) >> 2)) > 0x5FFCU) {
1102 if ((
totalLoaded + ((dmaList[1].end - dmaList[1].start) >> 2)) > 0x5FFCU) {
1153 if (
entity->blueprint->dma.start ==
entity->blueprint) {
1178 size = ((dmaList[0].
end - dmaList[0].
start) >> 2);
1179 size += ((dmaList[1].
end - dmaList[1].
start) >> 2);
1185 size = (
bp->dma.end -
bp->dma.start) >> 2;
1240 if (
bp->typeDataSize != 0) {
1245 entity->listIndex = listIndex;
1249 entity->scriptReadPos =
bp->updateEntityScript;
1251 entity->savedReadPos[0] =
bp->updateEntityScript;
1254 entity->collisionFlags = 0;
1255 entity->collisionTimer = 0;
1272 entity->virtualModelIndex = -1;
1273 entity->shadowIndex = -1;
1277 if (
bp->dma.start != 0) {
1280 if (
bp->renderCommandList !=
NULL) {
1292 switch (
bp->entityType) {
1302 if (
bp->fpInit !=
NULL) {
1307 return entity->listIndex;
1323 (*gCurrentShadowListPtr)[i] = shadow;
1327 shadow->
alpha = 128;
1336 if (
bp->animModelNode !=
NULL) {
1344 if (
bp->onCreateCallback !=
NULL) {
1345 bp->onCreateCallback(shadow);
1396 }
else if (mode == 1) {
1398 }
else if (mode == 2) {
1521 entity->shadowIndex = shadowIndex;
1525 return entity->shadowIndex;
1563 if (shadow !=
NULL) {
1572 if (
entity->alpha < 255) {
1633 entity->shadowPosY = 0.0f;
1648 entityID =
test_ray_entities(*x, *y, *z, 0.0f, -1.0f, 0.0f, &
hitX, &
hitY, &
hitZ, &
hitDepth, &
hitNx, &
hitNy, &
hitNz);
1654 colliderID =
test_ray_colliders(
COLLIDER_FLAG_IGNORE_PLAYER, *x, *y, *z, 0.0f, -1.0f, 0.0f, &
hitX, &
hitY, &
hitZ, &
hitDepth, &
hitNx,
1676 shadow->
scale.
x = 0.13 - (height / 2600.0f);
1678 shadow->
scale.
x = 0.12 - (height / 3600.0f);
1681 if (shadow->
scale.
x < 0.01) {
1689 shadow->
scale.
x = 0.13 - (height / 2600.0f);
1691 shadow->
scale.
x = 0.12 - (height / 3600.0f);
1694 if (shadow->
scale.
x < 0.01) {
1715 shadow->
scale.
x = 0.26f - (scale / 2600.0f);
1716 if (shadow->
scale.
x < 0.01) {
1719 shadow->
scale.
z = 0.13f - (scale / 2600.0f);
1720 if (shadow->
scale.
z < 0.01) {
1730 if (shadow->
scale.
x < 0.01) {
BSS s32 PopupMenu_SelectedIndex
struct WoodenCrateData * crate
s32(* EntityCallback)(struct Entity *)
struct HiddenPanelData * hiddenPanel
#define ASSERT(condition)
BSS ShadowList gBattleShadowList
Entity * get_entity_by_index(s32 index)
void render_shadows(void)
void update_entity_shadow_position(Entity *entity)
void update_shadows(void)
void render_entities(void)
BSS ShadowList * gCurrentShadowListPtr
s32 gLastCreatedEntityIndex
EntityList * get_entity_list(void)
void init_entity_data(void)
s32 create_entity_shadow(Entity *entity, f32 x, f32 y, f32 z)
BSS EntityList gBattleEntityList
BSS ShadowList gWorldShadowList
BSS EntityList * gCurrentEntityListPtr
void entity_reset_collision(Entity *entity)
s32 test_player_entity_aabb(Entity *entity)
void delete_entity(s32 entityIndex)
BSS s32 bEntityDataLoadedSize
#define WORLD_ENTITY_HEAP_BOTTOM
Shadow * get_shadow_by_index(s32 index)
void entity_free_static_data(EntityBlueprint *data)
s32 isAreaSpecificEntityDataLoaded
BSS EntityBlueprint * bEntityBlueprint[4]
s32 entity_start_script(Entity *entity)
void func_8010FD98(void *arg0, s32 alpha)
void update_entity_transform_matrix(Entity *entity)
void load_simple_entity_data(Entity *entity, EntityBlueprint *bp, s32 listIndex)
void clear_entity_data(b32 arg0)
void entity_swizzle_anim_pointers(EntityBlueprint *entityData, void *baseAnim, void *baseGfx)
void update_entities(void)
void update_entity_inverse_rotation_matrix(Entity *entity)
s32 entity_try_partner_interaction_trigger(s32 entityIdx)
#define WORLD_ENTITY_HEAP_BASE
void load_area_specific_entity_data(void)
s32 CreateEntityVarArgBuffer[4]
void entity_model_set_shadow_color(void *data)
void set_entity_commandlist(Entity *entity, s32 *entityScript)
b32 entity_raycast_down(f32 *x, f32 *y, f32 *z, f32 *hitYaw, f32 *hitPitch, f32 *hitLength)
Mostly used for shadows.
BSS s32 wEntityDataLoadedSize
s32 step_entity_commandlist(Entity *entity)
s32 entity_get_collision_flags(Entity *entity)
void exec_entity_commandlist(Entity *entity)
void set_peach_shadow_scale(Shadow *shadow, f32 scale)
s32 create_shadow_type(s32 type, f32 x, f32 y, f32 z)
void delete_entity_and_unload_data(s32 entityIndex)
void reload_world_entity_data(void)
void update_shadow_transform_matrix(Shadow *shadow)
void delete_shadow(s32 shadowIndex)
BSS EntityList gWorldEntityList
void load_split_entity_data(Entity *entity, EntityBlueprint *entityData, s32 listIndex)
s32 func_80111790(EntityBlueprint *data)
s32 create_shadow_from_data(ShadowBlueprint *bp, f32 x, f32 y, f32 z)
Addr BattleEntityHeapBottom
BSS EntityBlueprint * wEntityBlueprint[MAX_ENTITIES+2]
void func_8010FE44(void *arg0)
void entity_set_render_script(Entity *entity, EntityModelScript *cmdList)
u32 get_entity_type(s32 index)
void set_npc_shadow_scale(Shadow *shadow, f32 height, f32 npcRadius)
s32 create_entity(EntityBlueprint *bp,...)
s32 is_entity_data_loaded(Entity *entity, EntityBlueprint *blueprint, s32 *loadedStart, s32 *loadedEnd)
s32 is_block_on_ground(Entity *block)
s32 is_player_action_state(s8 actionState)
HiddenPanelsData gCurrentHiddenPanels
void set_standard_shadow_scale(Shadow *shadow, f32 height)
ShadowList * get_shadow_list(void)
s32 load_entity_model(EntityModelScript *cmdList)
ShadowBlueprint SquareShadow
ShadowBlueprint CircularShadowB
void set_entity_model_render_command_list(s32 idx, EntityModelScript *cmdList)
EntityModel * get_entity_model(s32 idx)
ShadowBlueprint CircularShadowA
@ ENTITY_SCRIPT_OP_PlaySound
@ ENTITY_SCRIPT_OP_RestartBoundScript
@ ENTITY_SCRIPT_OP_ClearFlags
@ ENTITY_SCRIPT_OP_SetFlags
@ ENTITY_SCRIPT_OP_SetCallback
@ SHADOW_FIXED_ALT_CIRCLE
@ SHADOW_VARYING_ALT_CIRCLE
@ COLLIDER_FLAG_IGNORE_PLAYER
@ ENTITY_TYPE_HAMMER1_BLOCK
@ ENTITY_TYPE_MUNCHLESIA_ENVELOP
@ ENTITY_TYPE_SINGLE_TRIGGER_BLOCK
@ ENTITY_TYPE_SCRIPT_SPRING
@ ENTITY_TYPE_MUNCHLESIA_CHEWING
@ ENTITY_TYPE_MUNCHLESIA_BEGIN_CHEW
@ ENTITY_TYPE_MUNCHLESIA_RESET2
@ ENTITY_TYPE_BOMBABLE_ROCK
@ ENTITY_TYPE_HIDDEN_RED_BLOCK
@ ENTITY_TYPE_SUPER_BLOCK
@ ENTITY_TYPE_HEALING_BLOCK
@ ENTITY_TYPE_BLUE_SWITCH
@ ENTITY_TYPE_MUNCHLESIA_GRAB
@ ENTITY_TYPE_MUNCHLESIA_SPIT_OUT
@ ENTITY_TYPE_MULTI_COIN_BRICK
@ ENTITY_TYPE_SIMPLE_SPRING
@ ENTITY_TYPE_RESET_MUNCHLESIA
@ ENTITY_TYPE_BRICK_BLOCK
@ ENTITY_TYPE_HIDDEN_YELLOW_BLOCK
@ ENTITY_TYPE_MULTI_TRIGGER_BLOCK
@ ENTITY_TYPE_HAMMER1_BLOCK_TINY
@ ENTITY_TYPE_MUNCHLESIA_RESET1
@ ENTITY_TYPE_YELLOW_BLOCK
@ ENTITY_TYPE_STAR_BOX_LAUNCHER
@ ENTITY_COLLISION_PARTNER
@ ENTITY_COLLISION_PLAYER_HAMMER
@ ENTITY_COLLISION_PLAYER_TOUCH_WALL
@ ENTITY_COLLISION_PLAYER_TOUCH_FLOOR
@ ENTITY_COLLISION_PLAYER_TOUCH_CEILING
@ ENTITY_COLLISION_PLAYER_PUSHING_AGAINST
@ ENTITY_COLLISION_PLAYER_LAST_FLOOR
@ ENTITY_FLAG_DETECTED_COLLISION
@ ENTITY_FLAG_CONTINUOUS_COLLISION
@ ENTITY_FLAG_IGNORE_DISTANCE_CULLING
@ ENTITY_FLAG_HAS_ANIMATED_MODEL
@ ENTITY_FLAG_DARK_SHADOW
@ ENTITY_FLAG_SHADOW_POS_DIRTY
@ ENTITY_FLAG_DRAW_IF_CLOSE_HIDE_MODE2
@ ENTITY_FLAG_DRAW_IF_CLOSE_HIDE_MODE1
@ ENTITY_FLAG_HAS_DYNAMIC_SHADOW
@ ENTITY_FLAG_PARTNER_COLLISION
@ ENTITY_FLAG_FIXED_SHADOW_SIZE
@ ENTITY_FLAG_BOUND_SCRIPT_DIRTY
@ ENTITY_FLAG_SKIP_UPDATE_TRANSFORM_MATRIX
@ ENTITY_FLAG_SKIP_UPDATE
@ ENTITY_FLAG_PENDING_INSTANCE_DELETE
@ ENTITY_FLAG_DISABLE_COLLISION
@ ENTITY_FLAG_ALWAYS_FACE_CAMERA
@ ENTITY_FLAG_FADING_AWAY
@ ENTITY_FLAG_PENDING_FULL_DELETE
@ ENTITY_FLAG_CIRCULAR_SHADOW
@ EVT_FLAG_RUN_IMMEDIATELY
don't wait for next update_scripts call
s32 evt_get_variable_index(Evt *script, s32 var)
s32 evt_get_variable(Evt *script, Bytecode var)
void draw_entity_model_A(s32, Mtx *)
void draw_entity_model_B(s32, Mtx *, s32, Vec3s *)
u32 dma_copy(Addr romStart, Addr romEnd, void *vramDest)
void exec_entity_model_commandlist(s32 idx)
f32 dist2D(f32 ax, f32 ay, f32 bx, f32 by)
Evt * start_script(EvtScript *source, s32 priority, s32 initialState)
void load_mesh_animator_tree(s32 index, StaticAnimatorNode **tree)
s32 create_model_animator(s16 *animPos)
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 bind_entity_model_setupGfx(s32 idx, void *setupGfxCallbackArg0, void(*fpSetupGfxCallback)(void *))
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 does_script_exist(s32 id)
s32 create_mesh_animator(s16 *animPos, s16 *animBuffer)
s8 get_current_partner_id(void)
void free_entity_model_by_index(s32 idx)
void load_model_animator_tree(s32, StaticAnimatorNode **)
void * heap_malloc(s32 size)
BSS u8 WorldEntityHeapBase[0x10]
void render_animated_model_with_vertices(s32 animatorID, Mtx *rootTransform, s32 segment, void *baseAddr)
ModelAnimator * set_animator_render_callback(s32 animModelID, void *callbackArg, void(*callbackFunc)(void *))
void render_animated_model(s32 animatorID, Mtx *rootTransform)
void delete_model_animator(ModelAnimator *animator)
ModelAnimator * get_animator_by_index(s32 animModelID)
void update_model_animator(s32)
void sfx_play_sound(s32 soundID)
ApiStatus AssignCrateFlag(Evt *script, b32 isInitialCall)
ApiStatus AssignChestFlag(Evt *script, b32 isInitialCall)
ApiStatus SetEntityCullMode(Evt *script, b32 isInitialCall)
ApiStatus UseDynamicShadow(Evt *script, b32 isInitialCall)
ApiStatus AssignBlockFlag(Evt *script, b32 isInitialCall)
ApiStatus AssignSwitchFlag(Evt *script, b32 isInitialCall)
ApiStatus AssignPanelFlag(Evt *script, b32 isInitialCall)
ApiStatus AssignScript(Evt *script, b32 isInitialCall)
ApiStatus MakeEntity(Evt *script, b32 isInitialCall)
Creates an entity.
#define DMA_COPY_SEGMENT(segment)
#define COLLISION_WITH_ENTITY_BIT
void(* fpSetupGfxCallback)(void *)
EvtScript * boundScriptBytecode
u8 Addr[]
Linker symbol address, as in ld_addrs.h.
PlayerStatus * gPlayerStatusPtr
CollisionStatus gCollisionStatus
GameStatus * gGameStatusPtr
PlayerStatus gPlayerStatus
s32 get_area_flag(s32 index)