AI takes split into account, debug view ai move points

This commit is contained in:
DizzyEggg 2019-02-09 13:21:32 +01:00
parent 413cf4f0ae
commit 691544fa0b
4 changed files with 98 additions and 2 deletions

View File

@ -594,7 +594,37 @@
.4byte \ptr
.endm
.macro if_has_move_with_split battler:req, split:req, ptr:req
.byte 0x69
.byte \battler
.byte \split
.4byte \ptr
.endm
.macro if_has_no_move_with_split battler:req, split:req, ptr:req
.byte 0x6A
.byte \battler
.byte \split
.4byte \ptr
.endm
@ useful script macros
.macro if_has_physical_move battler:req, ptr:req
if_has_move_with_split \battler, SPLIT_PHYSICAL, \ptr
.endm
.macro if_has_no_physical_move battler:req, ptr:req
if_has_no_move_with_split \battler, SPLIT_PHYSICAL, \ptr
.endm
.macro if_has_special_move battler:req, ptr:req
if_has_move_with_split \battler, SPLIT_SPECIAL, \ptr
.endm
.macro if_has_no_special_move battler:req, ptr:req
if_has_no_move_with_split \battler, SPLIT_SPECIAL, \ptr
.endm
.macro if_holds_no_item battler, ptr:req
if_holds_item \battler, 0, \ptr
.endm

View File

@ -474,6 +474,9 @@ AI_CBM_BellyDrum: @ 82DC341
AI_CBM_AttackUp: @ 82DC348
if_stat_level_equal AI_USER, STAT_ATK, 12, Score_Minus10
@ Do not raise attack if has no physical moves
if_has_move_with_effect AI_USER, EFFECT_BATON_PASS, AI_Ret
if_has_no_physical_move AI_USER, Score_Minus10
end
AI_CBM_DefenseUp: @ 82DC351
@ -486,6 +489,9 @@ AI_CBM_SpeedUp: @ 82DC35A
AI_CBM_SpAtkUp: @ 82DC363
if_stat_level_equal AI_USER, STAT_SPATK, 12, Score_Minus10
@ Do not raise sp. attack if has no special moves
if_has_move_with_effect AI_USER, EFFECT_BATON_PASS, AI_Ret
if_has_no_special_move AI_USER, Score_Minus10
end
AI_CBM_SpDefUp: @ 82DC36C
@ -3365,6 +3371,7 @@ AI_TryHelpingHandOnAlly:
goto Score_Plus2
AI_TrySwaggerOnAlly:
if_has_no_physical_move AI_USER_PARTNER, Score_Minus30
if_holds_item AI_TARGET, ITEM_PERSIM_BERRY, AI_TrySwaggerOnAlly2
if_ability AI_USER_PARTNER, ABILITY_OWN_TEMPO, AI_TrySwaggerOnAlly2
goto Score_Minus30

View File

@ -158,6 +158,8 @@ static void BattleAICmd_get_hazards_count(void);
static void BattleAICmd_if_doesnt_hold_berry(void);
static void BattleAICmd_if_share_type(void);
static void BattleAICmd_if_cant_use_last_resort(void);
static void BattleAICmd_if_has_move_with_split(void);
static void BattleAICmd_if_has_no_move_with_split(void);
// ewram
EWRAM_DATA const u8 *gAIScriptPtr = NULL;
@ -273,6 +275,8 @@ static const BattleAICmdFunc sBattleAICmdTable[] =
BattleAICmd_if_doesnt_hold_berry, // 0x66
BattleAICmd_if_share_type, // 0x67
BattleAICmd_if_cant_use_last_resort, // 0x68
BattleAICmd_if_has_move_with_split, // 0x69
BattleAICmd_if_has_no_move_with_split, // 0x6A
};
static const u16 sDiscouragedPowerfulMoveEffects[] =
@ -635,7 +639,7 @@ static void RecordLastUsedMoveByTarget(void)
}
}
static bool8 IsBattlerAIControlled(u8 battlerId)
static bool32 IsBattlerAIControlled(u32 battlerId)
{
switch (GetBattlerPosition(battlerId))
{
@ -2542,3 +2546,38 @@ static void BattleAICmd_if_cant_use_last_resort(void)
else
gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 2);
}
static bool32 HasMoveWithSplit(u32 battler, u32 split)
{
s32 i;
u16 *moves;
if (IsBattlerAIControlled(battler) || IsBattlerAIControlled(BATTLE_PARTNER(battler)))
moves = gBattleMons[battler].moves;
else
moves = gBattleResources->battleHistory->usedMoves[battler].moves;
for (i = 0; i < MAX_MON_MOVES; i++)
{
if (moves[i] != MOVE_NONE && moves[i] != 0xFFFF && gBattleMoves[moves[i]].split == split)
return TRUE;
}
return FALSE;
}
static void BattleAICmd_if_has_move_with_split(void)
{
if (HasMoveWithSplit(BattleAI_GetWantedBattler(gAIScriptPtr[1]), gAIScriptPtr[2]))
gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 3);
else
gAIScriptPtr += 7;
}
static void BattleAICmd_if_has_no_move_with_split(void)
{
if (!HasMoveWithSplit(BattleAI_GetWantedBattler(gAIScriptPtr[1]), gAIScriptPtr[2]))
gAIScriptPtr = T1_READ_PTR(gAIScriptPtr + 3);
else
gAIScriptPtr += 7;
}

