Mario Kart 7/8 Style Item Distributions [Sioist]
#1
This code builds upon XeR's Item Probability Modifier (original post here) for 10 player rooms to now include item tables for all 12 players. This code also now has 11 customizable tiers to simulate the way Mario Kart 7/8 determine item probabilities. This code also works offline.

NTSC-U:
C27ACBC4 00000052
7D8802A6 480001F9
00410000 004B0028
00000000 00000000
00000000 00000000
00000000 00000000
00000000 00140023
00320028 000F0019
00000000 00000000
00000000 00000000
00000000 0000000A
00000019 001E0032
000F000A 00230000
00050000 00000000
00000000 00000000
00050000 0014000A
0014000A 001E0000
0000001E 0014000F
000A0000 00000000
000F000A 000A000F
0000000F 00140000
00000014 00000000
0019001E 000F000F
00000000 00050014
000F000A 000F0000
000A0014 00000000
000A0000 00000014
0032000A 000F0000
00000014 000F000F
000F000A 00000005
000F0000 00000005
00000000 00000041
0000000A 00000019
002D000A 000A000A
000A0000 0000000A
00000000 00000000
00000000 003C0000
00000000 00370046
00000000 00000000
000F0000 00000000
00000000 00000000
00000019 00000000
000F0037 003C0000
00000000 0000002D
00000000 00000000
00000000 00000000
000A0000 00000028
0023002D 00000000
00000000 00460000
00000000 00000000
00000000 00000000
00000000 00F00000
00000000 00000000
000000F0 00000000
00000000 00000000
00000000 00000000
000000F0 00000000
00000000 00000000
00F00000 00000000
PPPPPPPP QQQQQQQQ
RRRRRRRR SSSSSSSS
TTTTTTTT UUUUUUUU
VVVVVVVV WWWWWWWW
XXXXXXXX YYYYYYYY
ZZZZZZZZ 7C8802A6
7D8803A6 3D60809B
616B8F70 816B0000
816B000C 816B0000
396B000C 3980000C
7D8903A6 89970070
1D8C00C4 7D6C5C2E
EDAD6828 C18B0000
FC8C6840 41840008
FDA06090 396B00C4
4200FFEC EDAD5828
ED8C6028 38600000
FC8D6040 41860028
7C8C2378 398C01C8
3960000B 7D6903A6
7D83642E 38630004
FC8D6040 41840008
4200FFF0 5463F0BE
1C630026 00000000

PAL:
C27BB624 00000052
7D8802A6 480001F9
00410000 004B0028
00000000 00000000
00000000 00000000
00000000 00000000
00000000 00140023
00320028 000F0019
00000000 00000000
00000000 00000000
00000000 0000000A
00000019 001E0032
000F000A 00230000
00050000 00000000
00000000 00000000
00050000 0014000A
0014000A 001E0000
0000001E 0014000F
000A0000 00000000
000F000A 000A000F
0000000F 00140000
00000014 00000000
0019001E 000F000F
00000000 00050014
000F000A 000F0000
000A0014 00000000
000A0000 00000014
0032000A 000F0000
00000014 000F000F
000F000A 00000005
000F0000 00000005
00000000 00000041
0000000A 00000019
002D000A 000A000A
000A0000 0000000A
00000000 00000000
00000000 003C0000
00000000 00370046
00000000 00000000
000F0000 00000000
00000000 00000000
00000019 00000000
000F0037 003C0000
00000000 0000002D
00000000 00000000
00000000 00000000
000A0000 00000028
0023002D 00000000
00000000 00460000
00000000 00000000
00000000 00000000
00000000 00F00000
00000000 00000000
000000F0 00000000
00000000 00000000
00000000 00000000
000000F0 00000000
00000000 00000000
00F00000 00000000
PPPPPPPP QQQQQQQQ
RRRRRRRR SSSSSSSS
TTTTTTTT UUUUUUUU
VVVVVVVV WWWWWWWW
XXXXXXXX YYYYYYYY
ZZZZZZZZ 7C8802A6
7D8803A6 3D60809B
616BD730 816B0000
816B000C 816B0000
396B000C 3980000C
7D8903A6 89970070
1D8C00C4 7D6C5C2E
EDAD6828 C18B0000
FC8C6840 41840008
FDA06090 396B00C4
4200FFEC EDAD5828
ED8C6028 38600000
FC8D6040 41860028
7C8C2378 398C01C8
3960000B 7D6903A6
7D83642E 38630004
FC8D6040 41840008
4200FFF0 5463F0BE
1C630026 00000000

