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

Lua Move monster to spawn pos when no target

silveralol

Advanced OT User
Joined
Mar 16, 2010
Messages
1,480
Solutions
9
Reaction score
211
hello folks, I compile my source with a new function called moveTo... then, with this function I want to send my monsters to the spawn position when not have any target
also remove the monster when go out of the spawn area
Code:
function onThink(creature)
    if not creature:isMonster() then 
        return true
    end
    local monster = creature:getMonster()
    local pos = monster:getSpawnPosition()
    if not pos then
        return true
    end
    if not monster:getTarget() then
        monster:moveTo(pos)
        return true
    end
    if not monster:isInSpawnRange(monster:getPosition()) then
        if monster:getTarget() then
            monster:getPosition():sendMagicEffect(CONST_ME_POFF)
            monster:remove()
        else
            monster:moveTo(pos)
        end
    end
    return true
end
the check if the monsters is out of the spawn range works, the monsters dissapear and summon another
the problem is not with the function moveTo() I test it with players and works fine...
Also I need check the runHealth, but the function MonsterType(monster):getRunHealth() seems don't work properly...
In my source I removed the check
Code:
if (!isInSpawnRange(_position)) {
        g_game.internalTeleport(this, masterPos);
        setIdle(true);
 }
how make it work ? :S
 
use monster:getType():getRunHealth(), should work
why make a new function to teleport monster? just use monster:teleportTo(pos)?
 
use monster:getType():getRunHealth(), should work
why make a new function to teleport monster? just use monster:teleportTo(pos)?
the function don't "teleport" the new function make the monster walk to the positiion parameter, it will be like the rl
also you don't tell about the issue :/ I need make work the function before handle with runHealth
 
the function don't "teleport" the new function make the monster walk to the positiion parameter, it will be like the rl
also you don't tell about the issue :/ I need make work the function before handle with runHealth
are you saying you want it to walk back to spawn position or teleport?
 
so you want the monster to walk back to the spawn when it leaves the spawn range? and your moveTo() function isnt working at all? try troubleshooting moveTo, or just use doMoveCreature(cid, dir) with the getPathTo position list
 
are you saying you want it to walk back to spawn position or teleport?
so you want the monster to walk back to the spawn when it leaves the spawn range? and your moveTo() function isnt working at all? try troubleshooting moveTo, or just use doMoveCreature(cid, dir) with the getPathTo position list
here the function...
https://github.com/mattyx14/otxserver/commit/9b528f0f2a361b812fd30188871f6648ca064a4f
as I said, the function works I TEST WITH PLAYERS!
 
no idea why it would work for players but not monsters, but as i said, try using doMoveCreature(cid, dir) with the table returned by getPathTo function (your moveTo() function uses the getPathTo table anyway, it just uses autowalk instead of force-moving creating, i guess)
 
Back
Top