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

TFS 0.X How to make a spell in area that set a storage to eveyone around for 10 seconds

Solution
This?
Lua:
local combat = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_EFFECT, CONST_ME_MORTAREA)
setCombatParam(combat, COMBAT_PARAM_AGGRESSIVE, 0)

local t = {}
function onTileCombat(cid, position)
    pid = getTopCreature(position).uid
    if pid > 0 then
        if pid ~= cid then
            table.insert(t, pid)
        end
    end
    return true
end

setCombatArea(combat, createCombatArea(AREA_SQUARE1X1))
setCombatCallback(combat, CALLBACK_PARAM_TARGETTILE, "onTileCombat")

function onCastSpell(cid, var)
    if doCombat(cid, combat, var) then
        for i = 1, #t do
            local pid = t[i]
            doCreatureSay(pid, "Cursed!", TALKTYPE_MONSTER, false)
            doCreatureSetStorage(pid, 668, 1)...
creatureList - declare it yourself, put found creatures in it
ticks - declare it yourself (10 if you wanted 10 sec)

in spell:

Code:
doSomething(creatureList, ticks)

the function:

Code:
function doSomething(creatureList, ticks)
	for i = 1, #creatureList do
		local creature = creatureList[i] -- treat it as cid
		-- check if creature still exists (I forgot what function did that in 0.4)
		-- do something
	end

	if ticks > 0 then
		addEvent(doSomething, 1000, creatureList, ticks - 1)
	end
end
 
Wouldn't be better if you add a condition ?

Explain what you wanna do, some people might not know what spell is that.
Idk, is it possible?

What i wanna do is:
Add a storage in a monster and in a player so i can deal with this as a debuff
So those monsters/players recive more dmg


creatureList - declare it yourself, put found creatures in it
ticks - declare it yourself (10 if you wanted 10 sec)

in spell:

Code:
doSomething(creatureList, ticks)

the function:

Code:
function doSomething(creatureList, ticks)
    for i = 1, #creatureList do
        local creature = creatureList[i] -- treat it as cid
        -- check if creature still exists (I forgot what function did that in 0.4)
        -- do something
    end

    if ticks > 0 then
        addEvent(doSomething, 1000, creatureList, ticks - 1)
    end
end

i tried this
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_SUBID, 68)
setConditionParam(condition, CONDITION_PARAM_BUFF, true)
setCombatCondition(combat, condition)

local function checking(cid)
    if not getCreatureCondition(cid, CONDITION_ATTRIBUTES, 68) then
        setPlayerStorageValue(cid, 668, -1)
        return false
    end
    doCreatureSay(cid, "Cursed!", TALKTYPE_MONSTER, false)
    addEvent(checking, 2000, cid) -- back to normal
end

function onTileCombat(cid, position)
    pid = getTopCreature(position).uid
    doAddCondition(pid, condition)
    if pid ~= cid then
        doCreatureSay(pid, "Cursed!", TALKTYPE_MONSTER, false)
        doAddCondition(pid, condition)
        doCreatureSetStorage(pid, 668, 1)
        checking(cid)
    end
    return true
end

local area = createCombatArea(AREA_SQUARE3X3)
setCombatArea(combat, area)
setCombatCallback(combat, CALLBACK_PARAM_TARGETTILE, "onTileCombat")

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

but it don't affect the monsters around and also dont affect the players around :(
 
I also tried this:
Code:
local combat = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_EFFECT, CONST_ME_MAGIC_RED)
setCombatParam(combat, COMBAT_PARAM_EFFECT, CONST_ME_HITAREA)
setCombatParam(combat, COMBAT_PARAM_AGGRESSIVE, false)

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

local condition = createConditionObject(CONDITION_ATTRIBUTES)
setConditionParam(condition, CONDITION_PARAM_TICKS, 10000)
setConditionParam(condition, CONDITION_PARAM_SUBID, 68)
setConditionParam(condition, CONDITION_PARAM_BUFF, true)
setCombatCondition(combat, condition)

local function checking(cid)
    if not getCreatureCondition(cid, CONDITION_ATTRIBUTES, 68) then
        setPlayerStorageValue(cid, 668, -1)
        return false
    end
    doCreatureSay(cid, "Cursed!", TALKTYPE_MONSTER, false)
    addEvent(checking, 2000, cid) -- back to normal
end

