player now equips the item picked up, if said item did not exist in their inventory

This commit is contained in:
minjaesong
2024-07-12 03:00:42 +09:00
parent c1ca06c8e0
commit 5a4c300612

View File

@@ -169,8 +169,15 @@ open class DroppedItem : ActorWithBody {
fun onItemPickup(actor: ActorWithBody) {
flagDespawn = true
val actorHadTheSameItem = (actor as Pocketed).inventory.contains(itemID)
(actor as Pocketed).inventory.add(itemID, itemCount)
Terrarum.ingame!!.sendItemPickupNoticelet(itemID, itemCount)
ItemCodex[itemID]!!.effectOnPickup(actor)
// if actor did not have the same item AND holding nothing, equip it
val qs = actor.actorValue.getAsInt(AVKey.__PLAYER_QUICKSLOTSEL)
if (!actorHadTheSameItem && qs != null && (actor as Pocketed).inventory.getQuickslotItem(qs) == null) {
(actor as Pocketed).inventory.setQuickslotItem(qs, itemID)
}
}
}