• 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!
  • 2026 staff recruitment is open! Check it out and consider applying!

TFS 0.X EXP BUG Event --- remaster for 0.3.7 otx 2.16

tuduras

Well-Known Member
Joined
Jun 4, 2017
Messages
340
Solutions
2
Reaction score
58
Hello. is possible rewrite MOD scirpt to otx based on 0.3.7 ?? MOD is exp bug
I tried few option and few mod but occurs error.
HERE post /data/MOD
LUA:
<?xml version='1.0' encoding='UTF-8'?>
<mod name='Bug_Event' version='3.0' enabled='yes'>
    <config name="Bug_config">
        <![CDATA[
            bugConfig = {
                BUG = {
                   
                   
                    ['EXP Bug'] = {
                        experience = 1,
                        rewardID = {
                                    {{1, 50000}, {11230, 2}},         -- 1 ivorka
                                    {{50001, 100000}, {7443, 1}}
                                    },
                        resp = true,  -- czy ma go tworzyc automatycznie (globaleventem nizej)
                        storage = 355345,
                        secondstorage = 355343,
                        appearEffect = CONST_ME_ICETORNADO
                    }
           
                   
                   
                },
               
           
                positionsX = {
                    {x=130,y=69,z=7}, --lewy gorny rog
                    {x=130,y=69,z=7}, --lewy gorny rog
                    {x=130,y=69,z=7}, --lewy gorny rog
                        {x=130,y=69,z=7}, --prawy dolny ro
                    {x=130,y=69,z=7} --lewy gorny rog
                },

                maxTopPlayery = 300,
                maxDistancexx = 7,
                maxBUG = 2,
                storage = 355342
            }

            summony = {
           
               
                ['EXP Bug'] = {
                    {90,{'Undead Jester', 'Undead Jester', 'Undead Jester', 'Undead Jester', 'Undead Jester', 'Undead Jester', 'Undead Jester', 'Undead Jester'}},
                    {70,{'Undead Jester', 'Undead Jester', 'Undead Jester', 'Undead Jester', 'Undead Jester', 'Undead Jester', 'Undead Jester', 'Undead Jester'}},
                    {50,{'Undead Jester', 'Undead Jester', 'Undead Jester', 'Undead Jester', 'Undead Jester', 'Undead Jester', 'Undead Jester', 'Undead Jester'}},
                    {30,{'Undead Jester', 'Undead Jester', 'Undead Jester', 'Undead Jester', 'Undead Jester', 'Undead Jester', 'Undead Jester', 'Undead Jester'}},
                    {10,{'Undead Jester', 'Undead Jester', 'Undead Jester', 'Undead Jester', 'Undead Jester', 'Undead Jester', 'Undead Jester', 'Undead Jester'}},
                    {60,{'Undead Jester', 'Undead Jester', 'Undead Jester', 'Undead Jester', 'Undead Jester', 'Undead Jester', 'Undead Jester', 'Undead Jester'}},
                    {5,{'Undead Jester', 'Undead Jester', 'Undead Jester', 'Undead Jester', 'Undead Jester', 'Undead Jester', 'Undead Jester', 'Undead Jester'}},
                    {4,{'Undead Jester', 'Undead Jester', 'Undead Jester', 'Undead Jester', 'Undead Jester', 'Undead Jester', 'Undead Jester', 'Undead Jester'}},
                    {3,{'Undead Jester', 'Undead Jester', 'Undead Jester', 'Undead Jester', 'Undead Jester', 'Undead Jester', 'Undead Jester', 'Undead Jester'}},
                    {0, {}}
                }
            }
           
            u = 0
        ]]>
    </config>


