diff --git a/src/game/bondgun.c b/src/game/bondgun.c index 1cc910b35..4d5428c0e 100644 --- a/src/game/bondgun.c +++ b/src/game/bondgun.c @@ -5316,7 +5316,7 @@ s32 bgunTickIncAutoSwitch(struct handweaponinfo *info, s32 handnum, struct hand playermgrDeleteWeapon(handnum); } - bgun0f09fa20(handnum); + bgunFreeRocket(handnum); hand->mode = HANDMODE_6; hand->stateminor = 2; @@ -9737,7 +9737,7 @@ bool bgunTickIncAttackingThrow(s32 handnum, struct hand *hand) invRemoveItemByNum(hand->gset.weaponnum); g_Vars.currentplayer->gunctrl.unk1583_04 = true; #if VERSION >= VERSION_NTSC_1_0 - bgun0f0a1ab0(); + bgunSwitchToPrevious(); #else bgunAutoSwitchWeapon(); #endif @@ -10561,7 +10561,7 @@ s32 bgunTickIncChangeGun(struct handweaponinfo *info, s32 handnum, struct hand * playermgrDeleteWeapon(handnum); } - bgun0f09fa20(handnum); + bgunFreeRocket(handnum); hand->mode = HANDMODE_6; hand->stateminor++; } else { @@ -10905,7 +10905,7 @@ bool bgunSetState(s32 handnum, s32 state) return valid; } -void bgunTick(s32 handnum) +void bgunTickHand(s32 handnum) { struct hand *hand = &g_Vars.currentplayer->hands[handnum]; struct handweaponinfo info; @@ -11708,22 +11708,22 @@ u32 bgunCalculateGunMemCapacity(void) return var800700a8; } -void bgun0f09df50(void) +void bgunFreeGunMem(void) { - g_Vars.currentplayer->gunctrl.gunmemowner = GUNMEMOWNER_11; + g_Vars.currentplayer->gunctrl.gunmemowner = GUNMEMOWNER_FREE; } -void bgun0f09df64(s32 arg0) +void bgunSetGunMemWeapon(s32 weaponnum) { struct player *player = g_Vars.currentplayer; - if (player->gunctrl.gunmemowner == GUNMEMOWNER_0) { + if (player->gunctrl.gunmemowner == GUNMEMOWNER_BONDGUN) { player->gunctrl.unk15b0 = 0; player->gunctrl.unk15b1 = 0; - player->gunctrl.gunmemnew = arg0; + player->gunctrl.gunmemnew = weaponnum; player->gunctrl.gunlocktimer = -1; } else { - player->gunctrl.gunmemnew = arg0; + player->gunctrl.gunmemnew = weaponnum; } } @@ -11771,7 +11771,7 @@ bool bgun0f09e004(s32 newowner) bool unlock = false; switch (player->gunctrl.gunmemowner) { - case GUNMEMOWNER_0: + case GUNMEMOWNER_BONDGUN: if (player->gunctrl.gunmemtype != -1) { player->gunctrl.gunmemnew = player->gunctrl.gunmemtype; } @@ -11781,7 +11781,7 @@ bool bgun0f09e004(s32 newowner) player->gunctrl.unk1583_06 = true; unlock = true; break; - case GUNMEMOWNER_2: + case GUNMEMOWNER_CHRBODY: if (g_Vars.mplayerisrunning) { unlock = true; } @@ -11790,7 +11790,7 @@ bool bgun0f09e004(s32 newowner) unlock = true; } - if (newowner == GUNMEMOWNER_1 && var8009dfc0 != 0) { + if (newowner == GUNMEMOWNER_INVMENU && var8009dfc0 != 0) { unlock = true; playerRemoveChrBody(); } @@ -11798,15 +11798,15 @@ bool bgun0f09e004(s32 newowner) case GUNMEMOWNER_3: unlock = true; break; - case GUNMEMOWNER_10: - case GUNMEMOWNER_11: + case GUNMEMOWNER_CHANGING: + case GUNMEMOWNER_FREE: unlock = true; break; } if (unlock) { player->gunctrl.gunlocktimer = -1; - player->gunctrl.gunmemowner = GUNMEMOWNER_10; + player->gunctrl.gunmemowner = GUNMEMOWNER_CHANGING; } } @@ -12280,7 +12280,7 @@ glabel bgun0f09e144 #if VERSION >= VERSION_NTSC_1_0 GLOBAL_ASM( -glabel bgunTickLoad +glabel bgunTickIncLoad /* f09e4e0: 27bdff58 */ addiu $sp,$sp,-168 /* f09e4e4: afb5002c */ sw $s5,0x2c($sp) /* f09e4e8: 3c15800a */ lui $s5,%hi(g_Vars) @@ -12687,7 +12687,7 @@ glabel bgunTickLoad ); #else GLOBAL_ASM( -glabel bgunTickLoad +glabel bgunTickIncLoad /* f09c38c: 27bdff58 */ addiu $sp,$sp,-168 /* f09c390: afb5002c */ sw $s5,0x2c($sp) /* f09c394: 3c15800a */ lui $s5,0x800a @@ -13087,7 +13087,7 @@ glabel bgunTickLoad ); #endif -//void bgunTickLoad(void) +//void bgunTickIncLoad(void) //{ // s32 spa4; // s32 bodynum; @@ -13099,7 +13099,7 @@ glabel bgunTickLoad // // struct player *player = g_Vars.currentplayer; // -// if ((player->gunctrl.gunmemowner == GUNMEMOWNER_0 || bgun0f09e004(GUNMEMOWNER_0)) && player->gunctrl.gunmemnew >= 0) { +// if ((player->gunctrl.gunmemowner == GUNMEMOWNER_BONDGUN || bgun0f09e004(GUNMEMOWNER_BONDGUN)) && player->gunctrl.gunmemnew >= 0) { // if (player->gunctrl.gunlocktimer == 0) { // spa4 = player->gunctrl.gunmemnew; // @@ -13320,12 +13320,12 @@ glabel bgunTickLoad // } //} -void bgun0f09ea90(void) +void bgunTickLoad(void) { s32 i; for (i = 0; i < g_Vars.lvupdate240; i += 8) { - bgunTickLoad(); + bgunTickIncLoad(); } } @@ -13351,10 +13351,10 @@ bool bgun0f09eae4(void) return false; } - if (g_Vars.currentplayer->gunctrl.gunmemowner) { - bgun0f09e004(GUNMEMOWNER_0); + if (g_Vars.currentplayer->gunctrl.gunmemowner != GUNMEMOWNER_BONDGUN) { + bgun0f09e004(GUNMEMOWNER_BONDGUN); - if (g_Vars.currentplayer->gunctrl.gunmemowner) { + if (g_Vars.currentplayer->gunctrl.gunmemowner != GUNMEMOWNER_BONDGUN) { g_Vars.lockscreen = true; return true; } @@ -13363,7 +13363,7 @@ bool bgun0f09eae4(void) bgun0f09df9c(); do { - bgunTickLoad(); + bgunTickIncLoad(); } while (!bgun0f09dd7c()); g_Vars.currentplayer->gunctrl.unk1583_06 = false; @@ -14629,7 +14629,7 @@ void bgun0f09f974(s32 handnum, struct weaponfunc_shootprojectile *func) } } -void bgun0f09fa20(s32 handnum) +void bgunFreeRocket(s32 handnum) { struct hand *hand = &g_Vars.currentplayer->hands[handnum]; @@ -17112,7 +17112,7 @@ glabel var7f1ac740 #if PAL GLOBAL_ASM( -glabel bgun0f0a0394 +glabel bgunSwivel .late_rodata glabel var7f1ac744 .word 0x3e99999a @@ -17652,7 +17652,7 @@ glabel var7f1ac764 ); #else GLOBAL_ASM( -glabel bgun0f0a0394 +glabel bgunSwivel .late_rodata glabel var7f1ac744 .word 0x3e99999a @@ -18192,7 +18192,13 @@ glabel var7f1ac764 ); #endif -void bgunSwivelTowards(f32 screenx, f32 screeny, f32 damp) +/** + * Swivel the gun towards the given screen coordinates, dampening the movement + * speed as it reaches the target. + * + * This is used for auto aim, the CMP's follow lock-on, and general turning. + */ +void bgunSwivelWithDamp(f32 screenx, f32 screeny, f32 damp) { struct weapon *weapon = weaponFindById(bgunGetWeaponNum(HAND_RIGHT)); f32 value = PAL ? weapon->eptr->unk10 : weapon->eptr->unk14; @@ -18201,15 +18207,21 @@ void bgunSwivelTowards(f32 screenx, f32 screeny, f32 damp) value = damp; } - bgun0f0a0394(screenx, screeny, damp, value); + bgunSwivel(screenx, screeny, damp, value); } -void bgun0f0a0b98(f32 screenx, f32 screeny) +/** + * Swivel the gun towards the given screen coordinates without slowing the speed + * speed as it reaches the target. + * + * This is used when manual aiming. + */ +void bgunSwivelWithoutDamp(f32 screenx, f32 screeny) { struct weapon *weapon = weaponFindById(bgunGetWeaponNum(HAND_RIGHT)); f32 value = PAL ? weapon->eptr->unk10 : weapon->eptr->unk14; - bgun0f0a0394(screenx, screeny, PAL ? 0.935f : 0.945f, value); + bgunSwivel(screenx, screeny, PAL ? 0.935f : 0.945f, value); } void bgunGetCrossPos(f32 *x, f32 *y) @@ -18518,7 +18530,7 @@ void bgunSetLastShootInfo(struct coord *pos, struct coord *dir, s32 handnum) hand->lastshootdir.z = dir->z; } -u32 bgunGetUnk0c30(s32 handnum) +s32 bgunGetShotsToTake(s32 handnum) { struct hand *hand = &g_Vars.currentplayer->hands[handnum]; @@ -18559,7 +18571,7 @@ void bgun0f0a134c(s32 handnum) playermgrDeleteWeapon(handnum); } - bgun0f09fa20(handnum); + bgunFreeRocket(handnum); } #if VERSION >= VERSION_JPN_FINAL @@ -18674,7 +18686,7 @@ glabel bgun0f0a1528 /* f0a2608: 1000000a */ b .JF0f0a2634 /* f0a260c: a2800000 */ sb $zero,0x0($s4) .JF0f0a2610: -/* f0a2610: 0fc27ba2 */ jal bgun0f09df64 +/* f0a2610: 0fc27ba2 */ jal bgunSetGunMemWeapon /* f0a2614: 00000000 */ nop /* f0a2618: 82990002 */ lb $t9,0x2($s4) /* f0a261c: 26a20ddc */ addiu $v0,$s5,0xddc @@ -18924,7 +18936,7 @@ void bgun0f0a1528(void) righthand->inuse = false; ctrl->weaponnum = WEAPON_NONE; } else { - bgun0f09df64(ctrl->switchtoweaponnum); + bgunSetGunMemWeapon(ctrl->switchtoweaponnum); ctrl->weaponnum = ctrl->switchtoweaponnum; lefthand->inuse = true; righthand->inuse = true; @@ -19055,7 +19067,7 @@ bool bgun0f0a1a10(s32 weaponnum) return false; } -s32 bgun0f0a1a68(s32 arg0) +s32 bgunGetSwitchToWeapon(s32 handnum) { s32 weaponnum; @@ -19065,14 +19077,14 @@ s32 bgun0f0a1a68(s32 arg0) weaponnum = g_Vars.currentplayer->gunctrl.weaponnum; } - if (!g_Vars.currentplayer->gunctrl.dualwielding && arg0 == 1) { + if (!g_Vars.currentplayer->gunctrl.dualwielding && handnum == HAND_LEFT) { weaponnum = WEAPON_NONE; } return weaponnum; } -void bgun0f0a1ab0(void) +void bgunSwitchToPrevious(void) { if (g_Vars.tickmode != TICKMODE_CUTSCENE) { struct player *player = g_Vars.currentplayer; @@ -19102,8 +19114,8 @@ void bgunCycleForward(void) struct player *player = g_Vars.currentplayer; if (g_Vars.tickmode != TICKMODE_CUTSCENE) { - weaponnum1 = bgun0f0a1a68(0); - weaponnum2 = bgun0f0a1a68(1); + weaponnum1 = bgunGetSwitchToWeapon(HAND_RIGHT); + weaponnum2 = bgunGetSwitchToWeapon(HAND_LEFT); if (weaponnum1 > WEAPON_PSYCHOSISGUN || weaponnum2 > WEAPON_PSYCHOSISGUN) { weaponnum1 = player->gunctrl.prevweaponnum; @@ -19129,8 +19141,8 @@ void bgunCycleBack(void) struct player *player = g_Vars.currentplayer; if (g_Vars.tickmode != TICKMODE_CUTSCENE) { - weaponnum1 = bgun0f0a1a68(0); - weaponnum2 = bgun0f0a1a68(1); + weaponnum1 = bgunGetSwitchToWeapon(HAND_RIGHT); + weaponnum2 = bgunGetSwitchToWeapon(HAND_LEFT); if (weaponnum2 == WEAPON_REMOTEMINE) { weaponnum2 = WEAPON_NONE; @@ -19532,9 +19544,9 @@ glabel bgunAutoSwitchWeapon // } //} -void bgunEquipWeapon2(bool arg0, s32 weaponnum) +void bgunEquipWeapon2(s32 handnum, s32 weaponnum) { - if (arg0 == 1) { + if (handnum == HAND_LEFT) { if (weaponnum == WEAPON_NONE) { g_Vars.currentplayer->gunctrl.dualwielding = false; } else { @@ -19598,7 +19610,7 @@ void bgunReloadIfPossible(s32 handnum) { struct player *player = g_Vars.currentplayer; - if (bgunGetAmmoTypeForWeapon(bgunGetWeaponNum(handnum), 0) + if (bgunGetAmmoTypeForWeapon(bgunGetWeaponNum(handnum), FUNC_PRIMARY) && player->hands[handnum].modenext == HANDMODE_NONE) { player->hands[handnum].modenext = HANDMODE_RELOAD; } @@ -20137,7 +20149,7 @@ bool bgun0f0a28d8(void) return false; } -void bgun0f0a29c8(void) +void bgunHandlePlayerDead(void) { struct player *player = g_Vars.currentplayer; s32 i; @@ -20158,11 +20170,11 @@ void bgun0f0a29c8(void) player->hands[i].matmot2 = 0; player->hands[i].matmot3 = 0; - bgunSetState(i, 0); + bgunSetState(i, HANDSTATE_IDLE); } - bgunEquipWeapon2(1, WEAPON_NONE); - bgunEquipWeapon2(0, WEAPON_NONE); + bgunEquipWeapon2(HAND_LEFT, WEAPON_NONE); + bgunEquipWeapon2(HAND_RIGHT, WEAPON_NONE); } } @@ -32376,7 +32388,7 @@ void bgunTickMaulerCharge(void) } } -void bgun0f0a6c30(void) +void bgunTickGameplay2(void) { struct player *player = g_Vars.currentplayer; struct hand *hand; @@ -32392,7 +32404,7 @@ void bgun0f0a6c30(void) if (player->gunctrl.unk1583_06) { // empty } else { - bgun0f09ea90(); + bgunTickLoad(); } // Return control to Jo if eyespy has been deselected @@ -35409,7 +35421,7 @@ void bgunPlayPropHitSound(struct gset *gset, struct prop *prop, s32 texturenum) #endif } -void bgun0f0a8404(struct coord *pos, s16 *rooms, s32 arg2) +void bgunPlayGlassHitSound(struct coord *pos, s16 *rooms, s32 arg2) { if (g_Vars.lvupdate240 > 0) { struct sndstate **handle = bgunAllocateAudioHandle(); @@ -36559,7 +36571,12 @@ bool bgunIsUsingSecondaryFunction(void) return false; } -void bgunsTick(bool triggeron) +/** + * Tick gun-related things during first-person gameplay. + * + * This function is not called during cutscenes. + */ +void bgunTickGameplay(bool triggeron) { s32 gunsfiring[2] = {false, false}; struct player *player = g_Vars.currentplayer; @@ -36679,8 +36696,8 @@ void bgunsTick(bool triggeron) bgunSetTriggerOn(HAND_LEFT, gunsfiring[1]); if (g_Vars.tickmode == TICKMODE_NORMAL && g_Vars.lvupdate240 > 0) { - bgunTick(HAND_RIGHT); - bgunTick(HAND_LEFT); + bgunTickHand(HAND_RIGHT); + bgunTickHand(HAND_LEFT); bgun0f09ce8c(); if (cheatIsActive(CHEAT_UNLIMITEDAMMONORELOADS)) { @@ -36804,43 +36821,39 @@ void bgunSetGunAmmoVisible(u32 reason, bool enable) } struct ammotype g_AmmoTypes[] = { - { 0, 0, 0 }, - { 800, 0, 0 }, - { 800, 0, 0 }, - { 69, 0, 0 }, - { 400, 0, -2 }, - { 100, 0, 0 }, - { 100, 0, 0 }, - { 12, 0, 0 }, - { 3, 0, -2 }, - { 10, 0, 0 }, - { 200, 0, 0 }, - { 40, 0, 0 }, - { 10, 0, 1 }, - { 10, 0, 1 }, - { 10, 0, 1 }, - { 800, 0, 0 }, - { 15, 0, -2 }, - { 50, 0, 0 }, - { 10, 0, 0 }, - { 200, 0, 0 }, -#if PAL - { 15000, 0, 0 }, -#else - { 18000, 0, 0 }, -#endif - { 4, 0, 0 }, - { 200, 0, 0 }, - { 2, 0, 0 }, - { 10, 0, 0 }, - { 10, 0, 0 }, - { 10, 0, 0 }, - { 1000, 0, 0 }, - { 10, 0, 0 }, - { 50, 0, -1 }, - { 1, 0, 0 }, - { 200, 0, 0 }, - { 10, 0, 0 }, + { 0, 0, 0 }, + { 800, 0, 0 }, // AMMOTYPE_PISTOL + { 800, 0, 0 }, // AMMOTYPE_SMG + { 69, 0, 0 }, // AMMOTYPE_CROSSBOW + { 400, 0, -2 }, // AMMOTYPE_RIFLE + { 100, 0, 0 }, // AMMOTYPE_SHOTGUN + { 100, 0, 0 }, // AMMOTYPE_FARSIGHT + { 12, 0, 0 }, // AMMOTYPE_GRENADE + { 3, 0, -2 }, // AMMOTYPE_ROCKET + { 10, 0, 0 }, // AMMOTYPE_KNIFE + { 200, 0, 0 }, // AMMOTYPE_MAGNUM + { 40, 0, 0 }, // AMMOTYPE_DEVASTATOR + { 10, 0, 1 }, // AMMOTYPE_REMOTE_MINE + { 10, 0, 1 }, // AMMOTYPE_PROXY_MINE + { 10, 0, 1 }, // AMMOTYPE_TIMED_MINE + { 800, 0, 0 }, // AMMOTYPE_REAPER + { 15, 0, -2 }, // AMMOTYPE_HOMINGROCKET + { 50, 0, 0 }, // AMMOTYPE_DART + { 10, 0, 0 }, // AMMOTYPE_NBOMB + { 200, 0, 0 }, // AMMOTYPE_SEDATIVE + { TICKS(18000), 0, 0 }, // AMMOTYPE_CLOAK + { 4, 0, 0 }, // AMMOTYPE_BOOST + { 200, 0, 0 }, // AMMOTYPE_PSYCHOSIS + { 2, 0, 0 }, // AMMOTYPE_17 + { 10, 0, 0 }, // AMMOTYPE_BUG + { 10, 0, 0 }, // AMMOTYPE_MICROCAMERA + { 10, 0, 0 }, // AMMOTYPE_PLASTIQUE + { 1000, 0, 0 }, // AMMOTYPE_1B + { 10, 0, 0 }, // AMMOTYPE_1C + { 50, 0, -1 }, // AMMOTYPE_1D + { 1, 0, 0 }, // AMMOTYPE_TOKEN + { 200, 0, 0 }, // AMMOTYPE_1F + { 10, 0, 0 }, // AMMOTYPE_ECM_MINE }; void bgunSetAmmoQuantity(s32 ammotype, s32 quantity) @@ -46633,7 +46646,7 @@ const char var7f1ac19c[] = "%02d:%02d\n"; // return gdl; //} -void bgunAddBoostc(s32 amount) +void bgunAddBoost(s32 amount) { g_Vars.speedpilltime += amount; @@ -46665,19 +46678,26 @@ void bgunApplyBoost(void) if (lvGetSlowMotionType() != SLOWMOTION_OFF) { bgunSubtractBoost(TICKS(1200)); } else { - bgunAddBoostc(TICKS(600)); + bgunAddBoost(TICKS(600)); } } void bgunRevertBoost(void) { if (lvGetSlowMotionType() != SLOWMOTION_OFF) { - bgunAddBoostc(TICKS(1200)); + bgunAddBoost(TICKS(1200)); } else { bgunSubtractBoost(TICKS(600)); } } +/** + * The main tick function as called from lvTick. + * + * This function doesn't do much because it's called during both cutscenes and + * gameplay, while most gun tick operations happen during gameplay only. + * See bgunTickGameplay for that. + */ void bgunTickBoost(void) { if (g_Vars.speedpillon && g_Vars.speedpilltime > 0 && !g_Vars.in_cutscene) { @@ -46700,7 +46720,7 @@ void bgunSetSightVisible(u32 reason, bool visible) g_Vars.currentplayer->gunsightoff |= reason; } -Gfx *bgun0f0abcb0(Gfx *gdl) +Gfx *bgunRenderSight(Gfx *gdl) { if (g_Vars.currentplayer->gunsightoff == false && !g_Vars.currentplayer->mpmenuon) { gdl = sightRender(gdl, true, currentPlayerGetSight()); diff --git a/src/game/bondgunreset.c b/src/game/bondgunreset.c index 75e3343a8..160c1f066 100644 --- a/src/game/bondgunreset.c +++ b/src/game/bondgunreset.c @@ -155,7 +155,7 @@ void bgunReset(void) g_Vars.currentplayer->gunctrl.unk15b1 = 0; g_Vars.currentplayer->gunctrl.gunmemtype = 0; g_Vars.currentplayer->gunctrl.gunmemnew = -1; - g_Vars.currentplayer->gunctrl.gunmemowner = GUNMEMOWNER_2; + g_Vars.currentplayer->gunctrl.gunmemowner = GUNMEMOWNER_CHRBODY; g_Vars.currentplayer->gunctrl.gunlocktimer = 0; g_Vars.currentplayer->gunctrl.unk1583_06 = true; diff --git a/src/game/bondmove.c b/src/game/bondmove.c index 84f0261b4..7f82585b1 100644 --- a/src/game/bondmove.c +++ b/src/game/bondmove.c @@ -1454,7 +1454,7 @@ void bmoveProcessInput(bool allowc1x, bool allowc1y, bool allowc1buttons, bool i movedata.speedvertaup = savedverta; } - bgunsTick(movedata.triggeron); + bgunTickGameplay(movedata.triggeron); if (g_Vars.bondvisible && (bgunIsFiring(HAND_RIGHT) || bgunIsFiring(HAND_LEFT))) { noiseradius = 0; @@ -1775,9 +1775,9 @@ void bmoveProcessInput(bool allowc1x, bool allowc1y, bool allowc1buttons, bool i y = g_Vars.currentplayer->autoaimy; if (followlockon) { - bgun0f0a0394(x, y, PAL ? 0.899f : 0.915f, PAL ? 0.899f : 0.915f); + bgunSwivel(x, y, PAL ? 0.899f : 0.915f, PAL ? 0.899f : 0.915f); } else { - bgunSwivelTowards(x, y, g_Vars.currentplayer->autoaimdamp); + bgunSwivelWithDamp(x, y, g_Vars.currentplayer->autoaimdamp); } } else { // This code moves the crosshair as the player turns and makes @@ -1793,13 +1793,13 @@ void bmoveProcessInput(bool allowc1x, bool allowc1y, bool allowc1buttons, bool i x = g_Vars.currentplayer->speedtheta * 0.3f + g_Vars.currentplayer->gunextraaimx; y = -g_Vars.currentplayer->speedverta * 0.1f + g_Vars.currentplayer->gunextraaimy; - bgunSwivelTowards(x, y, PAL ? 0.955f : 0.963f); + bgunSwivelWithDamp(x, y, PAL ? 0.955f : 0.963f); } } else if (movedata.canmanualaim) { // Adjust crosshair's position on screen // when holding aim and moving stick bgunSetAimType(0); - bgun0f0a0b98((movedata.c1stickxraw * 0.65f) / 80.0f, (movedata.c1stickyraw * 0.65f) / 80.0f); + bgunSwivelWithoutDamp((movedata.c1stickxraw * 0.65f) / 80.0f, (movedata.c1stickyraw * 0.65f) / 80.0f); } } diff --git a/src/game/menutick.c b/src/game/menutick.c index 992d29b4f..7e70778aa 100644 --- a/src/game/menutick.c +++ b/src/game/menutick.c @@ -686,11 +686,11 @@ void menuTick(void) } } - if (g_Vars.currentplayer->gunctrl.gunmemowner == 1 && g_Vars.stagenum != STAGE_CITRAINING) { + if (g_Vars.currentplayer->gunctrl.gunmemowner == GUNMEMOWNER_INVMENU && g_Vars.stagenum != STAGE_CITRAINING) { g_MenuData.unk5d5_01 = true; if (g_Menus[0].unk840.unk004) { - bgun0f09df50(); + bgunFreeGunMem(); g_Menus[0].unk840.unk004 = NULL; } } diff --git a/src/game/player.c b/src/game/player.c index 47ee3f9d0..3faa6abdd 100644 --- a/src/game/player.c +++ b/src/game/player.c @@ -1535,7 +1535,7 @@ void playerRemoveChrBody(void) chrRemove(g_Vars.currentplayer->prop, false); g_Vars.currentplayer->model00d4 = NULL; bmove0f0cb8c4(g_Vars.currentplayer); - bgun0f09df50(); + bgunFreeGunMem(); g_Vars.currentplayer->gunmem2 = NULL; } } @@ -4665,7 +4665,7 @@ void playerTick(bool arg0) // Handle mission exit on death if (g_Vars.currentplayer->isdead) { if (g_Vars.currentplayer->redbloodfinished == false) { - bgun0f0a29c8(); + bgunHandlePlayerDead(); } if (g_Vars.currentplayer->redbloodfinished && g_Vars.currentplayer->deathanimfinished) { @@ -5252,7 +5252,7 @@ Gfx *playerRenderHud(Gfx *gdl) } if (g_Vars.currentplayer->cameramode != CAMERAMODE_EYESPY) { - bgun0f0a6c30(); + bgunTickGameplay2(); gdl = boltbeamsRender(gdl); bgun0f0a7138(&gdl); gdl = lasersightRenderDot(gdl); @@ -5518,7 +5518,7 @@ Gfx *playerRenderHud(Gfx *gdl) } if (g_Vars.currentplayer->cameramode != CAMERAMODE_EYESPY) { - gdl = bgun0f0abcb0(gdl); + gdl = bgunRenderSight(gdl); if (bgunGetWeaponNum(HAND_RIGHT) == WEAPON_HORIZONSCANNER) { gdl = bviewRenderHorizonScanner(gdl); @@ -5639,7 +5639,7 @@ void playerDieByShooter(u32 shooter, bool force) } bmoveSetMode(MOVEMODE_WALK); - bgun0f0a29c8(); + bgunHandlePlayerDead(); if (playerGetMissionTime() - g_Vars.currentplayer->lifestarttime60 < g_Vars.currentplayerstats->shortestlife) { g_Vars.currentplayerstats->shortestlife = playerGetMissionTime() - g_Vars.currentplayer->lifestarttime60; diff --git a/src/game/playermgr.c b/src/game/playermgr.c index 075a38ce8..fd64e1df3 100644 --- a/src/game/playermgr.c +++ b/src/game/playermgr.c @@ -407,7 +407,7 @@ void playermgrAllocatePlayer(s32 index) g_Vars.players[index]->gunctrl.prevweaponnum = -1; g_Vars.players[index]->gunctrl.switchtoweaponnum = -1; - g_Vars.players[index]->gunctrl.gunmemowner = GUNMEMOWNER_2; + g_Vars.players[index]->gunctrl.gunmemowner = GUNMEMOWNER_CHRBODY; g_Vars.players[index]->gunctrl.gunlocktimer = 0; g_Vars.players[index]->gunctrl.action = 0; diff --git a/src/game/prop.c b/src/game/prop.c index 93f51a4f2..f635f66b4 100644 --- a/src/game/prop.c +++ b/src/game/prop.c @@ -1144,19 +1144,19 @@ void handInflictCloseRangeDamage(s32 handnum, struct gset *gset, bool arg2) * present for those. */ struct defaultobj *obj = prop->obj; - bool isbreakableobj = false; + bool isglass = false; if (obj && gset->weaponnum != WEAPON_TRANQUILIZER) { - isbreakableobj = obj->type == OBJTYPE_GLASS || obj->type == OBJTYPE_TINTEDGLASS; + isglass = obj->type == OBJTYPE_GLASS || obj->type == OBJTYPE_TINTEDGLASS; } if (arg2) { - isbreakableobj = false; + isglass = false; } if (prop->type == PROPTYPE_CHR || (prop->type == PROPTYPE_PLAYER && prop->chr && playermgrGetPlayerNumByProp(prop) != g_Vars.currentplayernum) - || isbreakableobj) { + || isglass) { f32 rangelimit = 60; f32 distance; f32 sp110; @@ -1180,7 +1180,7 @@ void handInflictCloseRangeDamage(s32 handnum, struct gset *gset, bool arg2) spf4[0] = camGetScreenHeight() * 0.16666667163372f; spf4[1] = camGetScreenHeight() * 0.125f; - if (isbreakableobj) { + if (isglass) { model = obj->model; } else { model = chr->model; @@ -1191,12 +1191,12 @@ void handInflictCloseRangeDamage(s32 handnum, struct gset *gset, bool arg2) && distance >= -rangelimit) { someval = 0x33; - if (isbreakableobj) { + if (isglass) { someval = 0; } if (cd0002dc18(&playerprop->pos, playerprop->rooms, &prop->pos, someval)) { - if (isbreakableobj) { + if (isglass) { struct model *model = obj->model; struct coord spd8; struct coord spcc; @@ -1207,7 +1207,7 @@ void handInflictCloseRangeDamage(s32 handnum, struct gset *gset, bool arg2) if (model000225d4(model, &spd8, &spcc, &node) > 0) { f32 damage = gsetGetDamage(gset) * 2.5f; skipthething = true; - bgun0f0a8404(&playerprop->pos, playerprop->rooms, -1); + bgunPlayGlassHitSound(&playerprop->pos, playerprop->rooms, -1); objTakeGunfire(obj, damage, &prop->pos, gset->weaponnum, g_Vars.currentplayernum); objDropRecursively(prop, false); } @@ -1303,7 +1303,7 @@ void handTickAttack(s32 handnum) handCreateBulletRaycast(handnum, true, true, 1, true); handCreateBulletRaycast(handnum, true, true, 1, true); } else { - handCreateBulletRaycast(handnum, true, true, bgunGetUnk0c30(handnum), g_Vars.mplayerisrunning); + handCreateBulletRaycast(handnum, true, true, bgunGetShotsToTake(handnum), g_Vars.mplayerisrunning); } mpstats0f0b0520(); diff --git a/src/game/propobj.c b/src/game/propobj.c index 5e17a0845..076761653 100644 --- a/src/game/propobj.c +++ b/src/game/propobj.c @@ -28356,7 +28356,7 @@ glabel var7f1ab110jf /* f0767b0: 2406ffff */ li $a2,-1 /* f0767b4: afa301e4 */ sw $v1,0x1e4($sp) /* f0767b8: afa40070 */ sw $a0,0x70($sp) -/* f0767bc: 0fc2a521 */ jal bgun0f0a8404 +/* f0767bc: 0fc2a521 */ jal bgunPlayGlassHitSound /* f0767c0: afa801ec */ sw $t0,0x1ec($sp) /* f0767c4: 8fa401e4 */ lw $a0,0x1e4($sp) /* f0767c8: 8fa801ec */ lw $t0,0x1ec($sp) @@ -31895,7 +31895,7 @@ glabel var7f1ab6dcpf /* f075910: 2406ffff */ li $a2,-1 /* f075914: afa301e4 */ sw $v1,0x1e4($sp) /* f075918: afa40070 */ sw $a0,0x70($sp) -/* f07591c: 0fc2a214 */ jal bgun0f0a8404 +/* f07591c: 0fc2a214 */ jal bgunPlayGlassHitSound /* f075920: afa801ec */ sw $t0,0x1ec($sp) /* f075924: 8fa401e4 */ lw $a0,0x1e4($sp) /* f075928: 8fa801ec */ lw $t0,0x1ec($sp) @@ -35440,7 +35440,7 @@ glabel var7f1ab6dcpf /* f075860: 2406ffff */ li $a2,-1 /* f075864: afa301e4 */ sw $v1,0x1e4($sp) /* f075868: afa40070 */ sw $a0,0x70($sp) -/* f07586c: 0fc2a1e8 */ jal bgun0f0a8404 +/* f07586c: 0fc2a1e8 */ jal bgunPlayGlassHitSound /* f075870: afa801ec */ sw $t0,0x1ec($sp) /* f075874: 8fa401e4 */ lw $a0,0x1e4($sp) /* f075878: 8fa801ec */ lw $t0,0x1ec($sp) @@ -38978,7 +38978,7 @@ glabel var7f1aa438 /* f07568c: 2406ffff */ addiu $a2,$zero,-1 /* f075690: afa301e4 */ sw $v1,0x1e4($sp) /* f075694: afa40070 */ sw $a0,0x70($sp) -/* f075698: 0fc2a101 */ jal bgun0f0a8404 +/* f075698: 0fc2a101 */ jal bgunPlayGlassHitSound /* f07569c: afa801ec */ sw $t0,0x1ec($sp) /* f0756a0: 8fa401e4 */ lw $a0,0x1e4($sp) /* f0756a4: 8fa801ec */ lw $t0,0x1ec($sp) @@ -42480,7 +42480,7 @@ glabel var7f1aa438 .NB0f0743bc: /* f0743bc: afa301ec */ sw $v1,0x1ec($sp) /* f0743c0: afa40074 */ sw $a0,0x74($sp) -/* f0743c4: 0fc29877 */ jal bgun0f0a8404 +/* f0743c4: 0fc29877 */ jal bgunPlayGlassHitSound /* f0743c8: afa701e8 */ sw $a3,0x1e8($sp) /* f0743cc: 8fa401e8 */ lw $a0,0x1e8($sp) /* f0743d0: 8fa301ec */ lw $v1,0x1ec($sp) @@ -71965,7 +71965,7 @@ glabel objHit /* f086260: 8d070004 */ lw $a3,0x4($t0) /* f086264: 8506003a */ lh $a2,0x3a($t0) /* f086268: 24e40008 */ addiu $a0,$a3,0x8 -/* f08626c: 0fc2a101 */ jal bgun0f0a8404 +/* f08626c: 0fc2a101 */ jal bgunPlayGlassHitSound /* f086270: 24e50028 */ addiu $a1,$a3,0x28 /* f086274: 10000007 */ b .L0f086294 /* f086278: 8fa80124 */ lw $t0,0x124($sp) @@ -72694,7 +72694,7 @@ glabel objHit /* f084abc: 8d070004 */ lw $a3,0x4($t0) /* f084ac0: 8506003a */ lh $a2,0x3a($t0) /* f084ac4: 24e40008 */ addiu $a0,$a3,0x8 -/* f084ac8: 0fc29877 */ jal bgun0f0a8404 +/* f084ac8: 0fc29877 */ jal bgunPlayGlassHitSound /* f084acc: 24e50028 */ addiu $a1,$a3,0x28 /* f084ad0: 10000007 */ beqz $zero,.NB0f084af0 /* f084ad4: 8fa80124 */ lw $t0,0x124($sp) diff --git a/src/include/constants.h b/src/include/constants.h index 709a7baaf..5ed3701ff 100644 --- a/src/include/constants.h +++ b/src/include/constants.h @@ -1115,12 +1115,12 @@ #define GUNCMD_PLAYANIMATION 10 #define GUNCMD_SETSOUNDSPEED 11 -#define GUNMEMOWNER_0 0 -#define GUNMEMOWNER_1 1 -#define GUNMEMOWNER_2 2 -#define GUNMEMOWNER_3 3 -#define GUNMEMOWNER_10 10 -#define GUNMEMOWNER_11 11 +#define GUNMEMOWNER_BONDGUN 0 +#define GUNMEMOWNER_INVMENU 1 +#define GUNMEMOWNER_CHRBODY 2 +#define GUNMEMOWNER_3 3 +#define GUNMEMOWNER_CHANGING 10 +#define GUNMEMOWNER_FREE 11 #define GUNAMMOREASON_OPTION 0x01 #define GUNAMMOREASON_NOCONTROL 0x02 diff --git a/src/include/game/bondgun.h b/src/include/game/bondgun.h index eba9d69c2..2bdcb5f87 100644 --- a/src/include/game/bondgun.h +++ b/src/include/game/bondgun.h @@ -52,7 +52,7 @@ s32 bgunTickIncChangeGun(struct handweaponinfo *info, s32 handnum, struct hand * s32 bgunTickIncState2(struct handweaponinfo *info, s32 handnum, struct hand *hand, s32 lvupdate); s32 bgunTickInc(struct handweaponinfo *info, s32 handnum, s32 lvupdate); bool bgunSetState(s32 handnum, s32 state); -void bgunTick(s32 handnum); +void bgunTickHand(s32 handnum); void bgun0f09ce8c(void); void bgunInitHandAnims(void); f32 bgunGetNoiseRadius(s32 handnum); @@ -64,13 +64,13 @@ bool bgun0f09dd7c(void); u32 bgunGetGunMemType(void); u8 *bgunGetGunMem(void); u32 bgunCalculateGunMemCapacity(void); -void bgun0f09df50(void); -void bgun0f09df64(s32 weaponnum); +void bgunFreeGunMem(void); +void bgunSetGunMemWeapon(s32 weaponnum); void bgun0f09df9c(void); bool bgun0f09e004(s32 newowner); void bgun0f09e144(void); +void bgunTickIncLoad(void); void bgunTickLoad(void); -void bgun0f09ea90(void); bool bgun0f09eae4(void); struct modelfiledata *bgun0f09ebbc(void); void bgun0f09ebcc(struct defaultobj *obj, struct coord *coord, s16 *rooms, Mtxf *matrix1, struct coord *arg4, Mtxf *matrix2, struct prop *prop, struct coord *pos); @@ -79,30 +79,30 @@ struct defaultobj *bgun0f09ee18(struct chrdata *chr, struct gset *gset, struct c void bgunCreateThrownProjectile(s32 handnum, struct gset *gset); void bgun0f09f848(s32 handnum); void bgun0f09f974(s32 handnum, struct weaponfunc_shootprojectile *func); -void bgun0f09fa20(s32 handnum); +void bgunFreeRocket(s32 handnum); void bgunCreateFiredProjectile(s32 handnum); -void bgun0f0a0394(f32 autoaimx, f32 autoaimy, f32 damp, f32 arg3); -void bgunSwivelTowards(f32 screenx, f32 screeny, f32 damp); -void bgun0f0a0b98(f32 arg0, f32 arg1); +void bgunSwivel(f32 autoaimx, f32 autoaimy, f32 damp, f32 arg3); +void bgunSwivelWithDamp(f32 screenx, f32 screeny, f32 damp); +void bgunSwivelWithoutDamp(f32 arg0, f32 arg1); void bgunGetCrossPos(f32 *x, f32 *y); void bgun0f0a0c08(struct coord *arg0, struct coord *arg1); void bgun0f0a0c44(s32 handnum, struct coord *arg1, struct coord *arg2); void bgunCalculateShotSpread(struct coord *arg0, struct coord *arg1, s32 handnum, bool dorandom); void bgun0f0a0fac(struct coord *arg0, s32 weaponnum, s32 funcnum, s32 arg3, s32 crouchpos, bool dual); void bgunSetLastShootInfo(struct coord *pos, struct coord *dir, s32 handnum); -u32 bgunGetUnk0c30(s32 handnum); +s32 bgunGetShotsToTake(s32 handnum); void bgun0f0a134c(s32 handnum); void bgun0f0a1528(void); void bgunEquipWeapon(s32 weaponnum); s32 bgunGetWeaponNum(s32 handnum); bool bgun0f0a1a10(s32 weaponnum); -s32 bgun0f0a1a68(s32 arg0); -void bgun0f0a1ab0(void); +s32 bgunGetSwitchToWeapon(s32 handnum); +void bgunSwitchToPrevious(void); void bgunCycleForward(void); void bgunCycleBack(void); bool bgunHasAmmoForWeapon(s32 weaponnum); void bgunAutoSwitchWeapon(void); -void bgunEquipWeapon2(bool arg0, s32 weaponnum); +void bgunEquipWeapon2(s32 handnum, s32 weaponnum); s32 bgunIsFiring(s32 handnum); s32 bgunGetAttackType(s32 handnum); char *bgunGetName(s32 weaponnum); @@ -115,7 +115,7 @@ u32 bgun0f0a233c(void); f32 bgun0f0a2498(f32 arg0, f32 arg1, f32 arg2, f32 arg3); void bgun0f0a24f0(struct coord *arg0, s32 handnum); bool bgun0f0a27c8(void); -void bgun0f0a29c8(void); +void bgunHandlePlayerDead(void); bool bgunIsMissionCritical(s32 weaponnum); void bgunLoseGun(struct prop *attacker); u32 bgun0f0a2da8(void); @@ -137,18 +137,18 @@ u32 bgun0f0a4e44(void); u32 bgun0f0a5300(void); void bgun0f0a5550(s32 handnum); void bgunTickMaulerCharge(void); -void bgun0f0a6c30(void); +void bgunTickGameplay2(void); s32 bgunAllocateFireslot(void); void bgun0f0a7138(Gfx **gdl); struct sndstate **bgunAllocateAudioHandle(void); void bgunPlayPropHitSound(struct gset *gset, struct prop *prop, s32 texturenum); -void bgun0f0a8404(struct coord *pos, s16 *rooms, s32 arg2); +void bgunPlayGlassHitSound(struct coord *pos, s16 *rooms, s32 arg2); void bgunPlayBgHitSound(struct gset *gset, struct coord *arg1, s32 texturenum, s16 *arg3); void bgunSetTriggerOn(s32 handnum, bool on); s32 bgunConsiderToggleGunFunction(s32 usedowntime, bool firing, s32 arg2); void bgun0f0a8c50(void); bool bgunIsUsingSecondaryFunction(void); -void bgunsTick(bool triggeron); +void bgunTickGameplay(bool triggeron); void bgunSetPassiveMode(bool enable); void bgunSetAimType(u32 aimtype); void bgunSetAimPos(struct coord *coord); @@ -172,13 +172,13 @@ void bgunResetAbmag(struct abmag *abmag); void bgun0f0a9da8(struct abmag *abmag, s32 remaining, s32 capacity, s32 height); Gfx *bgunRenderHudGauge(Gfx *gdl, s32 x1, s32 y1, s32 x2, s32 y2, struct abmag *abmag, s32 remaining, s32 capacity, u32 vacantcolour, u32 occupiedcolour, bool flip); Gfx *bgunRenderHud(Gfx *gdl); -void bgunAddBoostc(s32 arg0); +void bgunAddBoost(s32 arg0); void bgunSubtractBoost(s32 arg0); void bgunApplyBoost(void); void bgunRevertBoost(void); void bgunTickBoost(void); void bgunSetSightVisible(u32 bits, bool visible); -Gfx *bgun0f0abcb0(Gfx *gdl); +Gfx *bgunRenderSight(Gfx *gdl); void bgun0f0abd30(s32 handnum); s32 bgunGetWeaponNum2(s32 handnum); s8 bgunFreeFireslotWrapper(s32 fireslot);