From 43932249c6e44c012641f6ad0713cdb28e10728e Mon Sep 17 00:00:00 2001 From: MysterD Date: Sun, 15 Aug 2021 11:46:28 -0700 Subject: [PATCH] Added support for spawning Luigi-versions of metal/vanish/wing cap as items --- actors/custom0.h | 3 +++ actors/luigi_cap/geo.inc.c | 1 - actors/luigi_cap/model.inc.c | 14 +++++++--- include/model_ids.h | 16 ++++++----- levels/scripts.c | 16 ++++++++--- src/game/behaviors/exclamation_box.inc.c | 22 +++++++++++---- src/game/characters.c | 34 ++++++++++++++---------- src/game/characters.h | 3 +++ 8 files changed, 76 insertions(+), 33 deletions(-) diff --git a/actors/custom0.h b/actors/custom0.h index 5b9aac82..b06e49d5 100644 --- a/actors/custom0.h +++ b/actors/custom0.h @@ -5,6 +5,9 @@ // luigi_cap extern const GeoLayout luigis_cap_geo[]; +extern const GeoLayout luigis_metal_cap_geo[]; +extern const GeoLayout luigis_wing_cap_geo[]; +extern const GeoLayout luigis_winged_metal_cap_geo[]; extern const Gfx luigi_cap_seg3_dl_03022B30[]; extern const Gfx luigi_cap_seg3_dl_03022B68[]; extern const Gfx luigi_cap_seg3_dl_03022CC8[]; diff --git a/actors/luigi_cap/geo.inc.c b/actors/luigi_cap/geo.inc.c index 890280b8..13995b42 100644 --- a/actors/luigi_cap/geo.inc.c +++ b/actors/luigi_cap/geo.inc.c @@ -22,7 +22,6 @@ const GeoLayout luigis_metal_cap_geo[] = { GEO_OPEN_NODE(), GEO_SCALE(0x00, 16384), GEO_OPEN_NODE(), - GEO_ASM(1, geo_mario_set_player_colors), GEO_ASM(10, geo_update_layer_transparency), GEO_SWITCH_CASE(2, geo_switch_anim_state), GEO_OPEN_NODE(), diff --git a/actors/luigi_cap/model.inc.c b/actors/luigi_cap/model.inc.c index a9fa4c63..a46cdc2e 100644 --- a/actors/luigi_cap/model.inc.c +++ b/actors/luigi_cap/model.inc.c @@ -18,6 +18,12 @@ static const Lights1 luigi_cap_seg3_lights_0301CF38 = gdSPDefLights1( 0x00, 0x8C, 0x00, 0x28, 0x28, 0x28 ); +static const Lights1 luigi_cap_seg3_lights_white = gdSPDefLights1( + 0x7f, 0x7f, 0x7f, + 0xff, 0xff, 0xff, 0x28, 0x28, 0x28 +); + + // 0x0301CF50 ALIGNED8 static const u8 luigi_cap_seg3_texture_0301CF50[] = { #include "actors/mario_cap/mario_cap_metal.rgba16.inc.c" @@ -285,8 +291,8 @@ const Gfx luigi_cap_seg3_dl_03022FF8[] = { gsDPSetCombineMode(G_CC_MODULATERGBFADE, G_CC_MODULATERGBFADE), gsDPLoadTextureBlock(luigi_cap_seg3_texture_0301CF50, G_IM_FMT_RGBA, G_IM_SIZ_16b, 64, 32, 0, G_TX_WRAP | G_TX_NOMIRROR, G_TX_WRAP | G_TX_NOMIRROR, 6, 5, G_TX_NOLOD, G_TX_NOLOD), gsSPTexture(0x0F80, 0x07C0, 0, G_TX_RENDERTILE, G_ON), - gsSPLight(&luigi_cap_seg3_lights_0301CF20.l, 1), - gsSPLight(&luigi_cap_seg3_lights_0301CF20.a, 2), + gsSPLight(&luigi_cap_seg3_lights_white.l, 1), + gsSPLight(&luigi_cap_seg3_lights_white.a, 2), gsSPDisplayList(luigi_cap_seg3_dl_03022B30), gsSPDisplayList(luigi_cap_seg3_dl_03022B68), gsSPDisplayList(luigi_cap_seg3_dl_03022CC8), @@ -385,8 +391,8 @@ const Gfx luigi_cap_seg3_dl_03023298[] = { gsDPSetTile(G_IM_FMT_RGBA, G_IM_SIZ_16b, 16, 0, G_TX_RENDERTILE, 0, G_TX_WRAP | G_TX_NOMIRROR, 5, G_TX_NOLOD, G_TX_WRAP | G_TX_NOMIRROR, 6, G_TX_NOLOD), gsDPSetTileSize(0, 0, 0, (64 - 1) << G_TEXTURE_IMAGE_FRAC, (32 - 1) << G_TEXTURE_IMAGE_FRAC), gsSPTexture(0x0F80, 0x07C0, 0, G_TX_RENDERTILE, G_ON), - gsSPCopyLightEXT(1, 5), //gsSPLight(&luigi_cap_seg3_lights_0301CF20.l, 1), - gsSPCopyLightEXT(2, 6), //gsSPLight(&luigi_cap_seg3_lights_0301CF20.a, 2), + gsSPLight(&luigi_cap_seg3_lights_white.l, 1), + gsSPLight(&luigi_cap_seg3_lights_white.a, 2), gsSPDisplayList(luigi_cap_seg3_dl_03022B30), gsSPDisplayList(luigi_cap_seg3_dl_03022B68), gsSPDisplayList(luigi_cap_seg3_dl_03022CC8), diff --git a/include/model_ids.h b/include/model_ids.h index 57f38145..09319dae 100644 --- a/include/model_ids.h +++ b/include/model_ids.h @@ -24,12 +24,6 @@ /* Global models that are loaded for every level */ #define MODEL_MARIO 0x01 // mario_geo -#define MODEL_LUIGI 0xE2 // luigi_geo -#define MODEL_BUBBLE_PLAYER 0xE3 // water_bomb_geo - -/* Additional custom models */ - -#define MODEL_LUIGIS_CAP 0xE4 // luigis_cap_geo /* Various static level geometry, the geo layout differs but terrain object presets treat them the same.*/ @@ -591,4 +585,14 @@ #define MODEL_VCUTM_WARP_PIPE MODEL_LEVEL_GEOMETRY_16 // warp_pipe_geo #define MODEL_CASTLE_GROUNDS_WARP_PIPE MODEL_LEVEL_GEOMETRY_16 // warp_pipe_geo +/* Custom coop models */ + +#define MODEL_BUBBLE_PLAYER 0xE2 // water_bomb_geo + +#define MODEL_LUIGI 0xE3 // luigi_geo +#define MODEL_LUIGIS_CAP 0xE4 // luigis_cap_geo +#define MODEL_LUIGIS_METAL_CAP 0xE5 // luigis_metal_cap_geo +#define MODEL_LUIGIS_WING_CAP 0xE6 // luigis_wing_cap_geo +#define MODEL_LUIGIS_WINGED_METAL_CAP 0xE7 // luigis_winged_metal_cap_geo + #endif // MODEL_IDS_H diff --git a/levels/scripts.c b/levels/scripts.c index 7d5949a3..7ccd613f 100644 --- a/levels/scripts.c +++ b/levels/scripts.c @@ -68,8 +68,6 @@ const LevelScript level_main_scripts_entry[] = { LOAD_RAW( /*seg*/ 0x13, _behaviorSegmentRomStart, _behaviorSegmentRomEnd), ALLOC_LEVEL_POOL(), LOAD_MODEL_FROM_GEO(MODEL_MARIO, mario_geo), - LOAD_MODEL_FROM_GEO(MODEL_LUIGI, luigi_geo), // custom luigi - LOAD_MODEL_FROM_GEO(MODEL_BUBBLE_PLAYER, water_bomb_geo), LOAD_MODEL_FROM_GEO(MODEL_SMOKE, smoke_geo), LOAD_MODEL_FROM_GEO(MODEL_SPARKLES, sparkles_geo), LOAD_MODEL_FROM_GEO(MODEL_BUBBLE, bubble_geo), @@ -106,7 +104,6 @@ const LevelScript level_main_scripts_entry[] = { LOAD_MODEL_FROM_GEO(MODEL_MARIOS_WING_CAP, marios_wing_cap_geo), LOAD_MODEL_FROM_GEO(MODEL_MARIOS_CAP, marios_cap_geo), LOAD_MODEL_FROM_GEO(MODEL_MARIOS_CAP, marios_cap_geo), // repeated - LOAD_MODEL_FROM_GEO(MODEL_LUIGIS_CAP, luigis_cap_geo), // custom luigi_cap LOAD_MODEL_FROM_GEO(MODEL_BOWSER_KEY_CUTSCENE, bowser_key_cutscene_geo), LOAD_MODEL_FROM_GEO(MODEL_BOWSER_KEY, bowser_key_geo), LOAD_MODEL_FROM_GEO(MODEL_RED_FLAME_SHADOW, red_flame_shadow_geo), @@ -117,6 +114,19 @@ const LevelScript level_main_scripts_entry[] = { LOAD_MODEL_FROM_GEO(MODEL_EXPLOSION, explosion_geo), LOAD_MODEL_FROM_GEO(MODEL_DIRT_ANIMATION, dirt_animation_geo), LOAD_MODEL_FROM_GEO(MODEL_CARTOON_STAR, cartoon_star_geo), + + // CUSTOM MODELS BEGIN + + LOAD_MODEL_FROM_GEO(MODEL_BUBBLE_PLAYER, water_bomb_geo), + + LOAD_MODEL_FROM_GEO(MODEL_LUIGI, luigi_geo), + LOAD_MODEL_FROM_GEO(MODEL_LUIGIS_CAP, luigis_cap_geo), + LOAD_MODEL_FROM_GEO(MODEL_LUIGIS_METAL_CAP, luigis_metal_cap_geo), + LOAD_MODEL_FROM_GEO(MODEL_LUIGIS_WING_CAP, luigis_wing_cap_geo), + LOAD_MODEL_FROM_GEO(MODEL_LUIGIS_WINGED_METAL_CAP, luigis_winged_metal_cap_geo), + + // CUSTOM MODELS END + FREE_LEVEL_POOL(), CALL(/*arg*/ 0, /*func*/ lvl_init_from_save_file), LOOP_BEGIN(), diff --git a/src/game/behaviors/exclamation_box.inc.c b/src/game/behaviors/exclamation_box.inc.c index e177cf11..9a0b54fb 100644 --- a/src/game/behaviors/exclamation_box.inc.c +++ b/src/game/behaviors/exclamation_box.inc.c @@ -17,8 +17,7 @@ struct Struct802C0DF0 sExclamationBoxContents[] = { { 0, 0, 0, MODEL_MARIOS_WING { 1, 0, 0, MODEL_MARIOS_METAL_CAP, bhvMetalCap }, { 2, 0, 0, MODEL_MARIOS_CAP, bhvVanishCap }, { 3, 0, 0, MODEL_KOOPA_SHELL, bhvKoopaShell }, - { 4, 0, 0, MODEL_YELLOW_COIN, - bhvSingleCoinGetsSpawned }, + { 4, 0, 0, MODEL_YELLOW_COIN, bhvSingleCoinGetsSpawned }, { 5, 0, 0, MODEL_NONE, bhvThreeCoinsSpawn }, { 6, 0, 0, MODEL_NONE, bhvTenCoinsSpawn }, { 7, 0, 0, MODEL_1UP, bhv1upWalking }, @@ -112,8 +111,19 @@ void exclamation_box_act_3(void) { o->oAction = 4; } +static s32 exclamation_replace_model(struct MarioState* m, s32 model) { + switch (model) { + case MODEL_MARIOS_CAP: return m->character->capModelId; + case MODEL_MARIOS_METAL_CAP: return m->character->capMetalModelId; + case MODEL_MARIOS_WING_CAP: return m->character->capWingModelId; + case MODEL_MARIOS_WINGED_METAL_CAP: return m->character->capMetalWingModelId; + default: return model; + } +} + void exclamation_box_spawn_contents(struct Struct802C0DF0 *a0, u8 a1) { - struct Object* player = nearest_player_to_object(o); + struct MarioState* m = nearest_mario_state_to_object(o); + struct Object* player = m->marioObj; struct Object *sp1C = NULL; if (o->oExclamationBoxForce) { @@ -122,7 +132,9 @@ void exclamation_box_spawn_contents(struct Struct802C0DF0 *a0, u8 a1) { while (a0->unk0 != 99) { if (a1 == a0->unk0) { - sp1C = spawn_object(o, a0->model, a0->behavior); + s32 model = exclamation_replace_model(m, a0->model); + + sp1C = spawn_object(o, model, a0->behavior); sp1C->oVelY = 20.0f; sp1C->oForwardVel = 3.0f; sp1C->oMoveAngleYaw = player->oMoveAngleYaw; @@ -139,7 +151,7 @@ void exclamation_box_spawn_contents(struct Struct802C0DF0 *a0, u8 a1) { network_set_sync_id(sp1C); } struct Object* spawn_objects[] = { sp1C }; - u32 models[] = { a0->model }; + u32 models[] = { model }; network_send_spawn_objects(spawn_objects, models, 1); } break; diff --git a/src/game/characters.c b/src/game/characters.c index 9ab61e96..b46a2a5c 100644 --- a/src/game/characters.c +++ b/src/game/characters.c @@ -10,13 +10,16 @@ struct Character gCharacters[CT_MAX] = { [CT_MARIO] = { - .hudHead = ',', - .cameraHudHead = GLYPH_CAM_MARIO_HEAD, - .modelId = MODEL_MARIO, - .capModelId = MODEL_MARIOS_CAP, - .capKleptoAnimState = KLEPTO_ANIM_STATE_HOLDING_CAP, - .capUkikiAnimState = UKIKI_ANIM_STATE_HAT_ON, - .soundFreqScale = 1.0f, + .hudHead = ',', + .cameraHudHead = GLYPH_CAM_MARIO_HEAD, + .modelId = MODEL_MARIO, + .capModelId = MODEL_MARIOS_CAP, + .capMetalModelId = MODEL_MARIOS_METAL_CAP, + .capWingModelId = MODEL_MARIOS_WING_CAP, + .capMetalWingModelId = MODEL_MARIOS_WINGED_METAL_CAP, + .capKleptoAnimState = KLEPTO_ANIM_STATE_HOLDING_CAP, + .capUkikiAnimState = UKIKI_ANIM_STATE_HAT_ON, + .soundFreqScale = 1.0f, // sounds .soundYahWahHoo = SOUND_MARIO_YAH_WAH_HOO, .soundHoohoo = SOUND_MARIO_HOOHOO, @@ -63,13 +66,16 @@ struct Character gCharacters[CT_MAX] = { }, [CT_LUIGI] = { - .hudHead = '.', - .cameraHudHead = GLYPH_CAM_LUIGI_HEAD, - .modelId = MODEL_LUIGI, - .capModelId = MODEL_LUIGIS_CAP, - .capKleptoAnimState = KLEPTO_ANIM_STATE_HOLDING_CAP_LUIGI, - .capUkikiAnimState = UKIKI_ANIM_STATE_HAT_ON_LUIGI, - .soundFreqScale = 1.0f, + .hudHead = '.', + .cameraHudHead = GLYPH_CAM_LUIGI_HEAD, + .modelId = MODEL_LUIGI, + .capModelId = MODEL_LUIGIS_CAP, + .capMetalModelId = MODEL_LUIGIS_METAL_CAP, + .capWingModelId = MODEL_LUIGIS_WING_CAP, + .capMetalWingModelId = MODEL_LUIGIS_WINGED_METAL_CAP, + .capKleptoAnimState = KLEPTO_ANIM_STATE_HOLDING_CAP_LUIGI, + .capUkikiAnimState = UKIKI_ANIM_STATE_HAT_ON_LUIGI, + .soundFreqScale = 1.0f, // sounds .soundYahWahHoo = SOUND_LUIGI_YAH_WAH_HOO, .soundHoohoo = SOUND_LUIGI_HOOHOO, diff --git a/src/game/characters.h b/src/game/characters.h index f0b44151..08fe5c23 100644 --- a/src/game/characters.h +++ b/src/game/characters.h @@ -16,6 +16,9 @@ struct Character { u32 cameraHudHead; u32 modelId; u32 capModelId; + u32 capMetalModelId; + u32 capWingModelId; + u32 capMetalWingModelId; s32 capKleptoAnimState; s32 capUkikiAnimState; f32 soundFreqScale;