diff --git a/soh/include/functions.h b/soh/include/functions.h index 6b7732ae9..e75777c87 100644 --- a/soh/include/functions.h +++ b/soh/include/functions.h @@ -1090,8 +1090,8 @@ s32 Health_ChangeBy(PlayState* play, s16 healthChange); void Rupees_ChangeBy(s16 rupeeChange); void Inventory_ChangeAmmo(s16 item, s16 ammoChange); void Magic_Fill(PlayState* play); -void func_800876C8(PlayState* play); -s32 func_80087708(PlayState* play, s16 arg1, s16 arg2); +void Magic_Reset(PlayState* play); +s32 Magic_RequestChange(PlayState* play, s16 amount, s16 type); void func_80088AA0(s16 seconds); void func_80088AF0(PlayState* play); void func_80088B34(s16 arg0); diff --git a/soh/src/code/z_actor.c b/soh/src/code/z_actor.c index 1a122cc9b..79a3c8ace 100644 --- a/soh/src/code/z_actor.c +++ b/soh/src/code/z_actor.c @@ -2451,7 +2451,7 @@ void func_80030488(PlayState* play) { void Actor_DisableLens(PlayState* play) { if (play->actorCtx.lensActive) { play->actorCtx.lensActive = false; - func_800876C8(play); + Magic_Reset(play); } } diff --git a/soh/src/code/z_kaleido_setup.c b/soh/src/code/z_kaleido_setup.c index e9f097a45..77cc43e99 100644 --- a/soh/src/code/z_kaleido_setup.c +++ b/soh/src/code/z_kaleido_setup.c @@ -15,7 +15,7 @@ void KaleidoSetup_Update(PlayState* play) { if (pauseCtx->state == 0 && pauseCtx->debugState == 0 && play->gameOverCtx.state == GAMEOVER_INACTIVE && play->sceneLoadFlag == 0 && play->transitionMode == 0 && gSaveContext.cutsceneIndex < 0xFFF0 && gSaveContext.nextCutsceneIndex < 0xFFF0 && !Play_InCsMode(play) && - play->shootingGalleryStatus <= 1 && gSaveContext.magicState != 8 && gSaveContext.magicState != 9 && + play->shootingGalleryStatus <= 1 && gSaveContext.magicState != MAGIC_STATE_STEP_CAPACITY && gSaveContext.magicState != MAGIC_STATE_FILL && (play->sceneNum != SCENE_BOMBCHU_BOWLING_ALLEY || !Flags_GetSwitch(play, 0x38))) { u8 easyPauseBufferEnabled = CVarGetInteger("gCheatEasyPauseBufferEnabled", 0); diff --git a/soh/src/code/z_parameter.c b/soh/src/code/z_parameter.c index 1ff5b35b2..c41d1c188 100644 --- a/soh/src/code/z_parameter.c +++ b/soh/src/code/z_parameter.c @@ -2196,14 +2196,14 @@ u8 Item_Give(PlayState* play, u8 item) { } return Return_Item(item, MOD_NONE, item); } else if (item == ITEM_MAGIC_SMALL) { - if (gSaveContext.magicState != 10) { + if (gSaveContext.magicState != MAGIC_STATE_ADD) { if (play != NULL) { Magic_Fill(play); } } if (play != NULL) { - func_80087708(play, 12, 5); + Magic_RequestChange(play, 12, MAGIC_ADD); } if (!Flags_GetInfTable(INFTABLE_198)) { @@ -2213,13 +2213,13 @@ u8 Item_Give(PlayState* play, u8 item) { return Return_Item(item, MOD_NONE, item); } else if (item == ITEM_MAGIC_LARGE) { - if (gSaveContext.magicState != 10) { + if (gSaveContext.magicState != MAGIC_STATE_ADD) { if (play != NULL) { Magic_Fill(play); } } if (play != NULL) { - func_80087708(play, 24, 5); + Magic_RequestChange(play, 24, MAGIC_ADD); } if (!Flags_GetInfTable(INFTABLE_198)) { @@ -2328,7 +2328,7 @@ u16 Randomizer_Item_Give(PlayState* play, GetItemEntry giEntry) { slot = SLOT(item); if (item == RG_MAGIC_SINGLE) { gSaveContext.isMagicAcquired = true; - gSaveContext.magicFillTarget = 0x30; + gSaveContext.magicFillTarget = MAGIC_NORMAL_METER; Magic_Fill(play); return Return_Item_Entry(giEntry, RG_NONE); } else if (item == RG_MAGIC_DOUBLE) { @@ -2336,7 +2336,7 @@ u16 Randomizer_Item_Give(PlayState* play, GetItemEntry giEntry) { gSaveContext.isMagicAcquired = true; } gSaveContext.isDoubleMagicAcquired = true; - gSaveContext.magicFillTarget = 0x60; + gSaveContext.magicFillTarget = MAGIC_DOUBLE_METER; gSaveContext.magicLevel = 0; Magic_Fill(play); return Return_Item_Entry(giEntry, RG_NONE); @@ -3140,96 +3140,96 @@ void Inventory_ChangeAmmo(s16 item, s16 ammoChange) { void Magic_Fill(PlayState* play) { if (gSaveContext.isMagicAcquired) { gSaveContext.prevMagicState = gSaveContext.magicState; - gSaveContext.magicFillTarget = (gSaveContext.isDoubleMagicAcquired + 1) * 0x30; - gSaveContext.magicState = 9; + gSaveContext.magicFillTarget = (gSaveContext.isDoubleMagicAcquired + 1) * MAGIC_NORMAL_METER; + gSaveContext.magicState = MAGIC_STATE_FILL; } } -void func_800876C8(PlayState* play) { - if ((gSaveContext.magicState != 8) && (gSaveContext.magicState != 9)) { - if (gSaveContext.magicState == 10) { +void Magic_Reset(PlayState* play) { + if ((gSaveContext.magicState != MAGIC_STATE_STEP_CAPACITY) && (gSaveContext.magicState != MAGIC_STATE_FILL)) { + if (gSaveContext.magicState == MAGIC_STATE_ADD) { gSaveContext.prevMagicState = gSaveContext.magicState; } - gSaveContext.magicState = 5; + gSaveContext.magicState = MAGIC_STATE_RESET; } } -s32 func_80087708(PlayState* play, s16 arg1, s16 arg2) { +s32 Magic_RequestChange(PlayState* play, s16 amount, s16 type) { if (!gSaveContext.isMagicAcquired) { - return 0; + return false; } - if ((arg2 != 5) && (gSaveContext.magic - arg1) < 0) { + if ((type != 5) && (gSaveContext.magic - amount) < 0) { if (gSaveContext.magicCapacity != 0) { Audio_PlaySoundGeneral(NA_SE_SY_ERROR, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8); } - return 0; + return false; } - switch (arg2) { - case 0: - case 2: - if ((gSaveContext.magicState == 0) || (gSaveContext.magicState == 7)) { - if (gSaveContext.magicState == 7) { + switch (type) { + case MAGIC_CONSUME_NOW: + case MAGIC_CONSUME_NOW_ALT: + if ((gSaveContext.magicState == MAGIC_STATE_IDLE) || (gSaveContext.magicState == MAGIC_STATE_CONSUME_LENS)) { + if (gSaveContext.magicState == MAGIC_STATE_CONSUME_LENS) { play->actorCtx.lensActive = false; } - gSaveContext.magicTarget = gSaveContext.magic - arg1; - gSaveContext.magicState = 1; + gSaveContext.magicTarget = gSaveContext.magic - amount; + gSaveContext.magicState = MAGIC_STATE_CONSUME_SETUP; return 1; } else { Audio_PlaySoundGeneral(NA_SE_SY_ERROR, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8); - return 0; + return false; } - case 1: - if ((gSaveContext.magicState == 0) || (gSaveContext.magicState == 7)) { - if (gSaveContext.magicState == 7) { + case MAGIC_CONSUME_WAIT_NO_PREVIEW: + if ((gSaveContext.magicState == MAGIC_STATE_IDLE) || (gSaveContext.magicState == MAGIC_STATE_CONSUME_LENS)) { + if (gSaveContext.magicState == MAGIC_STATE_CONSUME_LENS) { play->actorCtx.lensActive = false; } - gSaveContext.magicTarget = gSaveContext.magic - arg1; - gSaveContext.magicState = 6; - return 1; + gSaveContext.magicTarget = gSaveContext.magic - amount; + gSaveContext.magicState = MAGIC_STATE_METER_FLASH_3; + return true; } else { Audio_PlaySoundGeneral(NA_SE_SY_ERROR, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8); - return 0; + return false; } - case 3: - if (gSaveContext.magicState == 0) { + case MAGIC_CONSUME_LENS: + if (gSaveContext.magicState == MAGIC_STATE_IDLE) { if (gSaveContext.magic != 0) { play->interfaceCtx.unk_230 = 80; - gSaveContext.magicState = 7; - return 1; + gSaveContext.magicState = MAGIC_STATE_CONSUME_LENS; + return true; } else { - return 0; + return false; } } else { - if (gSaveContext.magicState == 7) { - return 1; + if (gSaveContext.magicState == MAGIC_STATE_CONSUME_LENS) { + return true; } else { - return 0; + return false; } } - case 4: - if ((gSaveContext.magicState == 0) || (gSaveContext.magicState == 7)) { - if (gSaveContext.magicState == 7) { + case MAGIC_CONSUME_WAIT_PREVIEW: + if ((gSaveContext.magicState == MAGIC_STATE_IDLE) || (gSaveContext.magicState == MAGIC_STATE_CONSUME_LENS)) { + if (gSaveContext.magicState == MAGIC_STATE_CONSUME_LENS) { play->actorCtx.lensActive = false; } - gSaveContext.magicTarget = gSaveContext.magic - arg1; - gSaveContext.magicState = 4; - return 1; + gSaveContext.magicTarget = gSaveContext.magic - amount; + gSaveContext.magicState = MAGIC_STATE_METER_FLASH_2; + return true; } else { Audio_PlaySoundGeneral(NA_SE_SY_ERROR, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8); - return 0; + return false; } - case 5: + case MAGIC_ADD: if (gSaveContext.magicCapacity >= gSaveContext.magic) { - gSaveContext.magicTarget = gSaveContext.magic + arg1; + gSaveContext.magicTarget = gSaveContext.magic + amount; if (gSaveContext.magicTarget >= gSaveContext.magicCapacity) { gSaveContext.magicTarget = gSaveContext.magicCapacity; } - gSaveContext.magicState = 10; - return 1; + gSaveContext.magicState = MAGIC_STATE_ADD; + return true; } break; } @@ -3278,8 +3278,8 @@ void Interface_UpdateMagicBar(PlayState* play) { s16 temp; switch (gSaveContext.magicState) { - case 8: - temp = gSaveContext.magicLevel * 0x30; + case MAGIC_STATE_STEP_CAPACITY: + temp = gSaveContext.magicLevel * MAGIC_NORMAL_METER; if (gSaveContext.magicCapacity != temp) { if (gSaveContext.magicCapacity < temp) { gSaveContext.magicCapacity += 8; @@ -3293,11 +3293,11 @@ void Interface_UpdateMagicBar(PlayState* play) { } } } else { - gSaveContext.magicState = 9; + gSaveContext.magicState = MAGIC_STATE_FILL; } break; - case 9: + case MAGIC_STATE_FILL: gSaveContext.magic += 4; if (gSaveContext.gameMode == 0 && gSaveContext.sceneSetupIndex < 4) { @@ -3314,32 +3314,32 @@ void Interface_UpdateMagicBar(PlayState* play) { } break; - case 1: + case MAGIC_STATE_CONSUME_SETUP: sMagicBorderRatio = 2; - gSaveContext.magicState = 2; + gSaveContext.magicState = MAGIC_STATE_CONSUME; break; - case 2: + case MAGIC_STATE_CONSUME: gSaveContext.magic -= 2; if (gSaveContext.magic <= 0) { gSaveContext.magic = 0; - gSaveContext.magicState = 3; + gSaveContext.magicState = MAGIC_STATE_METER_FLASH_1; if (CVarGetInteger("gCosmetics.Consumable_MagicBorder.Changed", 0)) { sMagicBorder = CVarGetColor24("gCosmetics.Consumable_MagicBorder.Value", sMagicBorder_ori); } else { sMagicBorder = sMagicBorder_ori; } } else if (gSaveContext.magic == gSaveContext.magicTarget) { - gSaveContext.magicState = 3; + gSaveContext.magicState = MAGIC_STATE_METER_FLASH_1; if (CVarGetInteger("gCosmetics.Consumable_MagicBorder.Changed", 0)) { sMagicBorder = CVarGetColor24("gCosmetics.Consumable_MagicBorder.Value", sMagicBorder_ori); } else { sMagicBorder = sMagicBorder_ori; } } - case 3: - case 4: - case 6: + case MAGIC_STATE_METER_FLASH_1: + case MAGIC_STATE_METER_FLASH_2: + case MAGIC_STATE_METER_FLASH_3: temp = sMagicBorderIndexes[sMagicBorderStep]; borderChangeR = ABS(sMagicBorder.r - sMagicBorderColors[temp][0]) / sMagicBorderRatio; borderChangeG = ABS(sMagicBorder.g - sMagicBorderColors[temp][1]) / sMagicBorderRatio; @@ -3376,16 +3376,16 @@ void Interface_UpdateMagicBar(PlayState* play) { } break; - case 5: + case MAGIC_STATE_RESET: if (CVarGetInteger("gCosmetics.Consumable_MagicBorder.Changed", 0)) { sMagicBorder = CVarGetColor24("gCosmetics.Consumable_MagicBorder.Value", sMagicBorder_ori); } else { sMagicBorder = sMagicBorder_ori; } - gSaveContext.magicState = 0; + gSaveContext.magicState = MAGIC_STATE_IDLE; break; - case 7: + case MAGIC_STATE_CONSUME_LENS: if ((play->pauseCtx.state == 0) && (play->pauseCtx.debugState == 0) && (msgCtx->msgMode == MSGMODE_NONE) && (play->gameOverCtx.state == GAMEOVER_INACTIVE) && (play->sceneLoadFlag == 0) && (play->transitionMode == 0) && !Play_InCsMode(play)) { @@ -3402,7 +3402,7 @@ void Interface_UpdateMagicBar(PlayState* play) { play->actorCtx.lensActive = false; Audio_PlaySoundGeneral(NA_SE_SY_GLASSMODE_OFF, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8); - gSaveContext.magicState = 0; + gSaveContext.magicState = MAGIC_STATE_IDLE; if (CVarGetInteger("gCosmetics.Consumable_MagicBorder.Changed", 0)) { sMagicBorder = CVarGetColor24("gCosmetics.Consumable_MagicBorder.Value", sMagicBorder_ori); } else { @@ -3454,7 +3454,7 @@ void Interface_UpdateMagicBar(PlayState* play) { } break; - case 10: + case MAGIC_STATE_ADD: gSaveContext.magic += 4; Audio_PlaySoundGeneral(NA_SE_SY_GAUGE_UP - SFX_FLAG, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8); if (gSaveContext.magic >= gSaveContext.magicTarget) { @@ -3465,7 +3465,7 @@ void Interface_UpdateMagicBar(PlayState* play) { break; default: - gSaveContext.magicState = 0; + gSaveContext.magicState = MAGIC_STATE_IDLE; break; } } @@ -3598,7 +3598,7 @@ void Interface_DrawMagicBar(PlayState* play) { ENVIRONMENT, TEXEL0, ENVIRONMENT, 0, 0, 0, PRIMITIVE); gDPSetEnvColor(OVERLAY_DISP++, 0, 0, 0, 255); - if (gSaveContext.magicState == 4) { + if (gSaveContext.magicState == MAGIC_STATE_METER_FLASH_2) { // Yellow part of the bar indicating the amount of magic to be subtracted gDPSetPrimColor(OVERLAY_DISP++, 0, 0, magicbar_yellow.r, magicbar_yellow.g, magicbar_yellow.b, interfaceCtx->magicAlpha); @@ -5245,7 +5245,7 @@ void Interface_Draw(PlayState* play) { Interface_DrawLineupTick(play); } - if (fullUi || gSaveContext.magicState > 0) { + if (fullUi || gSaveContext.magicState > MAGIC_STATE_IDLE) { Interface_DrawMagicBar(play); } @@ -6541,7 +6541,7 @@ void Interface_Update(PlayState* play) { ((play->csCtx.state == CS_STATE_IDLE) || !Player_InCsMode(play))) { if ((gSaveContext.isMagicAcquired != 0) && (gSaveContext.magicLevel == 0)) { gSaveContext.magicLevel = gSaveContext.isDoubleMagicAcquired + 1; - gSaveContext.magicState = 8; + gSaveContext.magicState = MAGIC_STATE_STEP_CAPACITY; osSyncPrintf(VT_FGCOL(YELLOW)); osSyncPrintf("魔法スター─────ト!!!!!!!!!\n"); // "Magic Start!!!!!!!!!" osSyncPrintf("MAGIC_MAX=%d\n", gSaveContext.magicLevel); diff --git a/soh/src/code/z_play.c b/soh/src/code/z_play.c index fb4628834..3181b741c 100644 --- a/soh/src/code/z_play.c +++ b/soh/src/code/z_play.c @@ -545,7 +545,7 @@ void Play_Init(GameState* thisx) { if (gSaveContext.gameMode != 0 || gSaveContext.cutsceneIndex >= 0xFFF0) { gSaveContext.nayrusLoveTimer = 0; - func_800876C8(play); + Magic_Reset(play); gSaveContext.sceneSetupIndex = (gSaveContext.cutsceneIndex & 0xF) + 4; } else if (!LINK_IS_ADULT && IS_DAY) { gSaveContext.sceneSetupIndex = 0; diff --git a/soh/src/code/z_player_lib.c b/soh/src/code/z_player_lib.c index 32a3e6e48..3b005bbbf 100644 --- a/soh/src/code/z_player_lib.c +++ b/soh/src/code/z_player_lib.c @@ -342,7 +342,7 @@ uint8_t Player_IsCustomLinkModel() { s32 Player_InBlockingCsMode(PlayState* play, Player* this) { return (this->stateFlags1 & 0x20000080) || (this->csMode != 0) || (play->sceneLoadFlag == 0x14) || (this->stateFlags1 & 1) || (this->stateFlags3 & 0x80) || - ((gSaveContext.magicState != 0) && (Player_ActionToMagicSpell(this, this->itemAction) >= 0)); + ((gSaveContext.magicState != MAGIC_STATE_IDLE) && (Player_ActionToMagicSpell(this, this->itemAction) >= 0)); } s32 Player_InCsMode(PlayState* play) { diff --git a/soh/src/overlays/actors/ovl_Arrow_Fire/z_arrow_fire.c b/soh/src/overlays/actors/ovl_Arrow_Fire/z_arrow_fire.c index 850f793da..d257a7fd9 100644 --- a/soh/src/overlays/actors/ovl_Arrow_Fire/z_arrow_fire.c +++ b/soh/src/overlays/actors/ovl_Arrow_Fire/z_arrow_fire.c @@ -55,7 +55,7 @@ void ArrowFire_Init(Actor* thisx, PlayState* play) { } void ArrowFire_Destroy(Actor* thisx, PlayState* play) { - func_800876C8(play); + Magic_Reset(play); LOG_STRING("消滅"); // "Disappearance" } diff --git a/soh/src/overlays/actors/ovl_Arrow_Ice/z_arrow_ice.c b/soh/src/overlays/actors/ovl_Arrow_Ice/z_arrow_ice.c index 2d63f9890..94d7ecabc 100644 --- a/soh/src/overlays/actors/ovl_Arrow_Ice/z_arrow_ice.c +++ b/soh/src/overlays/actors/ovl_Arrow_Ice/z_arrow_ice.c @@ -56,7 +56,7 @@ void ArrowIce_Init(Actor* thisx, PlayState* play) { } void ArrowIce_Destroy(Actor* thisx, PlayState* play) { - func_800876C8(play); + Magic_Reset(play); LOG_STRING("消滅"); // "Disappearance" } diff --git a/soh/src/overlays/actors/ovl_Arrow_Light/z_arrow_light.c b/soh/src/overlays/actors/ovl_Arrow_Light/z_arrow_light.c index 3bea3b09f..9ddfb96a6 100644 --- a/soh/src/overlays/actors/ovl_Arrow_Light/z_arrow_light.c +++ b/soh/src/overlays/actors/ovl_Arrow_Light/z_arrow_light.c @@ -56,7 +56,7 @@ void ArrowLight_Init(Actor* thisx, PlayState* play) { } void ArrowLight_Destroy(Actor* thisx, PlayState* play) { - func_800876C8(play); + Magic_Reset(play); LOG_STRING("消滅"); // "Disappearance" } diff --git a/soh/src/overlays/actors/ovl_Bg_Dy_Yoseizo/z_bg_dy_yoseizo.c b/soh/src/overlays/actors/ovl_Bg_Dy_Yoseizo/z_bg_dy_yoseizo.c index 7223e936f..e8b2be4df 100644 --- a/soh/src/overlays/actors/ovl_Bg_Dy_Yoseizo/z_bg_dy_yoseizo.c +++ b/soh/src/overlays/actors/ovl_Bg_Dy_Yoseizo/z_bg_dy_yoseizo.c @@ -741,7 +741,7 @@ void BgDyYoseizo_Give_Reward(BgDyYoseizo* this, PlayState* play) { switch (actionIndex) { case FAIRY_UPGRADE_MAGIC: gSaveContext.isMagicAcquired = true; - gSaveContext.magicFillTarget = 0x30; + gSaveContext.magicFillTarget = MAGIC_NORMAL_METER; Interface_ChangeAlpha(9); break; case FAIRY_UPGRADE_DOUBLE_MAGIC: @@ -749,7 +749,7 @@ void BgDyYoseizo_Give_Reward(BgDyYoseizo* this, PlayState* play) { gSaveContext.isMagicAcquired = true; } gSaveContext.isDoubleMagicAcquired = true; - gSaveContext.magicFillTarget = 0x60; + gSaveContext.magicFillTarget = MAGIC_DOUBLE_METER; gSaveContext.magicLevel = 0; Interface_ChangeAlpha(9); break; diff --git a/soh/src/overlays/actors/ovl_En_M_Thunder/z_en_m_thunder.c b/soh/src/overlays/actors/ovl_En_M_Thunder/z_en_m_thunder.c index e088b9f10..6f8624518 100644 --- a/soh/src/overlays/actors/ovl_En_M_Thunder/z_en_m_thunder.c +++ b/soh/src/overlays/actors/ovl_En_M_Thunder/z_en_m_thunder.c @@ -85,9 +85,9 @@ void EnMThunder_Init(Actor* thisx, PlayState* play2) { this->unk_1CA = 0; if (player->stateFlags2 & 0x20000) { - if (!gSaveContext.isMagicAcquired || gSaveContext.magicState || + if (!gSaveContext.isMagicAcquired || (gSaveContext.magicState != MAGIC_STATE_IDLE) || (((this->actor.params & 0xFF00) >> 8) && - !(func_80087708(play, (this->actor.params & 0xFF00) >> 8, 0)))) { + !(Magic_RequestChange(play, (this->actor.params & 0xFF00) >> 8, MAGIC_CONSUME_NOW)))) { Audio_PlaySoundGeneral(NA_SE_IT_ROLLING_CUT, &player->actor.projectedPos, 4, &D_801333E0, &D_801333E0, &D_801333E8); Audio_PlaySoundGeneral(NA_SE_IT_SWORD_SWING_HARD, &player->actor.projectedPos, 4, &D_801333E0, &D_801333E0, @@ -116,7 +116,7 @@ void EnMThunder_Destroy(Actor* thisx, PlayState* play) { EnMThunder* this = (EnMThunder*)thisx; if (this->unk_1CA != 0) { - func_800876C8(play); + Magic_Reset(play); } Collider_DestroyCylinder(play, &this->collider); @@ -158,8 +158,8 @@ void func_80A9F408(EnMThunder* this, PlayState* play) { if (this->unk_1CA == 0) { if (player->unk_858 >= 0.1f) { - if ((gSaveContext.magicState) || (((this->actor.params & 0xFF00) >> 8) && - !(func_80087708(play, (this->actor.params & 0xFF00) >> 8, 4)))) { + if ((gSaveContext.magicState != MAGIC_STATE_IDLE) || (((this->actor.params & 0xFF00) >> 8) && + !(Magic_RequestChange(play, (this->actor.params & 0xFF00) >> 8, MAGIC_CONSUME_WAIT_PREVIEW)))) { func_80A9F350(this, play); func_80A9EFE0(this, func_80A9F350); this->unk_1C8 = 0; @@ -193,7 +193,7 @@ void func_80A9F408(EnMThunder* this, PlayState* play) { } else { player->stateFlags2 &= ~0x20000; if ((this->actor.params & 0xFF00) >> 8) { - gSaveContext.magicState = 1; + gSaveContext.magicState = MAGIC_STATE_CONSUME_SETUP; } if (player->unk_858 < 0.85f) { this->collider.info.toucher.dmgFlags = D_80AA044C[this->unk_1C7]; diff --git a/soh/src/overlays/actors/ovl_En_Partner/z_en_partner.c b/soh/src/overlays/actors/ovl_En_Partner/z_en_partner.c index 4a2201ab7..bfd4dfbbe 100644 --- a/soh/src/overlays/actors/ovl_En_Partner/z_en_partner.c +++ b/soh/src/overlays/actors/ovl_En_Partner/z_en_partner.c @@ -195,7 +195,7 @@ void UseBow(Actor* thisx, PlayState* play, u8 started, u8 arrowType) { } else if (started == 0) { if (this->itemTimer <= 0) { if (AMMO(ITEM_BOW) > 0) { - if (arrowType >= 1 && !func_80087708(play, magicArrowCosts[arrowType], 0)) { + if (arrowType >= 1 && !Magic_RequestChange(play, magicArrowCosts[arrowType], MAGIC_CONSUME_NOW)) { func_80078884(NA_SE_SY_ERROR); this->canMove = 1; return; @@ -455,7 +455,7 @@ void UseSpell(Actor* thisx, PlayState* play, u8 started, u8 spellType) { if (started == 0 && this->usedSpell != 0) { this->itemTimer = 10; - gSaveContext.magicState = 5; + gSaveContext.magicState = MAGIC_STATE_RESET; switch (this->usedSpell) { case 1: @@ -487,7 +487,7 @@ void UseSpell(Actor* thisx, PlayState* play, u8 started, u8 spellType) { break; } - gSaveContext.magicState = 3; + gSaveContext.magicState = MAGIC_STATE_METER_FLASH_1; this->magicTimer--; if (this->magicTimer <= 0) { gSaveContext.magic--; @@ -497,7 +497,7 @@ void UseSpell(Actor* thisx, PlayState* play, u8 started, u8 spellType) { this->itemTimer = 10; this->usedSpell = 0; - gSaveContext.magicState = 5; + gSaveContext.magicState = MAGIC_STATE_RESET; } } } diff --git a/soh/src/overlays/actors/ovl_En_Torch2/z_en_torch2.c b/soh/src/overlays/actors/ovl_En_Torch2/z_en_torch2.c index 0a3172fd0..b4b48d2aa 100644 --- a/soh/src/overlays/actors/ovl_En_Torch2/z_en_torch2.c +++ b/soh/src/overlays/actors/ovl_En_Torch2/z_en_torch2.c @@ -568,7 +568,7 @@ void EnTorch2_Update(Actor* thisx, PlayState* play2) { // Causes Dark Link to shield in place when Link is using magic attacks other than the spin attack - if ((gSaveContext.magicState == 3) && (player->meleeWeaponState == 0 || (player->meleeWeaponAnimation < SPIN_ATTACK_1H) || + if ((gSaveContext.magicState == MAGIC_STATE_METER_FLASH_1) && (player->meleeWeaponState == 0 || (player->meleeWeaponAnimation < SPIN_ATTACK_1H) || (player->meleeWeaponAnimation > BIG_SPIN_2H))) { sStickTilt = 0.0f; input->cur.stick_x = 0; diff --git a/soh/src/overlays/actors/ovl_En_Zl3/z_en_zl3.c b/soh/src/overlays/actors/ovl_En_Zl3/z_en_zl3.c index 2c23aa82d..d07f2de50 100644 --- a/soh/src/overlays/actors/ovl_En_Zl3/z_en_zl3.c +++ b/soh/src/overlays/actors/ovl_En_Zl3/z_en_zl3.c @@ -1810,7 +1810,7 @@ void func_80B5772C(EnZl3* this, PlayState* play) { } void func_80B57754(EnZl3* this, PlayState* play) { - if (gSaveContext.magicState == 0) { + if (gSaveContext.magicState == MAGIC_STATE_IDLE) { Actor_Spawn(&play->actorCtx, play, ACTOR_OCEFF_WIPE4, this->actor.world.pos.x, this->actor.world.pos.y, this->actor.world.pos.z, 0, 0, 0, 1, true); func_80B56DA4(this); diff --git a/soh/src/overlays/actors/ovl_Magic_Dark/z_magic_dark.c b/soh/src/overlays/actors/ovl_Magic_Dark/z_magic_dark.c index 882c6b46e..73a588ab3 100644 --- a/soh/src/overlays/actors/ovl_Magic_Dark/z_magic_dark.c +++ b/soh/src/overlays/actors/ovl_Magic_Dark/z_magic_dark.c @@ -65,7 +65,7 @@ void MagicDark_Init(Actor* thisx, PlayState* play) { void MagicDark_Destroy(Actor* thisx, PlayState* play) { if (gSaveContext.nayrusLoveTimer == 0) { - func_800876C8(play); + Magic_Reset(play); } } diff --git a/soh/src/overlays/actors/ovl_Magic_Fire/z_magic_fire.c b/soh/src/overlays/actors/ovl_Magic_Fire/z_magic_fire.c index 75be6e0bc..b245c988c 100644 --- a/soh/src/overlays/actors/ovl_Magic_Fire/z_magic_fire.c +++ b/soh/src/overlays/actors/ovl_Magic_Fire/z_magic_fire.c @@ -93,7 +93,7 @@ void MagicFire_Init(Actor* thisx, PlayState* play) { } void MagicFire_Destroy(Actor* thisx, PlayState* play) { - func_800876C8(play); + Magic_Reset(play); } void MagicFire_UpdateBeforeCast(Actor* thisx, PlayState* play) { diff --git a/soh/src/overlays/actors/ovl_Magic_Wind/z_magic_wind.c b/soh/src/overlays/actors/ovl_Magic_Wind/z_magic_wind.c index 90ca0e269..ac7a35036 100644 --- a/soh/src/overlays/actors/ovl_Magic_Wind/z_magic_wind.c +++ b/soh/src/overlays/actors/ovl_Magic_Wind/z_magic_wind.c @@ -70,7 +70,7 @@ void MagicWind_Init(Actor* thisx, PlayState* play) { void MagicWind_Destroy(Actor* thisx, PlayState* play) { MagicWind* this = (MagicWind*)thisx; SkelCurve_Destroy(play, &this->skelCurve); - func_800876C8(play); + Magic_Reset(play); // "wipe out" LOG_STRING("消滅"); } diff --git a/soh/src/overlays/actors/ovl_Oceff_Spot/z_oceff_spot.c b/soh/src/overlays/actors/ovl_Oceff_Spot/z_oceff_spot.c index 178921453..8aa68b160 100644 --- a/soh/src/overlays/actors/ovl_Oceff_Spot/z_oceff_spot.c +++ b/soh/src/overlays/actors/ovl_Oceff_Spot/z_oceff_spot.c @@ -70,7 +70,7 @@ void OceffSpot_Destroy(Actor* thisx, PlayState* play) { LightContext_RemoveLight(play, &play->lightCtx, this->lightNode1); LightContext_RemoveLight(play, &play->lightCtx, this->lightNode2); - func_800876C8(play); + Magic_Reset(play); if ((gSaveContext.nayrusLoveTimer != 0) && (play->actorCtx.actorLists[ACTORCAT_PLAYER].length != 0)) { player->stateFlags3 |= PLAYER_STATE3_RESTORE_NAYRUS_LOVE; } diff --git a/soh/src/overlays/actors/ovl_Oceff_Storm/z_oceff_storm.c b/soh/src/overlays/actors/ovl_Oceff_Storm/z_oceff_storm.c index d4d9acb92..3869fa6e4 100644 --- a/soh/src/overlays/actors/ovl_Oceff_Storm/z_oceff_storm.c +++ b/soh/src/overlays/actors/ovl_Oceff_Storm/z_oceff_storm.c @@ -60,7 +60,7 @@ void OceffStorm_Destroy(Actor* thisx, PlayState* play) { OceffStorm* this = (OceffStorm*)thisx; Player* player = GET_PLAYER(play); - func_800876C8(play); + Magic_Reset(play); if (gSaveContext.nayrusLoveTimer != 0) { player->stateFlags3 |= PLAYER_STATE3_RESTORE_NAYRUS_LOVE; } diff --git a/soh/src/overlays/actors/ovl_Oceff_Wipe/z_oceff_wipe.c b/soh/src/overlays/actors/ovl_Oceff_Wipe/z_oceff_wipe.c index 41b2d2905..0076a6385 100644 --- a/soh/src/overlays/actors/ovl_Oceff_Wipe/z_oceff_wipe.c +++ b/soh/src/overlays/actors/ovl_Oceff_Wipe/z_oceff_wipe.c @@ -40,7 +40,7 @@ void OceffWipe_Destroy(Actor* thisx, PlayState* play) { OceffWipe* this = (OceffWipe*)thisx; Player* player = GET_PLAYER(play); - func_800876C8(play); + Magic_Reset(play); if (gSaveContext.nayrusLoveTimer != 0) { player->stateFlags3 |= PLAYER_STATE3_RESTORE_NAYRUS_LOVE; } diff --git a/soh/src/overlays/actors/ovl_Oceff_Wipe2/z_oceff_wipe2.c b/soh/src/overlays/actors/ovl_Oceff_Wipe2/z_oceff_wipe2.c index 13a955640..38014b5e2 100644 --- a/soh/src/overlays/actors/ovl_Oceff_Wipe2/z_oceff_wipe2.c +++ b/soh/src/overlays/actors/ovl_Oceff_Wipe2/z_oceff_wipe2.c @@ -40,7 +40,7 @@ void OceffWipe2_Destroy(Actor* thisx, PlayState* play) { OceffWipe2* this = (OceffWipe2*)thisx; Player* player = GET_PLAYER(play); - func_800876C8(play); + Magic_Reset(play); if (gSaveContext.nayrusLoveTimer != 0) { player->stateFlags3 |= PLAYER_STATE3_RESTORE_NAYRUS_LOVE; } diff --git a/soh/src/overlays/actors/ovl_Oceff_Wipe3/z_oceff_wipe3.c b/soh/src/overlays/actors/ovl_Oceff_Wipe3/z_oceff_wipe3.c index eb85a2816..df3fc1a87 100644 --- a/soh/src/overlays/actors/ovl_Oceff_Wipe3/z_oceff_wipe3.c +++ b/soh/src/overlays/actors/ovl_Oceff_Wipe3/z_oceff_wipe3.c @@ -43,7 +43,7 @@ void OceffWipe3_Destroy(Actor* thisx, PlayState* play) { OceffWipe3* this = (OceffWipe3*)thisx; Player* player = GET_PLAYER(play); - func_800876C8(play); + Magic_Reset(play); if (gSaveContext.nayrusLoveTimer != 0) { player->stateFlags3 |= PLAYER_STATE3_RESTORE_NAYRUS_LOVE; } diff --git a/soh/src/overlays/actors/ovl_Oceff_Wipe4/z_oceff_wipe4.c b/soh/src/overlays/actors/ovl_Oceff_Wipe4/z_oceff_wipe4.c index 043db276d..5a66b2991 100644 --- a/soh/src/overlays/actors/ovl_Oceff_Wipe4/z_oceff_wipe4.c +++ b/soh/src/overlays/actors/ovl_Oceff_Wipe4/z_oceff_wipe4.c @@ -39,7 +39,7 @@ void OceffWipe4_Init(Actor* thisx, PlayState* play) { void OceffWipe4_Destroy(Actor* thisx, PlayState* play) { OceffWipe4* this = (OceffWipe4*)thisx; - func_800876C8(play); + Magic_Reset(play); } void OceffWipe4_Update(Actor* thisx, PlayState* play) { diff --git a/soh/src/overlays/actors/ovl_player_actor/z_player.c b/soh/src/overlays/actors/ovl_player_actor/z_player.c index a4d933c58..5f799227b 100644 --- a/soh/src/overlays/actors/ovl_player_actor/z_player.c +++ b/soh/src/overlays/actors/ovl_player_actor/z_player.c @@ -2224,7 +2224,7 @@ s32 func_8083442C(Player* this, PlayState* play) { s32 magicArrowType; if ((this->heldItemAction >= PLAYER_IA_BOW_FIRE) && (this->heldItemAction <= PLAYER_IA_BOW_0E) && - (gSaveContext.magicState != 0)) { + (gSaveContext.magicState != MAGIC_STATE_IDLE)) { func_80078884(NA_SE_SY_ERROR); } else { func_80833638(this, func_808351D4); @@ -2240,7 +2240,7 @@ s32 func_8083442C(Player* this, PlayState* play) { if (this->unk_860 >= 0) { if ((magicArrowType >= 0) && (magicArrowType <= 2) && - !func_80087708(play, sMagicArrowCosts[magicArrowType], 0)) { + !Magic_RequestChange(play, sMagicArrowCosts[magicArrowType], MAGIC_CONSUME_NOW)) { arrowType = ARROW_NORMAL; } @@ -2979,7 +2979,7 @@ void func_80835F44(PlayState* play, Player* this, s32 item) { } if (actionParam == PLAYER_IA_LENS_OF_TRUTH) { - if (func_80087708(play, 0, 3)) { + if (Magic_RequestChange(play, 0, MAGIC_CONSUME_LENS)) { if (play->actorCtx.lensActive) { Actor_DisableLens(play); } else { @@ -3004,7 +3004,7 @@ void func_80835F44(PlayState* play, Player* this, s32 item) { temp = Player_ActionToMagicSpell(this, actionParam); if (temp >= 0) { if (((actionParam == PLAYER_IA_FARORES_WIND) && (gSaveContext.respawn[RESPAWN_MODE_TOP].data > 0)) || - ((gSaveContext.magicCapacity != 0) && (gSaveContext.magicState == 0) && + ((gSaveContext.magicCapacity != 0) && (gSaveContext.magicState == MAGIC_STATE_IDLE) && (gSaveContext.magic >= sMagicSpellCosts[temp]))) { this->itemAction = actionParam; this->unk_6AD = 4; @@ -4981,7 +4981,7 @@ void func_8083AF44(PlayState* play, Player* this, s32 magicSpell) { func_80835DE4(play, this, func_808507F4, 0); this->unk_84F = magicSpell - 3; - func_80087708(play, sMagicSpellCosts[magicSpell], 4); + Magic_RequestChange(play, sMagicSpellCosts[magicSpell], MAGIC_CONSUME_WAIT_PREVIEW); u8 isFastFarores = CVarGetInteger("gFastFarores", 0) && this->itemAction == PLAYER_IA_FARORES_WIND; @@ -9740,7 +9740,7 @@ void Player_Init(Actor* thisx, PlayState* play2) { } if (gSaveContext.nayrusLoveTimer != 0) { - gSaveContext.magicState = 3; + gSaveContext.magicState = MAGIC_STATE_METER_FLASH_1; func_80846A00(play, this, 1); this->stateFlags3 &= ~PLAYER_STATE3_RESTORE_NAYRUS_LOVE; } @@ -10666,8 +10666,8 @@ void Player_UpdateCommon(Player* this, PlayState* play, Input* input) { func_80848C74(play, this); } - if ((this->stateFlags3 & PLAYER_STATE3_RESTORE_NAYRUS_LOVE) && (gSaveContext.nayrusLoveTimer != 0) && (gSaveContext.magicState == 0)) { - gSaveContext.magicState = 3; + if ((this->stateFlags3 & PLAYER_STATE3_RESTORE_NAYRUS_LOVE) && (gSaveContext.nayrusLoveTimer != 0) && (gSaveContext.magicState == MAGIC_STATE_IDLE)) { + gSaveContext.magicState = MAGIC_STATE_METER_FLASH_1; func_80846A00(play, this, 1); this->stateFlags3 &= ~PLAYER_STATE3_RESTORE_NAYRUS_LOVE; } @@ -11373,7 +11373,7 @@ void Player_Destroy(Actor* thisx, PlayState* play) { Collider_DestroyQuad(play, &this->meleeWeaponQuads[1]); Collider_DestroyQuad(play, &this->shieldQuad); - func_800876C8(play); + Magic_Reset(play); gSaveContext.linkAge = play->linkAgeOnLoad; @@ -13098,39 +13098,39 @@ void func_8084EAC0(Player* this, PlayState* play) { } if (CVarGetInteger("gBlueManaPercentRestore", 0)) { - if (gSaveContext.magicState != 10) { + if (gSaveContext.magicState != MAGIC_STATE_ADD) { Magic_Fill(play); } - func_80087708(play, + Magic_RequestChange(play, (gSaveContext.magicLevel * 48 * CVarGetInteger("gBluePotionMana", 100) / 100 + 15) / 16 * 16, - 5); + MAGIC_ADD); } else { - if (gSaveContext.magicState != 10) { + if (gSaveContext.magicState != MAGIC_STATE_ADD) { Magic_Fill(play); } - func_80087708(play, CVarGetInteger("gBluePotionMana", 100), 5); + Magic_RequestChange(play, CVarGetInteger("gBluePotionMana", 100), MAGIC_ADD); ; } } else if (CVarGetInteger("gGreenPotionEffect", 0) && this->itemAction == PLAYER_IA_BOTTLE_POTION_GREEN) { if (CVarGetInteger("gGreenPercentRestore", 0)) { - if (gSaveContext.magicState != 10) { + if (gSaveContext.magicState != MAGIC_STATE_ADD) { Magic_Fill(play); } - func_80087708(play, + Magic_RequestChange(play, (gSaveContext.magicLevel * 48 * CVarGetInteger("gGreenPotionMana", 100) / 100 + 15) / 16 * 16, - 5); + MAGIC_ADD); } else { - if (gSaveContext.magicState != 10) { + if (gSaveContext.magicState != MAGIC_STATE_ADD) { Magic_Fill(play); } - func_80087708(play, CVarGetInteger("gGreenPotionMana", 100), 5); + Magic_RequestChange(play, CVarGetInteger("gGreenPotionMana", 100), MAGIC_ADD); ; } } else if (CVarGetInteger("gMilkEffect", 0) && (this->itemAction == PLAYER_IA_BOTTLE_MILK_FULL || @@ -13174,7 +13174,7 @@ void func_8084EAC0(Player* this, PlayState* play) { func_8083C0E8(this, play); func_8005B1A4(Play_GetCamera(play, 0)); } else if (this->unk_850 == 1) { - if ((gSaveContext.healthAccumulator == 0) && (gSaveContext.magicState != 9)) { + if ((gSaveContext.healthAccumulator == 0) && (gSaveContext.magicState != MAGIC_STATE_FILL)) { func_80832B78(play, this, &gPlayerAnim_link_bottle_drink_demo_end); this->unk_850 = 2; Player_UpdateBottleHeld(play, this, ITEM_BOTTLE, PLAYER_IA_BOTTLE); @@ -13933,7 +13933,7 @@ void func_808507F4(Player* this, PlayState* play) { u8 isFastFarores = CVarGetInteger("gFastFarores", 0) && this->itemAction == PLAYER_IA_FARORES_WIND; if (LinkAnimation_Update(play, &this->skelAnime)) { if (this->unk_84F < 0) { - if ((this->itemAction == PLAYER_IA_NAYRUS_LOVE) || isFastFarores || (gSaveContext.magicState == 0)) { + if ((this->itemAction == PLAYER_IA_NAYRUS_LOVE) || isFastFarores || (gSaveContext.magicState == MAGIC_STATE_IDLE)) { func_80839FFC(this, play); func_8005B1A4(Play_GetCamera(play, 0)); } @@ -13944,10 +13944,10 @@ void func_808507F4(Player* this, PlayState* play) { if (func_80846A00(play, this, this->unk_84F) != NULL) { this->stateFlags1 |= PLAYER_STATE1_IN_ITEM_CS | PLAYER_STATE1_IN_CUTSCENE; if ((this->unk_84F != 0) || (gSaveContext.respawn[RESPAWN_MODE_TOP].data <= 0)) { - gSaveContext.magicState = 1; + gSaveContext.magicState = MAGIC_STATE_CONSUME_SETUP; } } else { - func_800876C8(play); + Magic_Reset(play); } } else { LinkAnimation_PlayLoopSetSpeed(play, &this->skelAnime, D_80854A64[this->unk_84F], 0.83f * (isFastFarores ? 2 : 1)); diff --git a/soh/src/overlays/gamestates/ovl_file_choose/z_file_choose.c b/soh/src/overlays/gamestates/ovl_file_choose/z_file_choose.c index 630a1159a..12bf9bf17 100644 --- a/soh/src/overlays/gamestates/ovl_file_choose/z_file_choose.c +++ b/soh/src/overlays/gamestates/ovl_file_choose/z_file_choose.c @@ -2987,8 +2987,8 @@ void FileChoose_LoadGame(GameState* thisx) { gSaveContext.unk_13EE = 0x32; gSaveContext.nayrusLoveTimer = 0; gSaveContext.healthAccumulator = 0; - gSaveContext.magicState = 0; - gSaveContext.prevMagicState = 0; + gSaveContext.magicState = MAGIC_STATE_IDLE; + gSaveContext.prevMagicState = MAGIC_STATE_IDLE; gSaveContext.forcedSeqId = NA_BGM_GENERAL_SFX; gSaveContext.skyboxTime = 0; gSaveContext.nextTransitionType = 0xFF; diff --git a/soh/src/overlays/misc/ovl_kaleido_scope/z_kaleido_scope_PAL.c b/soh/src/overlays/misc/ovl_kaleido_scope/z_kaleido_scope_PAL.c index 642fec066..6651f9316 100644 --- a/soh/src/overlays/misc/ovl_kaleido_scope/z_kaleido_scope_PAL.c +++ b/soh/src/overlays/misc/ovl_kaleido_scope/z_kaleido_scope_PAL.c @@ -4167,8 +4167,8 @@ void KaleidoScope_Update(PlayState* play) gSaveContext.health = CVarGetInteger("gFullHealthSpawn", 0) ? gSaveContext.healthCapacity : 0x30; Audio_QueueSeqCmd(0xF << 28 | SEQ_PLAYER_BGM_MAIN << 24 | 0xA); gSaveContext.healthAccumulator = 0; - gSaveContext.magicState = 0; - gSaveContext.prevMagicState = 0; + gSaveContext.magicState = MAGIC_STATE_IDLE; + gSaveContext.prevMagicState = MAGIC_STATE_IDLE; osSyncPrintf(VT_FGCOL(YELLOW)); osSyncPrintf("MAGIC_NOW=%d ", gSaveContext.magic); osSyncPrintf("Z_MAGIC_NOW_NOW=%d → ", gSaveContext.magicFillTarget);