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

Monster go to specified pos x, y, z after spawn

pacan123

New Member
Joined
Oct 5, 2012
Messages
32
Reaction score
2
Hello guys i need to create a script. What i need?
i want to make somethink like when monster is spawned he go to specified pos x, y, z im using tfs 1.2
i cant find function like this
For example creature:gotopos() or monster:gotopos() any suggestions?
 
ok I will check this one thanks!
Post automatically merged:


or thing:teleportTo(toPos)
ok man thanks for your help i added this one to my code compile it and works but now i have second question :) maybe you know answer :) im using it like spell and i just create some like:
function onCastSpell(creature, variant)
local destination = {x=x, y=y, z=z}
creature:moveTo(destination)
end
monster is going there only when someone is on the screen its obvious becouse he is using spell.
What I want?
I want to this monster will go there just after spawn. I dont know with function i need to use on this monster onThink()? or some? maybe you have any idea :)
 
Last edited:
You can use an onThink function to do this (I don't think it's the most correct), example function: (Storage = 1 time teleport)

Lua:
function onThink(creature, position, fromPosition)
    if not creature:isMonster() then
        return true
    end
    if creature:getStorageValue(18237112) ~= 1 then
        creature:teleportTo(Position(32369, 32228, 7)) -- Position to teleport
        creature:setStorageValue(18237112,1)
    end
end

In monster script you add:
Lua:
    <script>
        <event name="CREATURESCRIPTS_NAME" />
    </script>

By the way, I really recommend seeing this topic, it talks about the onSpawn function, which would be better for your purpose. Feature - [TFS 1.2] Monster:onSpawn(position, startup, artificial) (https://otland.net/threads/tfs-1-2-monster-onspawn-position-startup-artificial.257140/)
 
You can use an onThink function to do this (I don't think it's the most correct), example function: (Storage = 1 time teleport)

Lua:
function onThink(creature, position, fromPosition)
    if not creature:isMonster() then
        return true
    end
    if creature:getStorageValue(18237112) ~= 1 then
        creature:teleportTo(Position(32369, 32228, 7)) -- Position to teleport
        creature:setStorageValue(18237112,1)
    end
end

In monster script you add:
Lua:
    <script>
        <event name="CREATURESCRIPTS_NAME" />
    </script>

By the way, I really recommend seeing this topic, it talks about the onSpawn function, which would be better for your purpose. Feature - [TFS 1.2] Monster:onSpawn(position, startup, artificial) (https://otland.net/threads/tfs-1-2-monster-onspawn-position-startup-artificial.257140/)
ok can you explain

if not creature:isMonster() then
return true
end
why need i use this lines of code? why i need to check that creature is monster when i indicates it in monster script?
Second question
for what i check this one: creature:getStorageValue(18237112) ~= 1 and should set it after teleport to this creature:setStorageValue(18237112,1)

And i need to use moveTo() not teleportTo() becouse i dont want the monster will just teleport but move to this position
 
Last edited:
Back
Top