• 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 For tfs 0.4 [Help me with no aggressive aura effect]

ausirosiris

New Member
Joined
May 23, 2020
Messages
57
Reaction score
2
Lua:
local AURASYSTEM_STORAGE = 200001
local AURASYSTEM_AURA_DELAY = 0.1

local AURASYSTEM_CONFIG = {
DURATION = 30,
DELAY = 0.1,
TYPE = "all",
DAMAGE = {-100, -200}
}

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

I just need this to do the one specific effect around the player, nothing else, no damage and not aggressive so the effect can happen while in PZ.
 
Solution
Can anyone just help me recreate the motion of the effect around the player? that loops for a certain amount of time...
What does that motion look like?
Post automatically merged:

I'll just assume it's a simple effect that spins around the character.

Try this.
Lua:
local config = {
    interval = 330,  -- milliseconds (how fast the effect moves around the character)
    duration = 30000, -- milliseconds
    effect = CONST_ME_FIREATTACK,
    creatures = {} -- don't modify - holds creature data of people using the effect
}

local function auraEffect(cid, effect, interval, duration, offset)
    if not isPlayer(cid) then
        config.creatures[cid] = nil
        return
    end
    local positionOffsets = {{-1, -1},{-1, 0},{-1, 1},{0, 1},{1...
delete or green text these 2 lines
Lua:
doAreaCombatHealth(cid, x[r][1], position, 0, AURASYSTEM_CONFIG.DAMAGE[1], AURASYSTEM_CONFIG.DAMAGE[2], x[r][2])

doAreaCombatHealth(cid, AURASYSTEM_TEMPLATES[AURASYSTEM_CONFIG.TYPE][1], position, 0, AURASYSTEM_CONFIG.DAMAGE[1], AURASYSTEM_CONFIG.DAMAGE[2], AURASYSTEM_TEMPLATES[AURASYSTEM_CONFIG.TYPE][2])
 
delete or green text these 2 lines
Lua:
doAreaCombatHealth(cid, x[r][1], position, 0, AURASYSTEM_CONFIG.DAMAGE[1], AURASYSTEM_CONFIG.DAMAGE[2], x[r][2])

doAreaCombatHealth(cid, AURASYSTEM_TEMPLATES[AURASYSTEM_CONFIG.TYPE][1], position, 0, AURASYSTEM_CONFIG.DAMAGE[1], AURASYSTEM_CONFIG.DAMAGE[2], AURASYSTEM_TEMPLATES[AURASYSTEM_CONFIG.TYPE][2])
Hello. Thanks for the reply. Yes, i've tried removing, change/rewrite with too doSendMagicEffect but, it doesn't work. If i remove, no effect will happen. I want the effect, but since combat (i dont want to) the aura, dont do the effect inside a temple, or anything with pz. I want the effect moving around the player inside a pz not just only outside. I've had a complete diff script. It was an buff spell. But i've lost it and forgot completely how i've made it. I was hoping someone could help me with just the effect, so i can add my buff specs condition later. Anyway, thank you.
Post automatically merged:

Lua:
local config = {
    storage = 1337,
    duration = 1800,
    msg = "You need to wait until the buff ends to recast it."
}

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 count = 1

function onCastSpell(cid, var)
    if not isCreature(cid) then
        return
    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]
 
    if getCreatureStorage(cid, config.storage) > os.time() then
        addEvent(doCastSpell, 330, 7)


    count = count + 1
    if count > #directions[lookDirection] then
        count = 1
    end
end
if getCreatureStorage(cid, config.storage) > os.time() then
        return doPlayerSendCancel(cid, config.msg)
end
doCreatureSetStorage(cid, config.storage, os.time() + config.duration)

    doCombat(cid, combat, var)
return true
end

Just now, tried again to re-write/shorten it no errors in console but nothing happens.
 
Last edited:
Can anyone just help me recreate the motion of the effect around the player? that loops for a certain amount of time...
What does that motion look like?
Post automatically merged:

I'll just assume it's a simple effect that spins around the character.

Try this.
Lua:
local config = {
    interval = 330,  -- milliseconds (how fast the effect moves around the character)
    duration = 30000, -- milliseconds
    effect = CONST_ME_FIREATTACK,
    creatures = {} -- don't modify - holds creature data of people using the effect
}

local function auraEffect(cid, effect, interval, duration, offset)
    if not isPlayer(cid) then
        config.creatures[cid] = nil
        return
    end
    local positionOffsets = {{-1, -1},{-1, 0},{-1, 1},{0, 1},{1, 1},{1, 0},{1, -1},{0, -1}}
    local playerPos = getThingPosition(cid)
    doSendMagicEffect({x = playerPos.x + positionOffsets[offset][1], y = playerPos.y + positionOffsets[offset][2], z = playerPos.z}, effect)
    if duration <= 0 then
        config.creatures[cid] = nil
        return        
    end
    addEvent(auraEffect, interval, cid, effect, interval, duration - interval, (offset % 8) + 1)
end
    
function onCastSpell(cid, var)
    if config.creatures[cid] then
        doPlayerSendCancel(cid, "You need to wait until the buff ends to recast it.")
        return false
    end
    config.creatures[cid] = 1
    auraEffect(cid, config.effect, config.interval, config.duration, math.random(8))
    return true
end
 
Last edited:
Solution
What does that motion look like?
Post automatically merged:

I'll just assume it's a simple effect that spins around the character.

Try this.
Lua:
local config = {
    interval = 330,  -- milliseconds (how fast the effect moves around the character)
    duration = 30000, -- milliseconds
    effect = CONST_ME_FIREATTACK,
    creatures = {} -- don't modify - holds creature data of people using the effect
}

local function auraEffect(cid, effect, interval, duration, offset)
    if not isPlayer(cid) then
        config.creatures[cid] = nil
        return
    end
    local positionOffsets = {{-1, -1},{-1, 0},{-1, 1},{0, 1},{1, 1},{1, 0},{1, -1},{0, -1}}
    local playerPos = getThingPosition(cid)
    doSendMagicEffect({x = playerPos.x + positionOffsets[offset][1], y = playerPos.y + positionOffsets[offset][2], z = playerPos.z}, effect)
    if duration <= 0 then
        config.creatures[cid] = nil
        return       
    end
    addEvent(auraEffect, interval, cid, effect, interval, duration - interval, (offset % 8) + 1)
end
   
function onCastSpell(cid, var)
    if config.creatures[cid] then
        doPlayerSendCancel(cid, "You need to wait until the buff ends to recast it.")
        return false
    end
    config.creatures[cid] = 1
    auraEffect(cid, config.effect, config.interval, config.duration, math.random(8))
    return true
end
That's exactly it! Thank you very much, sir!!! No words to describe my gratitude!!!
 
Back
Top