#85 - on a computer the sticks and the pivot pair are dead weight: WASD steers, the mouse aims, Q/E pivot. All four go together the first time a keyboard or a mouse is used, and only where there is no touchscreen. A touch device with a keyboard attached keeps everything, because a finger is still a way to play it. #86 - the default gun shoots faster (500 -> 850) and further (320 -> 620). The interesting half is that a bolt now STOPS where the gun's range ends. Projectile lifetime is derived from fire_range at launch rather than set independently, so the distance a shot covers and the distance the aim guide draws are one number. They were two, and they disagreed: the guide promised 320 while a bolt actually flew speed * lifetime = 750, so shots landed on things well past the line saying where they would stop. #87 - the ship that fires throws sparks, so a shot is visibly attached to the vessel it came from; with a whole fleet shooting there was nothing tying the two together, which started mattering once the player had to aim. Enemy deaths gained a shockwave ring and roughly double the debris - a kill used to read as a small red puff that was easy to miss in a fight. #88 - everything moves 1.5x faster: fleet cruise, every vessel's max_speed and acceleration, and every enemy's. Scaling the enemies too keeps it a change of TEMPO rather than a difficulty cut, and scaling acceleration alongside speed keeps the handling from #77's tuning intact. Three tests carried assertions that were really about one balance pass: test_enemy_mothership pinned a literal 35.0 and now compares against the chaser, which is what "never reaches ramming speed" actually means; test_planet_atmosphere_transition flew far enough at the new speed to reach the landed garrison, and now clears it, since that test is about the handoff and not about a fight it never meant to pick. Also repaired real data loss, caught only because test_gas_burner failed: Godot had silently re-serialised GasBurnerBuildingDefinition.tres and dropped collected_outputs, capabilities, map_radius and map_phase, and had recreated a stale copy of it at the pre-#84 root path. Without collected_outputs no transporter ever collects a burner's energy. Both files restored from git. It had also resurrected pre-#84 SNAPSHOTS of Main.tscn, Planet.tscn and lunar_surface.gdshader at their old root paths - the root Main.tscn still carried 27 references to the flat layout. They are dead weight the engine never loads, since project.godot and every preload point into the folders, but they are exactly the kind of thing that wastes an hour later when someone edits the wrong copy. Deleted, and the root is now down to ui_theme.tres, icon.svg, web_shell.html and the two config files. Suite 119/119. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
67 lines
2.7 KiB
GDScript
67 lines
2.7 KiB
GDScript
class_name VesselWeaponComponent
|
|
extends Node
|
|
|
|
# The fleet's gun. It does NOT pick its own targets: the player aims it with
|
|
# the fire stick, and it shoots along whatever heading that stick reports for
|
|
# as long as it is held.
|
|
#
|
|
# It used to seek the nearest enemy in range and fire on its own, which meant
|
|
# combat happened whether or not the player did anything - there was nothing
|
|
# to aim, and nothing to decide. Firing is now an action like any other, and
|
|
# the right-hand stick is what performs it.
|
|
#
|
|
# `fire_direction` is set every frame by FireStickController from the stick's
|
|
# own reading, and cleared the moment it is released. Zero means "not firing",
|
|
# which is the resting state.
|
|
|
|
var capability_id: String = "weapon"
|
|
var fire_range: float
|
|
var fire_cooldown: float
|
|
var projectile_damage: int
|
|
var fire_timer: float = 0.0
|
|
var fire_direction: Vector2 = Vector2.ZERO
|
|
var projectile_scene: PackedScene = preload("res://vessels/Projectile.tscn")
|
|
# By path, not by class name - see the note at the top of MuzzleSparkVFX.
|
|
const MUZZLE_SPARK = preload("res://vfx/MuzzleSparkVFX.gd")
|
|
|
|
|
|
func apply_stats() -> void:
|
|
var ship: Node = get_parent()
|
|
var state: Node = ship.get_tree().root.get_node("GameState")
|
|
fire_range = state.vessel_stat(ship.vessel_type, "fire_range")
|
|
fire_cooldown = state.vessel_stat(ship.vessel_type, "fire_cooldown")
|
|
projectile_damage = int(state.vessel_stat(ship.vessel_type, "damage"))
|
|
|
|
|
|
# Called by FireStickController. A zero vector stops the gun.
|
|
func set_fire_direction(direction: Vector2) -> void:
|
|
fire_direction = direction if direction.length() > 0.001 else Vector2.ZERO
|
|
|
|
|
|
func is_firing() -> bool:
|
|
return fire_direction != Vector2.ZERO
|
|
|
|
|
|
func tick(delta: float) -> void:
|
|
# The cooldown runs down whether or not the trigger is held, so tapping
|
|
# the stick in a new direction is not punished by a timer that only
|
|
# started when the stick moved.
|
|
fire_timer -= delta
|
|
if fire_direction == Vector2.ZERO or fire_timer > 0.0:
|
|
return
|
|
var ship: Node2D = get_parent()
|
|
var projectile: Node2D = projectile_scene.instantiate()
|
|
projectile.position = ship.position
|
|
projectile.damage = projectile_damage
|
|
# The bolt stops where the gun's range ends, and the aim guide draws that
|
|
# same range - one number, one meaning.
|
|
projectile.set_range(fire_range)
|
|
ship.get_tree().root.add_child(projectile)
|
|
# Aimed by DIRECTION, not at a target: launch() takes a displacement, so
|
|
# the gun's own range decides how far the shot is sent.
|
|
projectile.launch(fire_direction.normalized() * fire_range)
|
|
# #87: sparks off the hull that fired, so a shot is visibly attached to
|
|
# the vessel it came from.
|
|
MUZZLE_SPARK.spawn(ship.get_tree().root, ship.global_position,
|
|
fire_direction.normalized())
|
|
fire_timer = fire_cooldown
|