<lib name="Bug_lib">
        <![CDATA[          
            function getsummonyToSummon(pctHealth, x, storage, cid)
                local summon = {}

                for i = 2, #x do
                    if pctHealth >= x[i][1] and pctHealth < x[i - 1][1] then
                        if getCreatureStorage(cid, storage) ~= i - 1 then
                            local l, v = i - 1, 0
                            for j = getCreatureStorage(cid, storage), l do
                                for _, name in pairs(x[j][2]) do
                                    table.insert(summon, name)
                                end
                                v = v + 1
                            end
                            doCreatureSetStorage(cid, storage, getCreatureStorage(cid, storage) + v)
                            return summon
                        else
                            for _, name in pairs(x[i - 1][2]) do
                                table.insert(summon, name)
                            end
                            doCreatureSetStorage(cid, storage, getCreatureStorage(cid, storage) + 1)
                            return summon
                        end
                    end
                end
                return summon
            end
           
           
           
   
            function doSendMagicEffectInArea(pos, effect, area) -- Function by mock
                local centro = {}
                centro.y = math.floor(#area / 2) + 1
                for y = 1, #area do
                    for x = 1, #area[y] do
                        if area[y][x] > 0 then
                            centro.x = math.floor(#area[y] / 2) + 1
                            doSendMagicEffect({x=pos.x+x-centro.x, y=pos.y+y-centro.y, z=pos.z}, (effect or 0))
                        end
                    end
                end
                return true
            end
           
            function addDamageToArea(pos, area) -- Function by mock
                local centro = {}
                centro.y = math.floor(#area / 2) + 1
                for y = 1, #area do
                    for x = 1, #area[y] do
                        if area[y][x] > 0 then
                            centro.x = math.floor(#area[y] / 2) + 1
                            local t = getThingfromPos({x=pos.x+x-centro.x, y=pos.y+y-centro.y, z=pos.z, stackpos=253}).uid
                            if isPlayer(t) then
                                doCreatureAddHealth(t, - (getCreatureMaxHealth(t) * 1 / 100))
                                doCreatureAddMana(t, - (getCreatureMaxMana(t) * 1 / 100))
                            end
                            doSendMagicEffect({x=pos.x+x-centro.x, y=pos.y+y-centro.y, z=pos.z}, 34)
                        end
                    end
                end
                return true
            end          
           
            function doCleanArea(pos, area) -- Function by mock
                local centro = {}
                centro.y = math.floor(#area / 2) + 1
                for y = 1, #area do
                    for x = 1, #area[y] do
                        if area[y][x] > 0 then
                            centro.x = math.floor(#area[y] / 2) + 1  
                            local i = getTileItemByType({x=pos.x+x-centro.x, y=pos.y+y-centro.y, z=pos.z}, ITEM_TYPE_MAGICFIELD)
                            if i.uid > 0 then
                                doRemoveItem(i.uid)
                            end
                        end
                    end
                end
                return true
            end
        ]]>
    </lib>

    <globalevent name="Summon_Bug" interval="3600000" event="script">
        <![CDATA[
            domodlib("Bug_config")
            domodlib("Bug_lib")

            local area = {
                {1, 1, 1},
                {1, 1, 1},
                {1, 1, 1}
            }

            function onThink(interval, lastExecution)
                local names, BUGSum = {}, {}
               
                for k, v in pairs(bugConfig.BUG) do
                    if getStorage(v.storage) <= 0 then
                        if v.resp then
                            table.insert(names, k)
                        end
                    end
                end
               
                if #names == 0 then
                    return false
                end
               
                local pos, name = bugConfig.positionsX[math.random(#bugConfig.positionsX)], names[math.random(#names)]
               
                if getStorage(bugConfig.storage) < 0 then
                    doSetStorage(bugConfig.storage, 0)
                end
               
                if getStorage(bugConfig.storage) + 1 > bugConfig.maxBUG then
                    for o, p in pairs(bugConfig.BUG) do
                        if getStorage(p.storage) == 1 then
                            table.insert(BUGSum, o)
                        end
                    end
                   
                    if #BUGSum == 0 then
                        if u ~= 1 then
                            doSetStorage(bugConfig.storage, 0)
                            u = 1
                        end
                    else                  
                        local rand = math.random(#BUGSum)
                        local mon = getCreatureByName(BUGSum[rand])
                        if isCreature(mon) then
                            doSendMagicEffect(getThingPos(mon), 10)
                            doSetStorage(bugConfig.BUG[BUGSum[rand]].storage, 0)
                            doSetStorage(bugConfig.BUG[BUGSum[rand]].secondstorage, 1)
                            doSetStorage(bugConfig.storage, getStorage(bugConfig.storage) - 1)

                            doRemoveCreature(mon)
                            table.remove(BUGSum, rand)
                        end
                    end
                end

                local monsters = doCreateMonster(name, pos, true, true, false)
                if type(monsters) == "number" then
                    doSendMagicEffectInArea(getThingPos(monsters), bugConfig.BUG[name].appearEffect, area)

                    doBroadcastMessage(name..' have been spawn. Find and defeat it.', MESSAGE_STATUS_WARNING)
                    doCreatureSetStorage(monsters, bugConfig.BUG[name].secondstorage, 1)

                    doSetStorage(bugConfig.BUG[name].storage, 1)
                    doSetStorage(bugConfig.storage, getStorage(bugConfig.storage) + 1)
                end

                return true
            end
        ]]>
    </globalevent>

<event type="statschange" name="BugStatsChange_Event" event="script">
        <![CDATA[          
            function onStatsChange(cid, attacker, type, combat, value)
                local stor = 355342
                if #getCreatureSummons(cid) > 0 and value > 0 and type == 1 then
                    if isPlayer(attacker) then
                        if exhaustion.check(attacker, stor) ~= true then
                            doPlayerSendTextMessage(attacker, MESSAGE_STATUS_CONSOLE_BLUE, 'You have to kill EXP Bug\'s summons until you will be able to kill it.')
                            exhaustion.set(attacker, stor, 5)
                        end
                    end
                    return false
                end              
                return true
            end          
        ]]>
    </event>

    <event type="think" name="BugThink_Event" event="script">
        <![CDATA[
            domodlib("Bug_config")
            domodlib("Bug_lib")
           
            local area = {
                {1, 0, 0, 1, 0, 0, 1},
                {0, 0, 1, 1, 1, 0, 0},
                {0, 1, 1, 1, 1, 1, 0},
                {1, 1, 1, 1, 1, 1, 1},
                {0, 1, 1, 1, 1, 1, 0},
                {0, 0, 1, 1, 1, 0, 0},
                {1, 0, 0, 1, 0, 0, 1}
            }
           
            local cleanArea = {
                {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1},
                {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1},
                {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1},
                {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1},
                {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1},
                {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1},
                {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1},
                {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1},
                {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1},
                {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1},
                {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1},
                {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1},
                {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1},
                {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1},
                {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1},
                {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1},
                {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}
            }

            function onThink(cid, interval)
                local xTable, pct = summony[getCreatureName(cid)], getCreatureHealth(cid) / getCreatureMaxHealth(cid) * 100

                if not xTable then
                    return false
                end
               
                if getCreatureStorage(cid, bugConfig.BUG[getCreatureName(cid)].secondstorage) <= 0 then
                    doCreatureSetStorage(cid, bugConfig.BUG[getCreatureName(cid)].secondstorage, 1)
                end

                table.sort(xTable, function(a, b) return a[1] > b[1] end)

                local summonyToSumm = getsummonyToSummon(pct, xTable, bugConfig.BUG[getCreatureName(cid)].secondstorage, cid)

                if #summonyToSumm ~= 0 then
                    doCleanArea(getThingPos(cid), cleanArea)
                    addDamageToArea(getThingPos(cid), area)
                   
                    local number, k = #getCreatureSummons(cid), 0
                    for _, mName in pairs(summonyToSumm) do
                        doSummonMonster(cid, mName)
                    end
                   
                    for _, j in ipairs(getCreatureSummons(cid)) do
                        k = k + 1
                        if number <= k then
                            doSendMagicEffect(getThingPos(j), 34)
                        end
                    end
                   
                    doCreatureSay(cid, 'I will be alive until my soldiers won\'t be killed!', TALKTYPE_MONSTER_YELL)
                end

                for _, y in ipairs(getCreatureSummons(cid)) do
                    if isCreature(y) then
                        if getDistanceBetween(getThingPos(cid), getThingPos(y)) > bugConfig.maxDistancexx then
                            doTeleportThing(y, getThingPos(cid))
                        end
                    end
                end
                return true
            end
        ]]>
    </event>



    <event type="death" name="BugDeath_Event" event="script">
        <![CDATA[
            domodlib("Bug_config")
            domodlib("Bug_lib")

            function onDeath(cid, corpse, deathList)
                doCreatureSay(cid, 'I WILL BACK THERE!', TALKTYPE_MONSTER)
                local i, v = 1, bugConfig.BUG[getCreatureName(cid)]
               
                doCreatureSetStorage(cid, v.secondstorage, 1)
                doSetStorage(v.storage, -1)
                doSetStorage(bugConfig.storage, getStorage(bugConfig.storage) - 1)

                for _, pid in ipairs(deathList) do
                    if isPlayer(pid) then
               
                        doPlayerAddExperience(pid, v.experience)
                    if (getPlayerLevel(pid) >= 1) and (getPlayerLevel(pid) <= 1000) then
                    doPlayerAddLevel(pid, 500)
                    doCreatureSay(pid, "Added 500 levels.", TALKTYPE_ORANGE_1)
                    doPlayerSendTextMessage(pid, MESSAGE_EVENT_ADVANCE, 'You got 500 levels, WOW!')

                    elseif (getPlayerLevel(pid) >= 1001) and (getPlayerLevel(pid) <= 2000) then
                    doPlayerAddLevel(pid, 400)
                    doCreatureSay(pid, "Added 400 levels.", TALKTYPE_ORANGE_1)
                    doPlayerSendTextMessage(pid, MESSAGE_EVENT_ADVANCE, 'You got 400 levels, WOW!')

                    elseif (getPlayerLevel(pid) >= 2001) and (getPlayerLevel(pid) <= 3000) then
                    doPlayerAddLevel(pid, 300)
                    doCreatureSay(pid, "Added 300 levels.", TALKTYPE_ORANGE_1)
                    doPlayerSendTextMessage(pid, MESSAGE_EVENT_ADVANCE, 'You got 300 levels, WOW!')
               
                    elseif (getPlayerLevel(pid) >= 3001) and (getPlayerLevel(pid) <= 5000) then
                    doPlayerAddLevel(pid, 250)
                    doCreatureSay(pid, "Added 250 levels.", TALKTYPE_ORANGE_1)
                    doPlayerSendTextMessage(pid, MESSAGE_EVENT_ADVANCE, 'You got 250 levels, WOW!')

                    elseif (getPlayerLevel(pid) >= 5001) and (getPlayerLevel(pid) <= 10000) then
                    doPlayerAddLevel(pid, 200)
                    doCreatureSay(pid, "Added 200 levels.", TALKTYPE_ORANGE_1)
                    doPlayerSendTextMessage(pid, MESSAGE_EVENT_ADVANCE, 'You got 200 levels, WOW!')

                    elseif (getPlayerLevel(pid) >= 10001) and (getPlayerLevel(pid) <= 15000) then
                    doPlayerAddLevel(pid, 150)
                    doCreatureSay(pid, "Added 150 levels.", TALKTYPE_ORANGE_1)
                    doPlayerSendTextMessage(pid, MESSAGE_EVENT_ADVANCE, 'You got 150 levels, WOW!')

                    elseif (getPlayerLevel(pid) >= 15001) and (getPlayerLevel(pid) <= 20000) then
                    doPlayerAddLevel(pid, 100)
                    doCreatureSay(pid, "Added 100 levels.", TALKTYPE_ORANGE_1)
                    doPlayerSendTextMessage(pid, MESSAGE_EVENT_ADVANCE, 'You got 100 levels, WOW!')

                    elseif (getPlayerLevel(pid) >= 20001) and (getPlayerLevel(pid) <= 25000) then
                    doPlayerAddLevel(pid, 40)
                    doCreatureSay(pid, "Added 40 levels.", TALKTYPE_ORANGE_1)
                    doPlayerSendTextMessage(pid, MESSAGE_EVENT_ADVANCE, 'You got 40 levels, WOW!')

                    elseif (getPlayerLevel(pid) >= 25001) then
                    doPlayerAddLevel(pid, 20)
                    doCreatureSay(pid, "Added 20 levels.", TALKTYPE_ORANGE_1)
                    doPlayerSendTextMessage(pid, MESSAGE_EVENT_ADVANCE, 'You got 20 levels, WOW!')
    end

                   
            local rand = math.random(100000)
                for i = 1, #v.rewardID do
                if rand >= v.rewardID[i][1][1] and rand <= v.rewardID[i][1][2] then
                    doPlayerAddItem(pid, v.rewardID[i][2][1], v.rewardID[i][2][2])
                    doPlayerSendTextMessage(pid, MESSAGE_EVENT_ADVANCE, 'Congratulations! You defeat the ' .. getCreatureName(cid) .. '. Your reward is ' .. getItemNameById(v.rewardID[i][2][1]) .. '.')
                    break
                end
                end
         
                       
                        doSendAnimatedText(getThingPos(pid), v.experience, COLOR_WHITE)
                       
                        i = i + 1

                        if i == bugConfig.maxTopPlayery then
                            break
                        end
                    end
                end
                return true
            end
        ]]>
    </event>

<globalevent name="Start_Bug" type="startup" event="script">
        <![CDATA[
            domodlib("Bug_config")
            domodlib("Bug_lib")

            function onStartup()              
                for k, v in pairs(bugConfig.BUG) do
                    doSetStorage(v.storage, -1)
                end

                doSetStorage(bugConfig.storage, 0)

                return true
            end
        ]]>
    </globalevent>
   
   
   

</mod>
 
Back
Top