• 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 Vocation Check in spells possible? TFS 1.2

henrik495

Henke
Joined
Jun 1, 2008
Messages
112
Reaction score
15
Location
sweden
Hello, i was wondering if it's possible to do something like this and if anyone knows how, tryied to play around with it but couldn't find anything working, but i'm not very experienced either so i was wondering if there's anyone out there that would help me? :D
for example if a elder druid casts exori max frigo it hits as a single target , and if vocationId 9 uses exori max frigo it will cast it as an AoE around the target

Code:
local combat = Combat()
combat:setParameter(COMBAT_PARAM_TYPE, COMBAT_ICEDAMAGE)
combat:setParameter(COMBAT_PARAM_EFFECT, CONST_ME_ICEATTACK)
combat:setParameter(COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_SMALLICE)
if vocationId = (9) then
combat:setArea(createCombatArea(AREA_CROSS1X1))

function onGetFormulaValues(player, level, maglevel)
    local min = (level / 5) + (maglevel * 4.5) + 35
    local max = (level / 5) + (maglevel * 7.3) + 55
    return -min, -max
end

combat:setCallback(CALLBACK_PARAM_LEVELMAGICVALUE, "onGetFormulaValues")

function onCastSpell(creature, var)
    return combat:execute(creature, var)
end
 
Last edited:
i think it works if you put it in onGetFormulaValues like
Code:
if player:getVocation() == 9 then
setarea~
end
...

Code:
function onGetFormulaValues(player, level, maglevel)
if player:getVocation() == 9 then
setArea(createCombatArea(AREA_CROSS1X1))
end
    local min = (level / 5) + (maglevel * 4.5) + 35
    local max = (level / 5) + (maglevel * 7.3) + 55
    return -min, -max
end

like that? not working :/ but thanks for trying
 
Code:
local combat = Combat()
combat:setParameter(COMBAT_PARAM_TYPE, COMBAT_ICEDAMAGE)
combat:setParameter(COMBAT_PARAM_EFFECT, CONST_ME_ICEATTACK)
combat:setParameter(COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_SMALLICE)
combat:setArea(createCombatArea(AREA_CROSS1X1))

local combat2 = Combat()
combat2:setParameter(COMBAT_PARAM_TYPE, COMBAT_ICEDAMAGE)
combat2:setParameter(COMBAT_PARAM_EFFECT, CONST_ME_ICEATTACK)
combat2:setParameter(COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_SMALLICE)
combat2:setArea(createCombatArea(AREA_CROSS1X1))

function onGetFormulaValues(player, level, maglevel)
local min = (level / 5) + (maglevel * 4.5) + 35
local max = (level / 5) + (maglevel * 7.3) + 55
return -min, -max
end

combat:setCallback(CALLBACK_PARAM_LEVELMAGICVALUE, "onGetFormulaValues")
combat2:setCallback(CALLBACK_PARAM_LEVELMAGICVALUE, "onGetFormulaValues")

function onCastSpell(creature, var)
if voc == druid then
return combat:execute(creature, var)
elseif voc == this second guy then
return combat2:execute(creature, var)
end
end

