Thief and Inventory APIs
This commit adds the Thief character with starter graphics
(no animations).
The Thief walks back and forth and will steal items from other
doodads, including the player. For singleton items that have no
quantity, like the Colored Keys, the Thief will only steal one
if he does not already have it. Quantitied items like the
Small Key are always stolen.
Flexibility in the playable character is introduced: Boy,
Azulian, Bird, and Thief all respond to playable controls.
There is not currently a method to enable these apart from
modifying balance.PlayerCharacterDoodad at compile time.
New and Changed Doodads
* Thief: new doodad that walks back and forth and will steal
items from other characters inventory.
* Bird: has no inventory and cannot pick up items, unless player
controlled. Its hitbox has also been fixed so it collides with
floors correctly - not something normally seen in the Bird.
* Boy: opts in to have inventory.
* Keys (all): only gives themselves to actors having inventories.
JavaScript API - New functions available
* Self.IsPlayer() - returns if the current actor IS the player.
* Self.SetInventory(bool) - doodads must opt-in to having an
inventory. Keys should only give themselves to doodads having
an inventory.
* Self.HasInventory() bool
* Self.AddItem(filename, qty)
* Self.RemoveItem(filename, qty)
* Self.HasItem(filename)
* Self.Inventory() - returns map[string]int
* Self.ClearInventory()
* Self.OnLeave(func(e)) now receives a CollideEvent as parameter
instead of the useless actor ID. Notably, e.Actor is the
leaving actor and e.Settled is always true.
Other Changes
* Play Mode: if playing as a character which doesn't obey gravity,
such as the bird, antigravity controls are enabled by default.
If you `import antigravity` you can turn gravity back on.
* Doodad collision scripts are no longer run in parallel
goroutines. It made the Thief's job difficult trying to steal
items in many threads simultaneously!
2021-08-10 05:42:22 +00:00
|
|
|
// Bird
|
|
|
|
|
2022-01-18 05:28:05 +00:00
|
|
|
let speed = 4,
|
2022-03-07 06:16:09 +00:00
|
|
|
Vx = Vy = 0,
|
|
|
|
altitude = Self.Position().Y; // original height in the level
|
2020-12-30 04:31:35 +00:00
|
|
|
|
2022-01-19 02:32:15 +00:00
|
|
|
let direction = "left",
|
|
|
|
lastDirection = "left";
|
|
|
|
let states = {
|
|
|
|
flying: 0,
|
|
|
|
diving: 1,
|
|
|
|
};
|
|
|
|
let state = states.flying;
|
2020-12-30 04:31:35 +00:00
|
|
|
|
2022-01-18 05:28:05 +00:00
|
|
|
function main() {
|
2020-12-30 04:31:35 +00:00
|
|
|
Self.SetMobile(true);
|
|
|
|
Self.SetGravity(false);
|
Thief and Inventory APIs
This commit adds the Thief character with starter graphics
(no animations).
The Thief walks back and forth and will steal items from other
doodads, including the player. For singleton items that have no
quantity, like the Colored Keys, the Thief will only steal one
if he does not already have it. Quantitied items like the
Small Key are always stolen.
Flexibility in the playable character is introduced: Boy,
Azulian, Bird, and Thief all respond to playable controls.
There is not currently a method to enable these apart from
modifying balance.PlayerCharacterDoodad at compile time.
New and Changed Doodads
* Thief: new doodad that walks back and forth and will steal
items from other characters inventory.
* Bird: has no inventory and cannot pick up items, unless player
controlled. Its hitbox has also been fixed so it collides with
floors correctly - not something normally seen in the Bird.
* Boy: opts in to have inventory.
* Keys (all): only gives themselves to actors having inventories.
JavaScript API - New functions available
* Self.IsPlayer() - returns if the current actor IS the player.
* Self.SetInventory(bool) - doodads must opt-in to having an
inventory. Keys should only give themselves to doodads having
an inventory.
* Self.HasInventory() bool
* Self.AddItem(filename, qty)
* Self.RemoveItem(filename, qty)
* Self.HasItem(filename)
* Self.Inventory() - returns map[string]int
* Self.ClearInventory()
* Self.OnLeave(func(e)) now receives a CollideEvent as parameter
instead of the useless actor ID. Notably, e.Actor is the
leaving actor and e.Settled is always true.
Other Changes
* Play Mode: if playing as a character which doesn't obey gravity,
such as the bird, antigravity controls are enabled by default.
If you `import antigravity` you can turn gravity back on.
* Doodad collision scripts are no longer run in parallel
goroutines. It made the Thief's job difficult trying to steal
items in many threads simultaneously!
2021-08-10 05:42:22 +00:00
|
|
|
Self.SetHitbox(0, 0, 46, 32);
|
2020-12-30 04:31:35 +00:00
|
|
|
Self.AddAnimation("fly-left", 100, ["left-1", "left-2"]);
|
|
|
|
Self.AddAnimation("fly-right", 100, ["right-1", "right-2"]);
|
|
|
|
|
Thief and Inventory APIs
This commit adds the Thief character with starter graphics
(no animations).
The Thief walks back and forth and will steal items from other
doodads, including the player. For singleton items that have no
quantity, like the Colored Keys, the Thief will only steal one
if he does not already have it. Quantitied items like the
Small Key are always stolen.
Flexibility in the playable character is introduced: Boy,
Azulian, Bird, and Thief all respond to playable controls.
There is not currently a method to enable these apart from
modifying balance.PlayerCharacterDoodad at compile time.
New and Changed Doodads
* Thief: new doodad that walks back and forth and will steal
items from other characters inventory.
* Bird: has no inventory and cannot pick up items, unless player
controlled. Its hitbox has also been fixed so it collides with
floors correctly - not something normally seen in the Bird.
* Boy: opts in to have inventory.
* Keys (all): only gives themselves to actors having inventories.
JavaScript API - New functions available
* Self.IsPlayer() - returns if the current actor IS the player.
* Self.SetInventory(bool) - doodads must opt-in to having an
inventory. Keys should only give themselves to doodads having
an inventory.
* Self.HasInventory() bool
* Self.AddItem(filename, qty)
* Self.RemoveItem(filename, qty)
* Self.HasItem(filename)
* Self.Inventory() - returns map[string]int
* Self.ClearInventory()
* Self.OnLeave(func(e)) now receives a CollideEvent as parameter
instead of the useless actor ID. Notably, e.Actor is the
leaving actor and e.Settled is always true.
Other Changes
* Play Mode: if playing as a character which doesn't obey gravity,
such as the bird, antigravity controls are enabled by default.
If you `import antigravity` you can turn gravity back on.
* Doodad collision scripts are no longer run in parallel
goroutines. It made the Thief's job difficult trying to steal
items in many threads simultaneously!
2021-08-10 05:42:22 +00:00
|
|
|
// Player Character controls?
|
|
|
|
if (Self.IsPlayer()) {
|
|
|
|
return player();
|
|
|
|
}
|
|
|
|
|
2022-01-17 04:09:27 +00:00
|
|
|
Events.OnCollide((e) => {
|
2022-01-18 05:28:05 +00:00
|
|
|
// If we're diving and we hit the player, game over!
|
|
|
|
if (e.Settled && state === states.diving && e.Actor.IsPlayer()) {
|
|
|
|
FailLevel("Watch out for birds!");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2022-03-27 18:51:14 +00:00
|
|
|
if (e.Actor.IsMobile() && e.Actor.HasGravity() && e.InHitbox) {
|
2020-12-30 04:31:35 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
// Sample our X position every few frames and detect if we've hit a solid wall.
|
2022-01-17 04:09:27 +00:00
|
|
|
let sampleTick = 0,
|
|
|
|
sampleRate = 2,
|
2022-01-18 05:28:05 +00:00
|
|
|
lastSampled = Point(0, 0);
|
2020-12-30 04:31:35 +00:00
|
|
|
|
2022-01-17 04:09:27 +00:00
|
|
|
setInterval(() => {
|
2022-01-18 05:28:05 +00:00
|
|
|
// Sample how far we've moved to detect hitting a wall.
|
2020-12-30 04:31:35 +00:00
|
|
|
if (sampleTick % sampleRate === 0) {
|
2022-01-18 05:28:05 +00:00
|
|
|
let curP = Self.Position()
|
|
|
|
let delta = Math.abs(curP.X - lastSampled.X);
|
2020-12-30 04:31:35 +00:00
|
|
|
if (delta < 5) {
|
|
|
|
direction = direction === "right" ? "left" : "right";
|
|
|
|
}
|
2022-01-18 05:28:05 +00:00
|
|
|
|
|
|
|
// If we were diving, check Y delta too for if we hit floor
|
|
|
|
if (state === states.diving && Math.abs(curP.Y - lastSampled.Y) < 5) {
|
|
|
|
state = states.flying;
|
|
|
|
}
|
|
|
|
lastSampled = curP
|
2020-12-30 04:31:35 +00:00
|
|
|
}
|
|
|
|
sampleTick++;
|
|
|
|
|
2022-01-18 05:28:05 +00:00
|
|
|
// Are we diving?
|
|
|
|
if (state === states.diving) {
|
|
|
|
Vy = speed
|
|
|
|
} else {
|
|
|
|
// If we are not flying at our original altitude, correct for that.
|
|
|
|
let curV = Self.Position();
|
|
|
|
Vy = 0.0;
|
|
|
|
if (curV.Y != altitude) {
|
|
|
|
Vy = curV.Y < altitude ? 1 : -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Scan for the player character and dive.
|
|
|
|
try {
|
|
|
|
AI_ScanForPlayer()
|
2022-03-07 06:16:09 +00:00
|
|
|
} catch (e) {
|
2022-01-18 05:28:05 +00:00
|
|
|
console.error("Error in AI_ScanForPlayer: %s", e);
|
|
|
|
}
|
2021-10-13 03:49:48 +00:00
|
|
|
}
|
|
|
|
|
2020-12-30 04:31:35 +00:00
|
|
|
// TODO: Vector() requires floats, pain in the butt for JS,
|
|
|
|
// the JS API should be friendlier and custom...
|
2022-01-17 04:09:27 +00:00
|
|
|
let Vx = parseFloat(speed * (direction === "left" ? -1 : 1));
|
2021-10-13 03:49:48 +00:00
|
|
|
Self.SetVelocity(Vector(Vx, Vy));
|
2020-12-30 04:31:35 +00:00
|
|
|
|
2022-01-18 05:28:05 +00:00
|
|
|
// If diving, exit - don't edit animation.
|
|
|
|
if (state === states.diving) {
|
2022-03-07 06:16:09 +00:00
|
|
|
Self.ShowLayerNamed("dive-" + direction);
|
2022-01-18 05:28:05 +00:00
|
|
|
lastDirection = direction;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2021-09-04 02:54:10 +00:00
|
|
|
// If we changed directions, stop animating now so we can
|
|
|
|
// turn around quickly without moonwalking.
|
|
|
|
if (direction !== lastDirection) {
|
|
|
|
Self.StopAnimation();
|
|
|
|
}
|
|
|
|
|
2020-12-30 04:31:35 +00:00
|
|
|
if (!Self.IsAnimating()) {
|
Thief and Inventory APIs
This commit adds the Thief character with starter graphics
(no animations).
The Thief walks back and forth and will steal items from other
doodads, including the player. For singleton items that have no
quantity, like the Colored Keys, the Thief will only steal one
if he does not already have it. Quantitied items like the
Small Key are always stolen.
Flexibility in the playable character is introduced: Boy,
Azulian, Bird, and Thief all respond to playable controls.
There is not currently a method to enable these apart from
modifying balance.PlayerCharacterDoodad at compile time.
New and Changed Doodads
* Thief: new doodad that walks back and forth and will steal
items from other characters inventory.
* Bird: has no inventory and cannot pick up items, unless player
controlled. Its hitbox has also been fixed so it collides with
floors correctly - not something normally seen in the Bird.
* Boy: opts in to have inventory.
* Keys (all): only gives themselves to actors having inventories.
JavaScript API - New functions available
* Self.IsPlayer() - returns if the current actor IS the player.
* Self.SetInventory(bool) - doodads must opt-in to having an
inventory. Keys should only give themselves to doodads having
an inventory.
* Self.HasInventory() bool
* Self.AddItem(filename, qty)
* Self.RemoveItem(filename, qty)
* Self.HasItem(filename)
* Self.Inventory() - returns map[string]int
* Self.ClearInventory()
* Self.OnLeave(func(e)) now receives a CollideEvent as parameter
instead of the useless actor ID. Notably, e.Actor is the
leaving actor and e.Settled is always true.
Other Changes
* Play Mode: if playing as a character which doesn't obey gravity,
such as the bird, antigravity controls are enabled by default.
If you `import antigravity` you can turn gravity back on.
* Doodad collision scripts are no longer run in parallel
goroutines. It made the Thief's job difficult trying to steal
items in many threads simultaneously!
2021-08-10 05:42:22 +00:00
|
|
|
Self.PlayAnimation("fly-" + direction, null);
|
2020-12-30 04:31:35 +00:00
|
|
|
}
|
2021-09-04 02:54:10 +00:00
|
|
|
|
|
|
|
lastDirection = direction;
|
2020-12-30 04:31:35 +00:00
|
|
|
}, 100);
|
|
|
|
}
|
Thief and Inventory APIs
This commit adds the Thief character with starter graphics
(no animations).
The Thief walks back and forth and will steal items from other
doodads, including the player. For singleton items that have no
quantity, like the Colored Keys, the Thief will only steal one
if he does not already have it. Quantitied items like the
Small Key are always stolen.
Flexibility in the playable character is introduced: Boy,
Azulian, Bird, and Thief all respond to playable controls.
There is not currently a method to enable these apart from
modifying balance.PlayerCharacterDoodad at compile time.
New and Changed Doodads
* Thief: new doodad that walks back and forth and will steal
items from other characters inventory.
* Bird: has no inventory and cannot pick up items, unless player
controlled. Its hitbox has also been fixed so it collides with
floors correctly - not something normally seen in the Bird.
* Boy: opts in to have inventory.
* Keys (all): only gives themselves to actors having inventories.
JavaScript API - New functions available
* Self.IsPlayer() - returns if the current actor IS the player.
* Self.SetInventory(bool) - doodads must opt-in to having an
inventory. Keys should only give themselves to doodads having
an inventory.
* Self.HasInventory() bool
* Self.AddItem(filename, qty)
* Self.RemoveItem(filename, qty)
* Self.HasItem(filename)
* Self.Inventory() - returns map[string]int
* Self.ClearInventory()
* Self.OnLeave(func(e)) now receives a CollideEvent as parameter
instead of the useless actor ID. Notably, e.Actor is the
leaving actor and e.Settled is always true.
Other Changes
* Play Mode: if playing as a character which doesn't obey gravity,
such as the bird, antigravity controls are enabled by default.
If you `import antigravity` you can turn gravity back on.
* Doodad collision scripts are no longer run in parallel
goroutines. It made the Thief's job difficult trying to steal
items in many threads simultaneously!
2021-08-10 05:42:22 +00:00
|
|
|
|
2022-01-18 05:28:05 +00:00
|
|
|
// A.I. subroutine: scan for the player character.
|
|
|
|
// The bird scans in a 45 degree angle downwards, if the
|
|
|
|
// player is seen nearby in that scan it will begin a dive.
|
2022-01-19 02:32:15 +00:00
|
|
|
// It's not hostile towards characters that can fly (having
|
|
|
|
// no gravity).
|
2022-01-18 05:28:05 +00:00
|
|
|
function AI_ScanForPlayer() {
|
2022-03-07 06:16:09 +00:00
|
|
|
// If Peaceful difficulty, do not attack.
|
|
|
|
if (Level.Difficulty < 0) {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2022-01-18 05:28:05 +00:00
|
|
|
let stepY = 12, // number of pixels to skip
|
|
|
|
stepX = stepY,
|
|
|
|
limit = stepX * 20, // furthest we'll scan
|
|
|
|
scanX = scanY = 0,
|
|
|
|
size = Self.Size(),
|
|
|
|
fromPoint = Self.Position();
|
|
|
|
|
|
|
|
// From what point do we begin the scan?
|
|
|
|
if (direction === 'left') {
|
|
|
|
stepX = -stepX;
|
|
|
|
fromPoint.Y += size.H;
|
|
|
|
} else {
|
|
|
|
fromPoint.Y += size.H;
|
|
|
|
fromPoint.X += size.W;
|
|
|
|
}
|
|
|
|
|
|
|
|
scanX = fromPoint.X;
|
|
|
|
scanY = fromPoint.Y;
|
|
|
|
|
|
|
|
for (let i = 0; i < limit; i += stepY) {
|
|
|
|
scanX += stepX;
|
|
|
|
scanY += stepY;
|
|
|
|
for (let actor of Actors.At(Point(scanX, scanY))) {
|
2022-01-19 02:32:15 +00:00
|
|
|
if (actor.IsPlayer() && actor.HasGravity()) {
|
2022-01-18 05:28:05 +00:00
|
|
|
state = states.diving;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
Thief and Inventory APIs
This commit adds the Thief character with starter graphics
(no animations).
The Thief walks back and forth and will steal items from other
doodads, including the player. For singleton items that have no
quantity, like the Colored Keys, the Thief will only steal one
if he does not already have it. Quantitied items like the
Small Key are always stolen.
Flexibility in the playable character is introduced: Boy,
Azulian, Bird, and Thief all respond to playable controls.
There is not currently a method to enable these apart from
modifying balance.PlayerCharacterDoodad at compile time.
New and Changed Doodads
* Thief: new doodad that walks back and forth and will steal
items from other characters inventory.
* Bird: has no inventory and cannot pick up items, unless player
controlled. Its hitbox has also been fixed so it collides with
floors correctly - not something normally seen in the Bird.
* Boy: opts in to have inventory.
* Keys (all): only gives themselves to actors having inventories.
JavaScript API - New functions available
* Self.IsPlayer() - returns if the current actor IS the player.
* Self.SetInventory(bool) - doodads must opt-in to having an
inventory. Keys should only give themselves to doodads having
an inventory.
* Self.HasInventory() bool
* Self.AddItem(filename, qty)
* Self.RemoveItem(filename, qty)
* Self.HasItem(filename)
* Self.Inventory() - returns map[string]int
* Self.ClearInventory()
* Self.OnLeave(func(e)) now receives a CollideEvent as parameter
instead of the useless actor ID. Notably, e.Actor is the
leaving actor and e.Settled is always true.
Other Changes
* Play Mode: if playing as a character which doesn't obey gravity,
such as the bird, antigravity controls are enabled by default.
If you `import antigravity` you can turn gravity back on.
* Doodad collision scripts are no longer run in parallel
goroutines. It made the Thief's job difficult trying to steal
items in many threads simultaneously!
2021-08-10 05:42:22 +00:00
|
|
|
// If under control of the player character.
|
|
|
|
function player() {
|
2022-02-21 21:09:51 +00:00
|
|
|
let playerSpeed = 12,
|
|
|
|
diving = false,
|
|
|
|
falling = false;
|
|
|
|
|
|
|
|
// The player can dive by moving downwards and laterally, but
|
|
|
|
// de-cheese their ability to just sweep across the ground; if
|
|
|
|
// they aren't seen to be moving downwards, cancel the dive.
|
|
|
|
let lastPoint = Self.Position();
|
|
|
|
setInterval(() => {
|
2022-03-07 06:16:09 +00:00
|
|
|
let nowAt = Self.Position();
|
|
|
|
if (nowAt.Y > lastPoint.Y) {
|
|
|
|
falling = true;
|
|
|
|
} else {
|
|
|
|
falling = false;
|
|
|
|
}
|
|
|
|
lastPoint = nowAt;
|
|
|
|
}, 100);
|
2022-01-19 05:24:36 +00:00
|
|
|
|
2022-01-17 04:09:27 +00:00
|
|
|
Events.OnKeypress((ev) => {
|
Thief and Inventory APIs
This commit adds the Thief character with starter graphics
(no animations).
The Thief walks back and forth and will steal items from other
doodads, including the player. For singleton items that have no
quantity, like the Colored Keys, the Thief will only steal one
if he does not already have it. Quantitied items like the
Small Key are always stolen.
Flexibility in the playable character is introduced: Boy,
Azulian, Bird, and Thief all respond to playable controls.
There is not currently a method to enable these apart from
modifying balance.PlayerCharacterDoodad at compile time.
New and Changed Doodads
* Thief: new doodad that walks back and forth and will steal
items from other characters inventory.
* Bird: has no inventory and cannot pick up items, unless player
controlled. Its hitbox has also been fixed so it collides with
floors correctly - not something normally seen in the Bird.
* Boy: opts in to have inventory.
* Keys (all): only gives themselves to actors having inventories.
JavaScript API - New functions available
* Self.IsPlayer() - returns if the current actor IS the player.
* Self.SetInventory(bool) - doodads must opt-in to having an
inventory. Keys should only give themselves to doodads having
an inventory.
* Self.HasInventory() bool
* Self.AddItem(filename, qty)
* Self.RemoveItem(filename, qty)
* Self.HasItem(filename)
* Self.Inventory() - returns map[string]int
* Self.ClearInventory()
* Self.OnLeave(func(e)) now receives a CollideEvent as parameter
instead of the useless actor ID. Notably, e.Actor is the
leaving actor and e.Settled is always true.
Other Changes
* Play Mode: if playing as a character which doesn't obey gravity,
such as the bird, antigravity controls are enabled by default.
If you `import antigravity` you can turn gravity back on.
* Doodad collision scripts are no longer run in parallel
goroutines. It made the Thief's job difficult trying to steal
items in many threads simultaneously!
2021-08-10 05:42:22 +00:00
|
|
|
Vx = 0;
|
|
|
|
Vy = 0;
|
|
|
|
|
2022-01-19 05:24:36 +00:00
|
|
|
if (ev.Right) {
|
|
|
|
direction = "right";
|
|
|
|
} else if (ev.Left) {
|
|
|
|
direction = "left";
|
Thief and Inventory APIs
This commit adds the Thief character with starter graphics
(no animations).
The Thief walks back and forth and will steal items from other
doodads, including the player. For singleton items that have no
quantity, like the Colored Keys, the Thief will only steal one
if he does not already have it. Quantitied items like the
Small Key are always stolen.
Flexibility in the playable character is introduced: Boy,
Azulian, Bird, and Thief all respond to playable controls.
There is not currently a method to enable these apart from
modifying balance.PlayerCharacterDoodad at compile time.
New and Changed Doodads
* Thief: new doodad that walks back and forth and will steal
items from other characters inventory.
* Bird: has no inventory and cannot pick up items, unless player
controlled. Its hitbox has also been fixed so it collides with
floors correctly - not something normally seen in the Bird.
* Boy: opts in to have inventory.
* Keys (all): only gives themselves to actors having inventories.
JavaScript API - New functions available
* Self.IsPlayer() - returns if the current actor IS the player.
* Self.SetInventory(bool) - doodads must opt-in to having an
inventory. Keys should only give themselves to doodads having
an inventory.
* Self.HasInventory() bool
* Self.AddItem(filename, qty)
* Self.RemoveItem(filename, qty)
* Self.HasItem(filename)
* Self.Inventory() - returns map[string]int
* Self.ClearInventory()
* Self.OnLeave(func(e)) now receives a CollideEvent as parameter
instead of the useless actor ID. Notably, e.Actor is the
leaving actor and e.Settled is always true.
Other Changes
* Play Mode: if playing as a character which doesn't obey gravity,
such as the bird, antigravity controls are enabled by default.
If you `import antigravity` you can turn gravity back on.
* Doodad collision scripts are no longer run in parallel
goroutines. It made the Thief's job difficult trying to steal
items in many threads simultaneously!
2021-08-10 05:42:22 +00:00
|
|
|
}
|
|
|
|
|
2022-01-19 05:24:36 +00:00
|
|
|
// Dive!
|
2022-02-21 21:09:51 +00:00
|
|
|
if (ev.Down && ev.Right && falling) {
|
2022-01-19 05:24:36 +00:00
|
|
|
Self.StopAnimation();
|
|
|
|
Self.ShowLayerNamed("dive-right");
|
2022-02-21 21:09:51 +00:00
|
|
|
diving = falling;
|
|
|
|
} else if (ev.Down && ev.Left && falling) {
|
2022-01-19 05:24:36 +00:00
|
|
|
Self.StopAnimation();
|
|
|
|
Self.ShowLayerNamed("dive-left");
|
2022-02-21 21:09:51 +00:00
|
|
|
diving = falling;
|
2022-01-19 05:24:36 +00:00
|
|
|
} else if (ev.Right) {
|
|
|
|
// Fly right.
|
Thief and Inventory APIs
This commit adds the Thief character with starter graphics
(no animations).
The Thief walks back and forth and will steal items from other
doodads, including the player. For singleton items that have no
quantity, like the Colored Keys, the Thief will only steal one
if he does not already have it. Quantitied items like the
Small Key are always stolen.
Flexibility in the playable character is introduced: Boy,
Azulian, Bird, and Thief all respond to playable controls.
There is not currently a method to enable these apart from
modifying balance.PlayerCharacterDoodad at compile time.
New and Changed Doodads
* Thief: new doodad that walks back and forth and will steal
items from other characters inventory.
* Bird: has no inventory and cannot pick up items, unless player
controlled. Its hitbox has also been fixed so it collides with
floors correctly - not something normally seen in the Bird.
* Boy: opts in to have inventory.
* Keys (all): only gives themselves to actors having inventories.
JavaScript API - New functions available
* Self.IsPlayer() - returns if the current actor IS the player.
* Self.SetInventory(bool) - doodads must opt-in to having an
inventory. Keys should only give themselves to doodads having
an inventory.
* Self.HasInventory() bool
* Self.AddItem(filename, qty)
* Self.RemoveItem(filename, qty)
* Self.HasItem(filename)
* Self.Inventory() - returns map[string]int
* Self.ClearInventory()
* Self.OnLeave(func(e)) now receives a CollideEvent as parameter
instead of the useless actor ID. Notably, e.Actor is the
leaving actor and e.Settled is always true.
Other Changes
* Play Mode: if playing as a character which doesn't obey gravity,
such as the bird, antigravity controls are enabled by default.
If you `import antigravity` you can turn gravity back on.
* Doodad collision scripts are no longer run in parallel
goroutines. It made the Thief's job difficult trying to steal
items in many threads simultaneously!
2021-08-10 05:42:22 +00:00
|
|
|
if (!Self.IsAnimating()) {
|
|
|
|
Self.PlayAnimation("fly-right", null);
|
|
|
|
}
|
|
|
|
Vx = playerSpeed;
|
2022-02-21 21:09:51 +00:00
|
|
|
diving = false;
|
Thief and Inventory APIs
This commit adds the Thief character with starter graphics
(no animations).
The Thief walks back and forth and will steal items from other
doodads, including the player. For singleton items that have no
quantity, like the Colored Keys, the Thief will only steal one
if he does not already have it. Quantitied items like the
Small Key are always stolen.
Flexibility in the playable character is introduced: Boy,
Azulian, Bird, and Thief all respond to playable controls.
There is not currently a method to enable these apart from
modifying balance.PlayerCharacterDoodad at compile time.
New and Changed Doodads
* Thief: new doodad that walks back and forth and will steal
items from other characters inventory.
* Bird: has no inventory and cannot pick up items, unless player
controlled. Its hitbox has also been fixed so it collides with
floors correctly - not something normally seen in the Bird.
* Boy: opts in to have inventory.
* Keys (all): only gives themselves to actors having inventories.
JavaScript API - New functions available
* Self.IsPlayer() - returns if the current actor IS the player.
* Self.SetInventory(bool) - doodads must opt-in to having an
inventory. Keys should only give themselves to doodads having
an inventory.
* Self.HasInventory() bool
* Self.AddItem(filename, qty)
* Self.RemoveItem(filename, qty)
* Self.HasItem(filename)
* Self.Inventory() - returns map[string]int
* Self.ClearInventory()
* Self.OnLeave(func(e)) now receives a CollideEvent as parameter
instead of the useless actor ID. Notably, e.Actor is the
leaving actor and e.Settled is always true.
Other Changes
* Play Mode: if playing as a character which doesn't obey gravity,
such as the bird, antigravity controls are enabled by default.
If you `import antigravity` you can turn gravity back on.
* Doodad collision scripts are no longer run in parallel
goroutines. It made the Thief's job difficult trying to steal
items in many threads simultaneously!
2021-08-10 05:42:22 +00:00
|
|
|
} else if (ev.Left) {
|
2022-01-19 05:24:36 +00:00
|
|
|
// Fly left.
|
Thief and Inventory APIs
This commit adds the Thief character with starter graphics
(no animations).
The Thief walks back and forth and will steal items from other
doodads, including the player. For singleton items that have no
quantity, like the Colored Keys, the Thief will only steal one
if he does not already have it. Quantitied items like the
Small Key are always stolen.
Flexibility in the playable character is introduced: Boy,
Azulian, Bird, and Thief all respond to playable controls.
There is not currently a method to enable these apart from
modifying balance.PlayerCharacterDoodad at compile time.
New and Changed Doodads
* Thief: new doodad that walks back and forth and will steal
items from other characters inventory.
* Bird: has no inventory and cannot pick up items, unless player
controlled. Its hitbox has also been fixed so it collides with
floors correctly - not something normally seen in the Bird.
* Boy: opts in to have inventory.
* Keys (all): only gives themselves to actors having inventories.
JavaScript API - New functions available
* Self.IsPlayer() - returns if the current actor IS the player.
* Self.SetInventory(bool) - doodads must opt-in to having an
inventory. Keys should only give themselves to doodads having
an inventory.
* Self.HasInventory() bool
* Self.AddItem(filename, qty)
* Self.RemoveItem(filename, qty)
* Self.HasItem(filename)
* Self.Inventory() - returns map[string]int
* Self.ClearInventory()
* Self.OnLeave(func(e)) now receives a CollideEvent as parameter
instead of the useless actor ID. Notably, e.Actor is the
leaving actor and e.Settled is always true.
Other Changes
* Play Mode: if playing as a character which doesn't obey gravity,
such as the bird, antigravity controls are enabled by default.
If you `import antigravity` you can turn gravity back on.
* Doodad collision scripts are no longer run in parallel
goroutines. It made the Thief's job difficult trying to steal
items in many threads simultaneously!
2021-08-10 05:42:22 +00:00
|
|
|
if (!Self.IsAnimating()) {
|
|
|
|
Self.PlayAnimation("fly-left", null);
|
|
|
|
}
|
|
|
|
Vx = -playerSpeed;
|
2022-02-21 21:09:51 +00:00
|
|
|
diving = false;
|
Thief and Inventory APIs
This commit adds the Thief character with starter graphics
(no animations).
The Thief walks back and forth and will steal items from other
doodads, including the player. For singleton items that have no
quantity, like the Colored Keys, the Thief will only steal one
if he does not already have it. Quantitied items like the
Small Key are always stolen.
Flexibility in the playable character is introduced: Boy,
Azulian, Bird, and Thief all respond to playable controls.
There is not currently a method to enable these apart from
modifying balance.PlayerCharacterDoodad at compile time.
New and Changed Doodads
* Thief: new doodad that walks back and forth and will steal
items from other characters inventory.
* Bird: has no inventory and cannot pick up items, unless player
controlled. Its hitbox has also been fixed so it collides with
floors correctly - not something normally seen in the Bird.
* Boy: opts in to have inventory.
* Keys (all): only gives themselves to actors having inventories.
JavaScript API - New functions available
* Self.IsPlayer() - returns if the current actor IS the player.
* Self.SetInventory(bool) - doodads must opt-in to having an
inventory. Keys should only give themselves to doodads having
an inventory.
* Self.HasInventory() bool
* Self.AddItem(filename, qty)
* Self.RemoveItem(filename, qty)
* Self.HasItem(filename)
* Self.Inventory() - returns map[string]int
* Self.ClearInventory()
* Self.OnLeave(func(e)) now receives a CollideEvent as parameter
instead of the useless actor ID. Notably, e.Actor is the
leaving actor and e.Settled is always true.
Other Changes
* Play Mode: if playing as a character which doesn't obey gravity,
such as the bird, antigravity controls are enabled by default.
If you `import antigravity` you can turn gravity back on.
* Doodad collision scripts are no longer run in parallel
goroutines. It made the Thief's job difficult trying to steal
items in many threads simultaneously!
2021-08-10 05:42:22 +00:00
|
|
|
} else {
|
2022-01-19 05:24:36 +00:00
|
|
|
// Hover in place.
|
|
|
|
if (!Self.IsAnimating()) {
|
2022-03-07 06:16:09 +00:00
|
|
|
Self.PlayAnimation("fly-" + direction);
|
2022-01-19 05:24:36 +00:00
|
|
|
}
|
2022-02-21 21:09:51 +00:00
|
|
|
diving = false;
|
Thief and Inventory APIs
This commit adds the Thief character with starter graphics
(no animations).
The Thief walks back and forth and will steal items from other
doodads, including the player. For singleton items that have no
quantity, like the Colored Keys, the Thief will only steal one
if he does not already have it. Quantitied items like the
Small Key are always stolen.
Flexibility in the playable character is introduced: Boy,
Azulian, Bird, and Thief all respond to playable controls.
There is not currently a method to enable these apart from
modifying balance.PlayerCharacterDoodad at compile time.
New and Changed Doodads
* Thief: new doodad that walks back and forth and will steal
items from other characters inventory.
* Bird: has no inventory and cannot pick up items, unless player
controlled. Its hitbox has also been fixed so it collides with
floors correctly - not something normally seen in the Bird.
* Boy: opts in to have inventory.
* Keys (all): only gives themselves to actors having inventories.
JavaScript API - New functions available
* Self.IsPlayer() - returns if the current actor IS the player.
* Self.SetInventory(bool) - doodads must opt-in to having an
inventory. Keys should only give themselves to doodads having
an inventory.
* Self.HasInventory() bool
* Self.AddItem(filename, qty)
* Self.RemoveItem(filename, qty)
* Self.HasItem(filename)
* Self.Inventory() - returns map[string]int
* Self.ClearInventory()
* Self.OnLeave(func(e)) now receives a CollideEvent as parameter
instead of the useless actor ID. Notably, e.Actor is the
leaving actor and e.Settled is always true.
Other Changes
* Play Mode: if playing as a character which doesn't obey gravity,
such as the bird, antigravity controls are enabled by default.
If you `import antigravity` you can turn gravity back on.
* Doodad collision scripts are no longer run in parallel
goroutines. It made the Thief's job difficult trying to steal
items in many threads simultaneously!
2021-08-10 05:42:22 +00:00
|
|
|
}
|
|
|
|
|
2022-02-21 21:09:51 +00:00
|
|
|
// Player is invulnerable while diving.
|
|
|
|
Self.SetInvulnerable(diving);
|
|
|
|
});
|
|
|
|
|
|
|
|
Events.OnCollide((e) => {
|
|
|
|
// If the player is diving at an enemy mob, destroy it.
|
|
|
|
if (diving && e.Settled && e.Actor.IsMobile() && !e.Actor.Invulnerable()) {
|
|
|
|
Sound.Play("crumbly-break.wav");
|
|
|
|
e.Actor.Destroy();
|
|
|
|
}
|
|
|
|
});
|
2022-01-17 04:09:27 +00:00
|
|
|
}
|