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

Lua boss warning spell

F

Fairytail

Guest
may someone help me make a boss spell that casts warning arrows in random positions (based on a density factor or something of sort in config) that after few secs would cast damage in the warning spot areas? tfs1.4.2

or even if just a constant area
 
Last edited by a moderator:
umm so chatgpt helped me do this xD ^^' but has two issues, targeted player is never included in the area and the combat area is random but stays the same every cast and does not get randomized again until the monster moves for some reason, spent like an hour or two with chatgpt and tweaking the results, tried randomizing the density as a sort of solution but no luck if someone maybe help me fix it ^^'



Lua:
local area = {
    {1, 1, 0, 0, 0, 1, 1},
    {1, 1, 1, 0, 1, 1, 1},
    {0, 1, 1, 1, 1, 1, 0},
    {0, 0, 1, 3, 1, 0, 0},
    {0, 1, 1, 1, 1, 1, 0},
    {1, 1, 1, 0, 1, 1, 1},
    {1, 1, 0, 0, 0, 1, 1}
}

function createRandomCombatArea(area, density)
  local sizeX = #area
  local sizeY = #area[1]
  local newArea = {}

  for x = 1, sizeX do
    newArea[x] = {}
    for y = 1, sizeY do
      if area[x][y] == 3 then
        newArea[x][y] = 2
      elseif math.random(0, 100) < density then
        newArea[x][y] = 1
      else
        newArea[x][y] = 0
      end
    end
  end

  return createCombatArea(newArea)
end

local density = 50 -- density value
local combatArea = createRandomCombatArea(area, density) -- create the combat area based on the density

function onCastSpell(creature, variant)
    local target = creature:getTarget()
    if not target or not target:isPlayer() then
        return false
    end
   
    local targetPos = target:getPosition()
    creature:say("Message", TALKTYPE_MONSTER_SAY)
   

   
    doAreaCombatHealth(creature, 0, targetPos, combatArea, 0, 0, 57)
   
    addEvent(function(pos)
        local minDmg = 500 -- minimum damage value
        local maxDmg = 1500 -- maximum damage value
        local dmg = math.random(minDmg, maxDmg) -- generate a random number between min and max values
       
        doAreaCombatHealth(creature, COMBAT_ICEDAMAGE, pos, combatArea, -dmg, -dmg, 80)
    end, 3000, targetPos)
   
    return true
end
 
Back
Top