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

MoveEvent Anti-Lure-Monster V.1 --//Otswe

Printer

if Printer then print("LUA") end
Senator
Premium User
Joined
Dec 27, 2009
Messages
5,782
Solutions
31
Reaction score
2,286
Location
Sweden?
Hello, this script is made to a request http://otland.net/f132/anti-lure-script-170873/

Simple script but pure otswe style :D
You write Monster Name and Back Posistion when it step into the tile, this will prevent that players lure a monster to far and it get teleport with the amout of health it had, instead of getting removed.

Go to movements/movements.xml and paste this line below:
<movevent type="StepIn" actionid="1000" event="script" value="antilure.lua"/>

Then goto movements/scripts and create new lua and name it "antilure.lua" and paste this script below:
Lua:
local everyone_love_otswe = true

local otswe = {
    monsters = { -- Monster Name, Teleport Back Posistion
        ["Orshabaal"] = { { x = 1070, y = 1051, z = 7 , stackpos = 1 } },
        ["Morgaroth"] = { { x = 1000, y = 1011, z = 7 , stackpos = 1 } },
    }
}
 
function onStepIn(cid, item, pos, fromPos) 
if isMonster(cid) and everyone_love_otswe == true then
    for otswe, pos in pairs(otswe.monsters) do
        if otswe == getCreatureName(cid) then
                        doTeleportThing(cid, pos[1])  
            doSendMagicEffect(getCreaturePosition(cid), CONST_ME_TELEPORT)
                        doSendMagicEffect(fromPos, CONST_ME_TELEPORT)
        end
        end
end 
if everyone_love_otswe == false then
   doCreatureSay(cid,"LOVE OTSWE, OR I WONT TELEPORT BACK!",TALKTYPE_MONSTER)    
end
    return TRUE
end

Scarlet Ayleid:
Lua:
local t = {
    ["Orshabaal"] = {pos = { x = 1070, y = 1051, z = 7 , stackpos = 1 }, range = 50},
    ["Morgaroth"] = {pos = { x = 1000, y = 1011, z = 7 , stackpos = 1 }, range = 50}
}
 
function distanceBetweenPos(pos1, pos2)
    return math.abs(pos1.x - pos2.x) + math.abs(pos1.y - pos2.y)
end

function onThink(cid)
    local cidName = getCreatureName(cid)
    if(distanceBetweenPos(getCreaturePosition(cid), t[cidName].pos) >= t[cidName].range) then
        doTeleportThing(cid, t[cidName].pos)
    end
    return true
end

Source Edit By Ninja:
Code:
if(g_config.getBool(ConfigManager::MONSTER_SPAWN_WALKBACK))
g_game.internalTeleport(this, getMasterPosition(), false);

Enjoy :D
 
Last edited:
You could do something using area. If monster walk out of this area then he go to original spot
 
We will see :p still version 1 xD
 
You could transform it in Globalevent(onthink) then if MONSTER X is out if area you want then it get teleported back

- - - Updated - - -

You can use global storage too, when raid boss globalstorage==1 then globalevent(onthink) will check only if globalevent==1.
When kill boss then globalevent==(globalevent) -1. So it will work if you have more than 1 boss
 
Asfar as i know, i need make that the script search inside that area if it can locate that monster, if not it will teleport it back. But i dont know how to make it locate.
 
Just an example
Lua:
area = {frompos = {x=33293, y=33035, z=5}, topos = {x=33329, y=33073, z=7}}
if isInRange(getCreaturePosition(cid), area.frompos, area.topos) then
	-- do nothing
else
	doTeleportThing(cid)
end
 
even better is that instead of having a range you check the distance from spawnPoint
Lua:
function distanceBetweenPos(pos1, pos2)
    return math.abs(pos1.x - pos2.x) + math.abs(pos1.y - pos2.y)
end

then you can use it like this:
Lua:
local t = {
    ["Orshabaal"] = {pos = { x = 1070, y = 1051, z = 7 , stackpos = 1 }, range = 50},
    ["Morgaroth"] = {pos = { x = 1000, y = 1011, z = 7 , stackpos = 1 }, range = 50}
}

function onThink(cid)
    local cidName = getCreatureName(cid)
    if(distanceBetweenPos(getCreaturePosition(cid), t[cidName].pos) >= t[cidName].range) then
        doTeleportThing(cid, t[cidName].pos)
    end
    return true
end
simple, fast, and cleaner :)
 
Thanks ive added it into main post, if you want to write info and how to add it feel free to edit my post :)
 
Everything is better in sources, this is a pretty rudimentary system, nothing that big
 
J.dre its not coded that the monster should get teleported back, just removed. Asfar i know :p
 
Teleports back the monster if a player has left the screen.

[cpp]if(g_config.getBool(ConfigManager::MONSTER_SPAWN_WALKBACK))
g_game.internalTeleport(this, getMasterPosition(), false);[/cpp]
 
Ive added it to into main post :p

Only one question, why does everyone take a part on this now? When the guy requested this, for serval days ago xD
 
well, I've taken an interest in improving codes of people in the Resources section, and there are plenty of people to help around with Support now(guess why xD)
 
Ive added it to into main post :p

Only one question, why does everyone take a part on this now? When the guy requested this, for serval days ago xD

I decided to participate in this now since I had forgotten about this request. Better late then never.
 
Teleports back the monster if a player has left the screen.

[cpp]if(g_config.getBool(ConfigManager::MONSTER_SPAWN_WALKBACK))
g_game.internalTeleport(this, getMasterPosition(), false);[/cpp]

And what about converting g_game.internalTeleport to this one?

g_game.internalMoveCreature(this, getMasterPosition(), 0);


Just curiuos, how to make this work without errors.
 
Back
Top