From 8c30c42c36b7904c223277b9739f5a7e78be1793 Mon Sep 17 00:00:00 2001 From: DizzyEggg Date: Sun, 26 Nov 2017 14:17:02 +0100 Subject: [PATCH] more labelling and changes --- include/battle_message.h | 2 +- src/battle_2.c | 68 ++++++++--------- src/battle_ai_script_commands.c | 12 +-- src/battle_ai_switch_items.c | 32 ++++---- src/battle_controllers.c | 4 +- src/battle_message.c | 6 +- src/battle_script_commands.c | 128 ++++++++++++++++---------------- src/battle_util.c | 16 ++-- sym_ewram.txt | 14 ++-- 9 files changed, 141 insertions(+), 141 deletions(-) diff --git a/include/battle_message.h b/include/battle_message.h index 8b724a3162..59d747db1d 100644 --- a/include/battle_message.h +++ b/include/battle_message.h @@ -197,7 +197,7 @@ struct StringInfoBattle { u16 currentMove; - u16 lastMove; + u16 originallyUsedMove; u16 lastItem; u8 lastAbility; u8 scrActive; diff --git a/src/battle_2.c b/src/battle_2.c index dffebabe78..53437811a4 100644 --- a/src/battle_2.c +++ b/src/battle_2.c @@ -120,14 +120,14 @@ extern u32 gBattleExecBuffer; extern u8 gMultiHitCounter; extern u8 gBattleMoveFlags; extern s32 gBattleMoveDamage; -extern const u8* gUnknown_02024230[BATTLE_BANKS_COUNT]; -extern u16 gUnknownMovesUsedByBanks[BATTLE_BANKS_COUNT]; -extern u16 gLastUsedMovesByBanks[BATTLE_BANKS_COUNT]; -extern u16 gTurnMovesHitWith[BATTLE_BANKS_COUNT]; -extern u16 gUnknown_02024258[BATTLE_BANKS_COUNT]; -extern u16 gUnknown_02024260[BATTLE_BANKS_COUNT]; +extern const u8* gSelectionBattleScripts[BATTLE_BANKS_COUNT]; +extern u16 gOriginallyLastPrintedMoves[BATTLE_BANKS_COUNT]; +extern u16 gOriginallyLastMoves[BATTLE_BANKS_COUNT]; +extern u16 gLastLandedMoves[BATTLE_BANKS_COUNT]; +extern u16 gLastHitByType[BATTLE_BANKS_COUNT]; +extern u16 gLastMoves[BATTLE_BANKS_COUNT]; extern u16 gLockedMoves[BATTLE_BANKS_COUNT]; -extern u8 gTurnMovesHitBy[BATTLE_BANKS_COUNT]; +extern u8 gLastHitBy[BATTLE_BANKS_COUNT]; extern u8 gUnknown_02024284[BATTLE_BANKS_COUNT]; extern u32 gStatuses3[BATTLE_BANKS_COUNT]; extern u16 gSideAffecting[2]; @@ -2743,15 +2743,15 @@ static void BattleStartClearSetData(void) gDisableStructs[i].isFirstTurn = 2; gUnknown_02024284[i] = 0; - gLastUsedMovesByBanks[i] = 0; - gTurnMovesHitWith[i] = 0; - gUnknown_02024258[i] = 0; - gUnknown_02024260[i] = 0; - gTurnMovesHitBy[i] = 0xFF; + gOriginallyLastMoves[i] = 0; + gLastLandedMoves[i] = 0; + gLastHitByType[i] = 0; + gLastMoves[i] = 0; + gLastHitBy[i] = 0xFF; gLockedMoves[i] = 0; - gUnknownMovesUsedByBanks[i] = 0; + gOriginallyLastPrintedMoves[i] = 0; gBattleResources->flags->flags[i] = 0; - gUnknown_02024230[i] = 0; + gSelectionBattleScripts[i] = 0; } for (i = 0; i < 2; i++) @@ -2908,14 +2908,14 @@ void SwitchInClearSetData(void) } gBattleMoveFlags = 0; - gDisableStructs[gActiveBank].isFirstTurn= 2; + gDisableStructs[gActiveBank].isFirstTurn = 2; gDisableStructs[gActiveBank].truantUnknownBit = disableStructCopy.truantUnknownBit; - gLastUsedMovesByBanks[gActiveBank] = 0; - gTurnMovesHitWith[gActiveBank] = 0; - gUnknown_02024258[gActiveBank] = 0; - gUnknown_02024260[gActiveBank] = 0; - gUnknownMovesUsedByBanks[gActiveBank] = 0; - gTurnMovesHitBy[gActiveBank] = 0xFF; + gOriginallyLastMoves[gActiveBank] = 0; + gLastLandedMoves[gActiveBank] = 0; + gLastHitByType[gActiveBank] = 0; + gLastMoves[gActiveBank] = 0; + gOriginallyLastPrintedMoves[gActiveBank] = 0; + gLastHitBy[gActiveBank] = 0xFF; *(gBattleStruct->mirrorMoves + gActiveBank * 2 + 0) = 0; *(gBattleStruct->mirrorMoves + gActiveBank * 2 + 1) = 0; @@ -3002,12 +3002,12 @@ void FaintClearSetData(void) gDisableStructs[gActiveBank].isFirstTurn = 2; - gLastUsedMovesByBanks[gActiveBank] = 0; - gTurnMovesHitWith[gActiveBank] = 0; - gUnknown_02024258[gActiveBank] = 0; - gUnknown_02024260[gActiveBank] = 0; - gUnknownMovesUsedByBanks[gActiveBank] = 0; - gTurnMovesHitBy[gActiveBank] = 0xFF; + gOriginallyLastMoves[gActiveBank] = 0; + gLastLandedMoves[gActiveBank] = 0; + gLastHitByType[gActiveBank] = 0; + gLastMoves[gActiveBank] = 0; + gOriginallyLastPrintedMoves[gActiveBank] = 0; + gLastHitBy[gActiveBank] = 0xFF; *(u8*)((u8*)(&gBattleStruct->choicedMove[gActiveBank]) + 0) = 0; *(u8*)((u8*)(&gBattleStruct->choicedMove[gActiveBank]) + 1) = 0; @@ -3189,7 +3189,7 @@ static void BattleIntroDrawPartySummaryScreens(void) if (gBattleTypeFlags & BATTLE_TYPE_TRAINER) { - for (i = 0; i < 6; i++) + for (i = 0; i < PARTY_SIZE; i++) { if (GetMonData(&gEnemyParty[i], MON_DATA_SPECIES2) == SPECIES_NONE || GetMonData(&gEnemyParty[i], MON_DATA_SPECIES2) == SPECIES_EGG) @@ -3207,7 +3207,7 @@ static void BattleIntroDrawPartySummaryScreens(void) EmitDrawPartyStatusSummary(0, hpStatus, 0x80); MarkBufferBankForExecution(gActiveBank); - for (i = 0; i < 6; i++) + for (i = 0; i < PARTY_SIZE; i++) { if (GetMonData(&gPlayerParty[i], MON_DATA_SPECIES2) == SPECIES_NONE || GetMonData(&gPlayerParty[i], MON_DATA_SPECIES2) == SPECIES_EGG) @@ -5217,11 +5217,11 @@ static void HandleAction_UseMove(void) gCurrentActionFuncId = 12; return; } - else if (gUnknown_02024230[gBankAttacker] != NULL) + else if (gSelectionBattleScripts[gBankAttacker] != NULL) { gBattleCommunication[MULTISTRING_CHOOSER] = 4; - gBattlescriptCurrInstr = gUnknown_02024230[gBankAttacker]; - gUnknown_02024230[gBankAttacker] = NULL; + gBattlescriptCurrInstr = gSelectionBattleScripts[gBankAttacker]; + gSelectionBattleScripts[gBankAttacker] = NULL; } else { @@ -5600,8 +5600,8 @@ static void HandleAction_ActionFinished(void) gBattleMoveFlags = 0; gBattleScripting.animTurn = 0; gBattleScripting.animTargetsHit = 0; - gTurnMovesHitWith[gBankAttacker] = 0; - gUnknown_02024258[gBankAttacker] = 0; + gLastLandedMoves[gBankAttacker] = 0; + gLastHitByType[gBankAttacker] = 0; gBattleStruct->dynamicMoveType = 0; gDynamicBasePower = 0; gBattleScripting.atk49_state = 0; diff --git a/src/battle_ai_script_commands.c b/src/battle_ai_script_commands.c index 24377eacc6..5fde5669ec 100644 --- a/src/battle_ai_script_commands.c +++ b/src/battle_ai_script_commands.c @@ -58,7 +58,7 @@ extern struct BattlePokemon gBattleMons[BATTLE_BANKS_COUNT]; extern u16 gCurrentMove; extern u8 gBankTarget; extern u8 gAbsentBankFlags; -extern u16 gLastUsedMovesByBanks[BATTLE_BANKS_COUNT]; +extern u16 gOriginallyLastMoves[BATTLE_BANKS_COUNT]; extern u16 gTrainerBattleOpponent_A; extern u16 gTrainerBattleOpponent_B; extern u32 gStatuses3[BATTLE_BANKS_COUNT]; @@ -633,12 +633,12 @@ static void RecordLastUsedMoveByTarget(void) for (i = 0; i < 4; i++) { - if (gBattleResources->battleHistory->usedMoves[gBankTarget].moves[i] == gLastUsedMovesByBanks[gBankTarget]) + if (gBattleResources->battleHistory->usedMoves[gBankTarget].moves[i] == gOriginallyLastMoves[gBankTarget]) break; - if (gBattleResources->battleHistory->usedMoves[gBankTarget].moves[i] != gLastUsedMovesByBanks[gBankTarget] // HACK: This redundant condition is a hack to make the asm match. + if (gBattleResources->battleHistory->usedMoves[gBankTarget].moves[i] != gOriginallyLastMoves[gBankTarget] // HACK: This redundant condition is a hack to make the asm match. && gBattleResources->battleHistory->usedMoves[gBankTarget].moves[i] == 0) { - gBattleResources->battleHistory->usedMoves[gBankTarget].moves[i] = gLastUsedMovesByBanks[gBankTarget]; + gBattleResources->battleHistory->usedMoves[gBankTarget].moves[i] = gOriginallyLastMoves[gBankTarget]; break; } } @@ -1252,9 +1252,9 @@ static void BattleAICmd_is_most_powerful_move(void) static void BattleAICmd_get_last_used_bank_move(void) { if (gAIScriptPtr[1] == AI_USER) - AI_THINKING_STRUCT->funcResult = gLastUsedMovesByBanks[sBank_AI]; + AI_THINKING_STRUCT->funcResult = gOriginallyLastMoves[sBank_AI]; else - AI_THINKING_STRUCT->funcResult = gLastUsedMovesByBanks[gBankTarget]; + AI_THINKING_STRUCT->funcResult = gOriginallyLastMoves[gBankTarget]; gAIScriptPtr += 2; } diff --git a/src/battle_ai_switch_items.c b/src/battle_ai_switch_items.c index f43b9b6b23..f5b6c7fe42 100644 --- a/src/battle_ai_switch_items.c +++ b/src/battle_ai_switch_items.c @@ -16,8 +16,8 @@ extern u32 gBattleTypeFlags; extern u32 gStatuses3[BATTLE_BANKS_COUNT]; extern struct BattlePokemon gBattleMons[BATTLE_BANKS_COUNT]; extern u16 gBattlePartyID[BATTLE_BANKS_COUNT]; -extern u16 gTurnMovesHitWith[BATTLE_BANKS_COUNT]; -extern u8 gTurnMovesHitBy[BATTLE_BANKS_COUNT]; +extern u16 gLastLandedMoves[BATTLE_BANKS_COUNT]; +extern u8 gLastHitBy[BATTLE_BANKS_COUNT]; extern u16 gDynamicBasePower; extern u8 gBattleMoveFlags; extern u8 gCritMultiplier; @@ -141,11 +141,11 @@ static bool8 FindMonThatAbsorbsOpponentsMove(void) if (HasSuperEffectiveMoveAgainstOpponents(TRUE) && Random() % 3 != 0) return FALSE; - if (gTurnMovesHitWith[gActiveBank] == 0) + if (gLastLandedMoves[gActiveBank] == 0) return FALSE; - if (gTurnMovesHitWith[gActiveBank] == 0xFFFF) + if (gLastLandedMoves[gActiveBank] == 0xFFFF) return FALSE; - if (gBattleMoves[gTurnMovesHitWith[gActiveBank]].power == 0) + if (gBattleMoves[gLastLandedMoves[gActiveBank]].power == 0) return FALSE; if (gBattleTypeFlags & BATTLE_TYPE_DOUBLE) @@ -162,11 +162,11 @@ static bool8 FindMonThatAbsorbsOpponentsMove(void) bankIn2 = gActiveBank; } - if (gBattleMoves[gTurnMovesHitWith[gActiveBank]].type == TYPE_FIRE) + if (gBattleMoves[gLastLandedMoves[gActiveBank]].type == TYPE_FIRE) absorbingTypeAbility = ABILITY_FLASH_FIRE; - else if (gBattleMoves[gTurnMovesHitWith[gActiveBank]].type == TYPE_WATER) + else if (gBattleMoves[gLastLandedMoves[gActiveBank]].type == TYPE_WATER) absorbingTypeAbility = ABILITY_WATER_ABSORB; - else if (gBattleMoves[gTurnMovesHitWith[gActiveBank]].type == TYPE_ELECTRIC) + else if (gBattleMoves[gLastLandedMoves[gActiveBank]].type == TYPE_ELECTRIC) absorbingTypeAbility = ABILITY_VOLT_ABSORB; else return FALSE; @@ -238,13 +238,13 @@ static bool8 ShouldSwitchIfNaturalCure(void) if (gBattleMons[gActiveBank].hp < gBattleMons[gActiveBank].maxHP / 2) return FALSE; - if ((gTurnMovesHitWith[gActiveBank] == 0 || gTurnMovesHitWith[gActiveBank] == 0xFFFF) && Random() & 1) + if ((gLastLandedMoves[gActiveBank] == 0 || gLastLandedMoves[gActiveBank] == 0xFFFF) && Random() & 1) { *(gBattleStruct->AI_monToSwitchIntoId + gActiveBank) = 6; EmitTwoReturnValues(1, ACTION_SWITCH, 0); return TRUE; } - else if (gBattleMoves[gTurnMovesHitWith[gActiveBank]].power == 0 && Random() & 1) + else if (gBattleMoves[gLastLandedMoves[gActiveBank]].power == 0 && Random() & 1) { *(gBattleStruct->AI_monToSwitchIntoId + gActiveBank) = 6; EmitTwoReturnValues(1, ACTION_SWITCH, 0); @@ -345,13 +345,13 @@ static bool8 FindMonWithFlagsAndSuperEffective(u8 flags, u8 moduloPercent) u16 move; u8 moveFlags; - if (gTurnMovesHitWith[gActiveBank] == 0) + if (gLastLandedMoves[gActiveBank] == 0) return FALSE; - if (gTurnMovesHitWith[gActiveBank] == 0xFFFF) + if (gLastLandedMoves[gActiveBank] == 0xFFFF) return FALSE; - if (gTurnMovesHitBy[gActiveBank] == 0xFF) + if (gLastHitBy[gActiveBank] == 0xFF) return FALSE; - if (gBattleMoves[gTurnMovesHitWith[gActiveBank]].power == 0) + if (gBattleMoves[gLastLandedMoves[gActiveBank]].power == 0) return FALSE; if (gBattleTypeFlags & BATTLE_TYPE_DOUBLE) @@ -411,10 +411,10 @@ static bool8 FindMonWithFlagsAndSuperEffective(u8 flags, u8 moduloPercent) else monAbility = gBaseStats[species].ability1; - moveFlags = AI_TypeCalc(gTurnMovesHitWith[gActiveBank], species, monAbility); + moveFlags = AI_TypeCalc(gLastLandedMoves[gActiveBank], species, monAbility); if (moveFlags & flags) { - bankIn1 = gTurnMovesHitBy[gActiveBank]; + bankIn1 = gLastHitBy[gActiveBank]; for (j = 0; j < 4; j++) { diff --git a/src/battle_controllers.c b/src/battle_controllers.c index 45ed8a73a3..b3fb91b42a 100644 --- a/src/battle_controllers.c +++ b/src/battle_controllers.c @@ -1120,7 +1120,7 @@ void EmitPrintString(u8 bufferId, u16 stringID) stringInfo = (struct StringInfoBattle*)(&gBattleBuffersTransferData[4]); stringInfo->currentMove = gCurrentMove; - stringInfo->lastMove = gOriginallyUsedMove; + stringInfo->originallyUsedMove = gOriginallyUsedMove; stringInfo->lastItem = gLastUsedItem; stringInfo->lastAbility = gLastUsedAbility; stringInfo->scrActive = gBattleScripting.bank; @@ -1152,7 +1152,7 @@ void EmitPrintSelectionString(u8 bufferId, u16 stringID) stringInfo = (struct StringInfoBattle*)(&gBattleBuffersTransferData[4]); stringInfo->currentMove = gCurrentMove; - stringInfo->lastMove = gOriginallyUsedMove; + stringInfo->originallyUsedMove = gOriginallyUsedMove; stringInfo->lastItem = gLastUsedItem; stringInfo->lastAbility = gLastUsedAbility; stringInfo->scrActive = gBattleScripting.bank; diff --git a/src/battle_message.c b/src/battle_message.c index 04eb5f6550..35b9004ac1 100644 --- a/src/battle_message.c +++ b/src/battle_message.c @@ -1916,11 +1916,11 @@ u32 BattleStringExpandPlaceholders(const u8* src, u8* dst) else toCpy = gMoveNames[gStringInfo->currentMove]; break; - case B_TXT_LAST_MOVE: // last used move name - if (gStringInfo->lastMove > LAST_MOVE_INDEX) + case B_TXT_LAST_MOVE: // originally used move name + if (gStringInfo->originallyUsedMove > LAST_MOVE_INDEX) toCpy = gText_UnknownMoveTypes[gBattleStruct->stringMoveType]; else - toCpy = gMoveNames[gStringInfo->lastMove]; + toCpy = gMoveNames[gStringInfo->originallyUsedMove]; break; case B_TXT_LAST_ITEM: // last used item if (gBattleTypeFlags & (BATTLE_TYPE_LINK | BATTLE_TYPE_x2000000)) diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index 9ab9160a43..0e6209ed8f 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -74,10 +74,10 @@ extern u8 gCurrentActionFuncId; extern u32 gHitMarker; extern u8 gBattleMoveFlags; extern u8 gBattleCommunication[]; -extern u16 gTurnMovesHitWith[4]; -extern u16 gUnknown_02024258[4]; -extern u16 gUnknown_02024260[4]; -extern u8 gTurnMovesHitBy[4]; +extern u16 gLastLandedMoves[4]; +extern u16 gLastHitByType[4]; +extern u16 gLastMoves[4]; +extern u8 gLastHitBy[4]; extern u8 gStringBank; extern u16 gDynamicBasePower; extern u16 gLastUsedItem; @@ -100,8 +100,8 @@ extern u8 gBattleBufferB[BATTLE_BANKS_COUNT][0x200]; extern u16 gLockedMoves[BATTLE_BANKS_COUNT]; extern u16 gPartnerTrainerId; extern u16 gOriginallyUsedMove; -extern u16 gUnknownMovesUsedByBanks[BATTLE_BANKS_COUNT]; -extern u16 gLastUsedMovesByBanks[BATTLE_BANKS_COUNT]; +extern u16 gOriginallyLastPrintedMoves[BATTLE_BANKS_COUNT]; +extern u16 gOriginallyLastMoves[BATTLE_BANKS_COUNT]; extern u16 gTrainerBattleOpponent_A; extern u16 gTrainerBattleOpponent_B; extern u8 gUnknown_020241E9; @@ -1105,8 +1105,8 @@ static void atk00_attackcanceler(void) { CancelMultiTurnMoves(gBankAttacker); gBattleMoveFlags |= MOVESTATUS_MISSED; - gTurnMovesHitWith[gBankTarget] = 0; - gUnknown_02024258[gBankTarget] = 0; + gLastLandedMoves[gBankTarget] = 0; + gLastHitByType[gBankTarget] = 0; gBattleCommunication[6] = 1; gBattlescriptCurrInstr++; } @@ -1118,11 +1118,11 @@ static void atk00_attackcanceler(void) static void JumpIfMoveFailed(u8 adder, u16 move) { - const void* BS_ptr = gBattlescriptCurrInstr + adder; + const u8 *BS_ptr = gBattlescriptCurrInstr + adder; if (gBattleMoveFlags & MOVESTATUS_NOEFFECT) { - gTurnMovesHitWith[gBankTarget] = 0; - gUnknown_02024258[gBankTarget] = 0; + gLastLandedMoves[gBankTarget] = 0; + gLastHitByType[gBankTarget] = 0; BS_ptr = BSScriptReadPtr(gBattlescriptCurrInstr + 1); } else @@ -1484,8 +1484,8 @@ static void atk06_typecalc(void) { gLastUsedAbility = gBattleMons[gBankTarget].ability; gBattleMoveFlags |= (MOVESTATUS_MISSED | MOVESTATUS_NOTAFFECTED); - gTurnMovesHitWith[gBankTarget] = 0; - gUnknown_02024258[gBankTarget] = 0; + gLastLandedMoves[gBankTarget] = 0; + gLastHitByType[gBankTarget] = 0; gBattleCommunication[6] = moveType; RecordAbilityBattle(gBankTarget, gLastUsedAbility); } @@ -1520,8 +1520,8 @@ static void atk06_typecalc(void) { gLastUsedAbility = ABILITY_WONDER_GUARD; gBattleMoveFlags |= MOVESTATUS_MISSED; - gTurnMovesHitWith[gBankTarget] = 0; - gUnknown_02024258[gBankTarget] = 0; + gLastLandedMoves[gBankTarget] = 0; + gLastHitByType[gBankTarget] = 0; gBattleCommunication[6] = 3; RecordAbilityBattle(gBankTarget, gLastUsedAbility); } @@ -4856,14 +4856,14 @@ static void atk49_moveend(void) u8 holdEffectAtk; u16 *choicedMoveAtk; u8 arg1, arg2; - u16 lastMove; + u16 originallyUsedMove; effect = FALSE; if (gOriginallyUsedMove == 0xFFFF) - lastMove = 0; + originallyUsedMove = 0; else - lastMove = gOriginallyUsedMove; + originallyUsedMove = gOriginallyUsedMove; arg1 = gBattlescriptCurrInstr[1]; arg2 = gBattlescriptCurrInstr[2]; @@ -5036,48 +5036,48 @@ static void atk49_moveend(void) } if (gHitMarker & HITMARKER_ATTACKSTRING_PRINTED) { - gUnknownMovesUsedByBanks[gBankAttacker] = gOriginallyUsedMove; + gOriginallyLastPrintedMoves[gBankAttacker] = gOriginallyUsedMove; } if (!(gAbsentBankFlags & gBitTable[gBankAttacker]) && !(gBattleStruct->field_91 & gBitTable[gBankAttacker]) - && gBattleMoves[lastMove].effect != EFFECT_BATON_PASS) + && gBattleMoves[originallyUsedMove].effect != EFFECT_BATON_PASS) { if (gHitMarker & HITMARKER_OBEYS) { - gLastUsedMovesByBanks[gBankAttacker] = gOriginallyUsedMove; - gUnknown_02024260[gBankAttacker] = gCurrentMove; + gOriginallyLastMoves[gBankAttacker] = gOriginallyUsedMove; + gLastMoves[gBankAttacker] = gCurrentMove; } else { - gLastUsedMovesByBanks[gBankAttacker] = 0xFFFF; - gUnknown_02024260[gBankAttacker] = 0xFFFF; + gOriginallyLastMoves[gBankAttacker] = 0xFFFF; + gLastMoves[gBankAttacker] = 0xFFFF; } if (!(gHitMarker & HITMARKER_FAINTED(gBankTarget))) - gTurnMovesHitBy[gBankTarget] = gBankAttacker; + gLastHitBy[gBankTarget] = gBankAttacker; if (gHitMarker & HITMARKER_OBEYS && !(gBattleMoveFlags & MOVESTATUS_NOEFFECT)) { if (gOriginallyUsedMove == 0xFFFF) { - gTurnMovesHitWith[gBankTarget] = gOriginallyUsedMove; + gLastLandedMoves[gBankTarget] = gOriginallyUsedMove; } else { - gTurnMovesHitWith[gBankTarget] = gCurrentMove; - GET_MOVE_TYPE(gCurrentMove, gUnknown_02024258[gBankTarget]); + gLastLandedMoves[gBankTarget] = gCurrentMove; + GET_MOVE_TYPE(gCurrentMove, gLastHitByType[gBankTarget]); } } else { - gTurnMovesHitWith[gBankTarget] = 0xFFFF; + gLastLandedMoves[gBankTarget] = 0xFFFF; } } gBattleScripting.atk49_state++; break; case 15: // mirror move if (!(gAbsentBankFlags & gBitTable[gBankAttacker]) && !(gBattleStruct->field_91 & gBitTable[gBankAttacker]) - && gBattleMoves[lastMove].flags & FLAG_MIRROR_MOVE_AFFECTED && gHitMarker & HITMARKER_OBEYS + && gBattleMoves[originallyUsedMove].flags & FLAG_MIRROR_MOVE_AFFECTED && gHitMarker & HITMARKER_OBEYS && gBankAttacker != gBankTarget && !(gHitMarker & HITMARKER_FAINTED(gBankTarget)) && !(gBattleMoveFlags & MOVESTATUS_NOEFFECT)) { @@ -5144,7 +5144,7 @@ static void atk4A_typecalc2(void) { gLastUsedAbility = gBattleMons[gBankTarget].ability; gBattleMoveFlags |= (MOVESTATUS_MISSED | MOVESTATUS_NOTAFFECTED); - gTurnMovesHitWith[gBankTarget] = 0; + gLastLandedMoves[gBankTarget] = 0; gBattleCommunication[6] = moveType; RecordAbilityBattle(gBankTarget, gLastUsedAbility); } @@ -5219,7 +5219,7 @@ static void atk4A_typecalc2(void) { gLastUsedAbility = ABILITY_WONDER_GUARD; gBattleMoveFlags |= MOVESTATUS_MISSED; - gTurnMovesHitWith[gBankTarget] = 0; + gLastLandedMoves[gBankTarget] = 0; gBattleCommunication[6] = 3; RecordAbilityBattle(gBankTarget, gLastUsedAbility); } @@ -7131,7 +7131,7 @@ static void atk76_various(void) static void atk77_setprotectlike(void) // protect and endure { bool8 notLastTurn = TRUE; - u16 lastMove = gUnknown_02024260[gBankAttacker]; + u16 lastMove = gLastMoves[gBankAttacker]; if (lastMove != MOVE_PROTECT && lastMove != MOVE_DETECT && lastMove != MOVE_ENDURE) gDisableStructs[gBankAttacker].protectUses = 0; @@ -8434,10 +8434,10 @@ static void atk9D_mimicattackcopy(void) { gOriginallyUsedMove = 0xFFFF; - if (IsMoveUncopyableByMimic(gLastUsedMovesByBanks[gBankTarget]) + if (IsMoveUncopyableByMimic(gOriginallyLastMoves[gBankTarget]) || gBattleMons[gBankAttacker].status2 & STATUS2_TRANSFORMED - || gLastUsedMovesByBanks[gBankTarget] == 0 - || gLastUsedMovesByBanks[gBankTarget] == 0xFFFF) + || gOriginallyLastMoves[gBankTarget] == 0 + || gOriginallyLastMoves[gBankTarget] == 0xFFFF) { gBattlescriptCurrInstr = BSScriptReadPtr(gBattlescriptCurrInstr + 1); } @@ -8447,20 +8447,20 @@ static void atk9D_mimicattackcopy(void) for (i = 0; i < 4; i++) { - if (gBattleMons[gBankAttacker].moves[i] == gLastUsedMovesByBanks[gBankTarget]) + if (gBattleMons[gBankAttacker].moves[i] == gOriginallyLastMoves[gBankTarget]) break; } if (i == 4) { - gBattleMons[gBankAttacker].moves[gCurrMovePos] = gLastUsedMovesByBanks[gBankTarget]; - if (gBattleMoves[gLastUsedMovesByBanks[gBankTarget]].pp < 5) - gBattleMons[gBankAttacker].pp[gCurrMovePos] = gBattleMoves[gLastUsedMovesByBanks[gBankTarget]].pp; + gBattleMons[gBankAttacker].moves[gCurrMovePos] = gOriginallyLastMoves[gBankTarget]; + if (gBattleMoves[gOriginallyLastMoves[gBankTarget]].pp < 5) + gBattleMons[gBankAttacker].pp[gCurrMovePos] = gBattleMoves[gOriginallyLastMoves[gBankTarget]].pp; else gBattleMons[gBankAttacker].pp[gCurrMovePos] = 5; - PREPARE_MOVE_BUFFER(gBattleTextBuff1, gLastUsedMovesByBanks[gBankTarget]) + PREPARE_MOVE_BUFFER(gBattleTextBuff1, gOriginallyLastMoves[gBankTarget]) gDisableStructs[gBankAttacker].unk18_b |= gBitTable[gCurrMovePos]; gBattlescriptCurrInstr += 5; @@ -8575,7 +8575,7 @@ static void atkA3_disablelastusedattack(void) for (i = 0; i < 4; i++) { - if (gBattleMons[gBankTarget].moves[i] == gLastUsedMovesByBanks[gBankTarget]) + if (gBattleMons[gBankTarget].moves[i] == gOriginallyLastMoves[gBankTarget]) break; } if (gDisableStructs[gBankTarget].disabledMove == 0 @@ -8600,13 +8600,13 @@ static void atkA4_trysetencore(void) for (i = 0; i < 4; i++) { - if (gBattleMons[gBankTarget].moves[i] == gLastUsedMovesByBanks[gBankTarget]) + if (gBattleMons[gBankTarget].moves[i] == gOriginallyLastMoves[gBankTarget]) break; } - if (gLastUsedMovesByBanks[gBankTarget] == MOVE_STRUGGLE - || gLastUsedMovesByBanks[gBankTarget] == MOVE_ENCORE - || gLastUsedMovesByBanks[gBankTarget] == MOVE_MIRROR_MOVE) + if (gOriginallyLastMoves[gBankTarget] == MOVE_STRUGGLE + || gOriginallyLastMoves[gBankTarget] == MOVE_ENCORE + || gOriginallyLastMoves[gBankTarget] == MOVE_MIRROR_MOVE) { i = 4; } @@ -8652,13 +8652,13 @@ static void atkA5_painsplitdmgcalc(void) static void atkA6_settypetorandomresistance(void) // conversion 2 { - if (gTurnMovesHitWith[gBankAttacker] == 0 - || gTurnMovesHitWith[gBankAttacker] == 0xFFFF) + if (gLastLandedMoves[gBankAttacker] == 0 + || gLastLandedMoves[gBankAttacker] == 0xFFFF) { gBattlescriptCurrInstr = BSScriptReadPtr(gBattlescriptCurrInstr + 1); } - else if (IsTwoTurnsMove(gTurnMovesHitWith[gBankAttacker]) - && gBattleMons[gTurnMovesHitBy[gBankAttacker]].status2 & STATUS2_MULTIPLETURNS) + else if (IsTwoTurnsMove(gLastLandedMoves[gBankAttacker]) + && gBattleMons[gLastHitBy[gBankAttacker]].status2 & STATUS2_MULTIPLETURNS) { gBattlescriptCurrInstr = BSScriptReadPtr(gBattlescriptCurrInstr + 1); } @@ -8672,7 +8672,7 @@ static void atkA6_settypetorandomresistance(void) // conversion 2 i *= 3; - if (TYPE_EFFECT_ATK_TYPE(i) == gUnknown_02024258[gBankAttacker] + if (TYPE_EFFECT_ATK_TYPE(i) == gLastHitByType[gBankAttacker] && TYPE_EFFECT_MULTIPLIER(i) <= TYPE_MUL_NOT_EFFECTIVE && gBattleMons[gBankAttacker].type1 != TYPE_EFFECT_DEF_TYPE(i) && gBattleMons[gBankAttacker].type2 != TYPE_EFFECT_DEF_TYPE(i)) @@ -8695,7 +8695,7 @@ static void atkA6_settypetorandomresistance(void) // conversion 2 case TYPE_FORESIGHT: break; default: - if (TYPE_EFFECT_ATK_TYPE(j) == gUnknown_02024258[gBankAttacker] + if (TYPE_EFFECT_ATK_TYPE(j) == gLastHitByType[gBankAttacker] && TYPE_EFFECT_MULTIPLIER(j) <= 5 && gBattleMons[gBankAttacker].type1 != TYPE_EFFECT_DEF_TYPE(i) && gBattleMons[gBankAttacker].type2 != TYPE_EFFECT_DEF_TYPE(i)) @@ -8729,10 +8729,10 @@ static void atkA8_copymovepermanently(void) // sketch gOriginallyUsedMove = 0xFFFF; if (!(gBattleMons[gBankAttacker].status2 & STATUS2_TRANSFORMED) - && gUnknownMovesUsedByBanks[gBankTarget] != MOVE_STRUGGLE - && gUnknownMovesUsedByBanks[gBankTarget] != 0 - && gUnknownMovesUsedByBanks[gBankTarget] != 0xFFFF - && gUnknownMovesUsedByBanks[gBankTarget] != MOVE_SKETCH) + && gOriginallyLastPrintedMoves[gBankTarget] != MOVE_STRUGGLE + && gOriginallyLastPrintedMoves[gBankTarget] != 0 + && gOriginallyLastPrintedMoves[gBankTarget] != 0xFFFF + && gOriginallyLastPrintedMoves[gBankTarget] != MOVE_SKETCH) { s32 i; @@ -8740,7 +8740,7 @@ static void atkA8_copymovepermanently(void) // sketch { if (gBattleMons[gBankAttacker].moves[i] == MOVE_SKETCH) continue; - if (gBattleMons[gBankAttacker].moves[i] == gUnknownMovesUsedByBanks[gBankTarget]) + if (gBattleMons[gBankAttacker].moves[i] == gOriginallyLastPrintedMoves[gBankTarget]) break; } @@ -8752,8 +8752,8 @@ static void atkA8_copymovepermanently(void) // sketch { struct MovePpInfo movePpData; - gBattleMons[gBankAttacker].moves[gCurrMovePos] = gUnknownMovesUsedByBanks[gBankTarget]; - gBattleMons[gBankAttacker].pp[gCurrMovePos] = gBattleMoves[gUnknownMovesUsedByBanks[gBankTarget]].pp; + gBattleMons[gBankAttacker].moves[gCurrMovePos] = gOriginallyLastPrintedMoves[gBankTarget]; + gBattleMons[gBankAttacker].pp[gCurrMovePos] = gBattleMoves[gOriginallyLastPrintedMoves[gBankTarget]].pp; gActiveBank = gBankAttacker; for (i = 0; i < 4; i++) @@ -8766,7 +8766,7 @@ static void atkA8_copymovepermanently(void) // sketch EmitSetMonData(0, REQUEST_MOVES_PP_BATTLE, 0, sizeof(struct MovePpInfo), &movePpData); MarkBufferBankForExecution(gActiveBank); - PREPARE_MOVE_BUFFER(gBattleTextBuff1, gUnknownMovesUsedByBanks[gBankTarget]) + PREPARE_MOVE_BUFFER(gBattleTextBuff1, gOriginallyLastPrintedMoves[gBankTarget]) gBattlescriptCurrInstr += 5; } @@ -8899,14 +8899,14 @@ static void atkAC_remaininghptopower(void) static void atkAD_tryspiteppreduce(void) { - if (gLastUsedMovesByBanks[gBankTarget] != 0 - && gLastUsedMovesByBanks[gBankTarget] != 0xFFFF) + if (gOriginallyLastMoves[gBankTarget] != 0 + && gOriginallyLastMoves[gBankTarget] != 0xFFFF) { s32 i; for (i = 0; i < 4; i++) { - if (gLastUsedMovesByBanks[gBankTarget] == gBattleMons[gBankTarget].moves[i]) + if (gOriginallyLastMoves[gBankTarget] == gBattleMons[gBankTarget].moves[i]) break; } @@ -8916,7 +8916,7 @@ static void atkAD_tryspiteppreduce(void) if (gBattleMons[gBankTarget].pp[i] < ppToDeduct) ppToDeduct = gBattleMons[gBankTarget].pp[i]; - PREPARE_MOVE_BUFFER(gBattleTextBuff1, gLastUsedMovesByBanks[gBankTarget]) + PREPARE_MOVE_BUFFER(gBattleTextBuff1, gOriginallyLastMoves[gBankTarget]) ConvertIntToDecimalStringN(gBattleTextBuff2, ppToDeduct, 0, 1); diff --git a/src/battle_util.c b/src/battle_util.c index 7f5d31b6f6..9f2bf27972 100644 --- a/src/battle_util.c +++ b/src/battle_util.c @@ -23,7 +23,7 @@ extern const u8* gBattlescriptCurrInstr; extern const u8* gBattlescriptPtrsForSelection[BATTLE_BANKS_COUNT]; -extern const u8* gUnknown_02024230[BATTLE_BANKS_COUNT]; +extern const u8* gSelectionBattleScripts[BATTLE_BANKS_COUNT]; extern struct BattlePokemon gBattleMons[BATTLE_BANKS_COUNT]; extern u8 gActiveBank; extern u8 gStringBank; @@ -43,7 +43,7 @@ extern s32 gBattleMoveDamage; extern struct BattleEnigmaBerry gEnigmaBerries[BATTLE_BANKS_COUNT]; extern u8 gBattleBufferB[BATTLE_BANKS_COUNT][0x200]; extern u32 gBattleTypeFlags; -extern u16 gLastUsedMovesByBanks[BATTLE_BANKS_COUNT]; +extern u16 gOriginallyLastMoves[BATTLE_BANKS_COUNT]; extern u32 gHitMarker; extern u8 gEffectBank; extern u16 gBattlePartyID[BATTLE_BANKS_COUNT]; @@ -363,7 +363,7 @@ u8 TrySetCantSelectMoveBattleScript(void) gCurrentMove = move; if (gBattleTypeFlags & BATTLE_TYPE_PALACE) { - gUnknown_02024230[gActiveBank] = BattleScript_82DAE2A; + gSelectionBattleScripts[gActiveBank] = BattleScript_82DAE2A; gProtectStructs[gActiveBank].flag_x10 = 1; } else @@ -373,12 +373,12 @@ u8 TrySetCantSelectMoveBattleScript(void) } } - if (move == gLastUsedMovesByBanks[gActiveBank] && move != MOVE_STRUGGLE && (gBattleMons[gActiveBank].status2 & STATUS2_TORMENT)) + if (move == gOriginallyLastMoves[gActiveBank] && move != MOVE_STRUGGLE && (gBattleMons[gActiveBank].status2 & STATUS2_TORMENT)) { CancelMultiTurnMoves(gActiveBank); if (gBattleTypeFlags & BATTLE_TYPE_PALACE) { - gUnknown_02024230[gActiveBank] = BattleScript_82DB098; + gSelectionBattleScripts[gActiveBank] = BattleScript_82DB098; gProtectStructs[gActiveBank].flag_x10 = 1; } else @@ -393,7 +393,7 @@ u8 TrySetCantSelectMoveBattleScript(void) gCurrentMove = move; if (gBattleTypeFlags & BATTLE_TYPE_PALACE) { - gUnknown_02024230[gActiveBank] = BattleScript_82DB0AF; + gSelectionBattleScripts[gActiveBank] = BattleScript_82DB0AF; gProtectStructs[gActiveBank].flag_x10 = 1; } else @@ -408,7 +408,7 @@ u8 TrySetCantSelectMoveBattleScript(void) gCurrentMove = move; if (gBattleTypeFlags & BATTLE_TYPE_PALACE) { - gUnknown_02024230[gActiveBank] = BattleScript_82DB185; + gSelectionBattleScripts[gActiveBank] = BattleScript_82DB185; gProtectStructs[gActiveBank].flag_x10 = 1; } else @@ -477,7 +477,7 @@ u8 CheckMoveLimitations(u8 bank, u8 unusableMoves, u8 check) unusableMoves |= gBitTable[i]; if (gBattleMons[bank].moves[i] == gDisableStructs[bank].disabledMove && check & MOVE_LIMITATION_DISABLED) unusableMoves |= gBitTable[i]; - if (gBattleMons[bank].moves[i] == gLastUsedMovesByBanks[bank] && check & MOVE_LIMITATION_TORMENTED && gBattleMons[bank].status2 & STATUS2_TORMENT) + if (gBattleMons[bank].moves[i] == gOriginallyLastMoves[bank] && check & MOVE_LIMITATION_TORMENTED && gBattleMons[bank].status2 & STATUS2_TORMENT) unusableMoves |= gBitTable[i]; if (gDisableStructs[bank].tauntTimer1 && check & MOVE_LIMITATION_TAUNT && gBattleMoves[gBattleMons[bank].moves[i]].power == 0) unusableMoves |= gBitTable[i]; diff --git a/sym_ewram.txt b/sym_ewram.txt index a66eb7356f..16cc33355b 100644 --- a/sym_ewram.txt +++ b/sym_ewram.txt @@ -366,28 +366,28 @@ gActionForBanks: @ 202421C gBattlescriptPtrsForSelection: @ 2024220 .space 0x10 -gUnknown_02024230: @ 2024230 +gSelectionBattleScripts: @ 2024230 .space 0x10 -gUnknownMovesUsedByBanks: @ 2024240 +gOriginallyLastPrintedMoves: @ 2024240 .space 0x8 -gLastUsedMovesByBanks: @ 2024248 +gOriginallyLastMoves: @ 2024248 .space 0x8 -gTurnMovesHitWith: @ 2024250 +gLastLandedMoves: @ 2024250 .space 0x8 -gUnknown_02024258: @ 2024258 +gLastHitByType: @ 2024258 .space 0x8 -gUnknown_02024260: @ 2024260 +gLastMoves: @ 2024260 .space 0x8 gLockedMoves: @ 2024268 .space 0x8 -gTurnMovesHitBy: @ 2024270 +gLastHitBy: @ 2024270 .space 0x4 gChosenMovesByBanks: @ 2024274