From 2af20b8596057d3e8a93e23f1bf808984d4bc189 Mon Sep 17 00:00:00 2001 From: Ryan Dwyer Date: Sat, 23 Jan 2021 16:47:02 +1000 Subject: [PATCH] Split game_0b0420.c to mpstats.c and game_0b0fd0.c and give mpstats functions consistent names --- ld/gamefiles.inc | 3 +- src/game/activemenu/activemenu.c | 2 +- src/game/activemenu/tick.c | 2 +- src/game/bondmove.c | 2 +- src/game/chr/chr.c | 2 +- src/game/chr/chraction.c | 27 +- src/game/chr/chraicommands.c | 7 +- src/game/core.c | 2 +- src/game/endscreen.c | 29 +- src/game/game_01b0a0.c | 2 +- src/game/game_0601b0.c | 7 +- src/game/game_097ba0.c | 2 +- src/game/game_0abe70.c | 2 +- src/game/{game_0b0420.c => game_0b0fd0.c} | 331 +---------------- src/game/game_0b63b0.c | 2 +- src/game/game_0b69d0.c | 3 +- src/game/game_0d7070.c | 2 +- src/game/game_0dcdb0.c | 2 +- src/game/game_102240.c | 2 +- src/game/game_190260.c | 2 +- src/game/game_197600.c | 2 +- src/game/game_1999b0.c | 2 +- src/game/game_1a7560.c | 2 +- src/game/inventory/inventory.c | 2 +- src/game/mplayer/ingame.c | 2 +- src/game/mplayer/mplayer.c | 19 +- src/game/mpstats.c | 351 ++++++++++++++++++ src/game/propobj.c | 19 +- src/game/training/menus.c | 2 +- src/game/training/training.c | 2 +- src/game/wallhit.c | 2 +- src/include/constants.h | 14 +- .../game/{game_0b0420.h => game_0b0fd0.h} | 18 +- src/include/game/mpstats.h | 21 ++ 34 files changed, 464 insertions(+), 427 deletions(-) rename src/game/{game_0b0420.c => game_0b0fd0.c} (72%) create mode 100644 src/game/mpstats.c rename src/include/game/{game_0b0420.h => game_0b0fd0.h} (73%) create mode 100644 src/include/game/mpstats.h diff --git a/ld/gamefiles.inc b/ld/gamefiles.inc index a764abfec..54bcedc3b 100644 --- a/ld/gamefiles.inc +++ b/ld/gamefiles.inc @@ -91,7 +91,8 @@ build/ROMID/game/game_097ba0.o (section); \ build/ROMID/game/data/data_0160b0.o (section); \ build/ROMID/game/game_0abe70.o (section); \ - build/ROMID/game/game_0b0420.o (section); \ + build/ROMID/game/mpstats.o (section); \ + build/ROMID/game/game_0b0fd0.o (section); \ build/ROMID/game/game_0b2150.o (section); \ build/ROMID/game/game_0b28d0.o (section); \ build/ROMID/game/game_0b3350.o (section); \ diff --git a/src/game/activemenu/activemenu.c b/src/game/activemenu/activemenu.c index f4d4d7944..5f2980314 100644 --- a/src/game/activemenu/activemenu.c +++ b/src/game/activemenu/activemenu.c @@ -12,7 +12,7 @@ #include "game/data/data_02e820.h" #include "game/game_005fd0.h" #include "game/game_097ba0.h" -#include "game/game_0b0420.h" +#include "game/game_0b0fd0.h" #include "game/game_0b3350.h" #include "game/game_0d4690.h" #include "game/game_0f09f0.h" diff --git a/src/game/activemenu/tick.c b/src/game/activemenu/tick.c index a00e3eb0c..0ce507e9c 100644 --- a/src/game/activemenu/tick.c +++ b/src/game/activemenu/tick.c @@ -10,7 +10,7 @@ #include "game/data/data_02da90.h" #include "game/game_01b0a0.h" #include "game/game_097ba0.h" -#include "game/game_0b0420.h" +#include "game/game_0b0fd0.h" #include "game/inventory/inventory.h" #include "game/game_127910.h" #include "game/pdoptions.h" diff --git a/src/game/bondmove.c b/src/game/bondmove.c index 653bf3996..8eb90e269 100644 --- a/src/game/bondmove.c +++ b/src/game/bondmove.c @@ -19,7 +19,7 @@ #include "game/game_096750.h" #include "game/game_096ca0.h" #include "game/game_097ba0.h" -#include "game/game_0b0420.h" +#include "game/game_0b0fd0.h" #include "game/game_0b3350.h" #include "game/game_0b69d0.h" #include "game/bondcutscene.h" diff --git a/src/game/chr/chr.c b/src/game/chr/chr.c index 94b379ec6..cd42096d7 100644 --- a/src/game/chr/chr.c +++ b/src/game/chr/chr.c @@ -19,7 +19,7 @@ #include "game/game_096360.h" #include "game/game_097ba0.h" #include "game/game_0abe70.h" -#include "game/game_0b0420.h" +#include "game/game_0b0fd0.h" #include "game/game_0b28d0.h" #include "game/game_0b3350.h" #include "game/game_0b69d0.h" diff --git a/src/game/chr/chraction.c b/src/game/chr/chraction.c index 57969e62a..7f2bbea1b 100644 --- a/src/game/chr/chraction.c +++ b/src/game/chr/chraction.c @@ -22,7 +22,7 @@ #include "game/game_0969d0.h" #include "game/game_097ba0.h" #include "game/game_0abe70.h" -#include "game/game_0b0420.h" +#include "game/game_0b0fd0.h" #include "game/game_0b28d0.h" #include "game/game_0b3350.h" #include "game/game_0b69d0.h" @@ -43,6 +43,7 @@ #include "game/pak/pak.h" #include "game/propobj.h" #include "game/wallhit.h" +#include "game/mpstats.h" #include "gvars/gvars.h" #include "lib/lib_04790.h" #include "lib/lib_04a80.h" @@ -2699,7 +2700,7 @@ glabel var7f1a8d44 /* f031a18: 24190001 */ addiu $t9,$zero,0x1 /* f031a1c: afb900e8 */ sw $t9,0xe8($sp) .L0f031a20: -/* f031a20: 0fc2c15d */ jal decrementKnockoutCount +/* f031a20: 0fc2c15d */ jal mpstatsDecrementTotalKnockoutCount /* f031a24: afa700ec */ sw $a3,0xec($sp) /* f031a28: 8fa700ec */ lw $a3,0xec($sp) .L0f031a2c: @@ -3791,7 +3792,7 @@ glabel var7f1a8d44 /* f0329e8: 8dada24c */ lw $t5,%lo(g_Vars+0x28c)($t5) /* f0329ec: 0fc4a24b */ jal setCurrentPlayerNum /* f0329f0: afad0058 */ sw $t5,0x58($sp) -/* f0329f4: 0fc2c169 */ jal mpstatsRecordKill +/* f0329f4: 0fc2c169 */ jal mpstatsRecordPlayerKill /* f0329f8: 00000000 */ nop /* f0329fc: 0fc4a24b */ jal setCurrentPlayerNum /* f032a00: 8fa40058 */ lw $a0,0x58($sp) @@ -3801,7 +3802,7 @@ glabel var7f1a8d44 /* f032a0c: 000ecac0 */ sll $t9,$t6,0xb /* f032a10: 07210004 */ bgez $t9,.L0f032a24 /* f032a14: 00000000 */ nop -/* f032a18: 0fc2c151 */ jal incrementKillCount +/* f032a18: 0fc2c151 */ jal mpstatsIncrementTotalKillCount /* f032a1c: 00000000 */ nop /* f032a20: 8fa20040 */ lw $v0,0x40($sp) .L0f032a24: @@ -4712,7 +4713,7 @@ glabel func0f0336a8 /* f0336d0: 2401001f */ addiu $at,$zero,0x1f /* f0336d4: 50410011 */ beql $v0,$at,.L0f03371c /* f0336d8: 8fbf0014 */ lw $ra,0x14($sp) -/* f0336dc: 0fc2c163 */ jal getKnockoutCount +/* f0336dc: 0fc2c163 */ jal mpstatsGetTotalKnockoutCount /* f0336e0: afa40018 */ sw $a0,0x18($sp) /* f0336e4: 28410002 */ slti $at,$v0,0x2 /* f0336e8: 10200005 */ beqz $at,.L0f033700 @@ -4722,7 +4723,7 @@ glabel func0f0336a8 /* f0336f8: 01c17825 */ or $t7,$t6,$at /* f0336fc: ac8f0018 */ sw $t7,0x18($a0) .L0f033700: -/* f033700: 0fc2c157 */ jal incrementKnockoutCount +/* f033700: 0fc2c157 */ jal mpstatsIncrementTotalKnockoutCount /* f033704: afa40018 */ sw $a0,0x18($sp) /* f033708: 8fa40018 */ lw $a0,0x18($sp) /* f03370c: 24180020 */ addiu $t8,$zero,0x20 @@ -6618,27 +6619,27 @@ glabel var7f1a8d98 /* f035324: 10000011 */ b .L0f03536c /* f035328: 8fa4014c */ lw $a0,0x14c($sp) .L0f03532c: -/* f03532c: 0fc2c11b */ jal func0f0b046c +/* f03532c: 0fc2c11b */ jal mpstatsIncrementPlayerShotCount2 /* f035330: 8fa4014c */ lw $a0,0x14c($sp) /* f035334: 1000000f */ b .L0f035374 /* f035338: 00000000 */ nop .L0f03533c: -/* f03533c: 0fc2c11b */ jal func0f0b046c +/* f03533c: 0fc2c11b */ jal mpstatsIncrementPlayerShotCount2 /* f035340: 24050004 */ addiu $a1,$zero,0x4 /* f035344: 1000000b */ b .L0f035374 /* f035348: 00000000 */ nop .L0f03534c: -/* f03534c: 0fc2c11b */ jal func0f0b046c +/* f03534c: 0fc2c11b */ jal mpstatsIncrementPlayerShotCount2 /* f035350: 24050005 */ addiu $a1,$zero,0x5 /* f035354: 10000007 */ b .L0f035374 /* f035358: 00000000 */ nop .L0f03535c: -/* f03535c: 0fc2c11b */ jal func0f0b046c +/* f03535c: 0fc2c11b */ jal mpstatsIncrementPlayerShotCount2 /* f035360: 24050002 */ addiu $a1,$zero,0x2 /* f035364: 10000003 */ b .L0f035374 /* f035368: 00000000 */ nop .L0f03536c: -/* f03536c: 0fc2c11b */ jal func0f0b046c +/* f03536c: 0fc2c11b */ jal mpstatsIncrementPlayerShotCount2 /* f035370: 24050003 */ addiu $a1,$zero,0x3 .L0f035374: /* f035374: 0fc4a24b */ jal setCurrentPlayerNum @@ -7529,7 +7530,7 @@ glabel var7f1a8d98 /* f03600c: afa80074 */ sw $t0,0x74($sp) /* f036010: 0fc4a24b */ jal setCurrentPlayerNum /* f036014: 00402025 */ or $a0,$v0,$zero -/* f036018: 0fc2c169 */ jal mpstatsRecordKill +/* f036018: 0fc2c169 */ jal mpstatsRecordPlayerKill /* f03601c: 00000000 */ nop /* f036020: 0fc4a24b */ jal setCurrentPlayerNum /* f036024: 8fa40074 */ lw $a0,0x74($sp) @@ -7538,7 +7539,7 @@ glabel var7f1a8d98 /* f03602c: 000a5ac0 */ sll $t3,$t2,0xb /* f036030: 05630004 */ bgezl $t3,.L0f036044 /* f036034: 8e0202d4 */ lw $v0,0x2d4($s0) -/* f036038: 0fc2c151 */ jal incrementKillCount +/* f036038: 0fc2c151 */ jal mpstatsIncrementTotalKillCount /* f03603c: 00000000 */ nop /* f036040: 8e0202d4 */ lw $v0,0x2d4($s0) .L0f036044: diff --git a/src/game/chr/chraicommands.c b/src/game/chr/chraicommands.c index e7d680cfc..9d15f9c64 100644 --- a/src/game/chr/chraicommands.c +++ b/src/game/chr/chraicommands.c @@ -25,7 +25,7 @@ #include "game/game_095320.h" #include "game/game_096750.h" #include "game/game_097ba0.h" -#include "game/game_0b0420.h" +#include "game/game_0b0fd0.h" #include "game/game_0b28d0.h" #include "game/game_0b69d0.h" #include "game/game_0dcdb0.h" @@ -45,6 +45,7 @@ #include "game/pad.h" #include "game/pdoptions.h" #include "game/propobj.h" +#include "game/mpstats.h" #include "gvars/gvars.h" #include "lib/lib_04790.h" #include "lib/lib_04a80.h" @@ -5877,9 +5878,9 @@ bool aiIfNumKnockedOutChrs(void) { u8 *cmd = g_Vars.ailist + g_Vars.aioffset; - if (cmd[2] < getKnockoutCount() && cmd[3] == 0) { + if (cmd[2] < mpstatsGetTotalKnockoutCount() && cmd[3] == 0) { g_Vars.aioffset = chraiGoToLabel(g_Vars.ailist, g_Vars.aioffset, cmd[4]); - } else if (getKnockoutCount() < cmd[2] && cmd[3] == 1) { + } else if (mpstatsGetTotalKnockoutCount() < cmd[2] && cmd[3] == 1) { g_Vars.aioffset = chraiGoToLabel(g_Vars.ailist, g_Vars.aioffset, cmd[4]); } else { g_Vars.aioffset += 5; diff --git a/src/game/core.c b/src/game/core.c index fdb0a7fa4..31091e0e8 100644 --- a/src/game/core.c +++ b/src/game/core.c @@ -63,7 +63,7 @@ #include "game/game_095320.h" #include "game/game_097ba0.h" #include "game/game_0abe70.h" -#include "game/game_0b0420.h" +#include "game/game_0b0fd0.h" #include "game/game_0b28d0.h" #include "game/game_0b63b0.h" #include "game/game_0b69d0.h" diff --git a/src/game/endscreen.c b/src/game/endscreen.c index 980b96a89..eb85ca513 100644 --- a/src/game/endscreen.c +++ b/src/game/endscreen.c @@ -13,7 +13,7 @@ #include "game/game_01b0a0.h" #include "game/game_095320.h" #include "game/game_097ba0.h" -#include "game/game_0b0420.h" +#include "game/game_0b0fd0.h" #include "game/game_0b69d0.h" #include "game/game_0d4690.h" #include "game/game_0e0770.h" @@ -28,6 +28,7 @@ #include "game/gamefile.h" #include "game/lang.h" #include "game/pdoptions.h" +#include "game/mpstats.h" #include "gvars/gvars.h" #include "lib/lib_09660.h" #include "lib/main.h" @@ -178,50 +179,50 @@ struct menudialog g_NextMissionMenuDialog = { char *soloMenuTextNumKills(struct menuitem *item) { - sprintf(g_StringPointer, "%d", currentPlayerGetNumKills()); + sprintf(g_StringPointer, "%d", mpstatsGetPlayerKillCount()); return g_StringPointer; } char *soloMenuTextNumShots(struct menuitem *item) { - sprintf(g_StringPointer, "%d", currentPlayerGetShotCount(SHOTCOUNT_TOTAL)); + sprintf(g_StringPointer, "%d", mpstatsGetPlayerShotCountByRegion(SHOTREGION_TOTAL)); return g_StringPointer; } char *soloMenuTextNumHeadShots(struct menuitem *item) { - sprintf(g_StringPointer, "%d", currentPlayerGetShotCount(SHOTCOUNT_HEAD)); + sprintf(g_StringPointer, "%d", mpstatsGetPlayerShotCountByRegion(SHOTREGION_HEAD)); return g_StringPointer; } char *soloMenuTextNumBodyShots(struct menuitem *item) { - sprintf(g_StringPointer, "%d", currentPlayerGetShotCount(SHOTCOUNT_BODY)); + sprintf(g_StringPointer, "%d", mpstatsGetPlayerShotCountByRegion(SHOTREGION_BODY)); return g_StringPointer; } char *soloMenuTextNumLimbShots(struct menuitem *item) { - sprintf(g_StringPointer, "%d", currentPlayerGetShotCount(SHOTCOUNT_LIMB)); + sprintf(g_StringPointer, "%d", mpstatsGetPlayerShotCountByRegion(SHOTREGION_LIMB)); return g_StringPointer; } char *soloMenuTextNumOtherShots(struct menuitem *item) { - u32 total = currentPlayerGetShotCount(SHOTCOUNT_GUN) + currentPlayerGetShotCount(SHOTCOUNT_5); + u32 total = mpstatsGetPlayerShotCountByRegion(SHOTREGION_GUN) + mpstatsGetPlayerShotCountByRegion(SHOTREGION_5); sprintf(g_StringPointer, "%d", total); return g_StringPointer; } char *soloMenuTextAccuracy(struct menuitem *item) { - s32 total = currentPlayerGetShotCount(SHOTCOUNT_TOTAL); - s32 numhead = currentPlayerGetShotCount(SHOTCOUNT_HEAD); - s32 numbody = currentPlayerGetShotCount(SHOTCOUNT_BODY); - s32 numlimb = currentPlayerGetShotCount(SHOTCOUNT_LIMB); - s32 numgun = currentPlayerGetShotCount(SHOTCOUNT_GUN); - s32 num5 = currentPlayerGetShotCount(SHOTCOUNT_5); - s32 numobject = currentPlayerGetShotCount(SHOTCOUNT_OBJECT); + s32 total = mpstatsGetPlayerShotCountByRegion(SHOTREGION_TOTAL); + s32 numhead = mpstatsGetPlayerShotCountByRegion(SHOTREGION_HEAD); + s32 numbody = mpstatsGetPlayerShotCountByRegion(SHOTREGION_BODY); + s32 numlimb = mpstatsGetPlayerShotCountByRegion(SHOTREGION_LIMB); + s32 numgun = mpstatsGetPlayerShotCountByRegion(SHOTREGION_GUN); + s32 num5 = mpstatsGetPlayerShotCountByRegion(SHOTREGION_5); + s32 numobject = mpstatsGetPlayerShotCountByRegion(SHOTREGION_OBJECT); f32 accuracy; if (total > 0) { diff --git a/src/game/game_01b0a0.c b/src/game/game_01b0a0.c index eb8e369a1..e6ba023ef 100644 --- a/src/game/game_01b0a0.c +++ b/src/game/game_01b0a0.c @@ -9,7 +9,7 @@ #include "game/data/data_02da90.h" #include "game/game_01b0a0.h" #include "game/game_097ba0.h" -#include "game/game_0b0420.h" +#include "game/game_0b0fd0.h" #include "game/inventory/inventory.h" #include "game/game_127910.h" #include "game/pdoptions.h" diff --git a/src/game/game_0601b0.c b/src/game/game_0601b0.c index 6493c77d8..e93a03830 100644 --- a/src/game/game_0601b0.c +++ b/src/game/game_0601b0.c @@ -18,7 +18,7 @@ #include "game/floor.h" #include "game/ceil.h" #include "game/game_097ba0.h" -#include "game/game_0b0420.h" +#include "game/game_0b0fd0.h" #include "game/game_0b3350.h" #include "game/game_0b69d0.h" #include "game/game_127910.h" @@ -32,6 +32,7 @@ #include "game/propobj.h" #include "game/splat.h" #include "game/wallhit.h" +#include "game/mpstats.h" #include "gvars/gvars.h" #include "lib/lib_0e9d0.h" #include "lib/lib_12dc0.h" @@ -2417,7 +2418,7 @@ void handTickAttack(s32 handnum) // right hand is not (ie. prevent firing both guns on the same tick) if (handnum == HAND_RIGHT || !handIsAttackingOnThisTick(HAND_RIGHT)) { chrUncloakTemporarily(g_Vars.currentplayer->prop->chr); - func0f0b046c((struct hand *)&tmpweaponnum, 0); + mpstatsIncrementPlayerShotCount2((struct hand *)&tmpweaponnum, 0); if (weaponnum == WEAPON_SHOTGUN) { handCreateBulletRaycast(handnum, true, true, 1, true); @@ -2430,7 +2431,7 @@ void handTickAttack(s32 handnum) handCreateBulletRaycast(handnum, true, true, func0f0a1318(handnum), g_Vars.mplayerisrunning); } - func0f0b0520(); + mpstats0f0b0520(); } break; case HANDATTACKTYPE_CLOSERANGE: diff --git a/src/game/game_097ba0.c b/src/game/game_097ba0.c index 6b9e59754..14ec0f6d2 100644 --- a/src/game/game_097ba0.c +++ b/src/game/game_097ba0.c @@ -22,7 +22,7 @@ #include "game/game_097aa0.h" #include "game/game_097ba0.h" #include "game/game_0abe70.h" -#include "game/game_0b0420.h" +#include "game/game_0b0fd0.h" #include "game/game_0b28d0.h" #include "game/game_0b3350.h" #include "game/game_0b69d0.h" diff --git a/src/game/game_0abe70.c b/src/game/game_0abe70.c index 0ab0a6c9d..8976a40ff 100644 --- a/src/game/game_0abe70.c +++ b/src/game/game_0abe70.c @@ -10,7 +10,7 @@ #include "game/game_0969d0.h" #include "game/game_097ba0.h" #include "game/game_0abe70.h" -#include "game/game_0b0420.h" +#include "game/game_0b0fd0.h" #include "game/game_0b3350.h" #include "game/game_0c33f0.h" #include "game/game_166e40.h" diff --git a/src/game/game_0b0420.c b/src/game/game_0b0fd0.c similarity index 72% rename from src/game/game_0b0420.c rename to src/game/game_0b0fd0.c index 585bd59c5..fd4fda9b3 100644 --- a/src/game/game_0b0420.c +++ b/src/game/game_0b0fd0.c @@ -10,7 +10,7 @@ #include "game/data/data_02da90.h" #include "game/inventory/items.h" #include "game/game_097ba0.h" -#include "game/game_0b0420.h" +#include "game/game_0b0fd0.h" #include "game/game_0b69d0.h" #include "game/game_0dcdb0.h" #include "game/game_127910.h" @@ -23,335 +23,6 @@ #include "lib/lib_13130.h" #include "types.h" -void func0f0b0420(struct hand *hand, s32 index) -{ - if (!weaponHasFlag(hand->weaponnum, WEAPONFLAG_00100000)) { - g_Vars.currentplayerstats->shotcount[index]++; - } -} - -void func0f0b046c(struct hand *hand, s32 index) -{ - if (index == 0) { - if (!weaponHasFlag(hand->weaponnum, WEAPONFLAG_00100000)) { - var80070590 = 1; - g_Vars.currentplayerstats->shotcount[index]++; - } - } else { - if (var80070590) { - if (!weaponHasFlag(hand->weaponnum, WEAPONFLAG_00100000)) { - g_Vars.currentplayerstats->shotcount[index]++; - } - - var80070590 = 0; - } - } -} - -void func0f0b0520(void) -{ - var80070590 = 0; -} - -s32 currentPlayerGetShotCount(u32 type) -{ - return g_Vars.currentplayerstats->shotcount[type]; -} - -void incrementKillCount(void) -{ - g_Vars.killcount++; -} - -void incrementKnockoutCount(void) -{ - g_Vars.knockoutcount++; -} - -void decrementKnockoutCount(void) -{ - g_Vars.knockoutcount--; -} - -u8 getKnockoutCount(void) -{ - return g_Vars.knockoutcount; -} - -u32 getKillCount(void) -{ - return g_Vars.killcount; -} - -void mpstatsRecordKill(void) -{ - char text[256]; - s32 simulkills; - s32 duration; - s32 time; - - g_Vars.currentplayerstats->killcount++; - g_Vars.currentplayer->killsthislife++; - - if (g_Vars.normmplayerisrunning) { - time = getMissionTime(); - - // Show HUD message - // "Kill count: %d" - sprintf(text, "%s: %d\n", langGet(L_GUN(1)), g_Vars.currentplayerstats->killcount); - hudmsgCreateViaPreset(text, HUDMSGTYPE_DEFAULT); - - // Update slowest/fastest two kills - if (g_Vars.currentplayerstats->killcount > 1) { - duration = time - g_Vars.currentplayer->lastkilltime60; - - if (duration > g_Vars.currentplayerstats->slowest2kills) { - g_Vars.currentplayerstats->slowest2kills = duration; - } - - if (duration < g_Vars.currentplayerstats->fastest2kills) { - g_Vars.currentplayerstats->fastest2kills = duration; - } - } - - // Update max simultaneous kills - simulkills = 1; - - g_Vars.currentplayer->lastkilltime60_4 = g_Vars.currentplayer->lastkilltime60_3; - g_Vars.currentplayer->lastkilltime60_3 = g_Vars.currentplayer->lastkilltime60_2; - g_Vars.currentplayer->lastkilltime60_2 = g_Vars.currentplayer->lastkilltime60; - g_Vars.currentplayer->lastkilltime60 = time; - - if (g_Vars.currentplayer->lastkilltime60_2 != -1 && g_Vars.currentplayer->lastkilltime60 - g_Vars.currentplayer->lastkilltime60_2 < 120) { - simulkills++; - - if (g_Vars.currentplayer->lastkilltime60_3 != -1 && g_Vars.currentplayer->lastkilltime60 - g_Vars.currentplayer->lastkilltime60_3 < 120) { - simulkills++; - - if (g_Vars.currentplayer->lastkilltime60_4 != -1 && g_Vars.currentplayer->lastkilltime60 - g_Vars.currentplayer->lastkilltime60_4 < 120) { - simulkills++; - } - } - } - - if (simulkills > g_Vars.currentplayerstats->maxsimulkills) { - g_Vars.currentplayerstats->maxsimulkills = simulkills; - } - } -} - -s32 currentPlayerGetNumKills(void) -{ - return g_Vars.currentplayerstats->killcount; -} - -void currentPlayerIncrementGgKillCount(void) -{ - g_Vars.currentplayerstats->ggkillcount++; -} - -void currentPlayerIncrementDeathCount(void) -{ - char buffer[256]; - - g_Vars.currentplayer->deathcount++; - - if (g_Vars.normmplayerisrunning) { - if (g_Vars.currentplayer->deathcount == 1) { - sprintf(buffer, langGet(L_GUN(2))); // "Died once" - } else { - sprintf(buffer, "%s %d %s\n", - langGet(L_GUN(3)), // "Died" - g_Vars.currentplayer->deathcount, - langGet(L_GUN(4))); // "times" - } - - hudmsgCreateViaPreset(buffer, HUDMSGTYPE_DEFAULT); - } -} - -void currentPlayerRecordSuicide(void) -{ - char text[256]; - s32 simulkills; - s32 duration; - s32 time; - s32 mpindex; - struct mpchr *mpchr; - - if (g_Vars.normmplayerisrunning) { - time = getMissionTime(); - mpindex = g_Vars.currentplayerstats->mpindex; - - if (mpindex < 4) { - mpchr = &g_MpPlayers[mpindex].base; - } else { - mpchr = &g_MpSimulants[mpindex - 4].base; - } - - // Show HUD message - // "Suicide count: %d" - sprintf(text, "%s: %d\n", langGet(L_GUN(5)), mpchr->killcounts[mpindex]); - hudmsgCreateViaPreset(text, HUDMSGTYPE_DEFAULT); - - // Update slowest/fastest two kills - if (g_Vars.currentplayerstats->killcount > 1) { - duration = time - g_Vars.currentplayer->lastkilltime60; - - if (duration > g_Vars.currentplayerstats->slowest2kills) { - g_Vars.currentplayerstats->slowest2kills = duration; - } - - if (duration < g_Vars.currentplayerstats->fastest2kills) { - g_Vars.currentplayerstats->fastest2kills = duration; - } - } - - // Update max simultaneous kills - simulkills = 1; - - g_Vars.currentplayer->lastkilltime60_4 = g_Vars.currentplayer->lastkilltime60_3; - g_Vars.currentplayer->lastkilltime60_3 = g_Vars.currentplayer->lastkilltime60_2; - g_Vars.currentplayer->lastkilltime60_2 = g_Vars.currentplayer->lastkilltime60; - g_Vars.currentplayer->lastkilltime60 = time; - - if (g_Vars.currentplayer->lastkilltime60_2 != -1 && g_Vars.currentplayer->lastkilltime60 - g_Vars.currentplayer->lastkilltime60_2 < 120) { - simulkills++; - - if (g_Vars.currentplayer->lastkilltime60_3 != -1 && g_Vars.currentplayer->lastkilltime60 - g_Vars.currentplayer->lastkilltime60_3 < 120) { - simulkills++; - - if (g_Vars.currentplayer->lastkilltime60_4 != -1 && g_Vars.currentplayer->lastkilltime60 - g_Vars.currentplayer->lastkilltime60_4 < 120) { - simulkills++; - } - } - } - - if (simulkills > g_Vars.currentplayerstats->maxsimulkills) { - g_Vars.currentplayerstats->maxsimulkills = simulkills; - } - } -} - -void mpstatsRecordDeath(s32 aplayernum, s32 vplayernum) -{ - s32 vmpindex = -1; - struct mpchr *vmpchr = NULL; - s32 ampindex; - struct mpchr *ampchr = NULL; - s32 prevplayernum; - char text[256]; - - if (g_Vars.normmplayerisrunning && g_MpSetup.scenario == MPSCENARIO_POPACAP) { - func0f1847b8(); - } - - // Find attacker and victim mpchrs - if (aplayernum >= 0) { - ampindex = func0f18d074(aplayernum); - - if (ampindex >= 0) { - if (ampindex < 4) { - ampchr = &g_MpPlayers[ampindex].base; - } else { - ampchr = &g_MpSimulants[ampindex - 4].base; - } - } - } - - if (vplayernum >= 0) { - vmpindex = func0f18d074(vplayernum); - - if (vmpindex >= 0) { - if (vmpindex < 4) { - vmpchr = &g_MpPlayers[vmpindex].base; - } else { - vmpchr = &g_MpSimulants[vmpindex - 4].base; - } - } - } - - if (vplayernum >= 0 && aplayernum == vplayernum) { - // Player suicide - if (vmpchr && vmpindex >= 0) { - vmpchr->numdeaths++; - vmpchr->killcounts[vmpindex]++; - } - - if (vplayernum < PLAYERCOUNT()) { - prevplayernum = g_Vars.currentplayernum; - setCurrentPlayerNum(vplayernum); - currentPlayerRecordSuicide(); - setCurrentPlayerNum(prevplayernum); - } - } else { - // Normal kill - if (vplayernum >= 0) { - if (vmpchr) { - vmpchr->numdeaths++; - } - - if (vplayernum < PLAYERCOUNT()) { - // Victim was a player - prevplayernum = g_Vars.currentplayernum; - setCurrentPlayerNum(vplayernum); - - if (g_Vars.normmplayerisrunning && aplayernum >= 0) { - // "Killed by %s" - sprintf(text, "%s %s", langGet(L_MISC(183)), var800ac500[aplayernum]->name); - hudmsgCreateViaPreset(text, HUDMSGTYPE_DEFAULT); - } - - currentPlayerIncrementDeathCount(); - setCurrentPlayerNum(prevplayernum); - } - } - - if (ampchr && vmpindex >= 0) { - ampchr->killcounts[vmpindex]++; - } - - if (aplayernum >= 0 && aplayernum < PLAYERCOUNT()) { - // Attacker was a player - prevplayernum = g_Vars.currentplayernum; - setCurrentPlayerNum(aplayernum); - - if (g_Vars.normmplayerisrunning && vplayernum >= 0) { - // "Killed %s" - sprintf(text, "%s %s", langGet(L_MISC(184)), var800ac500[vplayernum]->name); - hudmsgCreateViaPreset(text, HUDMSGTYPE_DEFAULT); - } - - mpstatsRecordKill(); - setCurrentPlayerNum(prevplayernum); - } - - // If someone killed an aibot - if (g_Vars.normmplayerisrunning - && aplayernum >= 0 - && vplayernum >= PLAYERCOUNT() - && aplayernum != vplayernum) { - g_MpPlayerChrs[vplayernum]->aibot->lastkilledbyplayernum = aplayernum; - } - } - - if (g_Vars.normmplayerisrunning && aplayernum >= 0 && g_MpPlayerChrs[aplayernum]->aibot) { - s32 thing = func0f1982d4(g_MpPlayerChrs[aplayernum]->aibot->weaponnum); - - if (thing >= 0) { - if (aplayernum == vplayernum) { - g_MpPlayerChrs[aplayernum]->aibot->unk244[thing][g_MpPlayerChrs[aplayernum]->aibot->gunfunc]++; - } else { - g_MpPlayerChrs[aplayernum]->aibot->unk214[thing][g_MpPlayerChrs[aplayernum]->aibot->gunfunc]++; - } - } - } - - g_Vars.unk000488++; -} - -const u32 var7f1acdcc[] = {0x00000000}; - struct weapon *weaponFindById(s32 itemid) { if (itemid < 0) { diff --git a/src/game/game_0b63b0.c b/src/game/game_0b63b0.c index 264288f97..50f6d8936 100644 --- a/src/game/game_0b63b0.c +++ b/src/game/game_0b63b0.c @@ -23,7 +23,7 @@ #include "game/game_096ca0.h" #include "game/game_097ba0.h" #include "game/game_0abe70.h" -#include "game/game_0b0420.h" +#include "game/game_0b0fd0.h" #include "game/game_0b2150.h" #include "game/game_0b3350.h" #include "game/game_0b63b0.h" diff --git a/src/game/game_0b69d0.c b/src/game/game_0b69d0.c index f18c471ab..9910b0167 100644 --- a/src/game/game_0b69d0.c +++ b/src/game/game_0b69d0.c @@ -23,7 +23,7 @@ #include "game/game_096ca0.h" #include "game/game_097ba0.h" #include "game/game_0abe70.h" -#include "game/game_0b0420.h" +#include "game/game_0b0fd0.h" #include "game/game_0b2150.h" #include "game/game_0b3350.h" #include "game/game_0b69d0.h" @@ -56,6 +56,7 @@ #include "game/pdoptions.h" #include "game/propobj.h" #include "game/splat.h" +#include "game/mpstats.h" #include "gvars/gvars.h" #include "lib/lib_04320.h" #include "lib/lib_04840.h" diff --git a/src/game/game_0d7070.c b/src/game/game_0d7070.c index 914c738e1..6cfb628a9 100644 --- a/src/game/game_0d7070.c +++ b/src/game/game_0d7070.c @@ -9,7 +9,7 @@ #include "game/data/data_020df0.h" #include "game/data/data_02da90.h" #include "game/game_097ba0.h" -#include "game/game_0b0420.h" +#include "game/game_0b0fd0.h" #include "game/game_0b2150.h" #include "game/game_0b3350.h" #include "game/game_0d4690.h" diff --git a/src/game/game_0dcdb0.c b/src/game/game_0dcdb0.c index 0865fdc93..54a72c0b7 100644 --- a/src/game/game_0dcdb0.c +++ b/src/game/game_0dcdb0.c @@ -9,7 +9,7 @@ #include "game/data/data_020df0.h" #include "game/data/data_02da90.h" #include "game/game_092610.h" -#include "game/game_0b0420.h" +#include "game/game_0b0fd0.h" #include "game/game_0b69d0.h" #include "game/game_0d4690.h" #include "game/game_0dcdb0.h" diff --git a/src/game/game_102240.c b/src/game/game_102240.c index 4da64c8db..db1c707d8 100644 --- a/src/game/game_102240.c +++ b/src/game/game_102240.c @@ -16,7 +16,7 @@ #include "game/game_01bea0.h" #include "game/game_095320.h" #include "game/game_097ba0.h" -#include "game/game_0b0420.h" +#include "game/game_0b0fd0.h" #include "game/game_0b3350.h" #include "game/game_0b69d0.h" #include "game/game_0f09f0.h" diff --git a/src/game/game_190260.c b/src/game/game_190260.c index 6ce3b0546..917a66203 100644 --- a/src/game/game_190260.c +++ b/src/game/game_190260.c @@ -14,7 +14,7 @@ #include "game/game_092610.h" #include "game/game_096750.h" #include "game/game_097ba0.h" -#include "game/game_0b0420.h" +#include "game/game_0b0fd0.h" #include "game/game_0b69d0.h" #include "game/game_127910.h" #include "game/game_157db0.h" diff --git a/src/game/game_197600.c b/src/game/game_197600.c index 460593050..c3a04c302 100644 --- a/src/game/game_197600.c +++ b/src/game/game_197600.c @@ -11,7 +11,7 @@ #include "game/debug.h" #include "game/chr/chr.h" #include "game/ceil.h" -#include "game/game_0b0420.h" +#include "game/game_0b0fd0.h" #include "game/game_127910.h" #include "game/mplayer/setup.h" #include "game/game_190260.h" diff --git a/src/game/game_1999b0.c b/src/game/game_1999b0.c index ee1d17954..f08e25095 100644 --- a/src/game/game_1999b0.c +++ b/src/game/game_1999b0.c @@ -12,7 +12,7 @@ #include "game/chr/chr.h" #include "game/game_092610.h" #include "game/game_097ba0.h" -#include "game/game_0b0420.h" +#include "game/game_0b0fd0.h" #include "game/game_127910.h" #include "game/game_1999b0.h" #include "game/pad.h" diff --git a/src/game/game_1a7560.c b/src/game/game_1a7560.c index 98c52c5a9..103ecb7e7 100644 --- a/src/game/game_1a7560.c +++ b/src/game/game_1a7560.c @@ -11,7 +11,7 @@ #include "game/data/data_02e820.h" #include "game/ceil.h" #include "game/game_097ba0.h" -#include "game/game_0b0420.h" +#include "game/game_0b0fd0.h" #include "game/game_0b3350.h" #include "game/game_0e0770.h" #include "game/game_0f09f0.h" diff --git a/src/game/inventory/inventory.c b/src/game/inventory/inventory.c index 5cbfc4fdf..3ed146d61 100644 --- a/src/game/inventory/inventory.c +++ b/src/game/inventory/inventory.c @@ -9,7 +9,7 @@ #include "game/data/data_020df0.h" #include "game/data/data_02da90.h" #include "game/game_097ba0.h" -#include "game/game_0b0420.h" +#include "game/game_0b0fd0.h" #include "game/inventory/inventory.h" #include "game/training/training.h" #include "game/lang.h" diff --git a/src/game/mplayer/ingame.c b/src/game/mplayer/ingame.c index 5ebddae1f..d2f562b59 100644 --- a/src/game/mplayer/ingame.c +++ b/src/game/mplayer/ingame.c @@ -10,7 +10,7 @@ #include "game/data/data_02da90.h" #include "game/game_005fd0.h" #include "game/title.h" -#include "game/game_0b0420.h" +#include "game/game_0b0fd0.h" #include "game/game_0b3350.h" #include "game/game_0d4690.h" #include "game/game_0f09f0.h" diff --git a/src/game/mplayer/mplayer.c b/src/game/mplayer/mplayer.c index 774cf8985..f496a63f2 100644 --- a/src/game/mplayer/mplayer.c +++ b/src/game/mplayer/mplayer.c @@ -12,7 +12,7 @@ #include "game/title.h" #include "game/game_01b0a0.h" #include "game/game_097ba0.h" -#include "game/game_0b0420.h" +#include "game/game_0b0fd0.h" #include "game/game_0b69d0.h" #include "game/game_0d4690.h" #include "game/game_0f09f0.h" @@ -22,6 +22,7 @@ #include "game/music.h" #include "game/mplayer/setup.h" #include "game/mplayer/scenarios.h" +#include "game/mpstats.h" #include "game/game_19aa80.h" #include "game/lang.h" #include "game/mplayer/mplayer.h" @@ -3167,10 +3168,10 @@ glabel var7f1b8db0 /* f18a6dc: 00002025 */ or $a0,$zero,$zero /* f18a6e0: af001974 */ sw $zero,0x1974($t8) /* f18a6e4: 8c590284 */ lw $t9,0x284($v0) -/* f18a6e8: 0fc2c14b */ jal currentPlayerGetShotCount +/* f18a6e8: 0fc2c14b */ jal mpstatsGetPlayerShotCountByRegion /* f18a6ec: af201978 */ sw $zero,0x1978($t9) /* f18a6f0: ae620000 */ sw $v0,0x0($s3) -/* f18a6f4: 0fc2c14b */ jal currentPlayerGetShotCount +/* f18a6f4: 0fc2c14b */ jal mpstatsGetPlayerShotCountByRegion /* f18a6f8: 24040001 */ addiu $a0,$zero,0x1 /* f18a6fc: ae620004 */ sw $v0,0x4($s3) /* f18a700: ae600008 */ sw $zero,0x8($s3) @@ -3265,22 +3266,22 @@ glabel var7f1b8db0 /* f18a84c: ae6e0034 */ sw $t6,0x34($s3) /* f18a850: e6680028 */ swc1 $f8,0x28($s3) /* f18a854: 46049183 */ div.s $f6,$f18,$f4 -/* f18a858: 0fc2c14b */ jal currentPlayerGetShotCount +/* f18a858: 0fc2c14b */ jal mpstatsGetPlayerShotCountByRegion /* f18a85c: e6660024 */ swc1 $f6,0x24($s3) /* f18a860: 00409025 */ or $s2,$v0,$zero -/* f18a864: 0fc2c14b */ jal currentPlayerGetShotCount +/* f18a864: 0fc2c14b */ jal mpstatsGetPlayerShotCountByRegion /* f18a868: 24040004 */ addiu $a0,$zero,0x4 /* f18a86c: afa20064 */ sw $v0,0x64($sp) -/* f18a870: 0fc2c14b */ jal currentPlayerGetShotCount +/* f18a870: 0fc2c14b */ jal mpstatsGetPlayerShotCountByRegion /* f18a874: 24040003 */ addiu $a0,$zero,0x3 /* f18a878: afa20068 */ sw $v0,0x68($sp) -/* f18a87c: 0fc2c14b */ jal currentPlayerGetShotCount +/* f18a87c: 0fc2c14b */ jal mpstatsGetPlayerShotCountByRegion /* f18a880: 24040002 */ addiu $a0,$zero,0x2 /* f18a884: afa2006c */ sw $v0,0x6c($sp) -/* f18a888: 0fc2c14b */ jal currentPlayerGetShotCount +/* f18a888: 0fc2c14b */ jal mpstatsGetPlayerShotCountByRegion /* f18a88c: 24040001 */ addiu $a0,$zero,0x1 /* f18a890: 00408825 */ or $s1,$v0,$zero -/* f18a894: 0fc2c14b */ jal currentPlayerGetShotCount +/* f18a894: 0fc2c14b */ jal mpstatsGetPlayerShotCountByRegion /* f18a898: 24040006 */ addiu $a0,$zero,0x6 /* f18a89c: 8e630000 */ lw $v1,0x0($s3) /* f18a8a0: 3c013f80 */ lui $at,0x3f80 diff --git a/src/game/mpstats.c b/src/game/mpstats.c new file mode 100644 index 000000000..331b45480 --- /dev/null +++ b/src/game/mpstats.c @@ -0,0 +1,351 @@ +#include +#include "constants.h" +#include "game/cheats.h" +#include "game/data/data_000000.h" +#include "game/data/data_0083d0.h" +#include "game/data/data_00e460.h" +#include "game/data/data_0160b0.h" +#include "game/data/data_01a3a0.h" +#include "game/data/data_020df0.h" +#include "game/data/data_02da90.h" +#include "game/inventory/items.h" +#include "game/game_097ba0.h" +#include "game/game_0b0fd0.h" +#include "game/game_0b69d0.h" +#include "game/game_0dcdb0.h" +#include "game/game_127910.h" +#include "game/mplayer/setup.h" +#include "game/game_197600.h" +#include "game/lang.h" +#include "game/mplayer/mplayer.h" +#include "game/pdoptions.h" +#include "gvars/gvars.h" +#include "lib/lib_13130.h" +#include "types.h" + +void mpstatsIncrementPlayerShotCount(struct hand *hand, s32 region) +{ + if (!weaponHasFlag(hand->weaponnum, WEAPONFLAG_00100000)) { + g_Vars.currentplayerstats->shotcount[region]++; + } +} + +void mpstatsIncrementPlayerShotCount2(struct hand *hand, s32 region) +{ + if (region == 0) { + if (!weaponHasFlag(hand->weaponnum, WEAPONFLAG_00100000)) { + var80070590 = 1; + g_Vars.currentplayerstats->shotcount[region]++; + } + } else { + if (var80070590) { + if (!weaponHasFlag(hand->weaponnum, WEAPONFLAG_00100000)) { + g_Vars.currentplayerstats->shotcount[region]++; + } + + var80070590 = 0; + } + } +} + +void mpstats0f0b0520(void) +{ + var80070590 = 0; +} + +s32 mpstatsGetPlayerShotCountByRegion(u32 type) +{ + return g_Vars.currentplayerstats->shotcount[type]; +} + +void mpstatsIncrementTotalKillCount(void) +{ + g_Vars.killcount++; +} + +void mpstatsIncrementTotalKnockoutCount(void) +{ + g_Vars.knockoutcount++; +} + +void mpstatsDecrementTotalKnockoutCount(void) +{ + g_Vars.knockoutcount--; +} + +u8 mpstatsGetTotalKnockoutCount(void) +{ + return g_Vars.knockoutcount; +} + +u32 mpstatsGetTotalKillCount(void) +{ + return g_Vars.killcount; +} + +void mpstatsRecordPlayerKill(void) +{ + char text[256]; + s32 simulkills; + s32 duration; + s32 time; + + g_Vars.currentplayerstats->killcount++; + g_Vars.currentplayer->killsthislife++; + + if (g_Vars.normmplayerisrunning) { + time = getMissionTime(); + + // Show HUD message + // "Kill count: %d" + sprintf(text, "%s: %d\n", langGet(L_GUN(1)), g_Vars.currentplayerstats->killcount); + hudmsgCreateViaPreset(text, HUDMSGTYPE_DEFAULT); + + // Update slowest/fastest two kills + if (g_Vars.currentplayerstats->killcount > 1) { + duration = time - g_Vars.currentplayer->lastkilltime60; + + if (duration > g_Vars.currentplayerstats->slowest2kills) { + g_Vars.currentplayerstats->slowest2kills = duration; + } + + if (duration < g_Vars.currentplayerstats->fastest2kills) { + g_Vars.currentplayerstats->fastest2kills = duration; + } + } + + // Update max simultaneous kills + simulkills = 1; + + g_Vars.currentplayer->lastkilltime60_4 = g_Vars.currentplayer->lastkilltime60_3; + g_Vars.currentplayer->lastkilltime60_3 = g_Vars.currentplayer->lastkilltime60_2; + g_Vars.currentplayer->lastkilltime60_2 = g_Vars.currentplayer->lastkilltime60; + g_Vars.currentplayer->lastkilltime60 = time; + + if (g_Vars.currentplayer->lastkilltime60_2 != -1 && g_Vars.currentplayer->lastkilltime60 - g_Vars.currentplayer->lastkilltime60_2 < 120) { + simulkills++; + + if (g_Vars.currentplayer->lastkilltime60_3 != -1 && g_Vars.currentplayer->lastkilltime60 - g_Vars.currentplayer->lastkilltime60_3 < 120) { + simulkills++; + + if (g_Vars.currentplayer->lastkilltime60_4 != -1 && g_Vars.currentplayer->lastkilltime60 - g_Vars.currentplayer->lastkilltime60_4 < 120) { + simulkills++; + } + } + } + + if (simulkills > g_Vars.currentplayerstats->maxsimulkills) { + g_Vars.currentplayerstats->maxsimulkills = simulkills; + } + } +} + +s32 mpstatsGetPlayerKillCount(void) +{ + return g_Vars.currentplayerstats->killcount; +} + +void mpstatsIncrementPlayerGgKillCount(void) +{ + g_Vars.currentplayerstats->ggkillcount++; +} + +void mpstatsRecordPlayerDeath(void) +{ + char buffer[256]; + + g_Vars.currentplayer->deathcount++; + + if (g_Vars.normmplayerisrunning) { + if (g_Vars.currentplayer->deathcount == 1) { + sprintf(buffer, langGet(L_GUN(2))); // "Died once" + } else { + sprintf(buffer, "%s %d %s\n", + langGet(L_GUN(3)), // "Died" + g_Vars.currentplayer->deathcount, + langGet(L_GUN(4))); // "times" + } + + hudmsgCreateViaPreset(buffer, HUDMSGTYPE_DEFAULT); + } +} + +void mpstatsRecordPlayerSuicide(void) +{ + char text[256]; + s32 simulkills; + s32 duration; + s32 time; + s32 mpindex; + struct mpchr *mpchr; + + if (g_Vars.normmplayerisrunning) { + time = getMissionTime(); + mpindex = g_Vars.currentplayerstats->mpindex; + + if (mpindex < 4) { + mpchr = &g_MpPlayers[mpindex].base; + } else { + mpchr = &g_MpSimulants[mpindex - 4].base; + } + + // Show HUD message + // "Suicide count: %d" + sprintf(text, "%s: %d\n", langGet(L_GUN(5)), mpchr->killcounts[mpindex]); + hudmsgCreateViaPreset(text, HUDMSGTYPE_DEFAULT); + + // Update slowest/fastest two kills + if (g_Vars.currentplayerstats->killcount > 1) { + duration = time - g_Vars.currentplayer->lastkilltime60; + + if (duration > g_Vars.currentplayerstats->slowest2kills) { + g_Vars.currentplayerstats->slowest2kills = duration; + } + + if (duration < g_Vars.currentplayerstats->fastest2kills) { + g_Vars.currentplayerstats->fastest2kills = duration; + } + } + + // Update max simultaneous kills + simulkills = 1; + + g_Vars.currentplayer->lastkilltime60_4 = g_Vars.currentplayer->lastkilltime60_3; + g_Vars.currentplayer->lastkilltime60_3 = g_Vars.currentplayer->lastkilltime60_2; + g_Vars.currentplayer->lastkilltime60_2 = g_Vars.currentplayer->lastkilltime60; + g_Vars.currentplayer->lastkilltime60 = time; + + if (g_Vars.currentplayer->lastkilltime60_2 != -1 && g_Vars.currentplayer->lastkilltime60 - g_Vars.currentplayer->lastkilltime60_2 < 120) { + simulkills++; + + if (g_Vars.currentplayer->lastkilltime60_3 != -1 && g_Vars.currentplayer->lastkilltime60 - g_Vars.currentplayer->lastkilltime60_3 < 120) { + simulkills++; + + if (g_Vars.currentplayer->lastkilltime60_4 != -1 && g_Vars.currentplayer->lastkilltime60 - g_Vars.currentplayer->lastkilltime60_4 < 120) { + simulkills++; + } + } + } + + if (simulkills > g_Vars.currentplayerstats->maxsimulkills) { + g_Vars.currentplayerstats->maxsimulkills = simulkills; + } + } +} + +void mpstatsRecordDeath(s32 aplayernum, s32 vplayernum) +{ + s32 vmpindex = -1; + struct mpchr *vmpchr = NULL; + s32 ampindex; + struct mpchr *ampchr = NULL; + s32 prevplayernum; + char text[256]; + + if (g_Vars.normmplayerisrunning && g_MpSetup.scenario == MPSCENARIO_POPACAP) { + func0f1847b8(); + } + + // Find attacker and victim mpchrs + if (aplayernum >= 0) { + ampindex = func0f18d074(aplayernum); + + if (ampindex >= 0) { + if (ampindex < 4) { + ampchr = &g_MpPlayers[ampindex].base; + } else { + ampchr = &g_MpSimulants[ampindex - 4].base; + } + } + } + + if (vplayernum >= 0) { + vmpindex = func0f18d074(vplayernum); + + if (vmpindex >= 0) { + if (vmpindex < 4) { + vmpchr = &g_MpPlayers[vmpindex].base; + } else { + vmpchr = &g_MpSimulants[vmpindex - 4].base; + } + } + } + + if (vplayernum >= 0 && aplayernum == vplayernum) { + // Player suicide + if (vmpchr && vmpindex >= 0) { + vmpchr->numdeaths++; + vmpchr->killcounts[vmpindex]++; + } + + if (vplayernum < PLAYERCOUNT()) { + prevplayernum = g_Vars.currentplayernum; + setCurrentPlayerNum(vplayernum); + mpstatsRecordPlayerSuicide(); + setCurrentPlayerNum(prevplayernum); + } + } else { + // Normal kill + if (vplayernum >= 0) { + if (vmpchr) { + vmpchr->numdeaths++; + } + + if (vplayernum < PLAYERCOUNT()) { + // Victim was a player + prevplayernum = g_Vars.currentplayernum; + setCurrentPlayerNum(vplayernum); + + if (g_Vars.normmplayerisrunning && aplayernum >= 0) { + // "Killed by %s" + sprintf(text, "%s %s", langGet(L_MISC(183)), var800ac500[aplayernum]->name); + hudmsgCreateViaPreset(text, HUDMSGTYPE_DEFAULT); + } + + mpstatsRecordPlayerDeath(); + setCurrentPlayerNum(prevplayernum); + } + } + + if (ampchr && vmpindex >= 0) { + ampchr->killcounts[vmpindex]++; + } + + if (aplayernum >= 0 && aplayernum < PLAYERCOUNT()) { + // Attacker was a player + prevplayernum = g_Vars.currentplayernum; + setCurrentPlayerNum(aplayernum); + + if (g_Vars.normmplayerisrunning && vplayernum >= 0) { + // "Killed %s" + sprintf(text, "%s %s", langGet(L_MISC(184)), var800ac500[vplayernum]->name); + hudmsgCreateViaPreset(text, HUDMSGTYPE_DEFAULT); + } + + mpstatsRecordPlayerKill(); + setCurrentPlayerNum(prevplayernum); + } + + // If someone killed an aibot + if (g_Vars.normmplayerisrunning + && aplayernum >= 0 + && vplayernum >= PLAYERCOUNT() + && aplayernum != vplayernum) { + g_MpPlayerChrs[vplayernum]->aibot->lastkilledbyplayernum = aplayernum; + } + } + + if (g_Vars.normmplayerisrunning && aplayernum >= 0 && g_MpPlayerChrs[aplayernum]->aibot) { + s32 thing = func0f1982d4(g_MpPlayerChrs[aplayernum]->aibot->weaponnum); + + if (thing >= 0) { + if (aplayernum == vplayernum) { + g_MpPlayerChrs[aplayernum]->aibot->unk244[thing][g_MpPlayerChrs[aplayernum]->aibot->gunfunc]++; + } else { + g_MpPlayerChrs[aplayernum]->aibot->unk214[thing][g_MpPlayerChrs[aplayernum]->aibot->gunfunc]++; + } + } + } + + g_Vars.unk000488++; +} diff --git a/src/game/propobj.c b/src/game/propobj.c index aace82661..041aa4836 100644 --- a/src/game/propobj.c +++ b/src/game/propobj.c @@ -31,7 +31,7 @@ #include "game/ceil.h" #include "game/game_097ba0.h" #include "game/game_0abe70.h" -#include "game/game_0b0420.h" +#include "game/game_0b0fd0.h" #include "game/game_0b28d0.h" #include "game/game_0b3350.h" #include "game/game_0b69d0.h" @@ -54,6 +54,7 @@ #include "game/core.h" #include "game/mplayer/setup.h" #include "game/mplayer/scenarios.h" +#include "game/mpstats.h" #include "game/game_190260.h" #include "game/game_1999b0.h" #include "game/training/training.h" @@ -17863,7 +17864,7 @@ glabel var7f1aa438 /* f075d40: 0fc4a24b */ jal setCurrentPlayerNum /* f075d44: 00402025 */ or $a0,$v0,$zero /* f075d48: 8fa40070 */ lw $a0,0x70($sp) -/* f075d4c: 0fc2c108 */ jal func0f0b0420 +/* f075d4c: 0fc2c108 */ jal mpstatsIncrementPlayerShotCount /* f075d50: 00002825 */ or $a1,$zero,$zero /* f075d54: 3c058007 */ lui $a1,%hi(var80069930) /* f075d58: 8ca59930 */ lw $a1,%lo(var80069930)($a1) @@ -17880,7 +17881,7 @@ glabel var7f1aa438 /* f075d84: 1040004c */ beqz $v0,.L0f075eb8 /* f075d88: 8fa70070 */ lw $a3,0x70($sp) /* f075d8c: 00e02025 */ or $a0,$a3,$zero -/* f075d90: 0fc2c108 */ jal func0f0b0420 +/* f075d90: 0fc2c108 */ jal mpstatsIncrementPlayerShotCount /* f075d94: 24050006 */ addiu $a1,$zero,0x6 /* f075d98: 10000047 */ b .L0f075eb8 /* f075d9c: 00000000 */ nop @@ -17941,27 +17942,27 @@ glabel var7f1aa438 /* f075e68: 10000011 */ b .L0f075eb0 /* f075e6c: 00e02025 */ or $a0,$a3,$zero .L0f075e70: -/* f075e70: 0fc2c108 */ jal func0f0b0420 +/* f075e70: 0fc2c108 */ jal mpstatsIncrementPlayerShotCount /* f075e74: 00e02025 */ or $a0,$a3,$zero /* f075e78: 1000000f */ b .L0f075eb8 /* f075e7c: 00000000 */ nop .L0f075e80: -/* f075e80: 0fc2c108 */ jal func0f0b0420 +/* f075e80: 0fc2c108 */ jal mpstatsIncrementPlayerShotCount /* f075e84: 24050004 */ addiu $a1,$zero,0x4 /* f075e88: 1000000b */ b .L0f075eb8 /* f075e8c: 00000000 */ nop .L0f075e90: -/* f075e90: 0fc2c108 */ jal func0f0b0420 +/* f075e90: 0fc2c108 */ jal mpstatsIncrementPlayerShotCount /* f075e94: 24050005 */ addiu $a1,$zero,0x5 /* f075e98: 10000007 */ b .L0f075eb8 /* f075e9c: 00000000 */ nop .L0f075ea0: -/* f075ea0: 0fc2c108 */ jal func0f0b0420 +/* f075ea0: 0fc2c108 */ jal mpstatsIncrementPlayerShotCount /* f075ea4: 24050002 */ addiu $a1,$zero,0x2 /* f075ea8: 10000003 */ b .L0f075eb8 /* f075eac: 00000000 */ nop .L0f075eb0: -/* f075eb0: 0fc2c108 */ jal func0f0b0420 +/* f075eb0: 0fc2c108 */ jal mpstatsIncrementPlayerShotCount /* f075eb4: 24050003 */ addiu $a1,$zero,0x3 .L0f075eb8: /* f075eb8: 0fc4a24b */ jal setCurrentPlayerNum @@ -36408,7 +36409,7 @@ glabel func0f085eac /* f086238: 8fa40048 */ lw $a0,0x48($sp) /* f08623c: 53200004 */ beqzl $t9,.L0f086250 /* f086240: 8faf00fc */ lw $t7,0xfc($sp) -/* f086244: 0fc2c11b */ jal func0f0b046c +/* f086244: 0fc2c11b */ jal mpstatsIncrementPlayerShotCount2 /* f086248: 24050006 */ addiu $a1,$zero,0x6 .L0f08624c: /* f08624c: 8faf00fc */ lw $t7,0xfc($sp) diff --git a/src/game/training/menus.c b/src/game/training/menus.c index 84cfc06e9..fdae5d5d3 100644 --- a/src/game/training/menus.c +++ b/src/game/training/menus.c @@ -11,7 +11,7 @@ #include "game/data/data_02e820.h" #include "game/ceil.h" #include "game/game_097ba0.h" -#include "game/game_0b0420.h" +#include "game/game_0b0fd0.h" #include "game/game_0b3350.h" #include "game/game_0e0770.h" #include "game/game_0f09f0.h" diff --git a/src/game/training/training.c b/src/game/training/training.c index 0402fad68..84e379051 100644 --- a/src/game/training/training.c +++ b/src/game/training/training.c @@ -15,7 +15,7 @@ #include "game/game_095320.h" #include "game/game_096750.h" #include "game/game_097ba0.h" -#include "game/game_0b0420.h" +#include "game/game_0b0fd0.h" #include "game/game_0b69d0.h" #include "game/game_0dcdb0.h" #include "game/game_0f09f0.h" diff --git a/src/game/wallhit.c b/src/game/wallhit.c index feed6b7d5..b83f54935 100644 --- a/src/game/wallhit.c +++ b/src/game/wallhit.c @@ -9,7 +9,7 @@ #include "game/data/data_02da90.h" #include "game/dlights.h" #include "game/chr/chr.h" -#include "game/game_0b0420.h" +#include "game/game_0b0fd0.h" #include "game/game_0b3350.h" #include "game/game_127910.h" #include "game/game_1668e0.h" diff --git a/src/include/constants.h b/src/include/constants.h index 7404a5cc5..f1e34f1c3 100644 --- a/src/include/constants.h +++ b/src/include/constants.h @@ -2846,13 +2846,13 @@ #define SCREENSPLIT_HORIZONTAL 0 #define SCREENSPLIT_VERTICAL 1 -#define SHOTCOUNT_TOTAL 0 -#define SHOTCOUNT_HEAD 1 -#define SHOTCOUNT_BODY 2 -#define SHOTCOUNT_LIMB 3 -#define SHOTCOUNT_GUN 4 -#define SHOTCOUNT_5 5 // hat? -#define SHOTCOUNT_OBJECT 6 +#define SHOTREGION_TOTAL 0 +#define SHOTREGION_HEAD 1 +#define SHOTREGION_BODY 2 +#define SHOTREGION_LIMB 3 +#define SHOTREGION_GUN 4 +#define SHOTREGION_5 5 // hat? +#define SHOTREGION_OBJECT 6 #define SIGHT_DEFAULT 0 #define SIGHT_CLASSIC 1 diff --git a/src/include/game/game_0b0420.h b/src/include/game/game_0b0fd0.h similarity index 73% rename from src/include/game/game_0b0420.h rename to src/include/game/game_0b0fd0.h index 9aa978ef6..82d54023a 100644 --- a/src/include/game/game_0b0420.h +++ b/src/include/game/game_0b0fd0.h @@ -1,22 +1,8 @@ -#ifndef IN_GAME_GAME_0B0420_H -#define IN_GAME_GAME_0B0420_H +#ifndef IN_GAME_GAME_0B0FD0_H +#define IN_GAME_GAME_0B0FD0_H #include #include "types.h" -void func0f0b0420(struct hand *hand, s32 index); -void func0f0b046c(struct hand *hand, s32 index); -void func0f0b0520(void); -s32 currentPlayerGetShotCount(u32 type); -void incrementKillCount(void); -void incrementKnockoutCount(void); -void decrementKnockoutCount(void); -u8 getKnockoutCount(void); -u32 getKillCount(void); -void mpstatsRecordKill(void); -s32 currentPlayerGetNumKills(void); -void currentPlayerIncrementDeathCount(void); -void currentPlayerRecordSuicide(void); -void mpstatsRecordDeath(s32 aplayernum, s32 vplayernum); struct weapon *weaponFindById(s32 itemid); struct weaponfunc *weaponGetFunctionById(u32 weaponnum, u32 which); struct weaponfunc *handGetWeaponFunction2(struct hand *hand); diff --git a/src/include/game/mpstats.h b/src/include/game/mpstats.h new file mode 100644 index 000000000..b6f7628db --- /dev/null +++ b/src/include/game/mpstats.h @@ -0,0 +1,21 @@ +#ifndef IN_GAME_MPSTATS_H +#define IN_GAME_MPSTATS_H +#include +#include "types.h" + +void mpstatsIncrementPlayerShotCount(struct hand *hand, s32 region); +void mpstatsIncrementPlayerShotCount2(struct hand *hand, s32 region); +void mpstats0f0b0520(void); +s32 mpstatsGetPlayerShotCountByRegion(u32 type); +void mpstatsIncrementTotalKillCount(void); +void mpstatsIncrementTotalKnockoutCount(void); +void mpstatsDecrementTotalKnockoutCount(void); +u8 mpstatsGetTotalKnockoutCount(void); +u32 mpstatsGetTotalKillCount(void); +void mpstatsRecordPlayerKill(void); +s32 mpstatsGetPlayerKillCount(void); +void mpstatsRecordPlayerDeath(void); +void mpstatsRecordPlayerSuicide(void); +void mpstatsRecordDeath(s32 aplayernum, s32 vplayernum); + +#endif