• 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 Spells conflict

lucasquevedobr

New Member
Joined
Mar 20, 2015
Messages
6
Reaction score
0
TFS: 1.3
Version: 10.98

I have 2 spells configured to apply DOT (Conditions), but:

  • when I use the Mix throw, it looks like it's conflicting with agony ground.
  • Agony ground is not applying dot.

I tried to rename the functions but it still didn't work, it looks like both lua scripts are using the same conditions or the same functions/combats.

Please help 🙏


Agony Ground

Lua:
-- Frames (1 = Area, 2 = Player, 3 = Player + Self Damaging)
local combat = {}
local combat2 = {}
local combat3 = {}

--local combat = Combat()
--combat:setParameter(COMBAT_PARAM_TYPE, COMBAT_ICEDAMAGE)

local arr = {
        {0, 1, 1, 1, 1, 1, 0},
        {1, 1, 1, 1, 1, 1, 1},
        {1, 1, 1, 1, 1, 1, 1},
        {1, 1, 1, 3, 1, 1, 1},
        {1, 1, 1, 1, 1, 1, 1},
        {1, 1, 1, 1, 1, 1, 1},
        {0, 1, 1, 1, 1, 1, 0}
      
}

local conditionFreeze = createConditionObject(CONDITION_FREEZING)
local conditionDazzled = createConditionObject(CONDITION_DAZZLED)
local conditionCurse = createConditionObject(CONDITION_CURSE)
setConditionParam(conditionFreeze, CONDITION_PARAM_DELAYED, 1)
setConditionParam(conditionDazzled, CONDITION_PARAM_DELAYED, 1)
setConditionParam(conditionCurse, CONDITION_PARAM_DELAYED, 1)

for i = 1, 49 do
    local area = createCombatArea(arr)
  
    combat[i] = Combat()
    combat[i]:setParameter(COMBAT_PARAM_TYPE, COMBAT_ICEDAMAGE)
    addCombatCondition(combat[i], conditionFreeze)
    combat[i]:setArea(area)
  
    combat2[i] = Combat()
    combat2[i]:setParameter(COMBAT_PARAM_TYPE, COMBAT_HOLYDAMAGE)
    addCombatCondition(combat2[i], conditionDazzled)
    combat2[i]:setArea(area)
  
    combat3[i] = Combat()
    combat3[i]:setParameter(COMBAT_PARAM_TYPE, COMBAT_DEATHDAMAGE)
    addCombatCondition(combat3[i], conditionCurse)
    combat3[i]:setArea(area)
end

function executeCombat(i, pos, variant)
  
    if variant.weapon == 1 then
        Position(pos):sendMagicEffect(CONST_ME_ICEAREA)
        combat[i]:execute(variant.player, variant.var)
    elseif variant.weapon == 2 then
        Position(pos):sendMagicEffect(CONST_ME_HOLYAREA)
        combat2[i]:execute(variant.player, variant.var)
    else
        Position(pos):sendMagicEffect(CONST_ME_INSECTS)
        combat3[i]:execute(variant.player, variant.var)
    end
end

function onCastSpell(creature, var)
    local id = pushThing(creature:getSlotItem(CONST_SLOT_LEFT)).itemid
    local weapon = 1
  
  
    if not ItemType(id):getWeaponType() == WEAPON_WAND then
            creature:sendCancelMessage("You need to equip an apprendice weapon to cast this spell!")
            return false
    end
  
    if string.match(getItemName(id), "crystal") then
        weapon = 1
    elseif string.match(getItemName(id), "ankh") then
        weapon = 2
    elseif string.match(getItemName(id), "skull") then
        weapon = 3
    else
        creature:sendCancelMessage("You need to equip an apprendice weapon to cast this spell!")
        return false
    end  

    local creaturepos = creature:getPosition()
    local variant = {var = var, weapon = weapon, player = creature}
  
    local level = creature:getLevel()
    local maglevel = creature:getMagicLevel()
    local min = (level / 50) + (maglevel * 0.01) + 15
    local max = (level / 50) + (maglevel * 0.02) + 25
    local conditionFormula = math.floor((creature:getLevel() / 10) + creature:getMagicLevel() / 2) * -1
  
    addDamageCondition(conditionFreeze, 20, 2000, math.floor((creature:getLevel() / 10) + creature:getMagicLevel() / 2) * -1)
    addDamageCondition(conditionDazzled, 20, 2000, math.floor((creature:getLevel() / 10) + creature:getMagicLevel() / 2) * -1)
    addDamageCondition(conditionCurse, 20, 2000, math.floor((creature:getLevel() / 10) + creature:getMagicLevel() / 2) * -1)

    if creature:getTarget() then
        creaturepos = creature:getTarget():getPosition()
    end

    local centre = {}
    local damagearea = {}
    for k,v in ipairs(arr) do
        for i = 1, #v do
            if v[i] == 3 or v[i] == 2 then
                centre.Row = k
                centre.Column = i
                table.insert(damagearea, centre)
            elseif v[i] == 1 then
                local darea = {}
                darea.Row = k
                darea.Column = i
                table.insert(damagearea, darea)
            end
        end
    end

    for i = 1,#damagearea do
        -- adjust delay randomizer here, different animations have different "sweet-spot" delays
        local modifierx = damagearea[i].Column - centre.Column
        local modifiery = damagearea[i].Row - centre.Row
        local damagepos = Position(creaturepos)
        damagepos.x = damagepos.x + modifierx
        damagepos.y = damagepos.y + modifiery
      
        combat[i]:setFormula(COMBAT_FORMULA_LEVELMAGIC, 0, -min, 0, -max)
        combat2[i]:setFormula(COMBAT_FORMULA_LEVELMAGIC, 0, -min, 0, -max)
        combat3[i]:setFormula(COMBAT_FORMULA_LEVELMAGIC, 0, -min, 0, -max)
      
        addEvent(executeCombat, (math.random(1,10) * 200) + (i * 200), i, damagepos, variant)
    end
    return true
