1. Guest, do you need help starting your own server? Take a look at our new guide with information and links to tutorials here.
  2. Guest, remember to add your server at our serverlist!

Solved Summon follow and floorchange

Discussion in 'Solved' started by Andreew, Apr 4, 2017.

  1. Andreew

    Andreew Member

    Joined:
    Feb 25, 2017
    Messages:
    48
    Likes Received:
    59
    Hey guys! i have this piece of code i found made by Azzkaban @ (the place that we never speek of, lool ) I edited it a bit to my likings.
    tho to the point, i would like do know how to add so that the summon will get teleported to me if im to far away or change floor.

    here is the code, im using TFS 1.2

    Code (Text):
    1.  
    2. local combat = createCombatObject()
    3. setCombatParam(combat, COMBAT_PARAM_TYPE, COMBAT_NONE)
    4. setCombatParam(combat, COMBAT_PARAM_EFFECT, CONST_ME_MORTAREA)
    5. setCombatFormula(combat, COMBAT_FORMULA_LEVELMAGIC, 0, 0, 0, 0)
    6. local maxsumons = 1
    7. function onCastSpell(cid, var)
    8.     local summoncount = getCreatureSummons(cid)
    9.     if #summoncount < 1 then
    10.         for i = 1, maxsumons - #summoncount do
    11.             doConvinceCreature(cid, doSummonCreature("Skeleton", getCreaturePosition(cid)))
    12.         end
    13.     end
    14.     return doCombat(cid, combat, var)
    15. end
    16.  
     
    Last edited: Apr 5, 2017
  2. Alpha

    Alpha Alphagenetics

    Joined:
    Apr 5, 2017
    Messages:
    1
    Likes Received:
    0
    Start by updating your functions instead of using old deprecated compat functions
     
  3. Andreew

    Andreew Member

    Joined:
    Feb 25, 2017
    Messages:
    48
    Likes Received:
    59
    Well @Alpha not a scripter myself, so i do use scripts others makes and just edit what i can to my likings and if the script works im all good with that..
    and I will post the solution on this tomorrow when i have the time cuz i already got help with it.. thanks for your input, even tho it did not "support" me at all.

    Edit:
    here comes the working script if someone else needed it :)

    change the spell lua to this
    Code (Text):
    1.  
    2. local combat = createCombatObject()
    3. setCombatParam(combat, COMBAT_PARAM_TYPE, COMBAT_NONE)
    4. setCombatParam(combat, COMBAT_PARAM_EFFECT, CONST_ME_MORTAREA)
    5. setCombatFormula(combat, COMBAT_FORMULA_LEVELMAGIC, 0, 0, 0, 0)
    6. local maxsumons = 1
    7. function onCastSpell(creature, variant)
    8.     local summoncount = #creature:getSummons()
    9.     if summoncount < 1 then
    10.         for i = 1, maxsumons - summoncount do
    11.             local summon = Game.createMonster("Skeleton", creature:getPosition())
    12.             if summon ~= nil then
    13.                 summon:setMaster(creature)
    14.                 summon:registerEvent("summontp")
    15.             end
    16.         end
    17.     end
    18.     return combat:execute(creature, variant)
    19. end
    20.  
    Add this to creaturescripts.xml:
    Code (Text):
    1.  
    2. <event type="think" name="summontp" script="summon_tp.lua" />
    3.  
    In summon_tp.lua:
    Code (Text):
    1.  
    2. local maxDistance = 8
    3.  
    4. local function getFreePos(position)
    5.     local usePosition = Position(position)
    6.     local tiles = { Tile(usePosition) }
    7.  
    8.     local tile
    9.     for y = -1, 1 do
    10.         for x = -1, 1 do
    11.             if x ~= 0 or y ~= 0 then
    12.                 usePosition.x = position.x + x
    13.                 usePosition.y = position.y + y
    14.  
    15.                 tile = Tile(usePosition)
    16.                 if tile then
    17.                     tiles[#tiles + 1] = tile
    18.                 end
    19.             end
    20.         end
    21.     end
    22.  
    23.     for i = 1, #tiles do
    24.         tile = tiles[i]
    25.         if tile:getCreatureCount() == 0 and not tile:hasProperty(CONST_PROP_BLOCKSOLID) and not tile:hasFlag(TILESTATE_PROTECTIONZONE) and not tile:hasFlag(TILESTATE_FLOORCHANGE) and not tile:hasFlag(TILESTATE_TELEPORT) then
    26.             return tile:getPosition()
    27.         end
    28.     end
    29.     return false
    30. end
    31.  
    If you try to set maxDistance to anything higher the script shouldn't work as the monster will be in indle state.

    The working code was provided to me by Frija so all creds to him and azzkaban aswell for first script.
     
    Last edited: Apr 6, 2017
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.