• 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!

Solved - Advanced Spell

Cadyan

Well-Known Member
Joined
Mar 30, 2008
Messages
845
Reaction score
63
TFS 1.0
I want an energy attack beam that is 5 squares long, and only does damage to players who have a certain storage value. On top of that, I want a storage value set on the "area" players when it is casted on them.
Can anyone do this?
NOTE: I do NOT want onTargetCombatHealth used, because players wont get recognized as the monster killer for some reason. I also want the damage to be set with a "Formula" above combat.
 
NOTE: I do NOT want onTargetCombatHealth used, because players wont get recognized as the monster killer for some reason.
What do you mean by this? This is the function that should be used with spells like this. Maybe you used 0 instead of cid as attacker?

Code:
local combat = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_EFFECT, CONST_ME_ENERGYHIT)

local area = createCombatArea(AREA_BEAM5, AREADIAGONAL_BEAM5)
setCombatArea(combat, area)

function onTargetCreature(cid, target)
     local p = Player(cid)
     min = -((p:getLevel() / 5) + (p:getMagicLevel() * 1.8) + 11)
     max = -((p:getLevel() / 5) + (p:getMagicLevel() * 3) + 19)
     if target and Player(target) then
         if p:getStorageValue(8000) >= 1 then
             doTargetCombatHealth(cid, target, COMBAT_ENERGYDAMAGE, min, max, CONST_ME_NONE)
             p:setStorageValue(7000, 1)
         end
     end
     return true
end

setCombatCallback(combat, CALLBACK_PARAM_TARGETCREATURE, "onTargetCreature")

function onCastSpell(cid, var)
     return doCombat(cid, combat, var)
end
 
Nicely done @Limos

But some things need changes, such as local p, should be local player and also createcombat and etc.. has also metatables for that:

Code:
local combat = Combat()
combat:setParameter(COMBAT_PARAM_EFFECT, CONST_ME_ENERGYHIT)

local area = createCombatArea(AREA_BEAM5, AREADIAGONAL_BEAM5)
combat:setArea(area)

function onTargetCreature(cid, target)
     local player = Player(cid)
     min = -((player:getLevel() / 5) + (player:getMagicLevel() * 1.8) + 11)
     max = -((player:getLevel() / 5) + (player:getMagicLevel() * 3) + 19)
     if target and Player(target) then
         if player:getStorageValue(8000) >= 1 then
             doTargetCombatHealth(cid, target, COMBAT_ENERGYDAMAGE, min, max, CONST_ME_NONE)
             player:setStorageValue(7000, 1)
         end
     end
     return true
end

combat:setCallback(CALLBACK_PARAM_TARGETCREATURE, "onTargetCreature")

function onCastSpell(creature, var)
        return combat:execute(creature, var)
end
 
Last edited:
I just copied energy beam from the TFS 1.0 datapack on github and added the targetcreature part.
Using local p or local player doesn't matter.
 
Thank you guys - I will surely make this work! One problem though:
Do you set the storage value on target the same way? And remember, when you have a BEAM you wont have a target. So how can I set the storage value on the BEAM targets?
 
Oh ye, p:setStorageValue(7000, 1) should be:
Code:
Player(target):setStorageValue(7000, 1)
This way it will set the storage to the players that will be hit by the combat.
 
Back
Top