Page 1 of 2
Random number generation... random random map generation.
Posted: Fri Aug 15, 2003 4:10 pm
by chris_in_cali
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.
Posted: Fri Aug 15, 2003 8:11 pm
by Bjarne BZR
randomint(15)
creates a random number between 0 and 14
Posted: Fri Aug 15, 2003 9:54 pm
by Alcoholic
remember its FROM 0 to 14, so it can be 0 and can be 14. you can optionally use (randomint (6) + 1) if you dont want 0.
Posted: Fri Aug 15, 2003 10:54 pm
by Bjarne BZR
Good point ( pint? ) Alcholic.
I'm wrong, Alcholic is right.
chris_in_cali wrote:It's also important that I can create multiple random number sets individually named.
Can you explain what you mean by this in another way? I don't really understand what you are asking for...
Posted: Sat Aug 16, 2003 12:21 am
by Alcoholic
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.
Posted: Sat Aug 16, 2003 4:17 am
by chris_in_cali
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.
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:
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
Posted: Sat Aug 16, 2003 4:26 am
by tltrude
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.
Posted: Sat Aug 16, 2003 5:05 am
by Alcoholic
Well that way is a little simpler. Under level waittill roundstart do this:
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!"
}
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.

Re: Hmmm
Posted: Sat Aug 16, 2003 7:10 am
by chris_in_cali
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.
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?
Posted: Sat Aug 16, 2003 7:14 am
by Alcoholic
Yeah, and you wouldn't have to wait for the map to load, and that also means people with faster comps don't get the jump on you.
Posted: Sat Aug 16, 2003 7:18 am
by chris_in_cali
Alcoholic wrote:Well that way is a little simpler. Under level waittill roundstart do this:
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!"
}
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.

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).
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?
Posted: Sat Aug 16, 2003 7:22 am
by Alcoholic
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.
Posted: Sat Aug 16, 2003 7:30 am
by chris_in_cali
Since you're around:
How do I add a target name to a group of brushes?
What do you think of this idea, personally?
Um... yeah.

And thanks for all your help so far.
Posted: Sat Aug 16, 2003 4:07 pm
by nuggets
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
Posted: Sat Aug 16, 2003 4:12 pm
by nuggets
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