mirror of
https://github.com/coop-deluxe/sm64coopdx.git
synced 2024-11-28 15:03:01 +00:00
bring back the ability to lose your cap (#229)
* bring back the ability to lose your cap * run autogen and add "cap" to the mario states guide * fix some indentation
This commit is contained in:
parent
4b567d8fc3
commit
a939ddc07b
13 changed files with 32 additions and 39 deletions
|
@ -708,6 +708,7 @@
|
||||||
--- @field public animation MarioAnimation
|
--- @field public animation MarioAnimation
|
||||||
--- @field public area Area
|
--- @field public area Area
|
||||||
--- @field public bubbleObj Object
|
--- @field public bubbleObj Object
|
||||||
|
--- @field public cap integer
|
||||||
--- @field public capTimer integer
|
--- @field public capTimer integer
|
||||||
--- @field public ceil Surface
|
--- @field public ceil Surface
|
||||||
--- @field public ceilHeight number
|
--- @field public ceilHeight number
|
||||||
|
|
|
@ -86,6 +86,7 @@ The `MarioState` structure contains 76 different variables, this guide will try
|
||||||
|`knockbackTimer`|`integer`|Used for invincibilty when flying through the air after a bonk or being hit by another player.
|
|`knockbackTimer`|`integer`|Used for invincibilty when flying through the air after a bonk or being hit by another player.
|
||||||
|`specialTripleJump`|`integer`|Can be used as a bool, sets whether or not to use the special triple jump unlocked after talking to Yoshi.
|
|`specialTripleJump`|`integer`|Can be used as a bool, sets whether or not to use the special triple jump unlocked after talking to Yoshi.
|
||||||
|`wallNormal`|`Vec3f`|The angle of the current wall on the x, y, and z axis.
|
|`wallNormal`|`Vec3f`|The angle of the current wall on the x, y, and z axis.
|
||||||
|
|`cap`|`integer`|Where Mario's cap is meant to be. Can be on Mario's head, the snowman's head in Snowman's Land, held by Klepto, or on Ukiki's head.
|
||||||
|
|
||||||
## Section 3: When should I use `gMarioStates`?
|
## Section 3: When should I use `gMarioStates`?
|
||||||
Most of the time you won't be using `gMarioStates[0]` to access your Mario, but rather use a hook. A lot of hooks pass `m` through the function. What does this mean? Well, here is a example with comments to explain it as good as possible:
|
Most of the time you won't be using `gMarioStates[0]` to access your Mario, but rather use a hook. A lot of hooks pass `m` through the function. What does this mean? Well, here is a example with comments to explain it as good as possible:
|
||||||
|
|
|
@ -1034,6 +1034,7 @@
|
||||||
| animation | [MarioAnimation](structs.md#MarioAnimation) | |
|
| animation | [MarioAnimation](structs.md#MarioAnimation) | |
|
||||||
| area | [Area](structs.md#Area) | |
|
| area | [Area](structs.md#Area) | |
|
||||||
| bubbleObj | [Object](structs.md#Object) | |
|
| bubbleObj | [Object](structs.md#Object) | |
|
||||||
|
| cap | `integer` | |
|
||||||
| capTimer | `integer` | |
|
| capTimer | `integer` | |
|
||||||
| ceil | [Surface](structs.md#Surface) | |
|
| ceil | [Surface](structs.md#Surface) | |
|
||||||
| ceilHeight | `number` | |
|
| ceilHeight | `number` | |
|
||||||
|
|
|
@ -397,6 +397,7 @@ struct MarioState
|
||||||
/*????*/ u8 specialTripleJump;
|
/*????*/ u8 specialTripleJump;
|
||||||
/*????*/ Vec3f wallNormal;
|
/*????*/ Vec3f wallNormal;
|
||||||
/*????*/ u8 visibleToEnemies;
|
/*????*/ u8 visibleToEnemies;
|
||||||
|
/*????*/ u32 cap;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct TextureInfo
|
struct TextureInfo
|
||||||
|
|
|
@ -193,28 +193,22 @@ void bhv_normal_cap_init(void) {
|
||||||
o->oFriction = 0.89f;
|
o->oFriction = 0.89f;
|
||||||
o->oBuoyancy = 0.9f;
|
o->oBuoyancy = 0.9f;
|
||||||
o->oOpacity = 0xFF;
|
o->oOpacity = 0xFF;
|
||||||
|
|
||||||
save_file_set_cap_pos(o->oPosX, o->oPosY, o->oPosZ);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void normal_cap_set_save_flags(void) {
|
void normal_cap_set_save_flags(void) {
|
||||||
save_file_clear_flags(SAVE_FLAG_CAP_ON_GROUND);
|
save_file_clear_flags(SAVE_FLAG_CAP_ON_GROUND);
|
||||||
|
|
||||||
switch (gCurrCourseNum) {
|
switch (gCurrCourseNum) {
|
||||||
case COURSE_SSL:
|
|
||||||
save_file_set_flags(SAVE_FLAG_CAP_ON_KLEPTO);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case COURSE_SL:
|
case COURSE_SL:
|
||||||
save_file_set_flags(SAVE_FLAG_CAP_ON_MR_BLIZZARD);
|
gMarioStates[0].cap = SAVE_FLAG_CAP_ON_MR_BLIZZARD;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case COURSE_TTM:
|
case COURSE_TTM:
|
||||||
save_file_set_flags(SAVE_FLAG_CAP_ON_UKIKI);
|
gMarioStates[0].cap = SAVE_FLAG_CAP_ON_UKIKI;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
save_file_set_flags(SAVE_FLAG_CAP_ON_KLEPTO);
|
gMarioStates[0].cap = SAVE_FLAG_CAP_ON_KLEPTO;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -251,9 +245,6 @@ void bhv_normal_cap_loop(void) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((s32) o->oForwardVel != 0)
|
|
||||||
save_file_set_cap_pos(o->oPosX, o->oPosY, o->oPosZ);
|
|
||||||
|
|
||||||
if (o->activeFlags == ACTIVE_FLAG_DEACTIVATED)
|
if (o->activeFlags == ACTIVE_FLAG_DEACTIVATED)
|
||||||
normal_cap_set_save_flags();
|
normal_cap_set_save_flags();
|
||||||
|
|
||||||
|
|
|
@ -97,12 +97,11 @@ void bhv_klepto_init(void) {
|
||||||
o->oKleptoStartPosY = o->oPosY;
|
o->oKleptoStartPosY = o->oPosY;
|
||||||
o->oKleptoStartPosZ = o->oPosZ;
|
o->oKleptoStartPosZ = o->oPosZ;
|
||||||
|
|
||||||
// skip hat save flags
|
if (gMarioStates[0].cap & SAVE_FLAG_CAP_ON_KLEPTO) {
|
||||||
//if (save_file_get_flags() & SAVE_FLAG_CAP_ON_KLEPTO) {
|
o->oAnimState = KLEPTO_ANIM_STATE_HOLDING_CAP;
|
||||||
// o->oAnimState = KLEPTO_ANIM_STATE_HOLDING_CAP;
|
} else {
|
||||||
//} else {
|
|
||||||
o->oAction = KLEPTO_ACT_WAIT_FOR_MARIO;
|
o->oAction = KLEPTO_ACT_WAIT_FOR_MARIO;
|
||||||
//}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
struct SyncObject* so = sync_object_init(o, 4000.0f);
|
struct SyncObject* so = sync_object_init(o, 4000.0f);
|
||||||
|
@ -419,7 +418,7 @@ void bhv_klepto_update(void) {
|
||||||
u8 modelIndex = (np->overrideModelIndex < CT_MAX) ? np->overrideModelIndex : 0;
|
u8 modelIndex = (np->overrideModelIndex < CT_MAX) ? np->overrideModelIndex : 0;
|
||||||
u32 capModel = gCharacters[modelIndex].capModelId;
|
u32 capModel = gCharacters[modelIndex].capModelId;
|
||||||
|
|
||||||
save_file_clear_flags(SAVE_FLAG_CAP_ON_KLEPTO);
|
gMarioStates[0].cap &= ~SAVE_FLAG_CAP_ON_KLEPTO;
|
||||||
|
|
||||||
struct Object* cap = spawn_object(o, capModel, bhvNormalCap);
|
struct Object* cap = spawn_object(o, capModel, bhvNormalCap);
|
||||||
if (cap != NULL) {
|
if (cap != NULL) {
|
||||||
|
|
|
@ -60,7 +60,7 @@ void bhv_mr_blizzard_init(void) {
|
||||||
} else {
|
} else {
|
||||||
if (o->oBehParams2ndByte != MR_BLIZZARD_STYPE_NO_CAP) {
|
if (o->oBehParams2ndByte != MR_BLIZZARD_STYPE_NO_CAP) {
|
||||||
// Cap wearing Mr. Blizzard from SL.
|
// Cap wearing Mr. Blizzard from SL.
|
||||||
if (save_file_get_flags() & SAVE_FLAG_CAP_ON_MR_BLIZZARD) {
|
if (gMarioStates[0].cap & SAVE_FLAG_CAP_ON_MR_BLIZZARD) {
|
||||||
o->oAnimState = 1;
|
o->oAnimState = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -244,7 +244,7 @@ static void mr_blizzard_act_death(void) {
|
||||||
// If Mr. Blizzard is wearing Mario's cap, clear
|
// If Mr. Blizzard is wearing Mario's cap, clear
|
||||||
// the save flag and spawn Mario's cap.
|
// the save flag and spawn Mario's cap.
|
||||||
if (o->oAnimState) {
|
if (o->oAnimState) {
|
||||||
save_file_clear_flags(SAVE_FLAG_CAP_ON_MR_BLIZZARD);
|
gMarioStates[0].cap &= ~SAVE_FLAG_CAP_ON_MR_BLIZZARD;
|
||||||
|
|
||||||
cap = spawn_object_relative(0, 5, 105, 0, o, MODEL_MARIOS_CAP, bhvNormalCap);
|
cap = spawn_object_relative(0, 5, 105, 0, o, MODEL_MARIOS_CAP, bhvNormalCap);
|
||||||
if (cap != NULL) {
|
if (cap != NULL) {
|
||||||
|
|
|
@ -644,13 +644,12 @@ void cap_ukiki_held_loop(void) {
|
||||||
* Initializatation for ukiki, determines if it has Mario's cap.
|
* Initializatation for ukiki, determines if it has Mario's cap.
|
||||||
*/
|
*/
|
||||||
void bhv_ukiki_init(void) {
|
void bhv_ukiki_init(void) {
|
||||||
// skip hat save flags
|
if (o->oBehParams2ndByte == UKIKI_CAP) {
|
||||||
//if (o->oBehParams2ndByte == UKIKI_CAP) {
|
if (gMarioStates[0].cap & SAVE_FLAG_CAP_ON_UKIKI) {
|
||||||
// if (save_file_get_flags() & SAVE_FLAG_CAP_ON_UKIKI) {
|
o->oUkikiTextState = UKIKI_TEXT_HAS_CAP;
|
||||||
// o->oUkikiTextState = UKIKI_TEXT_HAS_CAP;
|
o->oUkikiHasCap |= UKIKI_CAP_ON;
|
||||||
// o->oUkikiHasCap |= UKIKI_CAP_ON;
|
}
|
||||||
// }
|
}
|
||||||
//}
|
|
||||||
|
|
||||||
sync_object_init(o, 4000.0f);
|
sync_object_init(o, 4000.0f);
|
||||||
sync_object_init_field(o, &o->oUkikiTauntCounter);
|
sync_object_init_field(o, &o->oUkikiTauntCounter);
|
||||||
|
|
|
@ -394,7 +394,7 @@ void mario_blow_off_cap(struct MarioState *m, f32 capSpeed) {
|
||||||
struct Object *capObject;
|
struct Object *capObject;
|
||||||
|
|
||||||
if (does_mario_have_normal_cap_on_head(m)) {
|
if (does_mario_have_normal_cap_on_head(m)) {
|
||||||
save_file_set_cap_pos(m->pos[0], m->pos[1], m->pos[2]);
|
m->cap = SAVE_FLAG_CAP_ON_MR_BLIZZARD;
|
||||||
|
|
||||||
m->flags &= ~(MARIO_NORMAL_CAP | MARIO_CAP_ON_HEAD);
|
m->flags &= ~(MARIO_NORMAL_CAP | MARIO_CAP_ON_HEAD);
|
||||||
|
|
||||||
|
@ -426,7 +426,7 @@ u32 mario_lose_cap_to_enemy(struct MarioState* m, u32 arg) {
|
||||||
u32 wasWearingCap = FALSE;
|
u32 wasWearingCap = FALSE;
|
||||||
|
|
||||||
if (does_mario_have_normal_cap_on_head(m)) {
|
if (does_mario_have_normal_cap_on_head(m)) {
|
||||||
save_file_set_flags(arg == 1 ? SAVE_FLAG_CAP_ON_KLEPTO : SAVE_FLAG_CAP_ON_UKIKI);
|
gMarioStates[0].cap = (arg == 1 ? SAVE_FLAG_CAP_ON_KLEPTO : SAVE_FLAG_CAP_ON_UKIKI);
|
||||||
m->flags &= ~(MARIO_NORMAL_CAP | MARIO_CAP_ON_HEAD);
|
m->flags &= ~(MARIO_NORMAL_CAP | MARIO_CAP_ON_HEAD);
|
||||||
wasWearingCap = TRUE;
|
wasWearingCap = TRUE;
|
||||||
}
|
}
|
||||||
|
|
|
@ -2149,13 +2149,12 @@ void init_single_mario(struct MarioState* m) {
|
||||||
|
|
||||||
m->invincTimer = 0;
|
m->invincTimer = 0;
|
||||||
m->visibleToEnemies = TRUE;
|
m->visibleToEnemies = TRUE;
|
||||||
|
|
||||||
// always put the cap on head
|
if (m->cap & (SAVE_FLAG_CAP_ON_GROUND | SAVE_FLAG_CAP_ON_KLEPTO | SAVE_FLAG_CAP_ON_UKIKI | SAVE_FLAG_CAP_ON_MR_BLIZZARD)) {
|
||||||
/*if (save_file_get_flags() & (SAVE_FLAG_CAP_ON_GROUND | SAVE_FLAG_CAP_ON_KLEPTO | SAVE_FLAG_CAP_ON_UKIKI | SAVE_FLAG_CAP_ON_MR_BLIZZARD)) {
|
|
||||||
m->flags = 0;
|
m->flags = 0;
|
||||||
} else {*/
|
} else {
|
||||||
m->flags = (MARIO_CAP_ON_HEAD | MARIO_NORMAL_CAP);
|
m->flags = (MARIO_CAP_ON_HEAD | MARIO_NORMAL_CAP);
|
||||||
//}
|
}
|
||||||
|
|
||||||
m->forwardVel = 0.0f;
|
m->forwardVel = 0.0f;
|
||||||
m->squishTimer = 0;
|
m->squishTimer = 0;
|
||||||
|
@ -2198,7 +2197,6 @@ void init_single_mario(struct MarioState* m) {
|
||||||
|
|
||||||
m->action = (m->pos[1] <= (m->waterLevel - 100)) ? ACT_WATER_IDLE : ACT_IDLE;
|
m->action = (m->pos[1] <= (m->waterLevel - 100)) ? ACT_WATER_IDLE : ACT_IDLE;
|
||||||
|
|
||||||
mario_reset_bodystate(m);
|
|
||||||
update_mario_info_for_cam(m);
|
update_mario_info_for_cam(m);
|
||||||
m->marioBodyState->punchState = 0;
|
m->marioBodyState->punchState = 0;
|
||||||
|
|
||||||
|
|
|
@ -706,16 +706,16 @@ u16 save_file_get_sound_mode(void) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void save_file_move_cap_to_default_location(void) {
|
void save_file_move_cap_to_default_location(void) {
|
||||||
if (save_file_get_flags() & SAVE_FLAG_CAP_ON_GROUND) {
|
if (save_file_get_flags() & SAVE_FLAG_CAP_ON_GROUND || gMarioStates[0].cap == SAVE_FLAG_CAP_ON_GROUND) {
|
||||||
switch (gSaveBuffer.files[gCurrSaveFileNum - 1][gSaveFileUsingBackupSlot].capLevel) {
|
switch (gSaveBuffer.files[gCurrSaveFileNum - 1][gSaveFileUsingBackupSlot].capLevel) {
|
||||||
case LEVEL_SSL:
|
case LEVEL_SSL:
|
||||||
save_file_set_flags(SAVE_FLAG_CAP_ON_KLEPTO);
|
gMarioStates[0].cap = SAVE_FLAG_CAP_ON_KLEPTO;
|
||||||
break;
|
break;
|
||||||
case LEVEL_SL:
|
case LEVEL_SL:
|
||||||
save_file_set_flags(SAVE_FLAG_CAP_ON_MR_BLIZZARD);
|
gMarioStates[0].cap = SAVE_FLAG_CAP_ON_MR_BLIZZARD;
|
||||||
break;
|
break;
|
||||||
case LEVEL_TTM:
|
case LEVEL_TTM:
|
||||||
save_file_set_flags(SAVE_FLAG_CAP_ON_UKIKI);
|
gMarioStates[0].cap = SAVE_FLAG_CAP_ON_UKIKI;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
save_file_clear_flags(SAVE_FLAG_CAP_ON_GROUND);
|
save_file_clear_flags(SAVE_FLAG_CAP_ON_GROUND);
|
||||||
|
|
|
@ -821,6 +821,7 @@ static struct LuaObjectField sMarioStateFields[LUA_MARIO_STATE_FIELD_COUNT] = {
|
||||||
{ "animation", LVT_COBJECT_P, offsetof(struct MarioState, animation), false, LOT_MARIOANIMATION },
|
{ "animation", LVT_COBJECT_P, offsetof(struct MarioState, animation), false, LOT_MARIOANIMATION },
|
||||||
{ "area", LVT_COBJECT_P, offsetof(struct MarioState, area), false, LOT_AREA },
|
{ "area", LVT_COBJECT_P, offsetof(struct MarioState, area), false, LOT_AREA },
|
||||||
{ "bubbleObj", LVT_COBJECT_P, offsetof(struct MarioState, bubbleObj), false, LOT_OBJECT },
|
{ "bubbleObj", LVT_COBJECT_P, offsetof(struct MarioState, bubbleObj), false, LOT_OBJECT },
|
||||||
|
{ "cap", LVT_U32, offsetof(struct MarioState, cap), false, LOT_NONE },
|
||||||
{ "capTimer", LVT_U16, offsetof(struct MarioState, capTimer), false, LOT_NONE },
|
{ "capTimer", LVT_U16, offsetof(struct MarioState, capTimer), false, LOT_NONE },
|
||||||
{ "ceil", LVT_COBJECT_P, offsetof(struct MarioState, ceil), false, LOT_SURFACE },
|
{ "ceil", LVT_COBJECT_P, offsetof(struct MarioState, ceil), false, LOT_SURFACE },
|
||||||
{ "ceilHeight", LVT_F32, offsetof(struct MarioState, ceilHeight), false, LOT_NONE },
|
{ "ceilHeight", LVT_F32, offsetof(struct MarioState, ceilHeight), false, LOT_NONE },
|
||||||
|
|
|
@ -515,6 +515,7 @@ void network_shutdown(bool sendLeaving, bool exiting, bool popup) {
|
||||||
network_player_init();
|
network_player_init();
|
||||||
camera_set_use_course_specific_settings(true);
|
camera_set_use_course_specific_settings(true);
|
||||||
free_vtx_scroll_targets();
|
free_vtx_scroll_targets();
|
||||||
|
gMarioStates[0].cap = 0;
|
||||||
|
|
||||||
struct Controller* cnt = gMarioStates[0].controller;
|
struct Controller* cnt = gMarioStates[0].controller;
|
||||||
cnt->rawStickX = 0;
|
cnt->rawStickX = 0;
|
||||||
|
|
Loading…
Reference in a new issue