Sharpen the gas bomb and the laser

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019AJMdB7iuHuLFZM1aBu3GD
This commit is contained in:
Loïc Wisniewski 2026-09-04 22:34:29 +02:00
commit 1cb8fc54e9
6 changed files with 76 additions and 5 deletions

View file

@ -11,6 +11,9 @@ extends "res://controllers/AimedFleetAbilityController.gd"
# while they aim it.
const BEAM_EFFECT = preload("res://vfx/LaserBeamEffect.gd")
# #201: the beam borrows the fire stick's aim helper, so it is loaded here
# for its static assist rather than for anything a laser hull carries.
const WEAPON_COMPONENT = preload("res://vessels/VesselWeaponComponent.gd")
const BEAM_COLOR := BEAM_EFFECT.BEAM_COLOR
const TARGET_COLOR := Color(0.6, 0.95, 1.0)
const BEAM_HALF_WIDTH := BEAM_EFFECT.BEAM_HALF_WIDTH
@ -51,7 +54,25 @@ func _aim_max_range() -> float:
func _calculate_aim_target(drag: Vector2, origin: Vector2) -> Vector2:
# A beam always reaches full range; dragging chooses its direction only.
var direction: Vector2 = drag.normalized() if drag.length() > 0.001 else Vector2.UP
return origin + direction * _aim_max_range()
return _assisted_target(origin, origin + direction * _aim_max_range())
# The mouse path (#80) names a world point directly instead of dragging one
# into existence. It has a real cursor, so it is assisted from that rather
# than from a virtual one at the end of the beam - otherwise the crosshair
# would be the only aim in the game the helper does not touch.
func fire_at(world_target: Vector2) -> bool:
return super(_assisted_target(_aim_origin(), world_target))
# #201: ordinary fire's aim helper, applied to the beam. It answers with a
# PLACE, not a heading - the same thing the fire stick resolves and every
# hull then converges on - so a drag that ends near an enemy, or merely
# inside the assist cone, passes through that enemy instead of a few degrees
# past it. The beam still runs on to its full range from there.
func _assisted_target(origin: Vector2, point: Vector2) -> Vector2:
return WEAPON_COMPONENT.assisted_point(get_tree(), origin, point,
_aim_max_range())
func _consume_shot(component: Node) -> bool:
@ -62,7 +83,12 @@ func _perform_shot(ship: Node2D, component: Node) -> void:
# The cooldown was already spent by _consume_shot() above, so this fires
# the effect directly rather than going through fire_ability() and
# spending it twice.
var direction: Vector2 = aim_target - _aim_origin()
# Aimed from the HULL, not from the fleet centre. aim_target is a place
# now that the assist can move it onto an enemy (#201), and ordinary fire
# converges on such a place by letting each hull find its own heading to
# it - a shared heading measured at the centroid would walk this beam off
# the very target the assist just picked, by the ship's formation offset.
var direction: Vector2 = aim_target - ship.global_position
direction = direction.normalized() if direction.length() > 0.001 else Vector2.UP
var effect: Node2D = BEAM_EFFECT.fire(get_tree().root, ship.global_position,
direction, component.beam_range, int(component.damage))