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

[Mod] Automatic Raids [Day and Hour]

Critico

Sexy
Joined
Mar 25, 2010
Messages
370
Reaction score
176
Automatic Raids.xml
Lua:
<?xml version="1.0" encoding="UTF-8"?>  
<mod name="Automatic Raids" version="1.0" author="Vodkart And xotservx" contact="otl.com" enabled="yes">  
<config name="raids_func"><![CDATA[
days = {
["Monday"] = {
["21:30"] = {nome = "Orshabaal", pos = {fromPosition = {x=184, y=55, z=7},toPosition = {x=188, y=58, z=7}},m = {"5 Fire Devil", "2 Orshabaal"}, Time = 15},
["21:33"] = {nome = "Dragon", pos = {fromPosition = {x=197, y=57, z=7},toPosition = {x=203, y=60, z=7}},m = {"50 Dragon"}, Time = 20}
},
["Sunday"] = {
["10:08"] = {nome = "Demon", pos = {fromPosition = {x=202, y=11, z=7},toPosition = {x=204, y=12, z=7}}, m = {"20 Demon"}, Time = 15},
["10:46"] = {nome = "Hydra", pos = {fromPosition = {x=197, y=57, z=7},toPosition = {x=203, y=60, z=7}}, m = {"7 Hydra", "4 Cyclops"}, Time = 20}
}
}
]]></config>    
<globalevent name="AutomaticRaids" interval="60" event="script"><![CDATA[
domodlib('raids_func')
function onThink(interval, lastExecution)  
if days[os.date("%A")] then
hours = tostring(os.date("%X")):sub(1, 5)       
tb = days[os.date("%A")][hours] 
if tb then        
function removeCreature(tb)
for x = ((tb.pos.fromPosition.x)-10), ((tb.pos.toPosition.x)+10) do
for y = ((tb.pos.fromPosition.y)-10), ((tb.pos.toPosition.y)+10) do
local m = getTopCreature({x=x, y=y, z= tb.pos.fromPosition.z}).uid
if m ~= 0 and isMonster(m) then
doRemoveCreature(m)
end
end
end
end
doBroadcastMessage("The invasion of " .. tb.nome .. " started")
for _,x in pairs(tb.m) do
for s = 1, tonumber(x:match("%d+")) do
pos = {x = math.random(tb.pos.fromPosition.x, tb.pos.toPosition.x), y = math.random(tb.pos.fromPosition.y, tb.pos.toPosition.y), z = tb.pos.fromPosition.z}
doSummonCreature(x:match("%s(.+)"), pos)
end
end
addEvent(removeCreature, tb.Time*60*1000, tb)
end
end
return true
end
]]></globalevent>
</mod>


explanation:

Lua:
["Day"] = {
["Hour of the invasion"] = {nome = "INVASION NAME", pos = {beginning and end of the area}, monster = {"MONSTERS"}, Time = to remove monsters}
}


The day of the invasion is placed between " " and the first letter is uppercase, ex:

Lua:
"Saturday"


After are the hours the invasion, which is placed between " " and only the hours and minutes, seconds do not need, example:

Lua:
"15:00"

Positions are enclosed in {} by adding the x, y, and z is the beginning and end of the area, ex:

Lua:
pos = {fromPosition = {x=197, y=57, z=7},toPosition = {x=203, y=60, z=7}}

fromPosition - beginning of the area where the raid will happen
toPosition - end of the area where the raid will happen

The monters has a special way to set up, you put between {} and each monster between " ", and between "" you add "AMOUNT MONSTER"
and to add more types monster is separated by commas, for example:

Lua:
{"40 Water Elemental", "5 Cyclops"}

Time is an extra function, if nobody participate in the event then for the monsters do not stay on the map... and is in minutes, for example:
Lua:
Time = 15
 
Great release, really something people could take advantage of, tested? At rev/distro?
 
that code made me spoon my eyes out!

Even if you think this, what's the point of posting it?
He made alot scripts that are usefull for me, and if it's to help him, I suggest to show how he should make it.
I absolutely don't see a point of posting such things when someone is only giving away scripts for free.
 
Even if you think this, what's the point of posting it?
He made alot scripts that are usefull for me, and if it's to help him, I suggest to show how he should make it.
I absolutely don't see a point of posting such things when someone is only giving away scripts for free.