function onTileCombat(cid, position)
    pid = getTopCreature(position).uid
    doAddCondition(pid, condition)
    if pid ~= cid then
        doCreatureSay(pid, "Cursed!", TALKTYPE_MONSTER, false)
        doAddCondition(pid, condition)
        doCreatureSetStorage(pid, 668, 1)
        checking(cid)
    end
    return true
end

function onCastSpell(cid, var)
    doCombat(cid, combat, var)
    return true
end
But with the same old no effect...

The target on area are not saying: "Cursed!"
 
This?
Lua:
local combat = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_EFFECT, CONST_ME_MORTAREA)
setCombatParam(combat, COMBAT_PARAM_AGGRESSIVE, 0)

local t = {}
function onTileCombat(cid, position)
    pid = getTopCreature(position).uid
    if pid > 0 then
        if pid ~= cid then
            table.insert(t, pid)
        end
    end
    return true
end

setCombatArea(combat, createCombatArea(AREA_SQUARE1X1))
setCombatCallback(combat, CALLBACK_PARAM_TARGETTILE, "onTileCombat")

function onCastSpell(cid, var)
    if doCombat(cid, combat, var) then
        for i = 1, #t do
            local pid = t[i]
            doCreatureSay(pid, "Cursed!", TALKTYPE_MONSTER, false)
            doCreatureSetStorage(pid, 668, 1)
            addEvent(function()
                if isCreature(pid) then -- check if pid still exists
                    doCreatureSetStorage(pid, 668, -1)
                    doCreatureSay(pid, "Remove Storage!", TALKTYPE_MONSTER, false)
                end
            end, 3 * 1000)
        end
        t = {}
        return true
    end
end
 
Solution
This?
Lua:
local combat = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_EFFECT, CONST_ME_MORTAREA)
setCombatParam(combat, COMBAT_PARAM_AGGRESSIVE, 0)

local t = {}
function onTileCombat(cid, position)
    pid = getTopCreature(position).uid
    if pid > 0 then
        if pid ~= cid then
            table.insert(t, pid)
        end
    end
    return true
end

setCombatArea(combat, createCombatArea(AREA_SQUARE1X1))
setCombatCallback(combat, CALLBACK_PARAM_TARGETTILE, "onTileCombat")

function onCastSpell(cid, var)
    if doCombat(cid, combat, var) then
        for i = 1, #t do
            local pid = t[i]
            doCreatureSay(pid, "Cursed!", TALKTYPE_MONSTER, false)
            doCreatureSetStorage(pid, 668, 1)
            addEvent(function()
                if isCreature(pid) then -- check if pid still exists
                    doCreatureSetStorage(pid, 668, -1)
                    doCreatureSay(pid, "Remove Storage!", TALKTYPE_MONSTER, false)
                end
            end, 3 * 1000)
        end
        t = {}
        return true
    end
end

That is it!
Thank you so much!
Post automatically merged:

Did u know how to check target storage on

weapons/scripts/swords.lua
Code:
local combat = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_BLOCKARMOR, 1)
setCombatParam(combat, COMBAT_PARAM_TYPE, COMBAT_PHYSICALDAMAGE)

function onGetFormulaValues(cid, level, skill, attack, factor)
    min = ((damagebase_min) * (attack * 12) * (skill * 3)) * -0.10
    max = ((damagebase_max) * (attack * 12) * (skill * 3)) * -1.00
    return min, max
end
setCombatCallback(combat, CALLBACK_PARAM_SKILLVALUE, "onGetFormulaValues")

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


and spells/scripts/attack/sudden death.lua
Code:
local combat = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_TARGETCASTERORTOPMOST, true)
setCombatParam(combat, COMBAT_PARAM_TYPE, COMBAT_DEATHDAMAGE)
setCombatParam(combat, COMBAT_PARAM_EFFECT, CONST_ME_MORTAREA)
setCombatParam(combat, COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_SUDDENDEATH)
setCombatParam(combat, COMBAT_PARAM_CREATEITEM, IDDOITEMAQUI)
function onGetFormulaValues(cid, level, maglevel)
    min = ( (maglevel * spellcfg_sd_warrior) * 0.5 ) * -1
    max = ( (maglevel * spellcfg_sd_warrior) * 1.0 ) * -1
    return min, max
end
setCombatCallback(combat, CALLBACK_PARAM_LEVELMAGICVALUE, "onGetFormulaValues")

function onCastSpell(cid, var)
    return doCombat(cid, combat, var)
end
 
Last edited:
Back
Top