NTSC-J:

C27BAC90 00000052
7D8802A6 480001F9
00410000 004B0028
00000000 00000000
00000000 00000000
00000000 00000000
00000000 00140023
00320028 000F0019
00000000 00000000
00000000 00000000
00000000 0000000A
00000019 001E0032
000F000A 00230000
00050000 00000000
00000000 00000000
00050000 0014000A
0014000A 001E0000
0000001E 0014000F
000A0000 00000000
000F000A 000A000F
0000000F 00140000
00000014 00000000
0019001E 000F000F
00000000 00050014
000F000A 000F0000
000A0014 00000000
000A0000 00000014
0032000A 000F0000
00000014 000F000F
000F000A 00000005
000F0000 00000005
00000000 00000041
0000000A 00000019
002D000A 000A000A
000A0000 0000000A
00000000 00000000
00000000 003C0000
00000000 00370046
00000000 00000000
000F0000 00000000
00000000 00000000
00000019 00000000
000F0037 003C0000
00000000 0000002D
00000000 00000000
00000000 00000000
000A0000 00000028
0023002D 00000000
00000000 00460000
00000000 00000000
00000000 00000000
00000000 00F00000
00000000 00000000
000000F0 00000000
00000000 00000000
00000000 00000000
000000F0 00000000
00000000 00000000
00F00000 00000000
PPPPPPPP QQQQQQQQ
RRRRRRRR SSSSSSSS
TTTTTTTT UUUUUUUU
VVVVVVVV WWWWWWWW
XXXXXXXX YYYYYYYY
ZZZZZZZZ 7C8802A6
7D8803A6 3D60809B
616BC790 816B0000
816B000C 816B0000
396B000C 3980000C
7D8903A6 89970070
1D8C00C4 7D6C5C2E
EDAD6828 C18B0000
FC8C6840 41840008
FDA06090 396B00C4
4200FFEC EDAD5828
ED8C6028 38600000
FC8D6040 41860028
7C8C2378 398C01C8
3960000B 7D6903A6
7D83642E 38630004
FC8D6040 41840008
4200FFF0 5463F0BE
1C630026 00000000

NTSC-K:

C27A99E4 00000052
7D8802A6 480001F9
00410000 004B0028
00000000 00000000
00000000 00000000
00000000 00000000
00000000 00140023
00320028 000F0019
00000000 00000000
00000000 00000000
00000000 0000000A
00000019 001E0032
000F000A 00230000
00050000 00000000
00000000 00000000
00050000 0014000A
0014000A 001E0000
0000001E 0014000F
000A0000 00000000
000F000A 000A000F
0000000F 00140000
00000014 00000000
0019001E 000F000F
00000000 00050014
000F000A 000F0000
000A0014 00000000
000A0000 00000014
0032000A 000F0000
00000014 000F000F
000F000A 00000005
000F0000 00000005
00000000 00000041
0000000A 00000019
002D000A 000A000A
000A0000 0000000A
00000000 00000000
00000000 003C0000
00000000 00370046
00000000 00000000
000F0000 00000000
00000000 00000000
00000019 00000000
000F0037 003C0000
00000000 0000002D
00000000 00000000
00000000 00000000
000A0000 00000028
0023002D 00000000
00000000 00460000
00000000 00000000
00000000 00000000
00000000 00F00000
00000000 00000000
000000F0 00000000
00000000 00000000
00000000 00000000
000000F0 00000000
00000000 00000000
00F00000 00000000
PPPPPPPP QQQQQQQQ
RRRRRRRR SSSSSSSS
TTTTTTTT UUUUUUUU
VVVVVVVV WWWWWWWW
XXXXXXXX YYYYYYYY
ZZZZZZZZ 7C8802A6
7D8803A6 3D60809A
616BBD70 816B0000
816B000C 816B0000
396B000C 3980000C
7D8903A6 89970070
1D8C00C4 7D6C5C2E
EDAD6828 C18B0000
FC8C6840 41840008
FDA06090 396B00C4
4200FFEC EDAD5828
ED8C6028 38600000
FC8D6040 41860028
7C8C2378 398C01C8
3960000B 7D6903A6
7D83642E 38630004
FC8D6040 41840008
4200FFF0 5463F0BE
1C630026 00000000

