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

[REQUEST] Paralyze Spell

Lopaskurwa

Well-Known Member
Joined
Oct 6, 2017
Messages
912
Solutions
2
Reaction score
50
Hello
so i have request for paralyze spell so if you target player you type lets say "paralyze" that enemy becomes paralyzed and he starts to walk really slow and that paralyze effect disappears when 6 seconds pass
Using tfs 1.2
 
Just take the paralyze rune and set it as an attack, copy paste one of the attack spells in spells.xml
here is an example
HTML:
<instant group="attack" spellid="200" name="Paralyze" words="paralyze" level="1" mana="0" premium="0" range="7" needtarget="1" cooldown="1000" needlearn="0" script="support/paralyze_rune.lua" />
needtarget is the most important thing here, as it requires a target in order to cast the spell.

All we're doing here is referencing the same script of course you can copy and paste the same script and change the duration and then reference that script.
Example
LUA:
local duration = 6 * 1000 -- 6 seconds
local combat = Combat()
combat:setParameter(COMBAT_PARAM_EFFECT, CONST_ME_MAGIC_RED)

local condition = Condition(CONDITION_PARALYZE)
condition:setParameter(CONDITION_PARAM_TICKS, duration)
condition:setFormula(-1, 80, -1, 80)
combat:addCondition(condition)

function onCastSpell(creature, variant, isHotkey)
    if not combat:execute(creature, variant) then
        return false
    end

    creature:getPosition():sendMagicEffect(CONST_ME_MAGIC_GREEN)
    return true
end
 
Just take the paralyze rune and set it as an attack, copy paste one of the attack spells in spells.xml
here is an example
HTML:
<instant group="attack" spellid="200" name="Paralyze" words="paralyze" level="1" mana="0" premium="0" range="7" needtarget="1" cooldown="1000" needlearn="0" script="support/paralyze_rune.lua" />
needtarget is the most important thing here, as it requires a target in order to cast the spell.

All we're doing here is referencing the same script of course you can copy and paste the same script and change the duration and then reference that script.
Example
LUA:
local duration = 6 * 1000 -- 6 seconds
local combat = Combat()
combat:setParameter(COMBAT_PARAM_EFFECT, CONST_ME_MAGIC_RED)

local condition = Condition(CONDITION_PARALYZE)
condition:setParameter(CONDITION_PARAM_TICKS, duration)
condition:setFormula(-1, 80, -1, 80)
combat:addCondition(condition)

function onCastSpell(creature, variant, isHotkey)
    if not combat:execute(creature, variant) then
        return false
    end

    creature:getPosition():sendMagicEffect(CONST_ME_MAGIC_GREEN)
    return true
end
Thanks i'll try it today and let you know does it work or not.
 
Edit:
Untitled.png
 
swap combat:addCondition to combat:setCondition, this is TFS 1.2 not 1.3
If you want to use an outside local, you need to move the parameter into the function otherwise it loads from server start (or something along those lines..)
LUA:
local duration = 6 * 1000 -- 6 seconds
local combat = Combat()
combat:setParameter(COMBAT_PARAM_EFFECT, CONST_ME_MAGIC_RED)

local condition = Condition(CONDITION_PARALYZE)
condition:setFormula(-1, 80, -1, 80)
combat:addCondition(condition)

function onCastSpell(creature, variant, isHotkey)
    condition:setParameter(CONDITION_PARAM_TICKS, duration)
    if not combat:execute(creature, variant) then
        return false
    end

    creature:getPosition():sendMagicEffect(CONST_ME_MAGIC_GREEN)
    return true
end
there's no need to set ticks inside of a function every time the spell gets cast, it should be set outside after condition is defined
 
If you want to use an outside local, you need to move the parameter into the function otherwise it loads from server start (or something along those lines..)
LUA:
local duration = 6 * 1000 -- 6 seconds
local combat = Combat()
combat:setParameter(COMBAT_PARAM_EFFECT, CONST_ME_MAGIC_RED)

local condition = Condition(CONDITION_PARALYZE)
condition:setFormula(-1, 80, -1, 80)
combat:addCondition(condition)

function onCastSpell(creature, variant, isHotkey)
    condition:setParameter(CONDITION_PARAM_TICKS, duration)
    if not combat:execute(creature, variant) then
        return false
    end

    creature:getPosition():sendMagicEffect(CONST_ME_MAGIC_GREEN)
    return true
end
The server loads the condition & combat object when the server launches not when you execute the spell,
This here is the incorrect way to do things.
LUA:
function onCastSpell(creature, variant, isHotkey)
    -- doing things like this will cause you problems
    condition:setParameter(CONDITION_PARAM_TICKS, duration)
However you can set/add the condition within the spells execution, you just don't want to get into the bad habit of setting parameters within onCastSspell or even a user defined function because it is recreated every single time that is if it doesn't throw an error.
 
Dude where did you learn to code?
The server loads the condition & combat object when the server launches not when you execute the spell,
This here is the incorrect way to do things.
LUA:
function onCastSpell(creature, variant, isHotkey)
    -- doing things like this will cause you problems
    condition:setParameter(CONDITION_PARAM_TICKS, duration)
I don't need smack talk from you Codex. lmao
 

Similar threads

Back
Top