Skip to content

Commit

Permalink
bonkelement helper func
Browse files Browse the repository at this point in the history
  • Loading branch information
goldbuick committed Apr 27, 2024
1 parent 1dfa46e commit d22624f
Showing 1 changed file with 24 additions and 11 deletions.
35 changes: 24 additions & 11 deletions zss/firmware/zzt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import {
import {
BOARD_ELEMENT,
MAYBE_BOARD,
MAYBE_BOARD_ELEMENT,
boarddeleteobject,
boardelementread,
boardfindplayer,
Expand Down Expand Up @@ -183,6 +184,22 @@ function sendinteraction(
}
}

function bonkelement(
book: MAYBE_BOOK,
board: MAYBE_BOARD,
blocked: MAYBE_BOARD_ELEMENT,
dest: PT,
) {
if (ispresent(blocked?.id)) {
// mark headless
blocked.headless = true
// drop from luts
bookboardobjectnamedlookupdelete(book, board, blocked)
} else {
boardterrainsetfromkind(board, dest, 'empty')
}
}

function moveobject(
chip: CHIP,
book: MAYBE_BOOK,
Expand All @@ -203,14 +220,7 @@ function moveobject(
// delete destructible elements
const blockedkind = bookelementkindread(book, blocked)
if (blocked.destructible ?? blockedkind?.destructible) {
if (ispresent(blocked.id)) {
// mark headless
blocked.headless = true
// drop from luts
bookboardobjectnamedlookupdelete(book, board, blocked)
} else {
boardterrainsetfromkind(board, dest, 'empty')
}
bonkelement(book, board, blocked, dest)
}

return false
Expand Down Expand Up @@ -690,9 +700,12 @@ export const ZZT_FIRMWARE = createfirmware({
// blocked by object, send message
if (ispresent(blocked.id)) {
sendinteraction(chip, chip.id(), blocked, 'shot')
} else if (blocked.destructible) {
// delete terrain
boardterrainsetfromkind(maybeboard, start, 'empty')
}

// delete destructible elements
const blockedkind = bookelementkindread(maybebook, blocked)
if (blocked.destructible ?? blockedkind?.destructible) {
bonkelement(maybebook, maybeboard, blocked, start)
}

// and start bullet in headless mode
Expand Down

0 comments on commit d22624f

Please sign in to comment.