• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

Solved How to drop/remove specific item on player death?

whitevo

Feeling good, thats what I do.
Joined
Jan 2, 2015
Messages
3,452
Solutions
1
Reaction score
626
Location
Estonia
Currently im using this:
doSetCreatureDropLoot
problem with this: it only has True or False values.

Bolded text is the things I don't know, how to do.

How can i make it so if player dies then:
Script checks the container:
Script removes following items:

RestorePotion

Script drops following items to player corpse:
Food
CollectingQuestItems
Projectiles

Script runs trough all the equipment items in his bag:
and drop all of them in bag, but with 20% chance that it is removed from game instead of drop.


Script goes trough his equipped gear and:
For all the items adds description [soulbound]
Lowers upgrade values by 0-2(%)
 
Code:
if math.random(1, 100) == 20 then
-- do something
end
I think should be

Code:
if math.random(1, 5) == 5 then
-- do something
end
 
Code:
if math.random(1, 100) == 20 then
-- do something
end
I think should be

Code:
if math.random(1, 5) == 5 then
-- do something
end
  • math.random(upper) generates integer numbers between 1 and upper.
  • math.random(lower, upper) generates integer numbers between lower and upper.
 
math.random(upper) generates integer numbers between 1 and upper.
Didn't know that :eek:

Btw, this issue of mine isn't solved yet.
Not only i don't know where should i write function, i don't know what functions i should use.
 
Code:
local ids = {
     removeids = {2112, 2152},
     addids = {2112, 2160}
}

local function doRemoveCorpseItems(pos)
     local thing, t = Tile(pos):getTopVisibleThing(), {}
     if thing:isItem() and thing:isContainer() then
         for i = 0, thing:getSize() - 1 do
             if thing:getItem(i):isContainer() then
                 local bp = thing:getItem(i)
                 for c = 0, bp:getSize() - 1 do
                     if isInArray(ids.removeids, bp:getItem(c):getId()) then
                         table.insert(t, bp:getItem(c))
                     end
                     if ItemType(bp:getItem(c):getId()):getArmor() > 0 then
                         if math.random(5) == 1 then
                             table.insert(t, bp:getItem(c))
                         end
                     end
                 end
             end
         end
         for r = 1, #t do
             t[r]:remove()
         end
     end
end

function onDeath(player, corpse, killer, mostDamageKiller, unjustified, mostDamageUnjustified)
     for a = 1, #ids.addids do
         Container(corpse):addItem(ids.addids[a], 1)
     end
     addEvent(doRemoveCorpseItems, 100, player:getPosition())
     return true
end
 
Back
Top