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

Summon error

imback1

Unknown member
Joined
Jul 11, 2013
Messages
785
Solutions
1
Reaction score
46
Using this script but there is something missing on it, It is working good but when there is no area for the monster that will be summoned, it doesn't summon and gives me error because of there is an area behind the boss to be summoned, so i need it to summon it if there is no area for it behind the main boss that summon it.
TFS 0.4
1707241317938.png
1707241569673.png
so need it to be summoned on blue area if there is no area behind the boss
1707241821836.png
Lua:
local damagePercent = {
  {"Mini Breaker","Mini Breaker","The Breaker"}, -- this happens at 19.5% health
  {"The Breaker","Mini Breaker"}, -- this happens at 39% health
  {"The Breaker","Mini Breaker"}, -- this happens at 58.5% health
  {"The Breaker","Mini Breaker","The Breaker"}, -- this happens at 78% health
  {"The Breaker","Tech","Mini Breaker"}, -- this happens at 97.5%
  {"The Breaker","Tech","The Breaker"}, -- this happens at 97.5% health
  {"The Breaker","Tech","Turbo","Tech"}, -- this happens at 97.5% health
  {"Tech","Tech","Tech"}, -- this happens at 97.5% health
  {"Turbo","Turbo","Turbo"}, -- this happens at 97.5% health
}

function onThink(cid, interval)
  if isCreature(cid) then
  local temtem = getPlayerStorageValue(cid, "temtem")
  if temtem == -1 then temtem = 1 end
  if temtem <= #damagePercent then
  local SummonsList = damagePercent[temtem]
  if getCreatureHealth(cid) <= (getCreatureMaxHealth(cid) - ((10/100*getCreatureMaxHealth(cid))*temtem)) then
  for _, tid in ipairs(SummonsList) do
  doCreateMonster(tid, getCreaturePosition(cid)) ------------------------Fixed--
  end
  doPlayerSetStorageValue(cid, "temtem", temtem+1)
  end
  end
  end
  return true
end
 
Last edited:
Using this script but there is something missing on it, It is working good but when there is no area for the monster that will be summoned, it doesn't summon and gives me error because of there is an area behind the boss to be summoned, so i need it to summon it if there is no area for it behind the main boss that summon it.
TFS 0.4
View attachment 81906
View attachment 81907
so need it to be summoned on blue area if there is no area behind the boss
View attachment 81908
Lua:
local damagePercent = {
  {"Mini Breaker","Mini Breaker","The Breaker"}, -- this happens at 19.5% health
  {"The Breaker","Mini Breaker"}, -- this happens at 39% health
  {"The Breaker","Mini Breaker"}, -- this happens at 58.5% health
  {"The Breaker","Mini Breaker","The Breaker"}, -- this happens at 78% health
  {"The Breaker","Tech","Mini Breaker"}, -- this happens at 97.5%
  {"The Breaker","Tech","The Breaker"}, -- this happens at 97.5% health
  {"The Breaker","Tech","Turbo","Tech"}, -- this happens at 97.5% health
  {"Tech","Tech","Tech"}, -- this happens at 97.5% health
  {"Turbo","Turbo","Turbo"}, -- this happens at 97.5% health
}

function onThink(cid, interval)
  if isCreature(cid) then
  local temtem = getPlayerStorageValue(cid, "temtem")
  if temtem == -1 then temtem = 1 end
  if temtem <= #damagePercent then
  local SummonsList = damagePercent[temtem]
  if getCreatureHealth(cid) <= (getCreatureMaxHealth(cid) - ((10/100*getCreatureMaxHealth(cid))*temtem)) then
  for _, tid in ipairs(SummonsList) do
  doCreateMonster(tid, getCreaturePosition(cid)) ------------------------Fixed--
  end
  doPlayerSetStorageValue(cid, "temtem", temtem+1)
  end
  end
  end
  return true
end
Lua:
doCreateMonster(tid, {x = getCreaturePosition(cid).x - 2, y = getCreaturePosition(cid).y - 2, z = getCreaturePosition(cid).z})
maybe? idk didn't tested
 
Lua:
doCreateMonster(tid, {x = getCreaturePosition(cid).x - 2, y = getCreaturePosition(cid).y - 2, z = getCreaturePosition(cid).z})
maybe? idk didn't tested
1708106210608.png
You just summoned them away from the boss and the same problem that if there isn't an area it will give me an error
1708106261233.png
 
You can get the tile info using getTileInfo(pos) I believe, if a creature is there, try a different location.
getThingFromPos will check if it is a valid tile to spawn the monster
 
