Seems like a creaturescript to me. Save it as 'summonTeleport.lua' in your \data\creaturescripts\scripts\ and then open your \data\creaturescripts\creaturescripts.xml and add:It is a spell? why players online?
<event type="think" name="SummonTeleport" script="summonTeleport.lua" />
function onThink(creature, interval)
local maxDistance = 7
local owner = creature:getMaster()
local petPosition = creature:getPosition()
local ownerPosition = owner:getPosition()
if petPosition.z ~= ownerPosition.z or ownerPosition:getDistance(petPosition) >= maxDistance then
petPosition:sendMagicEffect(CONST_ME_TELEPORT)...
boolean[ALLOW_CLONES] = getGlobalBoolean(L, "allowClones", false);
boolean[TELEPORT_PLAYER_SUMMONS] = getGlobalBoolean(L, "teleportPlayerSummons", false);
boolean[TELEPORT_ALL_SUMMONS] = getGlobalBoolean(L, "teleportAllSummons", false);
ALLOW_CLONES,
TELEPORT_PLAYER_SUMMONS,
TELEPORT_ALL_SUMMONS,
extern Monsters g_monsters;
extern ConfigManager g_config;
void Monster::onCreatureLeave(Creature* creature)
{
// std::cout << "onCreatureLeave - " << creature->getName() << std::endl;
if (getMaster() == creature) {
if (g_config.getBoolean(TELEPORT_ALL_SUMMONS)) {
g_game.internalTeleport(this, creature->getPosition());
} else if (g_config.getBoolean(TELEPORT_PLAYER_SUMMONS) {
Player* player = creature->getPlayer();
if (player) {
g_game.internalTeleport(this, player->getPosition());
}
} else {
//Take random steps and only use defense abilities (e.g. heal) until its master comes back
isMasterInRange = false;
}
}
//update friendList
if (isFriend(creature)) {
if (!g_config.getBoolean(TELEPORT_ALL_SUMMONS) && !g_config.getBoolean(TELEPORT_PLAYER_SUMMONS)) {
removeFriend(creature);
}
}
//update targetList
if (isOpponent(creature)) {
if (!g_config.getBoolean(TELEPORT_ALL_SUMMONS) && !g_config.getBoolean(TELEPORT_PLAYER_SUMMONS)) {
removeTarget(creature);
if (targetList.empty()) {
updateIdleStatus();
}
}
}
}
function onThink(interval, lastExecution, thinkInterval)
local maxDistance = 10
for _, pid in ipairs(getPlayersOnline()) do
local sums = getCreatureSummons(pid)
if #sums > 0 then
for i = 1, #sums do
if getThingPos(pid).z ~= getThingPos(sums[i]).z or
getDistanceBetween(getThingPos(pid), getThingPos(sums[i])) > maxDistance then
doTeleportThing(sums[i], getThingPos(pid))
doSendMagicEffect(getThingPos(pid), 21)
end
end
end
end
return true
end
Lua:function onThink(interval, lastExecution, thinkInterval) local maxDistance = 10 for _, pid in ipairs(getPlayersOnline()) do local sums = getCreatureSummons(pid) if #sums > 0 then for i = 1, #sums do if getThingPos(pid).z ~= getThingPos(sums[i]).z or getDistanceBetween(getThingPos(pid), getThingPos(sums[i])) > maxDistance then doTeleportThing(sums[i], getThingPos(pid)) doSendMagicEffect(getThingPos(pid), 21) end end end end return true end
or check out hellboy's, made for 1.2 but you gotta find it in his scripts:
https://otland.net/threads/tfs-1-2-pet-system.236403
Seems like a creaturescript to me. Save it as 'summonTeleport.lua' in your \data\creaturescripts\scripts\ and then open your \data\creaturescripts\creaturescripts.xml and add:It is a spell? why players online?
<event type="think" name="SummonTeleport" script="summonTeleport.lua" />
function onThink(creature, interval)
local maxDistance = 7
local owner = creature:getMaster()
local petPosition = creature:getPosition()
local ownerPosition = owner:getPosition()
if petPosition.z ~= ownerPosition.z or ownerPosition:getDistance(petPosition) >= maxDistance then
petPosition:sendMagicEffect(CONST_ME_TELEPORT)
creature:teleportTo(ownerPosition)
creature:getPosition():sendMagicEffect(CONST_ME_TELEPORT)
end
return true
end
<defense name="teleporttomaster" interval="5000" chance="200000" />
<instant name="teleporttomaster" words="teleporttomaster" aggressive="0" needlearn="1" script="creature spell/teleport to master.lua" />
function onCastSpell(cid, var)
local master = cid:getMaster()
if master == null then
return false
end
if not master:isPlayer() then
return false
end
if(master:getPosition().z ~= cid:getPosition().z) then
cid:teleportTo(master:getPosition())
cid:getPosition():sendMagicEffect(CONST_ME_TELEPORT)
return true
end
if(master:getPosition():getDistance(cid:getPosition()) >= 14 ) then
cid:teleportTo(master:getPosition())
cid:getPosition():sendMagicEffect(CONST_ME_TELEPORT)
return true
end
return false
end