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

Spell Effect each 2s

dex93

New Member
Joined
May 31, 2015
Messages
57
Reaction score
3
Hi,
I'm trying to add a new spell for ED/MS.
I would like to do 40% resistance for death/psychical and after cast get effect every 2 seconds of
Lua:
setCombatParam(combat, COMBAT_PARAM_EFFECT, CONST_ME_MAGIC_RED)

My script looks like that :

Lua:
local combat = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_EFFECT, CONST_ME_MAGIC_RED)
setCombatParam(combat, COMBAT_PARAM_AGGRESSIVE, false)

local condition = createConditionObject(CONDITION_ATTRIBUTES)
setConditionParam(condition, CONDITION_PARAM_TICKS, 10000)
setConditionParam(condition, CONDITION_PARAM_SKILL_SHIELDPERCENT, 400)
setCombatCondition(combat, condition)

local disable = createConditionObject(CONDITION_PACIFIED)
setConditionParam(disable, CONDITION_PARAM_TICKS, 10000)
setCombatCondition(combat, disable)

local exhaust = createConditionObject(CONDITION_EXHAUST)
setConditionParam(exhaust, CONDITION_PARAM_SUBID, 1)
setConditionParam(exhaust, CONDITION_PARAM_TICKS, 10000)
setCombatCondition(combat, exhaust)

function onCastSpell(cid, var)
    return doCombat(cid, combat, var)
end

I'm beginner but I think about nice spell for I don't have enough knowledge to do this.

I would like to get every 1-2 seconds effect of magic red and resistance for death/psychical.
You can't use mana rune/potion or heal yourself for 2 seconds and this spell must be for 10s.
Could you help me?
TFS 0.4 3884
 
Solution
I didnt test it, check it out.
your spell
Code:
local combat = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_EFFECT, CONST_ME_MAGIC_RED)
setCombatParam(combat, COMBAT_PARAM_AGGRESSIVE, false)

local condition = createConditionObject(CONDITION_ATTRIBUTES)
setConditionParam(condition, CONDITION_PARAM_TICKS, 10000)
setConditionParam(condition, CONDITION_PARAM_SKILL_SHIELDPERCENT, 400)
setCombatCondition(combat, condition)

local disable = createConditionObject(CONDITION_PACIFIED)
setConditionParam(disable, CONDITION_PARAM_TICKS, 10000)
setCombatCondition(combat, disable)

local exhaust = createConditionObject(CONDITION_EXHAUST)
setConditionParam(exhaust, CONDITION_PARAM_SUBID, 1)
setConditionParam(exhaust, CONDITION_PARAM_TICKS...
I didnt test it, check it out.
your spell
Code:
local combat = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_EFFECT, CONST_ME_MAGIC_RED)
setCombatParam(combat, COMBAT_PARAM_AGGRESSIVE, false)

local condition = createConditionObject(CONDITION_ATTRIBUTES)
setConditionParam(condition, CONDITION_PARAM_TICKS, 10000)
setConditionParam(condition, CONDITION_PARAM_SKILL_SHIELDPERCENT, 400)
setCombatCondition(combat, condition)

local disable = createConditionObject(CONDITION_PACIFIED)
setConditionParam(disable, CONDITION_PARAM_TICKS, 10000)
setCombatCondition(combat, disable)

local exhaust = createConditionObject(CONDITION_EXHAUST)
setConditionParam(exhaust, CONDITION_PARAM_SUBID, 1)
setConditionParam(exhaust, CONDITION_PARAM_TICKS, 10000)
setCombatCondition(combat, exhaust)

function onCastSpell(cid, var)
   local timer = 1 -- every 1 second will be special effect, you can set to 2 or smth
   local times = 8 -- how long this spell exist (in seconds)
   setPlayerStorageValue(cid, 99, 1)
   for i = 1, times do
       addEvent(function()
           if isPlayer(cid) then
               doSendMagicEffect(getCreaturePosition(cid), CONST_ME_MAGIC_RED)
           end
       end, timer * 1000)
       if i == times then
           setPlayerStorageValue(cid, 99, -1)
       end
   end
    return doCombat(cid, combat, var)
end
add this to login lua
Code:
registerCreatureEvent(cid, "Resistance")
setPlayerStorageValue(cid, 99, -1)
add new script to creaturescripts (onStatsChange)
Code:
    function onStatsChange(cid, attacker, type, combat, value)
       if isPlayer(cid) and (type == STATSCHANGE_HEALTHLOSS or STATSCHANGE_MANALOSS) and getPlayerStorageValue(cid, 99) == 1 and (combat == COMBAT_PHYSICALDAMAGE or combat == COMBAT_DEATHDAMAGE) then
           doSendAnimatedText(getCreaturePosition(cid), "DODGED", TEXTCOLOR_WHITE)
           return false
       end
       return true
   end
 
Solution
Hi,
now it's better but I still have problem with effect. I would like to get this effect each 2 seconds. when I casted utamo exori I got magic red effect then after 2 seconds there's again magic red Effect and that's it. It's not repeating more than once.
 
