diff --git a/dev-assets/doodads/azulian/azulian.js b/dev-assets/doodads/azulian/azulian.js index d34cefa..221bc16 100644 --- a/dev-assets/doodads/azulian/azulian.js +++ b/dev-assets/doodads/azulian/azulian.js @@ -52,7 +52,7 @@ function main() { Events.OnCollide((e) => { // If we're diving and we hit the player, game over! // Azulians are friendly to Thieves though! - if (e.Settled && e.Actor.IsPlayer() && e.Actor.Doodad().Filename !== "thief.doodad") { + if (e.Settled && e.Actor.IsPlayer() && e.Actor.Doodad().Filename !== "thief.doodad" && e.Actor.Doodad().Title.indexOf("Azulian") < 0) { FailLevel("Watch out for the Azulians!"); return; } diff --git a/dev-assets/doodads/bird/bird.js b/dev-assets/doodads/bird/bird.js index 8d24276..7a11162 100644 --- a/dev-assets/doodads/bird/bird.js +++ b/dev-assets/doodads/bird/bird.js @@ -144,32 +144,45 @@ function AI_ScanForPlayer() { // If under control of the player character. function player() { + var playerSpeed = 12; + Self.SetInventory(true); Events.OnKeypress((ev) => { Vx = 0; Vy = 0; - if (ev.Up) { - Vy = -playerSpeed; - } else if (ev.Down) { - Vy = playerSpeed; + if (ev.Right) { + direction = "right"; + } else if (ev.Left) { + direction = "left"; } - if (ev.Right) { + // Dive! + if (ev.Down && ev.Right) { + Self.StopAnimation(); + Self.ShowLayerNamed("dive-right"); + } else if (ev.Down && ev.Left) { + Self.StopAnimation(); + Self.ShowLayerNamed("dive-left"); + } else if (ev.Right) { + // Fly right. if (!Self.IsAnimating()) { Self.PlayAnimation("fly-right", null); } Vx = playerSpeed; } else if (ev.Left) { + // Fly left. if (!Self.IsAnimating()) { Self.PlayAnimation("fly-left", null); } Vx = -playerSpeed; } else { - Self.StopAnimation(); - animating = false; + // Hover in place. + if (!Self.IsAnimating()) { + Self.PlayAnimation("fly-"+direction); + } } - Self.SetVelocity(Vector(Vx, Vy)); + // Self.SetVelocity(Vector(Vx, Vy)); }) } diff --git a/dev-assets/doodads/objects/checkpoint-flag.js b/dev-assets/doodads/objects/checkpoint-flag.js index 4e74741..5b28815 100644 --- a/dev-assets/doodads/objects/checkpoint-flag.js +++ b/dev-assets/doodads/objects/checkpoint-flag.js @@ -1,14 +1,25 @@ // Checkpoint Flag. -var isCurrentCheckpoint = false; +var isCurrentCheckpoint = false, + playerEntered = false + broadcastCooldown = time.Now(); function main() { Self.SetHitbox(22 + 16, 16, 75 - 16, 86); setActive(false); + // If the checkpoint is linked to any doodad, the player character will + // become that doodad when they cross this checkpoint. + let skin = null; + for (let actor of Self.GetLinks()) { + skin = actor.Filename; + actor.Destroy(); + } + // Checkpoints broadcast to all of their peers so they all // know which one is the most recently activated. Message.Subscribe("broadcast:checkpoint", (currentID) => { setActive(false); + return "a ok"; }); Events.OnCollide((e) => { @@ -21,10 +32,19 @@ function main() { return; } - // Set the player checkpoint. SetCheckpoint(Self.Position()); setActive(true); - Message.Broadcast("broadcast:checkpoint", Self.ID()) + + // Don't spam the PubSub queue or we get races and deadlocks. + if (time.Now().After(broadcastCooldown)) { + Message.Broadcast("broadcast:checkpoint", Self.ID()); + broadcastCooldown = time.Now().Add(5 * time.Second) + } + + // Are we setting a new player skin? + if (skin && e.Actor.Doodad().Filename !== skin) { + Actors.SetPlayerCharacter(skin); + } }); } diff --git a/dev-assets/doodads/thief/thief.js b/dev-assets/doodads/thief/thief.js index 91ee6a7..77c2a70 100644 --- a/dev-assets/doodads/thief/thief.js +++ b/dev-assets/doodads/thief/thief.js @@ -107,24 +107,17 @@ function ai() { // If under control of the player character. function playable() { Events.OnKeypress((ev) => { - Vx = 0; - Vy = 0; - if (ev.Right) { if (!Self.IsAnimating()) { Self.PlayAnimation("walk-right", null); } - Vx = playerSpeed; } else if (ev.Left) { if (!Self.IsAnimating()) { Self.PlayAnimation("walk-left", null); } - Vx = -playerSpeed; } else { Self.StopAnimation(); animating = false; } - - // Self.SetVelocity(Point(Vx, Vy)); }) }