Skip to content

Commit

Permalink
Add Doodle + update ability banlists (rh-hideout#3609)
Browse files Browse the repository at this point in the history
* Add Doodle

* Doodle test

* Oops

* Update battle_util.c

---------

Co-authored-by: Bassoonian <iasperbassoonian@gmail.com>
  • Loading branch information
kittenchilly and Bassoonian authored Dec 22, 2023
1 parent 83e2f4b commit 505b8b6
Show file tree
Hide file tree
Showing 9 changed files with 287 additions and 119 deletions.
12 changes: 11 additions & 1 deletion asm/macros/battle_script.inc
Original file line number Diff line number Diff line change
Expand Up @@ -1087,8 +1087,9 @@
.4byte \failInstr
.endm

.macro trycopyability failInstr:req
.macro trycopyability battler:req, failInstr:req
.byte 0xd3
.byte \battler
.4byte \failInstr
.endm

Expand Down Expand Up @@ -2332,6 +2333,15 @@
goto \jumpInstr
.endm

.macro setallytonextattacker jumpInstr:req
jumpifbyte CMP_GREATER_THAN, gBattlerAttacker, 0x1, 1f
addbyte gBattlerAttacker, 0x2
goto \jumpInstr
1:
subbyte gBattlerAttacker, 0x2
goto \jumpInstr
.endm

.macro jumpifleafguardprotected battler:req, jumpInstr:req
various \battler, VARIOUS_JUMP_IF_LEAF_GUARD_PROTECTED
.4byte \jumpInstr
Expand Down
31 changes: 30 additions & 1 deletion data/battle_scripts_1.s
Original file line number Diff line number Diff line change
Expand Up @@ -439,6 +439,35 @@ gBattleScriptsForMoveEffects::
.4byte BattleScript_EffectGlaiveRush @ EFFECT_GLAIVE_RUSH
.4byte BattleScript_EffectBrickBreak @ EFFECT_RAGING_BULL
.4byte BattleScript_EffectHit @ EFFECT_RAGE_FIST
.4byte BattleScript_EffectDoodle @ EFFECT_DOODLE

BattleScript_EffectDoodle:
attackcanceler
attackstring
ppreduce
attackanimation
waitanimation
setbyte gBattleCommunication, 0
BattleScript_EffectDoodle_CopyAbility:
trycopyability BS_ATTACKER, BattleScript_ButItFailed
.if B_ABILITY_POP_UP == TRUE
setbyte sFIXED_ABILITY_POPUP, TRUE
showabilitypopup BS_ATTACKER
pause 60
sethword sABILITY_OVERWRITE, 0
updateabilitypopup BS_ATTACKER
pause 20
destroyabilitypopup
pause 40
.endif
printstring STRINGID_PKMNCOPIEDFOE
waitmessage B_WAIT_TIME_LONG
switchinabilities BS_ATTACKER
jumpifbyte CMP_NOT_EQUAL, gBattleCommunication, 0x0, BattleScript_MoveEnd
addbyte gBattleCommunication, 1
jumpifnoally BS_TARGET, BattleScript_MoveEnd
setallytonextattacker BattleScript_EffectDoodle_CopyAbility
goto BattleScript_MoveEnd

BattleScript_EffectGlaiveRush::
call BattleScript_EffectHit_Ret
Expand Down Expand Up @@ -5915,7 +5944,7 @@ BattleScript_EffectRolePlay::
attackstring
ppreduce
accuracycheck BattleScript_ButItFailed, NO_ACC_CALC_CHECK_LOCK_ON
trycopyability BattleScript_ButItFailed
trycopyability BS_ATTACKER, BattleScript_ButItFailed
attackanimation
waitanimation
.if B_ABILITY_POP_UP == TRUE
Expand Down
7 changes: 4 additions & 3 deletions include/battle_util.h
Original file line number Diff line number Diff line change
Expand Up @@ -223,13 +223,14 @@ bool32 IsAlly(u32 battlerAtk, u32 battlerDef);
bool32 IsGen6ExpShareEnabled(void);

// Ability checks
bool32 IsRolePlayBannedAbilityAtk(u16 ability);
bool32 IsRolePlayBannedAbility(u16 ability);
bool32 IsSkillSwapBannedAbility(u16 ability);
bool32 IsRolePlayDoodleBannedAbility(u16 ability);
bool32 IsRolePlayDoodleBannedAbilityAttacker(u16 ability);
bool32 IsWorrySeedBannedAbility(u16 ability);
bool32 IsGastroAcidBannedAbility(u16 ability);
bool32 IsEntrainmentBannedAbility(u16 ability);
bool32 IsEntrainmentBannedAbilityAttacker(u16 ability);
bool32 IsEntrainmentTargetOrSimpleBeamBannedAbility(u16 ability);
bool32 IsSimpleBeamBannedAbility(u16 ability);

bool32 CanSleep(u32 battler);
bool32 CanBePoisoned(u32 battlerAttacker, u32 battlerTarget);
Expand Down
3 changes: 2 additions & 1 deletion include/constants/battle_move_effects.h
Original file line number Diff line number Diff line change
Expand Up @@ -416,7 +416,8 @@
#define EFFECT_GLAIVE_RUSH 410
#define EFFECT_RAGING_BULL 411
#define EFFECT_RAGE_FIST 412
#define EFFECT_DOODLE 413

#define NUM_BATTLE_MOVE_EFFECTS 413
#define NUM_BATTLE_MOVE_EFFECTS 414

#endif // GUARD_CONSTANTS_BATTLE_MOVE_EFFECTS_H
12 changes: 6 additions & 6 deletions src/battle_ai_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -2110,8 +2110,8 @@ static s32 AI_CheckBadMove(u32 battlerAtk, u32 battlerDef, u32 move, s32 score)
case EFFECT_ROLE_PLAY:
if (aiData->abilities[battlerAtk] == aiData->abilities[battlerDef]
|| aiData->abilities[battlerDef] == ABILITY_NONE
|| IsRolePlayBannedAbilityAtk(aiData->abilities[battlerAtk])
|| IsRolePlayBannedAbility(aiData->abilities[battlerDef]))
|| IsRolePlayDoodleBannedAbilityAttacker(aiData->abilities[battlerAtk])
|| IsRolePlayDoodleBannedAbility(aiData->abilities[battlerDef]))
ADJUST_SCORE(-10);
else if (IsAbilityOfRating(aiData->abilities[battlerAtk], 5))
ADJUST_SCORE(-4);
Expand Down Expand Up @@ -2158,15 +2158,15 @@ static s32 AI_CheckBadMove(u32 battlerAtk, u32 battlerDef, u32 move, s32 score)
case EFFECT_ENTRAINMENT:
if (aiData->abilities[battlerAtk] == ABILITY_NONE
|| IsEntrainmentBannedAbilityAttacker(aiData->abilities[battlerAtk])
|| IsEntrainmentTargetOrSimpleBeamBannedAbility(aiData->abilities[battlerDef])
|| IsEntrainmentBannedAbility(aiData->abilities[battlerDef])
|| aiData->holdEffects[battlerAtk] == HOLD_EFFECT_ABILITY_SHIELD)
ADJUST_SCORE(-10);
break;
case EFFECT_CORE_ENFORCER:
break;
case EFFECT_SIMPLE_BEAM:
if (aiData->abilities[battlerDef] == ABILITY_SIMPLE
|| IsEntrainmentTargetOrSimpleBeamBannedAbility(aiData->abilities[battlerDef])
|| IsSimpleBeamBannedAbility(aiData->abilities[battlerDef])
|| aiData->holdEffects[battlerDef] == HOLD_EFFECT_ABILITY_SHIELD)
ADJUST_SCORE(-10);
break;
Expand Down Expand Up @@ -4334,8 +4334,8 @@ static s32 AI_CheckViability(u32 battlerAtk, u32 battlerDef, u32 move, s32 score
}
break;
case EFFECT_ROLE_PLAY:
if (!IsRolePlayBannedAbilityAtk(aiData->abilities[battlerAtk])
&& !IsRolePlayBannedAbility(aiData->abilities[battlerDef])
if (!IsRolePlayDoodleBannedAbilityAttacker(aiData->abilities[battlerAtk])
&& !IsRolePlayDoodleBannedAbility(aiData->abilities[battlerDef])
&& !IsAbilityOfRating(aiData->abilities[battlerAtk], 5)
&& IsAbilityOfRating(aiData->abilities[battlerDef], 5))
ADJUST_SCORE(2);
Expand Down
19 changes: 10 additions & 9 deletions src/battle_script_commands.c
Original file line number Diff line number Diff line change
Expand Up @@ -9257,7 +9257,7 @@ static void Cmd_various(void)
case VARIOUS_SET_SIMPLE_BEAM:
{
VARIOUS_ARGS(const u8 *failInstr);
if (IsEntrainmentTargetOrSimpleBeamBannedAbility(gBattleMons[gBattlerTarget].ability)
if (IsSimpleBeamBannedAbility(gBattleMons[gBattlerTarget].ability)
|| gBattleMons[gBattlerTarget].ability == ABILITY_SIMPLE)
{
RecordAbilityBattle(gBattlerTarget, gBattleMons[gBattlerTarget].ability);
Expand All @@ -9282,7 +9282,7 @@ static void Cmd_various(void)
{
VARIOUS_ARGS(const u8 *failInstr);
if (IsEntrainmentBannedAbilityAttacker(gBattleMons[gBattlerAttacker].ability)
|| IsEntrainmentTargetOrSimpleBeamBannedAbility(gBattleMons[gBattlerTarget].ability))
|| IsEntrainmentBannedAbility(gBattleMons[gBattlerTarget].ability))
{
RecordAbilityBattle(gBattlerTarget, gBattleMons[gBattlerTarget].ability);
gBattlescriptCurrInstr = cmd->failInstr;
Expand Down Expand Up @@ -13875,24 +13875,25 @@ static void Cmd_tryswapitems(void)
}
}

// Role Play
// Role Play, Doodle
static void Cmd_trycopyability(void)
{
CMD_ARGS(const u8 *failInstr);
CMD_ARGS(u8 battler, const u8 *failInstr);

u32 battler = GetBattlerForBattleScript(cmd->battler);
u16 defAbility = gBattleMons[gBattlerTarget].ability;

if (gBattleMons[gBattlerAttacker].ability == defAbility
if (gBattleMons[battler].ability == defAbility
|| defAbility == ABILITY_NONE
|| IsRolePlayBannedAbilityAtk(gBattleMons[gBattlerAttacker].ability)
|| IsRolePlayBannedAbility(defAbility))
|| IsRolePlayDoodleBannedAbilityAttacker(gBattleMons[battler].ability)
|| IsRolePlayDoodleBannedAbility(defAbility))
{
gBattlescriptCurrInstr = cmd->failInstr;
}
else
{
gBattleScripting.abilityPopupOverwrite = gBattleMons[gBattlerAttacker].ability;
gBattleMons[gBattlerAttacker].ability = gBattleStruct->overwrittenAbilities[gBattlerAttacker] = defAbility;
gBattleScripting.abilityPopupOverwrite = gBattleMons[battler].ability;
gBattleMons[battler].ability = gBattleStruct->overwrittenAbilities[battler] = defAbility;
gLastUsedAbility = defAbility;
gBattlescriptCurrInstr = cmd->nextInstr;
}
Expand Down
Loading

0 comments on commit 505b8b6

Please sign in to comment.