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:
Isaac0-dev 2023-03-03 16:46:46 +10:00 committed by GitHub
parent c22c03a823
commit 5b1b20a0ae
13 changed files with 32 additions and 39 deletions

View File

@ -708,6 +708,7 @@
--- @field public animation MarioAnimation
--- @field public area Area
--- @field public bubbleObj Object
--- @field public cap integer
--- @field public capTimer integer
--- @field public ceil Surface
--- @field public ceilHeight number

View File

@ -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.
|`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.
|`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`?
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:

View File

@ -1034,6 +1034,7 @@
| animation | [MarioAnimation](structs.md#MarioAnimation) | |
| area | [Area](structs.md#Area) | |
| bubbleObj | [Object](structs.md#Object) | |
| cap | `integer` | |
| capTimer | `integer` | |
| ceil | [Surface](structs.md#Surface) | |
| ceilHeight | `number` | |

View File

@ -397,6 +397,7 @@ struct MarioState
/*????*/ u8 specialTripleJump;
/*????*/ Vec3f wallNormal;
/*????*/ u8 visibleToEnemies;
/*????*/ u32 cap;
};
struct TextureInfo

View File

@ -193,28 +193,22 @@ void bhv_normal_cap_init(void) {
o->oFriction = 0.89f;
o->oBuoyancy = 0.9f;
o->oOpacity = 0xFF;
save_file_set_cap_pos(o->oPosX, o->oPosY, o->oPosZ);
}
void normal_cap_set_save_flags(void) {
save_file_clear_flags(SAVE_FLAG_CAP_ON_GROUND);
switch (gCurrCourseNum) {
case COURSE_SSL:
save_file_set_flags(SAVE_FLAG_CAP_ON_KLEPTO);
break;
case COURSE_SL:
save_file_set_flags(SAVE_FLAG_CAP_ON_MR_BLIZZARD);
gMarioStates[0].cap = SAVE_FLAG_CAP_ON_MR_BLIZZARD;
break;
case COURSE_TTM:
save_file_set_flags(SAVE_FLAG_CAP_ON_UKIKI);
gMarioStates[0].cap = SAVE_FLAG_CAP_ON_UKIKI;
break;
default:
save_file_set_flags(SAVE_FLAG_CAP_ON_KLEPTO);
gMarioStates[0].cap = SAVE_FLAG_CAP_ON_KLEPTO;
break;
}
}
@ -251,9 +245,6 @@ void bhv_normal_cap_loop(void) {
break;
}
if ((s32) o->oForwardVel != 0)
save_file_set_cap_pos(o->oPosX, o->oPosY, o->oPosZ);
if (o->activeFlags == ACTIVE_FLAG_DEACTIVATED)
normal_cap_set_save_flags();

View File

@ -97,12 +97,11 @@ void bhv_klepto_init(void) {
o->oKleptoStartPosY = o->oPosY;
o->oKleptoStartPosZ = o->oPosZ;
// skip hat save flags
//if (save_file_get_flags() & SAVE_FLAG_CAP_ON_KLEPTO) {
// o->oAnimState = KLEPTO_ANIM_STATE_HOLDING_CAP;
//} else {
if (gMarioStates[0].cap & SAVE_FLAG_CAP_ON_KLEPTO) {
o->oAnimState = KLEPTO_ANIM_STATE_HOLDING_CAP;
} else {
o->oAction = KLEPTO_ACT_WAIT_FOR_MARIO;
//}
}
}
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;
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);
if (cap != NULL) {

View File

@ -60,7 +60,7 @@ void bhv_mr_blizzard_init(void) {
} else {
if (o->oBehParams2ndByte != MR_BLIZZARD_STYPE_NO_CAP) {
// 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;
}
}
@ -244,7 +244,7 @@ static void mr_blizzard_act_death(void) {
// If Mr. Blizzard is wearing Mario's cap, clear
// the save flag and spawn Mario's cap.
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);
if (cap != NULL) {

View File

@ -644,13 +644,12 @@ void cap_ukiki_held_loop(void) {
* Initializatation for ukiki, determines if it has Mario's cap.
*/
void bhv_ukiki_init(void) {
// skip hat save flags
//if (o->oBehParams2ndByte == UKIKI_CAP) {
// if (save_file_get_flags() & SAVE_FLAG_CAP_ON_UKIKI) {
// o->oUkikiTextState = UKIKI_TEXT_HAS_CAP;
// o->oUkikiHasCap |= UKIKI_CAP_ON;
// }
//}
if (o->oBehParams2ndByte == UKIKI_CAP) {
if (gMarioStates[0].cap & SAVE_FLAG_CAP_ON_UKIKI) {
o->oUkikiTextState = UKIKI_TEXT_HAS_CAP;
o->oUkikiHasCap |= UKIKI_CAP_ON;
}
}
sync_object_init(o, 4000.0f);
sync_object_init_field(o, &o->oUkikiTauntCounter);

View File

@ -394,7 +394,7 @@ void mario_blow_off_cap(struct MarioState *m, f32 capSpeed) {
struct Object *capObject;
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);
@ -426,7 +426,7 @@ u32 mario_lose_cap_to_enemy(struct MarioState* m, u32 arg) {
u32 wasWearingCap = FALSE;
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);
wasWearingCap = TRUE;
}

View File

@ -2149,13 +2149,12 @@ void init_single_mario(struct MarioState* m) {
m->invincTimer = 0;
m->visibleToEnemies = TRUE;
// always put the cap on head
/*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)) {
if (m->cap & (SAVE_FLAG_CAP_ON_GROUND | SAVE_FLAG_CAP_ON_KLEPTO | SAVE_FLAG_CAP_ON_UKIKI | SAVE_FLAG_CAP_ON_MR_BLIZZARD)) {
m->flags = 0;
} else {*/
} else {
m->flags = (MARIO_CAP_ON_HEAD | MARIO_NORMAL_CAP);
//}
}
m->forwardVel = 0.0f;
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;
mario_reset_bodystate(m);
update_mario_info_for_cam(m);
m->marioBodyState->punchState = 0;

View File

@ -706,16 +706,16 @@ u16 save_file_get_sound_mode(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) {
case LEVEL_SSL:
save_file_set_flags(SAVE_FLAG_CAP_ON_KLEPTO);
gMarioStates[0].cap = SAVE_FLAG_CAP_ON_KLEPTO;
break;
case LEVEL_SL:
save_file_set_flags(SAVE_FLAG_CAP_ON_MR_BLIZZARD);
gMarioStates[0].cap = SAVE_FLAG_CAP_ON_MR_BLIZZARD;
break;
case LEVEL_TTM:
save_file_set_flags(SAVE_FLAG_CAP_ON_UKIKI);
gMarioStates[0].cap = SAVE_FLAG_CAP_ON_UKIKI;
break;
}
save_file_clear_flags(SAVE_FLAG_CAP_ON_GROUND);

View File

@ -821,6 +821,7 @@ static struct LuaObjectField sMarioStateFields[LUA_MARIO_STATE_FIELD_COUNT] = {
{ "animation", LVT_COBJECT_P, offsetof(struct MarioState, animation), false, LOT_MARIOANIMATION },
{ "area", LVT_COBJECT_P, offsetof(struct MarioState, area), false, LOT_AREA },
{ "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 },
{ "ceil", LVT_COBJECT_P, offsetof(struct MarioState, ceil), false, LOT_SURFACE },
{ "ceilHeight", LVT_F32, offsetof(struct MarioState, ceilHeight), false, LOT_NONE },

View File

@ -515,6 +515,7 @@ void network_shutdown(bool sendLeaving, bool exiting, bool popup) {
network_player_init();
camera_set_use_course_specific_settings(true);
free_vtx_scroll_targets();
gMarioStates[0].cap = 0;
struct Controller* cnt = gMarioStates[0].controller;
cnt->rawStickX = 0;