Custom Item Probability Distribution Offline [Sioist]
#1
This code allows you to set custom probabilities for each item in offline VS mode and battle. These probabilities will apply regardless of what position you are in, and also applies to all the CPUs. 

Note: This code uses memory addresses from 0x800007b4 to 0x800007c8.

NTSC-U: 
040007B4 HHIIJJKK
040007B8 LLMMNNOO
040007BC PPQQRRSS
040007C0 TTUUVVWW
040007C4 XXYYZZ00
C27AB704 00000010
3D808000 618C07B4
39600013 7D6903A6
39400000 398CFFFF
8D6C0001 7D4A5A14
4200FFF8 7C8B2378
38600000 7D445378
3D40800F 614A2E40
7D4903A6 4E800421
7D645B78 398CFFED
39600013 7D6903A6
39600000 8D4C0001
7D6B5214 7C035800
41800008 4200FFF0
7D6902A6 39400013
7D6B5050 7D635B78
90770020 00000000


PAL:
040007B4 HHIIJJKK
040007B8 LLMMNNOO
040007BC PPQQRRSS
040007C0 TTUUVVWW
040007C4 XXYYZZ00
C27BA164 00000010
3D808000 618C07B4
39600013 7D6903A6
39400000 398CFFFF
8D6C0001 7D4A5A14
4200FFF8 7C8B2378
38600000 7D445378
3D40800F 614A2EE0
7D4903A6 4E800421
7D645B78 398CFFED
39600013 7D6903A6
39600000 8D4C0001
7D6B5214 7C035800
41800008 4200FFF0
7D6902A6 39400013
7D6B5050 7D635B78
90770020 00000000

NTSC-J:
040007B4 HHIIJJKK
040007B8 LLMMNNOO
040007BC PPQQRRSS
040007C0 TTUUVVWW
040007C4 XXYYZZ00
C27B97D0 00000010
3D808000 618C07B4
39600013 7D6903A6
39400000 398CFFFF
8D6C0001 7D4A5A14
4200FFF8 7C8B2378
38600000 7D445378
3D40800F 614A2E00
7D4903A6 4E800421
7D645B78 398CFFED
39600013 7D6903A6
39600000 8D4C0001
7D6B5214 7C035800
41800008 4200FFF0
7D6902A6 39400013
7D6B5050 7D635B78
90770020 00000000

NTSC-K:
040007B4 HHIIJJKK
040007B8 LLMMNNOO
040007BC PPQQRRSS
040007C0 TTUUVVWW
040007C4 XXYYZZ00
C27AE524 00000010
3D808000 618C07B4
39600013 7D6903A6
39400000 398CFFFF
8D6C0001 7D4A5A14
4200FFF8 7C8B2378
38600000 7D445378
3D40800F 614A2F58
7D4903A6 4E800421
7D645B78 398CFFED
39600013 7D6903A6
39600000 8D4C0001
7D6B5214 7C035800
41800008 4200FFF0
7D6902A6 39400013
7D6B5050 7D635B78
90770020 00000000

Legend:
HH - Green Shell
II - Red Shell
JJ - Banana 
KK - Fake Item Box
LL - Mushroom
MM - Triple Mushrooms
NN - Bomb-ombs
OO - Blue Shell
PP - Lightning
QQ - Star
RR - Golden Mushroom
SS - Mega Mushroom
TT - Blooper
UU - Pow Block
VV - Thunder Cloud
WW - Bullet Bill
XX - Triple Green Shell
YY - Triple Red Shell
ZZ - Triple Banana

Enter in a byte value from 00 to FF for each item. Each value is a weighting for how likely that item is to be pulled, relative to the other item values. For example, to have a 25% chance of pulling a Green Shell, a 75% chance of pulling a Red Shell, and a 0% chance for every other item, the first line would become 040007B4 01030000, with the subsequent lines filled in with zeros. The code will sum the values you entered, which in this case is 4. Now Green Shells have a 1/4 chance of being pulled, and Red Shells have a 3/4 chance. 

If an item is pulled that cannot be pulled because of item limits (such as pulling a Bullet Bill when another player/CPU already has a Bullet Bill) you will receive a mushroom by default. To increase these limits, check the two links below.

https://mkwii.com/showthread.php?tid=242
https://mkwii.com/showthread.php?tid=405

ASM Source:
Code:
.set base, 0x800007B4 # address where values are stored
.set randomizer, 0x800F2E40

lis r12, base@h
ori r12, r12, base@l

# grab sum of weights
li r11, 19
mtctr r11

li r10, 0
subi r12, r12, 0x1

sum_loop:
lbzu r11, 0x1 (r12)
add r10, r10, r11
bdnz+ sum_loop

# --------------

mr r11, r4 # save r4 value

# setup args
li r3, 0
mr r4, r10
lis r10, randomizer@h
ori r10, r10, randomizer@l
mtctr r10
bctrl
mr r4, r11 # restore r4

subi r12, r12, 0x13

li r11, 19
mtctr r11

li r11, 0

weights_loop:
lbzu r10, 0x1 (r12)
add r11, r11, r10
cmpw r3, r11
blt the_end
bdnz+ weights_loop

the_end:
mfctr r11
li r10, 0x13
sub r11, r10, r11
mr r3, r11
stw r3, 0x0020 (r23)

Code Created by: Sioist
Code Credits: Guru, CLF78


I hope to extend this code to allow probability distributions for each separate position, similar to XeR's God code.
Reply


Messages In This Thread
Custom Item Probability Distribution Offline [Sioist] - by sioist - 08-12-2021, 12:25 AM

Forum Jump:


Users browsing this thread: 1 Guest(s)