• Welcome to Smashboards, the world's largest Super Smash Brothers community! Over 250,000 Smash Bros. fans from around the world have come to discuss these great games in over 19 million posts!

    You are currently viewing our boards as a visitor. Click here to sign up right now and start on your path in the Smash community!

Completed Random P2 Percentage on D-Pad Left

rmn

Smash Rookie
Joined
Feb 15, 2016
Messages
15
Location
Alabama
In response to a request by J jra64 . When P1 presses dpad left, P2's damage will be randomized. To my knowledge, this code is compatible with 20XX's save/load state (it is executed after the state is loaded), but if you encounter a bug let me know.

$Randomize P2 Damage on Dpad Left [rmn]
C206CA78 0000000F
8803000C 2C000001
40A20068 3C60804C
60631FAC 80030000
540007FF 41A20054
38600XXX 3C008038
60000580 7C0903A6
4E800421 7C651B78
3C004330 C8028AC0
9001FFF8 9061FFFC
C821FFF8 EC210028
807E002C D0231830
88030007 2C00000B
41820010 3C808045
60843F70 B0A40000
8803221F 00000000

XXX: random percent will range from 0 to the number placed here (in hex) minus 1. To use 100 like in the original request, use 065.

Note that for Ice Climbers in the Player 2 slot, Nana and Popo will each have their percent randomized independently.

Code:
# 8006ca78, in PlayerThink
#  Original instruction lbz r0, 0x221F(r3)

# r3 = player data pointer
lbz  r0, 0xC(r3)
cmpwi  r0, 1
bne+  done
lis  r3, 0x804c
ori  r3, r3, 0x1fac
lwz  r0, 0(r3)
rlwinm. r0, r0, 0, 31, 31  # check dpad input
beq+  done
li  r3, 101  # random int will be 0-100
lis  r0, 0x8038
ori  r0, r0, 0x0580
mtctr  r0
bctrl  # get random integer
mr  r5, r3
lis  r0, 0x4330
lfd  f0, -0x7540(rtoc)
stw  r0, -0x8(sp)
stw  r3, -0x4(sp)
lfd  f1, -0x8(sp)
fsubs  f1, f1, f0  # converted to float
lwz  r3, 0x2C(r30)
stfs  f1, 0x1830(r3)  # save damage value
lbz  r0, 0x7(r3)
cmpwi  r0, 0xB  # if nana, don't update p2 damage onscreen
beq  done
lis  r4, 0x8045
ori  r4, r4, 0x3F70
sth  r5, 0(r4)  # update onscreen damage display
done:
lbz  r0, 0x221F(r3)
 
Last edited:

jra64

Smash Journeyman
Joined
Jan 30, 2004
Messages
372
Holy crap thank you very much rmn rmn ! I'm gonna check it right now. This will be so useful...

EDIT: Works like a charm. Thanks again!
 
Last edited:

Achilles1515

Smash Master
Joined
Jun 18, 2007
Messages
3,211
Location
Cincinnati / Columbus OH
J jra64
Not sure if you have seen yet, but I integrated this feature in 20XX 4.07 as an option in the Debug Menu --> Training Codes --> In-Game Toggles --> Save States/Replays menu. You can change the max and min percents for the output of the randomization.

rmn rmn
 
Last edited:
Top Bottom