Freedom Reborn

Freedom Force Forums => Scripting Forum => Topic started by: oktokels on May 04, 2022, 12:10:32 AM

Title: Random map
Post by: oktokels on May 04, 2022, 12:10:32 AM
Just thinking about making a random map selector for the rumble room. Could it be possible?  :wacko:
Title: Re: Random map
Post by: bearded on May 04, 2022, 02:47:07 PM
I've been thinking about this. Poke me later.
Title: Re: Random map
Post by: bearded on May 10, 2022, 04:01:00 PM
Here's what I came up with.
def GetBuildingList():
return ["building_avengermansion", "building_bank", "building_police", "building_guard", "building_temple", "building_battlement", "building_diner", "building_baxter", "turret_raygun", "turret_carrier", "turret_factory2", "turret_factory3", "turret_factory", "building_rundown", "fire_tank", "gas_tank", "powerup_cp", "powerup_ep", "powerup_hp", "powerup_pp", "car_ff", "building_hospital", "building_bugle", "building_church", "building_comics_museum", "building_sanctum", "building_tiny"]


def RandomBuilding():
buildingList = GetBuildingList()
randMarker = 7
gotoMarker = "hero_6"
building = buildingList.pop(randint(0, len(buildingList)-1))
spawnName = "building_"+`building`
Object_Spawn(building, building, 'hero_7')


You could have different lists, for differently themed maps, so you could not only pick a random map, it would make the map itself procedurally. All you would have to do is make different lists of things that would be in each map type, including civilians, or cars, anything that has a template. And you would need a blank map, the only thing on it would be markers in a grid, 1-9, or however big your map is.
Title: Re: Random map
Post by: oktokels on May 10, 2022, 04:33:34 PM
This is amazing, great job. Still unreadable for me, since I haven't even touched ffx.py. But it will be very useful for later. Nice work  :thumbup:
Title: Re: Random map
Post by: bearded on May 11, 2022, 04:03:49 AM
It won't work as it is. Needs a for/next loop. If someone could make a blank map with markers on it, I would put it together.
Title: Re: Random map
Post by: bearded on May 14, 2022, 11:32:26 AM
I started putting some work in this. I'm going to use the city map and replace all the layouts with markers. I'm going to have to use a small map, or it will lag creating a level.
Title: Re: Random map
Post by: bearded on May 15, 2022, 12:44:04 PM
I've got random civs set up. I'll post a "how to" tonight.
Title: Re: Random map
Post by: bearded on May 16, 2022, 10:27:22 AM
1. Load up the map you want to make random with the mission tab. You should see a lot of character types with the name civ_#. If some of them are fciv_# change it to civ_#, with the first one after the last. Meaning that if the last one was civ_16, then fciv_1 will be fciv_17. Change all the types to positional. This will remove all the civilians from the map. If there are no civilians already on the map, then create as many as you want, positional, with the names civ_#. That is, civ_1, civ_2, civ_3, etc. It's important that it's sequential.
2. Open up the mission file with any text editor. It will be in the same folder you loaded with ffedit, Mission.py. There should be code: def OnPostInit():
Below OnPostInit, paste this:      RandomCiv() and on a new line, paste this: def RandomCiv():
    for x in range(1, 16):
         civList = GetCivList()
         civ = civList.pop(randint(0, len(civList)-1))
         gotoMarker = "civ_" + `x`
         Object_Spawn(gotoMarker, civ, gotoMarker)

3. Now you need the civilians. In ffedit in the template tab, make a list of the civilians. You will at least see civilian_female and civilian_male. You can make any character into a civilian wandering the map, just make sure the have the class Game Object Civilian and a valid example nif. They will also need a character in the characters tab. The easiest way to do it, if you download a new civilian, or want to make any character a civilian, in templates give civilian_male a new name, like civilian_alchemist and change the example nif to her art folder, or the custom mesh folder you have the new nif in. Then do the same thing in the characters tab, rename civilian_male to the same name you changed it to in the templates folder. Important that the ai is CCivilian.
4. Go back to the text editor with your mission.py. Add this code on a new line: def GetCivList():
return ["civfem", "civilian_female", "civilian_female_leather", "civilian_female_polyester", "civilian_female_toughchick", "civilian_male", "civilian_male_biker", "civilian_male_leathercoat", "civilian_male_leatherjacket", "civilian_male_lifter", "civilian_male_lifter2", "civilian_male_rocker", "civilian_male_rocker_shades", "civilian_male_suit", "civilian_male_trenchcoat", "civilian_mmin", "civilian_nurse", "civmal", "civilian_billy", "civilian_female_teen", "civilian_female_skirt", "civilian_female", "civilian_female", "civilian_female", "civilian_female", "civilian_male", "civilian_male", "civilian_male"]

Change every name to your civilian names from part 3. If you want a type more common, simply have it in the list more, like in the example, I put civilian_female and civilian_male multiple times. Very important, every name in the list has to match the template name.

I'm going to do cars next, it will be very similar to this code, and then I'll get to buildings and terrain. But you can see how it will be done, if 1-4 works for you.
Hit me with any questions here, and if any advanced coder has advice on how I can make it more efficient, please do tell. I tend to write sphaghetti code.
Title: Re: Random map
Post by: bearded on May 16, 2022, 10:29:59 AM
Important note, in part 3 change the number in the for x in range(1, #) to the number of positionals you have. And in part 4, the names have to match the names in your templates.
Title: Re: Random map
Post by: oktokels on May 16, 2022, 02:30:26 PM
So, in simple words, this is a random map creator???
I was asking for a random map selector, but this is much further beyond that and a incredible idea if it gets to work. I'll try to test this the next weekend.  :cool:
Title: Re: Random map
Post by: bearded on May 19, 2022, 06:30:38 AM
Cars work now. Exact same process, except on the map I chose, all the cars were named _impobj_###. Fortunately they were in order, so;
def RandomCar():
    for x in range(977, 1010):
         carList = GetCarList()
         car = carList.pop(randint(0, len(carList)-1))
         gotoMarker = "_impobj_" + `x`
         Object_Spawn(gotoMarker, car, gotoMarker)

And my car list.
def GetCarList():
return ["car_1", "car_2", "car_3", "car_nostand", "car_armoured", "car_batmobile", "car_police", "car_taxi", "car_predicta", "car_bigsemi", "car_blocksemi", "car_bug", "car_concrete", "car_convertable", "datsun_280z", "f1car", "bus_greyhound", "lancia", "truck_nw", "oldbeetle", "pickup", "porsche", "service_van", "suv", "toyotavan", "truck"]

This can be used with any map, even the custom ones.
Next, I'll do buildings. This will be a little trickier, as the buildings are different sizes, and if they are too close, they overlap.
Title: Re: Random map
Post by: hmarrs on August 02, 2022, 06:56:46 PM
Please post my downloads you may have on here.
I for one Appreciate it.