Paper Mario DX
Paper Mario (N64) modding
 
Loading...
Searching...
No Matches
item_entity.c File Reference

Go to the source code of this file.

Macros

#define MAX_ITEM_ENTITIES   256
 
#define WD_VAR1   54
 
#define WD_VAR2   30
 
#define WD_VAR3   30
 
#define X_VAR1   20
 
#define HT_VAR1   height
 
#define WD_VAR4   280
 
#define X_PICKUP_ITEM_1   15
 
#define X_PICKUP_ITEM_2   40
 
#define X_PICKUP_THREW   40
 
#define Y_PICKUP_ITEM_1   offsetY
 
#define Y_PICKUP_ITEM_2   offsetY
 
#define Y_PICKUP_THREW   4
 

Functions

void item_entity_update (ItemEntity *)
 
void appendGfx_item_entity (void *)
 
void draw_item_entities (void)
 
void draw_ui_item_entities (void)
 
s32 test_item_player_collision (ItemEntity *)
 
void update_item_entity_collectable (ItemEntity *)
 
void draw_ui_item_entity_collectable (ItemEntity *)
 
void update_item_entity_stationary (ItemEntity *)
 
void draw_ui_item_entity_stationary (ItemEntity *)
 
void update_item_entity_no_pickup (ItemEntity *)
 
void draw_ui_item_entity_no_pickup (ItemEntity *)
 
void func_801363A0 (ItemEntity *)
 
void update_item_entity_pickup (ItemEntity *)
 
void draw_content_pickup_item_header (ItemEntity *item, s32 posX, s32 posY)
 
void draw_content_cant_carry_more (ItemEntity *item, s32 posX, s32 posY)
 
void draw_content_pickup_item_desc (ItemEntity *item, s32 posX, s32 posY)
 
void sparkle_script_init (ItemEntity *item, SparkleScript *script)
 
s32 sparkle_script_step (ItemEntity *item)
 
void sparkle_script_update (ItemEntity *item)
 
void draw_coin_sparkles (ItemEntity *item)
 
ItemEntityget_item_entity (s32 itemEntityIndex)
 
void hide_item_entity (ItemEntity *item)
 
void reveal_item_entity (ItemEntity *item)
 
void clear_item_entity_data (void)
 
void init_item_entity_list (void)
 
void item_entity_load (ItemEntity *item)
 
s32 make_item_entity (s32 itemID, f32 x, f32 y, f32 z, s32 itemSpawnMode, s32 pickupDelay, s32 angle, s32 pickupFlagIndex)
 
s32 make_item_entity_nodelay (s32 itemID, f32 x, f32 y, f32 z, s32 itemSpawnMode, s32 pickupVar)
 
s32 make_item_entity_delayed (s32 itemID, f32 x, f32 y, f32 z, s32 itemSpawnMode, s32 pickupDelay, s32 pickupVar)
 
s32 make_item_entity_at_player (s32 itemID, s32 category, s32 pickupMsgFlags)
 
void update_item_entities (void)
 
void render_item_entities (void)
 
void remove_item_entity_by_reference (ItemEntity *entity)
 
void remove_item_entity_by_index (s32 index)
 
void func_80133A94 (s32 idx, s32 itemID)
 
s32 test_item_entity_position (f32 x, f32 y, f32 z, f32 dist)
 
void set_item_entity_flags (s32 index, s32 flags)
 
void clear_item_entity_flags (s32 index, s32 flags)
 
void auto_collect_item_entity (s32 index)
 
b32 is_picking_up_item (void)
 
void set_item_entity_position (s32 itemEntityIndex, f32 x, f32 y, f32 z)
 
void set_current_item_entity_render_group (s32 group)
 
s32 get_current_item_entity_render_group (void)
 

Variables

SparkleScript SparkleScript_Coin
 
Gfx Gfx_RM1_ALPHATEST []
 
Gfx Gfx_RM2_ALPHATEST []
 
Lights1 ItemEntityLights = gdSPDefLights1(255, 255, 255, 0, 0, 0, 0, 0, 0)
 
HudCacheEntrygHudElementCacheTableRaster
 
HudCacheEntrygHudElementCacheTablePalette
 
u8 * gHudElementCacheBuffer
 
s32 * gHudElementCacheSize
 
s32 ItemEntitiesCreated
 
BSS s32 UnusedItemPhysicsScriptID
 
BSS s32 ItemEntityAlternatingSpawn
 
BSS s32 ItemEntityRenderGroup
 
BSS s16 CoinSparkleCenterX
 
BSS s16 CoinSparkleCenterY
 
BSS s16 CoinSparkleCenterZ
 
BSS s32 pad_ItemEntity [3]
 
BSS ItemEntityWorldItemEntities [256]
 
BSS ItemEntityBattleItemEntities [256]
 
BSS ItemEntity ** gCurrentItemEntities
 
BSS s16 isPickingUpItem
 
BSS s16 ItemSpawnWithinPlayerPickupDelay
 
BSS s16 D_801565A8
 
BSS PopupMenu ItemPickupMenu
 
BSS s32 ItemPickupIconID
 
BSS s32 ItemPickupStateDelay
 
BSS s32 ThrowAwayMenuIdx
 
BSS s32 ThrowAwayItemID
 
BSS EffectInstanceItemPickupGotOutline
 
BSS MessagePrintStateGotItemTutorialPrinter
 
BSS b32 GotItemTutorialClosed
 
Vtx D_8014C5A0 [4]
 
Vtx D_8014C5E0 [4]
 
Gfx D_8014C620 []
 
Gfx D_8014C678 []
 
Gfx D_8014C6A0 []
 
s16 PickupHeaderWindowHeight [] = { 32, 40 }
 
s16 PickupMessageWindowYOffsets [] = { 8, 4 }
 
s32 * gItemEntityScripts []
 

Macro Definition Documentation

◆ MAX_ITEM_ENTITIES

◆ WD_VAR1

#define WD_VAR1   54

Definition at line 2485 of file item_entity.c.

Referenced by func_801363A0().

◆ WD_VAR2

#define WD_VAR2   30

Definition at line 2486 of file item_entity.c.

Referenced by func_801363A0().

◆ WD_VAR3

#define WD_VAR3   30

Definition at line 2487 of file item_entity.c.

Referenced by func_801363A0().

◆ X_VAR1

#define X_VAR1   20

Definition at line 2488 of file item_entity.c.

Referenced by func_801363A0().

◆ HT_VAR1

#define HT_VAR1   height

Definition at line 2489 of file item_entity.c.

Referenced by func_801363A0().

◆ WD_VAR4

#define WD_VAR4   280

Definition at line 2490 of file item_entity.c.

Referenced by func_801363A0().

◆ X_PICKUP_ITEM_1

#define X_PICKUP_ITEM_1   15

Definition at line 2610 of file item_entity.c.

Referenced by draw_content_pickup_item_header().

◆ X_PICKUP_ITEM_2

#define X_PICKUP_ITEM_2   40

Definition at line 2611 of file item_entity.c.

Referenced by draw_content_pickup_item_header().

◆ X_PICKUP_THREW

#define X_PICKUP_THREW   40

Definition at line 2612 of file item_entity.c.

Referenced by draw_content_pickup_item_header().

◆ Y_PICKUP_ITEM_1

#define Y_PICKUP_ITEM_1   offsetY

Definition at line 2613 of file item_entity.c.

Referenced by draw_content_pickup_item_header().

◆ Y_PICKUP_ITEM_2

#define Y_PICKUP_ITEM_2   offsetY

Definition at line 2614 of file item_entity.c.

Referenced by draw_content_pickup_item_header().

◆ Y_PICKUP_THREW

#define Y_PICKUP_THREW   4

Definition at line 2615 of file item_entity.c.

Referenced by draw_content_pickup_item_header().

Function Documentation

◆ item_entity_update()

void item_entity_update ( ItemEntity * entity)

Definition at line 776 of file item_entity.c.

776 {
777 s32* args;
778 s32 max, threshold;
779
780 entity->nextUpdate--;
781 if (entity->nextUpdate != 0) {
782 return;
783 }
784
785 do {
786 args = entity->readPos;
787 switch(*args++) {
789 entity->nextUpdate = 60;
790 return;
792 entity->nextUpdate = *args++;
793 *args++;
794 *args++;
796 entity->lookupRasterIndex = *args++;
797 entity->lookupPaletteIndex = *args++;
798 } else {
799 entity->lookupRasterIndex = *args++ >> 16;
800 entity->lookupPaletteIndex = *args++ >> 16;
801 }
802 entity->readPos = args;
803 return;
805 entity->readPos = entity->savedReadPos;
806 break;
808 entity->savedReadPos = args;
809 entity->readPos = args;
810 break;
812 max = *args++;
813 threshold = *args++;
814 if (rand_int(max) < threshold) {
815 entity->readPos = entity->savedReadPos;
816 } else {
817 entity->readPos = args;
818 }
819 break;
820 }
821 } while (TRUE);
822}
#define rand_int
@ CONTEXT_WORLD
Definition enums.h:3529
@ ITEM_SCRIPT_OP_End
Definition item_entity.h:9
@ ITEM_SCRIPT_OP_RandomRestart
Definition item_entity.h:13
@ ITEM_SCRIPT_OP_SetImage
Definition item_entity.h:10
@ ITEM_SCRIPT_OP_Restart
Definition item_entity.h:11
@ ITEM_SCRIPT_OP_Loop
Definition item_entity.h:12
GameStatus * gGameStatusPtr
Definition main_loop.c:32

Referenced by item_entity_load(), and update_item_entities().

◆ appendGfx_item_entity()

void appendGfx_item_entity ( void * data)

Definition at line 910 of file item_entity.c.

