#46: sprint becomes a permanent speed upgrade
Owning the Sprint upgrade now multiplies the scarecrow's speed by
sprint_speed_mult (1.25) all the time, walking and running, on every
platform; the run clip speeds up to match. The hold-to-sprint burst is
gone: sprint_time, sprint_cooldown, the stamina state in PlayerCharacter
(can_sprint is now has_sprint), and the HUD's stamina bar. The upgrade
keeps its id, cost, and name; its text is "Run 25% faster, always".
The sprint input action stays in project.godot, unused.
Tests: test_scarecrow's sprint checks cover 1x without it, x1.25 with it
(run and walk, clip speed, network strength), 30 s with no time limit,
no cooldown, the next morning, and no platform dependence; test_nights
checks it after the retry and a loaded save; test_economy checks the
text matches the multiplier, the menu row, and that an old save's
{"sprint": 1} still owns it.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
f0291133fd
commit
962c7b0b93
9 changed files with 138 additions and 149 deletions
|
|
@ -203,7 +203,7 @@ upgrades = {
|
||||||
},
|
},
|
||||||
"sprint": {
|
"sprint": {
|
||||||
"name": "Sprint",
|
"name": "Sprint",
|
||||||
"text": "Sprint 80% faster for 4 s at a time, every 10 s",
|
"text": "Run 25% faster, always",
|
||||||
"track": "Scarecrow"
|
"track": "Scarecrow"
|
||||||
},
|
},
|
||||||
"sticky_tar": {
|
"sticky_tar": {
|
||||||
|
|
|
||||||
|
|
@ -142,7 +142,7 @@ func _ready() -> void:
|
||||||
var t0 := Time.get_ticks_msec()
|
var t0 := Time.get_ticks_msec()
|
||||||
config = campaign.config
|
config = campaign.config
|
||||||
campaign.set_physics_process(false) # ticked from step(), after the simulation
|
campaign.set_physics_process(false) # ticked from step(), after the simulation
|
||||||
player.config = config # the sprint
|
player.config = config # Sprint's speed boost
|
||||||
player.campaign = campaign
|
player.campaign = campaign
|
||||||
var shed_zone := zones.zone(FarmZone.Kind.SUPPLY_SHED)
|
var shed_zone := zones.zone(FarmZone.Kind.SUPPLY_SHED)
|
||||||
var pen_zone := zones.zone(FarmZone.Kind.ANIMAL_PEN)
|
var pen_zone := zones.zone(FarmZone.Kind.ANIMAL_PEN)
|
||||||
|
|
|
||||||
|
|
@ -45,12 +45,11 @@ extends Resource
|
||||||
## Patch up: hold for patch_time (rooted, no shooting) to restore patch_heal HP.
|
## Patch up: hold for patch_time (rooted, no shooting) to restore patch_heal HP.
|
||||||
@export var patch_time: float = 2.0
|
@export var patch_time: float = 2.0
|
||||||
@export_range(1, 100) var patch_heal: int = 3
|
@export_range(1, 100) var patch_heal: int = 3
|
||||||
## Sprint (the workbench's Sprint upgrade): hold sprint while moving to run sprint_speed_mult
|
## Sprint (the workbench's Sprint upgrade): once it's bought, the scarecrow moves
|
||||||
## times as fast for up to sprint_time seconds; once it ends, sprint_cooldown seconds until the
|
## sprint_speed_mult times as fast for good, walking and running alike (PlayerCharacter). No
|
||||||
## next one.
|
## button, time limit, or cooldown. Its "text" in upgrades below names the boost: keep the two
|
||||||
@export var sprint_speed_mult: float = 1.8
|
## in step.
|
||||||
@export var sprint_time: float = 4.0
|
@export var sprint_speed_mult: float = 1.25
|
||||||
@export var sprint_cooldown: float = 10.0
|
|
||||||
|
|
||||||
@export_group("Farm assets")
|
@export_group("Farm assets")
|
||||||
## Crop units and animals on the farm when the vacation starts; they must match the farm scene
|
## Crop units and animals on the farm when the vacation starts; they must match the farm scene
|
||||||
|
|
@ -148,8 +147,8 @@ extends Resource
|
||||||
## "name", "track" (the menu's heading), "text": what it does.
|
## "name", "track" (the menu's heading), "text": what it does.
|
||||||
## "stat": the one stat it changes. Stats are GameConfig settings, plus scarecrow_max_hp (the
|
## "stat": the one stat it changes. Stats are GameConfig settings, plus scarecrow_max_hp (the
|
||||||
## scarecrow's, in FarmState) and barrier_hp (fences' and gates' health). One without a stat
|
## scarecrow's, in FarmState) and barrier_hp (fences' and gates' health). One without a stat
|
||||||
## unlocks something instead (sprint: PlayerCharacter; the weapons: ScarecrowCombat; radar:
|
## does something else instead (sprint: PlayerCharacter's speed, by sprint_speed_mult; the
|
||||||
## RadarHud).
|
## weapons: ScarecrowCombat; radar: RadarHud).
|
||||||
## "mult" multiplies the stat, "add" adds to it: a number (the same every level) or an Array
|
## "mult" multiplies the stat, "add" adds to it: a number (the same every level) or an Array
|
||||||
## with one entry per level. Each owned level's entry applies in turn, so they stack.
|
## with one entry per level. Each owned level's entry applies in turn, so they stack.
|
||||||
## "levels": how many times it can be bought (1 by default). Level L costs costs[id] x
|
## "levels": how many times it can be bought (1 by default). Level L costs costs[id] x
|
||||||
|
|
@ -180,7 +179,7 @@ extends Resource
|
||||||
"texts": ["+2 max health", "+2 more max health", "+2 more max health"]},
|
"texts": ["+2 max health", "+2 more max health", "+2 more max health"]},
|
||||||
"pouch_upgrade": {"name": "Bigger pouch", "track": "Scarecrow", "stat": "pouch_capacity", "add": [8, 4, 4], "levels": 3,
|
"pouch_upgrade": {"name": "Bigger pouch", "track": "Scarecrow", "stat": "pouch_capacity", "add": [8, 4, 4], "levels": 3,
|
||||||
"texts": ["+8 pouch capacity (16 total)", "+4 pouch capacity (20 total)", "+4 pouch capacity (24 total)"]},
|
"texts": ["+8 pouch capacity (16 total)", "+4 pouch capacity (20 total)", "+4 pouch capacity (24 total)"]},
|
||||||
"sprint": {"name": "Sprint", "text": "Sprint 80% faster for 4 s at a time, every 10 s", "track": "Scarecrow"},
|
"sprint": {"name": "Sprint", "text": "Run 25% faster, always", "track": "Scarecrow"},
|
||||||
"reinforced_fences": {"name": "Reinforced fences", "track": "Defenses", "stat": "barrier_hp", "mult": [1.5, 1.25, 1.25], "levels": 3,
|
"reinforced_fences": {"name": "Reinforced fences", "track": "Defenses", "stat": "barrier_hp", "mult": [1.5, 1.25, 1.25], "levels": 3,
|
||||||
"texts": ["Fences and gates +50% health", "Fences and gates another +25% health", "Fences and gates +25% health again"]},
|
"texts": ["Fences and gates +50% health", "Fences and gates another +25% health", "Fences and gates +25% health again"]},
|
||||||
"long_range": {"name": "Long-range defenses", "track": "Defenses", "stat": "turret_range", "mult": [1.3, 1.15, 1.15], "levels": 3,
|
"long_range": {"name": "Long-range defenses", "track": "Defenses", "stat": "turret_range", "mult": [1.3, 1.15, 1.15], "levels": 3,
|
||||||
|
|
|
||||||
|
|
@ -7,15 +7,16 @@ extends CharacterBody3D
|
||||||
## (start_channel: patching up, gathering) it is rooted and loops the channel's clip; once fallen
|
## (start_channel: patching up, gathering) it is rooted and loops the channel's clip; once fallen
|
||||||
## (die) it plays the death clip and takes no input until revived. set_flash() tints the model
|
## (die) it plays the death clip and takes no input until revived. set_flash() tints the model
|
||||||
## for hit feedback.
|
## for hit feedback.
|
||||||
## Sprint (the workbench's Sprint upgrade): holding sprint (Shift / L3) while moving runs at
|
## Sprint (the workbench's Sprint upgrade): once it's bought, the scarecrow moves
|
||||||
## GameConfig.sprint_speed_mult times run_speed, the run clip sped up to match, for up to
|
## GameConfig.sprint_speed_mult times as fast for good (speed_factor), walking and running alike,
|
||||||
## sprint_time seconds; once it ends (time's up, let go, or stopped) it takes sprint_cooldown
|
## on every platform, and the run clip plays that much faster to match. There's no button, time
|
||||||
## seconds to come back. FarmSim sets config and campaign; without them, or without the upgrade,
|
## limit, or cooldown. FarmSim sets config and campaign; without them, or without the upgrade, it
|
||||||
## there's no sprint.
|
## moves at run_speed.
|
||||||
## Co-op: the other machine's scarecrow is remote_driven: it eases toward the position and facing
|
## Co-op: the other machine's scarecrow is remote_driven: it eases toward the position and facing
|
||||||
## it was last sent (net_position, net_yaw) and animates by net_speed (like input strength: 1 at
|
## it was last sent (net_position, net_yaw) and animates by net_speed (like input strength: 1 at
|
||||||
## run speed, more while sprinting) instead of reading the input. Each scarecrow sprints on the
|
## run speed, more with the Sprint upgrade) instead of reading the input. Each scarecrow's speed
|
||||||
## machine that plays it. set_tint() and set_tag() tell the two scarecrows apart.
|
## is worked out on the machine that plays it. set_tint() and set_tag() tell the two scarecrows
|
||||||
|
## apart.
|
||||||
## The core glow: every scarecrow has a small blue core in its chest (the alien part it absorbed
|
## The core glow: every scarecrow has a small blue core in its chest (the alien part it absorbed
|
||||||
## in the opening intro): a glowing gem on the chest bone (so it follows the animation), a soft
|
## in the opening intro): a glowing gem on the chest bone (so it follows the animation), a soft
|
||||||
## halo, and a weak blue light, pulsing slowly. It's unshaded (the toon look and the hit flash
|
## halo, and a weak blue light, pulsing slowly. It's unshaded (the toon look and the hit flash
|
||||||
|
|
@ -90,13 +91,9 @@ var net_position := Vector3.ZERO
|
||||||
var net_yaw: float = 0.0
|
var net_yaw: float = 0.0
|
||||||
var net_speed: float = 0.0
|
var net_speed: float = 0.0
|
||||||
|
|
||||||
## Set by FarmSim: the sprint's tuning, and the farm state that says whether it's unlocked.
|
## Set by FarmSim: Sprint's speed boost, and the farm state that says whether it's bought.
|
||||||
var config: GameConfig
|
var config: GameConfig
|
||||||
var campaign: CampaignController
|
var campaign: CampaignController
|
||||||
## Sprinting now, seconds of it left, and seconds until the next one (0 = ready).
|
|
||||||
var sprinting := false
|
|
||||||
var sprint_left: float = 0.0
|
|
||||||
var sprint_recharge: float = 0.0
|
|
||||||
|
|
||||||
var _aim := Vector2.ZERO
|
var _aim := Vector2.ZERO
|
||||||
var _aim_hold: float = 0.0
|
var _aim_hold: float = 0.0
|
||||||
|
|
@ -130,7 +127,6 @@ func _physics_process(delta: float) -> void:
|
||||||
_follow_net(delta)
|
_follow_net(delta)
|
||||||
return
|
return
|
||||||
var move := _move_direction() if alive and not rooted else Vector3.ZERO
|
var move := _move_direction() if alive and not rooted else Vector3.ZERO
|
||||||
step_sprint(delta, can_sprint() and input_enabled and Input.is_action_pressed("sprint"), move.length_squared() > 1e-4)
|
|
||||||
var horizontal := Vector3(velocity.x, 0.0, velocity.z).move_toward(move * run_speed * speed_factor(), acceleration * delta)
|
var horizontal := Vector3(velocity.x, 0.0, velocity.z).move_toward(move * run_speed * speed_factor(), acceleration * delta)
|
||||||
velocity.x = horizontal.x
|
velocity.x = horizontal.x
|
||||||
velocity.z = horizontal.z
|
velocity.z = horizontal.z
|
||||||
|
|
@ -169,46 +165,20 @@ func snap_to_net(at: Vector3, yaw: float) -> void:
|
||||||
model.rotation.y = yaw
|
model.rotation.y = yaw
|
||||||
|
|
||||||
|
|
||||||
## Movement strength for the network: 0 standing .. 1 at run speed (more while sprinting).
|
## Movement strength for the network: 0 standing .. 1 at run speed (sprint_speed_mult at full
|
||||||
|
## speed with the Sprint upgrade).
|
||||||
func move_strength() -> float:
|
func move_strength() -> float:
|
||||||
return clampf(Vector2(velocity.x, velocity.z).length() / run_speed, 0.0, 2.0)
|
return clampf(Vector2(velocity.x, velocity.z).length() / run_speed, 0.0, 2.0)
|
||||||
|
|
||||||
|
|
||||||
## Whether the Sprint upgrade is owned.
|
## Whether the Sprint upgrade is owned.
|
||||||
func can_sprint() -> bool:
|
func has_sprint() -> bool:
|
||||||
return config != null and campaign != null and Upgrades.owned(campaign.state, "sprint")
|
return config != null and campaign != null and Upgrades.owned(campaign.state, "sprint")
|
||||||
|
|
||||||
|
|
||||||
## Speed relative to run_speed: sprint_speed_mult while sprinting.
|
## Speed relative to run_speed: sprint_speed_mult with the Sprint upgrade, else 1.
|
||||||
func speed_factor() -> float:
|
func speed_factor() -> float:
|
||||||
return config.sprint_speed_mult if sprinting else 1.0
|
return config.sprint_speed_mult if has_sprint() else 1.0
|
||||||
|
|
||||||
|
|
||||||
## One tick of the sprint: starts one while held and moving (when unlocked and recharged); ends
|
|
||||||
## it when its time is up, it's let go, or the scarecrow stops; then counts the recharge down.
|
|
||||||
func step_sprint(dt: float, held: bool, moving: bool) -> void:
|
|
||||||
if sprinting:
|
|
||||||
sprint_left -= dt
|
|
||||||
if sprint_left <= 0.0 or not held or not moving or not alive or not can_sprint():
|
|
||||||
_end_sprint()
|
|
||||||
return
|
|
||||||
sprint_recharge = maxf(sprint_recharge - dt, 0.0)
|
|
||||||
if held and moving and alive and sprint_recharge == 0.0 and can_sprint():
|
|
||||||
sprinting = true
|
|
||||||
sprint_left = config.sprint_time
|
|
||||||
|
|
||||||
|
|
||||||
## Ready to sprint again at once (a new morning).
|
|
||||||
func reset_sprint() -> void:
|
|
||||||
sprinting = false
|
|
||||||
sprint_left = 0.0
|
|
||||||
sprint_recharge = 0.0
|
|
||||||
|
|
||||||
|
|
||||||
func _end_sprint() -> void:
|
|
||||||
sprinting = false
|
|
||||||
sprint_left = 0.0
|
|
||||||
sprint_recharge = config.sprint_cooldown if config != null else 0.0
|
|
||||||
|
|
||||||
|
|
||||||
## Shows or hides the core glow in the chest (on from the start).
|
## Shows or hides the core glow in the chest (on from the start).
|
||||||
|
|
@ -342,7 +312,6 @@ func stop_channel() -> void:
|
||||||
func die() -> void:
|
func die() -> void:
|
||||||
alive = false
|
alive = false
|
||||||
rooted = false
|
rooted = false
|
||||||
reset_sprint()
|
|
||||||
animation_player.speed_scale = 1.0
|
animation_player.speed_scale = 1.0
|
||||||
animation_player.play(death_animation, 0.15)
|
animation_player.play(death_animation, 0.15)
|
||||||
|
|
||||||
|
|
@ -351,7 +320,6 @@ func revive() -> void:
|
||||||
alive = true
|
alive = true
|
||||||
rooted = false
|
rooted = false
|
||||||
_aim_hold = 0.0
|
_aim_hold = 0.0
|
||||||
reset_sprint()
|
|
||||||
animation_player.play(idle_animation, 0.1)
|
animation_player.play(idle_animation, 0.1)
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -382,7 +350,7 @@ func _update_animation(strength: float) -> void:
|
||||||
clip = run_animation
|
clip = run_animation
|
||||||
elif strength > 0.0:
|
elif strength > 0.0:
|
||||||
clip = walk_animation
|
clip = walk_animation
|
||||||
# A sprint (strength above 1) plays the run clip faster.
|
# The Sprint upgrade's speed (strength above 1) plays the run clip faster.
|
||||||
animation_player.speed_scale = maxf(strength, 1.0) if clip == run_animation else 1.0
|
animation_player.speed_scale = maxf(strength, 1.0) if clip == run_animation else 1.0
|
||||||
if animation_player.current_animation != clip:
|
if animation_player.current_animation != clip:
|
||||||
animation_player.play(clip, blend_time)
|
animation_player.play(clip, blend_time)
|
||||||
|
|
|
||||||
|
|
@ -5,8 +5,7 @@ extends Control
|
||||||
## arc sweeping round while fear recharges, glowing blue when it's ready (a flash as it
|
## arc sweeping round while fear recharges, glowing blue when it's ready (a flash as it
|
||||||
## becomes ready); greyed out while the scarecrow is down. Beside it the health bar, one
|
## becomes ready); greyed out while the scarecrow is down. Beside it the health bar, one
|
||||||
## segment per point of max health (red filled, grey empty; while patching, the segments the
|
## segment per point of max health (red filled, grey empty; while patching, the segments the
|
||||||
## patch will fill fill in), and under it, once the Sprint upgrade is bought, a thin green
|
## patch will fill fill in).
|
||||||
## bar: the sprint's stamina (draining while sprinting, filling back while it recharges).
|
|
||||||
## * Bottom-center: the hotbar, one slot per main weapon owned (locked ones aren't shown),
|
## * Bottom-center: the hotbar, one slot per main weapon owned (locked ones aren't shown),
|
||||||
## numbered by the key that picks it (ScarecrowCombat.owned_main: weapon_k picks slot k), the
|
## numbered by the key that picks it (ScarecrowCombat.owned_main: weapon_k picks slot k), the
|
||||||
## one in hand highlighted; then past a divider the off-hand weapons owned (pumpkin bombs), in a
|
## one in hand highlighted; then past a divider the off-hand weapons owned (pumpkin bombs), in a
|
||||||
|
|
@ -24,10 +23,8 @@ const SEGMENT_SKEW := 7.0
|
||||||
## The health bar grows a segment per point of max health up to this width, then its segments
|
## The health bar grows a segment per point of max health up to this width, then its segments
|
||||||
## get narrower.
|
## get narrower.
|
||||||
const BAR_MAX_WIDTH := 360.0
|
const BAR_MAX_WIDTH := 360.0
|
||||||
const STAMINA_HEIGHT := 6.0
|
|
||||||
const HEALTH := Color(0.88, 0.14, 0.12)
|
const HEALTH := Color(0.88, 0.14, 0.12)
|
||||||
const EMPTY := Color(0.62, 0.62, 0.6, 0.85)
|
const EMPTY := Color(0.62, 0.62, 0.6, 0.85)
|
||||||
const STAMINA := Color(0.3, 0.9, 0.25)
|
|
||||||
const SLOT := Vector2(78.0, 72.0)
|
const SLOT := Vector2(78.0, 72.0)
|
||||||
const SLOT_GAP := 16.0
|
const SLOT_GAP := 16.0
|
||||||
const DIVIDER_GAP := 30.0
|
const DIVIDER_GAP := 30.0
|
||||||
|
|
@ -88,24 +85,6 @@ func _process(delta: float) -> void:
|
||||||
queue_redraw()
|
queue_redraw()
|
||||||
|
|
||||||
|
|
||||||
## Whether the green stamina bar shows: only once the Sprint upgrade is bought.
|
|
||||||
func stamina_shown() -> bool:
|
|
||||||
var body := kit.player if kit != null else null
|
|
||||||
return body != null and body.config != null and body.can_sprint()
|
|
||||||
|
|
||||||
|
|
||||||
## The green bar's fill, 0..1: the sprint left while sprinting, its recharge after, else full.
|
|
||||||
func stamina() -> float:
|
|
||||||
if not stamina_shown():
|
|
||||||
return 1.0
|
|
||||||
var body := kit.player
|
|
||||||
if body.sprinting:
|
|
||||||
return clampf(body.sprint_left / maxf(body.config.sprint_time, 0.001), 0.0, 1.0)
|
|
||||||
if body.sprint_recharge > 0.0:
|
|
||||||
return clampf(1.0 - body.sprint_recharge / maxf(body.config.sprint_cooldown, 0.001), 0.0, 1.0)
|
|
||||||
return 1.0
|
|
||||||
|
|
||||||
|
|
||||||
## The hotbar's slots as shown, left to right: {weapon, key (the number that picks it; 0 for
|
## The hotbar's slots as shown, left to right: {weapon, key (the number that picks it; 0 for
|
||||||
## the off-hand), offhand, selected}. Empty while it's hidden (build mode, no weapons).
|
## the off-hand), offhand, selected}. Empty while it's hidden (build mode, no weapons).
|
||||||
func slots() -> Array[Dictionary]:
|
func slots() -> Array[Dictionary]:
|
||||||
|
|
@ -163,7 +142,6 @@ func _draw_health() -> void:
|
||||||
var hp := kit.hp()
|
var hp := kit.hp()
|
||||||
var step := minf(SEGMENT.x + SEGMENT_GAP, (BAR_MAX_WIDTH + SEGMENT_GAP) / top)
|
var step := minf(SEGMENT.x + SEGMENT_GAP, (BAR_MAX_WIDTH + SEGMENT_GAP) / top)
|
||||||
var seg := Vector2(maxf(step - SEGMENT_GAP, 4.0), SEGMENT.y)
|
var seg := Vector2(maxf(step - SEGMENT_GAP, 4.0), SEGMENT.y)
|
||||||
var width := step * top - SEGMENT_GAP
|
|
||||||
var healing := 0
|
var healing := 0
|
||||||
var heal_frac := 0.0
|
var heal_frac := 0.0
|
||||||
if kit.patching:
|
if kit.patching:
|
||||||
|
|
@ -179,16 +157,6 @@ func _draw_health() -> void:
|
||||||
if i < hp: # a darker stroke along the bottom, like paint pooling
|
if i < hp: # a darker stroke along the bottom, like paint pooling
|
||||||
Sketch.line(self, at + Vector2(3.0, seg.y - 4.0), at + Vector2(seg.x - 3.0, seg.y - 4.0), full.darkened(0.3), 3.0, 60.0 + i, 0.6)
|
Sketch.line(self, at + Vector2(3.0, seg.y - 4.0), at + Vector2(seg.x - 3.0, seg.y - 4.0), full.darkened(0.3), 3.0, 60.0 + i, 0.6)
|
||||||
Sketch.outline(self, pts, Color(Sketch.INK, 0.55), 1.5, 80.0 + i, 0.8, 1)
|
Sketch.outline(self, pts, Color(Sketch.INK, 0.55), 1.5, 80.0 + i, 0.8, 1)
|
||||||
if not stamina_shown():
|
|
||||||
return
|
|
||||||
# The stamina bar, as wide as the health bar.
|
|
||||||
var bar := Rect2(BAR_ORIGIN + Vector2(0.0, SEGMENT.y + 12.0), Vector2(maxf(width, 120.0), STAMINA_HEIGHT))
|
|
||||||
var y := bar.get_center().y
|
|
||||||
Sketch.line(self, Vector2(bar.position.x, y), Vector2(bar.end.x, y), Color(Sketch.INK, 0.6), STAMINA_HEIGHT + 3.0, 101.0, 0.6)
|
|
||||||
Sketch.line(self, Vector2(bar.position.x, y), Vector2(bar.end.x, y), Color(0.16, 0.3, 0.14, 0.9), STAMINA_HEIGHT, 101.0, 0.6)
|
|
||||||
var fill := stamina()
|
|
||||||
if fill > 0.0:
|
|
||||||
Sketch.line(self, Vector2(bar.position.x, y), Vector2(bar.position.x + bar.size.x * fill, y), STAMINA, STAMINA_HEIGHT, 102.0, 0.6)
|
|
||||||
|
|
||||||
|
|
||||||
## A health segment: a slanted brush stroke.
|
## A health segment: a slanted brush stroke.
|
||||||
|
|
|
||||||
|
|
@ -15,8 +15,9 @@ extends RefCounted
|
||||||
## the scarecrow's max health (FarmState) when a level is bought, and the Bigger pouch upgrade
|
## the scarecrow's max health (FarmState) when a level is bought, and the Bigger pouch upgrade
|
||||||
## raises pouch_capacity (ResourceStore, shared: every scarecrow's pouch grows) the same way. The
|
## raises pouch_capacity (ResourceStore, shared: every scarecrow's pouch grows) the same way. The
|
||||||
## buyer pays from their own pouch and the shed (slot). Sprint, the weapons, and radar change no
|
## buyer pays from their own pouch and the shed (slot). Sprint, the weapons, and radar change no
|
||||||
## stat: owning them (owned(): level 1 or more) unlocks sprinting (PlayerCharacter), the weapons
|
## stat here; owning one (owned(): level 1 or more) is what counts: Sprint makes the scarecrow
|
||||||
## (ScarecrowCombat), and the minimap (RadarHud). Rapid fire and heavy seeds (bought at the
|
## faster for good (PlayerCharacter.speed_factor, by GameConfig.sprint_speed_mult), the weapons
|
||||||
|
## unlock in ScarecrowCombat, and radar's minimap in RadarHud. Rapid fire and heavy seeds (bought at the
|
||||||
## workbench) need the corn shooter (bought at the shed) first ("requires" crosses shops freely).
|
## workbench) need the corn shooter (bought at the shed) first ("requires" crosses shops freely).
|
||||||
|
|
||||||
## Menu order, grouped by track.
|
## Menu order, grouped by track.
|
||||||
|
|
@ -31,8 +32,8 @@ static func level(state: FarmState, id: String) -> int:
|
||||||
return int(state.upgrades.get(id, 0)) if state != null else 0
|
return int(state.upgrades.get(id, 0)) if state != null else 0
|
||||||
|
|
||||||
|
|
||||||
## Owned at any level (level 1 or more): what "requires" and the unlocks (sprint, the weapons,
|
## Owned at any level (level 1 or more): what "requires" and the stat-less ones (sprint's speed,
|
||||||
## radar) ask.
|
## the weapons, radar) ask.
|
||||||
static func owned(state: FarmState, id: String) -> bool:
|
static func owned(state: FarmState, id: String) -> bool:
|
||||||
return level(state, id) > 0
|
return level(state, id) > 0
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -263,7 +263,8 @@ func _hidden_items(r: GameTestRunner) -> void:
|
||||||
## multipliers multiply). upgrades_bought counts every level. The menu names the next level
|
## multipliers multiply). upgrades_bought counts every level. The menu names the next level
|
||||||
## ("Heavy seeds II") with its text and cost, says when it opens, and shows "Max" at the end.
|
## ("Heavy seeds II") with its text and cost, says when it opens, and shows "Max" at the end.
|
||||||
## Levels survive a save, the next morning, and a retry, and an old save's {"rapid_fire": 1}
|
## Levels survive a save, the next morning, and a retry, and an old save's {"rapid_fire": 1}
|
||||||
## loads as level 1.
|
## loads as level 1. Sprint (#46) is a speed upgrade now: its text names sprint_speed_mult, the
|
||||||
|
## menu offers it as that, and an old save's {"sprint": 1} still owns it (the id is unchanged).
|
||||||
func _tiers(r: GameTestRunner) -> void:
|
func _tiers(r: GameTestRunner) -> void:
|
||||||
var c := r.make_campaign((load("res://game/resources/game_config.tres") as GameConfig).duplicate(true) as GameConfig)
|
var c := r.make_campaign((load("res://game/resources/game_config.tres") as GameConfig).duplicate(true) as GameConfig)
|
||||||
var cfg := c.config
|
var cfg := c.config
|
||||||
|
|
@ -275,6 +276,11 @@ func _tiers(r: GameTestRunner) -> void:
|
||||||
r.check(tiered == 9 and Upgrades.max_level(cfg, "sprint") == 1 and Upgrades.max_level(cfg, "corn_shooter") == 1
|
r.check(tiered == 9 and Upgrades.max_level(cfg, "sprint") == 1 and Upgrades.max_level(cfg, "corn_shooter") == 1
|
||||||
and Upgrades.max_level(cfg, "alien_ray") == 1 and Upgrades.max_level(cfg, "radar") == 1,
|
and Upgrades.max_level(cfg, "alien_ray") == 1 and Upgrades.max_level(cfg, "radar") == 1,
|
||||||
"the nine stat upgrades have 3 levels; Sprint, the weapons, and Radar one (%d with 3)" % tiered)
|
"the nine stat upgrades have 3 levels; Sprint, the weapons, and Radar one (%d with 3)" % tiered)
|
||||||
|
var defaults := GameConfig.new()
|
||||||
|
var says := "Run %d%% faster, always"
|
||||||
|
r.check(Upgrades.text_at(cfg, "sprint", 1) == says % roundi((cfg.sprint_speed_mult - 1.0) * 100.0)
|
||||||
|
and Upgrades.text_at(defaults, "sprint", 1) == says % roundi((defaults.sprint_speed_mult - 1.0) * 100.0),
|
||||||
|
"Sprint says what it does: '%s' (x%.2f; game_config.gd's defaults agree)" % [Upgrades.text_at(cfg, "sprint", 1), cfg.sprint_speed_mult])
|
||||||
# Costs grow.
|
# Costs grow.
|
||||||
var grows := true
|
var grows := true
|
||||||
for id: String in cfg.upgrades:
|
for id: String in cfg.upgrades:
|
||||||
|
|
@ -304,6 +310,9 @@ func _tiers(r: GameTestRunner) -> void:
|
||||||
var row := panel._rows["heavy_seeds"] as Button
|
var row := panel._rows["heavy_seeds"] as Button
|
||||||
r.check(row.text == "Heavy seeds I — Each kernel does 2 damage (%s)" % ResourceStore.describe(Upgrades.cost(cfg, "heavy_seeds", 1)) and not row.disabled,
|
r.check(row.text == "Heavy seeds I — Each kernel does 2 damage (%s)" % ResourceStore.describe(Upgrades.cost(cfg, "heavy_seeds", 1)) and not row.disabled,
|
||||||
"the menu offers level I: '%s'" % row.text)
|
"the menu offers level I: '%s'" % row.text)
|
||||||
|
var sprint_row := panel._rows["sprint"] as Button
|
||||||
|
r.check(sprint_row.text == "Sprint — %s (%s)" % [Upgrades.text_at(cfg, "sprint", 1), ResourceStore.describe(Upgrades.cost(cfg, "sprint", 1))]
|
||||||
|
and not sprint_row.disabled, "the menu offers Sprint as the speed upgrade: '%s'" % sprint_row.text)
|
||||||
var damage := cfg.shot_damage
|
var damage := cfg.shot_damage
|
||||||
r.check(Upgrades.buy(c, "heavy_seeds").contains("done:") and Upgrades.level(s, "heavy_seeds") == 1
|
r.check(Upgrades.buy(c, "heavy_seeds").contains("done:") and Upgrades.level(s, "heavy_seeds") == 1
|
||||||
and roundi(Upgrades.value(cfg, s, "shot_damage")) == damage + 1, "level 1 on day 1: kernels do %d damage" % (damage + 1))
|
and roundi(Upgrades.value(cfg, s, "shot_damage")) == damage + 1, "level 1 on day 1: kernels do %d damage" % (damage + 1))
|
||||||
|
|
@ -373,13 +382,15 @@ func _tiers(r: GameTestRunner) -> void:
|
||||||
"and a retry from that morning keeps them")
|
"and a retry from that morning keeps them")
|
||||||
# A save from before levels: {"rapid_fire": 1} is level 1.
|
# A save from before levels: {"rapid_fire": 1} is level 1.
|
||||||
var old := c.state.to_dict()
|
var old := c.state.to_dict()
|
||||||
old["upgrades"] = {"corn_shooter": 1, "rapid_fire": 1}
|
old["upgrades"] = {"corn_shooter": 1, "rapid_fire": 1, "sprint": 1}
|
||||||
var was := SaveGame.read(TIERS_SAVE).state if SaveGame.write(old, TIERS_SAVE) == OK else null
|
var was := SaveGame.read(TIERS_SAVE).state if SaveGame.write(old, TIERS_SAVE) == OK else null
|
||||||
SaveGame.delete(TIERS_SAVE)
|
SaveGame.delete(TIERS_SAVE)
|
||||||
r.check(was != null and Upgrades.level(was, "rapid_fire") == 1 and Upgrades.owned(was, "rapid_fire")
|
r.check(was != null and Upgrades.level(was, "rapid_fire") == 1 and Upgrades.owned(was, "rapid_fire")
|
||||||
and is_equal_approx(Upgrades.value(cfg, was, "fire_rate"), cfg.fire_rate * Upgrades.per_level(mult, 1))
|
and is_equal_approx(Upgrades.value(cfg, was, "fire_rate"), cfg.fire_rate * Upgrades.per_level(mult, 1))
|
||||||
and Upgrades.next_cost(cfg, was, "rapid_fire") == Upgrades.cost(cfg, "rapid_fire", 2),
|
and Upgrades.next_cost(cfg, was, "rapid_fire") == Upgrades.cost(cfg, "rapid_fire", 2),
|
||||||
"an old save's {\"rapid_fire\": 1} loads as level 1, with level 2 next")
|
"an old save's {\"rapid_fire\": 1} loads as level 1, with level 2 next")
|
||||||
|
r.check(was != null and Upgrades.owned(was, "sprint") and Upgrades.level(was, "sprint") == 1,
|
||||||
|
"and its {\"sprint\": 1} still owns Sprint, now the speed upgrade (same id)")
|
||||||
c.queue_free()
|
c.queue_free()
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -193,7 +193,7 @@ func _upgrades(r: GameTestRunner, sim: FarmSim, player: PlayerCharacter) -> void
|
||||||
var morning := s.to_dict()
|
var morning := s.to_dict()
|
||||||
var shed := s.resources.shed_total()
|
var shed := s.resources.shed_total()
|
||||||
var spent := 0
|
var spent := 0
|
||||||
r.check(not player.can_sprint(), "(no sprint before the Sprint upgrade)")
|
r.check(not player.has_sprint() and player.speed_factor() == 1.0, "(no Sprint before the upgrade: 1x speed)")
|
||||||
var day := s.night
|
var day := s.night
|
||||||
s.night = 14 # every shed item is in stock by day 14 (#26's from_day)
|
s.night = 14 # every shed item is in stock by day 14 (#26's from_day)
|
||||||
for id in Upgrades.ORDER:
|
for id in Upgrades.ORDER:
|
||||||
|
|
@ -202,7 +202,8 @@ func _upgrades(r: GameTestRunner, sim: FarmSim, player: PlayerCharacter) -> void
|
||||||
r.check(Upgrades.level(s, id) == 1 and text.contains("done:"), "bought %s: '%s'" % [id, text])
|
r.check(Upgrades.level(s, id) == 1 and text.contains("done:"), "bought %s: '%s'" % [id, text])
|
||||||
s.night = day
|
s.night = day
|
||||||
r.check(s.resources.shed_total() == shed - spent, "all %d cost %d materials together (level 1 each)" % [Upgrades.ORDER.size(), spent])
|
r.check(s.resources.shed_total() == shed - spent, "all %d cost %d materials together (level 1 each)" % [Upgrades.ORDER.size(), spent])
|
||||||
r.check(player.can_sprint(), "sprint: the scarecrow can sprint")
|
r.check(player.has_sprint() and is_equal_approx(player.speed_factor(), cfg.sprint_speed_mult),
|
||||||
|
"sprint: the scarecrow is faster for good (x%.2f)" % player.speed_factor())
|
||||||
r.check(Upgrades.buy(c, "sprint", st).contains("already done") and Upgrades.buy(c, "rapid_fire", st).contains("level 2 opens on day 8")
|
r.check(Upgrades.buy(c, "sprint", st).contains("already done") and Upgrades.buy(c, "rapid_fire", st).contains("level 2 opens on day 8")
|
||||||
and Upgrades.level(s, "rapid_fire") == 1, "a one-off can't be bought twice, and an upgrade's level 2 waits for day 8")
|
and Upgrades.level(s, "rapid_fire") == 1, "a one-off can't be bought twice, and an upgrade's level 2 waits for day 8")
|
||||||
r.check(sim.combat.interval_ticks() < int(before["interval"]) and sim.combat.shot_damage() == int(before["damage"]) + 1,
|
r.check(sim.combat.interval_ticks() < int(before["interval"]) and sim.combat.shot_damage() == int(before["damage"]) + 1,
|
||||||
|
|
@ -261,12 +262,20 @@ func _upgrades(r: GameTestRunner, sim: FarmSim, player: PlayerCharacter) -> void
|
||||||
_step(sim, 1)
|
_step(sim, 1)
|
||||||
c.retry_night()
|
c.retry_night()
|
||||||
r.check(s != c.state and c.state.upgrades == bought, "a retry from that morning keeps them")
|
r.check(s != c.state and c.state.upgrades == bought, "a retry from that morning keeps them")
|
||||||
|
r.check(is_equal_approx(player.speed_factor(), cfg.sprint_speed_mult), "Sprint's speed too, after the retry (x%.2f)" % player.speed_factor())
|
||||||
var old := FarmState.from_dict(morning)
|
var old := FarmState.from_dict(morning)
|
||||||
r.check(old.upgrades.is_empty() and old.resources.shed_total() == shed, "(the morning before they were bought had none, and the materials)")
|
r.check(old.upgrades.is_empty() and old.resources.shed_total() == shed, "(the morning before they were bought had none, and the materials)")
|
||||||
c.new_campaign()
|
c.new_campaign()
|
||||||
_step(sim, 1)
|
_step(sim, 1)
|
||||||
r.check(c.state.upgrades.is_empty() and sim.combat.shot_damage() == 1 and st.max_hp("fence") == cfg.fence_hp and not player.can_sprint(),
|
r.check(c.state.upgrades.is_empty() and sim.combat.shot_damage() == 1 and st.max_hp("fence") == cfg.fence_hp and not player.has_sprint()
|
||||||
|
and player.speed_factor() == 1.0,
|
||||||
"a new vacation starts without them")
|
"a new vacation starts without them")
|
||||||
|
c.load_state(back)
|
||||||
|
_step(sim, 1)
|
||||||
|
r.check(player.has_sprint() and is_equal_approx(player.speed_factor(), cfg.sprint_speed_mult),
|
||||||
|
"continuing the save brings Sprint's speed back (x%.2f)" % player.speed_factor())
|
||||||
|
c.new_campaign()
|
||||||
|
_step(sim, 1)
|
||||||
player.global_position = AWAY
|
player.global_position = AWAY
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -4,16 +4,18 @@ extends RefCounted
|
||||||
## not through cover, not while fleeing), fear (only thieves in range flee, carriers drop their
|
## not through cover, not while fleeing), fear (only thieves in range flee, carriers drop their
|
||||||
## crop, thieves mid-steal lose their progress, the cooldown, thieves come back afterwards),
|
## crop, thieves mid-steal lose their progress, the cooldown, thieves come back afterwards),
|
||||||
## patching up (heals after the full channel while rooted; release, a hit, or fear cancel it;
|
## patching up (heals after the full channel while rooted; release, a hit, or fear cancel it;
|
||||||
## not at full health), sprint (only with the Sprint upgrade: faster while held and moving, 3 s at
|
## not at full health), Sprint (#46: the upgrade makes it sprint_speed_mult times as fast for
|
||||||
## most, then a 10 s recharge; letting go or stopping ends it early; the HUD line), defeat (Game
|
## good, walking and running, with nothing to hold, no time limit, no cooldown, and no stamina
|
||||||
## Over ahead of a stripped farm, the fall, the end panel and its Retry), the morning revive, and
|
## bar), defeat (Game Over ahead of a stripped farm, the fall, the end panel and its Retry), the
|
||||||
## the new input actions.
|
## morning revive, and the new input actions.
|
||||||
|
|
||||||
const S := LootSystem.Status
|
const S := LootSystem.Status
|
||||||
const T := ThiefBehavior.State
|
const T := ThiefBehavior.State
|
||||||
const DT := 1.0 / 60.0
|
const DT := 1.0 / 60.0
|
||||||
const AWAY := Vector3(-11.0, 0.0, 13.0)
|
const AWAY := Vector3(-11.0, 0.0, 13.0)
|
||||||
const SPOT := Vector2(8.0, -10.0) # open ground between the pen, the shed, and the field
|
const SPOT := Vector2(8.0, -10.0) # open ground between the pen, the shed, and the field
|
||||||
|
## A light stick: it walks (under run_threshold even with the Sprint upgrade).
|
||||||
|
const WALK_STICK := 0.4
|
||||||
|
|
||||||
|
|
||||||
func run(r: GameTestRunner) -> void:
|
func run(r: GameTestRunner) -> void:
|
||||||
|
|
@ -40,7 +42,7 @@ func run(r: GameTestRunner) -> void:
|
||||||
|
|
||||||
|
|
||||||
func _input_actions(r: GameTestRunner) -> void:
|
func _input_actions(r: GameTestRunner) -> void:
|
||||||
for action in ["fear", "patch", "interact", "build_mode", "rotate_left", "rotate_right", "cancel", "pause", "sprint"]:
|
for action in ["fear", "patch", "interact", "build_mode", "rotate_left", "rotate_right", "cancel", "pause"]:
|
||||||
var keyboard := false
|
var keyboard := false
|
||||||
var pad := false
|
var pad := false
|
||||||
if InputMap.has_action(action):
|
if InputMap.has_action(action):
|
||||||
|
|
@ -184,59 +186,90 @@ func _patch(r: GameTestRunner, sim: FarmSim, player: PlayerCharacter) -> void:
|
||||||
_heal(sim)
|
_heal(sim)
|
||||||
|
|
||||||
|
|
||||||
|
## Sprint (#46): owning the upgrade makes the scarecrow sprint_speed_mult times as fast for good,
|
||||||
|
## walking and running alike, on desktop and phones. Nothing is held (the old sprint key does
|
||||||
|
## nothing), and there's no time limit, no cooldown, and no stamina bar.
|
||||||
func _sprint(r: GameTestRunner, sim: FarmSim, player: PlayerCharacter, hud: ScarecrowHud) -> void:
|
func _sprint(r: GameTestRunner, sim: FarmSim, player: PlayerCharacter, hud: ScarecrowHud) -> void:
|
||||||
var cfg := sim.config
|
var cfg := sim.config
|
||||||
|
var mult := cfg.sprint_speed_mult
|
||||||
var s := sim.campaign.state
|
var s := sim.campaign.state
|
||||||
|
var start := Vector3(0.0, 0.0, 6.0) # the open ground south-west of the pen
|
||||||
s.upgrades.erase("sprint")
|
s.upgrades.erase("sprint")
|
||||||
hud._process(0.0)
|
r.check(not player.has_sprint() and player.speed_factor() == 1.0 and not hud.has_method(&"stamina"),
|
||||||
r.check(not player.can_sprint() and not hud.stamina_shown(), "no sprint before the upgrade (and no stamina bar on the HUD)")
|
"no Sprint before the upgrade: 1x speed (and the HUD has no stamina bar)")
|
||||||
# On the real body, over physics frames: the open ground south-west of the pen.
|
# On the real body, over physics frames: a full stick runs, a light one walks.
|
||||||
player.global_position = Vector3(0.0, 0.0, 6.0)
|
var old_key := InputMap.has_action("sprint")
|
||||||
player.velocity = Vector3.ZERO
|
if old_key:
|
||||||
Input.action_press("move_right")
|
Input.action_press("sprint") # the old hold-to-sprint key
|
||||||
Input.action_press("sprint")
|
var run0: float = await _speed_after(r, player, start, 1.0)
|
||||||
await _frames(r, 30)
|
var walk0: float = await _speed_after(r, player, start, WALK_STICK)
|
||||||
var speed := Vector2(player.velocity.x, player.velocity.z).length()
|
if old_key:
|
||||||
r.check(not player.sprinting and speed <= player.run_speed + 0.05, "without it, holding sprint just runs (%.1f m/s)" % speed)
|
Input.action_release("sprint")
|
||||||
|
r.check(absf(run0 - player.run_speed) < 0.05, "without it, it runs at %.2f m/s, even holding the old sprint key" % run0)
|
||||||
s.upgrades["sprint"] = 1
|
s.upgrades["sprint"] = 1
|
||||||
await _frames(r, 30)
|
var run1: float = await _speed_after(r, player, start, 1.0)
|
||||||
speed = Vector2(player.velocity.x, player.velocity.z).length()
|
r.check(absf(run1 - player.run_speed * mult) < 0.05,
|
||||||
r.check(player.sprinting and absf(speed - player.run_speed * cfg.sprint_speed_mult) < 0.1,
|
"with the Sprint upgrade it runs x%.2f with nothing held: %.2f m/s (%.2f without)" % [mult, run1, run0])
|
||||||
"with the Sprint upgrade, holding sprint while moving sprints: %.1f m/s (runs at %.1f)" % [speed, player.run_speed])
|
r.check(player.animation_player.current_animation == player.run_animation and absf(player.animation_player.speed_scale - mult) < 0.02,
|
||||||
r.check(player.animation_player.current_animation == player.run_animation and player.animation_player.speed_scale > 1.5,
|
"the run clip plays x%.2f to match" % player.animation_player.speed_scale)
|
||||||
"the run clip plays faster (x%.2f)" % player.animation_player.speed_scale)
|
r.check(absf(player.move_strength() - mult) < 0.02, "the partner's machine is told it's faster (strength %.2f)" % player.move_strength())
|
||||||
r.check(player.move_strength() > 1.5, "the partner's machine is told it's sprinting (strength %.2f)" % player.move_strength())
|
var walk1: float = await _speed_after(r, player, start, WALK_STICK)
|
||||||
r.check(hud.stamina_shown() and hud.stamina() < 1.0 and is_equal_approx(hud.stamina(), player.sprint_left / cfg.sprint_time),
|
r.check(walk0 > 0.5 and absf(walk1 - walk0 * mult) < 0.05 and player.animation_player.current_animation == player.walk_animation,
|
||||||
"the HUD's stamina bar appears, and drains while sprinting (%.2f)" % hud.stamina())
|
"walking (a light stick) is x%.2f too: %.2f m/s (%.2f without), on the walk clip" % [walk1 / maxf(walk0, 0.001), walk1, walk0])
|
||||||
|
# No time limit: 30 s of moving without a stop, the body stepped tick by tick inside one physics
|
||||||
|
# frame and put back on the open ground each second.
|
||||||
|
Input.action_press("move_right")
|
||||||
|
await r.physics_frame
|
||||||
|
var span := _hand_step(player, start, 30.0)
|
||||||
|
var last := Vector2(player.velocity.x, player.velocity.z).length()
|
||||||
|
r.check(absf(span.x - run1) < 0.05 and absf(span.y - run1) < 0.05 and absf(last - run1) < 0.05,
|
||||||
|
"no time limit: after 30 s of moving it still runs %.2f m/s (%.2f..%.2f m/s throughout)" % [last, span.x, span.y])
|
||||||
|
# No cooldown: stop, then go again.
|
||||||
Input.action_release("move_right")
|
Input.action_release("move_right")
|
||||||
await _frames(r, 2)
|
var stopped := _hand_step(player, start, 1.0)
|
||||||
r.check(not player.sprinting and player.sprint_recharge > cfg.sprint_cooldown - 0.1, "stopping ends it, and the recharge starts")
|
Input.action_press("move_right")
|
||||||
r.check(hud.stamina() < 0.1, "and starts filling back as it recharges (%.2f)" % hud.stamina())
|
var again := _hand_step(player, start, 0.5)
|
||||||
Input.action_release("sprint")
|
r.check(stopped.y < 0.05 and absf(again.x - run1) < 0.05 and absf(again.y - run1) < 0.05,
|
||||||
|
"no cooldown: stopped, then off again at once at %.2f m/s" % again.y)
|
||||||
|
Input.action_release("move_right")
|
||||||
|
sim.scarecrow.reset_for_morning()
|
||||||
|
r.check(is_equal_approx(player.speed_factor(), mult), "a new morning keeps it (x%.2f)" % player.speed_factor())
|
||||||
|
# Phones: the speed path never asks the platform, so MobilePort.active() makes no difference.
|
||||||
|
var asks := false
|
||||||
|
for script: GDScript in [player.get_script(), load("res://game/scripts/upgrades.gd")]:
|
||||||
|
asks = asks or script.source_code.contains("MobilePort")
|
||||||
|
r.check(not asks, "the speed doesn't depend on the platform (PlayerCharacter and Upgrades never ask MobilePort; phone mode here: %s)" % MobilePort.active())
|
||||||
|
s.upgrades.erase("sprint")
|
||||||
await _frames(r, 30)
|
await _frames(r, 30)
|
||||||
player.velocity = Vector3.ZERO
|
player.velocity = Vector3.ZERO
|
||||||
player.global_position = Vector3(SPOT.x, 0.0, SPOT.y)
|
player.global_position = Vector3(SPOT.x, 0.0, SPOT.y)
|
||||||
# The timing, tick by tick.
|
|
||||||
player.reset_sprint()
|
|
||||||
var ticks := 0
|
## Puts the scarecrow at a spot at rest, holds move_right at a stick strength for 30 physics
|
||||||
player.step_sprint(DT, true, true)
|
## frames, and returns its speed (m/s). move_right stays held.
|
||||||
while player.sprinting and ticks < 1200:
|
func _speed_after(r: GameTestRunner, player: PlayerCharacter, at: Vector3, strength: float) -> float:
|
||||||
player.step_sprint(DT, true, true)
|
player.global_position = at
|
||||||
ticks += 1
|
player.velocity = Vector3.ZERO
|
||||||
r.check(absf(ticks * DT - cfg.sprint_time) < DT * 2.0, "held, a sprint lasts %.1f s" % (ticks * DT))
|
Input.action_press("move_right", strength)
|
||||||
ticks = 0
|
await _frames(r, 30)
|
||||||
while not player.sprinting and ticks < 1200:
|
return Vector2(player.velocity.x, player.velocity.z).length()
|
||||||
player.step_sprint(DT, true, true)
|
|
||||||
ticks += 1
|
|
||||||
r.check(absf(ticks * DT - cfg.sprint_cooldown) < DT * 2.0, "then %.1f s to recharge, and still held it starts again" % (ticks * DT))
|
## Steps the body by hand for that many seconds of 60 Hz ticks (call it right after awaiting
|
||||||
player.step_sprint(1.0, true, true)
|
## physics_frame, so move_and_slide moves by DT), putting it back at the spot every second so it
|
||||||
player.step_sprint(DT, false, true)
|
## stays on open ground. Returns the lowest and highest speed (m/s) over the ticks after the
|
||||||
r.check(not player.sprinting and is_equal_approx(player.sprint_recharge, cfg.sprint_cooldown), "letting go early ends it, and the full recharge starts")
|
## first quarter second (the speed-up).
|
||||||
player.step_sprint(DT, true, false)
|
func _hand_step(player: PlayerCharacter, at: Vector3, seconds: float) -> Vector2:
|
||||||
r.check(not player.sprinting, "and it doesn't start standing still")
|
var span := Vector2(INF, 0.0)
|
||||||
sim.scarecrow.reset_for_morning()
|
var ticks := roundi(seconds / DT)
|
||||||
r.check(player.sprint_recharge == 0.0 and hud.stamina() == 1.0, "a new morning has it ready (a full bar)")
|
for i in ticks:
|
||||||
s.upgrades.erase("sprint")
|
if i % 60 == 0:
|
||||||
|
player.global_position = at
|
||||||
|
player._physics_process(DT)
|
||||||
|
if i >= 15:
|
||||||
|
var v := Vector2(player.velocity.x, player.velocity.z).length()
|
||||||
|
span = Vector2(minf(span.x, v), maxf(span.y, v))
|
||||||
|
return span
|
||||||
|
|
||||||
|
|
||||||
func _frames(r: GameTestRunner, n: int) -> void:
|
func _frames(r: GameTestRunner, n: int) -> void:
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue