diff options
author | ghoulslash <41651341+ghoulslash@users.noreply.github.com> | 2021-04-02 10:03:03 -0600 |
---|---|---|
committer | ghoulslash <41651341+ghoulslash@users.noreply.github.com> | 2021-04-02 10:03:03 -0600 |
commit | 44ffca8eb856e5ce9cfc6b9bf36417ec4657d6ae (patch) | |
tree | f7a14d61b987be052b00b7636070fa903bfff5cc | |
parent | 3e6bab718f4ab935f51e0927061e11c636bd1e7f (diff) |
Created Omnidirectional Jump (markdown)
-rw-r--r-- | Omnidirectional-Jump.md | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/Omnidirectional-Jump.md b/Omnidirectional-Jump.md new file mode 100644 index 0000000..880e743 --- /dev/null +++ b/Omnidirectional-Jump.md @@ -0,0 +1,61 @@ +## Omnidirectional Jump + +credits to ghoulslash + +This tutorial teaches you how to create a tile behavior that lets you jump over it from any direction +<a href="https://imgur.com/fT9c6ZV"><img src="https://imgur.com/fT9c6ZV.gif" title="source: imgur.com" /></a> + +### Step 1 - create the behavior +Open [include/constants/metatile_behaviors.h](../blob/master/include/constants/metatile_behaviors.h). Replace an unused behavior with: +e.g.: +```diff +-#define MB_UNUSED_1D 0x1D ++#define MB_OMNIDIRECTIONAL_JUMP 0x1D +``` + +### Step 1 - make the behavior do something +Open [src/event_object_movement.c](../blob/master/src/event_object_movement.c), and find `GetLedgeJumpDirection` and replace the entire function with the following: +```c +u8 GetLedgeJumpDirection(s16 x, s16 y, u8 z) +{ + static bool8 (*const sLedgeJumpBehaviors[])(u8) = { + MetatileBehavior_IsJumpSouth, + MetatileBehavior_IsJumpNorth, + MetatileBehavior_IsJumpWest, + MetatileBehavior_IsJumpEast, + }; + + u8 behavior; + u8 direction = z; + + if (direction == 0) + return 0; + else if (direction > 4) + direction -= 4; + + direction--; + behavior = MapGridGetMetatileBehaviorAt(x, y); + + if (sLedgeJumpBehaviors[direction](behavior) || MetatileBehavior_IsOmnidirectionalJump(behavior)) + return direction + 1; + + return DIR_NONE; +} +``` +### Step 3 - make the function recognize the behavior +Open [src/metatile_behavior.c](../blob/master/src/metatile_behavior.c). Add the following at the end of the file +```c +bool8 MetatileBehavior_IsOmnidirectionalJump(u8 metatileBehavior) +{ + if (metatileBehavior == MB_OMNIDIRECTIONAL_JUMP) + return TRUE; + else + return FALSE; +} +``` + +Then, open [include/metatile_behavior.h](../blob/master/include/metatile_behavior.h) and add the following somewhere: +```diff ++bool8 MetatileBehavior_IsOmnidirectionalJump(u8 metatileBehavior); +``` + |