From 13deed92fb3e34014f78e3d067fa72ddd5a7ae01 Mon Sep 17 00:00:00 2001 From: cawtds Date: Thu, 2 May 2024 02:29:12 +0200 Subject: [PATCH] updated up to Cmd_tryinfatuating --- asm/macros/battle_script.inc | 20 ++-- data/battle_scripts_1.s | 26 ++++- include/constants/battle_string_ids.h | 3 +- src/battle_message.c | 2 + src/battle_script_commands.c | 137 ++++++++++++++------------ src/data/battle_move_effects.h | 2 +- 6 files changed, 112 insertions(+), 78 deletions(-) diff --git a/asm/macros/battle_script.inc b/asm/macros/battle_script.inc index 2792624fa..046b3a769 100644 --- a/asm/macros/battle_script.inc +++ b/asm/macros/battle_script.inc @@ -794,23 +794,23 @@ 2: .endm - .macro setmultihitcounter param0:req + .macro setmultihitcounter value:req .byte 0x8d - .byte \param0 + .byte \value .endm .macro initmultihitstring .byte 0x8e .endm - .macro forcerandomswitch param0:req + .macro forcerandomswitch failInstr:req .byte 0x8f - .4byte \param0 + .4byte \failInstr .endm - .macro tryconversiontypechange param0:req + .macro tryconversiontypechange failInstr:req .byte 0x90 - .4byte \param0 + .4byte \failInstr .endm .macro givepaydaymoney @@ -821,9 +821,9 @@ .byte 0x92 .endm - .macro tryKO param0:req + .macro tryKO failInstr:req .byte 0x93 - .4byte \param0 + .4byte \failInstr .endm .macro damagetohalftargethp @@ -838,9 +838,9 @@ .byte 0x96 .endm - .macro tryinfatuating param0:req + .macro tryinfatuating failInstr:req .byte 0x97 - .4byte \param0 + .4byte \failInstr .endm .macro updatestatusicon battler:req diff --git a/data/battle_scripts_1.s b/data/battle_scripts_1.s index 92fad0a7a..8aef9b5f5 100644 --- a/data/battle_scripts_1.s +++ b/data/battle_scripts_1.s @@ -920,16 +920,32 @@ BattleScript_DoLeechSeed:: waitmessage B_WAIT_TIME_LONG goto BattleScript_MoveEnd -BattleScript_EffectSplash:: +BattleScript_EffectDoNothing:: attackcanceler attackstring ppreduce + jumpifmove MOVE_HOLD_HANDS, BattleScript_EffectHoldHands attackanimation waitanimation + jumpifmove MOVE_CELEBRATE, BattleScript_EffectCelebrate + jumpifmove MOVE_HAPPY_HOUR, BattleScript_EffectHappyHour incrementgamestat GAME_STAT_USED_SPLASH printstring STRINGID_BUTNOTHINGHAPPENED waitmessage B_WAIT_TIME_LONG goto BattleScript_MoveEnd +BattleScript_EffectHoldHands: + jumpifsideaffecting BS_TARGET, SIDE_STATUS_CRAFTY_SHIELD, BattleScript_ButItFailed + jumpifbyteequal gBattlerTarget, gBattlerAttacker, BattleScript_ButItFailed + attackanimation + waitanimation + goto BattleScript_MoveEnd +BattleScript_EffectCelebrate: + printstring STRINGID_CELEBRATEMESSAGE + waitmessage B_WAIT_TIME_LONG + goto BattleScript_MoveEnd +BattleScript_EffectHappyHour: + seteffectprimary MOVE_EFFECT_HAPPY_HOUR + goto BattleScript_MoveEnd BattleScript_EffectDisable:: attackcanceler @@ -6368,3 +6384,11 @@ BattleScript_RoarSuccessRet_Ret: waitstate return +BattleScript_NotAffectedAbilityPopUp:: + pause B_WAIT_TIME_SHORT + call BattleScript_AbilityPopUpTarget + orhalfword gMoveResultFlags, MOVE_RESULT_DOESNT_AFFECT_FOE + resultmessage + waitmessage B_WAIT_TIME_LONG + goto BattleScript_MoveEnd + diff --git a/include/constants/battle_string_ids.h b/include/constants/battle_string_ids.h index df2a1f9e4..95275b7fa 100644 --- a/include/constants/battle_string_ids.h +++ b/include/constants/battle_string_ids.h @@ -566,8 +566,9 @@ #define STRINGID_DRASTICALLY 563 #define STRINGID_SEVERELY 564 #define STRINGID_CLEARAMULETWONTLOWERSTATS 565 +#define STRINGID_CELEBRATEMESSAGE 566 -#define BATTLESTRINGS_COUNT 566 +#define BATTLESTRINGS_COUNT 567 // This is the string id that gBattleStringsTable starts with. // String ids before this (e.g. STRINGID_INTROMSG) are not in the table, diff --git a/src/battle_message.c b/src/battle_message.c index 6f19a36f3..1b1a3560e 100644 --- a/src/battle_message.c +++ b/src/battle_message.c @@ -695,6 +695,7 @@ static const u8 sText_FlowerVeilProtected[] = _("{B_DEF_NAME_WITH_PREFIX} surrou static const u8 sText_drastically[] = _("drastically "); static const u8 sText_severely[] = _("severely "); static const u8 sText_ClearAmuletWontLowerStats[] = _("{B_DEF_NAME_WITH_PREFIX}'s {B_LAST_ITEM} prevents\nits stats from being lowered!"); +static const u8 sText_CelebrateMessage[] = _("Congratulations, {B_PLAYER_NAME}!"); const u8 *const gBattleStringsTable[BATTLESTRINGS_COUNT - BATTLESTRINGS_TABLE_START] = { @@ -1252,6 +1253,7 @@ const u8 *const gBattleStringsTable[BATTLESTRINGS_COUNT - BATTLESTRINGS_TABLE_ST [STRINGID_DRASTICALLY - BATTLESTRINGS_TABLE_START] = sText_drastically, [STRINGID_SEVERELY - BATTLESTRINGS_TABLE_START] = sText_severely, [STRINGID_CLEARAMULETWONTLOWERSTATS - BATTLESTRINGS_TABLE_START] = sText_ClearAmuletWontLowerStats, + [STRINGID_CELEBRATEMESSAGE - BATTLESTRINGS_TABLE_START] = sText_CelebrateMessage, }; const u16 gTrainerUsedItemStringIds[] = diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index f3b330a6a..a16015bf9 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -742,10 +742,10 @@ void (* const gBattleScriptingCommandsTable[])(void) = Cmd_givepaydaymoney, //0x91 // done Cmd_setlightscreen, //0x92 // done Cmd_tryKO, //0x93 // done - Cmd_damagetohalftargethp, //0x94 - Cmd_setsandstorm, //0x95 - Cmd_weatherdamage, //0x96 - Cmd_tryinfatuating, //0x97 + Cmd_damagetohalftargethp, //0x94 // done + Cmd_setsandstorm, //0x95 // done + Cmd_weatherdamage, //0x96 // done + Cmd_tryinfatuating, //0x97 // done Cmd_updatestatusicon, //0x98 Cmd_setmist, //0x99 Cmd_setfocusenergy, //0x9A @@ -12580,129 +12580,136 @@ static void Cmd_tryKO(void) // Super Fang static void Cmd_damagetohalftargethp(void) { + CMD_ARGS(); + + // TODO: Dynamax + // gBattleMoveDamage = GetNonDynamaxHP(gBattlerTarget) / 2; gBattleMoveDamage = gBattleMons[gBattlerTarget].hp / 2; if (gBattleMoveDamage == 0) gBattleMoveDamage = 1; - gBattlescriptCurrInstr++; + gBattlescriptCurrInstr = cmd->nextInstr; } static void Cmd_setsandstorm(void) { - if (gBattleWeather & B_WEATHER_SANDSTORM) + CMD_ARGS(); + + if (!TryChangeBattleWeather(gBattlerAttacker, ENUM_WEATHER_SANDSTORM, FALSE)) { gMoveResultFlags |= MOVE_RESULT_MISSED; gBattleCommunication[MULTISTRING_CHOOSER] = B_MSG_WEATHER_FAILED; } else { - gBattleWeather = B_WEATHER_SANDSTORM_TEMPORARY; gBattleCommunication[MULTISTRING_CHOOSER] = B_MSG_STARTED_SANDSTORM; - gWishFutureKnock.weatherDuration = 5; } - gBattlescriptCurrInstr++; + gBattlescriptCurrInstr = cmd->nextInstr; } static void Cmd_weatherdamage(void) { + CMD_ARGS(); + + u32 ability = GetBattlerAbility(gBattlerAttacker); + + gBattleMoveDamage = 0; if (IS_BATTLE_TYPE_GHOST_WITHOUT_SCOPE(gBattleTypeFlags) && (GetBattlerSide(gBattlerAttacker) == B_SIDE_OPPONENT)) { - gBattleMoveDamage = 0; - gBattlescriptCurrInstr++; + gBattlescriptCurrInstr = cmd->nextInstr; return; } - if (WEATHER_HAS_EFFECT) + if (IsBattlerAlive(gBattlerAttacker) && WEATHER_HAS_EFFECT && ability != ABILITY_MAGIC_GUARD) { if (gBattleWeather & B_WEATHER_SANDSTORM) { - if (gBattleMons[gBattlerAttacker].type1 != TYPE_ROCK - && gBattleMons[gBattlerAttacker].type1 != TYPE_STEEL - && gBattleMons[gBattlerAttacker].type1 != TYPE_GROUND - && gBattleMons[gBattlerAttacker].type2 != TYPE_ROCK - && gBattleMons[gBattlerAttacker].type2 != TYPE_STEEL - && gBattleMons[gBattlerAttacker].type2 != TYPE_GROUND - && gBattleMons[gBattlerAttacker].ability != ABILITY_SAND_VEIL - && !(gStatuses3[gBattlerAttacker] & STATUS3_UNDERGROUND) - && !(gStatuses3[gBattlerAttacker] & STATUS3_UNDERWATER)) + if (!IS_BATTLER_OF_TYPE(gBattlerAttacker, TYPE_ROCK) + && !IS_BATTLER_OF_TYPE(gBattlerAttacker, TYPE_GROUND) + && !IS_BATTLER_OF_TYPE(gBattlerAttacker, TYPE_STEEL) + && ability != ABILITY_SAND_VEIL + && ability != ABILITY_SAND_FORCE + && ability != ABILITY_SAND_RUSH + && ability != ABILITY_OVERCOAT + && !(gStatuses3[gBattlerAttacker] & (STATUS3_UNDERGROUND | STATUS3_UNDERWATER)) + && GetBattlerHoldEffect(gBattlerAttacker, TRUE) != HOLD_EFFECT_SAFETY_GOGGLES) { + // TODO: Dynamax + // gBattleMoveDamage = GetNonDynamaxMaxHP(gBattlerAttacker) / 16; gBattleMoveDamage = gBattleMons[gBattlerAttacker].maxHP / 16; if (gBattleMoveDamage == 0) gBattleMoveDamage = 1; } - else - { - gBattleMoveDamage = 0; - } } if (gBattleWeather & B_WEATHER_HAIL) { - if (!IS_BATTLER_OF_TYPE(gBattlerAttacker, TYPE_ICE) - && !(gStatuses3[gBattlerAttacker] & STATUS3_UNDERGROUND) - && !(gStatuses3[gBattlerAttacker] & STATUS3_UNDERWATER)) + if (ability == ABILITY_ICE_BODY + && !(gStatuses3[gBattlerAttacker] & (STATUS3_UNDERGROUND | STATUS3_UNDERWATER)) + && !BATTLER_MAX_HP(gBattlerAttacker) + && !(gStatuses3[gBattlerAttacker] & STATUS3_HEAL_BLOCK)) { + gBattlerAbility = gBattlerAttacker; + // TODO: Dynamax + // gBattleMoveDamage = GetNonDynamaxMaxHP(gBattlerAttacker) / 16; + gBattleMoveDamage = gBattleMons[gBattlerAttacker].maxHP / 16; + if (gBattleMoveDamage == 0) + gBattleMoveDamage = 1; + gBattleMoveDamage *= -1; + } + else if (!IS_BATTLER_OF_TYPE(gBattlerAttacker, TYPE_ICE) + && ability != ABILITY_SNOW_CLOAK + && ability != ABILITY_OVERCOAT + && ability != ABILITY_ICE_BODY + && !(gStatuses3[gBattlerAttacker] & (STATUS3_UNDERGROUND | STATUS3_UNDERWATER)) + && GetBattlerHoldEffect(gBattlerAttacker, TRUE) != HOLD_EFFECT_SAFETY_GOGGLES) + { + // TODO: Dynamax + // gBattleMoveDamage = GetNonDynamaxMaxHP(gBattlerAttacker) / 16; gBattleMoveDamage = gBattleMons[gBattlerAttacker].maxHP / 16; if (gBattleMoveDamage == 0) gBattleMoveDamage = 1; } - else + } + if (gBattleWeather & B_WEATHER_SNOW) + { + if (ability == ABILITY_ICE_BODY + && !(gStatuses3[gBattlerAttacker] & (STATUS3_UNDERGROUND | STATUS3_UNDERWATER)) + && !BATTLER_MAX_HP(gBattlerAttacker) + && !(gStatuses3[gBattlerAttacker] & STATUS3_HEAL_BLOCK)) { - gBattleMoveDamage = 0; + gBattlerAbility = gBattlerAttacker; + gBattleMoveDamage = gBattleMons[gBattlerAttacker].maxHP / 16; + if (gBattleMoveDamage == 0) + gBattleMoveDamage = 1; + gBattleMoveDamage *= -1; } } } - else - { - gBattleMoveDamage = 0; - } - if (gAbsentBattlerFlags & gBitTable[gBattlerAttacker]) - gBattleMoveDamage = 0; - - gBattlescriptCurrInstr++; + gBattlescriptCurrInstr = cmd->nextInstr; } static void Cmd_tryinfatuating(void) { - struct Pokemon *monAttacker, *monTarget; - u16 speciesAttacker, speciesTarget; - u32 personalityAttacker, personalityTarget; + CMD_ARGS(const u8 *failInstr); - if (GetBattlerSide(gBattlerAttacker) == B_SIDE_PLAYER) - monAttacker = &gPlayerParty[gBattlerPartyIndexes[gBattlerAttacker]]; - else - monAttacker = &gEnemyParty[gBattlerPartyIndexes[gBattlerAttacker]]; - - if (GetBattlerSide(gBattlerTarget) == B_SIDE_PLAYER) - monTarget = &gPlayerParty[gBattlerPartyIndexes[gBattlerTarget]]; - else - monTarget = &gEnemyParty[gBattlerPartyIndexes[gBattlerTarget]]; - - speciesAttacker = GetMonData(monAttacker, MON_DATA_SPECIES); - personalityAttacker = GetMonData(monAttacker, MON_DATA_PERSONALITY); - - speciesTarget = GetMonData(monTarget, MON_DATA_SPECIES); - personalityTarget = GetMonData(monTarget, MON_DATA_PERSONALITY); - - if (gBattleMons[gBattlerTarget].ability == ABILITY_OBLIVIOUS) + if (GetBattlerAbility(gBattlerTarget) == ABILITY_OBLIVIOUS) { - gBattlescriptCurrInstr = BattleScript_ObliviousPreventsAttraction; + gBattlescriptCurrInstr = BattleScript_NotAffectedAbilityPopUp; gLastUsedAbility = ABILITY_OBLIVIOUS; RecordAbilityBattle(gBattlerTarget, ABILITY_OBLIVIOUS); } else { - if (GetGenderFromSpeciesAndPersonality(speciesAttacker, personalityAttacker) == GetGenderFromSpeciesAndPersonality(speciesTarget, personalityTarget) - || gBattleMons[gBattlerTarget].status2 & STATUS2_INFATUATION - || GetGenderFromSpeciesAndPersonality(speciesAttacker, personalityAttacker) == MON_GENDERLESS - || GetGenderFromSpeciesAndPersonality(speciesTarget, personalityTarget) == MON_GENDERLESS) + if (gBattleMons[gBattlerTarget].status2 & STATUS2_INFATUATION + || !AreBattlersOfOppositeGender(gBattlerAttacker, gBattlerTarget)) { - gBattlescriptCurrInstr = T1_READ_PTR(gBattlescriptCurrInstr + 1); + gBattlescriptCurrInstr = cmd->failInstr; } else { gBattleMons[gBattlerTarget].status2 |= STATUS2_INFATUATED_WITH(gBattlerAttacker); - gBattlescriptCurrInstr += 5; + gBattlescriptCurrInstr = cmd->nextInstr; } } } diff --git a/src/data/battle_move_effects.h b/src/data/battle_move_effects.h index 6b1c7bcdd..963ced6c5 100644 --- a/src/data/battle_move_effects.h +++ b/src/data/battle_move_effects.h @@ -357,7 +357,7 @@ const struct BattleMoveEffect gBattleMoveEffects[NUM_BATTLE_MOVE_EFFECTS] = [EFFECT_DO_NOTHING] = { - .battleScript = BattleScript_EffectHit, + .battleScript = BattleScript_EffectDoNothing, .encourageEncore = TRUE, },