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

@@ -6,5 +6,5 @@ entrypoint=net.torvald.terrarum.musicplayer.EntryPoint
releasedate=2024-02-10 releasedate=2024-02-10
version=1.0.0 version=1.0.0
jar=MusicPlayer.jar jar=MusicPlayer.jar
jarhash=bd958d6d17b599a88fa34948a2d93ef47256d79f4556f558b2a3330c3c6cccff jarhash=8e0220165a235b16f99bc93d40135a92f126a574f2ab306520fc811ebbddb85d
dependency=basegame 0.4.0 dependency=basegame 0.4.0

View File

@@ -127,9 +127,23 @@ class ActorInventory() : FixtureInventory() {
// damage the item // damage the item
newItem.durability -= (baseDamagePerSwing * swingDmgToFrameDmg).toFloat() newItem.durability -= (baseDamagePerSwing * swingDmgToFrameDmg).toFloat()
if (newItem.durability <= 0) if (newItem.durability <= 0) {
remove(newItem, 1) 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}") //println("[ActorInventory] consumed; ${item.durability}")
} }
} }

View File

@@ -114,7 +114,7 @@ class UIItemInventoryElemWide(
batch.color = nameColour batch.color = nameColour
val hasSecondaryName = (item?.nameSecondary?.isNotBlank() == true) val hasSecondaryName = (item?.nameSecondary?.isNotBlank() == true)
val itemNameRow1Y = if (hasSecondaryName) 1f else if (item!!.maxDurability > 0.0) textOffsetY else ((height - App.fontGame.lineHeight) / 2).roundToFloat() val itemNameRow1Y = if (hasSecondaryName) 1f else if (/*item!!.isCurrentlyDynamic &&*/ item!!.maxDurability > 0.0) textOffsetY else ((height - App.fontGame.lineHeight) / 2).roundToFloat()
val itemNameRow2Y = App.fontGame.lineHeight.toInt() - 2*itemNameRow1Y val itemNameRow2Y = App.fontGame.lineHeight.toInt() - 2*itemNameRow1Y
// draw name of the item // draw name of the item
@@ -136,7 +136,7 @@ class UIItemInventoryElemWide(
val percentage = if (item!!.maxDurability < 0.00001f) 0f else item!!.durability / item!!.maxDurability val percentage = if (item!!.maxDurability < 0.00001f) 0f else item!!.durability / item!!.maxDurability
val durabilityCol = UIItemInventoryCellCommonRes.getHealthMeterColour(percentage, 0f, 1f) val durabilityCol = UIItemInventoryCellCommonRes.getHealthMeterColour(percentage, 0f, 1f)
val durabilityBack = durabilityCol mul UIItemInventoryCellCommonRes.meterBackDarkening val durabilityBack = durabilityCol mul UIItemInventoryCellCommonRes.meterBackDarkening
if (item!!.maxDurability > 0.0) { if (/*item!!.isCurrentlyDynamic &&*/ item!!.maxDurability > 0.0) { // it's more helpful for newly created tools to have durability meter
batch.color = durabilityBack batch.color = durabilityBack
Toolkit.drawStraightLine(batch, barOffset, posY + durabilityBarOffY, barOffset + barFullLen, durabilityBarThickness, false) Toolkit.drawStraightLine(batch, barOffset, posY + durabilityBarOffY, barOffset + barFullLen, durabilityBarThickness, false)
batch.color = durabilityCol batch.color = durabilityCol