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

[Help] Set Static Damage On Spells.

MarkSmartRemark

Lua-Noob in Training :D
Joined
Jan 27, 2010
Messages
139
Reaction score
3
Can someone help me put static damage on spells? i want spells to deal random damage... i already have on how to heal random damage with a math.random but i dont know how to do damage with... can anyone help? =] thanks!
 
Example with Avalanche Rune:
Code:
local combat = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_TYPE, COMBAT_ICEDAMAGE)
setCombatParam(combat, COMBAT_PARAM_EFFECT, CONST_ME_ICEAREA)
setCombatParam(combat, COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_ICE)
[B][COLOR="Red"]setAttackFormula(combat, COMBAT_FORMULA_LEVELMAGIC, 5, 5, 1.4, 2.8, 40, 70)[/COLOR][/B]

local area = createCombatArea(AREA_CIRCLE3X3)
setCombatArea(combat, area)

function onCastSpell(cid, var)
	return doCombat(cid, combat, var)
end
Replace bold red with this:
Code:
setAttackFormula(combat, COMBAT_FORMULA_DAMAGE, -100, 0, -300, 0)
This would result in Avalanche Rune hitting between 100 and 300.
 
awesome... ill give it a try as soon as i copy and paste my server files into the new one because for some reason it said invalid account when id try to use acc manager -_-...!

either way thanks! rep again lmaoo your a great help =]
 