910 {
911 ItemEntity* item = (ItemEntity*)data;
912 Mtx mtxTransform;
913 Matrix4f mtxTranslate, mtxRotY, mtxScale;
914 s32 alpha = 255;
915 s32 yOffset;
916 f32 rot;
917
920 alpha = 255;
921 alpha = (item->alpha * alpha) / 255;
922 }
923 if (item->flags & ITEM_ENTITY_FLAG_HIDING) {
924 u8 r, g, b, a;
925
926 mdl_get_shroud_tint_params(&r, &g, &b, &a);
927 alpha = (alpha * (255 - a)) / 255;
928 }
929 }
930
931 if (!(item->flags & ITEM_ENTITY_FLAG_FULLSIZE)) {
932 yOffset = -2;
933 } else {
934 yOffset = -3;
935 }
936
937 if (item->itemID == ITEM_COIN || item->itemID == ITEM_STAR_POINT || item->itemID == ITEM_HEART) {
938 item->scale = 1.0f;
939 }
940
941 rot = clamp_angle(180.0f - gCameras[gCurrentCamID].curYaw);
942 guTranslateF(mtxTranslate, item->pos.x, item->pos.y + yOffset, item->pos.z);
943 guRotateF(mtxRotY, rot, 0.0f, 1.0f, 0.0f);
944 if (item->flags & ITEM_ENTITY_RESIZABLE) {
945 guScaleF(mtxScale, item->scale, item->scale, item->scale);
946 guMtxCatF(mtxRotY, mtxScale, mtxRotY);
947 }
948 guMtxCatF(mtxRotY, mtxTranslate, mtxTranslate);
949 guMtxF2L(mtxTranslate, &mtxTransform);
950
952
954 G_MTX_PUSH | G_MTX_LOAD | G_MTX_MODELVIEW);
955
956 if (gSpriteShadingProfile->flags != 0) {
957 gSPDisplayList(gMainGfxPos++, Gfx_RM2_ALPHATEST);
958 } else {
959 gSPDisplayList(gMainGfxPos++, Gfx_RM1_ALPHATEST);
960 }
961 gSPClearGeometryMode(gMainGfxPos++, G_CULL_BOTH | G_LIGHTING);
962 gSPDisplayList(gMainGfxPos++, D_8014C620);
963
965 if (gSpriteShadingProfile->flags != 0) {
966 gDPSetRenderMode(gMainGfxPos++, AA_EN | IM_RD | CVG_DST_SAVE | ZMODE_OPA | FORCE_BL | G_RM_PASS,
967 AA_EN | IM_RD | CVG_DST_SAVE | ZMODE_OPA | FORCE_BL |
968 GBL_c2(G_BL_CLR_IN, G_BL_A_IN, G_BL_CLR_MEM, G_BL_1MA));
969 } else {
970 gDPSetRenderMode(gMainGfxPos++, AA_EN | IM_RD | CVG_DST_SAVE | ZMODE_OPA | FORCE_BL |
971 GBL_c1(G_BL_CLR_IN, G_BL_A_IN, G_BL_CLR_MEM, G_BL_1MA),
972 AA_EN | IM_RD | CVG_DST_SAVE | ZMODE_OPA | FORCE_BL |
973 GBL_c2(G_BL_CLR_IN, G_BL_A_IN, G_BL_CLR_MEM, G_BL_1MA));
974 gDPSetCombineMode(gMainGfxPos++, PM_CC_2F, PM_CC_32);
975 gDPSetPrimColor(gMainGfxPos++, 0, 0, 255, 255, 255, alpha);
976 }
977 }
978
979 if (!(item->flags & ITEM_ENTITY_FLAG_FULLSIZE)) {
980 gDPLoadTLUT_pal16(gMainGfxPos++, 0, gHudElementCacheTablePalette[item->lookupPaletteIndex].data);
981 if (gSpriteShadingProfile->flags != 0) {
982 gDPSetTextureImage(gMainGfxPos++, G_IM_FMT_CI, G_IM_SIZ_8b, 12, gHudElementCacheTableRaster[item->lookupRasterIndex].data);
983 gDPSetTile(gMainGfxPos++, G_IM_FMT_CI, G_IM_SIZ_8b, 2, 0x0000, G_TX_LOADTILE, 0, G_TX_NOMIRROR |
984 G_TX_CLAMP, 8, G_TX_NOLOD, G_TX_NOMIRROR | G_TX_CLAMP, 8, G_TX_NOLOD);
985 gDPLoadSync(gMainGfxPos++);
986 gDPLoadTile(gMainGfxPos++, G_TX_LOADTILE, 0, 0, 0x002E, 0x005C);
987 gDPPipeSync(gMainGfxPos++);
988 gDPSetTile(gMainGfxPos++, G_IM_FMT_CI, G_IM_SIZ_4b, 2, 0x0000, 1, 0, G_TX_NOMIRROR | G_TX_CLAMP, 8,
989 G_TX_NOLOD, G_TX_NOMIRROR | G_TX_CLAMP, 8, G_TX_NOLOD);
990 gDPSetTileSize(gMainGfxPos++, 1, 0x0400, 0x0400, 0x045C, 0x045C);
991 gDPSetTile(gMainGfxPos++, G_IM_FMT_CI, G_IM_SIZ_4b, 2, 0x0000, G_TX_RENDERTILE, 1,
992 G_TX_NOMIRROR | G_TX_CLAMP, 8, G_TX_NOLOD, G_TX_NOMIRROR | G_TX_CLAMP, 8, G_TX_NOLOD);
993 gDPSetTile(gMainGfxPos++, G_IM_FMT_RGBA, G_IM_SIZ_16b, 4, 0x0100, 2, 0, G_TX_NOMIRROR | G_TX_WRAP,
994 G_TX_NOMASK, G_TX_NOLOD, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMASK, G_TX_NOLOD);
995 gDPSetTileSize(gMainGfxPos++, 2, 0, 0, 0x00FC, 0);
996
998 func_801491E4(mtxTranslate, 0, 0, 24, 24, alpha);
999 } else {
1000 func_801491E4(mtxTranslate, 0, 0, 24, 24, 255);
1001 }
1002 } else {
1003 gDPSetTextureImage(gMainGfxPos++, G_IM_FMT_CI, G_IM_SIZ_8b, 12, gHudElementCacheTableRaster[item->lookupRasterIndex].data);
1004 gDPSetTile(gMainGfxPos++, G_IM_FMT_CI, G_IM_SIZ_8b, 2, 0x0000, G_TX_LOADTILE, 0,
1005 G_TX_NOMIRROR | G_TX_CLAMP, 8, G_TX_NOLOD, G_TX_NOMIRROR | G_TX_CLAMP, 8, G_TX_NOLOD);
1006 gDPLoadSync(gMainGfxPos++);
1007 gDPLoadTile(gMainGfxPos++, G_TX_LOADTILE, 0, 0, 0x002E, 0x005C);
1008 gDPPipeSync(gMainGfxPos++);
1009 gDPSetTile(gMainGfxPos++, G_IM_FMT_CI, G_IM_SIZ_4b, 2, 0x0000, G_TX_RENDERTILE, 0,
1010 G_TX_NOMIRROR | G_TX_CLAMP, 8, G_TX_NOLOD, G_TX_NOMIRROR | G_TX_CLAMP, 8, G_TX_NOLOD);
1011 gDPSetTileSize(gMainGfxPos++, G_TX_RENDERTILE, 0x0400, 0x0400, 0x045C, 0x045C);
1012 }
1013 gSPDisplayList(gMainGfxPos++, D_8014C678);
1014 } else {
1015 gDPLoadTLUT_pal16(gMainGfxPos++, 0, gHudElementCacheTablePalette[item->lookupPaletteIndex].data);
1016 if (gSpriteShadingProfile->flags != 0) {
1017 gDPSetTextureImage(gMainGfxPos++, G_IM_FMT_CI, G_IM_SIZ_8b, 16, gHudElementCacheTableRaster[item->lookupRasterIndex].data);
1018 gDPSetTile(gMainGfxPos++, G_IM_FMT_CI, G_IM_SIZ_8b, 2, 0x0000, G_TX_LOADTILE, 0,
1019 G_TX_NOMIRROR | G_TX_CLAMP, 8, G_TX_NOLOD, G_TX_NOMIRROR | G_TX_CLAMP, 8, G_TX_NOLOD);
1020 gDPLoadSync(gMainGfxPos++);
1021 gDPLoadTile(gMainGfxPos++, G_TX_LOADTILE, 0, 0, 0x003E, 0x007C);
1022 gDPPipeSync(gMainGfxPos++);
1023 gDPSetTile(gMainGfxPos++, G_IM_FMT_CI, G_IM_SIZ_4b, 2, 0x0000, 1, 0, G_TX_NOMIRROR | G_TX_CLAMP,
1024 8, G_TX_NOLOD, G_TX_NOMIRROR | G_TX_CLAMP, 8, G_TX_NOLOD);
1025 gDPSetTileSize(gMainGfxPos++, 1, 0x0400, 0x0400, 0x047C, 0x047C);
1026 gDPSetTile(gMainGfxPos++, G_IM_FMT_CI, G_IM_SIZ_4b, 2, 0x0000, G_TX_RENDERTILE, 1,
1027 G_TX_NOMIRROR | G_TX_CLAMP, 8, G_TX_NOLOD, G_TX_NOMIRROR | G_TX_CLAMP, 8, G_TX_NOLOD);
1028 gDPSetTile(gMainGfxPos++, G_IM_FMT_RGBA, G_IM_SIZ_16b, 4, 0x0100, 2, 0, G_TX_NOMIRROR | G_TX_WRAP,
1029 G_TX_NOMASK, G_TX_NOLOD, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMASK, G_TX_NOLOD);
1030 gDPSetTileSize(gMainGfxPos++, 2, 0, 0, 0x00FC, 0);
1032 func_801491E4(mtxTranslate, 0, 0, 32, 32, alpha);
1033 } else {
1034 func_801491E4(mtxTranslate, 0, 0, 32, 32, 255);
1035 }
1036 } else {
1037 gDPSetTextureImage(gMainGfxPos++, G_IM_FMT_CI, G_IM_SIZ_8b, 16, gHudElementCacheTableRaster[item->lookupRasterIndex].data);
1038 gDPSetTile(gMainGfxPos++, G_IM_FMT_CI, G_IM_SIZ_8b, 2, 0x0000, G_TX_LOADTILE, 0,
1039 G_TX_NOMIRROR | G_TX_CLAMP, 8, G_TX_NOLOD, G_TX_NOMIRROR | G_TX_CLAMP, 8, G_TX_NOLOD);
1040 gDPLoadSync(gMainGfxPos++);
1041 gDPLoadTile(gMainGfxPos++, G_TX_LOADTILE, 0, 0, 0x003E, 0x007C);
1042 gDPPipeSync(gMainGfxPos++);
1043 gDPSetTile(gMainGfxPos++, G_IM_FMT_CI, G_IM_SIZ_4b, 2, 0x0000, G_TX_RENDERTILE, 0,
1044 G_TX_NOMIRROR | G_TX_CLAMP, 8, G_TX_NOLOD, G_TX_NOMIRROR | G_TX_CLAMP, 8, G_TX_NOLOD);
1045 gDPSetTileSize(gMainGfxPos++, G_TX_RENDERTILE, 0x0400, 0x0400, 0x047C, 0x047C);
1046 }
1047 gSPDisplayList(gMainGfxPos++, D_8014C6A0);
1048 }
1049 gSPPopMatrix(gMainGfxPos++, G_MTX_MODELVIEW);
1050 gDPPipeSync(gMainGfxPos++);
1051
1052 if (item->itemID == ITEM_COIN) {
1053 draw_coin_sparkles(item);
1054 }
1055}
Mtx matrixStack[0x200]
f32 Matrix4f[4][4]
#define guRotateF
#define guMtxF2L
#define guTranslateF
#define guMtxCatF
#define clamp_angle
#define mdl_get_shroud_tint_params
#define guScaleF
@ ITEM_ENTITY_RESIZABLE
Definition enums.h:2708
@ ITEM_ENTITY_FLAG_HIDING
Definition enums.h:2721
@ ITEM_ENTITY_FLAG_FULLSIZE
Definition enums.h:2712
@ ITEM_ENTITY_FLAG_TRANSPARENT
Definition enums.h:2713
void func_801491E4(Matrix4f mtx, s32, s32, s32, s32, s32 alpha)
Gfx D_8014C620[]
Definition item_entity.c:87
HudCacheEntry * gHudElementCacheTablePalette
Gfx D_8014C6A0[]
HudCacheEntry * gHudElementCacheTableRaster
Gfx Gfx_RM2_ALPHATEST[]
Definition model.c:905
Gfx D_8014C678[]
Gfx Gfx_RM1_ALPHATEST[]
Definition model.c:676
void draw_coin_sparkles(ItemEntity *item)
#define PM_CC_32
Definition macros.h:385
#define PM_CC_2F
Definition macros.h:384
Camera gCameras[4]
Definition cam_main.c:17
Gfx * gMainGfxPos
Definition cam_main.c:15
u16 gMatrixListPos
Definition main_loop.c:45
SpriteShadingProfile * gSpriteShadingProfile
DisplayContext * gDisplayContext
Definition cam_main.c:16
s16 gCurrentCamID
Definition cam_main.c:13

Referenced by draw_item_entities().

◆ draw_item_entities()

void draw_item_entities ( void )

Definition at line 1057 of file item_entity.c.

1057 {
1058 RenderTask rt;
1059 RenderTask* rtPtr = &rt;
1060 RenderTask* retTask;
1061 s32 i;
1062
1063 for (i = 0; i < MAX_ITEM_ENTITIES; i++) {
1065
1066 if (item != NULL
1067 && item->flags != 0
1068 && !(item->flags & ITEM_ENTITY_FLAG_HIDDEN)
1069 && (item->flags & (1 << gCurrentCamID))
1070 && !(item->flags & ITEM_ENTITY_FLAG_INVISIBLE)
1071 && (item->renderGroup == -1 || ItemEntityRenderGroup == item->renderGroup))
1072 {
1073 if (!(item->flags & ITEM_ENTITY_FLAG_TRANSPARENT)) {
1075 } else {
1077 }
1078
1079 rtPtr->appendGfxArg = item;
1081 rtPtr->dist = 0;
1082
1083 retTask = queue_render_task(rtPtr);
1085 }
1086 }
1087}
#define queue_render_task
@ ITEM_ENTITY_FLAG_HIDDEN
Definition enums.h:2700
@ ITEM_ENTITY_FLAG_INVISIBLE
Definition enums.h:2714
@ RENDER_TASK_FLAG_REFLECT_FLOOR
Definition enums.h:3318
@ RENDER_MODE_ALPHATEST
Definition enums.h:3276
@ RENDER_MODE_SURFACE_XLU_LAYER1
Definition enums.h:3282
#define MAX_ITEM_ENTITIES
Definition item_entity.c:16
void appendGfx_item_entity(void *)
BSS ItemEntity ** gCurrentItemEntities
Definition item_entity.c:41
BSS s32 ItemEntityRenderGroup
Definition item_entity.c:34
void * appendGfxArg
void(* appendGfx)(void *)

Referenced by clear_item_entity_data().

◆ draw_ui_item_entities()

void draw_ui_item_entities ( void )

Definition at line 1089 of file item_entity.c.

1089 {
1091 return;
1092 }
1093
1094 for (s32 i = 0; i < MAX_ITEM_ENTITIES; i++) {
1096
1097 if (item != NULL && item->flags != 0) {
1098 switch (item->spawnType) {
1101 break;
1105 break;
1112 break;
1113 }
1114 }
1115 }
1116}
@ ITEM_SPAWN_MODE_FIXED_SPAWN_ALWAYS
Definition enums.h:2307
@ ITEM_SPAWN_MODE_DECORATION
Definition enums.h:2292
@ ITEM_SPAWN_MODE_INVISIBLE
Definition enums.h:2293
@ ITEM_SPAWN_MODE_TOSS_FADE1
Definition enums.h:2314
@ ITEM_SPAWN_MODE_ITEM_BLOCK_SPAWN_ALWAYS
Definition enums.h:2311
@ ITEM_SPAWN_MODE_TOSS_SPAWN_ALWAYS
Definition enums.h:2294
@ ITEM_SPAWN_MODE_FALL_SPAWN_ALWAYS
Definition enums.h:2303
@ ITEM_SPAWN_MODE_KEY
Definition enums.h:2291
@ GLOBAL_OVERRIDES_PREV_400
Definition enums.h:4333
@ GLOBAL_OVERRIDES_PREV_800
Definition enums.h:4334
void draw_ui_item_entity_collectable(ItemEntity *)
void draw_ui_item_entity_no_pickup(ItemEntity *)
void draw_ui_item_entity_stationary(ItemEntity *)
s32 gOverrideFlags
Definition main_loop.c:11

Referenced by clear_item_entity_data().

◆ test_item_player_collision()

b32 test_item_player_collision ( ItemEntity * item)

Definition at line 1322 of file item_entity.c.

1322 {
1323 PlayerStatus* playerStatus = &gPlayerStatus;
1324 PartnerStatus* partnerStatus = &gPartnerStatus;
1325 EncounterStatus* encounterStatus = &gCurrentEncounter;
1326 Camera* camera = &gCameras[gCurrentCameraID];
1327 s32 actionState = playerStatus->actionState;
1328 f32 itemPickupRadius;
1329 f32 itemX, itemY, itemZ;
1330 f32 hammerX, hammerZ;
1331 f32 playerX, playerY, playerZ;
1332 f32 playerHalfHeight;
1333 f32 playerHalfRadius;
1334 f32 spriteFacingAngle;
1335 f32 hammerY;
1336 f32 dx, dz;
1337 f32 dist;
1338 f32 angle;
1339 b32 hitDetected;
1340 // below weird temps required to match
1341 f32 hammerRadius;
1342 f32 hammerHitboxHeight;
1343 f32 itemHitboxHeight;
1344 f32 tmpFourteen;
1345 f32 tmpYTopThreshold;
1346
1348 item->flags &= ~ITEM_ENTITY_FLAG_AUTO_COLLECT;
1349 return TRUE;
1350 }
1351
1353 return FALSE;
1354 }
1355
1356 if (encounterStatus->hitType == ENCOUNTER_TRIGGER_CONVERSATION) {
1357 return FALSE;
1358 }
1359
1361 return FALSE;
1362 }
1363
1364 tmpFourteen = 14.0f;
1365 if (isPickingUpItem) {
1366 return FALSE;
1367 }
1368
1369 hammerRadius = tmpFourteen;
1370 tmpYTopThreshold = 18.0f;
1371 itemHitboxHeight = 27.0f;
1372
1373 hitDetected = item->flags; // required to match
1374 if (item->flags & ITEM_ENTITY_FLAG_HIDDEN) {
1375 return FALSE;
1376 }
1377
1378 hammerHitboxHeight = tmpYTopThreshold;
1380 return FALSE;
1381 }
1382
1383 if (partnerStatus->partnerActionState != PARTNER_ACTION_NONE && partnerStatus->actingPartner == PARTNER_BOW) {
1384 return FALSE;
1385 }
1386
1387 if (
1388 (actionState == ACTION_STATE_USE_SPINNING_FLOWER
1389 || actionState == ACTION_STATE_USE_MUNCHLESIA
1390 || actionState == ACTION_STATE_USE_TWEESTER)
1391 && item->itemID != ITEM_COIN)
1392 {
1393 return FALSE;
1394 }
1395
1397 return FALSE;
1398 }
1399
1400 hitDetected = FALSE;
1401 playerX = playerStatus->pos.x;
1402 playerY = playerStatus->pos.y;
1403 playerZ = playerStatus->pos.z;
1404 playerHalfHeight = playerStatus->colliderHeight / 2;
1405 playerHalfRadius = playerStatus->colliderDiameter / 4;
1406
1407 spriteFacingAngle = playerStatus->spriteFacingAngle;
1408 if (spriteFacingAngle < 180.0f) {
1409 spriteFacingAngle = clamp_angle(camera->curYaw - 90.0f);
1410 } else {
1411 spriteFacingAngle = clamp_angle(camera->curYaw + 90.0f);
1412 }
1413
1414 hammerX = playerX;
1415 hammerY = playerY;
1416 hammerZ = playerZ;
1417 if (get_clamped_angle_diff(camera->curYaw, spriteFacingAngle) < 0.0f) {
1418 angle = clamp_angle(camera->curYaw - 90.0f);
1419 if (playerStatus->trueAnimation & SPRITE_ID_BACK_FACING) {
1420 angle = clamp_angle(angle + 30.0f);
1421 }
1422 } else {
1423 angle = clamp_angle(camera->curYaw + 90.0f);
1424 if (playerStatus->trueAnimation & SPRITE_ID_BACK_FACING) {
1425 angle = clamp_angle(angle - 30.0f);
1426 }
1427 }
1428
1429 add_vec2D_polar(&hammerX, &hammerZ, 24.0f, angle);
1430
1431 itemX = item->pos.x;
1432 itemY = item->pos.y;
1433 itemZ = item->pos.z;
1434
1435 itemPickupRadius = 13.5f;
1436
1437 // check for player collision
1438 dx = itemX - playerX;
1439 dz = itemZ - playerZ;
1440 dist = sqrtf(SQ(dx) + SQ(dz));
1441
1442 if (!(playerHalfRadius + itemPickupRadius <= dist) // XZ distance is close enough
1443 && !(itemY + itemHitboxHeight < playerY) // item is not below player
1444 && !(playerY + playerHalfHeight < itemY)) // player is not below item
1445 {
1446 hitDetected = TRUE;
1447 }
1448
1449 // check for hammer collision
1450 if (playerStatus->actionState == ACTION_STATE_HAMMER && (playerStatus->flags & PS_FLAG_HAMMER_CHECK)) {
1451 dx = itemX - hammerX;
1452 dz = itemZ - hammerZ;
1453 dist = sqrtf(SQ(dx) + SQ(dz));
1454
1455 if (!(hammerRadius + itemPickupRadius <= dist) // XZ distance is close enough
1456 && !(itemY + itemHitboxHeight < hammerY) // item is not below hammer
1457 && !(hammerY + hammerHitboxHeight < itemY)) // hammer is not below item
1458 {
1459 hitDetected = TRUE;
1460 }
1461 }
1462
1463 // if an item spawns inside the player, wait a bit before allowing pickup
1464 if (hitDetected) {
1468 return FALSE;
1469 }
1470 item->flags &= ~ITEM_ENTITY_FLAG_JUST_SPAWNED;
1471 }
1472 return TRUE;
1473 }
1474
1475 // no hit detected, skip 'spawned within player' checks in the future
1477 item->flags &= ~ITEM_ENTITY_FLAG_JUST_SPAWNED;
1478 }
1479 return FALSE;
1480}
s32 b32
AnimID trueAnimation
Encoding back-facing sprite.
#define sqrtf
@ ITEM_ENTITY_FLAG_CANT_COLLECT
Definition enums.h:2715
@ ITEM_ENTITY_FLAG_JUST_SPAWNED
Definition enums.h:2701
@ ITEM_ENTITY_FLAG_AUTO_COLLECT
Definition enums.h:2702
@ PS_FLAG_HAMMER_CHECK
Definition enums.h:3073
@ PARTNER_ACTION_NONE
Definition enums.h:2932
@ ENCOUNTER_TRIGGER_CONVERSATION
Definition enums.h:272
@ TIME_FREEZE_NONE
Definition enums.h:3464
@ PARTNER_BOW
Definition enums.h:2894
@ ACTION_STATE_USE_MUNCHLESIA
Set by the jan_09 squishy flower entity; throws the player in the air.
Definition enums.h:2458
@ ACTION_STATE_USE_TWEESTER
Definition enums.h:2459
@ ACTION_STATE_USE_SPINNING_FLOWER
Definition enums.h:2457
@ ACTION_STATE_HAMMER
Definition enums.h:2446
@ ENCOUNTER_STATE_NEUTRAL
Definition enums.h:6296
@ ENCOUNTER_STATE_NONE
Definition enums.h:6294
@ GLOBAL_OVERRIDES_CANT_PICK_UP_ITEMS
Definition enums.h:4339
s32 get_time_freeze_mode(void)
Definition main_loop.c:390
void add_vec2D_polar(f32 *x, f32 *y, f32 r, f32 theta)
Definition 43F0.c:685
f32 get_clamped_angle_diff(f32, f32)
Definition 43F0.c:606
BSS s16 ItemSpawnWithinPlayerPickupDelay
Definition item_entity.c:43
BSS s16 isPickingUpItem
Definition item_entity.c:42
EncounterStatus gCurrentEncounter
Definition encounter.c:176
#define SQ(x)
Definition macros.h:166
@ SPRITE_ID_BACK_FACING
Definition sprite.h:13
PartnerStatus gPartnerStatus
Definition partners.c:42
PlayerStatus gPlayerStatus
Definition 77480.c:39
s32 gCurrentCameraID
Definition cam_math.c:4
s32 gEncounterState
Definition encounter.c:174

