Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Removed gFlingTable from comments and added .flingEffects to src/data/moves_info.h for ai use (and future use?) #6131

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion include/constants/battle.h
Original file line number Diff line number Diff line change
Expand Up @@ -416,8 +416,10 @@
#define MOVE_EFFECT_LIGHT_SCREEN 85
#define MOVE_EFFECT_SALT_CURE 86
#define MOVE_EFFECT_EERIE_SPELL 87
ShadowzLmao2 marked this conversation as resolved.
Show resolved Hide resolved
#define MOVE_EFFECT_FLING_MENTAL_HERB 89
#define MOVE_EFFECT_FLING_WHITE_HERB 90

#define NUM_MOVE_EFFECTS 88
#define NUM_MOVE_EFFECTS 91

#define MOVE_EFFECT_AFFECTS_USER 0x2000
#define MOVE_EFFECT_CERTAIN 0x4000
Expand Down
1 change: 1 addition & 0 deletions include/item.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ struct Item
u8 type;
u8 battleUsage;
u8 flingPower;
u8 flingEffect;
const u32 *iconPic;
const u32 *iconPalette;
};
Expand Down
39 changes: 22 additions & 17 deletions src/battle_ai_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -2296,12 +2296,11 @@ static s32 AI_CheckBadMove(u32 battlerAtk, u32 battlerDef, u32 move, s32 score)
}
else
{
/* TODO Fling
u8 effect = gFlingTable[gBattleMons[battlerAtk].item].effect;
u8 effect = gItemsInfo[gBattleMons[battlerAtk].item].flingEffect;
switch (effect)
{
case MOVE_EFFECT_BURN:
if (!AI_CanBurn(battlerAtk, battlerDef, BATTLE_PARTNER(battlerAtk), move, aiData->partnerMove))
if (!AI_CanBurn(battlerAtk, battlerDef, aiData->abilities[battlerDef], BATTLE_PARTNER(battlerAtk), move, aiData->partnerMove))
ADJUST_SCORE(-10);
break;
case MOVE_EFFECT_PARALYSIS:
Expand All @@ -2316,12 +2315,16 @@ static s32 AI_CheckBadMove(u32 battlerAtk, u32 battlerDef, u32 move, s32 score)
if (!AI_CanPoison(battlerAtk, battlerDef, aiData->abilities[battlerDef], move, aiData->partnerMove))
ADJUST_SCORE(-10);
break;
case MOVE_EFFECT_FREEZE:
if (!CanBeFrozen(battlerDef, TRUE)
|| MoveBlockedBySubstitute(move, battlerAtk, battlerDef))
ADJUST_SCORE(-10);
case MOVE_EFFECT_FLINCH:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be filled in, other flinching effects already have score adjustments.

//TODO
break;
}*/
case MOVE_EFFECT_FLING_MENTAL_HERB:
//TODO
break;
case MOVE_EFFECT_FLING_WHITE_HERB:
//TODO
break;
}
}
break;
case EFFECT_EMBARGO:
Expand Down Expand Up @@ -4271,27 +4274,29 @@ static u32 AI_CalcMoveEffectScore(u32 battlerAtk, u32 battlerDef, u32 move)
ADJUST_SCORE(DECENT_EFFECT);
break;
case EFFECT_FLING:
/* TODO
switch (gFlingTable[aiData->items[battlerAtk]].effect)
u8 effect = gItemsInfo[gBattleMons[battlerAtk].item].flingEffect;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"Label followed by a declaration" will fail to compile on some compilers.

switch (effect)
{
case MOVE_EFFECT_BURN:
IncreaseBurnScore(battlerAtk, battlerDef, move, &score);
break;
case MOVE_EFFECT_FLINCH:
score += ShouldTryToFlinch(battlerAtk, battlerDef, aiData->abilities[battlerAtk], aiData->abilities[battlerDef], move);
break;
case MOVE_EFFECT_PARALYSIS:
IncreaseParalyzeScore(battlerAtk, battlerDef, move, &score);
break;
case MOVE_EFFECT_POISON:
case MOVE_EFFECT_TOXIC:
IncreasePoisonScore(battlerAtk, battlerDef, move, &score);
break;
case MOVE_EFFECT_FREEZE:
if (AI_CanFreeze(battlerAtk, battlerDef))
ADJUST_SCORE(GOOD_EFFECT);
case MOVE_EFFECT_FLINCH:
score += ShouldTryToFlinch(battlerAtk, battlerDef, aiData->abilities[battlerAtk], aiData->abilities[battlerDef], move);
break;
}*/
case MOVE_EFFECT_FLING_MENTAL_HERB:
//TODO
break;
case MOVE_EFFECT_FLING_WHITE_HERB:
//TODO
break;
}
break;
case EFFECT_EMBARGO:
if (aiData->holdEffects[battlerDef] != HOLD_EFFECT_NONE)
Expand Down
5 changes: 2 additions & 3 deletions src/battle_ai_util.c
Original file line number Diff line number Diff line change
Expand Up @@ -329,9 +329,8 @@ bool32 IsTruantMonVulnerable(u32 battlerAI, u32 opposingBattler)
for (i = 0; i < MAX_MON_MOVES; i++)
{
u32 move = gBattleResources->battleHistory->usedMoves[opposingBattler][i];
if (gMovesInfo[move].effect == EFFECT_PROTECT && move != MOVE_ENDURE)
return TRUE;
if (gMovesInfo[move].effect == EFFECT_SEMI_INVULNERABLE && AI_IsSlower(battlerAI, opposingBattler, GetAIChosenMove(battlerAI)))
if ((gMovesInfo[move].effect == EFFECT_PROTECT && move != MOVE_ENDURE) || move == MOVE_SUBSTITUTE
|| (gMovesInfo[move].effect == EFFECT_SEMI_INVULNERABLE && AI_IsSlower(battlerAI, opposingBattler, GetAIChosenMove(battlerAI))))
ShadowzLmao2 marked this conversation as resolved.
Show resolved Hide resolved
return TRUE;
}
return FALSE;
Expand Down
8 changes: 8 additions & 0 deletions src/data/items.h
Original file line number Diff line number Diff line change
Expand Up @@ -6987,6 +6987,7 @@ const struct Item gItemsInfo[] =
.type = ITEM_USE_BAG_MENU,
.fieldUseFunc = ItemUseOutOfBattle_CannotUse,
.flingPower = 30,
.flingEffect = MOVE_EFFECT_PARALYSIS,
.iconPic = gItemIcon_LightBall,
.iconPalette = gItemIconPalette_LightBall,
},
Expand Down Expand Up @@ -7695,6 +7696,7 @@ const struct Item gItemsInfo[] =
.type = ITEM_USE_BAG_MENU,
.fieldUseFunc = ItemUseOutOfBattle_CannotUse,
.flingPower = 70,
.flingEffect = MOVE_EFFECT_POISON,
.iconPic = gItemIcon_PoisonBarb,
.iconPalette = gItemIconPalette_PoisonBarb,
},
Expand Down Expand Up @@ -7929,6 +7931,7 @@ const struct Item gItemsInfo[] =
.type = ITEM_USE_BAG_MENU,
.fieldUseFunc = ItemUseOutOfBattle_CannotUse,
.flingPower = 30,
.flingEffect = MOVE_EFFECT_BURN,
.iconPic = gItemIcon_FlameOrb,
.iconPalette = gItemIconPalette_FlameOrb,
},
Expand All @@ -7946,6 +7949,7 @@ const struct Item gItemsInfo[] =
.type = ITEM_USE_BAG_MENU,
.fieldUseFunc = ItemUseOutOfBattle_CannotUse,
.flingPower = 30,
.flingEffect = MOVE_EFFECT_TOXIC,
.iconPic = gItemIcon_ToxicOrb,
.iconPalette = gItemIconPalette_ToxicOrb,
},
Expand Down Expand Up @@ -8204,6 +8208,7 @@ const struct Item gItemsInfo[] =
.type = ITEM_USE_BAG_MENU,
.fieldUseFunc = ItemUseOutOfBattle_CannotUse,
.flingPower = 10,
.flingEffect = MOVE_EFFECT_FLING_WHITE_HERB,
.iconPic = gItemIcon_InBattleHerb,
.iconPalette = gItemIconPalette_WhiteHerb,
},
Expand Down Expand Up @@ -8287,6 +8292,7 @@ const struct Item gItemsInfo[] =
.type = ITEM_USE_BAG_MENU,
.fieldUseFunc = ItemUseOutOfBattle_CannotUse,
.flingPower = 10,
.flingEffect = MOVE_EFFECT_FLING_MENTAL_HERB,
.iconPic = gItemIcon_InBattleHerb,
.iconPalette = gItemIconPalette_MentalHerb,
},
Expand All @@ -8303,6 +8309,7 @@ const struct Item gItemsInfo[] =
.fieldUseFunc = EVO_HELD_ITEM_FIELD_FUNC,
.effect = gItemEffect_EvoItem,
.flingPower = 30,
.flingEffect = MOVE_EFFECT_FLINCH,
.iconPic = gItemIcon_KingsRock,
.iconPalette = gItemIconPalette_KingsRock,
},
Expand Down Expand Up @@ -8788,6 +8795,7 @@ const struct Item gItemsInfo[] =
.fieldUseFunc = EVO_HELD_ITEM_FIELD_FUNC,
.effect = gItemEffect_EvoItem,
.flingPower = 30,
.flingEffect = MOVE_EFFECT_FLINCH,
.iconPic = gItemIcon_RazorFang,
.iconPalette = gItemIconPalette_RazorFang,
},
Expand Down
Loading