From a0aee34e3c505afc08fb8dcdfda1926193811bfe Mon Sep 17 00:00:00 2001 From: Forrest Date: Tue, 6 Oct 2026 13:39:00 -0400 Subject: [PATCH] Task #18: Alien Ray fires a beam The Alien Ray is now a held beam instead of a copy of the potato shot. While fire is held it ticks every alien_ray_tick_interval (0.15 s). Each tick traces a path from the scarecrow's center through the muzzle and on alien_ray_range (20 m) past it, cut short at the first wall (AlienBeam.trace on the world layer). It damages every enemy within alien_ray_width / 2 (0.25 m) plus its hit radius of that path, flyers included as with shots, nearest first, up to alien_ray_pierce (4), for alien_ray_damage (1). That is about 6.7 damage a second per enemy on the beam. Hits stay inside combat.step, so enemies.attacker credits kills. - EnemySystem.path_hits: every enemy along a polyline, ordered along it, with flat ends (nothing behind the scarecrow or past the wall). sweep_hit is unchanged. - AlienBeam: a WeaponModels held effect (hold 1.5 ticks, no fade). It is an unshaded HDR green core and glow, a muzzle light, and a flare where a wall stops it. Each frame it lays itself out from the muzzle along the model's -Z, with the same trace, so the partner's machine recomputes the wall clip locally. No protocol change. - Counters: a beam_ticks counter joins attacks(), and ray ticks no longer count as shots_fired. - Config: alien_ray_speed, alien_ray_lifetime and alien_ray_cooldown are removed. alien_ray_range, _width, _tick_interval and _pierce are added. The shop text says what it does now. Cost and hidden/reveal are unchanged. - Sound: a zapped signal and a "zap" cue (synth alien_beam.wav, its own seed). The other synth files regenerate byte-identical. Tests (test_weapons) replace the projectile-travel ray check and keep buy/equip: - a far target is hit on the same step; - nothing beside, behind or past the end is hit; - two in line and a crow are all hit; - a line is capped at pierce; - a wall stops it, including a barrel poking through one; - held ticks repeat and stop on release; - the beam is lit only while held, ends at the wall clip, follows the model's yaw, and the replica and attack-event paths work. Co-Authored-By: Claude Opus 5.5 --- assets/audio/CREDITS.md | 5 +- assets/audio/synth/alien_beam.wav | Bin 0 -> 15038 bytes assets/audio/synth/alien_beam.wav.import | 24 +++ game/resources/game_config.tres | 2 +- game/scripts/alien_beam.gd | 178 ++++++++++++++++++++ game/scripts/alien_beam.gd.uid | 1 + game/scripts/enemy_system.gd | 40 +++++ game/scripts/farm_audio.gd | 7 +- game/scripts/game_config.gd | 21 ++- game/scripts/scarecrow_combat.gd | 75 ++++++--- game/scripts/weapon_models.gd | 11 +- game/tests/test_weapons.gd | 206 ++++++++++++++++++++++- game/tools/synth_audio.gd | 28 +++ 13 files changed, 554 insertions(+), 44 deletions(-) create mode 100644 assets/audio/synth/alien_beam.wav create mode 100644 assets/audio/synth/alien_beam.wav.import create mode 100644 game/scripts/alien_beam.gd create mode 100644 game/scripts/alien_beam.gd.uid diff --git a/assets/audio/CREDITS.md b/assets/audio/CREDITS.md index 4db91c0..f325cdc 100644 --- a/assets/audio/CREDITS.md +++ b/assets/audio/CREDITS.md @@ -31,5 +31,6 @@ for before release. `synth/` is generated by `game/tools/synth_audio.gd` (deterministic, fixed seeds): the day and night ambience loops, the crow caws and squawk, the farmers' car (engine loop and horn), the -pitchfork's whoosh, the pumpkin bomb's burst, and the propane torch's roar. Kenney's packs have -no farm ambience, birds, vehicles, explosions, or fire. Re-run the tool to regenerate them. +pitchfork's whoosh, the pumpkin bomb's burst, the propane torch's roar, and the alien ray's hum. +Kenney's packs have no farm ambience, birds, vehicles, explosions, or fire. Re-run the tool to +regenerate them. diff --git a/assets/audio/synth/alien_beam.wav b/assets/audio/synth/alien_beam.wav new file mode 100644 index 0000000000000000000000000000000000000000..3d2689bd7a8606fbaca30100665832118975c92c GIT binary patch literal 15038 zcmWMtbzEXy6Q%@35CkO^1Q7wT13T7Tx4XX0ce}ga?e6aG-FJK4b;IuNq7-1pAQ-U0075@z6b!A_yqs}0nmVT ztM{$GJ+1=)U;)8^MSxj=t$^cz*MNn9{{glGWPniMZQy6%8{h<>2QU?w0XPGA1vmzT z02c!H0->NV&|Od$FcRbk;)BLOzTj7&m7q>A2$BnNfYTrZ@EGVZ@IH7lxZDX0#X*}O zH^6%#cR}fn@Ag{z8XMZyZrxxlvnwod<~;L!^YM|y(X3J3=rPN4vxjAhWv!)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pc-(~@W9+U_`rV|T}*06)N1$P*`+699^YZik@3 z{{vrzWP-y%O`rqd8<5xFmyoYciy_A#3Wytc4&(%AA_xTB0oV^}1U(1#0a*||fBQseOWjY%dts+-uLW7umOtziak?O#(4a`b$}g#j(rZQIv0dp|Cx#x9NT0Yzi=V_(Nw#-(noV61lBqSo;d Y{#fT&?^xHEW?YP8<}vG-ZOlIQf31!|w*UYD literal 0 HcmV?d00001 diff --git a/assets/audio/synth/alien_beam.wav.import b/assets/audio/synth/alien_beam.wav.import new file mode 100644 index 0000000..4188481 --- /dev/null +++ b/assets/audio/synth/alien_beam.wav.import @@ -0,0 +1,24 @@ +[remap] + +importer="wav" +type="AudioStreamWAV" +uid="uid://ceto7qi6bygq3" +path="res://.godot/imported/alien_beam.wav-642f51d82976a361c6cc469d9ac0236b.sample" + +[deps] + +source_file="res://assets/audio/synth/alien_beam.wav" +dest_files=["res://.godot/imported/alien_beam.wav-642f51d82976a361c6cc469d9ac0236b.sample"] + +[params] + +force/8_bit=false +force/mono=false +force/max_rate=false +force/max_rate_hz=44100 +edit/trim=false +edit/normalize=false +edit/loop_mode=0 +edit/loop_begin=0 +edit/loop_end=-1 +compress/mode=2 diff --git a/game/resources/game_config.tres b/game/resources/game_config.tres index 9cb67b3..32fd32d 100644 --- a/game/resources/game_config.tres +++ b/game/resources/game_config.tres @@ -104,7 +104,7 @@ upgrades = { "hidden": true, "name": "Alien ray", "shop": "shed", -"text": "A salvaged alien weapon: a fast, powerful beam", +"text": "A salvaged alien weapon: a long beam that pierces everything in its line while held", "track": "Weapon" }, "corn_shooter": { diff --git a/game/scripts/alien_beam.gd b/game/scripts/alien_beam.gd new file mode 100644 index 0000000..380f388 --- /dev/null +++ b/game/scripts/alien_beam.gd @@ -0,0 +1,178 @@ +class_name AlienBeam +extends Node3D +## The Alien Ray's beam (#18): a glowing green ray from the gun's muzzle straight out for length m, +## cut short at the first wall, with a green glow at the muzzle and a flare where a wall stops +## it. A WeaponModels held effect: it sits at the muzzle facing the way the scarecrow's model does +## (-Z), so it follows the model's yaw, which is all the partner's machine knows of the other +## scarecrow's aim. set_lit() shows it and hides it. +## While lit it is laid out again every frame (rebuild): trace() runs the same wall test as the +## damage does (ScarecrowCombat.beam_path), from the scarecrow's center through the muzzle and on, +## so its end is where the damage stops, on either machine (the walls are the same static farm on +## both, so the partner's machine needs nothing sent for it). + +## The beam's parts, as shares of the ray's hit width (alien_ray_width): a white-hot core and a +## green glow around it, both unshaded and brighter than white (HDR), so the beam still burns +## through the night look's dimmed picture, and unfogged. +const CORE := 0.22 +const GLOW := 0.75 +const CORE_COLOR := Color(0.85, 2.2, 1.0) +const GLOW_COLOR := Color(0.25, 1.6, 0.45, 0.45) +## The glow's width pulses this much (share), this fast (Hz), so the beam hums. +const PULSE := 0.18 +const PULSE_HZ := 9.0 +const LIGHT_COLOR := Color(0.4, 1.0, 0.5) +const LIGHT_ENERGY := 1.8 +const LIGHT_RANGE := 3.2 +const FLARE_SIZE := 0.5 +const WORLD_LAYER := 1 + +## The ray it was built for (m): how far it reaches past the muzzle, and how wide it hits. +var length: float +var width: float +var lit := false +## The beam as last laid out (world space): from the muzzle to where it ends, and whether a wall +## stopped it (at the barrel: nothing is drawn). +var start := Vector3.ZERO +var end := Vector3.ZERO +var blocked := false +var _core: MeshInstance3D +var _glow: MeshInstance3D +var _flare: MeshInstance3D +var _light: OmniLight3D +var _ray := PhysicsRayQueryParameters3D.new() +var _time := 0.0 + + +func _init(p_length: float = 20.0, p_width: float = 0.5) -> void: + length = p_length + width = p_width + name = "AlienBeam" + _ray.collision_mask = WORLD_LAYER + _ray.collide_with_areas = false + _core = _part("Core", _cylinder(), _material(CORE_COLOR, false)) + _glow = _part("Glow", _cylinder(), _material(GLOW_COLOR, true)) + var ball := SphereMesh.new() + ball.radius = 0.5 + ball.height = 1.0 + ball.radial_segments = 12 + ball.rings = 6 + _flare = _part("Flare", ball, _material(GLOW_COLOR, true)) + _light = OmniLight3D.new() + _light.name = "Glow" + _light.light_color = LIGHT_COLOR + _light.light_energy = LIGHT_ENERGY + _light.omni_range = LIGHT_RANGE + _light.shadow_enabled = false + add_child(_light) + set_lit(false) + + +## Shows the beam (laid out now and every frame after), or hides it. +func set_lit(on: bool) -> void: + lit = on + _light.visible = on + if on and is_inside_tree(): + rebuild(global_transform) + else: + for mi: MeshInstance3D in [_core, _glow, _flare]: + mi.visible = false + + +## Lays the beam out from a transform of this node (its global one, or the interpolated one each +## frame): the muzzle is its origin, the aim its -Z (level), and the scarecrow's center the point +## at the muzzle's height straight above the model's origin. Returns how long it is (m). +func rebuild(xform: Transform3D) -> float: + var fwd := -xform.basis.z + fwd.y = 0.0 + fwd = fwd.normalized() if fwd.length() > 1e-4 else Vector3.FORWARD + var center := xform * Vector3(-position.x, 0.0, -position.z) # (this node has no turn of its own) + var space := get_world_3d().direct_space_state if is_inside_tree() else null + var path := trace(space, _ray, center, xform.origin, fwd, length) + start = xform.origin + end = path[path.size() - 1] + blocked = path.size() < 3 or end.distance_to(start) < length - 1e-3 + var shown := lit and path.size() == 3 + var span := end - start + var span_len := span.length() if shown else 0.0 + _core.visible = shown and span_len > 1e-3 + _glow.visible = _core.visible + _flare.visible = _core.visible and blocked + if _core.visible: + var pulse := 1.0 + PULSE * sin(TAU * PULSE_HZ * _time) + _lay(_core, start, fwd, span_len, width * CORE) + _lay(_glow, start, fwd, span_len, width * GLOW * pulse) + _flare.global_transform = Transform3D(Basis.IDENTITY.scaled(Vector3.ONE * FLARE_SIZE * pulse), end) + return span_len + + +## The beam's path, world space at the gun's height: from center (the scarecrow's) through muzzle, +## then along dir (unit, level) for length m, cut at the first wall (space: the farm's physics, +## query: a ray on the world layer; null space: no walls). [center, muzzle, end], or, when a +## wall stands between the center and the muzzle (a barrel poking through it), [center, the hit]. +## Shared with ScarecrowCombat, so the damage and the beam drawn end at the same wall. +static func trace(space: PhysicsDirectSpaceState3D, query: PhysicsRayQueryParameters3D, center: Vector3, + muzzle: Vector3, dir: Vector3, p_length: float) -> PackedVector3Array: + var path := PackedVector3Array([center]) + for to: Vector3 in [muzzle, muzzle + dir * p_length]: + if space != null: + query.from = path[path.size() - 1] + query.to = to + var hit := space.intersect_ray(query) + if not hit.is_empty(): + path.append(hit["position"]) + return path + path.append(to) + return path + + +func _process(delta: float) -> void: + if not lit: + return + _time = fmod(_time + delta, 1.0) + rebuild(get_global_transform_interpolated()) + + +## A part of the beam, placed in world space (top_level) each frame, drawn as it's placed. +func _part(part_name: String, mesh: Mesh, mat: Material) -> MeshInstance3D: + var mi := MeshInstance3D.new() + mi.name = part_name + mi.mesh = mesh + mi.material_override = mat + mi.cast_shadow = GeometryInstance3D.SHADOW_CASTING_SETTING_OFF + mi.top_level = true + mi.physics_interpolation_mode = Node.PHYSICS_INTERPOLATION_MODE_OFF + add_child(mi) + return mi + + +## A cylinder 1 m long (along Y) and 1 m across: _lay stretches it. +static func _cylinder() -> CylinderMesh: + var c := CylinderMesh.new() + c.top_radius = 0.5 + c.bottom_radius = 0.5 + c.height = 1.0 + c.radial_segments = 10 + c.rings = 1 + c.cap_top = false + c.cap_bottom = false + return c + + +## Stretches a unit cylinder from `from` along dir (unit, level) for span m, thick m across. +static func _lay(mi: MeshInstance3D, from: Vector3, dir: Vector3, span: float, thick: float) -> void: + var side := dir.cross(Vector3.UP) + mi.global_transform = Transform3D(Basis(side * thick, dir * span, Vector3.UP * thick), from + dir * span * 0.5) + + +static func _material(color: Color, blend: bool) -> StandardMaterial3D: + var mat := StandardMaterial3D.new() + mat.shading_mode = BaseMaterial3D.SHADING_MODE_UNSHADED + mat.albedo_color = color + mat.emission_enabled = true + mat.emission = Color(color.r, color.g, color.b) + mat.disable_fog = true + mat.cull_mode = BaseMaterial3D.CULL_DISABLED + if blend: + mat.transparency = BaseMaterial3D.TRANSPARENCY_ALPHA + mat.render_priority = 1 + return mat diff --git a/game/scripts/alien_beam.gd.uid b/game/scripts/alien_beam.gd.uid new file mode 100644 index 0000000..b9bb58e --- /dev/null +++ b/game/scripts/alien_beam.gd.uid @@ -0,0 +1 @@ +uid://db40w7us6cn6d diff --git a/game/scripts/enemy_system.gd b/game/scripts/enemy_system.gd index 72644ca..a1c3c7c 100644 --- a/game/scripts/enemy_system.gd +++ b/game/scripts/enemy_system.gd @@ -570,6 +570,46 @@ func sweep_hit(x0: float, z0: float, x1: float, z1: float, use_motion: bool) -> return best +## Every living enemy along a path at combat height (a polyline: the Alien Ray's beam, #18, from +## the scarecrow through the muzzle to where it ends), flyers included like sweep_hit (their hit +## proxy stays at combat height): those whose hit proxy (hit_radius) comes within half_width of +## the path, ordered by how far along it they are (dense slots, at most max_hits; 0: all). Unlike +## sweep_hit (the nearest only, for shots that stop) it's for a beam that pierces. The ends are +## flat: nothing behind the path's start or past its end (a wall that cut it short) is hit, even +## if its proxy reaches across. Current positions (no motion test), every slot checked rather than +## the grid, which misses enemies spawned since the last step. +func path_hits(path: PackedVector2Array, half_width: float, max_hits: int = 0) -> PackedInt32Array: + var out := PackedInt32Array() + var last := path.size() - 2 + if last < 0: + return out + var head := path[1] - path[0] + var tail := path[last + 1] - path[last] + var found: Array = [] # [distance along the path, slot] + for i in active_count: + if alive[i] == 0: + continue + var e := Vector2(pos_x[i], pos_z[i]) + if (e - path[0]).dot(head) < 0.0 or (e - path[last + 1]).dot(tail) > 0.0: + continue # behind its start, or past its end + var reach := half_width + t_hit_radius[type[i]] + var along := 0.0 + for k in last + 1: + var a := path[k] + var ab := path[k + 1] - a + var seg := ab.length() + if seg > 1e-6: + var u := clampf((e - a).dot(ab) / (seg * seg), 0.0, 1.0) + if e.distance_squared_to(a + ab * u) <= reach * reach: + found.append([along + u * seg, i]) + break + along += seg + found.sort_custom(func(x: Array, y: Array) -> bool: return x[0] < y[0]) + for k in (found.size() if max_hits <= 0 else mini(found.size(), max_hits)): + out.append(found[k][1]) + return out + + ## Releases this tick's removals: emits enemy_removed (handle still valid), then swaps the last ## active enemy into each freed slot and updates every mapping. func commit_removals() -> void: diff --git a/game/scripts/farm_audio.gd b/game/scripts/farm_audio.gd index aa7ac1d..1ea3a10 100644 --- a/game/scripts/farm_audio.gd +++ b/game/scripts/farm_audio.gd @@ -4,8 +4,8 @@ extends Node3D ## stingers and outcomes; SFX: everything else; Ambience: the day and night loops). FarmSim ## creates it and setup() connects it to the farm's systems: ## * scarecrow: footsteps, its weapons (a pitchfork's whoosh and what it strikes, corn shots, -## the propane torch's roar, a pumpkin bomb's toss and burst), hurt, fall, fear and fear -## ready, patching and patched +## the propane torch's roar, the alien ray's hum, a pumpkin bomb's toss and burst), hurt, +## fall, fear and fear ready, patching and patched ## * enemies: crow caws and thieves' / fence breakers' / UFOs' arrivals (from where they come ## in), hits and deaths by type ## * theft: grabbed, dropped, recovered, carried off (with an alarm tone), animals following @@ -44,6 +44,8 @@ const CUES := { "stab": {"files": ["synth/pitchfork_whoosh.wav"], "db": -6.0, "pitch": 0.12, "max": 3}, # The Propane Torch: one roar per tick, each longer than a tick, so a held torch roars on. "burn": {"files": ["synth/torch_roar.wav"], "db": -7.0, "pitch": 0.08, "gap": 0.1, "max": 3}, + # The Alien Ray: one hum per tick, likewise longer than a tick, so a held ray hums on. + "zap": {"files": ["synth/alien_beam.wav"], "db": -10.0, "pitch": 0.04, "gap": 0.07, "max": 3}, "throw": {"files": ["kenney/rpg/cloth*.ogg"], "db": -4.0, "pitch": 0.1}, "boom": {"files": ["synth/pumpkin_boom.wav"], "db": 0.0, "pitch": 0.08, "gap": 0.05, "max": 4}, "hurt": {"files": ["kenney/impact/impactSoft_heavy_00*.ogg"], "db": -1.0, "pitch": 0.1, "gap": 0.1}, @@ -303,6 +305,7 @@ func _wire_weapons(combat: ScarecrowCombat, at: Callable) -> void: combat.fired.connect(func() -> void: play("shot", where.call())) combat.stabbed.connect(func(_n: int) -> void: play("stab", where.call())) combat.burned.connect(func(_n: int) -> void: play("burn", where.call())) + combat.zapped.connect(func(_n: int) -> void: play("zap", where.call())) combat.struck.connect(func(p: Vector3, type: int) -> void: play("hit_crow" if type == EnemySystem.TYPE_CROW else "hit", p)) combat.threw.connect(func(_to: Vector3) -> void: play("throw", where.call())) diff --git a/game/scripts/game_config.gd b/game/scripts/game_config.gd index 2ac3e13..80fcc35 100644 --- a/game/scripts/game_config.gd +++ b/game/scripts/game_config.gd @@ -155,7 +155,7 @@ extends Resource "potato_cannon": {"name": "Potato cannon", "text": "A slow heavy potato shot that hits hard from afar", "track": "Weapon", "shop": "shed"}, "shurikens": {"name": "Shurikens", "text": "Fast, cheap throws for a quick hit", "track": "Weapon", "shop": "shed"}, "propane_torch": {"name": "Propane torch", "text": "A jet of flame that burns everything in a band ahead of you while held", "track": "Weapon", "shop": "shed"}, - "alien_ray": {"name": "Alien ray", "text": "A salvaged alien weapon: a fast, powerful beam", "track": "Weapon", "shop": "shed", "hidden": true}, + "alien_ray": {"name": "Alien ray", "text": "A salvaged alien weapon: a long beam that pierces everything in its line while held", "track": "Weapon", "shop": "shed", "hidden": true}, "radar": {"name": "Radar", "text": "A minimap showing nearby enemy positions", "track": "Item", "shop": "shed", "hidden": true}, "wide_fear": {"name": "Wide fear", "text": "Fear reaches 30% farther", "track": "Fear", "stat": "fear_radius", "mult": 1.3}, "quick_fear": {"name": "Quick fear", "text": "Fear recharges 20% faster", "track": "Fear", "stat": "fear_cooldown", "mult": 0.8}, @@ -298,13 +298,18 @@ extends Resource @export_range(1, 20) var torch_damage: int = 1 @export_range(1, 20) var torch_targets: int = 5 @export var torch_tick_interval: float = 0.2 -## Alien Ray (the Alien ray upgrade, hidden until hidden_reveal_goop Alien Goop is collected): one -## heavy shot every alien_ray_cooldown s, alien_ray_damage each, flying fast (alien_ray_speed m/s) -## through FarmProjectiles. -@export var alien_ray_cooldown: float = 0.9 -@export_range(1, 80) var alien_ray_damage: int = 9 -@export var alien_ray_speed: float = 50.0 -@export var alien_ray_lifetime: float = 2.0 +## Alien Ray (the Alien ray upgrade, hidden until hidden_reveal_goop Alien Goop is collected): a +## beam while held (#18), a tick every alien_ray_tick_interval s, alien_ray_damage each to every +## enemy within alien_ray_width / 2 (plus its hit radius) of the beam, flyers too (the nearest +## alien_ray_pierce), from the scarecrow through the muzzle and on alien_ray_range m past it, cut +## short at the first wall (ScarecrowCombat.beam_path, EnemySystem.path_hits). It hits at once +## (no projectile). 1 every 0.15 s is about 6.7 damage a second to each enemy on the beam: the +## shed's guns do 4 to 6 to one, the torch 5 to each in its short band. +@export var alien_ray_range: float = 20.0 +@export var alien_ray_width: float = 0.5 +@export var alien_ray_tick_interval: float = 0.15 +@export_range(1, 80) var alien_ray_damage: int = 1 +@export_range(1, 20) var alien_ray_pierce: int = 4 @export_group("Radar") ## Radar (the Radar item, bought at the supply shed, hidden until hidden_reveal_goop Alien Goop is diff --git a/game/scripts/scarecrow_combat.gd b/game/scripts/scarecrow_combat.gd index 1695913..c12d533 100644 --- a/game/scripts/scarecrow_combat.gd +++ b/game/scripts/scarecrow_combat.gd @@ -40,13 +40,17 @@ extends Node3D ## gun's line, from the scarecrow out to torch_range past the muzzle (the ## nearest torch_targets), with a clear line (_band_hit), and its flame ## (TorchFlame) lit while fire is held -## alien ray one fast, powerful alien_ray_damage shot every alien_ray_cooldown, through -## FarmProjectiles at alien_ray_speed +## alien ray a beam while held (#18): an alien_ray_damage tick every +## alien_ray_tick_interval to every enemy along it (the nearest +## alien_ray_pierce), alien_ray_width wide, from the scarecrow through the +## muzzle and on alien_ray_range past it, cut short at the first wall +## (beam_path, EnemySystem.path_hits); no projectile, so it hits at once, and +## its beam (AlienBeam) shows while fire is held ## * Every weapon's model on the scarecrow (WeaponModels), an aim marker, and while a pumpkin ## bomb is ready a ring on the ground where one would land, as wide as its blast. A held -## weapon (the torch) lights its effect on each attack instead of replaying a motion; the -## effect stays lit for HOLD_TICKS of its ticks after the last one (WeaponModels.add_held_effect) -## and goes out at once when fire is let go. +## weapon (the torch, the alien ray) lights its effect on each attack instead of replaying a +## motion; the effect stays lit for HOLD_TICKS of its ticks after the last one +## (WeaponModels.add_held_effect) and goes out at once when fire is let go. ## While attacking, the model faces the aim. ## Co-op: the partner's weapons on the host read its RemoteControls (aim, fire and offhand, and ## its pick of main weapon come from the partner's game); on the partner's machine its own only @@ -61,10 +65,11 @@ enum Weapon { PITCHFORK, CORN_SHOOTER, PUMPKIN_BOMB, POTATO_CANNON, SHURIKENS, P ## A corn shot left the gun (for its sound). signal fired -## A pitchfork stab (how many it hit), a Propane Torch tick (how many it burned), and each enemy -## either struck (for the sounds). +## A pitchfork stab (how many it hit), a Propane Torch tick (how many it burned), an Alien Ray +## tick (how many it zapped), and each enemy any of them struck (for the sounds). signal stabbed(hits: int) signal burned(hits: int) +signal zapped(hits: int) signal struck(at: Vector3, enemy_type: int) ## A pumpkin bomb thrown (where it will land). signal threw(at: Vector3) @@ -89,7 +94,7 @@ const OFFHAND_WEAPONS: Array[int] = [Weapon.PUMPKIN_BOMB] const SWITCH_ACTIONS: Array[StringName] = [&"weapon_next", &"weapon_1", &"weapon_2"] ## Main weapons that fire from the muzzle (SIDE_OFFSET/muzzle_distance), so aiming at a target ## needs the same muzzle correction as the corn shooter's (attack_toward, the mouse in _update_aim). -## The Propane Torch's band runs along the gun's line too (#17). +## The Propane Torch's band runs along the gun's line too (#17), and the Alien Ray's beam (#18). const MUZZLE_WEAPONS: Array[int] = [Weapon.CORN_SHOOTER, Weapon.POTATO_CANNON, Weapon.SHURIKENS, Weapon.PROPANE_TORCH, Weapon.ALIEN_RAY] ## A held weapon's effect stays lit this many of its tick intervals after its last tick, so it @@ -116,8 +121,10 @@ var ground_point := Vector3.ZERO var shots_fired: int = 0 var stabs: int = 0 var bombs_thrown: int = 0 -## Propane Torch ticks applied (its own count, like stabs/shots_fired/bombs_thrown). +## Propane Torch ticks applied (its own count, like stabs/shots_fired/bombs_thrown), and Alien Ray +## ticks (#18: a beam, not shots). var torch_ticks: int = 0 +var beam_ticks: int = 0 ## Seconds until the next pumpkin bomb is in hand (0 = ready). var bomb_left: float = 0.0 var remote: RemoteControls @@ -161,6 +168,8 @@ func setup(cfg: GameConfig, player: PlayerCharacter, camera: Camera3D, shots: Fa models.setup(player.model, Vector3(SIDE_OFFSET, cfg.combat_height, -cfg.muzzle_distance)) models.add_held_effect(Weapon.PROPANE_TORCH, TorchFlame.new(cfg.torch_range, cfg.torch_width), cfg.torch_tick_interval * HOLD_TICKS, TorchFlame.LIFETIME) + models.add_held_effect(Weapon.ALIEN_RAY, AlienBeam.new(cfg.alien_ray_range, cfg.alien_ray_width), + cfg.alien_ray_tick_interval * HOLD_TICKS) _build_marker() @@ -287,7 +296,7 @@ func step(_dt: float) -> void: _offhand_needs_release = true # couldn't attack last tick (a menu, the partner's build mode) _stepped = _ticks if not held: - models.douse() # the torch's flame goes out as soon as fire is let go + models.douse() # the torch's flame and the ray's beam go out as soon as fire is let go if replica: if held: _player.face_aim(aim, 0.35) @@ -331,7 +340,7 @@ func offhand_toward(target: Vector2) -> bool: ## Attacks so far, with any weapon. func attacks() -> int: - return stabs + shots_fired + bombs_thrown + torch_ticks + return stabs + shots_fired + bombs_thrown + torch_ticks + beam_ticks ## Ticks between shots, and a shot's damage, with upgrades. @@ -350,7 +359,7 @@ func stab_ticks() -> int: ## Ticks between Potato Cannon shots, Shurikens throws, Propane Torch DoT ticks, and Alien Ray -## shots (each its own cooldown, GameConfig-tunable, no ammo). +## beam ticks (each its own cooldown, GameConfig-tunable, no ammo). func potato_ticks() -> int: return maxi(1, roundi(_cfg.potato_cannon_cooldown * Engine.physics_ticks_per_second)) @@ -364,7 +373,7 @@ func torch_interval_ticks() -> int: func alien_ray_ticks() -> int: - return maxi(1, roundi(_cfg.alien_ray_cooldown * Engine.physics_ticks_per_second)) + return maxi(1, roundi(_cfg.alien_ray_tick_interval * Engine.physics_ticks_per_second)) ## Where a bomb thrown now lands: the ground point aimed at (GAMEPAD_THROW ahead with the stick), @@ -402,7 +411,7 @@ func _use(w: int) -> bool: _torch_tick() Weapon.ALIEN_RAY: _cooldown[w] = alien_ray_ticks() - _shoot_alien_ray() + _beam_tick() _: _cooldown[w] = stab_ticks() _stab() @@ -460,17 +469,39 @@ func _shoot_potato() -> void: fired.emit() -## The Alien Ray: a fast, powerful shot through FarmProjectiles (hidden until enough Alien Goop is -## collected, Upgrades.revealed). -func _shoot_alien_ray() -> void: +## The Alien Ray's beam now (#18), world space at combat height: from the scarecrow's center +## through the muzzle, then on along the aim for alien_ray_range m, cut short at the first wall +## (AlienBeam.trace, which its beam drawn shares): [center, muzzle, end], or [center, the wall] +## when the barrel pokes through one. +func beam_path() -> PackedVector3Array: var origin := Vector3(_player.global_position.x, _cfg.combat_height, _player.global_position.z) var dir := Vector3(aim.x, 0.0, aim.y) var right := Vector3(-aim.y, 0.0, aim.x) var muzzle := origin + dir * _cfg.muzzle_distance + right * SIDE_OFFSET - shots_fired += 1 - _shots.fire(origin, muzzle, dir, _cfg.alien_ray_damage, _cfg.alien_ray_speed, _cfg.alien_ray_lifetime) + var space := get_world_3d().direct_space_state if is_inside_tree() else null + return AlienBeam.trace(space, _ray, origin, muzzle, dir, _cfg.alien_ray_range) + + +## The Alien Ray (hidden until enough Alien Goop is collected, Upgrades.revealed): a beam, applied +## every alien_ray_tick_interval s while held (it stops the moment fire is released). Each tick +## hits every enemy along beam_path within alien_ray_width / 2 (plus its hit radius), flyers too, +## the nearest alien_ray_pierce of them, for alien_ray_damage; nothing past the wall that ends it. +## Its beam is lit (WeaponModels' held effect). Inside step(), so FarmSim's enemies.attacker +## credits the kills to this scarecrow. +func _beam_tick() -> int: + beam_ticks += 1 models.attack(Weapon.ALIEN_RAY) - fired.emit() + var hits := 0 + if enemies != null: + var path := PackedVector2Array() + for p in beam_path(): + path.append(Vector2(p.x, p.z)) + var found: Array = [] # [order along the beam, slot] + for d in enemies.path_hits(path, _cfg.alien_ray_width * 0.5, _cfg.alien_ray_pierce): + found.append([found.size(), d]) + hits = _hit_nearest(found, _cfg.alien_ray_pierce, _cfg.alien_ray_damage) + zapped.emit(hits) + return hits ## Shurikens: shuriken_count fast, cheap projectiles through FarmProjectiles, on a short cooldown. @@ -546,8 +577,8 @@ func _band_hit(length: float, width: float, max_targets: int, damage: int) -> in return _hit_nearest(found, max_targets, damage) -## Damages the first max_targets of found ([distance, slot] pairs), nearest first. Returns how many -## it hit. +## Damages the first max_targets of found ([distance, slot] pairs), nearest first (the pitchfork, +## the torch, and the ray's beam). Returns how many it hit. func _hit_nearest(found: Array, max_targets: int, damage: int) -> int: var hits := 0 var es := enemies diff --git a/game/scripts/weapon_models.gd b/game/scripts/weapon_models.gd index b2bfcf5..665e2d7 100644 --- a/game/scripts/weapon_models.gd +++ b/game/scripts/weapon_models.gd @@ -15,11 +15,12 @@ extends Node3D ## yet (visuals stay out of scope): each is a placeholder pivot (_add_placeholder) at the corn ## shooter's gun spot, the corn shooter's mesh tinted a different color so they're still tellable ## apart in play; it kicks back like a gun on each attack, unless it's a held weapon. -## Held weapons (add_held_effect; the Propane Torch's TorchFlame, #17) attack every short tick -## while fire is held, so each attack lights their effect instead of replaying a motion. The -## effect sits at the muzzle facing the model's way and stays lit for its hold s after each -## attack: lit while fire is held, out hold s after the last attack (or at once with douse(), -## when fire is let go). Then it fades for fade s (shown, no longer lit) before it's hidden. The +## Held weapons (add_held_effect; the Propane Torch's TorchFlame, #17, and the Alien Ray's +## AlienBeam, #18) attack every short tick while fire is held, so each attack lights their effect +## instead of replaying a motion. The effect sits at the muzzle facing the model's way and stays +## lit for its hold s after each attack: lit while fire is held, out hold s after the last attack +## (or at once with douse(), when fire is let go). Then it fades for fade s (shown, no longer lit; +## the torch's fire in the air dying away, none for the beam) before it's hidden. The ## timers run on the simulation's clock, advance() from ScarecrowCombat.tick() (hand-stepped tests ## drive it too), or on the physics frames when nothing advances them: in co-op, the other ## scarecrow on the partner's farm is lit by its attack events and stepped by nothing there (and diff --git a/game/tests/test_weapons.gd b/game/tests/test_weapons.gd index ee7020d..2e3837e 100644 --- a/game/tests/test_weapons.gd +++ b/game/tests/test_weapons.gd @@ -10,8 +10,8 @@ extends RefCounted ## weapon in hand, both at once, held, not with the right click that leaves build mode); a bomb's ## throw (at the aim, its range clamped), flight, and burst (everything in its radius, crows too, ## nothing beyond, not the scarecrow), its recharge and the morning refill; the models on the -## scarecrow; the HUD's weapon panel; the shed's other weapons; and the Propane Torch's band of -## fire and its flame (#17). +## scarecrow; the HUD's weapon panel; the shed's other weapons; the Propane Torch's band of +## fire and its flame (#17); and the Alien Ray's beam (#18). const DT := 1.0 / 60.0 const AT := Vector2(0.0, 6.0) # open ground south-west of the pen @@ -41,6 +41,7 @@ func run(r: GameTestRunner) -> void: _hud(r, farm, sim) _shed_weapons(r, farm, sim) await _torch(r, farm, sim) + await _alien_ray(r, farm, sim) sim.enemies.behavior = keep farm.queue_free() await r.process_frame @@ -334,7 +335,8 @@ func _hud(r: GameTestRunner, farm: Node3D, sim: FarmSim) -> void: ## Task #7's four shed weapons (Potato Cannon, Shurikens, Propane Torch, Alien Ray): each ## purchasable at the supply shed, equippable, and deals damage. The Alien Ray stays hidden until -## enough Alien Goop is collected (Upgrades.revealed), then buys and works like the others. +## enough Alien Goop is collected (Upgrades.revealed), then buys like the others (_alien_ray: its +## beam, #18; _torch: the torch's band, #17). func _shed_weapons(r: GameTestRunner, farm: Node3D, sim: FarmSim) -> void: var c := sim.combat var cfg := sim.config @@ -355,7 +357,6 @@ func _shed_weapons(r: GameTestRunner, farm: Node3D, sim: FarmSim) -> void: r.check(Upgrades.revealed(s, cfg, "alien_ray"), "revealed once hidden_reveal_goop is collected") _buy_equip_hit(r, farm, sim, "potato_cannon", W.POTATO_CANNON, cfg.potato_cannon_speed) _buy_equip_hit(r, farm, sim, "shurikens", W.SHURIKENS, cfg.shuriken_speed) - _buy_equip_hit(r, farm, sim, "alien_ray", W.ALIEN_RAY, cfg.alien_ray_speed) c.equip(W.PITCHFORK) @@ -486,6 +487,203 @@ func _torch(r: GameTestRunner, farm: Node3D, sim: FarmSim) -> void: _clear(sim) +## The Alien Ray (#18), revealed in _shed_weapons: bought at the supply shed, a beam from the +## scarecrow through the muzzle and on alien_ray_range past it. A tick hits at once, however far +## along the beam, every enemy on it (crows too, the nearest alien_ray_pierce); nothing beside, +## behind, or beyond it; nothing past a wall, which cuts it short. Held, it ticks every +## alien_ray_tick_interval and stops on release. Its beam shows only while fire is held, follows +## the model's yaw, and ends where the damage does: its own wall test, as on the partner's +## machine, where attack events light it and it goes out by itself. +func _alien_ray(r: GameTestRunner, farm: Node3D, sim: FarmSim) -> void: + var c := sim.combat + var cfg := sim.config + var s := sim.campaign.state + var es := sim.enemies + var panel := farm.get_node("Hud/ShedPanel") as UpgradePanel + var model := sim.player.model + var at := Vector2(sim.player.global_position.x, sim.player.global_position.z) # (AT, give or take; east is open) + s.resources.shed = {"wood": 999, "scrap": 999, "straw": 999, "alien_goop": 999} + r.check(Upgrades.revealed(s, cfg, "alien_ray") and not c.owns(W.ALIEN_RAY), "the alien ray (revealed) isn't owned yet") + panel._buy("alien_ray") + r.check(Upgrades.owned(s, "alien_ray") and c.owns(W.ALIEN_RAY), "it's purchasable at the supply shed") + r.check(c.equip(W.ALIEN_RAY) and c.weapon == W.ALIEN_RAY, "and equippable") + var beam := c.models.held_effect(W.ALIEN_RAY) as AlienBeam + r.check(beam != null and not beam.visible and not c.models.lit(W.ALIEN_RAY), "its beam is off until it fires") + r.check(is_equal_approx(beam.length, cfg.alien_ray_range) and is_equal_approx(beam.width, cfg.alien_ray_width), + "the beam is sized to the ray (%.0f m long, %.1f m wide)" % [beam.length, beam.width]) + var full := es.t_hp[THIEF] + var reach := cfg.muzzle_distance + cfg.alien_ray_range # from the scarecrow's center + var east := at + Vector2(16.0, 0.0) + # One tick aimed east, spawned and zapped on the same step: no shot to wait for. The gun's line + # runs SIDE_OFFSET south of the scarecrow's, bent onto the aim point. + var far := es.spawn(THIEF, at.x + reach - 1.0, at.y, Vector2.LEFT) + var beside := es.spawn(THIEF, at.x + 7.0, at.y + 1.4, Vector2.LEFT) + var beside2 := es.spawn(THIEF, at.x + 11.0, at.y - 1.3, Vector2.LEFT) + var behind := es.spawn(THIEF, at.x - 1.5, at.y, Vector2.RIGHT) + var beyond := es.spawn(THIEF, at.x + reach + 1.5, at.y, Vector2.LEFT) + c.reset() + var ticks := c.beam_ticks + var shots := c.shots_fired + var attacks := c.attacks() + var played := sim.audio.played if sim.audio != null else {} + var zaps := int(played.get("zap", 0)) + var pops := int(played.get("shot", 0)) + r.check(c.attack_toward(east) and c.beam_ticks == ticks + 1 and c.shots_fired == shots and c.attacks() == attacks + 1, + "it fires a beam tick (counted as one, not as a shot)") + r.check(sim.audio == null or (int(played.get("zap", 0)) == zaps + 1 and int(played.get("shot", 0)) == pops), + "with a hum (its own sound, not the gun's pop)") + r.check(_hp(es, far) == full - cfg.alien_ray_damage, + "a thief %.0f m off, near the beam's end, is hit for %d on the same step" % [reach - 1.0, cfg.alien_ray_damage]) + r.check(_hp(es, beside) == full and _hp(es, beside2) == full, "one beside the beam, either side, isn't") + r.check(_hp(es, behind) == full and _hp(es, beyond) == full, "nor one behind the scarecrow, nor one past the beam's end") + r.check(c.models._attack_t < 0.0 and c.models.lit(W.ALIEN_RAY) and beam.visible, + "a tick lights the beam instead of replaying the gun's kick") + # The beam drawn, on the model turned to the aim (all the partner's machine knows of it), runs + # from the muzzle to the end of the damage's path. + var yaw := model.rotation.y + model.rotation.y = atan2(-c.aim.x, -c.aim.y) + var path := c.beam_path() + var drawn := beam.rebuild(beam.global_transform) + r.check(path.size() == 3 and _flat(beam.start).distance_to(_flat(path[1])) < 0.02 and _flat(beam.end).distance_to(_flat(path[2])) < 0.02 + and absf(drawn - cfg.alien_ray_range) < 0.02 and not beam.blocked and beam._core.visible, + "the beam runs from the muzzle the full %.0f m, where the damage does (drawn %.2f m)" % [cfg.alien_ray_range, drawn]) + _clear(sim) + # Two in line (and a crow over the same line) are all hit: it pierces. + var first := es.spawn(THIEF, at.x + 4.0, at.y, Vector2.LEFT) + var second := es.spawn(THIEF, at.x + 8.0, at.y, Vector2.LEFT) + var crow := es.spawn(EnemySystem.TYPE_CROW, at.x + 12.0, at.y, Vector2.LEFT) + c.reset() + c.attack_toward(east) + r.check(_hp(es, first) == full - cfg.alien_ray_damage and _hp(es, second) == full - cfg.alien_ray_damage, + "two thieves in line are both hit (the beam pierces)") + r.check(_hp(es, crow) < es.t_hp[EnemySystem.TYPE_CROW], "a crow over the beam is hit too") + _clear(sim) + # A whole line: the nearest alien_ray_pierce only. + var line: Array[int] = [] + for k in cfg.alien_ray_pierce + 2: + line.append(es.spawn(THIEF, at.x + 3.0 + k * 1.5, at.y, Vector2.LEFT)) + c.reset() + c.attack_toward(east) + var hit := line.map(func(h: int) -> bool: return _hp(es, h) < full) + var nearest := true + for k in line.size(): + nearest = nearest and hit[k] == (k < cfg.alien_ray_pierce) + r.check(nearest, "a line of %d: the nearest %d are hit (%s)" % [line.size(), cfg.alien_ray_pierce, hit]) + _clear(sim) + # A wall cuts it short: what's in front is hit, what's behind isn't, and the beam drawn ends there. + var wall := StaticBody3D.new() + var shape := CollisionShape3D.new() + var box := BoxShape3D.new() + box.size = Vector3(0.2, 3.0, 4.0) + shape.shape = box + wall.add_child(shape) + farm.add_child(wall) + wall.global_position = Vector3(at.x + 6.0, 1.5, at.y) + await r.physics_frame # it joins the physics space on the next physics frame + var front := es.spawn(THIEF, at.x + 4.0, at.y, Vector2.LEFT) + var walled := es.spawn(THIEF, at.x + 8.0, at.y, Vector2.LEFT) + var walled_far := es.spawn(THIEF, at.x + 15.0, at.y, Vector2.LEFT) + c.reset() + c.attack_toward(east) + r.check(_hp(es, front) == full - cfg.alien_ray_damage and _hp(es, walled) == full and _hp(es, walled_far) == full, + "a wall stops it: the thief in front is hit, the ones behind the wall aren't") + path = c.beam_path() + model.rotation.y = atan2(-c.aim.x, -c.aim.y) + drawn = beam.rebuild(beam.global_transform) + var face := at.x + 6.0 - 0.1 + r.check(path.size() == 3 and absf(path[2].x - face) < 0.05, "the beam's path ends at the wall's face (x %.2f, wall at %.2f)" % [path[2].x, face]) + r.check(beam.blocked and _flat(beam.end).distance_to(_flat(path[2])) < 0.05 and absf(drawn - _flat(path[1]).distance_to(_flat(path[2]))) < 0.05 + and beam._flare.visible, "the beam drawn ends there too (%.2f m from the muzzle), with a flare" % drawn) + _clear(sim) + # A barrel poking through a wall (the scarecrow pressed against it) fires nothing past it. + wall.global_position = Vector3(at.x + 0.75, 1.5, at.y) + await r.physics_frame + var past := es.spawn(THIEF, at.x + 3.0, at.y, Vector2.LEFT) + c.reset() + c.attack_toward(east) + path = c.beam_path() + drawn = beam.rebuild(beam.global_transform) + r.check(_hp(es, past) == full and path.size() == 2 and drawn == 0.0 and not beam._core.visible, + "a barrel poking through a wall hits nothing past it (and no beam shows beyond)") + wall.queue_free() + await r.physics_frame + _clear(sim) + model.rotation.y = yaw + # Held: a tick every alien_ray_tick_interval, the beam lit throughout; let go, both stop. + var tough := es.spawn(THIEF, at.x + 10.0, at.y, Vector2.LEFT) + es.health[es.resolve_handle(tough)] = 99 + c.device = ScarecrowCombat.Device.GAMEPAD # keeps the aim it's given + c.aim = Vector2(1.0, 0.0) + c.reset() + _step(sim, 1) # fire not held: the reset's release is seen + r.check(not c.models.lit(W.ALIEN_RAY) and not beam.visible, "(the beam went out: fire isn't held)") + ticks = c.beam_ticks + shots = c.shots_fired + var zapped: Array[int] = [] + var on_zap := func(n: int) -> void: zapped.append(n) + c.zapped.connect(on_zap) + var intervals := 5 + var lit_throughout := true + Input.action_press("fire") + for i in c.alien_ray_ticks() * intervals: + _step(sim, 1) + lit_throughout = lit_throughout and c.models.lit(W.ALIEN_RAY) and beam.lit and beam.visible + var held_ticks := c.beam_ticks - ticks + var damage := 99 - _hp(es, tough) + Input.action_release("fire") + _step(sim, 1) + var out_at_once := not c.models.lit(W.ALIEN_RAY) and not beam.lit and not beam.visible + var after := c.beam_ticks + _step(sim, c.alien_ray_ticks() * 3) + r.check(held_ticks == intervals and damage == intervals * cfg.alien_ray_damage and zapped.size() == intervals and c.shots_fired == shots, + "holding fire zaps every %.2f s: %d ticks in %.2f s, %d damage" % [cfg.alien_ray_tick_interval, held_ticks, intervals * cfg.alien_ray_tick_interval, damage]) + r.check(c.beam_ticks == after and 99 - _hp(es, tough) == damage, "letting go stops it") + r.check(lit_throughout, "the beam stays lit the whole time fire is held, between ticks too") + r.check(out_at_once, "and goes out the moment fire is let go") + c.zapped.disconnect(on_zap) + # The beam follows the model's yaw. + model.rotation.y = 1.0 + c.models.attack(W.ALIEN_RAY) + beam.rebuild(beam.global_transform) + var dir := _flat(beam.end - beam.start).normalized() + r.check(dir.dot(Vector2(-sin(1.0), -cos(1.0))) > 0.999, "the beam points the way the model faces") + model.rotation.y = yaw + # The partner's own scarecrow on its machine (a replica: the host zaps for it) shows the beam + # while fire is held there. + c.replica = true + Input.action_press("fire") + _step(sim, c.alien_ray_ticks() * 2) + var replica_lit := c.models.lit(W.ALIEN_RAY) and beam.visible and c.beam_ticks == after + Input.action_release("fire") + _step(sim, 1) + c.replica = false + r.check(replica_lit and not c.models.lit(W.ALIEN_RAY), "a replica's beam is lit while fire is held there, and zaps nothing") + # The other scarecrow on the partner's machine: lit by its attack events (one per tick) and + # stepped by nothing there, so its beam times out on the physics frames (and lays itself out + # every frame meanwhile). + var events_lit := true + for k in 3: + c.show_weapon(W.ALIEN_RAY) + c.models.attack(W.ALIEN_RAY) + for i in c.alien_ray_ticks(): + await r.physics_frame + events_lit = events_lit and c.models.lit(W.ALIEN_RAY) and beam.visible + var hold := cfg.alien_ray_tick_interval * ScarecrowCombat.HOLD_TICKS + for i in ceili(hold * Engine.physics_ticks_per_second) + 6: + await r.physics_frame + r.check(events_lit and not c.models.lit(W.ALIEN_RAY) and not beam.visible, + "on the partner's machine, attack events keep the beam lit, and it goes out by itself once they stop") + c.models.attack(W.ALIEN_RAY) + c.equip(W.PITCHFORK) + r.check(not beam.visible and not c.models.lit(W.ALIEN_RAY), "switching weapons puts it out at once") + c.device = ScarecrowCombat.Device.MOUSE + _clear(sim) + + +func _flat(v: Vector3) -> Vector2: + return Vector2(v.x, v.z) + + ## Buys id at the supply shed, equips w, and checks that a shot fired at a thief some meters off ## damages it once it arrives (speed m/s: how long to wait). func _buy_equip_hit(r: GameTestRunner, farm: Node3D, sim: FarmSim, id: String, w: int, speed: float) -> void: diff --git a/game/tools/synth_audio.gd b/game/tools/synth_audio.gd index 4a60eca..3230185 100644 --- a/game/tools/synth_audio.gd +++ b/game/tools/synth_audio.gd @@ -10,6 +10,8 @@ extends SceneTree ## pumpkin_boom.wav a deep thump, a burst of noise, and a wet splat (a pumpkin bomb) ## torch_roar.wav a gas jet's flickering roar and hiss with a few crackles (a propane ## torch tick; back-to-back plays blend into one roar) +## alien_beam.wav a buzzing, warbling ray hum over a high whine and a fizz (an alien ray +## tick; back-to-back plays blend into one hum) ## Loops carry a WAV 'smpl' loop point, so the importer's "Detect From WAV" loops them; every ## periodic part of a loop has a whole number of cycles in it and filtered noise is warmed up ## on the loop's own tail, so the seam is silent. Run with the editor closed, then let the @@ -40,6 +42,8 @@ func _initialize() -> void: _write("pumpkin_boom.wav", _boom(0.9), false) _rng.seed = 17 # its own seed, so adding it changed none of the sounds above _write("torch_roar.wav", _roar(0.42), false) + _rng.seed = 19 # its own seed too + _write("alien_beam.wav", _beam(0.34), false) quit(0) @@ -274,6 +278,30 @@ func _roar(length: float) -> PackedFloat32Array: return _normalize(buf, 0.7) +## An alien ray: a buzzy low tone (odd harmonics) warbling fast, a high whine sliding down, and a +## fizz of bright noise. It swells in fast and fades slowly, so plays one ray tick apart (shorter +## than it) overlap into one steady hum while the ray is held. +func _beam(length: float) -> PackedFloat32Array: + var n := int(length * RATE) + var fizz := _noise_lowpass(n, 7000.0) + var fizz_low := _noise_lowpass(n, 2500.0) + var buf := PackedFloat32Array() + buf.resize(n) + var phase := 0.0 + var whine := 0.0 + for i in n: + var t := float(i) / RATE + var u := float(i) / n + var env := minf(u / 0.08, 1.0) * minf((1.0 - u) / 0.5, 1.0) + phase += 196.0 * (1.0 + 0.06 * sin(TAU * 31.0 * t)) / RATE + whine += lerpf(1900.0, 1500.0, u) * (1.0 + 0.01 * sin(TAU * 13.0 * t)) / RATE + var buzz := 0.0 + for h in [1, 3, 5, 7, 9]: + buzz += sin(TAU * phase * h) / h + buf[i] = env * (0.8 * buzz + 0.18 * sin(TAU * whine) + 0.3 * (fizz[i] - fizz_low[i])) + return _normalize(buf, 0.7) + + func _horn() -> PackedFloat32Array: var n := int(0.9 * RATE) var buf := PackedFloat32Array()