View File

@ -35,7 +35,7 @@ struct BattleDebugModifyArrows
u8 arrowSpriteId[2];
u16 minValue;
u16 maxValue;
u16 currValue;
int currValue;
u8 currentDigit;
u8 maxDigits;
u8 charDigits[MAX_MODIFY_DIGITS];
@ -86,6 +86,7 @@ enum
LIST_ITEM_STATUS3,
LIST_ITEM_SIDE_STATUS,
LIST_ITEM_AI,
LIST_ITEM_AI_MOVES_PTS,
LIST_ITEM_VARIOUS,
LIST_ITEM_COUNT
};
@ -110,6 +111,7 @@ enum
VAR_SUBSTITUTE,
VAR_IN_LOVE,
VAR_U16_4_ENTRIES,
VAL_S8,
};
enum
@ -206,6 +208,7 @@ static const u8 sText_InDoubles[] = _("In Doubles");
static const u8 sText_HpAware[] = _("HP aware");
static const u8 sText_Unknown[] = _("Unknown");
static const u8 sText_InLove[] = _("In Love");
static const u8 sText_AIMovePts[] = _("AI Move Pts");
static const u8 sText_EmptyString[] = _("");
@ -301,6 +304,7 @@ static const struct ListMenuItem sMainListItems[] =
{sText_Status3, LIST_ITEM_STATUS3},
{sText_SideStatus, LIST_ITEM_SIDE_STATUS},
{sText_AI, LIST_ITEM_AI},
{sText_AIMovePts, LIST_ITEM_AI_MOVES_PTS},
{sText_Various, LIST_ITEM_VARIOUS},
};
@ -539,6 +543,7 @@ static const u8 sBitsToMaxDigit[] =
static const bool8 sHasChangeableEntries[LIST_ITEM_COUNT] =
{
[LIST_ITEM_MOVES] = TRUE,
[LIST_ITEM_AI_MOVES_PTS] = TRUE,
[LIST_ITEM_PP] = TRUE,
[LIST_ITEM_ABILITY] = TRUE,
[LIST_ITEM_TYPES] = TRUE,
@ -897,6 +902,9 @@ static void CreateSecondaryListMenu(struct BattleDebugMenu *data)
listTemplate.items = sSideStatusListItems;
itemsCount = ARRAY_COUNT(sSideStatusListItems);
break;
case LIST_ITEM_AI_MOVES_PTS:
itemsCount = 4;
break;
}
data->secondaryListItemCount = itemsCount;
@ -955,6 +963,7 @@ static void PrintSecondaryEntries(struct BattleDebugMenu *data)
{
case LIST_ITEM_MOVES:
case LIST_ITEM_PP:
case LIST_ITEM_AI_MOVES_PTS:
for (i = 0; i < 4; i++)
{
PadString(gMoveNames[gBattleMons[data->battlerId].moves[i]], text);
@ -1061,6 +1070,9 @@ static void UpdateBattlerValue(struct BattleDebugMenu *data)
case VAL_U8:
*(u8*)(data->modifyArrows.modifiedValPtr) = data->modifyArrows.currValue;
break;
case VAL_S8:
*(s8*)(data->modifyArrows.modifiedValPtr) = data->modifyArrows.currValue;
break;
case VAL_U16:
*(u16*)(data->modifyArrows.modifiedValPtr) = data->modifyArrows.currValue;
break;
@ -1312,6 +1324,14 @@ static void SetUpModifyArrows(struct BattleDebugMenu *data)
data->modifyArrows.typeOfVal = VAL_U8;
data->modifyArrows.currValue = gBattleMons[data->battlerId].pp[data->currentSecondaryListItemId];
break;
case LIST_ITEM_AI_MOVES_PTS:
data->modifyArrows.minValue = 0;
data->modifyArrows.maxValue = 255;
data->modifyArrows.maxDigits = 3;
data->modifyArrows.modifiedValPtr = &gBattleResources->ai->score;
data->modifyArrows.typeOfVal = VAL_S8;
data->modifyArrows.currValue = gBattleResources->ai->score[data->currentSecondaryListItemId];
break;
case LIST_ITEM_HELD_ITEM:
data->modifyArrows.minValue = 0;
data->modifyArrows.maxValue = ITEMS_COUNT - 1;