seems GarQet missed some small details, here:
Lua:
function onCastSpell(cid, var)
   local timer = 1 -- every 1 second will be special effect, you can set to 2 or smth
   local times = 8 -- how long this spell exist (in seconds)
   setPlayerStorageValue(cid, 99, 1)
   for i = 1,times,timer do
       addEvent(function()
            if isPlayer(cid) then
               doSendMagicEffect(getCreaturePosition(cid), CONST_ME_MAGIC_RED)
            end
            if i == times then
                setPlayerStorageValue(cid, 99, -1)
            end
       end,  i * 1000)
   end
    return doCombat(cid, combat, var)
end
EDIT: IMPORTANT NOTE: times MUST be a multiple of timer or the resistance will last forever
Probably better if you just put another addevent like this:
Lua:
function onCastSpell(cid, var)
   local timer = 1 -- every 1 second will be special effect, you can set to 2 or smth
   local times = 8 -- how long this spell exist (in seconds)
   setPlayerStorageValue(cid, 99, 1)
   for i = 1,times,timer do
       addEvent(function()
            if isPlayer(cid) then
               doSendMagicEffect(getCreaturePosition(cid), CONST_ME_MAGIC_RED)
            end
       end,  i * 1000)
       addEvent(function()
                setPlayerStorageValue(cid, 99, -1)
       end,  times*1000)
   end
    return doCombat(cid, combat, var)
end
 
Last edited:
I tested this spell.
I got every 2s effect but dmg of SD for example are still the same :<
Psychical dmg is the same as well I think.

I tried to get 40% less from death and psychical :<
and still I didn't get animation of Dodge as is this in onStatsChange.
 
change the spell script to
Lua:
   local timer = 1 -- every 1 second will be special effect, you can set to 2 or smth
   local cooldown = 8 -- spell exhaust time
   local times = 8 -- how long this spell exist (in seconds)
function onCastSpell(cid, var)
   registerCreatureEvent(cid, 'Resistance')
        addEvent(function()
            if cid then
                setPlayerStorageValue(cid,99,-1)
            end
        end, cooldown*1000)
if getPlayerStorageValue(cid,99) == 1 then
   doSendMagicEffect(getCreaturePosition(cid), CONST_ME_POFF)
   return false
end
   for i = 1,times,timer do
       addEvent(function()
            if cid then
               doSendMagicEffect(getCreaturePosition(cid), CONST_ME_MAGIC_RED)
            end
       end,  i * 1000)
      end
       return doCombat(cid, combat, var)
   end
put this in creaturescripts.xml
XML:
<event type="statschange" name="Resistance" script="resistance.lua" />
put resistance.lua in creaturescripts:
Lua:
function onStatsChange(cid, attacker, type, combat, value)
    if isPlayer(cid) and (type == STATSCHANGE_HEALTHLOSS or STATSCHANGE_MANALOSS) and getPlayerStorageValue(cid, 99) == 1 and (combat == COMBAT_PHYSICALDAMAGE or combat == COMBAT_DEATHDAMAGE) then
        return value*0.6
    end
    return true
end
it might work
 
Still is something wrong.
I tried use your function, I created resistance and onStages etc and still nothing.
I tried change a few things and still nothing.
Without utamo exori with 500 lvl and 100 mlvl by SD dmg are between 400-500 and with utamo exori dmg by SD is still the same.
Psychical dmg is still same as well.
I'm fixing a few others scripts but with this I have the biggest problem lol :p
 
do this instead resistance.lua
Lua:
function onStatsChange(cid, attacker, type, combat, value)
    if isPlayer(cid) and (type == STATSCHANGE_HEALTHLOSS or STATSCHANGE_MANALOSS) and getPlayerStorageValue(cid, 99) == 1 and (combat == COMBAT_PHYSICALDAMAGE or combat == COMBAT_DEATHDAMAGE) then
       doTargetCombatHealth(attacker,cid,combat,value*0.6, value*0.6, CONST_ME_NONE)
        return false
    end
    return true
end
 
but the spell works fine and you get the spell effects right? and the cooldown works as intended?
Noticed some mistakes, change to this
Lua:
local res = 40 -- block percentage %
function onStatsChange(cid, attacker, type, combat, value)
    if getPlayerStorageValue(cid,99) == 1 then
        if type == STATSCHANGE_HEALTHLOSS or type == STATSCHANGE_MANALOSS then
            if combat == COMBAT_PHYSICALDAMAGE or combat == COMBAT_DEATHDAMAGE then
                doTargetCombatHealth(attacker,cid,combat,value*(1-blockpercent/100), value*(1-blockpercent/100), CONST_ME_NONE)
                return false
            end
        end
    end
    return true
end
TFS 1.2 doesn't have onStatsChange so I can't test it, you will have to learn how to debug it yourself if it doesn't work but this is how to achieve what you want
 
Hmm, I don't know what is wrong but damage received is still same :/
I tried Death dmg and Psychical dmg and still the same.
Can I get any contact with you by pm or something?
I send you IP and you can check or something.
I don't know what's wrong ;v
 
Back
Top