Merge pull request #2004 from ghoulslash/be/sports

Add sport effects back
This commit is contained in:
Eduardo Quezada D'Ottone 2021-12-24 18:59:50 -03:00 committed by GitHub
commit 7bffe6d1d5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 99 additions and 31 deletions

View File

@ -25,6 +25,10 @@
#define ABILITYEFFECT_TRACE2 13 #define ABILITYEFFECT_TRACE2 13
#define ABILITYEFFECT_MOVE_END_OTHER 14 #define ABILITYEFFECT_MOVE_END_OTHER 14
#define ABILITYEFFECT_NEUTRALIZINGGAS 15 #define ABILITYEFFECT_NEUTRALIZINGGAS 15
#define ABILITYEFFECT_FIELD_SPORT 16 // Only used if B_SPORT_TURNS < GEN_6
// Special cases
#define ABILITYEFFECT_MUD_SPORT 252 // Only used if B_SPORT_TURNS < GEN_6
#define ABILITYEFFECT_WATER_SPORT 253 // Only used if B_SPORT_TURNS < GEN_6
#define ABILITYEFFECT_SWITCH_IN_TERRAIN 254 #define ABILITYEFFECT_SWITCH_IN_TERRAIN 254
#define ABILITYEFFECT_SWITCH_IN_WEATHER 255 #define ABILITYEFFECT_SWITCH_IN_WEATHER 255

View File

@ -174,6 +174,8 @@
#define STATUS4_ELECTRIFIED (1 << 0) #define STATUS4_ELECTRIFIED (1 << 0)
#define STATUS4_PLASMA_FISTS (1 << 1) #define STATUS4_PLASMA_FISTS (1 << 1)
#define STATUS4_MUD_SPORT (1 << 2) // Only used if B_SPORT_TURNS < GEN_6
#define STATUS4_WATER_SPORT (1 << 3) // Only used if B_SPORT_TURNS < GEN_6
#define HITMARKER_WAKE_UP_CLEAR (1 << 4) // Cleared when waking up. Never set or checked. #define HITMARKER_WAKE_UP_CLEAR (1 << 4) // Cleared when waking up. Never set or checked.
#define HITMARKER_SKIP_DMG_TRACK (1 << 5) #define HITMARKER_SKIP_DMG_TRACK (1 << 5)

View File

@ -118,7 +118,8 @@
#define B_PAYBACK_SWITCH_BOOST GEN_7 // In Gen5+, if the opponent switches out, Payback's damage will no longer be doubled. #define B_PAYBACK_SWITCH_BOOST GEN_7 // In Gen5+, if the opponent switches out, Payback's damage will no longer be doubled.
#define B_HIDDEN_POWER_DMG GEN_7 // In Gen6+, Hidden Power's base power was set to always be 60. Before, it was determined by the mon's IVs. #define B_HIDDEN_POWER_DMG GEN_7 // In Gen6+, Hidden Power's base power was set to always be 60. Before, it was determined by the mon's IVs.
#define B_ROUGH_SKIN_DMG GEN_7 // In Gen4+, Rough Skin contact damage is 1/8th of max HP instead of 1/16th. This will also affect Iron Barbs. #define B_ROUGH_SKIN_DMG GEN_7 // In Gen4+, Rough Skin contact damage is 1/8th of max HP instead of 1/16th. This will also affect Iron Barbs.
#define B_KNOCK_OFF_DMG GEN_8 // In Gen6+, Knock Off deals 50% more damage when knocking off an item #define B_KNOCK_OFF_DMG GEN_8 // In Gen6+, Knock Off deals 50% more damage when knocking off an item.
#define B_SPORT_DMG_REDUCTION GEN_7 // In Gen5+, Water/Mud Sport reduce Fire/Electric Damage by 67% instead of 50%.
// Type settings // Type settings
#define B_GHOSTS_ESCAPE GEN_7 // In Gen6+, abilities like Shadow Tag or moves like Mean Look fail on Ghost-type Pokémon. They can also escape any Wild Battle. #define B_GHOSTS_ESCAPE GEN_7 // In Gen6+, abilities like Shadow Tag or moves like Mean Look fail on Ghost-type Pokémon. They can also escape any Wild Battle.
@ -135,6 +136,7 @@
#define B_TAILWIND_TURNS GEN_7 // In Gen5+, Tailwind lasts 4 turns instead of 3. #define B_TAILWIND_TURNS GEN_7 // In Gen5+, Tailwind lasts 4 turns instead of 3.
#define B_SLEEP_TURNS GEN_7 // In Gen5+, sleep lasts for 1-3 turns instead of 2-5 turns. #define B_SLEEP_TURNS GEN_7 // In Gen5+, sleep lasts for 1-3 turns instead of 2-5 turns.
#define B_TAUNT_TURNS GEN_7 // In Gen5+, Taunt lasts 3 turns if the user acts before the target, or 4 turns if the target acted before the user. In Gen3, taunt lasts 2 turns and in Gen 4, 3-5 turns. #define B_TAUNT_TURNS GEN_7 // In Gen5+, Taunt lasts 3 turns if the user acts before the target, or 4 turns if the target acted before the user. In Gen3, taunt lasts 2 turns and in Gen 4, 3-5 turns.
#define B_SPORT_TURNS GEN_7 // In Gen6+, Water/Mud Sport last 5 turns, even if the user switches out.
// Move data settings // Move data settings
#define B_UPDATED_MOVE_DATA GEN_8 // Updates move data in gBattleMoves, including Power, Accuracy, PP, stat changes, targets, chances of secondary effects, etc. #define B_UPDATED_MOVE_DATA GEN_8 // Updates move data in gBattleMoves, including Power, Accuracy, PP, stat changes, targets, chances of secondary effects, etc.

