Merge branch 'battle_engine' of https://github.com/rh-hideout/pokeemerald-expansion into gen_8_moves_batch1

This commit is contained in:
BuffelSaft 2021-11-10 14:31:32 +13:00
commit e2599c2469
25 changed files with 865 additions and 208 deletions

View File

@ -1913,6 +1913,14 @@
.4byte \ptr
.endm
.macro photongeysercheck
various BS_ATTACKER, VARIOUS_PHOTON_GEYSER_CHECK
.endm
.macro shellsidearmcheck
various BS_ATTACKER, VARIOUS_SHELL_SIDE_ARM_CHECK
.endm
@ helpful macros
.macro setstatchanger stat:req, stages:req, down:req
setbyte sSTATCHANGER \stat | \stages << 3 | \down << 7

View File

@ -5,6 +5,7 @@
#include "constants/moves.h"
#include "constants/pokemon.h"
#include "constants/items.h"
#include "constants/battle_config.h"
.include "asm/macros.inc"
.include "asm/macros/battle_anim_script.inc"
.include "constants/constants.inc"
@ -14026,7 +14027,50 @@ Move_METEOR_BEAM::
end @to do:
Move_SHELL_SIDE_ARM::
end @to do:
launchtask AnimTask_ShellSideArm 0x5 0x0
jumpargeq 0x0, TRUE, Move_SHELL_SIDE_ARM_PHYSICAL
jumpargeq 0x0, FALSE, Move_SHELL_SIDE_ARM_SPECIAL
Move_SHELL_SIDE_ARM_PHYSICAL: @ Modified Body Slam, placeholder
loadspritegfx ANIM_TAG_IMPACT
createvisualtask AnimTask_BlendParticle, 5, ANIM_TAG_IMPACT, 0, 6, 6, RGB_MAGENTA
monbg ANIM_DEF_PARTNER
setalpha 12, 8
playsewithpan SE_M_TAKE_DOWN, SOUND_PAN_ATTACKER
createsprite gVerticalDipSpriteTemplate, ANIM_ATTACKER, 2, 6, 1, ANIM_ATTACKER
waitforvisualfinish
delay 11
createsprite gSlideMonToOffsetSpriteTemplate, ANIM_ATTACKER, 2, 0, 26, 0, 0, 5
delay 6
createsprite gBasicHitSplatSpriteTemplate, ANIM_ATTACKER, 4, -10, 0, ANIM_TARGET, 0
loopsewithpan SE_M_MEGA_KICK2, SOUND_PAN_TARGET, 10, 2
delay 1
createsprite gSlideMonToOffsetSpriteTemplate, ANIM_ATTACKER, 2, 1, -28, 0, 0, 3
waitforvisualfinish
createvisualtask AnimTask_ShakeMonInPlace, 2, ANIM_TARGET, 4, 0, 12, 1
waitforvisualfinish
delay 10
createsprite gSlideMonToOriginalPosSpriteTemplate, ANIM_ATTACKER, 2, 0, 0, 6
delay 5
createsprite gSlideMonToOriginalPosSpriteTemplate, ANIM_ATTACKER, 2, 1, 0, 6
waitforvisualfinish
clearmonbg ANIM_DEF_PARTNER
blendoff
end
Move_SHELL_SIDE_ARM_SPECIAL: @ Modified Snipe Shot, placeholder
loadspritegfx ANIM_TAG_IMPACT_2
loadspritegfx ANIM_TAG_LEER
createvisualtask AnimTask_BlendParticle, 5, ANIM_TAG_IMPACT_2, 0, 6, 6, RGB_MAGENTA
createvisualtask AnimTask_BlendParticle, 5, ANIM_TAG_LEER, 0, 6, 6, RGB_MAGENTA
launchtemplate gLeerSpriteTemplate 0x82, 2 0x18 -12
playsewithpan SE_M_DETECT, SOUND_PAN_ATTACKER
waitforvisualfinish
delay 0x20
playsewithpan SE_M_GIGA_DRAIN, SOUND_PAN_TARGET
launchtemplate gSnipeShotBallTemplate 0x82, 3, 0 0 24,
waitforvisualfinish
launchtask AnimTask_ShakeMon2 2 5 1 4 0 8, 1
waitforvisualfinish
end
Move_MISTY_EXPLOSION::
end @to do:
@ -14038,7 +14082,87 @@ Move_RISING_VOLTAGE::
end @to do:
Move_TERRAIN_PULSE::
end @to do:
loadspritegfx ANIM_TAG_DRAGON_PULSE
monbg ANIM_TARGET
setalpha 12, 8
createsprite gSimplePaletteBlendSpriteTemplate, ANIM_ATTACKER, 2, 1, 1, 0, 7, RGB_BLACK
launchtask AnimTask_TerrainPulse 0x5 0x0
jumpargeq 0x0, TYPE_ELECTRIC, TerrainPulseElectric
jumpargeq 0x0, TYPE_GRASS, TerrainPulseGrass
jumpargeq 0x0, TYPE_FAIRY, TerrainPulseFairy
jumpargeq 0x0, TYPE_PSYCHIC, TerrainPulsePsychic
TerrainPulseNormal:
createvisualtask AnimTask_BlendParticle, 5, ANIM_TAG_DRAGON_PULSE, 0, 12, 12, RGB_WHITE
waitforvisualfinish
playsewithpan SE_M_PSYBEAM, SOUND_PAN_ATTACKER
createsoundtask SoundTask_LoopSEAdjustPanning, SE_M_PSYBEAM2, SOUND_PAN_ATTACKER, SOUND_PAN_TARGET, 3, 4, 0, 15
call DragonPulseParticle
call DragonPulseParticle
createvisualtask AnimTask_SwayMon, 5, 0, 2, 51200, 24, ANIM_TARGET
createvisualtask AnimTask_BlendColorCycle, 2, 4, 2, 2, 0, 12, RGB_WHITE
goto TerrainPulseEnd
TerrainPulseElectric:
createvisualtask AnimTask_BlendParticle, 5, ANIM_TAG_DRAGON_PULSE, 0, 12, 12, RGB(27, 27, 0)
waitforvisualfinish
playsewithpan SE_M_PSYBEAM, SOUND_PAN_ATTACKER
createsoundtask SoundTask_LoopSEAdjustPanning, SE_M_PSYBEAM2, SOUND_PAN_ATTACKER, SOUND_PAN_TARGET, 3, 4, 0, 15
call DragonPulseParticle
call DragonPulseParticle
createvisualtask AnimTask_SwayMon, 5, 0, 4, 51200, 24, ANIM_TARGET
createvisualtask AnimTask_BlendColorCycle, 2, 4, 2, 2, 0, 12, RGB(27, 27, 0)
goto TerrainPulseEnd
TerrainPulseGrass:
createvisualtask AnimTask_BlendParticle, 5, ANIM_TAG_DRAGON_PULSE, 0, 12, 12, RGB(11, 26, 11)
waitforvisualfinish
playsewithpan SE_M_PSYBEAM, SOUND_PAN_ATTACKER
createsoundtask SoundTask_LoopSEAdjustPanning, SE_M_PSYBEAM2, SOUND_PAN_ATTACKER, SOUND_PAN_TARGET, 3, 4, 0, 15
call DragonPulseParticle
call DragonPulseParticle
createvisualtask AnimTask_SwayMon, 5, 0, 4, 51200, 24, ANIM_TARGET
createvisualtask AnimTask_BlendColorCycle, 2, 4, 2, 2, 0, 12, RGB(11, 26, 11)
goto TerrainPulseEnd
TerrainPulseFairy:
createvisualtask AnimTask_BlendParticle, 5, ANIM_TAG_DRAGON_PULSE, 0, 12, 12, RGB(31, 24, 31)
waitforvisualfinish
playsewithpan SE_M_PSYBEAM, SOUND_PAN_ATTACKER
createsoundtask SoundTask_LoopSEAdjustPanning, SE_M_PSYBEAM2, SOUND_PAN_ATTACKER, SOUND_PAN_TARGET, 3, 4, 0, 15
call DragonPulseParticle
call DragonPulseParticle
createvisualtask AnimTask_SwayMon, 5, 0, 4, 51200, 24, ANIM_TARGET
createvisualtask AnimTask_BlendColorCycle, 2, 4, 2, 2, 0, 12, RGB(31, 24, 31)
goto TerrainPulseEnd
TerrainPulsePsychic:
createvisualtask AnimTask_BlendParticle, 5, ANIM_TAG_DRAGON_PULSE, 0, 12, 12, RGB(27, 0, 13)
waitforvisualfinish
playsewithpan SE_M_PSYBEAM, SOUND_PAN_ATTACKER
createsoundtask SoundTask_LoopSEAdjustPanning, SE_M_PSYBEAM2, SOUND_PAN_ATTACKER, SOUND_PAN_TARGET, 3, 4, 0, 15
call DragonPulseParticle
call DragonPulseParticle
createvisualtask AnimTask_SwayMon, 5, 0, 4, 51200, 24, ANIM_TARGET
createvisualtask AnimTask_BlendColorCycle, 2, 4, 2, 2, 0, 12, RGB(27, 0, 13)
goto TerrainPulseEnd
TerrainPulseEnd:
call DragonPulseParticle
call DragonPulseParticle
call DragonPulseParticle
call DragonPulseParticle
call DragonPulseParticle
call DragonPulseParticle
call DragonPulseParticle
call DragonPulseParticle
call DragonPulseParticle
waitforvisualfinish
delay 1
createsprite gSimplePaletteBlendSpriteTemplate, ANIM_ATTACKER, 2, 1, 1, 7, 0, RGB_BLACK
waitforvisualfinish
blendoff
clearmonbg ANIM_TARGET
end
Move_SKITTER_SMACK::
end @to do:
@ -23310,17 +23434,50 @@ Move_SKY_UPPERCUT:
end
Move_SECRET_POWER:
createvisualtask AnimTask_GetFieldTerrain, 5
jumpargeq 0, STATUS_FIELD_MISTY_TERRAIN, Move_FAIRY_WIND
jumpargeq 0, STATUS_FIELD_GRASSY_TERRAIN, Move_NEEDLE_ARM
jumpargeq 0, STATUS_FIELD_ELECTRIC_TERRAIN, Move_THUNDER_SHOCK
jumpargeq 0, STATUS_FIELD_PSYCHIC_TERRAIN, Move_CONFUSION
createvisualtask AnimTask_GetBattleTerrain, 5
jumpargeq 0, BATTLE_TERRAIN_GRASS, Move_NEEDLE_ARM
jumpargeq 0, BATTLE_TERRAIN_LONG_GRASS, Move_MAGICAL_LEAF
jumpargeq 0, BATTLE_TERRAIN_SAND, Move_MUD_SHOT
jumpargeq 0, BATTLE_TERRAIN_UNDERWATER, Move_WATERFALL
jumpargeq 0, BATTLE_TERRAIN_WATER, Move_SURF
jumpargeq 0, BATTLE_TERRAIN_POND, Move_BUBBLE_BEAM
jumpargeq 0, BATTLE_TERRAIN_MOUNTAIN, Move_ROCK_THROW
jumpargeq 0, BATTLE_TERRAIN_CAVE, Move_BITE
jumpargeq 0, BATTLE_TERRAIN_BUILDING, Move_STRENGTH
jumpargeq 0, BATTLE_TERRAIN_GRASS, Move_NEEDLE_ARM
jumpargeq 0, BATTLE_TERRAIN_LONG_GRASS, Move_MAGICAL_LEAF
jumpargeq 0, BATTLE_TERRAIN_SAND, Move_MUD_SHOT
jumpargeq 0, BATTLE_TERRAIN_UNDERWATER, Move_WATERFALL
jumpargeq 0, BATTLE_TERRAIN_WATER, Move_SURF
jumpargeq 0, BATTLE_TERRAIN_POND, Move_BUBBLE_BEAM
jumpargeq 0, BATTLE_TERRAIN_MOUNTAIN, Move_ROCK_THROW
jumpargeq 0, BATTLE_TERRAIN_CAVE, Move_BITE
jumpargeq 0, BATTLE_TERRAIN_BUILDING, Move_STRENGTH
jumpargeq 0, BATTLE_TERRAIN_SOARING, Move_GUST
jumpargeq 0, BATTLE_TERRAIN_SKY_PILLAR, Move_GUST
jumpargeq 0, BATTLE_TERRAIN_BURIAL_GROUND, Move_SHADOW_SNEAK
jumpargeq 0, BATTLE_TERRAIN_PUDDLE, Move_MUD_SHOT
jumpargeq 0, BATTLE_TERRAIN_MARSH, Move_MUD_SHOT
jumpargeq 0, BATTLE_TERRAIN_SWAMP, Move_MUD_SHOT
.if B_SECRET_POWER_ANIMATION >= GEN_7
jumpargeq 0, BATTLE_TERRAIN_SNOW, Move_ICE_SHARD
.else
jumpargeq 0, BATTLE_TERRAIN_SNOW, Move_AVALANCHE
.endif
jumpargeq 0, BATTLE_TERRAIN_ICE, Move_ICE_SHARD
jumpargeq 0, BATTLE_TERRAIN_VOLCANO, Move_INCINERATE
jumpargeq 0, BATTLE_TERRAIN_DISTORTION_WORLD, Move_POUND
jumpargeq 0, BATTLE_TERRAIN_SPACE, Move_SWIFT
jumpargeq 0, BATTLE_TERRAIN_ULTRA_SPACE, Move_PSYWAVE
.if B_SECRET_POWER_ANIMATION >= GEN_7
jumpargeq 0, BATTLE_TERRAIN_BUILDING, Move_SPIT_UP
goto Move_SPIT_UP
.elseif B_SECRET_POWER_ANIMATION == GEN_6
jumpargeq 0, BATTLE_TERRAIN_BUILDING, Move_BODY_SLAM
goto Move_BODY_SLAM
.elseif B_SECRET_POWER_ANIMATION == GEN_5 || B_SECRET_POWER_ANIMATION == GEN_4
jumpargeq 0, BATTLE_TERRAIN_BUILDING, Move_BODY_SLAM
goto Move_MUD_SLAP
.else
jumpargeq 0, BATTLE_TERRAIN_BUILDING, Move_STRENGTH
goto Move_SLAM
.endif
Move_TWISTER:
loadspritegfx ANIM_TAG_LEAF
@ -24037,6 +24194,7 @@ General_TurnTrap:
jumpargeq 0, TRAP_ANIM_WHIRLPOOL, Status_Whirlpool
jumpargeq 0, TRAP_ANIM_CLAMP, Status_Clamp
jumpargeq 0, TRAP_ANIM_SAND_TOMB, Status_SandTomb
jumpargeq 0, TRAP_ANIM_MAGMA_STORM, Status_MagmaStorm
jumpargeq 0, TRAP_ANIM_INFESTATION, Status_Infestation
goto Status_BindWrap
Status_BindWrap:
@ -24063,6 +24221,32 @@ Status_FireSpin:
stopsound
end
Status_MagmaStorm:
loadspritegfx ANIM_TAG_SMALL_EMBER
fadetobg BG_MAGMA_STORM
waitbgfadeout
createvisualtask AnimTask_MoveSeismicTossBg, 3
playsewithpan SE_M_SACRED_FIRE2, SOUND_PAN_TARGET
loopsewithpan SE_M_SACRED_FIRE2, SOUND_PAN_TARGET, 5, 8
createvisualtask AnimTask_SeismicTossBgAccelerateDownAtEnd, 3
createvisualtask AnimTask_ShakeMon, 5, ANIM_TARGET, 0, 2, 47, 1
createvisualtask AnimTask_BlendColorCycle, 2, 6, 4, 2, 2, 0, 12, RGB(22, 9, 7)
call FireSpinEffect
call FireSpinEffect
createvisualtask AnimTask_BlendColorCycle, 2, 6, 4, 2, 2, 0, 12, RGB(22, 9, 7)
call FireSpinEffect
call FireSpinEffect
createvisualtask AnimTask_BlendColorCycle, 2, 6, 4, 2, 2, 0, 12, RGB(22, 9, 7)
call FireSpinEffect
restorebg
waitbgfadeout
setarg 7, 0xFFF
waitbgfadein
stopsound
clearmonbg ANIM_DEF_PARTNER
blendoff
end
Status_Whirlpool:
loadspritegfx ANIM_TAG_WATER_ORB
monbg ANIM_DEF_PARTNER

