Bounty Board¶
From the second wanted star, the handler puts a price on one police unit near you. Wreck it before the clock runs out for a bonus that grows with your wanted level. Ten bounties earn the BOUNTY GOLD paint. A code mod: events, drawing, its own sprite and text, announcer lines, a counter and settings.
| Mod id | Kind | Files |
|---|---|---|
bounty_board |
Lua code | 7 |
It comes with the game: turn it on under MODS on the home menu and start the game again. Browse it on GitHub.
mod.json¶
{
"id": "bounty_board",
"title": "Bounty Board",
"version": "1.0",
"api": 1,
"author": "Taxation Evasion",
"description": "From the second wanted star, the handler puts a price on one police unit near you. Wreck it before the clock runs out for a bonus that grows with your wanted level. Ten bounties earn the BOUNTY GOLD paint. A code mod: events, drawing, its own sprite and text, announcer lines, a counter and settings.",
"scripts": ["main.lua"],
"settings": [
{
"id": "frequency",
"label": "BOUNTIES",
"type": "choice",
"values": ["RARE", "NORMAL", "OFTEN"],
"default": "NORMAL",
"help": "How soon a new bounty follows the last one."
},
{
"id": "marker",
"label": "TARGET MARKER",
"type": "toggle",
"default": true,
"help": "A reticle on the marked unit, and an arrow toward it when it is off screen."
},
{
"id": "panel",
"label": "BOUNTY PANEL",
"type": "toggle",
"default": true,
"help": "The reward and the time left, under the objective."
}
]
}
main.lua¶
-- Bounty Board: from the second wanted star, one police unit near the car
-- carries a price. Wreck it in time and the bounty pays out.
-- Everything here goes through the `game` API (docs/modding/API.md).
local TIME = 20 -- seconds to claim a bounty
local WAIT = {RARE = 50, NORMAL = 30, OFTEN = 18} -- seconds between bounties
-- Which units can carry a price, and what each pays at the second star.
local PRICE = {patrol = 60, interceptor = 75, tank = 140}
local function money(n) return '$' .. math.floor(n) end
-- The simulation decides everything, so every machine sees the same run;
-- the draw handlers below only read `s.bounty_board`.
game.on('run_start', function(s)
s.bounty_board = {wait = 15, claimed = 0}
end)
-- The marked unit wrecked: pay out. Other mods can react to the claim
-- with game.on('bounty_board.claimed', ...).
game.on('enemy_death', function(s, e)
local b = s.bounty_board
if not (b and b.target == e) then return end
b.claimed, b.target = b.claimed + 1, nil
game.cash(s, b.cash)
game.count(s, 'bounty_board.bounties') -- toward the BOUNTY GOLD paint
game.sound(s, 'cash_tier', 0.4)
game.say(s, 'bounty_board.claimed', {game.text('bounty_board.claimed',
{cash = money(b.cash), total = b.claimed})})
if b.cash > (game.store('best') or 0) then game.store('best', b.cash) end
game.emit(s, 'bounty_board.claimed', {cash = b.cash, unit = e, total = b.claimed})
end)
-- It drove off or was cleared away without a takedown: the bounty lapses.
game.on('enemy_gone', function(s, e)
local b = s.bounty_board
if b and b.target == e then
b.target = nil
game.say(s, 'bounty_board.expired')
end
end)
game.on('tick', function(s, dt)
local b = s.bounty_board
if not b then return end
if b.target then
b.left = b.left - dt
if b.left <= 0 then
b.target = nil
game.say(s, 'bounty_board.expired')
end
return
end
if s.heat < 2 then return end
b.wait = b.wait - dt
if b.wait > 0 then return end
-- A unit close enough to chase, but not already on the bumper.
local picks = {}
for _, x in ipairs(game.enemies(s, s.player.x, s.player.y, 320)) do
if PRICE[x.role] and x.hp > 0 and game.distance(x, s.player) > 60 then picks[#picks + 1] = x end
end
if #picks == 0 then b.wait = 3; return end
e = picks[game.random(s, #picks)]
b.target, b.left = e, TIME
b.cash = PRICE[e.role] + 30 * (s.heat - 2)
b.wait = WAIT[game.setting('frequency')] or WAIT.NORMAL
game.sound(s, 'StartingBeepHi', 0.25)
game.say(s, 'bounty_board.posted', {game.text('bounty_board.posted',
{target = game.text('bounty_board.unit.' .. e.role), cash = money(b.cash)})})
end)
-- The marked unit: a turning reticle (bounty_board.reticle, from sprites/),
-- or an arrow from the car when the unit is off screen.
game.on('draw_world', function(s, d)
local b = s.bounty_board
local e = b and b.target
if not e or e.hp <= 0 or not game.setting('marker') then return end
local turn = d.reduced_motion and 0 or d.time * 1.5
if d.visible(e.x, e.y, 24) then
d.sprite('bounty_board.reticle', e.x, e.y, turn, 1.5, 0.95)
d.light(e.x, e.y, 40, 'gold', 0.5)
return
end
local a = game.angle(s.player, e)
local px, py = s.player.x, s.player.y
local function at(r, da) return px + math.cos(a + da) * r, py + math.sin(a + da) * r end
local tx, ty = at(46, 0)
local lx, ly = at(38, 0.18)
local rx, ry = at(38, -0.18)
d.line(lx, ly, tx, ty, 'gold', 0.9, 2)
d.line(rx, ry, tx, ty, 'gold', 0.9, 2)
end)
-- The reward and the time left, under the objective panel in the top right.
game.on('draw_hud', function(s, d)
local b = s.bounty_board
if not (b and b.target and b.target.hp > 0) or not game.setting('panel') then return end
d.anchor('top_right')
local x, y, w, h = 482, 64, 150, 22
-- The last five seconds blink, unless the player turned flashes down.
local urgent = b.left < 5 and not d.reduced_flashes and math.floor(d.time * 4) % 2 == 0
d.rect(x, y, w, h, 'black', 0.75)
d.box(x, y, w, h, urgent and 'red' or 'gold', 0.9)
d.text(game.text('bounty_board.reward', {cash = money(b.cash)}), x + 6, y + 4, 'gold')
d.text(game.text('bounty_board.seconds', {seconds = math.ceil(b.left)}), x + w - 6, y + 4,
urgent and 'red' or 'white', 'right')
d.rect(x + 6, y + h - 5, (w - 12) * math.max(0, b.left / TIME), 2, urgent and 'red' or 'gold', 0.9)
end)
announcer.json¶
[
{
"id": "bounty_board.posted",
"lines": [
"There's a price on that unit.",
"Wreck it before the clock runs out."
],
"priority": 2,
"ttl": 4
},
{
"id": "bounty_board.claimed",
"lines": ["Bounty collected.", "Clean work."],
"priority": 2,
"ttl": 4
},
{
"id": "bounty_board.expired",
"lines": [
"The bounty's off.",
"I'll find you another."
],
"priority": 1,
"ttl": 3
}
]
counters.json¶
paints.json¶
[
{
"id": "bounty_board.gold",
"name": "BOUNTY GOLD",
"rgb": [214, 168, 48],
"group": "COMBAT",
"counter": "bounty_board.bounties",
"target": 10,
"requirement": "Collect 10 bounties from the Bounty Board"
}
]
sprites/reticle.png¶
![]()
text/en.json¶
{
"bounty_board.reward": "BOUNTY {cash}",
"bounty_board.seconds": "{seconds}S",
"bounty_board.posted": "{target}: {cash}.",
"bounty_board.claimed": "{cash} paid. {total} this run.",
"bounty_board.unit.patrol": "A cop car",
"bounty_board.unit.interceptor": "An interceptor",
"bounty_board.unit.tank": "A rocket tank"
}