• 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.5] Downgrade Nekiro - Add Effects Spells

Forkz

Well-Known Member
Joined
Jun 29, 2020
Messages
419
Solutions
1
Reaction score
97
Hi otlanders,

How do I add an effect while the spell is active?


LUA:
local combat = Combat()
combat:setParameter(COMBAT_PARAM_EFFECT, CONST_ME_MAGIC_GREEN)
combat:setParameter(COMBAT_PARAM_AGGRESSIVE, 0)

local condition = Condition(CONDITION_REGENERATION)
condition:setParameter(CONDITION_PARAM_SUBID, 1)
condition:setParameter(CONDITION_PARAM_BUFF_SPELL, 1)
condition:setParameter(CONDITION_PARAM_TICKS, 1 * 60 * 1000)
condition:setParameter(CONDITION_PARAM_HEALTHGAIN, 800)
condition:setParameter(CONDITION_PARAM_HEALTHTICKS, 1000)
combat:addCondition(condition)

function onCastSpell(creature, var)
    return combat:execute(creature, var)
end
 
Solution
Could it also be done so that if the player disconnects and reconnects instantly he still has the effect, of course only if he still has the condition?

Because when I have the effect and I log out and log in again, the condition remains but the effect disappears.
i did not tested it

LUA:
local config = {
  duration = 1 * 15 * 1000,
}

local effect = {
  id = CONST_ME_SOUND_BLUE,
  interval = 500,
}

local combat = Combat()
combat:setParameter(COMBAT_PARAM_EFFECT, CONST_ME_MAGIC_GREEN)
combat:setParameter(COMBAT_PARAM_AGGRESSIVE, 0)

local condition = Condition(CONDITION_REGENERATION)
condition:setParameter(CONDITION_PARAM_SUBID, 1) -- SUB_ID must be unique among other CONDITION_REGENERATION entries...
Hi otlanders,

How do I add an effect while the spell is active?


LUA:
local combat = Combat()
combat:setParameter(COMBAT_PARAM_EFFECT, CONST_ME_MAGIC_GREEN)
combat:setParameter(COMBAT_PARAM_AGGRESSIVE, 0)

local condition = Condition(CONDITION_REGENERATION)
condition:setParameter(CONDITION_PARAM_SUBID, 1)
condition:setParameter(CONDITION_PARAM_BUFF_SPELL, 1)
condition:setParameter(CONDITION_PARAM_TICKS, 1 * 60 * 1000)
condition:setParameter(CONDITION_PARAM_HEALTHGAIN, 800)
condition:setParameter(CONDITION_PARAM_HEALTHTICKS, 1000)
combat:addCondition(condition)

function onCastSpell(creature, var)
    return combat:execute(creature, var)
end
LUA:
local combat = Combat()
combat:setParameter(COMBAT_PARAM_EFFECT, CONST_ME_MAGIC_GREEN)
combat:setParameter(COMBAT_PARAM_AGGRESSIVE, 0)

local condition = Condition(CONDITION_REGENERATION)
condition:setParameter(CONDITION_PARAM_SUBID, 1) -- SUB_ID must be unique among other CONDITION_REGENERATION entries
condition:setParameter(CONDITION_PARAM_BUFF_SPELL, 1)
condition:setParameter(CONDITION_PARAM_TICKS, 1 * 15 * 1000)
condition:setParameter(CONDITION_PARAM_HEALTHGAIN, 800)
condition:setParameter(CONDITION_PARAM_HEALTHTICKS, 1000)
combat:addCondition(condition)

local effect = {
  id = CONST_ME_SOUND_BLUE,
  interval = 500,
}

local active = {}
local function sendEffect(cid)
  local p = Player(cid)
  if p and p:hasCondition(CONDITION_REGENERATION, 1 --[[SUBID HERE]]) then
    p:getPosition():sendMagicEffect(effect.id)
    addEvent(sendEffect,effect.interval,cid)
  else
    active[cid] = nil
  end
end

function onCastSpell(creature, var)
  if combat:execute(creature, var) then
    local cid = creature:getId()
    if not active[cid] then
      active[cid] = true
      addEvent(sendEffect,effect.interval,cid)
    end
    return true
  end
end
 
LUA:
local combat = Combat()
combat:setParameter(COMBAT_PARAM_EFFECT, CONST_ME_MAGIC_GREEN)
combat:setParameter(COMBAT_PARAM_AGGRESSIVE, 0)

local condition = Condition(CONDITION_REGENERATION)
condition:setParameter(CONDITION_PARAM_SUBID, 1) -- SUB_ID must be unique among other CONDITION_REGENERATION entries
condition:setParameter(CONDITION_PARAM_BUFF_SPELL, 1)
condition:setParameter(CONDITION_PARAM_TICKS, 1 * 15 * 1000)
condition:setParameter(CONDITION_PARAM_HEALTHGAIN, 800)
condition:setParameter(CONDITION_PARAM_HEALTHTICKS, 1000)
combat:addCondition(condition)

local effect = {
  id = CONST_ME_SOUND_BLUE,
  interval = 500,
}

local active = {}
local function sendEffect(cid)
  local p = Player(cid)
  if p and p:hasCondition(CONDITION_REGENERATION, 1 --[[SUBID HERE]]) then
    p:getPosition():sendMagicEffect(effect.id)
    addEvent(sendEffect,effect.interval,cid)
  else
    active[cid] = nil
  end
end

function onCastSpell(creature, var)
  if combat:execute(creature, var) then
    local cid = creature:getId()
    if not active[cid] then
      active[cid] = true
      addEvent(sendEffect,effect.interval,cid)
    end
    return true
  end