end

Mix Throw

Lua:
-- Delay between animations.
local combat = {}
local combat2 = {}
local combat3 = {}
local combat4 = {}

-- Frames (1 = Area, 2 = Player, 3 = Player + Self Damaging)
local area = {
    {
        {0, 1, 0},
        {1, 3, 1},
        {0, 1, 0}
    },
    {
        {1, 0, 1},
        {0, 3, 0},
        {1, 0, 1}
    }
}

for i = 1, #area do
    combat[i] = Combat()
    combat[i]:setParameter(COMBAT_PARAM_TYPE, COMBAT_FIREDAMAGE)
    combat[i]:setParameter(COMBAT_PARAM_EFFECT, CONST_ME_FIREAREA)
    combat[1]:setParameter(COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_EXPLOSION)
end

for i = 1, #area do
    combat2[i] = Combat()
    combat2[i]:setParameter(COMBAT_PARAM_TYPE, COMBAT_FIREDAMAGE)
    combat2[i]:setParameter(COMBAT_PARAM_EFFECT, CONST_ME_FIREAREA)
    combat2[1]:setParameter(COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_EXPLOSION)
end

for i = 1, #area do
    combat3[i] = Combat()
    combat3[i]:setParameter(COMBAT_PARAM_TYPE, COMBAT_FIREDAMAGE)
    combat3[i]:setParameter(COMBAT_PARAM_EFFECT, CONST_ME_FIREAREA)
    combat3[1]:setParameter(COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_EXPLOSION)
end

for i = 1, #area do
    combat4[i] = Combat()
    combat4[i]:setParameter(COMBAT_PARAM_TYPE, COMBAT_FIREDAMAGE)
    combat4[i]:setParameter(COMBAT_PARAM_EFFECT, CONST_ME_FIREAREA)
    combat4[1]:setParameter(COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_EXPLOSION)
end

for x, _ in ipairs(area) do
    combat[x]:setArea(createCombatArea(area[x]))
    combat2[x]:setArea(createCombatArea(area[x]))
    combat3[x]:setArea(createCombatArea(area[x]))
    combat4[x]:setArea(createCombatArea(area[x]))
end

function executeCombatMixThrow(i, variant)
 
    if variant.curse == 1 then
        combat[i]:execute(variant.player, variant.var)
    elseif variant.curse == 2 then
        combat2[i]:execute(variant.player, variant.var)
    elseif variant.curse == 3 then
        combat3[i]:execute(variant.player, variant.var)
    else
        combat4[i]:execute(variant.player, variant.var)
    end
end


local conditionPara = createConditionObject(CONDITION_PARALYZE)
conditionPara:setFormula(-0.5, 40, -0.5, 40)

local conditionDrunk = createConditionObject(CONDITION_DRUNK)

local conditionFreeze = createConditionObject(CONDITION_FREEZING)
setConditionParam(conditionFreeze, CONDITION_PARAM_DELAYED, 1)

local conditionDazzled = createConditionObject(CONDITION_DAZZLED)
setConditionParam(conditionDazzled, CONDITION_PARAM_DELAYED, 1)

local conditionBleed = createConditionObject(CONDITION_BLEEDING)
setConditionParam(conditionBleed, CONDITION_PARAM_DELAYED, 1)

