Advertisement
Civilization Fanatics' Center  

Go Back   Civilization Fanatics' Forums > CIVILIZATION IV > Civ4 - Creation & Customization > Civ4 - Map Scripts

Reply
 
Thread Tools
Old Jul 29, 2009, 01:25 PM   #41
God-Emperor
Deity
 
Join Date: Jul 2009
Location: Texas
Posts: 3,353
Quote:
Originally Posted by TC01 View Post
I was trying to make it possible for wormholes to be added to this mapscript (like I did with the default FinalFrontier mapscript) and ran into some confusing errors.

Firstly, I wanted to make sure that my wormholes would be placed some distance away from each other and added this function to the mapscript, based on the checkForRoom one that is triggered from each feature generation.

Code:
    def checkForWormholeRoom(self,x,y,feature):
        gc = CyGlobalContext()
        mmap = gc.getMap()
        xStart = x - (CyMap().getGridWidth() / 4)
        xEnd = x + (CyMap().getGridWidth() / 4) + 1
        yStart = y - (CyMap().getGridHeight() / 4)
        yEnd = y + (CyMap().getGridHeight() / 4) + 1
        for yy in range(yStart,yEnd):
            for xx in range(xStart,xEnd):
                if (yy == yStart or yy == yEnd - 1) and (xx == xStart or xx == xEnd - 1):
                    continue #skipping corners
                i = GetIndex(xx,yy)
                if i == -1:
                    return False
                plot = mmap.plot(xx,yy)
                if plot.getFeatureType() != feature:
                    return False
        return True
Then, I changed the checkForRoom and shouldAddFeature function line (which requires them to all be true) to this:

Code:
if self.shouldPlaceFeature(x,y,self.featureWormhole) and self.checkForRoom(x,y,self.featureWormhole) and self.checkForWormholeRoom(x,y,self.featureWormhole):
However, when I do this the map seems to hang while "initializing map". So I gave up and removed this... but now my wormholes get dropped within, say, six plots of each other occasionally (which make them useless). Is there something wrong with my code? Or some easier way I can do this?
I think you need to reconsider the meanings of the "if" statements inside your loops.

I haven't looked at the scrip to see what the GetIndex function is doing, but I have to assume it is basically the equivalent of "mmap.plotNum(xx,yy)". If so, then what the "if" statement immediately after it doing is making the function return false if you ware within 25% of the map width or height of an edge.

I assume the function is used to allow the placement of a wormhole. If so, then that first "if" makes it impossible for you to place one within a very wide border around the edge of the map.

The second "if" condition is insisting that every single plot in the very wide area must have the same feature on it. I seriously doubt that you will find any region measuring half the side of the map in both directions where every single plot has the same feature. Thus it will effectively always return false. If the thing calling this loops until it returns true, then this would make it an infinite loop.

My suggestions, based on some assumptions about what you really want:

