Elwyn 106 #1 Posted April 21, 2015 Isso permite mais customização para a forma que o drop loot é feito, possibilitando inclusive loot rate diferenciadas a depender do player. Patch: https://gist.github.com/gugahoa/790f9e44a68b97bc033b (visualização no fim do post) Como aplicar:Linux: vá até o diretório onde ficam os sources do seu TFS (a raiz, onde fica o config.lua e o diretório src) e execute: patch -p1 -i <arquivo>.patch Windows: http://forums.otserv.com.br/index.php/topic/166757-como-aplicar-arquivos-patch/ (Copiei o LF, eu sei hahahaha) https://gist.github.com/gugahoa/790f9e44a68b97bc033b 1 1 G4RDENOT and hideonbush reacted to this Share this post Link to post
Elwyn 106 #2 Posted April 21, 2015 Para quem não sabe aplicar patch: Em creaturescripts.xml bote a tag: <event type="death" name="DropMonsterLoot" script="drop_monster_loot.lua"/> Crie um arquivo chamado drop_monster_loot.lua e cole o código: function onDeath(monster, corpse, killer, mostdamagekiller, lasthitunjustified, mostdamageunjustified) if not monster:isMonster() or monster:getMaster() then return true end if not corpse:isContainer() then return true end local owner = mostdamagekiller if killer and killer:isPlayer() then owner = killer end local modifier = 1 if owner and owner:isPlayer() then corpse:setAttribute(ITEM_ATTRIBUTE_OWNER, owner:getId()) end monster:getType():createLoot(corpse, 1) return true end Em events.xml bote a tag: <!-- Monster method --> <event class="Monster" method="onSpawn" enabled="1" /> Crie um arquivo chamado monster.lua na pasta scripts dentro da pasta events e cole o seguinte código: function Monster:onSpawn(pos, forced) self:registerEvent("DropMonsterLoot") return true end Na core, dentro da pasta lib, edite core.lua e adicione a linha: dofile('data/lib/core/monstertype.lua') Crie nessa mesma pasta um arquivo chamado monstertype.lua com o seguinte código: function MonsterType.createLoot(self, corpse, modifier) if not corpse then return end if configKeys.RATE_LOOT == 0 then return end local owner = Player(corpse:getAttribute(ITEM_ATTRIBUTE_OWNER)) if not owner or owner:getStamina() > 840 then for _, v in pairs(self:getLoot()) do 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 corpse:addItemEx(item) end else corpse:addItemEx(item, 1) end end end end 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) 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) owner:channelSay(nil, TALKTYPE_CHANNEL_O, loot_msg, 10) end end corpse:decay() end 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; end end 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 end return #lootTable == 0 and nil or lootTable end function MonsterType.createLootContainer(self, parent, lootBlock, modifier) if #lootBlock.childLoot == 0 then return true end 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 end return #parent > 0 end Em creature.cpp remova: if (corpse) { dropLoot(corpse->getContainer(), _lastHitCreature); } Substitua seu events.cpp, events.h e games.cpp por estes: https://gist.github.com/gugahoa/612cdfeb2519b82cd6a7 LEMBRANDO QUE SE TIVER DIFERENÇAS ENTRE OS SEUS events.cpp, events.h E game.cpp COPIE APENAS AS DIFERENÇAS ENTRE OS ARQUIVOS DE UM PARA O OUTRO! 1 lucassniper reacted to this Share this post Link to post