Referenced by update_item_entity_collectable(), and update_item_entity_stationary().

◆ update_item_entity_collectable()

void update_item_entity_collectable ( ItemEntity * item)

Definition at line 1583 of file item_entity.c.

1583 {
1584 PlayerStatus* playerStatus = &gPlayerStatus;
1585 PlayerData* playerData = &gPlayerData;
1586 ItemEntityPhysicsData* physData;
1587 s32 camID;
1588 s32 hit;
1589 f32 outX, outY, outZ, outDepth;
1590 f32 theta, sinAngle, cosAngle;
1591 f32 temp;
1592
1593 if (isPickingUpItem) {
1594 return;
1595 }
1596
1597 if (item->pickupDelay != 0) {
1598 item->pickupDelay--;
1599 return;
1600 }
1601
1603 camID = CAM_BATTLE;
1604 } else {
1605 camID = CAM_DEFAULT;
1606 }
1607
1608 switch (item->state) {
1610 reveal_item_entity(item);
1611 physData = heap_malloc(sizeof(*physData));
1612 item->physicsData = physData;
1613 ASSERT(physData != NULL);
1614
1615 if (item->flags & ITEM_ENTITY_FLAG_TOSS_HIGHER) {
1616 physData->verticalVel = 16.0f;
1617 physData->gravity = 2.0f;
1618 } else if (!(item->flags & ITEM_ENTITY_FLAG_TOSS_LOWER)) {
1619 physData->verticalVel = 12.0f;
1620 physData->gravity = 2.0f;
1621 } else {
1622 physData->verticalVel = 14.0f;
1623 physData->gravity = 2.0f;
1624 }
1625
1626 physData->collisionRadius = 24.0f;
1627 physData->constVel = 24.0f;
1628 if (item->spawnAngle < 0) {
1629 if (item_is_consumable(item->itemID) || item_is_key(item->itemID)) {
1630 if (rand_int(10000) < 5000) {
1631 physData->moveAngle = clamp_angle(gCameras[camID].curYaw + 105.0f + rand_int(30) - 15.0f);
1632 } else {
1633 physData->moveAngle = clamp_angle(gCameras[camID].curYaw - 105.0f + rand_int(30) - 15.0f);
1634 }
1635 physData->verticalVel += 4.0f;
1636 } else {
1637 switch (item->itemID) {
1638 case ITEM_HEART:
1639 physData->moveAngle = clamp_angle(gCameras[camID].curYaw + 90.0f + rand_int(120) - 60.0f);
1640 break;
1641 case ITEM_FLOWER_POINT:
1642 physData->moveAngle = clamp_angle(gCameras[camID].curYaw - 90.0f + rand_int(120) + 60.0f);
1643 break;
1644 case ITEM_COIN:
1645 if (rand_int(10000) < 5000) {
1646 physData->moveAngle = clamp_angle(gCameras[camID].curYaw + 90.0f + rand_int(120) - 60.0f);
1647 } else {
1648 physData->moveAngle = clamp_angle(gCameras[camID].curYaw - 90.0f + rand_int(120) - 60.0f);
1649 }
1650 break;
1651 case ITEM_KOOPA_FORTRESS_KEY:
1652 if (rand_int(10000) >= 5000) {
1653 physData->moveAngle = clamp_angle(gCameras[camID].curYaw - 90.0f + rand_int(120) - 60.0f);
1654 } else {
1655 physData->moveAngle = clamp_angle(gCameras[camID].curYaw + 90.0f + rand_int(120) - 60.0f);
1656 }
1657 break;
1658 case ITEM_STAR_POINT:
1660 physData->moveAngle = clamp_angle(gCameras[camID].curYaw - 90.0f + rand_int(120) - 60.0f);
1661 break;
1662 }
1663 if (rand_int(10000) < 5000) {
1664 physData->moveAngle = clamp_angle(gCameras[camID].curYaw + 90.0f + rand_int(60) - 30.0f);
1665 } else {
1666 physData->moveAngle = clamp_angle(gCameras[camID].curYaw - 90.0f + rand_int(60) - 30.0f);
1667 }
1668 break;
1669 case ITEM_HEART_POINT:
1670 physData->moveAngle = clamp_angle(gCameras[camID].curYaw + 90.0f + rand_int(120) - 60.0f);
1671 break;
1672 case ITEM_STAR_PIECE:
1673 if (rand_int(10000) < 5000) {
1674 physData->moveAngle = clamp_angle(gCameras[camID].curYaw + 90.0f + rand_int(60) - 30.0f);
1675 } else {
1676 physData->moveAngle = clamp_angle(gCameras[camID].curYaw - 90.0f + rand_int(60) - 30.0f);
1677 }
1678 break;
1679 case ITEM_HEART_PIECE:
1680 physData->moveAngle = clamp_angle(gCameras[camID].curYaw + 90.0f + rand_int(120) - 60.0f);
1681 break;
1682 default:
1683 physData->moveAngle = 0.0f;
1684 break;
1685 }
1686 }
1687
1688 if (!(item->flags & ITEM_ENTITY_FLAG_TOSS_HIGHER)) {
1689 temp = rand_int(2000);
1690 temp = (temp / 1000.0f) + 1.5;
1691 theta = DEG_TO_RAD(physData->moveAngle);
1692 sinAngle = sin_rad(theta);
1693 cosAngle = cos_rad(theta);
1694 physData->velX = temp * sinAngle;
1695 physData->velZ = -temp * cosAngle;
1696 } else {
1697 temp = rand_int(2000);
1698 temp = (temp / 1000.0f) + 2.0;
1699 theta = DEG_TO_RAD(physData->moveAngle);
1700 sinAngle = sin_rad(theta);
1701 cosAngle = cos_rad(theta);
1702 physData->velX = temp * sinAngle;
1703 physData->velZ = -temp * cosAngle;
1704 }
1705 } else {
1706 physData->moveAngle = clamp_angle(item->spawnAngle);
1708 temp = 1.5f + (0.6 * (item->spawnAngle / 360));
1709 } else {
1710 temp = 2.1f;
1711 }
1712 theta = DEG_TO_RAD(physData->moveAngle);
1713 sinAngle = sin_rad(theta);
1714 cosAngle = cos_rad(theta);
1715 physData->velX = temp * sinAngle;
1716 physData->velZ = -temp * cosAngle;
1717 }
1718
1720 physData->timeLeft = 180;
1721 physData->useSimplePhysics = FALSE;
1722 } else {
1723 if (!(item->flags & ITEM_ENTITY_FLAG_400000)) {
1724 physData->timeLeft = 17;
1725 } else {
1726 physData->timeLeft = 20;
1727 }
1728 physData->useSimplePhysics = FALSE;
1729 physData->verticalVel = 15.0f;
1730 physData->gravity = 1.6f;
1731 }
1732
1734 physData->timeLeft = 60;
1735 physData->useSimplePhysics = FALSE;
1736 physData->velX = 0.0f;
1737 physData->velZ = 0.0f;
1738 }
1739
1741 physData->verticalVel = 0.0f;
1742 physData->velX = 0.0f;
1743 physData->velZ = 0.0f;
1744 physData->useSimplePhysics = TRUE;
1745 }
1746
1748 physData->verticalVel = 0.0f;
1749 physData->velX = 0.0f;
1750 physData->velZ = 0.0f;
1751 physData->useSimplePhysics = TRUE;
1752 }
1753
1756 }
1758 break;
1759
1761 physData = item->physicsData;
1762
1763 // test for pickup
1766 && physData->useSimplePhysics
1768 ) {
1770 break;
1771 }
1772
1773 // check for expiration
1777 ) {
1778 physData->timeLeft--;
1779 if (physData->timeLeft < 0) {
1781 break;
1782 }
1783 }
1784
1785 // apply gravity
1786 if (!(item->flags & ITEM_ENTITY_FLAG_NO_GRAVITY)) {
1787 if (!(item->flags & ITEM_ENTITY_FLAG_CANT_COLLECT)) {
1788 physData->verticalVel -= physData->gravity;
1789 if (physData->verticalVel < -16.0) {
1790 physData->verticalVel = -16.0f;
1791 }
1792 item->pos.y += physData->verticalVel;
1793 item->pos.x += physData->velX;
1794 item->pos.z += physData->velZ;
1795 }
1796 }
1797
1798 // handle auto-collection from multi-coin bricks
1800 && physData->verticalVel <= 0.0f
1801 ) {
1803 break;
1804 }
1805
1806 // if the item has upward velocity, try moving it up
1810 && physData->verticalVel > 0.0f
1811 ) {
1812 temp = physData->constVel;
1813 outX = item->pos.x;
1814 outY = item->pos.y;
1815 outZ = item->pos.z;
1816 outDepth = temp + physData->verticalVel;
1817
1818 if (!physData->useSimplePhysics) {
1819 hit = npc_raycast_up(COLLIDER_FLAG_IGNORE_NPC, &outX, &outY, &outZ, &outDepth);
1820 } else {
1821 hit = npc_raycast_up(COLLIDER_FLAG_IGNORE_NPC, &outX, &outY, &outZ, &outDepth);
1822 }
1823
1824 if (hit && outDepth < temp) {
1825 item->pos.y = outY - temp;
1826 physData->verticalVel = 0.0f;
1827 }
1828 }
1829
1830 // if the item has non-zero lateral velocity, try moving it laterally
1834 && (physData->velX != 0.0f || physData->velZ != 0.0f)
1835 ) {
1836 outX = item->pos.x;
1837 outY = item->pos.y;
1838 outZ = item->pos.z;
1839
1840 if (!physData->useSimplePhysics) {
1841 hit = npc_test_move_complex_with_slipping(COLLIDER_FLAG_IGNORE_NPC, &outX, &outY, &outZ, 0.0f, physData->moveAngle, physData->constVel, physData->collisionRadius);
1842 } else {
1843 hit = npc_test_move_simple_with_slipping(COLLIDER_FLAG_IGNORE_NPC, &outX, &outY, &outZ, 0.0f, physData->moveAngle, physData->constVel, physData->collisionRadius);
1844 }
1845
1846 if (hit) {
1847 // if a wall is hit, bounce back
1848 item->pos.x = outX;
1849 item->pos.y = outY;
1850 item->pos.z = outZ;
1851 physData->moveAngle = clamp_angle(physData->moveAngle + 180.0f);
1852 theta = DEG_TO_RAD(physData->moveAngle);
1853 sinAngle = sin_rad(theta);
1854 cosAngle = cos_rad(theta);
1855 physData->velX = sinAngle * 2.0;
1856 physData->velZ = cosAngle * -2.0;
1857 }
1858 }
1859
1860 // if the item has downward velocity, try moving it down
1861 if (!(item->flags & ITEM_ENTITY_FLAG_NO_MOTION)
1863 && physData->verticalVel <= 0.0
1864 ) {
1865 physData->useSimplePhysics = TRUE;
1867 outX = item->pos.x;
1868 outY = (item->pos.y - physData->verticalVel) + 12.0f;
1869 outZ = item->pos.z;
1870 outDepth = -physData->verticalVel + 12.0f;
1871 if (!physData->useSimplePhysics) {
1872 hit = npc_raycast_down_sides(COLLIDER_FLAG_IGNORE_NPC, &outX, &outY, &outZ, &outDepth);
1873 } else {
1874 hit = npc_raycast_down_around(COLLIDER_FLAG_IGNORE_NPC, &outX, &outY, &outZ, &outDepth, 180.0f, 20.0f);
1875 }
1876 } else {
1877 outX = item->pos.x;
1878 outY = (item->pos.y - physData->verticalVel) + 12.0f;
1879 outZ = item->pos.z;
1880 outDepth = -physData->verticalVel + 12.0f;
1881 if (outY < outDepth + 0.0f) {
1882 outY = 0.0f;
1883 hit = TRUE;
1884 } else {
1885 hit = FALSE;
1886 }
1887 }
1888
1889 // handle bounce
1890 if (hit) {
1891 item->pos.y = outY;
1892 physData->verticalVel = -physData->verticalVel / 1.25;
1893 if (physData->verticalVel < 3.0) {
1894 physData->verticalVel = 0.0f;
1895 physData->velX = 0.0f;
1896 physData->velZ = 0.0f;
1898 } else {
1899 if (item_is_badge(item->itemID)) {
1901 } else if (item_is_consumable(item->itemID) || item_is_key(item->itemID)) {
1903 } else {
1904 switch (item->itemID) {
1905 case ITEM_HEART:
1907 break;
1908 case ITEM_COIN:
1910 break;
1911 case ITEM_KOOPA_FORTRESS_KEY:
1913 break;
1914 case ITEM_HEART_PIECE:
1916 break;
1917 case ITEM_STAR_POINT:
1919 break;
1920 case ITEM_HEART_POINT:
1922 break;
1923 case ITEM_STAR_PIECE:
1925 break;
1926 case ITEM_FLOWER_POINT:
1928 break;
1929 }
1930 }
1931 }
1932 }
1933 }
1934
1935 if (item->pos.y < -2000.0f) {
1937 }
1938 break;
1939 }
1940
1941 if (item->state == ITEM_PHYSICS_STATE_DEAD) {
1943 }
1944
1945 if (item->state == ITEM_PHYSICS_STATE_TOUCH) {
1948 }
1949
1950 fx_small_gold_sparkle(0, item->pos.x, item->pos.y + 16.0f, item->pos.z, 1.0f, 0);
1951
1952 if (item_is_consumable(item->itemID) || item_is_key(item->itemID) || item_is_badge(item->itemID)) {
1954 } else if (item->itemID == ITEM_STAR_PIECE) {
1955 playerData->starPiecesCollected++;
1957 } else {
1959 item->itemID = -1;
1960 }
1961
1962 switch (item->itemID) {
1963 case ITEM_HEART:
1964 if (playerData->curHP < playerData->curMaxHP) {
1965 fx_recover(0, playerStatus->pos.x, playerStatus->pos.y + playerStatus->colliderHeight, playerStatus->pos.z, 1);
1967 }
1968 playerData->curHP++;
1969 if (playerData->curHP > playerData->curMaxHP) {
1970 playerData->curHP = playerData->curMaxHP;
1971 }
1973 fx_sparkles(4, playerStatus->pos.x, playerStatus->pos.y + playerStatus->colliderHeight, playerStatus->pos.z, 30.0f);
1974 break;
1975 case ITEM_FLOWER_POINT:
1976 if (playerData->curFP < playerData->curMaxFP) {
1977 fx_recover(1, playerStatus->pos.x, playerStatus->pos.y + playerStatus->colliderHeight, playerStatus->pos.z, 1);
1979 }
1980 playerData->curFP++;
1981 if (playerData->curFP > playerData->curMaxFP) {
1982 playerData->curFP = playerData->curMaxFP;
1983 }
1985 fx_sparkles(4, playerStatus->pos.x, playerStatus->pos.y + playerStatus->colliderHeight, playerStatus->pos.z, 30.0f);
1986 break;
1987 case ITEM_COIN:
1988 playerData->coins++;
1989 if (playerData->coins > 999) {
1990 playerData->coins = 999;
1991 }
1993 playerData->totalCoinsEarned++;
1994 if (playerData->totalCoinsEarned > 99999) {
1995 playerData->totalCoinsEarned = 99999;
1996 }
1997 break;
1998 case ITEM_KOOPA_FORTRESS_KEY:
2000 break;
2001 case ITEM_STAR_POINT:
2002 playerData->starPoints++;
2003 if (playerData->starPoints > 100) {
2004 playerData->starPoints = 100;
2005 }
2007 break;
2008 case ITEM_HEART_POINT:
2009 playerData->curHP = playerData->curMaxHP;
2010 playerData->curFP = playerData->curMaxFP;
2012 break;
2013 }
2014#if !VERSION_JP
2015 D_801565A8 = FALSE;
2016#endif
2017 gOverrideFlags &= ~GLOBAL_OVERRIDES_40;
2019 }
2020 }
2021
2022 // items in this unused state are managed by a script
2023 // when the script is done executing, destroy these items
2024 if (item->state == ITEM_PHYSICS_STATE_04) {
2026#if !VERSION_JP
2027 D_801565A8 = FALSE;
2028#endif
2031 }
2032 }
2033
2034 if (item->state == ITEM_PHYSICS_STATE_PICKUP) {
2035 isPickingUpItem = TRUE;
2038#if !VERSION_JP
2039 D_801565A8 = FALSE;
2040#endif
2042 }
2043}
struct ItemEntityPhysicsData * physicsData
u16 starPiecesCollected
#define sfx_play_sound_at_position
#define npc_raycast_down_sides
#define ASSERT(condition)
@ ITEM_PICKUP_STATE_INIT
Definition enums.h:2741
@ ITEM_ENTITY_FLAG_DONE_FALLING
Definition enums.h:2723
@ ITEM_ENTITY_FLAG_NO_MOTION
Definition enums.h:2722
@ ITEM_ENTITY_FLAG_NO_GRAVITY
Definition enums.h:2707
@ ITEM_ENTITY_FLAG_ANGLE_RELATIVE_VELOCITY
Definition enums.h:2724
@ 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_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_PHYSICS_STATE_TOUCH
Definition enums.h:2733
@ ITEM_PHYSICS_STATE_INIT
Definition enums.h:2730
@ ITEM_PHYSICS_STATE_DEAD
Definition enums.h:2732
@ ITEM_PHYSICS_STATE_PICKUP
Definition enums.h:2735
@ ITEM_PHYSICS_STATE_04
Definition enums.h:2734
@ ITEM_PHYSICS_STATE_ALIVE
Definition enums.h:2731
@ ITEM_SPAWN_AT_PLAYER
Definition enums.h:2319
@ COLLIDER_FLAG_IGNORE_NPC
Definition enums.h:4697
@ SOUND_FLOWER_PICKUP
Definition enums.h:927
@ SOUND_COIN_BOUNCE
Definition enums.h:923
@ SOUND_ITEM_BOUNCE
Definition enums.h:930
@ SOUND_STAR_PIECE_BOUNCE
Definition enums.h:929
@ SOUND_RECOVER
Definition enums.h:1386
@ SOUND_BADGE_BOUNCE
Definition enums.h:931
@ SOUND_HEART_BOUNCE
Definition enums.h:925
@ SOUND_COIN_PICKUP
Definition enums.h:922
@ SOUND_HEART_PICKUP
Definition enums.h:924
@ SOUND_FLOWER_BOUNCE
Definition enums.h:928
@ SOUND_SPACE_DEFAULT
Definition enums.h:1737
@ GLOBAL_OVERRIDES_40
Definition enums.h:4325
@ GLOBAL_OVERRIDES_200
Definition enums.h:4328
@ GLOBAL_OVERRIDES_DISABLE_BATTLES
Definition enums.h:4327
@ CAM_DEFAULT
Definition enums.h:1800
@ CAM_BATTLE
Definition enums.h:1801
@ EVT_GROUP_FLAG_MENUS
Definition evt.h:135
b32 npc_raycast_down_around(s32, f32 *, f32 *, f32 *, f32 *, f32, f32)
s32 npc_test_move_complex_with_slipping(s32, f32 *, f32 *, f32 *, f32, f32, f32, f32)
s32 resume_all_group(s32 groupFlags)
f32 cos_rad(f32 x)
Definition 43F0.c:717
b32 npc_test_move_simple_with_slipping(s32, f32 *, f32 *, f32 *, f32, f32, f32, f32)
b32 npc_raycast_up(s32, f32 *, f32 *, f32 *, f32 *)
s32 does_script_exist(s32 id)
f32 sin_rad(f32 x)
Definition 43F0.c:713
void * heap_malloc(s32 size)
Definition heap.c:34
void reveal_item_entity(ItemEntity *item)
BSS s16 D_801565A8
Definition item_entity.c:45
s32 test_item_player_collision(ItemEntity *)
BSS s32 UnusedItemPhysicsScriptID
Definition item_entity.c:32
void remove_item_entity_by_reference(ItemEntity *entity)
#define DEG_TO_RAD(deg)
Definition macros.h:134
PlayerData gPlayerData
Definition 77480.c:40
s32 set_global_flag(s32 index)
Definition vars_access.c:65

