07-17-2023, 10:46 AM
(This post was last modified: 07-18-2023, 06:27 AM by Unnamed.
Edit Reason: Updated Title and use of Dynamic Memory Area
)
Auto Use Dodge Item When Shocked -Online- [Unnamed]
Online only.
I wanted to see how to improve Vegas Auto Attempt code and this is the outcome. Unlike his code, this code directly hooks the address that calls the shock damage on your console when another slot (not you) fires the shock and is only called once. This is the reason why the code should be completely independent of the NATNEG between clients.
Basically, the code works by delaying the shock damage (a few frames) on your console so that there is enough time to use our dodge item.
In addition to checking if you have a dodge item, this code also checks, unlike Vegas code, if you are already in star or mega state and does NOT fire a dodge item if that is the case. However, also for any moments where you normally can't use an item (i.e. during exit of cannon, spinning from getting hit by an item, etc), the code won't work.
NOTE: This code makes use of memory addresses 0x81670008 thru 0x81670009. Make sure no other codes in your GCT/Cheat-Manager are using those addresses!
NTSC-U
C278DD50 00000003
3F408167 987A0009
3B800005 9B9A0008
60000000 00000000
C2531134 00000008
901D0048 3FC08167
8BFE0008 2C1F0000
41A2000C 3BFFFFFF
9BFE0008 8BFE0008
2C1F0002 40A20018
887E0009 3FC0807A
63DE91C0 7FC803A6
4E800021 00000000
C251CE8C 0000000F
3D608167 898B0008
2C0C0004 40A20060
3D80809C 816CEE20
818C8F68 898C0B84
816B0014 1D8C0248
7D8C5A14 816C008C
2C0B0009 41820014
2C0B000B 4182000C
2C0B000F 40A20028
816C0000 816B0004
818B000C 558C0420
816B0008 556B0000
7D6B6215 40820008
60000004 B01E002C
60000000 00000000
PAL
C2796D5C 00000003
3F408167 987A0009
3B800005 9B9A0008
60000000 00000000
C2535C7C 00000008
901D0048 3FC08167
8BFE0008 2C1F0000
41A2000C 3BFFFFFF
9BFE0008 8BFE0008
2C1F0002 40A20018
887E0009 3FC0807B
63DE7C20 7FC803A6
4E800021 00000000
C2521300 0000000F
3D608167 898B0008
2C0C0004 40A20060
3D80809C 816C3618
818CD728 898C0B84
816B0014 1D8C0248
7D8C5A14 816C008C
2C0B0009 41820014
2C0B000B 4182000C
2C0B000F 40A20028
816C0000 816B0004
818B000C 558C0420
816B0008 556B0000
7D6B6215 40820008
60000004 B01E002C
60000000 00000000
NTSC-J
C27963C8 00000003
3F408167 987A0009
3B800005 9B9A0008
60000000 00000000
C25355FC 00000008
901D0048 3FC08167
8BFE0008 2C1F0000
41A2000C 3BFFFFFF
9BFE0008 8BFE0008
2C1F0002 40A20018
887E0009 3FC0807B
63DE728C 7FC803A6
4E800021 00000000
C2520C80 0000000F
3D608167 898B0008
2C0C0004 40A20060
3D80809C 816C2678
818CC788 898C0B84
816B0014 1D8C0248
7D8C5A14 816C008C
2C0B0009 41820014
2C0B000B 4182000C
2C0B000F 40A20028
816C0000 816B0004
818B000C 558C0420
816B0008 556B0000
7D6B6215 40820008
60000004 B01E002C
60000000 00000000
NTSC-K
C278511C 00000003
3F408167 987A0009
3B800005 9B9A0008
60000000 00000000
C2523CD4 00000008
901D0048 3FC08167
8BFE0008 2C1F0000
41A2000C 3BFFFFFF
9BFE0008 8BFE0008
2C1F0002 40A20018
887E0009 3FC0807A
63DE5FE0 7FC803A6
4E800021 00000000
C250F324 0000000F
3D608167 898B0008
2C0C0004 40A20060
3D80809B 816C1C58
818CBD68 898C0B84
816B0014 1D8C0248
7D8C5A14 816C008C
2C0B0009 41820014
2C0B000B 4182000C
2C0B000F 40A20028
816C0000 816B0004
818B000C 558C0420
816B0008 556B0000
7D6B6215 40820008
60000004 B01E002C
60000000 00000000
Source:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#######################################################
############## Shock event call #######################
#######################################################
#######################################################
## Inject at ##########################################
## NTSC-U 0x8078DD50 ###
## PAL 0x80796D5C ###
## NTSC-J 0x807963C8 ###
## NTSC-K 0x8078511C ###
#######################################################################################
## This adress normally calls the "Force Shock damage" on your console if another slot fired a shock. Therefore, it will only get called once, and should not get affected by NATNEG.
## To make the code work, we will overwrite the call and will store a frame counter to memory to let another adress call the event if a certain number is reached. That way, we delay the shock a few frames and can use our item.
## Again I repeat: The adress is ONLY called if another Slot fired the shock, it will not get called if you fire it.
#######################################################################################
lis r26, 0x8167 # r26, r28 and r29 are safe for use
stb r3, 0x0009 (r26) # r3 holds the player slot that used the shock, store it to memory
li r28, 5 # prepare frame counter
stb r28, 0x0008 (r26) # store frame counter
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#############################################################################
############### frame counter and apply shock damage ########################
#############################################################################
#######################################################
## Inject at ##########################################
## NTSC-U 0x80531134 ###
## PAL 0x80535C7C ###
## NTSC-J 0x805355FC ###
## NTSC-K 0x80523CD4 ###
###########################################
#### Shock Damage Adress ####
# 807A91C0 # NTSC-U
# 807B7C20 # PAL
# 807B728C # NTSC-J
# 807A5FE0 # NTSC-K
#######################################################################################
## To apply the shock damage, the frame counter gets lowered every frame when shock event was triggered. And if it reaches a certain number (2), we will call the shock damage.
## In Addition, if the frame counter is equal to 4 (two frames earlier than 2), we will use our dodge item (3rd ASM).
#######################################################################################
stw r0, 0x48(r29) # default instruction
####################################################
### Lowering the frame counter if it is not 0 ######
####################################################
lis r30, 0x8167
lbz r31, 0x0008(r30) # Load the frame counter
cmpwi r31, 0
beq+ skip_lowering # If 0, do not lower the counter
addi r31, r31, -1 # If not 0, lower the counter, it will lowered every frame til it hits 0 again
stb r31, 0x0008(r30) # store lowered frame counter
skip_lowering:
#####################################################
## Check if we need to apply shock damage ###
#####################################################
lbz r31, 0x0008(r30) # load the frame counter
cmpwi r31, 2
bne+ skip_shocked # if it is not 2 (two frames after we fired our item), skip the code
lbz r3, 0x0009(r30) # load the player slot that used the shock
lis r30, ShockDamageUpper
ori r30, r30, ShockDamageLower
mtlr r30
blrl # apply shock damage
skip_shocked:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#############################################################################
######################## Item Usage hook ###################################
#############################################################################
#######################################################
## Inject at ##########################################
## NTSC-U 0x8051CE8C ###
## PAL 0x80521300 ###
## NTSC-J 0x80520C80 ###
## NTSC-K 0x8050F324 ###
###########################################
#### Pointers ####
## PlayerHolder ##
# 809BEE20 # NTSC-U
# 809C3618 # PAL
# 809C2678 # NTSC-J
# 809B1C58 # NTSC-K
## RaceData ##
# 809B8F68 # NTSC-U
# 809BD728 # PAL
# 809BC788 # NTSC-J
# 809ABD68 # NTSC-K
#######################################################################################
## If the frame counter will equal 4, 2 frames before the shock damage is called, we will check if a dodge item is hold and if we are not in Mega or Star state.
## If so, the code will flip the Item usage bit and it will fire 2 frames before the shock damage is applied.
#######################################################################################
lis r11, 0x8167
lbz r12, 0x0008 (r11) # load the frame counter
cmpwi r12, 4
bne+ default # if it is 4 (two frames before we call the shock damage), we want to fire our dodge item if we have one and are not in star or mega state.
lis r12, PlayerHolderUpper
lwz r11, PlayerHolderLower (r12) # PlayerHolder Pointer
lwz r12, RaceDataLower (r12) # RaceData Pointer
lbz r12, 0x0B84 (r12) # Player Slot Byte
lwz r11, 0x0014 (r11)
mulli r12, r12, 0x248
add r12, r12, r11
lwz r11, 0x008C (r12) # Item of local Player
cmpwi r11, 0x9
beq- state_check # If Star, go to state check
cmpwi r11, 0xB
beq- state_check # If Mega, go to state check
cmpwi r11, 0xF
bne+ default # If NOT Bullet, we have no dodge Item, skip code
state_check:
lwz r11, 0 (r12)
lwz r11, 0x4 (r11)
lwz r12, 0xC (r11) # Load second state word of local player
rlwinm r12, r12, 0, 16, 16 # Bit 16 helds Mega state, mask all other bits out
lwz r11, 0x8 (r11) # Load first state word of local player
rlwinm r11, r11, 0, 0, 0 # Bit 0 helds Star state, mask all other bits out
add. r11, r11, r12 # add the states and compare to 0
bne- default # if not both are 0 (no state), skip the code
go:
ori r0, r0, 0x4 # Flip the Item Usage Bit!
default:
sth r0, 0x002C (r30) # Store item Input to memory
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Code Creator: Unnamed
Code Credits: 1superchip (Force Shock Damage), Seeky (Item Usage Adress)
Online only.
I wanted to see how to improve Vegas Auto Attempt code and this is the outcome. Unlike his code, this code directly hooks the address that calls the shock damage on your console when another slot (not you) fires the shock and is only called once. This is the reason why the code should be completely independent of the NATNEG between clients.
Basically, the code works by delaying the shock damage (a few frames) on your console so that there is enough time to use our dodge item.
In addition to checking if you have a dodge item, this code also checks, unlike Vegas code, if you are already in star or mega state and does NOT fire a dodge item if that is the case. However, also for any moments where you normally can't use an item (i.e. during exit of cannon, spinning from getting hit by an item, etc), the code won't work.
NOTE: This code makes use of memory addresses 0x81670008 thru 0x81670009. Make sure no other codes in your GCT/Cheat-Manager are using those addresses!
NTSC-U
C278DD50 00000003
3F408167 987A0009
3B800005 9B9A0008
60000000 00000000
C2531134 00000008
901D0048 3FC08167
8BFE0008 2C1F0000
41A2000C 3BFFFFFF
9BFE0008 8BFE0008
2C1F0002 40A20018
887E0009 3FC0807A
63DE91C0 7FC803A6
4E800021 00000000
C251CE8C 0000000F
3D608167 898B0008
2C0C0004 40A20060
3D80809C 816CEE20
818C8F68 898C0B84
816B0014 1D8C0248
7D8C5A14 816C008C
2C0B0009 41820014
2C0B000B 4182000C
2C0B000F 40A20028
816C0000 816B0004
818B000C 558C0420
816B0008 556B0000
7D6B6215 40820008
60000004 B01E002C
60000000 00000000
PAL
C2796D5C 00000003
3F408167 987A0009
3B800005 9B9A0008
60000000 00000000
C2535C7C 00000008
901D0048 3FC08167
8BFE0008 2C1F0000
41A2000C 3BFFFFFF
9BFE0008 8BFE0008
2C1F0002 40A20018
887E0009 3FC0807B
63DE7C20 7FC803A6
4E800021 00000000
C2521300 0000000F
3D608167 898B0008
2C0C0004 40A20060
3D80809C 816C3618
818CD728 898C0B84
816B0014 1D8C0248
7D8C5A14 816C008C
2C0B0009 41820014
2C0B000B 4182000C
2C0B000F 40A20028
816C0000 816B0004
818B000C 558C0420
816B0008 556B0000
7D6B6215 40820008
60000004 B01E002C
60000000 00000000
NTSC-J
C27963C8 00000003
3F408167 987A0009
3B800005 9B9A0008
60000000 00000000
C25355FC 00000008
901D0048 3FC08167
8BFE0008 2C1F0000
41A2000C 3BFFFFFF
9BFE0008 8BFE0008
2C1F0002 40A20018
887E0009 3FC0807B
63DE728C 7FC803A6
4E800021 00000000
C2520C80 0000000F
3D608167 898B0008
2C0C0004 40A20060
3D80809C 816C2678
818CC788 898C0B84
816B0014 1D8C0248
7D8C5A14 816C008C
2C0B0009 41820014
2C0B000B 4182000C
2C0B000F 40A20028
816C0000 816B0004
818B000C 558C0420
816B0008 556B0000
7D6B6215 40820008
60000004 B01E002C
60000000 00000000
NTSC-K
C278511C 00000003
3F408167 987A0009
3B800005 9B9A0008
60000000 00000000
C2523CD4 00000008
901D0048 3FC08167
8BFE0008 2C1F0000
41A2000C 3BFFFFFF
9BFE0008 8BFE0008
2C1F0002 40A20018
887E0009 3FC0807A
63DE5FE0 7FC803A6
4E800021 00000000
C250F324 0000000F
3D608167 898B0008
2C0C0004 40A20060
3D80809B 816C1C58
818CBD68 898C0B84
816B0014 1D8C0248
7D8C5A14 816C008C
2C0B0009 41820014
2C0B000B 4182000C
2C0B000F 40A20028
816C0000 816B0004
818B000C 558C0420
816B0008 556B0000
7D6B6215 40820008
60000004 B01E002C
60000000 00000000
Source:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#######################################################
############## Shock event call #######################
#######################################################
#######################################################
## Inject at ##########################################
## NTSC-U 0x8078DD50 ###
## PAL 0x80796D5C ###
## NTSC-J 0x807963C8 ###
## NTSC-K 0x8078511C ###
#######################################################################################
## This adress normally calls the "Force Shock damage" on your console if another slot fired a shock. Therefore, it will only get called once, and should not get affected by NATNEG.
## To make the code work, we will overwrite the call and will store a frame counter to memory to let another adress call the event if a certain number is reached. That way, we delay the shock a few frames and can use our item.
## Again I repeat: The adress is ONLY called if another Slot fired the shock, it will not get called if you fire it.
#######################################################################################
lis r26, 0x8167 # r26, r28 and r29 are safe for use
stb r3, 0x0009 (r26) # r3 holds the player slot that used the shock, store it to memory
li r28, 5 # prepare frame counter
stb r28, 0x0008 (r26) # store frame counter
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#############################################################################
############### frame counter and apply shock damage ########################
#############################################################################
#######################################################
## Inject at ##########################################
## NTSC-U 0x80531134 ###
## PAL 0x80535C7C ###
## NTSC-J 0x805355FC ###
## NTSC-K 0x80523CD4 ###
###########################################
#### Shock Damage Adress ####
# 807A91C0 # NTSC-U
# 807B7C20 # PAL
# 807B728C # NTSC-J
# 807A5FE0 # NTSC-K
#######################################################################################
## To apply the shock damage, the frame counter gets lowered every frame when shock event was triggered. And if it reaches a certain number (2), we will call the shock damage.
## In Addition, if the frame counter is equal to 4 (two frames earlier than 2), we will use our dodge item (3rd ASM).
#######################################################################################
stw r0, 0x48(r29) # default instruction
####################################################
### Lowering the frame counter if it is not 0 ######
####################################################
lis r30, 0x8167
lbz r31, 0x0008(r30) # Load the frame counter
cmpwi r31, 0
beq+ skip_lowering # If 0, do not lower the counter
addi r31, r31, -1 # If not 0, lower the counter, it will lowered every frame til it hits 0 again
stb r31, 0x0008(r30) # store lowered frame counter
skip_lowering:
#####################################################
## Check if we need to apply shock damage ###
#####################################################
lbz r31, 0x0008(r30) # load the frame counter
cmpwi r31, 2
bne+ skip_shocked # if it is not 2 (two frames after we fired our item), skip the code
lbz r3, 0x0009(r30) # load the player slot that used the shock
lis r30, ShockDamageUpper
ori r30, r30, ShockDamageLower
mtlr r30
blrl # apply shock damage
skip_shocked:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#############################################################################
######################## Item Usage hook ###################################
#############################################################################
#######################################################
## Inject at ##########################################
## NTSC-U 0x8051CE8C ###
## PAL 0x80521300 ###
## NTSC-J 0x80520C80 ###
## NTSC-K 0x8050F324 ###
###########################################
#### Pointers ####
## PlayerHolder ##
# 809BEE20 # NTSC-U
# 809C3618 # PAL
# 809C2678 # NTSC-J
# 809B1C58 # NTSC-K
## RaceData ##
# 809B8F68 # NTSC-U
# 809BD728 # PAL
# 809BC788 # NTSC-J
# 809ABD68 # NTSC-K
#######################################################################################
## If the frame counter will equal 4, 2 frames before the shock damage is called, we will check if a dodge item is hold and if we are not in Mega or Star state.
## If so, the code will flip the Item usage bit and it will fire 2 frames before the shock damage is applied.
#######################################################################################
lis r11, 0x8167
lbz r12, 0x0008 (r11) # load the frame counter
cmpwi r12, 4
bne+ default # if it is 4 (two frames before we call the shock damage), we want to fire our dodge item if we have one and are not in star or mega state.
lis r12, PlayerHolderUpper
lwz r11, PlayerHolderLower (r12) # PlayerHolder Pointer
lwz r12, RaceDataLower (r12) # RaceData Pointer
lbz r12, 0x0B84 (r12) # Player Slot Byte
lwz r11, 0x0014 (r11)
mulli r12, r12, 0x248
add r12, r12, r11
lwz r11, 0x008C (r12) # Item of local Player
cmpwi r11, 0x9
beq- state_check # If Star, go to state check
cmpwi r11, 0xB
beq- state_check # If Mega, go to state check
cmpwi r11, 0xF
bne+ default # If NOT Bullet, we have no dodge Item, skip code
state_check:
lwz r11, 0 (r12)
lwz r11, 0x4 (r11)
lwz r12, 0xC (r11) # Load second state word of local player
rlwinm r12, r12, 0, 16, 16 # Bit 16 helds Mega state, mask all other bits out
lwz r11, 0x8 (r11) # Load first state word of local player
rlwinm r11, r11, 0, 0, 0 # Bit 0 helds Star state, mask all other bits out
add. r11, r11, r12 # add the states and compare to 0
bne- default # if not both are 0 (no state), skip the code
go:
ori r0, r0, 0x4 # Flip the Item Usage Bit!
default:
sth r0, 0x002C (r30) # Store item Input to memory
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Code Creator: Unnamed
Code Credits: 1superchip (Force Shock Damage), Seeky (Item Usage Adress)