• 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!

Lua [0.3.7] Rare/Epic script for loot.

Dibis

Member
Joined
Dec 1, 2022
Messages
73
Reaction score
16
Location
POLAND
Hello.
I need script creatureevents.
When I kill monster on corpose position send text "RARE" or send magic effect, when item have > 1000 chance to loot or if item is located on special list in script.

Will such a script slow down the server a lot?
 
I can go this since I don't have 0.4 files on my pc and I'm on the phone RN but u can take this as a hint and it's easy to be converted caus it works with my friend
Lua:
local special_items = {
    -- list of special items
}

function onKill(creature, target)
    local corpse = Tile(target:getPosition()):getTopDownItem()
    if corpse then
        local item = corpse:getItem()
        if item:getChance() > 1000 or table.contains(special_items, item:getId()) then
            creature:say("RARE", TALKTYPE_MONSTER_SAY)
            target:getPosition():sendMagicEffect(CONST_ME_MAGIC_GREEN)
        end
    end
    return true
end
 
use this
 
use this
He don't need add new bonuses etc.
He need script send magic effect on corpose when in loot have etc: Magic Plate Armor...
 
All working good, but sometimes not send a magic effect. Not found item in corpose.
What is a problem? Help Please...

Lua:
RARE_ITEMS = {2148,5890}

function getTopItem(p) -- from Darkhaos's arena script
    p.stackpos = 0
    local v = getThingFromPos(p)
    repeat
        p.stackpos = p.stackpos + 1
        v = getThingFromPos(p)
    until v.itemid == 0
    p.stackpos = p.stackpos - 1
    return getThingFromPos(p)
end


function scanCorpseLoot(cid, pos)
    local corpse = getTopItem(pos)
    if isContainer(corpse.uid) then
        for n = (getContainerSize(corpse.uid) - 1), 0, -1 do
            if isInArray(RARE_ITEMS, getContainerItem(corpse.uid, n).itemid) then
                addEvent(warningRareLoot, 400, pos, 1)
                addEvent(warningRareLoot, 4000, pos, 1)
                addEvent(warningRareLoot, 8000, pos, 1)
                break
            end
        end
    end
end

function warningRareLoot(pos, rtype)
    if rtype == 1 then
        doSendAnimatedText(pos, "RARE LOOT", TEXTCOLOR_ORANGE)
        doSendMagicEffect(pos, 56) -- azul
    end
end



function onKill(cid, target, lastHit)
    if isMonster(target) then
        addEvent(scanCorpseLoot, 150, cid, getThingPos(target))
    end
    return true
end
Post automatically merged:

I can go this since I don't have 0.4 files on my pc and I'm on the phone RN but u can take this as a hint and it's easy to be converted caus it works with my friend
Lua:
local special_items = {
    -- list of special items
}

function onKill(creature, target)
    local corpse = Tile(target:getPosition()):getTopDownItem()
    if corpse then
        local item = corpse:getItem()
        if item:getChance() > 1000 or table.contains(special_items, item:getId()) then
            creature:say("RARE", TALKTYPE_MONSTER_SAY)
            target:getPosition():sendMagicEffect(CONST_ME_MAGIC_GREEN)
        end
    end
    return true
end


How I can add this function to TFS 0.3.7?
if item:getChance() > 1000 or table.contains(special_items, item:getId()) then

I need, becouse good options to set ifgetChance > 600 for RARE LOOT, not write ID to list.
 
Back
Top