updates
This commit is contained in:
parent
4298caf5cb
commit
2e6638b744
19 changed files with 484 additions and 185 deletions
|
|
@ -96,8 +96,9 @@ pack (`assets/farm/ithappy/farm/prefabs/assets/`).
|
|||
- The scarecrow's weapons (`ScarecrowCombat`): mouse or right-stick aim, hold fire. It starts
|
||||
with the **pitchfork** (melee: a stab every 0.5 s at the nearest few enemies in reach and in
|
||||
front). The **corn shooter** (the prototype's gun, through `FarmProjectiles`) and **pumpkin
|
||||
bombs** (thrown, bursting over 3 m: `PumpkinBombs`) are workbench upgrades. Switch with Tab /
|
||||
d-pad down or 1-3 outside build mode. The models are the user's (`assets/weapons/`, posed on
|
||||
bombs** (thrown, bursting over 3 m: `PumpkinBombs`) are workbench upgrades. The pitchfork and
|
||||
corn shooter are main weapons (fire; switch with Tab / d-pad down or 1-2 outside build mode);
|
||||
the bombs sit in the off-hand, thrown with right mouse / LT. The models are the user's (`assets/weapons/`, posed on
|
||||
the scarecrow by `WeaponModels`); the HUD's weapon panel (bottom right) shows them. Shots, the
|
||||
corn shooter, and enemy hit proxies sit at 1.8 m, above the sunflowers and the pen fence.
|
||||
* **Campaign** — `CampaignController` (`game/scripts/campaign_controller.gd`) runs the five-night
|
||||
|
|
|
|||
|
|
@ -235,19 +235,24 @@ Implemented in Step 4. The numbers are in `GameConfig`.
|
|||
- its own 1.2 s cooldown is over. The cooldown starts on every attempt.
|
||||
- Fence breakers hit for 2 HP every 1.5 s, but only while fighting the scarecrow. Crows
|
||||
never fight.
|
||||
- **Weapons** (fire: left mouse / RT; hold to keep attacking). Every scarecrow starts with the
|
||||
- **Weapons**, in two slots; hold a button to keep attacking. Every scarecrow starts with the
|
||||
**pitchfork**; the **corn shooter** and **pumpkin bombs** are bought at the workbench (below).
|
||||
Switch with **Tab / d-pad down** (the next one owned) or **1 / 2 / 3**, outside build mode
|
||||
(there those keys pick structures). The weapon in hand shows on the scarecrow and in the HUD's
|
||||
weapon panel (bottom right), which also lists the ones still to buy. Numbers in `GameConfig`.
|
||||
- **Main weapon** (left mouse / RT): the pitchfork or the corn shooter, in the right hand.
|
||||
Switch with **Tab / d-pad down** (the next one owned) or **1 / 2**, outside build mode (there
|
||||
those keys pick structures).
|
||||
- **Off-hand** (right mouse / LT): pumpkin bombs, in the left hand, thrown without putting the
|
||||
main weapon away; both buttons work at once. Right mouse is still dismantle / leave build
|
||||
mode in build mode, and the click that leaves it throws nothing.
|
||||
- Both show on the scarecrow and in the HUD's weapon panel (bottom right), which also lists the
|
||||
ones still to buy. Numbers in `GameConfig`.
|
||||
| Weapon | What it does | Damage | How often |
|
||||
|---|---|---|---|
|
||||
| Pitchfork | A stab at the aim: the nearest 3 enemies within 2.2 m (plus their size) and 50° either side of the aim, with a clear line (not through walls); crows too | 2 (a thief in 2 stabs, a crow in 1, a fence breaker in 3) | Every 0.5 s |
|
||||
| Corn shooter | The gun: kernels flying at combat height, stopped by walls | 1 (2 with heavy seeds) | 6 a second (8 with rapid fire) |
|
||||
| Pumpkin bombs | Thrown at the cursor (or 7 m ahead with the stick), 2–10 m away, in an arc; bursts on landing, hurting every enemy within 3 m (crows too; walls don't stop it; never the scarecrows, animals, or structures). An orange ring shows where it will land and how far it reaches | 3 (a thief at once, half a fence breaker) | One every 4 s; the next grows back in the hand. Every morning one is ready |
|
||||
| Pumpkin bombs | Thrown at the cursor (or 7 m ahead with the stick), 2–10 m away, in an arc; bursts on landing, hurting every enemy within 3 m (crows too; walls don't stop it; never the scarecrows, animals, or structures). While one is ready, an orange ring shows where it would land and how far it reaches (brighter while the button is held) | 3 (a thief at once, half a fence breaker) | One every 4 s; the next grows back in the hand. Every morning one is ready |
|
||||
- Each weapon keeps its own wait, so switching doesn't skip one. A weapon no longer owned (a
|
||||
retry from a morning before it was bought) goes back to the pitchfork. One bought from the
|
||||
workbench menu goes straight into the hand.
|
||||
retry from a morning before it was bought) goes back to the pitchfork, or out of the
|
||||
off-hand. One bought from the workbench menu goes straight into its hand.
|
||||
- **Fear** (Q / left shoulder): every enemy within **6 m** flees straight away for **2 s**.
|
||||
- Carriers drop their loot (D5).
|
||||
- Enemies in the middle of a steal lose their progress and their claim.
|
||||
|
|
@ -514,7 +519,7 @@ in `game/COOP.md`):
|
|||
- **What's shared:** the shed, the pouch, upgrades, and structures. Either player can gather,
|
||||
build, repair, buy upgrades, and start the day.
|
||||
- **What's your own:** your scarecrow's health, and the weapon in your hands: a weapon bought
|
||||
is there for both, and each player picks their own. Upgrades to max health apply to both.
|
||||
is there for both, and each player picks their own main weapon. Upgrades to max health apply to both.
|
||||
- **Falling:** a scarecrow at 0 HP is out until the morning, when it comes back at half health.
|
||||
**Game Over only when both are down at once.**
|
||||
- **Enemies** go for the nearer scarecrow.
|
||||
|
|
|
|||
|
|
@ -27,6 +27,12 @@ signal failed(text: String)
|
|||
|
||||
const SEARCH_EVERY := 2.0
|
||||
const GAME_PORT := 42400
|
||||
## What a LAN host's computer has to let in (GD-Sync's LocalServer: announcements on
|
||||
## 42354..42373, games on 42400..42419).
|
||||
const LAN_PORTS := "UDP 42354-42373 and 42400-42419"
|
||||
## Seconds to wait for the host to answer a join. A firewall in the way drops the request
|
||||
## without a word, so this is the only way to tell.
|
||||
const JOIN_TIMEOUT := 10.0
|
||||
const GAME_TAG := "harvest-season"
|
||||
|
||||
var gdsync: Node
|
||||
|
|
@ -40,6 +46,7 @@ var status := ""
|
|||
var _after_connect := "" # "host" or "search"
|
||||
var _join_target := ""
|
||||
var _search_left: float = 0.0
|
||||
var _join_left: float = 0.0
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
|
|
@ -96,6 +103,7 @@ func join(lobby: String) -> void:
|
|||
return
|
||||
_join_target = lobby
|
||||
stage = Stage.JOINING
|
||||
_join_left = JOIN_TIMEOUT
|
||||
_say("Joining %s..." % lobby)
|
||||
gdsync.lobby_join(lobby)
|
||||
|
||||
|
|
@ -169,6 +177,21 @@ func _process(delta: float) -> void:
|
|||
if _search_left <= 0.0:
|
||||
_search_left = SEARCH_EVERY
|
||||
gdsync.get_public_lobbies()
|
||||
elif stage == Stage.JOINING:
|
||||
_join_left -= delta
|
||||
if _join_left <= 0.0:
|
||||
_join_timed_out()
|
||||
|
||||
|
||||
## No answer to a join: give up and say why it's most likely.
|
||||
func _join_timed_out() -> void:
|
||||
var target := _join_target
|
||||
var lan := mode == Mode.LAN
|
||||
leave()
|
||||
if lan:
|
||||
failed.emit("No answer from %s. The host's firewall is probably blocking the game (it needs %s open), or the address is wrong. Or both of you pick Online." % [target, LAN_PORTS])
|
||||
else:
|
||||
failed.emit("No answer from %s through GD-Sync. Check your connection and try again." % target)
|
||||
|
||||
|
||||
func _begin(p_mode: Mode, p_name: String) -> bool:
|
||||
|
|
|
|||
|
|
@ -251,7 +251,7 @@ func _ready() -> void:
|
|||
if upgrade_panel != null:
|
||||
upgrade_panel.setup(campaign, structures, player)
|
||||
interactions.upgrade_panel = upgrade_panel
|
||||
upgrade_panel.bought.connect(func(id: String) -> void: # a new weapon goes into the hand
|
||||
upgrade_panel.bought.connect(func(id: String) -> void: # a new weapon goes into its hand
|
||||
var w := ScarecrowCombat.WEAPON_IDS.find(id)
|
||||
if w > 0:
|
||||
combat.equip(w))
|
||||
|
|
|
|||
|
|
@ -202,6 +202,8 @@ func to_menu() -> void:
|
|||
if sim.coop.is_client():
|
||||
_leave_as_partner("")
|
||||
return
|
||||
if sim.local_frozen:
|
||||
sim.freeze_local(false) # the co-op pause menu's freeze (resume() never runs from here)
|
||||
sim.coop.stop()
|
||||
lobby.leave()
|
||||
var c := sim.campaign
|
||||
|
|
|
|||
|
|
@ -8,20 +8,28 @@ extends RefCounted
|
|||
## kit classes (Scarecrow, Interactions, ScarecrowCombat) read this instead of the local Input
|
||||
## when their remote is set.
|
||||
|
||||
const ACTIONS: Array[StringName] = [&"fire", &"fear", &"patch", &"interact"]
|
||||
const ACTIONS: Array[StringName] = [&"fire", &"fear", &"patch", &"interact", &"offhand"]
|
||||
|
||||
var aim := Vector2(0.0, -1.0)
|
||||
var aim_point := Vector3.ZERO
|
||||
var ground_point := Vector3.ZERO
|
||||
## ScarecrowCombat.Device of the partner's aim, and its ScarecrowCombat.Weapon (-1: none said).
|
||||
## ScarecrowCombat.Device of the partner's aim, and its main ScarecrowCombat.Weapon (-1: none
|
||||
## said).
|
||||
var device: int = 0
|
||||
var weapon: int = -1
|
||||
var build_active := false
|
||||
var ui_open := false
|
||||
|
||||
var _held := 0
|
||||
var _presses := PackedInt32Array([0, 0, 0, 0])
|
||||
var _seen := PackedInt32Array([0, 0, 0, 0])
|
||||
var _presses := RemoteControls.counts()
|
||||
var _seen := RemoteControls.counts()
|
||||
|
||||
|
||||
## A count per action, all 0.
|
||||
static func counts() -> PackedInt32Array:
|
||||
var c := PackedInt32Array()
|
||||
c.resize(ACTIONS.size())
|
||||
return c
|
||||
|
||||
|
||||
func held(action: StringName) -> bool:
|
||||
|
|
@ -63,8 +71,8 @@ func release() -> void:
|
|||
|
||||
## The local side: an input record for the actions held now and every press so far.
|
||||
class Sender:
|
||||
var presses := PackedInt32Array([0, 0, 0, 0])
|
||||
var _was := PackedInt32Array([0, 0, 0, 0])
|
||||
var presses := RemoteControls.counts()
|
||||
var _was := RemoteControls.counts()
|
||||
|
||||
## Counts presses from input events (taps between two frames still count).
|
||||
func note(event: InputEvent) -> void:
|
||||
|
|
|
|||
|
|
@ -114,7 +114,7 @@ func refresh() -> void:
|
|||
_title.text = "The farmers are away"
|
||||
lines.append("Keep the farm safe for %d nights until they come home: the crops, the animals in the pen, and the supplies in the shed." % nights)
|
||||
lines.append("By day, gather wood, scrap, and straw (hold E), store them at the barn, and build defenses (B). There's more to gather off the farm, to the north, east, and south.")
|
||||
lines.append("At night, stab thieves with your pitchfork (left mouse), scare them off (Q), and pick up anything they drop. A dropped animal runs off: walk up to it and lead it back to the pen. The workbench sells a corn shooter and pumpkin bombs (switch weapons with Tab or 1-3).")
|
||||
lines.append("At night, stab thieves with your pitchfork (left mouse), scare them off (Q), and pick up anything they drop. A dropped animal runs off: walk up to it and lead it back to the pen. The workbench sells a corn shooter (switch weapons with Tab or 1-2) and pumpkin bombs (throw them with right mouse).")
|
||||
else:
|
||||
var e: Dictionary = s.night_log[s.night_log.size() - 1]
|
||||
_title.text = "Morning of day %d of %d" % [s.night, nights]
|
||||
|
|
|
|||
|
|
@ -2,17 +2,24 @@ class_name ScarecrowCombat
|
|||
extends Node3D
|
||||
## The scarecrow's weapons, ported from the prototype's PlayerInput + WeaponController (Step 4
|
||||
## finished the kit; the weapons came after Step 11):
|
||||
## * Three weapons (Weapon): the pitchfork, every scarecrow's from the start; the corn shooter
|
||||
## and pumpkin bombs, bought at the workbench (Upgrades "corn_shooter", "pumpkin_bomb").
|
||||
## weapon_next (Tab / d-pad down) cycles through the ones owned, weapon_1..3 (1-3) pick one,
|
||||
## both only outside build mode (where those keys pick structures) and with no menu open.
|
||||
## One no longer owned (a retry from before it was bought) goes back to the pitchfork.
|
||||
## * Three weapons (Weapon) in two slots: the main weapon in the right hand, the pitchfork
|
||||
## (every scarecrow's from the start) or the corn shooter, and pumpkin bombs in the off-hand
|
||||
## (the left); the corn shooter and the bombs are bought at the workbench (Upgrades
|
||||
## "corn_shooter", "pumpkin_bomb"). weapon_next (Tab / d-pad down) cycles through the main
|
||||
## weapons owned, weapon_1..2 (1-2) pick one, both only outside build mode (where those keys
|
||||
## pick structures) and with no menu open. The off-hand holds the off-hand weapon owned
|
||||
## (OFFHAND_WEAPONS; there's no pick while there's only one). A main weapon no longer owned (a
|
||||
## retry from before it was bought) goes back to the pitchfork, an off-hand one out of the hand.
|
||||
## * Aim with the mouse (the cursor projected onto the combat-height plane through the follow
|
||||
## camera, corrected for the gun's side offset so shots pass through the cursor; bombs land
|
||||
## on the ground point under the cursor) or the right stick (camera-relative, radial dead
|
||||
## zone, last aim kept). The active device switches only on deliberate input: mouse travel
|
||||
## past a threshold or a click, stick deflection past the dead zone or the trigger.
|
||||
## * Attack with the fire action, needing a fresh press after every reset; holding it repeats:
|
||||
## * Attack with the main weapon with fire (LMB / RT), and use the off-hand with offhand
|
||||
## (RMB / LT), each on its own, both at once too. Each needs a fresh press after every reset
|
||||
## (FarmSim resets on entering and leaving build mode, where the right mouse button is cancel),
|
||||
## and offhand also after any tick the scarecrow couldn't attack (a menu open, patching; in
|
||||
## co-op the partner's build mode, which its own machine toggles). Holding either repeats:
|
||||
## pitchfork a stab every pitchfork_interval: the nearest pitchfork_targets enemies
|
||||
## within pitchfork_reach and pitchfork_arc of the aim, with a clear line,
|
||||
## take pitchfork_damage
|
||||
|
|
@ -21,12 +28,13 @@ extends Node3D
|
|||
## pumpkin bomb one every bomb_cooldown, thrown at the aim point (bomb_min_range ..
|
||||
## bomb_range away; GAMEPAD_THROW ahead with the stick), bursting where it
|
||||
## lands (PumpkinBombs)
|
||||
## * The weapon in hand on the scarecrow's model (WeaponModels), and an aim marker (with bombs:
|
||||
## on the ground where one would land, ringed by its blast).
|
||||
## * Both weapons on the scarecrow's model (WeaponModels), an aim marker, and while a pumpkin
|
||||
## bomb is ready a ring on the ground where one would land, as wide as its blast.
|
||||
## While attacking, the model faces the aim.
|
||||
## Co-op: the partner's weapons on the host read its RemoteControls (aim, fire, and its pick of
|
||||
## weapon come from the partner's game); on the partner's machine its own only aims and shows the
|
||||
## attack motions (replica: the host attacks), and only the local player's aim marker shows.
|
||||
## Co-op: the partner's weapons on the host read its RemoteControls (aim, fire and offhand, and
|
||||
## its pick of main weapon come from the partner's game); on the partner's machine its own only
|
||||
## aims and shows the attack motions (replica: the host attacks), and only the local player's aim
|
||||
## marker shows.
|
||||
|
||||
enum Device { MOUSE, GAMEPAD }
|
||||
enum Weapon { PITCHFORK, CORN_SHOOTER, PUMPKIN_BOMB }
|
||||
|
|
@ -38,7 +46,8 @@ signal stabbed(hits: int)
|
|||
signal struck(at: Vector3, enemy_type: int)
|
||||
## A pumpkin bomb thrown (where it will land).
|
||||
signal threw(at: Vector3)
|
||||
## Any attack (co-op: the partner's machine shows its motion), and a change of weapon.
|
||||
## Any attack, with either hand (co-op: the partner's machine shows its motion), and a change of
|
||||
## main weapon.
|
||||
signal attacked(weapon: Weapon)
|
||||
signal switched(weapon: Weapon)
|
||||
|
||||
|
|
@ -47,14 +56,23 @@ const SIDE_OFFSET := 0.35
|
|||
## Upgrade ids that unlock the weapons (the pitchfork needs none), and what they're called.
|
||||
const WEAPON_IDS: Array[String] = ["pitchfork", "corn_shooter", "pumpkin_bomb"]
|
||||
const WEAPON_NAMES: Array[String] = ["Pitchfork", "Corn shooter", "Pumpkin bombs"]
|
||||
const SWITCH_ACTIONS: Array[StringName] = [&"weapon_next", &"weapon_1", &"weapon_2", &"weapon_3"]
|
||||
## The main weapons (Weapon), in the order weapon_next cycles and weapon_1.. pick them, and the
|
||||
## off-hand ones.
|
||||
const MAIN_WEAPONS: Array[int] = [Weapon.PITCHFORK, Weapon.CORN_SHOOTER]
|
||||
const OFFHAND_WEAPONS: Array[int] = [Weapon.PUMPKIN_BOMB]
|
||||
const SWITCH_ACTIONS: Array[StringName] = [&"weapon_next", &"weapon_1", &"weapon_2"]
|
||||
## How far ahead a bomb lands when aiming with the stick, and how high it leaves the hand.
|
||||
const GAMEPAD_THROW := 7.0
|
||||
const THROW_HEIGHT := 1.6
|
||||
## Opacity of the bomb's landing ring, and while offhand is held.
|
||||
const BLAST_ALPHA := 0.45
|
||||
const BLAST_HELD_ALPHA := 0.9
|
||||
const WORLD_LAYER := 1
|
||||
|
||||
var device: Device = Device.MOUSE
|
||||
## The main weapon, and the off-hand one (-1: none owned).
|
||||
var weapon: Weapon = Weapon.PITCHFORK
|
||||
var offhand: int = -1
|
||||
## Last valid horizontal aim direction (unit, XZ).
|
||||
var aim := Vector2(0.0, -1.0)
|
||||
## World point the mouse aims at (combat-height plane), and the ground point under the cursor;
|
||||
|
|
@ -86,6 +104,10 @@ var _blast: MeshInstance3D
|
|||
## through switches so swapping weapons can't skip a wait.
|
||||
var _cooldown := PackedInt32Array([0, 0, 0])
|
||||
var _needs_release := true
|
||||
var _offhand_needs_release := true
|
||||
## Ticks so far (tick), and the last one the scarecrow could attack in (step).
|
||||
var _ticks: int = 0
|
||||
var _stepped: int = 0
|
||||
var _mouse_travel: float = 0.0
|
||||
var _edges := ActionEdges.new()
|
||||
var _ray := PhysicsRayQueryParameters3D.new()
|
||||
|
|
@ -104,10 +126,12 @@ func setup(cfg: GameConfig, player: PlayerCharacter, camera: Camera3D, shots: Fa
|
|||
_build_marker()
|
||||
|
||||
|
||||
## Requires a fresh fire press, so a held button can't fire into a new morning or a retry.
|
||||
## Requires fresh fire and offhand presses, so a held button can't attack into a new morning or a
|
||||
## retry.
|
||||
func reset() -> void:
|
||||
_cooldown.fill(0)
|
||||
_needs_release = true
|
||||
_offhand_needs_release = true
|
||||
|
||||
|
||||
## A new morning (also after a retry): a pumpkin bomb back in hand.
|
||||
|
|
@ -116,6 +140,11 @@ func ready_for_morning() -> void:
|
|||
bomb_left = 0.0
|
||||
|
||||
|
||||
## Whether the weapon goes in the off-hand rather than the hand.
|
||||
static func is_offhand(w: int) -> bool:
|
||||
return OFFHAND_WEAPONS.has(w)
|
||||
|
||||
|
||||
## Whether this scarecrow has the weapon: the pitchfork always, the others once bought.
|
||||
func owns(w: int) -> bool:
|
||||
if w == Weapon.PITCHFORK:
|
||||
|
|
@ -123,27 +152,33 @@ func owns(w: int) -> bool:
|
|||
return w > 0 and w < WEAPON_IDS.size() and campaign != null and Upgrades.owned(campaign.state, WEAPON_IDS[w])
|
||||
|
||||
|
||||
## Takes the weapon in hand if it's owned. Returns whether it's in hand now.
|
||||
## Takes the weapon up if it's owned: a main weapon into the hand, an off-hand one into the
|
||||
## off-hand. Returns whether it's there now.
|
||||
func equip(w: int) -> bool:
|
||||
if not owns(w):
|
||||
return false
|
||||
if w != weapon:
|
||||
if is_offhand(w):
|
||||
_set_offhand(w)
|
||||
elif w != weapon:
|
||||
show_weapon(w)
|
||||
switched.emit(weapon)
|
||||
return true
|
||||
|
||||
|
||||
## The next weapon owned after the one in hand.
|
||||
## The next main weapon owned after the one in hand.
|
||||
func cycle() -> void:
|
||||
for k in range(1, WEAPON_IDS.size()):
|
||||
if equip((weapon + k) % WEAPON_IDS.size()):
|
||||
var at := MAIN_WEAPONS.find(weapon)
|
||||
for k in range(1, MAIN_WEAPONS.size()):
|
||||
if equip(MAIN_WEAPONS[(at + k) % MAIN_WEAPONS.size()]):
|
||||
return
|
||||
|
||||
|
||||
## Shows the weapon in hand without the ownership check (co-op: the other scarecrow's, as its
|
||||
## machine says).
|
||||
## Shows the main weapon in hand without the ownership check (co-op: the other scarecrow's, as
|
||||
## its machine says). An off-hand weapon doesn't go into the hand.
|
||||
func show_weapon(w: int) -> void:
|
||||
var next := clampi(w, 0, WEAPON_IDS.size() - 1) as Weapon
|
||||
if not MAIN_WEAPONS.has(w):
|
||||
return
|
||||
var next := w as Weapon
|
||||
if next == weapon and models.weapon == next:
|
||||
return # (a snapshot saying so again mustn't cut an attack's motion short)
|
||||
weapon = next
|
||||
|
|
@ -165,18 +200,24 @@ func _input(event: InputEvent) -> void:
|
|||
_to_gamepad()
|
||||
elif event is InputEventJoypadMotion:
|
||||
var jm := event as InputEventJoypadMotion
|
||||
if jm.axis == JOY_AXIS_TRIGGER_RIGHT and jm.axis_value > 0.5:
|
||||
if (jm.axis == JOY_AXIS_TRIGGER_RIGHT or jm.axis == JOY_AXIS_TRIGGER_LEFT) and jm.axis_value > 0.5:
|
||||
_to_gamepad()
|
||||
|
||||
|
||||
## Every tick, attacking or not (building, patching): the bomb's recharge, and the pick of
|
||||
## weapon (the switch actions count only when can_switch: outside build mode, no menu open; the
|
||||
## partner's pick comes from its game).
|
||||
## Every tick, attacking or not (building, patching): the bomb's recharge, the off-hand weapon,
|
||||
## and the pick of main weapon (the switch actions count only when can_switch: outside build
|
||||
## mode, no menu open; the partner's pick comes from its game).
|
||||
func tick(dt: float, can_switch: bool) -> void:
|
||||
_ticks += 1
|
||||
bomb_left = maxf(bomb_left - dt, 0.0)
|
||||
models.set_bomb_charge(1.0 - bomb_left / _cfg.bomb_cooldown if _cfg.bomb_cooldown > 0.0 else 1.0)
|
||||
if not owns(weapon):
|
||||
equip(Weapon.PITCHFORK)
|
||||
if not owns(offhand):
|
||||
_set_offhand(-1)
|
||||
for w in OFFHAND_WEAPONS:
|
||||
if equip(w):
|
||||
break
|
||||
if remote != null:
|
||||
if remote.weapon >= 0:
|
||||
equip(remote.weapon)
|
||||
|
|
@ -188,64 +229,63 @@ func tick(dt: float, can_switch: bool) -> void:
|
|||
return
|
||||
if p[&"weapon_next"]:
|
||||
cycle()
|
||||
for k in WEAPON_IDS.size():
|
||||
for k in MAIN_WEAPONS.size():
|
||||
if p[SWITCH_ACTIONS[k + 1]]:
|
||||
equip(k)
|
||||
equip(MAIN_WEAPONS[k])
|
||||
|
||||
|
||||
## One physics tick while the scarecrow can attack: update the aim, then attack with the weapon
|
||||
## in hand if fire is held and it's ready.
|
||||
## One physics tick while the scarecrow can attack: update the aim, then attack with the main
|
||||
## weapon if fire is held, and use the off-hand one if offhand is held, each if it's ready.
|
||||
func step(_dt: float) -> void:
|
||||
_update_aim()
|
||||
var held := remote.held(&"fire") if remote != null else Input.is_action_pressed("fire")
|
||||
var held := _held(&"fire")
|
||||
var off_held := _held(&"offhand")
|
||||
for i in _cooldown.size():
|
||||
_cooldown[i] = maxi(_cooldown[i] - 1, 0)
|
||||
if _ticks - _stepped > 1:
|
||||
_offhand_needs_release = true # couldn't attack last tick (a menu, the partner's build mode)
|
||||
_stepped = _ticks
|
||||
if replica:
|
||||
if held:
|
||||
_player.face_aim(aim, 0.35)
|
||||
_show_attack()
|
||||
return
|
||||
if _needs_release:
|
||||
if held:
|
||||
return
|
||||
if _needs_release and not held:
|
||||
_needs_release = false
|
||||
if not held:
|
||||
return
|
||||
_player.face_aim(aim, 0.35)
|
||||
attack()
|
||||
if _offhand_needs_release and not off_held:
|
||||
_offhand_needs_release = false
|
||||
if off_held and not _offhand_needs_release:
|
||||
_player.face_aim(aim, 0.35)
|
||||
use_offhand()
|
||||
if held and not _needs_release:
|
||||
_player.face_aim(aim, 0.35)
|
||||
attack()
|
||||
|
||||
|
||||
## The weapon in hand attacks along the aim, if it's ready. Returns whether it did.
|
||||
## The main weapon attacks along the aim, if it's ready. Returns whether it did.
|
||||
func attack() -> bool:
|
||||
if _cooldown[weapon] > 0:
|
||||
return false
|
||||
match weapon:
|
||||
Weapon.CORN_SHOOTER:
|
||||
_cooldown[weapon] = interval_ticks()
|
||||
_shoot()
|
||||
Weapon.PUMPKIN_BOMB:
|
||||
if bomb_left > 0.0 or not _throw():
|
||||
return false
|
||||
_:
|
||||
_cooldown[weapon] = stab_ticks()
|
||||
_stab()
|
||||
attacked.emit(weapon)
|
||||
return true
|
||||
return _use(weapon)
|
||||
|
||||
|
||||
## A scripted attack (the soak's scarecrow, tests): aims at target and attacks if ready.
|
||||
## The off-hand weapon is used (a pumpkin bomb thrown at the aim point), if one is ready.
|
||||
## Returns whether it was.
|
||||
func use_offhand() -> bool:
|
||||
return offhand >= 0 and _use(offhand)
|
||||
|
||||
|
||||
## A scripted attack (the soak's scarecrow, tests): aims at target and attacks with the main
|
||||
## weapon if it's ready.
|
||||
func attack_toward(target: Vector2) -> bool:
|
||||
var p := Vector2(_player.global_position.x, _player.global_position.z)
|
||||
var to := target - p
|
||||
if to.length() > 1e-3:
|
||||
aim = PlayerInput.muzzle_corrected_aim(to, to.normalized()) if weapon == Weapon.CORN_SHOOTER else to.normalized()
|
||||
aim_point = Vector3(target.x, _cfg.combat_height, target.y)
|
||||
ground_point = Vector3(target.x, 0.0, target.y)
|
||||
device = Device.MOUSE
|
||||
_player.face_aim(aim, 0.35)
|
||||
_aim_at(target, weapon == Weapon.CORN_SHOOTER)
|
||||
return attack()
|
||||
|
||||
|
||||
## The same with the off-hand weapon (a pumpkin bomb thrown at target).
|
||||
func offhand_toward(target: Vector2) -> bool:
|
||||
_aim_at(target, false)
|
||||
return use_offhand()
|
||||
|
||||
|
||||
## Attacks so far, with any weapon.
|
||||
func attacks() -> int:
|
||||
return stabs + shots_fired + bombs_thrown
|
||||
|
|
@ -276,6 +316,44 @@ func throw_target() -> Vector3:
|
|||
return Vector3(at.x, 0.0, at.y)
|
||||
|
||||
|
||||
func _held(action: StringName) -> bool:
|
||||
return remote.held(action) if remote != null else Input.is_action_pressed(action)
|
||||
|
||||
|
||||
func _use(w: int) -> bool:
|
||||
if _cooldown[w] > 0:
|
||||
return false
|
||||
match w:
|
||||
Weapon.CORN_SHOOTER:
|
||||
_cooldown[w] = interval_ticks()
|
||||
_shoot()
|
||||
Weapon.PUMPKIN_BOMB:
|
||||
if bomb_left > 0.0 or not _throw():
|
||||
return false
|
||||
_:
|
||||
_cooldown[w] = stab_ticks()
|
||||
_stab()
|
||||
attacked.emit(w)
|
||||
return true
|
||||
|
||||
|
||||
func _set_offhand(w: int) -> void:
|
||||
if w != offhand:
|
||||
offhand = w
|
||||
models.show_offhand(w)
|
||||
|
||||
|
||||
func _aim_at(target: Vector2, from_muzzle: bool) -> void:
|
||||
var p := Vector2(_player.global_position.x, _player.global_position.z)
|
||||
var to := target - p
|
||||
if to.length() > 1e-3:
|
||||
aim = PlayerInput.muzzle_corrected_aim(to, to.normalized()) if from_muzzle else to.normalized()
|
||||
aim_point = Vector3(target.x, _cfg.combat_height, target.y)
|
||||
ground_point = Vector3(target.x, 0.0, target.y)
|
||||
device = Device.MOUSE
|
||||
_player.face_aim(aim, 0.35)
|
||||
|
||||
|
||||
func _shoot() -> void:
|
||||
var origin := Vector3(_player.global_position.x, _cfg.combat_height, _player.global_position.z)
|
||||
var dir := Vector3(aim.x, 0.0, aim.y)
|
||||
|
|
@ -324,7 +402,7 @@ func _throw() -> bool:
|
|||
if bombs == null:
|
||||
return false
|
||||
var p := _player.global_position
|
||||
var hand := Vector3(p.x - aim.y * 0.4, THROW_HEIGHT, p.z + aim.x * 0.4)
|
||||
var hand := Vector3(p.x + aim.y * 0.4, THROW_HEIGHT, p.z - aim.x * 0.4) # the left
|
||||
var to := throw_target()
|
||||
if not bombs.throw(hand, to, _cfg.bomb_damage, _cfg.bomb_radius):
|
||||
return false
|
||||
|
|
@ -335,10 +413,11 @@ func _throw() -> bool:
|
|||
return true
|
||||
|
||||
|
||||
## The partner's machine: the attack motion on the weapon's own cadence (the host attacks).
|
||||
## The partner's machine: the main weapon's attack motion on its own cadence (the host attacks;
|
||||
## its throws show the bomb, and empty the off-hand).
|
||||
func _show_attack() -> void:
|
||||
if weapon == Weapon.PUMPKIN_BOMB or _cooldown[weapon] > 0:
|
||||
return # the host's throw shows the bomb, and empties the hand
|
||||
if _cooldown[weapon] > 0:
|
||||
return
|
||||
_cooldown[weapon] = interval_ticks() if weapon == Weapon.CORN_SHOOTER else stab_ticks()
|
||||
models.attack(weapon)
|
||||
|
||||
|
|
@ -390,24 +469,26 @@ func _to_gamepad() -> void:
|
|||
func _process(_delta: float) -> void:
|
||||
if _player == null:
|
||||
return
|
||||
var bomb := weapon == Weapon.PUMPKIN_BOMB
|
||||
_marker.visible = show_marker
|
||||
_blast.visible = show_marker and bomb
|
||||
if bomb:
|
||||
var at := throw_target()
|
||||
_marker.global_position = Vector3(at.x, 0.12, at.z)
|
||||
_blast.global_position = Vector3(at.x, 0.1, at.z)
|
||||
elif device == Device.MOUSE:
|
||||
if device == Device.MOUSE:
|
||||
_marker.global_position = Vector3(aim_point.x, _cfg.combat_height, aim_point.z)
|
||||
else:
|
||||
var p := _player.get_global_transform_interpolated().origin
|
||||
_marker.global_position = Vector3(p.x + aim.x * 3.0, _cfg.combat_height, p.z + aim.y * 3.0)
|
||||
# A pumpkin bomb ready in the off-hand: where it would land, brighter while offhand is held.
|
||||
var bomb := offhand == Weapon.PUMPKIN_BOMB and bomb_left == 0.0
|
||||
_blast.visible = show_marker and bomb
|
||||
if _blast.visible:
|
||||
var at := throw_target()
|
||||
_blast.global_position = Vector3(at.x, 0.1, at.z)
|
||||
var held := remote == null and Input.is_action_pressed("offhand")
|
||||
(_blast.material_override as StandardMaterial3D).albedo_color.a = BLAST_HELD_ALPHA if held else BLAST_ALPHA
|
||||
|
||||
|
||||
func _build_marker() -> void:
|
||||
_marker = _ring(0.2, 0.3, Color(1.0, 0.85, 0.25))
|
||||
_marker.name = "AimMarker"
|
||||
_blast = _ring(_cfg.bomb_radius - 0.08, _cfg.bomb_radius, Color(1.0, 0.55, 0.12, 0.8))
|
||||
_blast = _ring(_cfg.bomb_radius - 0.08, _cfg.bomb_radius, Color(1.0, 0.55, 0.12, BLAST_ALPHA))
|
||||
_blast.name = "BlastMarker"
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -4,17 +4,19 @@ extends Control
|
|||
## sweeps full while it cools down and flashes when it is ready again, the patch hint with its
|
||||
## progress, and once the Sprint upgrade is bought a sprint line (ready, seconds left, or
|
||||
## recharging); plus a red screen tint when the scarecrow is hit. Bottom-right, the weapons:
|
||||
## the three by number, the one in hand marked, the ones not bought yet greyed out (from the
|
||||
## workbench), the pumpkin bomb's recharge, and how to switch.
|
||||
## the main ones by number, the one in hand marked, and how to switch; under them the off-hand
|
||||
## (pumpkin bombs, marked when one is ready, else its recharge) and its button. The ones not
|
||||
## bought yet are greyed out (from the workbench).
|
||||
|
||||
const PIP := Vector2(22.0, 16.0)
|
||||
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, and its rows.
|
||||
const WEAPONS := Rect2(-340.0, -176.0, 304.0, 150.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)
|
||||
const WEAPON_ROW := 30.0
|
||||
const OFFHAND_TOP := 122.0
|
||||
|
||||
var kit: Scarecrow
|
||||
## This machine's scarecrow's weapons.
|
||||
|
|
@ -31,6 +33,8 @@ var _sprint_label: Label
|
|||
var _weapon_title: Label
|
||||
var _weapon_rows: Array[Label] = []
|
||||
var _weapon_hint: Label
|
||||
var _offhand_title: Label
|
||||
var _offhand_rows: Array[Label] = []
|
||||
var _hit: float = 0.0
|
||||
var _ready_flash: float = 0.0
|
||||
|
||||
|
|
@ -72,11 +76,15 @@ func _ready() -> void:
|
|||
_patch_label = _label(20)
|
||||
_sprint_label = _label(20)
|
||||
_weapon_title = _label(18)
|
||||
_weapon_title.text = "Weapon"
|
||||
for i in ScarecrowCombat.WEAPON_NAMES.size():
|
||||
_weapon_title.text = "Main weapon"
|
||||
for i in ScarecrowCombat.MAIN_WEAPONS.size():
|
||||
_weapon_rows.append(_label(20))
|
||||
_weapon_hint = _label(16)
|
||||
_weapon_hint.text = "Switch: Tab / 1-3 / d-pad down"
|
||||
_weapon_hint.text = "Switch: Tab / 1-2 / d-pad down"
|
||||
_offhand_title = _label(18)
|
||||
_offhand_title.text = "Off-hand right mouse / LT"
|
||||
for i in ScarecrowCombat.OFFHAND_WEAPONS.size():
|
||||
_offhand_rows.append(_label(20))
|
||||
|
||||
|
||||
func _process(delta: float) -> void:
|
||||
|
|
@ -123,29 +131,42 @@ func _process(delta: float) -> void:
|
|||
|
||||
func _update_weapons() -> void:
|
||||
var shown := combat != null
|
||||
_weapon_title.visible = shown
|
||||
_weapon_hint.visible = shown
|
||||
for l in _weapon_rows:
|
||||
for l: Label in [_weapon_title, _weapon_hint, _offhand_title] + _weapon_rows + _offhand_rows:
|
||||
l.visible = shown
|
||||
if not shown:
|
||||
return
|
||||
var at := _weapons_rect().position
|
||||
_weapon_title.position = at + Vector2(12.0, 6.0)
|
||||
for i in _weapon_rows.size():
|
||||
var l := _weapon_rows[i]
|
||||
var text := "%d %s" % [i + 1, ScarecrowCombat.WEAPON_NAMES[i]]
|
||||
var color := Color(0.95, 0.95, 0.95)
|
||||
if not combat.owns(i):
|
||||
text += " (workbench)"
|
||||
color = Color(0.55, 0.55, 0.55)
|
||||
elif i == ScarecrowCombat.Weapon.PUMPKIN_BOMB and combat.bomb_left > 0.0:
|
||||
text += " %.0f s" % ceilf(combat.bomb_left)
|
||||
if i == combat.weapon:
|
||||
color = Color(1.0, 0.85, 0.3)
|
||||
l.text = text
|
||||
l.add_theme_color_override("font_color", color)
|
||||
l.position = at + Vector2(30.0, 30.0 + i * WEAPON_ROW)
|
||||
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)
|
||||
_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)
|
||||
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)
|
||||
|
||||
|
||||
## A weapon's row: greyed out until it's bought, gold when it's in hand (lit).
|
||||
func _weapon_row(l: Label, text: String, w: int, lit: bool) -> void:
|
||||
var color := Color(0.95, 0.95, 0.95)
|
||||
if not combat.owns(w):
|
||||
text += " (workbench)"
|
||||
color = Color(0.55, 0.55, 0.55)
|
||||
elif lit:
|
||||
color = Color(1.0, 0.85, 0.3)
|
||||
l.text = text
|
||||
l.add_theme_color_override("font_color", color)
|
||||
|
||||
|
||||
## Whether the off-hand weapon is in the off-hand and ready (a pumpkin bomb not recharging).
|
||||
func _offhand_lit(w: int) -> bool:
|
||||
return w == combat.offhand and not (w == ScarecrowCombat.Weapon.PUMPKIN_BOMB and combat.bomb_left > 0.0)
|
||||
|
||||
|
||||
func _weapons_rect() -> Rect2:
|
||||
|
|
@ -178,15 +199,23 @@ func _draw() -> void:
|
|||
if combat != null:
|
||||
var w := _weapons_rect()
|
||||
draw_rect(w, Color(0.0, 0.0, 0.0, 0.42))
|
||||
var row := Rect2(w.position + Vector2(6.0, 32.0 + combat.weapon * WEAPON_ROW), Vector2(w.size.x - 12.0, WEAPON_ROW - 2.0))
|
||||
draw_rect(row, Color(1.0, 0.85, 0.3, 0.18))
|
||||
draw_rect(Rect2(row.position, Vector2(4.0, row.size.y)), Color(1.0, 0.85, 0.3))
|
||||
_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)
|
||||
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))
|
||||
draw_rect(Rect2(bar.position, Vector2(bar.size.x * kit.patch_elapsed / kit.config.patch_time, bar.size.y)), Color(0.45, 1.0, 0.4))
|
||||
|
||||
|
||||
## The marked row of the weapon panel w, top pixels down.
|
||||
func _draw_lit_row(w: Rect2, top: float) -> void:
|
||||
var row := Rect2(w.position + Vector2(6.0, top), Vector2(w.size.x - 12.0, WEAPON_ROW - 2.0))
|
||||
draw_rect(row, Color(1.0, 0.85, 0.3, 0.18))
|
||||
draw_rect(Rect2(row.position, Vector2(4.0, row.size.y)), Color(1.0, 0.85, 0.3))
|
||||
|
||||
|
||||
func _base() -> Vector2:
|
||||
return Vector2(36.0, size.y - 126.0 - (SPRINT_ROW if _sprint_shown() else 0.0))
|
||||
|
||||
|
|
|
|||
|
|
@ -17,7 +17,9 @@ signal closed
|
|||
const BINDINGS := [
|
||||
["Move", []],
|
||||
["Aim", []],
|
||||
["Shoot", ["fire"]],
|
||||
["Attack (main weapon)", ["fire"]],
|
||||
["Throw a pumpkin bomb (off-hand)", ["offhand"]],
|
||||
["Switch main weapon", ["weapon_1", "weapon_2", "weapon_next"]],
|
||||
["Fear", ["fear"]],
|
||||
["Patch up (hold)", ["patch"]],
|
||||
["Gather / repair / workbench", ["interact"]],
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ const TEXT := {
|
|||
"store": "Your pouch only holds so much: walk onto the barn's apron (the Supply Shed) to store what you carry.",
|
||||
"build": "Press [B / d-pad up] to build. Pick a fence [1], place it with left mouse / RT. Thieves have to break through fences.",
|
||||
"dusk": "Dusk: thieves come at nightfall, from every side of the farm.",
|
||||
"shoot": "Aim with the mouse or the right stick and hold left mouse / RT to stab with your pitchfork. The workbench sells a corn shooter and pumpkin bombs: switch with [Tab / 1-3].",
|
||||
"shoot": "Aim with the mouse or the right stick and hold left mouse / RT to stab with your pitchfork. The workbench sells a corn shooter (switch with [Tab / 1-2]) and pumpkin bombs for your off-hand: throw them with [right mouse / LT].",
|
||||
"fear": "Crowded? [Q / LB] Fear scares off everything nearby, and they drop what they carry.",
|
||||
"recover": "Something was dropped! Walk over it to bring it home. A dropped animal follows you back to the pen.",
|
||||
"patch": "Hurt? Hold [F / Y] to patch up with straw. Health carries over to the next night.",
|
||||
|
|
|
|||
|
|
@ -1,13 +1,14 @@
|
|||
class_name WeaponModels
|
||||
extends Node3D
|
||||
## The scarecrow's weapons as it holds them (ScarecrowCombat), from the models in
|
||||
## assets/weapons/, on the scarecrow's model (which faces -Z), only the one in use showing. The
|
||||
## Blender exports sit far from the origin, so each mesh is re-centered (mesh_of) and posed here:
|
||||
## assets/weapons/, on the scarecrow's model (which faces -Z): the main weapon in use in the
|
||||
## right hand, the off-hand one in the left. The Blender exports sit far from the origin, so each
|
||||
## mesh is re-centered (mesh_of) and posed here:
|
||||
## pitchfork held low like a spear at the right side, tines forward; a stab thrusts it out
|
||||
## corn shooter at the gun's spot, its corn-cob muzzle at the gameplay muzzle point; each shot
|
||||
## kicks it back
|
||||
## pumpkin bomb in the right hand; after a throw the next one grows back in the hand over the
|
||||
## recharge (set_bomb_charge)
|
||||
## pumpkin bomb in the left hand (the off-hand); after a throw the next one grows back in the
|
||||
## hand over the recharge (set_bomb_charge)
|
||||
## attack() plays the weapon's motion (the pumpkin just leaves the hand: the thrown one is
|
||||
## PumpkinBombs').
|
||||
|
||||
|
|
@ -26,6 +27,7 @@ const KICK := 0.09
|
|||
static var _meshes := {}
|
||||
|
||||
var weapon: int = 0
|
||||
var offhand: int = -1
|
||||
var _pivots: Array[Node3D] = []
|
||||
var _rest: Array[Transform3D] = []
|
||||
var _attack_t := -1.0
|
||||
|
|
@ -42,8 +44,8 @@ static func mesh_of(index: int) -> Mesh:
|
|||
return _meshes[index]
|
||||
|
||||
|
||||
## Builds the three under model. muzzle: the gameplay muzzle point on the model (the corn
|
||||
## shooter's tip goes there).
|
||||
## Builds the three under model, the pitchfork in hand and the off-hand empty. muzzle: the
|
||||
## gameplay muzzle point on the model (the corn shooter's tip goes there).
|
||||
func setup(model: Node3D, muzzle: Vector3) -> void:
|
||||
name = "Weapons"
|
||||
model.add_child(self)
|
||||
|
|
@ -52,9 +54,10 @@ func setup(model: Node3D, muzzle: Vector3) -> void:
|
|||
# Corn shooter: its tip (the mesh's +Z end, 0.59 m out) turned forward onto the muzzle point.
|
||||
var tip := 0.589 * SCALES[1]
|
||||
_add(1, Transform3D(Basis.from_euler(Vector3(0.0, PI, 0.0)), muzzle + Vector3(0.0, 0.0, tip)))
|
||||
# Pumpkin: in the right hand, in front.
|
||||
_add(2, Transform3D(Basis.IDENTITY, Vector3(0.42, 1.2, -0.5)))
|
||||
# Pumpkin: in the left hand, in front.
|
||||
_add(2, Transform3D(Basis.IDENTITY, Vector3(-0.42, 1.2, -0.5)))
|
||||
show_weapon(0)
|
||||
show_offhand(-1)
|
||||
|
||||
|
||||
func _add(index: int, rest: Transform3D) -> void:
|
||||
|
|
@ -70,19 +73,25 @@ func _add(index: int, rest: Transform3D) -> void:
|
|||
_rest.append(rest)
|
||||
|
||||
|
||||
## Shows only this weapon (ScarecrowCombat.Weapon).
|
||||
## Shows this main weapon (ScarecrowCombat.Weapon) in the right hand, and no other.
|
||||
func show_weapon(index: int) -> void:
|
||||
weapon = index
|
||||
_attack_t = -1.0
|
||||
for i in _pivots.size():
|
||||
for i in ScarecrowCombat.MAIN_WEAPONS:
|
||||
_pivots[i].visible = i == index
|
||||
_pivots[i].transform = _rest[i]
|
||||
_apply_charge()
|
||||
|
||||
|
||||
## The weapon's attack motion: a stab or a kick.
|
||||
## Shows this off-hand weapon in the left hand (-1: none).
|
||||
func show_offhand(index: int) -> void:
|
||||
offhand = index
|
||||
for i in ScarecrowCombat.OFFHAND_WEAPONS:
|
||||
_pivots[i].visible = i == index
|
||||
|
||||
|
||||
## The main weapon's attack motion: a stab or a kick.
|
||||
func attack(index: int) -> void:
|
||||
if index == weapon and index < 2:
|
||||
if index == weapon:
|
||||
_attack_t = 0.0
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ extends RefCounted
|
|||
## by hand, tick by tick. Covers the join (the welcome, both scarecrows on both farms, names,
|
||||
## co-op health), requests from the partner (start the day, build, buy), the partner's scarecrow
|
||||
## moving, gathering, and shooting on the host (and its pick of weapon), the weapons' stabs and
|
||||
## pumpkin bombs reaching the replica (drawn there, doing no damage of their own), enemies, loot,
|
||||
## pumpkin bombs (thrown from the off-hand, not with the right click leaving build mode) reaching the replica (drawn there, doing no damage of their own), enemies, loot,
|
||||
## and shots reaching the replica,
|
||||
## the co-op fall rule (one down is out until morning, both down is Game Over) and Retry, message
|
||||
## sizes with a crowd, dropped unreliable messages, and either side leaving.
|
||||
|
|
@ -228,19 +228,36 @@ func _weapons_shown() -> void:
|
|||
host.combat.equip(ScarecrowCombat.Weapon.PUMPKIN_BOMB)
|
||||
host.combat.ready_for_morning()
|
||||
var bursts := client.bombs.bursts
|
||||
host.combat.attack_toward(Vector2(host.player.global_position.x + 6.0, host.player.global_position.z))
|
||||
host.combat.offhand_toward(Vector2(host.player.global_position.x + 6.0, host.player.global_position.z))
|
||||
_pump(3)
|
||||
r.check(p1.weapon == ScarecrowCombat.Weapon.PUMPKIN_BOMB and client.bombs.flying() == 1, "P1's pumpkin bomb flies on the partner's farm too")
|
||||
r.check(p1.weapon == ScarecrowCombat.Weapon.PITCHFORK and client.bombs.flying() == 1,
|
||||
"P1's pumpkin bomb flies on the partner's farm too (from the off-hand: the pitchfork stays in hand there)")
|
||||
_pump(90)
|
||||
r.check(client.bombs.bursts == bursts + 1 and client.bombs.enemies_hit == 0 and host.bombs.flying() == 0,
|
||||
"and bursts there, harmless (the host's burst does the damage)")
|
||||
r.check(client.combat.equip(ScarecrowCombat.Weapon.PUMPKIN_BOMB), "the partner can take bombs up too (bought for both)")
|
||||
r.check(client.combat.offhand == ScarecrowCombat.Weapon.PUMPKIN_BOMB and host.partner.combat.offhand == ScarecrowCombat.Weapon.PUMPKIN_BOMB,
|
||||
"the partner has bombs in its off-hand too (bought for both)")
|
||||
var thrown := host.partner.combat.bombs_thrown
|
||||
Input.action_press("fire")
|
||||
var attacks := host.partner.combat.attacks()
|
||||
Input.action_press("offhand")
|
||||
_pump(10)
|
||||
Input.action_release("fire")
|
||||
Input.action_release("offhand")
|
||||
_pump(4)
|
||||
r.check(host.partner.combat.bombs_thrown == thrown + 1 and client.combat.bomb_left > 0.0, "P2's throw happens on the host, and its recharge shows on the partner's HUD")
|
||||
r.check(host.partner.combat.bombs_thrown == thrown + 1 and host.partner.combat.attacks() == attacks + 1 and client.combat.bomb_left > 0.0,
|
||||
"the partner's right click throws on the host (and nothing else), and its recharge shows on the partner's HUD")
|
||||
_pump(roundi(host.config.bomb_cooldown * 60.0) + 10)
|
||||
client.build.set_active(true)
|
||||
_pump(4)
|
||||
thrown = host.partner.combat.bombs_thrown
|
||||
Input.action_press("cancel") # the right mouse button: both actions
|
||||
Input.action_press("offhand")
|
||||
_pump(10)
|
||||
var left := not client.build.active
|
||||
Input.action_release("cancel")
|
||||
Input.action_release("offhand")
|
||||
_pump(4)
|
||||
r.check(left and host.partner.combat.bombs_thrown == thrown,
|
||||
"the partner's right click that leaves build mode throws nothing on the host, even held")
|
||||
_pump(90)
|
||||
for c: ScarecrowCombat in [host.combat, client.combat]:
|
||||
c.equip(ScarecrowCombat.Weapon.PITCHFORK)
|
||||
|
|
|
|||
|
|
@ -3,8 +3,9 @@ extends RefCounted
|
|||
## main menu over the paused farm; New vacation, Continue, and their questions; pausing freezes
|
||||
## the simulation tick; settings apply and persist from the pause menu; Restart the night and
|
||||
## Save & quit to menu put the farm back at the saved morning without touching the save; a
|
||||
## damaged save can't be continued; the failure screen and Retry; the farmers' return and the
|
||||
## final assessment; the first day's and night's tips; and the sounds hooked to the game.
|
||||
## damaged save can't be continued; quitting a hosted co-op game from the pause menu leaves the
|
||||
## scarecrow unfrozen; the failure screen and Retry; the farmers' return and the final
|
||||
## assessment; the first day's and night's tips; and the sounds hooked to the game.
|
||||
|
||||
const P := CampaignController.Phase
|
||||
const SAVE := "user://test_flow_save.json"
|
||||
|
|
@ -33,6 +34,7 @@ func run(p_r: GameTestRunner) -> void:
|
|||
await _settings()
|
||||
await _restart_and_quit_to_menu()
|
||||
await _continue_and_new()
|
||||
await _coop_quit_to_menu()
|
||||
await _tutorial()
|
||||
await _failure()
|
||||
await _ending()
|
||||
|
|
@ -196,6 +198,25 @@ func _continue_and_new() -> void:
|
|||
"New vacation doesn't ask about a damaged save and replaces it")
|
||||
|
||||
|
||||
## Hosting co-op, the pause menu freezes only this scarecrow; quitting to the menu from it must
|
||||
## unfreeze it, or the next game (hosting again, or joining a friend's) has no aim or buttons.
|
||||
func _coop_quit_to_menu() -> void:
|
||||
var links := CoopLink.pair()
|
||||
sim.coop.start_host(sim, links[0], "Ana", "Ben")
|
||||
main.pause()
|
||||
r.check(sim.local_frozen and not r.paused and sim.combat.remote != null, "hosting co-op, the pause menu freezes the scarecrow, not the farm")
|
||||
main.pause_menu.menu_button.pressed.emit()
|
||||
r.check(main.screen == Main.Screen.MENU and not sim.coop.is_active() and not sim.local_frozen and sim.combat.remote == null
|
||||
and sim.scarecrow.remote == null and sim.interactions.remote == null and sim.player.input_enabled,
|
||||
"quitting co-op to the menu unfreezes it")
|
||||
links[1].close()
|
||||
main.main_menu.continue_button.pressed.emit()
|
||||
sim.combat.aim_point = Vector3.ZERO
|
||||
await r.physics_frame
|
||||
await r.physics_frame
|
||||
r.check(main.screen == Main.Screen.PLAYING and sim.combat.aim_point != Vector3.ZERO, "and in the next game the aim follows the mouse again")
|
||||
|
||||
|
||||
func _tutorial() -> void:
|
||||
var t := sim.tutorial
|
||||
t.done = {}
|
||||
|
|
|
|||
|
|
@ -3,11 +3,13 @@ extends RefCounted
|
|||
## pitchfork to start; its stab (in reach and in the arc of the aim only, the nearest few, its
|
||||
## damage, once per interval, again and again while fire is held, not through a wall); the corn
|
||||
## shooter and pumpkin bombs bought at the workbench (rapid fire and heavy seeds need the corn
|
||||
## shooter first; a weapon bought goes into the hand); switching (Tab / 1-3, owned ones only, not
|
||||
## in build mode; one no longer owned falls back to the pitchfork); a bomb's throw (at the aim,
|
||||
## its range clamped), flight, and burst (everything in its radius, crows too, nothing beyond,
|
||||
## not the scarecrow), its recharge and the morning refill; the models on the scarecrow; and the
|
||||
## HUD's weapon panel.
|
||||
## shooter first; a weapon bought goes into its hand, bombs into the off-hand); switching the main
|
||||
## weapon (Tab / 1-2, owned ones only, not in build mode, never the bombs; one no longer owned
|
||||
## falls back to the pitchfork); the off-hand on its own button (right mouse / LT: with the main
|
||||
## weapon in hand, both at once, held, not with the right click that leaves build mode); a bomb's
|
||||
## throw (at the aim, its range clamped), flight, and burst (everything in its radius, crows too,
|
||||
## nothing beyond, not the scarecrow), its recharge and the morning refill; the models on the
|
||||
## scarecrow; and the HUD's weapon panel.
|
||||
|
||||
const DT := 1.0 / 60.0
|
||||
const AT := Vector2(0.0, 6.0) # open ground south-west of the pen
|
||||
|
|
@ -32,6 +34,7 @@ func run(r: GameTestRunner) -> void:
|
|||
await _wall(r, sim, farm)
|
||||
_unlocks(r, farm, sim)
|
||||
_switching(r, sim)
|
||||
_offhand(r, sim)
|
||||
_bombs(r, sim)
|
||||
_hud(r, farm, sim)
|
||||
sim.enemies.behavior = keep
|
||||
|
|
@ -41,8 +44,8 @@ func run(r: GameTestRunner) -> void:
|
|||
|
||||
func _start(r: GameTestRunner, sim: FarmSim, player: PlayerCharacter) -> void:
|
||||
var c := sim.combat
|
||||
r.check(c.weapon == W.PITCHFORK and c.owns(W.PITCHFORK) and not c.owns(W.CORN_SHOOTER) and not c.owns(W.PUMPKIN_BOMB),
|
||||
"a new vacation: the pitchfork in hand, and nothing else")
|
||||
r.check(c.weapon == W.PITCHFORK and c.owns(W.PITCHFORK) and not c.owns(W.CORN_SHOOTER) and not c.owns(W.PUMPKIN_BOMB)
|
||||
and c.offhand == -1, "a new vacation: the pitchfork in hand, and nothing else (the off-hand empty)")
|
||||
var pivots := c.models._pivots
|
||||
r.check(pivots.size() == 3 and pivots[0].visible and not pivots[1].visible and not pivots[2].visible, "only the pitchfork shows on the scarecrow")
|
||||
var near := true
|
||||
|
|
@ -132,8 +135,14 @@ func _unlocks(r: GameTestRunner, farm: Node3D, sim: FarmSim) -> void:
|
|||
"the corn shooter is bought at the workbench; then rapid fire can be")
|
||||
var panel := farm.get_node("Hud/UpgradePanel") as UpgradePanel
|
||||
panel._buy("pumpkin_bomb")
|
||||
r.check(combat.owns(W.PUMPKIN_BOMB) and combat.weapon == W.PUMPKIN_BOMB, "a weapon bought from the menu goes into the hand")
|
||||
r.check(combat.models._pivots[2].visible and not combat.models._pivots[0].visible, "and shows on the scarecrow")
|
||||
r.check(combat.owns(W.PUMPKIN_BOMB) and combat.offhand == W.PUMPKIN_BOMB and combat.weapon == W.PITCHFORK,
|
||||
"pumpkin bombs bought from the menu go into the off-hand, the pitchfork staying in hand")
|
||||
var pivots := combat.models._pivots
|
||||
r.check(pivots[2].visible and pivots[0].visible and not pivots[1].visible, "both show on the scarecrow")
|
||||
r.check(pivots[0].position.x > 0.0 and pivots[2].position.x < 0.0, "the pitchfork in the right hand, the pumpkin in the left")
|
||||
s.upgrades.erase("corn_shooter")
|
||||
panel._buy("corn_shooter")
|
||||
r.check(combat.weapon == W.CORN_SHOOTER and combat.offhand == W.PUMPKIN_BOMB, "the corn shooter bought from the menu goes into the hand")
|
||||
|
||||
|
||||
func _switching(r: GameTestRunner, sim: FarmSim) -> void:
|
||||
|
|
@ -144,11 +153,15 @@ func _switching(r: GameTestRunner, sim: FarmSim) -> void:
|
|||
for k in 3:
|
||||
_tap(sim, "weapon_next")
|
||||
seen.append(c.weapon)
|
||||
r.check(seen == [W.CORN_SHOOTER, W.PUMPKIN_BOMB, W.PITCHFORK], "Tab / d-pad down cycles through them: %s" % [seen])
|
||||
_tap(sim, "weapon_3")
|
||||
var third := c.weapon
|
||||
r.check(seen == [W.CORN_SHOOTER, W.PITCHFORK, W.CORN_SHOOTER] and c.offhand == W.PUMPKIN_BOMB,
|
||||
"Tab / d-pad down cycles through the main weapons, the bombs staying in the off-hand: %s" % [seen])
|
||||
_tap(sim, "weapon_1")
|
||||
r.check(third == W.PUMPKIN_BOMB and c.weapon == W.PITCHFORK, "1-3 pick one")
|
||||
var first := c.weapon
|
||||
_tap(sim, "weapon_2")
|
||||
r.check(first == W.PITCHFORK and c.weapon == W.CORN_SHOOTER, "1-2 pick one")
|
||||
r.check(c.equip(W.PUMPKIN_BOMB) and c.weapon == W.CORN_SHOOTER and not InputMap.has_action("weapon_3"),
|
||||
"the bombs never take the main hand (and there's no third weapon key)")
|
||||
c.equip(W.PITCHFORK)
|
||||
var east := AT + Vector2(5.0, 0.0)
|
||||
_step(sim, c.stab_ticks())
|
||||
c.attack_toward(east)
|
||||
|
|
@ -162,18 +175,79 @@ func _switching(r: GameTestRunner, sim: FarmSim) -> void:
|
|||
var building := c.weapon
|
||||
sim.build.set_active(false)
|
||||
r.check(building == W.PITCHFORK, "not in build mode (those keys pick structures there)")
|
||||
s.upgrades.erase("pumpkin_bomb")
|
||||
c.equip(W.CORN_SHOOTER)
|
||||
_tap(sim, "weapon_next")
|
||||
var skipped := c.weapon
|
||||
_tap(sim, "weapon_3")
|
||||
r.check(skipped == W.PITCHFORK and c.weapon == W.PITCHFORK, "only weapons owned: no pumpkin bombs without the upgrade")
|
||||
c.equip(W.CORN_SHOOTER)
|
||||
s.upgrades.erase("corn_shooter")
|
||||
_step(sim, 1)
|
||||
r.check(c.weapon == W.PITCHFORK, "one no longer owned (a retry from before it was bought) goes back to the pitchfork")
|
||||
_tap(sim, "weapon_next")
|
||||
var skipped := c.weapon
|
||||
_tap(sim, "weapon_2")
|
||||
r.check(skipped == W.PITCHFORK and c.weapon == W.PITCHFORK, "only weapons owned: no corn shooter without the upgrade")
|
||||
s.upgrades.erase("pumpkin_bomb")
|
||||
_step(sim, 1)
|
||||
r.check(c.offhand == -1 and not c.models._pivots[2].visible and not c.use_offhand(), "bombs no longer owned leave the off-hand")
|
||||
s.upgrades["corn_shooter"] = 1
|
||||
s.upgrades["pumpkin_bomb"] = 1
|
||||
_step(sim, 1)
|
||||
r.check(c.offhand == W.PUMPKIN_BOMB, "and come back to it once owned")
|
||||
|
||||
|
||||
## The off-hand's own button, with the corn shooter in hand.
|
||||
func _offhand(r: GameTestRunner, sim: FarmSim) -> void:
|
||||
var c := sim.combat
|
||||
var cfg := sim.config
|
||||
var recharge := roundi(cfg.bomb_cooldown * 60.0) + 2
|
||||
c.equip(W.CORN_SHOOTER)
|
||||
c.device = ScarecrowCombat.Device.GAMEPAD # keeps the aim it's given, and build mode's cursor in the open
|
||||
c.aim = Vector2(1.0, 0.0)
|
||||
c.ready_for_morning()
|
||||
_step(sim, 1)
|
||||
var thrown := c.bombs_thrown
|
||||
var shots := c.shots_fired
|
||||
_tap(sim, "offhand")
|
||||
r.check(c.bombs_thrown == thrown + 1 and c.shots_fired == shots and c.weapon == W.CORN_SHOOTER,
|
||||
"right mouse / LT throws a pumpkin bomb from the off-hand, the corn shooter staying in hand")
|
||||
_step(sim, recharge)
|
||||
Input.action_press("fire")
|
||||
Input.action_press("offhand")
|
||||
_step(sim, 1)
|
||||
Input.action_release("fire")
|
||||
Input.action_release("offhand")
|
||||
_step(sim, 1)
|
||||
r.check(c.bombs_thrown == thrown + 2 and c.shots_fired == shots + 1, "both at once: a shot and a throw")
|
||||
_step(sim, recharge)
|
||||
thrown = c.bombs_thrown
|
||||
Input.action_press("offhand")
|
||||
_step(sim, recharge + 2)
|
||||
Input.action_release("offhand")
|
||||
_step(sim, 1)
|
||||
r.check(c.bombs_thrown == thrown + 2, "holding it throws the next one as soon as it's back in hand (%d)" % (c.bombs_thrown - thrown))
|
||||
_step(sim, recharge)
|
||||
# The right mouse button also leaves build mode (cancel): that click throws nothing.
|
||||
sim.build.set_active(true)
|
||||
_step(sim, 2)
|
||||
thrown = c.bombs_thrown
|
||||
Input.action_press("cancel")
|
||||
Input.action_press("offhand")
|
||||
_step(sim, 1)
|
||||
var left := not sim.build.active
|
||||
_step(sim, 30)
|
||||
Input.action_release("cancel")
|
||||
Input.action_release("offhand")
|
||||
_step(sim, 1)
|
||||
r.check(left and c.bombs_thrown == thrown, "the right click that leaves build mode throws no bomb, even held")
|
||||
_tap(sim, "offhand")
|
||||
r.check(c.bombs_thrown == thrown + 1, "the next click does")
|
||||
c.ready_for_morning()
|
||||
thrown = c.bombs_thrown
|
||||
Input.action_press("offhand")
|
||||
_step(sim, 3)
|
||||
Input.action_release("offhand")
|
||||
_step(sim, 1)
|
||||
r.check(c.bombs_thrown == thrown, "a new morning needs a fresh press (held from the night before: nothing)")
|
||||
sim.bombs.clear()
|
||||
c.equip(W.PITCHFORK)
|
||||
c.device = ScarecrowCombat.Device.MOUSE
|
||||
|
||||
|
||||
func _bombs(r: GameTestRunner, sim: FarmSim) -> void:
|
||||
|
|
@ -181,7 +255,6 @@ func _bombs(r: GameTestRunner, sim: FarmSim) -> void:
|
|||
var cfg := sim.config
|
||||
var es := sim.enemies
|
||||
var kit := sim.scarecrow
|
||||
c.equip(W.PUMPKIN_BOMB)
|
||||
c.ready_for_morning()
|
||||
var target := AT + Vector2(6.0, 0.0)
|
||||
var on := es.spawn(THIEF, target.x, target.y, Vector2.LEFT)
|
||||
|
|
@ -190,9 +263,10 @@ func _bombs(r: GameTestRunner, sim: FarmSim) -> void:
|
|||
var out := es.spawn(THIEF, target.x + cfg.bomb_radius + 2.0, target.y, Vector2.LEFT)
|
||||
_step(sim, 1)
|
||||
var hp := kit.hp()
|
||||
r.check(c.attack_toward(target) and sim.bombs.flying() == 1 and is_equal_approx(c.bomb_left, cfg.bomb_cooldown),
|
||||
var bursts := sim.bombs.bursts
|
||||
r.check(c.offhand_toward(target) and sim.bombs.flying() == 1 and is_equal_approx(c.bomb_left, cfg.bomb_cooldown),
|
||||
"a pumpkin bomb is thrown at the aim point")
|
||||
r.check(not c.attack_toward(target), "only one every %.0f s" % cfg.bomb_cooldown)
|
||||
r.check(not c.offhand_toward(target), "only one every %.0f s" % cfg.bomb_cooldown)
|
||||
r.check(c.models._pivots[2].scale.x < 0.05, "it's gone from the hand")
|
||||
var ticks := 0
|
||||
while sim.bombs.flying() > 0 and ticks < 200:
|
||||
|
|
@ -202,7 +276,7 @@ func _bombs(r: GameTestRunner, sim: FarmSim) -> void:
|
|||
r.check(ticks * DT >= PumpkinBombs.MIN_FLIGHT - DT and ticks * DT <= PumpkinBombs.MAX_FLIGHT + DT, "it flies %.2f s" % (ticks * DT))
|
||||
r.check(es.resolve_handle(on) < 0 and es.resolve_handle(near) < 0 and es.resolve_handle(crow) < 0,
|
||||
"its burst stops everything within %.0f m (%d damage), crows too" % [cfg.bomb_radius, cfg.bomb_damage])
|
||||
r.check(_hp(es, out) == es.t_hp[THIEF] and kit.hp() == hp and sim.bombs.bursts == 1, "nothing beyond, and not the scarecrow")
|
||||
r.check(_hp(es, out) == es.t_hp[THIEF] and kit.hp() == hp and sim.bombs.bursts == bursts + 1, "nothing beyond, and not the scarecrow")
|
||||
_clear(sim)
|
||||
c.device = ScarecrowCombat.Device.MOUSE
|
||||
var me := Vector2(sim.player.global_position.x, sim.player.global_position.z)
|
||||
|
|
@ -214,7 +288,7 @@ func _bombs(r: GameTestRunner, sim: FarmSim) -> void:
|
|||
"it lands %.0f .. %.0f m away (%.1f, %.1f)" % [cfg.bomb_min_range, cfg.bomb_range, short, long])
|
||||
_step(sim, roundi(cfg.bomb_cooldown * 60.0) + 2)
|
||||
r.check(c.bomb_left == 0.0 and c.models._pivots[2].scale.x > 0.99, "after %.0f s another one is in hand" % cfg.bomb_cooldown)
|
||||
c.attack_toward(target)
|
||||
c.offhand_toward(target)
|
||||
c.ready_for_morning()
|
||||
r.check(c.bomb_left == 0.0, "a new morning puts one in hand")
|
||||
sim.bombs.clear()
|
||||
|
|
@ -223,15 +297,22 @@ func _bombs(r: GameTestRunner, sim: FarmSim) -> void:
|
|||
func _hud(r: GameTestRunner, farm: Node3D, sim: FarmSim) -> void:
|
||||
var hud := farm.get_node("Hud/ScarecrowHud") as ScarecrowHud
|
||||
var c := sim.combat
|
||||
var cfg := sim.config
|
||||
var s := sim.campaign.state
|
||||
s.upgrades.erase("corn_shooter")
|
||||
c.equip(W.PUMPKIN_BOMB)
|
||||
c.attack_toward(AT + Vector2(6.0, 0.0))
|
||||
c.ready_for_morning()
|
||||
_step(sim, 1)
|
||||
hud._process(0.0)
|
||||
var rows := hud._weapon_rows.map(func(l: Label) -> String: return l.text)
|
||||
r.check(rows[0] == "1 Pitchfork" and rows[1] == "2 Corn shooter (workbench)" and rows[2] == "3 Pumpkin bombs 4 s",
|
||||
"the HUD lists the weapons: %s" % [rows])
|
||||
r.check(hud._weapon_title.visible and hud._weapon_hint.text.contains("Tab"), "with how to switch")
|
||||
var charged: Array = hud._offhand_rows.map(func(l: Label) -> String: return l.text)
|
||||
c.offhand_toward(AT + Vector2(6.0, 0.0))
|
||||
hud._process(0.0)
|
||||
var rows: Array = hud._weapon_rows.map(func(l: Label) -> String: return l.text)
|
||||
var off: Array = hud._offhand_rows.map(func(l: Label) -> String: return l.text)
|
||||
r.check(rows == ["1 Pitchfork", "2 Corn shooter (workbench)"], "the HUD lists the main weapons by number: %s" % [rows])
|
||||
r.check(charged == ["Pumpkin bombs"] and off == ["Pumpkin bombs %.0f s" % ceilf(cfg.bomb_cooldown)],
|
||||
"and the off-hand's bombs, with their recharge: %s, %s" % [charged, off])
|
||||
r.check(hud._weapon_title.visible and hud._weapon_hint.text.contains("Tab") and hud._offhand_title.text.contains("right mouse"),
|
||||
"with how to switch, and the off-hand's button")
|
||||
s.upgrades.erase("pumpkin_bomb")
|
||||
_step(sim, 1)
|
||||
sim.bombs.clear()
|
||||
|
|
|
|||
|
|
@ -20,8 +20,13 @@ extends SceneTree
|
|||
## | toggle_mic | M | - | Co-op |
|
||||
## | sprint (hold)| Shift | L3 (stick) | Sprint |
|
||||
## | weapon_next | Tab | D-pad down | Weapons |
|
||||
## | weapon_1..3 | 1, 2, 3 | - | Weapons |
|
||||
## The weapon keys are build mode's (build_next, build_1..3): outside build mode they pick weapons.
|
||||
## | weapon_1..2 | 1, 2 | - | Weapons |
|
||||
## | offhand | Right mouse | LT | Off-hand |
|
||||
## The weapon keys are build mode's (build_next, build_1..2): outside build mode they pick the
|
||||
## main weapon. offhand shares the right mouse button with cancel: in build mode it dismantles.
|
||||
## STALE actions, from earlier versions of this table, are removed.
|
||||
|
||||
const STALE: Array[String] = ["weapon_3"]
|
||||
|
||||
|
||||
func _initialize() -> void:
|
||||
|
|
@ -41,8 +46,11 @@ func _initialize() -> void:
|
|||
_action("toggle_mic", [_key(KEY_M)])
|
||||
_action("sprint", [_key(KEY_SHIFT), _joy(JOY_BUTTON_LEFT_STICK)])
|
||||
_action("weapon_next", [_key(KEY_TAB), _joy(JOY_BUTTON_DPAD_DOWN)])
|
||||
for i in 3:
|
||||
for i in 2:
|
||||
_action("weapon_%d" % (i + 1), [_key(number_keys[i])])
|
||||
_action("offhand", [_mouse(MOUSE_BUTTON_RIGHT), _axis(JOY_AXIS_TRIGGER_LEFT)])
|
||||
for a in STALE:
|
||||
ProjectSettings.clear("input/" + a)
|
||||
var err := ProjectSettings.save()
|
||||
print("configure_input: save -> %s" % error_string(err))
|
||||
quit(0 if err == OK else 1)
|
||||
|
|
@ -70,3 +78,10 @@ func _joy(button: JoyButton) -> InputEventJoypadButton:
|
|||
var e := InputEventJoypadButton.new()
|
||||
e.button_index = button
|
||||
return e
|
||||
|
||||
|
||||
func _axis(axis: JoyAxis) -> InputEventJoypadMotion:
|
||||
var e := InputEventJoypadMotion.new()
|
||||
e.axis = axis
|
||||
e.axis_value = 1.0
|
||||
return e
|
||||
|
|
|
|||
|
|
@ -11,12 +11,14 @@ extends SceneTree
|
|||
## (127.0.0.1), for networks where broadcasts reach this machine. --online plays over GD-Sync's
|
||||
## servers instead (needs the API keys): the partner finds the host's lobby in the online list.
|
||||
## --host-name=Ana names the host (and so its lobby, "Ana's farm"); give both sides the same one.
|
||||
## --address=192.168.1.20 joins a host at that address (LAN) instead of 127.0.0.1.
|
||||
|
||||
var role := "host"
|
||||
var seconds := 20.0
|
||||
var discover := false
|
||||
var online := false
|
||||
var host_name := "Ana"
|
||||
var address := "127.0.0.1"
|
||||
## --shot=path: a screenshot at night with the enemies in (needs a window, not --headless).
|
||||
var shot := ""
|
||||
var main: Main
|
||||
|
|
@ -35,6 +37,8 @@ func _initialize() -> void:
|
|||
online = true
|
||||
elif String(a).begins_with("--host-name="):
|
||||
host_name = String(a).trim_prefix("--host-name=")
|
||||
elif String(a).begins_with("--address="):
|
||||
address = String(a).trim_prefix("--address=")
|
||||
elif String(a).begins_with("--seconds="):
|
||||
seconds = float(String(a).trim_prefix("--seconds="))
|
||||
_run.call_deferred()
|
||||
|
|
@ -103,7 +107,7 @@ func _run() -> void:
|
|||
_check(true, "found %s %s" % [found[0]["name"], "online" if online else "on the network"])
|
||||
lobby.join(String(found[0]["name"]))
|
||||
else:
|
||||
lobby.join_address("127.0.0.1", "Ben")
|
||||
lobby.join_address(address, "Ben")
|
||||
if not await _wait(func() -> bool: return sim.coop.is_client() and sim.coop._is_welcomed, 40.0):
|
||||
_check(false, "joined and got the farm within 40 s")
|
||||
await _finish()
|
||||
|
|
|
|||
|
|
@ -21,8 +21,8 @@ extends SceneTree
|
|||
## guard: it goes for the most urgent threat (carriers, then thieves
|
||||
## taking something, then dropped loot and loose animals, then other
|
||||
## thieves), attacks thieves in range with a clear line with its best
|
||||
## weapon (a pumpkin bomb into a crowd, the corn shooter once bought, else
|
||||
## the pitchfork, closing in to stab), uses fear on a
|
||||
## weapons (a pumpkin bomb from the off-hand into a crowd, and the corn
|
||||
## shooter once bought, else the pitchfork, closing in to stab), uses fear on a
|
||||
## carrier or a crowd in range, leads animals following it back to the pen
|
||||
## when no carrier is close, and patches up when hurt and nothing is close.
|
||||
## --minutes=10 night time to play (rounded up to whole nights)
|
||||
|
|
@ -458,8 +458,8 @@ func _guard() -> void:
|
|||
_walk_toward(goal, me)
|
||||
|
||||
|
||||
## Attacks the thief at target with the best weapon owned: a pumpkin bomb into a crowd of three
|
||||
## or more when one is ready, else the corn shooter, else the pitchfork (only within its reach).
|
||||
## Attacks the thief at target with the best weapons owned: a pumpkin bomb into a crowd of three
|
||||
## or more when one is ready, and the corn shooter, else the pitchfork (only within its reach).
|
||||
## Returns the distance it holds ground at.
|
||||
func _attack(target: Vector2, me: Vector2) -> float:
|
||||
var c := _sim.combat
|
||||
|
|
@ -470,8 +470,8 @@ func _attack(target: Vector2, me: Vector2) -> float:
|
|||
if es.alive[d] == 1 and Vector2(es.pos_x[d], es.pos_z[d]).distance_to(target) <= cfg.bomb_radius:
|
||||
crowd += 1
|
||||
var far := target.distance_to(me)
|
||||
if crowd >= 3 and c.bomb_left == 0.0 and far >= cfg.bomb_min_range and far <= cfg.bomb_range and c.equip(ScarecrowCombat.Weapon.PUMPKIN_BOMB):
|
||||
if c.attack_toward(target):
|
||||
if crowd >= 3 and c.offhand == ScarecrowCombat.Weapon.PUMPKIN_BOMB and far >= cfg.bomb_min_range and far <= cfg.bomb_range:
|
||||
if c.offhand_toward(target):
|
||||
_shots += 1
|
||||
if c.equip(ScarecrowCombat.Weapon.CORN_SHOOTER):
|
||||
if c.attack_toward(target):
|
||||
|
|
|
|||
|
|
@ -215,9 +215,10 @@ weapon_2={
|
|||
"events": Array[InputEvent]([Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":50,"key_label":0,"unicode":0,"location":0,"echo":false,"script":null)
|
||||
])
|
||||
}
|
||||
weapon_3={
|
||||
offhand={
|
||||
"deadzone": 0.5,
|
||||
"events": Array[InputEvent]([Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":51,"key_label":0,"unicode":0,"location":0,"echo":false,"script":null)
|
||||
"events": Array[InputEvent]([Object(InputEventMouseButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"button_mask":0,"position":Vector2(0, 0),"global_position":Vector2(0, 0),"factor":1.0,"button_index":2,"canceled":false,"pressed":false,"double_click":false,"script":null)
|
||||
, Object(InputEventJoypadMotion,"resource_local_to_scene":false,"resource_name":"","device":-1,"axis":4,"axis_value":1.0,"script":null)
|
||||
])
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue