Spell "distance" | TFS 1.3

Salvus

Member
Joined
Feb 7, 2019
Messages
30
Reaction score
12
How can i make this spell throw bolts, arrows or spears?

Code:
local combat = Combat()
combat:setParameter(COMBAT_PARAM_TYPE, COMBAT_HOLYDAMAGE)
combat:setParameter(COMBAT_PARAM_EFFECT, 18)
combat:setParameter(COMBAT_PARAM_BLOCKARMOR, true)
combat:setParameter(COMBAT_PARAM_USECHARGES, true)
combat:setArea(createCombatArea(AREA_WAVE3))

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

combat:setCallback(CALLBACK_PARAM_SKILLVALUE, "onGetFormulaValues")

function onCastSpell(creature, variant)
    return combat:execute(creature, variant)
end
I need to add something like combat:setParameter(COMBAT_PARAM_DISTANCEEFFECT, 1) ?

I dont want the param_effect i want to trow arrows and not some magic effect
 

Apollos

Dude who does stuff
Joined
Apr 22, 2009
Messages
701
Reaction score
427
Location
United States
How can i make this spell throw bolts, arrows or spears?

Code:
local combat = Combat()
combat:setParameter(COMBAT_PARAM_TYPE, COMBAT_HOLYDAMAGE)
combat:setParameter(COMBAT_PARAM_EFFECT, 18)
combat:setParameter(COMBAT_PARAM_BLOCKARMOR, true)
combat:setParameter(COMBAT_PARAM_USECHARGES, true)
combat:setArea(createCombatArea(AREA_WAVE3))

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

combat:setCallback(CALLBACK_PARAM_SKILLVALUE, "onGetFormulaValues")

function onCastSpell(creature, variant)
    return combat:execute(creature, variant)
end
I need to add something like combat:setParameter(COMBAT_PARAM_DISTANCEEFFECT, 1) ?

I dont want the param_effect i want to trow arrows and not some magic effect
Yeah you use something like:
combat:setParameter(COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_ENERGY)

You can find the distance effects here:
or
 
OP
S

Salvus

Member
Joined
Feb 7, 2019
Messages
30
Reaction score
12
Wow, amazing. Thank you mate!

Edit:

But how i set this up?

Code:
local combat = Combat()
combat:setParameter(COMBAT_PARAM_TYPE, COMBAT_HOLYDAMAGE)
combat:setParameter(COMBAT_PARAM_EFFECT, 21)
combat:setParameter(COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_SPEAR)
combat:setParameter(COMBAT_PARAM_BLOCKARMOR, true)
combat:setParameter(COMBAT_PARAM_USECHARGES, true)
combat:setArea(createCombatArea(AREA_WAVE3))

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

combat:setCallback(CALLBACK_PARAM_SKILLVALUE, "onGetFormulaValues")

function onCastSpell(creature, variant)
    return combat:execute(creature, variant)
end
Because this aren't working.

How do i add distanceeffect on it?
 
Last edited:

Apollos

Dude who does stuff
Joined
Apr 22, 2009
Messages
701
Reaction score
427
Location
United States
Wow, amazing. Thank you mate!

Edit:

But how i set this up?

Code:
local combat = Combat()
combat:setParameter(COMBAT_PARAM_TYPE, COMBAT_HOLYDAMAGE)
combat:setParameter(COMBAT_PARAM_EFFECT, 21)
combat:setParameter(COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_SPEAR)
combat:setParameter(COMBAT_PARAM_BLOCKARMOR, true)
combat:setParameter(COMBAT_PARAM_USECHARGES, true)
combat:setArea(createCombatArea(AREA_WAVE3))

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

combat:setCallback(CALLBACK_PARAM_SKILLVALUE, "onGetFormulaValues")

function onCastSpell(creature, variant)
    return combat:execute(creature, variant)
end
Because this aren't working.

How do i add distanceeffect on it?
Be aware it's against the rules to re-post within 24 hours if you are the last person who has posted.
I didn't notice before, you can't use distance effect with area spells, unless you use the onTargetTile callback, like this:
Lua:
local combat = Combat()
combat:setParameter(COMBAT_PARAM_TYPE, COMBAT_HOLYDAMAGE)
combat:setParameter(COMBAT_PARAM_EFFECT, CONST_ME_POISONAREA)
combat:setParameter(COMBAT_PARAM_BLOCKARMOR, true)
combat:setParameter(COMBAT_PARAM_USECHARGES, true)
combat:setArea(createCombatArea(AREA_WAVE3))

function onTargetTile(creature, position)
    creature:getPosition():sendDistanceEffect(position, CONST_ANI_SPEAR)
end

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

combat:setCallback(CALLBACK_PARAM_SKILLVALUE, "onGetFormulaValues")
combat:setCallback(CALLBACK_PARAM_TARGETTILE, "onTargetTile")

function onCastSpell(creature, variant)
    return combat:execute(creature, variant)
end
This code above will send spears to all tiles in spell area. If you want it to only send distance effect to the tile infront of player you can replace onTargetTile with this:
Lua:
function onTargetTile(creature, position)
    local toPosition = creature:getPosition()
    if getDistanceBetween(toPosition, position) == 1 then
        toPosition:sendDistanceEffect(position, CONST_ANI_SPEAR)
    end
end
 
OP
S

Salvus

Member
Joined
Feb 7, 2019
Messages
30
Reaction score
12
It works perfect thank you.
And thanks about the rule reminder i need to read them.
 
Top