• 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 1.5] Simple Aura System

Sarah Wesker

ƐƖєgαηт Sуηтαx ❤
Staff member
TFS Developer
Support Team
Joined
Mar 16, 2017
Messages
1,418
Solutions
155
Reaction score
1,975
Location
London
GitHub
MillhioreBT
Twitch
millhiorebt
Hello everyone,

I hope you're all doing well. Today, I'm here to share a very simple aura system for TFS 1.5 that I think you'll find interesting. This system has some basic but useful configurations that can add a new touch to your gameplay.

One of the options available is the ability to add a storage system for VIP users. Additionally, you can set requirements for equipped items, which can add an extra layer of challenge to your game.

You can activate the aura using a simple command, or you can set it to automatically activate upon login. It's worth noting that if you have the equipped item requirement enabled, the aura will disappear or appear depending on whether or not you have the required item equipped.

Overall, this system is a great way to add some extra fun and challenge to your game. Give it a try and let me know what you think!
data/scripts/simple_aura.lua
Lua:
--[[
    Simple Aura System
    By: 𝓜𝓲𝓵𝓵𝓱𝓲𝓸𝓻𝓮 𝓑𝓣
    Version: 1.1
    TFS 1.5
]]--

local simpleAura = {
    talkAction = "!aura",
    distanceEffect = CONST_ANI_ENERGY,
    vipStorage = 100000,
    autoStartOnLogin = true,
    onlyWhenEquippedItems = {
        [CONST_SLOT_LEFT] = 8931,
        [CONST_SLOT_RIGHT] = 8931
    },
    auxTable = {} -- don't touch this
}

local directions = {
    DIRECTION_NORTH,
    DIRECTION_NORTHEAST,
    DIRECTION_EAST,
    DIRECTION_SOUTHEAST,
    DIRECTION_SOUTH,
    DIRECTION_SOUTHWEST,
    DIRECTION_WEST,
    DIRECTION_NORTHWEST,
    DIRECTION_NORTH
}

function simpleAura.checkItems(player)
    for slotIndex, itemId in pairs(simpleAura.onlyWhenEquippedItems) do
        local slotItem = player:getSlotItem(slotIndex)
        if not slotItem or slotItem:getId() ~= itemId then
            return false
        end
    end
    return true
end

if next(simpleAura.onlyWhenEquippedItems) then
    local ec = EventCallback

    function ec.onItemMoved(player, item, count, fromPosition, toPosition, fromCylinder, toCylinder)
        local containerPos = toPosition.x == CONTAINER_POSITION and toPosition or fromPosition
        if containerPos.x == CONTAINER_POSITION then
            local slotIndex = simpleAura.onlyWhenEquippedItems[containerPos.y]
            if slotIndex then
                if simpleAura.checkItems(player) then
                    simpleAura.init(player)
                else
                    simpleAura.stop(player)
                end
            else
                simpleAura.stop(player)
            end
        end
    end

    ec:register(--[[0]])
end

function simpleAura.init(player)
    local playerId = player:getId()
    if not simpleAura.auxTable[playerId] then
        simpleAura.auxTable[playerId] = {}
    end

    if player:getStorageValue(simpleAura.vipStorage) <= 0 then
        return
    end

    local lastDirection = nil
    local auxTable = simpleAura.auxTable[playerId]
    for index, direction in pairs(directions) do
        auxTable[index] = addEvent(simpleAura.iterate, 125 * (index - 1), playerId, direction, lastDirection, index)
        lastDirection = direction
    end
end

function simpleAura.iterate(playerId, direction, lastDirection, index)
    local player = Player(playerId)
    if not player then
        return
    end

    if lastDirection then
        local lastPos = player:getPosition()
        lastPos:getNextPosition(lastDirection)
        local pos = player:getPosition()
        pos:getNextPosition(direction)
        lastPos:sendDistanceEffect(pos, simpleAura.distanceEffect)
    end

    if index == 9 then
        simpleAura.init(player)
    end
end

function simpleAura.stop(player)
    local playerId = player:getId()
    local auxTable = simpleAura.auxTable[playerId]
    if auxTable then
        for _, eventId in pairs(auxTable) do
            stopEvent(eventId)
        end
        simpleAura.auxTable[playerId] = nil
    end
    return true
end

local talkAction = TalkAction(simpleAura.talkAction)

function talkAction.onSay(player, words, param, type)
    if simpleAura.checkItems(player) then
        local auxTable = simpleAura.auxTable[player:getId()] or {}
        if #auxTable ~= 0 then
            player:sendCancelMessage("You already have an aura active.")
            return false
        end
        simpleAura.init(player)
    end

    return false
end

talkAction:register()

if simpleAura.autoStartOnLogin then
    local creatureEvent = CreatureEvent("AuraOnLogin")
    function creatureEvent.onLogin(player)
        if simpleAura.checkItems(player) then
            simpleAura.init(player)
        end
        return true
    end

    creatureEvent:register()
    local creatureEvent = CreatureEvent("AuraOnLogout")
    creatureEvent.onLogout = simpleAura.stop
    creatureEvent:register()
end

uff.gif
 
Last edited:
Cool system but i don't think so its good idea to handle this kind of visuals serverside, its much better to just send aura it to client and handle animations clientside, you don't rly want addEvent * playernumber every 125 ms
 
Cool system but i don't think so its good idea to handle this kind of visuals serverside, its much better to just send aura it to client and handle animations clientside, you don't rly want addEvent * playernumber every 125 ms
While it's more efficient to handle this on the client, there's nothing wrong with doing it from the server.
it could be many years before lastEventTimerId overflows, even with many online players.
And that's assuming it never server shutdowns eventually.
 
could possibly use this system to show that player has any item that has element protection and then cast the aura image for each element protection so would have the poison energy e.g flying around :D could use different color with the shaders to show if its penalty or absorbtion. :) just idea
 
Hello everyone,

I hope you're all doing well. Today, I'm here to share a very simple aura system for TFS 1.5 that I think you'll find interesting. This system has some basic but useful configurations that can add a new touch to your gameplay.

One of the options available is the ability to add a storage system for VIP users. Additionally, you can set requirements for equipped items, which can add an extra layer of challenge to your game.

You can activate the aura using a simple command, or you can set it to automatically activate upon login. It's worth noting that if you have the equipped item requirement enabled, the aura will disappear or appear depending on whether or not you have the required item equipped.

Overall, this system is a great way to add some extra fun and challenge to your game. Give it a try and let me know what you think!
data/scripts/simple_aura.lua
Lua:
--[[
    Simple Aura System
    By: 𝓜𝓲𝓵𝓵𝓱𝓲𝓸𝓻𝓮 𝓑𝓣
    Version: 1.1
    TFS 1.5
]]--

local simpleAura = {
    talkAction = "!aura",
    distanceEffect = CONST_ANI_ENERGY,
    vipStorage = 100000,
    autoStartOnLogin = true,
    onlyWhenEquippedItems = {
        [CONST_SLOT_LEFT] = 8931,
        [CONST_SLOT_RIGHT] = 8931
    },
    auxTable = {} -- don't touch this
}

local directions = {
    DIRECTION_NORTH,
    DIRECTION_NORTHEAST,
    DIRECTION_EAST,
    DIRECTION_SOUTHEAST,
    DIRECTION_SOUTH,
    DIRECTION_SOUTHWEST,
    DIRECTION_WEST,
    DIRECTION_NORTHWEST,
    DIRECTION_NORTH
}

function simpleAura.checkItems(player)
    for slotIndex, itemId in pairs(simpleAura.onlyWhenEquippedItems) do
        local slotItem = player:getSlotItem(slotIndex)
        if not slotItem or slotItem:getId() ~= itemId then
            return false
        end
    end
    return true
end

if next(simpleAura.onlyWhenEquippedItems) then
    local ec = EventCallback

    function ec.onItemMoved(player, item, count, fromPosition, toPosition, fromCylinder, toCylinder)
        local containerPos = toPosition.x == CONTAINER_POSITION and toPosition or fromPosition
        if containerPos.x == CONTAINER_POSITION then
            local slotIndex = simpleAura.onlyWhenEquippedItems[containerPos.y]
            if slotIndex then
                if simpleAura.checkItems(player) then
                    simpleAura.init(player)
                else
                    simpleAura.stop(player)
                end
            else
                simpleAura.stop(player)
            end
        end
    end

    ec:register(--[[0]])
end

