From e21519f6a1cf5a2f825ad2488d8cd0d23bfc5475 Mon Sep 17 00:00:00 2001 From: Noah Petherbridge Date: Sun, 20 Feb 2022 11:48:36 -0800 Subject: [PATCH] Invulnerable Anvil and other fixes * Add methods `Invulnerable() bool` and `SetInvulnerable(bool)` to the Actor API accessible in JavaScript (e.g. `Self.SetInvulnerable(true)`) * The Anvil is invulnerable - when played as, it can crush other mobs by jumping on them but is not defeated by those mobs at the same time. * Anvils don't destroy invulnerable mobs, such as other Anvils. * Bugfix: the Electric Door is considered to be opened from the first frame of animation when the door begins opening, and remains opened until the final frame of animation when it is closing. * New cheat code: `megaton weight` to play as the Anvil by default. --- dev-assets/doodads/doors/electric-door.js | 2 +- dev-assets/doodads/objects/anvil.js | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/dev-assets/doodads/doors/electric-door.js b/dev-assets/doodads/doors/electric-door.js index c918a3b..5c35201 100644 --- a/dev-assets/doodads/doors/electric-door.js +++ b/dev-assets/doodads/doors/electric-door.js @@ -14,9 +14,9 @@ function setPoweredState(powered) { } animating = true; + opened = true; Sound.Play("electric-door.wav") Self.PlayAnimation("open", () => { - opened = true; animating = false; }); } else { diff --git a/dev-assets/doodads/objects/anvil.js b/dev-assets/doodads/objects/anvil.js index 4390b98..8ea5d59 100644 --- a/dev-assets/doodads/objects/anvil.js +++ b/dev-assets/doodads/objects/anvil.js @@ -6,6 +6,7 @@ function main() { Self.SetHitbox(0, 0, 48, 25); Self.SetMobile(true); Self.SetGravity(true); + Self.SetInvulnerable(true); // Monitor our Y position to tell if we've been falling. let lastPoint = Self.Position(); @@ -33,7 +34,7 @@ function main() { FailLevel("Watch out for anvils!"); return; } - else if (e.Actor.IsMobile()) { + else if (e.Actor.IsMobile() && !e.Actor.Invulnerable()) { // Destroy mobile doodads. Sound.Play("crumbly-break.wav"); e.Actor.Destroy();