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

RevScripts Enviroment spell 1.3

denkan97

Well-Known Member
Joined
Dec 27, 2011
Messages
327
Solutions
2
Reaction score
50
Hello, i would want to make this script work like this instead:
*Config to use only one or more effects, for example 3, 5, 10 and 20.
*Config to use specific different locations not only from pos topos, for example Position(116, 423, 7), and Position(126, 443, 7), and Position(135, 436, 7),
*Make so the different locations have different delays so all don't go at the same time.

Found script here on otland so credit to the creator don't remember who.

Lua:
local config = {
    minDamage = 10,
    maxDamage = 1000,
    magicEffectStart = 1,
    magicEffectEnd = 50
}

local effects = {
    {
        fromPosition = Position(116, 423, 7),
        toPosition   = Position(123, 428, 7),
        effect       = CONST_ME_HOLYDAMAGE
    },
}

local spawnDamage = GlobalEvent("spawn damage")
function spawnDamage.onThink(interval)
    local jolf
    for i = 1, #effects do
        local settings = effects[i]

        local spectators = Game.getSpectators(settings.fromPosition, false, true, 7, 7, 5, 5)
        if #spectators > 0 then
            for y = settings.fromPosition.y, settings.toPosition.y do
                for x = settings.fromPosition.x, settings.toPosition.x do
                    newPosition = Position(x, y, settings.fromPosition.z)
                    newPosition:sendMagicEffect(math.random(config.magicEffectStart, config.magicEffectEnd))
                    jolf = Tile(newPosition):getTopCreature()
                    if jolf and jolf:isPlayer() then
                        doTargetCombatHealth(0, jolf, COMBAT_PHYSICALDAMAGE, -config.minDamage, -config.maxDamage, settings.effect)
                    end
                end
            end
        end
    end
    return true
 
Solution
In this way you can configure several dangerous areas and with different execution times

data/scripts/spawndamageeffects.lua
Lua:
local config = {

    {
        interval = 10 * 1000,
        centerPosition = Position(3188, 1816, 7),
        effect = CONST_ME_ICEATTACK,
        damageType = COMBAT_ICEDAMAGE,
        damageValue = {500, 1000}
    },

    {
        interval = 5 * 1000,
        centerPosition = Position(3196, 1807, 7),
        effect = CONST_ME_FIREATTACK,
        damageType = COMBAT_FIREDAMAGE,
        damageValue = {250, 800}
    }

}

for index, info in pairs(config) do
    local globalEvent = GlobalEvent(string.format("spawnDamage%d", index))

    function globalEvent.onThink(interval)
        for _...
In this way you can configure several dangerous areas and with different execution times

data/scripts/spawndamageeffects.lua
Lua:
local config = {

    {
        interval = 10 * 1000,
        centerPosition = Position(3188, 1816, 7),
        effect = CONST_ME_ICEATTACK,
        damageType = COMBAT_ICEDAMAGE,
        damageValue = {500, 1000}
    },

    {
        interval = 5 * 1000,
        centerPosition = Position(3196, 1807, 7),
        effect = CONST_ME_FIREATTACK,
        damageType = COMBAT_FIREDAMAGE,
        damageValue = {250, 800}
    }

}

for index, info in pairs(config) do
    local globalEvent = GlobalEvent(string.format("spawnDamage%d", index))

    function globalEvent.onThink(interval)
        for _, spectator in pairs(Game.getSpectators(info.centerPosition, false, true, 7, 7, 5, 5)) do
            doTargetCombat(0, spectator, info.damageType, -info.damageValue[1], -info.damageValue[2], info.effect, ORIGIN_NONE)
        end

        for x = (info.centerPosition.x - 7), (info.centerPosition.x + 7) do
            for y = (info.centerPosition.y - 5), (info.centerPosition.y + 5) do
                Position(x, y, info.centerPosition.z):sendMagicEffect(info.effect)
            end
        end
        return true
    end

    globalEvent:interval(info.interval)
    globalEvent:register()
end

another version of the same script, without Game.getSpectators
Lua:
local config = {

    {
        interval = 10 * 1000,
        centerPosition = Position(3188, 1816, 7),
        rangeX = 7,
        rangeY = 5,
        effect = CONST_ME_ICEATTACK,
        damageType = COMBAT_ICEDAMAGE,
        damageValue = {500, 1000}
    },

    {
        interval = 5 * 1000,
        centerPosition = Position(3196, 1807, 7),
        rangeX = 7,
        rangeY = 5,
        effect = CONST_ME_FIREATTACK,
        damageType = COMBAT_FIREDAMAGE,
        damageValue = {250, 800}
    }

}

for index, info in pairs(config) do
    local globalEvent = GlobalEvent(string.format("spawnDamage%d", index))

    function globalEvent.onThink(interval)
        for x = (info.centerPosition.x - info.rangeX), (info.centerPosition.x + info.rangeX) do
            for y = (info.centerPosition.y - info.rangeY), (info.centerPosition.y + info.rangeY) do
                local tempPos = Position(x, y, info.centerPosition.z)
                local tile = Tile(tempPos)
                if tile then
                    tempPos:sendMagicEffect(info.effect)
                    for _, creature in pairs(tile:getCreatures() or {}) do
                        if creature:isPlayer() then
                            doTargetCombat(0, creature, info.damageType, -info.damageValue[1], -info.damageValue[2], info.effect, ORIGIN_NONE)
                        end
                    end
                end
            end
        end
        return true
    end

    globalEvent:interval(info.interval)
    globalEvent:register()
