mirror of
https://github.com/Ninjdai1/pokeemerald.git
synced 2024-11-16 11:37:40 +01:00
Contest AI clean-up
This commit is contained in:
parent
c806992cfc
commit
92c4fc6345
@ -1,144 +0,0 @@
|
||||
.include "asm/macros.inc"
|
||||
.include "constants/constants.inc"
|
||||
|
||||
.section .rodata
|
||||
|
||||
.align 2
|
||||
gUnknown_085CDD00:: @ 85CDD00
|
||||
.4byte sub_81564DC
|
||||
.4byte sub_8156530
|
||||
.4byte sub_8156550
|
||||
.4byte sub_8156594
|
||||
.4byte sub_81565D8
|
||||
.4byte sub_815661C
|
||||
.4byte sub_8156660
|
||||
.4byte sub_8156684
|
||||
.4byte sub_81566C8
|
||||
.4byte sub_815670C
|
||||
.4byte sub_8156750
|
||||
.4byte sub_8156794
|
||||
.4byte sub_81567BC
|
||||
.4byte sub_8156800
|
||||
.4byte sub_8156844
|
||||
.4byte sub_8156888
|
||||
.4byte sub_81568CC
|
||||
.4byte sub_815690C
|
||||
.4byte sub_8156950
|
||||
.4byte sub_8156994
|
||||
.4byte sub_81569D8
|
||||
.4byte sub_8156A1C
|
||||
.4byte sub_8156A48
|
||||
.4byte sub_8156A98
|
||||
.4byte sub_8156AE8
|
||||
.4byte sub_8156B38
|
||||
.4byte sub_8156B88
|
||||
.4byte sub_8156BB4
|
||||
.4byte sub_8156C04
|
||||
.4byte sub_8156C54
|
||||
.4byte sub_8156CA4
|
||||
.4byte sub_8156CF4
|
||||
.4byte sub_8156D18
|
||||
.4byte sub_8156D5C
|
||||
.4byte sub_8156DA0
|
||||
.4byte sub_8156DE4
|
||||
.4byte sub_8156E2C
|
||||
.4byte sub_8156E74
|
||||
.4byte sub_8156EBC
|
||||
.4byte sub_8156F04
|
||||
.4byte sub_8156F44
|
||||
.4byte sub_8156F88
|
||||
.4byte sub_8156FCC
|
||||
.4byte sub_8157018
|
||||
.4byte sub_815705C
|
||||
.4byte sub_81570A0
|
||||
.4byte sub_815712C
|
||||
.4byte sub_8157174
|
||||
.4byte sub_8157200
|
||||
.4byte sub_8157248
|
||||
.4byte sub_81572A4
|
||||
.4byte sub_81572E8
|
||||
.4byte sub_815732C
|
||||
.4byte sub_8157370
|
||||
.4byte sub_81573B4
|
||||
.4byte sub_8157410
|
||||
.4byte sub_8157454
|
||||
.4byte sub_8157498
|
||||
.4byte sub_81574DC
|
||||
.4byte sub_8157520
|
||||
.4byte sub_8157578
|
||||
.4byte sub_81575BC
|
||||
.4byte sub_8157600
|
||||
.4byte sub_8157644
|
||||
.4byte sub_8157688
|
||||
.4byte sub_8157700
|
||||
.4byte sub_8157748
|
||||
.4byte sub_8157790
|
||||
.4byte sub_8157808
|
||||
.4byte sub_8157850
|
||||
.4byte sub_8157898
|
||||
.4byte sub_81578F8
|
||||
.4byte sub_8157940
|
||||
.4byte sub_8157988
|
||||
.4byte sub_81579CC
|
||||
.4byte sub_8157A10
|
||||
.4byte sub_8157A54
|
||||
.4byte sub_8157A98
|
||||
.4byte sub_8157ADC
|
||||
.4byte sub_8157B38
|
||||
.4byte sub_8157B7C
|
||||
.4byte sub_8157BC0
|
||||
.4byte sub_8157C04
|
||||
.4byte sub_8157C48
|
||||
.4byte sub_8157C94
|
||||
.4byte sub_8157CDC
|
||||
.4byte sub_8157D24
|
||||
.4byte sub_8157D60
|
||||
.4byte sub_8157DA8
|
||||
.4byte sub_8157DF0
|
||||
.4byte sub_8157E3C
|
||||
.4byte sub_8157E84
|
||||
.4byte sub_8157ECC
|
||||
.4byte sub_8157F14
|
||||
.4byte sub_8157F5C
|
||||
.4byte sub_8157FA0
|
||||
.4byte sub_8157FE8
|
||||
.4byte sub_8158030
|
||||
.4byte sub_8158078
|
||||
.4byte sub_81580C0
|
||||
.4byte sub_8158108
|
||||
.4byte sub_815814C
|
||||
.4byte sub_8158190
|
||||
.4byte sub_81581D4
|
||||
.4byte sub_8158218
|
||||
.4byte sub_8158254
|
||||
.4byte sub_8158298
|
||||
.4byte sub_81582DC
|
||||
.4byte sub_8158320
|
||||
.4byte sub_8158364
|
||||
.4byte sub_81583B8
|
||||
.4byte sub_81583FC
|
||||
.4byte sub_8158440
|
||||
.4byte sub_815846C
|
||||
.4byte sub_815849C
|
||||
.4byte sub_81584D4
|
||||
.4byte sub_8158508
|
||||
.4byte sub_815853C
|
||||
.4byte sub_815858C
|
||||
.4byte sub_81585DC
|
||||
.4byte sub_815862C
|
||||
.4byte sub_815867C
|
||||
.4byte sub_81586D0
|
||||
.4byte sub_8158724
|
||||
.4byte sub_8158778
|
||||
.4byte sub_81587CC
|
||||
.4byte sub_815881C
|
||||
.4byte sub_815886C
|
||||
.4byte dp15_call
|
||||
.4byte sub_81588BC
|
||||
.4byte sub_8158948
|
||||
.4byte sub_81589A4
|
||||
.4byte sub_81589EC
|
||||
.4byte sub_8158A34
|
||||
.4byte sub_8158AA0
|
||||
.4byte sub_8158AE8
|
||||
|
@ -341,7 +341,8 @@ struct UnknownContestStruct7
|
||||
u8 contestant;
|
||||
};
|
||||
|
||||
struct ContestAIInfo {
|
||||
struct ContestAIInfo
|
||||
{
|
||||
/*0x00*/ u8 aiState;
|
||||
/*0x02*/ u16 unk2;
|
||||
/*0x04*/ u8 unk4;
|
||||
@ -352,9 +353,9 @@ struct ContestAIInfo {
|
||||
/*0x14*/ u32 flags;
|
||||
/*0x18*/ s16 scriptResult;
|
||||
/*0x1A*/ s16 scriptArr[3];
|
||||
/*0x20*/ u32 stack[8];
|
||||
/*0x40*/ u8 unk40;
|
||||
/*0x41*/ u8 unk41;
|
||||
/*0x20*/ const u8 *stack[8];
|
||||
/*0x40*/ u8 stackSize;
|
||||
/*0x41*/ u8 contestantId;
|
||||
};
|
||||
|
||||
struct UnknownContestStruct5
|
||||
|
@ -203,7 +203,7 @@ SECTIONS {
|
||||
src/save.o(.text);
|
||||
src/mystery_event_script.o(.text);
|
||||
asm/field_effect_helpers.o(.text);
|
||||
asm/contest_ai.o(.text);
|
||||
src/contest_ai.o(.text);
|
||||
src/battle_anim_sound_tasks.o(.text);
|
||||
src/battle_controller_safari.o(.text);
|
||||
src/fldeff_sweetscent.o(.text);
|
||||
@ -488,7 +488,7 @@ SECTIONS {
|
||||
data/cable_car.o(.rodata);
|
||||
src/save.o(.rodata);
|
||||
data/field_effect_helpers.o(.rodata);
|
||||
data/contest_ai.o(.rodata);
|
||||
src/contest_ai.o(.rodata);
|
||||
src/battle_controller_safari.o(.rodata);
|
||||
data/battle_anim_815A0D4.o(.rodata);
|
||||
src/learn_move.o(.rodata);
|
||||
|
102
src/contest_ai.c
102
src/contest_ai.c
@ -4,7 +4,6 @@
|
||||
#include "contest_ai.h"
|
||||
#include "contest_effect.h"
|
||||
|
||||
extern u16 gSpecialVar_ContestCategory;
|
||||
extern u16 gContestMonConditions[];
|
||||
|
||||
extern const u8 *gAIScriptPtr;
|
||||
@ -294,22 +293,22 @@ static bool8 sub_81563B0(u8);
|
||||
static void AIStackPushVar(const u8 *);
|
||||
static u8 AIStackPop(void);
|
||||
|
||||
void ContestAI_ResetAI(u8 var)
|
||||
void ContestAI_ResetAI(u8 contestantAI)
|
||||
{
|
||||
int i;
|
||||
memset(eContestAI, 0, sizeof(struct ContestAIInfo));
|
||||
|
||||
for(i = 0; i < 4; i++)
|
||||
for (i = 0; i < 4; i++)
|
||||
eContestAI->unk5[i] = 100;
|
||||
|
||||
eContestAI->unk41 = var;
|
||||
eContestAI->unk40 = 0;
|
||||
eContestAI->flags = gContestMons[eContestAI->unk41].flags;
|
||||
eContestAI->contestantId = contestantAI;
|
||||
eContestAI->stackSize = 0;
|
||||
eContestAI->flags = gContestMons[eContestAI->contestantId].flags;
|
||||
}
|
||||
|
||||
u8 ContestAI_GetActionToUse(void)
|
||||
{
|
||||
while(eContestAI->flags != 0)
|
||||
while (eContestAI->flags != 0)
|
||||
{
|
||||
if (eContestAI->flags & 1)
|
||||
{
|
||||
@ -338,7 +337,7 @@ u8 ContestAI_GetActionToUse(void)
|
||||
|
||||
static void ContestAI_DoAIProcessing(void)
|
||||
{
|
||||
while(eContestAI->aiState != CONTESTAI_FINISHED)
|
||||
while (eContestAI->aiState != CONTESTAI_FINISHED)
|
||||
{
|
||||
switch(eContestAI->aiState)
|
||||
{
|
||||
@ -347,10 +346,10 @@ static void ContestAI_DoAIProcessing(void)
|
||||
case CONTESTAI_SETTING_UP:
|
||||
gAIScriptPtr = gContestAIs[eContestAI->unk10];
|
||||
|
||||
if (gContestMons[eContestAI->unk41].moves[eContestAI->unk4] == 0)
|
||||
if (gContestMons[eContestAI->contestantId].moves[eContestAI->unk4] == 0)
|
||||
eContestAI->unk2 = 0; // don't process a move that doesn't exist.
|
||||
else
|
||||
eContestAI->unk2 = gContestMons[eContestAI->unk41].moves[eContestAI->unk4];
|
||||
eContestAI->unk2 = gContestMons[eContestAI->contestantId].moves[eContestAI->unk4];
|
||||
eContestAI->aiState++;
|
||||
break;
|
||||
case CONTESTAI_PROCESSING:
|
||||
@ -379,7 +378,7 @@ static u8 sub_81563B0(u8 var)
|
||||
{
|
||||
int i;
|
||||
|
||||
for(i = 0; i < 4; i++)
|
||||
for (i = 0; i < 4; i++)
|
||||
if (shared192D0.turnOrder[i] == var)
|
||||
break;
|
||||
|
||||
@ -494,7 +493,7 @@ static void ContestAICmd_unk_0A(void)
|
||||
|
||||
static void ContestAICmd_get_user_order(void)
|
||||
{
|
||||
eContestAI->scriptResult = shared192D0.turnOrder[eContestAI->unk41];
|
||||
eContestAI->scriptResult = shared192D0.turnOrder[eContestAI->contestantId];
|
||||
gAIScriptPtr += 1;
|
||||
}
|
||||
|
||||
@ -540,7 +539,7 @@ static void ContestAICmd_unk_0F(void)
|
||||
|
||||
static void ContestAICmd_get_user_condition_maybe(void)
|
||||
{
|
||||
eContestAI->scriptResult = sContestantStatus[eContestAI->unk41].condition / 10;
|
||||
eContestAI->scriptResult = sContestantStatus[eContestAI->contestantId].condition / 10;
|
||||
gAIScriptPtr += 1;
|
||||
}
|
||||
|
||||
@ -586,7 +585,7 @@ static void ContestAICmd_unk_14(void)
|
||||
|
||||
static void ContestAICmd_unk_15(void)
|
||||
{
|
||||
eContestAI->scriptResult = sContestantStatus[eContestAI->unk41].unk4;
|
||||
eContestAI->scriptResult = sContestantStatus[eContestAI->contestantId].unk4;
|
||||
gAIScriptPtr += 1;
|
||||
}
|
||||
|
||||
@ -632,7 +631,7 @@ static void ContestAICmd_unk_19(void)
|
||||
|
||||
static void ContestAICmd_unk_1A(void)
|
||||
{
|
||||
eContestAI->scriptResult = gContestMonConditions[eContestAI->unk41];
|
||||
eContestAI->scriptResult = gContestMonConditions[eContestAI->contestantId];
|
||||
gAIScriptPtr += 1;
|
||||
}
|
||||
|
||||
@ -704,7 +703,7 @@ static void ContestAICmd_unk_21(void)
|
||||
|
||||
static void ContestAICmd_get_move_excitement(void)
|
||||
{
|
||||
eContestAI->scriptResult = Contest_GetMoveExcitement(gContestMons[eContestAI->unk41].moves[eContestAI->unk4]);
|
||||
eContestAI->scriptResult = Contest_GetMoveExcitement(gContestMons[eContestAI->contestantId].moves[eContestAI->unk4]);
|
||||
gAIScriptPtr += 1;
|
||||
}
|
||||
|
||||
@ -750,7 +749,7 @@ static void ContestAICmd_unk_26(void)
|
||||
|
||||
static void ContestAICmd_get_move_effect(void)
|
||||
{
|
||||
u16 move = gContestMons[eContestAI->unk41].moves[eContestAI->unk4];
|
||||
u16 move = gContestMons[eContestAI->contestantId].moves[eContestAI->unk4];
|
||||
|
||||
eContestAI->scriptResult = gContestMoves[move].effect;
|
||||
gAIScriptPtr += 1;
|
||||
@ -778,7 +777,7 @@ static void ContestAICmd_unk_29(void)
|
||||
|
||||
static void ContestAICmd_get_move_effect_type(void)
|
||||
{
|
||||
u16 move = gContestMons[eContestAI->unk41].moves[eContestAI->unk4];
|
||||
u16 move = gContestMons[eContestAI->contestantId].moves[eContestAI->unk4];
|
||||
|
||||
eContestAI->scriptResult = gContestEffects[gContestMoves[move].effect].effectType;
|
||||
gAIScriptPtr += 1;
|
||||
@ -807,12 +806,12 @@ static void ContestAICmd_unk_2C(void)
|
||||
static void ContestAICmd_check_move_has_highest_appeal(void)
|
||||
{
|
||||
int i;
|
||||
u16 move = gContestMons[eContestAI->unk41].moves[eContestAI->unk4];
|
||||
u16 move = gContestMons[eContestAI->contestantId].moves[eContestAI->unk4];
|
||||
u8 appeal = gContestEffects[gContestMoves[move].effect].appeal;
|
||||
|
||||
for(i = 0; i < 4; i++)
|
||||
for (i = 0; i < 4; i++)
|
||||
{
|
||||
u16 newMove = gContestMons[eContestAI->unk41].moves[i];
|
||||
u16 newMove = gContestMons[eContestAI->contestantId].moves[i];
|
||||
if (newMove != 0 && appeal < gContestEffects[gContestMoves[newMove].effect].appeal)
|
||||
break;
|
||||
}
|
||||
@ -838,12 +837,12 @@ static void ContestAICmd_unk_2E(void)
|
||||
static void ContestAICmd_unk_2F(void)
|
||||
{
|
||||
int i;
|
||||
u16 move = gContestMons[eContestAI->unk41].moves[eContestAI->unk4];
|
||||
u16 move = gContestMons[eContestAI->contestantId].moves[eContestAI->unk4];
|
||||
u8 jam = gContestEffects[gContestMoves[move].effect].jam;
|
||||
|
||||
for(i = 0; i < 4; i++)
|
||||
for (i = 0; i < 4; i++)
|
||||
{
|
||||
u16 newMove = gContestMons[eContestAI->unk41].moves[i];
|
||||
u16 newMove = gContestMons[eContestAI->contestantId].moves[i];
|
||||
if (newMove != 0 && jam < gContestEffects[gContestMoves[newMove].effect].jam)
|
||||
break;
|
||||
}
|
||||
@ -868,7 +867,7 @@ static void ContestAICmd_unk_30(void)
|
||||
|
||||
static void ContestAICmd_unk_31(void)
|
||||
{
|
||||
u16 move = gContestMons[eContestAI->unk41].moves[eContestAI->unk4];
|
||||
u16 move = gContestMons[eContestAI->contestantId].moves[eContestAI->unk4];
|
||||
|
||||
eContestAI->scriptResult = gContestEffects[gContestMoves[move].effect].appeal / 10;
|
||||
gAIScriptPtr += 1;
|
||||
@ -916,7 +915,7 @@ static void ContestAICmd_unk_35(void)
|
||||
|
||||
static void ContestAICmd_unk_36(void)
|
||||
{
|
||||
u16 move = gContestMons[eContestAI->unk41].moves[eContestAI->unk4];
|
||||
u16 move = gContestMons[eContestAI->contestantId].moves[eContestAI->unk4];
|
||||
|
||||
eContestAI->scriptResult = gContestEffects[gContestMoves[move].effect].jam / 10;
|
||||
gAIScriptPtr += 1;
|
||||
@ -965,12 +964,12 @@ static void ContestAICmd_unk_3A(void)
|
||||
static void ContestAICmd_get_move_used_count(void)
|
||||
{
|
||||
s16 result;
|
||||
u16 move = gContestMons[eContestAI->unk41].moves[eContestAI->unk4];
|
||||
u16 move = gContestMons[eContestAI->contestantId].moves[eContestAI->unk4];
|
||||
|
||||
if (move != sContestantStatus[eContestAI->unk41].prevMove)
|
||||
if (move != sContestantStatus[eContestAI->contestantId].prevMove)
|
||||
result = 0; // move is unique and not reused.
|
||||
else
|
||||
result = sContestantStatus[eContestAI->unk41].moveRepeatCount + 1;
|
||||
result = sContestantStatus[eContestAI->contestantId].moveRepeatCount + 1;
|
||||
|
||||
eContestAI->scriptResult = result;
|
||||
gAIScriptPtr += 1;
|
||||
@ -1020,13 +1019,13 @@ static void ContestAICmd_check_combo_starter(void)
|
||||
{
|
||||
u8 result = 0;
|
||||
int i;
|
||||
u16 move = gContestMons[eContestAI->unk41].moves[eContestAI->unk4];
|
||||
u16 move = gContestMons[eContestAI->contestantId].moves[eContestAI->unk4];
|
||||
|
||||
for(i = 0; i < 4; i++)
|
||||
for (i = 0; i < 4; i++)
|
||||
{
|
||||
if (gContestMons[eContestAI->unk41].moves[i])
|
||||
if (gContestMons[eContestAI->contestantId].moves[i])
|
||||
{
|
||||
result = AreMovesContestCombo(move, gContestMons[eContestAI->unk41].moves[i]);
|
||||
result = AreMovesContestCombo(move, gContestMons[eContestAI->contestantId].moves[i]);
|
||||
if (result)
|
||||
{
|
||||
result = 1;
|
||||
@ -1066,13 +1065,13 @@ static void ContestAICmd_check_combo_finisher(void)
|
||||
{
|
||||
u8 result = 0;
|
||||
int i;
|
||||
u16 move = gContestMons[eContestAI->unk41].moves[eContestAI->unk4];
|
||||
u16 move = gContestMons[eContestAI->contestantId].moves[eContestAI->unk4];
|
||||
|
||||
for(i = 0; i < 4; i++)
|
||||
for (i = 0; i < 4; i++)
|
||||
{
|
||||
if (gContestMons[eContestAI->unk41].moves[i])
|
||||
if (gContestMons[eContestAI->contestantId].moves[i])
|
||||
{
|
||||
result = AreMovesContestCombo(gContestMons[eContestAI->unk41].moves[i], move);
|
||||
result = AreMovesContestCombo(gContestMons[eContestAI->contestantId].moves[i], move);
|
||||
if (result)
|
||||
{
|
||||
result = 1;
|
||||
@ -1111,10 +1110,10 @@ static void ContestAICmd_unk_45(void)
|
||||
static void ContestAICmd_check_would_finish_combo(void)
|
||||
{
|
||||
u8 result = 0;
|
||||
u16 move = gContestMons[eContestAI->unk41].moves[eContestAI->unk4];
|
||||
u16 move = gContestMons[eContestAI->contestantId].moves[eContestAI->unk4];
|
||||
|
||||
if (sContestantStatus[eContestAI->unk41].prevMove)
|
||||
result = AreMovesContestCombo(sContestantStatus[eContestAI->unk41].prevMove, move);
|
||||
if (sContestantStatus[eContestAI->contestantId].prevMove)
|
||||
result = AreMovesContestCombo(sContestantStatus[eContestAI->contestantId].prevMove, move);
|
||||
|
||||
if (result)
|
||||
result = 1;
|
||||
@ -1305,7 +1304,7 @@ static void ContestAICmd_unk_59(void)
|
||||
{
|
||||
u8 var = sub_81563B0(gAIScriptPtr[1]);
|
||||
|
||||
eContestAI->scriptResult = sContestantStatus[var].unk4 - sContestantStatus[eContestAI->unk41].unk4;
|
||||
eContestAI->scriptResult = sContestantStatus[var].unk4 - sContestantStatus[eContestAI->contestantId].unk4;
|
||||
gAIScriptPtr += 2;
|
||||
}
|
||||
|
||||
@ -1353,7 +1352,7 @@ static void ContestAICmd_unk_5E(void)
|
||||
{
|
||||
u8 var = sub_81563B0(gAIScriptPtr[1]);
|
||||
|
||||
eContestAI->scriptResult = gContestMonConditions[var] - gContestMonConditions[eContestAI->unk41];
|
||||
eContestAI->scriptResult = gContestMonConditions[var] - gContestMonConditions[eContestAI->contestantId];
|
||||
gAIScriptPtr += 2;
|
||||
}
|
||||
|
||||
@ -1658,15 +1657,15 @@ static void ContestAICmd_unk_81(void)
|
||||
|
||||
static void AIStackPushVar(const u8 *ptr)
|
||||
{
|
||||
eContestAI->stack[eContestAI->unk40++] = (u32)ptr;
|
||||
eContestAI->stack[eContestAI->stackSize++] = ptr;
|
||||
}
|
||||
|
||||
static bool8 AIStackPop(void)
|
||||
{
|
||||
if (eContestAI->unk40 != 0)
|
||||
if (eContestAI->stackSize != 0)
|
||||
{
|
||||
--eContestAI->unk40;
|
||||
gAIScriptPtr = (u8 *)eContestAI->stack[eContestAI->unk40];
|
||||
--eContestAI->stackSize;
|
||||
gAIScriptPtr = eContestAI->stack[eContestAI->stackSize];
|
||||
return TRUE;
|
||||
}
|
||||
else
|
||||
@ -1680,12 +1679,11 @@ static void ContestAICmd_check_for_exciting_move(void)
|
||||
int result = 0;
|
||||
int i;
|
||||
|
||||
for(i = 0; i < 4; i++)
|
||||
for (i = 0; i < 4; i++)
|
||||
{
|
||||
if (gContestMons[eContestAI->unk41].moves[i])
|
||||
if (gContestMons[eContestAI->contestantId].moves[i])
|
||||
{
|
||||
// why is it using gSharedMem + 0x19325? that does not exist...
|
||||
if (Contest_GetMoveExcitement(gContestMons[eContestAI->unk41].moves[i]) == 1)
|
||||
if (Contest_GetMoveExcitement(gContestMons[eContestAI->contestantId].moves[i]) == 1)
|
||||
{
|
||||
result = 1;
|
||||
break;
|
||||
@ -1723,9 +1721,9 @@ static void ContestAICmd_unk_85(void)
|
||||
int i;
|
||||
u16 arg = T1_READ_16(gAIScriptPtr + 1);
|
||||
|
||||
for(i = 0; i < 4; i++)
|
||||
for (i = 0; i < 4; i++)
|
||||
{
|
||||
u16 move = gContestMons[eContestAI->unk41].moves[i];
|
||||
u16 move = gContestMons[eContestAI->contestantId].moves[i];
|
||||
if (move == arg)
|
||||
{
|
||||
result = 1;
|
||||
|
Loading…
Reference in New Issue
Block a user