local conditionCurse = createConditionObject(CONDITION_CURSE)
setConditionParam(conditionCurse, CONDITION_PARAM_DELAYED, 1)

local conditionPoison = createConditionObject(CONDITION_POISON)
setConditionParam(conditionPoison, CONDITION_PARAM_DELAYED, 1)

local conditionBurn = createConditionObject(CONDITION_FIRE)
setConditionParam(conditionBurn, CONDITION_PARAM_DELAYED, 1)

local flasks = {7635, 7634, 7636} -- priority to great > strong > regular potion flask

function onCastSpell(player, var)

    local flaskRatio = 1
    local p = {player = player, var = var, combat = combat}
 
    if getPlayerItemCount(player, flasks[1]) > 0 then player:removeItem(flasks[1], 1, -1, false) flaskRatio = 2
    elseif     getPlayerItemCount(player, flasks[2]) > 0 then player:removeItem(flasks[2], 1, -1, false) flaskRatio = 1.5
    elseif     getPlayerItemCount(player, flasks[3]) > 0 then player:removeItem(flasks[3], 1, -1, false)
    else player:sendCancelMessage("You need a flask to cast this spell!") return false
    end

    -- Damage formula
    local level = player:getLevel()
    local maglevel = player:getMagicLevel()
    local min = (level / 5) + (maglevel * 1.0) + 10
    local max = (level / 5) + (maglevel * 1.8) + 15
    local curses = math.random(1, 4)
    local variant = {var = var, curse = curse, player = player}
 
        combat[2]:setFormula(COMBAT_FORMULA_LEVELMAGIC, 0, -min, 0, -max)
        combat2[2]:setFormula(COMBAT_FORMULA_LEVELMAGIC, 0, -min, 0, -max)
        combat3[2]:setFormula(COMBAT_FORMULA_LEVELMAGIC, 0, -min, 0, -max)
        combat4[2]:setFormula(COMBAT_FORMULA_LEVELMAGIC, 0, -min, 0, -max)
     
        if curses == 1 then
            combat[1]:setFormula(COMBAT_FORMULA_LEVELMAGIC, 0, -min, 0, -max)
            conditionPara:setParameter(CONDITION_PARAM_TICKS, 4000 * flaskRatio)                 
            addDamageCondition(conditionFreeze, 2, 2000, math.floor((level / 10) + maglevel / 2) * -1 * flaskRatio)
                 
            addCombatCondition(combat[1], conditionPara)
            addCombatCondition(combat[1], conditionFreeze)
            combat[1]:execute(player, var) 
            addEvent(executeCombatMixThrow, 150, 2, variant)
        elseif curses == 2 then
            combat2[1]:setFormula(COMBAT_FORMULA_LEVELMAGIC, 0, -min, 0, -max)
            addDamageCondition(conditionBleed, 5, 2000, math.floor((level / 10) + maglevel / 2) * -1 * flaskRatio)
            addDamageCondition(conditionCurse, 5, 2000, math.floor((level / 10) + maglevel / 2) * -1 * flaskRatio)
                 
            addCombatCondition(combat2[1], conditionBleed)
            addCombatCondition(combat2[1], conditionCurse)
            combat2[1]:execute(player, var) 
            addEvent(executeCombatMixThrow, 150, 2, variant)
        elseif curses == 3 then
            combat3[1]:setFormula(COMBAT_FORMULA_LEVELMAGIC, 0, -min, 0, -max)
            conditionDrunk:setParameter(CONDITION_PARAM_TICKS, 8000 * flaskRatio)
            addDamageCondition(conditionDazzled, 4, 2000, math.floor((level / 10) + maglevel / 2) * -1 * flaskRatio)
                 
            addCombatCondition(combat3[1], conditionDrunk)
            addCombatCondition(combat3[1], conditionDazzled)
            combat3[1]:execute(player, var)
            addEvent(executeCombatMixThrow, 150, 2, variant)                 
        else
            combat4[1]:setFormula(COMBAT_FORMULA_LEVELMAGIC, 0, -min, 0, -max)
            addDamageCondition(conditionPoison, 2, 2000, math.floor((level / 10) + maglevel / 2) * -1 * flaskRatio)
            addDamageCondition(conditionBurn, 2, 2000, math.floor((level / 10) + maglevel / 2) * -1 * flaskRatio)
                 
            addCombatCondition(combat4[1], conditionPoison)
            addCombatCondition(combat4[1], conditionBurn)
            combat4[1]:execute(player, var)
            addEvent(executeCombatMixThrow, 150, 2, variant)
        end     
    return true
end

Screenshot_1.png
 
Last edited:
Back
Top