Referenced by update_item_entities().

◆ draw_ui_item_entity_collectable()

void draw_ui_item_entity_collectable ( ItemEntity * item)

Definition at line 2045 of file item_entity.c.

2045 {
2046 if (item->state == ITEM_PHYSICS_STATE_ALIVE) {
2047 ItemEntityPhysicsData* physicsData = item->physicsData;
2048 s32 flag = (item->flags & ITEM_ENTITY_FLAG_ODD_SPAWN_PARITY) > 0;
2049
2052 if (physicsData->timeLeft < 60) {
2053 if ((item->flags & ITEM_ENTITY_FLAG_CANT_COLLECT) || ((gGameStatusPtr->frameCounter + flag) & 1)) {
2054 item->flags &= ~ITEM_ENTITY_FLAG_HIDDEN;
2055 } else {
2057 }
2058 }
2059 } else {
2060 if (physicsData->timeLeft < 10) {
2061 item->alpha = physicsData->timeLeft * 28;
2063 }
2064 }
2065 }
2066 }
2067}
@ ITEM_ENTITY_FLAG_ODD_SPAWN_PARITY
Definition enums.h:2711

Referenced by draw_ui_item_entities().

◆ update_item_entity_stationary()

void update_item_entity_stationary ( ItemEntity * item)

Definition at line 2069 of file item_entity.c.

2069 {
2070 if (item->state == ITEM_PHYSICS_STATE_INIT) {
2071 if (test_item_player_collision(item)) {
2072 // change spawn type to initiate pickup
2073 isPickingUpItem = TRUE;
2076#if !VERSION_JP
2077 D_801565A8 = FALSE;
2078#endif
2080 }
2081 }
2082}

Referenced by update_item_entities().

◆ draw_ui_item_entity_stationary()

void draw_ui_item_entity_stationary ( ItemEntity * item)

Definition at line 2084 of file item_entity.c.

2084 {
2085}

Referenced by draw_ui_item_entities().

◆ update_item_entity_no_pickup()

void update_item_entity_no_pickup ( ItemEntity * item)

Definition at line 2087 of file item_entity.c.

2087 {
2088}

Referenced by update_item_entities().

◆ draw_ui_item_entity_no_pickup()

void draw_ui_item_entity_no_pickup ( ItemEntity * item)

Definition at line 2090 of file item_entity.c.

2090 {
2091}

Referenced by draw_ui_item_entities().

◆ func_801363A0()

void func_801363A0 ( ItemEntity * item)

Definition at line 2493 of file item_entity.c.

2493 {
2494 ItemData* itemData = &gItemTable[item->itemID];
2495 s32 itemMsg;
2496 s32 width;
2497 s32 posX;
2498 s32 offsetY;
2499 s32 posY;
2500 s32 height;
2501 s32 v1;
2502
2503 switch (item->state) {
2506 if (!(itemData->typeFlags & ITEM_TYPE_FLAG_BADGE)) {
2508 itemMsg = MSG_Menus_0058;
2509 } else {
2510 itemMsg = MSG_Menus_005A;
2511 }
2512
2514 itemMsg = MSG_Menus_005D;
2515 }
2517 itemMsg = MSG_Menus_005E;
2518 }
2520 itemMsg = MSG_Menus_005C;
2521 }
2522
2523 set_message_text_var(itemData->nameMsg, 0);
2524
2526 item->itemID != ITEM_STAR_PIECE &&
2529 width = get_msg_width(itemMsg, 0) + WD_VAR1;
2530 } else {
2531 width = get_msg_width(itemMsg, 0) + WD_VAR2;
2532 }
2533 posX = 160 - width / 2;
2534 posY = 76;
2535 } else {
2537 itemMsg = MSG_Menus_0059;
2538 } else {
2539 itemMsg = MSG_Menus_005B;
2540 }
2541
2543 itemMsg = MSG_Menus_005D;
2544 }
2546 itemMsg = MSG_Menus_005E;
2547 }
2549 itemMsg = MSG_Menus_005C;
2550 }
2551
2552 set_message_text_var(itemData->nameMsg, 0);
2553 width = get_msg_width(itemMsg, 0) + WD_VAR3;
2554 posX = 160 - width / 2;
2555 posY = 76;
2556 }
2557#if !VERSION_JP
2558 height = PickupHeaderWindowHeight[get_msg_lines(itemMsg) - 1];
2559#endif
2561 offsetY = 28;
2562 } else {
2563 offsetY = 0;
2564 }
2568 && item->itemID != ITEM_STAR_PIECE)
2569 ) {
2570 set_window_properties(WIN_PICKUP_HEADER, posX, posY - 24 + offsetY, width,
2573 set_window_properties(WIN_PICKUP_HEADER, posX, posY - 24 + offsetY, width,
2575 } else {
2576 set_window_properties(WIN_PICKUP_HEADER, posX, posY - 24 + offsetY, width,
2578 }
2579 if (item->itemID != ITEM_STAR_PIECE && item->itemID != ITEM_COIN) {
2580 posX = X_VAR1;
2582 }
2584 width = get_msg_width(MSG_Menus_0060, 0) + 24;
2585 posX = 160 - width / 2;
2587 }
2588 break;
2590 set_message_text_var(itemData->nameMsg, 0);
2591#if VERSION_JP
2592 width = get_msg_width(gItemTable[ThrowAwayItemID].nameMsg, 0) + 104;
2593#else
2594 width = get_msg_width(MSG_Menus_005F, 0) + 54;
2595#endif
2596 posX = 160 - width / 2;
2598 break;
2599 }
2600}
#define get_msg_width
@ ITEM_PICKUP_STATE_SHOW_GOT_ITEM
Definition enums.h:2743
@ ITEM_PICKUP_STATE_SHOW_TOO_MANY
Definition enums.h:2751
@ ITEM_PICKUP_STATE_AWAIT_THROW_AWAY
Definition enums.h:2753
@ ITEM_ENTITY_FLAG_4000000
Definition enums.h:2720
@ WINDOW_PRIORITY_0
Definition enums.h:3182
@ ITEM_TYPE_FLAG_BADGE
Definition enums.h:1839
@ ITEM_TYPE_FLAG_WORLD_USABLE
Definition enums.h:1834
@ ITEM_TYPE_FLAG_GEAR
Definition enums.h:1838
@ ITEM_TYPE_FLAG_KEY
Definition enums.h:1837
@ ITEM_PICKUP_FLAG_UNKNOWN
Definition enums.h:2762
@ ITEM_PICKUP_FLAG_3_STAR_PIECES
Definition enums.h:2764
@ ITEM_PICKUP_FLAG_UNIQUE
Definition enums.h:2765
@ ITEM_PICKUP_FLAG_1_COIN
Definition enums.h:2763
@ WIN_POPUP_DESC
Definition enums.h:5260
@ WIN_POPUP_TITLE_B
Definition enums.h:5258
@ WIN_PICKUP_HEADER
Definition enums.h:5253
void set_message_text_var(s32 msgID, s32 index)
Definition msg.c:1520
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
s32 get_msg_lines(s32 messageID)
Definition msg.c:1979
void draw_content_pickup_item_desc(ItemEntity *item, s32 posX, s32 posY)
#define WD_VAR4
#define WD_VAR2
#define WD_VAR3
void draw_content_cant_carry_more(ItemEntity *item, s32 posX, s32 posY)
void draw_content_pickup_item_header(ItemEntity *item, s32 posX, s32 posY)
#define X_VAR1
BSS s32 ThrowAwayItemID
Definition item_entity.c:51
#define HT_VAR1
#define WD_VAR1
s16 PickupHeaderWindowHeight[]
ItemData gItemTable[]

