home home

downloads files

forum forum

docs docs

wiki wiki

faq faq

Cube & Cube 2 FORUM


Random level generation in Cube 1

by vinny on 08/09/2015 05:36, 5 messages, last message: 08/21/2015 02:05, 1473 views, last view: 04/24/2024 09:27

I'm studying the Cube 1 codebase since it's very small and easy to grasp. After some time, i've found the rndmap.cpp source, which is a WIP code for random level generation.

Do you guys know any successful attemps at generating levels in Cube 1? I'm planning to do something like Nethack, but in Cube!

   Board Index   

#1: ..

by suicizer03 on 08/09/2015 22:28

I'm not sure about Cube Engine, but there surely are attempts on Cube Engine 2 instead. However, these attempts are often divided into based on generating geometry and on entities througout a map.

reply to this message

#2: ..

by asmanel on 08/12/2015 03:26

According to what I found, the functions of this files are used by perlin, a CubeScript hardcoded function that generate random heightfields.

I don't know any other any other mapping random generator (hardcoded or not) in games using the Cube Engine.

However, most of the thing possible to do at mapping can be done with a script (in CubeScript), including all the possible changes of the geometry.

Doing the same with the entities will need, however, some changes of the hardcode (C/C++ source code).

reply to this message

#3: ..

by vinny on 08/12/2015 15:56

I'm planning to do something simple first, like, generating a dungeon: http://gamedevelopment.tutsplus.com/tutorials/create-a-procedurally-generated-dungeon-cave-system--gamedev-10099

But i'm not familiar with block manipulation in Cube. Which functions should i use to manipulate the world? Like, raising/lower cubes? For a simple dungeon, i'll just need to raise/lower cubes to make the pathways, rooms, etc.

reply to this message

#4: ..

by asmanel on 08/14/2015 23:55

First, there are five types of cubes :
* normal
* solid (without ground nor ceiling)
* heightfielded (with heightfielded ground)
* heightfielded (with heightfielded ceiling)
* cornered

To modify cubes, they need to be selected. In a script, it can be done with the function select. Its syntax is :

select X Y XS YS

X and Y are the coordinate of the NW (northwest) corner of the selected zone and XS and YS are the size of the selection.

To change the type of the selected cubes, there are three functions, solid, heightfield and corner. The function corner have no argument but the two others have both one argument

"solid 0" make normal the cubes

"solid 1" make solid the cubes

"heightfield 0" make heightfielded the ground

"heightfield 2" make heightfielded the ceiling

"corner" make cubes cornered (walls at 45° from the cube borders). However, don't use it if the selection size isn't (1,1). If you try to do it, it probably won't work and, if it work, il will tends to be glitchy.

To move up or down a cube, the function to use is editheight. Its syntax is :

editheight S H

Depending on the value of S, the floor (if f=0) or the ceiling (if f=2) move H cubes. It move up if H is positive and move down if it's negative.

The function vdelta also change the height of heightfielded grounds and ceilings. It only have one argument. If this argument is positive, it increase the heightfield value, if it's negative, it decrease this value.

change the heightfield value of a cube doesn't change the height of the whole cube but only the one of its NW corner. the height of the other corners (and, so, the whole cube) depend on the heightfield values of the south, east and southeast neighboring cubes. (all cubes, heightfielded or not, have an unique heightfield value)

Higher heightfield values make cubes higher when it's the ceiling that is heightfielded but lower when it's the floor that is heightfielded.

the functions perlin, arch and slope also change the heightfield values to create faster arches (arch; usually round top of door), slopes or random grounds/ceilings (perlin).

About water, its level is the same in the whole map and can be set with waterlevel.

To create a random map you'll also need the function rnd. rnd X wil return any integer from 0 to X-1.


I didn't mention the textures (that can be edited with the function edittex) because you didn't didn't ask it.


The editing functions that was added in AC are also unmentionned but for two reasons :
* because both they doesn't exist in Cube
* they are documented in game in AC and ACR. here is the script that generate this documentation in the game (https://github.com/acreloaded/acr/blob/master/config/docs.cfg ; The lines 982 to 1276 are the part about edition).

reply to this message

#5: ..

by nixtrix on 08/21/2015 02:05

I'm not sure if there's any surviving code but there is a very early beta version of a random level generator for Cube called "Sludge". I can't for the life of me remember it, but I'll have a poke round and see if I can find the source files. The levels it made weren't very exciting (just flat randomly textured/lighted rooms with randomly placed monsters/items everywhere) but it's something.

reply to this message

   Board Index   


Unvalidated accounts can only reply to the 'Permanent Threads' section!


content by Aardappel & eihrul © 2001-2024
website by SleepwalkR © 2001-2024
53758258 visitors requested 71527395 pages
page created in 0.015 seconds using 10 queries
hosted by Boost Digital