View File

@ -367,7 +367,7 @@ gBattleScriptsForMoveEffects::
.4byte BattleScript_EffectGeomancy @ EFFECT_GEOMANCY
.4byte BattleScript_EffectFairyLock @ EFFECT_FAIRY_LOCK
.4byte BattleScript_EffectAllySwitch @ EFFECT_ALLY_SWITCH
.4byte BattleScript_EffectSleepHit @ EFFECT_SLEEP_HIT
.4byte BattleScript_EffectRelicSong @ EFFECT_RELIC_SONG
.4byte BattleScript_EffectAttackerDefenseDownHit @ EFFECT_ATTACKER_DEFENSE_DOWN_HIT
.4byte BattleScript_EffectHit @ EFFECT_BODY_PRESS
.4byte BattleScript_EffectEerieSpell @ EFFECT_EERIE_SPELL
@ -393,6 +393,9 @@ gBattleScriptsForMoveEffects::
.4byte BattleScript_EffectPlasmaFists @ EFFECT_PLASMA_FISTS
.4byte BattleScript_EffectHyperspaceFury @ EFFECT_HYPERSPACE_FURY
.4byte BattleScript_EffectAuraWheel @ EFFECT_AURA_WHEEL
.4byte BattleScript_EffectPhotonGeyser @ EFFECT_PHOTON_GEYSER
.4byte BattleScript_EffectShellSideArm @ EFFECT_SHELL_SIDE_ARM
.4byte BattleScript_EffectHit @ EFFECT_TERRAIN_PULSE
.4byte BattleScript_EffectJawLock @ EFFECT_JAW_LOCK
.4byte BattleScript_EffectNoRetreat @ EFFECT_NO_RETREAT
.4byte BattleScript_EffectTarShot @ EFFECT_TAR_SHOT
@ -401,6 +404,35 @@ gBattleScriptsForMoveEffects::
.4byte BattleScript_EffectClangorousSoul @ EFFECT_CLANGOROUS_SOUL
.4byte BattleScript_EffectHit @ EFFECT_BOLT_BEAK
BattleScript_EffectShellSideArm:
shellsidearmcheck
setmoveeffect MOVE_EFFECT_POISON
goto BattleScript_EffectHit
BattleScript_EffectPhotonGeyser:
attackcanceler
accuracycheck BattleScript_PrintMoveMissed, ACC_CURR_MOVE
attackstring
ppreduce
critcalc
damagecalc
adjustdamage
photongeysercheck
attackanimation
waitanimation
effectivenesssound
hitanimation BS_TARGET
waitstate
healthbarupdate BS_TARGET
datahpupdate BS_TARGET
critmessage
waitmessage B_WAIT_TIME_LONG
resultmessage
waitmessage B_WAIT_TIME_LONG
seteffectwithchance
tryfaintmon BS_TARGET, FALSE, NULL
goto BattleScript_MoveEnd
BattleScript_EffectAuraWheel: @ Aura Wheel can only be used by Morpeko
jumpifspecies BS_ATTACKER, SPECIES_MORPEKO, BattleScript_EffectSpeedUpHit
jumpifspecies BS_ATTACKER, SPECIES_MORPEKO_HANGRY, BattleScript_EffectSpeedUpHit
@ -854,9 +886,30 @@ BattleScript_EffectAttackerDefenseDownHit:
setmoveeffect MOVE_EFFECT_DEF_MINUS_1 | MOVE_EFFECT_AFFECTS_USER | MOVE_EFFECT_CERTAIN
goto BattleScript_EffectHit
BattleScript_EffectSleepHit:
setmoveeffect MOVE_EFFECT_SLEEP
goto BattleScript_EffectHit
BattleScript_EffectRelicSong:
setmoveeffect MOVE_EFFECT_RELIC_SONG | MOVE_EFFECT_AFFECTS_USER | MOVE_EFFECT_CERTAIN
attackcanceler
accuracycheck BattleScript_PrintMoveMissed, ACC_CURR_MOVE
attackstring
ppreduce
critcalc
damagecalc
adjustdamage
attackanimation
waitanimation
effectivenesssound
hitanimation BS_TARGET
waitstate
healthbarupdate BS_TARGET
datahpupdate BS_TARGET
critmessage
waitmessage B_WAIT_TIME_LONG
resultmessage
waitmessage B_WAIT_TIME_LONG
seteffectwithchance
argumentstatuseffect
tryfaintmon BS_TARGET, FALSE, NULL
goto BattleScript_MoveEnd
BattleScript_EffectAllySwitch:
attackcanceler
@ -7123,6 +7176,17 @@ BattleScript_AttackerFormChangeEnd3::
BattleScript_AttackerFormChangeEnd3NoPopup::
call BattleScript_AttackerFormChangeNoPopup
BattleScript_AttackerFormChangeMoveEffect::
waitmessage 1
handleformchange BS_ATTACKER, 0
handleformchange BS_ATTACKER, 1
playanimation BS_ATTACKER, B_ANIM_FORM_CHANGE, NULL
waitanimation
copybyte sBATTLER, gBattlerAttacker
printstring STRINGID_PKMNTRANSFORMED
waitmessage B_WAIT_TIME_LONG
handleformchange BS_ATTACKER, 2
end3
BattleScript_BallFetch::

View File

@ -225,10 +225,7 @@ struct FieldTimer
u8 wonderRoomTimer;
u8 magicRoomTimer;
u8 trickRoomTimer;
u8 grassyTerrainTimer;
u8 mistyTerrainTimer;
u8 electricTerrainTimer;
u8 psychicTerrainTimer;
u8 terrainTimer;
u8 gravityTimer;
u8 fairyLockTimer;
};
@ -932,5 +929,6 @@ extern u8 gBattleControllerData[MAX_BATTLERS_COUNT];
extern bool8 gHasFetchedBall;
extern u8 gLastUsedBall;
extern u16 gLastThrownBall;
extern bool8 gSwapDamageCategory; // Photon Geyser, Shell Side Arm, Light That Burns the Sky
#endif // GUARD_BATTLE_H

View File

@ -35,7 +35,8 @@ u16 AI_GetHoldEffect(u32 battlerId);
u32 AI_GetMoveAccuracy(u8 battlerAtk, u8 battlerDef, u16 atkAbility, u16 defAbility, u8 atkHoldEffect, u8 defHoldEffect, u16 move);
bool32 DoesBattlerIgnoreAbilityChecks(u16 atkAbility, u16 move);
bool32 AI_WeatherHasEffect(void);
bool32 CanAttackerFaintTarget(u8 battlerAtk, u8 battlerDef, u8 index, u8 numHits);
bool32 CanAIFaintTarget(u8 battlerAtk, u8 battlerDef, u8 numHits);
bool32 CanIndexMoveFaintTarget(u8 battlerAtk, u8 battlerDef, u8 index, u8 numHits);
bool32 AI_IsTerrainAffected(u8 battlerId, u32 flags);
bool32 AI_IsBattlerGrounded(u8 battlerId);
bool32 HasDamagingMove(u8 battlerId);

View File

@ -310,6 +310,5 @@ extern const u8 gText_BattleTourney[];
extern const u16 gMissStringIds[];
extern const u16 gStatUpStringIds[];
extern const u16 gTrappingMoves[];
#endif // GUARD_BATTLE_MESSAGE_H

View File

@ -36,6 +36,7 @@ u32 IsAbilityStatusProtected(u32 battler);
bool32 TryResetBattlerStatChanges(u8 battler);
bool32 CanCamouflage(u8 battlerId);
u16 GetNaturePowerMove(void);
u16 GetSecretPowerMoveEffect(void);
void StealTargetItem(u8 battlerStealer, u8 battlerItem);
u8 GetCatchingBattler(void);

View File

@ -410,6 +410,7 @@ extern const u8 BattleScript_PastelVeilActivates[];
extern const u8 BattleScript_MimicryActivatesEnd3[];
extern const u8 BattleScript_ApplyMimicry[];
extern const u8 BattleScript_AttackerFormChangeEnd3NoPopup[];
extern const u8 BattleScript_AttackerFormChangeMoveEffect[];
extern const u8 BattleScript_BothCanNoLongerEscape[];
extern const u8 BattleScript_OctolockEndTurn[];

View File

@ -357,23 +357,39 @@
#define MOVE_EFFECT_INCINERATE 0x44
#define MOVE_EFFECT_BUG_BITE 0x45
#define MOVE_EFFECT_RECOIL_HP_25 0x46
#define MOVE_EFFECT_TRAP_BOTH 0x47
#define NUM_MOVE_EFFECTS 0x48
#define MOVE_EFFECT_RELIC_SONG 0x47
#define MOVE_EFFECT_TRAP_BOTH 0x48
#define NUM_MOVE_EFFECTS 0x49
#define MOVE_EFFECT_AFFECTS_USER 0x4000
#define MOVE_EFFECT_CERTAIN 0x8000
// Battle terrain defines for gBattleTerrain.
#define BATTLE_TERRAIN_GRASS 0
#define BATTLE_TERRAIN_LONG_GRASS 1
#define BATTLE_TERRAIN_SAND 2
#define BATTLE_TERRAIN_UNDERWATER 3
#define BATTLE_TERRAIN_WATER 4
#define BATTLE_TERRAIN_POND 5
#define BATTLE_TERRAIN_MOUNTAIN 6
#define BATTLE_TERRAIN_CAVE 7
#define BATTLE_TERRAIN_BUILDING 8
#define BATTLE_TERRAIN_PLAIN 9
#define BATTLE_TERRAIN_GRASS 0
#define BATTLE_TERRAIN_LONG_GRASS 1
#define BATTLE_TERRAIN_SAND 2
#define BATTLE_TERRAIN_UNDERWATER 3
#define BATTLE_TERRAIN_WATER 4
#define BATTLE_TERRAIN_POND 5
#define BATTLE_TERRAIN_MOUNTAIN 6
#define BATTLE_TERRAIN_CAVE 7
#define BATTLE_TERRAIN_BUILDING 8
#define BATTLE_TERRAIN_PLAIN 9
// New battle terrains are used for Secret Power but not fully implemented.
#define BATTLE_TERRAIN_SOARING 10
#define BATTLE_TERRAIN_SKY_PILLAR 11
#define BATTLE_TERRAIN_BURIAL_GROUND 12
#define BATTLE_TERRAIN_PUDDLE 13
#define BATTLE_TERRAIN_MARSH 14
#define BATTLE_TERRAIN_SWAMP 15
#define BATTLE_TERRAIN_SNOW 16
#define BATTLE_TERRAIN_ICE 17
#define BATTLE_TERRAIN_VOLCANO 18
#define BATTLE_TERRAIN_DISTORTION_WORLD 19
#define BATTLE_TERRAIN_SPACE 20
#define BATTLE_TERRAIN_ULTRA_SPACE 21
#define BATTLE_TERRAIN_COUNT 22
#define B_WAIT_TIME_LONG 64
#define B_WAIT_TIME_MED 48

View File

@ -565,7 +565,8 @@
#define TRAP_ANIM_WHIRLPOOL 2
#define TRAP_ANIM_CLAMP 3
#define TRAP_ANIM_SAND_TOMB 4
#define TRAP_ANIM_INFESTATION 5
#define TRAP_ANIM_MAGMA_STORM 5
#define TRAP_ANIM_INFESTATION 6
// Weather defines for battle animation scripts.
#define ANIM_WEATHER_NONE 0

View File

