• 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 [Server 0.4] Spell Aura System Version 2.0

samuel157

/root
Joined
Mar 19, 2010
Messages
447
Solutions
3
Reaction score
49
Location
São Paulo, Brazil
GitHub
Samuel10M
Spell/Script
Lua:
local AURASYSTEM_STORAGE = 200001 -- STORAGE DE CONTROLE
local AURASYSTEM_AURA_DELAY = 0.1


local AURASYSTEM_CONFIG = {
DURATION = 30, -- O tempo de duração da aura
DELAY = 0.1, -- O delay, quanto menor, mais rápida a aura será.
TYPE = "all", -- O tipo de aura. [fire/ice/energy/earth/death/holy/all]
DAMAGE = {-100, -200} -- O dano da aura
}

local AURASYSTEM_DIRECTIONS = {
[NORTH] = {
    {0, 0}, {1, 0}, {1, 1}, {1, 2}, {0, 2}, {-1, 2}, {-1, 1}, {-1, 0}
},
[EAST] = {
    {0, 0}, {0, 1}, {-1, 1}, {-2, 1}, {-2, 0}, {-2, -1}, {-1, -1}, {0, -1}
},
[sOUTH] = {
    {0, 0}, {-1, 0}, {-1, -1}, {-1, -2}, {0, -2}, {1, -2}, {1, -1}, {1, 0}
},
[WEST] = {
    {0, 0}, {0, -1}, {1, -1}, {2, -1}, {2, 0}, {2, 1}, {1, 1}, {0, 1}
}
}

local AURASYSTEM_TEMPLATES = {
["fire"] = {COMBAT_FIREDAMAGE, CONST_ME_FIREATTACK},
["ice"] = {COMBAT_ICEDAMAGE, CONST_ME_ICEATTACK},
["earth"] = {COMBAT_EARTHDAMAGE, CONST_ME_SMALLPLANTS},
["energy"] = {COMBAT_ENERGYDAMAGE, CONST_ME_PURPLEENERGY},
["holy"] = {COMBAT_HOLYDAMAGE, CONST_ME_HOLYDAMAGE},
["death"] = {COMBAT_DEATHDAMAGE, CONST_ME_MORTAREA},
["all"] = {
    {COMBAT_FIREDAMAGE, CONST_ME_FIREATTACK},
    {COMBAT_ICEDAMAGE, CONST_ME_ICEATTACK},
    {COMBAT_EARTHDAMAGE, CONST_ME_SMALLPLANTS},
    {COMBAT_ENERGYDAMAGE, CONST_ME_PURPLEENERGY},
    {COMBAT_HOLYDAMAGE, CONST_ME_HOLYDAMAGE},
    {COMBAT_DEATHDAMAGE, CONST_ME_MORTAREA}
}
}

local AURASYSTEM_COUNT = 1

function doPlayerCastAura(cid, position)
if getCreatureStorage(cid, AURASYSTEM_STORAGE) == -1 then

end

local PLAYER_LOOKDIRECTION = getCreatureLookDirection(cid)

local tmp = AURASYSTEM_DIRECTIONS[PLAYER_LOOKDIRECTION][AURASYSTEM_COUNT]
local position = getPositionByDirection(getThingPosition(cid), PLAYER_LOOKDIRECTION, 1)

position.x = position.x + tmp[1]
position.y = position.y + tmp[2]

