• 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 Question (Raid Related)

Exoltes

Novia OTserv Developer
Joined
Jul 2, 2009
Messages
563
Reaction score
47
Location
Belgium
I'm working on a 8.54 Open Tibia Server using The Forgotten Server - Version 0.2.7 (Mystic Spirit).

I wondered if it was possible to create a raid which can be activated by using a certain item.

Thanks in advance.
 
You can use doSummonCreature in an action script and just let it summon several monsters and you can add broadcast aswell.
 
Couple different monsters but also the same monsters on different locations. But mostly I want to understand how it works so I can use it on more places in my server.
 
Code:
local monsters = {
   {name = "Pirate Buccaneer", pos = {x = 89, y = 126, z = 7}},
   {name = "Pirate Buccaneer", pos = {x = 90, y = 126, z = 7}},
   {name = "Pirate Buccaneer", pos = {x = 91, y = 126, z = 7}},

   {name = "Pirate Corsair", pos = {x = 89, y = 127, z = 7}},
   {name = "Pirate Corsair", pos = {x = 90, y = 127, z = 7}},
   {name = "Pirate Corsair", pos = {x = 91, y = 127, z = 7}},
   {name = "Pirate Corsair", pos = {x = 92, y = 127, z = 7}},
   {name = "Pirate Corsair", pos = {x = 93, y = 127, z = 7}},

   {name = "Pirate Cutthroat", pos = {x = 89, y = 128, z = 7}},
   {name = "Pirate Cutthroat", pos = {x = 90, y = 128, z = 7}},

   {name = "Pirate Marauder", pos = {x = 89, y = 129, z = 7}},
   {name = "Pirate Marauder", pos = {x = 90, y = 129, z = 7}},
   {name = "Pirate Marauder", pos = {x = 91, y = 129, z = 7}},
   {name = "Pirate Marauder", pos = {x = 92, y = 129, z = 7}}
}

function onUse(cid, item, fromPosition, itemEx, toPosition)
     local spec = getSpectators({x = 91, y = 127, z = 7}, 5, 5, FALSE)
     if spec ~= nil then
         for _, s in pairs(spec) do
             n = getCreatureName(s)
             if n == "Pirate Buccaneer" or n == "Pirate Corsair" or n == "Pirate Cutthroat" or n == "Pirate Marauder" then
                 doPlayerSendCancel(cid, "The raid is still there.")
                 return TRUE
             end
         end
     end
     for m = 1, #monsters do
         doSummonCreature(monsters[m].name, monsters[m].pos)
     end
     broadcastMessage("Pirate raid started.")
     return TRUE
end
 
Tried to add the script but I think I went wrong somewhere, because I do get my 'broadcastMessage("Boys! To arms!!!", MESSAGE_EVENT_ADVANCE)' but no monsters spawn. Also not getting any errors in my console.

Code:
local monsters = {
   {name = "Pirate Buccaneer", pos = {x = 847, y = 1141, z = 6}},
   {name = "Pirate Buccaneer", pos = {x = 848, y = 1141, z = 6}},
   {name = "Pirate Buccaneer", pos = {x = 849, y = 1141, z = 6}},

   {name = "Pirate Corsair", pos = {x = 847, y = 1142, z = 6}},
   {name = "Pirate Corsair", pos = {x = 848, y = 1142, z = 6}},
   {name = "Pirate Corsair", pos = {x = 849, y = 1142, z = 6}},
   {name = "Pirate Corsair", pos = {x = 850, y = 1142, z = 6}},
   {name = "Pirate Corsair", pos = {x = 851, y = 1142, z = 6}},

   {name = "Pirate Cutthroat", pos = {x = 847, y = 1143, z = 6}},
   {name = "Pirate Cutthroat", pos = {x = 848, y = 1143, z = 6}},

   {name = "Pirate Marauder", pos = {x = 847, y = 1144, z = 6}},
   {name = "Pirate Marauder", pos = {x = 848, y = 1144, z = 6}},
   {name = "Pirate Marauder", pos = {x = 849, y = 1144, z = 6}},
   {name = "Pirate Marauder", pos = {x = 850, y = 1144, z = 6}}
}

function onUse(cid, item, fromPosition, itemEx, toPosition)
local function doTransformBack(pos, itemid, transformid)
     return doTransformItem(getTileItemById(pos, transformid).uid, itemid)