@ -95,7 +95,6 @@
#define B_CRIT_CHANCE GEN_7 // Chances of a critical hit landing. See CalcCritChanceStage.
#define B_CRIT_MULTIPLIER GEN_7 // In Gen6+, critical hits multiply damage by 1.5 instead of 2.
#define B_PARALYSIS_SPEED GEN_7 // In Gen7+, Speed is decreased by 50% instead of 75%.
#define B_TERRAIN_TYPE_BOOST GEN_8 // In Gen8, damage is boosted by 30% instead of 50%.
#define B_CONFUSION_SELF_DMG_CHANCE GEN_7 // In Gen7+, confusion has a 33.3% of self-damage, instead of 50%.
#define B_MULTI_HIT_CHANCE GEN_7 // In Gen5+, multi-hit moves have different %. See Cmd_setmultihitcounter for values.
@ -161,7 +160,8 @@
#define B_SHADOW_TAG_ESCAPE GEN_7 // In Gen4+, if both sides have a Pokémon with Shadow Tag, all battlers can escape. Before, neither side could escape this situation.
#define B_MOODY_ACC_EVASION GEN_8 // In Gen8, Moody CANNOT raise Accuracy and Evasion anymore.
#define B_FLASH_FIRE_FROZEN GEN_7 // In Gen5+, Flash Fire can trigger even when frozen, when it couldn't before.
#define B_SYNCHRONIZE_NATURE GEN_8 // In Gen8, if the Pokémon with Synchronize is leading the party, it's 100% guaranteed that wild Pokémon will have the same ability, as opposed to 50% previously.
#define B_SYNCHRONIZE_NATURE GEN_8 // In Gen8, if a Pokémon with Synchronize is leading the party, it's 100% guaranteed that wild Pokémon will have the same ability, as opposed to 50% previously.
#define B_SYNCHRONIZE_TOXIC GEN_8 // In Gen5+, if a Pokémon with Synchronize is badly poisoned, the opponent will also become badly poisoned. Previously, the opponent would become regular poisoned.
#define B_UPDATED_INTIMIDATE GEN_8 // In Gen8, Intimidate doesn't work on opponents with the Inner Focus, Scrappy, Own Tempo or Oblivious abilities.
// Item settings
@ -170,6 +170,7 @@
#define B_X_ITEMS_BUFF GEN_7 // In Gen7+, the X Items raise a stat by 2 stages instead of 1.
#define B_MENTAL_HERB GEN_5 // In Gen5+, the Mental Herb cures Infatuation, Taunt, Encore, Torment, Heal Block, and Disable
#define B_TRAINERS_KNOCK_OFF_ITEMS TRUE // If TRUE, trainers can steal/swap your items (non-berries are restored after battle). In vanilla games trainers cannot steal items.
#define B_SOUL_DEW_BOOST GEN_7 // In Gens3-6, Soul Dew boosts Lati@s' Sp. Atk and Sp. Def. In Gen7+ it boosts the power of their Psychic and Dragon type moves instead.
// Flag settings
// To use the following features in scripting, replace the 0s with the flag ID you're assigning it to.
@ -182,26 +183,31 @@
// Eg: Replace with VAR_UNUSED_0x40F7 so you can use VAR_TERRAIN for that feature.
#define VAR_TERRAIN 0 // If this var has a value, assigning a STATUS_FIELD_xx_TERRAIN to it before battle causes the battle to start with that terrain active
// Terrain settings
#define B_TERRAIN_BG_CHANGE TRUE // If set to TRUE, terrain moves permanently change the default battle background until the effect fades.
#define B_THUNDERSTORM_TERRAIN TRUE // If TRUE, overworld Thunderstorm generates Rain and Electric Terrain as in Gen 8.
#define B_TERRAIN_TYPE_BOOST GEN_8 // In Gen8, damage is boosted by 30% instead of 50%.
#define B_SECRET_POWER_EFFECT GEN_7 // Secret Power's effects change depending on terrain and generation. See GetSecretPowerMoveEffect.
#define B_SECRET_POWER_ANIMATION GEN_7 // Secret Power's animations change depending on terrain and generation.
#define B_NATURE_POWER_MOVES GEN_8 // Nature Power calls different moves depending on terrain and generation. See sNaturePowerMoves.
#define B_CAMOUFLAGE_TYPES GEN_7 // Camouflage changes the user to different types depending on terrain and generation. See sTerrainToType.
// Interface settings
#define B_ABILITY_POP_UP TRUE // In Gen5+, the Pokémon abilities are displayed in a pop-up, when they activate in battle.
#define B_FAST_INTRO TRUE // If set to TRUE, battle intro texts print at the same time as animation of a Pokémon, as opposing to waiting for the animation to end.
#define B_SHOW_TARGETS TRUE // If set to TRUE, all available targets, for moves hitting 2 or 3 Pokémon, will be shown before selecting a move.
#define B_SHOW_SPLIT_ICON TRUE // If set to TRUE, it will show an icon in the summary showing the move's category split.
#define B_HIDE_HEALTHBOX_IN_ANIMS TRUE // If set to TRUE, hides healthboxes during move animations.
#define B_TERRAIN_BG_CHANGE TRUE // If set to TRUE, terrain moves permanently change the default battle background until the effect fades.
// Critical Capture
#define B_CRITICAL_CAPTURE TRUE // If set to TRUE, Critical Capture will be enabled.
#define B_CATCHING_CHARM_BOOST 20 // % boost in Critical Capture odds if player has the Catching Charm.
// Last Used Ball
#define B_LAST_USED_BALL TRUE // If TRUE, the "last used ball" feature from Gen 7 will be implemented
#define B_LAST_USED_BALL_BUTTON R_BUTTON // If last used ball is implemented, this button (or button combo) will trigger throwing the last used ball.
// Catching settings
#define B_SEMI_INVULNERABLE_CATCH GEN_7 // In Gen4+, you cannot throw a ball against a Pokemon that is in a semi-invulnerable state (dig/fly/etc)
#define B_CATCHING_CHARM_BOOST 20 // % boost in Critical Capture odds if player has the Catching Charm.
#define B_CRITICAL_CAPTURE TRUE // If set to TRUE, Critical Capture will be enabled.
#define B_LAST_USED_BALL TRUE // If TRUE, the "last used ball" feature from Gen 7 will be implemented
#define B_LAST_USED_BALL_BUTTON R_BUTTON // If last used ball is implemented, this button (or button combo) will trigger throwing the last used ball.
// Other
#define B_DOUBLE_WILD_CHANCE 0 // % chance of encountering two Pokémon in a Wild Encounter.
#define B_THUNDERSTORM_TERRAIN TRUE // If TRUE, overworld Thunderstorm generates Rain and Electric Terrain as in Gen 8.
#define B_SEMI_INVULNERABLE_CATCH GEN_7 // In Gen4+, you cannot throw a ball against a Pokemon that is in a semi-invulnerable state (dig/fly/etc)
// Animation Settings
#define B_NEW_SWORD_PARTICLE FALSE // If set to TRUE, it updates Swords Dance's particle.

View File

@ -350,7 +350,7 @@
#define EFFECT_GEOMANCY 344
#define EFFECT_FAIRY_LOCK 345
#define EFFECT_ALLY_SWITCH 346
#define EFFECT_SLEEP_HIT 347
#define EFFECT_RELIC_SONG 347
#define EFFECT_ATTACKER_DEFENSE_DOWN_HIT 348
#define EFFECT_BODY_PRESS 349
#define EFFECT_EERIE_SPELL 350
@ -376,14 +376,17 @@
#define EFFECT_PLASMA_FISTS 370
#define EFFECT_HYPERSPACE_FURY 371
#define EFFECT_AURA_WHEEL 372
#define EFFECT_JAW_LOCK 373
#define EFFECT_NO_RETREAT 374
#define EFFECT_TAR_SHOT 375
#define EFFECT_POLTERGEIST 376
#define EFFECT_OCTOLOCK 377
#define EFFECT_CLANGOROUS_SOUL 378
#define EFFECT_BOLT_BEAK 379
#define EFFECT_PHOTON_GEYSER 373
#define EFFECT_SHELL_SIDE_ARM 374
#define EFFECT_TERRAIN_PULSE 375
#define EFFECT_JAW_LOCK 376
#define EFFECT_NO_RETREAT 377
#define EFFECT_TAR_SHOT 378
#define EFFECT_POLTERGEIST 379
#define EFFECT_OCTOLOCK 380
#define EFFECT_CLANGOROUS_SOUL 381
#define EFFECT_BOLT_BEAK 382
#define NUM_BATTLE_MOVE_EFFECTS 380
#define NUM_BATTLE_MOVE_EFFECTS 383
#endif // GUARD_CONSTANTS_BATTLE_MOVE_EFFECTS_H

View File

@ -199,12 +199,14 @@
#define VARIOUS_JUMP_IF_LEAF_GUARD_PROTECTED 126
#define VARIOUS_SET_ATTACKER_STICKY_WEB_USER 127
#define VARIOUS_TRY_TO_APPLY_MIMICRY 128
#define VARIOUS_TRY_NO_RETREAT 129
#define VARIOUS_TRY_TAR_SHOT 130
#define VARIOUS_CAN_TAR_SHOT_WORK 131
#define VARIOUS_CHECK_POLTERGEIST 132
#define VARIOUS_SET_OCTOLOCK 133
#define VARIOUS_CUT_1_3_HP_RAISE_STATS 134
#define VARIOUS_PHOTON_GEYSER_CHECK 129
#define VARIOUS_SHELL_SIDE_ARM_CHECK 130
#define VARIOUS_TRY_NO_RETREAT 131
#define VARIOUS_TRY_TAR_SHOT 132
#define VARIOUS_CAN_TAR_SHOT_WORK 133
#define VARIOUS_CHECK_POLTERGEIST 134
#define VARIOUS_SET_OCTOLOCK 135
#define VARIOUS_CUT_1_3_HP_RAISE_STATS 136
// Cmd_manipulatedamage
#define DMG_CHANGE_SIGN 0

View File

@ -410,7 +410,7 @@
#define STRINGID_PKMNTWISTEDDIMENSIONS 406
#define STRINGID_POINTEDSTONESFLOAT 407
#define STRINGID_CLOAKEDINMYSTICALMOONLIGHT 408
#define STRINGID_TRAPPERBYSWIRLINGMAGMA 409
#define STRINGID_TRAPPEDBYSWIRLINGMAGMA 409
#define STRINGID_VANISHEDINSTANTLY 410
#define STRINGID_PROTECTEDTEAM 411
#define STRINGID_SHAREDITSGUARD 412

View File

@ -1473,7 +1473,7 @@ static s16 AI_CheckBadMove(u8 battlerAtk, u8 battlerDef, u16 move, s16 score)
else if (move == MOVE_FAKE_OUT) // filter out first impression
{
if ((AI_DATA->atkHoldEffect == HOLD_EFFECT_CHOICE_BAND || AI_DATA->atkAbility == ABILITY_GORILLA_TACTICS)
&& (CountUsablePartyMons(battlerDef) > 0 || !CanAttackerFaintTarget(battlerAtk, battlerDef, AI_THINKING_STRUCT->movesetIndex, 0)))
&& (CountUsablePartyMons(battlerDef) > 0 || !CanIndexMoveFaintTarget(battlerAtk, battlerDef, AI_THINKING_STRUCT->movesetIndex, 0)))
{
if (CountUsablePartyMons(battlerAtk) == 0)
score -= 10; // Don't lock the attacker into Fake Out if they can't switch out afterwards.
@ -1714,7 +1714,7 @@ static s16 AI_CheckBadMove(u8 battlerAtk, u8 battlerDef, u16 move, s16 score)
if (AI_DATA->defAbility == ABILITY_WONDER_GUARD && effectiveness < AI_EFFECTIVENESS_x2)
score -= 10;
else if (AI_DATA->atkAbility != ABILITY_TRUANT
&& !CanAttackerFaintTarget(battlerAtk, battlerDef, AI_THINKING_STRUCT->movesetIndex, 0))
&& !CanIndexMoveFaintTarget(battlerAtk, battlerDef, AI_THINKING_STRUCT->movesetIndex, 0))
score -= 2;
break;
case EFFECT_SPITE:
@ -2465,7 +2465,7 @@ static s16 AI_TryToFaint(u8 battlerAtk, u8 battlerDef, u16 move, s16 score)
if (gBattleMoves[move].power == 0)
return score; // can't make anything faint with no power
if (CanAttackerFaintTarget(battlerAtk, battlerDef, AI_THINKING_STRUCT->movesetIndex, 0) && gBattleMoves[move].effect != EFFECT_EXPLOSION)
if (CanIndexMoveFaintTarget(battlerAtk, battlerDef, AI_THINKING_STRUCT->movesetIndex, 0) && gBattleMoves[move].effect != EFFECT_EXPLOSION)
{
// this move can faint the target
if (GetWhoStrikesFirst(battlerAtk, battlerDef, TRUE) == 0 || GetMovePriority(battlerAtk, move) > 0)
@ -2707,7 +2707,7 @@ static s16 AI_DoubleBattle(u8 battlerAtk, u8 battlerDef, u16 move, s16 score)
&& !IS_MOVE_STATUS(move)
&& HasMoveWithSplit(battlerAtkPartner, SPLIT_PHYSICAL)
&& BattlerStatCanRise(battlerAtkPartner, atkPartnerAbility, STAT_ATK)
&& !CanAttackerFaintTarget(battlerAtk, battlerAtkPartner, AI_THINKING_STRUCT->movesetIndex, 1))
&& !CanIndexMoveFaintTarget(battlerAtk, battlerAtkPartner, AI_THINKING_STRUCT->movesetIndex, 1))
{
RETURN_SCORE_PLUS(1);
}
@ -2716,7 +2716,7 @@ static s16 AI_DoubleBattle(u8 battlerAtk, u8 battlerDef, u16 move, s16 score)
if (!IS_MOVE_STATUS(move)
&& (moveType == TYPE_DARK || moveType == TYPE_GHOST || moveType == TYPE_BUG)
&& BattlerStatCanRise(battlerAtkPartner, atkPartnerAbility, STAT_SPEED)
&& !CanAttackerFaintTarget(battlerAtk, battlerAtkPartner, AI_THINKING_STRUCT->movesetIndex, 1))
&& !CanIndexMoveFaintTarget(battlerAtk, battlerAtkPartner, AI_THINKING_STRUCT->movesetIndex, 1))
{
RETURN_SCORE_PLUS(1);
}
@ -2782,7 +2782,7 @@ static s16 AI_DoubleBattle(u8 battlerAtk, u8 battlerDef, u16 move, s16 score)
&& !IS_MOVE_STATUS(move)
&& HasMoveWithSplit(battlerAtkPartner, SPLIT_PHYSICAL)
&& BattlerStatCanRise(battlerAtkPartner, atkPartnerAbility, STAT_ATK)
&& !CanAttackerFaintTarget(battlerAtk, battlerAtkPartner, AI_THINKING_STRUCT->movesetIndex, 0))
&& !CanIndexMoveFaintTarget(battlerAtk, battlerAtkPartner, AI_THINKING_STRUCT->movesetIndex, 0))
{
RETURN_SCORE_PLUS(1);
}
@ -2971,7 +2971,7 @@ static s16 AI_CheckViability(u8 battlerAtk, u8 battlerDef, u16 move, s16 score)
case ABILITY_BEAST_BOOST:
if (GetWhoStrikesFirst(battlerAtk, battlerDef, TRUE) == 0) // attacker should go first
{
if (CanAttackerFaintTarget(battlerAtk, battlerDef, AI_THINKING_STRUCT->movesetIndex, 0))
if (CanIndexMoveFaintTarget(battlerAtk, battlerDef, AI_THINKING_STRUCT->movesetIndex, 0))
score += 8; // prioritize killing target for stat boost
}
break;
@ -3772,7 +3772,7 @@ static s16 AI_CheckViability(u8 battlerAtk, u8 battlerDef, u16 move, s16 score)
case EFFECT_FELL_STINGER:
if (gBattleMons[battlerAtk].statStages[STAT_ATK] < MAX_STAT_STAGE
&& AI_DATA->atkAbility != ABILITY_CONTRARY
&& CanAttackerFaintTarget(battlerAtk, battlerDef, AI_THINKING_STRUCT->movesetIndex, 0))
&& CanIndexMoveFaintTarget(battlerAtk, battlerDef, AI_THINKING_STRUCT->movesetIndex, 0))
{
if (GetWhoStrikesFirst(battlerAtk, battlerDef, TRUE) == 0) // Attacker goes first
score += 9;
@ -4305,7 +4305,7 @@ static s16 AI_CheckViability(u8 battlerAtk, u8 battlerDef, u16 move, s16 score)
if (!IsBattlerGrounded(battlerDef))
score += 3;
break;
case EFFECT_SLEEP_HIT: // Relic Song
case EFFECT_RELIC_SONG:
#if (defined SPECIES_MELOETTA && defined SPECIES_MELOETTA_PIROUETTE)
if (AI_DATA->atkSpecies == SPECIES_MELOETTA && gBattleMons[battlerDef].defense < gBattleMons[battlerDef].spDefense)
score += 3; // Change to pirouette if can do more damage
@ -4923,7 +4923,7 @@ static s16 AI_HPAware(u8 battlerAtk, u8 battlerDef, u16 move, s16 score)
}
// consider target HP
if (CanAttackerFaintTarget(battlerAtk, battlerDef, AI_THINKING_STRUCT->movesetIndex, 0))
if (CanIndexMoveFaintTarget(battlerAtk, battlerDef, AI_THINKING_STRUCT->movesetIndex, 0))
{
score += 2;
}

