From d529ac3b60015b888540b90ed736127badf1fb15 Mon Sep 17 00:00:00 2001 From: Eduardo Alvaro Quezada D'Ottone Date: Thu, 23 Apr 2020 03:01:28 -0400 Subject: [PATCH] More Battle config (#352) * Binding move turns. * Binding damage. * Incineratable Gems. * Flash Fire while frozen. * Sleep turns. * Synchronized natures % * Confusion self damage chance. * Fixed confused self-damage check --- include/constants/battle_config.h | 9 ++++++++- src/battle_script_commands.c | 8 ++++---- src/battle_util.c | 8 ++++---- src/wild_encounter.c | 3 ++- 4 files changed, 18 insertions(+), 10 deletions(-) diff --git a/include/constants/battle_config.h b/include/constants/battle_config.h index 911fe53e6..8e68db99d 100644 --- a/include/constants/battle_config.h +++ b/include/constants/battle_config.h @@ -62,6 +62,8 @@ #define B_BURN_DAMAGE GEN_6 // In Gen7+, burn damage is 1/16th of max HP instead of 1/8th. #define B_PARALYSIS_SPEED GEN_6 // In Gen7+, speed is decreased by 50% instead of 75%. #define B_TERRAIN_TYPE_BOOST GEN_6 // In Gen8+, speed is boosted by 30% instead of 50%. +#define B_BINDING_DAMAGE GEN_6 // In Gen6+, binding damage is 1/8 of max HP instead of 1/16. (With Binding Band, 1/6 and 1/8 respectively.) +#define B_CONFUSION_SELF_DMG_CHANCE GEN_6 // In Gen7+, confusion has a 33.3% of self-damage, instead of 50%. // Move settings #define B_FELL_STINGER_STAT_RAISE GEN_6 // In Gen7+, it raises Atk by 3 stages instead of 2 if it causes the target to faint. @@ -69,6 +71,8 @@ #define B_TOXIC_NEVER_MISS GEN_6 // In Gen6+, if Toxic is used by a Poison type, it will never miss. #define B_PAYBACK_SWITCH_BOOST GEN_6 // In Gen5+, if the opponent switches out, Payback's damage will no longer be doubled. #define B_KINGS_SHIELD_LOWER_ATK GEN_6 // In Gen7+, it lowers Atk by 1 stage instead of 2 of oponents that hit it. +#define B_BINDING_TURNS GEN_6 // In Gen5+, binding moves last for 4-5 turns instead of 2-5 turns. (With Grip Claw, 7 and 5 turns respectively.) +#define B_INCINERATE_GEMS GEN_6 // In Gen6+, Incinerate can destroy Gems. // Ability settings #define B_ABILITY_POP_UP GEN_6 // In Gen5+, the Pokémon abilities are displayed in a pop-up, when they activate in battle. @@ -77,8 +81,11 @@ #define B_STANCE_CHANGE_FAIL GEN_7 // In Gen7+, Aegislash's form change does not happen, if the Pokémon cannot use a move, because of confusion, paralysis, etc. In gen6, the form change occurs despite not being able to move. #define B_GHOSTS_ESCAPE GEN_6 // In Gen6+, ghosts can escape even when blocked by abilities such as Shadow Tag. #define B_MOODY_ACC_EVASION GEN_6 // In Gen8+, Moody CANNOT raise Accuray and Evasion any more. +#define B_FLASH_FIRE_FROZEN GEN_6 // In Gen5+, Flash Fire can trigger even when frozen, when it couldn't before. +#define B_SYNCHRONIZE_NATURE GEN_6 // In Gen8+, if the Pokémon with Synchronize is leading the party, it's 100% guaranteed that wild Pokémon will have the same ability, as opposed to 50% previously. // Other -#define B_FAST_INTRO TRUE // If set to TRUE, battle intro texts print at the same time as animation of a Pokémon, as opposing to waiting for the animation to end. +#define B_FAST_INTRO TRUE // If set to TRUE, battle intro texts print at the same time as animation of a Pokémon, as opposing to waiting for the animation to end. +#define B_SLEEP_TURNS GEN_6 // In Gen5+, sleep lasts for 1-3 turns instead of 2-5 turns. #endif // GUARD_CONSTANTS_BATTLE_CONFIG_H diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index 04feb20da..f33ec552b 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -2442,7 +2442,7 @@ void SetMoveEffect(bool32 primary, u32 certain) BattleScriptPush(gBattlescriptCurrInstr + 1); if (sStatusFlagsForMoveEffects[gBattleScripting.moveEffect] == STATUS1_SLEEP) - gBattleMons[gEffectBattler].status1 |= ((Random() & 3) + 2); + gBattleMons[gEffectBattler].status1 |= (B_SLEEP_TURNS >= GEN_5) ? ((Random() & 2) + 1) : ((Random() & 3) + 2); else gBattleMons[gEffectBattler].status1 |= sStatusFlagsForMoveEffects[gBattleScripting.moveEffect]; @@ -2588,9 +2588,9 @@ void SetMoveEffect(bool32 primary, u32 certain) { gBattleMons[gEffectBattler].status2 |= STATUS2_WRAPPED; if (GetBattlerHoldEffect(gBattlerAttacker, TRUE) == HOLD_EFFECT_GRIP_CLAW) - gDisableStructs[gEffectBattler].wrapTurns = 7; + gDisableStructs[gEffectBattler].wrapTurns = (B_BINDING_TURNS >= GEN_5) ? 7 : 5; else - gDisableStructs[gEffectBattler].wrapTurns = ((Random() % 2) + 4); + gDisableStructs[gEffectBattler].wrapTurns = (B_BINDING_TURNS >= GEN_5) ? ((Random() % 2) + 4) : ((Random() % 4) + 2); gBattleStruct->wrappedMove[gEffectBattler] = gCurrentMove; gBattleStruct->wrappedBy[gEffectBattler] = gBattlerAttacker; @@ -3011,7 +3011,7 @@ void SetMoveEffect(bool32 primary, u32 certain) gBattlescriptCurrInstr++; break; case MOVE_EFFECT_INCINERATE: - if (GetBattlerHoldEffect(gEffectBattler, FALSE) == HOLD_EFFECT_GEMS + if ((B_INCINERATE_GEMS >= GEN_6 && GetBattlerHoldEffect(gEffectBattler, FALSE) == HOLD_EFFECT_GEMS) || (gBattleMons[gEffectBattler].item >= FIRST_BERRY_INDEX && gBattleMons[gEffectBattler].item <= LAST_BERRY_INDEX)) { gLastUsedItem = gBattleMons[gEffectBattler].item; diff --git a/src/battle_util.c b/src/battle_util.c index 174b4eda6..b3b0aee8e 100644 --- a/src/battle_util.c +++ b/src/battle_util.c @@ -1612,9 +1612,9 @@ u8 DoBattlerEndTurnEffects(void) PREPARE_MOVE_BUFFER(gBattleTextBuff1, gBattleStruct->wrappedMove[gActiveBattler]); gBattlescriptCurrInstr = BattleScript_WrapTurnDmg; if (GetBattlerHoldEffect(gBattleStruct->wrappedBy[gActiveBattler], TRUE) == HOLD_EFFECT_BINDING_BAND) - gBattleMoveDamage = gBattleMons[gActiveBattler].maxHP / 8; + gBattleMoveDamage = gBattleMons[gActiveBattler].maxHP / (B_BINDING_DAMAGE >= GEN_6) ? 6 : 8; else - gBattleMoveDamage = gBattleMons[gActiveBattler].maxHP / 16; + gBattleMoveDamage = gBattleMons[gActiveBattler].maxHP / (B_BINDING_DAMAGE >= GEN_6) ? 8 : 16; if (gBattleMoveDamage == 0) gBattleMoveDamage = 1; @@ -2310,7 +2310,7 @@ u8 AtkCanceller_UnableToUseMove(void) gBattleMons[gBattlerAttacker].status2--; if (gBattleMons[gBattlerAttacker].status2 & STATUS2_CONFUSION) { - if (Random() & 1) + if (Random() % ((B_CONFUSION_SELF_DMG_CHANCE >= GEN_7) ? 3 : 2 == 0)) { gBattleCommunication[MULTISTRING_CHOOSER] = 0; BattleScriptPushCursor(); @@ -3319,7 +3319,7 @@ u8 AbilityBattleEffects(u8 caseID, u8 battler, u8 ability, u8 special, u16 moveA effect = 2, statId = STAT_ATK; break; case ABILITY_FLASH_FIRE: - if (moveType == TYPE_FIRE && !(gBattleMons[battler].status1 & STATUS1_FREEZE)) + if (moveType == TYPE_FIRE && !((gBattleMons[battler].status1 & STATUS1_FREEZE) && B_FLASH_FIRE_FROZEN <= GEN_4)) { if (!(gBattleResources->flags->flags[battler] & RESOURCE_FLAG_FLASH_FIRE)) { diff --git a/src/wild_encounter.c b/src/wild_encounter.c index 9853d542f..9f2197cee 100644 --- a/src/wild_encounter.c +++ b/src/wild_encounter.c @@ -18,6 +18,7 @@ #include "battle_pike.h" #include "battle_pyramid.h" #include "constants/abilities.h" +#include "constants/battle_config.h" #include "constants/game_stat.h" #include "constants/items.h" #include "constants/layouts.h" @@ -336,7 +337,7 @@ static u8 PickWildMonNature(void) // check synchronize for a pokemon with the same ability if (!GetMonData(&gPlayerParty[0], MON_DATA_SANITY_IS_EGG) && GetMonAbility(&gPlayerParty[0]) == ABILITY_SYNCHRONIZE - && Random() % 2 == 0) + && ((B_SYNCHRONIZE_NATURE >= GEN_8) || Random() % 2 == 0)) { return GetMonData(&gPlayerParty[0], MON_DATA_PERSONALITY) % 25; }