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

[Map Script] PerfectWorld2.py

Discussion in 'Civ4 - Map Scripts' started by cephalo, Feb 17, 2009.

  1. cephalo

    cephalo Deity

    Joined:
    Jul 26, 2007
    Messages:
    2,058
    Location:
    Missouri, USA
    Ok I took a nap, and while napping I realized that there is no harm in simply reinitializing the map once generation begins. So I initialize to setup the map options, and then initialize again before anything has a chance to change. That fixed the problem with Blue Marble.

    However, I also found a couple of intermittant bugs that I would like to track down before the next release. One of them is in the starting plot code, and I've never seen it before, so it might be related to my reinitialization.
     
  2. ColdFever

    ColdFever blue

    Joined:
    Sep 14, 2001
    Messages:
    478
    Location:
    Luebeck, Germany, civilized.de
    Thanks a lot for the interesting and reassuring information, Cephalo!
     
  3. cephalo

    cephalo Deity

    Joined:
    Jul 26, 2007
    Messages:
    2,058
    Location:
    Missouri, USA
    Ok, I've been generating maps for two evenings, and none of those intermittant bugs have shown up, preventing me from fixing them. The one that causes the starting plot code to crash is especially insidious, because if you don't have popups enabled you can play half a game before you realize the starting plots are bad.

    So instead of fixing the bugs I can no longer find, but I know are still there, I added a popup window that comes up in case the starting plot code fails. It pops up even if python errors are disabled to let the player know he's using the default placement, which doesn't work well with PW. It also contains some debugging info to help me repeat the error and maybe even fix it some day.

    Also, the Blue Marble problem appears to be fixed.

    2.03 is released!
     
  4. ColdFever

    ColdFever blue

    Joined:
    Sep 14, 2001
    Messages:
    478
    Location:
    Luebeck, Germany, civilized.de
    Great service. I installed the new PW2 map script and can confirm that it runs nicely with Blue Marble in multiplayer now. Thanks, Cephalo!
     
  5. Bad Player

    Bad Player Deity

    Joined:
    Oct 31, 2005
    Messages:
    3,531
    Location:
    (Bris)Vegas!
    will this work with 1.19 bts?
     
  6. dwaxe

    dwaxe is not a fanatic

    Joined:
    Aug 11, 2007
    Messages:
    1,506
    Location:
    The Internet
    Yes it will. I've started a new game and it does.
     
  7. TheLadiesOgre

    TheLadiesOgre Aspiring Codesmith

    Joined:
    Jan 16, 2009
    Messages:
    505
    Cephalo,
    I have a question for you. I know that you know a lot about map scripting, PerfectWorld and PerfectWorld2 are both superb examples of your skills. I was wondering if you thought it would be at all possible to incorporate the mountains from colonization into a BTS map. I am not talking about a simple exchange of peaks, I am thinking in addition to the peaks from BTS, there would also be the peaks from colonization. The way I was thinking is that they would be a terrain passable intermediary between hills and typical BTS terrain impassable peaks. Think about it, people do live in mountains like the rockies and the appalachian range and many other ranges across the world, that is what the colonization peaks could represent. I don't know what all this idea would entail, though I assume it would require some dll editing (so that it recognizes the new "low peaks"), XML editing (to add the game info for the low peaks) and then the map script to actually implement them. The marshes could be added as well (I know that they already work for BTS cause I downloaded them the other day and have them in my custom assets) for even more perceived depth to the map. Do you think that it would be possible? :confused: If so, what would need to be done and how could I help?
     
  8. cephalo

    cephalo Deity

    Joined:
    Jul 26, 2007
    Messages:
    2,058
    Location:
    Missouri, USA
    This would have to be an actual mod. Once you get the 'in-between' stuff to appear in game, then it's pretty trivial to make a special version of PW to generate it. Seven05made a version of PW1 with 'Deep Ocean' that looked really nice.

    Different terrain types, like TERRAIN_MARSH, are easy, but you might run into trouble with the 'lesser peaks'. The plot types, PLOT_PEAK, PLOT_HILLS, PLOT_LAND, PLOT_OCEAN are hard coded in the core I believe. Each type is used for determining the 3D shape of the map plot. Colonization only changes the shape of PLOT_PEAK, it doesn't actually give us a new type. Trying to create a new 'PlotType' will require a ton of research. I'm not saying it's impossible, but one would have to know alot more than I do about how the graphics engine handles map squares.
     
  9. TheLadiesOgre

    TheLadiesOgre Aspiring Codesmith

    Joined:
    Jan 16, 2009
    Messages:
    505
    Correct me if I am wrong, but the dll is the hardcoded part of the game right? If it is then PLOT_LESSER_PEAK would need to be added to CvPlot.cpp right? (I know how to edit XML and do math in Python, last night was the first time I actually looked at any SDK files and I damn near pitched my laptop out the window it was so aggravating). I'm trying to teach myself how to do this stuff with a little more depth than solely XML editing and I really think that this would look cool. If I'm wrong about the dll though, then it is a moot point anyway.

    Edit: Would what I was looking for look like this?

    Spoiler :
    PlotTypes CvPlot::getPlotType() const
    {
    return (PlotTypes)m_ePlotType;
    }


    bool CvPlot::isWater() const
    {
    return (getPlotType() == PLOT_OCEAN);
    }


    bool CvPlot::isFlatlands() const
    {
    return (getPlotType() == PLOT_LAND);
    }


    bool CvPlot::isHills() const
    {
    return (getPlotType() == PLOT_HILLS);
    }


    bool CvPlot::isPeak() const
    {
    return (getPlotType() == PLOT_PEAK);
    }


    bool CvPlot::isLesserPeak() const
    {
    return (getPlotType() == PLOT_LESSER);
    }


    Note, I already added PLOT_LESSER (that is if I'm doing the right thing at the right spot)
     
  10. cephalo

    cephalo Deity

    Joined:
    Jul 26, 2007
    Messages:
    2,058
    Location:
    Missouri, USA
    The DLL is the deepest level of the game we have access to, but then there is some deeper stuff involving the graphics engine. I've seen alot of mods, and I have not seen one yet that adds a new plot type. That doesn't mean it's impossible, but it does mean that you as the modder would be charting new territory. For one thing, you would need to determine how your new plot type interacts graphically with neighboring plot types, both of the same type and others like peaks. You can imagine it can get complicated! I don't even know where that kind of logic happens, I'm thinking maybe it's not in the DLL (Someone correct me if I'm wrong!).

    One plot type that people often want in their mods is the 'Volcano' plot type. All the ones that I've seen use a terrain 'feature' instead of an actual plot type in an attempt to fake it, and it looks terrible because there can't be any interaction with the neighboring plots. It invariably looks like a giant Hershey's Kiss sitting on a plain, with no relation to any hills or mountains that may be nearby.
     
  11. TheLadiesOgre

    TheLadiesOgre Aspiring Codesmith

    Joined:
    Jan 16, 2009
    Messages:
    505
    With as open as Firaxis has been what with releasing the SDK and all, do you think if I explained what I was trying to do they'd point me in the right direction?
     
  12. cephalo

    cephalo Deity

    Joined:
    Jul 26, 2007
    Messages:
    2,058
    Location:
    Missouri, USA
    I'm not sure who to talk to about that. It's one of those things where you could try to email somebody from Firaxis, and then wait until CivXIII comes out before you get a response. :lol:

    Sometimes they will reply to posts on Civfanatics. I've seen it happen, but don't hold your breath.
     
  13. TheLadiesOgre

    TheLadiesOgre Aspiring Codesmith

    Joined:
    Jan 16, 2009
    Messages:
    505
    Yeah, I saw Soren Johnsons post on CivIV cheat codes, back when CivIv had just shipped
     
  14. TheLadiesOgre

    TheLadiesOgre Aspiring Codesmith

    Joined:
    Jan 16, 2009
    Messages:
    505
    Cephalo, thanks again for the help I haven't had a chance to test out the altered script yet (I will tonight, and let you know if it worked tomorrow). Though, I had a thought while I was comparing the two regarding the "Make Harbor" function. I was wondering if it would be possible to alter the "Make Harbor" function so that sometimes it would make a big harbor and sometimes it would split the harbor into coast and marsh and just run the river to the coast. I know that I'm not describing what I'm thinking the best, I'll make WB screenshots of what I'm trying to describe and post them tomorrow along with my test results.
     
  15. TheLadiesOgre

    TheLadiesOgre Aspiring Codesmith

    Joined:
    Jan 16, 2009
    Messages:
    505
    I can't get it to "Setup Map" during the initializing process. It goes "Initializing", "Setup Players" and then straight to "Finishing". When the map opens, I have no units and I have been defeated. I am attaching the altered file (not sure which one is the one that actually gave me a map), but I had to play with it a little to even get it to go past initializing (I let it sit for 15 minutes the one time I tried it). I compared it with Faireweather and the unaltered PerfectWorld2 and I was up a good deal of the night unleashing strings of expletives at my computer. I even renamed it at one point to see if that would make it work. Please tell me what I did wrong and how to fix it.
     
  16. cephalo

    cephalo Deity

    Joined:
    Jul 26, 2007
    Messages:
    2,058
    Location:
    Missouri, USA
    If you are going to get involved in Python programming, you need to turn on python error pop ups in your config file, and look at your PythonErr.log file. Also, if you are trying to figure out what your code is doing and how far it's getting, use print statements that will show up in your PythonDbg.log file. Python has some quirks that take getting used to, and the simplest error will crash the map.

    I don't have time to go through your code, and if I solved the problem for you, you wouldn't learn anything!
     
  17. muxec

    muxec Prince

    Joined:
    Jun 25, 2002
    Messages:
    453
    Location:
    Probably at home :)
    Nice script, I will try playing on such a map today.
     
  18. TheLadiesOgre

    TheLadiesOgre Aspiring Codesmith

    Joined:
    Jan 16, 2009
    Messages:
    505
    I finally got it to work late last night, though it wasn't planting jungles at all and forests were only on the southernmost and northernmost coastlines. However, I fixed that today and the only thing I can't figure out now is why it keeps giving me a one tile wide strip of land right where the minimaps east-west border is. It isn't giving me any errors and I've compared it to a out-of-the-box (as it were) copy of PerfectWorld2 and it is essentially the same file other than the marsh and some stuff I grabbed from FaireWeather concerning marsh. Could you at least point me in the direction you think I should be looking based off of what I have described?
     
  19. cephalo

    cephalo Deity

    Joined:
    Jul 26, 2007
    Messages:
    2,058
    Location:
    Missouri, USA
    Hmm, if everything you changed concerns only marsh and where to put it, I can't think of anything that would create land where water should be. Did you mess with the heights and widths of the map at all? I ask because there are some complications that can arise when you change the heightmap size.
     
  20. TheLadiesOgre

    TheLadiesOgre Aspiring Codesmith

    Joined:
    Jan 16, 2009
    Messages:
    505
    I uncommented the block under #Remove Bad Features (jungle in a standard game) and the only variables I messed with were minMarshTemp and alwaysMarshTemp. Oh, and I added getContinentCenter the whole way down to return nID from FaireWeather (but when I added that is when it actually started to give me a map) I'll check through that stuff to see if it is obviously different from anything comparable from PerfectWorld2. I really like the maps it is giving me other than the strip of land. If I increase this Width value will it fix it?

    Spoiler :
    #Height and Width of main climate and height maps. This does not
    #reflect the resulting map size. Both dimensions( + 1 if wrapping in
    #that dimension = False) must be evenly divisble by self.hmMaxGrain
    self.hmWidth = 176
    self.hmHeight = 81
     

Share This Page