Skip to content
This repository has been archived by the owner on May 20, 2023. It is now read-only.

Commit

Permalink
Feat: Colorful Loot (#969)
Browse files Browse the repository at this point in the history
  • Loading branch information
FakeShinoda committed Apr 1, 2020
1 parent 29a0e9d commit 92fc45e
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 53 deletions.
9 changes: 3 additions & 6 deletions data/creaturescripts/scripts/rewardChest/boss.lua
Expand Up @@ -173,15 +173,12 @@ function onDeath(creature, corpse, killer, mostDamageKiller, lastHitUnjustified,
end
if con.player and con.score ~= 0 then
local lootMessage = {"The following items are available in your reward chest: "}
local lootMessage = ("The following items dropped by %s are available in your reward chest: %s"):format(creature:getName(), reward:getContentDescription())
if --[[stamina > 840]]true then
if stamina > 840 then
reward:getContentDescription(lootMessage)
else
table.insert(lootMessage, 'nothing (due to low stamina)')
end
table.insert(lootMessage, ".")
con.player:sendTextMessage(MESSAGE_INFO_DESCR, table.concat(lootMessage))
con.player:sendTextMessage(MESSAGE_LOOT, lootMessage)
elseif con.score ~= 0 then
insertRewardItems(con.guid, timestamp, playerLoot)
end
Expand Down
46 changes: 0 additions & 46 deletions data/lib/miscellaneous/reward_boss.lua
Expand Up @@ -30,51 +30,6 @@ local function pushValues(buffer, sep, ...)
end
end

function Item.getNameDescription(self)
local subType = self:getSubType()
local itemType = self:getType()

local buffer = {}

local name = self:getName() or ''
if(#name ~= 0) then
if(itemType:isStackable() and subType > 1) then
pushValues(buffer, ' ', subType, self:getPluralName())
else
local article = self:getArticle() or ''
pushValues(buffer, ' ', select(#article ~= 0 and 1 or 2, article, name))
end
else
pushValues(buffer, ' ', 'an item of type', self:getId())
end

return table.concat(buffer)
end

function Container.getContentDescription(self, outputBuffer)
local firstItem = true
local buffer = outputBuffer or {}
for i = 1, self:getSize() do
local item = self:getItem(i - 1)

if(firstItem) then
firstItem = false
else
table.insert(buffer, ", ")
end

table.insert(buffer, item:getNameDescription())
end

if firstItem then
table.insert(buffer, "nothing")
end

if not outputBuffer then
return table.concat(buffer)
end
end

function Player.getRewardChest(self, autocreate)
return self:getDepotChest(99, autocreate)
end
Expand All @@ -94,7 +49,6 @@ function Player.inBossFight(self)
return false
end

-- by https://otland.net/members/cbrm.25752/ with some modifications
function MonsterType.createLootItem(self, lootBlock, chance, lootTable)
local lootTable, itemCount = lootTable or {}, 0
local randvalue = math.random(0, 100000) / (getConfigInfo("rateLoot") * chance)
Expand Down
2 changes: 1 addition & 1 deletion src/container.cpp
Expand Up @@ -202,7 +202,7 @@ std::ostringstream& Container::getContentDescription(std::ostringstream& os) con
os << ", ";
}

os << item->getNameDescription();
os << "{" << item->getClientID() << "|" << item->getNameDescription() << "}";
}

if (firstitem) {
Expand Down

0 comments on commit 92fc45e

Please sign in to comment.