B8: Thrown powder kegs with line-of-sight blasts
Fire with a powder keg held now throws one (Explosives.throw): lobbed along the look direction, it drops down anything it strikes, rests where it lands, falls again if its support goes, and blows when its fuse runs out (3 s). The blast (Explosives.blast) reaches blast_radius, measured to the nearest point of each body, piece or prop: - terrain, pieces, props and fixed solids shield what is behind them; players are hit if their body middle or head is in sight; - damage falls off linearly to BLAST_EDGE_FACTOR at the edge, times tier; - players take damage armor first, credited to the thrower, who takes BLAST_SELF_FACTOR of their own; - pieces and props take structure_damage, so kegs can breach breakwaters. Everything reached is worked out before any damage is applied. Line of sight uses a per-blast Sight: the nearby solids once, a cheap box pre-check per ray, and a coarse terrain check skipped above the highest ground in reach. Four kegs blowing on one tick inside a 5x5x3 stone fort take about 5 ms, under the 12 ms tick budget (tested). Kegs in flight and lying lit are drawn with the item models (EntityView); capture scenario items_kegs. A blast emits "explosion" for A7's effects and an impact the sound director already plays as keg_blast. The launcher and bots that throw are follow-up #83. Closes #22 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -132,3 +132,28 @@ func test_pines_between_the_shoulder_camera_and_the_player_are_hidden() -> void:
|
||||
for prop: int in hidden_at_some_yaw:
|
||||
assert_true(view.props.is_drawn(prop))
|
||||
view.free()
|
||||
|
||||
|
||||
## B8: a thrown keg is drawn in flight and lying, with the item models, and stops being
|
||||
## drawn once it has blown.
|
||||
func test_thrown_kegs_are_drawn_until_they_blow() -> void:
|
||||
var sim: Simulation = Simulation.new(5, SimGround.flat())
|
||||
var thrower: SimEntity = sim.entities.find(sim.add_player())
|
||||
thrower.position = Vector3(50.0, 0.0, 50.0)
|
||||
thrower.on_ground = true
|
||||
Inventory.give(thrower, ItemCatalog.code_of("powder_keg"), 2)
|
||||
thrower.selected = 1
|
||||
var view: MatchView = MatchView.new()
|
||||
view.setup(sim, 1)
|
||||
sim.submit_command(1, PlayerCommand.from_input(sim.tick, Vector2.ZERO, 0.0, 0.0, PlayerCommand.BUTTON_FIRE, 1))
|
||||
sim.step()
|
||||
view.sync()
|
||||
assert_eq(sim.projectiles.size(), 1)
|
||||
assert_eq(view.entities.pickup_count(), 1, "the keg in flight")
|
||||
for _i: int in Explosives.fuse_ticks(ItemCatalog.get_def(ItemCatalog.code_of("powder_keg"))):
|
||||
sim.submit_command(1, PlayerCommand.from_input(sim.tick, Vector2.ZERO, 0.0, 0.0, 0, 1))
|
||||
sim.step()
|
||||
view.sync()
|
||||
assert_eq(sim.projectiles.size(), 0)
|
||||
assert_eq(view.entities.pickup_count(), 0, "gone once it blew")
|
||||
view.free()
|
||||
|
||||
Reference in New Issue
Block a user