end
Could it also be done so that if the player disconnects and reconnects instantly he still has the effect, of course only if he still has the condition?

Because when I have the effect and I log out and log in again, the condition remains but the effect disappears.
 
LUA:
local combat = Combat()
combate:setParameter(COMBAT_PARAM_EFFECT, CONST_ME_MAGIC_GREEN)
combate:setParameter(COMBAT_PARAM_AGGRESSIVE, 0)

condição local = Condição (CONDITION_REGENERATION)
condição:setParameter(CONDITION_PARAM_SUBID, 1) -- SUB_ID deve ser exclusivo entre outras entradas CONDITION_REGENERATION
condição:setParameter(CONDITION_PARAM_BUFF_SPELL, 1)
condição:setParameter(CONDITION_PARAM_TICKS, 1 * 15 * 1000)
condição:setParameter(CONDITION_PARAM_HEALTHGAIN, 800)
condição:setParameter(CONDITION_PARAM_HEALTHTICKS, 1000)
combate:addCondição(condição)

efeito local = {
  id = CONST_ME_SOUND_BLUE,
  intervalo = 500,
}

ativo local = {}
função local sendEffect(cid);
  local p = Jogador(cid)
  se p e p:hasCondition(CONDITION_REGENERATION, 1 --[[SUBID AQUI]]) então
    p:getPosition():sendMagicEffect(efeito.id)
    addEvent(sendEffect,efeito.intervalo,cid)
  outro
    ativo[cid] = nulo
  fim
fim

função onCastSpell(criatura, var)
  se combate:execute(criatura, var) então
    cid local = criatura:getId()
    se não estiver ativo[cid] então
      ativo[cid] = verdadeiro
      addEvent(sendEffect,efeito.intervalo,cid)
    fim
    retornar verdadeiro
  fim
fim
Working!
 
Could it also be done so that if the player disconnects and reconnects instantly he still has the effect, of course only if he still has the condition?

Because when I have the effect and I log out and log in again, the condition remains but the effect disappears.
i did not tested it

LUA:
local config = {
  duration = 1 * 15 * 1000,
}

local effect = {
  id = CONST_ME_SOUND_BLUE,
  interval = 500,
}

local combat = Combat()
combat:setParameter(COMBAT_PARAM_EFFECT, CONST_ME_MAGIC_GREEN)
combat:setParameter(COMBAT_PARAM_AGGRESSIVE, 0)

local condition = Condition(CONDITION_REGENERATION)
condition:setParameter(CONDITION_PARAM_SUBID, 1) -- SUB_ID must be unique among other CONDITION_REGENERATION entries
condition:setParameter(CONDITION_PARAM_BUFF_SPELL, 1)
condition:setParameter(CONDITION_PARAM_TICKS, config.duration)
condition:setParameter(CONDITION_PARAM_HEALTHGAIN, 800)
condition:setParameter(CONDITION_PARAM_HEALTHTICKS, 1000)
combat:addCondition(condition)

local active = {}
local function sendEffect(playerName)
  if active[playerName] and active[playerName] > (os.mtime() - config.duration) then
    local p = Player(playerName)
    if p and p:hasCondition(CONDITION_REGENERATION, 1 --[[SUBID HERE]]) then
      p:getPosition():sendMagicEffect(effect.id)
    end
    addEvent(sendEffect,effect.interval,playerName)
  else
    active[playerName] = nil
  end
end

function onCastSpell(creature, var)
  if combat:execute(creature, var) then
    local playerName = creature:getName()
    local now = os.mtime()
    if not active[playerName] or active[playerName] < now then
      if not active[playerName] then
        addEvent(sendEffect,effect.interval,playerName)
      end
      active[playerName] = now
    end
    return true
  end
end
 
Solution
i did not tested it

LUA:
local config = {
  duration = 1 * 15 * 1000,
}

local effect = {
  id = CONST_ME_SOUND_BLUE,
  interval = 500,
}

local combat = Combat()
combat:setParameter(COMBAT_PARAM_EFFECT, CONST_ME_MAGIC_GREEN)
combat:setParameter(COMBAT_PARAM_AGGRESSIVE, 0)

local condition = Condition(CONDITION_REGENERATION)
condition:setParameter(CONDITION_PARAM_SUBID, 1) -- SUB_ID must be unique among other CONDITION_REGENERATION entries
condition:setParameter(CONDITION_PARAM_BUFF_SPELL, 1)
condition:setParameter(CONDITION_PARAM_TICKS, config.duration)
condition:setParameter(CONDITION_PARAM_HEALTHGAIN, 800)
condition:setParameter(CONDITION_PARAM_HEALTHTICKS, 1000)
combat:addCondition(condition)

local active = {}
local function sendEffect(playerName)
  if active[playerName] and active[playerName] > (os.mtime() - config.duration) then
    local p = Player(playerName)
    if p and p:hasCondition(CONDITION_REGENERATION, 1 --[[SUBID HERE]]) then
      p:getPosition():sendMagicEffect(effect.id)
    end
    addEvent(sendEffect,effect.interval,playerName)
  else
    active[playerName] = nil
  end
end

function onCastSpell(creature, var)
  if combat:execute(creature, var) then
    local playerName = creature:getName()
    local now = os.mtime()
    if not active[playerName] or active[playerName] < now then
      if not active[playerName] then
        addEvent(sendEffect,effect.interval,playerName)
      end
      active[playerName] = now
    end
    return true
  end
end
Working, thanks <3
 
Back
Top