Hey cykotitan, i tried out what you told me and it doesntt work =( i copied exactly what you put except in the combat i put combat2 since its the second parameter thingy... :x is there any other way? :p
 
I won't convert anything to be compatible only with new TFS, so I can't help you. Also this is working on 0.2
 
actually the formula changed, but its (almost) compatible with old one, so it should work. Dont remember order of parameters, but this two are still in old place(I'm 99% sure)
 
Code:
function setAttackFormula(combat, type, minl, maxl, minm, maxm, min, max)
	local min, max = min or 0, max or 0
	return setCombatFormula(combat, type, -1, 0, -1, 0, minl, maxl, minm, maxm, min, max)
end
^ oww

ok, try:
Code:
setCombatFormula(combat, COMBAT_FORMULA_DAMAGE, 0, -100, 0, -300)
 
My bad i took a while guys, wasnt around... heres the script... the static damage that i want is ALLL the way down in the second combat after the "--------------------------" let me know if you guys get anything =)

PHP:
local config = {
    followPlayer = true,
    cancelOnMove = false,
}

local distanceEffects = {
    {type = CONST_ANI_SMALLICE, from = {x = 0, y = 5}, to = {x = 0, y = 0}, interval = 100 },                                 
    {type = CONST_ANI_SMALLICE, from = {x = 1, y = 4}, to = {x = 0, y = 0}, interval = 200 },
    {type = CONST_ANI_SMALLICE, from = {x = 2, y = 3}, to = {x = 0, y = 0}, interval = 300 },                                 
    {type = CONST_ANI_SMALLICE, from = {x = 3, y = 2}, to = {x = 0, y = 0}, interval = 400 },
    {type = CONST_ANI_SMALLICE, from = {x = 4, y = 1}, to = {x = 0, y = 0}, interval = 500 },                                 
    {type = CONST_ANI_SMALLICE, from = {x = 5, y = 0}, to = {x = 0, y = 0}, interval = 600 },
    {type = CONST_ANI_SMALLICE, from = {x = 4, y = -1}, to = {x = 0, y = 0}, interval = 700 },
    {type = CONST_ANI_SMALLICE, from = {x = 3, y = -2}, to = {x = 0, y = 0}, interval = 800 },
    {type = CONST_ANI_SMALLICE, from = {x = 2, y = -3}, to = {x = 0, y = 0}, interval = 900 },
    {type = CONST_ANI_SMALLICE, from = {x = 1, y = -4}, to = {x = 0, y = 0}, interval = 1000 },
    {type = CONST_ANI_SMALLICE, from = {x = 0, y = -5}, to = {x = 0, y = 0}, interval = 1100 },
    {type = CONST_ANI_SMALLICE, from = {x = -1, y = -4}, to = {x = 0, y = 0}, interval = 1200 },
    {type = CONST_ANI_SMALLICE, from = {x = -2, y = -3}, to = {x = 0, y = 0}, interval = 1300 },
    {type = CONST_ANI_SMALLICE, from = {x = -3, y = -2}, to = {x = 0, y = 0}, interval = 1400 },
    {type = CONST_ANI_SMALLICE, from = {x = -4, y = -1}, to = {x = 0, y = 0}, interval = 1500 },
    {type = CONST_ANI_SMALLICE, from = {x = -5, y = 0}, to = {x = 0, y = 0}, interval = 1600 },
    {type = CONST_ANI_SMALLICE, from = {x = -4, y = 1}, to = {x = 0, y = 0}, interval = 1700 }, 
    {type = CONST_ANI_SMALLICE, from = {x = -3, y = 2}, to = {x = 0, y = 0}, interval = 1800 },
    {type = CONST_ANI_SMALLICE, from = {x = -2, y = 3}, to = {x = 0, y = 0}, interval = 1900 },  
    {type = CONST_ANI_SMALLICE, from = {x = -1, y = 4}, to = {x = 0, y = 0}, interval = 2000 }, 
}

local interval = {0, 0, 0, 0, 0,
}

local arr = {AREA_SQUARE1X1, AREA_SQUARE1X1, AREA_SQUARE1X1, AREA_CIRCLE1X1, AREA_CIRCLE1X1,
}

local params = {
    {[COMBAT_PARAM_TYPE] = COMBAT_NONE, [COMBAT_PARAM_EFFECT] = CONST_ANI_NONE },
    {[COMBAT_PARAM_TYPE] = COMBAT_NONE, [COMBAT_PARAM_EFFECT] = CONST_ANI_NONE },
    {[COMBAT_PARAM_TYPE] = COMBAT_NONE, [COMBAT_PARAM_EFFECT] = CONST_ANI_NONE },
    {[COMBAT_PARAM_TYPE] = COMBAT_NONE, [COMBAT_PARAM_EFFECT] = CONST_ANI_NONE },
    {[COMBAT_PARAM_TYPE] = COMBAT_NONE, [COMBAT_PARAM_EFFECT] = CONST_ANI_NONE },
}

local formulae = {
    {COMBAT_FORMULA_UNDEFINED, 0, 0, 0, 0},
    {COMBAT_FORMULA_UNDEFINED, 0, 0, 0, 0},
    {COMBAT_FORMULA_UNDEFINED, 0, 0, 0, 0},
    {COMBAT_FORMULA_UNDEFINED, 0, 0, 0, 0},
    {COMBAT_FORMULA_UNDEFINED, 0, 0, 0, 0},
}

----------------------------------------------------------------------------------------------------------------
local combat, area = {}, {}

for i, v in ipairs(arr) do
    combat[i], area[i] = createCombatObject(), createCombatArea(v)
    setCombatArea(combat[i], area[i])
    for key, value in ipairs(params[i]) do
        setCombatParam(combat[i], key, value)
    end
    setCombatFormula(combat[i], formulae[i][1], formulae[i][2], formulae[i][3], formulae[i][4], formulae[i][5])
end

local function equalPos(pos1, pos2)
    return pos1.x == pos2.x and pos1.y == pos2.y and pos1.z == pos2.z
end

local function onCastSpell1(cid, var, i, prevpos, dir)
    if isCreature(cid) then
        if config.cancelOnMove and not (equalPos(prevpos, getCreaturePosition(cid)) or dir == getCreatureLookDirection(cid)) then
            return true
        end
        if config.followPlayer and variantToPosition(var) then
            var.pos = getCreaturePosition(cid)
        end
        return doCombat(cid, combat[i], var)
    end
end

local function distanceShoot(cid, from, to, type, prevpos, dir)
    if isCreature(cid) then
        if config.cancelOnMove and not (equalPos(prevpos, getCreaturePosition(cid)) or dir == getCreatureLookDirection(cid)) then
            return true
        end
        local pos = cid
        if config.followPlayer then
            pos = getCreaturePosition(cid)
        end
        local frompos, topos = {x = pos.x, y = pos.y, z = pos.z}, {x = pos.x, y = pos.y, z = pos.z}
        frompos.x, frompos.y = frompos.x + from.x, frompos.y + from.y
        topos.x, topos.y = topos.x + to.x, topos.y + to.y
        return doSendDistanceShoot(frompos, topos, type)
    end
end

------------------------------------------------------------------------------------------------------------------------------------------
-------Config-------
local CD = 23000
local cdtime = 5

--------------------


local combat2 = createCombatObject()
setCombatParam(combat2, COMBAT_PARAM_TYPE, COMBAT_ICEDAMAGE)
setCombatParam(combat2, COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_SMALLICE)
setCombatFormula(combat2, COMBAT_FORMULA_LEVELMAGIC, -18, 0, -20, 0)

local condition2 = createConditionObject(CONDITION_PARALYZE)
setConditionParam(condition2, CONDITION_PARAM_TICKS, 4000)
setConditionParam(condition2, CONDITION_PARAM_SPEED, -100)
setCombatCondition(combat2, condition2)

-------------------------------------------------------------------------------------------------------------------------------------------

local function onCastSpell2(parameters) 
doCombat(parameters.cid, parameters.combat2, parameters.var) 
end


function onCastSpell(cid, var)
    local time = 0
    for i, v in ipairs(arr) do
        time = time+interval[i]
        addEvent(onCastSpell1, time, cid, var, i, (config.cancelOnMove and getCreaturePosition(cid) or nil), (config.cancelOnMove and getCreatureLookDirection(cid)))
    end
    for i, v in ipairs(distanceEffects) do
        addEvent(distanceShoot, v.interval, (config.followPlayer and cid or getCreaturePosition(cid)), v.from, v.to, v.type, (config.cancelOnMove and getCreaturePosition(cid) or nil), (config.cancelOnMove and getCreatureLookDirection(cid)))
    	end
	local parameters = { cid = cid, var = var, combat2 = combat2 } 
		addEvent(onCastSpell2, 2500, parameters) 
		if exhaustion.check(cid, CD) == false then
                exhaustion.set(cid, CD, cdtime)
                  else
                doPlayerSendCancel(cid, "Cooldown of FrostBolt Rank 1[" ..exhaustion.get(cid,CD).."]")
end
    return true
end

Thanks! AND if you guys could, can someone tell me how to do the sendAnimatedText thing also?... i want it to say "Frozen!" in blue letters :p With the second parameter of course since the first one only charges? feel free to use the script for yourselves :D

EDIT:
Code:
function setAttackFormula(combat, type, minl, maxl, minm, maxm, min, max)
	local min, max = min or 0, max or 0
	return setCombatFormula(combat, type, -1, 0, -1, 0, minl, maxl, minm, maxm, min, max)
end
^ oww

ok, try:
Code:
setCombatFormula(combat, COMBAT_FORMULA_DAMAGE, 0, -100, 0, -300)

Worked Perfectly!!! Thanks!
 
Last edited:
can anyone help me with the doSendAnimatedText up there? >.< with the script i put up? :p like that my spell will be done :DD thanks!!! and the animated text should do when the second parameter thingy hits since the first ones charging :p thanks!
 
LUA:
local config = {
    followPlayer = true,
    cancelOnMove = false,
}

local distanceEffects = {
    {type = CONST_ANI_SMALLICE, from = {x = 0, y = 5}, to = {x = 0, y = 0}, interval = 100 },                                 
    {type = CONST_ANI_SMALLICE, from = {x = 1, y = 4}, to = {x = 0, y = 0}, interval = 200 },
    {type = CONST_ANI_SMALLICE, from = {x = 2, y = 3}, to = {x = 0, y = 0}, interval = 300 },                                 
    {type = CONST_ANI_SMALLICE, from = {x = 3, y = 2}, to = {x = 0, y = 0}, interval = 400 },
    {type = CONST_ANI_SMALLICE, from = {x = 4, y = 1}, to = {x = 0, y = 0}, interval = 500 },                                 
    {type = CONST_ANI_SMALLICE, from = {x = 5, y = 0}, to = {x = 0, y = 0}, interval = 600 },
    {type = CONST_ANI_SMALLICE, from = {x = 4, y = -1}, to = {x = 0, y = 0}, interval = 700 },
    {type = CONST_ANI_SMALLICE, from = {x = 3, y = -2}, to = {x = 0, y = 0}, interval = 800 },
    {type = CONST_ANI_SMALLICE, from = {x = 2, y = -3}, to = {x = 0, y = 0}, interval = 900 },
    {type = CONST_ANI_SMALLICE, from = {x = 1, y = -4}, to = {x = 0, y = 0}, interval = 1000 },
    {type = CONST_ANI_SMALLICE, from = {x = 0, y = -5}, to = {x = 0, y = 0}, interval = 1100 },
    {type = CONST_ANI_SMALLICE, from = {x = -1, y = -4}, to = {x = 0, y = 0}, interval = 1200 },
    {type = CONST_ANI_SMALLICE, from = {x = -2, y = -3}, to = {x = 0, y = 0}, interval = 1300 },
    {type = CONST_ANI_SMALLICE, from = {x = -3, y = -2}, to = {x = 0, y = 0}, interval = 1400 },
    {type = CONST_ANI_SMALLICE, from = {x = -4, y = -1}, to = {x = 0, y = 0}, interval = 1500 },
    {type = CONST_ANI_SMALLICE, from = {x = -5, y = 0}, to = {x = 0, y = 0}, interval = 1600 },
    {type = CONST_ANI_SMALLICE, from = {x = -4, y = 1}, to = {x = 0, y = 0}, interval = 1700 }, 
    {type = CONST_ANI_SMALLICE, from = {x = -3, y = 2}, to = {x = 0, y = 0}, interval = 1800 },
    {type = CONST_ANI_SMALLICE, from = {x = -2, y = 3}, to = {x = 0, y = 0}, interval = 1900 },  
    {type = CONST_ANI_SMALLICE, from = {x = -1, y = 4}, to = {x = 0, y = 0}, interval = 2000 }, 
}

local interval = {0, 0, 0, 0, 0,
}

local arr = {AREA_SQUARE1X1, AREA_SQUARE1X1, AREA_SQUARE1X1, AREA_CIRCLE1X1, AREA_CIRCLE1X1,
}

local params = {
    {[COMBAT_PARAM_TYPE] = COMBAT_NONE, [COMBAT_PARAM_EFFECT] = CONST_ANI_NONE },
    {[COMBAT_PARAM_TYPE] = COMBAT_NONE, [COMBAT_PARAM_EFFECT] = CONST_ANI_NONE },
    {[COMBAT_PARAM_TYPE] = COMBAT_NONE, [COMBAT_PARAM_EFFECT] = CONST_ANI_NONE },
    {[COMBAT_PARAM_TYPE] = COMBAT_NONE, [COMBAT_PARAM_EFFECT] = CONST_ANI_NONE },
    {[COMBAT_PARAM_TYPE] = COMBAT_NONE, [COMBAT_PARAM_EFFECT] = CONST_ANI_NONE },
}

local formulae = {
    {COMBAT_FORMULA_UNDEFINED, 0, 0, 0, 0},
    {COMBAT_FORMULA_UNDEFINED, 0, 0, 0, 0},
    {COMBAT_FORMULA_UNDEFINED, 0, 0, 0, 0},
    {COMBAT_FORMULA_UNDEFINED, 0, 0, 0, 0},
    {COMBAT_FORMULA_UNDEFINED, 0, 0, 0, 0},
}

----------------------------------------------------------------------------------------------------------------
local combat, area = {}, {}

for i, v in ipairs(arr) do
    combat[i], area[i] = createCombatObject(), createCombatArea(v)
    setCombatArea(combat[i], area[i])
    for key, value in ipairs(params[i]) do
        setCombatParam(combat[i], key, value)
    end
    setCombatFormula(combat[i], formulae[i][1], formulae[i][2], formulae[i][3], formulae[i][4], formulae[i][5])
end

local function equalPos(pos1, pos2)
    return pos1.x == pos2.x and pos1.y == pos2.y and pos1.z == pos2.z
end

local function onCastSpell1(cid, var, i, prevpos, dir)
    if isCreature(cid) then
        if config.cancelOnMove and not (equalPos(prevpos, getCreaturePosition(cid)) or dir == getCreatureLookDirection(cid)) then
            return true
        end
        if config.followPlayer and variantToPosition(var) then
            var.pos = getCreaturePosition(cid)
        end
        return doCombat(cid, combat[i], var)
    end
end

local function distanceShoot(cid, from, to, type, prevpos, dir)
    if isCreature(cid) then
        if config.cancelOnMove and not (equalPos(prevpos, getCreaturePosition(cid)) or dir == getCreatureLookDirection(cid)) then
            return true
        end
        local pos = cid
        if config.followPlayer then
            pos = getCreaturePosition(cid)
        end
        local frompos, topos = {x = pos.x, y = pos.y, z = pos.z}, {x = pos.x, y = pos.y, z = pos.z}
        frompos.x, frompos.y = frompos.x + from.x, frompos.y + from.y
        topos.x, topos.y = topos.x + to.x, topos.y + to.y
        return doSendDistanceShoot(frompos, topos, type)
    end
end

------------------------------------------------------------------------------------------------------------------------------------------
-------Config-------
local CD = 23000
local cdtime = 5

--------------------


local combat2 = createCombatObject()
setCombatParam(combat2, COMBAT_PARAM_TYPE, COMBAT_ICEDAMAGE)
setCombatParam(combat2, COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_SMALLICE)
setCombatFormula(combat2, COMBAT_FORMULA_LEVELMAGIC, -18, 0, -20, 0)

local condition2 = createConditionObject(CONDITION_PARALYZE)
setConditionParam(condition2, CONDITION_PARAM_TICKS, 4000)
setConditionParam(condition2, CONDITION_PARAM_SPEED, -100)
setCombatCondition(combat2, condition2)

-------------------------------------------------------------------------------------------------------------------------------------------

local function onCastSpell2(parameters) 
doCombat(parameters.cid, parameters.combat2, parameters.var)
doSendAnimatedText(getCreaturePosition(cid), "MAX9LETTERS", 89) 
end


function onCastSpell(cid, var)
    local time = 0
    for i, v in ipairs(arr) do
        time = time+interval[i]
        addEvent(onCastSpell1, time, cid, var, i, (config.cancelOnMove and getCreaturePosition(cid) or nil), (config.cancelOnMove and getCreatureLookDirection(cid)))
    end
    for i, v in ipairs(distanceEffects) do
        addEvent(distanceShoot, v.interval, (config.followPlayer and cid or getCreaturePosition(cid)), v.from, v.to, v.type, (config.cancelOnMove and getCreaturePosition(cid) or nil), (config.cancelOnMove and getCreatureLookDirection(cid)))
        end
    local parameters = { cid = cid, var = var, combat2 = combat2 } 
        addEvent(onCastSpell2, 2500, parameters) 
        if exhaustion.check(cid, CD) == false then
                exhaustion.set(cid, CD, cdtime)
                  else
                doPlayerSendCancel(cid, "Cooldown of FrostBolt Rank 1[" ..exhaustion.get(cid,CD).."]")
end
    return true
end

not tested!
try to mess around with it by adding this line:
LUA:
doSendAnimatedText(getCreaturePosition(cid), "MAX9LETTERS", 89)

I'm not quiet sure where to add it, but try the script above to test it out!
 
Back
Top