end
 
Last edited:
Solution
thx
In this way you can configure several dangerous areas and with different execution times

data/scripts/spawndamageeffects.lua
Lua:
local config = {

    {
        interval = 10 * 1000,
        centerPosition = Position(3188, 1816, 7),
        effect = CONST_ME_ICEATTACK,
        damageType = COMBAT_ICEDAMAGE,
        damageValue = {500, 1000}
    },

    {
        interval = 5 * 1000,
        centerPosition = Position(3196, 1807, 7),
        effect = CONST_ME_FIREATTACK,
        damageType = COMBAT_FIREDAMAGE,
        damageValue = {250, 800}
    }

}

for index, info in pairs(config) do
    local globalEvent = GlobalEvent(string.format("spawnDamage%d", index))

    function globalEvent.onThink(interval)
        for _, spectator in pairs(Game.getSpectators(info.centerPosition, false, true, 7, 7, 5, 5)) do
            doTargetCombat(0, spectator, info.damageType, -info.damageValue[1], -info.damageValue[2], info.effect, ORIGIN_NONE)
        end

        for x = (info.centerPosition.x - 7), (info.centerPosition.x + 7) do
            for y = (info.centerPosition.y - 5), (info.centerPosition.y + 5) do
                Position(x, y, info.centerPosition.z):sendMagicEffect(info.effect)
            end
        end
        return true
    end

    globalEvent:interval(info.interval)
    globalEvent:register()
end

Thx for the help! :)

Got a problem, when i change it like this to make it only 1sqm it still hits all sqms like this
for x = (info.centerPosition.x - 7), (info.centerPosition.x + 7) do
for y = (info.centerPosition.y - 5), (info.centerPosition.y + 5) do


Lua:
local config = {
-------------500+ quest-----------------

    {
        interval = 3 * 1000,
        centerPosition = Position(1001, 995, 5),
        effect = CONST_ME_FIREATTACK,
        damageType = COMBAT_FIREDAMAGE,
        damageValue = {500, 1000}
    }

}

for index, info in pairs(config) do
    local globalEvent = GlobalEvent(string.format("spawnDamage%d", index))

    function globalEvent.onThink(interval)
        for _, spectator in pairs(Game.getSpectators(info.centerPosition, false, true, 0, 0, 0, 0)) do
            doTargetCombat(0, spectator, info.damageType, -info.damageValue[1], -info.damageValue[2], info.effect, ORIGIN_NONE)
        end

        for x = (info.centerPosition.x - 0), (info.centerPosition.x + 0) do
            for y = (info.centerPosition.y - 0), (info.centerPosition.y + 0) do
                Position(x, y, info.centerPosition.z):sendMagicEffect(info.effect)
            end
        end
        return true
    end

    globalEvent:interval(info.interval)
    globalEvent:register()
end

But if i change it to:
Then it only do dmg inside the effects
Lua:
for x = (info.centerPosition.x - 1), (info.centerPosition.x + 1) do

for y = (info.centerPosition.y - 1), (info.centerPosition.y + 1) do
 
Last edited:
thx


Thx for the help! :)

Got a problem, when i change it like this to make it only 1sqm it still hits all sqms like this
for x = (info.centerPosition.x - 7), (info.centerPosition.x + 7) do
for y = (info.centerPosition.y - 5), (info.centerPosition.y + 5) do


Lua:
local config = {
-------------500+ quest-----------------

    {
        interval = 3 * 1000,
        centerPosition = Position(1001, 995, 5),
        effect = CONST_ME_FIREATTACK,
        damageType = COMBAT_FIREDAMAGE,
        damageValue = {500, 1000}
    }

}

for index, info in pairs(config) do
    local globalEvent = GlobalEvent(string.format("spawnDamage%d", index))

    function globalEvent.onThink(interval)
        for _, spectator in pairs(Game.getSpectators(info.centerPosition, false, true, 0, 0, 0, 0)) do
            doTargetCombat(0, spectator, info.damageType, -info.damageValue[1], -info.damageValue[2], info.effect, ORIGIN_NONE)
        end

        for x = (info.centerPosition.x - 0), (info.centerPosition.x + 0) do
            for y = (info.centerPosition.y - 0), (info.centerPosition.y + 0) do
                Position(x, y, info.centerPosition.z):sendMagicEffect(info.effect)
            end
        end
        return true
    end

    globalEvent:interval(info.interval)
    globalEvent:register()
end

But if i change it to:
Then it only do dmg inside the effects
Lua:
for x = (info.centerPosition.x - 1), (info.centerPosition.x + 1) do

for y = (info.centerPosition.y - 1), (info.centerPosition.y + 1) do
Check my post again, I have updated it and added a new similar script, but without making use of the Game.getSpectators function, although it will be less efficient, but not enough to be considered bad
 
Back
Top