Completed Custom Subaction Event - Create Reflect Hitboxes

Joined
Nov 9, 2014
Messages
635
#1

Code:
$Custom Subaction Event - Create Reflect Hitbox [UnclePunch]
04007c44 60000000
0400a9dc 60000000
C2071774 00000017
80A40008 89C50001
2C0E0000 41820094
7FC7F378 38C00001
3DC08006 61CEDA48
91C721C8 A1C50002
55CE801E 91C71A04
A1C50004 55CE801E
91C71A34 A1C50006
55CE801E 91C71A38
A1C50008 55CE801E
91C719F8 A1C5000A
55CE801E 91C719FC
38000032 90071A30
38000010 98072218
38000001 806705E8
54002036 7C03002E
900719E4 38000000
90071A00 39C00000
99C719E8 3805000C
90040008 48000014
39C00000 99DE2218
38050004 90040008
4E800020 00000000
Custom Subaction Format
Enable Reflect: FF01RRRR DDDDSSSS XXXXYYYY
Disable Reflect: FF000000


FF = Reflect Subaction Command Byte
00/01 = Used by the function to determine whether to enable the reflect hitbox or disable it. Keep this 01 for enabling and 00 for disabling.

RRRR = Radius Size, use the upper 2 bytes of a single floating point representation*
DDDD = Damage Multiplier, use the upper 2 bytes of a single floating point representation*
SSSS = Projectile Speed Multiplier, use the upper 2 bytes of a single floating point representation*
XXXX = X Position, use the upper 2 bytes of a single floating point representation*
YYYY = Y Position, use the upper 2 bytes of a single floating point representation*

*Use the converter here, http://www6.uniovi.es/~antonio/uned/ieee754/IEEE-754.html



Example in Crazy Hand:

Code:
#r5 = subaction RAM location

lwz    r5,0x8(r4)                #load current subaction RAM location
lbz r14,0x1(r5)            #get enable/disable byte
cmpwi r14,0x0            #check if 0
beq disableReflect            #branch to disable reflect


enableReflect:                #a lot of this code was copied from the game's createReflectHitbox function
mr r7,player                #move player block pointer into r7
li    r6, 1
load r14,0x8006da48                 #function that points to blr
stw    r14, 0x21C8 (r7)            #store in address that is read on reflectHit
lhz r14,0x2(r5)                #get radius from subaction syntax
slwi r14,r14,16
stw r14, 0x1A04 (r7)                #radius size
lhz r14,0x4(r5)                #get damage mult from subaction syntax
slwi r14,r14,16
stw r14, 0x1A34 (r7)                #damage multiplier
lhz r14,0x6(r5)                #get speed mult from subaction syntax
slwi r14,r14,16
stw r14, 0x1A38 (r7)                #speed multiplier
lhz r14,0x8(r5)                #get x from subaction syntax
slwi r14,r14,16
stw    r14, 0x19F8 (r7)            #x position
lhz r14,0xa(r5)                #get Y from subaction syntax
slwi r14,r14,16
stw    r14, 0x19FC (r7)            #y position
li r0,0x32
stw    r0, 0x1A30 (r7)            #max damage reflectable
li r0,0x10              
stb    r0, 0x2218 (r7)            #set reflectActive flag to active
li r0,0x1
lwz    r3, 0x05E8 (r7)
rlwinm    r0, r0, 4, 0, 27
lwzx    r0, r3, r0
stw    r0, 0x19E4 (r7)
li r0,0
stw    r0, 0x1A00 (r7)            #z position
li r14,0x0                #flag that needs to be set in order for reflector hitbox to follow players
stb r14,0x19e8(r7)
addi r0,r5,0xC
stw r0,0x8(r4)
b done

disableReflect:
li r14,0
setReflectFlag r14                #set reflectActive flag to inactive
addi r0,r5,0x4
stw r0,0x8(r4)

done:
blr
Thanks @Achilles1515 and @Punkline for their help!
 
Last edited:
Top