You can get the tile info using getTileInfo(pos) I believe, if a creature is there, try a different location.
getThingFromPos will check if it is a valid tile to spawn the monster
doesn't work too!
 
solution....upgrade your 0.4 to 1.4, 0.4 is full of bugs....

In 1.x+, you can pass either "extended" or "forced" to Game.createMonster() which would solve your issue. I assume this functionality is not present in doCreateMonster.

So either upgrade, or make your own djikstra type algorithm to search outwards from the boss' position until you find a suitable tile.
 
I was reviewing some of the functions that Jimmywest10 posted, and since there wasn't much to do at work, I decided to utilize your script along with some other functions. I quickly put together the script, but I haven't had the chance to test it yet.

If it doesn't work as expected, I highly recommend considering the use of TFS 1.x instead, as suggested by @Fjorda. It's a better option to avoid potential complications. TFS 1.x is more comprehensive, making it easier to find similar scripts or even develop custom scripts that surpass the capabilities of TFS 0.4, which is known for its numerous bugs. I hope this explanation clarifies the situation.


Lua:
local damagePercent = {
  {"Mini Breaker", "Mini Breaker", "The Breaker"}, -- this happens at 19.5% health
  {"The Breaker", "Mini Breaker"}, -- this happens at 39% health
  {"The Breaker", "Mini Breaker"}, -- this happens at 58.5% health
  {"The Breaker", "Mini Breaker", "The Breaker"}, -- this happens at 78% health
  {"The Breaker", "Tech", "Mini Breaker"}, -- this happens at 97.5%
  {"The Breaker", "Tech", "The Breaker"}, -- this happens at 97.5% health
  {"The Breaker", "Tech", "Turbo", "Tech"}, -- this happens at 97.5% health
  {"Tech", "Tech", "Tech"}, -- this happens at 97.5% health
  {"Turbo", "Turbo", "Turbo"} -- this happens at 97.5% health
}

function onThink(cid, interval)
  if isCreature(cid) then
    local temtem = getPlayerStorageValue(cid, "temtem")
    if temtem == -1 then
      temtem = 1
    end
    if temtem <= #damagePercent then
      local summonsList = damagePercent[temtem]
      if getCreatureHealth(cid) <= (getCreatureMaxHealth(cid) - ((10 / 100 * getCreatureMaxHealth(cid)) * temtem)) then
        for _, monsterName in ipairs(summonsList) do
          local summonPos = getCreaturePosition(cid)
          local freePos = getClosestFreePosition(cid, summonPos, false, false)
          if not freePos then
            freePos = findAlternativePosition(cid, summonPos)
          end
          if freePos then
            doCreateMonster(monsterName, freePos)
          else
            print("Error: Unable to find a position to summon the monstrous" .. monsterName)
          end
        end
        setPlayerStorageValue(cid, "temtem", temtem + 1)
      end
    end
  end
  return true
end

function findAlternativePosition(cid, summonPos)
  for i = -1, 1 do
    for j = -1, 1 do
      if not (i == 0 and j == 0) then
        local newPos = {x = summonPos.x + i, y = summonPos.y + j, z = summonPos.z}
        if isWalkable(newPos, cid, 0, 0) then
          return newPos
        end
      end
    end
  end
  return nil
end

function isWalkable(pos, creature, pz, monster)
  local tile = Tile(pos)
  if tile then
    local ground = tile:getGround()
    if ground and not tile:hasProperty(CONST_PROP_IMMOVABLEBLOCKSOLID) and not tile:hasProperty(CONST_PROP_BLOCKSOLID) then
      if pz and tile:hasFlag(TILESTATE_PROTECTIONZONE) then
        return false
      end
      if monster and tile:getTopCreature() then
        return false
      end
      return true
    end
  end
  return false
end
 
I was reviewing some of the functions that Jimmywest10 posted, and since there wasn't much to do at work, I decided to utilize your script along with some other functions. I quickly put together the script, but I haven't had the chance to test it yet.

If it doesn't work as expected, I highly recommend considering the use of TFS 1.x instead, as suggested by @Fjorda. It's a better option to avoid potential complications. TFS 1.x is more comprehensive, making it easier to find similar scripts or even develop custom scripts that surpass the capabilities of TFS 0.4, which is known for its numerous bugs. I hope this explanation clarifies the situation.


