Skip to content

Commit 795ec7b

Browse files
committed
include walljump trigger trigger option
1 parent f920841 commit 795ec7b

3 files changed

Lines changed: 44 additions & 2 deletions

File tree

Code/TriggerTrigger.cs

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,15 @@ public class TriggerTrigger : Trigger {
1616
public static void Load() {
1717
On.Celeste.Level.LoadLevel += Level_LoadLevel;
1818
On.Celeste.Player.Jump += Player_Jump;
19+
On.Celeste.Player.WallJump += Player_WallJump;
1920
On.Celeste.PlayerCollider.Check += PlayerCollider_Check;
2021
IL.Monocle.Engine.Update += Engine_Update;
2122
}
2223

2324
public static void Unload() {
2425
On.Celeste.Level.LoadLevel -= Level_LoadLevel;
2526
On.Celeste.Player.Jump -= Player_Jump;
27+
On.Celeste.Player.WallJump -= Player_WallJump;
2628
On.Celeste.PlayerCollider.Check -= PlayerCollider_Check;
2729
IL.Monocle.Engine.Update -= Engine_Update;
2830
}
@@ -73,6 +75,8 @@ public TriggerTrigger(EntityData data, Vector2 offset) : base(data, offset) {
7375
excludeTalkers = data.Bool("excludeTalkers", false);
7476
ifSafe = data.Bool("onlyIfSafe", false);
7577
includeCoyote = data.Bool("includeCoyote", false);
78+
includeWalljump = data.Bool("includeWallJump", false);
79+
resetAfterJump = data.Bool("resetAfterJump", false);
7680
playerState = data.Int("playerState", 0);
7781
if (string.IsNullOrEmpty(data.Attr("entityType", ""))) {
7882
collideType = data.Attr("entityTypeToCollide", "Celeste.Strawberry");
@@ -501,7 +505,35 @@ private static void Player_Jump(On.Celeste.Player.orig_Jump orig, Player self, b
501505
foreach (TriggerTrigger trigger in self.SceneAs<Level>().Tracker.GetEntities<TriggerTrigger>()) {
502506
if (trigger.activationType == ActivationTypes.Jumping) {
503507
trigger.externalActivation = true;
504-
self.Add(new Coroutine(trigger.JumpRoutine(self, trigger), true));
508+
if (trigger.resetAfterJump)
509+
{
510+
trigger.resetActivation = true;
511+
}
512+
else
513+
{
514+
self.Add(new Coroutine(trigger.JumpRoutine(self, trigger), true));
515+
}
516+
}
517+
}
518+
}
519+
520+
private static void Player_WallJump(On.Celeste.Player.orig_WallJump orig, Player self, int dir)
521+
{
522+
orig(self, dir);
523+
if (self == null) { return; }
524+
foreach (TriggerTrigger trigger in self.SceneAs<Level>().Tracker.GetEntities<TriggerTrigger>())
525+
{
526+
if (trigger.activationType == ActivationTypes.Jumping && trigger.includeWalljump)
527+
{
528+
trigger.externalActivation = true;
529+
if (trigger.resetAfterJump)
530+
{
531+
trigger.resetActivation = true;
532+
}
533+
else
534+
{
535+
self.Add(new Coroutine(trigger.JumpRoutine(self, trigger), true));
536+
}
505537
}
506538
}
507539
}
@@ -589,6 +621,8 @@ public static void UpdateFreezeInput()
589621
private bool excludeTalkers;
590622
private bool ifSafe;
591623
private bool includeCoyote;
624+
public bool includeWalljump;
625+
public bool resetAfterJump;
592626
private int playerState;
593627
private TalkComponent talker;
594628
private List<Entity> entitiesInside;

Loenn/lang/en_gb.lang

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -388,6 +388,7 @@ triggers.vitellary/triggertrigger.attributes.description.solidType=Class name of
388388
triggers.vitellary/triggertrigger.attributes.description.inputType=The type of input the player needs to press.
389389
triggers.vitellary/triggertrigger.attributes.description.holdInput=Whether the trigger will be active for the entire time the input is held, or just for the frame it's pressed.
390390
triggers.vitellary/triggertrigger.attributes.description.onlyIfSafe=Whether the floor the player is standing on needs to be safe ground (aka. ground that a berry could be collected on).
391+
triggers.vitellary/triggertrigger.attributes.description.resetAfterJump=If true, the trigger will only be activated for one frame when you jump, rather than waiting until you touch the floor to deactivate.
391392

392393
# Edit Depth Trigger
393394
triggers.vitellary/editdepthtrigger.attributes.description.depth=New depth to set the entity to. Lower / negative values will make the entities render above others.

Loenn/triggers/trigger_trigger.lua

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,9 @@ function triggerTrigger.ignoredFields(entity)
9494
"excludeTalkers",
9595
"onlyIfSafe",
9696
"playerState",
97-
"includeCoyote"
97+
"includeCoyote",
98+
"includeWallJump",
99+
"resetAfterJump",
98100
}
99101

100102
local function doNotIgnore(value)
@@ -145,6 +147,9 @@ function triggerTrigger.ignoredFields(entity)
145147
elseif atype == "OnGrounded" then
146148
doNotIgnore("onlyIfSafe")
147149
doNotIgnore("includeCoyote")
150+
elseif atype == "Jumping" then
151+
doNotIgnore("includeWallJump")
152+
doNotIgnore("resetAfterJump")
148153
elseif atype == "OnPlayerState" then
149154
doNotIgnore("playerState")
150155
end
@@ -190,6 +195,8 @@ for _, mode in pairs(activationTypes) do
190195
onlyIfSafe = false,
191196
playerState = 0,
192197
includeCoyote = false,
198+
includeWallJump = true,
199+
resetAfterJump = false,
193200
}
194201
}
195202
table.insert(triggerTrigger.placements, placement)

0 commit comments

Comments
 (0)