• 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 TFS 1.3 Spell with direction condition and position effect

Icaraii

Active Member
Joined
Jan 5, 2020
Messages
260
Reaction score
32
Hello guys, I'm doing some custom spells with sprites 96x64 and I would like a little hlep with two things.

1: How do I make the spell show effects with those variations: if player facing north or south effect x, if player facing left or right effect y.

2: As my sprites are bigger than 32x32, I need to set them in place by x,y,z, however I don't know how to set that up. I would like for when player is facing north, effect will be set a specific x,y,z. If player is facing south, effect will be set to another specific x,y,z. If player is facing left, effect will be set to another specific x,y,z. If player is facing right, effect will be set to another specific x,y,z.

Now I will put all the ways I tried to do this script and I will be glad if anyone can help me with it.

Try one:

Lua:
local combat = Combat()
combat:setParameter(COMBAT_PARAM_TYPE, COMBAT_PHYSICALDAMAGE)
combat:setParameter(COMBAT_PARAM_BLOCKARMOR, false)
combat:setParameter(COMBAT_PARAM_USECHARGES, true)

local area = createCombatArea( {
{1, 1, 1},
{0, 3, 0},
{0, 0, 0} } )
setCombatArea(combat, area)

function onGetFormulaValues(player, skill, attack, skill, factor)

    local maxHealth = player:getMaxHealth()
    local maxMana = player:getMaxMana()
    local playlvl = player:getLevel()

    if (playlvl<300) then
    local min = ((player:getLevel()) + ((maxHealth + maxMana) / 16) + (attack * 4) + (skill * 2)) * 0,5
    local max = ((player:getLevel()) + ((maxHealth + maxMana) / 16) + (attack * 4) + (skill * 2)) * 1,0
    return -min, -max
    
    else
    local min = ((300) + ((maxHealth + maxMana) / 16) + (attack * 4) + (skill * 2)) * 0,5
    local max = ((300) + ((maxHealth + maxMana) / 16) + (attack * 4) + (skill * 2)) * 1,0
    return -min, -max
    end   
end
combat:setCallback(CALLBACK_PARAM_SKILLVALUE, "onGetFormulaValues")

function onCastSpell(creature, variant, cid)
local parameters = { cid = cid, var = var}
local position = {x=getThingPos(getCreatureTarget(cid)).x+1, y=getThingPos(getCreatureTarget(cid)).y+1, z=getThingPos(getCreatureTarget(cid)).z}
doSendMagicEffect(position, 99)

local position = {x=getPlayerPosition(cid).x+1, y=getPlayerPosition(cid).y+1, z=getPlayerPosition(cid).z}
    return combat:execute(creature, variant, cid)
end

Error try 1:

Lua Script Error: [Spell Interface]
data/spells/scripts/dps/fallensword.lua:eek:nCastSpell
data/lib/compat/compat.lua:1050: attempt to compare number with boolean
stack traceback:
[C]: in function '__le'
data/lib/compat/compat.lua:1050: in function 'getThingPos'
data/spells/scripts/dps/fallensword.lua:34: in function <data/spells/scripts/dps/fallensword.lua:32>


Try 2:

Code:
local combat = Combat()
combat:setParameter(COMBAT_PARAM_TYPE, COMBAT_PHYSICALDAMAGE)
combat:setParameter(COMBAT_PARAM_BLOCKARMOR, false)
combat:setParameter(COMBAT_PARAM_USECHARGES, true)

local area = createCombatArea( {
{0, 0, 0},
{0, 3, 0},
{0, 0, 0} } )
setCombatArea(combat, area)

function onGetFormulaValues(player, skill, attack, skill, factor)

    local maxHealth = player:getMaxHealth()
    local maxMana = player:getMaxMana()
    local playlvl = player:getLevel()

    if (playlvl<300) then
    local min = ((player:getLevel()) + ((maxHealth + maxMana) / 16) + (attack * 4) + (skill * 2)) * 0,5
    local max = ((player:getLevel()) + ((maxHealth + maxMana) / 16) + (attack * 4) + (skill * 2)) * 1,0
    return -min, -max
    
    else
    local min = ((300) + ((maxHealth + maxMana) / 16) + (attack * 4) + (skill * 2)) * 0,5
    local max = ((300) + ((maxHealth + maxMana) / 16) + (attack * 4) + (skill * 2)) * 1,0
    return -min, -max
    end   
end
combat:setCallback(CALLBACK_PARAM_SKILLVALUE, "onGetFormulaValues")

function onCastSpell(creature, variant, player)
    local position = Player:getPosition()
    local effectPosition = Position({x = position.x+1, y = position.y+1, z = position.z})
    effectPosition:sendMagicEffect(99)
    return combat:execute(creature, variant)
end

error try 2:

Lua Script Error: [Spell Interface]
data/spells/scripts/dps/fallensword.lua:eek:nCastSpell
data/spells/scripts/dps/fallensword.lua:34: attempt to index local 'position' (a nil value)
stack traceback:
[C]: in function '__index'
data/spells/scripts/dps/fallensword.lua:34: in function <data/spells/scripts/dps/fallensword.lua:32>
Post automatically merged:

I manage to figure out the error, somebody close this topic please
 
Last edited:
Top