From 04ec4d57a08b5f32660b3c20a4e9c480f0a1b9a0 Mon Sep 17 00:00:00 2001 From: Ryan Dwyer Date: Mon, 5 Apr 2021 23:58:08 +1000 Subject: [PATCH] Decompile handCalculateShotSpread --- src/game/game_097ba0.c | 273 ++++++++------------------------- src/game/inventory/items.c | 44 +++--- src/game/prop.c | 10 +- src/game/propobj.c | 4 +- src/include/game/game_097ba0.h | 2 +- src/include/game/prop.h | 2 +- src/include/types.h | 2 +- 7 files changed, 93 insertions(+), 244 deletions(-) diff --git a/src/game/game_097ba0.c b/src/game/game_097ba0.c index 8aa30e22d..9b0902d7e 100644 --- a/src/game/game_097ba0.c +++ b/src/game/game_097ba0.c @@ -17695,7 +17695,7 @@ glabel var7f1ac72c /* f09f2e8: 27a401e8 */ addiu $a0,$sp,0x1e8 /* f09f2ec: 27a501dc */ addiu $a1,$sp,0x1dc /* f09f2f0: 8fa60240 */ lw $a2,0x240($sp) -/* f09f2f4: 0fc2832c */ jal func0f0a0cb0 +/* f09f2f4: 0fc2832c */ jal handCalculateShotSpread /* f09f2f8: 24070001 */ addiu $a3,$zero,0x1 /* f09f2fc: 0fc2d5de */ jal currentPlayerGetUnk174c /* f09f300: 00000000 */ nop @@ -18211,7 +18211,7 @@ glabel var7f1ac72c /* f09f2e8: 27a401e8 */ addiu $a0,$sp,0x1e8 /* f09f2ec: 27a501dc */ addiu $a1,$sp,0x1dc /* f09f2f0: 8fa60240 */ lw $a2,0x240($sp) -/* f09f2f4: 0fc2832c */ jal func0f0a0cb0 +/* f09f2f4: 0fc2832c */ jal handCalculateShotSpread /* f09f2f8: 24070001 */ addiu $a3,$zero,0x1 /* f09f2fc: 0fc2d5de */ jal currentPlayerGetUnk174c /* f09f300: 00000000 */ nop @@ -18817,7 +18817,7 @@ glabel var7f1ac740 /* f09fe28: 27a40204 */ addiu $a0,$sp,0x204 /* f09fe2c: 27a501f8 */ addiu $a1,$sp,0x1f8 /* f09fe30: 02003025 */ move $a2,$s0 -/* f09fe34: 0fc283f5 */ jal func0f0a0cb0 +/* f09fe34: 0fc283f5 */ jal handCalculateShotSpread /* f09fe38: 24070001 */ li $a3,0x1 /* f09fe3c: 0fc2d726 */ jal currentPlayerGetUnk174c /* f09fe40: 00000000 */ nop @@ -19452,7 +19452,7 @@ glabel var7f1ac740 /* f09fb24: 27a40204 */ addiu $a0,$sp,0x204 /* f09fb28: 27a501f8 */ addiu $a1,$sp,0x1f8 /* f09fb2c: 02003025 */ or $a2,$s0,$zero -/* f09fb30: 0fc2832c */ jal func0f0a0cb0 +/* f09fb30: 0fc2832c */ jal handCalculateShotSpread /* f09fb34: 24070001 */ addiu $a3,$zero,0x1 /* f09fb38: 0fc2d5de */ jal currentPlayerGetUnk174c /* f09fb3c: 00000000 */ nop @@ -20079,7 +20079,7 @@ glabel var7f1ac740 /* f09d99c: 27a40204 */ addiu $a0,$sp,0x204 /* f09d9a0: 27a501f8 */ addiu $a1,$sp,0x1f8 /* f09d9a4: 02003025 */ or $a2,$s0,$zero -/* f09d9a8: 0fc27a99 */ jal func0f0a0cb0 +/* f09d9a8: 0fc27a99 */ jal handCalculateShotSpread /* f09d9ac: 24070001 */ addiu $a3,$zero,0x1 /* f09d9b0: 0fc2cd36 */ jal currentPlayerGetUnk174c /* f09d9b4: 00000000 */ sll $zero,$zero,0x0 @@ -21731,213 +21731,62 @@ void func0f0a0c44(s32 handnum, struct coord *arg1, struct coord *arg2) func0f0b4c3c(g_Vars.currentplayer->hands[handnum].crosspos, arg2, 1); } -GLOBAL_ASM( -glabel func0f0a0cb0 -/* f0a0cb0: 27bdffb8 */ addiu $sp,$sp,-72 -/* f0a0cb4: 44801000 */ mtc1 $zero,$f2 -/* f0a0cb8: afbf0014 */ sw $ra,0x14($sp) -/* f0a0cbc: afa40048 */ sw $a0,0x48($sp) -/* f0a0cc0: afa5004c */ sw $a1,0x4c($sp) -/* f0a0cc4: afa60050 */ sw $a2,0x50($sp) -/* f0a0cc8: afa70054 */ sw $a3,0x54($sp) -/* f0a0ccc: 00c02025 */ or $a0,$a2,$zero -/* f0a0cd0: 0fc2c43b */ jal currentPlayerGetWeaponFunction -/* f0a0cd4: e7a2003c */ swc1 $f2,0x3c($sp) -/* f0a0cd8: 3c0e800a */ lui $t6,%hi(g_Vars+0x284) -/* f0a0cdc: 8dcea244 */ lw $t6,%lo(g_Vars+0x284)($t6) -/* f0a0ce0: c7a2003c */ lwc1 $f2,0x3c($sp) -/* f0a0ce4: 10400007 */ beqz $v0,.L0f0a0d04 -/* f0a0ce8: afae002c */ sw $t6,0x2c($sp) -/* f0a0cec: 8c4f0000 */ lw $t7,0x0($v0) -/* f0a0cf0: 24010001 */ addiu $at,$zero,0x1 -/* f0a0cf4: 31f800ff */ andi $t8,$t7,0xff -/* f0a0cf8: 57010003 */ bnel $t8,$at,.L0f0a0d08 -/* f0a0cfc: 8fa40050 */ lw $a0,0x50($sp) -/* f0a0d00: c4420020 */ lwc1 $f2,0x20($v0) -.L0f0a0d04: -/* f0a0d04: 8fa40050 */ lw $a0,0x50($sp) -.L0f0a0d08: -/* f0a0d08: 0fc2867c */ jal getCurrentPlayerWeaponIdWrapper -/* f0a0d0c: e7a2003c */ swc1 $f2,0x3c($sp) -/* f0a0d10: 00402025 */ or $a0,$v0,$zero -/* f0a0d14: 0fc2c601 */ jal weaponHasInvEFlag -/* f0a0d18: 24050004 */ addiu $a1,$zero,0x4 -/* f0a0d1c: 10400013 */ beqz $v0,.L0f0a0d6c -/* f0a0d20: c7a2003c */ lwc1 $f2,0x3c($sp) -/* f0a0d24: 8fa80050 */ lw $t0,0x50($sp) -/* f0a0d28: 8fb9002c */ lw $t9,0x2c($sp) -/* f0a0d2c: 24010001 */ addiu $at,$zero,0x1 -/* f0a0d30: 00084900 */ sll $t1,$t0,0x4 -/* f0a0d34: 01284823 */ subu $t1,$t1,$t0 -/* f0a0d38: 00094880 */ sll $t1,$t1,0x2 -/* f0a0d3c: 01284821 */ addu $t1,$t1,$t0 -/* f0a0d40: 000948c0 */ sll $t1,$t1,0x3 -/* f0a0d44: 01284821 */ addu $t1,$t1,$t0 -/* f0a0d48: 00094880 */ sll $t1,$t1,0x2 -/* f0a0d4c: 03295021 */ addu $t2,$t9,$t1 -/* f0a0d50: 8d4b0b90 */ lw $t3,0xb90($t2) -/* f0a0d54: 15610005 */ bne $t3,$at,.L0f0a0d6c -/* f0a0d58: 3c013e80 */ lui $at,0x3e80 -/* f0a0d5c: 44812000 */ mtc1 $at,$f4 -/* f0a0d60: 00000000 */ nop -/* f0a0d64: 46041082 */ mul.s $f2,$f2,$f4 -/* f0a0d68: 00000000 */ nop -.L0f0a0d6c: -/* f0a0d6c: 0fc331a0 */ jal bmoveGetCrouchPos -/* f0a0d70: e7a2003c */ swc1 $f2,0x3c($sp) -/* f0a0d74: 14400006 */ bnez $v0,.L0f0a0d90 -/* f0a0d78: c7a2003c */ lwc1 $f2,0x3c($sp) -/* f0a0d7c: 3c013f00 */ lui $at,0x3f00 -/* f0a0d80: 44813000 */ mtc1 $at,$f6 -/* f0a0d84: 00000000 */ nop -/* f0a0d88: 46061082 */ mul.s $f2,$f2,$f6 -/* f0a0d8c: 00000000 */ nop -.L0f0a0d90: -/* f0a0d90: 8fac002c */ lw $t4,0x2c($sp) -/* f0a0d94: 3c013fc0 */ lui $at,0x3fc0 -/* f0a0d98: 818d0de4 */ lb $t5,0xde4($t4) -/* f0a0d9c: 11a00005 */ beqz $t5,.L0f0a0db4 -/* f0a0da0: 00000000 */ nop -/* f0a0da4: 44814000 */ mtc1 $at,$f8 -/* f0a0da8: 00000000 */ nop -/* f0a0dac: 46081082 */ mul.s $f2,$f2,$f8 -/* f0a0db0: 00000000 */ nop -.L0f0a0db4: -/* f0a0db4: 0c002f9d */ jal viGetFovY -/* f0a0db8: e7a2003c */ swc1 $f2,0x3c($sp) -/* f0a0dbc: 3c0142f0 */ lui $at,0x42f0 -/* f0a0dc0: 44815000 */ mtc1 $at,$f10 -/* f0a0dc4: c7a2003c */ lwc1 $f2,0x3c($sp) -/* f0a0dc8: 8fae0054 */ lw $t6,0x54($sp) -/* f0a0dcc: 46025402 */ mul.s $f16,$f10,$f2 -/* f0a0dd0: 46008483 */ div.s $f18,$f16,$f0 -/* f0a0dd4: 11c00020 */ beqz $t6,.L0f0a0e58 -/* f0a0dd8: e7b20038 */ swc1 $f18,0x38($sp) -/* f0a0ddc: 0c004b70 */ jal random -/* f0a0de0: 00000000 */ nop -/* f0a0de4: 0c004b70 */ jal random -/* f0a0de8: afa20024 */ sw $v0,0x24($sp) -/* f0a0dec: 44822000 */ mtc1 $v0,$f4 -/* f0a0df0: 8faf0024 */ lw $t7,0x24($sp) -/* f0a0df4: 04410005 */ bgez $v0,.L0f0a0e0c -/* f0a0df8: 468021a0 */ cvt.s.w $f6,$f4 -/* f0a0dfc: 3c014f80 */ lui $at,0x4f80 -/* f0a0e00: 44814000 */ mtc1 $at,$f8 -/* f0a0e04: 00000000 */ nop -/* f0a0e08: 46083180 */ add.s $f6,$f6,$f8 -.L0f0a0e0c: -/* f0a0e0c: 3c012f80 */ lui $at,0x2f80 -/* f0a0e10: 44815000 */ mtc1 $at,$f10 -/* f0a0e14: 448f9000 */ mtc1 $t7,$f18 -/* f0a0e18: 3c014f80 */ lui $at,0x4f80 -/* f0a0e1c: 460a3402 */ mul.s $f16,$f6,$f10 -/* f0a0e20: 05e10004 */ bgez $t7,.L0f0a0e34 -/* f0a0e24: 46809120 */ cvt.s.w $f4,$f18 -/* f0a0e28: 44814000 */ mtc1 $at,$f8 -/* f0a0e2c: 00000000 */ nop -/* f0a0e30: 46082100 */ add.s $f4,$f4,$f8 -.L0f0a0e34: -/* f0a0e34: 3c012f80 */ lui $at,0x2f80 -/* f0a0e38: 44813000 */ mtc1 $at,$f6 -/* f0a0e3c: 3c013f00 */ lui $at,0x3f00 -/* f0a0e40: 44819000 */ mtc1 $at,$f18 -/* f0a0e44: 46062282 */ mul.s $f10,$f4,$f6 -/* f0a0e48: 46125201 */ sub.s $f8,$f10,$f18 -/* f0a0e4c: 46088082 */ mul.s $f2,$f16,$f8 -/* f0a0e50: 10000003 */ b .L0f0a0e60 -/* f0a0e54: 00000000 */ nop -.L0f0a0e58: -/* f0a0e58: 44801000 */ mtc1 $zero,$f2 -/* f0a0e5c: 00000000 */ nop -.L0f0a0e60: -/* f0a0e60: 0fc2d5f6 */ jal currentPlayerGetScreenWidth -/* f0a0e64: e7a20034 */ swc1 $f2,0x34($sp) -/* f0a0e68: 0c002f06 */ jal viGetHeight -/* f0a0e6c: e7a0001c */ swc1 $f0,0x1c($sp) -/* f0a0e70: 0fc2d60a */ jal currentPlayerGetPerspAspect -/* f0a0e74: a7a20022 */ sh $v0,0x22($sp) -/* f0a0e78: c7a20034 */ lwc1 $f2,0x34($sp) -/* f0a0e7c: c7a40038 */ lwc1 $f4,0x38($sp) -/* f0a0e80: 87b80022 */ lh $t8,0x22($sp) -/* f0a0e84: c7aa001c */ lwc1 $f10,0x1c($sp) -/* f0a0e88: 46041182 */ mul.s $f6,$f2,$f4 -/* f0a0e8c: 44988000 */ mtc1 $t8,$f16 -/* f0a0e90: 8fa8002c */ lw $t0,0x2c($sp) -/* f0a0e94: 8fb90054 */ lw $t9,0x54($sp) -/* f0a0e98: 46808220 */ cvt.s.w $f8,$f16 -/* f0a0e9c: 460a3482 */ mul.s $f18,$f6,$f10 -/* f0a0ea0: c50a1660 */ lwc1 $f10,0x1660($t0) -/* f0a0ea4: 46080102 */ mul.s $f4,$f0,$f8 -/* f0a0ea8: 46049183 */ div.s $f6,$f18,$f4 -/* f0a0eac: 460a3400 */ add.s $f16,$f6,$f10 -/* f0a0eb0: 1320001f */ beqz $t9,.L0f0a0f30 -/* f0a0eb4: e7b00040 */ swc1 $f16,0x40($sp) -/* f0a0eb8: 0c004b70 */ jal random -/* f0a0ebc: 00000000 */ nop -/* f0a0ec0: 0c004b70 */ jal random -/* f0a0ec4: afa20024 */ sw $v0,0x24($sp) -/* f0a0ec8: 8fa90024 */ lw $t1,0x24($sp) -/* f0a0ecc: 3c012f80 */ lui $at,0x2f80 -/* f0a0ed0: 44810000 */ mtc1 $at,$f0 -/* f0a0ed4: 44894000 */ mtc1 $t1,$f8 -/* f0a0ed8: 3c014f80 */ lui $at,0x4f80 -/* f0a0edc: 05210004 */ bgez $t1,.L0f0a0ef0 -/* f0a0ee0: 468044a0 */ cvt.s.w $f18,$f8 -/* f0a0ee4: 44812000 */ mtc1 $at,$f4 -/* f0a0ee8: 00000000 */ nop -/* f0a0eec: 46049480 */ add.s $f18,$f18,$f4 -.L0f0a0ef0: -/* f0a0ef0: 46009182 */ mul.s $f6,$f18,$f0 -/* f0a0ef4: 3c013f00 */ lui $at,0x3f00 -/* f0a0ef8: 44815000 */ mtc1 $at,$f10 -/* f0a0efc: 44824000 */ mtc1 $v0,$f8 -/* f0a0f00: 3c014f80 */ lui $at,0x4f80 -/* f0a0f04: 46804120 */ cvt.s.w $f4,$f8 -/* f0a0f08: 04410004 */ bgez $v0,.L0f0a0f1c -/* f0a0f0c: 460a3401 */ sub.s $f16,$f6,$f10 -/* f0a0f10: 44819000 */ mtc1 $at,$f18 -/* f0a0f14: 00000000 */ nop -/* f0a0f18: 46122100 */ add.s $f4,$f4,$f18 -.L0f0a0f1c: -/* f0a0f1c: 46002182 */ mul.s $f6,$f4,$f0 -/* f0a0f20: 00000000 */ nop -/* f0a0f24: 46103082 */ mul.s $f2,$f6,$f16 -/* f0a0f28: 10000003 */ b .L0f0a0f38 -/* f0a0f2c: 00000000 */ nop -.L0f0a0f30: -/* f0a0f30: 44801000 */ mtc1 $zero,$f2 -/* f0a0f34: 00000000 */ nop -.L0f0a0f38: -/* f0a0f38: 0fc2d5fa */ jal currentPlayerGetScreenHeight -/* f0a0f3c: e7a20034 */ swc1 $f2,0x34($sp) -/* f0a0f40: 0c002f06 */ jal viGetHeight -/* f0a0f44: e7a0001c */ swc1 $f0,0x1c($sp) -/* f0a0f48: c7a20034 */ lwc1 $f2,0x34($sp) -/* f0a0f4c: c7aa0038 */ lwc1 $f10,0x38($sp) -/* f0a0f50: c7b2001c */ lwc1 $f18,0x1c($sp) -/* f0a0f54: 44823000 */ mtc1 $v0,$f6 -/* f0a0f58: 460a1202 */ mul.s $f8,$f2,$f10 -/* f0a0f5c: 8faa002c */ lw $t2,0x2c($sp) -/* f0a0f60: 8fa30048 */ lw $v1,0x48($sp) -/* f0a0f64: 44800000 */ mtc1 $zero,$f0 -/* f0a0f68: 27a40040 */ addiu $a0,$sp,0x40 -/* f0a0f6c: 3c063f80 */ lui $a2,0x3f80 -/* f0a0f70: 46803420 */ cvt.s.w $f16,$f6 -/* f0a0f74: 46124102 */ mul.s $f4,$f8,$f18 -/* f0a0f78: c5481664 */ lwc1 $f8,0x1664($t2) -/* f0a0f7c: 46102283 */ div.s $f10,$f4,$f16 -/* f0a0f80: 46085480 */ add.s $f18,$f10,$f8 -/* f0a0f84: e7b20044 */ swc1 $f18,0x44($sp) -/* f0a0f88: e4600000 */ swc1 $f0,0x0($v1) -/* f0a0f8c: e4600004 */ swc1 $f0,0x4($v1) -/* f0a0f90: e4600008 */ swc1 $f0,0x8($v1) -/* f0a0f94: 0fc2d30f */ jal func0f0b4c3c -/* f0a0f98: 8fa5004c */ lw $a1,0x4c($sp) -/* f0a0f9c: 8fbf0014 */ lw $ra,0x14($sp) -/* f0a0fa0: 27bd0048 */ addiu $sp,$sp,0x48 -/* f0a0fa4: 03e00008 */ jr $ra -/* f0a0fa8: 00000000 */ nop -); +void handCalculateShotSpread(struct coord *arg0, struct coord *arg1, s32 handnum, bool dorandom) +{ + f32 crosspos[2]; + f32 spread = 0; + f32 scaledspread; + f32 randfactor; + struct weaponfunc *func = currentPlayerGetWeaponFunction(handnum); + struct player *player = g_Vars.currentplayer; + + if (func != NULL && (func->type & 0xff) == INVENTORYFUNCTYPE_SHOOT_SINGLE) { + struct weaponfunc_shootsingle *shootfunc = (struct weaponfunc_shootsingle *) func; + spread = shootfunc->spread; + } + + // Unsure what this is + if (weaponHasInvEFlag(getCurrentPlayerWeaponIdWrapper(handnum), 0x00000004) + && player->hands[handnum].unk0b90 == 1) { + spread *= 0.25f; + } + + // Decrease spread if double crouched + if (bmoveGetCrouchPos() == CROUCHPOS_SQUAT) { + spread *= 0.5f; + } + + // Increase spread if dual wielding + if (player->hands[HAND_LEFT].inuse) { + spread *= 1.5f; + } + + scaledspread = 120.0f * spread / viGetFovY(); + + if (dorandom) { + randfactor = (random() * (1.0f / U32_MAX) - 0.5f) * (random() * (1.0f / U32_MAX)); + } else { + randfactor = 0; + } + + crosspos[0] = player->crosspos[0] + randfactor * scaledspread * currentPlayerGetScreenWidth() + / (viGetHeight() * currentPlayerGetPerspAspect()); + + if (dorandom) { + randfactor = (random() * (1.0f / U32_MAX) - 0.5f) * (random() * (1.0f / U32_MAX)); + } else { + randfactor = 0; + } + + crosspos[1] = player->crosspos[1] + (randfactor * scaledspread * currentPlayerGetScreenHeight()) + / viGetHeight(); + + arg0->x = 0; + arg0->y = 0; + arg0->z = 0; + + func0f0b4c3c(crosspos, arg1, 1); +} GLOBAL_ASM( glabel func0f0a0fac diff --git a/src/game/inventory/items.c b/src/game/inventory/items.c index 5e67dfdb1..f6a83d8ee 100644 --- a/src/game/inventory/items.c +++ b/src/game/inventory/items.c @@ -121,7 +121,7 @@ struct weaponfunc_shootsingle invfunc_00011160 = { &invmenupos_00011098, 0x00000000, 1, // damage - 0x40c00000, + 6, // spread 6, 18, 2, 8, 0x40a00000, 0x40000000, @@ -444,7 +444,7 @@ struct weaponfunc_shootsingle invfunc_falcon2_singleshot = { &invmenupos_00011098, 0x10000000, 1, // damage - 0x3f800000, + 1, // spread 3, 5, 2, 0, 0x41200000, 0x41700000, @@ -466,7 +466,7 @@ struct weaponfunc_shootsingle invfunc_falcon2silenced_singleshot = { &invmenupos_00011098, 0x10000000, 1, // damage - 0x3f800000, + 1, // spread 3, 5, 2, 0, 0x41200000, 0x41700000, @@ -673,7 +673,7 @@ struct weaponfunc_shootsingle invfunc_magsec_singleshot = { &invmenupos_00011098, 0x10000000, 1.1, // damage - 0x40c00000, + 6, // spread 4, 8, 3, 0, 0x40a00000, 0x41200000, @@ -695,7 +695,7 @@ struct weaponfunc_shootsingle invfunc_magsec_burst = { &invmenupos_00011098, 0x10000000, 1.1, // damage - 0x41200000, + 10, // spread 9, 14, 0, 0, 0x41000000, 0x41400000, @@ -840,7 +840,7 @@ struct weaponfunc_shootsingle invfunc_dy357_singleshot = { &invmenupos_00011098, 0x14000000, 2, // damage - 0x00000000, + 0, // spread 8, 16, 0, -1, 0x41400000, 0x420c0000, @@ -862,7 +862,7 @@ struct weaponfunc_shootsingle invfunc_dy357lx_singleshot = { &invmenupos_00011098, 0x1e000000, 200, // damage - 0x00000000, + 0, // spread 8, 24, 0, -1, 0x41400000, 0x420c0000, @@ -1009,7 +1009,7 @@ struct weaponfunc_shootsingle invfunc_phoenix_singleshot = { &invmenupos_00011098, 0x10000000, 1.1, // damage - 0x40400000, + 3, // spread 3, 5, 2, 0, 0x41200000, 0x41700000, @@ -1031,7 +1031,7 @@ struct weaponfunc_shootsingle invfunc_phoenix_explosiveshells = { &invmenupos_00011098, 0x10000000, 1.2, // damage - 0x40a00000, + 5, // spread 13, 15, 25, 0, 0x41700000, 0x41c80000, @@ -1149,7 +1149,7 @@ struct weaponfunc_shootsingle invfunc_mauler_singleshot = { &invmenupos_00011098, 0x00000000, 1.2, // damage - 0x40c00000, + 6, // spread 3, 9, 32, 28, 0x00000000, 0x00000000, @@ -1171,7 +1171,7 @@ struct weaponfunc_shootsingle invfunc_mauler_chargeshot = { &invmenupos_00011098, 0x00000000, 1.2, // damage - 0x40c00000, + 6, // spread 3, 9, 32, 28, 0x00000000, 0x00000000, @@ -2403,7 +2403,7 @@ struct weaponfunc_shootsingle invfunc_shotgun_single = { &invmenupos_00011098, 0x00000000, 0.6, // damage - 0x41f00000, + 30, // spread 20, 28, 0, 0, 0x00000000, 0x00000000, @@ -2425,7 +2425,7 @@ struct weaponfunc_shootsingle invfunc_shotgun_double = { &invmenupos_00011098, 0x00000000, 0.6, // damage - 0x41800000, + 16, // spread 20, 28, 0, 0, 0x00000000, 0x00000000, @@ -3445,7 +3445,7 @@ struct weaponfunc_shootsingle invfunc_farsight_shoot = { &invmenupos_00011098, 0x00000000, 100, // damage - 0x00000000, + 0, // spread 70, 40, 0, 0, 0x00000000, 0x00000000, @@ -3467,7 +3467,7 @@ struct weaponfunc_shootsingle invfunc_farsight_targetlocator = { &invmenupos_00011098, 0x00000000, 100, // damage - 0x00000000, + 0, // spread 70, 40, 0, 0, 0x00000000, 0x00000000, @@ -3708,7 +3708,7 @@ struct weaponfunc_shootsingle invfunc_tranquilizer_shoot = { &invmenupos_00011098, 0x10000000, 0.25, // damage - 0x40400000, + 3, // spread 3, 5, 5, 0, 0x3f800000, 0x00000000, @@ -3802,7 +3802,7 @@ struct weaponfunc_shootsingle invfunc_psychosisgun_shoot = { &invmenupos_00011098, 0x10000000, 0.5, // damage - 0x40400000, + 3, // spread 3, 5, 5, 0, 0x3f800000, 0x00000000, @@ -3884,7 +3884,7 @@ struct weaponfunc_shootsingle invfunc_sniperrifle_singleshot = { &invmenupos_00011098, 0x10000000, 1.2, // damage - 0x00000000, + 0, // spread 6, 10, 0, 0, 0x41000000, 0x00000000, @@ -3967,7 +3967,7 @@ struct weaponfunc_shootsingle invfunc_laser_pulse = { &invmenupos_00011098, 0x00000000, 1, // damage - 0x00000000, + 0, // spread 6, 18, 24, -1, 0x00000000, 0x00000000, @@ -4056,7 +4056,7 @@ struct weaponfunc_shootsingle invfunc_pp9i_shoot = { &invmenupos_00011098, 0x10000000, 1, // damage - 0x3f800000, + 1, // spread 4, 8, 3, 0, 0x40400000, 0x41200000, @@ -4117,7 +4117,7 @@ struct weaponfunc_shootsingle invfunc_cc13_shoot = { &invmenupos_00011098, 0x10000000, 1, // damage - 0x40c00000, + 6, // spread 4, 8, 3, 0, 0x40a00000, 0x41200000, @@ -5931,7 +5931,7 @@ struct weaponfunc_shootsingle invfunc_tester_primary = { &invmenupos_00011070, 0x10000000, 1, // damage - 0x40c00000, + 6, // spread 4, 8, 3, 0, 0x00000000, 0x00000000, diff --git a/src/game/prop.c b/src/game/prop.c index 88f988e4c..9625b6112 100644 --- a/src/game/prop.c +++ b/src/game/prop.c @@ -2213,7 +2213,7 @@ glabel var7f1a9ebc /* f061d68: 8fa70078 */ lw $a3,0x78($sp) /* f061d6c: 8fa60070 */ lw $a2,0x70($sp) /* f061d70: 27a50064 */ addiu $a1,$sp,0x64 -/* f061d74: 0fc2832c */ jal func0f0a0cb0 +/* f061d74: 0fc2832c */ jal handCalculateShotSpread /* f061d78: 27a40058 */ addiu $a0,$sp,0x58 /* f061d7c: 8fae0078 */ lw $t6,0x78($sp) /* f061d80: 24010002 */ addiu $at,$zero,0x2 @@ -2311,14 +2311,14 @@ glabel var7f1a9ebc /* f061ed0: 00000000 */ nop ); -void handCreateBulletRaycast(s32 handnum, bool arg1, bool arg2, s32 arg3, bool arg4) +void handCreateBulletRaycast(s32 handnum, bool arg1, bool dorandom, s32 arg3, bool arg4) { struct coord sp5c; struct coord sp50; struct coord sp44; struct coord sp38; - func0f0a0cb0(&sp38, &sp44, handnum, arg2); + handCalculateShotSpread(&sp38, &sp44, handnum, dorandom); if (arg3 > 0) { func00015b68(currentPlayerGetUnk174c(), &sp38, &sp50); @@ -2631,7 +2631,7 @@ void handInflictCloseRangeDamage(s32 handnum, struct shorthand *hand, bool arg2) struct coord spcc; u32 spc8 = 0; - func0f0a0cb0(&spd8, &spcc, handnum, true); + handCalculateShotSpread(&spd8, &spcc, handnum, true); if (func000225d4(spe4, &spd8, &spcc, &spc8) > 0) { f32 damage = handGetDamage(hand) * 2.5f; @@ -2651,7 +2651,7 @@ void handInflictCloseRangeDamage(s32 handnum, struct shorthand *hand, bool arg2) s32 sp9c = 15; if (!chrIsAvoiding(chr)) { - func0f0a0cb0(&spb8, &spac, handnum, true); + handCalculateShotSpread(&spb8, &spac, handnum, true); skipthething = true; func00015b10(currentPlayerGetUnk174c(), &spac); func0f0a7d98(hand, prop, -1); diff --git a/src/game/propobj.c b/src/game/propobj.c index cf5043beb..219ab2d4c 100644 --- a/src/game/propobj.c +++ b/src/game/propobj.c @@ -58199,7 +58199,7 @@ glabel func0f0841dc /* f084384: 27a40040 */ addiu $a0,$sp,0x40 /* f084388: 27a50034 */ addiu $a1,$sp,0x34 /* f08438c: 00003025 */ or $a2,$zero,$zero -/* f084390: 0fc2832c */ jal func0f0a0cb0 +/* f084390: 0fc2832c */ jal handCalculateShotSpread /* f084394: 00003825 */ or $a3,$zero,$zero /* f084398: 02002025 */ or $a0,$s0,$zero /* f08439c: 0fc209b3 */ jal func0f0826cc @@ -58461,7 +58461,7 @@ glabel func0f0841dc /* f084384: 27a40040 */ addiu $a0,$sp,0x40 /* f084388: 27a50034 */ addiu $a1,$sp,0x34 /* f08438c: 00003025 */ or $a2,$zero,$zero -/* f084390: 0fc2832c */ jal func0f0a0cb0 +/* f084390: 0fc2832c */ jal handCalculateShotSpread /* f084394: 00003825 */ or $a3,$zero,$zero /* f084398: 02002025 */ or $a0,$s0,$zero /* f08439c: 0fc209b3 */ jal func0f0826cc diff --git a/src/include/game/game_097ba0.h b/src/include/game/game_097ba0.h index c68641a43..e46680c0b 100644 --- a/src/include/game/game_097ba0.h +++ b/src/include/game/game_097ba0.h @@ -83,7 +83,7 @@ void func0f0a0b98(f32 arg0, f32 arg1); void currentPlayerGetCrossPos(f32 *x, f32 *y); void func0f0a0c08(struct coord *arg0, struct coord *arg1); void func0f0a0c44(s32 handnum, struct coord *param_2, struct coord *arg2); -void func0f0a0cb0(struct coord *arg0, struct coord *arg1, s32 handnum, bool arg3); +void handCalculateShotSpread(struct coord *arg0, struct coord *arg1, s32 handnum, bool dorandom); u32 func0f0a0fac(void); void func0f0a12b0(struct coord *arg0, struct coord *arg1, s32 handnum); u32 handGetUnk0c30(s32 handnum); diff --git a/src/include/game/prop.h b/src/include/game/prop.h index d7622d76f..be501dacb 100644 --- a/src/include/game/prop.h +++ b/src/include/game/prop.h @@ -22,7 +22,7 @@ u32 func0f060984(void); u32 func0f060bac(void); void func0f060db8(s32 handnum, bool arg1, struct coord *arg2, struct coord *arg3, struct coord *arg4, struct coord *arg5, u32 arg6, f32 arg7, bool arg8); struct prop *func0f061d54(s32 handnum, u32 arg1, u32 arg2); -void handCreateBulletRaycast(s32 handnum, bool arg1, bool arg2, s32 arg3, bool arg4); +void handCreateBulletRaycast(s32 handnum, bool arg1, bool dorandom, s32 arg3, bool arg4); u32 func0f061fa8(void); void handInflictCloseRangeDamage(s32 handnum, struct shorthand *hand, bool arg2); void handTickAttack(s32 handnum); diff --git a/src/include/types.h b/src/include/types.h index fe187125a..9bfdde347 100644 --- a/src/include/types.h +++ b/src/include/types.h @@ -3114,7 +3114,7 @@ struct weaponfunc_shootsingle { /*0x14*/ struct inventory_menupos *unk14; /*0x18*/ u32 unk18; /*0x1c*/ f32 damage; - /*0x20*/ u32 unk20; + /*0x20*/ f32 spread; /** * Setting these 4 bytes to higher values causes slower recoil animations