abysspartyy
Smash Cadet
- Joined
- May 11, 2015
- Messages
- 55
* note: the match above has a damage ratio of 0.25 so players aren't killed in one hit
- Every hit will roll a number between 0 to 100 and multiply the hit's damage by that number divided by 10
- Example: so if a hit does 25 damage and our random number is 26, the final damage calculation is as follows:
(25 * 26) / 10 = 65.0 damage
In other words, it did 2.6 times the damage.
- Example: so if a hit does 25 damage and our random number is 26, the final damage calculation is as follows:
((101 - 1) / 10)
the damage!If you want to change the maximum multiplier, change the highlighted part in orange to whatever multiplier you want in hex.
For example, I want it to do between 0 and 3 times the damage only:
- Add 1 to 3 = 4
- Multiply 4 by 10 = 40
- Convert it to hex (use a hex converter online) = 28
- Change the highlighted part from 65 to 28
Rich (BB code):
$Random Damage Multiplier [sushie]
*Every hit has a random multiplier applied to it
C2089284 00000007
38600065 3D808038
618C0580 7D8903A6
4E800421 3C63000A
90610014 E3E15014
102107DA 1021F824
48000004 8001002C
60000000 00000000
Python:
import geckon, ../melee
const
MaxMultiplier = 10.0
Divisor = 10
OriginalCodeLine = ppc: lwz r0, 0x002C(sp)
defineCodes:
createCode "Random Damage Multiplier":
authors "sushie"
description "Every hit has a random multiplier applied to it"
patchInsertAsm "80089284":
# free to use: f31, r0, r30, r31
{hsdRandi(maxVal = (MaxMultiplier * 10).intVal, inclusive = true)}
# Cast the Divisor and our multiplier as floats into f31
addis r3, r3, {Divisor}
stw r3, 0x14(sp)
psq_l f31, 0x14(sp), 0, 5
# Multiply damage by multiplier
ps_muls1 f1, f1, f31
# Divide our new damage by 10 and store in f1
ps_div f1, f1, f31
b OriginalExit
OriginalExit:
{OriginalCodeLine}
Rich (BB code):
$Random Damage Multiplier (Non-projectile) [sushie]
C207AC30 00000012
FC400890 38600065
3D808038 618C0580
7D8903A6 4E800421
48000029 EC220072
48000019 7C6802A6
C0430000 EC211024
FC00081E 48000054
4E800021 41200000
7C0802A6 90010004
9421FF00 BE810008
D0410038 3C004330
C84298A8 6C638000
900100F0 906100F4
C82100F0 EC211028
C0410038 BA810008
80010104 38210100
7C0803A6 4E800020
7FE3FB78 00000000
Rich (BB code):
$Random Damage Multiplier (Projectiles) [sushie]
*Every projectile hit has a random damage multiplier applied to it
C22724A8 00000012
7C7E1B78 38600191
3D808038 618C0580
7D8903A6 4E800421
2C030000 4081006C
48000021 48000015
7C6802A6 C0430000
EC411024 48000054
4E800021 41200000
7C0802A6 90010004
9421FF00 BE810008
D0410038 3C004330
C84298A8 6C638000
900100F0 906100F4
C82100F0 EC211028
C0410038 BA810008
80010104 38210100
7C0803A6 4E800020
7FC3F378 00000000
Python:
import geckon
const
FuncIntToFloat = "IntToFloat"
MultiplierMax = 40.0 # up to 40 times the damage
RegisterMultiplier = f2
RegisterRandomMultiplier = f1
OriginalCodeLine = ppc:
mr r30, r3
defineCodes:
createCode "Random Damage Multiplier (Projectiles)":
authors "Odante"
description "Every projectile hit has a random damage multiplier applied to it"
patchInsertAsm "802724A8":
{OriginalCodeLine}
# get random multiplier in r3
{hsdRandi(max = (MultiplierMax * 10).int, inclusive = true)}
# multiplier shouldn't be 0
CheckIfValidMultiplier:
cmpwi r3, 0
ble Exit
bl {FuncIntToFloat} # convert to float, result is now in f1
# divide multiplier by 10
# safe to use f2 because we are going to overwrite it anyways
bl MultiplierFloats
mflr r3
# load the float 10 into f2
lfs {RegisterMultiplier}, DivisorOffset(r3)
# divide our random multiplier (f1) by 10 (f2) and store it back into f2
fdivs {RegisterMultiplier}, {RegisterRandomMultiplier}, {RegisterMultiplier}
b Exit
MultiplierFloats:
blrl
`.set` DivisorOffset, 0x0
`.float` 10.0
{FuncIntToFloat}:
{defineIntToFloat()}
Exit:
mr r3, r30 # restore r3
Code:
####################################################
Random Damage Multiplier (Non-projectiles) [Odante]
####################################################
PatchHookBranchLink 0x8007ac30 {
.macro branchl reg, address
lis \reg, \address @h
ori \reg,\reg,\address @l
mtctr \reg
bctrl
.endm
# maximum random multiplier / 10
# example: 100 = 10 times the damage
# 50 = 5 times the damage
# 5 = 0.5 times the damage
.set MultiplierMax, 100
# f1 contains our original damage
# after all calculations including model scale and
# smash attack charging
# r3 is free to use here, no backup needed
DamageMultiplier:
fmr f2, f1 # backup f1 - original damage to deal
li r3, MultiplierMax + 1 # set max num to generate (from 0 to max (not including max))
branchl r12, HSD_Randi
bl IntToFloat # convert to float and store result in f1
fmuls f1, f2, f1 # multiply damage (in f2) by multiplier (in f1) and store in f1
# f2 is free to use now
# Divide our damage by 10
bl MultiplierFloat
mflr r3
lfs f2, 0x0(r3) # load 10.0 into f2
fdivs f1,f1,f2 # divide damage (in f1) by 10 (in f2) and store in f1
fctiwz f0,f1
b Original_Exit
MultiplierFloat:
blrl
.float 10.0
##############################
# Credits to UnclePunch
# From: https://github.com/UnclePunch/Training-Mode/blob/master/ASM/training-mode/Onscreen%20Display/Wavedash%20Display/Wavedash%20Timing%20Display.asm
IntToFloat:
mflr r0
stw r0, 0x4(r1)
stwu r1,-0x100(r1) # make space for 12 registers
stmw r20,0x8(r1)
stfs f2,0x38(r1)
lis r0, 0x4330
lfd f2, -0x6758 (rtoc)
xoris r3, r3,0x8000
stw r0,0xF0(sp)
stw r3,0xF4(sp)
lfd f1,0xF0(sp)
fsubs f1,f1,f2 #Convert To Float
lfs f2,0x38(r1)
lmw r20,0x8(r1)
lwz r0, 0x104(r1)
addi r1,r1,0x100 # release the space
mtlr r0
blr
##############################
Original_Exit:
mr r3, r31
}
Thank you to

Also thank you to

Last edited: