Identify unnamed chr functions

This commit is contained in:
Ryan Dwyer 2024-08-18 17:02:55 +10:00
parent 58544052af
commit 748a32c59e
17 changed files with 241 additions and 232 deletions

View File

@ -1670,7 +1670,7 @@ void bg_build_tables(s32 stagenum)
}
bg_set_stage_translation_thing(g_Stages[g_StageIndex].unk14);
chr0f028490(g_Stages[g_StageIndex].unk14);
chrs_set_stage_translation_thing(g_Stages[g_StageIndex].unk14);
for (i = 0; i < MAX_PLAYERS; i++) {
g_Vars.playerstats[i].scale_bg2gfx = g_Stages[g_StageIndex].unk18;

View File

@ -412,7 +412,7 @@ void body_instantiate_chr(s32 stagenum, struct packedchr *packed, s32 cmdindex)
if (model != NULL) {
angle = atan2f(pad.look.x, pad.look.z);
prop = chr_allocate(model, &pad.pos, rooms, angle, ailist_find_by_id(packed->ailistnum));
prop = chr_create_with_model(model, &pad.pos, rooms, angle, ailist_find_by_id(packed->ailistnum));
if (prop != NULL) {
prop_activate(prop);
@ -572,7 +572,7 @@ struct prop *body_instantiate_eyespy(struct pad *pad, RoomNum room)
model = body_instantiate_model_with_spawnflags(BODY_EYESPY, 0, 0);
if (model) {
prop = chr_allocate(model, &pad->pos, rooms, 0, ailist_find_by_id(GAILIST_IDLE));
prop = chr_create_with_model(model, &pad->pos, rooms, 0, ailist_find_by_id(GAILIST_IDLE));
if (prop) {
prop_activate(prop);

View File

@ -53,7 +53,7 @@ void botmgr_allocate_bot(s32 chrnum, s32 aibotnum)
struct coord pos = {0.0f, 0.0f, 0.0f};
u32 stack;
prop = chr_allocate(model, &pos, rooms, 0.0f, ailist_find_by_id(GAILIST_AIBOT_INIT));
prop = chr_create_with_model(model, &pos, rooms, 0.0f, ailist_find_by_id(GAILIST_AIBOT_INIT));
if (prop != NULL) {
prop_activate(prop);

View File

@ -56,15 +56,15 @@ s16 *g_Chrnums;
s16 *g_ChrIndexes;
struct chrdata *g_CurModelChr;
struct var80062960 *var80062960 = NULL;
s32 var80062964 = 0;
f32 var80062968 = 0;
bool var8006296c = false;
s32 g_SelectedAnimNum = 0;
u32 var80062974 = 0x00000000;
u32 var80062978 = 0x00000000;
u32 var8006297c = 0;
u32 var80062980 = 0;
struct onscreendoor *g_ChrsOnscreenDoors = NULL;
s32 g_ChrsNumOnscreenDoors = 0;
f32 g_ChrsAnimSpeed = 0;
bool g_ChrsAnimDebugSetAll = false;
s32 g_ChrsAnimDebugAnimNum = 0;
u32 g_ChrsAnimDebugPaused = 0x00000000;
u32 g_ChrsAnimDebugSlow = 0x00000000;
bool g_ChrsDebugPatrols = false;
bool g_ChrsDebugSomething = false;
s32 g_NextChrnum = 5000;
struct chrdata *g_ChrSlots = NULL;
@ -161,24 +161,24 @@ Vtx *chr_allocate_vertices(s32 numvertices)
return (Vtx *) gfx_allocate(numvertices * sizeof(Vtx));
}
void chrs_set_var8006297c(u32 arg0)
void chrs_set_debug_patrols(bool enabled)
{
var8006297c = arg0;
g_ChrsDebugPatrols = enabled;
}
u32 chrs_get_var8006297c(void)
bool chrs_get_debug_patrols(void)
{
return var8006297c;
return g_ChrsDebugPatrols;
}
void chrs_set_var80062980(u32 arg0)
void chrs_set_debug_something(bool enabled)
{
var80062980 = arg0;
g_ChrsDebugSomething = enabled;
}
u32 chrs_get_var80062980(void)
bool chrs_get_debug_something(void)
{
return var80062980;
return g_ChrsDebugSomething;
}
void chr_set_perim_enabled(struct chrdata *chr, bool enable)
@ -513,7 +513,7 @@ bool chr_ascend(struct chrdata *chr, struct coord *pos, RoomNum *rooms, f32 amou
return result == CDRESULT_NOCOLLISION;
}
bool chr0f01f378(struct model *model, struct coord *arg1, struct coord *arg2, f32 *mangroundptr)
bool chr_update_position(struct model *model, struct coord *arg1, struct coord *arg2, f32 *mangroundptr)
{
struct chrdata *chr = model->chr;
struct prop *prop = chr->prop;
@ -1073,7 +1073,11 @@ s16 chrs_get_next_unused_chrnum(void)
return chrnum;
}
void chr_init(struct prop *prop, u8 *ailist)
/**
* Allocate a chr from the pool, set default values, register a chrnum
* and assign it to the prop.
*/
void chr_allocate(struct prop *prop, u8 *ailist)
{
s32 i;
struct chrdata *chr = NULL;
@ -1289,7 +1293,11 @@ void chr_init(struct prop *prop, u8 *ailist)
splat_reset_chr(chr);
}
struct prop *chr0f020b14(struct prop *prop, struct model *model,
/**
* Place the chr in the stage at the given position.
* Allocate a chr struct if the prop doesn't have one yet.
*/
struct prop *chr_place(struct prop *prop, struct model *model,
struct coord *pos, RoomNum *rooms, f32 faceangle, u8 *ailist)
{
struct chrdata *chr;
@ -1300,17 +1308,17 @@ struct prop *chr0f020b14(struct prop *prop, struct model *model,
prop->type = PROPTYPE_CHR;
if (prop->chr == NULL) {
chr_init(prop, ailist);
chr_allocate(prop, ailist);
}
chr = prop->chr;
model_set_anim70(model, chr0f01f378);
model_set_anim70(model, chr_update_position);
model->chr = chr;
model->unk01 = 1;
chr->model = model;
chr_set_look_angle(chr, faceangle);
model_set_anim_play_speed(model, PALUPF(var80062968), 0);
model_set_anim_play_speed(model, PALUPF(g_ChrsAnimSpeed), 0);
testpos.x = pos->x;
testpos.y = pos->y + 100;
@ -1345,12 +1353,12 @@ struct prop *chr0f020b14(struct prop *prop, struct model *model,
return prop;
}
struct prop *chr_allocate(struct model *model, struct coord *pos, RoomNum *rooms, f32 faceangle, u8 *ailist)
struct prop *chr_create_with_model(struct model *model, struct coord *pos, RoomNum *rooms, f32 faceangle, u8 *ailist)
{
struct prop *prop = prop_allocate();
if (prop) {
prop = chr0f020b14(prop, model, pos, rooms, faceangle, ailist);
prop = chr_place(prop, model, pos, rooms, faceangle, ailist);
if (cheat_is_active(CHEAT_ENEMYSHIELDS)) {
chr_set_shield(prop->chr, 8);
@ -1466,22 +1474,28 @@ void chr_clear_references(s32 propnum)
}
}
void chr0f0211a8(f32 arg0)
/**
* For the fast animation cheat from GE.
*
* The cheat doesn't exist in PD, but the functions are still here.
* These functions are not called.
*/
void chrs_set_anim_speed(f32 speed)
{
s32 i;
var80062968 = arg0;
g_ChrsAnimSpeed = speed;
for (i = 0; i < g_NumChrSlots; i++) {
if (g_ChrSlots[i].model) {
model_set_anim_play_speed(g_ChrSlots[i].model, PALUPF(var80062968), 600);
model_set_anim_play_speed(g_ChrSlots[i].model, PALUPF(g_ChrsAnimSpeed), 600);
}
}
}
f32 chr0f02124c(void)
f32 chrs_get_anim_speed(void)
{
return var80062968;
return g_ChrsAnimSpeed;
}
void chr_update_aim_properties(struct chrdata *chr)
@ -1916,7 +1930,7 @@ void chr_detect_rooms(struct chrdata *chr)
prop_register_rooms(chr->prop);
}
void chr0f0220ec(struct chrdata *chr, s32 lvupdate240, bool arg2)
void chr_update_anim(struct chrdata *chr, s32 lvupdate240, bool arg2)
{
struct model *model = chr->model;
@ -1946,7 +1960,7 @@ void chr0f0220ec(struct chrdata *chr, s32 lvupdate240, bool arg2)
}
}
void chr0f022214(struct chrdata *chr, struct prop *prop, bool fulltick)
void chr_tick_child(struct chrdata *chr, struct prop *prop, bool fulltick)
{
struct defaultobj *obj = prop->obj;
struct model *model = obj->model;
@ -2000,7 +2014,7 @@ void chr0f022214(struct chrdata *chr, struct prop *prop, bool fulltick)
if (prop);
next = child->next;
chr0f022214(chr, child, fulltick);
chr_tick_child(chr, child, fulltick);
child = next;
}
} else {
@ -2423,10 +2437,10 @@ s32 chr_tick(struct prop *prop)
chr_tick_poisoned(chr);
if ((chr->chrflags & CHRCFLAG_HIDDEN) == 0 || (chr->chrflags & CHRCFLAG_NEVERSLEEP)) {
if (var8006296c) {
if (anim_has_frames(g_SelectedAnimNum)) {
if (model_get_anim_num(model) != g_SelectedAnimNum || !anim_has_frames(model_get_anim_num(model))) {
model_set_animation(model, g_SelectedAnimNum, 0, 0.0f, 0.5f, 0.0f);
if (g_ChrsAnimDebugSetAll) {
if (anim_has_frames(g_ChrsAnimDebugAnimNum)) {
if (model_get_anim_num(model) != g_ChrsAnimDebugAnimNum || !anim_has_frames(model_get_anim_num(model))) {
model_set_animation(model, g_ChrsAnimDebugAnimNum, 0, 0.0f, 0.5f, 0.0f);
}
}
} else {
@ -2437,10 +2451,10 @@ s32 chr_tick(struct prop *prop)
}
}
if (var80062974) {
if (g_ChrsAnimDebugPaused) {
lvupdate240 = 0;
if (var80062978) {
if (g_ChrsAnimDebugSlow) {
lvupdate240 = 1;
}
}
@ -2467,7 +2481,7 @@ s32 chr_tick(struct prop *prop)
}
if (fulltick) {
chr0f0220ec(chr, lvupdate240, true);
chr_update_anim(chr, lvupdate240, true);
}
} else {
needsupdate = false;
@ -2486,9 +2500,9 @@ s32 chr_tick(struct prop *prop)
model->anim->average = false;
if (chr->actiontype == ACT_ANIM && !chr->act_anim.movewheninvis && chr->act_anim.lockpos) {
chr0f0220ec(chr, lvupdate240, false);
chr_update_anim(chr, lvupdate240, false);
} else {
chr0f0220ec(chr, lvupdate240, true);
chr_update_anim(chr, lvupdate240, true);
}
}
@ -2517,7 +2531,7 @@ s32 chr_tick(struct prop *prop)
}
} else {
if (fulltick) {
chr0f0220ec(chr, lvupdate240, true);
chr_update_anim(chr, lvupdate240, true);
}
needsupdate = func0f08e8ac(prop, &prop->pos, model_get_effective_scale(model), true);
@ -2540,16 +2554,16 @@ s32 chr_tick(struct prop *prop)
model->anim->average = false;
if (needsupdate && !chr->act_anim.lockpos) {
chr0f0220ec(chr, lvupdate240, true);
chr_update_anim(chr, lvupdate240, true);
} else {
chr0f0220ec(chr, lvupdate240, false);
chr_update_anim(chr, lvupdate240, false);
}
}
} else if (chr->actiontype == ACT_STAND) {
model->anim->average = false;
if (chr->chrflags & CHRCFLAG_FORCETOGROUND) {
chr0f0220ec(chr, lvupdate240, true);
chr_update_anim(chr, lvupdate240, true);
needsupdate = func0f08e8ac(prop, &prop->pos, model_get_effective_scale(model), true);
} else {
needsupdate = func0f08e8ac(prop, &prop->pos, model_get_effective_scale(model), true);
@ -2558,22 +2572,22 @@ s32 chr_tick(struct prop *prop)
if (fulltick) {
if (g_Vars.coopplayernum >= 0 || g_Vars.antiplayernum >= 0) {
if (needsupdate) {
chr0f0220ec(chr, lvupdate240, true);
chr_update_anim(chr, lvupdate240, true);
} else if (model->anim->animnum2 != 0) {
chr0f0220ec(chr, lvupdate240, false);
chr_update_anim(chr, lvupdate240, false);
}
} else {
chr0f0220ec(chr, lvupdate240, true);
chr_update_anim(chr, lvupdate240, true);
}
}
} else if (needsupdate) {
if (chr->act_stand.playwalkanim == true) {
chr0f0220ec(chr, lvupdate240, false);
chr_update_anim(chr, lvupdate240, false);
} else {
chr0f0220ec(chr, lvupdate240, true);
chr_update_anim(chr, lvupdate240, true);
}
} else if (model->anim->animnum2 != 0) {
chr0f0220ec(chr, lvupdate240, false);
chr_update_anim(chr, lvupdate240, false);
}
}
} else if (chr->actiontype == ACT_DEAD) {
@ -2583,14 +2597,14 @@ s32 chr_tick(struct prop *prop)
|| (player = g_Vars.players[playermgr_get_player_num_by_prop(prop)], player->cameramode == CAMERAMODE_EYESPY)
|| (player->cameramode == CAMERAMODE_THIRDPERSON && player->visionmode == VISIONMODE_SLAYERROCKET))) {
model->anim->average = false;
chr0f0220ec(chr, lvupdate240, true);
chr_update_anim(chr, lvupdate240, true);
needsupdate = func0f08e8ac(prop, &prop->pos, model_get_effective_scale(model), true);
} else {
isrepeatframe2 = false;
if (fulltick) {
model->anim->average = false;
chr0f0220ec(chr, lvupdate240, true);
chr_update_anim(chr, lvupdate240, true);
}
if (chr->model && chr->model->anim && (g_Anims[chr->model->anim->animnum].flags & ANIMFLAG_HASREPEATFRAMES)) {
@ -2789,7 +2803,7 @@ s32 chr_tick(struct prop *prop)
while (child) {
next = child->next;
chr0f022214(chr, child, fulltick);
chr_tick_child(chr, child, fulltick);
child = next;
}
@ -2943,38 +2957,38 @@ void chr_drop_items_for_owner_reap(struct chrdata *chr)
chr->hidden |= CHRHFLAG_DROPPINGITEM;
}
u8 var80062a48[] = { 64, 10, 10 };
u8 g_ChrBloodColour[] = { 0x40, 0x0a, 0x0a };
void chr0f0246e4(u8 *arg0)
void chrs_set_blood_colour(u8 *rgb)
{
var80062a48[0] = arg0[0];
var80062a48[1] = arg0[1];
var80062a48[2] = arg0[2];
g_ChrBloodColour[0] = rgb[0];
g_ChrBloodColour[1] = rgb[1];
g_ChrBloodColour[2] = rgb[2];
}
void chr0f024708(u8 *arg0)
void chrs_get_blood_colour(u8 *rgb)
{
arg0[0] = var80062a48[0];
arg0[1] = var80062a48[1];
arg0[2] = var80062a48[2];
rgb[0] = g_ChrBloodColour[0];
rgb[1] = g_ChrBloodColour[1];
rgb[2] = g_ChrBloodColour[2];
}
void chr0f02472c(void)
void chrs_reset_onscreen_doors(void)
{
var80062964 = 0;
g_ChrsNumOnscreenDoors = 0;
}
bool chr0f024738(struct chrdata *chr)
bool chr_find_onscreen_doors(struct chrdata *chr)
{
s16 *propnumptr;
s16 propnums[256];
s32 i;
struct var80062960 *thing;
struct onscreendoor *osd;
struct coord *campos;
bool result = false;
for (i = 0; i < var80062964; i++) {
var80062960[i].unk004 = 0;
for (i = 0; i < g_ChrsNumOnscreenDoors; i++) {
g_ChrsOnscreenDoors[i].unk004 = false;
}
room_get_props(chr->prop->rooms, propnums, 256);
@ -2997,57 +3011,57 @@ bool chr0f024738(struct chrdata *chr)
&& (obj->flags & (OBJFLAG_00000010 | OBJFLAG_AISEETHROUGH)) == 0
&& (obj->flags2 & OBJFLAG2_DOOR_ALTCOORDSYSTEM) == 0
&& !((door->doorflags & DOORFLAG_0080) == 0 && door->frac > 0)) {
for (i = 0; i < var80062964; i++) {
if (var80062960[i].prop == prop) {
for (i = 0; i < g_ChrsNumOnscreenDoors; i++) {
if (g_ChrsOnscreenDoors[i].prop == prop) {
break;
}
}
if (i < var80062964) {
thing = &var80062960[i];
if (i < g_ChrsNumOnscreenDoors) {
osd = &g_ChrsOnscreenDoors[i];
} else {
if (var80062964 > 14) {
if (g_ChrsNumOnscreenDoors > 14) {
goto next;
}
thing = &var80062960[var80062964];
thing->prop = prop;
thing->unk00c = 0;
thing->unk130 = 0;
thing->unk004 = 0;
osd = &g_ChrsOnscreenDoors[g_ChrsNumOnscreenDoors];
osd->prop = prop;
osd->unk00c = 0;
osd->unk130 = 0;
osd->unk004 = 0;
var80062964++;
g_ChrsNumOnscreenDoors++;
}
if (!thing->unk00c) {
if (!osd->unk00c) {
struct modelrodata_bbox *bbox = obj_find_bbox_rodata(obj);
thing->bbox = *bbox;
osd->bbox = *bbox;
mtx3_to_mtx4(obj->realrot, &thing->unk02c);
mtx4_set_translation(&obj->prop->pos, &thing->unk02c);
mtx000172f0(thing->unk02c.m, thing->unk06c.m);
mtx3_to_mtx4(obj->realrot, &osd->unk02c);
mtx4_set_translation(&obj->prop->pos, &osd->unk02c);
mtx000172f0(osd->unk02c.m, osd->unk06c.m);
campos = &g_Vars.currentplayer->cam_pos;
thing->unk12c = (
+ thing->unk06c.m[0][2] * campos->f[0]
+ thing->unk06c.m[1][2] * campos->f[1]
+ thing->unk06c.m[2][2] * campos->f[2]) + thing->unk06c.m[3][2];
osd->unk12c = (
+ osd->unk06c.m[0][2] * campos->f[0]
+ osd->unk06c.m[1][2] * campos->f[1]
+ osd->unk06c.m[2][2] * campos->f[2]) + osd->unk06c.m[3][2];
mtx00015be4(&thing->unk06c, cam_get_projection_mtxf(), &thing->unk0ac);
thing->unk00c = true;
mtx00015be4(&osd->unk06c, cam_get_projection_mtxf(), &osd->unk0ac);
osd->unk00c = true;
}
model_get_root_position(chr->model, &pos);
thing->unk008 = (
thing->unk06c.m[0][2] * pos.f[0] +
thing->unk06c.m[1][2] * pos.f[1] +
thing->unk06c.m[2][2] * pos.f[2]) + thing->unk06c.m[3][2];
osd->unk008 = (
osd->unk06c.m[0][2] * pos.f[0] +
osd->unk06c.m[1][2] * pos.f[1] +
osd->unk06c.m[2][2] * pos.f[2]) + osd->unk06c.m[3][2];
if ((thing->unk008 > thing->bbox.zmax && thing->unk12c < thing->bbox.zmin)
|| (thing->unk008 < thing->bbox.zmin && thing->unk12c > thing->bbox.zmax)) {
thing->unk004 = true;
if ((osd->unk008 > osd->bbox.zmax && osd->unk12c < osd->bbox.zmin)
|| (osd->unk008 < osd->bbox.zmin && osd->unk12c > osd->bbox.zmax)) {
osd->unk004 = true;
result = true;
}
}
@ -3061,14 +3075,14 @@ next:
return result;
}
bool chr0f024b18(struct model *model, struct modelnode *node)
bool chr_should_render_gundl(struct model *model, struct modelnode *node)
{
struct model *rootmodel;
struct modelnode *bboxnode;
f32 value;
struct doorobj *door;
struct modelrodata_bbox *bbox;
struct var80062960 *thing;
struct onscreendoor *osd;
s32 i;
s32 j;
bool done;
@ -3106,55 +3120,55 @@ bool chr0f024b18(struct model *model, struct modelnode *node)
bbox = &bboxnode->rodata->bbox;
mtx = model_find_node_mtx(model, node, 0);
for (i = 0; i < var80062964; i++) {
if (var80062960[i].unk004) {
thing = &var80062960[i];
for (i = 0; i < g_ChrsNumOnscreenDoors; i++) {
if (g_ChrsOnscreenDoors[i].unk004) {
osd = &g_ChrsOnscreenDoors[i];
done = false;
spb0 = false;
door = thing->prop->door;
door = osd->prop->door;
mtx00015be4(&thing->unk0ac, mtx, &spb4);
mtx00015be4(&osd->unk0ac, mtx, &spb4);
if (thing->unk130 == 0) {
if (osd->unk130 == 0) {
if (door->doortype == DOORTYPE_VERTICAL) {
spa0.x = thing->bbox.xmin;
spa0.y = thing->bbox.ymin;
spa0.z = thing->bbox.zmin;
spa0.x = osd->bbox.xmin;
spa0.y = osd->bbox.ymin;
spa0.z = osd->bbox.zmin;
sp94.x = thing->bbox.xmax;
sp94.y = thing->bbox.ymin;
sp94.z = thing->bbox.zmin;
sp94.x = osd->bbox.xmax;
sp94.y = osd->bbox.ymin;
sp94.z = osd->bbox.zmin;
sp88.x = thing->bbox.xmax;
sp88.y = thing->bbox.ymax;
sp88.z = thing->bbox.zmin;
sp88.x = osd->bbox.xmax;
sp88.y = osd->bbox.ymax;
sp88.z = osd->bbox.zmin;
} else {
spa0.x = thing->bbox.xmax;
spa0.y = thing->bbox.ymax;
spa0.z = thing->bbox.zmin;
spa0.x = osd->bbox.xmax;
spa0.y = osd->bbox.ymax;
spa0.z = osd->bbox.zmin;
sp94.x = thing->bbox.xmax;
sp94.y = thing->bbox.ymin;
sp94.z = thing->bbox.zmin;
sp94.x = osd->bbox.xmax;
sp94.y = osd->bbox.ymin;
sp94.z = osd->bbox.zmin;
sp88.x = thing->bbox.xmin;
sp88.y = thing->bbox.ymin;
sp88.z = thing->bbox.zmin;
sp88.x = osd->bbox.xmin;
sp88.y = osd->bbox.ymin;
sp88.z = osd->bbox.zmin;
}
mtx00015be4(cam_get_world_to_screen_mtxf(), &thing->unk02c, &thing->unk0ec);
mtx4_transform_vec(&thing->unk0ec, &spa0, &sp70);
cam0f0b4dec(&sp70, thing->unk134);
mtx4_transform_vec(&thing->unk0ec, &sp94, &sp70);
cam0f0b4dec(&sp70, thing->unk13c);
mtx4_transform_vec(&thing->unk0ec, &sp88, &sp70);
cam0f0b4dec(&sp70, thing->unk144);
mtx00015be4(cam_get_world_to_screen_mtxf(), &osd->unk02c, &osd->unk0ec);
mtx4_transform_vec(&osd->unk0ec, &spa0, &sp70);
cam0f0b4dec(&sp70, osd->unk134);
mtx4_transform_vec(&osd->unk0ec, &sp94, &sp70);
cam0f0b4dec(&sp70, osd->unk13c);
mtx4_transform_vec(&osd->unk0ec, &sp88, &sp70);
cam0f0b4dec(&sp70, osd->unk144);
thing->unk130 = 1;
thing->unk14c = thing->unk13c[1] - thing->unk134[1];
thing->unk150 = -(thing->unk13c[0] - thing->unk134[0]);
thing->unk154 = thing->unk14c * thing->unk134[0] + thing->unk150 * thing->unk134[1];
thing->unk158 = thing->unk14c * thing->unk144[0] + thing->unk150 * thing->unk144[1] - thing->unk154;
osd->unk130 = 1;
osd->unk14c = osd->unk13c[1] - osd->unk134[1];
osd->unk150 = -(osd->unk13c[0] - osd->unk134[0]);
osd->unk154 = osd->unk14c * osd->unk134[0] + osd->unk150 * osd->unk134[1];
osd->unk158 = osd->unk14c * osd->unk144[0] + osd->unk150 * osd->unk144[1] - osd->unk154;
}
for (j = 0; j < 8; j++) {
@ -3204,10 +3218,9 @@ bool chr0f024b18(struct model *model, struct modelnode *node)
mtx4_transform_vec(mtx, &sp64, &sp70);
cam0f0b4dec(&sp70, sp80);
value = thing->unk14c * sp80[0] + thing->unk150 * sp80[1] - thing->unk154;
value = osd->unk14c * sp80[0] + osd->unk150 * sp80[1] - osd->unk154;
if ((thing->unk158 >= 0.0f && value < 0.0f)
|| (thing->unk158 <= 0.0f && value > 0.0f)) {
if ((osd->unk158 >= 0.0f && value < 0.0f) || (osd->unk158 <= 0.0f && value > 0.0f)) {
spb0 = true;
break;
}
@ -3215,12 +3228,12 @@ bool chr0f024b18(struct model *model, struct modelnode *node)
if (!done) {
mtx4_transform_vec(&spb4, &sp64, &sp70);
if (sp70.x >= thing->bbox.xmin
&& sp70.x <= thing->bbox.xmax
&& sp70.y >= thing->bbox.ymin
&& sp70.y <= thing->bbox.ymax
&& ((thing->bbox.zmax < thing->unk008 && sp70.z < thing->bbox.zmax)
|| (thing->unk008 < thing->bbox.zmin && thing->bbox.zmin < sp70.z))) {
if (sp70.x >= osd->bbox.xmin
&& sp70.x <= osd->bbox.xmax
&& sp70.y >= osd->bbox.ymin
&& sp70.y <= osd->bbox.ymax
&& ((osd->bbox.zmax < osd->unk008 && sp70.z < osd->bbox.zmax)
|| (osd->unk008 < osd->bbox.zmin && osd->bbox.zmin < sp70.z))) {
done = true;
}
}
@ -3280,9 +3293,9 @@ void chr_get_blood_colour(s16 bodynum, u8 *colour1, u32 *colour2)
case BODY_THEKING:
case BODY_ELVISWAISTCOAT:
if (colour1) {
colour1[0] = 10;
colour1[0] = 0x0a;
colour1[1] = 0x40;
colour1[2] = 10;
colour1[2] = 0x0a;
}
if (colour2) {
colour2[0] = 0x103010ff;
@ -3294,9 +3307,9 @@ void chr_get_blood_colour(s16 bodynum, u8 *colour1, u32 *colour2)
case BODY_EYESPY:
case BODY_CHICROB:
if (colour1) {
colour1[0] = 10;
colour1[1] = 10;
colour1[2] = 10;
colour1[0] = 0x0a;
colour1[1] = 0x0a;
colour1[2] = 0x0a;
}
if (colour2) {
colour2[0] = 0xb0b030a0;
@ -3311,7 +3324,7 @@ void chr_get_blood_colour(s16 bodynum, u8 *colour1, u32 *colour2)
if (colour1) {
colour1[0] = 0x40;
colour1[1] = 0x19;
colour1[2] = 10;
colour1[2] = 0x0a;
}
if (colour2) {
colour2[0] = 0x302010ff;
@ -3323,8 +3336,8 @@ void chr_get_blood_colour(s16 bodynum, u8 *colour1, u32 *colour2)
if (colour1) {
colour1[0] = 0x40;
colour1[1] = 10;
colour1[2] = 10;
colour1[1] = 0x0a;
colour1[2] = 0x0a;
}
if (colour2) {
@ -3374,7 +3387,7 @@ Gfx *chr_render(struct prop *prop, Gfx *gdl, bool xlupass)
}
chr_get_blood_colour(chr->bodynum, spec, NULL);
chr0f0246e4(spec);
chrs_set_blood_colour(spec);
alpha *= obj_calculate_fade_dist_opacity_frac(prop, model_get_effective_scale(model));
if (g_Vars.currentplayer->visionmode == VISIONMODE_XRAY) {
@ -3491,7 +3504,7 @@ Gfx *chr_render(struct prop *prop, Gfx *gdl, bool xlupass)
colour[3] = 0xff;
}
renderdata.envcolour = var80062a48[0] << 24 | var80062a48[1] << 16 | var80062a48[2] << 8;
renderdata.envcolour = g_ChrBloodColour[0] << 24 | g_ChrBloodColour[1] << 16 | g_ChrBloodColour[2] << 8;
renderdata.fogcolour = colour[0] << 24 | colour[1] << 16 | colour[2] << 8 | colour[3];
if (alpha < 0xff) {
@ -3548,8 +3561,8 @@ Gfx *chr_render(struct prop *prop, Gfx *gdl, bool xlupass)
g_Vars.currentplayerstats->drawplayercount++;
if (chr0f024738(chr)) {
var8005efc4 = chr0f024b18;
if (chr_find_onscreen_doors(chr)) {
g_ModelShouldRenderGunDlCallback = chr_should_render_gundl;
}
// Render the chr's model
@ -3565,7 +3578,7 @@ Gfx *chr_render(struct prop *prop, Gfx *gdl, bool xlupass)
gdl = renderdata.gdl;
var8005efc4 = NULL;
g_ModelShouldRenderGunDlCallback = NULL;
// Render shadow
if (xlupass) {
@ -3684,7 +3697,7 @@ void chr_emit_sparks(struct chrdata *chr, struct prop *prop, s32 hitpart, struct
#endif
}
void chr0f0260c4(struct model *model, s32 hitpart, struct modelnode *node, struct coord *arg3)
void chr_bruise_from_stabby_projectile(struct model *model, s32 hitpart, struct modelnode *node, struct coord *arg3)
{
struct modelnode *bestnode = NULL;
s32 mindist = 0x7fffffff;
@ -4786,45 +4799,45 @@ void chr_hit(struct shotdata *shotdata, struct hit *hit)
}
}
void chr0f028490(f32 arg1)
void chrs_set_stage_translation_thing(f32 arg1)
{
// empty
}
void chr0f028498(bool value)
void chranimdebug_everyone(bool enable)
{
var8006296c = value;
var8005efbc = value;
g_ChrsAnimDebugSetAll = enable;
g_ChrsAnimDebugForceLoop = enable;
}
void chr0f0284ac(s32 arg0)
void chranimdebug_decrement_anim(s32 quantity)
{
g_SelectedAnimNum -= arg0;
g_ChrsAnimDebugAnimNum -= quantity;
if (g_SelectedAnimNum <= 0) {
g_SelectedAnimNum = anim_get_num_animations() - 1;
if (g_ChrsAnimDebugAnimNum <= 0) {
g_ChrsAnimDebugAnimNum = anim_get_num_animations() - 1;
}
}
void chr0f0284f4(s32 arg0)
void chranimdebug_increment_anim(s32 quantity)
{
g_SelectedAnimNum += arg0;
g_ChrsAnimDebugAnimNum += quantity;
if (g_SelectedAnimNum >= anim_get_num_animations()) {
g_SelectedAnimNum = 1;
if (g_ChrsAnimDebugAnimNum >= anim_get_num_animations()) {
g_ChrsAnimDebugAnimNum = 1;
}
}
void chrs_toggle_anim_debug(void)
void chranimdebug_toggle_paused(void)
{
var80062974 = !var80062974;
g_ChrsAnimDebugPaused = !g_ChrsAnimDebugPaused;
}
void chrs_set_anims_playing(s32 arg0)
void chranimdebug_select_anim(bool enable)
{
var80062978 = arg0;
g_ChrsAnimDebugSlow = enable;
main_override_variable("selectanimnum", &g_SelectedAnimNum);
main_override_variable("selectanimnum", &g_ChrsAnimDebugAnimNum);
}
void chrs_check_for_noise(f32 noiseradius)

View File

@ -15103,7 +15103,7 @@ struct prop *chr_spawn_at_coord(s32 bodynum, s32 headnum, struct coord *pos, Roo
struct chrdata *chr;
if (model) {
prop = chr_allocate(model, &pos2, rooms2, angle, ailist);
prop = chr_create_with_model(model, &pos2, rooms2, angle, ailist);
if (prop) {
prop_activate_this_frame(prop);

View File

@ -433,7 +433,7 @@ bool ai_chr_do_animation(void)
chr_try_start_anim(chr, anim_id, fstartframe, fendframe, cmd[8], cmd[9], speed);
if (startframe == 0xfffe) {
chr0f0220ec(chr, 1, true);
chr_update_anim(chr, 1, true);
if (chr->prop->type == PROPTYPE_PLAYER) {
u32 playernum = playermgr_get_player_num_by_prop(chr->prop);

View File

@ -11,12 +11,12 @@ void chrmgr_reset(void)
{
s32 i;
var80062968 = 1;
var8006296c = 0;
g_SelectedAnimNum = 0;
var80062974 = 0;
var80062978 = 0;
var8006297c = 0;
g_ChrsAnimSpeed = 1;
g_ChrsAnimDebugSetAll = false;
g_ChrsAnimDebugAnimNum = 0;
g_ChrsAnimDebugPaused = false;
g_ChrsAnimDebugSlow = false;
g_ChrsDebugPatrols = false;
g_NextChrnum = 5000;
g_ChrSlots = NULL;
g_NumChrSlots = 0;
@ -27,11 +27,11 @@ void chrmgr_reset(void)
g_ShieldHits[i].prop = NULL;
}
g_ShieldHitActive = 0;
g_ShieldHitActive = false;
g_NumChrs = 0;
g_Chrnums = NULL;
g_ChrIndexes = NULL;
var80062960 = memp_alloc(ALIGN16(15 * sizeof(struct var80062960)), MEMPOOL_STAGE);
g_ChrsOnscreenDoors = memp_alloc(ALIGN16(15 * sizeof(struct onscreendoor)), MEMPOOL_STAGE);
for (i = 0; i < ARRAYCOUNT(var8009ccc0); i++) {
var8009ccc0[i] = (void *)ALIGN64(memp_alloc(16 * 16 * sizeof(u16) + 0x40, MEMPOOL_STAGE));

View File

@ -1300,7 +1300,7 @@ Gfx *lv_render(Gfx *gdl)
props_test_for_pickup();
gdl = bg_render(gdl);
chr0f028498(var80075d68 == 15 || g_AnimHostEnabled);
chranimdebug_everyone(var80075d68 == 15 || g_AnimHostEnabled);
gdl = props_render_beams(gdl);
gdl = shards_render(gdl);
gdl = sparks_render(gdl);

View File

@ -1452,8 +1452,8 @@ void player_tick_chr_body(void)
g_Vars.currentplayer->model00d4 = body_instantiate_model_to_addr(bodynum, headnum, bodymodeldef, headmodeldef, false, model, true, true);
chr0f020b14(g_Vars.currentplayer->prop, g_Vars.currentplayer->model00d4, &g_Vars.currentplayer->prop->pos,
g_Vars.currentplayer->prop->rooms, turnangle, 0);
chr_place(g_Vars.currentplayer->prop, g_Vars.currentplayer->model00d4, &g_Vars.currentplayer->prop->pos,
g_Vars.currentplayer->prop->rooms, turnangle, NULL);
g_Vars.currentplayer->prop->type = PROPTYPE_PLAYER;
chr = g_Vars.currentplayer->prop->chr;

View File

@ -373,7 +373,7 @@ void player_reset(void)
prop_activate(g_Vars.currentplayer->prop);
prop_enable(g_Vars.currentplayer->prop);
chr_init(g_Vars.currentplayer->prop, NULL);
chr_allocate(g_Vars.currentplayer->prop, NULL);
if (g_Vars.coopplayernum >= 0) {
g_Vars.currentplayer->prop->chr->team = TEAM_ALLY;

View File

@ -2225,7 +2225,7 @@ void props_tick_player(bool islastplayer)
props_defrag_room_props();
}
chr0f02472c();
chrs_reset_onscreen_doors();
}
void props_tick_pad_effects(void)

View File

@ -4698,11 +4698,11 @@ void weapon_tick(struct prop *prop)
}
}
void func0f07063c(struct prop *prop, bool arg1)
void func0f07063c(struct prop *prop, bool fulltick)
{
struct defaultobj *obj = prop->obj;
if (arg1) {
if (fulltick) {
if (obj->type == OBJTYPE_AMMOCRATE || obj->type == OBJTYPE_MULTIAMMOCRATE) {
ammocrate_tick(prop);
} else if (obj->type == OBJTYPE_WEAPON) {
@ -7006,7 +7006,7 @@ s32 projectile_tick(struct defaultobj *obj, bool *embedded)
mtx0001719c(sp184->m, sp188.m);
mtx4_transform_vec_in_place(&sp188, &sp1c8);
chr0f0260c4(g_EmbedModel, g_EmbedHitPart, g_EmbedNode, &sp1c8);
chr_bruise_from_stabby_projectile(g_EmbedModel, g_EmbedHitPart, g_EmbedNode, &sp1c8);
}
}
}

View File

@ -44,7 +44,7 @@ extern s32 g_NumGlobalAilists;
extern s32 g_NumLvAilists;
extern bool g_ModelDistanceDisabled;
extern f32 g_ModelDistanceScale;
extern bool var8005efbc;
extern bool g_ChrsAnimDebugForceLoop;
extern f32 var8005efc0;
extern u8 var8005efb0_2;
extern u32 var8005efd0;
@ -128,13 +128,13 @@ extern u8 var80062948;
extern u8 var8006294c;
extern u32 var80062950;
extern bool g_WeatherTickEnabled;
extern struct var80062960 *var80062960;
extern f32 var80062968;
extern bool var8006296c;
extern s32 g_SelectedAnimNum;
extern u32 var80062974;
extern u32 var80062978;
extern u32 var8006297c;
extern struct onscreendoor *g_ChrsOnscreenDoors;
extern f32 g_ChrsAnimSpeed;
extern bool g_ChrsAnimDebugSetAll;
extern s32 g_ChrsAnimDebugAnimNum;
extern u32 g_ChrsAnimDebugPaused;
extern u32 g_ChrsAnimDebugSlow;
extern bool g_ChrsDebugPatrols;
extern s32 g_NextChrnum;
extern struct chrdata *g_ChrSlots;
extern s32 g_NumChrSlots;

View File

@ -14,18 +14,18 @@ bool chr_ascend(struct chrdata *chr, struct coord *pos, RoomNum *rooms, f32 amou
bool chr_ascend(struct chrdata *chr, struct coord *pos, RoomNum *rooms, f32 amount);
#endif
bool chr0f01f378(struct model *model, struct coord *arg1, struct coord *arg2, f32 *mangroundptr);
bool chr_update_position(struct model *model, struct coord *arg1, struct coord *arg2, f32 *mangroundptr);
s32 chrs_get_num_free(void);
s16 chrs_get_next_unused_chrnum(void);
struct prop *chr0f020b14(struct prop *prop, struct model *model, struct coord *pos, RoomNum *rooms, f32 arg3, u8 *ailist);
struct prop *chr_place(struct prop *prop, struct model *model, struct coord *pos, RoomNum *rooms, f32 arg3, u8 *ailist);
void chr_remove(struct prop *prop, bool free);
void chr_update_aim_properties(struct chrdata *chr);
void chr_flinch_body(struct chrdata *chr);
void chr_flinch_head(struct chrdata *chr, f32 arg1);
f32 chr_get_flinch_amount(struct chrdata *chr);
void chr_find_entered_rooms_at_pos(struct chrdata *chr, struct coord *pos, RoomNum *rooms);
void chr0f0220ec(struct chrdata *chr, s32 lvupdate240, bool arg2);
void chr0f022214(struct chrdata *chr, struct prop *child, bool fulltick);
void chr_update_anim(struct chrdata *chr, s32 lvupdate240, bool arg2);
void chr_tick_child(struct chrdata *chr, struct prop *child, bool fulltick);
void chr_update_cloak(struct chrdata *chr);
s32 chr_get_cloak_alpha(struct chrdata *chr);
void chr_set_poisoned(struct chrdata *chr, struct prop *poisonprop);
@ -35,20 +35,20 @@ s32 chr_tick(struct prop *prop);
void chr_drop_concealed_items(struct chrdata *chr);
void chr_set_hudpiece_visible(struct chrdata *chr, bool visible);
void chr_drop_items_for_owner_reap(struct chrdata *chr);
void chr0f0246e4(u8 *arg0);
bool chr0f024738(struct chrdata *chr);
bool chr0f024b18(struct model *model, struct modelnode *node);
void chrs_set_blood_colour(u8 *rgb);
bool chr_find_onscreen_doors(struct chrdata *chr);
bool chr_should_render_gundl(struct model *model, struct modelnode *node);
void chr_render_attached_object(struct prop *prop, struct modelrenderdata *renderdata, bool xlupass, struct chrdata *chr);
void chr_get_blood_colour(s16 bodynum, u8 *colour1, u32 *colour2);
Gfx *chr_render(struct prop *prop, Gfx *gdl, bool xlupass);
void chr_emit_sparks(struct chrdata *chr, struct prop *prop, s32 hitpart, struct coord *coord, struct coord *coord2, struct chrdata *chr2);
void chr0f0260c4(struct model *model, s32 hitpart, struct modelnode *node, struct coord *arg3);
void chr_bruise_from_stabby_projectile(struct model *model, s32 hitpart, struct modelnode *node, struct coord *arg3);
void chr_bruise(struct model *model, s32 hitpart, struct modelnode *node, struct coord *arg3);
void chr_disfigure(struct chrdata *chr, struct coord *exppos, f32 damageradius);
f32 chr_get_hit_radius(struct chrdata *chr);
void chr_test_hit(struct prop *prop, struct shotdata *shotdata, bool isshooting, bool cheap);
void chr_hit(struct shotdata *shotdata, struct hit *hit);
void chr0f028498(bool value);
void chranimdebug_everyone(bool enable);
void chrs_check_for_noise(f32 noiseradius);
bool chr_calculate_auto_aim(struct prop *prop, struct coord *arg1, f32 *arg2, f32 *arg3);
s32 shieldhit_node_to_cmnum(struct prop *arg0, struct modelnode *node, struct model *model, struct prop *arg3);
@ -70,25 +70,21 @@ void chr_set_drcaroll_images(struct chrdata *drcaroll, s32 imageleft, s32 imager
s32 chrs_get_num_slots(void);
void chr_register(s32 chrnum, s32 chrindex);
Vtx *chr_allocate_vertices(s32 numvertices);
void chrs_set_var8006297c(u32 arg0);
u32 chrs_get_var8006297c(void);
void chrs_set_var80062980(u32 arg0);
u32 chrs_get_var80062980(void);
void chr_set_perim_enabled(struct chrdata *chr, bool enable);
void chr_set_max_damage(struct chrdata *chr, f32 maxdamage);
f32 chr_get_max_damage(struct chrdata *chr);
void chr_add_health(struct chrdata *chr, f32 health);
f32 chr_get_armor(struct chrdata *chr);
void chr_init(struct prop *prop, u8 *ailist);
struct prop *chr_allocate(struct model *model, struct coord *pos, RoomNum *rooms, f32 faceangle, u8 *ailist);
void chr_allocate(struct prop *prop, u8 *ailist);
struct prop *chr_create_with_model(struct model *model, struct coord *pos, RoomNum *rooms, f32 faceangle, u8 *ailist);
void chr_clear_references(s32 propnum);
void chr_find_entered_rooms(struct chrdata *chr, RoomNum *room);
void chr_detect_rooms(struct chrdata *chr);
void chr_cloak(struct chrdata *chr, bool arg1);
void chr_uncloak(struct chrdata *chr, bool value);
void chr_uncloak_temporarily(struct chrdata *chr);
void chr0f02472c(void);
void chr0f028490(f32 arg1);
void chrs_reset_onscreen_doors(void);
void chrs_set_stage_translation_thing(f32 arg1);
struct chrdata *chr_find_by_literal_id(s32 chrnum);
struct prop *chr_get_held_prop(struct chrdata *chr, s32 hand);
struct prop *chr_get_held_usable_prop(struct chrdata *chr, s32 hand);

View File

@ -4,7 +4,7 @@
#include "data.h"
#include "types.h"
extern bool (*var8005efc4)(struct model *model, struct modelnode *node);
extern bool (*g_ModelShouldRenderGunDlCallback)(struct model *model, struct modelnode *node);
extern Vtx *(*g_ModelVtxAllocatorFunc)(s32 numvertices);
extern void (*g_ModelJointPositionedFunc)(s32 mtxindex, Mtxf *mtx);

View File

@ -5868,7 +5868,7 @@ struct hatposition {
f32 unk14;
};
struct var80062960 {
struct onscreendoor {
/*0x000*/ struct prop *prop;
/*0x004*/ bool unk004;
/*0x008*/ f32 unk008;

View File

@ -87,9 +87,9 @@ u32 var8005efb0 = 0;
bool g_ModelDistanceDisabled = false;
f32 g_ModelDistanceScale = 1;
bool var8005efbc = false;
bool g_ChrsAnimDebugForceLoop = false;
f32 var8005efc0 = 0;
bool (*var8005efc4)(struct model *model, struct modelnode *node) = NULL;
bool (*g_ModelShouldRenderGunDlCallback)(struct model *model, struct modelnode *node) = NULL;
#if VERSION >= VERSION_PAL_BETA
bool var8005efd8_2 = false;
@ -1712,7 +1712,7 @@ f32 model_get_effective_anim_speed(struct model *model)
s32 model_constrain_or_wrap_anim_frame(s32 frame, s16 animnum, f32 endframe)
{
if (frame < 0) {
if (var8005efbc || (g_Anims[animnum].flags & ANIMFLAG_LOOP)) {
if (g_ChrsAnimDebugForceLoop || (g_Anims[animnum].flags & ANIMFLAG_LOOP)) {
frame = anim_get_num_frames(animnum) - (-frame % anim_get_num_frames(animnum));
} else {
frame = 0;
@ -1720,7 +1720,7 @@ s32 model_constrain_or_wrap_anim_frame(s32 frame, s16 animnum, f32 endframe)
} else if (endframe >= 0 && frame > (s32)endframe) {
frame = ceil(endframe);
} else if (frame >= anim_get_num_frames(animnum)) {
if (var8005efbc || (g_Anims[animnum].flags & ANIMFLAG_LOOP)) {
if (g_ChrsAnimDebugForceLoop || (g_Anims[animnum].flags & ANIMFLAG_LOOP)) {
frame = frame % anim_get_num_frames(animnum);
} else {
frame = anim_get_num_frames(animnum) - 1;
@ -3153,7 +3153,7 @@ void model_render_node_gundl(struct modelrenderdata *renderdata, struct model *m
{
struct modelrodata_gundl *rodata = &node->rodata->gundl;
if (var8005efc4 && !var8005efc4(model, node)) {
if (g_ModelShouldRenderGunDlCallback && !g_ModelShouldRenderGunDlCallback(model, node)) {
return;
}
@ -3205,7 +3205,7 @@ void model_render_node_dl(struct modelrenderdata *renderdata, struct model *mode
{
union modelrodata *rodata = node->rodata;
if (var8005efc4 && !var8005efc4(model, node)) {
if (g_ModelShouldRenderGunDlCallback && !g_ModelShouldRenderGunDlCallback(model, node)) {
return;
}