mirror of
https://github.com/Ninjdai1/pokeemerald.git
synced 2024-11-16 11:37:40 +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,30 +435,25 @@ 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;
|
||||
@ -551,6 +546,8 @@ 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++) {
|
||||
|
||||
@ -676,6 +673,8 @@ static void Cmd_createvisualtaskontargets(void)
|
||||
}
|
||||
|
||||
numArgs = GetBattleAnimMoveTargets(battlerArgIndex, targets);
|
||||
if (numArgs == 0)
|
||||
return;
|
||||
|
||||
for (i = 0; i < numArgs; i++)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user