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

Magic Wall Math Random TFS 1.3

IgoR lYCAN

New Member
Joined
Dec 1, 2018
Messages
169
Reaction score
4
TFS 1.3
How to set a duration, that will be beetween 14~20 seconds.



lua script :

LUA:
local combat = Combat()
combat:setParameter(COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_ENERGY)
combat:setParameter(COMBAT_PARAM_CREATEITEM, ITEM_MAGICWALL)

function onCastSpell(creature, var, isHotkey)
    return combat:execute(creature, var)
end

tag :
XML:
    <rune group="attack" spellid="86" name="Magic Wall" id="2293" allowfaruse="1" charges="3" lvl="1" maglv="0" exhaustion="2000" groupcooldown="2000" blocktype="all" script="support/magic wall rune.lua" />

on itens.xml :
XML:
    <item id="1497" article="a" name="magic wall">
        <attribute key="type" value="magicfield" />
        <attribute key="decayTo" value="0" />
        <attribute key="duration" value="20" />
    </item>
 
Last edited:
Solution
remove the xml rune registration of magic wall (from spells.xml), and add this to data/scripts/ folder:

magic_wall_rune.lua
LUA:
local combat = Combat()
combat:setParameter(COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_ENERGY)

function onCreateMagicWall(creature, tile)
    local item = Item(ITEM_MAGICWALL)
    item:setAttribute(ITEM_ATTRIBUTE_DURATION, math.random(14,20))
    return item:moveTo(tile)
    --return Game.createItem(item, 1, tile:getPosition())
end

combat:setCallback(CALLBACK_PARAM_TARGETTILE, "onCreateMagicWall")

local spell = Spell("rune")
function spell.onCastSpell(creature, variant, isHotkey)
    return combat:execute(creature, variant)
end

spell:name("Magic Wall Rune")
spell:group("attack")
spell:id(86)
spell:cooldown(2 *...
TFS version?

Give as much information as possible(TFS version, OS, errors, scripts).
Learn how to display a code through this link.
 
TFS version?


Learn how to display a code through this link.

My bad, TFS 1.3
edit: now is fine? :)
 
Last edited:
LUA:
local function removeWall(item)
doRemoveItem(item.uid) blablabla
end

function onCastSpell(cid, var)
local timer = math.random(14,20)
local mwall = doCreateItem(mwallitemid, variantToPos(var) i dont remember correct order)

addEvent(removeWall, timer, mwall)
return true
end

here is the logic, just finish this script with uids and cids and it will work like a charm
 
remove the xml rune registration of magic wall (from spells.xml), and add this to data/scripts/ folder:

magic_wall_rune.lua
LUA:
local combat = Combat()
combat:setParameter(COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_ENERGY)

function onCreateMagicWall(creature, tile)
    local item = Item(ITEM_MAGICWALL)
    item:setAttribute(ITEM_ATTRIBUTE_DURATION, math.random(14,20))
    return item:moveTo(tile)
    --return Game.createItem(item, 1, tile:getPosition())
end

combat:setCallback(CALLBACK_PARAM_TARGETTILE, "onCreateMagicWall")

local spell = Spell("rune")
function spell.onCastSpell(creature, variant, isHotkey)
    return combat:execute(creature, variant)
end

spell:name("Magic Wall Rune")
spell:group("attack")
spell:id(86)
spell:cooldown(2 * 1000)
spell:groupCooldown(2 * 1000)
spell:level(32)
spell:magicLevel(9)
spell:runeId(2293)
spell:charges(3)
spell:isBlocking(true, true)
spell:allowFarUse(true)
spell:register()
 
Last edited:
Solution
Back
Top