Identify unknown properties in gset struct

This commit is contained in:
Ryan Dwyer 2024-09-08 20:18:44 +10:00
parent 51c8d83659
commit 23039e4c92
10 changed files with 61 additions and 53 deletions

View File

@ -342,7 +342,7 @@ bool bgun_test_gun_vis_command(struct gunviscmd *cmd, struct hand *hand)
switch (cmd->type) {
case GUNVISCMD_CHECKUPGRADE:
if (((hand->gset.unk0639 >> cmd->param) & 1) == 0) {
if (((hand->gset.upgradewant >> cmd->param) & 1) == 0) {
result = false;
}
break;
@ -5366,7 +5366,7 @@ void bgun_tick_switch2(void)
player->hands[i].lastshootframe60 = 0;
player->hands[i].gset.weaponfunc = FUNC_PRIMARY;
player->hands[i].gset.weaponnum = ctrl->weaponnum;
player->hands[i].gset.unk0639 = (ctrl->upgradewant >> (i * 4)) & 0xf;
player->hands[i].gset.upgradewant = (ctrl->upgradewant >> (i * 4)) & 0xf;
player->hands[i].gangstarot = 0.0f;
bgun0f0abd30(i);
@ -8522,7 +8522,7 @@ void bgun_play_prop_hit_sound(struct gset *gset, struct prop *prop, s32 texturen
if (texturenum == 10000) {
soundnum = SFX_SHIELD_DAMAGE;
} else if (gset->weaponnum == WEAPON_LASER) {
if (gset->weaponfunc == FUNC_PRIMARY || ((gset->unk063a % 4) == 0 && (random() % 2))) {
if (gset->weaponfunc == FUNC_PRIMARY || ((gset->lasershots % 4) == 0 && (random() % 2))) {
if ((random() % 2) == 0) {
soundnum = SFX_CLOAK_ON;
} else {
@ -8660,7 +8660,7 @@ void bgun_play_prop_hit_sound(struct gset *gset, struct prop *prop, s32 texturen
snd_start(var80095200, SFX_SHIELD_DAMAGE, handle, -1, -1, -1, -1, -1);
soundnum = SFX_SHIELD_DAMAGE;
} else if (gset->weaponnum == WEAPON_LASER) {
if (gset->weaponfunc == FUNC_PRIMARY || (gset->unk063a % 8) == 0) {
if (gset->weaponfunc == FUNC_PRIMARY || (gset->lasershots % 8) == 0) {
if ((random() % 2) == 0) {
soundnum = SFX_CLOAK_ON;
} else {
@ -8763,7 +8763,7 @@ void bgun_play_bg_hit_sound(struct gset *gset, struct coord *hitpos, s32 texture
if (gset->weaponnum == WEAPON_LASER) {
playdefault = false;
if (gset->weaponfunc == FUNC_PRIMARY || ((gset->unk063a % 4) == 0 && (random() % 2))) {
if (gset->weaponfunc == FUNC_PRIMARY || ((gset->lasershots % 4) == 0 && (random() % 2))) {
// Laser sounds
s16 sounds[] = {SFX_CLOAK_ON, SFX_CLOAK_OFF};
soundnum = sounds[rand1 % ARRAYCOUNT(sounds)];
@ -8857,7 +8857,7 @@ void bgun_play_bg_hit_sound(struct gset *gset, struct coord *hitpos, s32 texture
overridden = false;
if (gset->weaponnum == WEAPON_LASER) {
if (gset->weaponfunc == FUNC_PRIMARY || (gset->unk063a % 8) == 0) {
if (gset->weaponfunc == FUNC_PRIMARY || (gset->lasershots % 8) == 0) {
// Laser sounds
s16 sounds[] = {SFX_CLOAK_ON, SFX_CLOAK_OFF};
soundnum = sounds[rand1 % ARRAYCOUNT(sounds)];

View File

@ -5059,8 +5059,8 @@ void chr_damage(struct chrdata *chr, f32 damage, struct coord *vector, struct gs
chr->act_preargh.hitpart = hitpart;
chr->act_preargh.aplayernum = aplayernum;
chr->act_preargh.gset.weaponnum = gset->weaponnum;
chr->act_preargh.gset.unk0639 = gset->unk0639;
chr->act_preargh.gset.unk063a = gset->unk063a;
chr->act_preargh.gset.upgradewant = gset->upgradewant;
chr->act_preargh.gset.miscbyte = gset->miscbyte;
chr->act_preargh.gset.weaponfunc = gset->weaponfunc;
chr->sleep = 0;
@ -10257,7 +10257,7 @@ void chr_tick_shoot(struct chrdata *chr, s32 handnum)
normalshoot = false;
} else if (gset.weaponnum == WEAPON_MAULER && isaibot && gset.weaponfunc == FUNC_SECONDARY) {
gset.unk063a = (s32) (chr->aibot->maulercharge[handnum] * 10.0f);
gset.maulercharge = (s32) (chr->aibot->maulercharge[handnum] * 10.0f);
chr->aibot->maulercharge[handnum] = 0;
}

View File

@ -411,15 +411,15 @@ void gset_populate(s32 handnum, struct gset *gset)
{
gset->weaponnum = g_Vars.currentplayer->gunctrl.weaponnum;
gset->weaponfunc = g_Vars.currentplayer->hands[handnum].gset.weaponfunc;
gset->unk063a = g_Vars.currentplayer->hands[handnum].gset.unk063a;
gset->unk0639 = g_Vars.currentplayer->hands[handnum].gset.unk0639;
gset->miscbyte = g_Vars.currentplayer->hands[handnum].gset.miscbyte;
gset->upgradewant = g_Vars.currentplayer->hands[handnum].gset.upgradewant;
if (gset->weaponnum == WEAPON_MAULER) {
gset->unk063a = g_Vars.currentplayer->hands[handnum].matmot1 * 10.0f;
gset->maulercharge = g_Vars.currentplayer->hands[handnum].matmot1 * 10.0f;
}
if (gset->weaponnum == WEAPON_LASER) {
gset->unk063a = g_Vars.currentplayer->hands[handnum].burstbullets & 0xff;
gset->lasershots = g_Vars.currentplayer->hands[handnum].burstbullets & 0xff;
}
}
@ -499,7 +499,7 @@ f32 gset_get_damage(struct gset *gset)
}
if (gset->weaponnum == WEAPON_MAULER) {
damage = (gset->unk063a / 3.0f + 1.0f) * damage;
damage = (gset->maulercharge / 3.0f + 1.0f) * damage;
}
if (bgun_is_firing(HAND_LEFT) && bgun_is_firing(HAND_RIGHT)) {

View File

@ -195,8 +195,8 @@ void ctc_init_props(void)
0x0fff, // floorcol
0, // tiles
WEAPON_BRIEFCASE2, // weaponnum
0, // unk5d
0, // unk5e
0, // upgradewant
0, // miscbyte
FUNC_PRIMARY, // gunfunc
0, // fadeouttimer60
-1, // dualweaponnum

View File

@ -206,8 +206,8 @@ void htb_create_uplink(void)
0x0fff, // floorcol
0, // tiles
WEAPON_DATAUPLINK, // weaponnum
0, // unk5d
0, // unk5e
0, // upgradewant
0, // miscbyte
FUNC_PRIMARY, // gunfunc
0, // fadeouttimer60
-1, // dualweaponnum

View File

@ -205,8 +205,8 @@ void htb_create_token(void)
0x0fff, // floorcol
0, // tiles
WEAPON_BRIEFCASE2, // weaponnum
0, // unk5d
0, // unk5e
0, // upgradewant
0, // miscbyte
FUNC_PRIMARY, // gunfunc
0, // fadeouttimer60
-1, // dualweaponnum

View File

@ -1319,8 +1319,8 @@ void player_tick_chr_body(void)
0x0fff, // floorcol
0, // tiles
WEAPON_FALCON2, // weaponnum
0, // unk5d
0, // unk5e
0, // upgradewant
0, // miscbyte
FUNC_PRIMARY, // gunfunc
0, // fadeouttimer60
-1, // dualweaponnum

View File

@ -15726,7 +15726,7 @@ void obj_hit(struct shotdata *shotdata, struct hit *hit)
if (obj->modelnum == MODEL_TARGET) {
if (hit->hitthing.texturenum == TEXTURE_0B9E) {
fr_calculate_hit(obj, &sp110, shotdata->gset.unk063a);
fr_calculate_hit(obj, &sp110, shotdata->gset.maulercharge);
} else if ((shotdata->gset.weaponnum != WEAPON_CALLISTO || shotdata->gset.weaponfunc != FUNC_SECONDARY)
#if VERSION >= VERSION_NTSC_1_0
&& shotdata->gset.weaponnum != WEAPON_FARSIGHT
@ -18600,8 +18600,8 @@ struct weaponobj *weapon_create_projectile_from_gset(s32 modelnum, struct gset *
0x0fff, // floorcol
0, // tiles
0, // weaponnum
0, // unk5d
0, // unk5e
0, // upgradewant
0, // miscbyte
0, // gunfunc
0, // fadeouttimer60
-1, // dualweaponnum
@ -18612,8 +18612,8 @@ struct weaponobj *weapon_create_projectile_from_gset(s32 modelnum, struct gset *
*weapon = tmp;
weapon->weaponnum = gset->weaponnum;
weapon->unk5d = gset->unk0639;
weapon->unk5e = gset->unk063a;
weapon->upgradewant = gset->upgradewant;
weapon->miscbyte = gset->miscbyte;
weapon->gunfunc = gset->weaponfunc;
// This switch is useless because everything uses the same case
@ -18683,7 +18683,7 @@ void weapon_delete_from_chr(struct chrdata *chr, s32 hand)
}
}
struct prop *weapon_create_for_chr(struct chrdata *chr, s32 modelnum, s32 weaponnum, u32 flags, struct weaponobj *obj, struct modeldef *modeldef)
struct prop *weapon_create_for_chr(struct chrdata *chr, s32 modelnum, s32 weaponnum, u32 flags, struct weaponobj *weapon, struct modeldef *modeldef)
{
struct prop *prop;
struct model *model;
@ -18696,8 +18696,8 @@ struct prop *weapon_create_for_chr(struct chrdata *chr, s32 modelnum, s32 weapon
prop = prop_allocate();
model = modelmgr_instantiate_model_without_anim(modeldef);
if (obj == NULL) {
obj = weapon_create(prop == NULL, model == NULL, modeldef);
if (weapon == NULL) {
weapon = weapon_create(prop == NULL, model == NULL, modeldef);
}
if (prop == NULL) {
@ -18708,7 +18708,7 @@ struct prop *weapon_create_for_chr(struct chrdata *chr, s32 modelnum, s32 weapon
model = modelmgr_instantiate_model_without_anim(modeldef);
}
if (obj && prop && model) {
if (weapon && prop && model) {
struct weaponobj tmp = {
256, // extrascale
0, // hidden2
@ -18733,8 +18733,8 @@ struct prop *weapon_create_for_chr(struct chrdata *chr, s32 modelnum, s32 weapon
0x0fff, // floorcol
0, // tiles
0, // weaponnum
0, // unk5d
0, // unk5e
0, // upgradewant
0, // miscbyte
0, // gunfunc
0, // fadeouttimer60
-1, // dualweaponnum
@ -18742,17 +18742,17 @@ struct prop *weapon_create_for_chr(struct chrdata *chr, s32 modelnum, s32 weapon
NULL, // dualweapon
};
*obj = tmp;
*weapon = tmp;
obj->weaponnum = weaponnum;
obj->gunfunc = FUNC_PRIMARY;
obj->unk5e = 0;
obj->unk5d = 0;
obj->base.modelnum = modelnum;
obj->base.flags = flags | OBJFLAG_ASSIGNEDTOCHR;
obj->base.pad = chr->chrnum;
weapon->weaponnum = weaponnum;
weapon->gunfunc = FUNC_PRIMARY;
weapon->miscbyte = 0;
weapon->upgradewant = 0;
weapon->base.modelnum = modelnum;
weapon->base.flags = flags | OBJFLAG_ASSIGNEDTOCHR;
weapon->base.pad = chr->chrnum;
prop = func0f08b108(obj, chr, modeldef, prop, model);
prop = func0f08b108(weapon, chr, modeldef, prop, model);
} else {
if (model) {
modelmgr_free_model(model);
@ -18763,9 +18763,9 @@ struct prop *weapon_create_for_chr(struct chrdata *chr, s32 modelnum, s32 weapon
prop = NULL;
}
if (obj) {
obj->base.prop = NULL;
obj->base.model = NULL;
if (weapon) {
weapon->base.prop = NULL;
weapon->base.model = NULL;
}
}

View File

@ -144,7 +144,7 @@ struct autogunobj *laptop_deploy(s32 modelnum, struct gset *gset, struct chrdata
struct weaponobj *weapon_create_projectile_from_gset(s32 modelnum, struct gset *gset, struct chrdata *chr);
struct weaponobj *weapon_create_projectile_from_weapon_num(s32 modelnum, s32 weaponnum, struct chrdata *chr);
void weapon_delete_from_chr(struct chrdata *chr, s32 hand);
struct prop *weapon_create_for_chr(struct chrdata *chr, s32 modelnum, s32 weaponnum, u32 flags, struct weaponobj *obj, struct modeldef *modeldef);
struct prop *weapon_create_for_chr(struct chrdata *chr, s32 modelnum, s32 weaponnum, u32 flags, struct weaponobj *weapon, struct modeldef *modeldef);
struct prop *chr_give_weapon(struct chrdata *chr, s32 model, s32 weaponnum, u32 flags);
s32 weapon_test_for_pickup(struct prop *prop);
void weapon_set_gunfire_visible(struct prop *prop, bool visible, RoomNum room);

View File

@ -931,8 +931,12 @@ struct act_argh {
// Gun settings
struct gset {
u8 weaponnum;
u8 unk0639;
u8 unk063a;
u8 upgradewant;
union {
u8 miscbyte;
u8 lasershots;
u8 maulercharge;
};
u8 weaponfunc; // 0 or 1
};
@ -1537,10 +1541,14 @@ struct weaponobj { // objtype 0x08
union {
struct gset gset;
struct {
/*0x5c*/ u8 weaponnum;
/*0x5d*/ s8 unk5d;
/*0x5e*/ s8 unk5e;
/*0x5f*/ u8 gunfunc;
u8 weaponnum;
u8 upgradewant;
union {
u8 miscbyte;
u8 lasershots;
u8 maulercharge;
};
u8 gunfunc;
};
};
@ -2849,7 +2857,7 @@ struct gunviscmd {
// unk00 - Some kind of condition field
// 0 = terminator
// 4 = if bit in hand->unk0639 (bit index specified via unk02)
// 4 = if bit in hand->upgradewant (bit index specified via unk02)
// 5 = if in left hand
// 6 = if in right hand
u8 type;