autoequip consumable tool

This commit is contained in:
minjaesong
2024-02-11 22:59:06 +09:00
parent 57d25431bd
commit 49c595319b
3 changed files with 18 additions and 4 deletions

View File

@@ -127,9 +127,23 @@ class ActorInventory() : FixtureInventory() {
// damage the item
newItem.durability -= (baseDamagePerSwing * swingDmgToFrameDmg).toFloat()
if (newItem.durability <= 0)
if (newItem.durability <= 0) {
remove(newItem, 1)
// auto pull the same item if the player has one
(actor as Pocketed).inventory.let { inv ->
inv.itemList.filter { ItemCodex[it.itm]?.originalID == newItem.originalID }.firstOrNull()?.let { (itm, qty) ->
println("AutoEquip item $itm")
actor.equipItem(itm)
// also unequip on the quickslot
actor.actorValue.getAsInt(AVKey.__PLAYER_QUICKSLOTSEL)?.let {
setQuickslotItem(it, itm)
}
}
}
}
//println("[ActorInventory] consumed; ${item.durability}")
}
}