Skip to content

Instantly share code, notes, and snippets.

@jugeeya
Last active May 13, 2018 23:05
Show Gist options
  • Save jugeeya/f43434a721c63d3cc93acb348ef69ffa to your computer and use it in GitHub Desktop.
Save jugeeya/f43434a721c63d3cc93acb348ef69ffa to your computer and use it in GitHub Desktop.
Sm4sh teleporting via input command script
// in script_11, see accompanying asm example to see where loc_9 is
// this contains all the code between loc_9 and loc_A in that
void loc_9()
{
global18 = sys_18(1);
// If this is a new frame, i.e. currentFrame globalvar isn't current
if(global14 != sys_13(1))
{
if(global26 & 0x4 /*If B is pressed*/ || sys_e(10002, 1) /*Or if B is held*/)
{
// set current position
sys_14( 0x3,
sys_1b(1), // Get center stage X (would get ledge position X if the ledge collision existed)
sys_1b(2) + 5f, // Get center stage Y (same as above)
sys_1b(0xc)); // Get current player Z
}
}
}
begin 0x0, 0x0
pushInt. 0x1
sys. 0x1, 0x30
pushInt. 0x0
equals.
if loc_7
pushVar. 0x1, 0x8
pushInt. 0x0
equals.
if loc_1
pushVar. 0x1, 0x9
pushInt. 0x49742400
floatLess.
if loc_1
pushInt. 0x1
else loc_2
loc_1:
pushInt. 0x0
loc_2:
if loc_5
pushInt. 0x2
sys. 0x1, 0x49
pushInt. 0x1
equals.
if loc_3
pushInt. 0x0
sys. 0x1, 0x4c
float+= 0x1, 0x9
pushInt. 0x1
setVar 0x1, 0x3
else loc_4
loc_3:
pushVar. 0x1, 0xa
pushInt. 0x3f800000
addf.
floatVarSet 0x1, 0x9
pushVar. 0x1, 0x9
floatVarSet 0x1, 0xa
pushInt. 0x0
setVar 0x1, 0x3
loc_4:
else loc_6
loc_5:
pushInt. 0x2
sys. 0x1, 0x49
setVar 0x1, 0x3
loc_6:
else loc_8
loc_7:
pushInt. 0x1
setVar 0x1, 0x3
loc_8:
pushVar. 0x1, 0xe
pushInt. 0x0
notEqual.
if loc_9
unk_2E loc_9
pushVar. 0x1, 0xe
callFunc 0x0
loc_9:
pushInt. 0x1
sys. 0x1, 0x18
setVar 0x1, 0x12
# this is the perfect spot to have anything done once a frame
pushInt. 0x1
sys. 0x1, 0x13
pushVar. 0x1, 0x14
notEquals.
if newFrame
pushVar. 0x1, 0x26
pushInt. 0x4
bitAnd. # B is pressed
pushInt. 0x2712
pushInt. 0x1
sys. 0x2, 0xe # B is held
bitOr.
if BPressedOrHeld
pushInt. 0x3
pushInt. 0x1
sys. 0x1, 0x1b # get X ledge position (instead gets centerstage pos)
pushInt. 0x2
sys. 0x1, 0x1b # get Y ledge position
pushInt. 5.0f
addf. # ledge Y + 5
pushInt. 0xc
sys. 0x1, 0x1b # get current Z position
sys 0x4, 0x14 # set absolute position
BPressedOrHeld:
newFrame:
pushInt. 0x1
sys. 0x1, 0x13 #"push animation frame"
floatVarSet 0x1, 0x14
pushVar. 0x1, 0x2
pushInt. 0x0
notEqual.
if loc_B
unk_2E loc_A
pushVar. 0x1, 0x2
callFunc 0x0
loc_A:
pushInt. 0x0
setVar 0x1, 0x2
loc_B:
pushVar. 0x1, 0x3
not.
if loc_D
pushVar. 0x1, 0xf
pushInt. 0x0
notEqual.
if loc_C
unk_2E loc_C
pushVar. 0x1, 0xf
callFunc 0x0
loc_C:
pushVar. 0x1, 0x10
pushInt. 0x0
notEqual.
if loc_D
unk_2E loc_D
pushVar. 0x1, 0x10
callFunc 0x0
loc_D:
pushInt. 0x0
setVar 0x1, 0x8
end
@jugeeya
Copy link
Author

jugeeya commented May 13, 2018

https://gfycat.com/ShoddyTanFairyfly What it looks like in-game. It's a bit janky of course, but if the conditions are changed (for example, only upon pressing B), it would look much more natural.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment