The engine don't give any errors
data/events/scripts/monster.lua
Monsters dont drop any loot
data/scripts/eventcallbacks/monster/default_onDropLoot
HELP ME
data/events/scripts/monster.lua
LUA:
function Monster:onDropLoot(corpse)
if hasEventCallback(EVENT_CALLBACK_ONDROPLOOT) then
EventCallback(EVENT_CALLBACK_ONDROPLOOT, self, corpse)
end
end
function Monster:onSpawn(position, startup, artificial)
if hasEventCallback(EVENT_CALLBACK_ONSPAWN) then
return EventCallback(EVENT_CALLBACK_ONSPAWN, self, position, startup, artificial)
else
return true
end
end
if configManager.getNumber(configKeys.RATE_LOOT) == 0 then
return
end
local player = Player(corpse:getCorpseOwner())
if not player or player:getStamina() <= 840 then
local monsterLoot = mType:getLoot()
local percentLoot = 0
if player:getStorageValue(STORAGEVALUE_LOOT_TEMPO) > os.time() then
local potion = lootPotion[player:getStorageValue(STORAGEVALUE_LOOT_ID)]
if potion then
percentLoot = potion.exp / 100
end
end
local percent = 0
if mType:getName():lower() == boostCreature[1].name:lower() then
percent = boostCreature[1].loot / 100
end
for i = 1, #monsterLoot do
monsterLoot[i].chance = monsterLoot[i].chance + (monsterLoot[i].chance * percent) + (monsterLoot[i].chance * percentLoot)
local item = corpse:createLootItem(monsterLoot[i])
if not item then
print(string.format('[Warning] DropLoot: Could not add loot item to corpse. [Monster: %s]', mType:getName()))
end
end
if player then
local text = ("Loot de %s: %s"):format(mType:getNameDescription(), corpse:getContentDescription())
local party = player:getParty()
if party then
party:broadcastPartyLoot(text)
else
if player:getStorageValue(STORAGEVALUE_LOOT) == 1 then
sendChannelMessage(11, TALKTYPE_CHANNEL_O, text)
else
player:sendTextMessage(MESSAGE_INFO_DESCR, text)
end
end
end
else
local text = ("Loot de %s: nothing (due to low resistance)"):format(mType:getNameDescription())
local party = player:getParty()
if party then
party:broadcastPartyLoot(text)
else
if player:getStorageValue(STORAGEVALUE_LOOT) == 1 then
sendChannelMessage(11, TALKTYPE_CHANNEL_O, text)
else
player:sendTextMessage(MESSAGE_INFO_DESCR, text)
end
end
end
end
function Monster:onSpawn(position, startup, artificial)
return true
end
Monsters dont drop any loot
data/scripts/eventcallbacks/monster/default_onDropLoot
Code:
local ec = EventCallback
ec.onDropLoot = function(self, corpse)
if configManager.getNumber(configKeys.RATE_LOOT) == 0 then
return
end
local player = Player(corpse:getCorpseOwner())
local mType = self:getType()
if not player or player:getStamina() > 840 then
local monsterLoot = mType:getLoot()
for i = 1, #monsterLoot do
local item = corpse:createLootItem(monsterLoot[i])
if not item then
print('[Warning] DropLoot:', 'Could not add loot item to corpse.')
end
end
if player then
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_INFO_DESCR, text)
end
end
else
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_INFO_DESCR, text)
end
end
end
ec:register()