Big Root and STRENGTH Sap

This commit is contained in:
DizzyEggg 2020-04-13 15:00:17 +02:00
parent 51e2e0ad10
commit cb5b673f8a
8 changed files with 93 additions and 10 deletions

View File

@ -1678,6 +1678,16 @@
.byte \val
.endm
.macro getstatvalue battler:req, statId:req
various \battler, VARIOUS_GET_STAT_VALUE
.byte \statId
.endm
.macro jumpiffullhp battler:req, ptr:req
various \battler, VARIOUS_JUMP_IF_FULL_HP
.4byte \ptr
.endm
@ helpful macros
.macro setstatchanger stat:req, stages:req, down:req
setbyte sSTATCHANGER \stat | \stages << 3 | \down << 7

View File

@ -355,6 +355,53 @@ gBattleScriptsForMoveEffects:: @ 82D86A8
.4byte BattleScript_EffectGearUp
.4byte BattleScript_EffectIncinerate
.4byte BattleScript_EffectBugBite
.4byte BattleScript_EffectStrengthSap
BattleScript_EffectStrengthSap:
setstatchanger STAT_ATK, 1, TRUE
attackcanceler
jumpifsubstituteblocks BattleScript_ButItFailedAtkStringPpReduce
accuracycheck BattleScript_PrintMoveMissed, ACC_CURR_MOVE
attackstring
ppreduce
jumpifstat BS_TARGET, CMP_NOT_EQUAL, STAT_ATK, 0, BattleScript_StrengthSapTryLower
pause 0x20
statbuffchange STAT_BUFF_ALLOW_PTR, BattleScript_MoveEnd
printfromtable gStatDownStringIds
waitmessage 0x40
goto BattleScript_MoveEnd
BattleScript_StrengthSapTryLower:
getstatvalue BS_TARGET, STAT_ATK
jumpiffullhp BS_ATTACKER, BattleScript_StrengthSapMustLower
attackanimation
waitanimation
statbuffchange STAT_BUFF_ALLOW_PTR, BattleScript_StrengthSapHp
jumpifbyte CMP_EQUAL, cMULTISTRING_CHOOSER, 0x3, BattleScript_StrengthSapHp
BattleScript_StrengthSapLower:
setgraphicalstatchangevalues
playanimation BS_TARGET, B_ANIM_STATS_CHANGE, sB_ANIM_ARG1
printfromtable gStatDownStringIds
waitmessage 0x40
goto BattleScript_StrengthSapHp
@ Drain HP without lowering a stat
BattleScript_StrengthSapTryHp:
jumpiffullhp BS_ATTACKER, BattleScript_ButItFailed
attackanimation
waitanimation
BattleScript_StrengthSapHp:
jumpiffullhp BS_ATTACKER, BattleScript_MoveEnd
manipulatedamage DMG_BIG_ROOT
healthbarupdate BS_ATTACKER
datahpupdate BS_ATTACKER
printstring STRINGID_PKMNENERGYDRAINED
waitmessage 0x40
goto BattleScript_MoveEnd
BattleScript_StrengthSapMustLower:
statbuffchange STAT_BUFF_ALLOW_PTR, BattleScript_MoveEnd
jumpifbyte CMP_EQUAL, cMULTISTRING_CHOOSER, 0x3, BattleScript_MoveEnd
attackanimation
waitanimation
goto BattleScript_StrengthSapLower
BattleScript_EffectBugBite:
setmoveeffect MOVE_EFFECT_BUG_BITE | MOVE_EFFECT_CERTAIN
@ -5196,7 +5243,7 @@ BattleScript_LeechSeedTurnDrain::
datahpupdate BS_ATTACKER
copyword gBattleMoveDamage, gHpDealt
jumpifability BS_ATTACKER, ABILITY_LIQUID_OOZE, BattleScript_LeechSeedTurnPrintLiquidOoze
manipulatedamage DMG_CHANGE_SIGN
manipulatedamage DMG_BIG_ROOT
setbyte cMULTISTRING_CHOOSER, 0x3
goto BattleScript_LeechSeedTurnPrintAndUpdateHp
BattleScript_LeechSeedTurnPrintLiquidOoze::

View File

@ -66,6 +66,7 @@ u8 CheckMoveLimitations(u8 battlerId, u8 unusableMoves, u8 check);
bool8 AreAllMovesUnusable(void);
u8 GetImprisonedMovesCount(u8 battlerId, u16 move);
u8 DoFieldEndTurnEffects(void);
s32 GetDrainedBigRootHp(u32 battler, s32 hp);
u8 DoBattlerEndTurnEffects(void);
bool8 HandleWishPerishSongOnTurnEnd(void);
bool8 HandleFaintedMonActions(void);

View File