function simpleAura.init(player)
    local playerId = player:getId()
    if not simpleAura.auxTable[playerId] then
        simpleAura.auxTable[playerId] = {}
    end

    if player:getStorageValue(simpleAura.vipStorage) <= 0 then
        return
    end

    local lastDirection = nil
    local auxTable = simpleAura.auxTable[playerId]
    for index, direction in pairs(directions) do
        auxTable[index] = addEvent(simpleAura.iterate, 125 * (index - 1), playerId, direction, lastDirection, index)
        lastDirection = direction
    end
end

function simpleAura.iterate(playerId, direction, lastDirection, index)
    local player = Player(playerId)
    if not player then
        return
    end

    if lastDirection then
        local lastPos = player:getPosition()
        lastPos:getNextPosition(lastDirection)
        local pos = player:getPosition()
        pos:getNextPosition(direction)
        lastPos:sendDistanceEffect(pos, simpleAura.distanceEffect)
    end

    if index == 9 then
        simpleAura.init(player)
    end
end

function simpleAura.stop(player)
    local playerId = player:getId()
    local auxTable = simpleAura.auxTable[playerId]
    if auxTable then
        for _, eventId in pairs(auxTable) do
            stopEvent(eventId)
        end
        simpleAura.auxTable[playerId] = nil
    end
    return true
end

local talkAction = TalkAction(simpleAura.talkAction)

function talkAction.onSay(player, words, param, type)
    if simpleAura.checkItems(player) then
        local auxTable = simpleAura.auxTable[player:getId()] or {}
        if #auxTable ~= 0 then
            player:sendCancelMessage("You already have an aura active.")
            return false
        end
        simpleAura.init(player)
    end

    return false
end

talkAction:register()

if simpleAura.autoStartOnLogin then
    local creatureEvent = CreatureEvent("AuraOnLogin")
    function creatureEvent.onLogin(player)
        if simpleAura.checkItems(player) then
            simpleAura.init(player)
        end
        return true
    end

    creatureEvent:register()
    local creatureEvent = CreatureEvent("AuraOnLogout")
    creatureEvent.onLogout = simpleAura.stop
    creatureEvent:register()
end

View attachment 74372


Nice Sarah, i tried to add multiple effects ( 4x in total) surrounding the target by using
Lua:
addEvent(simpleAura.init(player),......)

However, i know this is not correct, as im not able to stop an event triggering another event that are looping.
I failed on removing the 4 effects surrounding the player, so was wondering if you could give me a hint on how to add more effects ( that is 4 energy balls) to it?
 
This would be a fun spell addition to mages, at least for early game where you have this ball flying around you doing damage to everything it touches. Even 1-2 damage per hit would be good if the ball lasted like a minute
 
[error] Lua script error:
scriptInterface: [Scripts Interface]
scriptId: [C:\xampp\htdocs\Servidor\data-otservbr-global/scripts\actions\other\others\simple_aura.lua]
timerEvent: []
callbackId:[]
function: [Scripts Interface]
error [EventCallback is nil, failed to register script
stack traceback:
[C]: in function 'register'
...rvbr-global/scripts\actions\other\others\simple_aura.lua:54: in main chunk]

[error] Lua script error:
scriptInterface: [Scripts Interface]
scriptId: [C:\xampp\htdocs\Servidor\data-otservbr-global/scripts\actions\other\others\simple_aura.lua]
timerEvent: []
callbackId:[]
function: [Scripts Interface]
error [TalkAction with name !aura does't have groupType
stack traceback:
[C]: in function 'register'
 
[error] Lua script error:
scriptInterface: [Scripts Interface]
scriptId: [C:\xampp\htdocs\Servidor\data-otservbr-global/scripts\actions\other\others\simple_aura.lua]
timerEvent: []
callbackId:[]
function: [Scripts Interface]
error [EventCallback is nil, failed to register script
stack traceback:
[C]: in function 'register'
...rvbr-global/scripts\actions\other\others\simple_aura.lua:54: in main chunk]

[error] Lua script error:
scriptInterface: [Scripts Interface]
scriptId: [C:\xampp\htdocs\Servidor\data-otservbr-global/scripts\actions\other\others\simple_aura.lua]
timerEvent: []
callbackId:[]
function: [Scripts Interface]
error [TalkAction with name !aura does't have groupType
stack traceback:
[C]: in function 'register'
I don't think the main script supports otservbr, only tfs 1.5
 
Back
Top