Random Level Scripting
Some of you may have seen the latest Geezer level set, R.I.P. If the random levels are of interest to you, then maybe you should know how to do it yourself.
Note: All the example scripts in this article were created by Cowboy. I did not create them, I am just explaining them. I have not changed them in any way.
The Basic Unit: random
The element random, like random number generators in many programing languages, generates a random number between 0 and 1, never 0, never 1.
Random Walls
Lets look at Infinity, the level that stays fixed. Heres the random number script:
// randoms for wallDoors
event1 = int(31 + (random *2) )
event2 = int(33 + (random *2) )
event3 = int(35 + (random *2) )
event4 = int(37 + (random *2) )
event5 = int(39 + (random *2) )
event6 = int(41 + (random *2) )
event7 = int(43 + (random *2) )
event8 = int(45 + (random *2) )
event9 = int(47 + (random *2) )
event10 = int(49 + (random *2) )
Note that an arc is not needed for this statement. What this does is assign the value 31 or 32 to event1, 33 or 34 to event2, ect. Then this script is used:
// send out random messages
// for change of scenery
object Base
in = @start
out[0] = event1
out[1] = event2
out[2] = event3
out[3] = event4
out[4] = event5
out[5] = event6
out[6] = event7
out[7] = event8
out[8] = event9
out[9] = event10
end
Note that this needs an arc because it is a base. What this does is send out messages with numbers in event1-event10, for example event1 sends out either 31 or 32. You may think that messages are words with an @ before them, but the level design manual states Object communicate between each other using messages. The message consists simply of a message number. Either notation can be used.
The wallDoor scripts look like like this:
object WallDoor
open = 31
close = 32
deltaY = blockHeight
deltaZ = 0
deltaX = 0
yaw = 0
openSpeed = opSpd
closeSpeed = clSpd
guardDelay = 5
volume = 0
status = isClosed
shotPower = 0
end
Elsewhere in the level:
opSpd = 100
clSpd = 100
blockHeight = 200
Note that more then one wallDoor can be made to open or close with one message. Each wallDoor is a separate block. When they open, they move up 200 meters, and do so quickly that it looks instantaneous.
Random Goodie Amounts
Heres what is needed for random goodie amounts.
// randoms for number of goodies
goodie1 = int(1 + (random *8) )
goodie2 = int(1 + (random *8) )
goodie3 = int(1 + (random *8) )
goodie4 = int(1 + (random *8) )
goodie5 = int(1 + (random *8) )
goodie6 = int(1 + (random *8) )
goodie7 = int(1 + (random *8) )
goodie8 = int(1 + (random *8) )
goodie9 = int(1 + (random *8) )
goodie10 = int(1 + (random *8) )
Again, note that this does not need an arc. This sets random numbers from 1-8 into the variables. For the actual goodies, the amount is defined as:
missiles = goodie1
or
grenades = goodie1
Conclusion
These are just a few things that can be done with random scripting. I encourage you to look for more items of interest. Open up levels in ResEdit and ClarisWorks/AppleWorks. Once you figure them out, you should be able to duplicate them in your levels. As always, ask before taking other peoples scripts. I asked for permission to use these scripts.
If you have comments about this artile, please e-mail me
Home