Every level banks one choice. Choices queue, and are spent at an NPC in the
hub: walk to it, press E, take one of three weighted options. Seven upgrades,
all data — split shot, glass cannon, spread, sniper, doubleshot, poison,
eraser — and SimWorld gained no per-upgrade branch to run any of them.
The four ambiguities in the brief were settled with the user first, since
each changes what gets written:
damage base x (1 + sum additive) x product multiplicative. The flat
+5% every upgrade carries, spread's -10%, doubleshot's -50%
and glass cannon's +100% pool; sniper multiplies on top, so
two snipers is 4x and not +200%.
glass half the LEVELLED maximum, multiplying if taken twice, so the
price does not fade to a rounding error by level 15.
poison independent stacks, not a refresh.
split +/-45 degrees from the original heading.
Independent poison stacks sound expensive and are not: every dose lasts the
same number of ticks, so doses expire in the order they were added, the
pending expiries are a plain FIFO, and PoisonTrack only ever looks at its
front. O(1) per actor per tick however many are live.
Stats are derived from the upgrade list and never stored, the way level is
derived from experience -- a saved stat cannot disagree with the upgrades
that produced it. Upgrade riders (split charges, poison, erase chance) travel
on the bullet instead, because a shot in flight has to keep what it was fired
with rather than gaining Poison because the shooter just took it.
Two invariants this collided with, both now pinned:
- bullet speed gained a ceiling. Wall collision samples once per tick, so
anything over a tile per tick tunnels; two snipers asked for 2480 u/s
against a 1920 threshold, and a tunnelling bullet looks like a bullet.
- BULLET_INTEREST_RADIUS rose to 2900, because an upgraded player shot is
now the longest-travelling bullet in the game. test_interest measured
the worst case from static content, which upgrades quietly invalidated.
Choosing is intent checked three ways: a choice must be owed, the index must
name one of the three options the SERVER put on the table, and the player
must be standing at the NPC. The offer is rolled once and persisted, so
closing the screen is not a reroll and neither is a crash.
tools/diag_upgrades.tscn covers level -> banked choice -> refused in a
dungeon and refused across the room -> taken at the NPC -> new stats ->
on disk. Bots never walk to the quartermaster, so the smoke test cannot.
Known gap recorded in the roadmap: at PLAYER_BULLET_DAMAGE = 6, the +5% the
first upgrade carries rounds back to 6 and visibly does nothing. It comes out
right in aggregate, but the fix is a balance edit across content.gd and so is
the user's call.
check.sh clean, 357 tests, SMOKE PASS (18 assertions), all four diagnostics
green.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
1 parent
a943aa19f6
commit
b351bc2d55
47 files changed
+2438
-92
No files matched your search
@@ -307,9 +307,63 @@ func _enter_world_as(peer_id: int, c: Character) -> void:
|
||||
p.adopt(c)
|
||||
GameLog.info("server", "peer %d playing '%s' (level %d)"
|
||||
% [peer_id, c.display_name, c.level])
|
||||
_send_upgrades(peer_id)
|
||||
_broadcast_roster()
|
||||
|
||||
|
||||
## Spend one level-up on one of the three options the server put on the table.
|
||||
##
|
||||
## Everything about this is checked here rather than trusted: that there is a
|
||||
## choice owing, that the index names an option the server itself offered, and
|
||||
## that the player is standing at the NPC. The index is the only thing the
|
||||
## client contributes, and it selects from a list the client did not write.
|
||||
func on_choose_upgrade(peer_id: int, index: int) -> void:
|
||||
var account: int = peer_accounts.get(peer_id, AuthProvider.NO_ACCOUNT)
|
||||
var character_id: String = peer_characters.get(peer_id, "")
|
||||
if account == AuthProvider.NO_ACCOUNT or character_id.is_empty():
|
||||
Net.send_select_result(peer_id, Protocol.SelectResult.NOT_AUTHENTICATED,
|
||||
"not signed in")
|
||||
return
|
||||
var here := instance_of(peer_id)
|
||||
if here == null or here.kind != Protocol.InstanceKind.LOBBY:
|
||||
Net.send_select_result(peer_id, Protocol.SelectResult.NOT_IN_HUB,
|
||||
"upgrades are chosen in the hub")
|
||||
return
|
||||
var p: SimPlayer = here.world.players.get(peer_id)
|
||||
if p == null or not here.world.at_upgrade_npc(p.pos):
|
||||
Net.send_select_result(peer_id, Protocol.SelectResult.NOT_AT_THE_NPC,
|
||||
"stand at the quartermaster to spend a level")
|
||||
return
|
||||
var taken := store.take_upgrade(account, character_id, index)
|
||||
if taken.is_empty():
|
||||
Net.send_select_result(peer_id, Protocol.SelectResult.NOTHING_TO_CHOOSE,
|
||||
"nothing to choose")
|
||||
_send_upgrades(peer_id)
|
||||
return
|
||||
# Rebuild the player's numbers from the new list. adopt() does exactly this
|
||||
# and nothing else that matters here, so it stays the single place where a
|
||||
# character's record becomes a player's stats.
|
||||
var c := store.get_character(account, character_id)
|
||||
if c != null:
|
||||
p.adopt(c)
|
||||
GameLog.info("server", "peer %d took upgrade '%s'" % [peer_id, taken])
|
||||
Net.send_select_result(peer_id, Protocol.SelectResult.OK, "")
|
||||
_send_upgrades(peer_id)
|
||||
_send_characters(peer_id)
|
||||
|
||||
|
||||
func _send_upgrades(peer_id: int) -> void:
|
||||
var account: int = peer_accounts.get(peer_id, AuthProvider.NO_ACCOUNT)
|
||||
var character_id: String = peer_characters.get(peer_id, "")
|
||||
if account == AuthProvider.NO_ACCOUNT or character_id.is_empty():
|
||||
return
|
||||
var c := store.get_character(account, character_id)
|
||||
if c == null:
|
||||
return
|
||||
Net.send_upgrades(peer_id, NetCodec.encode_upgrade_state(
|
||||
c.pending_choices, c.offer, c.upgrades))
|
||||
|
||||
|
||||
func on_input(peer_id: int, data: PackedByteArray) -> void:
|
||||
var inst := instance_of(peer_id)
|
||||
if inst == null:
|
||||
@@ -332,7 +386,8 @@ func _place(peer_id: int, inst: Instance) -> void:
|
||||
Net.send_enter_instance(peer_id, inst.id, int(inst.kind), inst.world.tick,
|
||||
String(inst.boss_id), inst.world.spawn_point,
|
||||
inst.world.map.width, inst.world.map.height,
|
||||
NetCodec.encode_portals(inst.world.portals), String(inst.dungeon_id))
|
||||
NetCodec.encode_portals(inst.world.portals), String(inst.dungeon_id),
|
||||
inst.world.upgrade_npc)
|
||||
# Seed the area around the spawn before anything else, so the player is not
|
||||
# briefly standing in an unrendered void on arrival.
|
||||
_stream_map(peer_id, inst)
|
||||
@@ -489,6 +544,10 @@ func _grant_xp(peer_id: int, amount: int) -> void:
|
||||
mine.total_xp = earned.total_xp
|
||||
if levels <= 0:
|
||||
return
|
||||
# One choice per level, banked rather than offered immediately: the NPC is
|
||||
# in the hub and the level was earned in a dungeon, so they have to queue or
|
||||
# they would be lost.
|
||||
store.grant_choices(account, character_id, levels)
|
||||
# A level raises max health immediately, and heals by the amount gained --
|
||||
# a level-up mid-fight should feel like relief, not like a bar that grew
|
||||
# further away from full.
|
||||
@@ -501,8 +560,10 @@ func _grant_xp(peer_id: int, amount: int) -> void:
|
||||
p.level = c.level
|
||||
p.max_hp = c.max_hp()
|
||||
p.hp = mini(p.hp + (p.max_hp - before), p.max_hp)
|
||||
GameLog.info("server", "peer %d reached level %d" % [peer_id, c.level])
|
||||
GameLog.info("server", "peer %d reached level %d (%d choice(s) pending)"
|
||||
% [peer_id, c.level, c.pending_choices])
|
||||
_send_characters(peer_id)
|
||||
_send_upgrades(peer_id)
|
||||
|
||||
|
||||
## Death is permanent. The character is retired -- kept for archival, never
|
||||
|
||||
Reference in new issue
Block a user