Use dynamically allocated arrays for aibots tracking other chrs
This commit is contained in:
parent
e5e9e7333b
commit
94717149a0
|
|
@ -77,194 +77,203 @@ void botmgrAllocateBot(s32 chrnum, s32 aibotnum)
|
|||
aibot = mempAlloc(sizeof(struct aibot), MEMPOOL_STAGE);
|
||||
chr->aibot = aibot;
|
||||
|
||||
if (aibot != NULL) {
|
||||
chr->tude = 0;
|
||||
chr->voicebox = random() % 3;
|
||||
|
||||
if (g_HeadsAndBodies[chr->bodynum].ismale == false) {
|
||||
chr->voicebox = VOICEBOX_FEMALE;
|
||||
}
|
||||
|
||||
chr->target = -1;
|
||||
chr->naturalanim = 0;
|
||||
chr->myspecial = -1;
|
||||
chr->yvisang = 0;
|
||||
chr->teamscandist = 0;
|
||||
chr->convtalk = 0;
|
||||
chr->myaction = MA_AIBOTMAINLOOP;
|
||||
|
||||
g_MpAllChrPtrs[g_MpNumChrs] = chr;
|
||||
g_MpAllChrConfigPtrs[g_MpNumChrs] = &g_BotConfigsArray[aibotnum].base;
|
||||
g_MpNumChrs++;
|
||||
|
||||
aibot->ammoheld = mempAlloc(36 * sizeof(s32), MEMPOOL_STAGE);
|
||||
|
||||
for (i = 0; i < 33; i++) {
|
||||
aibot->ammoheld[i] = 0;
|
||||
}
|
||||
|
||||
aibot->config = &g_BotConfigsArray[aibotnum];
|
||||
|
||||
switch (g_BotConfigsArray[aibotnum].difficulty) {
|
||||
case BOTDIFF_MEAT:
|
||||
aibot->followchance = 0;
|
||||
break;
|
||||
case BOTDIFF_EASY:
|
||||
aibot->followchance = 10;
|
||||
break;
|
||||
default:
|
||||
case BOTDIFF_NORMAL:
|
||||
aibot->followchance = 20;
|
||||
break;
|
||||
case BOTDIFF_HARD:
|
||||
aibot->followchance = 40;
|
||||
break;
|
||||
case BOTDIFF_PERFECT:
|
||||
aibot->followchance = 60;
|
||||
break;
|
||||
case BOTDIFF_DARK:
|
||||
aibot->followchance = 0;
|
||||
break;
|
||||
}
|
||||
|
||||
aibot->aibotnum = aibotnum;
|
||||
aibot->unk064 = 0;
|
||||
aibot->gotoprop = NULL;
|
||||
aibot->timeuntilreload60[0] = 0;
|
||||
aibot->timeuntilreload60[1] = 0;
|
||||
aibot->throwtimer60 = 0;
|
||||
aibot->unk040 = 0.0f;
|
||||
aibot->loadedammo[0] = 0;
|
||||
aibot->loadedammo[1] = 0;
|
||||
aibot->unk058 = 0;
|
||||
aibot->unk059 = 0;
|
||||
aibot->nextbullettimer60[0] = 0;
|
||||
aibot->nextbullettimer60[1] = 0;
|
||||
#if VERSION < VERSION_PAL_BETA
|
||||
aibot->unk030 = 301;
|
||||
#endif
|
||||
aibot->unk038 = 0;
|
||||
aibot->punchtimer60[HAND_LEFT] = -1;
|
||||
aibot->punchtimer60[HAND_RIGHT] = 0;
|
||||
aibot->attackingplayernum = -1;
|
||||
aibot->followingplayernum = -1;
|
||||
aibot->dangerouspropnum = -1;
|
||||
aibot->unk068 = 0;
|
||||
aibot->unk06c = 0.0f;
|
||||
aibot->unk070 = 0.0f;
|
||||
aibot->distmode = -1;
|
||||
aibot->lastkilledbyplayernum = -1;
|
||||
aibot->feudplayernum = -1;
|
||||
aibot->command = AIBOTCMD_NORMAL;
|
||||
aibot->unk098 = 0.0f;
|
||||
|
||||
aibot->defendholdpos.x = pos.x;
|
||||
aibot->defendholdpos.y = pos.y;
|
||||
aibot->defendholdpos.z = pos.z;
|
||||
|
||||
aibot->weaponnum = WEAPON_UNARMED;
|
||||
|
||||
aibot->burstsdone[0] = 0;
|
||||
aibot->burstsdone[1] = 0;
|
||||
aibot->skrocket = NULL;
|
||||
aibot->unk0a0 = 0;
|
||||
|
||||
aibot->gunfunc = FUNC_PRIMARY;
|
||||
aibot->iscloserangeweapon = true;
|
||||
aibot->teamisonlyai = false;
|
||||
aibot->hasbriefcase = false;
|
||||
aibot->hascase = false;
|
||||
aibot->cloakdeviceenabled = false;
|
||||
aibot->rcp120cloakenabled = false;
|
||||
aibot->unk04c_04 = false;
|
||||
aibot->unk04c_03 = false;
|
||||
aibot->hasuplink = false;
|
||||
aibot->unk04c_00 = false;
|
||||
|
||||
aibot->hillpadnum = -1;
|
||||
aibot->hillcovernum = -1;
|
||||
|
||||
aibot->lastknownhill = -1;
|
||||
aibot->cyclonedischarging[HAND_LEFT] = false;
|
||||
aibot->cyclonedischarging[HAND_RIGHT] = false;
|
||||
aibot->changeguntimer60 = 0;
|
||||
aibot->distmodettl60 = 0;
|
||||
aibot->forcemainloop = false;
|
||||
aibot->returntodefendtimer60 = 0;
|
||||
aibot->reaperspeed[HAND_LEFT] = 0;
|
||||
aibot->reaperspeed[HAND_RIGHT] = 0;
|
||||
aibot->maulercharge[HAND_LEFT] = 0.0f;
|
||||
aibot->maulercharge[HAND_RIGHT] = 0.0f;
|
||||
aibot->unk0a4 = model0001ae44(chr->model);
|
||||
aibot->angleoffset = 0.0f;
|
||||
aibot->speedtheta = 0.0f;
|
||||
aibot->unk0b0 = model0001ae44(chr->model);
|
||||
|
||||
aibot->unk0b4 = 0.0f;
|
||||
aibot->unk0b8 = 0.0f;
|
||||
aibot->shotspeed.x = 0.0f;
|
||||
aibot->shotspeed.y = 0.0f;
|
||||
aibot->shotspeed.z = 0.0f;
|
||||
aibot->commandtimer60 = 0;
|
||||
aibot->shootdelaytimer60 = 0;
|
||||
aibot->targetlastseen60 = -1;
|
||||
aibot->lastseenanytarget60 = -1;
|
||||
aibot->targetinsight = false;
|
||||
aibot->queryplayernum = 0;
|
||||
|
||||
for (i = 0; i < MAX_MPCHRS; i++) {
|
||||
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;
|
||||
aibot->unk1c4 = 0.0f;
|
||||
aibot->unk1c8 = 0.0f;
|
||||
aibot->unk1cc = -1;
|
||||
aibot->unk1d0 = 0;
|
||||
aibot->unk1d4 = 0.0f;
|
||||
aibot->unk1e4 = -1;
|
||||
aibot->waypoints[0] = NULL;
|
||||
aibot->unk208 = 0;
|
||||
aibot->random1 = random();
|
||||
aibot->random1ttl60 = 0;
|
||||
|
||||
for (i = 0; i < 6; i++) {
|
||||
aibot->killsbygunfunc[i][0] = 0.0f;
|
||||
aibot->killsbygunfunc[i][1] = 0.0f;
|
||||
|
||||
aibot->suicidesbygunfunc[i][0] = 0.0f;
|
||||
aibot->suicidesbygunfunc[i][1] = 0.0f;
|
||||
|
||||
aibot->equipdurations60[i][0] = 0;
|
||||
aibot->equipdurations60[i][1] = 0;
|
||||
|
||||
aibot->unk2a8[i] = 0;
|
||||
}
|
||||
|
||||
aibot->unk2a4 = 0;
|
||||
aibot->dampensuicidesttl60 = 0;
|
||||
aibot->unk2c4 = 0.0f;
|
||||
aibot->targetcloaktimer60 = 0;
|
||||
aibot->canseecloaked = false;
|
||||
|
||||
aibot->random2ttl60 = 0;
|
||||
aibot->random2 = random();
|
||||
aibot->randomfrac = RANDOMFRAC();
|
||||
aibot->cheap = false;
|
||||
#if VERSION >= VERSION_NTSC_1_0
|
||||
aibot->unk078 = 0;
|
||||
aibot->unk050 = 0;
|
||||
aibot->unk09d = 0;
|
||||
#endif
|
||||
} else {
|
||||
if (aibot == NULL) {
|
||||
g_MpBotChrPtrs[--g_BotCount] = NULL;
|
||||
return;
|
||||
}
|
||||
|
||||
aibot->chrdistances = mempAlloc(MAX_MPCHRS * sizeof(f32), MEMPOOL_STAGE);
|
||||
aibot->chrsinsight = mempAlloc(MAX_MPCHRS * sizeof(u8), MEMPOOL_STAGE);
|
||||
aibot->chrslastseen60 = mempAlloc(MAX_MPCHRS * sizeof(s32), MEMPOOL_STAGE);
|
||||
aibot->chrrooms = mempAlloc(MAX_MPCHRS * sizeof(s8), MEMPOOL_STAGE);
|
||||
|
||||
if (!aibot->chrdistances || !aibot->chrsinsight || !aibot->chrslastseen60 || !aibot->chrrooms) {
|
||||
g_MpBotChrPtrs[--g_BotCount] = NULL;
|
||||
return;
|
||||
}
|
||||
|
||||
chr->tude = 0;
|
||||
chr->voicebox = random() % 3;
|
||||
|
||||
if (g_HeadsAndBodies[chr->bodynum].ismale == false) {
|
||||
chr->voicebox = VOICEBOX_FEMALE;
|
||||
}
|
||||
|
||||
chr->target = -1;
|
||||
chr->naturalanim = 0;
|
||||
chr->myspecial = -1;
|
||||
chr->yvisang = 0;
|
||||
chr->teamscandist = 0;
|
||||
chr->convtalk = 0;
|
||||
chr->myaction = MA_AIBOTMAINLOOP;
|
||||
|
||||
g_MpAllChrPtrs[g_MpNumChrs] = chr;
|
||||
g_MpAllChrConfigPtrs[g_MpNumChrs] = &g_BotConfigsArray[aibotnum].base;
|
||||
g_MpNumChrs++;
|
||||
|
||||
aibot->ammoheld = mempAlloc(36 * sizeof(s32), MEMPOOL_STAGE);
|
||||
|
||||
for (i = 0; i < 33; i++) {
|
||||
aibot->ammoheld[i] = 0;
|
||||
}
|
||||
|
||||
aibot->config = &g_BotConfigsArray[aibotnum];
|
||||
|
||||
switch (g_BotConfigsArray[aibotnum].difficulty) {
|
||||
case BOTDIFF_MEAT:
|
||||
aibot->followchance = 0;
|
||||
break;
|
||||
case BOTDIFF_EASY:
|
||||
aibot->followchance = 10;
|
||||
break;
|
||||
default:
|
||||
case BOTDIFF_NORMAL:
|
||||
aibot->followchance = 20;
|
||||
break;
|
||||
case BOTDIFF_HARD:
|
||||
aibot->followchance = 40;
|
||||
break;
|
||||
case BOTDIFF_PERFECT:
|
||||
aibot->followchance = 60;
|
||||
break;
|
||||
case BOTDIFF_DARK:
|
||||
aibot->followchance = 0;
|
||||
break;
|
||||
}
|
||||
|
||||
aibot->aibotnum = aibotnum;
|
||||
aibot->unk064 = 0;
|
||||
aibot->gotoprop = NULL;
|
||||
aibot->timeuntilreload60[0] = 0;
|
||||
aibot->timeuntilreload60[1] = 0;
|
||||
aibot->throwtimer60 = 0;
|
||||
aibot->unk040 = 0.0f;
|
||||
aibot->loadedammo[0] = 0;
|
||||
aibot->loadedammo[1] = 0;
|
||||
aibot->unk058 = 0;
|
||||
aibot->unk059 = 0;
|
||||
aibot->nextbullettimer60[0] = 0;
|
||||
aibot->nextbullettimer60[1] = 0;
|
||||
aibot->unk030 = 301;
|
||||
aibot->unk038 = 0;
|
||||
aibot->punchtimer60[HAND_LEFT] = -1;
|
||||
aibot->punchtimer60[HAND_RIGHT] = 0;
|
||||
aibot->attackingplayernum = -1;
|
||||
aibot->followingplayernum = -1;
|
||||
aibot->dangerouspropnum = -1;
|
||||
aibot->unk068 = 0;
|
||||
aibot->unk06c = 0.0f;
|
||||
aibot->unk070 = 0.0f;
|
||||
aibot->distmode = -1;
|
||||
aibot->lastkilledbyplayernum = -1;
|
||||
aibot->feudplayernum = -1;
|
||||
aibot->command = AIBOTCMD_NORMAL;
|
||||
aibot->unk098 = 0.0f;
|
||||
|
||||
aibot->defendholdpos.x = pos.x;
|
||||
aibot->defendholdpos.y = pos.y;
|
||||
aibot->defendholdpos.z = pos.z;
|
||||
|
||||
aibot->weaponnum = WEAPON_UNARMED;
|
||||
|
||||
aibot->burstsdone[0] = 0;
|
||||
aibot->burstsdone[1] = 0;
|
||||
aibot->skrocket = NULL;
|
||||
aibot->unk0a0 = 0;
|
||||
|
||||
aibot->gunfunc = FUNC_PRIMARY;
|
||||
aibot->iscloserangeweapon = true;
|
||||
aibot->teamisonlyai = false;
|
||||
aibot->hasbriefcase = false;
|
||||
aibot->hascase = false;
|
||||
aibot->cloakdeviceenabled = false;
|
||||
aibot->rcp120cloakenabled = false;
|
||||
aibot->unk04c_04 = false;
|
||||
aibot->unk04c_03 = false;
|
||||
aibot->hasuplink = false;
|
||||
aibot->unk04c_00 = false;
|
||||
|
||||
aibot->hillpadnum = -1;
|
||||
aibot->hillcovernum = -1;
|
||||
|
||||
aibot->lastknownhill = -1;
|
||||
aibot->cyclonedischarging[HAND_LEFT] = false;
|
||||
aibot->cyclonedischarging[HAND_RIGHT] = false;
|
||||
aibot->changeguntimer60 = 0;
|
||||
aibot->distmodettl60 = 0;
|
||||
aibot->forcemainloop = false;
|
||||
aibot->returntodefendtimer60 = 0;
|
||||
aibot->reaperspeed[HAND_LEFT] = 0;
|
||||
aibot->reaperspeed[HAND_RIGHT] = 0;
|
||||
aibot->maulercharge[HAND_LEFT] = 0.0f;
|
||||
aibot->maulercharge[HAND_RIGHT] = 0.0f;
|
||||
aibot->unk0a4 = model0001ae44(chr->model);
|
||||
aibot->angleoffset = 0.0f;
|
||||
aibot->speedtheta = 0.0f;
|
||||
aibot->unk0b0 = model0001ae44(chr->model);
|
||||
|
||||
aibot->unk0b4 = 0.0f;
|
||||
aibot->unk0b8 = 0.0f;
|
||||
aibot->shotspeed.x = 0.0f;
|
||||
aibot->shotspeed.y = 0.0f;
|
||||
aibot->shotspeed.z = 0.0f;
|
||||
aibot->commandtimer60 = 0;
|
||||
aibot->shootdelaytimer60 = 0;
|
||||
aibot->targetlastseen60 = -1;
|
||||
aibot->lastseenanytarget60 = -1;
|
||||
aibot->targetinsight = false;
|
||||
aibot->queryplayernum = 0;
|
||||
|
||||
for (i = 0; i < ARRAYCOUNT(aibot->chrnumsbydistanceasc); i++) {
|
||||
aibot->chrnumsbydistanceasc[i] = -1;
|
||||
}
|
||||
|
||||
for (i = 0; i < MAX_MPCHRS; i++) {
|
||||
aibot->chrdistances[i] = U32_MAX;
|
||||
aibot->chrsinsight[i] = 0;
|
||||
aibot->chrslastseen60[i] = -1;
|
||||
aibot->chrrooms[i] = -1;
|
||||
}
|
||||
|
||||
aibot->unk1c0 = 0.0f;
|
||||
aibot->unk1c4 = 0.0f;
|
||||
aibot->unk1c8 = 0.0f;
|
||||
aibot->unk1cc = -1;
|
||||
aibot->unk1d0 = 0;
|
||||
aibot->unk1d4 = 0.0f;
|
||||
aibot->unk1e4 = -1;
|
||||
aibot->waypoints[0] = NULL;
|
||||
aibot->unk208 = 0;
|
||||
aibot->random1 = random();
|
||||
aibot->random1ttl60 = 0;
|
||||
|
||||
for (i = 0; i < 6; i++) {
|
||||
aibot->killsbygunfunc[i][0] = 0.0f;
|
||||
aibot->killsbygunfunc[i][1] = 0.0f;
|
||||
|
||||
aibot->suicidesbygunfunc[i][0] = 0.0f;
|
||||
aibot->suicidesbygunfunc[i][1] = 0.0f;
|
||||
|
||||
aibot->equipdurations60[i][0] = 0;
|
||||
aibot->equipdurations60[i][1] = 0;
|
||||
|
||||
aibot->unk2a8[i] = 0;
|
||||
}
|
||||
|
||||
aibot->unk2a4 = 0;
|
||||
aibot->dampensuicidesttl60 = 0;
|
||||
aibot->unk2c4 = 0.0f;
|
||||
aibot->targetcloaktimer60 = 0;
|
||||
aibot->canseecloaked = false;
|
||||
|
||||
aibot->random2ttl60 = 0;
|
||||
aibot->random2 = random();
|
||||
aibot->randomfrac = RANDOMFRAC();
|
||||
aibot->cheap = false;
|
||||
aibot->unk078 = 0;
|
||||
aibot->unk050 = 0;
|
||||
aibot->unk09d = 0;
|
||||
|
||||
botinvInit(chr, 10);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -794,11 +794,11 @@ struct aibot {
|
|||
/*0x124*/ s32 lastseenanytarget60;
|
||||
/*0x128*/ bool targetinsight;
|
||||
/*0x12c*/ s32 queryplayernum;
|
||||
/*0x130*/ s8 chrnumsbydistanceasc[12];
|
||||
/*0x13c*/ f32 chrdistances[MAX_MPCHRS];
|
||||
/*0x16c*/ u8 chrsinsight[MAX_MPCHRS];
|
||||
/*0x178*/ s32 chrslastseen60[MAX_MPCHRS];
|
||||
/*0x1a8*/ s16 chrrooms[MAX_MPCHRS];
|
||||
/*0x130*/ s16 chrnumsbydistanceasc[12];
|
||||
/*0x13c*/ f32 *chrdistances;
|
||||
/*0x16c*/ u8 *chrsinsight;
|
||||
/*0x178*/ s32 *chrslastseen60;
|
||||
/*0x1a8*/ s8 *chrrooms;
|
||||
/*0x1c0*/ f32 unk1c0;
|
||||
/*0x1c4*/ f32 unk1c4;
|
||||
/*0x1c8*/ f32 unk1c8;
|
||||
|
|
|
|||
Loading…
Reference in New Issue