View File

@ -660,9 +660,9 @@ bool32 MovesWithSplitUnusable(u32 attacker, u32 target, u32 split)
for (i = 0; i < MAX_MON_MOVES; i++)
{
if (moves[i] != MOVE_NONE
&& moves[i] != 0xFFFF
&& GetBattleMoveSplit(moves[i]) == split
&& !(unusable & gBitTable[i]))
&& moves[i] != 0xFFFF
&& GetBattleMoveSplit(moves[i]) == split
&& !(unusable & gBitTable[i]))
{
SetTypeBeforeUsingMove(moves[i], attacker);
GET_MOVE_TYPE(moves[i], moveType);
@ -1033,7 +1033,7 @@ bool32 IsAiFaster(u8 battler)
bool32 CanTargetFaintAi(u8 battlerDef, u8 battlerAtk)
{
s32 i, dmg;
u32 unusable = CheckMoveLimitations(battlerDef, 0, 0xFF & ~MOVE_LIMITATION_PP);
u32 unusable = CheckMoveLimitations(battlerDef, 0, 0xFF);
u16 *moves = gBattleResources->battleHistory->usedMoves[battlerDef];
for (i = 0; i < MAX_MON_MOVES; i++)
@ -1048,10 +1048,36 @@ bool32 CanTargetFaintAi(u8 battlerDef, u8 battlerAtk)
return FALSE;
}
// Check if AI mon has the means to faint the target with any of its moves.
// If numHits > 1, check if the target will be KO'ed by that number of hits (ignoring healing effects)
bool32 CanAIFaintTarget(u8 battlerAtk, u8 battlerDef, u8 numHits)
{
s32 i, dmg;
u32 moveLimitations = CheckMoveLimitations(battlerAtk, 0, 0xFF);
u16 *moves = gBattleMons[battlerAtk].moves;
for (i = 0; i < MAX_MON_MOVES; i++)
{
if (moves[i] != MOVE_NONE && moves[i] != 0xFFFF && !(moveLimitations & gBitTable[i]))
{
// Use the pre-calculated value in simulatedDmg instead of re-calculating it
dmg = AI_THINKING_STRUCT->simulatedDmg[battlerAtk][battlerDef][i];
if (numHits)
dmg *= numHits;
if (gBattleMons[battlerDef].hp <= dmg)
return TRUE;
}
}
return FALSE;
}
bool32 CanMoveFaintBattler(u16 move, u8 battlerDef, u8 battlerAtk, u8 nHits)
{
s32 i, dmg;
u32 unusable = CheckMoveLimitations(battlerDef, 0, 0xFF & ~MOVE_LIMITATION_PP);
u32 unusable = CheckMoveLimitations(battlerDef, 0, 0xFF);
if (move != MOVE_NONE && move != 0xFFFF && !(unusable & gBitTable[i]) && AI_CalcDamage(move, battlerDef, battlerAtk) >= gBattleMons[battlerAtk].hp)
return TRUE;
@ -1063,7 +1089,7 @@ bool32 CanMoveFaintBattler(u16 move, u8 battlerDef, u8 battlerAtk, u8 nHits)
bool32 CanTargetFaintAiWithMod(u8 battlerDef, u8 battlerAtk, s32 hpMod, s32 dmgMod)
{
u32 i;
u32 unusable = CheckMoveLimitations(battlerDef, 0, 0xFF & ~MOVE_LIMITATION_PP);
u32 unusable = CheckMoveLimitations(battlerDef, 0, 0xFF);
u16 *moves = gBattleResources->battleHistory->usedMoves[battlerDef];
for (i = 0; i < MAX_MON_MOVES; i++)
@ -1677,7 +1703,7 @@ u32 CountNegativeStatStages(u8 battlerId)
bool32 ShouldLowerAttack(u8 battlerAtk, u8 battlerDef, u16 defAbility)
{
if (IsAiFaster(AI_CHECK_FASTER) && CanAttackerFaintTarget(battlerAtk, battlerDef, AI_THINKING_STRUCT->movesetIndex, 0))
if (IsAiFaster(AI_CHECK_FASTER) && CanAIFaintTarget(battlerAtk, battlerDef, 0))
return FALSE; // Don't bother lowering stats if can kill enemy.
if (gBattleMons[battlerDef].statStages[STAT_ATK] > 4
@ -1685,7 +1711,7 @@ bool32 ShouldLowerAttack(u8 battlerAtk, u8 battlerDef, u16 defAbility)
&& defAbility != ABILITY_CONTRARY
&& defAbility != ABILITY_CLEAR_BODY
&& defAbility != ABILITY_WHITE_SMOKE
//&& defAbility != ABILITY_FULL_METAL_BODY
&& defAbility != ABILITY_FULL_METAL_BODY
&& defAbility != ABILITY_HYPER_CUTTER)
return TRUE;
return FALSE;
@ -1693,7 +1719,7 @@ bool32 ShouldLowerAttack(u8 battlerAtk, u8 battlerDef, u16 defAbility)
bool32 ShouldLowerDefense(u8 battlerAtk, u8 battlerDef, u16 defAbility)
{
if (IsAiFaster(AI_CHECK_FASTER) && CanAttackerFaintTarget(battlerAtk, battlerDef, AI_THINKING_STRUCT->movesetIndex, 0))
if (IsAiFaster(AI_CHECK_FASTER) && CanAIFaintTarget(battlerAtk, battlerDef, 0))
return FALSE; // Don't bother lowering stats if can kill enemy.
if (gBattleMons[battlerDef].statStages[STAT_DEF] > 4
@ -1701,7 +1727,7 @@ bool32 ShouldLowerDefense(u8 battlerAtk, u8 battlerDef, u16 defAbility)
&& defAbility != ABILITY_CONTRARY
&& defAbility != ABILITY_CLEAR_BODY
&& defAbility != ABILITY_WHITE_SMOKE
//&& defAbility != ABILITY_FULL_METAL_BODY
&& defAbility != ABILITY_FULL_METAL_BODY
&& defAbility != ABILITY_BIG_PECKS)
return TRUE;
return FALSE;
@ -1709,13 +1735,13 @@ bool32 ShouldLowerDefense(u8 battlerAtk, u8 battlerDef, u16 defAbility)
bool32 ShouldLowerSpeed(u8 battlerAtk, u8 battlerDef, u16 defAbility)
{
if (IsAiFaster(AI_CHECK_FASTER) && CanAttackerFaintTarget(battlerAtk, battlerDef, AI_THINKING_STRUCT->movesetIndex, 0))
if (IsAiFaster(AI_CHECK_FASTER) && CanAIFaintTarget(battlerAtk, battlerDef, 0))
return FALSE; // Don't bother lowering stats if can kill enemy.
if (IsAiFaster(AI_CHECK_SLOWER)
&& defAbility != ABILITY_CONTRARY
&& defAbility != ABILITY_CLEAR_BODY
//&& defAbility != ABILITY_FULL_METAL_BODY
&& defAbility != ABILITY_FULL_METAL_BODY
&& defAbility != ABILITY_WHITE_SMOKE)
return TRUE;
return FALSE;
@ -1723,14 +1749,14 @@ bool32 ShouldLowerSpeed(u8 battlerAtk, u8 battlerDef, u16 defAbility)
bool32 ShouldLowerSpAtk(u8 battlerAtk, u8 battlerDef, u16 defAbility)
{
if (IsAiFaster(AI_CHECK_FASTER) && CanAttackerFaintTarget(battlerAtk, battlerDef, AI_THINKING_STRUCT->movesetIndex, 0))
if (IsAiFaster(AI_CHECK_FASTER) && CanAIFaintTarget(battlerAtk, battlerDef, 0))
return FALSE; // Don't bother lowering stats if can kill enemy.
if (gBattleMons[battlerDef].statStages[STAT_SPATK] > 4
&& HasMoveWithSplit(battlerDef, SPLIT_SPECIAL)
&& defAbility != ABILITY_CONTRARY
&& defAbility != ABILITY_CLEAR_BODY
//&& defAbility != ABILITY_FULL_METAL_BODY
&& defAbility != ABILITY_FULL_METAL_BODY
&& defAbility != ABILITY_WHITE_SMOKE)
return TRUE;
return FALSE;
@ -1738,14 +1764,14 @@ bool32 ShouldLowerSpAtk(u8 battlerAtk, u8 battlerDef, u16 defAbility)
bool32 ShouldLowerSpDef(u8 battlerAtk, u8 battlerDef, u16 defAbility)
{
if (IsAiFaster(AI_CHECK_FASTER) && CanAttackerFaintTarget(battlerAtk, battlerDef, AI_THINKING_STRUCT->movesetIndex, 0))
if (IsAiFaster(AI_CHECK_FASTER) && CanAIFaintTarget(battlerAtk, battlerDef, 0))
return FALSE; // Don't bother lowering stats if can kill enemy.
if (gBattleMons[battlerDef].statStages[STAT_SPDEF] > 4
&& HasMoveWithSplit(battlerAtk, SPLIT_SPECIAL)
&& defAbility != ABILITY_CONTRARY
&& defAbility != ABILITY_CLEAR_BODY
//&& defAbility != ABILITY_FULL_METAL_BODY
&& defAbility != ABILITY_FULL_METAL_BODY
&& defAbility != ABILITY_WHITE_SMOKE)
return TRUE;
return FALSE;
@ -1753,13 +1779,13 @@ bool32 ShouldLowerSpDef(u8 battlerAtk, u8 battlerDef, u16 defAbility)
bool32 ShouldLowerAccuracy(u8 battlerAtk, u8 battlerDef, u16 defAbility)
{
if (IsAiFaster(AI_CHECK_FASTER) && CanAttackerFaintTarget(battlerAtk, battlerDef, AI_THINKING_STRUCT->movesetIndex, 0))
if (IsAiFaster(AI_CHECK_FASTER) && CanAIFaintTarget(battlerAtk, battlerDef, 0))
return FALSE; // Don't bother lowering stats if can kill enemy.
if (defAbility != ABILITY_CONTRARY
&& defAbility != ABILITY_CLEAR_BODY
&& defAbility != ABILITY_WHITE_SMOKE
//&& defAbility != ABILITY_FULL_METAL_BODY
&& defAbility != ABILITY_FULL_METAL_BODY
&& defAbility != ABILITY_KEEN_EYE)
return TRUE;
return FALSE;
@ -1767,19 +1793,19 @@ bool32 ShouldLowerAccuracy(u8 battlerAtk, u8 battlerDef, u16 defAbility)
bool32 ShouldLowerEvasion(u8 battlerAtk, u8 battlerDef, u16 defAbility)
{
if (IsAiFaster(AI_CHECK_FASTER) && CanAttackerFaintTarget(battlerAtk, battlerDef, AI_THINKING_STRUCT->movesetIndex, 0))
if (IsAiFaster(AI_CHECK_FASTER) && CanAIFaintTarget(battlerAtk, battlerDef, 0))
return FALSE; // Don't bother lowering stats if can kill enemy.
if (gBattleMons[battlerDef].statStages[STAT_EVASION] > DEFAULT_STAT_STAGE
&& defAbility != ABILITY_CONTRARY
&& defAbility != ABILITY_CLEAR_BODY
//&& defAbility != ABILITY_FULL_METAL_BODY
&& defAbility != ABILITY_FULL_METAL_BODY
&& defAbility != ABILITY_WHITE_SMOKE)
return TRUE;
return FALSE;
}
bool32 CanAttackerFaintTarget(u8 battlerAtk, u8 battlerDef, u8 index, u8 numHits)
bool32 CanIndexMoveFaintTarget(u8 battlerAtk, u8 battlerDef, u8 index, u8 numHits)
{
s32 dmg = AI_THINKING_STRUCT->simulatedDmg[battlerAtk][battlerDef][index];
@ -2433,9 +2459,9 @@ bool32 ShouldPivot(u8 battlerAtk, u8 battlerDef, u16 defAbility, u16 move, u8 mo
if (GetWhoStrikesFirst(battlerAtk, battlerDef, TRUE) == 0) // Attacker goes first
{
if (!CanAttackerFaintTarget(battlerAtk, battlerDef, moveIndex, 0)) // Can't KO foe otherwise
if (!CanAIFaintTarget(battlerAtk, battlerDef, 0)) // Can't KO foe otherwise
{
if (CanAttackerFaintTarget(battlerAtk, battlerDef, moveIndex, 2))
if (CanAIFaintTarget(battlerAtk, battlerDef, 2))
{
// attacker can kill target in two hits (theoretically)
if (CanTargetFaintAi(battlerDef, battlerAtk))
@ -2500,7 +2526,7 @@ bool32 ShouldPivot(u8 battlerAtk, u8 battlerDef, u16 defAbility, u16 move, u8 mo
}
else if (CanTargetFaintAiWithMod(battlerDef, battlerAtk, 0, 2)) // Foe can 2HKO AI
{
if (CanAttackerFaintTarget(battlerAtk, battlerDef, moveIndex, 0))
if (CanAIFaintTarget(battlerAtk, battlerDef, 0))
{
if (!BattlerWillFaintFromSecondaryDamage(battlerAtk, AI_DATA->atkAbility))
return CAN_TRY_PIVOT; // Use this move to KO if you must
@ -2512,7 +2538,7 @@ bool32 ShouldPivot(u8 battlerAtk, u8 battlerDef, u16 defAbility, u16 move, u8 mo
}
else // Foe can 3HKO+ AI
{
if (CanAttackerFaintTarget(battlerAtk, battlerDef, moveIndex, 0))
if (CanAIFaintTarget(battlerAtk, battlerDef, 0))
{
if (!BattlerWillFaintFromSecondaryDamage(battlerAtk, AI_DATA->atkAbility) // This is the only move that can KO
&& !hasStatBoost) //You're not wasting a valuable stat boost
@ -2520,7 +2546,7 @@ bool32 ShouldPivot(u8 battlerAtk, u8 battlerDef, u16 defAbility, u16 move, u8 mo
return CAN_TRY_PIVOT;
}
}
else if (CanAttackerFaintTarget(battlerAtk, battlerDef, moveIndex, 2))
else if (CanAIFaintTarget(battlerAtk, battlerDef, 2))
{
// can knock out foe in 2 hits
if (IS_MOVE_STATUS(move) && (shouldSwitch //Damaging move
@ -2904,7 +2930,7 @@ bool32 ShouldUseRecoilMove(u8 battlerAtk, u8 battlerDef, u32 recoilDmg, u8 moveI
if (recoilDmg >= gBattleMons[battlerAtk].hp //Recoil kills attacker
&& CountUsablePartyMons(battlerDef) != 0) //Foe has more than 1 target left
{
if (recoilDmg >= gBattleMons[battlerDef].hp && !CanAttackerFaintTarget(battlerAtk, battlerDef, moveIndex, 0))
if (recoilDmg >= gBattleMons[battlerDef].hp && !CanAIFaintTarget(battlerAtk, battlerDef, 0))
return TRUE; //If it's the only KO move then just use it
else
return FALSE; //Not as good to use move if you'll faint and not win

View File

@ -5064,3 +5064,34 @@ void AnimTask_PrimalReversion(u8 taskId)
gBattleAnimArgs[0] = 0;
DestroyAnimVisualTask(taskId);
}
void AnimTask_ShellSideArm(u8 taskId)
{
if (gSwapDamageCategory)
gBattleAnimArgs[0] = TRUE;
else
gBattleAnimArgs[0] = FALSE;
DestroyAnimVisualTask(taskId);
}
void AnimTask_TerrainPulse(u8 taskId)
{
if (IsBattlerTerrainAffected(gBattleAnimAttacker, STATUS_FIELD_TERRAIN_ANY))
{
if (gFieldStatuses & STATUS_FIELD_ELECTRIC_TERRAIN)
gBattleAnimArgs[0] = TYPE_ELECTRIC;
else if (gFieldStatuses & STATUS_FIELD_GRASSY_TERRAIN)
gBattleAnimArgs[0] = TYPE_GRASS;
else if (gFieldStatuses & STATUS_FIELD_MISTY_TERRAIN)
gBattleAnimArgs[0] = TYPE_FAIRY;
else if (gFieldStatuses & STATUS_FIELD_PSYCHIC_TERRAIN)
gBattleAnimArgs[0] = TYPE_PSYCHIC;
else //failsafe
gBattleAnimArgs[0] = 0;
}
else
{
gBattleAnimArgs[0] = 0;
}
DestroyAnimVisualTask(taskId);
}

View File

@ -2496,6 +2496,8 @@ void AnimTask_GetTrappedMoveAnimId(u8 taskId)
gBattleAnimArgs[0] = TRAP_ANIM_CLAMP;
else if (gBattleSpritesDataPtr->animationData->animArg == MOVE_SAND_TOMB)
gBattleAnimArgs[0] = TRAP_ANIM_SAND_TOMB;
else if (gBattleSpritesDataPtr->animationData->animArg == MOVE_MAGMA_STORM)
gBattleAnimArgs[0] = TRAP_ANIM_MAGMA_STORM;
else if (gBattleSpritesDataPtr->animationData->animArg == MOVE_INFESTATION)
gBattleAnimArgs[0] = TRAP_ANIM_INFESTATION;
else

View File

@ -136,6 +136,7 @@ void AnimTask_SetCamouflageBlend(u8 taskId)
gBattleAnimArgs[4] = RGB(31, 31, 31);
break;
case BATTLE_TERRAIN_PLAIN:
default:
gBattleAnimArgs[4] = RGB(31, 31, 31);
break;
}
@ -904,6 +905,12 @@ void AnimTask_GetBattleTerrain(u8 taskId)
DestroyAnimVisualTask(taskId);
}
void AnimTask_GetFieldTerrain(u8 taskId)
{
gBattleAnimArgs[0] = gFieldStatuses & STATUS_FIELD_TERRAIN_ANY;
DestroyAnimVisualTask(taskId);
}
void AnimTask_AllocBackupPalBuffer(u8 taskId)
{
gMonSpritesGfxPtr->buffer = AllocZeroed(0x2000);

View File

@ -232,6 +232,7 @@ EWRAM_DATA struct TotemBoost gTotemBoosts[MAX_BATTLERS_COUNT] = {0};
EWRAM_DATA bool8 gHasFetchedBall = FALSE;
EWRAM_DATA u8 gLastUsedBall = 0;
EWRAM_DATA u16 gLastThrownBall = 0;
EWRAM_DATA bool8 gSwapDamageCategory = FALSE; // Photon Geyser, Shell Side Arm, Light That Burns the Sky
// IWRAM common vars
void (*gPreBattleCallback1)(void);
@ -2941,6 +2942,8 @@ static void BattleStartClearSetData(void)
gBattleStruct->usedHeldItems[i][1] = 0;
gBattleStruct->itemStolen[i].originalItem = GetMonData(&gPlayerParty[i], MON_DATA_HELD_ITEM);
}
gSwapDamageCategory = FALSE; // Photon Geyser, Shell Side Arm, Light That Burns the Sky
}
void SwitchInClearSetData(void)
@ -5189,6 +5192,22 @@ void SetTypeBeforeUsingMove(u16 move, u8 battlerAtk)
if (ItemId_GetPocket(gBattleMons[battlerAtk].item) == POCKET_BERRIES)
gBattleStruct->dynamicMoveType = gNaturalGiftTable[ITEM_TO_BERRY(gBattleMons[battlerAtk].item)].type;
}
else if (gBattleMoves[move].effect == EFFECT_TERRAIN_PULSE)
{
if (IsBattlerTerrainAffected(battlerAtk, STATUS_FIELD_TERRAIN_ANY))
{
if (gFieldStatuses & STATUS_FIELD_ELECTRIC_TERRAIN)
gBattleStruct->dynamicMoveType = TYPE_ELECTRIC | 0x80;
else if (gFieldStatuses & STATUS_FIELD_GRASSY_TERRAIN)
gBattleStruct->dynamicMoveType = TYPE_GRASS | 0x80;
else if (gFieldStatuses & STATUS_FIELD_MISTY_TERRAIN)
gBattleStruct->dynamicMoveType = TYPE_FAIRY | 0x80;
else if (gFieldStatuses & STATUS_FIELD_PSYCHIC_TERRAIN)
gBattleStruct->dynamicMoveType = TYPE_PSYCHIC | 0x80;
else //failsafe
gBattleStruct->dynamicMoveType = TYPE_NORMAL | 0x80;
}
}
attackerAbility = GetBattlerAbility(battlerAtk);
GET_MOVE_TYPE(move, moveType);

View File

@ -1205,7 +1205,7 @@ const u8 *const gBattleStringsTable[BATTLESTRINGS_COUNT] =
[STRINGID_PKMNTWISTEDDIMENSIONS - 12] = sText_PkmnTwistedDimensions,
[STRINGID_POINTEDSTONESFLOAT - 12] = sText_PointedStonesFloat,
[STRINGID_CLOAKEDINMYSTICALMOONLIGHT - 12] = sText_CloakedInMysticalMoonlight,
[STRINGID_TRAPPERBYSWIRLINGMAGMA - 12] = sText_TrappedBySwirlingMagma,
[STRINGID_TRAPPEDBYSWIRLINGMAGMA - 12] = sText_TrappedBySwirlingMagma,
[STRINGID_VANISHEDINSTANTLY - 12] = sText_VanishedInstantly,
[STRINGID_PROTECTEDTEAM - 12] = sText_ProtectedTeam,
[STRINGID_SHAREDITSGUARD - 12] = sText_SharedItsGuard,
@ -1545,16 +1545,17 @@ const u16 gFirstTurnOfTwoStringIds[] =
[B_MSG_TURN1_FREEZE_SHOCK] = STRINGID_CLOAKEDINAFREEZINGLIGHT,
};
// Index copied from move's index in gTrappingMoves
// Index copied from move's index in sTrappingMoves
const u16 gWrappedStringIds[] =
{
STRINGID_PKMNSQUEEZEDBYBIND, // MOVE_BIND
STRINGID_PKMNWRAPPEDBY, // MOVE_WRAP
STRINGID_PKMNTRAPPEDINVORTEX, // MOVE_FIRE_SPIN
STRINGID_PKMNCLAMPED, // MOVE_CLAMP
STRINGID_PKMNTRAPPEDINVORTEX, // MOVE_WHIRLPOOL
STRINGID_PKMNTRAPPEDBYSANDTOMB,// MOVE_SAND_TOMB
STRINGID_INFESTATION, // MOVE_INFESTATION
STRINGID_PKMNSQUEEZEDBYBIND, // MOVE_BIND
STRINGID_PKMNWRAPPEDBY, // MOVE_WRAP
STRINGID_PKMNTRAPPEDINVORTEX, // MOVE_FIRE_SPIN
STRINGID_PKMNCLAMPED, // MOVE_CLAMP
STRINGID_PKMNTRAPPEDINVORTEX, // MOVE_WHIRLPOOL
STRINGID_PKMNTRAPPEDBYSANDTOMB, // MOVE_SAND_TOMB
STRINGID_TRAPPEDBYSWIRLINGMAGMA, // MOVE_MAGMA_STORM
STRINGID_INFESTATION, // MOVE_INFESTATION
};
const u16 gMistUsedStringIds[] =
@ -1765,11 +1766,6 @@ const u16 gCaughtMonStringIds[] =
[B_MSG_LANETTES_BOX_FULL] = STRINGID_PKMNBOXLANETTESPCFULL,
};
const u16 gTrappingMoves[] =
{
MOVE_BIND, MOVE_WRAP, MOVE_FIRE_SPIN, MOVE_CLAMP, MOVE_WHIRLPOOL, MOVE_SAND_TOMB, MOVE_INFESTATION, 0xFFFF
};
const u16 gRoomsStringIds[] =
{
STRINGID_PKMNTWISTEDDIMENSIONS, STRINGID_TRICKROOMENDS,

View File

@ -279,6 +279,11 @@ static const s32 sExperienceScalingFactors[] =
159767,
};
static const u16 sTrappingMoves[] =
{
MOVE_BIND, MOVE_WRAP, MOVE_FIRE_SPIN, MOVE_CLAMP, MOVE_WHIRLPOOL, MOVE_SAND_TOMB, MOVE_MAGMA_STORM, MOVE_INFESTATION, 0xFFFF
};
#define STAT_CHANGE_WORKED 0
#define STAT_CHANGE_DIDNT_WORK 1
@ -1092,18 +1097,76 @@ static const u16 sMoveEffectsForbiddenToInstruct[] =
FORBIDDEN_INSTRUCT_END
};
static const u16 sNaturePowerMoves[] =
static const u16 sNaturePowerMoves[BATTLE_TERRAIN_COUNT] =
{
#if B_NATURE_POWER_MOVES >= GEN_7
[BATTLE_TERRAIN_GRASS] = MOVE_ENERGY_BALL,
[BATTLE_TERRAIN_LONG_GRASS] = MOVE_ENERGY_BALL,
[BATTLE_TERRAIN_SAND] = MOVE_EARTH_POWER,
[BATTLE_TERRAIN_UNDERWATER] = MOVE_HYDRO_PUMP,
[BATTLE_TERRAIN_WATER] = MOVE_HYDRO_PUMP,
[BATTLE_TERRAIN_POND] = MOVE_HYDRO_PUMP,
[BATTLE_TERRAIN_MOUNTAIN] = MOVE_EARTH_POWER,
[BATTLE_TERRAIN_CAVE] = MOVE_POWER_GEM,
[BATTLE_TERRAIN_CAVE] = MOVE_EARTH_POWER,
[BATTLE_TERRAIN_BUILDING] = MOVE_TRI_ATTACK,
[BATTLE_TERRAIN_PLAIN] = MOVE_TRI_ATTACK
[BATTLE_TERRAIN_PLAIN] = MOVE_TRI_ATTACK,
[BATTLE_TERRAIN_SNOW] = MOVE_ICE_BEAM,
#elif B_NATURE_POWER_MOVES == GEN_6
[BATTLE_TERRAIN_GRASS] = MOVE_ENERGY_BALL,
[BATTLE_TERRAIN_LONG_GRASS] = MOVE_ENERGY_BALL,
[BATTLE_TERRAIN_SAND] = MOVE_EARTH_POWER,
[BATTLE_TERRAIN_WATER] = MOVE_HYDRO_PUMP,
[BATTLE_TERRAIN_POND] = MOVE_HYDRO_PUMP,
[BATTLE_TERRAIN_MOUNTAIN] = MOVE_EARTH_POWER,
[BATTLE_TERRAIN_CAVE] = MOVE_EARTH_POWER,
[BATTLE_TERRAIN_BUILDING] = MOVE_TRI_ATTACK,
[BATTLE_TERRAIN_PLAIN] = MOVE_TRI_ATTACK,
[BATTLE_TERRAIN_SNOW] = MOVE_FROST_BREATH,
#elif B_NATURE_POWER_MOVES == GEN_5
[BATTLE_TERRAIN_GRASS] = MOVE_SEED_BOMB,
[BATTLE_TERRAIN_LONG_GRASS] = MOVE_SEED_BOMB,
[BATTLE_TERRAIN_SAND] = MOVE_EARTHQUAKE,
[BATTLE_TERRAIN_WATER] = MOVE_HYDRO_PUMP,
[BATTLE_TERRAIN_POND] = MOVE_HYDRO_PUMP,
[BATTLE_TERRAIN_MOUNTAIN] = MOVE_EARTHQUAKE,
[BATTLE_TERRAIN_CAVE] = MOVE_EARTHQUAKE,
[BATTLE_TERRAIN_BUILDING] = MOVE_TRI_ATTACK,
[BATTLE_TERRAIN_PLAIN] = MOVE_EARTHQUAKE,
[BATTLE_TERRAIN_SNOW] = MOVE_BLIZZARD,
#elif B_NATURE_POWER_MOVES == GEN_4
[BATTLE_TERRAIN_GRASS] = MOVE_SEED_BOMB,
[BATTLE_TERRAIN_LONG_GRASS] = MOVE_SEED_BOMB,
[BATTLE_TERRAIN_SAND] = MOVE_EARTHQUAKE,
[BATTLE_TERRAIN_WATER] = MOVE_HYDRO_PUMP,
[BATTLE_TERRAIN_POND] = MOVE_HYDRO_PUMP,
[BATTLE_TERRAIN_MOUNTAIN] = MOVE_ROCK_SLIDE,
[BATTLE_TERRAIN_CAVE] = MOVE_ROCK_SLIDE,
[BATTLE_TERRAIN_BUILDING] = MOVE_TRI_ATTACK,
[BATTLE_TERRAIN_PLAIN] = MOVE_EARTHQUAKE,
[BATTLE_TERRAIN_SNOW] = MOVE_BLIZZARD,
#else // Gen 1-3
[BATTLE_TERRAIN_GRASS] = MOVE_STUN_SPORE,
[BATTLE_TERRAIN_LONG_GRASS] = MOVE_RAZOR_LEAF,
[BATTLE_TERRAIN_SAND] = MOVE_EARTHQUAKE,
[BATTLE_TERRAIN_WATER] = MOVE_SURF,
[BATTLE_TERRAIN_POND] = MOVE_BUBBLE_BEAM,
[BATTLE_TERRAIN_MOUNTAIN] = MOVE_ROCK_SLIDE,
[BATTLE_TERRAIN_CAVE] = MOVE_SHADOW_BALL,
[BATTLE_TERRAIN_BUILDING] = MOVE_SWIFT,
[BATTLE_TERRAIN_PLAIN] = MOVE_SWIFT,
[BATTLE_TERRAIN_SNOW] = MOVE_BLIZZARD,
#endif
[BATTLE_TERRAIN_UNDERWATER] = MOVE_HYDRO_PUMP,
[BATTLE_TERRAIN_SOARING] = MOVE_AIR_SLASH,
[BATTLE_TERRAIN_SKY_PILLAR] = MOVE_AIR_SLASH,
[BATTLE_TERRAIN_BURIAL_GROUND] = MOVE_SHADOW_BALL,
[BATTLE_TERRAIN_PUDDLE] = MOVE_MUD_BOMB,
[BATTLE_TERRAIN_MARSH] = MOVE_MUD_BOMB,
[BATTLE_TERRAIN_SWAMP] = MOVE_MUD_BOMB,
[BATTLE_TERRAIN_ICE] = MOVE_ICE_BEAM,
[BATTLE_TERRAIN_VOLCANO] = MOVE_LAVA_PLUME,
[BATTLE_TERRAIN_DISTORTION_WORLD] = MOVE_TRI_ATTACK,
[BATTLE_TERRAIN_SPACE] = MOVE_DRACO_METEOR,
[BATTLE_TERRAIN_ULTRA_SPACE] = MOVE_PSYSHOCK,
};
static const u16 sPickupItems[] =
@ -1148,18 +1211,38 @@ static const u8 sPickupProbabilities[] =
30, 40, 50, 60, 70, 80, 90, 94, 98
};
static const u8 sTerrainToType[] =
static const u8 sTerrainToType[BATTLE_TERRAIN_COUNT] =
{
[BATTLE_TERRAIN_GRASS] = TYPE_GRASS,
[BATTLE_TERRAIN_LONG_GRASS] = TYPE_GRASS,
[BATTLE_TERRAIN_SAND] = TYPE_GROUND,
[BATTLE_TERRAIN_UNDERWATER] = TYPE_WATER,
[BATTLE_TERRAIN_WATER] = TYPE_WATER,
[BATTLE_TERRAIN_POND] = TYPE_WATER,
[BATTLE_TERRAIN_MOUNTAIN] = TYPE_GROUND,
[BATTLE_TERRAIN_CAVE] = TYPE_ROCK,
[BATTLE_TERRAIN_BUILDING] = TYPE_NORMAL,
[BATTLE_TERRAIN_PLAIN] = TYPE_NORMAL,
[BATTLE_TERRAIN_GRASS] = TYPE_GRASS,
[BATTLE_TERRAIN_LONG_GRASS] = TYPE_GRASS,
[BATTLE_TERRAIN_SAND] = TYPE_GROUND,
[BATTLE_TERRAIN_UNDERWATER] = TYPE_WATER,
[BATTLE_TERRAIN_WATER] = TYPE_WATER,
[BATTLE_TERRAIN_POND] = TYPE_WATER,
[BATTLE_TERRAIN_CAVE] = TYPE_ROCK,
[BATTLE_TERRAIN_BUILDING] = TYPE_NORMAL,
[BATTLE_TERRAIN_SOARING] = TYPE_FLYING,
[BATTLE_TERRAIN_SKY_PILLAR] = TYPE_FLYING,
[BATTLE_TERRAIN_BURIAL_GROUND] = TYPE_GHOST,
[BATTLE_TERRAIN_PUDDLE] = TYPE_GROUND,
[BATTLE_TERRAIN_MARSH] = TYPE_GROUND,
[BATTLE_TERRAIN_SWAMP] = TYPE_GROUND,
[BATTLE_TERRAIN_SNOW] = TYPE_ICE,
[BATTLE_TERRAIN_ICE] = TYPE_ICE,
[BATTLE_TERRAIN_VOLCANO] = TYPE_FIRE,
[BATTLE_TERRAIN_DISTORTION_WORLD] = TYPE_NORMAL,
[BATTLE_TERRAIN_SPACE] = TYPE_DRAGON,
[BATTLE_TERRAIN_ULTRA_SPACE] = TYPE_PSYCHIC,
#if B_CAMOUFLAGE_TYPES >= GEN_5
[BATTLE_TERRAIN_MOUNTAIN] = TYPE_GROUND,
[BATTLE_TERRAIN_PLAIN] = TYPE_GROUND,
#elif B_CAMOUFLAGE_TYPES == GEN_4
[BATTLE_TERRAIN_MOUNTAIN] = TYPE_ROCK,
[BATTLE_TERRAIN_PLAIN] = TYPE_GROUND,
#else
[BATTLE_TERRAIN_MOUNTAIN] = TYPE_ROCK,
[BATTLE_TERRAIN_PLAIN] = TYPE_NORMAL,
#endif
};
// - ITEM_ULTRA_BALL skips Master Ball and ITEM_NONE
@ -1499,7 +1582,7 @@ static void Cmd_attackcanceler(void)
&& ((!IsTwoTurnsMove(gCurrentMove) || (gBattleMons[gBattlerAttacker].status2 & STATUS2_MULTIPLETURNS)))
&& gBattleMoves[gCurrentMove].effect != EFFECT_SUCKER_PUNCH)
{
if (gBattleMoves[gCurrentMove].flags & FLAG_MAKES_CONTACT)
if (IsMoveMakingContact(gCurrentMove, gBattlerAttacker))
gProtectStructs[gBattlerAttacker].touchedProtectLike = TRUE;
CancelMultiTurnMoves(gBattlerAttacker);
gMoveResultFlags |= MOVE_RESULT_MISSED;
@ -2978,9 +3061,9 @@ void SetMoveEffect(bool32 primary, u32 certain)
for (gBattleCommunication[MULTISTRING_CHOOSER] = 0; ; gBattleCommunication[MULTISTRING_CHOOSER]++)
{
if (gBattleCommunication[MULTISTRING_CHOOSER] > 5)
if (gBattleCommunication[MULTISTRING_CHOOSER] > ARRAY_COUNT(sTrappingMoves) - 1)
break;
if (gTrappingMoves[gBattleCommunication[MULTISTRING_CHOOSER]] == gCurrentMove)
if (sTrappingMoves[gBattleCommunication[MULTISTRING_CHOOSER]] == gCurrentMove)
break;
}
}
@ -2992,7 +3075,8 @@ void SetMoveEffect(bool32 primary, u32 certain)
case MOVE_EFFECT_SP_DEF_PLUS_1:
case MOVE_EFFECT_ACC_PLUS_1:
case MOVE_EFFECT_EVS_PLUS_1:
if (ChangeStatBuffs(SET_STAT_BUFF_VALUE(1),
if (NoAliveMonsForEitherParty()
|| ChangeStatBuffs(SET_STAT_BUFF_VALUE(1),
gBattleScripting.moveEffect - MOVE_EFFECT_ATK_PLUS_1 + 1,
affectsUser, 0))
{
@ -3039,7 +3123,8 @@ void SetMoveEffect(bool32 primary, u32 certain)
case MOVE_EFFECT_SP_DEF_PLUS_2:
case MOVE_EFFECT_ACC_PLUS_2:
case MOVE_EFFECT_EVS_PLUS_2:
if (ChangeStatBuffs(SET_STAT_BUFF_VALUE(2),
if (NoAliveMonsForEitherParty()
|| ChangeStatBuffs(SET_STAT_BUFF_VALUE(2),
gBattleScripting.moveEffect - MOVE_EFFECT_ATK_PLUS_2 + 1,
affectsUser, 0))
{
@ -3153,8 +3238,15 @@ void SetMoveEffect(bool32 primary, u32 certain)
gBattlescriptCurrInstr++;
break;
case MOVE_EFFECT_ALL_STATS_UP:
BattleScriptPush(gBattlescriptCurrInstr + 1);
gBattlescriptCurrInstr = BattleScript_AllStatsUp;
if (NoAliveMonsForEitherParty())
{
gBattlescriptCurrInstr++;
}
else
{
BattleScriptPush(gBattlescriptCurrInstr + 1);
gBattlescriptCurrInstr = BattleScript_AllStatsUp;
}
break;
case MOVE_EFFECT_RAPIDSPIN:
BattleScriptPush(gBattlescriptCurrInstr + 1);
@ -3400,6 +3492,21 @@ void SetMoveEffect(bool32 primary, u32 certain)
gBattlescriptCurrInstr = BattleScript_MoveEffectBugBite;
}
break;
case MOVE_EFFECT_RELIC_SONG:
if (GetBattlerAbility(gBattlerAttacker) != ABILITY_SHEER_FORCE)
{
if (gBattleMons[gBattlerAttacker].species == SPECIES_MELOETTA)
{
gBattleMons[gBattlerAttacker].species = SPECIES_MELOETTA_PIROUETTE;
BattleScriptPushCursorAndCallback(BattleScript_AttackerFormChangeMoveEffect);
}
else if (gBattleMons[gBattlerAttacker].species == SPECIES_MELOETTA_PIROUETTE)
{
gBattleMons[gBattlerAttacker].species = SPECIES_MELOETTA;
BattleScriptPushCursorAndCallback(BattleScript_AttackerFormChangeMoveEffect);
}
}
break;
case MOVE_EFFECT_TRAP_BOTH:
if (!(gBattleMons[gBattlerTarget].status2 & STATUS2_ESCAPE_PREVENTION) && !(gBattleMons[gBattlerAttacker].status2 & STATUS2_ESCAPE_PREVENTION))
{
@ -7245,19 +7352,19 @@ static void HandleTerrainMove(u32 moveEffect)
switch (moveEffect)
{
case EFFECT_MISTY_TERRAIN:
statusFlag = STATUS_FIELD_MISTY_TERRAIN, timer = &gFieldTimers.mistyTerrainTimer;
statusFlag = STATUS_FIELD_MISTY_TERRAIN, timer = &gFieldTimers.terrainTimer;
gBattleCommunication[MULTISTRING_CHOOSER] = 0;
break;
case EFFECT_GRASSY_TERRAIN:
statusFlag = STATUS_FIELD_GRASSY_TERRAIN, timer = &gFieldTimers.grassyTerrainTimer;
statusFlag = STATUS_FIELD_GRASSY_TERRAIN, timer = &gFieldTimers.terrainTimer;
gBattleCommunication[MULTISTRING_CHOOSER] = 1;
break;
case EFFECT_ELECTRIC_TERRAIN:
statusFlag = STATUS_FIELD_ELECTRIC_TERRAIN, timer = &gFieldTimers.electricTerrainTimer;
statusFlag = STATUS_FIELD_ELECTRIC_TERRAIN, timer = &gFieldTimers.terrainTimer;
gBattleCommunication[MULTISTRING_CHOOSER] = 2;
break;
case EFFECT_PSYCHIC_TERRAIN:
statusFlag = STATUS_FIELD_PSYCHIC_TERRAIN, timer = &gFieldTimers.psychicTerrainTimer;
statusFlag = STATUS_FIELD_PSYCHIC_TERRAIN, timer = &gFieldTimers.terrainTimer;
gBattleCommunication[MULTISTRING_CHOOSER] = 3;
break;
}
@ -8305,6 +8412,9 @@ static void Cmd_various(void)
case VARIOUS_ARGUMENT_STATUS_EFFECT:
switch (gBattleMoves[gCurrentMove].argument)
{
case STATUS1_SLEEP:
gBattleScripting.moveEffect = MOVE_EFFECT_SLEEP;
break;
case STATUS1_BURN:
gBattleScripting.moveEffect = MOVE_EFFECT_BURN;
break;
@ -8852,23 +8962,20 @@ static void Cmd_various(void)
else
gBattlescriptCurrInstr += 7; // can heal
return;
case VARIOUS_REMOVE_TERRAIN:
case VARIOUS_REMOVE_TERRAIN:
gFieldTimers.terrainTimer = 0;
switch (gFieldStatuses & STATUS_FIELD_TERRAIN_ANY)
{
case STATUS_FIELD_MISTY_TERRAIN:
gFieldTimers.mistyTerrainTimer = 0;
gBattleCommunication[MULTISTRING_CHOOSER] = 0;
break;
case STATUS_FIELD_GRASSY_TERRAIN:
gFieldTimers.grassyTerrainTimer = 0;
gBattleCommunication[MULTISTRING_CHOOSER] = 1;
break;
case STATUS_FIELD_ELECTRIC_TERRAIN:
gFieldTimers.electricTerrainTimer = 0;
gBattleCommunication[MULTISTRING_CHOOSER] = 2;
break;
case STATUS_FIELD_PSYCHIC_TERRAIN:
gFieldTimers.psychicTerrainTimer = 0;
gBattleCommunication[MULTISTRING_CHOOSER] = 3;
break;
default:
@ -9017,6 +9124,61 @@ static void Cmd_various(void)
else
gBattlescriptCurrInstr += 9;
return;
case VARIOUS_PHOTON_GEYSER_CHECK:
{
u32 attackerAtkStat = gBattleMons[gBattlerAttacker].attack;
u8 attackerAtkStage = gBattleMons[gBattlerAttacker].statStages[STAT_ATK];
u32 attackerSpAtkStat = gBattleMons[gBattlerAttacker].spAttack;
gSwapDamageCategory = FALSE;
attackerAtkStat *= gStatStageRatios[attackerAtkStage][0];
attackerAtkStat /= gStatStageRatios[attackerAtkStage][1];
attackerAtkStage = gBattleMons[gBattlerAttacker].statStages[STAT_SPATK];
attackerSpAtkStat *= gStatStageRatios[attackerAtkStage][0];
attackerSpAtkStat /= gStatStageRatios[attackerAtkStage][1];
if (attackerAtkStat > attackerSpAtkStat)
gSwapDamageCategory = TRUE;
break;
}
case VARIOUS_SHELL_SIDE_ARM_CHECK: // 0% chance GameFreak actually checks this way according to DaWobblefet, but this is the only functional explanation at the moment
{
u32 attackerAtkStat = gBattleMons[gBattlerAttacker].attack;
u32 targetDefStat = gBattleMons[gBattlerTarget].defense;
u32 attackerSpAtkStat = gBattleMons[gBattlerAttacker].spAttack;
u32 targetSpDefStat = gBattleMons[gBattlerTarget].spDefense;
u8 statStage;
u32 physical;
u32 special;
gSwapDamageCategory = FALSE;
statStage = gBattleMons[gBattlerAttacker].statStages[STAT_ATK];
attackerAtkStat *= gStatStageRatios[statStage][0];
attackerAtkStat /= gStatStageRatios[statStage][1];
statStage = gBattleMons[gBattlerTarget].statStages[STAT_DEF];
targetDefStat *= gStatStageRatios[statStage][0];
targetDefStat /= gStatStageRatios[statStage][1];
physical = ((((2 * gBattleMons[gBattlerAttacker].level / 5 + 2) * gBattleMoves[gCurrentMove].power * attackerAtkStat) / targetDefStat) / 50);
statStage = gBattleMons[gBattlerAttacker].statStages[STAT_SPATK];
attackerSpAtkStat *= gStatStageRatios[statStage][0];
attackerSpAtkStat /= gStatStageRatios[statStage][1];
statStage = gBattleMons[gBattlerTarget].statStages[STAT_SPDEF];
targetSpDefStat *= gStatStageRatios[statStage][0];
targetSpDefStat /= gStatStageRatios[statStage][1];
special = ((((2 * gBattleMons[gBattlerAttacker].level / 5 + 2) * gBattleMoves[gCurrentMove].power * attackerSpAtkStat) / targetSpDefStat) / 50);
if (((physical > special) || (physical == special && (Random() % 2) == 0)))
gSwapDamageCategory = TRUE;
break;
}
case VARIOUS_JUMP_IF_LEAF_GUARD_PROTECTED:
if (IsLeafGuardProtected(gActiveBattler))
{
@ -11880,13 +12042,15 @@ static void Cmd_callterrainattack(void) // nature power
u16 GetNaturePowerMove(void)
{
if (gFieldStatuses & STATUS_FIELD_MISTY_TERRAIN)
return MOVE_MOONBLAST;
return MOVE_MOONBLAST;
else if (gFieldStatuses & STATUS_FIELD_ELECTRIC_TERRAIN)
return MOVE_THUNDERBOLT;
return MOVE_THUNDERBOLT;
else if (gFieldStatuses & STATUS_FIELD_GRASSY_TERRAIN)
return MOVE_ENERGY_BALL;
return MOVE_ENERGY_BALL;
else if (gFieldStatuses & STATUS_FIELD_PSYCHIC_TERRAIN)
return MOVE_PSYCHIC;
return MOVE_PSYCHIC;
else if (sNaturePowerMoves == MOVE_NONE)
return MOVE_TRI_ATTACK;
return sNaturePowerMoves[gBattleTerrain];
}
@ -12470,39 +12634,114 @@ static void Cmd_jumpifhasnohp(void)
static void Cmd_getsecretpowereffect(void)
{
switch (gBattleTerrain)
{
case BATTLE_TERRAIN_GRASS:
gBattleScripting.moveEffect = MOVE_EFFECT_SLEEP;
break;
case BATTLE_TERRAIN_LONG_GRASS:
gBattleScripting.moveEffect = MOVE_EFFECT_SLEEP;
break;
case BATTLE_TERRAIN_SAND:
gBattleScripting.moveEffect = MOVE_EFFECT_ACC_MINUS_1;
break;
case BATTLE_TERRAIN_UNDERWATER:
gBattleScripting.moveEffect = MOVE_EFFECT_ATK_MINUS_1;
break;
case BATTLE_TERRAIN_WATER:
gBattleScripting.moveEffect = MOVE_EFFECT_ATK_MINUS_1;
break;
case BATTLE_TERRAIN_POND:
gBattleScripting.moveEffect = MOVE_EFFECT_ATK_MINUS_1;
break;
case BATTLE_TERRAIN_MOUNTAIN:
gBattleScripting.moveEffect = MOVE_EFFECT_ACC_MINUS_1;
break;
case BATTLE_TERRAIN_CAVE:
gBattleScripting.moveEffect = MOVE_EFFECT_FLINCH;
break;
default:
gBattleScripting.moveEffect = MOVE_EFFECT_PARALYSIS;
break;
}
gBattleScripting.moveEffect = GetSecretPowerMoveEffect();
gBattlescriptCurrInstr++;
}
u16 GetSecretPowerMoveEffect(void)
{
u16 moveEffect;
u32 fieldTerrain = gFieldStatuses & STATUS_FIELD_TERRAIN_ANY;
if (fieldTerrain)
{
switch (fieldTerrain)
{
case STATUS_FIELD_MISTY_TERRAIN:
moveEffect = MOVE_EFFECT_SP_ATK_MINUS_1;
break;
case STATUS_FIELD_GRASSY_TERRAIN:
moveEffect = MOVE_EFFECT_SLEEP;
break;
case STATUS_FIELD_ELECTRIC_TERRAIN:
moveEffect = MOVE_EFFECT_PARALYSIS;
break;
case STATUS_FIELD_PSYCHIC_TERRAIN:
moveEffect = MOVE_EFFECT_SPD_MINUS_1;
break;
default:
moveEffect = MOVE_EFFECT_PARALYSIS;
break;
}
}
else
{
switch (gBattleTerrain)
{
case BATTLE_TERRAIN_GRASS:
#if B_SECRET_POWER_EFFECT >= GEN_4
moveEffect = MOVE_EFFECT_SLEEP;
#else
moveEffect = MOVE_EFFECT_POISON;
#endif
break;
case BATTLE_TERRAIN_LONG_GRASS:
moveEffect = MOVE_EFFECT_SLEEP;
break;
case BATTLE_TERRAIN_SAND:
moveEffect = MOVE_EFFECT_ACC_MINUS_1;
break;
case BATTLE_TERRAIN_UNDERWATER:
#if B_SECRET_POWER_EFFECT >= GEN_6
moveEffect = MOVE_EFFECT_ATK_MINUS_1;
#else
moveEffect = MOVE_EFFECT_DEF_MINUS_1;
#endif
break;
case BATTLE_TERRAIN_WATER:
moveEffect = MOVE_EFFECT_ATK_MINUS_1;
break;
case BATTLE_TERRAIN_POND:
#if B_SECRET_POWER_EFFECT >= GEN_4
moveEffect = MOVE_EFFECT_ATK_MINUS_1;
#else
moveEffect = MOVE_EFFECT_SPD_MINUS_1;
#endif
break;
case BATTLE_TERRAIN_MOUNTAIN:
#if B_SECRET_POWER_EFFECT >= GEN_5
moveEffect = MOVE_EFFECT_ACC_MINUS_1;
#elif B_SECRET_POWER_EFFECT == GEN_4
moveEffect = MOVE_EFFECT_FLINCH;
#else
moveEffect = MOVE_EFFECT_CONFUSION;
#endif
break;
case BATTLE_TERRAIN_CAVE:
case BATTLE_TERRAIN_BURIAL_GROUND:
case BATTLE_TERRAIN_SPACE:
moveEffect = MOVE_EFFECT_FLINCH;
break;
case BATTLE_TERRAIN_SOARING:
case BATTLE_TERRAIN_SKY_PILLAR:
case BATTLE_TERRAIN_MARSH:
case BATTLE_TERRAIN_SWAMP:
moveEffect = MOVE_EFFECT_SPD_MINUS_1;
break;
case BATTLE_TERRAIN_PUDDLE:
#if B_SECRET_POWER_EFFECT >= GEN_5
moveEffect = MOVE_EFFECT_SPD_MINUS_1;
#else
moveEffect = MOVE_EFFECT_ACC_MINUS_1;
#endif
break;
case BATTLE_TERRAIN_SNOW:
case BATTLE_TERRAIN_ICE:
moveEffect = MOVE_EFFECT_FREEZE;
break;
case BATTLE_TERRAIN_VOLCANO:
moveEffect = MOVE_EFFECT_BURN;
break;
case BATTLE_TERRAIN_ULTRA_SPACE:
moveEffect = MOVE_EFFECT_DEF_MINUS_1;
break;
default:
moveEffect = MOVE_EFFECT_PARALYSIS;
break;
}
}
return moveEffect;
}
static void Cmd_pickup(void)
{
s32 i;
@ -12730,10 +12969,30 @@ bool32 CanCamouflage(u8 battlerId)
static void Cmd_settypetoterrain(void)
{
if (!IS_BATTLER_OF_TYPE(gBattlerAttacker, sTerrainToType[gBattleTerrain]))
u8 terrainType;
switch(gFieldStatuses & STATUS_FIELD_TERRAIN_ANY)
{
SET_BATTLER_TYPE(gBattlerAttacker, sTerrainToType[gBattleTerrain]);
PREPARE_TYPE_BUFFER(gBattleTextBuff1, sTerrainToType[gBattleTerrain]);
case STATUS_FIELD_ELECTRIC_TERRAIN:
terrainType = TYPE_ELECTRIC;
break;
case STATUS_FIELD_GRASSY_TERRAIN:
terrainType = TYPE_GRASS;
break;
case STATUS_FIELD_MISTY_TERRAIN:
terrainType = TYPE_FAIRY;
break;
case STATUS_FIELD_PSYCHIC_TERRAIN:
terrainType = TYPE_PSYCHIC;
break;
default:
terrainType = sTerrainToType[gBattleTerrain];
break;
}
if (!IS_BATTLER_OF_TYPE(gBattlerAttacker, terrainType))
{
SET_BATTLER_TYPE(gBattlerAttacker, terrainType);
PREPARE_TYPE_BUFFER(gBattleTextBuff1, terrainType);
gBattlescriptCurrInstr += 5;
}
@ -13433,4 +13692,3 @@ static bool32 CriticalCapture(u32 odds)
return FALSE;
#endif
}

View File

@ -2326,7 +2326,7 @@ u8 DoFieldEndTurnEffects(void)
break;
case ENDTURN_ELECTRIC_TERRAIN:
if (gFieldStatuses & STATUS_FIELD_ELECTRIC_TERRAIN
&& (!(gFieldStatuses & STATUS_FIELD_TERRAIN_PERMANENT) && --gFieldTimers.electricTerrainTimer == 0))
&& (!(gFieldStatuses & STATUS_FIELD_TERRAIN_PERMANENT) && --gFieldTimers.terrainTimer == 0))
{
gFieldStatuses &= ~(STATUS_FIELD_ELECTRIC_TERRAIN | STATUS_FIELD_TERRAIN_PERMANENT);
TryToRevertMimicry();
@ -2337,7 +2337,7 @@ u8 DoFieldEndTurnEffects(void)
break;
case ENDTURN_MISTY_TERRAIN:
if (gFieldStatuses & STATUS_FIELD_MISTY_TERRAIN
&& (!(gFieldStatuses & STATUS_FIELD_TERRAIN_PERMANENT) && --gFieldTimers.mistyTerrainTimer == 0))
&& (!(gFieldStatuses & STATUS_FIELD_TERRAIN_PERMANENT) && --gFieldTimers.terrainTimer == 0))
{
gFieldStatuses &= ~(STATUS_FIELD_MISTY_TERRAIN);
TryToRevertMimicry();
@ -2350,7 +2350,7 @@ u8 DoFieldEndTurnEffects(void)
if (gFieldStatuses & STATUS_FIELD_GRASSY_TERRAIN)
{
if (!(gFieldStatuses & STATUS_FIELD_TERRAIN_PERMANENT)
&& (gFieldTimers.grassyTerrainTimer == 0 || --gFieldTimers.grassyTerrainTimer == 0))
&& (gFieldTimers.terrainTimer == 0 || --gFieldTimers.terrainTimer == 0))
{
gFieldStatuses &= ~(STATUS_FIELD_GRASSY_TERRAIN);
TryToRevertMimicry();
@ -2362,7 +2362,7 @@ u8 DoFieldEndTurnEffects(void)
break;
case ENDTURN_PSYCHIC_TERRAIN:
if (gFieldStatuses & STATUS_FIELD_PSYCHIC_TERRAIN
&& (!(gFieldStatuses & STATUS_FIELD_TERRAIN_PERMANENT) && --gFieldTimers.psychicTerrainTimer == 0))
&& (!(gFieldStatuses & STATUS_FIELD_TERRAIN_PERMANENT) && --gFieldTimers.terrainTimer == 0))
{
gFieldStatuses &= ~(STATUS_FIELD_PSYCHIC_TERRAIN);
TryToRevertMimicry();
@ -4351,28 +4351,28 @@ u8 AbilityBattleEffects(u8 caseID, u8 battler, u16 ability, u8 special, u16 move
}
break;
case ABILITY_ELECTRIC_SURGE:
if (TryChangeBattleTerrain(battler, STATUS_FIELD_ELECTRIC_TERRAIN, &gFieldTimers.electricTerrainTimer))
if (TryChangeBattleTerrain(battler, STATUS_FIELD_ELECTRIC_TERRAIN, &gFieldTimers.terrainTimer))
{
BattleScriptPushCursorAndCallback(BattleScript_ElectricSurgeActivates);
effect++;
}
break;
case ABILITY_GRASSY_SURGE:
if (TryChangeBattleTerrain(battler, STATUS_FIELD_GRASSY_TERRAIN, &gFieldTimers.grassyTerrainTimer))
if (TryChangeBattleTerrain(battler, STATUS_FIELD_GRASSY_TERRAIN, &gFieldTimers.terrainTimer))
{
BattleScriptPushCursorAndCallback(BattleScript_GrassySurgeActivates);
effect++;
}
break;
case ABILITY_MISTY_SURGE:
if (TryChangeBattleTerrain(battler, STATUS_FIELD_MISTY_TERRAIN, &gFieldTimers.mistyTerrainTimer))
if (TryChangeBattleTerrain(battler, STATUS_FIELD_MISTY_TERRAIN, &gFieldTimers.terrainTimer))
{
BattleScriptPushCursorAndCallback(BattleScript_MistySurgeActivates);
effect++;
}
break;
case ABILITY_PSYCHIC_SURGE:
if (TryChangeBattleTerrain(battler, STATUS_FIELD_PSYCHIC_TERRAIN, &gFieldTimers.psychicTerrainTimer))
if (TryChangeBattleTerrain(battler, STATUS_FIELD_PSYCHIC_TERRAIN, &gFieldTimers.terrainTimer))
{
BattleScriptPushCursorAndCallback(BattleScript_PsychicSurgeActivates);
effect++;
@ -4929,7 +4929,7 @@ u8 AbilityBattleEffects(u8 caseID, u8 battler, u16 ability, u8 special, u16 move
if (!(gMoveResultFlags & MOVE_RESULT_NO_EFFECT)
&& IsBattlerAlive(gBattlerAttacker)
&& TARGET_TURN_DAMAGED
&& (gBattleMoves[move].flags & FLAG_MAKES_CONTACT))
&& (IsMoveMakingContact(move, gBattlerAttacker)))
{
switch (gBattleMons[gBattlerAttacker].ability)
{
@ -5148,7 +5148,7 @@ u8 AbilityBattleEffects(u8 caseID, u8 battler, u16 ability, u8 special, u16 move
if (!(gMoveResultFlags & MOVE_RESULT_NO_EFFECT)
&& gBattleMons[gBattlerAttacker].hp != 0
&& !gProtectStructs[gBattlerAttacker].confusionSelfDmg
&& (gBattleMoves[move].flags & FLAG_MAKES_CONTACT)
&& (IsMoveMakingContact(move, gBattlerAttacker))
&& TARGET_TURN_DAMAGED
&& CanBeBurned(gBattlerAttacker)
&& (Random() % 3) == 0)
@ -5164,7 +5164,7 @@ u8 AbilityBattleEffects(u8 caseID, u8 battler, u16 ability, u8 special, u16 move
if (!(gMoveResultFlags & MOVE_RESULT_NO_EFFECT)
&& gBattleMons[gBattlerAttacker].hp != 0
&& !gProtectStructs[gBattlerAttacker].confusionSelfDmg
&& (gBattleMoves[move].flags & FLAG_MAKES_CONTACT)
&& (IsMoveMakingContact(move, gBattlerAttacker))
&& TARGET_TURN_DAMAGED
&& gBattleMons[gBattlerTarget].hp != 0
&& (Random() % 3) == 0
@ -5240,7 +5240,7 @@ u8 AbilityBattleEffects(u8 caseID, u8 battler, u16 ability, u8 special, u16 move
&& !gProtectStructs[gBattlerAttacker].confusionSelfDmg
&& TARGET_TURN_DAMAGED
&& IsBattlerAlive(battler)
&& (gBattleMoves[move].flags & FLAG_MAKES_CONTACT)
&& (IsMoveMakingContact(move, gBattlerAttacker))
&& !(gStatuses3[gBattlerAttacker] & STATUS3_PERISH_SONG))
{
if (!(gStatuses3[battler] & STATUS3_PERISH_SONG))
@ -5484,8 +5484,10 @@ u8 AbilityBattleEffects(u8 caseID, u8 battler, u16 ability, u8 special, u16 move
if (!(gBattleMons[gBattlerAttacker].status1 & STATUS1_ANY))
{
gBattleStruct->synchronizeMoveEffect &= ~(MOVE_EFFECT_AFFECTS_USER | MOVE_EFFECT_CERTAIN);
if (gBattleStruct->synchronizeMoveEffect == MOVE_EFFECT_TOXIC)
gBattleStruct->synchronizeMoveEffect = MOVE_EFFECT_POISON;
#if B_SYNCHRONIZE_TOXIC < GEN_5
if (gBattleStruct->synchronizeMoveEffect == MOVE_EFFECT_TOXIC)
gBattleStruct->synchronizeMoveEffect = MOVE_EFFECT_POISON;
#endif
gBattleScripting.moveEffect = gBattleStruct->synchronizeMoveEffect + MOVE_EFFECT_AFFECTS_USER;
gBattleScripting.battler = gBattlerAbility = gBattlerTarget;
@ -7424,13 +7426,24 @@ u32 GetBattlerHoldEffectParam(u8 battlerId)
bool32 IsMoveMakingContact(u16 move, u8 battlerAtk)
{
if (!(gBattleMoves[move].flags & FLAG_MAKES_CONTACT))
return FALSE;
{
if (gBattleMoves[move].effect == EFFECT_SHELL_SIDE_ARM && gSwapDamageCategory)
return TRUE;
else
return FALSE;
}
else if (GetBattlerAbility(battlerAtk) == ABILITY_LONG_REACH)
{
return FALSE;
}
else if (GetBattlerHoldEffect(battlerAtk, TRUE) == HOLD_EFFECT_PROTECTIVE_PADS)
{
return FALSE;
}
else
{
return TRUE;
}
}
bool32 IsBattlerGrounded(u8 battlerId)
@ -7788,7 +7801,7 @@ static u16 CalcMoveBasePower(u16 move, u8 battlerAtk, u8 battlerDef)
if (weight >= ARRAY_COUNT(sHeatCrashPowerTable))
basePower = sHeatCrashPowerTable[ARRAY_COUNT(sHeatCrashPowerTable) - 1];
else
basePower = sHeatCrashPowerTable[i];
basePower = sHeatCrashPowerTable[weight];
break;
case EFFECT_PUNISHMENT:
basePower = 60 + (CountBattlerStatIncreases(battlerDef, FALSE) * 20);
@ -7869,6 +7882,11 @@ static u16 CalcMoveBasePower(u16 move, u8 battlerAtk, u8 battlerDef)
if (gFieldStatuses & STATUS_FIELD_GRAVITY)
MulModifier(&basePower, UQ_4_12(1.5));
break;
case EFFECT_TERRAIN_PULSE:
if ((gFieldStatuses & STATUS_FIELD_TERRAIN_ANY)
&& IsBattlerGrounded(gBattlerAttacker))
basePower *= 2;
break;
}
// move-specific base power changes
@ -7942,7 +7960,7 @@ static u32 CalcMoveBasePowerAfterModifiers(u16 move, u8 battlerAtk, u8 battlerDe
MulModifier(&modifier, UQ_4_12(1.3));
break;
case ABILITY_TOUGH_CLAWS:
if (gBattleMoves[move].flags & FLAG_MAKES_CONTACT)
if (IsMoveMakingContact(move, battlerAtk))
MulModifier(&modifier, UQ_4_12(1.3));
break;
case ABILITY_STRONG_JAW:
@ -8092,7 +8110,11 @@ static u32 CalcMoveBasePowerAfterModifiers(u16 move, u8 battlerAtk, u8 battlerDe
MulModifier(&modifier, holdEffectModifier);
break;
case HOLD_EFFECT_SOUL_DEW:
if ((gBattleMons[battlerAtk].species == SPECIES_LATIAS || gBattleMons[battlerAtk].species == SPECIES_LATIOS) && !(gBattleTypeFlags & BATTLE_TYPE_FRONTIER))
#if B_SOUL_DEW_BOOST >= GEN_7
if ((gBattleMons[battlerAtk].species == SPECIES_LATIAS || gBattleMons[battlerAtk].species == SPECIES_LATIOS) && (moveType == TYPE_PSYCHIC || moveType == TYPE_DRAGON))
#else
if ((gBattleMons[battlerAtk].species == SPECIES_LATIAS || gBattleMons[battlerAtk].species == SPECIES_LATIOS) && !(gBattleTypeFlags & BATTLE_TYPE_FRONTIER) && IS_MOVE_SPECIAL(move))
#endif
MulModifier(&modifier, holdEffectModifier);
break;
case HOLD_EFFECT_GEMS:
@ -8505,6 +8527,14 @@ static u32 CalcDefenseStat(u16 move, u8 battlerAtk, u8 battlerDef, u8 moveType,
if (!usesDefStat)
MulModifier(&modifier, UQ_4_12(1.5));
break;
#if B_SOUL_DEW_BOOST <= GEN_6
case HOLD_EFFECT_SOUL_DEW:
if ((gBattleMons[battlerDef].species == SPECIES_LATIAS || gBattleMons[battlerDef].species == SPECIES_LATIOS)
&& !(gBattleTypeFlags & BATTLE_TYPE_FRONTIER)
&& !usesDefStat)
MulModifier(&modifier, UQ_4_12(1.5));
break;
#endif
}
// sandstorm sp.def boost for rock types
@ -9069,6 +9099,7 @@ void UndoFormChange(u32 monId, u32 side, bool32 isSwitchingOut)
// Changed Form ID Default Form ID Should change on switch
{SPECIES_MIMIKYU_BUSTED, SPECIES_MIMIKYU, FALSE},
{SPECIES_GRENINJA_ASH, SPECIES_GRENINJA_BATTLE_BOND, FALSE},
{SPECIES_MELOETTA_PIROUETTE, SPECIES_MELOETTA, FALSE},
{SPECIES_AEGISLASH_BLADE, SPECIES_AEGISLASH, TRUE},
{SPECIES_DARMANITAN_ZEN_MODE, SPECIES_DARMANITAN, TRUE},
{SPECIES_MINIOR, SPECIES_MINIOR_CORE_RED, TRUE},
@ -9227,7 +9258,9 @@ bool8 ShouldGetStatBadgeBoost(u16 badgeFlag, u8 battlerId)
u8 GetBattleMoveSplit(u32 moveId)
{
if (IS_MOVE_STATUS(moveId) || B_PHYSICAL_SPECIAL_SPLIT >= GEN_4)
if (gSwapDamageCategory) // Photon Geyser, Shell Side Arm, Light That Burns the Sky
return SPLIT_PHYSICAL;
else if (IS_MOVE_STATUS(moveId) || B_PHYSICAL_SPECIAL_SPLIT >= GEN_4)
return gBattleMoves[moveId].split;
else if (gBattleMoves[moveId].type < TYPE_MYSTERY)
return SPLIT_PHYSICAL;

View File

@ -8614,7 +8614,7 @@ const struct BattleMove gBattleMoves[MOVES_COUNT] =
[MOVE_RELIC_SONG] =
{
.effect = EFFECT_SLEEP_HIT,
.effect = EFFECT_RELIC_SONG,
.power = 75,
.type = TYPE_NORMAL,
.accuracy = 100,
@ -8624,6 +8624,7 @@ const struct BattleMove gBattleMoves[MOVES_COUNT] =
.priority = 0,
.flags = FLAG_PROTECT_AFFECTED | FLAG_MIRROR_MOVE_AFFECTED | FLAG_SOUND | FLAG_SHEER_FORCE_BOOST,
.split = SPLIT_SPECIAL,
.argument = STATUS1_SLEEP,
},
[MOVE_SECRET_SWORD] =
@ -10454,7 +10455,7 @@ const struct BattleMove gBattleMoves[MOVES_COUNT] =
[MOVE_PHOTON_GEYSER] =
{
.effect = EFFECT_PLACEHOLDER, // Needs a custom move effect
.effect = EFFECT_PHOTON_GEYSER,
.power = 100,
.type = TYPE_PSYCHIC,
.accuracy = 100,
@ -10462,7 +10463,7 @@ const struct BattleMove gBattleMoves[MOVES_COUNT] =
.secondaryEffectChance = 0,
.target = MOVE_TARGET_FOES_AND_ALLY,
.priority = 0,
.flags = FLAG_PROTECT_AFFECTED | FLAG_MIRROR_MOVE_AFFECTED | FLAG_KINGS_ROCK_AFFECTED,
.flags = FLAG_PROTECT_AFFECTED | FLAG_MIRROR_MOVE_AFFECTED | FLAG_KINGS_ROCK_AFFECTED | FLAG_TARGET_ABILITY_IGNORED,
.split = SPLIT_SPECIAL,
},
@ -11290,12 +11291,12 @@ const struct BattleMove gBattleMoves[MOVES_COUNT] =
[MOVE_SHELL_SIDE_ARM] =
{
.effect = EFFECT_PLACEHOLDER, //TODO
.effect = EFFECT_SHELL_SIDE_ARM,
.power = 90,
.type = TYPE_POISON,
.accuracy = 100,
.pp = 10,
.secondaryEffectChance = 0,
.secondaryEffectChance = 20,
.target = MOVE_TARGET_SELECTED,
.priority = 0,
.flags = FLAG_PROTECT_AFFECTED | FLAG_MIRROR_MOVE_AFFECTED | FLAG_KINGS_ROCK_AFFECTED | FLAG_SHEER_FORCE_BOOST,
@ -11346,7 +11347,7 @@ const struct BattleMove gBattleMoves[MOVES_COUNT] =
[MOVE_TERRAIN_PULSE] =
{
.effect = EFFECT_PLACEHOLDER, //TODO
.effect = EFFECT_TERRAIN_PULSE,
.power = 50,
.type = TYPE_NORMAL,
.accuracy = 100,

View File

@ -2839,7 +2839,7 @@ static const u8 sMETEOR_BEAMDescription[] = _(
"Sp. Attack before attacking.");
static const u8 sSHELL_SIDE_ARMDescription[] = _(
"Uses higher of physical and\n"
"Deals better of physical and\n"
"special damage. May poison.");
static const u8 sMISTY_EXPLOSIONDescription[] = _(