basically you have to create 2 combats and choose one depending on the player's vocation
I'm leaving changing the area and getting player's vocation to you (it's trivial enough ...)
 
Code:
local combat = Combat()
combat:setParameter(COMBAT_PARAM_TYPE, COMBAT_ICEDAMAGE)
combat:setParameter(COMBAT_PARAM_EFFECT, CONST_ME_ICEATTACK)
combat:setParameter(COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_SMALLICE)
combat:setArea(createCombatArea(AREA_CROSS1X1))

local combat2 = Combat()
combat2:setParameter(COMBAT_PARAM_TYPE, COMBAT_ICEDAMAGE)
combat2:setParameter(COMBAT_PARAM_EFFECT, CONST_ME_ICEATTACK)
combat2:setParameter(COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_SMALLICE)
combat2:setArea(createCombatArea(AREA_CROSS1X1))

function onGetFormulaValues(player, level, maglevel)
local min = (level / 5) + (maglevel * 4.5) + 35
local max = (level / 5) + (maglevel * 7.3) + 55
return -min, -max
end

combat:setCallback(CALLBACK_PARAM_LEVELMAGICVALUE, "onGetFormulaValues")
combat2:setCallback(CALLBACK_PARAM_LEVELMAGICVALUE, "onGetFormulaValues")

function onCastSpell(creature, var)
if voc == druid then
return combat:execute(creature, var)
elseif voc == this second guy then
return combat2:execute(creature, var)
end
end

basically you have to create 2 combats and choose one depending on the player's vocation
I'm leaving changing the area and getting player's vocation to you (it's trivial enough ...)
thanks alot :D
 
Code:
local combat = Combat()
combat:setParameter(COMBAT_PARAM_TYPE, COMBAT_ICEDAMAGE)
combat:setParameter(COMBAT_PARAM_EFFECT, CONST_ME_ICEATTACK)
combat:setParameter(COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_SMALLICE)
combat:setArea(createCombatArea(AREA_CROSS1X1))

local combat2 = Combat()
combat2:setParameter(COMBAT_PARAM_TYPE, COMBAT_ICEDAMAGE)
combat2:setParameter(COMBAT_PARAM_EFFECT, CONST_ME_ICEATTACK)
combat2:setParameter(COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_SMALLICE)
combat2:setArea(createCombatArea(AREA_CROSS1X1))

function onGetFormulaValues(player, level, maglevel)
local min = (level / 5) + (maglevel * 4.5) + 35
local max = (level / 5) + (maglevel * 7.3) + 55
return -min, -max
end

combat:setCallback(CALLBACK_PARAM_LEVELMAGICVALUE, "onGetFormulaValues")
combat2:setCallback(CALLBACK_PARAM_LEVELMAGICVALUE, "onGetFormulaValues")

function onCastSpell(creature, var)
if voc == druid then
return combat:execute(creature, var)
elseif voc == this second guy then
return combat2:execute(creature, var)
end
end

basically you have to create 2 combats and choose one depending on the player's vocation
I'm leaving changing the area and getting player's vocation to you (it's trivial enough ...)

Code:
local combat = Combat()
combat:setParameter(COMBAT_PARAM_TYPE, COMBAT_ICEDAMAGE)
combat:setParameter(COMBAT_PARAM_EFFECT, CONST_ME_ICEATTACK)
combat:setParameter(COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_SMALLICE)

local combat2 = Combat()
combat2:setParameter(COMBAT_PARAM_TYPE, COMBAT_ICEDAMAGE)
combat2:setParameter(COMBAT_PARAM_EFFECT, CONST_ME_ICEATTACK)
combat2:setParameter(COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_SMALLICE)
combat2:setArea(createCombatArea(AREA_CROSS1X1))

function onGetFormulaValues(player, level, maglevel)
local min = (level / 5) + (maglevel * 4.5) + 35
local max = (level / 5) + (maglevel * 7.3) + 55
return -min, -max
end

combat:setCallback(CALLBACK_PARAM_LEVELMAGICVALUE, "onGetFormulaValues")
combat2:setCallback(CALLBACK_PARAM_LEVELMAGICVALUE, "onGetFormulaValues")

function onCastSpell(creature, var)
    if creature:getVocation():getId() ~= 9 then
        return combat:execute(creature, var)
    elseif creature:getVocation():getId() == 9 then
        return combat2:execute(creature, var)
end
end
nvm fixed, had to add onGetFormulaValues2 also
 
Last edited:
Code:
if creature:getVocation():getId() ~= 9 then
return combat:execute(creature, var)
elseif creature:getVocation():getId() == 9 then
return combat2:execute(creature, var)
end

can be reduced to

Code:
if creature:getVocation():getId() ~= 9 then
return combat:execute(creature, var)
else
return combat2:execute(creature, var)
end
:p
 
Code:
if creature:getVocation():getId() ~= 9 then
return combat:execute(creature, var)
elseif creature:getVocation():getId() == 9 then
return combat2:execute(creature, var)
end

can be reduced to

Code:
if creature:getVocation():getId() ~= 9 then
return combat:execute(creature, var)
else
return combat2:execute(creature, var)
end
:p
ty
 
Back
Top