end    



        if itemEx.itemid == 5675 and item.uid == 5569 then
        if getPlayerStorageValue(cid, 7008) == -1 then
           local rand = math.random(1, 2)
           if rand == 1 then
            doSendMagicEffect(toPosition,CONST_ME_FIREAREA)
            doTargetCombatHealth(0, cid, COMBAT_FIREDAMAGE, -100, -100, CONST_ME_NONE)
              doCreatureSay(cid, "KABOOM!", TALKTYPE_ORANGE_1)
            doTransformItem(itemEx.uid, 2255)
            addEvent(doTransformBack, 42*60*1000, toPosition, itemEx.itemid, 2255)
            broadcastMessage("Boys! To arms!!!", MESSAGE_EVENT_ADVANCE)
            local spec = getSpectators({x = 849, y = 1143, z = 6}, 5, 5, FALSE)
            if spec ~= nil then
                for _, s in pairs(spec) do
                    n = getCreatureName(s)
                    if n == "Pirate Buccaneer" or n == "Pirate Corsair" or n == "Pirate Cutthroat" or n == "Pirate Marauder" then
                        doPlayerSendCancel(cid, "The raid is still there.")
                    return TRUE
                    end
            end
            for m = 1, #monsters do
            doSummonCreature(monsters[m].name, monsters[m].pos)
            end
            broadcastMessage("Pirate raid started.")
            end
          else
            doSendMagicEffect(toPosition,CONST_ME_FIREAREA)
            doTargetCombatHealth(0, cid, COMBAT_FIREDAMAGE, -100, -100, CONST_ME_NONE)
              doCreatureSay(cid, "KABOOM!", TALKTYPE_ORANGE_1)
            doTransformItem(itemEx.uid, 2255)
            addEvent(doTransformBack, 28*60*1000, toPosition, itemEx.itemid, 2255)
        end
        else
              doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You allready found XXX his treasure.")
end
end
     return TRUE
end

Code:
local monsters = {
   {name = "Pirate Buccaneer", pos = {x = 847, y = 1141, z = 6}},
   {name = "Pirate Buccaneer", pos = {x = 848, y = 1141, z = 6}},
   {name = "Pirate Buccaneer", pos = {x = 849, y = 1141, z = 6}},

   {name = "Pirate Corsair", pos = {x = 847, y = 1142, z = 6}},
   {name = "Pirate Corsair", pos = {x = 848, y = 1142, z = 6}},
   {name = "Pirate Corsair", pos = {x = 849, y = 1142, z = 6}},
   {name = "Pirate Corsair", pos = {x = 850, y = 1142, z = 6}},
   {name = "Pirate Corsair", pos = {x = 851, y = 1142, z = 6}},

   {name = "Pirate Cutthroat", pos = {x = 847, y = 1143, z = 6}},
   {name = "Pirate Cutthroat", pos = {x = 848, y = 1143, z = 6}},

   {name = "Pirate Marauder", pos = {x = 847, y = 1144, z = 6}},
   {name = "Pirate Marauder", pos = {x = 848, y = 1144, z = 6}},
   {name = "Pirate Marauder", pos = {x = 849, y = 1144, z = 6}},
   {name = "Pirate Marauder", pos = {x = 850, y = 1144, z = 6}}
}

function onUse(cid, item, fromPosition, itemEx, toPosition)
local function doTransformBack(pos, itemid, transformid)
     return doTransformItem(getTileItemById(pos, transformid).uid, itemid)
end 



        if itemEx.itemid == 5675 and item.uid == 5569 then
        if getPlayerStorageValue(cid, 7008) == -1 then
           local rand = math.random(1, 2)
           if rand == 1 then
            doSendMagicEffect(toPosition,CONST_ME_FIREAREA)
            doTargetCombatHealth(0, cid, COMBAT_FIREDAMAGE, -100, -100, CONST_ME_NONE)
              doCreatureSay(cid, "KABOOM!", TALKTYPE_ORANGE_1)
            doTransformItem(itemEx.uid, 2255)
            addEvent(doTransformBack, 42*60*1000, toPosition, itemEx.itemid, 2255)
            broadcastMessage("Boys! To arms!!!", MESSAGE_EVENT_ADVANCE)
                    for m = 1, #monsters do
                    doSummonCreature(monsters[m].name, monsters[m].pos)
end
          else
            doSendMagicEffect(toPosition,CONST_ME_FIREAREA)
            doTargetCombatHealth(0, cid, COMBAT_FIREDAMAGE, -100, -100, CONST_ME_NONE)
              doCreatureSay(cid, "KABOOM!", TALKTYPE_ORANGE_1)
            doTransformItem(itemEx.uid, 2255)
            addEvent(doTransformBack, 28*60*1000, toPosition, itemEx.itemid, 2255)
        end
        else
              doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You allready found XXX his treasure.")
end
end
     return TRUE
end

Tried it like this and now it works.

btw is there a way to like delay the respawn with 3 seconds and put in a teleporter effect on the spots they spawn before they actually spawn?
 
Last edited by a moderator:
Can you tab your scripts? Else I have to copy and paste them in notepad then tab them before I'm able to read it.
What do you mean by delay the respawn with 3 seconds? For the teleport effect, you can add a magic effect in the for loop and use monsters[m].pos as position, if the monsters should spawn later you can use addEvent.
 
Aren't my scripts tapped already? i just use notepad always :D

What I kinda want is that first you get the magic effect of teleport then u get like a second break and then the actual monster spawns with the magical teleport effect.
 
