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

@ -13,10 +13,10 @@ const PIP_GAP := 5.0
const FEAR_RADIUS := 26.0
## Extra height of the panel for the sprint line.
const SPRINT_ROW := 30.0
## The weapon panel, from the bottom-right corner, its rows, and where its off-hand part starts.
const WEAPONS := Rect2(-340.0, -220.0, 304.0, 194.0)
## The weapon panel, from the bottom-right corner: its row height, and its width (its height grows
## with ScarecrowCombat.MAIN_WEAPONS / OFFHAND_WEAPONS, see _weapons_rect / _offhand_top).
const WEAPON_PANEL_WIDTH := 320.0
const WEAPON_ROW := 30.0
const OFFHAND_TOP := 122.0
var kit: Scarecrow
## This machine's scarecrow's weapons.
@ -137,19 +137,23 @@ func _update_weapons() -> void:
return
var at := _weapons_rect().position
_weapon_title.position = at + Vector2(12.0, 6.0)
# weapon_1.. only picks the first SWITCH_ACTIONS.size() - 1 (Task #7 added more main weapons
# than there are number keys): only those rows get a number, the rest just their name.
var keyed := ScarecrowCombat.SWITCH_ACTIONS.size() - 1
for k in _weapon_rows.size():
var w := ScarecrowCombat.MAIN_WEAPONS[k]
_weapon_row(_weapon_rows[k], "%d %s" % [k + 1, ScarecrowCombat.WEAPON_NAMES[w]], w, w == combat.weapon)
var text := "%d %s" % [k + 1, ScarecrowCombat.WEAPON_NAMES[w]] if k < keyed else ScarecrowCombat.WEAPON_NAMES[w]
_weapon_row(_weapon_rows[k], text, w, w == combat.weapon)
_weapon_rows[k].position = at + Vector2(30.0, 30.0 + k * WEAPON_ROW)
_weapon_hint.position = at + Vector2(12.0, 30.0 + _weapon_rows.size() * WEAPON_ROW + 2.0)
_offhand_title.position = at + Vector2(12.0, OFFHAND_TOP + 6.0)
_offhand_title.position = at + Vector2(12.0, _offhand_top() + 6.0)
for k in _offhand_rows.size():
var w := ScarecrowCombat.OFFHAND_WEAPONS[k]
var text := ScarecrowCombat.WEAPON_NAMES[w]
if w == ScarecrowCombat.Weapon.PUMPKIN_BOMB and combat.owns(w) and combat.bomb_left > 0.0:
text += " %.0f s" % ceilf(combat.bomb_left)
_weapon_row(_offhand_rows[k], text, w, _offhand_lit(w))
_offhand_rows[k].position = at + Vector2(30.0, OFFHAND_TOP + 30.0 + k * WEAPON_ROW)
_offhand_rows[k].position = at + Vector2(30.0, _offhand_top() + 30.0 + k * WEAPON_ROW)
## A weapon's row: greyed out until it's bought, gold when it's in hand (lit).
@ -170,8 +174,15 @@ func _offhand_lit(w: int) -> bool:
return w == combat.offhand and not (w == ScarecrowCombat.Weapon.PUMPKIN_BOMB and combat.bomb_left > 0.0)
## Top of the off-hand section, under the main weapon rows and the switch hint (grows with
## ScarecrowCombat.MAIN_WEAPONS.size()).
func _offhand_top() -> float:
return 30.0 + ScarecrowCombat.MAIN_WEAPONS.size() * WEAPON_ROW + 32.0
func _weapons_rect() -> Rect2:
return Rect2(size + WEAPONS.position, WEAPONS.size)
var height := _offhand_top() + 30.0 + ScarecrowCombat.OFFHAND_WEAPONS.size() * WEAPON_ROW + 12.0
return Rect2(size - Vector2(WEAPON_PANEL_WIDTH + 36.0, height + 26.0), Vector2(WEAPON_PANEL_WIDTH, height))
func _draw() -> void:
@ -203,7 +214,7 @@ func _draw() -> void:
_draw_lit_row(w, 32.0 + ScarecrowCombat.MAIN_WEAPONS.find(combat.weapon) * WEAPON_ROW)
var off := ScarecrowCombat.OFFHAND_WEAPONS.find(combat.offhand)
if off >= 0 and _offhand_lit(combat.offhand):
_draw_lit_row(w, OFFHAND_TOP + 32.0 + off * WEAPON_ROW)
_draw_lit_row(w, _offhand_top() + 32.0 + off * WEAPON_ROW)
if kit.patching:
var bar := Rect2(base + Vector2(FEAR_RADIUS * 2.0 + 14.0, 92.0), Vector2(210.0, 8.0))
draw_rect(bar, Color(0.1, 0.1, 0.1, 0.9))