add terrain seeds

This commit is contained in:
Evan 2021-01-06 20:22:05 -07:00
parent c1dd3fca21
commit 7fffe23e63
8 changed files with 118 additions and 4 deletions

View File

@ -1760,6 +1760,11 @@
various BS_ABILITY_BATTLER, VARIOUS_DESTROY_ABILITY_POPUP
.endm
.macro doterrainseed battler:req, ptr:req
various \battler, VARIOUS_TERRAIN_SEED
.4byte \ptr
.endm
@ helpful macros
.macro setstatchanger stat:req, stages:req, down:req
setbyte sSTATCHANGER \stat | \stages << 3 | \down << 7

View File

@ -1520,6 +1520,7 @@ BattleScript_EffectPsychicTerrain:
waitanimation
printfromtable gTerrainStringIds
waitmessage 0x40
call BattleScript_TerrainSeedLoop
goto BattleScript_MoveEnd
BattleScript_EffectTopsyTurvy:
@ -1862,10 +1863,6 @@ RoomServiceLoop:
playanimation BS_TARGET, B_ANIM_HELD_ITEM_EFFECT, NULL
waitanimation
playstatchangeanimation BS_TARGET, BIT_SPEED, STAT_CHANGE_NEGATIVE
@ setgraphicalstatchangevalues
@ playanimation BS_TARGET, B_ANIM_STATS_CHANGE, sB_ANIM_ARG1
@ waitanimation
printstring STRINGID_USINGXTHEYOFZN
waitmessage 0x40
removeitem BS_TARGET
@ -6882,6 +6879,19 @@ BattleScript_SnowWarningActivates::
playanimation BS_BATTLER_0, B_ANIM_HAIL_CONTINUES, NULL
call BattleScript_WeatherFormChanges
end3
BattleScript_TerrainSeedLoop:
savetarget
setbyte gBattlerTarget, 0
TerrainSeedLoop:
copybyte sBATTLER, gBattlerTarget
doterrainseed BS_TARGET, TerrainSeedLoop_NextBattler
removeitem BS_TARGET
TerrainSeedLoop_NextBattler:
addbyte gBattlerTarget, 0x1
jumpifbytenotequal gBattlerTarget, gBattlersCount, TerrainSeedLoop
restoretarget
return
BattleScript_ElectricSurgeActivates::
pause 0x20
@ -6889,6 +6899,7 @@ BattleScript_ElectricSurgeActivates::
printstring STRINGID_TERRAINBECOMESELECTRIC
waitstate
playanimation BS_SCRIPTING, B_ANIM_TERRAIN_ELECTRIC, NULL
call BattleScript_TerrainSeedLoop
end3
BattleScript_MistySurgeActivates::
@ -6897,6 +6908,7 @@ BattleScript_MistySurgeActivates::
printstring STRINGID_TERRAINBECOMESMISTY
waitstate
playanimation BS_SCRIPTING, B_ANIM_TERRAIN_MISTY, NULL
call BattleScript_TerrainSeedLoop
end3
BattleScript_GrassySurgeActivates::
@ -6905,6 +6917,7 @@ BattleScript_GrassySurgeActivates::
printstring STRINGID_TERRAINBECOMESGRASSY
waitstate
playanimation BS_SCRIPTING, B_ANIM_TERRAIN_GRASSY, NULL
call BattleScript_TerrainSeedLoop
end3
BattleScript_PsychicSurgeActivates::
@ -6913,6 +6926,7 @@ BattleScript_PsychicSurgeActivates::
printstring STRINGID_TERRAINBECOMESPSYCHIC
waitstate
playanimation BS_SCRIPTING, B_ANIM_TERRAIN_PSYCHIC, NULL
call BattleScript_TerrainSeedLoop
end3
BattleScript_BadDreamsActivates::
@ -7612,6 +7626,20 @@ BattleScript_82DB85B::
call BattleScript_StatUp
removeitem BS_ATTACKER
end2
BattleScript_BerryStatRaiseRet::
jumpifability BS_SCRIPTING, ABILITY_RIPEN, BattleScript_BerryStatRaiseRet_AbilityPopup
goto BattleScript_BerryStatRaiseRet_Anim
BattleScript_BerryStatRaiseRet_AbilityPopup:
call BattleScript_AbilityPopUp
BattleScript_BerryStatRaiseRet_Anim:
playanimation BS_SCRIPTING, B_ANIM_HELD_ITEM_EFFECT, NULL
statbuffchange STAT_BUFF_ALLOW_PTR, BattleScript_BerryStatRaiseRet_End
BattleScript_BerryStatRaiseRet_End:
setbyte cMULTISTRING_CHOOSER, 0x4
call BattleScript_StatUp
removeitem BS_SCRIPTING
return
BattleScript_BerryFocusEnergyEnd2::
playanimation BS_ATTACKER, B_ANIM_HELD_ITEM_EFFECT, NULL

