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

Generating maps?

Yep it works
I spawned randomly some brushes with 919 on surface
They do the work:
4.png

then i spawning randomly 5x10165
10165
(because it lies on stack 1 where are few items according to whole area so getThingfrompos goes faster )

next i scan whole area replacing it with
8595

and i put brush with mixed floor one level down.
So under ladder is always terrain.Sometimes 5x5 sometimes whole tunnels
Code:
local function drillDungeon(itemid)
        for x = startPos.x,endPos.x do
                for y = startPos.y,endPos.y do
                        for z = startPos.z,endPos.z do
                                pos = {x = x,y = y,z = z,stackpos = 1}
                                thing = getThingFromPos(pos,false)
                                if thing.itemid == itemid then
                                        tempPos = {x = x,y = y,z = z+1,stackpos = 1}
                                        placeBrush(19,math.random(0,360),0,tempPos)
                                        doRemoveItem(thing.uid,1)
                                        doCreateItem(8595,1,pos)
                                        doCreateItem(8599,1,tempPos)
                                end
                        end
                end
        end
end

and for now it looks something like this
5.png


i think this solution is capable of creating multi floor dungeons/mine's.
Now i try to detail it.
When dungeons will be ready i think i try make mountains go up like in cyclopolis near Thais xd.
 
Last edited:
sounds strange, but works perfectly
I'm done with basic functions. Now I'll try to make new event based on my script. Whole opentibia needs new events. I'm getting tired of those copy-pastes most servers use these days.

Feel free to use my code if it could shorten your work.
You may detail tunnels using code you did for trees and crystal or rewrite my code.

pathable checking(for details below)
Code:
function isPathable(pos)
if queryTileAddThing(getThingfromPos({x = pos.x, y = pos.y, z = pos.z, stackpos = 0}).uid, {x = pos.x, y = pos.y, z = pos.z}) == RETURNVALUE_NOERROR then
return true
else
return false
end
end

function doCreateItem_Pathable(id, count, pos)
if isPathable(pos) then
doCreateItem(id, count, pos)
return true
else
return false
end
end

This is how I do details this way:
Code:
function doDetails(id, items, cpt, row, level, turnid)
local inst_tier = pits_event_config.caves[id]
if turnid == inst_turn[id] then
   for map_row = 0, inst_tier.map_size[1] - 1 do
     if math.random(1, 1000) <= cpt then
       if getTileItemById({x = inst_tier.map_corner.x + map_row,y = inst_tier.map_corner.y + row,z = inst_tier.map_corner.z + level}, 1387).uid == 0 then
         can_detail_here = true
         for str_excluded = 1, #generated_structures[id] do
           if isInRange({x = inst_tier.map_corner.x + map_row,y = inst_tier.map_corner.y + row,z = inst_tier.map_corner.z + level},{x = generated_structures[id][str_excluded][1], y = generated_structures[id][str_excluded][2], z = generated_structures[id][str_excluded][3]},{x = generated_structures[id][str_excluded][4], y = generated_structures[id][str_excluded][5], z = generated_structures[id][str_excluded][6]}) then
             can_detail_here = false
             break
           end
         end
         if can_detail_here then
           doCreateItem_Pathable(items[math.random(1, #items)], 1, {x = inst_tier.map_corner.x + map_row,y = inst_tier.map_corner.y + row,z = inst_tier.map_corner.z + level})     
         end
       end
     end
   end
end
end

Code:
-- lib
ARRAY_OLD_TREES = {2709, 2710, 2719, 2720, 2721, 2770, 2784, 3323, 5392, 5396}
...
-- config
pits_event_config = {
   caves = {
     [1] = {
       details = {
         [1] = {chance_per_tile = 30, ARRAY_OLD_TREES,ARRAY_CAVE,ARRAY_UNWALKABLE_STONES,ARRAY_DEBRIS,ARRAY_CAMPFIRES,ARRAY_PILLARS,ARRAY_BLACK_JAGGED,ARRAY_SKULLS,ARRAY_RAND_STUFF,ARRAY_BONES,ARRAY_STONE_PILES},
...
-- core
local inst_tier = pits_event_config.caves[id]
...
-- core
  if inst_tier.details ~= nil then
     for i_types = 1, #inst_tier.details do
       world_details[id] = {}
       if pits_event_config.main.output then
         global_gen_delay[id] = global_gen_delay[id] + pits_event_config.main.chunk_update_interval
         addEvent(sendChannelMessage_Turn, global_gen_delay[id], pits_event_config.main.output_channel_id, TALKTYPE_CHANNEL_O, "["..inst_tier.map_name.."]: Generating details... layer "..i_types.."/"..#inst_tier.details..".",id, inst_turn[id])
       end
       for i_arrays = 1, #inst_tier.details[i_types] do
       for i_details = 1, #inst_tier.details[i_types][i_arrays] do
         table.insert(world_details[id], inst_tier.details[i_types][i_arrays][i_details])
       end
       end
       table.sort(world_details[id])
       for detail_row = 0, inst_tier.map_size[2]-1 do
       for detail_level = 0, inst_tier.map_size[3]-1 do
         addEvent(doDetails,global_gen_delay[id],id,world_details[id],inst_tier.details[i_types].chance_per_tile,detail_row,detail_level, inst_turn[id]) -- turn id is number to avoid spawning details after closing area
         global_gen_delay[id] = global_gen_delay[id] + pits_event_config.main.chunk_update_interval
       end
       end
       if pits_event_config.main.output then
         addEvent(sendChannelMessage_Turn, global_gen_delay[id], pits_event_config.main.output_channel_id, TALKTYPE_CHANNEL_O, "["..inst_tier.map_name.."]: Generating details... layer "..i_types.." completed.",id, inst_turn[id])
       end
     end
   end
 
zbizu, it's looking really nice.

I don't want to bother going through the codes, it looks really messy, but I'm hoping you provide an algorithm of how you're generating a map, could that be possible? I don't need the code or anything, just wondering how you're telling the server to make a decent looking circle (island) without screwing it up.
 
It's laggy so I abandoned it for tunnels method(it's faster and simpler).

from nw corner to se corner there is math.random(1, 1000) and if it's <= than chance per tile it spawns one tile there and then checks if other spots aren't outside of event area.
If 3x3 tile can be spawned, there is second math.random and it spawns. Radius is increased(to know dist from main point) and chance goes lower. If it's 0 or below loop breaks.

It's in first post.
 
Last edited:
This is crazy, i can belive what i see, is awesome, i would like to contribute but i think that my IQ isn't enough to do something like this haha
 
That looks really neat and awesome - something that I could see a lot of potential with if done right! I hope to see a system like this polished and finished.
 
I'll create this system in future. The system is finished yet and remember Zbizu I hate you so very much
 
Last edited:
@Artis
yeah, whatever... drama you make in threads started by me is pointless
good luck with this system
it's ready to use

I gave you my word before and I won't break my promise.
I just don't accept tracking me.

Edit:
just send me pm and stop fucking offtoping there
 
Last edited:
I don't have anything. Yes, I got your world to correct. Bieleve in you, sorry I can't bieleve in you've simulated my friend. I can't trust you. When I trusted you I was thinking in you. I have good heart and cannot do wrong toward you.

I'll remembert about this fact.
 
Back
Top