From 63252f71e1ef576a84a42229b0733115dbe0bcde Mon Sep 17 00:00:00 2001 From: Ryan Dwyer Date: Sat, 17 Aug 2024 19:07:33 +1000 Subject: [PATCH] Improve shieldhit functions --- src/game/botact.c | 2 +- src/game/chr.c | 259 ++++++++++++++++++----------------- src/game/chraction.c | 96 +++++++------ src/game/chraicommands.c | 10 +- src/game/chrmgr.c | 4 +- src/game/nbomb.c | 2 +- src/game/player.c | 2 +- src/game/prop.c | 4 +- src/game/propobj.c | 70 +++++----- src/include/constants.h | 3 +- src/include/game/chr.h | 20 +-- src/include/game/chraction.h | 8 +- src/include/types.h | 6 +- 13 files changed, 257 insertions(+), 229 deletions(-) diff --git a/src/game/botact.c b/src/game/botact.c index 03f1f00cf..d077954fc 100644 --- a/src/game/botact.c +++ b/src/game/botact.c @@ -267,7 +267,7 @@ bool botact_shoot_farsight(struct chrdata *chr, s32 arg1, struct coord *vector, } chr_emit_sparks(oppchr, oppprop, hitpart, &oppprop->pos, vector, chr); - func0f0341dc(oppchr, damage, vector, &gset, chr->prop, HITPART_GENERAL, oppprop, node, model, side, 0); + chr_damage_by_impact(oppchr, damage, vector, &gset, chr->prop, HITPART_GENERAL, oppprop, node, model, side, NULL); } } diff --git a/src/game/chr.c b/src/game/chr.c index 5a166ab37..2c1d09d24 100644 --- a/src/game/chr.c +++ b/src/game/chr.c @@ -2295,7 +2295,7 @@ void chr_tick_poisoned(struct chrdata *chr) if (chr->poisoncounter <= 0) { if (!g_Vars.normmplayerisrunning) { - chr_damage_by_misc(chr, 100, &coord, &gset, chr->poisonprop); + chr_damage_by_dizziness(chr, 100, &coord, &gset, chr->poisonprop); chr_flinch_head(chr, M_PI); } @@ -2306,7 +2306,7 @@ void chr_tick_poisoned(struct chrdata *chr) if (g_Vars.normmplayerisrunning) { if (chr->poisoncounter / TICKS(720) != (chr->poisoncounter + g_Vars.lvupdate240) / TICKS(720)) { - chr_damage_by_misc(chr, 1.3f, &coord, &gset, chr->poisonprop); + chr_damage_by_dizziness(chr, 1.3f, &coord, &gset, chr->poisonprop); } } } @@ -3543,7 +3543,7 @@ Gfx *chr_render(struct prop *prop, Gfx *gdl, bool xlupass) } if (chr->race == RACE_DRCAROLL) { - chr_set_dr_caroll_images(chr, chr->drcarollimage_left, chr->drcarollimage_right); + chr_set_drcaroll_images(chr, chr->drcarollimage_left, chr->drcarollimage_right); } g_Vars.currentplayerstats->drawplayercount++; @@ -3834,7 +3834,7 @@ void chr0f0260c4(struct model *model, s32 hitpart, struct modelnode *node, struc } // Do a pass over the entire model's tree, looking for vertices that share - // the chosen vertex, and darken then. + // the chosen vertex, and darken them. curnode = model->definition->rootnode; while (curnode) { @@ -4587,7 +4587,7 @@ void chr_hit(struct shotdata *shotdata, struct hit *hit) Mtxf spb0; struct coord hitpos; struct coord sp98; - s16 sp90[3]; + s16 hitpos_s16[3]; u8 ismelee = false; struct weaponfunc *func = gset_get_weapon_function(&shotdata->gset); f32 shield; @@ -4617,15 +4617,15 @@ void chr_hit(struct shotdata *shotdata, struct hit *hit) chr_emit_sparks(chr, hit->prop, hit->hitpart, &hitpos, &shotdata->gundir3d, g_Vars.currentplayer->prop->chr); - sp90[0] = hit->hitthing.pos.x; - sp90[1] = hit->hitthing.pos.y; - sp90[2] = hit->hitthing.pos.z; + hitpos_s16[0] = hit->hitthing.pos.x; + hitpos_s16[1] = hit->hitthing.pos.y; + hitpos_s16[2] = hit->hitthing.pos.z; shield = chr_get_shield(chr); - func0f0341dc(chr, gset_get_damage(&shotdata->gset), &shotdata->gundir3d, &shotdata->gset, + chr_damage_by_impact(chr, gset_get_damage(&shotdata->gset), &shotdata->gundir3d, &shotdata->gset, g_Vars.currentplayer->prop, hit->hitpart, hit->prop, hit->bboxnode, - hit->model, hit->hitthing.unk28 / 2, sp90); + hit->model, hit->hitthing.unk28 / 2, hitpos_s16); if (g_Vars.antiplayernum >= 0 && g_Vars.currentplayer == g_Vars.anti @@ -5051,38 +5051,63 @@ bool chr_calculate_auto_aim(struct prop *prop, struct coord *arg1, f32 *arg2, f3 return false; } -bool chr0f028d50(struct prop *arg0, struct prop *arg1, struct modelnode *node, struct model *model, s32 *total) +/** + * Iterate the iterprop, its children and siblings to find wantprop. + * Sum the number of matrix slots in the model data of each model that has been iterated. + * + * This function is recursive, where each recursion is for an attached child + * or sibling. + * + * @bug: The matrices are counted from the same model definition + * regardless of what model the children have. + */ +bool shieldhit_find_cmnum_for_prop(struct prop *iterprop, struct prop *wantprop, struct modelnode *node, struct model *model, s32 *total) { - if (arg1 == arg0) { + if (wantprop == iterprop) { *total += model_find_node_mtx_index(node, 0); return true; } *total += model->definition->nummatrices; - if (arg0->child && chr0f028d50(arg0->child, arg1, node, model, total) > 0) { + if (iterprop->child && shieldhit_find_cmnum_for_prop(iterprop->child, wantprop, node, model, total) > 0) { return true; } - if (arg0->next && chr0f028d50(arg0->next, arg1, node, model, total) > 0) { + if (iterprop->next && shieldhit_find_cmnum_for_prop(iterprop->next, wantprop, node, model, total) > 0) { return true; } return false; } -s32 chr0f028e18(struct prop *arg0, struct modelnode *node, struct model *model, struct prop *arg3) +/** + * Given a model node, find the associated cmnum. + * + * The node may be on the root prop (chr or obj). It may also be a node on an + * attached prop such as a knife or mine. + */ +s32 shieldhit_node_to_cmnum(struct prop *wantprop, struct modelnode *node, struct model *model, struct prop *rootprop) { - s32 result = 0; + s32 cmnum = 0; - if (chr0f028d50(arg3, arg0, node, model, &result)) { - return result; + if (shieldhit_find_cmnum_for_prop(rootprop, wantprop, node, model, &cmnum)) { + return cmnum; } return -1; } -bool chr0f028e6c(s32 arg0, struct prop *prop, struct prop **propptr, struct modelnode **nodeptr, struct model **modelptr) +/** + * Convert a cmnum to a prop, model and node. + * + * For example, a chr might have 14 matrices, and they might have a mine + * attached to them which has one matrix. cmnums 0-13 will refer to matrices in + * the chr's model, while cmnum 14 will be the mine. + * + * Return true if the cmnum was valid and values were written to the pointers. + */ +bool shieldhit_cmnum_to_node(s32 cmnum, struct prop *prop, struct prop **propptr, struct modelnode **nodeptr, struct model **modelptr) { \ while (true) { bool result = false; @@ -5097,11 +5122,11 @@ bool chr0f028e6c(s32 arg0, struct prop *prop, struct prop **propptr, struct mode if (1); - if (arg0 >= model->definition->nummatrices) { - arg0 -= model->definition->nummatrices; + if (cmnum >= model->definition->nummatrices) { + cmnum -= model->definition->nummatrices; if (prop->child) { - result = chr0f028e6c(arg0, prop->child, propptr, nodeptr, modelptr); + result = shieldhit_cmnum_to_node(cmnum, prop->child, propptr, nodeptr, modelptr); } if (prop->next && !result) { @@ -5110,7 +5135,7 @@ bool chr0f028e6c(s32 arg0, struct prop *prop, struct prop **propptr, struct mode } } else { *propptr = prop; - *nodeptr = model_find_node_by_mtx_index(model, arg0); + *nodeptr = model_find_node_by_mtx_index(model, cmnum); *modelptr = model; result = true; } @@ -5119,14 +5144,14 @@ bool chr0f028e6c(s32 arg0, struct prop *prop, struct prop **propptr, struct mode } } -void shieldhit_create(struct prop *prop, f32 shield, struct prop *arg2, struct modelnode *node, struct model *model, s32 side, s16 *arg6) +void shieldhit_create(struct prop *rootprop, f32 shield, struct prop *hitprop, struct modelnode *node, struct model *model, s32 side, s16 *hitpos) { struct shieldhit *shieldhit = NULL; s32 i; s32 j; // Find any slot that isn't in use (ie. prop is NULL) - for (i = 0; i < 20; i++) { + for (i = 0; i < MAX_SHIELDHITS; i++) { if (g_ShieldHits[i].prop == NULL) { shieldhit = &g_ShieldHits[i]; break; @@ -5138,7 +5163,7 @@ void shieldhit_create(struct prop *prop, f32 shield, struct prop *arg2, struct m struct shieldhit *oldesthit = NULL; s32 oldestframe = g_Vars.lvframe60; - for (i = 0; i < 20; i++) { + for (i = 0; i < MAX_SHIELDHITS; i++) { if (g_ShieldHits[i].lvframe60 < oldestframe) { oldesthit = &g_ShieldHits[i]; oldestframe = g_ShieldHits[i].lvframe60; @@ -5149,7 +5174,7 @@ void shieldhit_create(struct prop *prop, f32 shield, struct prop *arg2, struct m } if (shieldhit) { - shieldhit->prop = prop; + shieldhit->prop = rootprop; shieldhit->node = node; shieldhit->model = model; shieldhit->side = side; @@ -5162,19 +5187,19 @@ void shieldhit_create(struct prop *prop, f32 shield, struct prop *arg2, struct m shieldhit->unk011 = 2 + (random() % 6); shieldhit->shield = shield; - if (arg6) { - shieldhit->unk012 = arg6[0]; - shieldhit->unk014 = arg6[1]; - shieldhit->unk016 = arg6[2]; + if (hitpos) { + shieldhit->hitposx = hitpos[0]; + shieldhit->hitposy = hitpos[1]; + shieldhit->hitposz = hitpos[2]; } else { - shieldhit->unk012 = 0x7fff; + shieldhit->hitposx = 0x7fff; } if (node) { bool pass = true; - for (i = 0; i < 20; i++) { - if (g_ShieldHits[i].prop == prop) { + for (i = 0; i < MAX_SHIELDHITS; i++) { + if (g_ShieldHits[i].prop == rootprop) { for (j = 0; j < 32; j++) { if (shieldhit->unk018[j] != -1 && shieldhit->unk018[j] != -2) { pass = false; @@ -5189,7 +5214,7 @@ void shieldhit_create(struct prop *prop, f32 shield, struct prop *arg2, struct m } if (pass) { - s32 index = chr0f028e18(arg2, node, model, prop); + s32 index = shieldhit_node_to_cmnum(hitprop, node, model, rootprop); if (index < 32) { shieldhit->unk018[index] = 0; @@ -5198,10 +5223,10 @@ void shieldhit_create(struct prop *prop, f32 shield, struct prop *arg2, struct m } } - if (prop->type == PROPTYPE_CHR || prop->type == PROPTYPE_PLAYER) { - prop->chr->hidden2 |= CHRH2FLAG_SHIELDHIT; - } else if (prop->type == PROPTYPE_OBJ || prop->type == PROPTYPE_WEAPON || prop->type == PROPTYPE_DOOR) { - prop->obj->flags3 |= OBJFLAG3_SHIELDHIT; + if (rootprop->type == PROPTYPE_CHR || rootprop->type == PROPTYPE_PLAYER) { + rootprop->chr->hidden2 |= CHRH2FLAG_SHIELDHIT; + } else if (rootprop->type == PROPTYPE_OBJ || rootprop->type == PROPTYPE_WEAPON || rootprop->type == PROPTYPE_DOOR) { + rootprop->obj->flags3 |= OBJFLAG3_SHIELDHIT; } } @@ -5218,7 +5243,7 @@ void shieldhit_remove(struct shieldhit *shieldhit) // Check if there are other shield hits active g_ShieldHitActive = false; - for (i = 0; i < 20; i++) { + for (i = 0; i < MAX_SHIELDHITS; i++) { if (g_ShieldHits[i].prop) { g_ShieldHitActive = true; break; @@ -5226,7 +5251,7 @@ void shieldhit_remove(struct shieldhit *shieldhit) } // Check if the prop being removed has other shield hits too - for (i = 0; i < 20; i++) { + for (i = 0; i < MAX_SHIELDHITS; i++) { if (prop == g_ShieldHits[i].prop) { exists = true; break; @@ -5251,47 +5276,47 @@ void shieldhits_remove_by_prop(struct prop *prop) { s32 i; - for (i = 0; i < 20; i++) { + for (i = 0; i < MAX_SHIELDHITS; i++) { if (prop == g_ShieldHits[i].prop) { shieldhit_remove(&g_ShieldHits[i]); } } } -s32 chr0f02932c(struct prop *prop, s32 arg1) +s32 shieldhit_find_parentnode_cmnum(struct prop *prop, s32 prevcmnum) { - s32 result = -1; + s32 cmnum = -1; struct modelnode *node2; struct prop *prop2; struct modelnode *node; struct model *model; - if (chr0f028e6c(arg1, prop, &prop2, &node, &model) && node) { + if (shieldhit_cmnum_to_node(prevcmnum, prop, &prop2, &node, &model) && node) { node2 = model_node_find_parent_mtx_node(node); if (node2) { - result = chr0f028e18(prop2, node2, model, prop); + cmnum = shieldhit_node_to_cmnum(prop2, node2, model, prop); } else if (prop2->parent && model->attachedtomodel && model->attachedtonode) { - result = chr0f028e18(prop2->parent, model->attachedtonode, model->attachedtomodel, prop); + cmnum = shieldhit_node_to_cmnum(prop2->parent, model->attachedtonode, model->attachedtomodel, prop); } } - return result; + return cmnum; } -s32 chr0f0293ec(struct prop *prop, s32 cmnum) +s32 shieldhit_find_childnode_cmnum(struct prop *prop, s32 prevcmnum) { - s32 result = -1; + s32 cmnum = -1; struct modelnode *node2; struct prop *prop2; struct modelnode *node; struct model *model; - if (chr0f028e6c(cmnum, prop, &prop2, &node, &model) && node) { + if (shieldhit_cmnum_to_node(prevcmnum, prop, &prop2, &node, &model) && node) { node2 = model_node_find_child_mtx_node(node); if (node2) { - result = chr0f028e18(prop2, node2, model, prop); + cmnum = shieldhit_node_to_cmnum(prop2, node2, model, prop); } else { struct prop *child = prop2->child; @@ -5300,7 +5325,7 @@ s32 chr0f0293ec(struct prop *prop, s32 cmnum) if (model == parentmodel->attachedtomodel) { if (node == parentmodel->attachedtonode) { - result = chr0f028e18(child, parentmodel->definition->rootnode, parentmodel, prop); + cmnum = shieldhit_node_to_cmnum(child, parentmodel->definition->rootnode, parentmodel, prop); break; } } @@ -5310,22 +5335,22 @@ s32 chr0f0293ec(struct prop *prop, s32 cmnum) } } - return result; + return cmnum; } -s32 chr0f0294cc(struct prop *prop, s32 arg1) +s32 shieldhit_find_anynode_cmnum(struct prop *prop, s32 prevcmnum) { - s32 result = -1; + s32 cmnum = -1; struct prop *child; struct prop *prop2; struct modelnode *node2; struct model *model2; - if (chr0f028e6c(arg1, prop, &prop2, &node2, &model2) && node2) { + if (shieldhit_cmnum_to_node(prevcmnum, prop, &prop2, &node2, &model2) && node2) { struct modelnode *node3 = model_node_find_child_or_parent_mtx_node(node2); if (node3) { - result = chr0f028e18(prop2, node3, model2, prop); + cmnum = shieldhit_node_to_cmnum(prop2, node3, model2, prop); } else if (model_node_find_parent_mtx_node(node2) == NULL && prop2->parent) { child = prop2->parent->child; @@ -5341,7 +5366,7 @@ s32 chr0f0294cc(struct prop *prop, s32 arg1) if (parent->attachedtomodel == model2->attachedtomodel) { if (parent->attachedtonode == model2->attachedtonode) { - result = chr0f028e18(child, parent->definition->rootnode, parent, prop); + cmnum = shieldhit_node_to_cmnum(child, parent->definition->rootnode, parent, prop); break; } } @@ -5352,45 +5377,35 @@ s32 chr0f0294cc(struct prop *prop, s32 arg1) } } - return result; + return cmnum; } -void chr0f0295f8(f32 arg0, s32 *arg1, s32 *arg2, s32 *arg3) +void shieldhit_health_to_rgb(f32 health, s32 *r, s32 *g, s32 *b) { - if (arg0 < 1.5f) { - *arg1 = 57 - (s32)((1.5f - arg0) * 28.0f); - *arg2 = 75 - (s32)((1.5f - arg0) * 20.0f); - *arg3 = 0; - return; + if (health < 1.5f) { + *r = 57 - (s32) ((1.5f - health) * 28); + *g = 75 - (s32) ((1.5f - health) * 20); + *b = 0; + } else if (health < 3.0f) { + *r = 102 - (s32) ((3.0f - health) * 30); + *g = 90 - (s32) ((3.0f - health) * 10); + *b = 0; + } else if (health < 4.5f) { + *r = 174 - (s32) ((4.5f - health) * 48); + *g = 129 - (s32) ((4.5f - health) * 26); + *b = 0; + } else if (health < 6.0f) { + *r = 162 - (s32) ((6.0f - health) * -8); + *g = 54 - (s32) ((6.0f - health) * -50); + *b = 0; + } else { + *r = 162; + *g = 54; + *b = 0; } - - if (arg0 < 3.0f) { - *arg1 = 102 - (s32)((3.0f - arg0) * 30.0f); - *arg2 = 90 - (s32)((3.0f - arg0) * 10.0f); - *arg3 = 0; - return; - } - - if (arg0 < 4.5f) { - *arg1 = 174 - (s32)((4.5f - arg0) * 48.0f); - *arg2 = 129 - (s32)((4.5f - arg0) * 26.0f); - *arg3 = 0; - return; - } - - if (arg0 < 6.0f) { - *arg1 = 162 - (s32)((6.0f - arg0) * -8.0f); - *arg2 = 54 - (s32)((6.0f - arg0) * -50.0f); - *arg3 = 0; - return; - } - - *arg1 = 162; - *arg2 = 54; - *arg3 = 0; } -f32 prop_get_shield_thing(struct prop **propptr) +f32 shieldhit_get_health(struct prop **propptr) { struct prop *prop = *propptr; @@ -5405,8 +5420,8 @@ f32 prop_get_shield_thing(struct prop **propptr) return 4; } - // If this function is returning the shield amount, - // why would it return 8 for all objects here? + // Objects don't have shields with health, + // hence why the max health is returned here. return 8; } @@ -5415,7 +5430,7 @@ f32 prop_get_shield_thing(struct prop **propptr) bool g_ShieldHitActive = false; -Gfx *chr_render_shield_component(Gfx *gdl, struct shieldhit *hit, struct prop *prop, struct model *model, +Gfx *shieldhit_render_component(Gfx *gdl, struct shieldhit *hit, struct prop *prop, struct model *model, struct modelnode *node, s32 side, s32 arg6, s32 arg7, s32 alpha) { struct modelrodata_bbox *bbox = &node->rodata->bbox; @@ -5582,7 +5597,7 @@ Gfx *chr_render_shield_component(Gfx *gdl, struct shieldhit *hit, struct prop *p } } - chr0f0295f8(shield, &red1, &green1, &blue1); + shieldhit_health_to_rgb(shield, &red1, &green1, &blue1); red2 = red1 - 20; green2 = green1 - 20; @@ -5985,14 +6000,14 @@ Gfx *chr_render_shield_component(Gfx *gdl, struct shieldhit *hit, struct prop *p vertices[4] = vtxtemplate; - if (hit->unk012 == 0x7fff) { + if (hit->hitposx == 0x7fff) { vertices[4].x = (vertices[0].x + vertices[1].x + vertices[2].x + vertices[3].x) >> 2; vertices[4].y = (vertices[0].y + vertices[1].y + vertices[2].y + vertices[3].y) >> 2; vertices[4].z = (vertices[0].z + vertices[1].z + vertices[2].z + vertices[3].z) >> 2; } else { - vertices[4].x = hit->unk012; - vertices[4].y = hit->unk014; - vertices[4].z = hit->unk016; + vertices[4].x = hit->hitposx; + vertices[4].y = hit->hitposy; + vertices[4].z = hit->hitposz; } vertices[4].colour = 0xc; @@ -6158,7 +6173,7 @@ Gfx *shieldhit_render(Gfx *gdl, struct prop *prop1, struct prop *prop2, s32 alph model = chr->model; } else { model = prop2->obj->model; - specificnode = model_get_part(model->definition, MODELPART_BASIC_0067); + specificnode = model_get_part(model->definition, MODELPART_BASIC_SHIELD); } node = model->definition->rootnode; @@ -6169,10 +6184,10 @@ Gfx *shieldhit_render(Gfx *gdl, struct prop *prop1, struct prop *prop2, s32 alph struct shieldhit *s0 = NULL; struct shieldhit *s1 = NULL; struct shieldhit *s2 = NULL; - s32 index = chr0f028e18(prop2, node, model, prop1); + s32 index = shieldhit_node_to_cmnum(prop2, node, model, prop1); s32 i; - for (i = 0; i < 20; i++) { + for (i = 0; i < MAX_SHIELDHITS; i++) { struct shieldhit *iter = &g_ShieldHits[i]; if (iter->prop == prop1) { @@ -6197,11 +6212,11 @@ Gfx *shieldhit_render(Gfx *gdl, struct prop *prop1, struct prop *prop2, s32 alph } if (s0) { - gdl = chr_render_shield_component(gdl, s0, prop1, s0->model, s0->node, s0->side, -1, -1, 255); + gdl = shieldhit_render_component(gdl, s0, prop1, s0->model, s0->node, s0->side, -1, -1, 255); } else if (s1) { - gdl = chr_render_shield_component(gdl, s1, prop1, model, node, -1, -1, -1, 255); + gdl = shieldhit_render_component(gdl, s1, prop1, model, node, -1, -1, -1, 255); } else if (s2) { - gdl = chr_render_shield_component(gdl, s2, prop1, model, node, -2, s2->unk018[index], s2->unk038[index], 255); + gdl = shieldhit_render_component(gdl, s2, prop1, model, node, -2, s2->unk018[index], s2->unk038[index], 255); } else { if (arg4) { if (specificnode) { @@ -6222,16 +6237,16 @@ Gfx *shieldhit_render(Gfx *gdl, struct prop *prop1, struct prop *prop2, s32 alph gDPSetTextureFilter(gdl++, G_TF_BILERP); gDPSetColorDither(gdl++, G_CD_BAYER); - gdl = chr_render_shield_component(gdl, NULL, prop1, model, node, -7, -1, -1, 255); + gdl = shieldhit_render_component(gdl, NULL, prop1, model, node, -7, -1, -1, 255); } else { if (index == cmnum1) { - gdl = chr_render_shield_component(gdl, NULL, prop1, model, node, -3, -1, -1, alpha); + gdl = shieldhit_render_component(gdl, NULL, prop1, model, node, -3, -1, -1, alpha); } else if (index == cmnum2) { - gdl = chr_render_shield_component(gdl, NULL, prop1, model, node, -4, -1, -1, alpha); + gdl = shieldhit_render_component(gdl, NULL, prop1, model, node, -4, -1, -1, alpha); } else if (index == cmnum3) { - gdl = chr_render_shield_component(gdl, NULL, prop1, model, node, -5, -1, -1, alpha); + gdl = shieldhit_render_component(gdl, NULL, prop1, model, node, -5, -1, -1, alpha); } else if (index == cmnum4) { - gdl = chr_render_shield_component(gdl, NULL, prop1, model, node, -6, -1, -1, alpha); + gdl = shieldhit_render_component(gdl, NULL, prop1, model, node, -6, -1, -1, alpha); } } } @@ -6283,7 +6298,7 @@ Gfx *chr_render_cloak(Gfx *gdl, struct prop *chrprop, struct prop *thisprop) model = thisprop->chr->model; } else { model = thisprop->obj->model; - bbox = model_get_part(model->definition, MODELPART_BASIC_0067); + bbox = model_get_part(model->definition, MODELPART_BASIC_SHIELD); } if (thisprop->parent == NULL) { @@ -6317,7 +6332,7 @@ Gfx *chr_render_cloak(Gfx *gdl, struct prop *chrprop, struct prop *thisprop) while (node) { if ((node->type & 0xff) == MODELNODETYPE_BBOX) { if (bbox == NULL || node == bbox) { - s32 index = chr0f028e18(thisprop, node, model, chrprop); + s32 index = shieldhit_node_to_cmnum(thisprop, node, model, chrprop); if (bbox) { index = 19; @@ -6455,7 +6470,7 @@ Gfx *chr_render_shield(Gfx *gdl, struct chrdata *chr, u32 alpha) for (i = 0; i <= numiterations; ) { if (operation == 0) { - candidate = chr0f02932c(chr->prop, chr->cmnum); + candidate = shieldhit_find_parentnode_cmnum(chr->prop, chr->cmnum); operation = 1; if (candidate >= 0) { @@ -6468,7 +6483,7 @@ Gfx *chr_render_shield(Gfx *gdl, struct chrdata *chr, u32 alpha) again = false; } } else if (operation == 1) { - candidate = chr0f0293ec(chr->prop, chr->cmnum); + candidate = shieldhit_find_childnode_cmnum(chr->prop, chr->cmnum); if (candidate >= 0) { operation = 2; @@ -6486,7 +6501,7 @@ Gfx *chr_render_shield(Gfx *gdl, struct chrdata *chr, u32 alpha) } } } else if (operation == 2) { - candidate = chr0f0294cc(chr->prop, candidate); + candidate = shieldhit_find_anynode_cmnum(chr->prop, candidate); if (candidate >= 0) { if (candidate != chr->cmnum2) { @@ -6530,11 +6545,11 @@ void shieldhits_tick(void) s32 j; if (g_ShieldHitActive) { - for (i = 0; i < 20; i++) { + for (i = 0; i < MAX_SHIELDHITS; i++) { if (g_ShieldHits[i].prop) { if (g_ShieldHits[i].lvframe60 >= g_Vars.lvframe60 - TICKS(80)) { changed = true; - g_ShieldHits[i].shield += (prop_get_shield_thing(&g_ShieldHits[i].prop) - g_ShieldHits[i].shield) * g_Vars.lvupdate60f * (PAL ? 0.0151515156f : 0.0125f); + g_ShieldHits[i].shield += (shieldhit_get_health(&g_ShieldHits[i].prop) - g_ShieldHits[i].shield) * g_Vars.lvupdate60f * (PAL ? 0.0151515156f : 0.0125f); } for (j = 0; j < 32; j++) { @@ -6543,7 +6558,7 @@ void shieldhits_tick(void) time60 = g_ShieldHits[i].unk018[j] + g_Vars.lvupdate60; if (g_ShieldHits[i].unk018[j] < 1 && time60 > 0) { - index = chr0f02932c(g_ShieldHits[i].prop, j); + index = shieldhit_find_parentnode_cmnum(g_ShieldHits[i].prop, j); if (index >= 0 && index < 32) { if (g_ShieldHits[i].unk018[index] == -1) { @@ -6552,7 +6567,7 @@ void shieldhits_tick(void) } } - index = chr0f0293ec(g_ShieldHits[i].prop, j); + index = shieldhit_find_childnode_cmnum(g_ShieldHits[i].prop, j); while (index >= 0) { if (index < 32) { @@ -6562,7 +6577,7 @@ void shieldhits_tick(void) } } - index = chr0f0294cc(g_ShieldHits[i].prop, index); + index = shieldhit_find_anynode_cmnum(g_ShieldHits[i].prop, index); } } @@ -6588,7 +6603,7 @@ void shieldhits_tick(void) } } -void chr_set_dr_caroll_images(struct chrdata *drcaroll, s32 imageleft, s32 imageright) +void chr_set_drcaroll_images(struct chrdata *drcaroll, s32 imageleft, s32 imageright) { if (drcaroll && imageleft >= DRCAROLLIMAGE_EYESDEFAULT && imageleft <= DRCAROLLIMAGE_BINARY diff --git a/src/game/chraction.c b/src/game/chraction.c index 3a5d960f6..51273c777 100644 --- a/src/game/chraction.c +++ b/src/game/chraction.c @@ -4072,11 +4072,11 @@ void chr_set_shield(struct chrdata *chr, f32 amount) } } -bool func0f034080(struct chrdata *chr, struct modelnode *node, struct prop *prop, struct model *model, s32 side, s16 *arg5) +bool chr_try_create_shieldhit(struct chrdata *chr, struct modelnode *node, struct prop *prop, struct model *model, s32 side, s16 *hitpos) { if (chr_get_shield(chr) > 0) { if (node && (node->type & 0xff) == MODELNODETYPE_BBOX) { - shieldhit_create(chr->prop, chr_get_shield(chr), prop, node, model, side, arg5); + shieldhit_create(chr->prop, chr_get_shield(chr), prop, node, model, side, hitpos); } return true; @@ -4090,7 +4090,7 @@ bool func0f034080(struct chrdata *chr, struct modelnode *node, struct prop *prop * * Used for knife poison, nbomb damage, Investigation radioactivity and Escape gas. */ -void chr_damage_by_misc(struct chrdata *chr, f32 damage, struct coord *vector, struct gset *gset, struct prop *prop) +void chr_damage_by_dizziness(struct chrdata *chr, f32 damage, struct coord *vector, struct gset *gset, struct prop *prop) { chr_damage(chr, damage, vector, gset, prop, HITPART_GENERAL, false, // damageshield @@ -4098,7 +4098,7 @@ void chr_damage_by_misc(struct chrdata *chr, f32 damage, struct coord *vector, s NULL, // node NULL, // model -1, // side - NULL, // arg11 + NULL, // hitpos false, // explosion NULL); // explosionpos } @@ -4111,12 +4111,20 @@ void chr_damage_by_laser(struct chrdata *chr, f32 damage, struct coord *vector, NULL, // node NULL, // model -1, // side - NULL, // arg11 + NULL, // hitpos false, // explosion NULL); // explosionpos } -void func0f0341dc(struct chrdata *chr, f32 damage, struct coord *vector, struct gset *gset, struct prop *prop, s32 hitpart, struct prop *prop2, struct modelnode *node, struct model *model, s32 side, s16 *arg10) +/** + * Damage the chr due to an impact with a direction. + * + * Used by: + * - Players doing melee attacks + * - Being shot + * - Hit by knife + */ +void chr_damage_by_impact(struct chrdata *chr, f32 damage, struct coord *vector, struct gset *gset, struct prop *prop, s32 hitpart, struct prop *prop2, struct modelnode *node, struct model *model, s32 side, s16 *hitpos) { chr_damage(chr, damage, vector, gset, prop, hitpart, true, // damageshield @@ -4124,15 +4132,15 @@ void func0f0341dc(struct chrdata *chr, f32 damage, struct coord *vector, struct node, // node model, // model side, // side - arg10, // arg11 + hitpos, // hitpos false, // explosion NULL); // explosionpos } /** - * Unused, and same as chr_damage_by_impact but sets hitpart to HITPART_GENERAL instead of argument. + * Unused, and same as chr_damage_by_general but sets hitpart to HITPART_GENERAL instead of argument. */ -void func0f034248(struct chrdata *chr, f32 damage, struct coord *vector, struct gset *gset, struct prop *prop) +void chr_damage_by_general_unused(struct chrdata *chr, f32 damage, struct coord *vector, struct gset *gset, struct prop *prop) { struct modelnode *node = NULL; struct model *model = NULL; @@ -4149,15 +4157,19 @@ void func0f034248(struct chrdata *chr, f32 damage, struct coord *vector, struct node, // node model, // model side, // side - NULL, // arg11 + NULL, // hitpos false, // explosion NULL); // explosionpos } /** - * Used for punching, but also used by AI commands to make chrs take damage. + * Used by: + * - AI when killing chrs at end of Infilration + * - NPCs when punching or kicking + * - Autoguns shooting a player + * - Non-rocket projectiles being created directly in a chr's bbox */ -void chr_damage_by_impact(struct chrdata *chr, f32 damage, struct coord *vector, struct gset *gset, struct prop *prop, s32 hitpart) +void chr_damage_by_general(struct chrdata *chr, f32 damage, struct coord *vector, struct gset *gset, struct prop *prop, s32 hitpart) { struct modelnode *node = NULL; struct model *model = NULL; @@ -4173,7 +4185,7 @@ void chr_damage_by_impact(struct chrdata *chr, f32 damage, struct coord *vector, node, // node model, // model side, // side - NULL, // arg11 + NULL, // hitpos false, // explosion NULL); // explosionpos } @@ -4186,7 +4198,7 @@ void chr_damage_by_explosion(struct chrdata *chr, f32 damage, struct coord *vect NULL, // node NULL, // model -1, // side - NULL, // arg11 + NULL, // hitpos true, // explosion explosionpos); } @@ -4232,13 +4244,13 @@ void player_update_damage_stats(struct prop *attacker, struct prop *victim, f32 * node - if shielded, model node (of type bbox) which was hit * model - if shielded, model of chr * side - if shielded, side of the model node's bounding box which was hit (0-5) - * arg11 - ? + * hitpos - ? * explosion - true if damage is coming from an explosion * explosionpos - position of said explosion */ void chr_damage(struct chrdata *chr, f32 damage, struct coord *vector, struct gset *gset, struct prop *aprop, s32 hitpart, bool damageshield, struct prop *prop2, - struct modelnode *node, struct model *model, s32 side, s16 *arg11, + struct modelnode *node, struct model *model, s32 side, s16 *hitpos, bool explosion, struct coord *explosionpos) { bool onehitko = false; @@ -4525,19 +4537,19 @@ void chr_damage(struct chrdata *chr, f32 damage, struct coord *vector, struct gs if (shield > 0) { if (g_Vars.normmplayerisrunning) { #if VERSION >= VERSION_PAL_FINAL - // Fixing a @bug? + // Fixing a @bug damage = damage * mp_handicap_to_damage_scale(g_PlayerConfigsArray[g_Vars.currentplayerstats->mpindex].handicap); #else - damage /= mp_handicap_to_damage_scale(g_PlayerConfigsArray[g_Vars.currentplayerstats->mpindex].handicap); + damage = damage / mp_handicap_to_damage_scale(g_PlayerConfigsArray[g_Vars.currentplayerstats->mpindex].handicap); #endif } chr->chrflags |= CHRCFLAG_SHIELDDAMAGED; if (prop2 && node && chr->model) { - func0f034080(chr, node, prop2, model, side, arg11); + chr_try_create_shieldhit(chr, node, prop2, model, side, hitpos); } else { - shieldhit_create(chr->prop, chr_get_shield(chr), NULL, NULL, NULL, 0, 0); + shieldhit_create(chr->prop, chr_get_shield(chr), NULL, NULL, NULL, 0, NULL); } if (g_Vars.normmplayerisrunning && (g_MpSetup.options & MPOPTION_ONEHITKILLS)) { @@ -7702,7 +7714,7 @@ void chr_punch_inflict_damage(struct chrdata *chr, s32 damage, s32 range, u8 rev bgun_play_prop_hit_sound(&gset, targetprop, -1); if (targetprop->type == PROPTYPE_PLAYER || targetprop->type == PROPTYPE_CHR) { - chr_damage_by_impact(targetprop->chr, gset_get_damage(&gset) * damage, &vector, &gset, chr->prop, 200); + chr_damage_by_general(targetprop->chr, gset_get_damage(&gset) * damage, &vector, &gset, chr->prop, 200); } } @@ -7717,27 +7729,27 @@ struct punchanim { }; struct punchanim g_HumanPunchAnims[] = { - { 0x027c, 5, 20, 60 }, - { 0x027d, 5, 20, 31 }, - { 0x027e, 5, 20, 48 }, - { 0x027f, 5, 20, 69 }, - { 0x0212, 5, 20, 64 }, - { 0x0213, 5, 20, 52 }, - { 0x0214, 5, 20, 51 }, - { 0x020e, 5, 20, 53 }, - { 0x020f, 5, 20, 89 }, - { 0x0210, 5, 20, 71 }, - { 0x0215, 5, 20, 62 }, - { 0x0211, 5, 20, 72 }, + { ANIM_027C, 5, 20, 60 }, + { ANIM_027D, 5, 20, 31 }, + { ANIM_027E, 5, 20, 48 }, + { ANIM_027F, 5, 20, 69 }, + { ANIM_0212, 5, 20, 64 }, + { ANIM_0213, 5, 20, 52 }, + { ANIM_0214, 5, 20, 51 }, + { ANIM_020E, 5, 20, 53 }, + { ANIM_020F, 5, 20, 89 }, + { ANIM_0210, 5, 20, 71 }, + { ANIM_0215, 5, 20, 62 }, + { ANIM_0211, 5, 20, 72 }, }; struct punchanim g_SkedarPunchAnims[] = { - { 0x034c, 15, 25, 100 }, - { 0x034d, 15, 25, -1 }, - { 0x0395, 15, 25, -1 }, - { 0x0346, 15, 25, -1 }, - { 0x0347, 15, 25, -1 }, - { 0x034f, 15, 25, -1 }, + { ANIM_034C, 15, 25, 100 }, + { ANIM_034D, 15, 25, -1 }, + { ANIM_0395, 15, 25, -1 }, + { ANIM_0346, 15, 25, -1 }, + { ANIM_0347, 15, 25, -1 }, + { ANIM_034F, 15, 25, -1 }, }; /** @@ -10307,7 +10319,7 @@ void chr_tick_shoot(struct chrdata *chr, s32 handnum) chr_calculate_shield_hit(targetchr, &hitpos, &vector, &node, &hitpart, &model, &side); } - func0f0341dc(targetchr, damage, &vector, &gset, chr->prop, HITPART_GENERAL, targetprop, node, model, side, NULL); + chr_damage_by_impact(targetchr, damage, &vector, &gset, chr->prop, HITPART_GENERAL, targetprop, node, model, side, NULL); } else if ((hitprop == NULL || (hitprop->type != PROPTYPE_CHR && hitprop->type != PROPTYPE_PLAYER)) && sqshotdist < 100.0f * 100.0f) { // Hit the background or something other than a @@ -10339,7 +10351,7 @@ void chr_tick_shoot(struct chrdata *chr, s32 handnum) } chr_emit_sparks(hitchr, hitprop, hitpart, &hitpos, &vector, chr); - func0f0341dc(hitchr, damage, &vector, &gset, chr->prop, HITPART_GENERAL, hitprop, node, model, side, NULL); + chr_damage_by_impact(hitchr, damage, &vector, &gset, chr->prop, HITPART_GENERAL, hitprop, node, model, side, NULL); } else { makebeam = false; firingthisframe = false; @@ -12750,7 +12762,7 @@ void chr_tick_go_pos(struct chrdata *chr) // Try and warp the chr past whatever obstacle is blocking them? struct coord sp196 = {0, 0, 0}; - chr_damage_by_misc(chr, 1, &sp196, NULL, NULL); + chr_damage_by_dizziness(chr, 1, &sp196, NULL, NULL); chr->lastmoveok60 = g_Vars.lvframe60; return; diff --git a/src/game/chraicommands.c b/src/game/chraicommands.c index 53980d699..06811c673 100644 --- a/src/game/chraicommands.c +++ b/src/game/chraicommands.c @@ -811,7 +811,7 @@ bool ai0019(void) if (chr && chr->prop) { f32 damage = gset_get_damage((struct gset *)&cmd[4]); - chr_damage_by_impact(chr, damage, &pos, (struct gset *)&cmd[4], NULL, (s8)cmd[3]); + chr_damage_by_general(chr, damage, &pos, (struct gset *)&cmd[4], NULL, (s8)cmd[3]); } g_Vars.aioffset += 8; @@ -845,7 +845,7 @@ bool ai_chr_damage_chr(void) guNormalize(&vector.x, &vector.y, &vector.z); weapon = prop->weapon; damage = gset_get_damage(&weapon->gset); - chr_damage_by_impact(chr2, damage, &vector, &weapon->gset, chr1->prop, (s8)cmd[4]); + chr_damage_by_general(chr2, damage, &vector, &weapon->gset, chr1->prop, (s8)cmd[4]); } } @@ -8049,11 +8049,11 @@ bool ai_damage_chr_by_amount(void) if (chr && chr->prop) { if (cmd[4] == 2) { struct gset gset = {WEAPON_COMBATKNIFE, 0, 0, FUNC_POISON}; - chr_damage_by_misc(chr, (s32)cmd[3] * 0.03125f, &coord, &gset, NULL); + chr_damage_by_dizziness(chr, (s32)cmd[3] * 0.03125f, &coord, &gset, NULL); } else if (cmd[4] == 0) { - chr_damage_by_misc(chr, (s32)cmd[3] * 0.03125f, &coord, NULL, NULL); + chr_damage_by_dizziness(chr, (s32)cmd[3] * 0.03125f, &coord, NULL, NULL); } else { - chr_damage_by_misc(chr, (s32)cmd[3] * -0.03125f, &coord, NULL, NULL); + chr_damage_by_dizziness(chr, (s32)cmd[3] * -0.03125f, &coord, NULL, NULL); } } diff --git a/src/game/chrmgr.c b/src/game/chrmgr.c index f0f3ff7b2..6287939d6 100644 --- a/src/game/chrmgr.c +++ b/src/game/chrmgr.c @@ -21,9 +21,9 @@ void chrmgr_reset(void) g_ChrSlots = NULL; g_NumChrSlots = 0; - g_ShieldHits = memp_alloc(sizeof(struct shieldhit) * 20, MEMPOOL_STAGE); + g_ShieldHits = memp_alloc(sizeof(struct shieldhit) * MAX_SHIELDHITS, MEMPOOL_STAGE); - for (i = 0; i < 20; i++) { + for (i = 0; i < MAX_SHIELDHITS; i++) { g_ShieldHits[i].prop = NULL; } diff --git a/src/game/nbomb.c b/src/game/nbomb.c index e97c11408..762e15f1c 100644 --- a/src/game/nbomb.c +++ b/src/game/nbomb.c @@ -497,7 +497,7 @@ void nbomb_inflict_damage(struct nbomb *nbomb) struct coord vector = {0, 0, 0}; f32 damage = 0.01f * g_Vars.lvupdate60freal; - chr_damage_by_misc(chr, damage, &vector, &gset, nbomb->ownerprop); + chr_damage_by_dizziness(chr, damage, &vector, &gset, nbomb->ownerprop); #if VERSION >= VERSION_NTSC_1_0 if (chr->actiontype); diff --git a/src/game/player.c b/src/game/player.c index 1b7b6bb5a..987b42f7a 100644 --- a/src/game/player.c +++ b/src/game/player.c @@ -4370,7 +4370,7 @@ Gfx *player_render_shield(Gfx *gdl) sp88[0] = cam_get_screen_width() * (1.0f + 0.002f * ((g_Vars.currentplayer->shieldshowrnd >> 20) % 100) + (g_Vars.currentplayer->shieldshowtime * (0.2f + 0.002f * (g_Vars.currentplayer->shieldshowrnd % 100)) * (1.0f / 60.0f))); sp88[1] = cam_get_screen_height() * (1.0f + 0.002f * ((g_Vars.currentplayer->shieldshowrnd >> 24) % 100) + (g_Vars.currentplayer->shieldshowtime * (0.2f + 0.002f * ((g_Vars.currentplayer->shieldshowrnd >> 8) % 100)) * (1.0f / 60.0f))); - chr0f0295f8(shield, &red, &green, &blue); + shieldhit_health_to_rgb(shield, &red, &green, &blue); if (g_Vars.currentplayer->shieldshowtime < 30) { f20 = 1 - g_Vars.currentplayer->shieldshowtime * (1.0f / 120.0f); diff --git a/src/game/prop.c b/src/game/prop.c index 1d90bf9be..477706a43 100644 --- a/src/game/prop.c +++ b/src/game/prop.c @@ -1262,8 +1262,8 @@ void hand_inflict_melee_damage(s32 handnum, struct gset *gset, bool arg2) hitpart = HITPART_TORSO; } - func0f0341dc(chr, gset_get_damage(gset), &gundir2d, gset, - g_Vars.currentplayer->prop, hitpart, chr->prop, node, model, side, 0); + chr_damage_by_impact(chr, gset_get_damage(gset), &gundir2d, gset, + g_Vars.currentplayer->prop, hitpart, chr->prop, node, model, side, NULL); } } } diff --git a/src/game/propobj.c b/src/game/propobj.c index cc81480dd..381b01ec3 100644 --- a/src/game/propobj.c +++ b/src/game/propobj.c @@ -120,9 +120,9 @@ struct linksceneryobj *g_LinkedScenery = NULL; struct blockedpathobj *g_BlockedPaths = NULL; struct prop *g_EmbedProp = NULL; s32 g_EmbedHitPart = 0; -u32 g_EmbedSide = 0x00000000; -s16 var8006993c[3] = {0}; -u32 var80069944 = 0x00000000; +u32 g_EmbedSide = 0; +s16 g_EmbedHitPos[3] = {0}; +s32 g_EmbedTextureNum = 0; f32 g_CctvWaitScale = 1; f32 g_CctvDamageRxScale = 1; f32 g_AutogunAccuracyScale = 1; @@ -2715,9 +2715,9 @@ bool func0f06b610(struct defaultobj *obj, struct coord *arg1, struct coord *arg2 g_EmbedNode = spe4; g_EmbedSide = thing1.unk28 / 2; - var8006993c[0] = thing1.pos.x; - var8006993c[1] = thing1.pos.y; - var8006993c[2] = thing1.pos.z; + g_EmbedHitPos[0] = thing1.pos.x; + g_EmbedHitPos[1] = thing1.pos.y; + g_EmbedHitPos[2] = thing1.pos.z; result = 1; } @@ -2737,7 +2737,7 @@ bool func0f06b610(struct defaultobj *obj, struct coord *arg1, struct coord *arg2 } while (hitpart > 0); if (obj->flags3 & OBJFLAG3_HOVERBEDSHIELD) { - node = model_get_part(model->definition, MODELPART_BASIC_0067); + node = model_get_part(model->definition, MODELPART_BASIC_SHIELD); if (node && func0f084594(model, node, arg5, arg6, &thing2, &mtxindex2, &node2)) { if (hitpart <= 0 || @@ -2792,15 +2792,15 @@ bool func0f06b610(struct defaultobj *obj, struct coord *arg1, struct coord *arg2 g_EmbedModel = model; g_EmbedNode = node1; - var80069944 = thing1.texturenum; + g_EmbedTextureNum = thing1.texturenum; result = true; if (thing1.texturenum == 10000) { g_EmbedSide = thing1.unk28 / 2; - var8006993c[0] = thing1.pos.x; - var8006993c[1] = thing1.pos.y; - var8006993c[2] = thing1.pos.z; + g_EmbedHitPos[0] = thing1.pos.x; + g_EmbedHitPos[1] = thing1.pos.y; + g_EmbedHitPos[2] = thing1.pos.z; } } } @@ -3047,9 +3047,9 @@ bool func0f06c28c(struct chrdata *chr, struct coord *arg1, struct coord *arg2, s g_EmbedNode = spcc; g_EmbedSide = sp7c.unk28 / 2; - var8006993c[0] = sp7c.pos.x; - var8006993c[1] = sp7c.pos.y; - var8006993c[2] = sp7c.pos.z; + g_EmbedHitPos[0] = sp7c.pos.x; + g_EmbedHitPos[1] = sp7c.pos.y; + g_EmbedHitPos[2] = sp7c.pos.z; result = true; } @@ -3245,7 +3245,7 @@ s32 func0f06cd00(struct defaultobj *obj, struct coord *pos, struct coord *arg2, } g_EmbedProp = 0; - var80069944 = 0; + g_EmbedTextureNum = 0; sp1c4.x = pos->x; sp1c4.y = pos->y; @@ -3274,7 +3274,7 @@ s32 func0f06cd00(struct defaultobj *obj, struct coord *pos, struct coord *arg2, hitthing.pos.y *= scale; hitthing.pos.z *= scale; - var80069944 = hitthing.texturenum; + g_EmbedTextureNum = hitthing.texturenum; s0 = true; @@ -3384,7 +3384,7 @@ bool func0f06d37c(struct defaultobj *obj, struct coord *arg1, struct coord *arg2 f32 f2; g_EmbedProp = NULL; - var80069944 = 0; + g_EmbedTextureNum = 0; sp80.x = arg1->x; sp80.y = arg1->y; @@ -6947,7 +6947,7 @@ s32 projectile_tick(struct defaultobj *obj, bool *embedded) stick = false; } - if (var80069944 == 10000) { + if (g_EmbedTextureNum == 10000) { stick = false; } @@ -6989,8 +6989,8 @@ s32 projectile_tick(struct defaultobj *obj, bool *embedded) ownerprop = obj->projectile->ownerprop; ownershield = chr_get_shield(hitchr); - func0f0341dc(hitchr, gset_get_damage(&weapon->gset), &var8009ce78, &weapon->gset, ownerprop, - g_EmbedHitPart, g_EmbedProp, g_EmbedNode, g_EmbedModel, g_EmbedSide, var8006993c); + chr_damage_by_impact(hitchr, gset_get_damage(&weapon->gset), &var8009ce78, &weapon->gset, ownerprop, + g_EmbedHitPart, g_EmbedProp, g_EmbedNode, g_EmbedModel, g_EmbedSide, g_EmbedHitPos); if (ownershield <= 0.0f) { chr_emit_sparks(hitchr, g_EmbedProp, g_EmbedHitPart, &sp5e8, &sp5f4, ownerprop ? ownerprop->chr : NULL); @@ -7014,13 +7014,13 @@ s32 projectile_tick(struct defaultobj *obj, bool *embedded) } else if (hitprop->type == PROPTYPE_OBJ) { struct defaultobj *hitobj = hitprop->obj; - if (var80069944 == 10000) { + if (g_EmbedTextureNum == 10000) { shield = (hitobj->flags3 & OBJFLAG3_SHOWSHIELD) ? 4 : 8; - shieldhit_create(hitprop, shield, g_EmbedProp, g_EmbedNode, g_EmbedModel, g_EmbedSide, var8006993c); + shieldhit_create(hitprop, shield, g_EmbedProp, g_EmbedNode, g_EmbedModel, g_EmbedSide, g_EmbedHitPos); } - if (hitobj->modelnum == MODEL_TARGET && var80069944 == TEXTURE_0B9E) { + if (hitobj->modelnum == MODEL_TARGET && g_EmbedTextureNum == TEXTURE_0B9E) { fr_calculate_hit(hitobj, &sp5e8, 0.0f); } } @@ -7041,13 +7041,13 @@ s32 projectile_tick(struct defaultobj *obj, bool *embedded) } } - func0f0341dc(g_EmbedProp->chr, 2.0f, &var8009ce78, &weapon->gset, ownerprop2, - g_EmbedHitPart, g_EmbedProp, g_EmbedNode, g_EmbedModel, g_EmbedSide, var8006993c); + chr_damage_by_impact(g_EmbedProp->chr, 2.0f, &var8009ce78, &weapon->gset, ownerprop2, + g_EmbedHitPart, g_EmbedProp, g_EmbedNode, g_EmbedModel, g_EmbedSide, g_EmbedHitPos); } else if (g_EmbedProp->type == PROPTYPE_OBJ || g_EmbedProp->type == PROPTYPE_WEAPON) { - if (var80069944 == 10000) { + if (g_EmbedTextureNum == 10000) { f32 shield = (g_EmbedProp->obj->flags3 & OBJFLAG3_SHOWSHIELD) ? 4 : 8; - shieldhit_create(hitprop, shield, g_EmbedProp, g_EmbedNode, g_EmbedModel, g_EmbedSide, var8006993c); + shieldhit_create(hitprop, shield, g_EmbedProp, g_EmbedNode, g_EmbedModel, g_EmbedSide, g_EmbedHitPos); } obj_damage(g_EmbedProp->obj, 100, &prop->pos, weapon->weaponnum, ownerplayernum); @@ -7059,11 +7059,11 @@ s32 projectile_tick(struct defaultobj *obj, bool *embedded) } else { if (hitprop->type == PROPTYPE_CHR || (hitprop->type == PROPTYPE_PLAYER && hitprop->chr)) { struct chrdata *chr = hitprop->chr; - func0f034080(chr, g_EmbedNode, g_EmbedProp, g_EmbedModel, g_EmbedSide, var8006993c); - } else if ((hitprop->type == PROPTYPE_OBJ || hitprop->type == PROPTYPE_WEAPON) && var80069944 == 10000) { + chr_try_create_shieldhit(chr, g_EmbedNode, g_EmbedProp, g_EmbedModel, g_EmbedSide, g_EmbedHitPos); + } else if ((hitprop->type == PROPTYPE_OBJ || hitprop->type == PROPTYPE_WEAPON) && g_EmbedTextureNum == 10000) { shield = (hitprop->obj->flags3 & OBJFLAG3_SHOWSHIELD) ? 4 : 8; - shieldhit_create(hitprop, shield, g_EmbedProp, g_EmbedNode, g_EmbedModel, g_EmbedSide, var8006993c); + shieldhit_create(hitprop, shield, g_EmbedProp, g_EmbedNode, g_EmbedModel, g_EmbedSide, g_EmbedHitPos); } } } @@ -9144,7 +9144,7 @@ void autogun_tick_shoot(struct prop *autogunprop) } chr_emit_sparks(hitchr, hitprop, hitpart, &hitpos, &dir, ownerchr); - func0f0341dc(hitchr, damage, &dir, &gset, ownerprop, HITPART_GENERAL, hitprop, hitnode, hitmodel, hitside, NULL); + chr_damage_by_impact(hitchr, damage, &dir, &gset, ownerprop, HITPART_GENERAL, hitprop, hitnode, hitmodel, hitside, NULL); } } else { missed = true; @@ -9256,7 +9256,7 @@ void autogun_tick_shoot(struct prop *autogunprop) damage = 0.5f * g_AutogunDamageTxScale; - chr_damage_by_impact(targetprop->chr, damage, &dir, &gset, 0, HITPART_GENERAL); + chr_damage_by_general(targetprop->chr, damage, &dir, &gset, 0, HITPART_GENERAL); autogun->shotbondsum = 0.0f; } @@ -20790,7 +20790,7 @@ void gas_tick(void) if (g_GasReleaseTimer240 >= 1800) { struct coord dir = {0, 0, 0}; - chr_damage_by_misc(g_Vars.currentplayer->prop->chr, 0.125f, &dir, NULL, NULL); + chr_damage_by_dizziness(g_Vars.currentplayer->prop->chr, 0.125f, &dir, NULL, NULL); } } @@ -21290,7 +21290,7 @@ void projectile_create(struct prop *fromprop, struct fireslotthing *arg1, struct } bgun_play_prop_hit_sound(&gset, targetprop, -1); - chr_damage_by_impact(targetprop->chr, gset_get_damage(&gset) * arg1->unk10, dir, &gset, 0, 200); + chr_damage_by_general(targetprop->chr, gset_get_damage(&gset) * arg1->unk10, dir, &gset, 0, HITPART_GENERAL); arg1->unk14 = 0.0f; } } @@ -21319,7 +21319,7 @@ void projectile_create(struct prop *fromprop, struct fireslotthing *arg1, struct chr->blurdrugamount = TICKS(5000); } - func0f0341dc(chr, gset_get_damage(&gset), dir, &gset, 0, hitpart, obstacle, node, model, side, NULL); + chr_damage_by_impact(chr, gset_get_damage(&gset), dir, &gset, 0, hitpart, obstacle, node, model, side, NULL); } else if (obstacle->type == PROPTYPE_OBJ || obstacle->type == PROPTYPE_WEAPON || obstacle->type == PROPTYPE_DOOR) { struct defaultobj *obj = obstacle->obj; diff --git a/src/include/constants.h b/src/include/constants.h index 11f04af06..8a0c0bf24 100644 --- a/src/include/constants.h +++ b/src/include/constants.h @@ -26,6 +26,7 @@ #define MAX_PLAYERS 4 #define MAX_PROPSPERROOMCHUNK 7 #define MAX_ROOMPROPLISTCHUNKS 256 +#define MAX_SHIELDHITS 20 #define MAX_SQUADRONS 16 #define MAX_TEAMS 8 @@ -2291,7 +2292,7 @@ #define MODELPART_BASIC_0064 0x0064 // type19 #define MODELPART_BASIC_0065 0x0065 // type19 #define MODELPART_BASIC_0066 0x0066 // type19 -#define MODELPART_BASIC_0067 0x0067 // bbox +#define MODELPART_BASIC_SHIELD 0x0067 // bbox #define MODELPART_BASIC_00C8 0x00c8 // toggle #define MODELPART_BASIC_00C9 0x00c9 // toggle #define MODELPART_BASIC_00CA 0x00ca // toggle diff --git a/src/include/game/chr.h b/src/include/game/chr.h index 791677d9e..0f4e94876 100644 --- a/src/include/game/chr.h +++ b/src/include/game/chr.h @@ -51,22 +51,22 @@ void chr_hit(struct shotdata *shotdata, struct hit *hit); void chr0f028498(bool value); void chrs_check_for_noise(f32 noiseradius); bool chr_calculate_auto_aim(struct prop *prop, struct coord *arg1, f32 *arg2, f32 *arg3); -s32 chr0f028e18(struct prop *arg0, struct modelnode *node, struct model *model, struct prop *arg3); -bool chr0f028e6c(s32 arg0, struct prop *prop, struct prop **propptr, struct modelnode **nodeptr, struct model **modelptr); -void shieldhit_create(struct prop *prop, f32 shield, struct prop *arg2, struct modelnode *node, struct model *model, s32 side, s16 *arg6); +s32 shieldhit_node_to_cmnum(struct prop *arg0, struct modelnode *node, struct model *model, struct prop *arg3); +bool shieldhit_cmnum_to_node(s32 arg0, struct prop *prop, struct prop **propptr, struct modelnode **nodeptr, struct model **modelptr); +void shieldhit_create(struct prop *rootprop, f32 shield, struct prop *hitprop, struct modelnode *node, struct model *model, s32 side, s16 *arg6); void shieldhit_remove(struct shieldhit *shieldhit); void shieldhits_remove_by_prop(struct prop *prop); -s32 chr0f02932c(struct prop *prop, s32 arg1); -s32 chr0f0293ec(struct prop *prop, s32 arg1); -s32 chr0f0294cc(struct prop *prop, s32 arg1); -void chr0f0295f8(f32 arg0, s32 *arg1, s32 *arg2, s32 *arg3); -f32 prop_get_shield_thing(struct prop **propptr); -Gfx *chr_render_shield_component(Gfx *gdl, struct shieldhit *hit, struct prop *prop, struct model *model, struct modelnode *node, s32 side, s32 arg6, s32 arg7, s32 alpha); +s32 shieldhit_find_parentnode_cmnum(struct prop *prop, s32 prevcmnum); +s32 shieldhit_find_childnode_cmnum(struct prop *prop, s32 prevcmnum); +s32 shieldhit_find_anynode_cmnum(struct prop *prop, s32 prevcmnum); +void shieldhit_health_to_rgb(f32 health, s32 *r, s32 *g, s32 *b); +f32 shieldhit_get_health(struct prop **propptr); +Gfx *shieldhit_render_component(Gfx *gdl, struct shieldhit *hit, struct prop *prop, struct model *model, struct modelnode *node, s32 side, s32 arg6, s32 arg7, s32 alpha); Gfx *shieldhit_render(Gfx *gdl, struct prop *prop1, struct prop *prop2, s32 alpha, bool arg4, s32 cmnum1, s32 cmnum2, s32 cmnum3, s32 cmnum4); Gfx *chr_render_cloak(Gfx *gdl, struct prop *chr1, struct prop *chr2); Gfx *chr_render_shield(Gfx *gdl, struct chrdata *chr, u32 alpha); void shieldhits_tick(void); -void chr_set_dr_caroll_images(struct chrdata *drcaroll, s32 imageleft, s32 imageright); +void chr_set_drcaroll_images(struct chrdata *drcaroll, s32 imageleft, s32 imageright); s32 chrs_get_num_slots(void); void chr_register(s32 chrnum, s32 chrindex); Vtx *chr_allocate_vertices(s32 numvertices); diff --git a/src/include/game/chraction.h b/src/include/game/chraction.h index 236b45bc5..c4e015e32 100644 --- a/src/include/game/chraction.h +++ b/src/include/game/chraction.h @@ -48,11 +48,11 @@ void chr_knock_out(struct chrdata *chr, f32 angle, s32 hitpart, struct gset *gse bool chr_is_anim_preventing_argh(struct chrdata *chr, f32 *arg1); void chr_choke(struct chrdata *chr, s32 choketype); void chr_set_shield(struct chrdata *chr, f32 shield); -bool func0f034080(struct chrdata *chr, struct modelnode *node, struct prop *prop, struct model *model, s32 side, s16 *arg5); -void chr_damage_by_misc(struct chrdata *chr, f32 damage, struct coord *vector, struct gset *gset, struct prop *prop); +bool chr_try_create_shieldhit(struct chrdata *chr, struct modelnode *node, struct prop *prop, struct model *model, s32 side, s16 *arg5); +void chr_damage_by_dizziness(struct chrdata *chr, f32 damage, struct coord *vector, struct gset *gset, struct prop *prop); void chr_damage_by_laser(struct chrdata *chr, f32 damage, struct coord *vector, struct gset *gset, struct prop *prop); -void func0f0341dc(struct chrdata *chr, f32 damage, struct coord *vector, struct gset *gset, struct prop *prop, s32 hitpart, struct prop *prop2, struct modelnode *node, struct model *model, s32 side, s16 *arg10); -void chr_damage_by_impact(struct chrdata *chr, f32 damage, struct coord *vector, struct gset *gset, struct prop *prop, s32 arg5); +void chr_damage_by_impact(struct chrdata *chr, f32 damage, struct coord *vector, struct gset *gset, struct prop *prop, s32 hitpart, struct prop *prop2, struct modelnode *node, struct model *model, s32 side, s16 *hitpos); +void chr_damage_by_general(struct chrdata *chr, f32 damage, struct coord *vector, struct gset *gset, struct prop *prop, s32 arg5); void chr_damage_by_explosion(struct chrdata *chr, f32 damage, struct coord *vector, struct prop *prop, struct coord *explosionpos); void player_update_damage_stats(struct prop *attacker, struct prop *victim, f32 damage); void chr_damage(struct chrdata *chr, f32 damage, struct coord *vector, struct gset *gset, struct prop *aprop, s32 hitpart, bool damageshield, struct prop *prop2, struct modelnode *node, struct model *model, s32 side, s16 *arg11, bool explosion, struct coord *explosionpos); diff --git a/src/include/types.h b/src/include/types.h index 0601ea7eb..4a943c6bf 100644 --- a/src/include/types.h +++ b/src/include/types.h @@ -5065,9 +5065,9 @@ struct shieldhit { /*0x0c*/ s32 lvframe60; /*0x10*/ s8 side; /*0x11*/ s8 unk011; - /*0x12*/ s16 unk012; - /*0x14*/ s16 unk014; - /*0x14*/ s16 unk016; + /*0x12*/ s16 hitposx; + /*0x14*/ s16 hitposy; + /*0x14*/ s16 hitposz; /*0x18*/ s8 unk018[32]; /*0x38*/ u8 unk038[32]; /*0x58*/ f32 shield;