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

@ -11,6 +11,10 @@ extends Node3D
## hand over the recharge (set_bomb_charge)
## attack() plays the weapon's motion (the pumpkin just leaves the hand: the thrown one is
## PumpkinBombs').
## Task #7's Potato Cannon, Shurikens, Propane Torch, and Alien Ray have no models of their own
## 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 still kicks back like a gun on each attack.
const PATHS: Array[String] = ["res://assets/weapons/PitchFork.glb", "res://assets/weapons/CornShooter.glb",
"res://assets/weapons/PumpkinBomb.glb"]
@ -56,6 +60,13 @@ func setup(model: Node3D, muzzle: Vector3) -> void:
_add(1, Transform3D(Basis.from_euler(Vector3(0.0, PI, 0.0)), muzzle + Vector3(0.0, 0.0, tip)))
# Pumpkin: in the left hand, in front.
_add(2, Transform3D(Basis.IDENTITY, Vector3(-0.42, 1.2, -0.5)))
# Potato cannon, shurikens, propane torch, and the alien ray (Task #7): no models yet, so each
# is the corn shooter's mesh at the same gun spot, tinted so they're still tellable apart.
var gun_rest := Transform3D(Basis.from_euler(Vector3(0.0, PI, 0.0)), muzzle + Vector3(0.0, 0.0, tip))
_add_placeholder(3, gun_rest, Color(0.55, 0.38, 0.22)) # potato cannon: earthy brown
_add_placeholder(4, gun_rest, Color(0.75, 0.78, 0.82)) # shurikens: steel grey
_add_placeholder(5, gun_rest, Color(0.95, 0.45, 0.12)) # propane torch: flame orange
_add_placeholder(6, gun_rest, Color(0.35, 0.95, 0.4)) # alien ray: alien green
show_weapon(0)
show_offhand(-1)
@ -73,6 +84,24 @@ func _add(index: int, rest: Transform3D) -> void:
_rest.append(rest)
## A placeholder main weapon (Task #7, no model of its own): the corn shooter's mesh, tinted, at
## rest. index must follow the order _add was called in (ScarecrowCombat.Weapon).
func _add_placeholder(index: int, rest: Transform3D, tint: Color) -> void:
var pivot := Node3D.new()
pivot.name = ScarecrowCombat.WEAPON_IDS[index]
add_child(pivot)
var mi := MeshInstance3D.new()
mi.mesh = mesh_of(1) # the corn shooter's, reused (no new art for Task #7)
mi.scale = Vector3.ONE * SCALES[1]
var mat := StandardMaterial3D.new()
mat.albedo_color = tint
mi.material_override = mat
pivot.add_child(mi)
pivot.transform = rest
_pivots.append(pivot)
_rest.append(rest)
## Shows this main weapon (ScarecrowCombat.Weapon) in the right hand, and no other.
func show_weapon(index: int) -> void:
weapon = index