• 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+ how to parse player/item to combat?

Mjmackan

Mapper ~ Writer
Premium User
Joined
Jul 18, 2009
Messages
1,424
Solutions
15
Reaction score
176
Location
Sweden
Using tfs 1.4
How would I parse for example the player to my combat?

Example script:
Lua:
local combat = Combat()
combat:setParameter(COMBAT_PARAM_TYPE, COMBAT_PHYSICALDAMAGE)
combat:setParameter(COMBAT_PARAM_EFFECT, player:getVocation():getId()) <---- This will return that player is nil, how do I parse it?
combat:setParameter(COMBAT_PARAM_BLOCKARMOR, true)
combat:setParameter(COMBAT_PARAM_USECHARGES, true)
combat:setArea(createCombatArea(AREA_SQUARE1X1))

function onGetFormulaValues(player, skill, attack, factor)
    local min = (player:getLevel() / 5) + (skill * attack * 0.03) + 7
    local max = (player:getLevel() / 5) + (skill * attack * 0.05) + 11
    return -min, -max
end

combat:setCallback(CALLBACK_PARAM_SKILLVALUE, "onGetFormulaValues")

function onCastSpell(player, variant)
    return combat:execute(player, variant)
end
 
Just move that parameter inside onCastSpell, so you can get that information from player
EDIT: Unlike TFS 0.x (which is very limited), you can do that on TFS 1.x
 
Last edited:
Just move that parameter inside onCastSpell, so you can get that information from player
EDIT: Unlike TFS 0.x (which is very limited), you can do that on TFS 1.x
Doing so, does nothing. Not even getting any errors.

Here's the code now:
Lua:
local combat = Combat()
combat:setParameter(COMBAT_PARAM_TYPE, COMBAT_PHYSICALDAMAGE)
combat:setParameter(COMBAT_PARAM_EFFECT, coolEffect) <---- This will return that player is nil, how do I parse it?
combat:setParameter(COMBAT_PARAM_BLOCKARMOR, true)
combat:setParameter(COMBAT_PARAM_USECHARGES, true)
combat:setArea(createCombatArea(AREA_SQUARE1X1))

function onGetFormulaValues(player, skill, attack, factor)
    local min = (player:getLevel() / 5) + (skill * attack * 0.03) + 7
    local max = (player:getLevel() / 5) + (skill * attack * 0.05) + 11
    return -min, -max
end

combat:setCallback(CALLBACK_PARAM_SKILLVALUE, "onGetFormulaValues")

function onCastSpell(player, variant)
local coolEffect = player:getVocation():getId()
    return combat:execute(player, variant, coolEffect)
end
 
Doing so, does nothing. Not even getting any errors.

Lua:
function onCastSpell(player, variant)
    local coolEffect = player:getVocation():getId()
    
    combat:setParameter(COMBAT_PARAM_EFFECT, coolEffect)
    return combat:execute(player, variant)
end
 
Solution
Lua:
function onCastSpell(player, variant)
    local coolEffect = player:getVocation():getId()
   
    combat:setParameter(COMBAT_PARAM_EFFECT, coolEffect)
    return combat:execute(player, variant)
end
Thanks, that worked out!
 
Back
Top