An enemy's choice of action, BattleCommand_SelectAutomatic. More...
Go to the source code of this file.
Data Structures | |
| struct | BattleAutomaticState |
| An enemy's memory of its action choice, kept in BattleUnit.rewards (0 in every row of enemies.tsv, so it starts cleared). More... | |
Functions | |
| s32 | BattleCommand_SelectAutomatic (struct BattleActionRecord *request, s32 retry) |
| Chooses an enemy's action (a party member's is chosen in the menu): one of the eight in its definition, picked by its action strategy, with an item instead where its item mask says so, and a target worth the ability. | |
An enemy's choice of action, BattleCommand_SelectAutomatic.
Part of battle.c, the battle object, compiled only through it.
Definition in file enemy_ai.c.
| s32 BattleCommand_SelectAutomatic | ( | struct BattleActionRecord * | request, |
| s32 | retry ) |
Chooses an enemy's action (a party member's is chosen in the menu): one of the eight in its definition, picked by its action strategy, with an item instead where its item mask says so, and a target worth the ability.
A choice that cannot be made (too little PP, sealed, a forbidden escape, no worthwhile target) picks again; after 18 tries the enemy defends. Called with retry 0 for each enemy as the round is built (BattlePres_BuildOpponentEntries), and with retry 1 at its turn (BattlePresentation_DispatchAction). Writes request's command, parameter, target and range; strategies 3 and 4 advance the place remembered in BattleUnit.rewards. Returns nothing. retry : 0 when the round is built: only a guard is settled now (it must raise before anyone acts); 1 at the enemy's turn: the rest.
Picks a place in the action list from a 0-255 roll and eight weights: the first place whose running total passes the roll, else place 0.
Definition at line 33 of file enemy_ai.c.
Referenced by BattleCommand_SelectAutomatic(), BattlePres_BuildOpponentEntries(), and BattlePresentation_DispatchAction().