In the first "if" make it a "continue" instead of a "return False" so that the loops will keep looping, just skipping the rest of the statements in the loop when the plot is off the map (if that's what i = -1 means)

For the second "if" it is less clear what you want. I am guessing that what you really want is to find out if there is already some feature (a wormhole, I expect) in the area. In that case, change the condition from "!=" to "==", so that you will bail out if you find the feature instead of bailing out if you don't find the feature.

Last edited by God-Emperor; Jul 29, 2009 at 01:27 PM. Reason: even more typos than usual
God-Emperor is offline   Reply With Quote
Old Jul 29, 2009, 07:02 PM   #42
TC01
Deity
 
TC01's Avatar
 
Join Date: Jun 2009
Location: Irregularly Online
Posts: 2,132
There are actually three if statements there, though.

For the first one (the wide radius around the edge of the map), I'll delete that one. I changed the values of xStart, xEnd, yStart, and yEnd from the original checkForRoom function and didn't look to see where else they were used. So I'll just get rid of this part.

For the second one (what you later say the first one), I'll change it to a continue.

For the third one (the second one, as you say), you are correct in what I want... again, I based it off of the original function, where it is a "!=", but it's a "no feature", rather than a specific feature. I'll change it to a "=="



Just tested it, it worked fine. Thanks God-Emperor!
TC01 is offline   Reply With Quote
Old Jul 30, 2009, 01:09 AM   #43
God-Emperor
Deity
 
Join Date: Jul 2009
Location: Texas
Posts: 3,353
Quote:
Originally Posted by TC01 View Post
There are actually three if statements there, though.
Oops. Bad editing - I left out the line that was supposed to say something like "The first one may be OK but the next two are probably wrong", with my later numbering refering to the two that were wrong. Fortunately you figured out what I meant.

Way back in highschool I had a math teacher who said that when at the blackboard she would write A, say B, think C, but really mean D. I am, fortunately, usually a step or two closer to what I really mean than that.

Quote:
Originally Posted by TC01 View Post
Just tested it, it worked fine. Thanks God-Emperor!
You're welcome.
God-Emperor is offline   Reply With Quote
Old Aug 01, 2009, 08:14 AM   #44
Daryl95
Templar
 
Daryl95's Avatar
 
Join Date: Nov 2008
Location: America
Posts: 271
How can I add new features to this map and change the features used for spiral arms and the center of the galaxy. I have made new features but when I try to add them to this map it disappears from the map script selection screen. I even tried adding them to the original FinalFrontier.py but then the game crashed. I just copied and pasted code and changed the feature names.
__________________
"The definition of insanity is repeating the same behavior over and over again expecting different results." - Benjamin Franklin
This isn't working

The New MoreStuffMod!
Daryl95 is offline   Reply With Quote
Old Aug 02, 2009, 12:37 PM   #45
TC01
Deity
 
TC01's Avatar
 
Join Date: Jun 2009
Location: Irregularly Online
Posts: 2,132
Quote:
Originally Posted by Daryl95 View Post
How can I add new features to this map and change the features used for spiral arms and the center of the galaxy. I have made new features but when I try to add them to this map it disappears from the map script selection screen. I even tried adding them to the original FinalFrontier.py but then the game crashed. I just copied and pasted code and changed the feature names.
I was able to add features (see the discussion above).

In your XML, are the features added to the top or bottom of the file? There are apparently problems if you add to the top. (I used a module so it worked fine).
TC01 is offline   Reply With Quote
Old Aug 02, 2009, 07:03 PM   #46
Daryl95
Templar
 
Daryl95's Avatar
 
Join Date: Nov 2008
Location: America
Posts: 271
Quote:
Originally Posted by TC01 View Post
I was able to add features (see the discussion above).

In your XML, are the features added to the top or bottom of the file? There are apparently problems if you add to the top. (I used a module so it worked fine).
They are at the bottom. I added the Quasar then I loaded the game and it didn't show up. Then I added the Spiral Arm and the mapscript wouldn't show up. It's possible this is from me adding to the FinalFrontier.py but I think it was this one. I know I was having problems with this particular one though.
__________________
"The definition of insanity is repeating the same behavior over and over again expecting different results." - Benjamin Franklin
This isn't working

The New MoreStuffMod!
Daryl95 is offline   Reply With Quote
Old Aug 02, 2009, 07:37 PM   #47
TC01
Deity
 
TC01's Avatar
 
Join Date: Jun 2009
Location: Irregularly Online
Posts: 2,132
Quote:
Originally Posted by Daryl95 View Post
They are at the bottom. I added the Quasar then I loaded the game and it didn't show up. Then I added the Spiral Arm and the mapscript wouldn't show up. It's possible this is from me adding to the FinalFrontier.py but I think it was this one. I know I was having problems with this particular one though.
First, do you have python exceptions on?

The process to add a feature to this mapscript is quite complicated. Here's how I did it for WormholesSpiralGalaxy (and for the generic supernova when I did more complicated stuff)

1. Define how many of your feature to be placed per plot. I only wanted two on the entire map, so I don't have a value for this (so it's just the supernova). Put it at the top of the file:

Code:
SupernovasPerPlot = 0.00042
2. Add a "ft = featureDef" statement under def initFeatureDefList. These values control, well, I'm not quite sure for some. armDistance controls how far it is from each arm, that I know. You can compare the Solar System and the Black Hole FeatureDefs if you want...

Code:
        ft = FeatureDef(self.featureWormhole)
        ft.arcLength = 0.5
        ft.arcLengthRange = 0.7
        ft.arcLengthMaxChance = 1.0
        ft.armDistance = 0.2
        ft.armDistanceRange = 0.3
        ft.armDistanceMaxChance = 0.5
        self.featureDefList.append(ft)
3. Declare your feature in the beginning of def generateFeatures.

Code:
        self.featureWormhole = gc.getInfoTypeForString("FEATURE_WORMHOLE")
4. Define how many times you want your feature to appear on the map. For WormholesSpiralGalaxy, I only wanted two, so this is the Supernova line:

Code:
        numSupernovas = int(float(numPlots) * SupernovasPerPlot)
5. Again, this is the supernova, since I did different stuff. But this is the actual code to find the plot the feature should be placed. Same function as the two above.

