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:
@@ -237,13 +237,22 @@ func _unhandled_input(event: InputEvent) -> void:
|
||||
return
|
||||
for i in range(8):
|
||||
if event.is_action_pressed("hotbar_%d" % (i + 1)):
|
||||
player.select(i)
|
||||
player.select_in_row(i)
|
||||
return
|
||||
if event.is_action_pressed("row_up"):
|
||||
player.change_row(-1)
|
||||
return
|
||||
if event.is_action_pressed("row_down"):
|
||||
player.change_row(1)
|
||||
return
|
||||
if event.is_action_pressed("drop"):
|
||||
Actions.drop(player, player.selected, 1 if Input.is_key_pressed(KEY_SHIFT) else 0)
|
||||
return
|
||||
if event is InputEventMouseButton and event.pressed and Input.mouse_mode == Input.MOUSE_MODE_CAPTURED:
|
||||
if event.button_index == MOUSE_BUTTON_WHEEL_UP:
|
||||
player.select(player.selected - 1)
|
||||
player.select_in_row(player.selected % player.HOTBAR - 1)
|
||||
elif event.button_index == MOUSE_BUTTON_WHEEL_DOWN:
|
||||
player.select(player.selected + 1)
|
||||
player.select_in_row(player.selected % player.HOTBAR + 1)
|
||||
if event.is_action_released("attack") and _drawing:
|
||||
_release_bow()
|
||||
return
|
||||
|
||||
@@ -49,10 +49,26 @@ func held_item_id() -> String:
|
||||
var s = inventory.get_slot(selected)
|
||||
return s.id if s != null else ""
|
||||
|
||||
## Holds the item in bag slot `i` (any slot: 1-8 pick from the current row,
|
||||
## K and M move between rows of 8).
|
||||
func select(i: int) -> void:
|
||||
selected = wrapi(i, 0, HOTBAR)
|
||||
selected = wrapi(i, 0, inventory.size())
|
||||
selected_changed.emit()
|
||||
|
||||
## The bag row (0 = the top) the 1-8 keys and the hotbar show.
|
||||
func row() -> int:
|
||||
return selected / HOTBAR
|
||||
|
||||
func rows() -> int:
|
||||
return inventory.size() / HOTBAR
|
||||
|
||||
## Column `col` of the current row; and the same column a row up or down.
|
||||
func select_in_row(col: int) -> void:
|
||||
select(row() * HOTBAR + wrapi(col, 0, HOTBAR))
|
||||
|
||||
func change_row(by: int) -> void:
|
||||
select(wrapi(row() + by, 0, rows()) * HOTBAR + selected % HOTBAR)
|
||||
|
||||
## Called by workbenches and chests (container = null for plain crafting).
|
||||
func open_inventory(container: Node) -> void:
|
||||
inventory_requested.emit(container)
|
||||
|
||||
@@ -274,6 +274,8 @@ func reset_after_death() -> void:
|
||||
func damage(amount: float, from: Vector3, by: String = "") -> void:
|
||||
if dead:
|
||||
return
|
||||
if player != null and player.get("inventory") != null:
|
||||
amount *= Actions.charm_mult(player.inventory, by) # (a fang necklace against wolves)
|
||||
cause = "Killed by %s" % by if not by.is_empty() else "You were killed"
|
||||
health = maxf(health - amount, 0.0)
|
||||
_hurt_cd = HURT_NO_REGEN
|
||||
|
||||
Reference in New Issue
Block a user