From 509db703852a39abbe61b04d334f3feabf0a3918 Mon Sep 17 00:00:00 2001 From: mjcox244 <66311016+mjcox244@users.noreply.github.com> Date: Sat, 19 Mar 2022 04:30:53 +0000 Subject: [PATCH 1/2] Add more Example Lua mods (#35) --- docs/lua/examples/Instant_Clip.lua | 12 ++++++++++++ docs/lua/examples/Moonjump.lua | 10 ++++++++++ docs/lua/lua.md | 3 +++ mods/Mario-Run.lua | 24 ++++++++++++++++++++++++ 4 files changed, 49 insertions(+) create mode 100644 docs/lua/examples/Instant_Clip.lua create mode 100644 docs/lua/examples/Moonjump.lua create mode 100644 mods/Mario-Run.lua diff --git a/docs/lua/examples/Instant_Clip.lua b/docs/lua/examples/Instant_Clip.lua new file mode 100644 index 00000000..1a735362 --- /dev/null +++ b/docs/lua/examples/Instant_Clip.lua @@ -0,0 +1,12 @@ +-- name: Instant Clip +-- description: Press L trigger, profit! + +function mario_update(m) + if (m.controller.buttonDown & L_TRIG) ~= 0 then -- If L pressed + set_mario_action(m, ACT_WALKING, 0) --set mario to walking so his vel is used + m.forwardVel = 400 --set Velocity to clip speed + end +end + +-- hooks -- +hook_event(HOOK_MARIO_UPDATE, mario_update) \ No newline at end of file diff --git a/docs/lua/examples/Moonjump.lua b/docs/lua/examples/Moonjump.lua new file mode 100644 index 00000000..5927d7b1 --- /dev/null +++ b/docs/lua/examples/Moonjump.lua @@ -0,0 +1,10 @@ +-- name: MoonJump +-- description: Hold the A button to Moonjump +function mario_update(m) + if (m.controller.buttonDown & A_BUTTON) ~= 0 then --If the A button is pressed + m.vel.y = 25 --Set Y velocity to 25 + end +end + +-- hooks -- +hook_event(HOOK_MARIO_UPDATE, mario_update) \ No newline at end of file diff --git a/docs/lua/lua.md b/docs/lua/lua.md index de8b8bf7..fdb5e27e 100644 --- a/docs/lua/lua.md +++ b/docs/lua/lua.md @@ -48,6 +48,7 @@ All of this is a holdover from when there were only two players. It was a reason - [Faster Swimming](../../mods/faster-swimming.lua) - [Hide and Seek Gamemode](../../mods/hide-and-seek.lua) - [Football (soccer) Gamemode](../../mods/football.lua) +- [Mario Run](../../mods/Mario-Run.lua) - [HUD Rendering](examples/hud.lua) - [Object Spawning](examples/spawn-stuff.lua) - [Custom Ball Behavior](examples/behavior-ball.lua) @@ -55,3 +56,5 @@ All of this is a holdover from when there were only two players. It was a reason - [Add to Goomba Behavior](examples/behavior-add-to-goomba.lua) - [Behavior with Surface Collisions](examples/behavior-surface-collisions.lua) - [Custom Box Model](examples/custom-box-model) +- [Moonjump](examples/Moonjump.lua) +- [Instant Clip](examples/Instant_Clip.lua) diff --git a/mods/Mario-Run.lua b/mods/Mario-Run.lua new file mode 100644 index 00000000..b9ea3bbe --- /dev/null +++ b/mods/Mario-Run.lua @@ -0,0 +1,24 @@ +-- name: Mario RUN! +-- description: Mario Is contantly runing + +Threshold = 50 --set Threshold to 50 + +function mario_update(m) + --Prevent mario from ideling + if m.action == ACT_IDLE then --If idle + set_mario_action(m, ACT_WALKING, 0) --Make Mario walk + end + + --Crouching doesnt apply vel so prevent that + if m.action == ACT_CROUCHING then --If crouching + set_mario_action(m, ACT_WALKING, 0) --Make Mario walk + end + + --Speed floor + if (m.forwardVel > 0-Threshold) and (m.forwardVel < Threshold) then --If Mario isn't moveing fast enough + m.forwardVel = Threshold --set forwards velocity to whatevet the threashold is set to + end +end + +-- hooks -- +hook_event(HOOK_MARIO_UPDATE, mario_update) From 579fa405241a29af75753942956e3b4db73a1cef Mon Sep 17 00:00:00 2001 From: Prince Frizzy Date: Sat, 19 Mar 2022 00:31:04 -0400 Subject: [PATCH 2/2] Some small cleanup, And re-add generating the coop.map to the Makefile. (#36) --- Makefile | 6 +++ src/game/behaviors/treasure_chest.inc.c | 63 +++++++++++++------------ 2 files changed, 38 insertions(+), 31 deletions(-) diff --git a/Makefile b/Makefile index c3f9fd25..9aea84ae 100644 --- a/Makefile +++ b/Makefile @@ -1045,6 +1045,12 @@ endif #all: $(ROM) all: $(EXE) +ifeq ($(WINDOWS_BUILD),1) +exemap: $(EXE) + $(V)$(OBJDUMP) -t $(EXE) > $(BUILD_DIR)/coop.map +all: exemap +endif + ifeq ($(COMPARE),1) @$(PRINT) "$(GREEN)Checking if ROM matches.. $(NO_COL)\n" @$(SHA1SUM) --quiet -c $(TARGET).sha1 && $(PRINT) "$(TARGET): $(GREEN)OK$(NO_COL)\n" || ($(PRINT) "$(YELLOW)Building the ROM file has succeeded, but does not match the original ROM.\nThis is expected, and not an error, if you are making modifications.\nTo silence this message, use 'make COMPARE=0.' $(NO_COL)\n" && false) diff --git a/src/game/behaviors/treasure_chest.inc.c b/src/game/behaviors/treasure_chest.inc.c index 8187b5f5..18dfae41 100644 --- a/src/game/behaviors/treasure_chest.inc.c +++ b/src/game/behaviors/treasure_chest.inc.c @@ -19,42 +19,43 @@ void bhv_treasure_chest_top_loop(void) { struct Object* sp34 = o->parentObj->parentObj; switch (o->oAction) { - case 0: - if (o->parentObj->oAction == 1) - o->oAction = 1; - break; - - case 1: - if (o->oTimer == 0) { - if (sp34->oTreasureChestUnkFC == 0) { - spawn_object_relative(0, 0, -80, 120, o, MODEL_BUBBLE, bhvWaterAirBubble); - play_sound(SOUND_GENERAL_CLAM_SHELL1, o->header.gfx.cameraToObject); + case 0: + if (o->parentObj->oAction == 1) { + o->oAction = 1; } - else { - play_sound(SOUND_GENERAL_OPEN_CHEST, o->header.gfx.cameraToObject); + break; + + case 1: + if (o->oTimer == 0) { + if (sp34->oTreasureChestUnkFC == 0) { + spawn_object_relative(0, 0, -80, 120, o, MODEL_BUBBLE, bhvWaterAirBubble); + play_sound(SOUND_GENERAL_CLAM_SHELL1, o->header.gfx.cameraToObject); + } else { + play_sound(SOUND_GENERAL_OPEN_CHEST, o->header.gfx.cameraToObject); + } } - } - o->oFaceAnglePitch += -0x200; - if (o->oFaceAnglePitch < -0x4000) { - o->oFaceAnglePitch = -0x4000; - o->oAction++; - if (o->parentObj->oBehParams2ndByte != 4) - spawn_orange_number(o->parentObj->oBehParams2ndByte, 0, -40, 0); - } - break; + o->oFaceAnglePitch += -0x200; + if (o->oFaceAnglePitch < -0x4000) { + o->oFaceAnglePitch = -0x4000; + o->oAction++; + if (o->parentObj->oBehParams2ndByte != 4) + spawn_orange_number(o->parentObj->oBehParams2ndByte, 0, -40, 0); + } + break; - case 2: - if (o->parentObj->oAction == 0) - o->oAction = 3; - break; + case 2: + if (o->parentObj->oAction == 0) { + o->oAction = 3; + } + break; - case 3: - o->oFaceAnglePitch += 0x800; - if (o->oFaceAnglePitch > 0) { - o->oFaceAnglePitch = 0; - o->oAction = 0; - } + case 3: + o->oFaceAnglePitch += 0x800; + if (o->oFaceAnglePitch > 0) { + o->oFaceAnglePitch = 0; + o->oAction = 0; + } } }