Referenced by update_item_entity_pickup().

◆ update_item_entity_pickup()

void update_item_entity_pickup ( ItemEntity * item)

Definition at line 2093 of file item_entity.c.

2093 {
2094 PlayerData* playerData = &gPlayerData;
2095 PlayerStatus* playerStatus = &gPlayerStatus;
2096 PopupMenu* menu = &ItemPickupMenu;
2097 ItemData* itemData;
2098 s32 numEntries;
2099 s32 msgID;
2100 s32 i;
2101
2102 if (item->state == ITEM_PICKUP_STATE_INIT) {
2103 isPickingUpItem = TRUE;
2104 if (!(item->flags & ITEM_ENTITY_FLAG_2000000)) {
2109 }
2110 hide_item_entity(item);
2112 }
2113
2114 switch (item->state) {
2116 if (!(item->flags & ITEM_ENTITY_FLAG_2000000)) {
2117 // list of action state conditions which allow item pickup
2118 // remain in this state (via break) until one of these is TRUE
2119 s32 actionState = playerStatus->actionState;
2120 if (!(
2121 playerStatus->animFlags & PA_FLAG_NO_OOB_RESPAWN
2122 || ((playerStatus->timeInAir != 0 || actionState == ACTION_STATE_JUMP || actionState == ACTION_STATE_FALLING)
2123 && playerStatus->enableCollisionOverlapsCheck
2124 && playerStatus->inputDisabledCount != 0)
2125 || actionState == ACTION_STATE_LAUNCH
2126 || actionState == ACTION_STATE_RIDE
2127 || actionState == ACTION_STATE_IDLE
2128 || (actionState == ACTION_STATE_USE_SPINNING_FLOWER && playerStatus->actionSubstate == 1)
2129 )) {
2130 break;
2131 }
2132 }
2133
2137 } else if (gItemTable[item->itemID].typeFlags & ITEM_TYPE_FLAG_KEY) {
2139 } else if (item->itemID == ITEM_COIN) {
2140 sfx_play_sound_at_position(SOUND_COIN_PICKUP, 0, item->pos.x, item->pos.y, item->pos.z);
2141 } else {
2143 }
2144 }
2145
2150
2151 if (!(item->flags & ITEM_ENTITY_FLAG_2000000)) {
2153 for (i = 0; i < ARRAY_COUNT(playerData->invItems); i++) {
2154 if (playerData->invItems[i] == ITEM_NONE) {
2155 break;
2156 }
2157 }
2158
2159 if (i < ARRAY_COUNT(playerData->invItems)) {
2160 playerData->invItems[i] = item->itemID;
2161 } else {
2163 goto block_47; // TODO required to match
2164 }
2165 }
2166
2168 for (i = 0; i < ARRAY_COUNT(playerData->keyItems); i++) {
2169 if (playerData->keyItems[i] == ITEM_NONE) {
2170 break;
2171 }
2172 }
2173
2174 if (i < ARRAY_COUNT(playerData->keyItems)) {
2175 playerData->keyItems[i] = item->itemID;
2176 } else {
2178 goto block_47; // TODO required to match
2179 }
2180 }
2181
2183 for (i = 0; i < ARRAY_COUNT(playerData->badges); i++) {
2184 if (playerData->badges[i] == ITEM_NONE) {
2185 break;
2186 }
2187 }
2188
2189 if (i < ARRAY_COUNT(playerData->badges)) {
2190 playerData->badges[i] = item->itemID;
2191 } else {
2193 goto block_47; // TODO required to match
2194 }
2195 }
2196
2197 if (item->itemID == ITEM_STAR_PIECE) {
2198 playerData->starPieces++;
2199 if (playerData->starPieces > MAX_STAR_PIECES) {
2200 playerData->starPieces = MAX_STAR_PIECES;
2201 }
2202 }
2203
2204 if (item->itemID == ITEM_LUCKY_STAR) {
2205 playerData->hasActionCommands = TRUE;
2206 }
2207
2208 if (item->itemID >= ITEM_HAMMER && item->itemID <= ITEM_ULTRA_HAMMER) {
2209 playerData->hammerLevel = item->itemID - ITEM_HAMMER;
2210 }
2211
2212 if (item->itemID >= ITEM_BOOTS && item->itemID <= ITEM_ULTRA_BOOTS) {
2213 playerData->bootsLevel = item->itemID - ITEM_BOOTS;
2214 }
2215 }
2216
2217block_47: // TODO required to match
2220 }
2222 func_801363A0(item);
2226 }
2229 break;
2230
2232 if (ItemPickupStateDelay == 9) {
2235 || (item->itemID == ITEM_STAR_PIECE)
2237 || (item->flags & ITEM_ENTITY_FLAG_4000000)
2239 ) {
2240 item->pos.x = playerStatus->pos.x;
2241 item->pos.y = playerStatus->pos.y + playerStatus->colliderHeight;
2242 item->pos.z = playerStatus->pos.z;
2243 suggest_player_anim_always_forward(ANIM_MarioW1_Lift);
2244 }
2245
2247 fx_got_item_outline(
2248 1,
2249 item->pos.x,
2250 item->pos.y + 8.0f,
2251 item->pos.z,
2252 1.0f,
2254 );
2255 }
2256 }
2257
2258 if (ItemPickupStateDelay < 9) {
2261 || (item->itemID == ITEM_STAR_PIECE)
2263 || (item->flags & ITEM_ENTITY_FLAG_4000000)
2265 ) {
2266 suggest_player_anim_always_forward(ANIM_MarioW1_Lift);
2267 }
2268 }
2269
2270 if (ItemPickupStateDelay == 7) {
2273 || (item->itemID == ITEM_STAR_PIECE)
2275 || (item->flags & ITEM_ENTITY_FLAG_4000000)
2277 ) {
2278 item->flags &= ~ITEM_ENTITY_FLAG_HIDDEN;
2279 }
2280 }
2281
2282 if (ItemPickupStateDelay == 6) {
2283 func_801363A0(item);
2285 if (item->itemID != ITEM_STAR_PIECE && item->itemID != ITEM_COIN) {
2287 }
2288 }
2289
2290 if (ItemPickupStateDelay != 0) {
2292 break;
2293 }
2294
2295 // wait for input
2298 {
2299 hide_item_entity(item);
2302 && !(playerStatus->animFlags & PA_FLAG_NO_OOB_RESPAWN)
2303 ) {
2305 }
2306
2309 }
2313 }
2314 break;
2318 {
2320 }
2321 break;
2325 {
2328 break;
2329 }
2330
2331 if (item->itemID == ITEM_STAR_PIECE && !evt_get_variable(NULL, GF_Tutorial_GotStarPiece)) {
2334 break;
2335 }
2337 break;
2339 msgID = MSG_NONE;
2341 msgID = MSG_Menus_Tutorial_GotItem;
2342 }
2343 if (item->itemID == ITEM_STAR_PIECE) {
2344 msgID = MSG_Menus_Tutorial_GotStarPiece;
2345 }
2349 break;
2351 if (GotItemTutorialClosed == TRUE) {
2352 isPickingUpItem = FALSE;
2353 } else {
2354 break;
2355 }
2357 if (!(item->flags & ITEM_ENTITY_FLAG_2000000)) {
2361 gOverrideFlags &= ~GLOBAL_OVERRIDES_40;
2362 }
2367 isPickingUpItem = FALSE;
2368 break;
2370 numEntries = 0;
2372 // add new item to menu
2373 itemData = &gItemTable[item->itemID];
2374 menu->ptrIcon[numEntries] = gItemHudScripts[itemData->hudElemID].enabled;
2375 menu->userIndex[numEntries] = item->itemID;
2376 menu->enabled[numEntries] = TRUE;
2377 menu->nameMsg[numEntries] = itemData->nameMsg;
2378 menu->descMsg[numEntries] = itemData->shortDescMsg;
2379 numEntries++;
2380 // add player inventory to menu
2381 for (i = 0; i < ARRAY_COUNT(playerData->invItems); i++) {
2382 if (playerData->invItems[i] != ITEM_NONE) {
2383 itemData = &gItemTable[playerData->invItems[i]];
2384 menu->ptrIcon[numEntries] = gItemHudScripts[itemData->hudElemID].enabled;
2385 menu->userIndex[numEntries] = playerData->invItems[i];
2386 menu->enabled[numEntries] = TRUE;
2387 menu->nameMsg[numEntries] = itemData->nameMsg;
2388 menu->descMsg[numEntries] = itemData->shortDescMsg;
2389 numEntries++;
2390 }
2391 }
2393 menu->numEntries = numEntries;
2394 menu->initialPos = 0;
2400 }
2401 break;
2406 {
2408 }
2409 break;
2411 if (ItemPickupStateDelay == 0) {
2412 ThrowAwayMenuIdx = menu->result;
2413 if (ThrowAwayMenuIdx == 0) {
2414 break;
2415 }
2417 }
2419 if (ItemPickupStateDelay >= 15) {
2421 if (ThrowAwayMenuIdx == 255) {
2422 ThrowAwayMenuIdx = 1;
2423 }
2426
2430 playerStatus->pos.x,
2431 playerStatus->pos.y + playerStatus->colliderHeight,
2432 playerStatus->pos.z, 3, 0, 0
2433 )
2434 )->renderGroup = -1;
2435
2436 if (ThrowAwayMenuIdx >= 2) {
2437 playerData->invItems[ThrowAwayMenuIdx - 2] = ITEM_NONE;
2439 add_item(item->itemID);
2440 }
2441 suggest_player_anim_always_forward(ANIM_MarioW1_Lift);
2442 func_801363A0(item);
2446 }
2447 break;
2452 }
2453 break;
2458 {
2460 }
2461 break;
2463 suggest_player_anim_always_forward(ANIM_Mario1_Idle);
2467 gOverrideFlags &= ~GLOBAL_OVERRIDES_40;
2472 isPickingUpItem = FALSE;
2473 break;
2474 }
2475}
void create_standard_popup_menu(PopupMenu *popup)
IconHudScriptPair gItemHudScripts[]
s16 badges[128]
s8 enableCollisionOverlapsCheck
u32 pressedButtons[4]
s16 keyItems[32]
s16 invItems[10]
s8 flags
Definition demo_api.c:15
struct GotItemOutlineFXData * gotItemOutline
Definition effects.h:2491
EffectData data
Definition effects.h:2605
@ ITEM_PICKUP_STATE_HIDE_TOO_MANY
Definition enums.h:2752
@ ITEM_PICKUP_STATE_AWAIT_TUTORIAL
Definition enums.h:2749
@ ITEM_PICKUP_STATE_SHOW_THREW_AWAY
Definition enums.h:2754
@ ITEM_PICKUP_STATE_HIDE_THREW_AWAY
Definition enums.h:2755
@ ITEM_PICKUP_STATE_CHECK_TUTORIALS
Definition enums.h:2747
@ ITEM_PICKUP_STATE_THROW_AWAY_DONE
Definition enums.h:2756
@ ITEM_PICKUP_STATE_HIDE_GOT_ITEM
Definition enums.h:2744
@ ITEM_PICKUP_STATE_DONE
Definition enums.h:2745
@ ITEM_PICKUP_STATE_SHOW_TUTORIAL
Definition enums.h:2748
@ ITEM_PICKUP_STATE_AWAIT_VALID_STATE
Definition enums.h:2742
@ BUTTON_A
Definition enums.h:2790
@ BUTTON_STICK_UP
Definition enums.h:2791
@ BUTTON_STICK_DOWN
Definition enums.h:2792
@ BUTTON_STICK_LEFT
Definition enums.h:2793
@ BUTTON_STICK_RIGHT
Definition enums.h:2794
@ BUTTON_B
Definition enums.h:2789
@ ITEM_ENTITY_FLAG_SAVE_ON_RECEIPT
Definition enums.h:2725
@ ITEM_ENTITY_FLAG_2000000
Definition enums.h:2719
@ POPUP_MENU_THROW_AWAY_ITEM
Definition enums.h:3133
@ ITEM_TYPE_FLAG_CONSUMABLE
Definition enums.h:1836
@ WINDOW_FLAG_INITIAL_ANIMATION
Definition enums.h:4996
@ PA_FLAG_NO_OOB_RESPAWN
Definition enums.h:3121
@ TIME_FREEZE_FULL
Definition enums.h:3466
@ ITEM_PICKUP_FLAG_NO_ANIMS
Definition enums.h:2761
@ ITEM_PICKUP_FLAG_NO_SOUND
Definition enums.h:2760
@ SOUND_JINGLE_GOT_BADGE
Definition enums.h:708
@ SOUND_JINGLE_GOT_KEY
Definition enums.h:707
@ SOUND_JINGLE_GOT_ITEM
Definition enums.h:706
@ ACTION_STATE_RIDE
Definition enums.h:2461
@ ACTION_STATE_JUMP
Definition enums.h:2430
@ ACTION_STATE_LAUNCH
Shy Guy Toybox jack-in-the-boxes.
Definition enums.h:2433
@ ACTION_STATE_IDLE
Definition enums.h:2426
@ ACTION_STATE_FALLING
Definition enums.h:2435
s32 evt_get_variable(Evt *script, Bytecode var)
Definition evt.c:1690
s32 is_player_dismounted(void)
Definition 77480.c:827
void msg_printer_set_origin_pos(MessagePrintState *msgPrintState, s32 x, s32 y)
Definition msg.c:1489
void hide_popup_menu(void)
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
void set_window_update(s32 panelID, s32)
Definition windows.c:434
void partner_disable_input(void)
Definition partners.c:2489
void suggest_player_anim_always_forward(AnimID anim)
Definition 77480.c:913
void sort_consumables(void)
Bubbles up player inventory items such that all ITEM_NONE values are at the bottom.
Definition inventory.c:404
void decrement_status_bar_disabled(void)
Definition inventory.c:1646
s32 disable_player_input(void)
Definition 77480.c:990
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
s32 evt_set_variable(Evt *script, Bytecode var, s32 value)
Definition evt.c:1847
s32 enable_player_input(void)
Definition 77480.c:998
void destroy_popup_menu(void)
void set_action_state(s32 actionState)
Definition 7E9D0.c:209
MessagePrintState * msg_get_printer_for_msg(s32 msgID, s32 *a1)
Definition msg.c:1424
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
void increment_status_bar_disabled(void)
Definition inventory.c:1654
void hud_element_set_script(s32 id, HudScript *anim)
void hud_element_set_render_pos(s32 id, s32 x, s32 y)
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.
void hud_element_free(s32 id)
s32 userIndex[32]
s32 nameMsg[32]
@ HUD_ELEMENT_FLAG_80
Definition hud_element.h:80
HudScript * ptrIcon[32]
s32 enabled[32]
HudScript * enabled
s32 descMsg[32]
s32 add_item(s32 itemID)
Add itemID to player inventory and return inventory slot in which it was placed.
Definition inventory.c:146
BSS PopupMenu ItemPickupMenu
Definition item_entity.c:47
ItemEntity * get_item_entity(s32 itemEntityIndex)
BSS EffectInstance * ItemPickupGotOutline
Definition item_entity.c:52
void func_801363A0(ItemEntity *)
BSS s32 ThrowAwayMenuIdx
Definition item_entity.c:50
BSS s32 ItemPickupStateDelay
Definition item_entity.c:49
BSS b32 GotItemTutorialClosed
Definition item_entity.c:54
s32 make_item_entity_delayed(s32 itemID, f32 x, f32 y, f32 z, s32 itemSpawnMode, s32 pickupDelay, s32 pickupVar)
BSS MessagePrintState * GotItemTutorialPrinter
Definition item_entity.c:53
BSS s32 ItemPickupIconID
Definition item_entity.c:48
void hide_item_entity(ItemEntity *item)
void partner_enable_input(void)
Definition partners.c:2480
void sfx_play_sound(s32 soundID)
Definition sfx.c:517
@ GF_Tutorial_GotStarPiece
@ GF_Tutorial_GotItem
#define ARRAY_COUNT(arr)
Definition macros.h:40
#define MAX_STAR_PIECES
Definition macros.h:100
Window gWindows[64]
Definition windows.c:23