Lua:
local damagePercent = {
  {"Mini Breaker", "Mini Breaker", "The Breaker"}, -- this happens at 19.5% health
  {"The Breaker", "Mini Breaker"}, -- this happens at 39% health
  {"The Breaker", "Mini Breaker"}, -- this happens at 58.5% health
  {"The Breaker", "Mini Breaker", "The Breaker"}, -- this happens at 78% health
  {"The Breaker", "Tech", "Mini Breaker"}, -- this happens at 97.5%
  {"The Breaker", "Tech", "The Breaker"}, -- this happens at 97.5% health
  {"The Breaker", "Tech", "Turbo", "Tech"}, -- this happens at 97.5% health
  {"Tech", "Tech", "Tech"}, -- this happens at 97.5% health
  {"Turbo", "Turbo", "Turbo"} -- this happens at 97.5% health
}

function onThink(cid, interval)
  if isCreature(cid) then
    local temtem = getPlayerStorageValue(cid, "temtem")
    if temtem == -1 then
      temtem = 1
    end
    if temtem <= #damagePercent then
      local summonsList = damagePercent[temtem]
      if getCreatureHealth(cid) <= (getCreatureMaxHealth(cid) - ((10 / 100 * getCreatureMaxHealth(cid)) * temtem)) then
        for _, monsterName in ipairs(summonsList) do
          local summonPos = getCreaturePosition(cid)
          local freePos = getClosestFreePosition(cid, summonPos, false, false)
          if not freePos then
            freePos = findAlternativePosition(cid, summonPos)
          end
          if freePos then
            doCreateMonster(monsterName, freePos)
          else
            print("Error: Unable to find a position to summon the monstrous" .. monsterName)
          end
        end
        setPlayerStorageValue(cid, "temtem", temtem + 1)
      end
    end
  end
  return true
end

function findAlternativePosition(cid, summonPos)
  for i = -1, 1 do
    for j = -1, 1 do
      if not (i == 0 and j == 0) then
        local newPos = {x = summonPos.x + i, y = summonPos.y + j, z = summonPos.z}
        if isWalkable(newPos, cid, 0, 0) then
          return newPos
        end
      end
    end
  end
  return nil
end

function isWalkable(pos, creature, pz, monster)
  local tile = Tile(pos)
  if tile then
    local ground = tile:getGround()
    if ground and not tile:hasProperty(CONST_PROP_IMMOVABLEBLOCKSOLID) and not tile:hasProperty(CONST_PROP_BLOCKSOLID) then
      if pz and tile:hasFlag(TILESTATE_PROTECTIONZONE) then
        return false
      end
      if monster and tile:getTopCreature() then
        return false
      end
      return true
    end
  end
  return false
end
I recommend to use 1.x TFS and i want it too but the problem is that i'll need to change the whole scripts and everything to work with 1.X and i can't do it really, I was searching for someone who can upgrade 0.4 to 1.x
1710512592562.png
 
I was searching for someone who can upgrade 0.4 to 1.x
Look, someone taught me how to convert the script from TFS 0.4 to 1.x, and I managed to learn and keep learning... the scripts have been converted for a year now with my project!!... just follow the tutorial in data/lib/compat/compat.lua, it explains everything perfectly, no secrets... easy to use indeed... I'll share the two example links with you.
 
Sorry, I was a bit confused and frustrated. I looked at the wrong functions. It was indeed for TFS 1+, so I went back and revised everything, realizing that it was mixed with TFS 1.x + TFS 0.4. I tried to redo the script, and now everything is for TFS 0.4 correctly. Now it's just a matter of testing it. Hopefully, it should work!

Lua:
local damagePercent = {
  {"Mini Breaker", "Mini Breaker", "The Breaker"}, -- this happens at 19.5% health
  {"The Breaker", "Mini Breaker"}, -- this happens at 39% health
  {"The Breaker", "Mini Breaker"}, -- this happens at 58.5% health
  {"The Breaker", "Mini Breaker", "The Breaker"}, -- this happens at 78% health
  {"The Breaker", "Tech", "Mini Breaker"}, -- this happens at 97.5%
  {"The Breaker", "Tech", "The Breaker"}, -- this happens at 97.5% health
  {"The Breaker", "Tech", "Turbo", "Tech"}, -- this happens at 97.5% health
  {"Tech", "Tech", "Tech"}, -- this happens at 97.5% health
  {"Turbo", "Turbo", "Turbo"} -- this happens at 97.5% health
}

