How to make pseudo-random battle maps?

Users who are viewing this thread

So I know how to change battle maps so that they can be individual scenes (or at least according to this post here:
from http://forums.taleworlds.com/index.php/topic,95000.msg2496245.html#msg2496245

Tempered said:
I thought I answered this question for you in another thread?

You need to read up on using the module system first and foremost  because you will need to recompile some code.
Then you need to edit 8 scenes in scenes.py  They will be named "random_scene_plain", "random_scene_steppe", etc. etc. for each terrain type.

First, delete the flag sf_randomize

Code:
    ("random_scene_steppe",sf_generate|sf_randomize|sf_auto_entry_points,"none", "none", (0,0),(240,240),-0.5,"0x0000000229602800000691a400003efe00004b34000059be",
    [],[], "outer_terrain_steppe"),

It will look like this after deleting the flag

Code:
  ("random_scene_steppe",sf_generate|sf_auto_entry_points,"none", "none", (0,0),(240,240),-0.5,"0x0000000229602800000691a400003efe00004b34000059be",
    [],[], "outer_terrain_steppe"),

Now, look at that very big number at the end, you need to replace it with one you copy from the game.
Set windowed mode and edit mode in the game configuration and then start a game.  When on the world map, click on the "terrain" button.  You  now need to adjust the sliders in the menu to generate a terrain that you like.  You can keep on hitting generate until you are happy with the results. Once you have it how you like it, hit the copy key.  This will copy that huge number which tells the game how to generate your terrain. 

Close the game and edit the 8 random scene entries in module_scenes.py.  Paste the number you just copied over the number in each scene entry.
Compile the game and you're done. No more random battle scenes.
It works well enough in this manner, but obviously it's not all that exciting to play on the same map all the time).

However I'm a total noob when it comes to scripting and I'm not entirely sure where to look or what sort of code I could write so that there be multiple scenes for each terrain type so that I won't get the insane hills that show up in native, but will still have "random" battle scenes.
 
There are two ways to deal with it; I'm currently using a fusion of both:

1. Redesign the campaign map so that there aren't many mountain terrain polygons. The bumpiness of terrain in randomly generated scenes is based solely on the distance to the nearest mountain texture on the map. So a map with lots of valleys and cliffs will cause almost every scene to be ridiculously bumpy. There was a long-assumed myth that it was the height of the terrain that caused it, but I've tested it and terrain height makes almost no difference.
The downside to this is that you can end up breaking the strategic element of the game by allowing campaigning armies to just plough through the whole game unimpeded like it's Risk.

2. Set a random scene chooser in module_scripts. This is very flexible and you can even include random scenes, forts and towns in the list. Go to setup_random_scene in module_scripts and use this code as a template for each terrain type:

LocNlol said:
...
(else_try),
  (eq, ":terrain_type", rt_forest),
  (store_random_in_range, ":random_no", 0, 3), #due to the way this works, it will only pick the numbers 0 ,1 and 2, NOT 3. Bear this in mind if you're expanding this code.
  (try_begin),
      (eq, ":random_no", 0),
      (assign, ":scene_to_use", "scn_customforest"),
  (else_try),
      (eq, ":random_no", 1),
      (assign, ":scene_to_use", "scn_customforest2"),
  (else_try),
      (eq, ":random_no", 2),
      (assign, ":scene_to_use", "scn_customforest3"),
  (try_end),
(else_try),
...

 
Thanks. For the first one, would I use Thorgrim's map editor, or Swyter's cartographer to do something like that?

The second is more up my alley for what I want to do though. Seems simple enough as well. I appreciate the help.
 
Back
Top Bottom