Yesterday, 07:56 AM
(Yesterday, 04:06 AM)Vega Wrote: Can you post the source to this code? Would like to take a closer look at it.
Code:
Prevent you from controlling your kart when spectating others
Wheelie
80581B2C
lwz r12, 0x0(r29)
lwz r12, 0x0(r12)
lbz r12, 0x10(r12)
lis r11, 0x8000
lbz r11, 0x1620(r11) # Load camera target ID
cmpwi r11, 0 # If camera target is you
beq end # End code
cmpwi r12, 0 # Else, check if kart is yours
beqlr # If it is, return to avoid you from doing wheelies if you are spectating other players
end: # original
stwu r1, -0x10(r1)
All other controls (except wheelie - done above)
8058E058
lwz r12, 0x0(r29)
lwz r12, 0x0(r12)
lbz r12, 0x10(r12)
lis r11, 0x8000
lbz r11, 0x1620(r11) # Load camera target ID
cmpwi r11, 0 # If camera target is you
beq end # End code
cmpwi r12, 0 # Else, check if kart is yours
beqlr # if it is, return to avoid you from doing moving or doing any control if you are spectating other players
end: # original
stwu r1, -0x30(r1)
Item usage
8078ED0C
lhz r0, 0xC(r29)
lis r12, 0x8000
lbz r12, 0x1620(r12) # load camera target ID
cmpwi r12, 0 # If camera target is you
beq- end # If it isn't, end code
cmpwi r27, 0 # Else, check if item user ID is you
bne- end # If it isn't, end code
li r0, 0 # If it is, prevent you from using item
end:
Code:
Manipulate return pointer to control targetted CPU inputs (kart, items etc)
80589BE4
lbz r0, 0x10(r3)
lis r12, 0x8000
lbz r12, 0x1620(r12) # Load camera target ID
cmpw r0, r12 # Check if camera target is equal to player ID
bne end # If not, end code
li r0, 0 # If it is, set ID to mine so pointer calculation will return my pointer
end:
Code:
Cycle camera through everyone
805971F8
.set controller, 0x803414C2 # Controller address
.set buttonMask, 0xYYYY # Both previous and next button masked together
.set buttonPrev, 0xZZZZ # Button to cycle to previous
lis r30, 0x8000
lbz r4, 0x1620(r30) # Load camera target ID (stored in EVA)
lis r12, 0x8034
lhz r3, controller@l(r12) # Load controller address
lis r12, 0x809C
lwz r12, -0x11E0(r12)
lbz r12, 0x10(r12) # Obtain amount of players in the race
subi r12, r12, 0x1 # Subtract by one so it's correct
andi. r3, r3, buttonMask # Check if either cycle buttons are being pressed
beq- setPressState # If it isn't, skip code and go to setPressState to set isPress to false
lbz r11, 0x1621(r30) # Load pressState
cmpwi r11, 0 # Check if button is not pressed
bne- setPressState # If pressed, skip code (Since it sets it after first execution, code below will only execute for a frame)
andi. r11, r3, buttonPrev # Check if cycle to previous button is pressed
beq- cycleNext # If it isn't, cycle to the next
cmpwi r4, 0 # Checks if camera target ID is zero
subi r4, r4, 0x1 # Cycle to previous (NOTE: If you are in a race and targetting player ID above 1 then go to TT, you will freeze when increasing because it is invalid ID. I forgot to check it while making the code)
bne storeCam # If not zero, branch to store
mr r4, r12 # If it is zero, cycle back to last player ID (player amount - 1)
b storeCam # Store cam
cycleNext:
cmpw r12, r4 # Checks if last player ID (player amount - 1) is equal to camera target ID (camera is targetting last player)
addi r4, r4, 0x1 # Cycle to next (NOTE: If you are in a race and targetting player ID above 4 then go to TT, you will freeze when increasing because it is invalid ID. I forgot to check it while making the code)
bne- storeCam # If not equal, branch to store
li r4, 0 # If it is, reset back to first player
storeCam:
stb r4, 0x9C(r29) # Store camera target ID to camera ID
stb r4, 0x1620(r30) # Store camera target ID to EVA
setPressState:
andi. r3, r3, buttonMask # Check if either cycle buttons are being pressed
li r11, 0x1 # Set to true
bne- .loc_0x78 # If either pressed, store true to pressState
li r11, 0 # Else, it is not pressed, so set to false
pressState:
stb r11, 0x1621(r30) # Store pressState
Disable CPU AI for targetted CPU (avoid turning to route, stuck respawn etc)
80728F84
lis r12, 0x8000
lbz r12, 0x1620(r12) # Load camera target ID
lwz r11, 0x0(r29)
lwz r10, 0x0(r11)
lbz r10, 0x10(r10) # Load CPU ID
cmpw r12, r10 # If camera target ID is equal to CPU ID
bne end # Skip code if not equal
lwz r12, 0x4(r11)
lwz r11, 0x14(r12)
rlwinm r11,r11,0,0,30 # If it is, clear isCpu bit
stw r11, 0x14(r12)
blr
end: # original
stwu r1, -0x10(r1)
Code:
Targetted CPU has player minimap icon elements (Big icon, searchlight, outline etc)
Big icon and searchlight
807E1CA8
lis r12, 0x8000
lbz r12, 0x1620(r12) # Load camera target ID
cmpw r4, r12 # Compare minimap player ID with camera target ID for check
Outline
807E2018
lwz r0, 0xB90(r3)
lis r12, 0x8000
lbz r12, 0x1620(r12) # Load camera target ID
lwz r11, -0x4(r28) # Load pointer
cmpwi r11, 0 # if nullptr
beq- end # End code if (pointer == NULL)
lwz r11, 0x0(r11)
lwz r11, 0x0(r11)
lbz r11, 0x10(r11) # Load player ID
addi r11, r11, 0x1 # Increment by one so it's correct
cmpw r11, r12 # If player ID is equal to camera target ID
bne end # End code if not
# If it is, load and store values necessary to give outline to minimap
li r0, 0x2
lwz r12, 0x1BC(r28)
li r11, 0x1
stb r11, 0xBB(r12)
lwz r12, 0x1C0(r28)
li r11, 0x5
stb r11, 0xBB(r12)
end: