diff --git a/src/game/chr/chr.c b/src/game/chr/chr.c index 977b1912b..9ffe9de4d 100644 --- a/src/game/chr/chr.c +++ b/src/game/chr/chr.c @@ -2691,8 +2691,8 @@ void chrInit(struct prop *prop, u8 *ailist) } chr->talktimer = 3600; - chr->cloakfade_00 = 0; - chr->cloakfade_06 = 0; + chr->cloakfadefrac = 0; + chr->cloakfadefinished = false; chr->inlift = false; chr->targetlastseenp.x = 0; chr->targetlastseenp.y = 0; @@ -4455,419 +4455,161 @@ void chrUncloakTemporarily(struct chrdata *chr) chr->cloakpause = 120; } -GLOBAL_ASM( -glabel func0f022624 -.late_rodata -glabel var7f1a87ac -.word 0x3ecccccd -glabel var7f1a87b0 -.word 0x40490fdb -.text -/* f022624: 27bdffd0 */ addiu $sp,$sp,-48 -/* f022628: afbf001c */ sw $ra,0x1c($sp) -/* f02262c: afb00018 */ sw $s0,0x18($sp) -/* f022630: 848202da */ lh $v0,0x2da($a0) -/* f022634: 00808025 */ or $s0,$a0,$zero -/* f022638: 3c0e800a */ lui $t6,%hi(g_Vars+0x38) -/* f02263c: 58400009 */ blezl $v0,.L0f022664 -/* f022640: 8e0202d4 */ lw $v0,0x2d4($s0) -/* f022644: 8dce9ff8 */ lw $t6,%lo(g_Vars+0x38)($t6) -/* f022648: 004e7823 */ subu $t7,$v0,$t6 -/* f02264c: a48f02da */ sh $t7,0x2da($a0) -/* f022650: 849802da */ lh $t8,0x2da($a0) -/* f022654: 5f000003 */ bgtzl $t8,.L0f022664 -/* f022658: 8e0202d4 */ lw $v0,0x2d4($s0) -/* f02265c: a48002da */ sh $zero,0x2da($a0) -/* f022660: 8e0202d4 */ lw $v0,0x2d4($s0) -.L0f022664: -/* f022664: 5040009b */ beqzl $v0,.L0f0228d4 -/* f022668: 8e04001c */ lw $a0,0x1c($s0) -/* f02266c: 8c43004c */ lw $v1,0x4c($v0) -/* f022670: 0003c980 */ sll $t9,$v1,0x6 -/* f022674: 00191fc2 */ srl $v1,$t9,0x1f -/* f022678: 50600022 */ beqzl $v1,.L0f022704 -/* f02267c: 8c49009c */ lw $t1,0x9c($v0) -/* f022680: 8c49001c */ lw $t1,0x1c($v0) -/* f022684: 02002025 */ or $a0,$s0,$zero -/* f022688: 8d260050 */ lw $a2,0x50($t1) -/* f02268c: 58c00014 */ blezl $a2,.L0f0226e0 -/* f022690: 8e0202d4 */ lw $v0,0x2d4($s0) -/* f022694: 0fc0e6a5 */ jal chrIsDead -/* f022698: afa6002c */ sw $a2,0x2c($sp) -/* f02269c: 1440000f */ bnez $v0,.L0f0226dc -/* f0226a0: 8fa6002c */ lw $a2,0x2c($sp) -/* f0226a4: 8e0a0014 */ lw $t2,0x14($s0) -/* f0226a8: 3c0c800a */ lui $t4,%hi(g_Vars+0x38) -/* f0226ac: 000a5880 */ sll $t3,$t2,0x2 -/* f0226b0: 0563000f */ bgezl $t3,.L0f0226f0 -/* f0226b4: 8e0202d4 */ lw $v0,0x2d4($s0) -/* f0226b8: 8d8c9ff8 */ lw $t4,%lo(g_Vars+0x38)($t4) -/* f0226bc: 00cc3023 */ subu $a2,$a2,$t4 -/* f0226c0: 5cc00003 */ bgtzl $a2,.L0f0226d0 -/* f0226c4: 8e0d02d4 */ lw $t5,0x2d4($s0) -/* f0226c8: 00003025 */ or $a2,$zero,$zero -/* f0226cc: 8e0d02d4 */ lw $t5,0x2d4($s0) -.L0f0226d0: -/* f0226d0: 8dae001c */ lw $t6,0x1c($t5) -/* f0226d4: 10000005 */ beqz $zero,.L0f0226ec -/* f0226d8: adc60050 */ sw $a2,0x50($t6) -.L0f0226dc: -/* f0226dc: 8e0202d4 */ lw $v0,0x2d4($s0) -.L0f0226e0: -/* f0226e0: 904f004c */ lbu $t7,0x4c($v0) -/* f0226e4: 31f8fffd */ andi $t8,$t7,0xfffd -/* f0226e8: a058004c */ sb $t8,0x4c($v0) -.L0f0226ec: -/* f0226ec: 8e0202d4 */ lw $v0,0x2d4($s0) -.L0f0226f0: -/* f0226f0: 8c43004c */ lw $v1,0x4c($v0) -/* f0226f4: 0003c980 */ sll $t9,$v1,0x6 -/* f0226f8: 1000005c */ beqz $zero,.L0f02286c -/* f0226fc: 00191fc2 */ srl $v1,$t9,0x1f -/* f022700: 8c49009c */ lw $t1,0x9c($v0) -.L0f022704: -/* f022704: 00095880 */ sll $t3,$t1,0x2 -/* f022708: 05630059 */ bgezl $t3,.L0f022870 -/* f02270c: 8e040014 */ lw $a0,0x14($s0) -/* f022710: 8c4c0020 */ lw $t4,0x20($v0) -/* f022714: 2401000d */ addiu $at,$zero,0xd -/* f022718: 5581004d */ bnel $t4,$at,.L0f022850 -/* f02271c: 8e0202d4 */ lw $v0,0x2d4($s0) -/* f022720: 0fc0e6a5 */ jal chrIsDead -/* f022724: 02002025 */ or $a0,$s0,$zero -/* f022728: 14400048 */ bnez $v0,.L0f02284c -/* f02272c: 2405000d */ addiu $a1,$zero,0xd -/* f022730: 8e0402d4 */ lw $a0,0x2d4($s0) -/* f022734: 00003025 */ or $a2,$zero,$zero -/* f022738: 0fc666f9 */ jal func0f199be4 -/* f02273c: 24070001 */ addiu $a3,$zero,0x1 -/* f022740: 58400043 */ blezl $v0,.L0f022850 -/* f022744: 8e0202d4 */ lw $v0,0x2d4($s0) -/* f022748: 8e0d0014 */ lw $t5,0x14($s0) -/* f02274c: 3c01800a */ lui $at,0x800a -/* f022750: 000d7080 */ sll $t6,$t5,0x2 -/* f022754: 05c30039 */ bgezl $t6,.L0f02283c -/* f022758: 8e0202d4 */ lw $v0,0x2d4($s0) -/* f02275c: c424a004 */ lwc1 $f4,-0x5ffc($at) -/* f022760: 3c017f1b */ lui $at,%hi(var7f1a87ac) -/* f022764: c42687ac */ lwc1 $f6,%lo(var7f1a87ac)($at) -/* f022768: 8e0202d4 */ lw $v0,0x2d4($s0) -/* f02276c: 3c013f80 */ lui $at,0x3f80 -/* f022770: 46062202 */ mul.s $f8,$f4,$f6 -/* f022774: c44a02c4 */ lwc1 $f10,0x2c4($v0) -/* f022778: 44819000 */ mtc1 $at,$f18 -/* f02277c: 46085400 */ add.s $f16,$f10,$f8 -/* f022780: e45002c4 */ swc1 $f16,0x2c4($v0) -/* f022784: 8e0202d4 */ lw $v0,0x2d4($s0) -/* f022788: c44002c4 */ lwc1 $f0,0x2c4($v0) -/* f02278c: 4600903e */ c.le.s $f18,$f0 -/* f022790: 00000000 */ sll $zero,$zero,0x0 -/* f022794: 45020029 */ bc1fl .L0f02283c -/* f022798: 8e0202d4 */ lw $v0,0x2d4($s0) -/* f02279c: 4600010d */ trunc.w.s $f4,$f0 -/* f0227a0: 2404000d */ addiu $a0,$zero,0xd -/* f0227a4: 00002825 */ or $a1,$zero,$zero -/* f0227a8: 44062000 */ mfc1 $a2,$f4 -/* f0227ac: 00000000 */ sll $zero,$zero,0x0 -/* f0227b0: 44863000 */ mtc1 $a2,$f6 -/* f0227b4: 00000000 */ sll $zero,$zero,0x0 -/* f0227b8: 468032a0 */ cvt.s.w $f10,$f6 -/* f0227bc: 460a0201 */ sub.s $f8,$f0,$f10 -/* f0227c0: e44802c4 */ swc1 $f8,0x2c4($v0) -/* f0227c4: 8e0202d4 */ lw $v0,0x2d4($s0) -/* f0227c8: 8c430024 */ lw $v1,0x24($v0) -/* f0227cc: 18600008 */ blez $v1,.L0f0227f0 -/* f0227d0: 0066c023 */ subu $t8,$v1,$a2 -/* f0227d4: ac580024 */ sw $t8,0x24($v0) -/* f0227d8: 8e0202d4 */ lw $v0,0x2d4($s0) -/* f0227dc: 8c590024 */ lw $t9,0x24($v0) -/* f0227e0: 5f200016 */ bgtzl $t9,.L0f02283c -/* f0227e4: 8e0202d4 */ lw $v0,0x2d4($s0) -/* f0227e8: 10000013 */ beqz $zero,.L0f022838 -/* f0227ec: ac400024 */ sw $zero,0x24($v0) -.L0f0227f0: -/* f0227f0: 0fc6666c */ jal func0f1999b0 -/* f0227f4: afa6002c */ sw $a2,0x2c($sp) -/* f0227f8: 8e0802d4 */ lw $t0,0x2d4($s0) -/* f0227fc: 00022080 */ sll $a0,$v0,0x2 -/* f022800: 8fa6002c */ lw $a2,0x2c($sp) -/* f022804: 8d09001c */ lw $t1,0x1c($t0) -/* f022808: 01241821 */ addu $v1,$t1,$a0 -/* f02280c: 8c650000 */ lw $a1,0x0($v1) -/* f022810: 18a00009 */ blez $a1,.L0f022838 -/* f022814: 00a65023 */ subu $t2,$a1,$a2 -/* f022818: ac6a0000 */ sw $t2,0x0($v1) -/* f02281c: 8e0b02d4 */ lw $t3,0x2d4($s0) -/* f022820: 8d6c001c */ lw $t4,0x1c($t3) -/* f022824: 01841821 */ addu $v1,$t4,$a0 -/* f022828: 8c6d0000 */ lw $t5,0x0($v1) -/* f02282c: 5da00003 */ bgtzl $t5,.L0f02283c -/* f022830: 8e0202d4 */ lw $v0,0x2d4($s0) -/* f022834: ac600000 */ sw $zero,0x0($v1) -.L0f022838: -/* f022838: 8e0202d4 */ lw $v0,0x2d4($s0) -.L0f02283c: -/* f02283c: 8c43004c */ lw $v1,0x4c($v0) -/* f022840: 00037180 */ sll $t6,$v1,0x6 -/* f022844: 10000009 */ beqz $zero,.L0f02286c -/* f022848: 000e1fc2 */ srl $v1,$t6,0x1f -.L0f02284c: -/* f02284c: 8e0202d4 */ lw $v0,0x2d4($s0) -.L0f022850: -/* f022850: 9058009c */ lbu $t8,0x9c($v0) -/* f022854: 3319ffdf */ andi $t9,$t8,0xffdf -/* f022858: a059009c */ sb $t9,0x9c($v0) -/* f02285c: 8e0202d4 */ lw $v0,0x2d4($s0) -/* f022860: 8c43004c */ lw $v1,0x4c($v0) -/* f022864: 00034180 */ sll $t0,$v1,0x6 -/* f022868: 00081fc2 */ srl $v1,$t0,0x1f -.L0f02286c: -/* f02286c: 8e040014 */ lw $a0,0x14($s0) -.L0f022870: -/* f022870: 3c012000 */ lui $at,0x2000 -/* f022874: 00815024 */ and $t2,$a0,$at -/* f022878: 14600005 */ bnez $v1,.L0f022890 -/* f02287c: 01402025 */ or $a0,$t2,$zero -/* f022880: 8c4b009c */ lw $t3,0x9c($v0) -/* f022884: 000b6880 */ sll $t5,$t3,0x2 -/* f022888: 05a1000b */ bgez $t5,.L0f0228b8 -/* f02288c: 00000000 */ sll $zero,$zero,0x0 -.L0f022890: -/* f022890: 54800060 */ bnezl $a0,.L0f022a14 -/* f022894: 8e090014 */ lw $t1,0x14($s0) -/* f022898: 860e02da */ lh $t6,0x2da($s0) -/* f02289c: 02002025 */ or $a0,$s0,$zero -/* f0228a0: 5dc0005c */ bgtzl $t6,.L0f022a14 -/* f0228a4: 8e090014 */ lw $t1,0x14($s0) -/* f0228a8: 0fc08921 */ jal chrCloak -/* f0228ac: 24050001 */ addiu $a1,$zero,0x1 -/* f0228b0: 10000058 */ beqz $zero,.L0f022a14 -/* f0228b4: 8e090014 */ lw $t1,0x14($s0) -.L0f0228b8: -/* f0228b8: 10800055 */ beqz $a0,.L0f022a10 -/* f0228bc: 24050001 */ addiu $a1,$zero,0x1 -/* f0228c0: 0fc08946 */ jal chrUncloak -/* f0228c4: 02002025 */ or $a0,$s0,$zero -/* f0228c8: 10000052 */ beqz $zero,.L0f022a14 -/* f0228cc: 8e090014 */ lw $t1,0x14($s0) -/* f0228d0: 8e04001c */ lw $a0,0x1c($s0) -.L0f0228d4: -/* f0228d4: 24010006 */ addiu $at,$zero,0x6 -/* f0228d8: 3c18800a */ lui $t8,%hi(g_Vars+0x28c) -/* f0228dc: 908f0000 */ lbu $t7,0x0($a0) -/* f0228e0: 55e1004c */ bnel $t7,$at,.L0f022a14 -/* f0228e4: 8e090014 */ lw $t1,0x14($s0) -/* f0228e8: 8f18a24c */ lw $t8,%lo(g_Vars+0x28c)($t8) -/* f0228ec: 0fc4a25f */ jal propGetPlayerNum -/* f0228f0: afb80024 */ sw $t8,0x24($sp) -/* f0228f4: 0fc4a24b */ jal setCurrentPlayerNum -/* f0228f8: 00402025 */ or $a0,$v0,$zero -/* f0228fc: 3c02800a */ lui $v0,%hi(g_Vars+0x284) -/* f022900: 8c42a244 */ lw $v0,%lo(g_Vars+0x284)($v0) -/* f022904: 8c4300c4 */ lw $v1,0xc4($v0) -/* f022908: 30640040 */ andi $a0,$v1,0x40 -/* f02290c: 10800020 */ beqz $a0,.L0f022990 -/* f022910: 00000000 */ sll $zero,$zero,0x0 -/* f022914: 0fc2a5dc */ jal ammoGetQuantity -/* f022918: 24040014 */ addiu $a0,$zero,0x14 -/* f02291c: 18400012 */ blez $v0,.L0f022968 -/* f022920: 00000000 */ sll $zero,$zero,0x0 -/* f022924: 8e190014 */ lw $t9,0x14($s0) -/* f022928: 3c09800a */ lui $t1,%hi(g_Vars+0x38) -/* f02292c: 00194080 */ sll $t0,$t9,0x2 -/* f022930: 05010008 */ bgez $t0,.L0f022954 -/* f022934: 00000000 */ sll $zero,$zero,0x0 -/* f022938: 8d299ff8 */ lw $t1,%lo(g_Vars+0x38)($t1) -/* f02293c: 00492823 */ subu $a1,$v0,$t1 -/* f022940: 1ca00002 */ bgtz $a1,.L0f02294c -/* f022944: 00000000 */ sll $zero,$zero,0x0 -/* f022948: 00002825 */ or $a1,$zero,$zero -.L0f02294c: -/* f02294c: 0fc2a58a */ jal currentPlayerGiveAmmo -/* f022950: 24040014 */ addiu $a0,$zero,0x14 -.L0f022954: -/* f022954: 3c02800a */ lui $v0,%hi(g_Vars+0x284) -/* f022958: 8c42a244 */ lw $v0,%lo(g_Vars+0x284)($v0) -/* f02295c: 8c4300c4 */ lw $v1,0xc4($v0) -/* f022960: 1000000b */ beqz $zero,.L0f022990 -/* f022964: 30640040 */ andi $a0,$v1,0x40 -.L0f022968: -/* f022968: 3c02800a */ lui $v0,%hi(g_Vars+0x284) -/* f02296c: 8c42a244 */ lw $v0,%lo(g_Vars+0x284)($v0) -/* f022970: 2401ffbf */ addiu $at,$zero,-65 -/* f022974: 8c4a00c4 */ lw $t2,0xc4($v0) -/* f022978: 01415824 */ and $t3,$t2,$at -/* f02297c: ac4b00c4 */ sw $t3,0xc4($v0) -/* f022980: 3c02800a */ lui $v0,%hi(g_Vars+0x284) -/* f022984: 8c42a244 */ lw $v0,%lo(g_Vars+0x284)($v0) -/* f022988: 8c4300c4 */ lw $v1,0xc4($v0) -/* f02298c: 30640040 */ andi $a0,$v1,0x40 -.L0f022990: -/* f022990: 54800009 */ bnezl $a0,.L0f0229b8 -/* f022994: 8e0e0014 */ lw $t6,0x14($s0) -/* f022998: 804c1580 */ lb $t4,0x1580($v0) -/* f02299c: 2401000d */ addiu $at,$zero,0xd -/* f0229a0: 306d0080 */ andi $t5,$v1,0x80 -/* f0229a4: 1581000f */ bne $t4,$at,.L0f0229e4 -/* f0229a8: 00000000 */ sll $zero,$zero,0x0 -/* f0229ac: 11a0000d */ beqz $t5,.L0f0229e4 -/* f0229b0: 00000000 */ sll $zero,$zero,0x0 -/* f0229b4: 8e0e0014 */ lw $t6,0x14($s0) -.L0f0229b8: -/* f0229b8: 000e7880 */ sll $t7,$t6,0x2 -/* f0229bc: 05e00012 */ bltz $t7,.L0f022a08 -/* f0229c0: 00000000 */ sll $zero,$zero,0x0 -/* f0229c4: 861802da */ lh $t8,0x2da($s0) -/* f0229c8: 02002025 */ or $a0,$s0,$zero -/* f0229cc: 1f00000e */ bgtz $t8,.L0f022a08 -/* f0229d0: 00000000 */ sll $zero,$zero,0x0 -/* f0229d4: 0fc08921 */ jal chrCloak -/* f0229d8: 24050001 */ addiu $a1,$zero,0x1 -/* f0229dc: 1000000a */ beqz $zero,.L0f022a08 -/* f0229e0: 00000000 */ sll $zero,$zero,0x0 -.L0f0229e4: -/* f0229e4: 14800008 */ bnez $a0,.L0f022a08 -/* f0229e8: 00000000 */ sll $zero,$zero,0x0 -/* f0229ec: 8e190014 */ lw $t9,0x14($s0) -/* f0229f0: 02002025 */ or $a0,$s0,$zero -/* f0229f4: 00194080 */ sll $t0,$t9,0x2 -/* f0229f8: 05010003 */ bgez $t0,.L0f022a08 -/* f0229fc: 00000000 */ sll $zero,$zero,0x0 -/* f022a00: 0fc08946 */ jal chrUncloak -/* f022a04: 24050001 */ addiu $a1,$zero,0x1 -.L0f022a08: -/* f022a08: 0fc4a24b */ jal setCurrentPlayerNum -/* f022a0c: 8fa40024 */ lw $a0,0x24($sp) -.L0f022a10: -/* f022a10: 8e090014 */ lw $t1,0x14($s0) -.L0f022a14: -/* f022a14: 00095080 */ sll $t2,$t1,0x2 -/* f022a18: 0543002a */ bgezl $t2,.L0f022ac4 -/* f022a1c: 960f02e0 */ lhu $t7,0x2e0($s0) -/* f022a20: 960b02e0 */ lhu $t3,0x2e0($s0) -/* f022a24: 3c0e800a */ lui $t6,%hi(g_Vars+0x34) -/* f022a28: 3c19800a */ lui $t9,%hi(g_Vars+0x38) -/* f022a2c: 316c0001 */ andi $t4,$t3,0x1 -/* f022a30: 55800018 */ bnezl $t4,.L0f022a94 -/* f022a34: 920302e1 */ lbu $v1,0x2e1($s0) -/* f022a38: 8dce9ff4 */ lw $t6,%lo(g_Vars+0x34)($t6) -/* f022a3c: 920302e1 */ lbu $v1,0x2e1($s0) -/* f022a40: 000e7880 */ sll $t7,$t6,0x2 -/* f022a44: 01ee7821 */ addu $t7,$t7,$t6 -/* f022a48: 00036842 */ srl $t5,$v1,0x1 -/* f022a4c: 05e10003 */ bgez $t7,.L0f022a5c -/* f022a50: 000fc0c3 */ sra $t8,$t7,0x3 -/* f022a54: 25e10007 */ addiu $at,$t7,0x7 -/* f022a58: 0001c0c3 */ sra $t8,$at,0x3 -.L0f022a5c: -/* f022a5c: 01b81021 */ addu $v0,$t5,$t8 -/* f022a60: 28410080 */ slti $at,$v0,0x80 -/* f022a64: 14200006 */ bnez $at,.L0f022a80 -/* f022a68: 00027040 */ sll $t6,$v0,0x1 -/* f022a6c: 34690001 */ ori $t1,$v1,0x1 -/* f022a70: a20902e1 */ sb $t1,0x2e1($s0) -/* f022a74: 312a0001 */ andi $t2,$t1,0x1 -/* f022a78: 10000055 */ beqz $zero,.L0f022bd0 -/* f022a7c: a20a02e1 */ sb $t2,0x2e1($s0) -.L0f022a80: -/* f022a80: 306fff01 */ andi $t7,$v1,0xff01 -/* f022a84: 01cf6825 */ or $t5,$t6,$t7 -/* f022a88: 10000051 */ beqz $zero,.L0f022bd0 -/* f022a8c: a20d02e1 */ sb $t5,0x2e1($s0) -/* f022a90: 920302e1 */ lbu $v1,0x2e1($s0) -.L0f022a94: -/* f022a94: 8f399ff8 */ lw $t9,%lo(g_Vars+0x38)($t9) -/* f022a98: 2401007f */ addiu $at,$zero,0x7f -/* f022a9c: 0003c042 */ srl $t8,$v1,0x1 -/* f022aa0: 03191021 */ addu $v0,$t8,$t9 -/* f022aa4: 0041001a */ div $zero,$v0,$at -/* f022aa8: 00004810 */ mfhi $t1 -/* f022aac: 00095840 */ sll $t3,$t1,0x1 -/* f022ab0: 306cff01 */ andi $t4,$v1,0xff01 -/* f022ab4: 016c7025 */ or $t6,$t3,$t4 -/* f022ab8: 10000045 */ beqz $zero,.L0f022bd0 -/* f022abc: a20e02e1 */ sb $t6,0x2e1($s0) -/* f022ac0: 960f02e0 */ lhu $t7,0x2e0($s0) -.L0f022ac4: -/* f022ac4: 24010001 */ addiu $at,$zero,0x1 -/* f022ac8: 31ed0001 */ andi $t5,$t7,0x1 -/* f022acc: 55a1002e */ bnel $t5,$at,.L0f022b88 -/* f022ad0: 920302e1 */ lbu $v1,0x2e1($s0) -/* f022ad4: 921802e1 */ lbu $t8,0x2e1($s0) -/* f022ad8: 3c014f80 */ lui $at,0x4f80 -/* f022adc: 3319fffe */ andi $t9,$t8,0xfffe -/* f022ae0: 332800ff */ andi $t0,$t9,0xff -/* f022ae4: 00084842 */ srl $t1,$t0,0x1 -/* f022ae8: 44898000 */ mtc1 $t1,$f16 -/* f022aec: a21902e1 */ sb $t9,0x2e1($s0) -/* f022af0: 05210004 */ bgez $t1,.L0f022b04 -/* f022af4: 468084a0 */ cvt.s.w $f18,$f16 -/* f022af8: 44812000 */ mtc1 $at,$f4 -/* f022afc: 00000000 */ sll $zero,$zero,0x0 -/* f022b00: 46049480 */ add.s $f18,$f18,$f4 -.L0f022b04: -/* f022b04: 3c0142fe */ lui $at,0x42fe -/* f022b08: 44813000 */ mtc1 $at,$f6 -/* f022b0c: 3c017f1b */ lui $at,%hi(var7f1a87b0) -/* f022b10: c42887b0 */ lwc1 $f8,%lo(var7f1a87b0)($at) -/* f022b14: 46069003 */ div.s $f0,$f18,$f6 -/* f022b18: 46000280 */ add.s $f10,$f0,$f0 -/* f022b1c: 46085302 */ mul.s $f12,$f10,$f8 -/* f022b20: 0c0068f4 */ jal cosf -/* f022b24: 00000000 */ sll $zero,$zero,0x0 -/* f022b28: 3c013f80 */ lui $at,0x3f80 -/* f022b2c: 44818000 */ mtc1 $at,$f16 -/* f022b30: 3c0141a0 */ lui $at,0x41a0 -/* f022b34: 44819000 */ mtc1 $at,$f18 -/* f022b38: 46008101 */ sub.s $f4,$f16,$f0 -/* f022b3c: 3c013f00 */ lui $at,0x3f00 -/* f022b40: 44815000 */ mtc1 $at,$f10 -/* f022b44: 920802e1 */ lbu $t0,0x2e1($s0) -/* f022b48: 46122182 */ mul.s $f6,$f4,$f18 -/* f022b4c: 240c00fe */ addiu $t4,$zero,0xfe -/* f022b50: 3109ff01 */ andi $t1,$t0,0xff01 -/* f022b54: 460a3202 */ mul.s $f8,$f6,$f10 -/* f022b58: 4600440d */ trunc.w.s $f16,$f8 -/* f022b5c: 440b8000 */ mfc1 $t3,$f16 -/* f022b60: 00000000 */ sll $zero,$zero,0x0 -/* f022b64: 018b7023 */ subu $t6,$t4,$t3 -/* f022b68: 05c10003 */ bgez $t6,.L0f022b78 -/* f022b6c: 000e7843 */ sra $t7,$t6,0x1 -/* f022b70: 25c10001 */ addiu $at,$t6,0x1 -/* f022b74: 00017843 */ sra $t7,$at,0x1 -.L0f022b78: -/* f022b78: 000fc840 */ sll $t9,$t7,0x1 -/* f022b7c: 03295025 */ or $t2,$t9,$t1 -/* f022b80: a20a02e1 */ sb $t2,0x2e1($s0) -/* f022b84: 920302e1 */ lbu $v1,0x2e1($s0) -.L0f022b88: -/* f022b88: 3c0c800a */ lui $t4,%hi(g_Vars+0x34) -/* f022b8c: 00032042 */ srl $a0,$v1,0x1 -/* f022b90: 1880000f */ blez $a0,.L0f022bd0 -/* f022b94: 3068ff01 */ andi $t0,$v1,0xff01 -/* f022b98: 8d8c9ff4 */ lw $t4,%lo(g_Vars+0x34)($t4) -/* f022b9c: 000c5880 */ sll $t3,$t4,0x2 -/* f022ba0: 016c5821 */ addu $t3,$t3,$t4 -/* f022ba4: 05610003 */ bgez $t3,.L0f022bb4 -/* f022ba8: 000b70c3 */ sra $t6,$t3,0x3 -/* f022bac: 25610007 */ addiu $at,$t3,0x7 -/* f022bb0: 000170c3 */ sra $t6,$at,0x3 -.L0f022bb4: -/* f022bb4: 008e1023 */ subu $v0,$a0,$t6 -/* f022bb8: 04430003 */ bgezl $v0,.L0f022bc8 -/* f022bbc: 0002c040 */ sll $t8,$v0,0x1 -/* f022bc0: 00001025 */ or $v0,$zero,$zero -/* f022bc4: 0002c040 */ sll $t8,$v0,0x1 -.L0f022bc8: -/* f022bc8: 0308c825 */ or $t9,$t8,$t0 -/* f022bcc: a21902e1 */ sb $t9,0x2e1($s0) -.L0f022bd0: -/* f022bd0: 8fbf001c */ lw $ra,0x1c($sp) -/* f022bd4: 8fb00018 */ lw $s0,0x18($sp) -/* f022bd8: 27bd0030 */ addiu $sp,$sp,0x30 -/* f022bdc: 03e00008 */ jr $ra -/* f022be0: 00000000 */ sll $zero,$zero,0x0 -); +void chrUpdateCloak(struct chrdata *chr) +{ + s32 qty; + s32 ammotype; + u32 prevplayernum; + f32 fVar14; + s32 fadefrac; + + // Decrement cloakpause + if (chr->cloakpause > 0) { + chr->cloakpause -= g_Vars.lvupdate240_60; + + if (chr->cloakpause < 1) { + chr->cloakpause = 0; + } + } + + // Handle ammo decrease and determine if cloak is still enabled + if (chr->aibot) { + if (chr->aibot->cloakdeviceenabled) { + qty = chr->aibot->ammotypes->quantities[AMMOTYPE_CLOAK]; + + if (qty > 0 && !chrIsDead(chr)) { + if (chr->hidden & CHRHFLAG_CLOAKED) { + qty -= g_Vars.lvupdate240_60; + + if (qty <= 0) { + qty = 0; + } + + chr->aibot->ammotypes->quantities[AMMOTYPE_CLOAK] = qty; + } + } else { + chr->aibot->cloakdeviceenabled = false; + } + } else if (chr->aibot->rcp120cloakenabled) { + if (chr->aibot->weaponnum == WEAPON_RCP120 + && !chrIsDead(chr) + && func0f199be4(chr->aibot, WEAPON_RCP120, 0, 1) > 0) { + if (chr->hidden & CHRHFLAG_CLOAKED) { + chr->aibot->unk2c4 += g_Vars.lvupdate240f * 0.4f; + + if (chr->aibot->unk2c4 >= 1) { + qty = chr->aibot->unk2c4; + chr->aibot->unk2c4 -= qty; + + if (chr->aibot->unk024 > 0) { + chr->aibot->unk024 -= qty; + + if (chr->aibot->unk024 <= 0) { + chr->aibot->unk024 = 0; + } + } else { + ammotype = func0f1999b0(WEAPON_RCP120, 0); + + if (chr->aibot->ammotypes->quantities[ammotype] > 0) { + chr->aibot->ammotypes->quantities[ammotype] -= qty; + + if (chr->aibot->ammotypes->quantities[ammotype] <= 0) { + chr->aibot->ammotypes->quantities[ammotype] = 0; + } + } + } + } + } + } else { + chr->aibot->rcp120cloakenabled = false; + } + } + + if (chr->aibot->cloakdeviceenabled || chr->aibot->rcp120cloakenabled) { + if ((chr->hidden & CHRHFLAG_CLOAKED) == 0) { + if (chr->cloakpause < 1) { + chrCloak(chr, true); + } + } + } else if (chr->hidden & CHRHFLAG_CLOAKED) { + chrUncloak(chr, true); + } + } else if (chr->prop->type == PROPTYPE_PLAYER) { + prevplayernum = g_Vars.currentplayernum; + setCurrentPlayerNum(propGetPlayerNum(chr->prop)); + + if (g_Vars.currentplayer->itemswitch & 0x00000040) { + // Cloak is active - but may or may not be in effect due to recent shooting + s32 qty = ammoGetQuantity(AMMOTYPE_CLOAK); + + if (qty > 0) { + if (chr->hidden & CHRHFLAG_CLOAKED) { + // Cloak is effective + qty -= g_Vars.lvupdate240_60; + + if (qty < 1) { + qty = 0; + } + + currentPlayerSetAmmoQuantity(AMMOTYPE_CLOAK, qty); + } + } else { + // Out of cloak ammo - turn off cloak + g_Vars.currentplayer->itemswitch &= ~0x00000040; + } + } + + // If cloak is enabled via cloaking device or via RCP120 + if ((g_Vars.currentplayer->itemswitch & 0x00000040) + || (g_Vars.currentplayer->weaponnum == WEAPON_RCP120 + && (g_Vars.currentplayer->itemswitch & 0x00000080))) { + if ((chr->hidden & CHRHFLAG_CLOAKED) == 0 && chr->cloakpause < 1) { + chrCloak(chr, true); + } + } else { + if ((g_Vars.currentplayer->itemswitch & 0x00000040) == 0 + && (chr->hidden & CHRHFLAG_CLOAKED)) { + chrUncloak(chr, true); + } + } + + setCurrentPlayerNum(prevplayernum); + } + + // Update cloakfade + if (chr->hidden & CHRHFLAG_CLOAKED) { + if (chr->cloakfadefinished == false) { + fadefrac = chr->cloakfadefrac + (g_Vars.lvupdate240 * 5) / 8; + + if (fadefrac >= 128) { + chr->cloakfadefinished = true; + chr->cloakfadefrac = 0; + } else { + chr->cloakfadefrac = fadefrac; + } + } else { + s32 tmp = chr->cloakfadefrac + g_Vars.lvupdate240_60; + chr->cloakfadefrac = tmp % 127; + } + } else { + if (chr->cloakfadefinished == true) { + chr->cloakfadefinished = false; + + fVar14 = 1.0f - cosf((chr->cloakfadefrac / 127.0f + chr->cloakfadefrac / 127.0f) * M_PI); + chr->cloakfadefrac = (254 - (s32)(fVar14 * 20.0f * 0.5f)) / 2; + } + + if (chr->cloakfadefrac > 0) { + fadefrac = chr->cloakfadefrac - (g_Vars.lvupdate240 * 5) / 8; + + if (fadefrac < 0) { + fadefrac = 0; + } + + chr->cloakfadefrac = fadefrac; + } + } +} GLOBAL_ASM( glabel func0f022be4 @@ -5408,7 +5150,7 @@ glabel var7f1a87d8 /* f0232f8: 00000000 */ sll $zero,$zero,0x0 /* f0232fc: e60602dc */ swc1 $f6,0x2dc($s0) .L0f023300: -/* f023300: 0fc08989 */ jal func0f022624 +/* f023300: 0fc08989 */ jal chrUpdateCloak /* f023304: 02002025 */ or $a0,$s0,$zero /* f023308: 0fc08b58 */ jal func0f022d60 /* f02330c: 02002025 */ or $a0,$s0,$zero diff --git a/src/game/game_011110.c b/src/game/game_011110.c index d58d9a62b..0aabd979c 100644 --- a/src/game/game_011110.c +++ b/src/game/game_011110.c @@ -659,7 +659,7 @@ glabel var7f1a827c /* f011b4c: 118d0004 */ beq $t4,$t5,.L0f011b60 /* f011b50: 00000000 */ sll $zero,$zero,0x0 /* f011b54: 8e040004 */ lw $a0,0x4($s0) -/* f011b58: 0fc2a58a */ jal currentPlayerGiveAmmo +/* f011b58: 0fc2a58a */ jal currentPlayerSetAmmoQuantity /* f011b5c: 8e050008 */ lw $a1,0x8($s0) .L0f011b60: /* f011b60: 10000049 */ beqz $zero,.L0f011c88 @@ -756,7 +756,7 @@ glabel var7f1a827c /* f011cb0: 0fc44762 */ jal currentPlayerGiveWeapon /* f011cb4: 24040009 */ addiu $a0,$zero,0x9 /* f011cb8: 2404000a */ addiu $a0,$zero,0xa -/* f011cbc: 0fc2a58a */ jal currentPlayerGiveAmmo +/* f011cbc: 0fc2a58a */ jal currentPlayerSetAmmoQuantity /* f011cc0: 24050050 */ addiu $a1,$zero,0x50 .L0f011cc4: /* f011cc4: 0fc41b99 */ jal cheatIsActive @@ -766,7 +766,7 @@ glabel var7f1a827c /* f011cd4: 0fc44762 */ jal currentPlayerGiveWeapon /* f011cd8: 24040016 */ addiu $a0,$zero,0x16 /* f011cdc: 24040006 */ addiu $a0,$zero,0x6 -/* f011ce0: 0fc2a58a */ jal currentPlayerGiveAmmo +/* f011ce0: 0fc2a58a */ jal currentPlayerSetAmmoQuantity /* f011ce4: 24050050 */ addiu $a1,$zero,0x50 .L0f011ce8: /* f011ce8: 0fc41b99 */ jal cheatIsActive @@ -776,7 +776,7 @@ glabel var7f1a827c /* f011cf8: 0fc44762 */ jal currentPlayerGiveWeapon /* f011cfc: 24040031 */ addiu $a0,$zero,0x31 /* f011d00: 24040014 */ addiu $a0,$zero,0x14 -/* f011d04: 0fc2a58a */ jal currentPlayerGiveAmmo +/* f011d04: 0fc2a58a */ jal currentPlayerSetAmmoQuantity /* f011d08: 24051c20 */ addiu $a1,$zero,0x1c20 .L0f011d0c: /* f011d0c: 0fc41b99 */ jal cheatIsActive @@ -800,7 +800,7 @@ glabel var7f1a827c /* f011d4c: 0fc44762 */ jal currentPlayerGiveWeapon /* f011d50: 24040018 */ addiu $a0,$zero,0x18 /* f011d54: 24040008 */ addiu $a0,$zero,0x8 -/* f011d58: 0fc2a58a */ jal currentPlayerGiveAmmo +/* f011d58: 0fc2a58a */ jal currentPlayerSetAmmoQuantity /* f011d5c: 2405000a */ addiu $a1,$zero,0xa .L0f011d60: /* f011d60: 0fc41b99 */ jal cheatIsActive @@ -810,7 +810,7 @@ glabel var7f1a827c /* f011d70: 0fc44762 */ jal currentPlayerGiveWeapon /* f011d74: 24040015 */ addiu $a0,$zero,0x15 /* f011d78: 24040004 */ addiu $a0,$zero,0x4 -/* f011d7c: 0fc2a58a */ jal currentPlayerGiveAmmo +/* f011d7c: 0fc2a58a */ jal currentPlayerSetAmmoQuantity /* f011d80: 240500c8 */ addiu $a1,$zero,0xc8 .L0f011d84: /* f011d84: 0fc41b99 */ jal cheatIsActive @@ -827,10 +827,10 @@ glabel var7f1a827c /* f011dac: 0fc44762 */ jal currentPlayerGiveWeapon /* f011db0: 24040012 */ addiu $a0,$zero,0x12 /* f011db4: 24040004 */ addiu $a0,$zero,0x4 -/* f011db8: 0fc2a58a */ jal currentPlayerGiveAmmo +/* f011db8: 0fc2a58a */ jal currentPlayerSetAmmoQuantity /* f011dbc: 240500c8 */ addiu $a1,$zero,0xc8 /* f011dc0: 2404000b */ addiu $a0,$zero,0xb -/* f011dc4: 0fc2a58a */ jal currentPlayerGiveAmmo +/* f011dc4: 0fc2a58a */ jal currentPlayerSetAmmoQuantity /* f011dc8: 24050014 */ addiu $a1,$zero,0x14 .L0f011dcc: /* f011dcc: 0fc41b99 */ jal cheatIsActive @@ -840,7 +840,7 @@ glabel var7f1a827c /* f011ddc: 0fc44762 */ jal currentPlayerGiveWeapon /* f011de0: 2404000e */ addiu $a0,$zero,0xe /* f011de4: 24040002 */ addiu $a0,$zero,0x2 -/* f011de8: 0fc2a58a */ jal currentPlayerGiveAmmo +/* f011de8: 0fc2a58a */ jal currentPlayerSetAmmoQuantity /* f011dec: 240500c8 */ addiu $a1,$zero,0xc8 .L0f011df0: /* f011df0: 0fc41b99 */ jal cheatIsActive @@ -850,7 +850,7 @@ glabel var7f1a827c /* f011e00: 0fc44762 */ jal currentPlayerGiveWeapon /* f011e04: 24040007 */ addiu $a0,$zero,0x7 /* f011e08: 24040001 */ addiu $a0,$zero,0x1 -/* f011e0c: 0fc2a58a */ jal currentPlayerGiveAmmo +/* f011e0c: 0fc2a58a */ jal currentPlayerSetAmmoQuantity /* f011e10: 240500c8 */ addiu $a1,$zero,0xc8 .L0f011e14: /* f011e14: 0fc41b99 */ jal cheatIsActive @@ -862,7 +862,7 @@ glabel var7f1a827c /* f011e2c: 10400009 */ beqz $v0,.L0f011e54 /* f011e30: 24040016 */ addiu $a0,$zero,0x16 .L0f011e34: -/* f011e34: 0fc2a58a */ jal currentPlayerGiveAmmo +/* f011e34: 0fc2a58a */ jal currentPlayerSetAmmoQuantity /* f011e38: 24050004 */ addiu $a1,$zero,0x4 /* f011e3c: 0fc41b99 */ jal cheatIsActive /* f011e40: 24040021 */ addiu $a0,$zero,0x21 @@ -878,7 +878,7 @@ glabel var7f1a827c /* f011e64: 0fc44762 */ jal currentPlayerGiveWeapon /* f011e68: 24040024 */ addiu $a0,$zero,0x24 /* f011e6c: 24040001 */ addiu $a0,$zero,0x1 -/* f011e70: 0fc2a58a */ jal currentPlayerGiveAmmo +/* f011e70: 0fc2a58a */ jal currentPlayerSetAmmoQuantity /* f011e74: 240500c8 */ addiu $a1,$zero,0xc8 .L0f011e78: /* f011e78: 0fc41b99 */ jal cheatIsActive @@ -888,7 +888,7 @@ glabel var7f1a827c /* f011e88: 0fc44762 */ jal currentPlayerGiveWeapon /* f011e8c: 24040025 */ addiu $a0,$zero,0x25 /* f011e90: 24040004 */ addiu $a0,$zero,0x4 -/* f011e94: 0fc2a58a */ jal currentPlayerGiveAmmo +/* f011e94: 0fc2a58a */ jal currentPlayerSetAmmoQuantity /* f011e98: 240500c8 */ addiu $a1,$zero,0xc8 .L0f011e9c: /* f011e9c: 0fc41b99 */ jal cheatIsActive @@ -898,7 +898,7 @@ glabel var7f1a827c /* f011eac: 0fc44762 */ jal currentPlayerGiveWeapon /* f011eb0: 24040026 */ addiu $a0,$zero,0x26 /* f011eb4: 24040002 */ addiu $a0,$zero,0x2 -/* f011eb8: 0fc2a58a */ jal currentPlayerGiveAmmo +/* f011eb8: 0fc2a58a */ jal currentPlayerSetAmmoQuantity /* f011ebc: 240500c8 */ addiu $a1,$zero,0xc8 .L0f011ec0: /* f011ec0: 0fc41b99 */ jal cheatIsActive @@ -908,7 +908,7 @@ glabel var7f1a827c /* f011ed0: 0fc44762 */ jal currentPlayerGiveWeapon /* f011ed4: 24040027 */ addiu $a0,$zero,0x27 /* f011ed8: 24040004 */ addiu $a0,$zero,0x4 -/* f011edc: 0fc2a58a */ jal currentPlayerGiveAmmo +/* f011edc: 0fc2a58a */ jal currentPlayerSetAmmoQuantity /* f011ee0: 240500c8 */ addiu $a1,$zero,0xc8 .L0f011ee4: /* f011ee4: 0fc41b99 */ jal cheatIsActive @@ -918,7 +918,7 @@ glabel var7f1a827c /* f011ef4: 0fc44762 */ jal currentPlayerGiveWeapon /* f011ef8: 24040028 */ addiu $a0,$zero,0x28 /* f011efc: 24040002 */ addiu $a0,$zero,0x2 -/* f011f00: 0fc2a58a */ jal currentPlayerGiveAmmo +/* f011f00: 0fc2a58a */ jal currentPlayerSetAmmoQuantity /* f011f04: 240500c8 */ addiu $a1,$zero,0xc8 .L0f011f08: /* f011f08: 0fc41b99 */ jal cheatIsActive @@ -928,7 +928,7 @@ glabel var7f1a827c /* f011f18: 0fc44762 */ jal currentPlayerGiveWeapon /* f011f1c: 24040029 */ addiu $a0,$zero,0x29 /* f011f20: 24040002 */ addiu $a0,$zero,0x2 -/* f011f24: 0fc2a58a */ jal currentPlayerGiveAmmo +/* f011f24: 0fc2a58a */ jal currentPlayerSetAmmoQuantity /* f011f28: 240500c8 */ addiu $a1,$zero,0xc8 .L0f011f2c: /* f011f2c: 0fc41b99 */ jal cheatIsActive @@ -938,7 +938,7 @@ glabel var7f1a827c /* f011f3c: 0fc44762 */ jal currentPlayerGiveWeapon /* f011f40: 2404002a */ addiu $a0,$zero,0x2a /* f011f44: 24040004 */ addiu $a0,$zero,0x4 -/* f011f48: 0fc2a58a */ jal currentPlayerGiveAmmo +/* f011f48: 0fc2a58a */ jal currentPlayerSetAmmoQuantity /* f011f4c: 240500c8 */ addiu $a1,$zero,0xc8 .L0f011f50: /* f011f50: 0fc41b99 */ jal cheatIsActive @@ -948,7 +948,7 @@ glabel var7f1a827c /* f011f60: 0fc44762 */ jal currentPlayerGiveWeapon /* f011f64: 2404002b */ addiu $a0,$zero,0x2b /* f011f68: 24040002 */ addiu $a0,$zero,0x2 -/* f011f6c: 0fc2a58a */ jal currentPlayerGiveAmmo +/* f011f6c: 0fc2a58a */ jal currentPlayerSetAmmoQuantity /* f011f70: 240500c8 */ addiu $a1,$zero,0xc8 /* f011f74: 8fa90080 */ lw $t1,0x80($sp) .L0f011f78: @@ -1376,7 +1376,7 @@ glabel var7f1a827c // break; // case INTROTYPE_AMMO: // if (cmd[3] == 0 && g_Vars.currentplayer != g_Vars.anti) { -// currentPlayerGiveAmmo(cmd[1], cmd[2]); +// currentPlayerSetAmmoQuantity(cmd[1], cmd[2]); // } // cmd += 4; // break; @@ -1421,17 +1421,17 @@ glabel var7f1a827c // // if (cheatIsActive(CHEAT_TRENTSMAGNUM)) { // currentPlayerGiveWeapon(WEAPON_DY357LX); -// currentPlayerGiveAmmo(AMMOTYPE_MAGNUM, 80); +// currentPlayerSetAmmoQuantity(AMMOTYPE_MAGNUM, 80); // } // // if (cheatIsActive(CHEAT_FARSIGHT)) { // currentPlayerGiveWeapon(WEAPON_FARSIGHTXR20); -// currentPlayerGiveAmmo(AMMOTYPE_FARSIGHT, 80); +// currentPlayerSetAmmoQuantity(AMMOTYPE_FARSIGHT, 80); // } // // if (cheatIsActive(CHEAT_CLOAKINGDEVICE)) { // currentPlayerGiveWeapon(WEAPON_CLOAKINGDEVICE); -// currentPlayerGiveAmmo(AMMOTYPE_CLOAK, 7200); +// currentPlayerSetAmmoQuantity(AMMOTYPE_CLOAK, 7200); // } // // if (cheatIsActive(CHEAT_PERFECTDARKNESS)) { @@ -1444,12 +1444,12 @@ glabel var7f1a827c // // if (cheatIsActive(CHEAT_ROCKETLAUNCHER)) { // currentPlayerGiveWeapon(WEAPON_ROCKETLAUNCHER); -// currentPlayerGiveAmmo(AMMOTYPE_ROCKET, 10); +// currentPlayerSetAmmoQuantity(AMMOTYPE_ROCKET, 10); // } // // if (cheatIsActive(CHEAT_SNIPERRIFLE)) { // currentPlayerGiveWeapon(WEAPON_SNIPERRIFLE); -// currentPlayerGiveAmmo(AMMOTYPE_RIFLE, 200); +// currentPlayerSetAmmoQuantity(AMMOTYPE_RIFLE, 200); // } // // if (cheatIsActive(CHEAT_XRAYSCANNER)) { @@ -1458,22 +1458,22 @@ glabel var7f1a827c // // if (cheatIsActive(CHEAT_SUPERDRAGON)) { // currentPlayerGiveWeapon(WEAPON_SUPERDRAGON); -// currentPlayerGiveAmmo(AMMOTYPE_RIFLE, 200); -// currentPlayerGiveAmmo(AMMOTYPE_DEVASTATOR, 20); +// currentPlayerSetAmmoQuantity(AMMOTYPE_RIFLE, 200); +// currentPlayerSetAmmoQuantity(AMMOTYPE_DEVASTATOR, 20); // } // // if (cheatIsActive(CHEAT_LAPTOPGUN)) { // currentPlayerGiveWeapon(WEAPON_LAPTOPGUN); -// currentPlayerGiveAmmo(AMMOTYPE_SMG, 200); +// currentPlayerSetAmmoQuantity(AMMOTYPE_SMG, 200); // } // // if (cheatIsActive(CHEAT_PHOENIX)) { // currentPlayerGiveWeapon(WEAPON_PHOENIX); -// currentPlayerGiveAmmo(AMMOTYPE_PISTOL, 200); +// currentPlayerSetAmmoQuantity(AMMOTYPE_PISTOL, 200); // } // // if (cheatIsActive(CHEAT_PSYCHOSISGUN) || cheatIsActive(CHEAT_ALLGUNS)) { -// currentPlayerGiveAmmo(AMMOTYPE_PSYCHOSIS, 4); +// currentPlayerSetAmmoQuantity(AMMOTYPE_PSYCHOSIS, 4); // // if (cheatIsActive(CHEAT_PSYCHOSISGUN)) { // currentPlayerGiveWeapon(WEAPON_PSYCHOSISGUN); @@ -1482,42 +1482,42 @@ glabel var7f1a827c // // if (cheatIsActive(CHEAT_PP9I)) { // currentPlayerGiveWeapon(WEAPON_PP9I); -// currentPlayerGiveAmmo(AMMOTYPE_PISTOL, 200); +// currentPlayerSetAmmoQuantity(AMMOTYPE_PISTOL, 200); // } // // if (cheatIsActive(CHEAT_CC13)) { // currentPlayerGiveWeapon(WEAPON_CC13); -// currentPlayerGiveAmmo(AMMOTYPE_RIFLE, 200); +// currentPlayerSetAmmoQuantity(AMMOTYPE_RIFLE, 200); // } // // if (cheatIsActive(CHEAT_KL01313)) { // currentPlayerGiveWeapon(WEAPON_KL01313); -// currentPlayerGiveAmmo(AMMOTYPE_SMG, 200); +// currentPlayerSetAmmoQuantity(AMMOTYPE_SMG, 200); // } // // if (cheatIsActive(CHEAT_KF7SPECIAL)) { // currentPlayerGiveWeapon(WEAPON_KF7SPECIAL); -// currentPlayerGiveAmmo(AMMOTYPE_RIFLE, 200); +// currentPlayerSetAmmoQuantity(AMMOTYPE_RIFLE, 200); // } // // if (cheatIsActive(CHEAT_ZZT)) { // currentPlayerGiveWeapon(WEAPON_ZZT); -// currentPlayerGiveAmmo(AMMOTYPE_SMG, 200); +// currentPlayerSetAmmoQuantity(AMMOTYPE_SMG, 200); // } // // if (cheatIsActive(CHEAT_DMC)) { // currentPlayerGiveWeapon(WEAPON_DMC); -// currentPlayerGiveAmmo(AMMOTYPE_SMG, 200); +// currentPlayerSetAmmoQuantity(AMMOTYPE_SMG, 200); // } // // if (cheatIsActive(CHEAT_AR53)) { // currentPlayerGiveWeapon(WEAPON_AR53); -// currentPlayerGiveAmmo(AMMOTYPE_RIFLE, 200); +// currentPlayerSetAmmoQuantity(AMMOTYPE_RIFLE, 200); // } // // if (cheatIsActive(CHEAT_RCP45)) { // currentPlayerGiveWeapon(WEAPON_RCP45); -// currentPlayerGiveAmmo(AMMOTYPE_SMG, 200); +// currentPlayerSetAmmoQuantity(AMMOTYPE_SMG, 200); // } // // if (!hasdefaultweapon) { diff --git a/src/game/game_097ba0.c b/src/game/game_097ba0.c index ab9f847ee..ee60f461d 100644 --- a/src/game/game_097ba0.c +++ b/src/game/game_097ba0.c @@ -20977,8 +20977,8 @@ void currentPlayerTickInventory(bool triggeron) g_Vars.currentplayer->unk1583_00 = 0; g_Vars.currentplayer->itemswitch = 0; chr->cloakpause = 0; - chr->cloakfade_00 = 0; - chr->cloakfade_06 = 0; + chr->cloakfadefrac = 0; + chr->cloakfadefinished = false; chr->hidden &= ~CHRHFLAG_CLOAKED; } @@ -21233,7 +21233,7 @@ struct ammotype g_AmmoTypes[] = { }; GLOBAL_ASM( -glabel currentPlayerGiveAmmo +glabel currentPlayerSetAmmoQuantity /* f0a9628: 27bdffc8 */ addiu $sp,$sp,-56 /* f0a962c: afb20020 */ sw $s2,0x20($sp) /* f0a9630: afb1001c */ sw $s1,0x1c($sp) @@ -21463,7 +21463,7 @@ void currentPlayerGiveUnlimitedAmmo(bool force) } if (give) { - currentPlayerGiveAmmo(i, g_AmmoTypes[i].capacity); + currentPlayerSetAmmoQuantity(i, g_AmmoTypes[i].capacity); } } } @@ -21506,7 +21506,7 @@ void currentPlayerGiveAmmoForWeapon(u32 weaponnum, u32 func, u32 quantity) struct inventory_ammo *ammo = weapon->ammos[func]; if (ammo) { - currentPlayerGiveAmmo(ammo->type, quantity); + currentPlayerSetAmmoQuantity(ammo->type, quantity); } } } diff --git a/src/game/game_0b63b0.c b/src/game/game_0b63b0.c index 96143bbce..83ec24edd 100644 --- a/src/game/game_0b63b0.c +++ b/src/game/game_0b63b0.c @@ -1627,7 +1627,7 @@ glabel var7f1ad568 /* f0b76a4: 15a00004 */ bnez $t5,.L0f0b76b8 /* f0b76a8: 00000000 */ sll $zero,$zero,0x0 /* f0b76ac: 8e240004 */ lw $a0,0x4($s1) -/* f0b76b0: 0fc2a58a */ jal currentPlayerGiveAmmo +/* f0b76b0: 0fc2a58a */ jal currentPlayerSetAmmoQuantity /* f0b76b4: 8e250008 */ lw $a1,0x8($s1) .L0f0b76b8: /* f0b76b8: 1000000a */ beqz $zero,.L0f0b76e4 @@ -11168,10 +11168,10 @@ glabel var7f1ad6ac // // chrSetMaxDamage(chr, 4); // -// chr->cloakfade_06 = true; +// chr->cloakfadefinished = true; // chr->chrflags |= CHRCFLAG_00040000; // chr->hidden |= CHRHFLAG_CLOAKED; -// chr->cloakfade_00 = 0; +// chr->cloakfadefrac = 0; // // chrGiveWeapon(chr, MODEL_CHRFALCON2, WEAPON_FALCON2, 0); // } @@ -11214,10 +11214,10 @@ glabel var7f1ad6ac // chrAddHealth(chr, 40); // } // -// chr->cloakfade_06 = true; +// chr->cloakfadefinished = true; // chr->chrflags |= CHRCFLAG_00040000; // chr->hidden |= CHRHFLAG_PSYCHOSISED; -// chr->cloakfade_00 = 0; +// chr->cloakfadefrac = 0; // // chrSetMaxDamage(chr, 20); // } @@ -11262,10 +11262,10 @@ glabel var7f1ad6ac // // chrSetMaxDamage(chr, 10); // -// chr->cloakfade_06 = true; +// chr->cloakfadefinished = true; // chr->chrflags |= CHRCFLAG_00040000; // chr->hidden |= CHRHFLAG_CLOAKED; -// chr->cloakfade_00 = 0; +// chr->cloakfadefrac = 0; // // chrGiveWeapon(chr, MODEL_CHRAVENGER, WEAPON_K7AVENGER, 0); // } @@ -11310,10 +11310,10 @@ glabel var7f1ad6ac // // chrSetMaxDamage(chr, 10); // -// chr->cloakfade_06 = true; +// chr->cloakfadefinished = true; // chr->chrflags |= CHRCFLAG_00040000; // chr->hidden |= CHRHFLAG_CLOAKED; -// chr->cloakfade_00 = 0; +// chr->cloakfadefrac = 0; // // chrGiveWeapon(chr, MODEL_CHRDY357TRENT, WEAPON_DY357LX, 0); // chrGiveWeapon(chr, MODEL_CHRDY357, WEAPON_DY357MAGNUM, 0x10000000); @@ -11359,10 +11359,10 @@ glabel var7f1ad6ac // // chrSetMaxDamage(chr, 10); // -// chr->cloakfade_06 = true; +// chr->cloakfadefinished = true; // chr->chrflags |= CHRCFLAG_00040000; // chr->hidden |= CHRHFLAG_CLOAKED; -// chr->cloakfade_00 = 0; +// chr->cloakfadefrac = 0; // // chrGiveWeapon(chr, MODEL_CHRRCP120, WEAPON_RCP120, 0); // } @@ -14385,7 +14385,7 @@ glabel var7f1ad710 /* f0c2950: 01856821 */ addu $t5,$t4,$a1 /* f0c2954: 14ed0004 */ bne $a3,$t5,.L0f0c2968 /* f0c2958: 00000000 */ sll $zero,$zero,0x0 -/* f0c295c: 0fc08989 */ jal func0f022624 +/* f0c295c: 0fc08989 */ jal chrUpdateCloak /* f0c2960: 02002025 */ or $a0,$s0,$zero /* f0c2964: 8e2619c8 */ lw $a2,0x19c8($s1) .L0f0c2968: diff --git a/src/game/game_190260.c b/src/game/game_190260.c index 19d1f10fc..c11bf2339 100644 --- a/src/game/game_190260.c +++ b/src/game/game_190260.c @@ -320,7 +320,7 @@ glabel mpChrReset // aibot->unk04c_02 = 0; // aibot->unk04c_01 = 1; // aibot->unk09c_00 = 0; -// aibot->unk04c_06 = 0; +// aibot->cloakdeviceenabled = false; // aibot->unk04c_04 = 0; // aibot->unk04c_03 = 0; // aibot->unk09c_01 = 0; @@ -340,7 +340,7 @@ glabel mpChrReset // aibot->unk04e = 0; // aibot->unk044 = 0; // aibot->unk0a0 = 0; -// aibot->unk09c_02 = 0; +// aibot->rcp120cloakenabled = false; // aibot->unk064 = 0; // aibot->unk04c_00 = 0; // aibot->unk048 = -1; diff --git a/src/game/game_19c990.c b/src/game/game_19c990.c index c9043571c..99a7206a7 100644 --- a/src/game/game_19c990.c +++ b/src/game/game_19c990.c @@ -2030,12 +2030,12 @@ glabel func0f19e900 /* f19e948: 8fa40020 */ lw $a0,0x20($sp) /* f19e94c: 14a10005 */ bne $a1,$at,.L0f19e964 /* f19e950: 00000000 */ sll $zero,$zero,0x0 -/* f19e954: 0fc2a58a */ jal currentPlayerGiveAmmo +/* f19e954: 0fc2a58a */ jal currentPlayerSetAmmoQuantity /* f19e958: 8fa5001c */ lw $a1,0x1c($sp) /* f19e95c: 10000004 */ beqz $zero,.L0f19e970 /* f19e960: 8fae0028 */ lw $t6,0x28($sp) .L0f19e964: -/* f19e964: 0fc2a58a */ jal currentPlayerGiveAmmo +/* f19e964: 0fc2a58a */ jal currentPlayerSetAmmoQuantity /* f19e968: 8fa40020 */ lw $a0,0x20($sp) /* f19e96c: 8fae0028 */ lw $t6,0x28($sp) .L0f19e970: @@ -2048,12 +2048,12 @@ glabel func0f19e900 /* f19e988: 2404000b */ addiu $a0,$zero,0xb /* f19e98c: 14a10005 */ bne $a1,$at,.L0f19e9a4 /* f19e990: 00000000 */ sll $zero,$zero,0x0 -/* f19e994: 0fc2a58a */ jal currentPlayerGiveAmmo +/* f19e994: 0fc2a58a */ jal currentPlayerSetAmmoQuantity /* f19e998: 8fa5001c */ lw $a1,0x1c($sp) /* f19e99c: 10000004 */ beqz $zero,.L0f19e9b0 /* f19e9a0: 8fbf0014 */ lw $ra,0x14($sp) .L0f19e9a4: -/* f19e9a4: 0fc2a58a */ jal currentPlayerGiveAmmo +/* f19e9a4: 0fc2a58a */ jal currentPlayerSetAmmoQuantity /* f19e9a8: 2404000b */ addiu $a0,$zero,0xb /* f19e9ac: 8fbf0014 */ lw $ra,0x14($sp) .L0f19e9b0: @@ -3325,14 +3325,14 @@ glabel var7f1b94e4 /* f19fdbc: 00000000 */ sll $zero,$zero,0x0 /* f19fdc0: a6a00476 */ sh $zero,0x476($s5) .L0f19fdc4: -/* f19fdc4: 0fc2a58a */ jal currentPlayerGiveAmmo +/* f19fdc4: 0fc2a58a */ jal currentPlayerSetAmmoQuantity /* f19fdc8: 02202025 */ or $a0,$s1,$zero /* f19fdcc: 10000006 */ beqz $zero,.L0f19fde8 /* f19fdd0: 24010012 */ addiu $at,$zero,0x12 .L0f19fdd4: /* f19fdd4: 14410003 */ bne $v0,$at,.L0f19fde4 /* f19fdd8: 02202025 */ or $a0,$s1,$zero -/* f19fddc: 0fc2a58a */ jal currentPlayerGiveAmmo +/* f19fddc: 0fc2a58a */ jal currentPlayerSetAmmoQuantity /* f19fde0: 02002825 */ or $a1,$s0,$zero .L0f19fde4: /* f19fde4: 24010012 */ addiu $at,$zero,0x12 @@ -3359,14 +3359,14 @@ glabel var7f1b94e4 /* f19fe34: 00000000 */ sll $zero,$zero,0x0 /* f19fe38: a6a00478 */ sh $zero,0x478($s5) .L0f19fe3c: -/* f19fe3c: 0fc2a58a */ jal currentPlayerGiveAmmo +/* f19fe3c: 0fc2a58a */ jal currentPlayerSetAmmoQuantity /* f19fe40: 2404000b */ addiu $a0,$zero,0xb /* f19fe44: 10000006 */ beqz $zero,.L0f19fe60 /* f19fe48: a2a0045a */ sb $zero,0x45a($s5) .L0f19fe4c: /* f19fe4c: 14610003 */ bne $v1,$at,.L0f19fe5c /* f19fe50: 2404000b */ addiu $a0,$zero,0xb -/* f19fe54: 0fc2a58a */ jal currentPlayerGiveAmmo +/* f19fe54: 0fc2a58a */ jal currentPlayerSetAmmoQuantity /* f19fe58: 02002825 */ or $a1,$s0,$zero .L0f19fe5c: /* f19fe5c: a2a0045a */ sb $zero,0x45a($s5) @@ -4904,7 +4904,7 @@ void dtRestorePlayer(void) g_DeviceTrainingData.obj = NULL; if (dtGetWeaponByDeviceIndex(func0f1a1d68(var80088ad8)) == WEAPON_ECMMINE) { - currentPlayerGiveAmmo(AMMOTYPE_ECM_MINE, 0); + currentPlayerSetAmmoQuantity(AMMOTYPE_ECM_MINE, 0); } if (g_Vars.currentplayer->eyespy) { @@ -5002,7 +5002,7 @@ void dtEnd(void) { g_DeviceTrainingData.intraining = false; dtRestorePlayer(); - currentPlayerGiveAmmo(AMMOTYPE_CLOAK, 0); + currentPlayerSetAmmoQuantity(AMMOTYPE_CLOAK, 0); chrSetStageFlag(NULL, STAGEFLAG_CI_DEVICE_ABORTING); chrUnsetStageFlag(NULL, STAGEFLAG_CI_TRIGGER_DEVICE_FAILURE); chrUnsetStageFlag(NULL, ciGetStageFlagByDeviceIndex(func0f1a1d68(var80088ad8))); diff --git a/src/game/propobj.c b/src/game/propobj.c index 5d581a725..da87b52a9 100644 --- a/src/game/propobj.c +++ b/src/game/propobj.c @@ -38719,7 +38719,7 @@ glabel func0f088028 /* f088070: 02002025 */ or $a0,$s0,$zero /* f088074: 8fb8002c */ lw $t8,0x2c($sp) /* f088078: 02002025 */ or $a0,$s0,$zero -/* f08807c: 0fc2a58a */ jal currentPlayerGiveAmmo +/* f08807c: 0fc2a58a */ jal currentPlayerSetAmmoQuantity /* f088080: 00582821 */ addu $a1,$v0,$t8 /* f088084: 8fb90034 */ lw $t9,0x34($sp) /* f088088: 02002025 */ or $a0,$s0,$zero @@ -39414,7 +39414,7 @@ glabel var7f1aae70 /* f088cec: 00c2082a */ slt $at,$a2,$v0 /* f088cf0: 1020000b */ beqz $at,.L0f088d20 /* f088cf4: 00a92821 */ addu $a1,$a1,$t1 -/* f088cf8: 0fc2a58a */ jal currentPlayerGiveAmmo +/* f088cf8: 0fc2a58a */ jal currentPlayerSetAmmoQuantity /* f088cfc: 8fa4006c */ lw $a0,0x6c($sp) /* f088d00: 8faa0070 */ lw $t2,0x70($sp) /* f088d04: 8fab00a4 */ lw $t3,0xa4($sp) @@ -39446,7 +39446,7 @@ glabel var7f1aae70 /* f088d64: 0fc2a5dc */ jal ammoGetQuantity /* f088d68: 2404000b */ addiu $a0,$zero,0xb /* f088d6c: 2404000b */ addiu $a0,$zero,0xb -/* f088d70: 0fc2a58a */ jal currentPlayerGiveAmmo +/* f088d70: 0fc2a58a */ jal currentPlayerSetAmmoQuantity /* f088d74: 24450005 */ addiu $a1,$v0,0x5 /* f088d78: 8fae0070 */ lw $t6,0x70($sp) /* f088d7c: 8faf00a4 */ lw $t7,0xa4($sp) diff --git a/src/include/game/chr/chr.h b/src/include/game/chr/chr.h index 5c387ae26..a9c0f8217 100644 --- a/src/include/game/chr/chr.h +++ b/src/include/game/chr/chr.h @@ -20,7 +20,7 @@ u32 func0f02143c(void); void func0f021fa8(struct chrdata *chr, struct coord *pos, s16 *room); void func0f0220ec(struct chrdata *chr, s32 arg1, s32 arg2); u32 func0f022214(void); -u32 func0f022624(void); +void chrUpdateCloak(struct chrdata *chr); u32 func0f022be4(void); u32 func0f022cc8(void); u32 func0f022d60(void); diff --git a/src/include/game/game_097ba0.h b/src/include/game/game_097ba0.h index 2dc49637c..17691b1bb 100644 --- a/src/include/game/game_097ba0.h +++ b/src/include/game/game_097ba0.h @@ -151,7 +151,7 @@ void func0f0a9464(struct coord *coord); void func0f0a9494(u32 operation); void func0f0a94d0(u32 operation, struct coord *a, struct coord *b); void func0f0a95ec(u32 arg0, bool enable); -void currentPlayerGiveAmmo(s32 ammotype, s32 quantity); +void currentPlayerSetAmmoQuantity(s32 ammotype, s32 quantity); s32 ammoGetQuantity(u32 type); s32 currentPlayerGetAmmoCount(s32 ammotype); u32 ammotypeGetMaxCapacity(u32 ammotype); diff --git a/src/include/game/game_1999b0.h b/src/include/game/game_1999b0.h index 86b2eb401..ccb6e1897 100644 --- a/src/include/game/game_1999b0.h +++ b/src/include/game/game_1999b0.h @@ -3,10 +3,10 @@ #include #include "types.h" -u32 func0f1999b0(void); +s32 func0f1999b0(u32 weaponnum, u32 arg1); u32 func0f1999f8(void); u32 func0f199a40(void); -u32 func0f199be4(void); +s32 func0f199be4(struct aibot *aibot, u32 weaponnum, u32 arg2, u32 arg3); u32 func0f199cb8(void); u32 func0f199d70(void); void func0f199e3c(struct aibot *aibot, u32 weaponnum, bool proxy, u32 qty); diff --git a/src/include/types.h b/src/include/types.h index 54a3e50f3..84b4e25c5 100644 --- a/src/include/types.h +++ b/src/include/types.h @@ -166,7 +166,7 @@ struct aibot { /*0x018*/ u32 unk018; /*0x01c*/ struct aibotammotype *ammotypes; /*0x020*/ u32 weaponnum; - /*0x024*/ u32 unk024; + /*0x024*/ s32 unk024; /*0x028*/ u32 unk028; /*0x02c*/ u16 unk02c; /*0x02e*/ u16 unk02e; @@ -185,7 +185,7 @@ struct aibot { /*0x04c*/ u8 unk04c_03 : 1; /*0x04c*/ u8 unk04c_04 : 1; /*0x04c*/ u8 unk04c_05 : 1; - /*0x04c*/ u8 unk04c_06 : 1; + /*0x04c*/ u8 cloakdeviceenabled : 1; /*0x04c*/ u8 unk04c_07 : 1; /*0x04d*/ u8 unk04d; /*0x04e*/ u8 unk04e; @@ -222,7 +222,7 @@ struct aibot { /*0x098*/ f32 unk098; /*0x09c*/ u8 unk09c_00 : 1; /*0x09c*/ u8 unk09c_01 : 1; - /*0x09c*/ u8 unk09c_02 : 1; + /*0x09c*/ u8 rcp120cloakenabled : 1; /*0x09c*/ u8 unk09c_03 : 1; /*0x09c*/ u8 unk09c_04 : 1; /*0x09c*/ u8 unk09c_05 : 1; @@ -336,7 +336,13 @@ struct aibot { /*0x2b8*/ u32 unk2b8; /*0x2bc*/ u32 unk2bc; /*0x2c0*/ u32 unk2c0; + + /** + * Some kind of cloak counter? Ticks up while cloaked. Over 1 causes RCP120 + * ammo to be removed, and when this happens this value is decreased. + */ /*0x2c4*/ f32 unk2c4; + /*0x2c8*/ u32 unk2c8; /*0x2cc*/ u32 unk2cc; /*0x2d0*/ u32 unk2d0; @@ -689,11 +695,16 @@ struct chrdata { /*0x2c8*/ struct coord runfrompos; /*0x2d4*/ struct aibot *aibot; /*0x2d8*/ s16 blurdrugamount; - /*0x2da*/ u16 cloakpause; + + // Cloakpause is set to a positive value when shooting, then decreases to + // zero over a couple of seconds. When zero is reached, the cloak is + // applied again. + /*0x2da*/ s16 cloakpause; + /*0x2dc*/ f32 drugheadsway; /*0x2e0*/ u8 drugheadcount; - /*0x2e1*/ u8 cloakfade_00 : 7; - /*0x2e1*/ u8 cloakfade_06 : 1; + /*0x2e1*/ u8 cloakfadefrac : 7; + /*0x2e1*/ u8 cloakfadefinished : 1; /*0x2e2*/ u8 teamscandist; /*0x2e3*/ u8 naturalanim[1]; /*0x2e4*/ s32 myspecial; // This is an object tag ID @@ -1713,7 +1724,11 @@ struct player { /*0x00b8*/ f32 crouchspeed; /*0x00bc*/ struct prop *prop; /*0x00c0*/ bool bondperimenabled; + + // 0x00000040 = cloaking device enabled + // 0x00000080 = RCP120 cloak enabled /*0x00c4*/ u32 itemswitch; + /*0x00c8*/ s32 badrockettime; /*0x00cc*/ u32 unk00cc; /*0x00d0*/ u32 unk00d0;