Use constants in chrai.c

This commit is contained in:
Ryan Dwyer 2019-12-29 08:17:38 +10:00
parent 60aff809cd
commit e922b18cc8
4 changed files with 28 additions and 23 deletions

View File

@ -31401,11 +31401,11 @@ glabel chrIsStopped
//{
// u32 anim = func0001d13c(chr->unk020);
//
// if (anim == 0x269 || anim == 0x26b) {
// if (anim == ANIM_SNIPING_0269 || anim == ANIM_SNIPING_026B) {
// return false;
// }
//
// if (anim == 0x26a && chr->act_attack.unk034 <= chr->act_attack.unk033) {
// if (anim == ANIM_SNIPING_026A && chr->act_attack.unk034 <= chr->act_attack.unk033) {
// chrStopFiring(chr);
// return true;
// }

View File

@ -51,7 +51,7 @@ u32 chraiGoToLabel(u8 *ailist, u32 aioffset, u8 label)
} while (true);
}
void chraiExecute(void *entity, s32 entity_type)
void chraiExecute(void *entity, s32 proptype)
{
g_Vars.chrdata = NULL;
g_Vars.objdata = NULL;
@ -60,14 +60,14 @@ void chraiExecute(void *entity, s32 entity_type)
g_Vars.ailist = NULL;
g_Vars.aioffset = 0;
if (entity_type == 3) {
if (proptype == PROPTYPE_CHR) {
g_Vars.chrdata = entity;
} else if (entity_type == 1) {
} else if (proptype == PROPTYPE_OBJ) {
struct defaultobj *obj = entity;
if (obj->type == 0x27) {
if (obj->type == OBJTYPE_27) {
g_Vars.objdata = entity;
} else if (obj->type == 0x28) {
} else if (obj->type == OBJTYPE_28) {
g_Vars.aicdata = entity;
} else if (obj->type == OBJTYPE_HOVERVEHICLE || obj->type == OBJTYPE_ARMEDVEHICLE) {
g_Vars.hovdata = entity;
@ -94,25 +94,27 @@ void chraiExecute(void *entity, s32 entity_type)
}
// Check if the ailist should be switched to a different one
if (g_Vars.chrdata && (g_Vars.chrdata->chrflags & 0x00200000)) {
u32 animationmaybe = func0001d13c(g_Vars.chrdata->unk020);
if (g_Vars.chrdata && (g_Vars.chrdata->chrflags & CHRCFLAG_00200000)) {
u32 anim = func0001d13c(g_Vars.chrdata->unk020);
if (g_Vars.chrdata->aishotlist >= 0
&& g_Vars.chrdata->cshield <= 0
&& (0 <= g_Vars.chrdata->damage || g_Vars.chrdata->gunprop != NULL)
&& animationmaybe != 0x269 && animationmaybe != 0x26b && animationmaybe != 0x26a) {
&& anim != ANIM_SNIPING_0269
&& anim != ANIM_SNIPING_026B
&& anim != ANIM_SNIPING_026A) {
// Set shot list
g_Vars.chrdata->chrflags &= ~0x00200000;
g_Vars.chrdata->chrflags &= ~CHRCFLAG_00200000;
g_Vars.ailist = ailistFindById(g_Vars.chrdata->aishotlist);
g_Vars.aioffset = 0;
}
} else if (g_Vars.chrdata && (g_Vars.chrdata->chrflags & 0x08000000)) {
g_Vars.chrdata->chrflags &= ~0x08000000;
} else if (g_Vars.chrdata && (g_Vars.chrdata->chrflags & CHRCFLAG_CONSIDER_DODGE)) {
g_Vars.chrdata->chrflags &= ~CHRCFLAG_CONSIDER_DODGE;
if (g_Vars.chrdata->aishootingatmelist >= 0
&& ailistFindById(g_Vars.chrdata->aishootingatmelist) != g_Vars.chrdata->ailist
&& g_Vars.chrdata->dodgerating > (u32)random() % 100
&& chrHasFlag(g_Vars.chrdata, 0x00000400, BANK_1) == 0
&& chrHasFlag(g_Vars.chrdata, 0x00010000, BANK_0) == 0
&& chrHasFlag(g_Vars.chrdata, CHRFLAG1_00000400, BANK_1) == 0
&& chrHasFlag(g_Vars.chrdata, CHRFLAG0_AIVSAI, BANK_0) == 0
&& ailistFindById(g_Vars.chrdata->aishootingatmelist) != g_Vars.chrdata->ailist
&& g_Vars.chrdata->actiontype != ACT_ATTACK
&& g_Vars.chrdata->actiontype != ACT_ATTACKWALK
@ -135,7 +137,7 @@ void chraiExecute(void *entity, s32 entity_type)
}
} else if (g_Vars.chrdata
&& g_Vars.chrdata->darkroomthing
&& chrHasFlag(g_Vars.chrdata, 0x00000400, BANK_1) == 0
&& chrHasFlag(g_Vars.chrdata, CHRFLAG1_00000400, BANK_1) == 0
&& ailistFindById(g_Vars.chrdata->aidarkroomlist) != g_Vars.chrdata->ailist
&& g_Vars.unk0004b4 != 0x1c) {
g_Vars.chrdata->darkroomthing = 0;
@ -145,8 +147,8 @@ void chraiExecute(void *entity, s32 entity_type)
&& g_Vars.chrdata->actiontype != ACT_DEAD
&& g_Vars.chrdata->actiontype != ACT_ARGH) {
// Set darkroom list
chrSetFlags(g_Vars.chrdata, 0x00000400, BANK_1);
chrSetFlags(g_Vars.chrdata, 0x10000000, BANK_1);
chrSetFlags(g_Vars.chrdata, CHRFLAG1_00000400, BANK_1);
chrSetFlags(g_Vars.chrdata, CHRFLAG1_10000000, BANK_1);
g_Vars.chrdata->alertness = 0;
g_Vars.ailist = ailistFindById(g_Vars.chrdata->aidarkroomlist);
g_Vars.aioffset = 0;

View File

@ -3294,7 +3294,7 @@ bool ai0065(void)
if (obj && obj->prop) {
if (obj->prop->type == PROPTYPE_DOOR) {
func0f08fee8(obj->prop, 0);
} else if (obj->prop->type == PROPTYPE_1 || obj->prop->type == PROPTYPE_WEAPON) {
} else if (obj->prop->type == PROPTYPE_OBJ || obj->prop->type == PROPTYPE_WEAPON) {
func0f086f40(obj->prop);
}
}
@ -12277,7 +12277,7 @@ bool ai0183(void)
u8 *cmd = g_Vars.ailist + g_Vars.aioffset;
struct prop *target = chrGetTargetProp(g_Vars.chrdata);
if (target->type == PROPTYPE_5 || target->type == PROPTYPE_PLAYER) {
if (target->type == PROPTYPE_EYESPY || target->type == PROPTYPE_PLAYER) {
g_Vars.aioffset = chraiGoToLabel(g_Vars.ailist, g_Vars.aioffset, cmd[2]);
} else {
g_Vars.aioffset += 3;

View File

@ -289,7 +289,7 @@
#define CHRCFLAG_01000000 0x01000000 // Typically set on allies during init
#define CHRCFLAG_02000000 0x02000000 // can be unset by cmd0168
#define CHRCFLAG_04000000 0x04000000 // Set by aiChrKill command
#define CHRCFLAG_08000000 0x08000000 // Not used in scripts
#define CHRCFLAG_CONSIDER_DODGE 0x08000000
#define CHRCFLAG_10000000 0x10000000 // Not used in scripts
#define CHRCFLAG_20000000 0x20000000 // Not used in scripts
#define CHRCFLAG_40000000 0x40000000 // Not used in scripts
@ -684,11 +684,11 @@
#define PATHTYPE_CIRCULAR 1
#define PATHTYPE_FLYING 2
#define PROPTYPE_1 1
#define PROPTYPE_OBJ 1
#define PROPTYPE_DOOR 2
#define PROPTYPE_CHR 3
#define PROPTYPE_WEAPON 4
#define PROPTYPE_5 5
#define PROPTYPE_EYESPY 5
#define PROPTYPE_PLAYER 6
#define RACE_HUMAN 0
@ -1668,6 +1668,9 @@
#define ANIM_LOOK_AROUND_FRANTIC 0x025f
#define ANIM_SITTING_0265 0x0265
//.set ANIM_, 0x0266: covering mouth looking
#define ANIM_SNIPING_0269 0x269
#define ANIM_SNIPING_026A 0x26a
#define ANIM_SNIPING_026B 0x26b
#define ANIM_DRAW_PISTOL_0288 0x0288
#define ANIM_DRAW_PISTOL_0289 0x0289
//.set ANIM_, 0x02c4: Jo in Defense intro