From f9a24932eda233ae5ec5976679f4f0006251ad7c Mon Sep 17 00:00:00 2001 From: Ryan Dwyer Date: Fri, 8 Jan 2021 14:52:47 +1000 Subject: [PATCH] Decompile handTickAttack --- src/game/bondmove.c | 14 +- src/game/core.c | 16 +- src/game/game_0601b0.c | 378 +++++++++------------------------ src/game/game_097ba0.c | 44 ++-- src/game/game_0b0420.c | 4 +- src/game/inventory/items.c | 14 +- src/include/constants.h | 19 +- src/include/game/core.h | 2 +- src/include/game/game_0601b0.h | 10 +- src/include/game/game_097ba0.h | 18 +- src/include/game/game_0b0420.h | 6 +- src/include/types.h | 4 +- tools/patchpiracysums | 2 +- 13 files changed, 183 insertions(+), 348 deletions(-) diff --git a/src/game/bondmove.c b/src/game/bondmove.c index ace621d8b..9529691ed 100644 --- a/src/game/bondmove.c +++ b/src/game/bondmove.c @@ -2917,18 +2917,18 @@ glabel var7f1ad8e4 /* f0ca944: 8e580324 */ lw $t8,0x324($s2) /* f0ca948: 5300002b */ beqzl $t8,.L0f0ca9f8 /* f0ca94c: 24040002 */ addiu $a0,$zero,0x2 -/* f0ca950: 0fc2883f */ jal func0f0a20fc +/* f0ca950: 0fc2883f */ jal handIsAttackingOnThisTick /* f0ca954: 00002025 */ or $a0,$zero,$zero /* f0ca958: 54400006 */ bnezl $v0,.L0f0ca974 /* f0ca95c: 44805000 */ mtc1 $zero,$f10 -/* f0ca960: 0fc2883f */ jal func0f0a20fc +/* f0ca960: 0fc2883f */ jal handIsAttackingOnThisTick /* f0ca964: 24040001 */ addiu $a0,$zero,0x1 /* f0ca968: 50400023 */ beqzl $v0,.L0f0ca9f8 /* f0ca96c: 24040002 */ addiu $a0,$zero,0x2 /* f0ca970: 44805000 */ mtc1 $zero,$f10 .L0f0ca974: /* f0ca974: 00002025 */ or $a0,$zero,$zero -/* f0ca978: 0fc2883f */ jal func0f0a20fc +/* f0ca978: 0fc2883f */ jal handIsAttackingOnThisTick /* f0ca97c: e7aa00b4 */ swc1 $f10,0xb4($sp) /* f0ca980: 1040000c */ beqz $v0,.L0f0ca9b4 /* f0ca984: 00000000 */ nop @@ -2944,7 +2944,7 @@ glabel var7f1ad8e4 /* f0ca9ac: 00002025 */ or $a0,$zero,$zero /* f0ca9b0: e7a000b4 */ swc1 $f0,0xb4($sp) .L0f0ca9b4: -/* f0ca9b4: 0fc2883f */ jal func0f0a20fc +/* f0ca9b4: 0fc2883f */ jal handIsAttackingOnThisTick /* f0ca9b8: 24040001 */ addiu $a0,$zero,0x1 /* f0ca9bc: 1040000b */ beqz $v0,.L0f0ca9ec /* f0ca9c0: 00000000 */ nop @@ -4871,14 +4871,14 @@ glabel var7f1ad8e4 // // a944 // // I think this is checking which gun is making the loudest noise and is // // alerting nearby chrs to it. -// if (g_Vars.unk000324 && (func0f0a20fc(0) || func0f0a20fc(1))) { +// if (g_Vars.unk000324 && (handIsAttackingOnThisTick(0) || handIsAttackingOnThisTick(1))) { // spb4 = 0; // -// if (func0f0a20fc(0) && func0f09cf58(0) > spb4) { +// if (handIsAttackingOnThisTick(0) && func0f09cf58(0) > spb4) { // spb4 = func0f09cf58(0); // } // -// if (func0f0a20fc(1) && func0f09cf58(1) > spb4) { +// if (handIsAttackingOnThisTick(1) && func0f09cf58(1) > spb4) { // spb4 = func0f09cf58(1); // } // diff --git a/src/game/core.c b/src/game/core.c index 953caca1f..e2ddd5791 100644 --- a/src/game/core.c +++ b/src/game/core.c @@ -216,7 +216,7 @@ void coreUpdateMiscSfx(void) } } else { bool usingboost = g_Vars.speedpillon - && coreGetEffectiveSlowMotion() == SLOWMOTION_OFF + && coreGetSlowMotionType() == SLOWMOTION_OFF && g_Vars.in_cutscene == false; bool usingrocket; @@ -459,7 +459,7 @@ void coreLoadStage(s32 stagenum) #if PIRACYCHECKS { u32 checksum = 0; - s32 *i = (s32 *)&coreGetEffectiveSlowMotion; + s32 *i = (s32 *)&coreGetSlowMotionType; s32 *end = (s32 *)&coreTick; while (i < end) { @@ -1600,14 +1600,14 @@ Gfx *coreRender(Gfx *gdl) scenarioCallback14(NULL); func0f0601b0(); func0f064ce8(); - func0f062b2c(); + handsTickAttack(); // Calculate lookingatprop if (PLAYERCOUNT() == 1 || g_Vars.coopplayernum >= 0 || g_Vars.antiplayernum >= 0 || (weaponHasFlag(handGetWeaponNum(HAND_RIGHT), WEAPONFLAG_AIMTRACK) && currentPlayerIsInSightAimMode())) { - g_Vars.currentplayer->lookingatprop.prop = func0f061d54(0, 0, 0); + g_Vars.currentplayer->lookingatprop.prop = func0f061d54(HAND_RIGHT, 0, 0); if (g_Vars.currentplayer->lookingatprop.prop) { if (g_Vars.currentplayer->lookingatprop.prop->type == PROPTYPE_CHR @@ -1877,7 +1877,7 @@ Gfx *coreRender(Gfx *gdl) || (g_Vars.speedpillwant && !g_Vars.speedpillon) || (!g_Vars.speedpillwant && g_Vars.speedpillon)) { if (g_Vars.speedpillchange == 30 && !g_Vars.speedpillwant) { - audioStart(var80095200, coreGetEffectiveSlowMotion() ? 0x5c9 : 0x2ad, 0, -1, -1, -1, -1, -1); + audioStart(var80095200, coreGetSlowMotionType() ? 0x5c9 : 0x2ad, 0, -1, -1, -1, -1, -1); } if (g_Vars.speedpillchange < 15) { @@ -2258,7 +2258,7 @@ void coreUpdateCutsceneTime(void) } GLOBAL_ASM( -glabel coreGetEffectiveSlowMotion +glabel coreGetSlowMotionType /* f16b854: 27bdffd0 */ addiu $sp,$sp,-48 /* f16b858: afbf0014 */ sw $ra,0x14($sp) /* f16b85c: 3c04b000 */ lui $a0,0xb000 @@ -2339,7 +2339,7 @@ glabel coreGetEffectiveSlowMotion ); // Can't match the antipiracy part -//u32 coreGetEffectiveSlowMotion(void) +//u32 coreGetSlowMotionType(void) //{ //#if PIRACYCHECKS // u32 addr = sub54321(0xb000de8d); @@ -2431,7 +2431,7 @@ void coreTick(void) g_Vars.players[j]->joybutinhibit = 0xefffefff; } } else { - s32 slowmo = coreGetEffectiveSlowMotion(); + s32 slowmo = coreGetSlowMotionType(); g_Vars.lvupdate240 = g_Vars.diffframe240; if (slowmo == SLOWMOTION_ON) { diff --git a/src/game/game_0601b0.c b/src/game/game_0601b0.c index e9e3016e0..f90241612 100644 --- a/src/game/game_0601b0.c +++ b/src/game/game_0601b0.c @@ -2007,7 +2007,7 @@ glabel var7f1a9ebc ); GLOBAL_ASM( -glabel func0f061ed4 +glabel handCreateBulletRaycast .late_rodata glabel var7f1a9ec0 .word 0x4f7ffe00 @@ -2267,7 +2267,7 @@ glabel func0f061fa8 ); GLOBAL_ASM( -glabel func0f062270 +glabel handInflictCloseRangeDamage .late_rodata glabel var7f1a9ec4 .word 0x3e2aaaab @@ -2624,281 +2624,111 @@ glabel var7f1a9ec4 /* f062790: 27bd0138 */ addiu $sp,$sp,0x138 ); -GLOBAL_ASM( -glabel func0f062794 -.late_rodata -glabel var7f1a9ec8 -.word func0f062794+0x144 # f0628d8 -glabel var7f1a9ecc -.word func0f062794+0x2f4 # f062a88 -glabel var7f1a9ed0 -.word func0f062794+0x338 # f062acc -glabel var7f1a9ed4 -.word func0f062794+0x26c # f062a00 -glabel var7f1a9ed8 -.word func0f062794+0x2b0 # f062a44 -glabel var7f1a9edc -.word func0f062794+0x2d4 # f062a68 -glabel var7f1a9ee0 -.word func0f062794+0x2e4 # f062a78 -glabel var7f1a9ee4 -.word func0f062794+0x304 # f062a98 -glabel var7f1a9ee8 -.word func0f062794+0x34c # f062ae0 -glabel var7f1a9eec -.word func0f062794+0x298 # f062a2c -glabel var7f1a9ef0 -.word func0f062794+0x384 # f062b18 -glabel var7f1a9ef4 -.word func0f062794+0x2c4 # f062a58 -.text -/* f062794: 00047100 */ sll $t6,$a0,0x4 -/* f062798: 01c47023 */ subu $t6,$t6,$a0 -/* f06279c: 000e7080 */ sll $t6,$t6,0x2 -/* f0627a0: 01c47021 */ addu $t6,$t6,$a0 -/* f0627a4: 000e70c0 */ sll $t6,$t6,0x3 -/* f0627a8: 3c0f800a */ lui $t7,%hi(g_Vars+0x284) -/* f0627ac: 8defa244 */ lw $t7,%lo(g_Vars+0x284)($t7) -/* f0627b0: 27bdffb8 */ addiu $sp,$sp,-72 -/* f0627b4: 01c47021 */ addu $t6,$t6,$a0 -/* f0627b8: 000e7080 */ sll $t6,$t6,0x2 -/* f0627bc: afbf0024 */ sw $ra,0x24($sp) -/* f0627c0: afb00020 */ sw $s0,0x20($sp) -/* f0627c4: afae002c */ sw $t6,0x2c($sp) -/* f0627c8: 01eec821 */ addu $t9,$t7,$t6 -/* f0627cc: 8f280d0c */ lw $t0,0xd0c($t9) -/* f0627d0: 00808025 */ or $s0,$a0,$zero -/* f0627d4: 24030001 */ addiu $v1,$zero,0x1 -/* f0627d8: 00085680 */ sll $t2,$t0,0x1a -/* f0627dc: 0541001e */ bgez $t2,.L0f062858 -/* f0627e0: 00000000 */ nop -/* f0627e4: 0fc2866a */ jal handGetWeaponNum -/* f0627e8: afa30044 */ sw $v1,0x44($sp) -/* f0627ec: 24010014 */ addiu $at,$zero,0x14 -/* f0627f0: 1441000d */ bne $v0,$at,.L0f062828 -/* f0627f4: 8fa30044 */ lw $v1,0x44($sp) -/* f0627f8: 3c0b800a */ lui $t3,%hi(g_Vars+0x284) -/* f0627fc: 8d6ba244 */ lw $t3,%lo(g_Vars+0x284)($t3) -/* f062800: 8fac002c */ lw $t4,0x2c($sp) -/* f062804: 24010003 */ addiu $at,$zero,0x3 -/* f062808: 016c6821 */ addu $t5,$t3,$t4 -/* f06280c: 8dae0b90 */ lw $t6,0xb90($t5) -/* f062810: 01c1001a */ div $zero,$t6,$at -/* f062814: 00007810 */ mfhi $t7 -/* f062818: 24010001 */ addiu $at,$zero,0x1 -/* f06281c: 11e10002 */ beq $t7,$at,.L0f062828 -/* f062820: 00000000 */ nop -/* f062824: 00001825 */ or $v1,$zero,$zero -.L0f062828: -/* f062828: 10600004 */ beqz $v1,.L0f06283c -/* f06282c: 02002025 */ or $a0,$s0,$zero -/* f062830: 24050001 */ addiu $a1,$zero,0x1 -/* f062834: 0fc18755 */ jal func0f061d54 -/* f062838: 24060002 */ addiu $a2,$zero,0x2 -.L0f06283c: -/* f06283c: 3c18800a */ lui $t8,%hi(g_Vars+0x284) -/* f062840: 8f18a244 */ lw $t8,%lo(g_Vars+0x284)($t8) -/* f062844: 8fb9002c */ lw $t9,0x2c($sp) -/* f062848: 03191821 */ addu $v1,$t8,$t9 -/* f06284c: 90680d0f */ lbu $t0,0xd0f($v1) -/* f062850: 3109ffdf */ andi $t1,$t0,0xffdf -/* f062854: a0690d0f */ sb $t1,0xd0f($v1) -.L0f062858: -/* f062858: 0fc2883f */ jal func0f0a20fc -/* f06285c: 02002025 */ or $a0,$s0,$zero -/* f062860: 504000ae */ beqzl $v0,.L0f062b1c -/* f062864: 8fbf0024 */ lw $ra,0x24($sp) -/* f062868: 0fc2884b */ jal func0f0a212c -/* f06286c: 02002025 */ or $a0,$s0,$zero -/* f062870: afa20040 */ sw $v0,0x40($sp) -/* f062874: 0fc2866a */ jal handGetWeaponNum -/* f062878: 02002025 */ or $a0,$s0,$zero -/* f06287c: 3c0a800a */ lui $t2,%hi(g_Vars+0x284) -/* f062880: 8d4aa244 */ lw $t2,%lo(g_Vars+0x284)($t2) -/* f062884: 8fab002c */ lw $t3,0x2c($sp) -/* f062888: afa2003c */ sw $v0,0x3c($sp) -/* f06288c: 02002025 */ or $a0,$s0,$zero -/* f062890: 014b1821 */ addu $v1,$t2,$t3 -/* f062894: 906c0d0f */ lbu $t4,0xd0f($v1) -/* f062898: 27a50038 */ addiu $a1,$sp,0x38 -/* f06289c: 318dffef */ andi $t5,$t4,0xffef -/* f0628a0: 0fc2c6bc */ jal func0f0b1af0 -/* f0628a4: a06d0d0f */ sb $t5,0xd0f($v1) -/* f0628a8: 0fc683f2 */ jal frIncrementNumShots -/* f0628ac: 00000000 */ nop -/* f0628b0: 8fae0040 */ lw $t6,0x40($sp) -/* f0628b4: 25cfffff */ addiu $t7,$t6,-1 -/* f0628b8: 2de1000c */ sltiu $at,$t7,0xc -/* f0628bc: 10200096 */ beqz $at,.L0f062b18 -/* f0628c0: 000f7880 */ sll $t7,$t7,0x2 -/* f0628c4: 3c017f1b */ lui $at,%hi(var7f1a9ec8) -/* f0628c8: 002f0821 */ addu $at,$at,$t7 -/* f0628cc: 8c2f9ec8 */ lw $t7,%lo(var7f1a9ec8)($at) -/* f0628d0: 01e00008 */ jr $t7 -/* f0628d4: 00000000 */ nop -/* f0628d8: 12000004 */ beqz $s0,.L0f0628ec -/* f0628dc: 00000000 */ nop -/* f0628e0: 0fc2883f */ jal func0f0a20fc -/* f0628e4: 00002025 */ or $a0,$zero,$zero -/* f0628e8: 1440008b */ bnez $v0,.L0f062b18 -.L0f0628ec: -/* f0628ec: 3c18800a */ lui $t8,%hi(g_Vars+0x284) -/* f0628f0: 8f18a244 */ lw $t8,%lo(g_Vars+0x284)($t8) -/* f0628f4: 8f1900bc */ lw $t9,0xbc($t8) -/* f0628f8: 0fc0897d */ jal chrUncloakTemporarily -/* f0628fc: 8f240004 */ lw $a0,0x4($t9) -/* f062900: 27a40038 */ addiu $a0,$sp,0x38 -/* f062904: 0fc2c11b */ jal func0f0b046c -/* f062908: 00002825 */ or $a1,$zero,$zero -/* f06290c: 8fa8003c */ lw $t0,0x3c($sp) -/* f062910: 24010013 */ addiu $at,$zero,0x13 -/* f062914: 02002025 */ or $a0,$s0,$zero -/* f062918: 1501002b */ bne $t0,$at,.L0f0629c8 -/* f06291c: 24050001 */ addiu $a1,$zero,0x1 -/* f062920: 24090001 */ addiu $t1,$zero,0x1 -/* f062924: afa90010 */ sw $t1,0x10($sp) -/* f062928: 24060001 */ addiu $a2,$zero,0x1 -/* f06292c: 0fc187b5 */ jal func0f061ed4 -/* f062930: 24070001 */ addiu $a3,$zero,0x1 -/* f062934: 240a0001 */ addiu $t2,$zero,0x1 -/* f062938: afaa0010 */ sw $t2,0x10($sp) -/* f06293c: 02002025 */ or $a0,$s0,$zero -/* f062940: 24050001 */ addiu $a1,$zero,0x1 -/* f062944: 24060001 */ addiu $a2,$zero,0x1 -/* f062948: 0fc187b5 */ jal func0f061ed4 -/* f06294c: 24070001 */ addiu $a3,$zero,0x1 -/* f062950: 240b0001 */ addiu $t3,$zero,0x1 -/* f062954: afab0010 */ sw $t3,0x10($sp) -/* f062958: 02002025 */ or $a0,$s0,$zero -/* f06295c: 24050001 */ addiu $a1,$zero,0x1 -/* f062960: 24060001 */ addiu $a2,$zero,0x1 -/* f062964: 0fc187b5 */ jal func0f061ed4 -/* f062968: 24070001 */ addiu $a3,$zero,0x1 -/* f06296c: 240c0001 */ addiu $t4,$zero,0x1 -/* f062970: afac0010 */ sw $t4,0x10($sp) -/* f062974: 02002025 */ or $a0,$s0,$zero -/* f062978: 24050001 */ addiu $a1,$zero,0x1 -/* f06297c: 24060001 */ addiu $a2,$zero,0x1 -/* f062980: 0fc187b5 */ jal func0f061ed4 -/* f062984: 24070001 */ addiu $a3,$zero,0x1 -/* f062988: 240d0001 */ addiu $t5,$zero,0x1 -/* f06298c: afad0010 */ sw $t5,0x10($sp) -/* f062990: 02002025 */ or $a0,$s0,$zero -/* f062994: 24050001 */ addiu $a1,$zero,0x1 -/* f062998: 24060001 */ addiu $a2,$zero,0x1 -/* f06299c: 0fc187b5 */ jal func0f061ed4 -/* f0629a0: 24070001 */ addiu $a3,$zero,0x1 -/* f0629a4: 240e0001 */ addiu $t6,$zero,0x1 -/* f0629a8: afae0010 */ sw $t6,0x10($sp) -/* f0629ac: 02002025 */ or $a0,$s0,$zero -/* f0629b0: 24050001 */ addiu $a1,$zero,0x1 -/* f0629b4: 24060001 */ addiu $a2,$zero,0x1 -/* f0629b8: 0fc187b5 */ jal func0f061ed4 -/* f0629bc: 24070001 */ addiu $a3,$zero,0x1 -/* f0629c0: 1000000b */ b .L0f0629f0 -/* f0629c4: 00000000 */ nop -.L0f0629c8: -/* f0629c8: 0fc284c6 */ jal func0f0a1318 -/* f0629cc: 02002025 */ or $a0,$s0,$zero -/* f0629d0: 3c0f800a */ lui $t7,%hi(g_Vars+0x314) -/* f0629d4: 8defa2d4 */ lw $t7,%lo(g_Vars+0x314)($t7) -/* f0629d8: 02002025 */ or $a0,$s0,$zero -/* f0629dc: 24050001 */ addiu $a1,$zero,0x1 -/* f0629e0: 24060001 */ addiu $a2,$zero,0x1 -/* f0629e4: 00403825 */ or $a3,$v0,$zero -/* f0629e8: 0fc187b5 */ jal func0f061ed4 -/* f0629ec: afaf0010 */ sw $t7,0x10($sp) -.L0f0629f0: -/* f0629f0: 0fc2c148 */ jal func0f0b0520 -/* f0629f4: 00000000 */ nop -/* f0629f8: 10000048 */ b .L0f062b1c -/* f0629fc: 8fbf0024 */ lw $ra,0x24($sp) -/* f062a00: 3c18800a */ lui $t8,%hi(g_Vars+0x284) -/* f062a04: 8f18a244 */ lw $t8,%lo(g_Vars+0x284)($t8) -/* f062a08: 8f1900bc */ lw $t9,0xbc($t8) -/* f062a0c: 0fc0897d */ jal chrUncloakTemporarily -/* f062a10: 8f240004 */ lw $a0,0x4($t9) -/* f062a14: 02002025 */ or $a0,$s0,$zero -/* f062a18: 27a50038 */ addiu $a1,$sp,0x38 -/* f062a1c: 0fc1889c */ jal func0f062270 -/* f062a20: 00003025 */ or $a2,$zero,$zero -/* f062a24: 1000003d */ b .L0f062b1c -/* f062a28: 8fbf0024 */ lw $ra,0x24($sp) -/* f062a2c: 02002025 */ or $a0,$s0,$zero -/* f062a30: 27a50038 */ addiu $a1,$sp,0x38 -/* f062a34: 0fc1889c */ jal func0f062270 -/* f062a38: 24060001 */ addiu $a2,$zero,0x1 -/* f062a3c: 10000037 */ b .L0f062b1c -/* f062a40: 8fbf0024 */ lw $ra,0x24($sp) -/* f062a44: 3c04800a */ lui $a0,%hi(g_Vars+0x28c) -/* f062a48: 0fc22a7d */ jal playerActivateRemoteMineDetonator -/* f062a4c: 8c84a24c */ lw $a0,%lo(g_Vars+0x28c)($a0) -/* f062a50: 10000032 */ b .L0f062b1c -/* f062a54: 8fbf0024 */ lw $ra,0x24($sp) -/* f062a58: 0fc18b74 */ jal func0f062dd0 -/* f062a5c: 00000000 */ nop -/* f062a60: 1000002e */ b .L0f062b1c -/* f062a64: 8fbf0024 */ lw $ra,0x24($sp) -/* f062a68: 0fc2aeea */ jal func0f0abba8 -/* f062a6c: 00000000 */ nop -/* f062a70: 1000002a */ b .L0f062b1c -/* f062a74: 8fbf0024 */ lw $ra,0x24($sp) -/* f062a78: 0fc2aefa */ jal func0f0abbe8 -/* f062a7c: 00000000 */ nop -/* f062a80: 10000026 */ b .L0f062b1c -/* f062a84: 8fbf0024 */ lw $ra,0x24($sp) -/* f062a88: 0fc27ea1 */ jal func0f09fa84 -/* f062a8c: 02002025 */ or $a0,$s0,$zero -/* f062a90: 10000022 */ b .L0f062b1c -/* f062a94: 8fbf0024 */ lw $ra,0x24($sp) -/* f062a98: 3c08800a */ lui $t0,%hi(g_Vars+0x284) -/* f062a9c: 8d08a244 */ lw $t0,%lo(g_Vars+0x284)($t0) -/* f062aa0: 8d0900ac */ lw $t1,0xac($t0) -/* f062aa4: 15200005 */ bnez $t1,.L0f062abc -/* f062aa8: 00000000 */ nop -/* f062aac: 0fc30ebd */ jal currentPlayerAdjustCrouchPos -/* f062ab0: 24040002 */ addiu $a0,$zero,0x2 -/* f062ab4: 10000019 */ b .L0f062b1c -/* f062ab8: 8fbf0024 */ lw $ra,0x24($sp) -.L0f062abc: -/* f062abc: 0fc30ebd */ jal currentPlayerAdjustCrouchPos -/* f062ac0: 2404fffe */ addiu $a0,$zero,-2 -/* f062ac4: 10000015 */ b .L0f062b1c -/* f062ac8: 8fbf0024 */ lw $ra,0x24($sp) -/* f062acc: 02002025 */ or $a0,$s0,$zero -/* f062ad0: 0fc27c40 */ jal func0f09f100 -/* f062ad4: 27a50038 */ addiu $a1,$sp,0x38 -/* f062ad8: 10000010 */ b .L0f062b1c -/* f062adc: 8fbf0024 */ lw $ra,0x24($sp) -/* f062ae0: 3c02800a */ lui $v0,%hi(g_Vars+0x284) -/* f062ae4: 8c42a244 */ lw $v0,%lo(g_Vars+0x284)($v0) -/* f062ae8: 2401ffbf */ addiu $at,$zero,-65 -/* f062aec: 8c4400c4 */ lw $a0,0xc4($v0) -/* f062af0: 30830080 */ andi $v1,$a0,0x80 -/* f062af4: 0003502b */ sltu $t2,$zero,$v1 -/* f062af8: 11400005 */ beqz $t2,.L0f062b10 -/* f062afc: 00816024 */ and $t4,$a0,$at -/* f062b00: 2401ff7f */ addiu $at,$zero,-129 -/* f062b04: 00815824 */ and $t3,$a0,$at -/* f062b08: 10000003 */ b .L0f062b18 -/* f062b0c: ac4b00c4 */ sw $t3,0xc4($v0) -.L0f062b10: -/* f062b10: 358d0080 */ ori $t5,$t4,0x80 -/* f062b14: ac4d00c4 */ sw $t5,0xc4($v0) -.L0f062b18: -/* f062b18: 8fbf0024 */ lw $ra,0x24($sp) -.L0f062b1c: -/* f062b1c: 8fb00020 */ lw $s0,0x20($sp) -/* f062b20: 27bd0048 */ addiu $sp,$sp,0x48 -/* f062b24: 03e00008 */ jr $ra -/* f062b28: 00000000 */ nop -); +void handTickAttack(s32 handnum) +{ + if (g_Vars.currentplayer->hands[handnum].unk0d0f_02) { + s32 doit = true; -void func0f062b2c(void) + if (handGetWeaponNum(handnum) == WEAPON_REAPER + && (g_Vars.currentplayer->hands[handnum].unk0b90 % 3) != 1) { + doit = false; + } + + if (doit) { + func0f061d54(handnum, 1, 2); + } + + g_Vars.currentplayer->hands[handnum].unk0d0f_02 = false; + } + + if (handIsAttackingOnThisTick(handnum)) { + s32 type = handGetAttackType(handnum); + s32 weaponnum = handGetWeaponNum(handnum); + u8 stack1; + u8 stack2; + u8 stack3; + u8 tmpweaponnum; + bool cloaked; + + g_Vars.currentplayer->hands[handnum].unk0d0f_03 = false; + + func0f0b1af0(handnum, &tmpweaponnum); + frIncrementNumShots(); + + switch (type) { + case HANDATTACKTYPE_SHOOT: + // Always execute if right hand, but if left hand then execute if + // 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(&tmpweaponnum, 0); + + if (weaponnum == WEAPON_SHOTGUN) { + handCreateBulletRaycast(handnum, true, true, true, true); + handCreateBulletRaycast(handnum, true, true, true, true); + handCreateBulletRaycast(handnum, true, true, true, true); + handCreateBulletRaycast(handnum, true, true, true, true); + handCreateBulletRaycast(handnum, true, true, true, true); + handCreateBulletRaycast(handnum, true, true, true, true); + } else { + handCreateBulletRaycast(handnum, true, true, func0f0a1318(handnum), g_Vars.mplayerisrunning); + } + + func0f0b0520(); + } + break; + case HANDATTACKTYPE_CLOSERANGE: + chrUncloakTemporarily(g_Vars.currentplayer->prop->chr); + handInflictCloseRangeDamage(handnum, &tmpweaponnum, false); + break; + case HANDATTACKTYPE_CLOSERANGENOUNCLOAK: + handInflictCloseRangeDamage(handnum, &tmpweaponnum, true); + break; + case HANDATTACKTYPE_DETONATE: + playerActivateRemoteMineDetonator(g_Vars.currentplayernum); + break; + case HANDATTACKTYPE_UPLINK: + func0f062dd0(); + break; + case HANDATTACKTYPE_BOOST: + cboostBoost(); + break; + case HANDATTACKTYPE_REVERTBOOST: + cboostRevert(); + break; + case HANDATTACKTYPE_SHOOTPROJECTILE: + handCreateFiredProjectile(handnum); + break; + case HANDATTACKTYPE_CROUCH: + if (g_Vars.currentplayer->crouchpos == CROUCH_SQUAT) { + currentPlayerAdjustCrouchPos(2); + } else { + currentPlayerAdjustCrouchPos(-2); + } + break; + case HANDATTACKTYPE_THROWPROJECTILE: + handCreateThrownProjectile(handnum, &tmpweaponnum); + break; + case HANDATTACKTYPE_RCP120CLOAK: + cloaked = (g_Vars.currentplayer->devicesactive & DEVICE_CLOAKRCP120) != 0; + + if (cloaked) { + g_Vars.currentplayer->devicesactive &= ~DEVICE_CLOAKRCP120; + } else { + g_Vars.currentplayer->devicesactive = + (g_Vars.currentplayer->devicesactive & ~DEVICE_CLOAKDEVICE) + | DEVICE_CLOAKRCP120; + } + break; + } + } +} + +void handsTickAttack(void) { if (g_Vars.lvupdate240 > 0) { - func0f062794(false); - func0f062794(true); + handTickAttack(HAND_RIGHT); + handTickAttack(HAND_LEFT); } } diff --git a/src/game/game_097ba0.c b/src/game/game_097ba0.c index 233f41956..16de094dc 100644 --- a/src/game/game_097ba0.c +++ b/src/game/game_097ba0.c @@ -1786,9 +1786,9 @@ bool func0f0990b0(struct weaponfunc *basefunc, struct weapon *weapon) if ((basefunc->type & 0xff) == INVENTORYFUNCTYPE_SPECIAL) { struct weaponfunc_special *func = (struct weaponfunc_special *)basefunc; - if (func->specialfunc != SPECIALFUNC_REMOTEMINE_DETONATE - && func->specialfunc != SPECIALFUNC_COMBATBOOST_BOOST - && func->specialfunc != SPECIALFUNC_COMBATBOOST_REVERT) { + if (func->specialfunc != HANDATTACKTYPE_DETONATE + && func->specialfunc != HANDATTACKTYPE_BOOST + && func->specialfunc != HANDATTACKTYPE_REVERTBOOST) { return true; } } @@ -6823,7 +6823,7 @@ glabel func0f09cf88 /* f09cfc0: 27a40050 */ addiu $a0,$sp,0x50 /* f09cfc4: 0fc2c807 */ jal func0f0b201c /* f09cfc8: 27a50028 */ addiu $a1,$sp,0x28 -/* f09cfcc: 0fc2883f */ jal func0f0a20fc +/* f09cfcc: 0fc2883f */ jal handIsAttackingOnThisTick /* f09cfd0: 00002025 */ or $a0,$zero,$zero /* f09cfd4: 1040000c */ beqz $v0,.L0f09d008 /* f09cfd8: 3c014270 */ lui $at,0x4270 @@ -6871,7 +6871,7 @@ glabel func0f09cf88 /* f09d074: 00000000 */ nop /* f09d078: e6060840 */ swc1 $f6,0x840($s0) .L0f09d07c: -/* f09d07c: 0fc2883f */ jal func0f0a20fc +/* f09d07c: 0fc2883f */ jal handIsAttackingOnThisTick /* f09d080: 24040001 */ addiu $a0,$zero,0x1 /* f09d084: 3c014270 */ lui $at,0x4270 /* f09d088: 44818000 */ mtc1 $at,$f16 @@ -9321,7 +9321,7 @@ glabel var7f1ac704 ); GLOBAL_ASM( -glabel func0f09f100 +glabel handCreateThrownProjectile .late_rodata glabel var7f1ac708 .word 0x4096c5bf @@ -9997,7 +9997,7 @@ glabel func0f09fa20 ); GLOBAL_ASM( -glabel func0f09fa84 +glabel handCreateFiredProjectile .late_rodata glabel var7f1ac730 .word 0x3fd55555 @@ -12583,14 +12583,14 @@ void currentPlayerEquipWeaponWrapper(bool arg0, s32 weaponnum) } } -s32 func0f0a20fc(s32 handnum) +s32 handIsAttackingOnThisTick(s32 handnum) { return g_Vars.currentplayer->hands[handnum].unk063c; } -s32 func0f0a212c(s32 handnum) +s32 handGetAttackType(s32 handnum) { - return g_Vars.currentplayer->hands[handnum].unk0ce4; + return g_Vars.currentplayer->hands[handnum].attacktype; } char *weaponGetName(s32 weaponnum) @@ -13237,7 +13237,7 @@ void currentPlayerLoseGunInNbombStorm(struct prop *prop) && player->hands[i].unk0c3c == 4 && player->hands[i].unk0c40 == 0) { drop = false; - func0f09f100(i + 2, &player->hands[i]); + handCreateThrownProjectile(i + 2, &player->hands[i].weaponnum); } } } @@ -23275,7 +23275,7 @@ glabel hudRenderAmmo /* f0abacc: 00000000 */ nop ); -void speedpillAddBoost(s32 amount) +void cboostAdd(s32 amount) { g_Vars.speedpilltime += amount; @@ -23284,7 +23284,7 @@ void speedpillAddBoost(s32 amount) } if (!g_Vars.speedpillwant) { - u32 sound = coreGetEffectiveSlowMotion() ? 0x2ad : 0x5c9; + u32 sound = coreGetSlowMotionType() ? 0x2ad : 0x5c9; audioStart(var80095200, sound, 0, -1, -1, -1, -1, -1); } @@ -23292,7 +23292,7 @@ void speedpillAddBoost(s32 amount) g_Vars.speedpillwant = true; } -void speedpillRevert(s32 amount) +void cboostSubtract(s32 amount) { g_Vars.speedpilltime -= amount; @@ -23302,21 +23302,21 @@ void speedpillRevert(s32 amount) } } -void func0f0abba8(void) +void cboostBoost(void) { - if (coreGetEffectiveSlowMotion()) { - speedpillRevert(SECSTOTIME60(20)); + if (coreGetSlowMotionType() != SLOWMOTION_OFF) { + cboostSubtract(SECSTOTIME60(20)); } else { - speedpillAddBoost(SECSTOTIME60(10)); + cboostAdd(SECSTOTIME60(10)); } } -void func0f0abbe8(void) +void cboostRevert(void) { - if (coreGetEffectiveSlowMotion()) { - speedpillAddBoost(SECSTOTIME60(20)); + if (coreGetSlowMotionType() != SLOWMOTION_OFF) { + cboostAdd(SECSTOTIME60(20)); } else { - speedpillRevert(SECSTOTIME60(10)); + cboostSubtract(SECSTOTIME60(10)); } } diff --git a/src/game/game_0b0420.c b/src/game/game_0b0420.c index 1fc32271f..bbe2e58b5 100644 --- a/src/game/game_0b0420.c +++ b/src/game/game_0b0420.c @@ -1415,12 +1415,12 @@ glabel func0f0b1d28 /* f0b1de4: 00000000 */ nop /* f0b1de8: 24040001 */ addiu $a0,$zero,0x1 .L0f0b1dec: -/* f0b1dec: 0fc2883f */ jal func0f0a20fc +/* f0b1dec: 0fc2883f */ jal handIsAttackingOnThisTick /* f0b1df0: e7a20018 */ swc1 $f2,0x18($sp) /* f0b1df4: 10400007 */ beqz $v0,.L0f0b1e14 /* f0b1df8: c7a20018 */ lwc1 $f2,0x18($sp) /* f0b1dfc: 00002025 */ or $a0,$zero,$zero -/* f0b1e00: 0fc2883f */ jal func0f0a20fc +/* f0b1e00: 0fc2883f */ jal handIsAttackingOnThisTick /* f0b1e04: e7a20018 */ swc1 $f2,0x18($sp) /* f0b1e08: 10400002 */ beqz $v0,.L0f0b1e14 /* f0b1e0c: c7a20018 */ lwc1 $f2,0x18($sp) diff --git a/src/game/inventory/items.c b/src/game/inventory/items.c index af8551a58..22fad56a6 100644 --- a/src/game/inventory/items.c +++ b/src/game/inventory/items.c @@ -1557,7 +1557,7 @@ struct weaponfunc_special invfunc_rcp120_cloak = { &invmenupos_00010fd0, // menupos NULL, // fire animation 0x00102000, // flags - SPECIALFUNC_RCP120_CLOAK, + HANDATTACKTYPE_RCP120CLOAK, 0x0000001e, 0x00000000, }; @@ -3082,7 +3082,7 @@ struct weaponfunc_special invfunc_remotemine_detonate = { &invmenupos_00010fd0, // menupos NULL, // fire animation 0x00102000, // flags - SPECIALFUNC_REMOTEMINE_DETONATE, + HANDATTACKTYPE_DETONATE, 0x0000001e, 0x00000000, }; @@ -3902,7 +3902,7 @@ struct weaponfunc_special invfunc_sniperrifle_crouch = { &invmenupos_00010fd0, // menupos NULL, // fire animation 0x00102000, // flags - SPECIALFUNC_SNIPERRIFLE_CROUCH, + HANDATTACKTYPE_CROUCH, 0x0000001e, 0x00000000, }; @@ -5044,7 +5044,7 @@ struct weaponfunc_special invfunc_combatboost_boost = { &invmenupos_00010fd0, // menupos NULL, // fire animation 0x00002000, // flags - SPECIALFUNC_COMBATBOOST_BOOST, + HANDATTACKTYPE_BOOST, 0x0000001e, 0x05c90000, }; @@ -5057,7 +5057,7 @@ struct weaponfunc_special invfunc_combatboost_revert = { &invmenupos_00010fd0, // menupos NULL, // fire animation 0x00002000, // flags - SPECIALFUNC_COMBATBOOST_REVERT, + HANDATTACKTYPE_REVERTBOOST, 0x0000001e, 0x05c90000, }; @@ -5358,7 +5358,7 @@ struct weaponfunc_special invfunc_datauplink_primary = { &invmenupos_00010fd0, // menupos NULL, // fire animation 0x00102000, // flags - SPECIALFUNC_DATAUPLINK_UPLINK, + HANDATTACKTYPE_UPLINK, 0x0000001e, 0x00000000, }; @@ -5524,7 +5524,7 @@ struct weaponfunc_special invfunc_unused_8006f9a4 = { &invmenupos_00010fd0, // menupos NULL, // fire animation 0x00102000, // flags - SPECIALFUNC_DATAUPLINK_UPLINK, + HANDATTACKTYPE_UPLINK, 0x0000001e, 0x00000000, }; diff --git a/src/include/constants.h b/src/include/constants.h index d9d3ba596..04022e6b5 100644 --- a/src/include/constants.h +++ b/src/include/constants.h @@ -818,6 +818,18 @@ #define HAND_RIGHT 0 #define HAND_LEFT 1 +#define HANDATTACKTYPE_SHOOT 1 +#define HANDATTACKTYPE_SHOOTPROJECTILE 2 +#define HANDATTACKTYPE_THROWPROJECTILE 3 +#define HANDATTACKTYPE_CLOSERANGE 4 +#define HANDATTACKTYPE_DETONATE 5 +#define HANDATTACKTYPE_BOOST 6 +#define HANDATTACKTYPE_REVERTBOOST 7 +#define HANDATTACKTYPE_CROUCH 8 +#define HANDATTACKTYPE_RCP120CLOAK 9 +#define HANDATTACKTYPE_CLOSERANGENOUNCLOAK 10 +#define HANDATTACKTYPE_UPLINK 12 + #define HANGARBIO_INSTITUTE 0 #define HANGARBIO_DDTOWER 1 #define HANGARBIO_LABBASEMENT 2 @@ -2881,13 +2893,6 @@ #define SPECIALDIE_OVERRAILING 5 #define SPECIALDIE_ONCHAIR 6 -#define SPECIALFUNC_REMOTEMINE_DETONATE 5 -#define SPECIALFUNC_COMBATBOOST_BOOST 6 -#define SPECIALFUNC_COMBATBOOST_REVERT 7 -#define SPECIALFUNC_SNIPERRIFLE_CROUCH 8 -#define SPECIALFUNC_RCP120_CLOAK 9 -#define SPECIALFUNC_DATAUPLINK_UPLINK 12 - #define SPEED_WALK 0 #define SPEED_JOG 1 #define SPEED_RUN 2 diff --git a/src/include/game/core.h b/src/include/game/core.h index b4a570950..ba7e05515 100644 --- a/src/include/game/core.h +++ b/src/include/game/core.h @@ -20,7 +20,7 @@ Gfx *coreRender(Gfx *gdl); void coreUpdateSoloHandicaps(void); s32 sub54321(s32 value); void coreUpdateCutsceneTime(void); -s32 coreGetEffectiveSlowMotion(void); +s32 coreGetSlowMotionType(void); void coreTick(void); void coreRecordDistanceMoved(void); void coreCheckPauseStateChanged(void); diff --git a/src/include/game/game_0601b0.h b/src/include/game/game_0601b0.h index 30fdc34de..6199e41f7 100644 --- a/src/include/game/game_0601b0.h +++ b/src/include/game/game_0601b0.h @@ -20,12 +20,12 @@ Gfx *propsRender(Gfx *gdl, s16 arg1, s32 arg2, s16 *arg3); u32 func0f060984(void); u32 func0f060bac(void); u32 func0f060db8(void); -struct prop *func0f061d54(u32 arg0, u32 arg1, u32 arg2); -u32 func0f061ed4(void); +struct prop *func0f061d54(s32 handnum, u32 arg1, u32 arg2); +void handCreateBulletRaycast(s32 handnum, bool arg1, bool arg2, bool arg3, bool arg4); u32 func0f061fa8(void); -u32 func0f062270(void); -void func0f062794(bool arg0); -void func0f062b2c(void); +void handInflictCloseRangeDamage(s32 handnum, u8 *weaponnum, bool arg2); +void handTickAttack(s32 handnum); +void handsTickAttack(void); void func0f062b64(struct prop *prop, s32 arg1); struct prop *currentPlayerFindPropForInteract(bool eyespy); void func0f062dd0(void); diff --git a/src/include/game/game_097ba0.h b/src/include/game/game_097ba0.h index cae73b45d..49e7da7b2 100644 --- a/src/include/game/game_097ba0.h +++ b/src/include/game/game_097ba0.h @@ -71,11 +71,11 @@ u32 func0f09ebbc(void); void func0f09ebcc(struct defaultobj *obj, struct coord *coord, s16 *rooms, Mtxf *matrix1, f32 *arg4, Mtxf *matrix2, struct prop *prop, struct coord *pos); u32 func0f09ed2c(void); void func0f09ee18(struct chrdata *chr, u8 *arg1, struct coord *pos, s16 *rooms, Mtxf *arg4, struct coord *arg5); -void func0f09f100(u32 arg0, struct hand *hand); +void handCreateThrownProjectile(s32 handnum, u8 *weaponnum); u32 func0f09f848(void); u32 func0f09f974(void); u32 func0f09fa20(void); -u32 func0f09fa84(void); +void handCreateFiredProjectile(s32 handnum); void func0f0a0394(f32 autoaimx, f32 autoaimy, f32 damp, f32 arg3); void currentPlayerSwivelGunTowards(f32 screenx, f32 screeny, f32 damp); void func0f0a0b98(f32 arg0, f32 arg1); @@ -85,7 +85,7 @@ void func0f0a0c44(s32 handnum, struct coord *param_2, struct coord *arg2); u32 func0f0a0cb0(void); u32 func0f0a0fac(void); u32 func0f0a12b0(void); -u32 func0f0a1318(void); +bool func0f0a1318(s32 handnum); u32 func0f0a134c(void); u32 func0f0a1528(void); void currentPlayerEquipWeapon(s32 weaponnum); @@ -98,8 +98,8 @@ void func0f0a1c2c(void); bool func0f0a1d14(u32 weaponnum); void func0f0a1df4(void); void currentPlayerEquipWeaponWrapper(bool arg0, s32 weaponnum); -s32 func0f0a20fc(s32 handnum); -s32 func0f0a212c(s32 handnum); +s32 handIsAttackingOnThisTick(s32 handnum); +s32 handGetAttackType(s32 handnum); char *weaponGetName(s32 weaponnum); u16 weaponGetNameId(s32 weaponnum); char *weaponGetShortName(s32 arg0); @@ -167,10 +167,10 @@ u32 func0f0a9d94(void); u32 func0f0a9da8(void); u32 func0f0a9fc0(void); Gfx *hudRenderAmmo(Gfx *gdl); -void speedpillAddBoost(s32 arg0); -void speedpillRevert(s32 arg0); -void func0f0abba8(void); -void func0f0abbe8(void); +void cboostAdd(s32 arg0); +void cboostSubtract(s32 arg0); +void cboostBoost(void); +void cboostRevert(void); void speedpillTick(void); void currentPlayerSetGunSightVisible(u32 bits, bool visible); Gfx *func0f0abcb0(Gfx *gdl); diff --git a/src/include/game/game_0b0420.h b/src/include/game/game_0b0420.h index 6231bf37e..dc9f2fc0e 100644 --- a/src/include/game/game_0b0420.h +++ b/src/include/game/game_0b0420.h @@ -4,8 +4,8 @@ #include "types.h" u32 func0f0b0420(void); -u32 func0f0b046c(void); -u32 func0f0b0520(void); +void func0f0b046c(u8 *weaponnum, u32 arg1); +void func0f0b0520(void); s32 currentPlayerGetShotCount(u32 type); void incrementKillCount(void); void incrementKnockoutCount(void); @@ -37,7 +37,7 @@ s32 currentPlayerGetDeviceState(s32 weaponnum); void currentPlayerSetDeviceActive(s32 weaponum, bool active); u16 weaponGetModelNum(s32 weaponnum); u16 weaponGetModelNum2(s32 weaponnum); -u32 func0f0b1af0(void); +void func0f0b1af0(s32 handnum, u8 *weaponnum); struct inventory_ammo *handGetAmmoDefinition(struct hand *hand); u8 handGetSingleUnk3c(struct hand *hand); f32 handGetSingleUnk34(struct hand *hand); diff --git a/src/include/types.h b/src/include/types.h index e55dca35c..4429032fe 100644 --- a/src/include/types.h +++ b/src/include/types.h @@ -2035,7 +2035,7 @@ struct hand { /*0x0b84*/ u32 unk0b84; /*0x0b88*/ u32 unk0b88; /*0x0b8c*/ u32 unk0b8c; - /*0x0b90*/ u32 unk0b90; + /*0x0b90*/ s32 unk0b90; /*0x0b94*/ struct coord unk0b94; /*0x0ba0*/ u32 unk0ba0; /*0x0ba4*/ u32 unk0ba4; @@ -2120,7 +2120,7 @@ struct hand { /*0x0cd8*/ u32 unk0cd8; /*0x0cdc*/ u32 unk0cdc; /*0x0ce0*/ u32 unk0ce0; - /*0x0ce4*/ u32 unk0ce4; + /*0x0ce4*/ u32 attacktype; /*0x0ce8*/ struct remoteminething *unk0ce8; /*0x0cec*/ ubool unk0cec; /*0x0cf0*/ struct coord unk0cf0; diff --git a/tools/patchpiracysums b/tools/patchpiracysums index 4f3d98f51..3e10e9e21 100755 --- a/tools/patchpiracysums +++ b/tools/patchpiracysums @@ -190,7 +190,7 @@ class Tool: self.patch(algo03, 'propobjHandlePickupByAibot', 'func0f08e2ac') self.patch(algo04, 'chrUncloak', 'propobjHandlePickupByAibot') self.patch(algo05, 'func0f028590', 'func00002078') - self.patch(algo06, 'coreLoadStage', 'coreGetEffectiveSlowMotion') + self.patch(algo06, 'coreLoadStage', 'coreGetSlowMotionType') self.patch(algo07, 'propAllocateEyespy', 'coreLoadStage') self.patch(algo08, 'chrConsiderGrenadeThrow', 'func0f15b534') self.patch(algo09, 'func0f09e144', 'tagsAllocatePtrs')