Skip to content

Commit

Permalink
Fix dynamite not always destroying other lit dynamite
Browse files Browse the repository at this point in the history
  • Loading branch information
TheGLander committed May 3, 2024
1 parent 21649e1 commit 9bc9c6f
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 15 deletions.
16 changes: 15 additions & 1 deletion logic/src/actors/items.ts
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,21 @@ export class TNT extends Item {
this.destroy(null, null)
const lit = new LitTNT(this.level, this.tile.position)
lit.inventory.itemMax = other.inventory.itemMax
lit.inventory.items = [...other.inventory.items]
lit.inventory.items = other.inventory.items.map(item => {
const rootTile = this.level.field[0][0]
const rootActor = rootTile[item.layer]
delete rootTile[item.layer]
const nItem = new actorDB[item.id](
this.level,
[0, 0],
item.customData
) as Item
nItem.pickup(lit)
if (rootActor !== undefined) {
rootTile[item.layer] = rootActor
}
return nItem
})
for (const keyType in other.inventory.keys)
lit.inventory.keys[keyType] = { ...other.inventory.keys[keyType] }
lit.recomputeTags()
Expand Down
23 changes: 11 additions & 12 deletions logic/src/actors/monsters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,8 @@ export class LitTNT extends Monster {
const protector = iterableFind(tile.allActors, val =>
val.hasTag("blocks-tnt")
)
if (protector) protectedLayer = protector.layer
if (protector && !(tileHadMovable && tile[this.layer]!.id === this.id))
protectedLayer = protector.layer

for (const actor of Array.from(tile.allActorsReverse))
if (actor.layer >= protectedLayer) {
Expand All @@ -274,19 +275,17 @@ export class LitTNT extends Monster {
? 2 + Math.sign(tile.x - this.tile.x)
: 1 + Math.sign(tile.y - this.tile.y)
)
if (
(!actor.exists ||
actor.destroy(
this,
actor.layer === Layer.STATIONARY || actor.layer === Layer.MOVABLE
? "explosion"
: null
// false
// true
)) &&
actor.layer === Layer.MOVABLE
if (!actor.exists) continue

let destroyed = actor.destroy(
actor === protector && protectedLayer !== actor.layer ? null : this,
actor.layer === Layer.STATIONARY || actor.layer === Layer.MOVABLE
? "explosion"
: null
)
if (destroyed && actor.layer === Layer.MOVABLE) {
movableDied = true
}
}
// Create a memorial fire if a movable got blown up (if we can)
if (tileHadMovable && movableDied && !tile.hasLayer(Layer.STATIONARY))
Expand Down
4 changes: 2 additions & 2 deletions logic/src/actors/walls.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,9 +106,9 @@ export class ThinWall extends Actor {
shouldDie(): boolean {
if (this.hasTag("canopy")) {
// Remove all traces of the canopy
this.tags &= ~getTagFlag("thinWall")
this.tags &= ~(getTagFlag("canopy") | getTagFlag("blocks-tnt"))
this.customData = this.customData.split("C").join("")
return false
return this.customData === ""
}
return true
}
Expand Down

0 comments on commit 9bc9c6f

Please sign in to comment.