• 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:
Increase interval2.

Do you want that raid to happen more than once a day (server restart cycle)? Or just random?
 
I do not restart my server at serversafe so i want it to happen x amount of time with a randomizing factor of x.
 
The truth is that TFS raid system is not very good for boss raids because you can't block a raid if it's not cleared yet. My suggestion is to look for a custom raid system or restart server or just increase the amount of time between raids/number of raids to avoid them getting repeated often.
 
Isn't there a way to like, check if monster with name x is online, do not execute raid?

My knowledge can't go that far sorry. With TFS raid system you can't do that. I don't know if adding some kind of script you can do that check, someone else will have to help you here.
 
[29/08/2014 11:27:37] [Error] Raid: Could not load data/raids/Demodras.lua!
[29/08/2014 11:27:37] [Error] Raids: failed to load raid Demodras

Server\data\raids\raids.xml
Code:
<?xml version="1.0" encoding="UTF-8"?>
<raids>
    <raid name="Demodras" file="Demodras.lua" interval2="1" margin="1"/>
    <raid name="The Pit Lord" file="The Pit Lord.xml" interval2="379" margin="177"/>
    <raid name="Undead Tortoise" file="The Pit Lord.xml" interval2="379" margin="177"/>
</raids>

Server\data\raids\Demodras.lua
Code:
local monsters = {
   {name = "Demodras", pos = {x = 1141, y = 1000, z = 11}}
}

function onUse(cid, item, fromPosition, itemEx, toPosition)
     local spec = getSpectators({x = 1141, y = 1000, z = 11}, 5, 5, FALSE)
     if spec ~= nil then
         for _, s in pairs(spec) do
             n = getCreatureName(s)
             if n == "Demmodras" then
                 return TRUE
             end
         end
     end
     for m = 1, #monsters do
         doSummonCreature(monsters[m].name, monsters[m].pos)
     end
     broadcastMessage("Demodras has returnd to it's lair")
     return TRUE
end
 
Function onUse means it should be in actions, you can also add it in talkactions with function onSay to make it work like a talkaction.
 
You mean that the raid broadcasts a msg and that the talkaction script activates at the broadcast msg to check if it has to spawn the monster or not?
 
I'm not sure if you can use lua instead of xml for a raid.

There are two solutions for your problem:


Solution 1 - (the one I'm using) Link a creaturescript to Demodras, so it will be removed X hours after its spawn.

in creaturescripts.xml:
Code:
<event type="think" name="RemoveBoss" event="script" value="removeboss.lua"/>

this is removeboss.lua:
Code:
seconds = 57600
--16 hrs = 57600

function onThink(cid)
    addEvent(killboss,1000*seconds, {cid=cid})
    return true
end

function killboss(cid)
local cid = cid.cid
    if isCreature(cid) then
        doRemoveCreature(cid)
        return true
    end
    return true
end

Where seconds is the number of seconds that the monster will stay alive, before being removed by the server. I use 16 hours, because that is the minimun interval between raids in my server.

in demodras.xml, add this:
Code:
    <script>
        <event name="RemoveBoss" />
    </script>



Solution 2 - Link a creaturescript to Demodras of type="think". In this script, use the getSpectator function to check if Demodras is a spectator of Demodras. If so, remove the creature. UNTESTED - you need to test, in case this function removes the 2 Demodras instead of only removing one. If you use this solution, it will be complicated to implemented the message "Demodras has returned...".
 
[02/09/2014 17:08:21] [Error] Raid: delay tag missing.
[02/09/2014 17:08:21] Raids: Error in file(data/raids/Demodras.xml) eventNode: script

Code:
<raid>
<announce delay="0" type="event" message="Demodras, the evil dragon boss, has returned to its lair."/>
    <script>
        <event delay="0" name="RemoveBoss"/>
    </script>
<singlespawn delay="5" name="Demodras" x="1141" y="1000" z="11"/>
</raid>
 
You need to add in the monster file, not the raid file. Here is my demodras.xml - I added the script after the loot.

PHP:
<?xml version="1.0" encoding="UTF-8"?>
<monster name="Demodras" nameDescription="Demodras" race="blood" experience="6000" speed="230" manacost="0">
    <health now="4500" max="4500"/>
    <look type="204" corpse="5984"/>
    <targetchange interval="2000" chance="10"/>
    <strategy attack="100" defense="0"/>
    <flags>
        <flag summonable="0"/>
        <flag attackable="1"/>
        <flag hostile="1"/>
        <flag illusionable="0"/>
        <flag convinceable="0"/>
        <flag pushable="0"/>
        <flag canpushitems="1"/>
        <flag canpushcreatures="1"/>
        <flag targetdistance="1"/>
        <flag staticattack="90"/>
        <flag runonhealth="300"/>
    </flags>
    <attacks>
        <attack name="melee" interval="2000" skill="50" attack="80"/>
        <attack name="fire" interval="2000" chance="25" range="7" radius="4" target="1" min="-350" max="-400">
            <attribute key="shootEffect" value="fire"/>
            <attribute key="areaEffect" value="firearea"/>
        </attack>
        <attack name="fire" interval="4000" chance="25" length="8" spread="3" min="-300" max="-550">
            <attribute key="areaEffect" value="firearea"/>
        </attack>
    </attacks>
    <defenses armor="35" defense="25">
        <defense name="healing" interval="2000" chance="25" min="300" max="700">
            <attribute key="areaEffect" value="blueshimmer"/>
        </defense>
    </defenses>
    <elements>
        <element energyPercent="20"/>
        <element earthPercent="80"/>
        <element icePercent="-5"/>
    </elements>
    <immunities>
        <immunity paralyze="1"/>
        <immunity fire="1"/>
        <immunity invisible="1"/>
    </immunities>
    <summons maxSummons="2">
        <summon name="Dragon" interval="2000" chance="20" max="2"/>
    </summons>
    <voices interval="2000" chance="10">
        <voice sentence="I WILL SET THE WORLD ON FIRE!" yell="1"/>
        <voice sentence="I WILL PROTECT MY BROOD!" yell="1"/>
    </voices>
    <loot>
    <item id="7399" chance="100000" /><!-- dragon lord trophy -->
    <item id="2152" countmax="10" chance="55225" /><!-- platinum coin -->
    <item id="5919" chance="100000" /><!-- dragon claw -->
    <item id="2672" chance="53125" /><!-- dragon ham -->
    <item id="5948" chance="5750" /><!-- red dragon leather -->
    <item id="7590" chance="5750" /><!-- great mana potion -->
</loot>
    <script>
        <event name="RemoveBoss" />
    </script>
</monster>
 
The first solution works but it's not 100% what I want, so I tried to make the second one.

Made the following script but it removes the boss whenever it spawns, so not only when there is 2
Code:
function onThink(cid)
            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
            broadcastMessage("Test!", MESSAGE_EVENT_ADVANCE)
                doRemoveCreature(cid)
                    return TRUE
                    end
end
end
end
 

Similar threads

Back
Top