function onThink(cid, interval)
  if isCreature(cid) then
    local temtem = getPlayerStorageValue(cid, "temtem")
    if temtem == -1 then
      temtem = 0
    end
    
    if temtem < #damagePercent then
      local healthThreshold = (100 - (temtem * 19.5)) / 100
      if getCreatureHealth(cid) / getCreatureMaxHealth(cid) <= healthThreshold then
        local summonsList = damagePercent[temtem + 1]
        local baseSummonPos = getCreaturePosition(cid)
        
        for _, monsterName in ipairs(summonsList) do
          local freePos = getClosestFreePosition(cid, baseSummonPos)
          if freePos then 
            if doSummonCreature(monsterName, freePos)
              print("Summoned monster " .. monsterName)
            else
              print("Error: Summoning of monster " .. monsterName .. " failed.")
            end
          else
            print("Error: Unable to find a position to summon the monster " .. monsterName)
          end
        end

        setPlayerStorageValue(cid, "temtem", temtem + 1)
      end
    end
  end
  return true
end

function getClosestFreePosition(cid, baseSummonPos)
  for i = -1, 1 do
    for j = -1, 1 do
      if not (i == 0 and j == 0) then
        local newPos = {x = baseSummonPos.x + i, y = baseSummonPos.y + j, z = baseSummonPos.z}
        if isWalkable(newPos, cid, false, false) then
          return newPos
        end
      end
    end
  end
  return nil
end

function isWalkable(pos, creature, pz, monster)
  local tile = getTileThingByPos(pos)
  if tile and tile.itemid > 0 then
    local ground = getTileInfo(pos).ground
    if ground and not hasProperty(ground.uid, CONST_PROP_BLOCKSOLID) then
      if pz and getTileInfo(pos).protection then
        return false
      end
      if monster and getTopCreature(pos).uid > 0 then
        return false
      end
      return true
    end
  end
  return false
end
 
Last edited:
Sorry, I was a bit confused and frustrated. I looked at the wrong functions. It was indeed for TFS 1+, so I went back and revised everything, realizing that it was mixed with TFS 1.x + TFS 0.4. I tried to redo the script, and now everything is for TFS 0.4 correctly. Now it's just a matter of testing it. Hopefully, it should work!

Lua:
local damagePercent = {
  {"Mini Breaker", "Mini Breaker", "The Breaker"}, -- this happens at 19.5% health
  {"The Breaker", "Mini Breaker"}, -- this happens at 39% health
  {"The Breaker", "Mini Breaker"}, -- this happens at 58.5% health
  {"The Breaker", "Mini Breaker", "The Breaker"}, -- this happens at 78% health
  {"The Breaker", "Tech", "Mini Breaker"}, -- this happens at 97.5%
  {"The Breaker", "Tech", "The Breaker"}, -- this happens at 97.5% health
  {"The Breaker", "Tech", "Turbo", "Tech"}, -- this happens at 97.5% health
  {"Tech", "Tech", "Tech"}, -- this happens at 97.5% health
  {"Turbo", "Turbo", "Turbo"} -- this happens at 97.5% health
}

function onThink(cid, interval)
  if isCreature(cid) then
    local temtem = getPlayerStorageValue(cid, "temtem")
    if temtem == -1 then
      temtem = 0
    end
   
    if temtem < #damagePercent then
      local healthThreshold = (100 - (temtem * 19.5)) / 100
      if getCreatureHealth(cid) / getCreatureMaxHealth(cid) <= healthThreshold then
        local summonsList = damagePercent[temtem + 1]
        local baseSummonPos = getCreaturePosition(cid)
       
        for _, monsterName in ipairs(summonsList) do
          local freePos = getClosestFreePosition(cid, baseSummonPos)
          if freePos then
            if doSummonCreature(monsterName, freePos)
              print("Summoned monster " .. monsterName)
            else
              print("Error: Summoning of monster " .. monsterName .. " failed.")
            end
          else
            print("Error: Unable to find a position to summon the monster " .. monsterName)
          end
        end

        setPlayerStorageValue(cid, "temtem", temtem + 1)
      end
    end
  end
  return true
end

function getClosestFreePosition(cid, baseSummonPos)
  for i = -1, 1 do
    for j = -1, 1 do
      if not (i == 0 and j == 0) then
        local newPos = {x = baseSummonPos.x + i, y = baseSummonPos.y + j, z = baseSummonPos.z}
        if isWalkable(newPos, cid, false, false) then
          return newPos
        end
      end
    end
  end
  return nil
end

function isWalkable(pos, creature, pz, monster)
  local tile = getTileThingByPos(pos)
  if tile and tile.itemid > 0 then
    local ground = getTileInfo(pos).ground
    if ground and not hasProperty(ground.uid, CONST_PROP_BLOCKSOLID) then
      if pz and getTileInfo(pos).protection then
        return false
      end
      if monster and getTopCreature(pos).uid > 0 then
        return false
      end
      return true
    end
  end
  return false
end
Well, Sorry for bothering you all, but it doesn't work again, hmm.
 
Back
Top