noshirtstan
New Member
- Joined
- Aug 2, 2020
- Messages
- 68
- Reaction score
- 2
Hey folks,
So my extra loot script won't drop the second item in the table.
Here is my code:
Any thoughts?
TFS 1.3
So my extra loot script won't drop the second item in the table.
Here is my code:
Lua:
local extra_loot = {
{hasName = "odibrand", items = {
{id = 26448, count = 10, chance = 100000, storage = 1, aid = 1}, -- 100% chance
}},
{items = {
{id = 26384, count = 1, chance = 100000, storage = 1, aid = 1}, -- 5% chance to drop common recipe
{id = 2160, count = 1, chance = 100000}
}},
}
function Container:addExtraLoot(c, t)
if t.hasName then
local cn = c:getName():lower()
local cm = t.hasName:lower()
if not cn:match(cm) then
return true
end
end
for i = 1, #t.items do
local count = 1
if t.items[i].count then
if t.items[i].countMax then
count = math.random(t.items[i].count, titems[i].countMax)
else
count = t.items[i].count
end
else
if t.items[i].countMax then
count = math.random(1, t.items[i].countMax)
end
end
if math.random(0, 100000) <= t.items[i].chance then -- Common Recipe Formula
local rndm = math.random(50501, 50506)
local rndm1 = math.random(101, 110)
local rndm2 = math.random(201, 211)
local rndm3 = math.random(301, 310)
local rndm4 = math.random(401, 410)
local rndm5 = math.random(501, 510)
local rndm6 = math.random(601, 610)
local item = self:addItem(t.items[i].id, count)
if t.items[i].storage and t.items[i].aid then
item:setAttribute(ITEM_ATTRIBUTE_ACTIONID, rndm)
if rndm == 50501 then
if t.items[i].id == 26384 then
item:setAttribute(ITEM_ATTRIBUTE_TEXT, rndm1)
item:setAttribute(ITEM_ATTRIBUTE_NAME, "Common Blacksmithing Recipe")
return true
elseif t.items[i].id == 26447 then
item:setAttribute(ITEM_ATTRIBUTE_TEXT, rndm1)
item:setAttribute(ITEM_ATTRIBUTE_NAME, "Rare Blacksmithing Recipe")
return true
elseif t.items[i].id == 26448 and t.items[i].hasName == "odibrand" then
item:setAttribute(ITEM_ATTRIBUTE_TEXT, math.random(901, 906))
item:setAttribute(ITEM_ATTRIBUTE_NAME, "Boss Blacksmithing Recipe")
return true
end
end
if rndm == 50502 then
item:setAttribute(ITEM_ATTRIBUTE_TEXT, rndm2)
item:setAttribute(ITEM_ATTRIBUTE_NAME, "Common Alchemy Recipe")
return true
end
if rndm == 50503 then
item:setAttribute(ITEM_ATTRIBUTE_TEXT, rndm3)
item:setAttribute(ITEM_ATTRIBUTE_NAME, "Common Inscription Recipe")
return true
end
if rndm == 50504 then
item:setAttribute(ITEM_ATTRIBUTE_TEXT, rndm4)
item:setAttribute(ITEM_ATTRIBUTE_NAME, "Common Tailoring Recipe")
return true
end
if rndm == 50505 then
item:setAttribute(ITEM_ATTRIBUTE_TEXT, rndm5)
item:setAttribute(ITEM_ATTRIBUTE_NAME, "Common Leatherworking Recipe")
return true
end
if rndm == 50506 then
item:setAttribute(ITEM_ATTRIBUTE_TEXT, rndm6)
item:setAttribute(ITEM_ATTRIBUTE_NAME, "Common Engineering Recipe")
return true
end
return true
end
return true
end
return true
end
return true
end
function onDeath(creature, corpse, killer, mostDamage, unjustified, mostDamage_unjustified)
if not creature:isMonster() then return true end
if corpse and corpse:isContainer() then
for i = 1, #extra_loot do
corpse:addExtraLoot(creature, extra_loot[i])
end
end
return true
end
Any thoughts?
TFS 1.3