Ir para conteúdo

Featured Replies

Postado

@MatCollier Vai ficar assim.

function Player:onGainExperience(source, exp, rawExp) 

if getPlayerStorageValue(cid, stor) >= 0 then
local stor = 12345 -- storage
    -- Apply rarity chance to corpse contents
       find_loot_Container(corpse:getPosition())
     
       -- Print loot list to Server Log
       if owner then
           local loot_msg = "Loot of " .. self:getNameDescription() .. ": " .. corpse:getContentDescription()

           if owner:getParty() then
               owner:getParty():broadcastLoot(loot_msg)
               owner:getParty():broadcastChannelLoot(loot_msg)
           else
               owner:sendTextMessage(MESSAGE_INFO_DESCR, loot_msg)
               -- Loot channel un-used on my server.
               -- owner:channelSay(nil, TALKTYPE_CHANNEL_O, loot_msg, 10)
           end
       end
   else
       local loot_msg = "Loot of " .. self:getNameDescription() .. ": nothing (due to low stamina)"

       if owner:getParty() then
           owner:getParty():broadcastLoot(loot_msg)
           owner:getParty():broadcastChannelLoot(loot_msg)
       else
           owner:sendTextMessage(MESSAGE_INFO_DESCR, loot_msg)
       end
   
local corpse:decay() = corpse:decay()
function MonsterType.createLootItem(self, lootBlock, modifier)
   local lootTable = {}
   local itemCount = 0
   local randvalue = math.random(0, 100000) / (configManager.getNumber(configKeys.RATE_LOOT) * modifier);
      if randvalue < lootBlock.chance then
       if (ItemType(lootBlock.itemId):isStackable()) then
           itemCount = randvalue % lootBlock.maxCount + 1;
       else
           itemCount = 1;
   while (itemCount > 0) do
       local n = math.min(itemCount, 100)
       itemCount = itemCount - n

       local item = Game.createItem(lootBlock.itemId, n)

       if item then
           if lootBlock.subType ~= -1 then
               item:transform(lootBlock.itemId, lootBlock.subType)
           end

           if lootBlock.actionId ~= -1 then
               item:setActionId(lootBlock.actionId)
           end

           if lootBlock.text and lootBlock.text ~= "" then
               item:setAttribute(ITEM_ATTRIBUTE_TEXT, lootBlock.text)
           end

           table.insert(lootTable, item)
       end
   

   return #lootTable == 0 and nil or lootTable
function MonsterType.createLootContainer(self, parent, lootBlock, modifier)
   if #lootBlock.childLoot == 0 then
       return true
   

   for _, v in pairs(lootBlock.childLoot) do
       if parent:getSize() < parent:getCapacity() then
           local itemList = self:createLootItem(v, modifier)
           if itemList then
               for _, item in ipairs(itemList) do
                   if item:isContainer() then
                       local lootContainer = self:createLootContainer(item, v, modifier)
                       if lootContainer then
                           parent:addItemEx(item)
                       end
                   else
                       parent:addItem(item, 1)
                   end
               end
           end
       end
   
   return #parent > 0
end
	return true
	end
	end
	end
	end
	end
	end
	end

	return exp

end

	
  • Respostas 24
  • Visualizações 1.2k
  • Created
  • Última resposta

Top Posters In This Topic

Most Popular Posts

  • luanluciano93
    luanluciano93

    Resultado sobre o que pesquisei ...  Em data/events/scripts/monster.lua tem uma função que pelo que me parece gera o loot do monstro:  function Monster:onDropLoot(corpse) if configManager.getN

  • luanluciano93
    luanluciano93

Posted Images

Postado

Este valor 10000 = %10

Postado

10000*10 = 100%@MatCollier 

 local randvalue = math.random(0, 100000*10)

Participe da conversa

Você pode postar agora e se cadastrar mais tarde. Se você tem uma conta, faça o login para postar com sua conta.

Visitante
Responder

Quem Está Navegando 0

  • Nenhum usuário registrado visualizando esta página.

Conteúdo Similar

Estatísticas dos Fóruns

  • Tópicos 96.9k
  • Posts 519.7k

Informação Importante

Confirmação de Termo