Referenced by update_item_entities().

◆ draw_content_pickup_item_header()

void draw_content_pickup_item_header ( ItemEntity * item,
s32 posX,
s32 posY )

Definition at line 2618 of file item_entity.c.

2618 {
2619 ItemData* itemData = &gItemTable[item->itemID];
2620 s32 itemMsg;
2621 s32 offsetY;
2622
2623 switch (item->state) {
2628 if (!(itemData->typeFlags & ITEM_TYPE_FLAG_BADGE)) {
2630 itemMsg = MSG_Menus_0058;
2631 } else {
2632 itemMsg = MSG_Menus_005A;
2633 }
2634 set_message_text_var(itemData->nameMsg, 0);
2635
2637 itemMsg = MSG_Menus_005D;
2638 }
2640 itemMsg = MSG_Menus_005E;
2641 }
2643 itemMsg = MSG_Menus_005C;
2644 }
2645 } else {
2647 itemMsg = MSG_Menus_0059;
2648 } else {
2649 itemMsg = MSG_Menus_005B;
2650 }
2651
2653 itemMsg = MSG_Menus_005D;
2654 }
2656 itemMsg = MSG_Menus_005E;
2657 }
2659 itemMsg = MSG_Menus_005C;
2660 }
2661
2662 set_message_text_var(itemData->nameMsg, 0);
2663 }
2664
2665#if !VERSION_JP
2666 offsetY = PickupMessageWindowYOffsets[get_msg_lines(itemMsg) - 1];
2667#endif
2668
2671 || item->itemID == ITEM_STAR_PIECE
2674 ) {
2675 draw_msg(itemMsg, posX + X_PICKUP_ITEM_1, posY + Y_PICKUP_ITEM_1, 255, MSG_PAL_2F, 0);
2676 } else {
2677 draw_msg(itemMsg, posX + X_PICKUP_ITEM_2, posY + Y_PICKUP_ITEM_2, 255, MSG_PAL_2F, 0);
2679 hud_element_set_render_pos(ItemPickupIconID, posX + 20, posY + 20);
2681 }
2682 }
2683 break;
2687 draw_msg(MSG_Menus_005F, posX + X_PICKUP_THREW, posY + Y_PICKUP_THREW, 255, MSG_PAL_2F, 0);
2688 hud_element_set_render_pos(ItemPickupIconID, posX + 20, posY + 20);
2690 break;
2691 }
2692}
#define draw_msg
@ MSG_PAL_2F
Definition enums.h:5452
void hud_element_draw_next(s32 id)
s16 PickupMessageWindowYOffsets[]
#define X_PICKUP_ITEM_2
#define Y_PICKUP_THREW
#define X_PICKUP_ITEM_1
#define Y_PICKUP_ITEM_1
#define Y_PICKUP_ITEM_2
#define X_PICKUP_THREW

Referenced by func_801363A0().

◆ draw_content_cant_carry_more()

void draw_content_cant_carry_more ( ItemEntity * item,
s32 posX,
s32 posY )

Definition at line 2694 of file item_entity.c.

2694 {
2695 draw_msg(MSG_Menus_0060, x + 12, y + 4, 255, MSG_PAL_34, 0);
2696}
@ MSG_PAL_34
Definition enums.h:5457

Referenced by func_801363A0().

◆ draw_content_pickup_item_desc()

void draw_content_pickup_item_desc ( ItemEntity * item,
s32 posX,
s32 posY )

Definition at line 2698 of file item_entity.c.

2698 {
2699 ItemData* itemData = &gItemTable[item->itemID];
2700 s32 itemMsg;
2701
2702 switch (item->state) {
2707 itemMsg = itemData->shortDescMsg;
2708 draw_msg(itemMsg, posX + 8, posY, 255, MSG_PAL_STANDARD, 0);
2709 break;
2710 }
2711}
@ MSG_PAL_STANDARD
Definition enums.h:5415

Referenced by func_801363A0().

◆ sparkle_script_init()

void sparkle_script_init ( ItemEntity * item,
SparkleScript * script )

Definition at line 124 of file item_entity.c.

124 {
125 item->sparkleReadPos = (s32*)script;
126 item->sparkleNextUpdate = 1;
127 item->sparkleSavedPos = (s32*)script;
128}
s32 * sparkleSavedPos

Referenced by make_item_entity(), make_item_entity_at_player(), and update_item_entities().

◆ sparkle_script_step()

s32 sparkle_script_step ( ItemEntity * item)

Definition at line 130 of file item_entity.c.

130 {
131 s32* readPos = item->sparkleReadPos;
132
133 switch (*readPos++) {
135 item->sparkleNextUpdate = *readPos++;
136 item->sparkleUnk44 = *readPos++;
137 item->sparkleReadPos = readPos;
138 break;
140 item->sparkleReadPos = item->sparkleSavedPos;
141 return TRUE;
142 case SPARKLE_OP_Jump:
143 item->sparkleSavedPos = readPos;
144 item->sparkleReadPos = readPos;
145 return TRUE;
146 case SPARKLE_OP_SetCI:
147 item->sparkleNextUpdate = *readPos++;
148 item->sparkleRaster = (IMG_PTR)*readPos++;
149 item->sparklePalette = (PAL_PTR)*readPos++;
150 item->sparkleWidth = *readPos++;
151 item->sparkleHeight = *readPos++;
152 item->sparkleReadPos = readPos;
153 break;
154 case SPARKLE_OP_Break:
155 readPos++; // ignore arg
156 item->sparkleReadPos = readPos;
157 case SPARKLE_OP_End:
158 return TRUE;
159 }
160 return FALSE;
161}
#define PAL_PTR
#define IMG_PTR
@ SPARKLE_OP_SetCI
@ SPARKLE_OP_End
@ SPARKLE_OP_Jump
@ SPARKLE_OP_Restart
@ SPARKLE_OP_Break
@ SPARKLE_OP_SetGfx

Referenced by sparkle_script_update().

◆ sparkle_script_update()

void sparkle_script_update ( ItemEntity * item)

Definition at line 163 of file item_entity.c.

163 {
164 item->sparkleNextUpdate--;
165 if (item->sparkleNextUpdate <= 0) {
166 while (sparkle_script_step(item)) {}
167 }
168}
s32 sparkle_script_step(ItemEntity *item)

Referenced by make_item_entity(), make_item_entity_at_player(), and update_item_entities().

◆ draw_coin_sparkles()

void draw_coin_sparkles ( ItemEntity * item)

Definition at line 170 of file item_entity.c.

170 {
171 f32 x, y, z;
172 f32 angle;
173 Matrix4f sp18;
174 Matrix4f sp58;
175 Matrix4f sp98;
176 Matrix4f spD8;
177 ImgFXTexture ifxImg;
178
182 angle = clamp_angle(180.0f - gCameras[gCurrentCamID].curYaw);
183
184 guTranslateF(sp18, x, y, z);
185 guTranslateF(sp58, item->pos.x, item->pos.y + 12.0f, item->pos.z);
186 guRotateF(sp98, angle, 0.0f, 1.0f, 0.0f);
187 guMtxCatF(sp18, sp98, sp98);
188 guMtxCatF(sp98, sp58, spD8);
190
191 gSPMatrix(gMainGfxPos++, &gDisplayContext->matrixStack[gMatrixListPos++], G_MTX_PUSH | G_MTX_LOAD | G_MTX_MODELVIEW);
192 gDPSetCycleType(gMainGfxPos++, G_CYC_1CYCLE);
193 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);
194 gSPSetGeometryMode(gMainGfxPos++, G_ZBUFFER | G_SHADE | G_LIGHTING | G_SHADING_SMOOTH);
195 gSPSetLights1(gMainGfxPos++, ItemEntityLights);
196 gSPTexture(gMainGfxPos++, -1, -1, 0, G_TX_RENDERTILE, G_ON);
197 gDPSetTextureLOD(gMainGfxPos++, G_TL_TILE);
198 gDPSetTexturePersp(gMainGfxPos++, G_TP_PERSP);
199 gDPSetTextureFilter(gMainGfxPos++, G_TF_BILERP);
200 gDPSetColorDither(gMainGfxPos++, G_CD_DISABLE);
201 gDPSetTextureDetail(gMainGfxPos++, G_TD_CLAMP);
202 gDPSetTextureConvert(gMainGfxPos++, G_TC_FILT);
203 gDPSetCombineKey(gMainGfxPos++, G_CK_NONE);
204 gDPSetAlphaCompare(gMainGfxPos++, G_AC_NONE);
205
206 ifxImg.raster = item->sparkleRaster;
207 ifxImg.palette = item->sparklePalette;
208 ifxImg.width = item->sparkleWidth;
209 ifxImg.height = item->sparkleHeight;
210 ifxImg.xOffset = -item->sparkleWidth / 2;
211 ifxImg.yOffset = item->sparkleHeight / 2;
212 ifxImg.alpha = 255;
213 imgfx_appendGfx_component(0, &ifxImg, 0, spD8);
214
215 gSPPopMatrix(gMainGfxPos++, G_MTX_MODELVIEW);
216 gDPPipeSync(gMainGfxPos++);
217}
s32 imgfx_appendGfx_component(s32, ImgFXTexture *, u32, Matrix4f)
Definition imgfx.c:704
BSS s16 CoinSparkleCenterY
Definition item_entity.c:36
BSS s16 CoinSparkleCenterZ
Definition item_entity.c:37
BSS s16 CoinSparkleCenterX
Definition item_entity.c:35
Lights1 ItemEntityLights

Referenced by appendGfx_item_entity().

◆ get_item_entity()

ItemEntity * get_item_entity ( s32 itemEntityIndex)

◆ hide_item_entity()

void hide_item_entity ( ItemEntity * item)

Definition at line 223 of file item_entity.c.

223 {
224 Shadow* shadow;
225
227 if (item->shadowIndex >= 0) {
228 shadow = get_shadow_by_index(item->shadowIndex);
229 shadow->flags |= ENTITY_FLAG_HIDDEN;
230 }
231}
@ ENTITY_FLAG_HIDDEN
Definition enums.h:2613
Shadow * get_shadow_by_index(s32 index)
Definition entity.c:534

Referenced by make_item_entity(), and update_item_entity_pickup().

◆ reveal_item_entity()

void reveal_item_entity ( ItemEntity * item)

Definition at line 233 of file item_entity.c.

233 {
234 Shadow* shadow;
235
236 item->flags &= ~ITEM_ENTITY_FLAG_HIDDEN;
237 if (item->shadowIndex >= 0) {
238 shadow = get_shadow_by_index(item->shadowIndex);
239 shadow->flags &= ~ENTITY_FLAG_HIDDEN;
240 }
241}

Referenced by update_item_entity_collectable().

◆ 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_world(WorldArgs, WorldArgs)
s32 create_worker_frontUI(void(*updateFunc)(void), void(*drawFunc)(void))
Definition worker.c:63
BSS s32 ItemEntityAlternatingSpawn
Definition item_entity.c:33
void draw_item_entities(void)
void draw_ui_item_entities(void)
BSS ItemEntity * BattleItemEntities[256]
Definition item_entity.c:40
s32 ItemEntitiesCreated
Definition item_entity.c:30
BSS ItemEntity * WorldItemEntities[256]
Definition item_entity.c:39

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_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}

Referenced by state_step_end_battle(), and state_step_unpause().

◆ item_entity_load()

void item_entity_load ( ItemEntity * item)

Definition at line 291 of file item_entity.c.

291 {
292 s32* pos;
293 HudCacheEntry* entry;
294 s32 cond;
295 s32 raster;
296 s32 palette;
297 s32 size;
298 s32 i;
299
300 item->savedReadPos = item->readPos = pos = gItemEntityScripts[item->itemID];
301
302 while (TRUE) {
303 switch (*pos++) {
305 break;
308 default:
309 continue;
311 pos += 2;
312 continue;
314 pos++;
315 raster = *pos++;
316 palette = *pos++;
317
318 // 32x32 or 24x24 (divided by 2 because these are ci4 iamges)
319 size = (item->flags & ITEM_ENTITY_FLAG_FULLSIZE) ? (32 * 32 / 2) : (24 * 24 / 2);
320
322 i = 0;
323 while (TRUE) {
324 if (entry->id == -1) {
325 entry->id = raster;
327
328 ASSERT(*gHudElementCacheSize + size < 0x11000);
329 nuPiReadRom((s32)icon_ROM_START + raster, entry->data, size);
330 *gHudElementCacheSize += size;
332 *pos = i;
333 } else {
334 *pos = (u16)(*pos) | (i << 16);
335 }
336 pos++;
337 break;
338 } else {
339 cond = entry->id == raster; // TODO required to match
340 if (cond) {
342 *pos = i;
343 } else {
344 *pos = (u16)(*pos) | (i << 16);
345 }
346 pos++;
347 break;
348 }
349 }
350 entry++;
351 i++;
352 }
354
356 i = 0;
357 while (TRUE) {
358 if (entry->id == -1) {
359 entry->id = palette;
361 ASSERT(*gHudElementCacheSize + 0x20 < 0x11000);
362 nuPiReadRom((s32)icon_ROM_START + palette, entry->data, 0x20);
363 *gHudElementCacheSize += 0x20;
365 *pos = i;
366 } else {
367 *pos = (u16)(*pos) | (i << 16);
368 }
369 pos++;
370 break;
371 } else if (entry->id == palette) {
373 *pos = i;
374 } else {
375 *pos = (u16)(*pos) | (i << 16);
376 }
377 pos++;
378 break;
379 }
380 entry++;
381 i++;
382 }
383 continue;
384 }
385 break;
386 }
387 item_entity_update(item);
388}
Vec3s pos
Definition demo_api.c:17
u8 * gHudElementCacheBuffer
s32 * gHudElementCacheSize
s32 * gItemEntityScripts[]
void item_entity_update(ItemEntity *)

Referenced by func_80133A94(), make_item_entity(), and make_item_entity_at_player().

◆ make_item_entity()

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

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}
Vec3f playerGroundTraceAngles
@ ITEM_ENTITY_FLAG_1000
Definition enums.h:2706
@ ITEM_ENTITY_FLAG_CAM1
Definition enums.h:2696
@ 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_FLAG_CAM2
Definition enums.h:2697
@ 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
Definition enums.h:2309
@ ITEM_SPAWN_MODE_TOSS_FADE3
Definition enums.h:2316
@ 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_SPAWN_ONCE
Definition enums.h:2298
@ ITEM_SPAWN_MODE_BATTLE_REWARD
Definition enums.h:2295
@ 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_ITEM_BLOCK_COIN
Definition enums.h:2312
@ ITEM_SPAWN_MODE_ITEM_BLOCK_BADGE
Definition enums.h:2302
@ SHADOW_VARYING_CIRCLE
Definition enums.h:2535
@ ITEM_TYPE_FLAG_ENTITY_FULLSIZE
Definition enums.h:1843
@ VIS_GROUP_5
Definition enums.h:2285
void set_standard_shadow_scale(Shadow *shadow, f32 scale)
Definition entity.c:1674
s32 create_shadow_type(s32 type, f32 x, f32 y, f32 z)
Definition entity.c:1528
void item_entity_load(ItemEntity *item)
SparkleScript SparkleScript_Coin
void sparkle_script_update(ItemEntity *item)
void sparkle_script_init(ItemEntity *item, SparkleScript *script)
#define EVT_GAME_FLAG_CUTOFF
Definition macros.h:34
#define EVT_INDEX_OF_GAME_FLAG(v)
Definition macros.h:142
s32 get_global_flag(s32 index)
Definition vars_access.c:89

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_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}
s32 make_item_entity(s32 itemID, f32 x, f32 y, f32 z, s32 itemSpawnMode, s32 pickupDelay, s32 angle, s32 pickupFlagIndex)

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