if AURASYSTEM_CONFIG.TYPE == "all" then
    local x = AURASYSTEM_TEMPLATES[AURASYSTEM_CONFIG.TYPE]
    local r = math.random(1, #x)
    doAreaCombatHealth(cid, x[r][1], position, 0, AURASYSTEM_CONFIG.DAMAGE[1], AURASYSTEM_CONFIG.DAMAGE[2], x[r][2])
else
    doAreaCombatHealth(cid, AURASYSTEM_TEMPLATES[AURASYSTEM_CONFIG.TYPE][1], position, 0, AURASYSTEM_CONFIG.DAMAGE[1], AURASYSTEM_CONFIG.DAMAGE[2], AURASYSTEM_TEMPLATES[AURASYSTEM_CONFIG.TYPE][2])
end

if getCreatureStorage(cid, AURASYSTEM_STORAGE) > os.time() then
    addEvent(doPlayerCastAura, AURASYSTEM_CONFIG.DELAY * 1000, cid)
end

AURASYSTEM_COUNT = AURASYSTEM_COUNT + 1
if AURASYSTEM_COUNT > #AURASYSTEM_DIRECTIONS[PLAYER_LOOKDIRECTION] then
    AURASYSTEM_COUNT = 1
end
end

function onCastSpell(cid, var)
if getCreatureStorage(cid, AURASYSTEM_STORAGE) > os.time() then
    return doPlayerSendDefaultCancel(cid, RETURNVALUE_NOTPOSSIBLE)
end

doCreatureSetStorage(cid, AURASYSTEM_STORAGE, os.time() + AURASYSTEM_CONFIG.DURATION)
return doPlayerCastAura(cid)
end

Spell.xml
Lua:
<instant name="Aura" words="aura" lvl="50" mana="100" prem="0" blockwalls="1" needlearn="0" event="script" value="aura spell.lua"/>

Error on Console:
Lua:
[15/09/2021 15:50:26] Reloaded spells.
[15/09/2021 15:52:55] [Warning - BaseEvents::loadFromXml] Cannot open spells.xml file.
[15/09/2021 15:52:55] Line: 2340, Info: Extra content at the end of the document
[15/09/2021 15:52:56] [Error - Game::reloadInfo] Failed to reload spells.
Code:

Clip:

 
I idented code/changed some variables, reading became easier

Lua:
local config = {
    storage = 200001, -- STORAGE DE CONTROLE
    duration = 30, -- O tempo de duração da aura
    delay = 100, -- O delay, em ms, quanto menor, mais rápida a aura será.
    type = "all", -- O tipo de aura. [fire/ice/energy/earth/death/holy/all]
    damage = { -100, -200 } -- O dano da aura
}

local directions = {
    [NORTH] = {{0, 0}, {1, 0}, {1, 1}, {1, 2}, {0, 2}, {-1, 2}, {-1, 1}, {-1, 0}},
    [EAST] = {{0, 0}, {0, 1}, {-1, 1}, {-2, 1}, {-2, 0}, {-2, -1}, {-1, -1}, {0, -1}},
    [SOUTH] = {{0, 0}, {-1, 0}, {-1, -1}, {-1, -2}, {0, -2}, {1, -2}, {1, -1}, {1, 0}},
    [WEST] = {{0, 0}, {0, -1}, {1, -1}, {2, -1}, {2, 0}, {2, 1}, {1, 1}, {0, 1}}
}

local templates = {
    ["fire"] = { COMBAT_FIREDAMAGE, CONST_ME_FIREATTACK },
    ["ice"] = { COMBAT_ICEDAMAGE, CONST_ME_ICEATTACK },
    ["earth"] = { COMBAT_EARTHDAMAGE, CONST_ME_SMALLPLANTS },
    ["energy"] = { COMBAT_ENERGYDAMAGE, CONST_ME_PURPLEENERGY },
    ["holy"] = { COMBAT_HOLYDAMAGE, CONST_ME_HOLYDAMAGE },
    ["death"] = { COMBAT_DEATHDAMAGE, CONST_ME_MORTAREA },
    ["all"] = {
        { COMBAT_FIREDAMAGE, CONST_ME_FIREATTACK },
        { COMBAT_ICEDAMAGE, CONST_ME_ICEATTACK },
        { COMBAT_EARTHDAMAGE, CONST_ME_SMALLPLANTS },
        { COMBAT_ENERGYDAMAGE, CONST_ME_PURPLEENERGY },
        { COMBAT_HOLYDAMAGE, CONST_ME_HOLYDAMAGE },
        { COMBAT_DEATHDAMAGE, CONST_ME_MORTAREA }
    }
}

local count = 1

function doPlayerCastAura(cid)
    if not isCreature(cid) then -- verifica se o jogador existe, evite com que cid seja nulo
        return
    end

    if getCreatureStorage(cid, config.storage) == -1 then
        -- cade o código daqui?
    end

    local lookDirection = getCreatureLookDirection(cid)

    local dir = directions[lookDirection][count]
    local pos = getPositionByDirection(getThingPosition(cid), lookDirection, 1)

    pos.x = pos.x + dir[1]
    pos.y = pos.y + dir[2]

    local template = templates[config.type]
    if config.type == "all" then
        local i = math.random(1, #template)
        doAreaCombatHealth(cid, template[i][1], pos, 0, config.damage[1], config.damage[2], template[i][2])
    else
        doAreaCombatHealth(cid, template[1], pos, 0, config.damage[1], config.damage[2], template[2])
    end

    if getCreatureStorage(cid, config.storage) > os.time() then
        addEvent(doPlayerCastAura, config.delay, cid)
    end

    count = count + 1
    if count > #directions[lookDirection] then
        count = 1
    end
end

function onCastSpell(cid, var)
    if getCreatureStorage(cid, config.storage) > os.time() then
        return doPlayerSendDefaultCancel(cid, RETURNVALUE_NOTPOSSIBLE)
    end

    doCreatureSetStorage(cid, config.storage, os.time() + config.duration)
    return doPlayerCastAura(cid)
end

rename your file, don't use spaces for file names.
from
XML:
value="aura spell.lua"/>
to
XML:
value="aura-spell.lua"/>
or
XML:
value="aura_spell.lua"/>
 
Last edited:
[19/10/2021 23:19:02] [Warning - BaseEvents::loadFromXml] Cannot open spells.xml file.
[19/10/2021 23:19:02] Line: 253, Info: Extra content at the end of the document


[19/10/2021 23:19:02] > ERROR: Unable to load Spells!


I did what you told me and it didn't work

@Ramon Bernardo

 

Attachments

The problem is the slash in the header:
XML:
<instant name="Aura" words="aura" lvl="50" mana="100" prem="0" blockwalls="1" needlearn="0" event="script" value="aura_spell.lua"/>
    <vocation id="1"/>
    <vocation id="2"/>
    <vocation id="3"/>
    <vocation id="4"/>
    <vocation id="5"/>
    <vocation id="6"/>
    <vocation id="7"/>
    <vocation id="8"/>
</instant>

note:
XML:
value="aura_spell.lua"/>
correct:
XML:
value="aura_spell.lua">

Spells.xml organized, download below
 

Attachments

  • organized spells.xml
    45.7 KB · Views: 2 · VirusTotal
Back
Top