Similar to XeR's code, fill in the item probability weightings as half-words. For 1st place's items, fill in values in the first purple color group. The next color group down (red) is 2nd place's items, then 3rd, then 4th, etc all the way to 12th places items in the final green color group. 


The order of the items is the index of each item, so the first half-word (aka 4 digits) is the weighting for green shells, then red shells, bananas, mushrooms, etc.

When you get an item box, your position no longer matters (unless you are in 1st) for which place box you get. It is dependent on your distance to 1st place. There are 11 different tiers of distances, each one corresponding to 2nd place through 12th place boxes. The distance from 1st place is measured by subtracting your race completion from 1st place's. 

For example, if the first tier is set at a value of 0.10 (0x3DCCCCCD in hex), you will receive 2nd place boxes if, at the time of pulling the item box, your race completion is within 0.10 of first place. This means that you need to be within 10% of a lap on any track to receive 2nd place boxes. Then if the next tier is set at 0.20 (0x3E4CCCCD in hex), your race completion must be within 0.1 and 0.2 to receive 3rd place boxes. Continue with subsequent tiers until last place.

For the last tier, it is recommended you set a large value (at least 3) so that a player doesn't fall so far behind that they exceed the last tier's value.

PPPPPPPP - Tier 1, 2nd place boxes
QQQQQQQQ - Tier 2, 3rd place boxes
.
.
YYYYYYYY - Tier 10, 11th place boxes
ZZZZZZZZ - Tier 11, 12th place boxes


Here is a decimal to float conversion calculator to translate the race completion values into floats to put into the code.

ASM Source:
Code:
.set ptr_playerData, 0x809b8f70

