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

Teleport summons TFS 1.2

wafuboe

Member
Joined
Dec 24, 2010
Messages
881
Solutions
2
Reaction score
22
Is there a way to make summons teleport to you when you are to away or when you reach an upper or lower floor?

I remeber that in older versions in config.lua there was an option.
 
Solution
It is a spell? why players online?
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:
Code:
<event type="think" name="SummonTeleport" script="summonTeleport.lua" />

EDIT:
Maybe use this for your 'summonTeleport.lua' (Credits to Hellboy / yrpen)
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)...
i see it here but not remember where.

function on think
if creature get master then
local a = master:getPosition
local b = creature:getPosition
if a are far from b then
creature teleport to master.
elseif a is in other floor then
creature teleport to master.

something like that bro good luck
 
configmanager.cpp
under
C++:
boolean[ALLOW_CLONES] = getGlobalBoolean(L, "allowClones", false);
add
C++:
boolean[TELEPORT_PLAYER_SUMMONS] = getGlobalBoolean(L, "teleportPlayerSummons", false);
boolean[TELEPORT_ALL_SUMMONS] = getGlobalBoolean(L, "teleportAllSummons", false);

configmanager.h
in enum boolean_config_t
under
C++:
ALLOW_CLONES,
add
C++:
TELEPORT_PLAYER_SUMMONS,
TELEPORT_ALL_SUMMONS,

monster.cpp
under
C++:
extern Monsters g_monsters;
add
C++:
extern ConfigManager g_config;
replace Monster::eek:nCreatureLeave(Creature* creature) to this:
C++:
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();
            }
        }
    }
}
 
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
 
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

It is a spell? why players online?
 
It is a spell? why players online?
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:
Code:
<event type="think" name="SummonTeleport" script="summonTeleport.lua" />

EDIT:
Maybe use this for your 'summonTeleport.lua' (Credits to Hellboy / yrpen)
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
 
Last edited:
Solution
i made a quick fix for that matter :) no need to edit source.

all you have to do is add that custom spell to your pet.

in apprentice.xml ( your pet or w/e)

Code:
    <defense name="teleporttomaster" interval="5000"  chance="200000" />


in spells.lua
Code:
  <instant name="teleporttomaster" words="teleporttomaster"  aggressive="0" needlearn="1" script="creature spell/teleport to master.lua" />

in creature spell/teleport to master.lua(custom spell script)
Code:
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

hope it can help someone :)
 
Back
Top