1. We have added a Gift Upgrades feature that allows you to gift an account upgrade to another member, just in time for the holiday season. You can see the gift option when going to the Account Upgrades screen, or on any user profile screen.
    Dismiss Notice

PerfectMongoose (PW3 Civ4 Port)

Discussion in 'Civ4 - Map Scripts' started by LunarMongoose, Dec 14, 2010.

  1. OnmyojiOmn

    OnmyojiOmn Chieftain

    Joined:
    Aug 4, 2006
    Messages:
    371
    Okay, thanks.

    The starting location resources can still be pretty frustrating. I get whales a lot, which should never happen on ancient starts. I had one game where I started on a large continent and two civs each started on their own little island chains. Their starting warrior/scout was placed on the large continent, separated from the settler.

    Just aesthetically speaking, large plains areas could have a check to make sure there's some kind of feature or resource placed per x number of contiguous plains tiles. I've had like a third of the world land area bunched up in one gargantuan plain that was nothing but empty plains terrain. Looks pretty weird.

    Overall it's a great script and I don't see myself going back to PW2f any time soon.
     
  2. LunarMongoose

    LunarMongoose Chieftain

    Joined:
    Jan 29, 2006
    Messages:
    731
    Gender:
    Male
    Location:
    Boston, MA, USA
    In regular BTS, Whales have no TechCityTrade value, which is what all previous versions of PW used, and no TechReveal value either. There is therefore no reason Whales shouldn't be part of Ancient starts... or that they shouldn't have been part of them in previous PWs either. (PW has never checked how far out in the tech tree the ability to harvest a resource is.) Sorry if I'm not being much help with this heh. I don't have time to test it vs older versions relative to Whale sightings right now, but I just double-checked the code so I'm quite sure about that part...

    That's obviously odd, but I'm almost certain it's nothing I did directly. The starting location selection code should be line-for-line identical to PW2.06. It's probably just a result of the more interesting/diverse landforms generated, and not a problem I would expect to see on larger map sizes in any case. (It also matters a great deal whether you're using the Old World setting or not.)

    I've seen that effect as well, to some degree. Directly calculating the size of a contiguous block of a terrain type is certainly doable, but I'd have to write it myself since there's no existing function to do that. What you're describing is exactly how resources are placed as it is though. The problem has more to do with the vanilla resources' XML placement settings, so even if I did calculate it I wouldn't necessarily have any good options for what to place.

    Luxury resources are designed to clump, and they are also restricted to only one landmass per type so they're bad examples. Strategics can be limited in total quantity and also tend to be revealed much later. If you just look at health resources which it tries to spread out evenly across the world, there are only 3 in regular BTS that can spawn on Plains: Cows, Sheep and Wheat. They're complicated and I haven't used them in a while so I don't remember the details atm, but there are some XML settings for each that are extremely relevant: iPlacementOrder, iConstAppearance, iMinAreaSize, iMinLatitude, iMaxLatitude, Rands, iPlayer, iTilesPer, iMinLandPercent, iUnique, iGroupRange, iGroupRand and bArea. I suspect some of these values on vanilla Cows/Sheep/Wheat, the fact that there are only 3 Plains health resources, and lack of advanced tech to reveal all the strategic resources, is the basic problem.

    I have a lot of those values set differently in my mod, and I also have more resource types like Bison, so there tends to be stuff on the Great Plains it generates, but I haven't run any tests in a couple weeks now and I wasn't paying much attention to this issue to begin with, so I'm not sure how much better it actually is (if any).
     
  3. SeekTruthFromFacts

    SeekTruthFromFacts Chieftain

    Joined:
    Nov 2, 2009
    Messages:
    656
    Can this be used with Warlords, or is it BTS only?
     
  4. remiller66

    remiller66 Chieftain

    Joined:
    Jun 11, 2003
    Messages:
    4
    Location:
    Spartanburg, SC
    Every time I use PW2f (or a map script based on it, like this one) I end up with a world of nothing but grassland and rivers. I get no mountains or ocean.:confused: I do get resources scattered on the map. Now, PW2 map script gives me great maps. Any ideas what may be causing this for me? The only mods I use are BUG AI and Blue Marble.
     
  5. LunarMongoose

    LunarMongoose Chieftain

    Joined:
    Jan 29, 2006
    Messages:
    731
    Gender:
    Male
    Location:
    Boston, MA, USA
    I actually don't know, but it wouldn't surprise me if it didn't. This is not something that's even worth my time to bother testing, honestly. BTS costs so little it's practically free at this point, it was/is a great expansion, and most mods require it; I strongly recommend picking it up.

    I know for a fact PW2, PW2f, and my two scripts here all work correctly with a clean BTS installation. "Nothing but grassland, rivers and resources" is the standard failure mode of all map scripts, meaning whenever anything goes wrong in their code, that's almost always what you get. That's true of all maps, not just these.

    PW2f's changes over PW2 are fairly minor code-wise though so just from memory I'm not sure why that'd be happening for you. I'm quite certain the maps themselves are all fine, so all I can suggest is the usual default suggestion... make sure your MyDocuments/CustomAssets folder is empty, and failing that, reinstall BTS. Though as I said above, I'm not sure if vanilla Civ4 or Warlords will work.
     
  6. remiller66

    remiller66 Chieftain

    Joined:
    Jun 11, 2003
    Messages:
    4
    Location:
    Spartanburg, SC
    Wow! Thanks LunarMongoose. Emptying the customassets folder did the trick. Your map script works great, now. Thanks, again!
     
  7. OnmyojiOmn

    OnmyojiOmn Chieftain

    Joined:
    Aug 4, 2006
    Messages:
    371
    I play mods that install under the game folder, and I have this problem whenever I try to run a map script from My Games\BTS\PublicMaps. I have to install the script in the PrivateMaps folder for the mod. Not really a big deal.
     
  8. Manfred Belheim

    Manfred Belheim Oh you can edit this

    Joined:
    Sep 11, 2009
    Messages:
    7,184
    Is it possible to modify the script slightly to allow an extra choice for starting positions? Basically I'd like to add a "Random" choice as well as "Old World" and "Everywhere", that way I can't be sure if there's going to be a New World or not, just to add an extra bit of spice to the exploration.

    Well I'm sure it IS possible, but can I be pointed in the right direction? I've found the part of the script where the option is, but I don't really know how to modify it to get this option.
     
  9. LunarMongoose

    LunarMongoose Chieftain

    Joined:
    Jan 29, 2006
    Messages:
    731
    Gender:
    Male
    Location:
    Boston, MA, USA
    Adding a third menu option is a little bit of work. Search for "mc.AllowNewWorld" to see the 4 or so places you'll have to make changes; you'll have to change that global to be handled as an int instead of a bool, enter a name for the new menu item, etc... which is actually very easy if you just base it on the code that's already there.

    Much simpler is just overriding one of the existing two menu choices to do what you want. Since that only amounts to two lines of code (plus you may want to rename the menu item), I'm gonna go ahead and give it to ya. :) Search for the function "def generatePlotTypes()", go down to where it says "if mc.AllowNewWorld", and insert this extra "if" block just before it:

    Code:
    	tm.Initialize()
    	tm.GeneratePlotMap()
    	tm.GenerateTerrainMap()
    	rm.generateRiverMap()
    	if mc.AllowNewWorld: # or "if not mc", depending on the menu item to override
    		mc.AllowNewWorld = (PRand.random() < 0.5) # or whatever chance you want
    	if mc.AllowNewWorld:
    		continentMap.generateContinentMap()
    	plotTypes = [PlotTypes.PLOT_OCEAN] * em.length
    Btw I'm only 95% sure this will work, since the global is also referenced down in assignStartingPlots() which is another core hook function, and without checking the SDK code I'm not positive it's called after generatePlotTypes() like it would need to be. It should be though.

    Assuming this does work, I'll consider adding it as an option if there's an update in the future, which you would think there would be, at some point... ;)
     
  10. Manfred Belheim

    Manfred Belheim Oh you can edit this

    Joined:
    Sep 11, 2009
    Messages:
    7,184
    Thanks :)

    Before coming back to this thread I already had another look and changed

    Code:
    def getCustomMapOptionDefault(argsList):
    	return 0
    
    
    def isRandomCustomMapOption(argsList):
    	return False
    to

    Code:
    def getCustomMapOptionDefault(argsList):
    	return 0
    
    
    def isRandomCustomMapOption(argsList):
    	return True
    Which has added a "Random" option to pretty much every menu option. I thought it was probably a bit too crude to work though, but I tested it by generating a map with the same random seed a few times. One time a large continent at the bottom had no starting civs and the other times it did so it seems like it might be working. Not sure though.

    But even if it does I think I'd prefer your neater solutions :)
     
  11. LunarMongoose

    LunarMongoose Chieftain

    Joined:
    Jan 29, 2006
    Messages:
    731
    Gender:
    Male
    Location:
    Boston, MA, USA
    What the heck? ... Holy carp. I didn't know that flag even existed! (Edit: Actually I think I did, and completely forgot. Oops.) I'd have to take a closer look which I don't have time to do atm, but based on how I already know the menu options work, I would strongly suspect what you did will in fact work perfectly, and would even be the preferred solution. (It's actually "neater" to use built-in functionality than to add more of one's own, though you can still control the random chance with my version if you wanted something other than coin-flip odds.)

    I'm guessing it just causes the exe (not the dll since this stuff is hardcoded sadly) to pick a menu option randomly when the script starts, as if a user had picked it. The option probably exists precisely b/c of the problem I mentioned with different hook functions referencing the same settings at different times potentially, so that you need to know where the first thing that runs in the map script is so you can do your own randomizing there, so every function sees the same value of it. (Just be glad the game isn't trying to multithread this process, heh heh.)

    Anyway, if what you found and did does what I think it will, it should run the same code that gets run when the user manually chooses a given option, even if it's a custom option... So yeah, if/when I ever post a new version I will probably turn that on. Thanks for reminding me of it. :)
     
  12. strategyonly

    strategyonly C2C Supreme Commander

    Joined:
    Mar 13, 2006
    Messages:
    20,445
    Gender:
    Male
    Location:
    MN
    How would these mapscripts work with a completely revised edition of Civ4, ie, I have Prehistoric era, a TransHuman Era and a Galactic Era, all included in my mod?

    I tried the PerfectMongoose_v310 one, but dont know if things need to be revised for my mod, and PerfectWorld_v208 didnt work at all?
     
  13. LunarMongoose

    LunarMongoose Chieftain

    Joined:
    Jan 29, 2006
    Messages:
    731
    Gender:
    Male
    Location:
    Boston, MA, USA
    The mapscripts don't care about new techs, units, buildings, civics, or leaders. They DO care about new terrain types, features, and resources. If you have only added new ones then it will probably work but won't make use of them in many cases. If you have changed or removed any existing vanilla terrain/feature/resource types, that may crash them.

    MongooseMod comes with customized versions of 3.1/2.08, for example, due to the extra content in the mod. Some of the t/f/r types are handled on a case-by-case basis in the mapscript code, so I'd have to see your mod to give you very detailed, specific answers. Updating these files for custom content isn't THAT hard, but it can be kinda tricky.

    The best advice I can give ya is to compare the vanilla PM files from this thread with the custom versions that come with MM, and figure out what you need to do from there. I apologize, but I really don't have time to do it myself for other people's mods, heh.
     
  14. Tholal

    Tholal Chieftain

    Joined:
    May 19, 2009
    Messages:
    1,676
    Excellent! Glad to see the Civ4 mapscript getting some love!

    But where are the rivers? I created a couple of maps with default settings, standard size map, and 90% of the rivers are only 1-2 tiles long. The longest I ever saw was 4 tiles. What happened to the real rivers?
     
  15. LunarMongoose

    LunarMongoose Chieftain

    Joined:
    Jan 29, 2006
    Messages:
    731
    Gender:
    Male
    Location:
    Boston, MA, USA
    Well, I tweaked some of the control variables around several times trying to get better rivers and lakes, so I'm not sure what to tell ya. Admittedly I mainly tested it on Huge maps, so it's possible my settings didn't scale down to smaller map sizes very well.

    You can try adjusting them; they're clearly labelled and described at the top of the file just like they've always been (just open it in any text editor). You can also try the PW2 climate menu option, since that uses a mostly-separate set of control values (and a completely different moisture map).

    I'll take a look at smaller maps when I have time, though just offhand I'm not sure there are really supposed to be rivers longer than 4 tiles on something the size of Standard, from a realism standpoint. I could easily be wrong though.

    Edit - Though come to think of it, I was actually left wanting rivers to be a bit longer in the PW3 climate system. (Sorry, it's been a while now since I've worked on this so I kinda forgot, heh.) I basically plugged the new climate map, which includes a new moisture/rainfall map, into the old PW2 river generator since PW3 didn't come with one (because Civ5, for which PW3 was written, handles river placement automatically, or something). SO BASICALLY I need to write a new river function for the PW3 climate system, but it's a hard/complicated subject and the existing one worked well enough I thought, so I didn't bother. I'll look into it if/when I have time, though it's a low priority atm.

    Again, just to be clear, the PW2 climate setting in the PM3 file does NOT make it work the same as the PW2 file; it still uses the PW3 landmass generator, which is the other big half of the equation. In a future version I was going to try to combine the two map files, basically adding a PW2/PW3 landmass type menu option to go with the existing climate menu option. This will also be a lot of work though, so it's a low priority too. :)
     
  16. LunarMongoose

    LunarMongoose Chieftain

    Joined:
    Jan 29, 2006
    Messages:
    731
    Gender:
    Male
    Location:
    Boston, MA, USA
    I really hope the small flood of MM downloads the last few weeks hasn't just been to get the custom versions of this mapscript, lol. Oh well, don't forget to try the mod while you're at it then! :p
     
  17. AIAndy

    AIAndy Chieftain

    Joined:
    Jun 8, 2011
    Messages:
    3,408
    Something seems to be really wrong with the PW3 rainfall model compared to the PW2 one. While with PW2 all plots get at least a bit of rain, with PW3 you get many land plots with exactly zero rain. That is neither realistic nor do I think that is intended.
    The result in your script is that temperature makes those plains or deserts and nearly all plots with at least a bit of rainfall become grassland.
     
  18. LunarMongoose

    LunarMongoose Chieftain

    Joined:
    Jan 29, 2006
    Messages:
    731
    Gender:
    Male
    Location:
    Boston, MA, USA
    You might be surprised, heh. The code that generates the rainfall maps is copied out unchanged from PW3 for Civ5. In the thread for that version Ceph talked about this issue a fair amount, though atm I don't remember all the details. Something about rain shadows from mountains, and trying to actually be more realistic. I do know PW3 uses a completely different rain system, rewritten from scratch since PW2.

    I do remember checking the rainfall values numerically in a bunch of tests to make sure the code was working right when I was porting it. I definitely wasn't getting 0's very often. I did wind up changing the terrain threshold values for rain and temperature a fair amount, but I was pretty sure it was working right and that what I changed was just preference. (I was trying to get them to show up in roughly equal quantities overall.)

    I could, of course, be completely wrong - that's always possible. ;) But I am reasonably sure I reproduced Ceph's original code correctly. I don't claim to understand that part of it; he's the climate/statistics/modelling/mathematics expert, heh.

    You can try setting the threshold values back to their Civ5 defaults... If you get significantly different results at that point from what happens with Ceph's original version in Civ5, THEN I probably DID do something wrong. :)
     
  19. AIAndy

    AIAndy Chieftain

    Joined:
    Jun 8, 2011
    Messages:
    3,408
    What I was trying to do is adapt the script for the extra terrain now being added to the C2C mod. With PW2 that worked fine, computing rainfall thresholds in the same way from the percent of plots you want with a certain terrain.
    With PW3, using that same plot percent to threshold calculation, huge amounts of plots end up as salt flats. So I printed the rainfall map to see what happens and those plots simply had 0 rainfall resulting in the threshold calculation fail.
     
  20. LunarMongoose

    LunarMongoose Chieftain

    Joined:
    Jan 29, 2006
    Messages:
    731
    Gender:
    Male
    Location:
    Boston, MA, USA
    Okay. Well like I said, I'm 90% sure that's just how PW3's rainfall system works. Ceph made a big deal about mountains creating "rain shadows" when he wrote it, among other effects, and this was heavily discussed in the Civ5 PW3 thread.

    I did specifically allow PM to use the PW2 climate system (temperature and rainfall) with the PW3 terrain system (better-looking landmasses) because I recognized the major difference with the new climate system, and I knew that if I might want the old system, then others might too, heh.

    But I don't think it's anything I did wrong in the port.
     

Share This Page