View File

@ -209,6 +209,7 @@ extern const u8 BattleScript_SelectingNotAllowedMoveChoiceItem[];
extern const u8 BattleScript_HangedOnMsg[];
extern const u8 BattleScript_BerryConfuseHealEnd2[];
extern const u8 BattleScript_BerryStatRaiseEnd2[];
extern const u8 BattleScript_BerryStatRaiseRet[];
extern const u8 BattleScript_BerryFocusEnergyEnd2[];
extern const u8 BattleScript_ActionSelectionItemsCantBeUsed[];
extern const u8 BattleScript_ArenaTurnBeginning[];

View File

@ -130,5 +130,6 @@ void ClearIllusionMon(u32 battlerId);
bool32 SetIllusionMon(struct Pokemon *mon, u32 battlerId);
bool8 ShouldGetStatBadgeBoost(u16 flagId, u8 battlerId);
u8 GetBattleMoveSplit(u32 moveId);
u8 TryHandleSeed(u8 battler, u32 terrainFlag, u8 statId, u16 itemId, bool32 execute);
#endif // GUARD_BATTLE_UTIL_H

View File

@ -167,6 +167,7 @@
#define VARIOUS_PARALYZE_TYPE_IMMUNITY 100
#define VARIOUS_JUMP_IF_ABSENT 101
#define VARIOUS_DESTROY_ABILITY_POPUP 102
#define VARIOUS_TERRAIN_SEED 103
// Cmd_manipulatedamage
#define DMG_CHANGE_SIGN 0

View File

@ -146,4 +146,10 @@
#define HOLD_EFFECT_CHOICE(holdEffect)((holdEffect == HOLD_EFFECT_CHOICE_BAND || holdEffect == HOLD_EFFECT_CHOICE_SCARF || holdEffect == HOLD_EFFECT_CHOICE_SPECS))
// terrain seed params
#define HOLD_EFFECT_PARAM_ELECTRIC_TERRAIN 0
#define HOLD_EFFECT_PARAM_GRASSY_TERRAIN 1
#define HOLD_EFFECT_PARAM_MISTY_TERRAIN 2
#define HOLD_EFFECT_PARAM_PSYCHIC_TERRAIN 3
#endif // GUARD_HOLD_EFFECTS_H

View File