set_up:
  mflr r12
  bl the_code
  # 1st place
  .long 0x00410000
  .long 0x004b0028
  .long 0x00000000
  .long 0x00000000
  .long 0x00000000
  .long 0x00000000
  .long 0x00000000
  .long 0x00000000
  .long 0x00000000
  # 2nd place, lower halfword
  .long 0x00140023
  .long 0x00320028
  .long 0x000f0019
  .long 0x00000000
  .long 0x00000000
  .long 0x00000000
  .long 0x00000000
  .long 0x00000000
  .long 0x0000000a
  .long 0x00000019
  # 3rd place
  .long 0x001e0032
  .long 0x000f000a
  .long 0x00230000
  .long 0x00050000
  .long 0x00000000
  .long 0x00000000
  .long 0x00000000
  .long 0x00050000
  .long 0x0014000a
  # 4th place, lower halfword
  .long 0x0014000a
  .long 0x001e0000
  .long 0x0000001e
  .long 0x0014000f
  .long 0x000a0000
  .long 0x00000000
  .long 0x000f000a
  .long 0x000a000f
  .long 0x0000000f
  .long 0x00140000
  # 5th place
  .long 0x00000014
  .long 0x00000000
  .long 0x0019001e
  .long 0x000f000f
  .long 0x00000000
  .long 0x00050014
  .long 0x000f000a
  .long 0x000f0000
  .long 0x000a0014
  # 6th place, lower halfword
  .long 0x00000000
  .long 0x000a0000
  .long 0x00000014
  .long 0x0032000a
  .long 0x000f0000
  .long 0x00000014
  .long 0x000f000f
  .long 0x000f000a
  .long 0x00000005
  .long 0x000f0000
  # 7th place
  .long 0x00000005
  .long 0x00000000
  .long 0x00000041
  .long 0x0000000a
  .long 0x00000019
  .long 0x002d000a
  .long 0x000a000a
  .long 0x000a0000
  .long 0x0000000a
  # 8th place, lower halfword
  .long 0x00000000
  .long 0x00000000
  .long 0x00000000
  .long 0x003c0000
  .long 0x00000000
  .long 0x00370046
  .long 0x00000000
  .long 0x00000000
  .long 0x000f0000
  .long 0x00000000
  # 9th place
  .long 0x00000000
  .long 0x00000000
  .long 0x00000019
  .long 0x00000000
  .long 0x000f0037
  .long 0x003c0000
  .long 0x00000000
  .long 0x0000002d
  .long 0x00000000
  # 10th place, lower halfword
  .long 0x00000000
  .long 0x00000000
  .long 0x00000000
  .long 0x000a0000
  .long 0x00000028
  .long 0x0023002d
  .long 0x00000000
  .long 0x00000000
  .long 0x00460000
  .long 0x00000000
  # 11th place
  .long 0x00000000
  .long 0x00000000
  .long 0x00000000
  .long 0x00000000
  .long 0x00f00000
  .long 0x00000000
  .long 0x00000000
  .long 0x000000f0
  .long 0x00000000
  # 12th place, lower halfword
  .long 0x00000000
  .long 0x00000000
  .long 0x00000000
  .long 0x00000000
  .long 0x000000f0
  .long 0x00000000
  .long 0x00000000
  .long 0x00000000
  .long 0x00f00000
  .long 0x00000000
  # tier data
  .long 0x3d23d70a # 4%
  .long 0x3da3d70a # 8%
  .long 0x3e19999a # 15%
  .long 0x3e4ccccd # 20%
  .long 0x3e800000 # 25%
  .long 0x3eb33333 # 35%
  .long 0x3ee66666 # 45%
  .long 0x3f19999a # 60%
  .long 0x3f4ccccd # 80%
  .long 0x3f8ccccd # 110%
  .long 0x42000000 # 3200%

the_code:
  mflr r4
  mtlr r12

# get player race completion pointer
lis r11, ptr_playerData@h
ori r11, r11, ptr_playerData@l
lwz r11, 0 (r11)
lwz r11, 12 (r11)
lwz r11, 0 (r11)
addi r11, r11, 12

li r12, 12
mtctr r12

# get player index and race completion
lbz r12, 0x70 (r23)
mulli r12, r12, 0xc4
lfsx f11, r12, r11

fsubs f13, f13, f13

# find 1st place's race completion
max_loop:
  lfs f12, 0 (r11)
  fcmpo cr1, f12, f13
  blt cr1, 0x8
  fmr f13, f12
  addi r11, r11, 0xc4
  bdnz+ max_loop

# difference in race completion
fsubs f13, f13, f11
fsubs f12, f12, f12 # set to 0

# if player is in 1st
li r3, 0
fcmpo cr1, f13, f12
beq cr1, the_end

mr r12, r4
addi r12, r12, 456

li r11, 11
mtctr r11

# loop through tiers to decide
# what place item box to give
tiers_loop:
  lfsx f12, r3, r12
  addi r3, r3, 4
  fcmpo cr1, f13, f12
  blt cr1, the_end
  bdnz+ tiers_loop

# multiply to point to correct
# place in probability table
the_end:
  srwi r3, r3, 2 # divide by 4
  mulli r3, r3, 38

Code created by: Sioist
Code credits: XeR
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)