dot-economy is the per-round money question: what a player can afford this
round, when they may spend it, and what a kill or a lost round pays.
dot-loadout answers the permanent one — what
you own — and had no answer for this.
Requires dot-core.
Usage
var economy := DotEconomyManager.new()
economy.team_fn = match_node.team_of
economy.alive_fn = world.is_alive
economy.in_buy_zone_fn = func(key): return world.in_buy_zone(key)
economy.setup(shop_items) # Array[DotShopItem]
add_child(economy)
economy.on_round_start(tick) # opens the buy window
economy.advance(tick) # closes it on time
economy.on_kill("ada", "bob", &"rifle")
economy.on_round_end(winning_team) # pays the winners and the ladder
A buy menu asks before it draws, so a disabled button carries its reason:
var why := economy.may_buy(key, &"sniper")
button.disabled = not why.ok
button.tooltip_text = "" if why.ok else why.error.message
It sells ids and grants nothing
economy.bought.connect(func(key, id, price, balance):
loadouts.entitlements_for(key).grant(id)) # or an arsenal, or a boolean
A shop item holds no scene, no mesh and no item resource, so a purchase validates on a server that does not have the content.
Per life, not per purchase
DotShopItem.per_life_limit and requires count what a player holds now, not what they bought. Holdings fell only on a refund or a reset, so a player who died with a rifle could not buy it again and a helmet stayed sold to somebody whose kevlar was gone. Tell the manager when that changes:
economy.on_death("ada") # empties what ada held; the money stays
economy.lost("ada", &"grenade", 1) # thrown, dropped or used: takes that many away
A game that calls neither behaves as before.
Why the defaults are what they are
A buy economy looks arbitrary and is not. Each default is a number the round-based competitive shooters converged on over twenty years:
- 800 to start, 16000 as a ceiling. The first round is a pistol round, the second is a decision, the fifth is a full buy. Remove the ceiling and a team that saves twice buys everything for ever.
- A loss bonus of 1400 rising by 500 to 3400. Without it the losing team is poorer because they are losing, which is a feedback loop with one outcome.
- A kill pays 300, and a shop item can override that: the genre pays 100 for a sniper-rifle kill and 1500 for a knife kill. The cheapest way to make money is the riskiest thing you can do.