You clearly aren't a scripter, this is not an insult or anything likely, tbh the code is pretty good but for us to read it it's hard, there are tons of scripters and even who scripted it (which I believed actually tabbed but his code came wrong somehow) who prefers the code tabbed and moreover if it is in fact a good code (which in this case is).
 
Even if you think this, what's the point of posting it?
He made alot scripts that are usefull for me, and if it's to help him, I suggest to show how he should make it.
I absolutely don't see a point of posting such things when someone is only giving away scripts for free.

I'm not directly disregarding OP, I'm simply pointing out the pain that we scripters suffer when we see this, like santi said, it's really hard to read.

So as an apology for my comment, I post the script tabbed.
Lua:
<?xml version="1.0" encoding="UTF-8"?>  
<mod name="Automatic Raids" version="1.0" author="Vodkart And xotservx" contact="otl.com" enabled="yes">  
<config name="raids_func"><![CDATA[
    days = {
        ["Monday"] = {
            ["21:30"] = {
                nome = "Orshabaal", 
                pos = {fromPosition = {x=184, y=55, z=7},toPosition = {x=188, y=58, z=7}},
                m = {"5 Fire Devil", "2 Orshabaal"},
                Time = 15
            },
            ["21:33"] = {
                nome = "Dragon", 
                pos = {fromPosition = {x=197, y=57, z=7},toPosition = {x=203, y=60, z=7}},
                m = {"50 Dragon"}, 
                Time = 20
            }    
        },
        ["Sunday"] = {
            ["10:08"] = {
                nome = "Demon", 
                pos = {fromPosition = {x=202, y=11, z=7},toPosition = {x=204, y=12, z=7}}, 
                m = {"20 Demon"}, 
                Time = 15
            },
            ["10:46"] = {
                nome = "Hydra", 
                pos = {fromPosition = {x=197, y=57, z=7},toPosition = {x=203, y=60, z=7}}, 
                m = {"7 Hydra", "4 Cyclops"}, 
                Time = 20
            }
        }
    }
]]></config>    
<globalevent name="AutomaticRaids" interval="60" event="script"><![CDATA[
domodlib('raids_func')
function onThink(interval, lastExecution)  
    if days[os.date("%A")] then
        hours = tostring(os.date("%X")):sub(1, 5)       
        tb = days[os.date("%A")][hours] 
        if tb then        
            function removeCreature(tb)
                for x = ((tb.pos.fromPosition.x)-10), ((tb.pos.toPosition.x)+10) do
                    for y = ((tb.pos.fromPosition.y)-10), ((tb.pos.toPosition.y)+10) do
                        local m = getTopCreature({x=x, y=y, z=tb.pos.fromPosition.z}).uid
                        if m ~= 0 and isMonster(m) then
                            doRemoveCreature(m)
                        end
                    end
                end
            end
            doBroadcastMessage("The invasion of " .. tb.nome .. " started")
            for _,x in pairs(tb.m) do
                for s = 1, tonumber(x:match("%d+")) do
                    pos = {
                        x = math.random(tb.pos.fromPosition.x,tb.pos.toPosition.x), 
                        y = math.random(tb.pos.fromPosition.y, tb.pos.toPosition.y), 
                        z = tb.pos.fromPosition.z
                    }
                    doSummonCreature(x:match("%s(.+)"), pos)
                end
            end
            addEvent(removeCreature, tb.Time*60*1000, tb)
        end
    end
return true
end
]]></globalevent>
</mod>
 
@Santi

I wasn't talking about you, you gave a tip/advice and I also agreed with it. It's just that I didn't see a point of the comment Shinmaru made.
Btw, I do make scripts myself too and I also think it's more easy to read with tabs, but that doesn't change the fact that I think comments like that are useless.

@Shinmaru

You should just have said that (use tabs, because like this it's really hard to read). Makes it more usefull for the person who made the script :p
But nice you made the script tabbed :)
 
Last edited:
Not working with tfs: 0.4 | rev: 3777

Error
kdCRm-3.png

 

Attachments

In data/monsters/monsters.xml loading Orshabaal.xml ?
The script spawns the area with orsabaal's until it isn't able to spawn more then it gives the error: '<luaDoCreateMonster> Cannot create monster: orsabaal'

Edit: I've set the script to only spawn one.
 
Back
Top