Uses for every material (clay jar, bedroll, pelt rug, fang necklace, bear cloak, pemmican, bait), Q to drop, K/M bag rows on 1-8, help pages; protocol 14
This commit is contained in:
@@ -31,6 +31,9 @@ func _ready() -> void:
|
||||
_bind("inventory", [KEY_TAB, KEY_I])
|
||||
_bind("rotate_piece", [KEY_R])
|
||||
_bind("dismantle", [KEY_X])
|
||||
_bind("drop", [KEY_Q]) # (shift+Q drops just one)
|
||||
_bind("row_up", [KEY_K]) # the 1-8 keys pick from the bag row above...
|
||||
_bind("row_down", [KEY_M]) # ...or below
|
||||
for i in range(8):
|
||||
_bind("hotbar_%d" % (i + 1), [KEY_1 + i])
|
||||
_bind_mouse("attack", MOUSE_BUTTON_LEFT)
|
||||
@@ -736,8 +739,53 @@ static func harvest_sound(tool_kind: String, felled: bool) -> String:
|
||||
|
||||
## A piece going down: wood, stone, or something soft.
|
||||
static func place_sound(id: String) -> String:
|
||||
if id.contains("stone") or id in ["campfire", "forge", "hearth", "stonecutter"]:
|
||||
if id.contains("stone") or id.contains("jar") or id in ["campfire", "forge", "hearth", "stonecutter"]:
|
||||
return "place_stone"
|
||||
if id.contains("rug") or id.contains("bed") or id == "smoking_rack":
|
||||
return "place_soft"
|
||||
return "place_wood"
|
||||
|
||||
# --- charms and bait ------------------------------------------------------------------
|
||||
|
||||
## A charm carried anywhere in the bag (the fang necklace: {"against": "wolf",
|
||||
## "damage": 0.7}) takes the edge off hits from what it's against. `by` is the
|
||||
## hit's "a wolf" / "a alpha wolf" / "a spirit wolf" (survival.damage).
|
||||
static func charm_mult(inv: Inventory, by: String) -> float:
|
||||
var m := 1.0
|
||||
if by.is_empty():
|
||||
return m
|
||||
for s in inv.slots:
|
||||
if s == null:
|
||||
continue
|
||||
var c: Dictionary = ItemDB.get_item(String(s.id)).get("charm", {})
|
||||
if not c.is_empty() and by.to_lower().contains(String(c.get("against", "?"))):
|
||||
m = minf(m, float(c.get("damage", 1.0)))
|
||||
return m
|
||||
|
||||
const BAIT := "rotten_food"
|
||||
const BAIT_WAIT := 0.6 ## carried while fishing: bites come this much sooner
|
||||
|
||||
## Drops the stack in `slot` (or `count` of it) at your feet, a little in
|
||||
## front (Q drops what's in your hand). Online the server does it, for everyone.
|
||||
func drop(player: Node3D, slot: int, count: int = 0) -> bool:
|
||||
if _online():
|
||||
return _ask("drop", [slot, count])
|
||||
var s = player.inventory.get_slot(slot)
|
||||
if s == null:
|
||||
return false
|
||||
var n: int = int(s.count) if count <= 0 else mini(count, int(s.count))
|
||||
# (on a server the player is a proxy under PlayerNet, not a child of the world)
|
||||
var world: Node = WorldNet.world if Net.is_server() else player.get_parent()
|
||||
if world == null or not world.has_method("drop_item"):
|
||||
return false
|
||||
var fwd: Vector3 = -player.global_basis.z
|
||||
fwd.y = 0.0
|
||||
var at: Vector3 = player.global_position + fwd.normalized() * 0.9
|
||||
at.y = world.terrain.sample_height(at.x, at.z) + 0.05 if world.get("terrain") != null else player.global_position.y
|
||||
var extra := Inventory.extra_of(s)
|
||||
if world.drop_item(String(s.id), n, Transform3D(Basis(), at), extra) == null:
|
||||
return false
|
||||
player.inventory.take_from(slot, n)
|
||||
Sfx.at("pickup", at)
|
||||
notify.emit("Dropped %d %s" % [n, ItemDB.item_name(String(s.id))])
|
||||
return true
|
||||
|
||||
Reference in New Issue
Block a user