# Original code by Ralf @ GC-Forever and Aleron Ives # https://www.gc-forever.com/forums/viewtopic.php?t=2050 # https://www.gc-forever.com/forums/viewtopic.php?t=2049 # Xbox port by fuzziqersoftware .meta visibility="all" .meta name="Mag alert" .meta description="Plays a sound when\nyour Mag is hungry" entry_ptr: reloc0: .offsetof start .versions 3OJ2 3OJ3 3OJ4 3OJ5 3OE0 3OE1 3OE2 3OP0 .label play_sound, start: .include WriteCodeBlocks .data 0x8000BF30 .deltaof code_start, code_end .address 0x8000BF30 code_start: # [std] (TItemMag* this @ r3) -> void lwz r4, [r3 + 0xF0] lhz r4, [r4 + 0x1C] # r4 = this->owner_player->entity_id lwz r5, [r13 - ] # local_client_id cmpl r4, r5 bnelr lis r3, 0x0002 ori r3, r3, 0x2825 li r4, 0 b play_sound code_end: .data .data 0x00000004 .address b code_start .data 0x00000000 .data 0x00000000 .versions 4OJB 4OJD 4OJU 4OED 4OEU 4OPD 4OPU start: .include WriteCodeBlocks .data .data 0x0A .address hook_call: jmp hook1 int 3 int 3 hook_ret_sound: add esp, 0x10 hook_ret_no_sound: .data .deltaof hook1, hook1_end .address hook1: xor eax, eax mov dword [esi + 0x00000194], eax jmp hook2 hook1_end: .data .deltaof hook2, hook2_end .address hook2: mov edx, dword [esi + 0x000000F0] movzx edx, word [edx + 0x0000001C] # edx = this->owner_player->entity_id jmp hook3 hook2_end: .data .deltaof hook3, hook3_end .address hook3: cmp [], edx # local_client_id jmp hook4 hook3_end: .data .deltaof hook4, hook4_end .address hook4: jne hook_ret_no_sound jmp hook5 hook4_end: .data .deltaof hook5, hook5_end .address hook5: push eax push eax push eax add al, 0x8D push eax mov edx, # play_sound jmp hook6 hook5_end: .data .deltaof hook6, hook6_end .address hook6: call edx jmp hook_ret_sound hook6_end: .data 0x00000000 .data 0x00000000 .versions 50YJ 59NJ 59NL start: pop ecx push 6 push call get_code_size .deltaof patch_code, patch_code_end get_code_size: pop eax push dword [eax] call patch_code_end patch_code: # [eax] (TItemMag* this @ ecx) -> void mov dword [ecx + ], eax mov eax, [ecx + 0x00F8] movzx eax, word [eax + 0x001C] # eax = this->owner_player->entity_id cmp [], eax jne patch_code_skip_sound push 0 push 0 push 0 push 0xAC mov eax, call eax add esp, 0x10 patch_code_skip_sound: ret patch_code_end: push ecx .include WriteCallToCode