Please login or register.

Login with username, password and session length
 

News:

Happy 20th Birthday, Freedom Force !!!


Author Topic: Random map  (Read 872 times)

Offline oktokels

  • Hero Member
  • Posts: 592
Random map
« 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:

Offline bearded

  • b?rtinleger
  • Hero Member
  • Posts: 3640
Re: Random map
« Reply #1 on: May 04, 2022, 02:47:07 PM »
I've been thinking about this. Poke me later.

Offline bearded

  • b?rtinleger
  • Hero Member
  • Posts: 3640
Re: Random map
« Reply #2 on: May 10, 2022, 04:01:00 PM »
Here's what I came up with.
Code: [Select]
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.

Offline oktokels

  • Hero Member
  • Posts: 592
Re: Random map
« Reply #3 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:

Offline bearded

  • b?rtinleger
  • Hero Member
  • Posts: 3640
Re: Random map
« Reply #4 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.

Offline bearded

  • b?rtinleger
  • Hero Member
  • Posts: 3640
Re: Random map
« Reply #5 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.

Offline bearded

  • b?rtinleger
  • Hero Member
  • Posts: 3640
Re: Random map
« Reply #6 on: May 15, 2022, 12:44:04 PM »
I've got random civs set up. I'll post a "how to" tonight.

Offline bearded

  • b?rtinleger
  • Hero Member
  • Posts: 3640
Re: Random map
« Reply #7 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:
Code: [Select]
def OnPostInit():
Below OnPostInit, paste this:
Code: [Select]
     RandomCiv() and on a new line, paste this:
Code: [Select]
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:
Code: [Select]
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.

Offline bearded

  • b?rtinleger
  • Hero Member
  • Posts: 3640
Re: Random map
« Reply #8 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.

Offline oktokels

  • Hero Member
  • Posts: 592
Re: Random map
« Reply #9 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:

Offline bearded

  • b?rtinleger
  • Hero Member
  • Posts: 3640
Re: Random map
« Reply #10 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;
Code: [Select]
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.
Code: [Select]
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.

Offline hmarrs

  • Sr. Member
  • Posts: 372
Re: Random map
« Reply #11 on: August 02, 2022, 06:56:46 PM »
Please post my downloads you may have on here.
I for one Appreciate it.