Oldesta
Active Member
- Joined
- Dec 16, 2024
- Messages
- 190
- Reaction score
- 38
When I kill monsters, I get the loot message ONLY if there is no loot being dropped.
As an example "Loot of a dog: nothing".
But, if loot drops (from any monster), then I get no lootmessage and the monster freeze on its spot too.
I think it is related to my default_onDropLoot.lua script.
I just can't figure out what part of it:
As an example "Loot of a dog: nothing".
But, if loot drops (from any monster), then I get no lootmessage and the monster freeze on its spot too.
I think it is related to my default_onDropLoot.lua script.
I just can't figure out what part of it:
LUA:
local ec = EventCallback
-- Rarity Animations
local rare_popup = false
local rare_effect = false
local rare_effect_id = 71
ec.onDropLoot = function(self, corpse)
if configManager.getNumber(configKeys.RATE_LOOT) == -1 then
return
end
local player = Player(corpse:getCorpseOwner())
local mType = self:getType()
if not player or player:getStamina() > 840 then
if not configManager.getBoolean(configKeys.MONSTERS_SPAWN_WITH_LOOT) then
local lootBag = Game.createItem(1987, 1)
corpse:addItemEx(lootBag)
local monsterLoot = mType:getLoot()
for i = 1, #monsterLoot do
local itemType = ItemType(monsterLoot[i].itemId)
if itemType:getWeaponType() == WEAPON_SHIELD or itemType:getWeaponType() == WEAPON_WAND or
itemType:getWeaponType() == WEAPON_DISTANCE or itemType:getDuration() > 0 or
itemType:getCharges() > 0 or itemType:hasStopDuration() then
local item = lootBag:createLootItem(monsterLoot[i])
if not item then
print('[Warning] DropLoot:', 'Could not add loot item to loot bag.')
end
else
local item = corpse:createLootItem(monsterLoot[i])
if not item then
print('[Warning] DropLoot:', 'Could not add loot item to corpse.')
end
end
end
if lootBag:getSize() == 0 then
lootBag:remove()
end
end
-- Apply rarity chance to corpse contents and apply animation
if rollRarity(corpse) > 0 then -- If a rare item was rolled, play animation
if rare_popup then
local spectators = Game.getSpectators(corpse:getPosition(), false, true, 7, 7, 5, 5)
for i = 1, #spectators do
spectators[i]:say(rare_text, TALKTYPE_MONSTER_SAY, false, spectators[i], corpse:getPosition())
end
end
if rare_effect then
corpse:getPosition():sendMagicEffect(rare_effect_id)
end
end
if configManager.getBoolean(configKeys.SHOW_MONSTER_LOOT_MESSAGE) then
if player then
player:updateKillTracker(self, corpse)
local text = ("Loot of %s: %s"):format(mType:getNameDescription(), corpse:getContentDescription())
local party = player:getParty()
if party then
party:broadcastPartyLoot(text)
else
player:sendTextMessage(MESSAGE_EVENT_ADVANCE, text)
end
end
end
elseif configManager.getBoolean(configKeys.SHOW_MONSTER_LOOT_MESSAGE) then
local text = ("Loot of %s: nothing (due to low stamina)"):format(mType:getNameDescription())
local party = player:getParty()
if party then
party:broadcastPartyLoot(text)
else
player:sendTextMessage(MESSAGE_EVENT_ADVANCE, text)
end
end
end
ec:register()
