Eight tickets. The last one is the interesting one. #166 - PLAINER DIALOG. Every spoken line rewritten: the nine prologue lines and all twenty quest brief/done pairs. Mostly splitting em-dash subclauses into sentences and dropping the literary register ("hulls" -> "ships", "That is our hands back" -> "That frees us for other work"). Same meaning, same voice. #167 - NOTHING ANNOUNCED TWICE. Quests carry an `important` flag; seven of the twenty have it, and they are the search for the World Ship. A quest handed out with its goal ALREADY met is now credited in silence unless it is one of those - no brief, no answer, both signals still fired and the index still moved, so it appears ticked in the objectives panel. The chain used to stop the game to set a task the player had already done, then stop it again to congratulate them on it. #168 - THE KEYBOARD CAN ANSWER A DIALOG. The rule the ticket asks for (still arriving, show it all; already whole, move on) was already the rule for a click since #149, but a key press reached the banner and did nothing - and this game is played with WASD and a mouse. Touch, click and key now go through one door. Modifiers alone and auto-repeat echoes are not presses. #169 - A LOADING SCREEN. A press raises a cover, and the load happens after it has been on screen for a frame, so the wait is something the player is watching. Deliberately still a blocking load: load_threaded_request() comes back FAILED for these scenes, reporting text-parse errors that load() does not produce, because the global class names and preloads they reach each other through are not resolvable off the loading thread. A progress bar is not worth a menu that sometimes refuses to start the game, and the web build ships with thread support off anyway. Further presses while loading are ignored - on the web a button fires on PRESS, so an impatient double tap costs nothing to make and used to build the world twice. #170 - THE PICTURE BEFORE THE CAPTION. The prologue's first line was up before the scene had finished arriving, so the game opened STOPPED (#128) over a convoy nobody had seen yet. It flies for three seconds first. #171 - THE CONTROLS FOLLOW WHAT IS BEING HELD. is_touchscreen_available() asks whether a touch COULD arrive, and in a browser that is yes on any laptop whose panel reports touch support - so the web build put thumb sticks over a screen being played with a mouse, and switched mouse aiming off on the machine it exists for. The reading is now the last input actually used, it lives in GameState so the sticks and the guns cannot disagree, and it is two-way: nothing can strand a tablet, because the gesture that needs the controls is the gesture that brings them back. A touch suppresses mouse evidence for a second, so the click Godot manufactures out of a tap is not mistaken for a mouse. #172 - AIM AT A PLACE. Every gun was handed the same direction, so a fleet firing at something threw a sheet of parallel bolts past either side of it and only the middle hull could hit - worse the wider the formation. Guns now take a POINT and each hull works out its own heading to it, so the fleet's fire converges. The mouse already had a place and was flattening it into a bearing; a pushed stick names the point at the guns' reach along it, so touch loses nothing. The assist (#89) still bends a shot onto an enemy, now per hull and around that hull's own heading. The aim guide stops at the point and marks it. #173 - AND THE ONE THAT EXPLAINS ITSELF. "In the web export version the fleet can not store any resources" is not a web bug. It is the third time the Godot editor's .tres writer has quietly dropped a property it thought was default-valued: InterceptorVesselDefinition losing `capabilities` leaves cargo_capacity at 20 and takes away the "cargo" claim that fleet_cargo_capacity() actually gates on, so the hold is zero and nothing can be mined or carried. That is the symptom, word for word. test_definitions_intact caught it in the suite. What it could not do is catch it in a BUILD - an export is taken from the working tree at whatever moment the editor last touched it, which is exactly when the damage is done and exactly where nobody is running tests. The checks move to core/CatalogCheck.gd and now run at startup in every build as well as in the test, from the same function. On the web push_error lands in the on-page log web_shell.html mirrors, which is the only error a phone can read. The tree is intact today, so a fresh export should restore the hold. The point of the change is that the next time it is not, the build says so. Full suite green at 154/154. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0139MmxRAJSUe1j77kftAWv3
170 lines
7 KiB
GDScript
170 lines
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.
|
|
#
|
|
# #172: it is aimed at a POINT, not along a heading.
|
|
#
|
|
# Every gun in the fleet used to be handed the SAME direction, so a fleet
|
|
# firing at something threw a sheet of parallel bolts past either side of it
|
|
# and only the middle hull could ever hit. Handed a point instead, each hull
|
|
# works out its own heading to that point, and the fleet's fire converges
|
|
# where the player is actually pointing - which is what having several ships
|
|
# should be worth.
|
|
#
|
|
# The point is set every frame by FireStickController, from the mouse's own
|
|
# world position or from where the fire stick is pushed, and cleared the
|
|
# moment the trigger is let go. No point 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
|
|
# Where this gun is pointed, in WORLD space, and whether it is pointed at all.
|
|
# A point rather than a Vector2.ZERO sentinel: the origin is a perfectly
|
|
# ordinary place to aim at, and a fleet that happened to be near it would
|
|
# stop firing.
|
|
var fire_target: Vector2 = Vector2.ZERO
|
|
var has_fire_target: bool = false
|
|
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"))
|
|
|
|
|
|
# Forgejo #89: how far off the aimed heading a target may sit and still be
|
|
# picked up. 28 degrees is wide enough that pointing roughly at something hits
|
|
# it, and narrow enough that the shot still goes where the player pointed -
|
|
# past about 45 the gun starts choosing targets on its own, which is the
|
|
# behaviour #80 deliberately took away.
|
|
const ASSIST_CONE_DEGREES: float = 28.0
|
|
|
|
|
|
# The heading a shot fired from `origin` along `direction` should actually
|
|
# take: straight, unless an enemy sits inside the assist cone and within
|
|
# reach, in which case it points at the nearest one.
|
|
#
|
|
# Static, and used by BOTH the gun and the aim guide (see
|
|
# FireStickController._draw). If the guide drew the raw stick heading while
|
|
# the shot took an assisted one, the line would be telling the player
|
|
# something the gun does not do - the same class of mismatch #86 removed
|
|
# between the guide's length and a bolt's actual reach.
|
|
#
|
|
# Enemies only, never asteroids. Snapping onto a rock while the player is
|
|
# trying to hit the thing shooting at them would be the assist working
|
|
# against them; rocks are large, stationary enough, and easy to hit on
|
|
# purpose.
|
|
static func assisted_heading(tree: SceneTree, origin: Vector2, direction: Vector2,
|
|
reach: float) -> Vector2:
|
|
var heading: Vector2 = direction.normalized()
|
|
if heading == Vector2.ZERO or tree == null:
|
|
return heading
|
|
var cone: float = cos(deg_to_rad(ASSIST_CONE_DEGREES))
|
|
var nearest: Vector2 = Vector2.ZERO
|
|
var nearest_distance: float = INF
|
|
for enemy in tree.get_nodes_in_group("enemies"):
|
|
if not is_instance_valid(enemy) or not (enemy is Node2D):
|
|
continue
|
|
var to_enemy: Vector2 = (enemy as Node2D).global_position - origin
|
|
var distance: float = to_enemy.length()
|
|
if distance > reach or distance < 0.001 or distance >= nearest_distance:
|
|
continue
|
|
if to_enemy.normalized().dot(heading) < cone:
|
|
continue
|
|
nearest_distance = distance
|
|
nearest = to_enemy
|
|
return heading if nearest == Vector2.ZERO else nearest.normalized()
|
|
|
|
|
|
# Where this gun is firing FROM. The hull it is bolted to.
|
|
func muzzle() -> Vector2:
|
|
var ship: Node2D = get_parent() as Node2D
|
|
return ship.global_position if ship != null else Vector2.ZERO
|
|
|
|
|
|
# Called by FireStickController every frame the trigger is held.
|
|
func aim_at(point: Vector2) -> void:
|
|
fire_target = point
|
|
has_fire_target = true
|
|
|
|
|
|
func hold_fire() -> void:
|
|
has_fire_target = false
|
|
|
|
|
|
# For anything that knows a DISPLACEMENT rather than a place: an outpost
|
|
# garrison has already measured the vector to the enemy it picked (see
|
|
# VesselGarrisonComponent._shoot), and a lone stationed vessel has no fleet
|
|
# to converge with anyway. Zero still means stop.
|
|
func set_fire_direction(direction: Vector2) -> void:
|
|
if direction.length() <= 0.001:
|
|
hold_fire()
|
|
return
|
|
aim_at(muzzle() + direction)
|
|
|
|
|
|
func is_firing() -> bool:
|
|
return has_fire_target
|
|
|
|
|
|
# The heading a shot from THIS hull will actually take: from the muzzle to the
|
|
# aimed point, bent onto an enemy sitting inside the assist cone. Zero when the
|
|
# gun is not firing, or when the point is on top of the ship - there is no
|
|
# heading to a place you are already at.
|
|
func firing_heading() -> Vector2:
|
|
if not has_fire_target:
|
|
return Vector2.ZERO
|
|
var to_point: Vector2 = fire_target - muzzle()
|
|
if to_point.length() <= 0.001:
|
|
return Vector2.ZERO
|
|
return assisted_heading(get_tree(), muzzle(), to_point, fire_range)
|
|
|
|
|
|
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 not has_fire_target or fire_timer > 0.0:
|
|
return
|
|
# #172: worked out per HULL, from this ship to the aimed point, which is
|
|
# what makes the fleet's fire converge rather than run parallel.
|
|
var heading: Vector2 = firing_heading()
|
|
if heading == Vector2.ZERO:
|
|
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)
|
|
# The bolt is sent the gun's own range along that heading, whether the
|
|
# aimed point is nearer or further: range is a property of the gun, not of
|
|
# where the player pointed. A point beyond reach is fired toward and falls
|
|
# short; a point inside it is flown through.
|
|
projectile.launch(heading * 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, heading)
|
|
# #146: and heard. Beside the spark rather than inside it, because the
|
|
# spark is about this hull and the sound is about the shot.
|
|
Sfx.play(ship.get_tree(), Sfx.SHOT)
|
|
fire_timer = fire_cooldown
|