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

TFS 1.X+ Spawn creature with script once and then it will respawn normally?

endziu2222

Active Member
Joined
Nov 2, 2010
Messages
177
Solutions
1
Reaction score
48
I am trying to create a script that creates temporary spawning areas with specific creatures. Every day is a different creature so onDeath will not work here I think.
Is there a way to create monsters at specific positions at the map and once dead they will spawn with specific interval? same way it works placed with map editor?

TFS 1.5
 
I would go about it like this - globalevent with a reference to the creature, and every X minutes it checks if its alive. If its not it picks a creature thats assigned to that day and spawns it? I'm sure you can figure it out with some fiddling

Well of course other method is to go and read how the spawns are setup during map-reading.
 
@endziu2222 Ok what I suggest is to use a raid system such as this one

Then you should do a few things. I'll give you an example of how to spawn a monster that died, in the same SQM it died, and spawn it after "x" time it dies.

Lua:
local function onRespawn(name, position)
    local monster = Game.createMonster(name, position, false, true)
    if monster then
        position:sendMagicEffect(CONST_ME_TELEPORT)
    end
end

function onDeath(monster, corpse, killer, mostDamageKiller, unjustified, mostDamageUnjustified)
    addEvent(onRespawn, 120 * 60 * 1000, monster:getName(), monster:getPosition())
    return true
end

We register our script in creaturescripts:
XML:
<event type="muerte" name="creature_Death" script="creaturedeath.lua" />

Then we add the following to our monster:
Lua:
    <script>
    <event name="creature_Death"/>
    </script>

But this will only spawn the single creature from the raid. If you wish to do the same to the others creatures, just add the <script> tag to your monsters but I warn you, it will spawn the creature with "x" time after being killed. So play with those functions to achieve what you seek.

Also be aware that you can spawn the creature onStartUp too using globalevents.
Lua:
function onStartup()
Game.createMonster('Creaturename', Position(x,y,z))
end

Regards!
 
Back
Top