@ -8322,6 +8322,34 @@ static void Cmd_various(void)
case VARIOUS_DESTROY_ABILITY_POPUP:
DestroyAbilityPopUp(gActiveBattler);
break;
case VARIOUS_TERRAIN_SEED:
if (GetBattlerHoldEffect(gActiveBattler, TRUE) == HOLD_EFFECT_SEEDS)
{
u8 effect = 0;
u16 item = gBattleMons[gActiveBattler].item;
switch (GetBattlerHoldEffectParam(gActiveBattler))
{
case HOLD_EFFECT_PARAM_ELECTRIC_TERRAIN:
effect = TryHandleSeed(gActiveBattler, STATUS_FIELD_ELECTRIC_TERRAIN, STAT_DEF, item, FALSE);
break;
case HOLD_EFFECT_PARAM_GRASSY_TERRAIN:
effect = TryHandleSeed(gActiveBattler, STATUS_FIELD_GRASSY_TERRAIN, STAT_DEF, item, FALSE);
break;
case HOLD_EFFECT_PARAM_MISTY_TERRAIN:
effect = TryHandleSeed(gActiveBattler, STATUS_FIELD_MISTY_TERRAIN, STAT_SPDEF, item, FALSE);
break;
case HOLD_EFFECT_PARAM_PSYCHIC_TERRAIN:
effect = TryHandleSeed(gActiveBattler, STATUS_FIELD_PSYCHIC_TERRAIN, STAT_SPDEF, item, FALSE);
break;
}
if (effect)
{
//gBattlescriptCurrInstr += 7;
return;
}
}
gBattlescriptCurrInstr = T1_READ_PTR(gBattlescriptCurrInstr + 3);
return;
}
gBattlescriptCurrInstr += 3;

View File

@ -5073,6 +5073,33 @@ static u8 RandomStatRaiseBerry(u32 battlerId, u32 itemId)
return 0;
}
u8 TryHandleSeed(u8 battler, u32 terrainFlag, u8 statId, u16 itemId, bool32 execute)
{
if (gFieldStatuses & terrainFlag && gBattleMons[battler].statStages[statId] < MAX_STAT_STAGE)
{
PREPARE_STAT_BUFFER(gBattleTextBuff1, statId);
PREPARE_STRING_BUFFER(gBattleTextBuff2, STRINGID_STATROSE);
gLastUsedItem = itemId; // for surge abilities
gEffectBattler = battler;
gBattleScripting.battler = battler;
SET_STATCHANGER(statId, 1, FALSE);
gBattleScripting.animArg1 = 0xE + statId;
gBattleScripting.animArg2 = 0;
if (execute)
{
BattleScriptExecute(BattleScript_BerryStatRaiseEnd2);
}
else
{
BattleScriptPushCursor();
gBattlescriptCurrInstr = BattleScript_BerryStatRaiseRet;
}
return ITEM_STATS_CHANGE;
}
return 0;
}
static u8 ItemHealHp(u32 battlerId, u32 itemId, bool32 end2, bool32 percentHeal)
{
if (HasEnoughHpToEatBerry(battlerId, 2, itemId))
@ -5312,6 +5339,23 @@ u8 ItemBattleEffects(u8 caseID, u8 battlerId, bool8 moveTurn)
BattleScriptExecute(BattleScript_BerryStatRaiseEnd2);
effect = ITEM_STATS_CHANGE;
}
case HOLD_EFFECT_SEEDS:
switch (GetBattlerHoldEffectParam(battlerId))
{
case HOLD_EFFECT_PARAM_ELECTRIC_TERRAIN:
effect = TryHandleSeed(battlerId, STATUS_FIELD_ELECTRIC_TERRAIN, STAT_DEF, gLastUsedItem, TRUE);
break;
case HOLD_EFFECT_PARAM_GRASSY_TERRAIN:
effect = TryHandleSeed(battlerId, STATUS_FIELD_GRASSY_TERRAIN, STAT_DEF, gLastUsedItem, TRUE);
break;
case HOLD_EFFECT_PARAM_MISTY_TERRAIN:
effect = TryHandleSeed(battlerId, STATUS_FIELD_MISTY_TERRAIN, STAT_SPDEF, gLastUsedItem, TRUE);
break;
case HOLD_EFFECT_PARAM_PSYCHIC_TERRAIN:
effect = TryHandleSeed(battlerId, STATUS_FIELD_PSYCHIC_TERRAIN, STAT_SPDEF, gLastUsedItem, TRUE);
break;
}
break;
}