mirror of
https://github.com/Ninjdai1/pokeemerald.git
synced 2024-12-26 03:34:15 +01:00
fix GetBattleAnimMoveTargets logic (#3278)
* fix GetBattleAnimMoveTargets logic * more efficient GetBattleAnimMoveTargets --------- Co-authored-by: ghoulslash <pokevoyager0@gmail.com>
This commit is contained in:
parent
2fa4206bf1
commit
675aa5db41
@ -54,7 +54,8 @@
|
||||
|
||||
#define WEATHER_HAS_EFFECT ((!IsAbilityOnField(ABILITY_CLOUD_NINE) && !IsAbilityOnField(ABILITY_AIR_LOCK)))
|
||||
|
||||
#define IS_WHOLE_SIDE_ALIVE(battler)((IsBattlerAlive(battler) && IsBattlerAlive(BATTLE_PARTNER(battler))))
|
||||
#define IS_WHOLE_SIDE_ALIVE(battler) ((IsBattlerAlive(battler) && IsBattlerAlive(BATTLE_PARTNER(battler))))
|
||||
#define IS_ALIVE_AND_PRESENT(battler) (IsBattlerAlive(battler) && IsBattlerSpritePresent(battler))
|
||||
|
||||
// for Natural Gift and Fling
|
||||
struct TypePower
|
||||
|
@ -435,32 +435,27 @@ static void Cmd_unloadspritegfx(void)
|
||||
|
||||
static u8 GetBattleAnimMoveTargets(u8 battlerArgIndex, u8 *targets)
|
||||
{
|
||||
u8 numTargets = 1;
|
||||
u8 numTargets = 0;
|
||||
int idx = 0;
|
||||
u32 battler = gBattleAnimArgs[battlerArgIndex];
|
||||
switch (GetBattlerMoveTargetType(gBattleAnimAttacker, gAnimMoveIndex))
|
||||
{
|
||||
case MOVE_TARGET_BOTH:
|
||||
targets[0] = gBattleAnimArgs[battlerArgIndex];
|
||||
numTargets = 1;
|
||||
if (IsBattlerAlive(BATTLE_PARTNER(targets[0])))
|
||||
{
|
||||
targets[1] = BATTLE_PARTNER(targets[0]);
|
||||
numTargets = 2;
|
||||
}
|
||||
break;
|
||||
case MOVE_TARGET_FOES_AND_ALLY:
|
||||
targets[0] = gBattleAnimArgs[battlerArgIndex];
|
||||
numTargets = 1;
|
||||
if (IsBattlerAlive(BATTLE_PARTNER(targets[0])))
|
||||
{
|
||||
targets[1] = BATTLE_PARTNER(targets[0]);
|
||||
if (IS_ALIVE_AND_PRESENT(BATTLE_PARTNER(BATTLE_OPPOSITE(battler)))) {
|
||||
targets[idx++] = BATTLE_PARTNER(BATTLE_OPPOSITE(battler));
|
||||
numTargets++;
|
||||
}
|
||||
|
||||
if (IsBattlerAlive(BATTLE_PARTNER(BATTLE_OPPOSITE(targets[0]))))
|
||||
{
|
||||
targets[2] = BATTLE_PARTNER(BATTLE_OPPOSITE(targets[0]));
|
||||
// fallthrough
|
||||
case MOVE_TARGET_BOTH:
|
||||
if (IS_ALIVE_AND_PRESENT(battler)) {
|
||||
targets[idx++] = battler;
|
||||
numTargets++;
|
||||
}
|
||||
battler = BATTLE_PARTNER(battler);
|
||||
if (IS_ALIVE_AND_PRESENT(battler)) {
|
||||
targets[idx++] = battler;
|
||||
numTargets++;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
targets[0] = gBattleAnimArgs[battlerArgIndex]; // original
|
||||
@ -551,7 +546,9 @@ static void CreateSpriteOnTargets(const struct SpriteTemplate *template, u8 argV
|
||||
subpriority = GetSubpriorityForMoveAnim(argVar);
|
||||
|
||||
ntargets = GetBattleAnimMoveTargets(battlerArgIndex, targets);
|
||||
|
||||
if (ntargets == 0)
|
||||
return;
|
||||
|
||||
for (i = 0; i < ntargets; i++) {
|
||||
|
||||
if (overwriteAnimTgt)
|
||||
@ -676,7 +673,9 @@ static void Cmd_createvisualtaskontargets(void)
|
||||
}
|
||||
|
||||
numArgs = GetBattleAnimMoveTargets(battlerArgIndex, targets);
|
||||
|
||||
if (numArgs == 0)
|
||||
return;
|
||||
|
||||
for (i = 0; i < numArgs; i++)
|
||||
{
|
||||
gBattleAnimArgs[battlerArgIndex] = targets[i];
|
||||
|
Loading…
Reference in New Issue
Block a user