Code:
local monsters = {
   {name = "Pirate Buccaneer", pos = {x = 89, y = 126, z = 7}},
   {name = "Pirate Buccaneer", pos = {x = 90, y = 126, z = 7}},
   {name = "Pirate Buccaneer", pos = {x = 91, y = 126, z = 7}},

   {name = "Pirate Corsair", pos = {x = 89, y = 127, z = 7}},
   {name = "Pirate Corsair", pos = {x = 90, y = 127, z = 7}},
   {name = "Pirate Corsair", pos = {x = 91, y = 127, z = 7}},
   {name = "Pirate Corsair", pos = {x = 92, y = 127, z = 7}},
   {name = "Pirate Corsair", pos = {x = 93, y = 127, z = 7}},

   {name = "Pirate Cutthroat", pos = {x = 89, y = 128, z = 7}},
   {name = "Pirate Cutthroat", pos = {x = 90, y = 128, z = 7}},

   {name = "Pirate Marauder", pos = {x = 89, y = 129, z = 7}},
   {name = "Pirate Marauder", pos = {x = 90, y = 129, z = 7}},
   {name = "Pirate Marauder", pos = {x = 91, y = 129, z = 7}},
   {name = "Pirate Marauder", pos = {x = 92, y = 129, z = 7}}
}

function onUse(cid, item, fromPosition, itemEx, toPosition)
     local spec = getSpectators({x = 91, y = 127, z = 7}, 5, 5, FALSE)
     if spec ~= nil then
         for _, s in pairs(spec) do
             n = getCreatureName(s)
             if n == "Pirate Buccaneer" or n == "Pirate Corsair" or n == "Pirate Cutthroat" or n == "Pirate Marauder" then
                 doPlayerSendCancel(cid, "The raid is still there.")
                 return TRUE
             end
         end
     end
     for m = 1, #monsters do
         doSummonCreature(monsters[m].name, monsters[m].pos)
     end
     broadcastMessage("Pirate raid started.")
     return TRUE
end
Just a little advice Limos, when doing things like this (creating monsters and then check if they still exist) it's quite horrible to check for a certain area instead of the uid of the monster itself.
It's not necessary to check an entire area for maybe just one creature alive + if the creature moved out of the check range it wouldn't even catch it :p

a better method is to save the monster in a table and then check if that uid still exists.
like this:
Code:
local monsters = {
   {name = "Pirate Buccaneer", pos = {x = 89, y = 126, z = 7}},
   {name = "Pirate Buccaneer", pos = {x = 90, y = 126, z = 7}},
   {name = "Pirate Buccaneer", pos = {x = 91, y = 126, z = 7}},

   {name = "Pirate Corsair", pos = {x = 89, y = 127, z = 7}},
   {name = "Pirate Corsair", pos = {x = 90, y = 127, z = 7}},
   {name = "Pirate Corsair", pos = {x = 91, y = 127, z = 7}},
   {name = "Pirate Corsair", pos = {x = 92, y = 127, z = 7}},
   {name = "Pirate Corsair", pos = {x = 93, y = 127, z = 7}},

   {name = "Pirate Cutthroat", pos = {x = 89, y = 128, z = 7}},
   {name = "Pirate Cutthroat", pos = {x = 90, y = 128, z = 7}},

   {name = "Pirate Marauder", pos = {x = 89, y = 129, z = 7}},
   {name = "Pirate Marauder", pos = {x = 90, y = 129, z = 7}},
   {name = "Pirate Marauder", pos = {x = 91, y = 129, z = 7}},
   {name = "Pirate Marauder", pos = {x = 92, y = 129, z = 7}}
}

local raidMonsters = {}
function onUse(cid, item, fromPosition, itemEx, toPosition)
   for k, v in pairs(raidMonsters) do
     if isCreature(v) then
       doPlayerSendCancel(cid, "The raid is still there.")
       return TRUE
     elseif k == #raidMonsters then
       raidMonsters = {}
     end
   end
   for m = 1, #monsters do
     local raidMonster = doSummonCreature(monsters[m].name, monsters[m].pos)
     table.insert(raidMonsters, raidMonster)
   end
   broadcastMessage("Pirate raid started.")
   return TRUE
end
 
What about monsters on spawns? I checked for a certain area so it only looks if the monsters in the raid zone are still there.
 
What about monsters on spawns? I checked for a certain area so it only looks if the monsters in the raid zone are still there.
well for a me a raid is finished when you kill the monsters which where exclusively spawned for the raid and not monsters which happen to spawn in the near aswell, as they'll respawn anyway :p
imagine if you have a grid of 100x100 to check and there are around 150 normal spawns, you could never clear it fast enough to actually finish the raid then (if you spawn for the raid same monsters, which spawn regular aswell)

It's in general not a good idea to iterate through an entire area as it'll always cost more memory then just throwing the uid's of the monsters in a table and when all are gone just clear the table ^^
and if you make the check area to little people could lure monsters outside and abuse it that way.
 
Back
Top