• 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!
  • 2026 staff recruitment is open! Check it out and consider applying!

Lua can use spell only when attack a target

Helliot1

Owner of Empire Online
Joined
Jul 26, 2017
Messages
315
Solutions
1
Reaction score
60
Hello, im creatinga spells, that only can cast when you are attacking a target

What I'm doing wrong?

LUA:
local combat = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_TYPE, COMBAT_PHYSICALDAMAGE)
setCombatParam(combat, COMBAT_PARAM_EFFECT, 4)
setCombatFormula(combat, COMBAT_FORMULA_LEVELMAGIC, -1, -20, -1, -30, 5, 5, 1, 1)

local area = createCombatArea(AREA_SQUARE1X1)
setCombatArea(combat, area)

function Creature.isMonster(self)
       return doCombat(cid, combat, var)
        end
    else
        doPlayerSendCancel(cid, "You need a target to cast this spell.")
    end
end
 
Last edited:
idk what tfs you use but you have to add that option inside your spells.xml

casterTargetOrDirection="1"
Code:
<instant group="attack" spellid="169" name="Apprentice's Strike" words="exori min flam" lvl="8" mana="6" prem="0" range="3" casterTargetOrDirection="1" blockwalls="1" cooldown="2000" groupcooldown="2000" needlearn="0" script="attack/apprentices_strike.lua">
        <vocation name="Sorcerer" />
        <vocation name="Druid" />
        <vocation name="Master Sorcerer" />
        <vocation name="Elder Druid" />
    </instant>

TFS 1.2, since u didnt state your tfs version
 
idk what tfs you use but you have to add that option inside your spells.xml

casterTargetOrDirection="1"
Code:
<instant group="attack" spellid="169" name="Apprentice's Strike" words="exori min flam" lvl="8" mana="6" prem="0" range="3" casterTargetOrDirection="1" blockwalls="1" cooldown="2000" groupcooldown="2000" needlearn="0" script="attack/apprentices_strike.lua">
        <vocation name="Sorcerer" />
        <vocation name="Druid" />
        <vocation name="Master Sorcerer" />
        <vocation name="Elder Druid" />
    </instant>

TFS 1.2, since u didnt state your tfs version

It's already active, but don't work :(. When I use a spell without a target it cast the spell..
I need a spells that only cast when I have a target selected
 
Back
Top