◆ 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}

Referenced by update_item_entity_pickup().

◆ make_item_entity_at_player()

s32 make_item_entity_at_player ( s32 itemID,
s32 category,
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_TYPE_CONSUMABLE
Definition enums.h:1827

◆ 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}
@ GLOBAL_OVERRIDES_800
Definition enums.h:4330
@ GLOBAL_OVERRIDES_400
Definition enums.h:4329
void update_item_entity_pickup(ItemEntity *)
void update_item_entity_collectable(ItemEntity *)
void update_item_entity_no_pickup(ItemEntity *)
void update_item_entity_stationary(ItemEntity *)

Referenced by state_step_battle(), and state_step_world().

◆ render_item_entities()

void render_item_entities ( void )

Definition at line 1118 of file item_entity.c.

1118 {
1119 s32 i;
1120 s32 offsetY;
1121 f32 rotX;
1122 Mtx sp18;
1123 Matrix4f sp58;
1124 Matrix4f sp98;
1125 Matrix4f spD8;
1126 u8 r1, g1, b1, a1;
1127 s32 alpha;
1128
1129 // needed to move 'i++' to the bottom
1130 for (i = 0; i < MAX_ITEM_ENTITIES;) {
1132 if (item != NULL) {
1133 if ((item->flags != 0)) {
1134 if (!(item->flags & ITEM_ENTITY_FLAG_HIDDEN)) {
1135 if ((item->flags & ITEM_ENTITY_FLAG_INVISIBLE)) {
1136 if (!(item->flags & ITEM_ENTITY_FLAG_FULLSIZE)) {
1137 offsetY = -4;
1138 } else {
1139 offsetY = 0;
1140 }
1141
1142 if (item->itemID == ITEM_COIN || item->itemID == ITEM_STAR_POINT || item->itemID == ITEM_HEART) {
1143 offsetY = 0;
1144 item->scale = 1.0f;
1145 }
1146
1147 rotX = clamp_angle(180.0f - gCameras[gCurrentCamID].curYaw);
1148 guTranslateF(sp58, item->pos.x, -item->pos.y - offsetY, item->pos.z);
1149 guRotateF(sp98, rotX, 0.0f, 1.0f, 0.0f);
1150 if (item->flags & ITEM_ENTITY_RESIZABLE) {
1151 guScaleF(spD8, item->scale, item->scale, item->scale);
1152 guMtxCatF(sp98, spD8, sp98);
1153 }
1154 guMtxCatF(sp98, sp58, sp58);
1155 guMtxF2L(sp58, &sp18);
1157 gSPMatrix(gMainGfxPos++, &gDisplayContext->matrixStack[gMatrixListPos++], G_MTX_PUSH | G_MTX_LOAD | G_MTX_MODELVIEW);
1158
1159 if (gSpriteShadingProfile->flags != 0) {
1160 gSPDisplayList(gMainGfxPos++, Gfx_RM2_ALPHATEST);
1161 } else {
1162 gSPDisplayList(gMainGfxPos++, Gfx_RM1_ALPHATEST);
1163 }
1164 gSPClearGeometryMode(gMainGfxPos++, G_LIGHTING);
1165 gSPDisplayList(gMainGfxPos++, D_8014C620);
1166
1167 alpha = 255;
1169 if (item->flags & ITEM_ENTITY_FLAG_TRANSPARENT) {
1170 alpha = item->alpha * alpha / 255;
1171 }
1172 if (item->flags & ITEM_ENTITY_FLAG_HIDING) {
1173 mdl_get_shroud_tint_params(&r1, &g1, &b1, &a1);
1174 alpha = alpha * (255 - a1) / 255;
1175 }
1177 if (gSpriteShadingProfile->flags != 0) {
1178 gDPSetRenderMode(gMainGfxPos++, AA_EN | IM_RD | CVG_DST_SAVE | ZMODE_OPA | FORCE_BL | G_RM_PASS,
1179 AA_EN | IM_RD | CVG_DST_SAVE | ZMODE_OPA | FORCE_BL | GBL_c2(G_BL_CLR_IN, G_BL_A_IN, G_BL_CLR_MEM, G_BL_1MA));
1180 } else {
1181 gDPSetRenderMode(gMainGfxPos++, AA_EN | IM_RD | CVG_DST_SAVE | ZMODE_OPA | FORCE_BL | GBL_c1(G_BL_CLR_IN, G_BL_A_IN, G_BL_CLR_MEM, G_BL_1MA),
1182 AA_EN | IM_RD | CVG_DST_SAVE | ZMODE_OPA | FORCE_BL | GBL_c2(G_BL_CLR_IN, G_BL_A_IN, G_BL_CLR_MEM, G_BL_1MA));
1183 gDPSetCombineMode(gMainGfxPos++, PM_CC_2F, PM_CC_32);
1184 gDPSetPrimColor(gMainGfxPos++, 0, 0, 255, 255, 255, alpha);
1185 }
1186 }
1187 }
1188
1189 if (!(item->flags & ITEM_ENTITY_FLAG_FULLSIZE)) {
1190 gDPLoadTLUT_pal16(gMainGfxPos++, 0, gHudElementCacheTablePalette[item->lookupPaletteIndex].data);
1191 if (gSpriteShadingProfile->flags != 0) {
1192 gDPSetTextureImage(gMainGfxPos++, G_IM_FMT_CI, G_IM_SIZ_8b, 12, gHudElementCacheTableRaster[item->lookupRasterIndex].data);
1193 gDPSetTile(gMainGfxPos++, G_IM_FMT_CI, G_IM_SIZ_8b, 2, 0x0000, G_TX_LOADTILE, 0, G_TX_NOMIRROR | G_TX_CLAMP, 8, G_TX_NOLOD, G_TX_NOMIRROR | G_TX_CLAMP, 8, G_TX_NOLOD);
1194 gDPLoadSync(gMainGfxPos++);
1195 gDPLoadTile(gMainGfxPos++, G_TX_LOADTILE, 0, 0, 0x002E, 0x005C);
1196 gDPPipeSync(gMainGfxPos++);
1197 gDPSetTile(gMainGfxPos++, G_IM_FMT_CI, G_IM_SIZ_4b, 2, 0x0000, 1, 0, G_TX_NOMIRROR | G_TX_CLAMP, 8, G_TX_NOLOD, G_TX_NOMIRROR | G_TX_CLAMP, 8, G_TX_NOLOD);
1198 gDPSetTileSize(gMainGfxPos++, 1, 0x0400, 0x0400, 0x045C, 0x045C);
1199 gDPSetTile(gMainGfxPos++, G_IM_FMT_CI, G_IM_SIZ_4b, 2, 0x0000, G_TX_RENDERTILE, 1, G_TX_NOMIRROR | G_TX_CLAMP, 8, G_TX_NOLOD, G_TX_NOMIRROR | G_TX_CLAMP, 8, G_TX_NOLOD);
1200 gDPSetTile(gMainGfxPos++, G_IM_FMT_RGBA, G_IM_SIZ_16b, 4, 0x0100, 2, 0, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMASK, G_TX_NOLOD, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMASK, G_TX_NOLOD);
1201 gDPSetTileSize(gMainGfxPos++, 2, 0, 0, 0x00FC, 0);
1203 func_801491E4(sp58, 0, 0, 24, 24, alpha);
1204 } else {
1205 func_801491E4(sp58, 0, 0, 24, 24, 255);
1206 }
1207 } else {
1208 gDPSetTextureImage(gMainGfxPos++, G_IM_FMT_CI, G_IM_SIZ_8b, 12, gHudElementCacheTableRaster[item->lookupRasterIndex].data);
1209 gDPSetTile(gMainGfxPos++, G_IM_FMT_CI, G_IM_SIZ_8b, 2, 0x0000, G_TX_LOADTILE, 0, G_TX_NOMIRROR | G_TX_CLAMP, 8, G_TX_NOLOD, G_TX_NOMIRROR | G_TX_CLAMP, 8, G_TX_NOLOD);
1210 gDPLoadSync(gMainGfxPos++);
1211 gDPLoadTile(gMainGfxPos++, G_TX_LOADTILE, 0, 0, 0x002E, 0x005C);
1212 gDPPipeSync(gMainGfxPos++);
1213 gDPSetTile(gMainGfxPos++, G_IM_FMT_CI, G_IM_SIZ_4b, 2, 0x0000, G_TX_RENDERTILE, 0, G_TX_NOMIRROR | G_TX_CLAMP, 8, G_TX_NOLOD, G_TX_NOMIRROR | G_TX_CLAMP, 8, G_TX_NOLOD);
1214 gDPSetTileSize(gMainGfxPos++, G_TX_RENDERTILE, 0x0400, 0x0400, 0x045C, 0x045C);
1215 }
1216 gSPDisplayList(gMainGfxPos++, D_8014C678);
1217 } else {
1218 gDPLoadTLUT_pal16(gMainGfxPos++, 0, gHudElementCacheTablePalette[item->lookupPaletteIndex].data);
1219 if (gSpriteShadingProfile->flags != 0) {
1220 gDPSetTextureImage(gMainGfxPos++, G_IM_FMT_CI, G_IM_SIZ_8b, 16, gHudElementCacheTableRaster[item->lookupRasterIndex].data);
1221 gDPSetTile(gMainGfxPos++, G_IM_FMT_CI, G_IM_SIZ_8b, 2, 0x0000, G_TX_LOADTILE, 0, G_TX_NOMIRROR | G_TX_CLAMP, 8, G_TX_NOLOD, G_TX_NOMIRROR | G_TX_CLAMP, 8, G_TX_NOLOD);
1222 gDPLoadSync(gMainGfxPos++);
1223 gDPLoadTile(gMainGfxPos++, G_TX_LOADTILE, 0, 0, 0x003E, 0x007C);
1224 gDPPipeSync(gMainGfxPos++);
1225 gDPSetTile(gMainGfxPos++, G_IM_FMT_CI, G_IM_SIZ_4b, 2, 0x0000, 1, 0, G_TX_NOMIRROR | G_TX_CLAMP, 8, G_TX_NOLOD, G_TX_NOMIRROR | G_TX_CLAMP, 8, G_TX_NOLOD);
1226 gDPSetTileSize(gMainGfxPos++, 1, 0x0400, 0x0400, 0x047C, 0x047C);
1227 gDPSetTile(gMainGfxPos++, G_IM_FMT_CI, G_IM_SIZ_4b, 2, 0x0000, G_TX_RENDERTILE, 1, G_TX_NOMIRROR | G_TX_CLAMP, 8, G_TX_NOLOD, G_TX_NOMIRROR | G_TX_CLAMP, 8, G_TX_NOLOD);
1228 gDPSetTile(gMainGfxPos++, G_IM_FMT_RGBA, G_IM_SIZ_16b, 4, 0x0100, 2, 0, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMASK, G_TX_NOLOD, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMASK, G_TX_NOLOD);
1229 gDPSetTileSize(gMainGfxPos++, 2, 0, 0, 0x00FC, 0);
1231 func_801491E4(sp58, 0, 0, 32, 32, alpha);
1232 } else {
1233 func_801491E4(sp58, 0, 0, 32, 32, 255);
1234 }
1235 } else {
1236 gDPSetTextureImage(gMainGfxPos++, G_IM_FMT_CI, G_IM_SIZ_8b, 16, gHudElementCacheTableRaster[item->lookupRasterIndex].data);
1237 gDPSetTile(gMainGfxPos++, G_IM_FMT_CI, G_IM_SIZ_8b, 2, 0x0000, G_TX_LOADTILE, 0, G_TX_NOMIRROR | G_TX_CLAMP, 8, G_TX_NOLOD, G_TX_NOMIRROR | G_TX_CLAMP, 8, G_TX_NOLOD);
1238 gDPLoadSync(gMainGfxPos++);
1239 gDPLoadTile(gMainGfxPos++, G_TX_LOADTILE, 0, 0, 0x003E, 0x007C);
1240 gDPPipeSync(gMainGfxPos++);
1241 gDPSetTile(gMainGfxPos++, G_IM_FMT_CI, G_IM_SIZ_4b, 2, 0x0000, G_TX_RENDERTILE, 0, G_TX_NOMIRROR | G_TX_CLAMP, 8, G_TX_NOLOD, G_TX_NOMIRROR | G_TX_CLAMP, 8, G_TX_NOLOD);
1242 gDPSetTileSize(gMainGfxPos++, G_TX_RENDERTILE, 0x0400, 0x0400, 0x047C, 0x047C);
1243 }
1244 gSPDisplayList(gMainGfxPos++, D_8014C6A0);
1245 }
1246 gSPPopMatrix(gMainGfxPos++, G_MTX_MODELVIEW);
1247 gDPPipeSync(gMainGfxPos++);
1248 }
1249 }
1250 }
1251 }
1252 i++;
1253 }
1254}

Referenced by render_frame().

◆ remove_item_entity_by_reference()

void remove_item_entity_by_reference ( ItemEntity * entity)

Definition at line 1256 of file item_entity.c.

1256 {
1257 s32 index;
1258
1259 for (index = 0; index < MAX_ITEM_ENTITIES; index++) {
1260 if (gCurrentItemEntities[index] == entity) {
1261 break;
1262 }
1263 }
1264
1265 if (index < MAX_ITEM_ENTITIES) {
1266 if (entity->physicsData != NULL) {
1267 heap_free(entity->physicsData);
1268 }
1269
1270 switch (entity->spawnType) {
1277 delete_shadow(entity->shadowIndex);
1278 break;
1279 }
1280
1282 isPickingUpItem = FALSE;
1283 gCurrentItemEntities[index] = NULL;
1284 }
1285}
s32 heap_free(void *ptr)
Definition heap.c:42
void delete_shadow(s32)
Definition entity.c:626

Referenced by update_item_entity_collectable(), and update_item_entity_pickup().

◆ 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().

◆ func_80133A94()

void func_80133A94 ( s32 idx,
s32 itemID )

Definition at line 1306 of file item_entity.c.

1306 {
1307 ItemEntity* item = gCurrentItemEntities[idx];
1308
1309 item->itemID = itemID;
1310
1312 item->flags &= ~ITEM_ENTITY_FLAG_FULLSIZE;
1313
1314 if (gItemTable[itemID].typeFlags & ITEM_TYPE_FLAG_ENTITY_FULLSIZE) {
1316 item->flags &= ~ITEM_ENTITY_RESIZABLE;
1317 }
1318
1319 item_entity_load(item);
1320}

◆ test_item_entity_position()

s32 test_item_entity_position ( f32 x,
f32 y,
f32 z,
f32 dist )

Definition at line 1482 of file item_entity.c.

