Forewarn
This commit is contained in:
parent
36b52eb063
commit
98b2e88e56
4 changed files with 89 additions and 14 deletions
|
@ -17,6 +17,7 @@ u8 BattleAI_ChooseMoveOrAction(void);
|
||||||
bool32 IsTruantMonVulnerable(u32 battlerAI, u32 opposingBattler);
|
bool32 IsTruantMonVulnerable(u32 battlerAI, u32 opposingBattler);
|
||||||
bool32 IsBattlerAIControlled(u32 battlerId);
|
bool32 IsBattlerAIControlled(u32 battlerId);
|
||||||
void ClearBattlerMoveHistory(u8 battlerId);
|
void ClearBattlerMoveHistory(u8 battlerId);
|
||||||
|
void RecordMoveBattle(u8 battlerId, u32 move);
|
||||||
void RecordAbilityBattle(u8 battlerId, u8 abilityId);
|
void RecordAbilityBattle(u8 battlerId, u8 abilityId);
|
||||||
void ClearBattlerAbilityHistory(u8 battlerId);
|
void ClearBattlerAbilityHistory(u8 battlerId);
|
||||||
void RecordItemEffectBattle(u8 battlerId, u8 itemEffect);
|
void RecordItemEffectBattle(u8 battlerId, u8 itemEffect);
|
||||||
|
|
|
@ -731,19 +731,7 @@ static void BattleAI_DoAIProcessing(void)
|
||||||
|
|
||||||
static void RecordLastUsedMoveByTarget(void)
|
static void RecordLastUsedMoveByTarget(void)
|
||||||
{
|
{
|
||||||
s32 i;
|
RecordMoveBattle(gBattlerTarget, gLastMoves[gBattlerTarget]);
|
||||||
|
|
||||||
for (i = 0; i < MAX_MON_MOVES; i++)
|
|
||||||
{
|
|
||||||
if (BATTLE_HISTORY->usedMoves[gBattlerTarget].moves[i] == gLastMoves[gBattlerTarget])
|
|
||||||
break;
|
|
||||||
if (BATTLE_HISTORY->usedMoves[gBattlerTarget].moves[i] != gLastMoves[gBattlerTarget] // HACK: This redundant condition is a hack to make the asm match.
|
|
||||||
&& BATTLE_HISTORY->usedMoves[gBattlerTarget].moves[i] == MOVE_NONE)
|
|
||||||
{
|
|
||||||
BATTLE_HISTORY->usedMoves[gBattlerTarget].moves[i] = gLastMoves[gBattlerTarget];
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool32 IsBattlerAIControlled(u32 battlerId)
|
bool32 IsBattlerAIControlled(u32 battlerId)
|
||||||
|
@ -770,6 +758,22 @@ void ClearBattlerMoveHistory(u8 battlerId)
|
||||||
BATTLE_HISTORY->usedMoves[battlerId].moves[i] = MOVE_NONE;
|
BATTLE_HISTORY->usedMoves[battlerId].moves[i] = MOVE_NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void RecordMoveBattle(u8 battlerId, u32 move)
|
||||||
|
{
|
||||||
|
s32 i;
|
||||||
|
|
||||||
|
for (i = 0; i < MAX_MON_MOVES; i++)
|
||||||
|
{
|
||||||
|
if (BATTLE_HISTORY->usedMoves[battlerId].moves[i] == move)
|
||||||
|
break;
|
||||||
|
if (BATTLE_HISTORY->usedMoves[battlerId].moves[i] == MOVE_NONE)
|
||||||
|
{
|
||||||
|
BATTLE_HISTORY->usedMoves[battlerId].moves[i] = move;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void RecordAbilityBattle(u8 battlerId, u8 abilityId)
|
void RecordAbilityBattle(u8 battlerId, u8 abilityId)
|
||||||
{
|
{
|
||||||
BATTLE_HISTORY->abilities[battlerId] = abilityId;
|
BATTLE_HISTORY->abilities[battlerId] = abilityId;
|
||||||
|
|
|
@ -589,7 +589,7 @@ static const u8 sText_SlowStartEnd[] = _("{B_ATK_NAME_WITH_PREFIX} finally got\n
|
||||||
static const u8 sText_SolarPowerHpDrop[] = _("The {B_ATK_NAME_WITH_PREFIX}'s {B_ATK_ABILITY}\ntakes its toll!");
|
static const u8 sText_SolarPowerHpDrop[] = _("The {B_ATK_NAME_WITH_PREFIX}'s {B_ATK_ABILITY}\ntakes its toll!");
|
||||||
static const u8 sText_AftermathDmg[] = _("{B_ATK_NAME_WITH_PREFIX} is hurt!");
|
static const u8 sText_AftermathDmg[] = _("{B_ATK_NAME_WITH_PREFIX} is hurt!");
|
||||||
static const u8 sText_AnticipationActivates[] = _("{B_ATK_NAME_WITH_PREFIX} shuddered\nin anticipation!");
|
static const u8 sText_AnticipationActivates[] = _("{B_ATK_NAME_WITH_PREFIX} shuddered\nin anticipation!");
|
||||||
static const u8 sText_ForewarnActivates[] = _("{B_ATK_ABILITY} alerted the {B_ATK_NAME_WITH_PREFIX} to the\n{B_DEF_NAME_WITH_PREFIX}'s {B_BUFF1}!");
|
static const u8 sText_ForewarnActivates[] = _("{B_ATK_ABILITY} alerted {B_ATK_NAME_WITH_PREFIX}\nto the{B_DEF_NAME_WITH_PREFIX}'s {B_BUFF1}!");
|
||||||
static const u8 sText_IceBodyHpGain[] = _("{B_ATK_NAME_WITH_PREFIX}'s {B_ATK_ABILITY}\nhealed it a little bit!");
|
static const u8 sText_IceBodyHpGain[] = _("{B_ATK_NAME_WITH_PREFIX}'s {B_ATK_ABILITY}\nhealed it a little bit!");
|
||||||
static const u8 sText_SnowWarningHail[] = _("It started to hail!");
|
static const u8 sText_SnowWarningHail[] = _("It started to hail!");
|
||||||
static const u8 sText_FriskActivates[] = _("{B_ATK_NAME_WITH_PREFIX} frisked {B_DEF_NAME_WITH_PREFIX} and\nfound its {B_LAST_ITEM}!");
|
static const u8 sText_FriskActivates[] = _("{B_ATK_NAME_WITH_PREFIX} frisked {B_DEF_NAME_WITH_PREFIX} and\nfound its {B_LAST_ITEM}!");
|
||||||
|
@ -1238,6 +1238,7 @@ const u16 gSwitchInAbilityStringIds[] =
|
||||||
{
|
{
|
||||||
STRINGID_MOLDBREAKERENTERS, STRINGID_TERAVOLTENTERS, STRINGID_TURBOBLAZEENTERS,
|
STRINGID_MOLDBREAKERENTERS, STRINGID_TERAVOLTENTERS, STRINGID_TURBOBLAZEENTERS,
|
||||||
STRINGID_SLOWSTARTENTERS, STRINGID_UNNERVEENTERS, STRINGID_ANTICIPATIONACTIVATES,
|
STRINGID_SLOWSTARTENTERS, STRINGID_UNNERVEENTERS, STRINGID_ANTICIPATIONACTIVATES,
|
||||||
|
STRINGID_FOREWARNACTIVATES
|
||||||
};
|
};
|
||||||
|
|
||||||
const u16 gMissStringIds[] =
|
const u16 gMissStringIds[] =
|
||||||
|
|
|
@ -16,6 +16,7 @@
|
||||||
#include "battle_ai_script_commands.h"
|
#include "battle_ai_script_commands.h"
|
||||||
#include "event_data.h"
|
#include "event_data.h"
|
||||||
#include "link.h"
|
#include "link.h"
|
||||||
|
#include "malloc.h"
|
||||||
#include "berry.h"
|
#include "berry.h"
|
||||||
#include "pokedex.h"
|
#include "pokedex.h"
|
||||||
#include "mail.h"
|
#include "mail.h"
|
||||||
|
@ -2786,6 +2787,64 @@ static bool32 ShouldChangeFormHpBased(u32 battler)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static u8 ForewarnChooseMove(u32 battler)
|
||||||
|
{
|
||||||
|
struct Forewarn {
|
||||||
|
u8 battlerId;
|
||||||
|
u8 power;
|
||||||
|
u16 moveId;
|
||||||
|
};
|
||||||
|
u32 i, j, bestId, count;
|
||||||
|
struct Forewarn *data = malloc(sizeof(struct Forewarn) * MAX_BATTLERS_COUNT * MAX_MON_MOVES);
|
||||||
|
|
||||||
|
// Put all moves
|
||||||
|
for (count = 0, i = 0; i < MAX_BATTLERS_COUNT; i++)
|
||||||
|
{
|
||||||
|
if (IsBattlerAlive(i) && GetBattlerSide(i) != GetBattlerSide(battler))
|
||||||
|
{
|
||||||
|
for (j = 0; j < MAX_MON_MOVES; j++)
|
||||||
|
{
|
||||||
|
if (gBattleMons[i].moves[j] == MOVE_NONE)
|
||||||
|
continue;
|
||||||
|
data[count].moveId = gBattleMons[i].moves[j];
|
||||||
|
data[count].battlerId = i;
|
||||||
|
switch (gBattleMoves[data[count].moveId].effect)
|
||||||
|
{
|
||||||
|
case EFFECT_OHKO:
|
||||||
|
data[count].power = 150;
|
||||||
|
break;
|
||||||
|
case EFFECT_COUNTER:
|
||||||
|
case EFFECT_MIRROR_COAT:
|
||||||
|
case EFFECT_METAL_BURST:
|
||||||
|
data[count].power = 120;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
if (gBattleMoves[data[count].moveId].power == 1)
|
||||||
|
data[count].power = 80;
|
||||||
|
else
|
||||||
|
data[count].power = gBattleMoves[data[count].moveId].power;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
count++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (bestId = 0, i = 1; i < count; i++)
|
||||||
|
{
|
||||||
|
if (data[i].power > data[bestId].power)
|
||||||
|
bestId = i;
|
||||||
|
else if (data[i].power == data[bestId].power && Random() & 1)
|
||||||
|
bestId = i;
|
||||||
|
}
|
||||||
|
|
||||||
|
gBattlerTarget = data[bestId].battlerId;
|
||||||
|
PREPARE_MOVE_BUFFER(gBattleTextBuff1, data[bestId].moveId)
|
||||||
|
RecordMoveBattle(gBattlerTarget, data[bestId].moveId);
|
||||||
|
|
||||||
|
free(data);
|
||||||
|
}
|
||||||
|
|
||||||
u8 AbilityBattleEffects(u8 caseID, u8 battler, u8 ability, u8 special, u16 moveArg)
|
u8 AbilityBattleEffects(u8 caseID, u8 battler, u8 ability, u8 special, u16 moveArg)
|
||||||
{
|
{
|
||||||
u8 effect = 0;
|
u8 effect = 0;
|
||||||
|
@ -2960,6 +3019,16 @@ u8 AbilityBattleEffects(u8 caseID, u8 battler, u8 ability, u8 special, u16 moveA
|
||||||
effect++;
|
effect++;
|
||||||
}
|
}
|
||||||
return effect; // Note: It returns effect as to not record the ability if Frisk does not activate.
|
return effect; // Note: It returns effect as to not record the ability if Frisk does not activate.
|
||||||
|
case ABILITY_FOREWARN:
|
||||||
|
if (!gSpecialStatuses[battler].switchInAbilityDone)
|
||||||
|
{
|
||||||
|
ForewarnChooseMove(battler);
|
||||||
|
gBattleCommunication[MULTISTRING_CHOOSER] = 6;
|
||||||
|
gSpecialStatuses[battler].switchInAbilityDone = 1;
|
||||||
|
BattleScriptPushCursorAndCallback(BattleScript_SwitchInAbilityMsg);
|
||||||
|
effect++;
|
||||||
|
}
|
||||||
|
break;
|
||||||
case ABILITY_DOWNLOAD:
|
case ABILITY_DOWNLOAD:
|
||||||
if (!gSpecialStatuses[battler].switchInAbilityDone)
|
if (!gSpecialStatuses[battler].switchInAbilityDone)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue