050b8251a7
ci / verify (push) Successful in 48s
Four always-on-screen slots, items as data, and loot tables on enemies and bosses. Health potions drop rarely from trash and always from the Warden; the Warden also drops a Warden's Ration, one per living player, which does nothing at all. The ration is not filler. Player-instanced loot is a separate code path from shared loot -- a distinct entity per owner, filtered per peer in the snapshot encoder -- and the cheapest way to keep that path honest is to have something in the game that exercises it on every boss kill. Item actions ride the input frame rather than becoming new client messages. InputFrame gained BTN_USE, BTN_DROP and a slot byte, which buys the packet-loss redundancy, the replay guard on last_input_tick, ordering against movement on the same tick, and a rate limit of one action per tick -- all of which a separate RPC would have needed bolted back on. The cost is that anything in the frame which must not repeat has to be edge-triggered, since frames are resent and a starved server coasts on the last one it holds. Instanced loot is enforced in NetCodec.encode_snapshot, beside the actor interest radius: a peer is never told another player's copy exists. Hiding it client-side would have been the same mistake as relying on fog to hide enemies. Inventories live on the character and are written to the store on every transaction, so a crash between "picked it up" and "wrote it down" cannot lose or duplicate an item. Anything dropped becomes world-shared whatever it was before, and a potion used at full health is refused rather than spent. tools/diag_loot.tscn covers drop -> snapshot -> pick up -> persist -> use -> drop plus both visibilities on the wire, for the same reason diag_progression exists: bots are poor shots and almost never produce a drop. It asserts each input frame was actually consumed, after an early version silently dropped its first press and every later check passed for the wrong reason. check.sh clean, 266 tests, SMOKE PASS, all three diagnostics green. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
56 lines
2.0 KiB
GDScript
56 lines
2.0 KiB
GDScript
extends SceneTree
|
|
## Writes the project's input map into project.godot.
|
|
##
|
|
## Hand-editing the [input] section is error-prone -- the events are serialised
|
|
## engine objects with a long property list. Generating them through the real
|
|
## API means the file is always in the format the engine expects.
|
|
##
|
|
## godot --headless --path . --script tools/setup_input_map.gd
|
|
##
|
|
## Re-run after changing the bindings below. Physical keycodes are used so the
|
|
## bindings follow key position rather than layout.
|
|
|
|
|
|
func _init() -> void:
|
|
_action("move_up", [_key(KEY_W), _key(KEY_UP)])
|
|
_action("move_down", [_key(KEY_S), _key(KEY_DOWN)])
|
|
_action("move_left", [_key(KEY_A), _key(KEY_LEFT)])
|
|
_action("move_right", [_key(KEY_D), _key(KEY_RIGHT)])
|
|
_action("fire", [_mouse(MOUSE_BUTTON_LEFT), _key(KEY_SPACE)])
|
|
_action("emergency_escape", [_key(KEY_F)])
|
|
_action("interact", [_key(KEY_E)])
|
|
# One per inventory slot. Number keys use the slot; shift-number drops it,
|
|
# which is read in code rather than bound here -- a modifier is not an
|
|
# action, and duplicating four bindings to express it would be worse.
|
|
for i in SimConfig.INVENTORY_SLOTS:
|
|
_action("use_slot_%d" % (i + 1), [_key((KEY_1 + i) as Key)])
|
|
_action("system_menu", [_key(KEY_ESCAPE)])
|
|
_action("debug_overlay", [_key(KEY_F1)])
|
|
var err := ProjectSettings.save()
|
|
print("input map written, err=%d" % err)
|
|
quit(0 if err == OK else 1)
|
|
|
|
|
|
func _action(name: String, events: Array) -> void:
|
|
ProjectSettings.set_setting("input/" + name, {
|
|
"deadzone": 0.2,
|
|
"events": events,
|
|
})
|
|
|
|
|
|
## device -1 (DEVICE_ID_EMULATION) is what the editor writes and is the only
|
|
## value that matches input from a real device. A freshly constructed event
|
|
## defaults to 16, which silently matches nothing.
|
|
func _key(code: Key) -> InputEventKey:
|
|
var e := InputEventKey.new()
|
|
e.device = -1
|
|
e.physical_keycode = code
|
|
return e
|
|
|
|
|
|
func _mouse(button: MouseButton) -> InputEventMouseButton:
|
|
var e := InputEventMouseButton.new()
|
|
e.device = -1
|
|
e.button_index = button
|
|
return e
|