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

Lua Spawn monsters in x,y,z and dont let them leave defined area

henkas

Well-Known Member
Joined
Jul 8, 2015
Messages
1,067
Solutions
5
Reaction score
63
TFS 1.X. Does anyone got a system where at every x hour there would be a chance for lets say teleports appear on x,y,z and from those teleports monsters would come out so far its pretty basic but the hard part comes how to prevent monsters from leaving lets say 10 tiles from their spawn point so they wont be lured, if they are lured somehow they get teleported back there.
 
When I face this problem, where created monsters by script don't have a lure limit, I just put some natural barriers, like a lake, montains or trees around the area.
If you wanna do this in open world, I think you will need to create a moveevent in every title in a 10 sqm diameter where it identifies the monster by name, and then teleports it to where you want it.
 
TFS 1.X. Does anyone got a system where at every x hour there would be a chance for lets say teleports appear on x,y,z and from those teleports monsters would come out so far its pretty basic but the hard part comes how to prevent monsters from leaving lets say 10 tiles from their spawn point so they wont be lured, if they are lured somehow they get teleported back there.
You can register an onThink event on each monster you generate with your script.
The event will be responsible for checking if the monster is too far from the point you want to be the center of your RAID. (TP)

Example:
LUA:
local centerPosition = Position(1000, 1000, 7)
local maxRadius = 10

local thinkEvent = CreatureEvent("MyCustomThinkEvent")

function thinkEvent.onThink(creature, interval)
    if creature:getPosition():getDistance(centerPosition) > maxRadius then
        creature:teleportTo(centerPosition)
    end
end

thinkEvent:register()

and you can add this event to the monsters with the registerEvent method.

Example:
LUA:
local monster = Game.createMonster("Orc", Position(995, 995, 7))
if monster then
    monster:registerEvent("MyCustomThinkEvent")
end
 
Back
Top