1482 {
1483 ItemEntity* item;
1484 f32 dx, dy, dz;
1485 s32 i;
1486
1489 {
1490 return -1;
1491 }
1492
1493 for (i = 0; i < MAX_ITEM_ENTITIES; i++){
1494 item = gCurrentItemEntities[i];
1495
1496 if (item == NULL) {
1497 continue;
1498 }
1499
1500 if (item->flags == 0) {
1501 continue;
1502 }
1503
1505 continue;
1506 }
1507
1508 if (item->spawnType == ITEM_SPAWN_MODE_INVISIBLE) {
1509 continue;
1510 }
1511
1512 if (item->flags & ITEM_ENTITY_FLAG_HIDDEN) {
1513 continue;
1514 }
1515
1517 continue;
1518 }
1519
1520 dx = item->pos.x - x;
1521 dz = item->pos.y - y;
1522 dy = item->pos.z - z;
1523 if (sqrtf(SQ(dx) + SQ(dz) + SQ(dy)) < dist) {
1524 return i;
1525 }
1526 }
1527 return -1;
1528}
s32 is_starting_conversation(void)
Definition encounter.c:2818

Referenced by check_for_item_collision().

◆ set_item_entity_flags()

void set_item_entity_flags ( s32 index,
s32 flags )

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}

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}

◆ auto_collect_item_entity()

void auto_collect_item_entity ( s32 index)

Definition at line 1547 of file item_entity.c.

1547 {
1548 ItemEntity* item = gCurrentItemEntities[index];
1551}

◆ is_picking_up_item()

b32 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}

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().

◆ 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().

◆ set_current_item_entity_render_group()

void set_current_item_entity_render_group ( s32 group)

Definition at line 1575 of file item_entity.c.

1575 {
1576 ItemEntityRenderGroup = group;
1577}

◆ get_current_item_entity_render_group()

s32 get_current_item_entity_render_group ( void )

Definition at line 1579 of file item_entity.c.

1579 {
1580 return ItemEntityRenderGroup;
1581}

Variable Documentation

◆ SparkleScript_Coin

SparkleScript SparkleScript_Coin
extern

Definition at line 745 of file global_hud_scripts.c.

745 {
746 sp_Break(13)
747 sp_SetCI(1, ui_coin_sparkle_0, 8, 8)
748 sp_SetCI(1, ui_coin_sparkle_1, 8, 8)
749 sp_SetCI(1, ui_coin_sparkle_2, 8, 8)
750 sp_SetCI(2, ui_coin_sparkle_none, 8, 8)
751 sp_SetCI(1, ui_coin_sparkle_2, 8, 8)
752 sp_SetCI(1, ui_coin_sparkle_3, 8, 8)
753 sp_SetCI(1, ui_coin_sparkle_none, 8, 8)
754 sp_SetCI(1, ui_coin_sparkle_4, 8, 8)
755 sp_SetCI(1, ui_coin_sparkle_none, 8, 8)
756 sp_SetCI(1, ui_coin_sparkle_5, 8, 8)
757 sp_SetCI(127, ui_coin_sparkle_none, 8, 8)
758 sp_SetCI(127, ui_coin_sparkle_none, 8, 8)
759 sp_End
760};
#define sp_SetCI(time, name, width, height)
#define sp_Break(unk)
Purpose unknown; arg is not read.
#define sp_End

Referenced by make_item_entity(), make_item_entity_at_player(), and update_item_entities().

◆ Gfx_RM1_ALPHATEST

Gfx Gfx_RM1_ALPHATEST[]
extern

Definition at line 676 of file model.c.

676 {
677 gsDPSetRenderMode(G_RM_AA_ZB_TEX_EDGE, G_RM_AA_ZB_TEX_EDGE2),
678 gsDPSetCycleType(G_CYC_1CYCLE),
679 gsSPClearGeometryMode(G_SHADE | G_CULL_BOTH | G_FOG | G_LIGHTING | G_TEXTURE_GEN | G_TEXTURE_GEN_LINEAR | G_LOD | G_SHADING_SMOOTH),
680 gsSPSetGeometryMode(G_ZBUFFER | G_SHADE | G_LIGHTING | G_SHADING_SMOOTH),
681 gsSPEndDisplayList(),
682};

Referenced by appendGfx_item_entity(), and render_item_entities().

◆ Gfx_RM2_ALPHATEST

Gfx Gfx_RM2_ALPHATEST
extern
Initial value:
= {
gsDPSetRenderMode(G_RM_PASS, G_RM_AA_ZB_TEX_EDGE2),
gsDPSetCycleType(G_CYC_2CYCLE),
gsSPClearGeometryMode(G_SHADE | G_CULL_BOTH | G_FOG | G_LIGHTING | G_TEXTURE_GEN | G_TEXTURE_GEN_LINEAR | G_LOD | G_SHADING_SMOOTH),
gsSPSetGeometryMode(G_ZBUFFER | G_SHADE | G_LIGHTING | G_SHADING_SMOOTH),
gsSPEndDisplayList(),
}

Definition at line 905 of file model.c.

905 {
906 gsDPSetRenderMode(G_RM_PASS, G_RM_AA_ZB_TEX_EDGE2),
907 gsDPSetCycleType(G_CYC_2CYCLE),
908 gsSPClearGeometryMode(G_SHADE | G_CULL_BOTH | G_FOG | G_LIGHTING | G_TEXTURE_GEN | G_TEXTURE_GEN_LINEAR | G_LOD | G_SHADING_SMOOTH),
909 gsSPSetGeometryMode(G_ZBUFFER | G_SHADE | G_LIGHTING | G_SHADING_SMOOTH),
910 gsSPEndDisplayList(),
911};

Referenced by appendGfx_item_entity(), and render_item_entities().

◆ ItemEntityLights

Lights1 ItemEntityLights = gdSPDefLights1(255, 255, 255, 0, 0, 0, 0, 0, 0)

Definition at line 117 of file item_entity.c.

Referenced by draw_coin_sparkles().

◆ gHudElementCacheTableRaster

◆ gHudElementCacheTablePalette

◆ gHudElementCacheBuffer

u8* gHudElementCacheBuffer
extern

◆ gHudElementCacheSize

s32* gHudElementCacheSize
extern

◆ ItemEntitiesCreated

s32 ItemEntitiesCreated

◆ UnusedItemPhysicsScriptID

BSS s32 UnusedItemPhysicsScriptID

Definition at line 32 of file item_entity.c.

Referenced by update_item_entity_collectable().

◆ ItemEntityAlternatingSpawn

BSS s32 ItemEntityAlternatingSpawn

◆ ItemEntityRenderGroup

◆ CoinSparkleCenterX

BSS s16 CoinSparkleCenterX

Definition at line 35 of file item_entity.c.

Referenced by clear_item_entity_data(), draw_coin_sparkles(), and update_item_entities().

◆ CoinSparkleCenterY

BSS s16 CoinSparkleCenterY

Definition at line 36 of file item_entity.c.

Referenced by clear_item_entity_data(), draw_coin_sparkles(), and update_item_entities().

◆ CoinSparkleCenterZ

BSS s16 CoinSparkleCenterZ

Definition at line 37 of file item_entity.c.

Referenced by clear_item_entity_data(), draw_coin_sparkles(), and update_item_entities().

◆ pad_ItemEntity

BSS s32 pad_ItemEntity[3]

Definition at line 38 of file item_entity.c.

◆ WorldItemEntities

BSS ItemEntity* WorldItemEntities[256]

Definition at line 39 of file item_entity.c.

Referenced by clear_item_entity_data(), and init_item_entity_list().

◆ BattleItemEntities

BSS ItemEntity* BattleItemEntities[256]

Definition at line 40 of file item_entity.c.

Referenced by clear_item_entity_data(), and init_item_entity_list().

◆ gCurrentItemEntities

◆ isPickingUpItem

◆ ItemSpawnWithinPlayerPickupDelay

BSS s16 ItemSpawnWithinPlayerPickupDelay

Definition at line 43 of file item_entity.c.

Referenced by make_item_entity(), and test_item_player_collision().

◆ D_801565A8

◆ ItemPickupMenu

BSS PopupMenu ItemPickupMenu

Definition at line 47 of file item_entity.c.

Referenced by update_item_entity_pickup().

◆ ItemPickupIconID

BSS s32 ItemPickupIconID

Definition at line 48 of file item_entity.c.

Referenced by draw_content_pickup_item_header(), and update_item_entity_pickup().

◆ ItemPickupStateDelay

BSS s32 ItemPickupStateDelay

Definition at line 49 of file item_entity.c.

Referenced by update_item_entity_pickup().

◆ ThrowAwayMenuIdx

BSS s32 ThrowAwayMenuIdx

Definition at line 50 of file item_entity.c.

Referenced by update_item_entity_pickup().

◆ ThrowAwayItemID

BSS s32 ThrowAwayItemID

◆ ItemPickupGotOutline

BSS EffectInstance* ItemPickupGotOutline

Definition at line 52 of file item_entity.c.

Referenced by update_item_entity_pickup().

◆ GotItemTutorialPrinter

BSS MessagePrintState* GotItemTutorialPrinter

Definition at line 53 of file item_entity.c.

Referenced by update_item_entity_pickup().

◆ GotItemTutorialClosed

BSS b32 GotItemTutorialClosed

Definition at line 54 of file item_entity.c.

Referenced by update_item_entity_pickup().

◆ D_8014C5A0

Vtx D_8014C5A0[4]
Initial value:
= {
{{{ -12, 0, 0 }, 0, { 0x2300, 0x2300 }, { 0, 0, 0, 255 }}},
{{{ 11, 0, 0 }, 0, { 0x2000, 0x2300 }, { 0, 0, 0, 255 }}},
{{{ 11, 23, 0 }, 0, { 0x2000, 0x2000 }, { 0, 0, 0, 255 }}},
{{{ -12, 23, 0 }, 0, { 0x2300, 0x2000 }, { 0, 0, 0, 255 }}},
}

Definition at line 73 of file item_entity.c.

73 {
74 {{{ -12, 0, 0 }, 0, { 0x2300, 0x2300 }, { 0, 0, 0, 255 }}},
75 {{{ 11, 0, 0 }, 0, { 0x2000, 0x2300 }, { 0, 0, 0, 255 }}},
76 {{{ 11, 23, 0 }, 0, { 0x2000, 0x2000 }, { 0, 0, 0, 255 }}},
77 {{{ -12, 23, 0 }, 0, { 0x2300, 0x2000 }, { 0, 0, 0, 255 }}},
78};

◆ D_8014C5E0

Vtx D_8014C5E0[4]
Initial value:
= {
{{{ -16, 0, 0 }, 0, { 0x2400, 0x2400 }, { 0, 0, 0, 255 }}},
{{{ 15, 0, 0 }, 0, { 0x2000, 0x2400 }, { 0, 0, 0, 255 }}},
{{{ 15, 31, 0 }, 0, { 0x2000, 0x2000 }, { 0, 0, 0, 255 }}},
{{{ -16, 31, 0 }, 0, { 0x2400, 0x2000 }, { 0, 0, 0, 255 }}},
}

Definition at line 80 of file item_entity.c.

80 {
81 {{{ -16, 0, 0 }, 0, { 0x2400, 0x2400 }, { 0, 0, 0, 255 }}},
82 {{{ 15, 0, 0 }, 0, { 0x2000, 0x2400 }, { 0, 0, 0, 255 }}},
83 {{{ 15, 31, 0 }, 0, { 0x2000, 0x2000 }, { 0, 0, 0, 255 }}},
84 {{{ -16, 31, 0 }, 0, { 0x2400, 0x2000 }, { 0, 0, 0, 255 }}},
85};

◆ D_8014C620

Gfx D_8014C620[]
Initial value:
= {
gsDPPipeSync(),
gsSPTexture(0xFFFF, 0xFFFF, 0, G_TX_RENDERTILE, G_ON),
gsDPSetCombineMode(G_CC_DECALRGBA, G_CC_DECALRGBA),
gsDPSetTexturePersp(G_TP_PERSP),
gsDPSetTextureDetail(G_TD_CLAMP),
gsDPSetTextureLOD(G_TL_TILE),
gsDPSetTextureLUT(G_TT_NONE),
gsDPSetTextureFilter(G_TF_BILERP),
gsDPSetTextureConvert(G_TC_FILT),
gsDPSetTextureLUT(G_TT_RGBA16),
gsSPEndDisplayList(),
}

Definition at line 87 of file item_entity.c.

87 {
88 gsDPPipeSync(),
89 gsSPTexture(0xFFFF, 0xFFFF, 0, G_TX_RENDERTILE, G_ON),
90 gsDPSetCombineMode(G_CC_DECALRGBA, G_CC_DECALRGBA),
91 gsDPSetTexturePersp(G_TP_PERSP),
92 gsDPSetTextureDetail(G_TD_CLAMP),
93 gsDPSetTextureLOD(G_TL_TILE),
94 gsDPSetTextureLUT(G_TT_NONE),
95 gsDPSetTextureFilter(G_TF_BILERP),
96 gsDPSetTextureConvert(G_TC_FILT),
97 gsDPSetTextureLUT(G_TT_RGBA16),
98 gsSPEndDisplayList(),
99};

Referenced by appendGfx_item_entity(), and render_item_entities().

◆ D_8014C678

Gfx D_8014C678[]
Initial value:
= {
gsSPClearGeometryMode(G_CULL_BACK | G_LIGHTING | G_SHADING_SMOOTH),
gsSPVertex(D_8014C5A0, 4, 0),
gsSP2Triangles(0, 1, 2, 0, 0, 2, 3, 0),
gsDPPipeSync(),
gsSPEndDisplayList(),
}
Vtx D_8014C5A0[4]
Definition item_entity.c:73

Definition at line 101 of file item_entity.c.

101 {
102 gsSPClearGeometryMode(G_CULL_BACK | G_LIGHTING | G_SHADING_SMOOTH),
103 gsSPVertex(D_8014C5A0, 4, 0),
104 gsSP2Triangles(0, 1, 2, 0, 0, 2, 3, 0),
105 gsDPPipeSync(),
106 gsSPEndDisplayList(),
107};

Referenced by appendGfx_item_entity(), and render_item_entities().

◆ D_8014C6A0

Gfx D_8014C6A0[]
Initial value:
= {
gsSPClearGeometryMode(G_CULL_BACK | G_LIGHTING | G_SHADING_SMOOTH),
gsSPVertex(D_8014C5E0, 4, 0),
gsSP2Triangles(0, 1, 2, 0, 0, 2, 3, 0),
gsDPPipeSync(),
gsSPEndDisplayList(),
}
Vtx D_8014C5E0[4]
Definition item_entity.c:80

Definition at line 109 of file item_entity.c.

109 {
110 gsSPClearGeometryMode(G_CULL_BACK | G_LIGHTING | G_SHADING_SMOOTH),
111 gsSPVertex(D_8014C5E0, 4, 0),
112 gsSP2Triangles(0, 1, 2, 0, 0, 2, 3, 0),
113 gsDPPipeSync(),
114 gsSPEndDisplayList(),
115};

Referenced by appendGfx_item_entity(), and render_item_entities().

◆ PickupHeaderWindowHeight

s16 PickupHeaderWindowHeight[] = { 32, 40 }

Definition at line 120 of file item_entity.c.

120{ 32, 40 };

Referenced by func_801363A0().

◆ PickupMessageWindowYOffsets

s16 PickupMessageWindowYOffsets[] = { 8, 4 }

Definition at line 121 of file item_entity.c.

121{ 8, 4 };

Referenced by draw_content_pickup_item_header().

◆ gItemEntityScripts

s32* gItemEntityScripts[]
extern

Referenced by item_entity_load().