• 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 check if monster is online

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'm wondering if there is a way to block a raid from re-happening if the previous raid hasn't been completely cleared (can be a single boss monster raid or a full raid).

-> Raids.xml
Code:
    <raid name="Demodras" file="Demodras.xml" interval2="379" margin="177"/>

-> Demodras.xml
Code:
 <raid>
<announce delay="0" type="event" message="Demodras, the evil dragon boss, has returned to its lair." />
<singlespawn delay="0" name="Demodras" x="1141" y="1000" z="11" />
</raid>

With this the Demodras keeps on stacking everytime the raid happens.

If I change Demodras.xml to
Code:
<raid>
<announce delay="0" type="event" message="Demodras, the evil dragon boss, has returned to its lair." />
<areaspawn delay="0" fromx="1141" fromy="1000" fromz="11" tox="1141" toy="1000" toz="11">
    <monster name="Demodras" amount="1" />
  </areaspawn>
</raid>

The Demodras won't stack anymore because the tile is already filled.
Still the message appears. And if the Demodras is lured away and not killed, a second Demodras will spawn.

Thanks in advance.
 
Last edited:
Untested, but it may work

PHP:
function onThink(cid)
    local flag = 0
    local spec = getSpectators({x = 809, y = 971, z = 7}, 10, 10, FALSE)
    if spec ~= nil then
        for _, s in pairs(spec) do
            n = getCreatureName(s)
            if n == "Demodras" then
                flag = flag + 1
            end
        end
        if flag > 1 then
            broadcastMessage("Test!", MESSAGE_EVENT_ADVANCE)
            doRemoveCreature(cid)
            return TRUE
        end
    end
end
 
Nice!

Works pretty great, sometimes it bugs (1 out of 50?) and 2 stay alive but once they are killed the 2nd doesn't leave a body. It might also poof if player is near, haven't tested that.
 
You can try this code to use it with all raid bosses, not only Demodras:

PHP:
function onThink(cid)
    local flag = 0
    local spec = getSpectators({x = 809, y = 971, z = 7}, 10, 10, FALSE)
    if spec ~= nil then
        for _, s in pairs(spec) do
            n = getCreatureName(s)
            cidname = getCreatureName(cid)
            if n == cidname then
                flag = flag + 1
            end
        end
        if flag > 1 then
            broadcastMessage("Test!", MESSAGE_EVENT_ADVANCE)
            doRemoveCreature(cid)
            return TRUE
        end
    end
end
 
well if I use it like this and a boss spawns within a normal respawn wont it check the normal creatures also and remove them?
 
No, because you only add the script to the creatures you want to execute it. You added
Code:
    <script>
<event name="RemoveBoss" />
</script>

to Demodras, so, only Demodras will execute it, not other creatures.

but I'm not sure, you may need to test it
 
But since it will be all bosses in the same script, how do i make this line check multiple floors?
Code:
    local spec = getSpectators({x = 1000, y = 1000, z = 7}, 1000, 1000, FALSE)


Also when the script bugs and the 2nd Demodras stays, it still disappears whenever a player comes near it.


also if i now put a 2nd Demodras on a different floor, and i make a 3rd on the floor which is being checked the 3rd and the 2nd will be removed at the time I summon the third.


Also it doesn't always remove the new creature, it removes the creature which is found most north-west in the area of search.
 
Last edited:
Change FALSE to TRUE for multifloor.
Btw, if there are more bosses far away from eachother, you can also just use a different script for the other boss instead of checking for range 1000, which is pretty big and will take much memory since onThink loads all the time.
 
instead of using {x = 1000, y = 1000, z = 7} as position, try to use the creature prosition:
getCreaturePosition(cid)
 

Similar threads

Back
Top