Random number generation... random random map generation.
Moderator: Moderators
- chris_in_cali
- Sergeant
- Posts: 65
- Joined: Thu Jun 26, 2003 9:46 am
Random number generation... random random map generation.
Is it possible with the scripting in MOHAA? Within a range, like, 1, 2, or 3. It's also important that I can create multiple random number sets individually named.
Last edited by chris_in_cali on Sat Aug 16, 2003 4:36 pm, edited 1 time in total.
-
Bjarne BZR
- Site Admin
- Posts: 3298
- Joined: Wed Feb 05, 2003 2:04 pm
- Location: Sweden
- Contact:
-
Bjarne BZR
- Site Admin
- Posts: 3298
- Joined: Wed Feb 05, 2003 2:04 pm
- Location: Sweden
- Contact:
Me neither, but I can guess...
do you mean making sets of random numbers? like
local.a = randomint 6
local.b = randomint 8
local.c = randomint 10
level.set1 = (local.a::local.b::local.c)
local.a = randomint 6
local.b = randomint 8
local.c = randomint 10
level.set2 = (local.a::local.b::local.c)
It's a little more complicated if you ask me.
do you mean making sets of random numbers? like
local.a = randomint 6
local.b = randomint 8
local.c = randomint 10
level.set1 = (local.a::local.b::local.c)
local.a = randomint 6
local.b = randomint 8
local.c = randomint 10
level.set2 = (local.a::local.b::local.c)
It's a little more complicated if you ask me.
- chris_in_cali
- Sergeant
- Posts: 65
- Joined: Thu Jun 26, 2003 9:46 am
yes... I actually had an idea I wanted to throw at you guys that I won't be able to do myself... this was just the key to it working. Here goes:Alcoholic wrote:Me neither, but I can guess...
do you mean making sets of random numbers? like
local.a = randomint 6
local.b = randomint 8
local.c = randomint 10
level.set1 = (local.a::local.b::local.c)
local.a = randomint 6
local.b = randomint 8
local.c = randomint 10
level.set2 = (local.a::local.b::local.c)
![]()
It's a little more complicated if you ask me.
I know you can set objects off of the map and then place them where they need to be during prespawn... I'm pretty sure you can group brushes together and do this as well. The idea is for a randomly generating map. Take a planned out city map, or other, and section it off into natural sections. From here you can create multiple buildings for each particular section of land; maybe a two-story, four-story, and blown out building on one section -- a small park, large government building, or otherwise on another.
So then you'd script a random number for each plot covering the amount of buildings created for it, then place whatever selected building onto it's plot during prespawn. You could use VIS planes (fields? whatever they are. The things where you can script a particular segment of the map to be drawn or not drawn based on where you are). You can have a VIS plane under the map where you store all of the buildings and such so they're not drawn.
Well, what do you think? I've never scripted anything before, I just had the idea and, being that I wouldn't be able to do it myself, figured I'd just throw it to the community. It would make for an interesting, dynamic map that would keep people a little more on their toes. Just let me know what's missing or wrong with this idea... I suppose map size may be an issue as well.
Hmmm
Sort of a map-changes-every-round type of thing, right? Well, the host server can do that now by just changing to a new map! Seems like a lot of work for something that could be done with a pack of different maps.
Well that way is a little simpler. Under level waittill roundstart do this:
Just copy the switch statement over again for building sets b and c. I think as long as they are hidden, they won't really lag up the place as much as if they were shown, so your in the clear. 
Code: Select all
$buildinga_1 hide //a is for the local.buildinga variable
$buildinga_2 hide //_2 is for the randomint thingy
$buildinga_3 hide
$buildingb_1 hide
$buildingb_2 hide
$buildingb_3 hide
$buildingc_1 hide
$buildingc_2 hide
$buildingc_3 hide
local.buildinga = (randomint (3) + 1)
local.buildingb = (randomint (3) + 1)
local.buildingc = (randomint (3) + 1)
switch (local.buildinga)
{
case 1: //result was 1
$buildinga_1 show
break
case 2: //result was 2
$buildinga_2 show
break
case 3: //result was 3
$buildinga_3 show
break
default: //result was not any of the above cases
println "WHAT THE HELL? DEFAULT CASE? THAT CANT HAPPEN!"
}- chris_in_cali
- Sergeant
- Posts: 65
- Joined: Thu Jun 26, 2003 9:46 am
Re: Hmmm
Maybe... but I thought the idea was interesting. Even if you only section off five pieces of the level for swapping and make three alternates for each you have 243 combinations that could come up... each being a little different of a dynamic, especially if the buildings are close enough to eachother to see/interact/whatever. Don't agree?tltrude wrote:Sort of a map-changes-every-round type of thing, right? Well, the host server can do that now by just changing to a new map! Seems like a lot of work for something that could be done with a pack of different maps.
- chris_in_cali
- Sergeant
- Posts: 65
- Joined: Thu Jun 26, 2003 9:46 am
Ok, wait. So each of the buidings are placed atop one another and only the one matching the generated number is shown? How do you group brushes and name them for scripting. I don't have the time to really try my idea, but I think I may try it on a smaller scale just to see it work. I've never even looked at the scripting language for MOHAA though, so I don't know what I have to do to set script objects and such yet (I'm sure I can probably find this in a tutorial somewhere though).Alcoholic wrote:Well that way is a little simpler. Under level waittill roundstart do this:
Just copy the switch statement over again for building sets b and c. I think as long as they are hidden, they won't really lag up the place as much as if they were shown, so your in the clear.Code: Select all
$buildinga_1 hide //a is for the local.buildinga variable $buildinga_2 hide //_2 is for the randomint thingy $buildinga_3 hide $buildingb_1 hide $buildingb_2 hide $buildingb_3 hide $buildingc_1 hide $buildingc_2 hide $buildingc_3 hide local.buildinga = (randomint (3) + 1) local.buildingb = (randomint (3) + 1) local.buildingc = (randomint (3) + 1) switch (local.buildinga) { case 1: //result was 1 $buildinga_1 show break case 2: //result was 2 $buildinga_2 show break case 3: //result was 3 $buildinga_3 show break default: //result was not any of the above cases println "WHAT THE HELL? DEFAULT CASE? THAT CANT HAPPEN!" }
So not showing a building means it isn't drawn, which is the same as my idea for placing them in a VIS box off map where they aren't drawn, right? I'm just curious how that would look in the editor when you've stacked the buildings on top of eachother like that. I suppose you could select the version you want if you needed through the menu if you've grouped all the brushes though, right?
I'm still new to all this. Still testing assumptions and such. BTW, what do you think of a map like this? You could also make different road, wall, etc layouts that could be dealt with in the same way. Interesting, or not so much?
It will look like hell in the editor, but should work in game. Now you MIGHT have some entities that you want hidden with the building. I mean, you dont want the building to disappear, but doors still show, right? Anyways, for everything in building "a" that you want to hide, give every existing entity in it the same targetname, (key/value targetname myname::INRADIANT), and in script, you use that common targetname to hide them. for the rest of the building that isnt an entity, make it all one script_object, and give it also the same targetname. so if you had 500 different entities targetnamed "stupiddoor", then in script if you added the line:
$stupiddoor delete
all 500 of those stupid doors would be gone.
$stupiddoor delete
all 500 of those stupid doors would be gone.
- chris_in_cali
- Sergeant
- Posts: 65
- Joined: Thu Jun 26, 2003 9:46 am
-
nuggets
- General
- Posts: 1006
- Joined: Fri Feb 28, 2003 2:57 am
- Location: U-england-K (england in the UK) :P
- Contact:
remember to add notsolid to the brushes aswell, that could really start some complications 
level waittill prespawn
$building_a thread the_working 2
$building_b thread the_working 2
$building_c thread the_working 2
/*change the 2 to a higher value if you want there to be a higher chance
that building will appear*/
//etc...
the_working local.weight:
self.random = randomint (local.weight)
if (self.random == 0) //meaning it's not wanted
{self hide
self notsolid}
end
level waittill prespawn
$building_a thread the_working 2
$building_b thread the_working 2
$building_c thread the_working 2
/*change the 2 to a higher value if you want there to be a higher chance
that building will appear*/
//etc...
the_working local.weight:
self.random = randomint (local.weight)
if (self.random == 0) //meaning it's not wanted
{self hide
self notsolid}
end
hope this helps, prob not cos it's all foreign 2 me :-/
-
nuggets
- General
- Posts: 1006
- Joined: Fri Feb 28, 2003 2:57 am
- Location: U-england-K (england in the UK) :P
- Contact:
and i forgot to add, if you want to change the number of floors on buildings, do this after you've got this working, changing internal elements of buildings will cause major complications,
...knowing if stairs are needed
...if the floor should allow for a staircase
...the height of a chimney
...targetnames for windows that are breakable
also you'll need to use ambientlight when compiling your map, using sunlight will cast shadows on buildings that may be invisible
...knowing if stairs are needed
...if the floor should allow for a staircase
...the height of a chimney
...targetnames for windows that are breakable
also you'll need to use ambientlight when compiling your map, using sunlight will cast shadows on buildings that may be invisible
hope this helps, prob not cos it's all foreign 2 me :-/