@ -343,5 +343,6 @@
#define EFFECT_GEAR_UP 337
#define EFFECT_INCINERATE 338
#define EFFECT_BUG_BITE 339
#define EFFECT_STRENGTH_SAP 340
#endif // GUARD_CONSTANTS_BATTLE_MOVE_EFFECTS_H

View File

@ -146,6 +146,8 @@
#define VARIOUS_TRY_ILLUSION_OFF 83
#define VARIOUS_SET_SPRITEIGNORE0HP 84
#define VARIOUS_HANDLE_FORM_CHANGE 85
#define VARIOUS_GET_STAT_VALUE 86
#define VARIOUS_JUMP_IF_FULL_HP 87
// Cmd_manipulatedmg
#define DMG_CHANGE_SIGN 0
@ -154,6 +156,7 @@
#define DMG_1_8_TARGET_HP 3
#define DMG_FULL_ATTACKER_HP 4
#define DMG_CURR_ATTACKER_HP 5
#define DMG_BIG_ROOT 6
// Cmd_jumpifcantswitch
#define SWITCH_IGNORE_ESCAPE_PREVENTION 0x80

View File

@ -6789,6 +6789,19 @@ static void Cmd_various(void)
else
gBattlescriptCurrInstr += 7;
return;
case VARIOUS_GET_STAT_VALUE:
i = gBattlescriptCurrInstr[3];
gBattleMoveDamage = *(u16*)(&gBattleMons[gActiveBattler].attack) + (i - 1);
gBattleMoveDamage *= gStatStageRatios[gBattleMons[gActiveBattler].statStages[i]][0];
gBattleMoveDamage /= gStatStageRatios[gBattleMons[gActiveBattler].statStages[i]][1];
gBattlescriptCurrInstr += 4;
return;
case VARIOUS_JUMP_IF_FULL_HP:
if (BATTLER_MAX_HP(gActiveBattler))
gBattlescriptCurrInstr = T1_READ_PTR(gBattlescriptCurrInstr + 3);
else
gBattlescriptCurrInstr += 7;
return;
case VARIOUS_TRACE_ABILITY:
gBattleMons[gActiveBattler].ability = gBattleStruct->tracedAbility[gActiveBattler];
break;
@ -8094,6 +8107,9 @@ static void Cmd_manipulatedamage(void)
case DMG_CURR_ATTACKER_HP:
gBattleMoveDamage = gBattleMons[gBattlerAttacker].hp;
break;
case DMG_BIG_ROOT:
gBattleMoveDamage = GetDrainedBigRootHp(gBattlerAttacker, gBattleMoveDamage);
break;
}
gBattlescriptCurrInstr += 2;

View File

@ -1395,6 +1395,17 @@ enum
ENDTURN_BATTLER_COUNT
};
// Ingrain, Leech Seed, Strength Sap and Aqua Ring
s32 GetDrainedBigRootHp(u32 battler, s32 hp)
{
if (GetBattlerHoldEffect(battler, TRUE) == HOLD_EFFECT_BIG_ROOT)
hp = (hp * 1300) / 1000;
if (hp == 0)
hp = 1;
return hp * -1;
}
u8 DoBattlerEndTurnEffects(void)
{
u32 ability, effect = 0;
@ -1418,10 +1429,7 @@ u8 DoBattlerEndTurnEffects(void)
&& !(gStatuses3[gActiveBattler] & STATUS3_HEAL_BLOCK)
&& gBattleMons[gActiveBattler].hp != 0)
{
gBattleMoveDamage = gBattleMons[gActiveBattler].maxHP / 16;
if (gBattleMoveDamage == 0)
gBattleMoveDamage = 1;
gBattleMoveDamage *= -1;
gBattleMoveDamage = GetDrainedBigRootHp(gActiveBattler, gBattleMons[gActiveBattler].maxHP / 16);
BattleScriptExecute(BattleScript_IngrainTurnHeal);
effect++;
}
@ -1433,10 +1441,7 @@ u8 DoBattlerEndTurnEffects(void)
&& !(gStatuses3[gActiveBattler] & STATUS3_HEAL_BLOCK)
&& gBattleMons[gActiveBattler].hp != 0)
{
gBattleMoveDamage = gBattleMons[gActiveBattler].maxHP / 16;
if (gBattleMoveDamage == 0)
gBattleMoveDamage = 1;
gBattleMoveDamage *= -1;
gBattleMoveDamage = GetDrainedBigRootHp(gActiveBattler, gBattleMons[gActiveBattler].maxHP / 16);
BattleScriptExecute(BattleScript_AquaRingHeal);
effect++;
}

View File

@ -8858,7 +8858,7 @@ const struct BattleMove gBattleMoves[MOVES_COUNT] =
[MOVE_STRENGTH_SAP] =
{
.effect = EFFECT_PLACEHOLDER,
.effect = EFFECT_STRENGTH_SAP,
.power = 0,
.type = TYPE_GRASS,
.accuracy = 100,