Task #7: four new shed weapons (Potato Cannon, Shurikens, Propane Torch, Alien Ray)

All four go in the main hand alongside the pitchfork and corn shooter, cooldown-based
with no ammo, every stat GameConfig-tunable: Potato Cannon is a slow heavy shot,
Shurikens a fast cheap throw, Propane Torch a sustained cone DoT while held (shares
the pitchfork's cone-hit test), and Alien Ray a fast powerful shot that stays hidden
in the shop until enough Alien Goop is collected. FarmProjectiles.fire() gained
optional speed/lifetime overrides (backward compatible) so each ranged weapon can fly
at its own pace. WeaponModels gained tinted placeholder pivots for the new weapons
(no new art), and the number-key switch loop and HUD panel layout were fixed to not
go out of bounds now that there are more main weapons than number keys.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
Forrest 2026-10-05 15:39:56 -04:00
parent b43af8a680
commit b9dcd24b5d
9 changed files with 399 additions and 62 deletions

View file

@ -30,6 +30,9 @@ var _pz := PackedFloat32Array()
var _dx := PackedFloat32Array()
var _dz := PackedFloat32Array()
var _life := PackedFloat32Array()
## Per-shot speed (m/s): cfg.projectile_speed unless fire() was given its own (Task #7's Potato
## Cannon, Shurikens, and Alien Ray fly at their own speeds).
var _speed := PackedFloat32Array()
var _damage := PackedInt32Array()
var _cfg: GameConfig
var _enemies: EnemySystem
@ -43,7 +46,7 @@ func setup(cfg: GameConfig, enemies: EnemySystem, bounds: Rect2, shooter: RID) -
_enemies = enemies
_bounds = bounds
capacity = cfg.projectile_capacity
for a: PackedFloat32Array in [_px, _pz, _dx, _dz, _life]:
for a: PackedFloat32Array in [_px, _pz, _dx, _dz, _life, _speed]:
a.resize(capacity)
a.fill(0.0)
_damage.resize(capacity)
@ -73,7 +76,10 @@ func clear() -> void:
## Fires from the weapon origin (scarecrow center at combat height) through the muzzle. The
## origin -> muzzle segment is tested first, so a barrel poking through a wall resolves there
## instead of spawning the shot on the far side. Returns false if the shot was skipped.
func fire(origin: Vector3, muzzle: Vector3, dir: Vector3, damage: int = 1) -> bool:
## speed/lifetime (<= 0: cfg.projectile_speed / cfg.projectile_lifetime) let a weapon's shot fly at
## its own pace (Task #7: the Potato Cannon's slow heavy shot, Shurikens, and the Alien Ray's fast
## one), with every other caller unchanged.
func fire(origin: Vector3, muzzle: Vector3, dir: Vector3, damage: int = 1, speed: float = -1.0, lifetime: float = -1.0) -> bool:
if active_count >= capacity:
exhausted += 1
return false
@ -87,16 +93,17 @@ func fire(origin: Vector3, muzzle: Vector3, dir: Vector3, damage: int = 1) -> bo
_pz[d] = muzzle.z
_dx[d] = dir.x
_dz[d] = dir.z
_life[d] = _cfg.projectile_lifetime
_life[d] = lifetime if lifetime > 0.0 else _cfg.projectile_lifetime
_damage[d] = damage
_speed[d] = speed if speed > 0.0 else _cfg.projectile_speed
_renderer.write_new(d, muzzle.x, muzzle.z, dir.x, dir.z, 0.0)
return true
func step(dt: float) -> void:
var step_len := _cfg.projectile_speed * dt
var i := 0
while i < active_count:
var step_len := _speed[i] * dt
var x0 := _px[i]
var z0 := _pz[i]
var x1 := x0 + _dx[i] * step_len
@ -179,5 +186,6 @@ func _release(i: int) -> void:
_dz[i] = _dz[last]
_life[i] = _life[last]
_damage[i] = _damage[last]
_speed[i] = _speed[last]
_renderer.move_slot(last, i)
active_count -= 1