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

TFS 1.X+ Custom Monster Spell: Instant Damage + Condition

krafttomten

Well-Known Member
Joined
Jul 23, 2017
Messages
103
Solutions
1
Reaction score
75
Location
Sweden
Hello OTland!

Does anyone know how to write a custom monster spell in lua that both adds a certain condition, let's say decrease shield skill, and also does instant damage? There are no such monster spells in the original distro that I could find by looking through all of them. And all of my tests have resulted in the monster shooting the spell so fast that the server crashes 😬

This is my code

Lua:
local combat = Combat()
combat:setParameter(COMBAT_PARAM_TYPE, COMBAT_DEATHDAMAGE)
combat:setParameter(COMBAT_PARAM_EFFECT, CONST_ME_MORTAREA)
combat:setParameter(COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_DEATH)
combat:setArea(createCombatArea(AREA_BEAM1))

local parameters = {
    {key = CONDITION_PARAM_TICKS, value = 10 * 1000},
    {key = CONDITION_PARAM_SKILL_SHIELDPERCENT, value = 60},
}

function onCastSpell(creature, variant)
    for _, target in ipairs(combat:getTargets(creature, variant)) do
        target:addAttributeCondition(parameters)
    end
    return true
end
 
Lua:
local combat = Combat()
combat:setParameter(COMBAT_PARAM_TYPE, COMBAT_DEATHDAMAGE)
combat:setParameter(COMBAT_PARAM_EFFECT, CONST_ME_MORTAREA)
combat:setParameter(COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_DEATH)
combat:setArea(createCombatArea(AREA_BEAM1))

local parameters = {
    {key = CONDITION_PARAM_TICKS, value = 10 * 1000},
    {key = CONDITION_PARAM_SKILL_SHIELDPERCENT, value = 60},
}

function onCastSpell(creature, variant)
    for _, target in ipairs(combat:getTargets(creature, variant)) do
        target:addAttributeCondition(parameters)
        combat:execute(creature, variant)
    end
    return true
end

Like so? It causes server to crash. And I have not added any damage to the spell either, and don't know how to..
 
Oh yea, it worked! Still no damage, but I found COMBAT_FORMULA_DAMAGE in the src files. Now everything works. Ty for the help Boy67

Lua:
local combat = Combat()
combat:setParameter(COMBAT_PARAM_TYPE, COMBAT_DEATHDAMAGE)
combat:setParameter(COMBAT_PARAM_EFFECT, CONST_ME_MORTAREA)
combat:setParameter(COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_DEATH)
combat:setFormula(COMBAT_FORMULA_DAMAGE, -10, -50)
combat:setArea(createCombatArea(AREA_BEAM1))


local parameters = {
    {key = CONDITION_PARAM_TICKS, value = 10 * 1000},
    {key = CONDITION_PARAM_SKILL_SHIELDPERCENT, value = 60}
}


function onCastSpell(creature, variant)
    for _, target in ipairs(combat:getTargets(creature, variant)) do
        target:addAttributeCondition(parameters)
    end
    combat:execute(creature, variant)
    return true
end
 
Oh yea, it worked! Still no damage, but I found COMBAT_FORMULA_DAMAGE in the src files. Now everything works. Ty for the help Boy67

Lua:
local combat = Combat()
combat:setParameter(COMBAT_PARAM_TYPE, COMBAT_DEATHDAMAGE)
combat:setParameter(COMBAT_PARAM_EFFECT, CONST_ME_MORTAREA)
combat:setParameter(COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_DEATH)
combat:setFormula(COMBAT_FORMULA_DAMAGE, -10, -50)
combat:setArea(createCombatArea(AREA_BEAM1))


local parameters = {
    {key = CONDITION_PARAM_TICKS, value = 10 * 1000},
    {key = CONDITION_PARAM_SKILL_SHIELDPERCENT, value = 60}
}


function onCastSpell(creature, variant)
    for _, target in ipairs(combat:getTargets(creature, variant)) do
        target:addAttributeCondition(parameters)
    end
    combat:execute(creature, variant)
    return true
end
try adding the damage into the monster xml file
 
Back
Top