Code:
        #Supernovas
        numPlaced = 0
        iterations = 0
        while(True):
            iterations += 1
            if iterations > 20:
                print "Not all supernovas could be placed!!!!!!!!!!!!!!"
                break
            if numPlaced == numSupernovas:
                break
            for n in range(len(plotList)):
                x,y = plotList[n]
                if self.shouldPlaceFeature(x,y,self.featureSupernova) and self.checkForRoom(x,y,self.featureSupernova):
                    numPlaced += 1
                    self.placeSupernova(x,y)
                    if numPlaced == numSupernovas:
                        break
        print "Placed %(p)d out of %(n)d supernovas" % {"p":numPlaced,"n":numSupernovas}
6. Then, there's the function to actually place the feature (called from the function above. It should be idented under the def generateFeatures function. The "placeholder" is whatever feature you want to surround the feature. Here is the wormhole one again:

Code:
    def placeWormhole(self, x, y):
        gc = CyGlobalContext()
        mmap = gc.getMap()
        xStart = x - 2
        xEnd = x + 3
        yStart = y - 2
        yEnd = y + 3
        for yy in range(yStart,yEnd):
            for xx in range(xStart,xEnd):
                if (yy == yStart or yy == yEnd - 1) and (xx == xStart or xx == xEnd - 1):
                    continue #skipping corners
                plot = mmap.plot(xx,yy)
                if x == xx and y == yy:
                    plot.setFeatureType(self.featureWormhole,0)
                else:
                    plot.setFeatureType(self.featurePlaceHolder,0)
TC01 is offline   Reply With Quote
Old Apr 24, 2010, 11:44 AM   #48
Challs
Warlord
 
Challs's Avatar
 
Join Date: Apr 2010
Location: Denmark
Posts: 106
...

Looks nice in the picture. I just hope i does the same in game
Challs is offline   Reply With Quote
Old Apr 24, 2010, 03:40 PM   #49
God-Emperor
Deity
 
Join Date: Jul 2009
Location: Texas
Posts: 3,353
It works well.

They are a bit larger (in total number of plots) than the regular Final Frontier map of the same size category but there are typically more unusable plots so it works out to a similar number of star systems (it might be slightly more). Exploration is a little harder and maintenance is a little higher due to things being a little more spread out.
__________________
Mod: Final Frontier Plus, version 1.83 released 26-August-2013
Mod: Rocks 2 Rockets, version 0 patch 0.4 released 26-October-2013
God-Emperor is offline   Reply With Quote
Old Aug 02, 2013, 03:20 PM   #50
PsiCorps
FF: Babylon 5 mod team
 
PsiCorps's Avatar
 
Join Date: Dec 2007
Location: Britain
Posts: 1,294
I realize that this may well be classed as a dead thread but I have a question about Final Frontier map features.

Is it possible to have the 2nd and 3rd radii effects of the black hole set as an invisible effect?

What I am thinking is this. A scout ship goes out into space and is opening up the depths of space for your civ... unfortunately it is caught in a gravity field it was unable to detect due to the quality of it's equipment. The ship is lost and the Civ only has a rough idea of where they lost contact with their vessel.. The area of space becomes a no go zone until such time as they develop equipment that enables them to identify exactly where the event horizon of the black hole is and thus revealing the entirety of the Black Hole.

If it's possible to hide the central and outer regions of the black hole until a tech is researched I'd really like to know.
__________________
"The Corps is Mother, the Corps is Father"

The Babylon Project: A Babylon 5 Mod for Civ IV BtS
PsiCorps is offline   Reply With Quote
Reply

Bookmarks

Tags
final frontier, map script

Go Back Civilization Fanatics' Forums > CIVILIZATION IV > Civ4 - Creation & Customization > Civ4 - Map Scripts > [Map Script] SpiralGalaxy.py for Final Frontier

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
[Map Script] PerfectWorld.py cephalo Civ4 - Map Scripts 635 Dec 08, 2013 10:27 AM
[Map Script] PerfectWorld2.py cephalo Civ4 - Map Scripts 754 Jul 20, 2013 11:53 PM
[Map script]Creation.py for FFH2 cephalo FfH2 Modmods, Scenarios, and Maps 421 Jul 16, 2010 06:56 AM
[Map Script] NewWorld.py SevenSpirits Civ4 - Map Scripts 12 Jan 25, 2009 09:40 AM
[Map Script]SpiralGalaxy.py for Final Frontier cephalo Civ4 BTS - Official Mods & Scenarios 0 Feb 12, 2008 06:16 PM


Advertisement

All times are GMT -6. The time now is 02:43 PM.


Powered by vBulletin®
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
This site is copyright Civilization Fanatics' Center.
Support CFC: Amazon.com | Amazon UK | Amazon DE | Amazon CA | Amazon FR