Stockpile gen4 effect and fixed spit up

This commit is contained in:
DizzyEggg 2019-07-09 19:06:12 +02:00
parent d3d9051c4a
commit 3e476adf4a
4 changed files with 81 additions and 31 deletions

View File

@ -729,8 +729,9 @@
.4byte \param0
.endm
.macro stockpile
.macro stockpile id:req
.byte 0x85
.byte \id
.endm
.macro stockpiletobasedamage param0:req

View File

@ -3946,11 +3946,30 @@ BattleScript_EffectStockpile::
attackcanceler
attackstring
ppreduce
stockpile
stockpile 0
attackanimation
waitanimation
printfromtable gStockpileUsedStringIds
waitmessage 0x40
jumpifmovehadnoeffect BattleScript_EffectStockpileEnd
jumpifstat BS_ATTACKER, CMP_LESS_THAN, STAT_DEF, 0xC, BattleScript_EffectStockpileDef
jumpifstat BS_ATTACKER, CMP_EQUAL, STAT_SPDEF, 0xC, BattleScript_EffectStockpileEnd
BattleScript_EffectStockpileDef:
setbyte sSTAT_ANIM_PLAYED, FALSE
playstatchangeanimation BS_ATTACKER, BIT_DEF | BIT_SPDEF, 0x0
setstatchanger STAT_DEF, 1, FALSE
statbuffchange MOVE_EFFECT_AFFECTS_USER | STAT_CHANGE_BS_PTR, BattleScript_EffectStockpileSpDef
jumpifbyte CMP_EQUAL, cMULTISTRING_CHOOSER, 0x2, BattleScript_EffectStockpileSpDef
printfromtable gStatUpStringIds
waitmessage 0x40
BattleScript_EffectStockpileSpDef::
setstatchanger STAT_SPDEF, 1, FALSE
statbuffchange MOVE_EFFECT_AFFECTS_USER | STAT_CHANGE_BS_PTR, BattleScript_EffectStockpileEnd
jumpifbyte CMP_EQUAL, cMULTISTRING_CHOOSER, 0x2, BattleScript_EffectStockpileEnd
printfromtable gStatUpStringIds
waitmessage 0x40
BattleScript_EffectStockpileEnd:
stockpile 1
goto BattleScript_MoveEnd
BattleScript_EffectSpitUp::
@ -3959,9 +3978,10 @@ BattleScript_EffectSpitUp::
attackstring
ppreduce
accuracycheck BattleScript_PrintMoveMissed, ACC_CURR_MOVE
stockpiletobasedamage BattleScript_SpitUpFail
typecalc
setbyte gIsCriticalHit, FALSE
damagecalc
adjustdamage
stockpiletobasedamage BattleScript_SpitUpFail
goto BattleScript_HitFromAtkAnimation
BattleScript_SpitUpFail::
pause 0x20

View File

@ -82,6 +82,10 @@ struct DisableStruct
u16 encoredMove;
u8 protectUses;
u8 stockpileCounter;
s8 stockpileDef;
s8 stockpileSpDef;
s8 stockpileBeforeDef;
s8 stockpileBeforeSpDef;
u8 substituteHP;
u8 disableTimer:4;
u8 disableTimerStartValue:4;

View File

@ -7962,6 +7962,9 @@ static void atk84_jumpifcantmakeasleep(void)
static void atk85_stockpile(void)
{
switch (gBattlescriptCurrInstr[1])
{
case 0:
if (gDisableStructs[gBattlerAttacker].stockpileCounter >= 3)
{
gMoveResultFlags |= MOVE_RESULT_MISSED;
@ -7970,10 +7973,22 @@ static void atk85_stockpile(void)
else
{
gDisableStructs[gBattlerAttacker].stockpileCounter++;
gDisableStructs[gBattlerAttacker].stockpileBeforeDef = gBattleMons[gBattlerAttacker].statStages[STAT_DEF];
gDisableStructs[gBattlerAttacker].stockpileBeforeSpDef = gBattleMons[gBattlerAttacker].statStages[STAT_SPDEF];
PREPARE_BYTE_NUMBER_BUFFER(gBattleTextBuff1, 1, gDisableStructs[gBattlerAttacker].stockpileCounter);
gBattleCommunication[MULTISTRING_CHOOSER] = 0;
}
gBattlescriptCurrInstr++;
break;
case 1: // Save def/sp def stats.
if (!(gMoveResultFlags & MOVE_RESULT_NO_EFFECT))
{
gDisableStructs[gBattlerAttacker].stockpileDef += gBattleMons[gBattlerAttacker].statStages[STAT_DEF] - gDisableStructs[gBattlerAttacker].stockpileBeforeDef;
gDisableStructs[gBattlerAttacker].stockpileSpDef += gBattleMons[gBattlerAttacker].statStages[STAT_SPDEF] - gDisableStructs[gBattlerAttacker].stockpileBeforeSpDef;
}
break;
}
gBattlescriptCurrInstr += 2;
}
static void atk86_stockpiletobasedamage(void)
@ -7986,11 +8001,12 @@ static void atk86_stockpiletobasedamage(void)
else
{
if (gBattleCommunication[6] != 1)
{
gBattleScripting.animTurn = gDisableStructs[gBattlerAttacker].stockpileCounter;
}
gDisableStructs[gBattlerAttacker].stockpileCounter = 0;
// Restore stat changes from stockpile.
gBattleMons[gBattlerAttacker].statStages[STAT_DEF] -= gDisableStructs[gBattlerAttacker].stockpileDef;
gBattleMons[gBattlerAttacker].statStages[STAT_SPDEF] -= gDisableStructs[gBattlerAttacker].stockpileSpDef;
gBattlescriptCurrInstr += 5;
}
}
@ -8004,7 +8020,9 @@ static void atk87_stockpiletohpheal(void)
gBattlescriptCurrInstr = jumpPtr;
gBattleCommunication[MULTISTRING_CHOOSER] = 0;
}
else if (gBattleMons[gBattlerAttacker].maxHP == gBattleMons[gBattlerAttacker].hp)
else
{
if (gBattleMons[gBattlerAttacker].maxHP == gBattleMons[gBattlerAttacker].hp)
{
gDisableStructs[gBattlerAttacker].stockpileCounter = 0;
gBattlescriptCurrInstr = jumpPtr;
@ -8024,6 +8042,11 @@ static void atk87_stockpiletohpheal(void)
gBattlescriptCurrInstr += 5;
gBattlerTarget = gBattlerAttacker;
}
// Restore stat changes from stockpile.
gBattleMons[gBattlerAttacker].statStages[STAT_DEF] -= gDisableStructs[gBattlerAttacker].stockpileDef;
gBattleMons[gBattlerAttacker].statStages[STAT_SPDEF] -= gDisableStructs[gBattlerAttacker].stockpileSpDef;
}
}
static void atk88_setdrainedhp(void)
@ -8276,6 +8299,8 @@ static void atk8A_normalisebuffs(void) // haze
for (i = 0; i < gBattlersCount; i++)
{
gDisableStructs[i].stockpileDef = 0;
gDisableStructs[i].stockpileSpDef = 0;
for (j = 0; j < NUM_BATTLE_STATS; j++)
gBattleMons[i].statStages[j] = 6;
}