T1 tutorial: Actions events, the Guide autoload, chapter 1 with Old Tam the hermit, guide panel and marker, saved progress; roadmap: auto-update plan
This commit is contained in:
@@ -10,6 +10,17 @@ extends Node
|
||||
|
||||
signal notify(text: String) ## short HUD toast ("+4 Wood", "Need an axe")
|
||||
signal item_gained(id: String, n: int)
|
||||
## What players did (docs/TUTORIAL_DESIGN.md §3): the tutorial's Guide (and
|
||||
## later hints and addons) listen to these. Emitted where the game decides
|
||||
## (single-player, or on a server for each player's character).
|
||||
signal crafted(player: Node, recipe_id: String, output: String, count: int)
|
||||
signal harvested(player: Node, node: Node, felled: bool)
|
||||
signal placed(player: Node, item_id: String, piece: Node)
|
||||
signal ate(player: Node, item_id: String)
|
||||
signal killed(player: Node, kind: String)
|
||||
signal butchered(player: Node, kind: String)
|
||||
signal caught(player: Node, fish: String)
|
||||
signal slept(player: Node)
|
||||
|
||||
const STATION_RANGE := 6.0
|
||||
const REACH := 3.2
|
||||
@@ -207,6 +218,7 @@ func craft(player: Node, recipe_id: String) -> bool:
|
||||
for id in r.inputs:
|
||||
inv.remove(id, int(r.inputs[id]))
|
||||
_give(player, r.output, r.count)
|
||||
crafted.emit(player, recipe_id, String(r.output), int(r.count))
|
||||
return true
|
||||
|
||||
func pickup(player: Node3D, pickup_node: Node3D) -> bool:
|
||||
@@ -250,6 +262,7 @@ func harvest_hit(player: Node3D, node: Node3D, hit_point: Vector3) -> bool:
|
||||
for id in drops:
|
||||
_give(player, id, int(drops[id]))
|
||||
use_held(player)
|
||||
harvested.emit(player, node, bool(node.depleted))
|
||||
return true
|
||||
|
||||
func can_place(player: Node3D, slot: int) -> bool:
|
||||
@@ -271,7 +284,8 @@ func place(player: Node3D, slot: int, xf: Transform3D, world: Node3D) -> bool:
|
||||
notify.emit("Can't place that here")
|
||||
return false
|
||||
player.inventory.take_from(slot, 1)
|
||||
world.spawn_piece(def, xf)
|
||||
var piece: Node3D = world.spawn_piece(def, xf)
|
||||
placed.emit(player, id, piece)
|
||||
return true
|
||||
|
||||
## Takes a placed piece back into your inventory. Building pieces that lose
|
||||
@@ -369,6 +383,7 @@ func use_bed(player: Node3D, bed: Node3D) -> bool:
|
||||
notify.emit(why)
|
||||
return false
|
||||
world.sleep(player)
|
||||
slept.emit(player)
|
||||
return true
|
||||
|
||||
# --- hunting and combat ---------------------------------------------------------
|
||||
@@ -420,6 +435,7 @@ func melee(player: Node3D, target: Node3D) -> bool:
|
||||
use_held(player)
|
||||
if target.is_dead():
|
||||
notify.emit("Killed a %s" % target.display_name().to_lower())
|
||||
killed.emit(player, String(target.kind))
|
||||
return true
|
||||
|
||||
## A melee blow at another player (online, with PvP on). Online only.
|
||||
@@ -465,6 +481,7 @@ func projectile_hit(shooter: Node3D, target: Node3D, damage: float, at: Vector3,
|
||||
target.take_hit(damage, shooter.global_position if shooter != null else at, embed_id)
|
||||
if was_alive and target.is_dead():
|
||||
tell(shooter, "Killed a %s" % target.display_name().to_lower())
|
||||
killed.emit(shooter, String(target.kind))
|
||||
|
||||
## Throws the spear in `slot` from `origin` along `dir`.
|
||||
func throw_spear(player: Node3D, slot: int, origin: Vector3, dir: Vector3, world: Node3D) -> bool:
|
||||
@@ -540,6 +557,7 @@ func butcher(player: Node3D, carcass: Node3D) -> bool:
|
||||
return false
|
||||
var drops: Dictionary = carcass.butcher_drops()
|
||||
carcass.remove_from_group("carcass")
|
||||
butchered.emit(player, String(carcass.kind))
|
||||
for id in drops:
|
||||
var got := _give(player, id, int(drops[id]))
|
||||
if got < int(drops[id]):
|
||||
@@ -584,6 +602,7 @@ func reel(player: Node3D, world: Node3D) -> bool:
|
||||
if _give(player, caught, 1) == 0:
|
||||
world.drop_item(caught, 1, Transform3D(Basis(), player.global_position + Vector3(0, 0.1, 0)))
|
||||
notify.emit("Caught a %s" % ItemDB.item_name(caught).to_lower())
|
||||
emit_signal("caught", player, caught) # (the local `caught` hides the signal's name)
|
||||
return true
|
||||
|
||||
## Puts on the cloak in `slot` (swapping out any cloak you were wearing).
|
||||
@@ -642,8 +661,10 @@ func eat(player: Node3D, slot: int) -> bool:
|
||||
notify.emit("You're full")
|
||||
return false
|
||||
player.inventory.take_from(slot, 1)
|
||||
var eaten := String(s.id)
|
||||
player.survival.eat(food)
|
||||
notify.emit("Ate %s" % ItemDB.item_name(s.id).to_lower())
|
||||
notify.emit("Ate %s" % ItemDB.item_name(eaten).to_lower())
|
||||
ate.emit(player, eaten)
|
||||
# Raw meat and fish can make you ill (P4). Cooked, smoked or salted can't.
|
||||
if food_rng.randf() < float(food.get("risk", 0.0)):
|
||||
player.survival.poison()
|
||||
|
||||
Reference in New Issue
Block a user