View File

@ -1603,11 +1603,13 @@ static s16 AI_CheckBadMove(u8 battlerAtk, u8 battlerDef, u16 move, s16 score)
break; break;
case EFFECT_MUD_SPORT: case EFFECT_MUD_SPORT:
if (gFieldStatuses & STATUS_FIELD_MUDSPORT if (gFieldStatuses & STATUS_FIELD_MUDSPORT
|| gStatuses4[battlerAtk] & STATUS4_MUD_SPORT
|| PartnerHasSameMoveEffectWithoutTarget(AI_DATA->battlerAtkPartner, move, AI_DATA->partnerMove)) || PartnerHasSameMoveEffectWithoutTarget(AI_DATA->battlerAtkPartner, move, AI_DATA->partnerMove))
score -= 10; score -= 10;
break; break;
case EFFECT_WATER_SPORT: case EFFECT_WATER_SPORT:
if (gFieldStatuses & STATUS_FIELD_WATERSPORT if (gFieldStatuses & STATUS_FIELD_WATERSPORT
|| gStatuses4[battlerAtk] & STATUS4_WATER_SPORT
|| PartnerHasSameMoveEffectWithoutTarget(AI_DATA->battlerAtkPartner, move, AI_DATA->partnerMove)) || PartnerHasSameMoveEffectWithoutTarget(AI_DATA->battlerAtkPartner, move, AI_DATA->partnerMove))
score -= 10; score -= 10;
break; break;

View File

@ -3030,7 +3030,7 @@ void SwitchInClearSetData(void)
gStatuses3[gActiveBattler] &= (STATUS3_LEECHSEED_BATTLER | STATUS3_LEECHSEED | STATUS3_ALWAYS_HITS | STATUS3_PERISH_SONG | STATUS3_ROOTED gStatuses3[gActiveBattler] &= (STATUS3_LEECHSEED_BATTLER | STATUS3_LEECHSEED | STATUS3_ALWAYS_HITS | STATUS3_PERISH_SONG | STATUS3_ROOTED
| STATUS3_GASTRO_ACID | STATUS3_EMBARGO | STATUS3_TELEKINESIS | STATUS3_MAGNET_RISE | STATUS3_HEAL_BLOCK | STATUS3_GASTRO_ACID | STATUS3_EMBARGO | STATUS3_TELEKINESIS | STATUS3_MAGNET_RISE | STATUS3_HEAL_BLOCK
| STATUS3_AQUA_RING | STATUS3_POWER_TRICK); | STATUS3_AQUA_RING | STATUS3_POWER_TRICK);
gStatuses4[gActiveBattler] &= (STATUS4_MUD_SPORT | STATUS4_WATER_SPORT);
for (i = 0; i < gBattlersCount; i++) for (i = 0; i < gBattlersCount; i++)
{ {
if (GetBattlerSide(gActiveBattler) != GetBattlerSide(i) if (GetBattlerSide(gActiveBattler) != GetBattlerSide(i)
@ -3048,9 +3048,8 @@ void SwitchInClearSetData(void)
{ {
gBattleMons[gActiveBattler].status2 = 0; gBattleMons[gActiveBattler].status2 = 0;
gStatuses3[gActiveBattler] = 0; gStatuses3[gActiveBattler] = 0;
}
gStatuses4[gActiveBattler] = 0; gStatuses4[gActiveBattler] = 0;
}
for (i = 0; i < gBattlersCount; i++) for (i = 0; i < gBattlersCount; i++)
{ {

View File

@ -12996,6 +12996,7 @@ static void Cmd_settypebasedhalvers(void) // water and mud sport
if (gBattleMoves[gCurrentMove].effect == EFFECT_MUD_SPORT) if (gBattleMoves[gCurrentMove].effect == EFFECT_MUD_SPORT)
{ {
#if B_SPORT_TURNS >= GEN_6
if (!(gFieldStatuses & STATUS_FIELD_MUDSPORT)) if (!(gFieldStatuses & STATUS_FIELD_MUDSPORT))
{ {
gFieldStatuses |= STATUS_FIELD_MUDSPORT; gFieldStatuses |= STATUS_FIELD_MUDSPORT;
@ -13003,9 +13004,18 @@ static void Cmd_settypebasedhalvers(void) // water and mud sport
gBattleCommunication[MULTISTRING_CHOOSER] = B_MSG_WEAKEN_ELECTRIC; gBattleCommunication[MULTISTRING_CHOOSER] = B_MSG_WEAKEN_ELECTRIC;
worked = TRUE; worked = TRUE;
} }
#else
if (!(gStatuses4[gBattlerAttacker] & STATUS4_MUD_SPORT))
{
gStatuses4[gBattlerAttacker] |= STATUS4_MUD_SPORT;
gBattleCommunication[MULTISTRING_CHOOSER] = B_MSG_WEAKEN_ELECTRIC;
worked = TRUE;
}
#endif
} }
else // water sport else // water sport
{ {
#if B_SPORT_TURNS >= GEN_6
if (!(gFieldStatuses & STATUS_FIELD_WATERSPORT)) if (!(gFieldStatuses & STATUS_FIELD_WATERSPORT))
{ {
gFieldStatuses |= STATUS_FIELD_WATERSPORT; gFieldStatuses |= STATUS_FIELD_WATERSPORT;
@ -13013,6 +13023,14 @@ static void Cmd_settypebasedhalvers(void) // water and mud sport
gBattleCommunication[MULTISTRING_CHOOSER] = B_MSG_WEAKEN_FIRE; gBattleCommunication[MULTISTRING_CHOOSER] = B_MSG_WEAKEN_FIRE;
worked = TRUE; worked = TRUE;
} }
#else
if (!(gStatuses4[gBattlerAttacker] & STATUS4_WATER_SPORT))
{
gStatuses4[gBattlerAttacker] |= v;
gBattleCommunication[MULTISTRING_CHOOSER] = B_MSG_WEAKEN_FIRE;
worked = TRUE;
}
#endif
} }
if (worked) if (worked)

View File

@ -2381,21 +2381,25 @@ u8 DoFieldEndTurnEffects(void)
gBattleStruct->turnCountersTracker++; gBattleStruct->turnCountersTracker++;
break; break;
case ENDTURN_WATER_SPORT: case ENDTURN_WATER_SPORT:
#if B_SPORT_TURNS >= GEN_6
if (gFieldStatuses & STATUS_FIELD_WATERSPORT && --gFieldTimers.waterSportTimer == 0) if (gFieldStatuses & STATUS_FIELD_WATERSPORT && --gFieldTimers.waterSportTimer == 0)
{ {
gFieldStatuses &= ~STATUS_FIELD_WATERSPORT; gFieldStatuses &= ~STATUS_FIELD_WATERSPORT;
BattleScriptExecute(BattleScript_WaterSportEnds); BattleScriptExecute(BattleScript_WaterSportEnds);
effect++; effect++;
} }
#endif
gBattleStruct->turnCountersTracker++; gBattleStruct->turnCountersTracker++;
break; break;
case ENDTURN_MUD_SPORT: case ENDTURN_MUD_SPORT:
#if B_SPORT_TURNS >= GEN_6
if (gFieldStatuses & STATUS_FIELD_MUDSPORT && --gFieldTimers.mudSportTimer == 0) if (gFieldStatuses & STATUS_FIELD_MUDSPORT && --gFieldTimers.mudSportTimer == 0)
{ {
gFieldStatuses &= ~STATUS_FIELD_MUDSPORT; gFieldStatuses &= ~STATUS_FIELD_MUDSPORT;
BattleScriptExecute(BattleScript_MudSportEnds); BattleScriptExecute(BattleScript_MudSportEnds);
effect++; effect++;
} }
#endif
gBattleStruct->turnCountersTracker++; gBattleStruct->turnCountersTracker++;
break; break;
case ENDTURN_GRAVITY: case ENDTURN_GRAVITY:
@ -5620,6 +5624,35 @@ u8 AbilityBattleEffects(u8 caseID, u8 battler, u16 ability, u8 special, u16 move
break; break;
} }
break; break;
case ABILITYEFFECT_FIELD_SPORT:
switch (gLastUsedAbility)
{
case ABILITYEFFECT_MUD_SPORT:
for (i = 0; i < gBattlersCount; i++)
{
if (gStatuses4[i] & STATUS4_MUD_SPORT)
effect = i + 1;
}
break;
case ABILITYEFFECT_WATER_SPORT:
for (i = 0; i < gBattlersCount; i++)
{
if (gStatuses4[i] & STATUS4_WATER_SPORT)
effect = i + 1;
}
break;
default:
for (i = 0; i < gBattlersCount; i++)
{
if (gBattleMons[i].ability == ability)
{
gLastUsedAbility = ability;
effect = i + 1;
}
}
break;
}
break;
} }
if (effect && gLastUsedAbility != 0xFF) if (effect && gLastUsedAbility != 0xFF)
@ -8329,7 +8362,15 @@ static u32 CalcMoveBasePowerAfterModifiers(u16 move, u8 battlerAtk, u8 battlerDe
MulModifier(&modifier, (B_TERRAIN_TYPE_BOOST >= GEN_8) ? UQ_4_12(1.3) : UQ_4_12(1.5)); MulModifier(&modifier, (B_TERRAIN_TYPE_BOOST >= GEN_8) ? UQ_4_12(1.3) : UQ_4_12(1.5));
if (gFieldStatuses & STATUS_FIELD_PSYCHIC_TERRAIN && moveType == TYPE_PSYCHIC && IsBattlerGrounded(battlerAtk) && !(gStatuses3[battlerAtk] & STATUS3_SEMI_INVULNERABLE)) if (gFieldStatuses & STATUS_FIELD_PSYCHIC_TERRAIN && moveType == TYPE_PSYCHIC && IsBattlerGrounded(battlerAtk) && !(gStatuses3[battlerAtk] & STATUS3_SEMI_INVULNERABLE))
MulModifier(&modifier, (B_TERRAIN_TYPE_BOOST >= GEN_8) ? UQ_4_12(1.3) : UQ_4_12(1.5)); MulModifier(&modifier, (B_TERRAIN_TYPE_BOOST >= GEN_8) ? UQ_4_12(1.3) : UQ_4_12(1.5));
#if B_SPORT_TURNS >= GEN_6
if ((gFieldStatuses & STATUS_FIELD_MUDSPORT && moveType == TYPE_ELECTRIC)
|| (gFieldStatuses & STATUS_FIELD_WATERSPORT && moveType == TYPE_FIRE))
MulModifier(&modifier, (B_SPORT_DMG_REDUCTION >= GEN_5) ? UQ_4_12(0.23) : UQ_4_12(0.5));
#else
if ((moveType == TYPE_ELECTRIC && AbilityBattleEffects(ABILITYEFFECT_FIELD_SPORT, 0, 0, ABILITYEFFECT_MUD_SPORT, 0))
|| (moveType == TYPE_FIRE && AbilityBattleEffects(ABILITYEFFECT_FIELD_SPORT, 0, 0, ABILITYEFFECT_WATER_SPORT, 0)))
MulModifier(&modifier, (B_SPORT_DMG_REDUCTION >= GEN_5) ? UQ_4_12(0.23) : UQ_4_12(0.5));
#endif
return ApplyModifier(modifier, basePower); return ApplyModifier(modifier, basePower);
} }