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

RevScripts Modification to utevo res" teleport creatures far from master

ralke

(҂ ͠❛ ෴ ͡❛)ᕤ
Joined
Dec 17, 2011
Messages
1,470
Solutions
27
Reaction score
844
Location
Santiago - Chile
GitHub
ralke23
Twitch
ralke23
Hi there! I wonder if someone could help me with a modification for utevo res " spell. I need that summons follows the master if they're a certain ammount of SQM away from it. For this I have searched and found this piece of code here:

Lua:
-- If you are > 9 sqm away from master, try teleport somewhere in his behind vicinity
    if not masterPos:isInRange(
        Position(summonPos.x-9,summonPos.y-9,summonPos.z), Position(summonPos.x+9,summonPos.y+9,summonPos.z)
    ) then
        local masterDirection = master:getDirection()
        for i = -2, 1, 1 do
            -- Center
            local centerBehindPos = Position(masterPos)
            centerBehindPos:getNextPosition(masterDirection, i)
            if teleportSummon(summon, centerBehindPos) then return true end

            -- Adjacent to center
            local adjacent1 = Position(centerBehindPos)
            adjacent1:getNextPosition((masterDirection + 1) % 4, 1)
            if teleportSummon(summon, adjacent1) then return true end
        
            -- Opposite Adjacent to center
            local adjacent2 = Position(centerBehindPos)
            adjacent2:getNextPosition((masterDirection + 3) % 4, 1)
            if teleportSummon(summon, adjacent2) then return true end
        end
        return false
    end


I'm not sure if this is enough to achieve what I need, and also, how to merge this into the utevo res" spell

I wonder too if this is the best way to teleport the summons, if there's another solution in c++ that is more optimized I can test it aswell.

Thanks in advance,
Regards!
 
I am using this one:
teleporttomaster.lua

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 not getTilePzInfo(master:getPosition()) then
if(master:getPosition().z ~= cid:getPosition().z) then
  cid:teleportTo(master:getPosition())
  cid:getPosition():sendMagicEffect(CONST_ME_TELEPORT)
  return true
  end
  end

  if not getTilePzInfo(master:getPosition()) then
  if(master:getPosition():getDistance(cid:getPosition()) >=7 ) then
  cid:teleportTo(master:getPosition())
  cid:getPosition():sendMagicEffect(CONST_ME_TELEPORT)
  return true
  end
  end

  return false
end

However, with this, you have to declare it as an attack/spell in the monster.xml files
 
just convert it if you want, works fine:
 
I am using this one:
teleporttomaster.lua

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 not getTilePzInfo(master:getPosition()) then
if(master:getPosition().z ~= cid:getPosition().z) then
  cid:teleportTo(master:getPosition())
  cid:getPosition():sendMagicEffect(CONST_ME_TELEPORT)
  return true
  end
  end

  if not getTilePzInfo(master:getPosition()) then
  if(master:getPosition():getDistance(cid:getPosition()) >=7 ) then
  cid:teleportTo(master:getPosition())
  cid:getPosition():sendMagicEffect(CONST_ME_TELEPORT)
  return true
  end
  end

  return false
end

However, with this, you have to declare it as an attack/spell in the monster.xml files

I didn't get it well, how should I register it on monster file? I tried something like
XML:
<attack script="monster/fire_elemental_teleport.lua" range="5" interval="2000" chance="5" />
Just to see how it behaves and the fire elemental now has an area spell and surrounding monsters are their summons now xD
So.. How's the best way to register this? Thanks in advance

just convert it if you want, works fine:

I'll try thanks! By the way, globalevents aren't a bad manner to do this? This probably will spam a script every interval of 1000, isn't that bad?
Regards!
 
I didn't get it well, how should I register it on monster file? I tried something like
XML:
<attack script="monster/fire_elemental_teleport.lua" range="5" interval="2000" chance="5" />
Just to see how it behaves and the fire elemental now has an area spell and surrounding monsters are their summons now xD
So.. How's the best way to register this? Thanks in advance



I'll try thanks! By the way, globalevents aren't a bad manner to do this? This probably will spam a script every interval of 1000, isn't that bad?
Regards!
idk how huge is the impact, think it depends on your host/resources and how many ppl do you have on-line.. but i don't think it's big deal.
 
I didn't get it well, how should I register it on monster file? I tried something like
XML:
<attack script="monster/fire_elemental_teleport.lua" range="5" interval="2000" chance="5" />
Just to see how it behaves and the fire elemental now has an area spell and surrounding monsters are their summons now xD
So.. How's the best way to register this? Thanks in advance



I'll try thanks! By the way, globalevents aren't a bad manner to do this? This probably will spam a script every interval of 1000, isn't that bad?
Regards!
Lua:
<defense name="teleporttomaster" interval="500" chance="100">
            <attribute key="areaEffect" value="blueshimmer"/>             
</defense>

I have it like this
Post automatically merged:

Lua:
<defense name="teleporttomaster" interval="500" chance="100">
            <attribute key="areaEffect" value="blueshimmer"/>            
</defense>

I have it like this
I missed that the thread said RevScripts. I am using it as a normal spell cast by the monster. So it needs to be declared in monster.xml and spells.xml. Sorry for the confusion :)

The declaration in spells.xml can be as for any spell since players won't be able to take advantage of it.
 
Last edited:
Back
Top