Decompile botChooseGeneralTarget

This commit is contained in:
Ryan Dwyer 2021-12-26 20:38:43 +10:00
parent 805551e5cd
commit cb6d6e1e2c
8 changed files with 315 additions and 1005 deletions

File diff suppressed because it is too large Load Diff

View File

@ -44,7 +44,7 @@ void botcmdTickDistMode(struct chrdata *chr)
struct aibot *aibot = chr->aibot;
s32 prevmode = aibot->distmode;
struct prop *targetprop = NULL;
s32 somevalue = 0;
bool insight = false;
f32 minattackdistance;
f32 maxattackdistance;
f32 limit3;
@ -59,7 +59,7 @@ void botcmdTickDistMode(struct chrdata *chr)
if (chr->myaction == MA_AIBOTFOLLOW && aibot->followingplayernum >= 0) {
limits = g_BotDistConfigs[BOTDISTCFG_FOLLOW];
targetprop = g_MpAllChrPtrs[aibot->followingplayernum]->prop;
somevalue = aibot->unk16c[aibot->followingplayernum];
insight = aibot->chrsinsight[aibot->followingplayernum];
if (chr->target != -1 && (confignum == BOTDISTCFG_CLOSE || confignum == BOTDISTCFG_KAZE)) {
struct prop *target = chrGetTargetProp(chr);
@ -70,7 +70,7 @@ void botcmdTickDistMode(struct chrdata *chr)
if (xdiff * xdiff + ydiff * ydiff + zdiff * zdiff < 500 * 500) {
limits = g_BotDistConfigs[confignum];
targetprop = target;
somevalue = aibot->unk128;
insight = aibot->targetinsight;
}
}
} else {
@ -78,10 +78,10 @@ void botcmdTickDistMode(struct chrdata *chr)
if (chr->myaction == MA_AIBOTATTACK && aibot->attackingplayernum >= 0) {
targetprop = g_MpAllChrPtrs[aibot->attackingplayernum]->prop;
somevalue = aibot->unk16c[aibot->attackingplayernum];
insight = aibot->chrsinsight[aibot->attackingplayernum];
} else if (chr->target != -1) {
targetprop = chrGetTargetProp(chr);
somevalue = aibot->unk128;
insight = aibot->targetinsight;
}
}
@ -125,17 +125,17 @@ void botcmdTickDistMode(struct chrdata *chr)
}
#if VERSION >= VERSION_NTSC_1_0
if (newmode != BOTDISTMODE_BACKUP || somevalue == 0 || aibot->unk050 != targetprop) {
if (newmode != BOTDISTMODE_BACKUP || !insight || aibot->unk050 != targetprop) {
aibot->unk050 = NULL;
aibot->unk09d = 0;
}
if (newmode == BOTDISTMODE_OK) {
if (somevalue == 0) {
if (!insight) {
newmode = BOTDISTMODE_ADVANCE;
}
} else if (newmode == BOTDISTMODE_BACKUP) {
if (somevalue == 0) {
if (!insight) {
newmode = BOTDISTMODE_ADVANCE;
aibot->unk050 = targetprop;
aibot->unk09d = PALDOWN(20) + (random() % PALDOWN(120));
@ -150,7 +150,7 @@ void botcmdTickDistMode(struct chrdata *chr)
}
}
#else
if (newmode == BOTDISTMODE_OK && somevalue == 0) {
if (newmode == BOTDISTMODE_OK && !insight) {
newmode = BOTDISTMODE_ADVANCE;
}
#endif

View File

@ -628,7 +628,7 @@ void botinvScoreWeapon(struct chrdata *chr, s32 weaponnum, s32 funcnum, s32 arg3
if (chr->aibot->config->difficulty > BOTDIFF_MEAT) {
if (comparewithtarget) {
if (chr->target != -1
&& chr->aibot->unk16c[mpPlayerGetIndex(chrGetTargetProp(chr)->chr)] == 0
&& chr->aibot->chrsinsight[mpPlayerGetIndex(chrGetTargetProp(chr)->chr)] == 0
&& (chr->aibot->rand % 2) == 0) {
score1 += 10;
} else {
@ -645,7 +645,7 @@ void botinvScoreWeapon(struct chrdata *chr, s32 weaponnum, s32 funcnum, s32 arg3
if (chr->aibot->config->difficulty >= BOTDIFF_NORMAL) {
if (comparewithtarget) {
if (chr->target != -1
&& chr->aibot->unk16c[mpPlayerGetIndex(chrGetTargetProp(chr)->chr)] == 0
&& chr->aibot->chrsinsight[mpPlayerGetIndex(chrGetTargetProp(chr)->chr)] == 0
&& (chr->aibot->rand % 2) == 0) {
score1 = 178;
score2 = 188;
@ -978,8 +978,8 @@ void botinvTick(struct chrdata *chr)
if (newweaponnum == WEAPON_COMBATKNIFE
&& botactGetAmmoQuantityByWeapon(aibot, WEAPON_COMBATKNIFE, FUNC_SECONDARY, true) >= 2
&& chr->target != -1
&& chr->aibot->playerdistances[mpPlayerGetIndex(chrGetTargetProp(chr)->chr)] > 200
&& chr->aibot->playerdistances[mpPlayerGetIndex(chrGetTargetProp(chr)->chr)] < 1500) {
&& chr->aibot->chrdistances[mpPlayerGetIndex(chrGetTargetProp(chr)->chr)] > 200
&& chr->aibot->chrdistances[mpPlayerGetIndex(chrGetTargetProp(chr)->chr)] < 1500) {
newfuncnum = FUNC_SECONDARY;
}

View File

@ -211,18 +211,18 @@ void botmgrAllocateBot(s32 chrnum, s32 aibotnum)
aibot->shotspeed.y = 0.0f;
aibot->shotspeed.z = 0.0f;
aibot->unk118 = 0;
aibot->unk11c = 0;
aibot->unk120 = -1;
aibot->unk124 = -1;
aibot->unk128 = 0;
aibot->unk12c = 0;
aibot->targethotness = 0;
aibot->targetlastseen60 = -1;
aibot->lastseenanytarget60 = -1;
aibot->targetinsight = false;
aibot->queryplayernum = 0;
for (i = 0; i < 12; i++) {
aibot->unk130[i] = -1;
aibot->playerdistances[i] = U32_MAX;
aibot->unk16c[i] = 0;
aibot->unk178[i] = -1;
aibot->unk1a8[i] = -1;
aibot->chrnumsbydistanceasc[i] = -1;
aibot->chrdistances[i] = U32_MAX;
aibot->chrsinsight[i] = 0;
aibot->chrslastseen60[i] = -1;
aibot->chrrooms[i] = -1;
}
aibot->unk1c0 = 0.0f;
@ -253,7 +253,7 @@ void botmgrAllocateBot(s32 chrnum, s32 aibotnum)
aibot->unk2a4 = 0;
aibot->dampensuicidesttl60 = 0;
aibot->unk2c4 = 0.0f;
aibot->unk2c8 = 0;
aibot->targetcloaktimer60 = 0;
aibot->unk09c_03 = 0;

View File

@ -6729,7 +6729,7 @@ bool chrCanSeeChr(struct chrdata *chr, struct chrdata *target, s16 *room)
u32 stack;
s16 sp88[] = {-1, 0, 0, 0, 0, 0, 0, 0};
if (bot0f19294c(chr, target) == 0) {
if (botIsTargetInvisible(chr, target) == 0) {
struct prop *prop = chr->prop;
struct coord pos;
s16 rooms[8];

View File

@ -21962,7 +21962,7 @@ glabel var7f1aa3d0
/* f0738fc: 24060002 */ addiu $a2,$zero,0x2
/* f073900: 1040004a */ beqz $v0,.L0f073a2c
/* f073904: 00002025 */ or $a0,$zero,$zero
/* f073908: 0fc64a53 */ jal bot0f19294c
/* f073908: 0fc64a53 */ jal botIsTargetInvisible
/* f07390c: 02002825 */ or $a1,$s0,$zero
/* f073910: 14400046 */ bnez $v0,.L0f073a2c
/* f073914: 00000000 */ nop
@ -22419,7 +22419,7 @@ glabel var7f1aa3d0
/* f0738fc: 24060002 */ addiu $a2,$zero,0x2
/* f073900: 1040004a */ beqz $v0,.L0f073a2c
/* f073904: 00002025 */ or $a0,$zero,$zero
/* f073908: 0fc64a53 */ jal bot0f19294c
/* f073908: 0fc64a53 */ jal botIsTargetInvisible
/* f07390c: 02002825 */ or $a1,$s0,$zero
/* f073910: 14400046 */ bnez $v0,.L0f073a2c
/* f073914: 00000000 */ nop

View File

@ -25,13 +25,13 @@ void bot0f1921f8(struct chrdata *chr, f32 *move);
#endif
void botLoseGun(struct chrdata *chr, struct prop *attacker);
void bot0f19277c(struct chrdata *chr, s32 propnum);
bool bot0f19294c(struct chrdata *botchr, struct chrdata *otherchr);
void botSetTarget(struct chrdata *chr, s32 propnum);
bool botIsTargetInvisible(struct chrdata *botchr, struct chrdata *otherchr);
bool botHasGround(struct chrdata *chr);
void bot0f192a74(struct chrdata *chr);
bool botPassesPeaceCheck(struct chrdata *botchr, struct chrdata *otherchr);
bool botPassesCowardCheck(struct chrdata *botchr, struct chrdata *otherchr);
u32 bot0f192e90(void);
void botChooseGeneralTarget(struct chrdata *chr);
void bot0f19369c(struct chrdata *chr, s32 arg1);
s32 bot0f1937a4(struct chrdata *chr, s32 arg1);
s32 botGetNumOpponentsInHill(struct chrdata *chr);

View File

@ -934,16 +934,16 @@ struct aibot {
/*0x108*/ struct coord shotspeed; // "boost" when aibot is shot
/*0x114*/ s32 unk114;
/*0x118*/ u32 unk118;
/*0x11c*/ s32 unk11c;
/*0x120*/ s32 unk120;
/*0x124*/ s32 unk124;
/*0x128*/ s32 unk128;
/*0x12c*/ u32 unk12c;
/*0x130*/ s8 unk130[12];
/*0x13c*/ f32 playerdistances[12];
/*0x16c*/ u8 unk16c[12];
/*0x178*/ s32 unk178[12];
/*0x1a8*/ s16 unk1a8[12];
/*0x11c*/ s32 targethotness; // ticks up when target onscreen, down when offscreen, always >= 0
/*0x120*/ s32 targetlastseen60;
/*0x124*/ s32 lastseenanytarget60;
/*0x128*/ bool targetinsight;
/*0x12c*/ s32 queryplayernum;
/*0x130*/ s8 chrnumsbydistanceasc[12];
/*0x13c*/ f32 chrdistances[12];
/*0x16c*/ u8 chrsinsight[12];
/*0x178*/ s32 chrslastseen60[12];
/*0x1a8*/ s16 chrrooms[12];
/*0x1c0*/ f32 unk1c0;
/*0x1c4*/ f32 unk1c4;
/*0x1c8*/ f32 unk1c8;
@ -978,7 +978,15 @@ struct aibot {
*/
/*0x2c4*/ f32 unk2c4;
/*0x2c8*/ s32 unk2c8;
/**
* 120 when target is in sight
* 0 when target is not in sight
* Ticks down when target is in sight but cloaked
*
* Bot maintains target while cloak timer is active
*/
/*0x2c8*/ s32 targetcloaktimer60;
/*0x2cc*/ u32 unk2cc;
/*0x2d0*/ u32 unk2d0;
/*0x2d4*/ f32 unk2d4;