Fimbulvetr
Emperor
damn it, nvm
forgot a :
forgot a :
def AddBonusType(self,eBonus,plotIndexList):
gc = CyGlobalContext()
gameMap = CyMap()
featureForest = gc.getInfoTypeForString("FEATURE_FOREST")
#first get bonus/area link
for i in range(gc.getNumBonusInfos()):
if self.bonusList[i].eBonus == eBonus:
bonus = self.bonusList[i]
bonusInfo = gc.getBonusInfo(eBonus)
print "AddBonusType for %(bt)s, cbc=%(cb)d dbc=%(db)d" % {"bt":bonusInfo.getType(), \
"cb":bonus.currentBonusCount,"db":bonus.desiredBonusCount}
if bonus.currentBonusCount >= bonus.desiredBonusCount:
print "AddBonusType retfalse1 currentBonusCount=%(cb)d, desiredBonusCount=%(db)d" % {"cb":bonus.currentBonusCount,"db":bonus.desiredBonusCount}
return False
bonusPlaced = False
#now add bonuses
for i in range(len(plotIndexList)):
index = plotIndexList[i]
plot = gameMap.plotByIndex(index)
x = plot.getX()
y = plot.getY()
if self.CanPlaceBonusAt(plot,eBonus,False,False):
print "AddBonusType:CanPlaceBonusAt for %(bt)s" % {"bt":bonusInfo.getType()}
#temporarily remove any feature
featureEnum = plot.getFeatureType()
if featureEnum == featureForest:
featureVariety = plot.getFeatureVariety()
plot.setFeatureType(FeatureTypes.NO_FEATURE,-1)
#place bonus
plot.setBonusType(eBonus)
bonusPlaced = True
bonus.currentBonusCount += 1
#restore the feature if possible
if featureEnum == featureForest:
if bonusInfo == None or bonusInfo.isFeature(featureEnum) or (bonusInfo.getTechReveal() != TechTypes.NO_TECH):
plot.setFeatureType(featureEnum,featureVariety)
groupRange = bonusInfo.getGroupRange()
#NEW CODE
#added/maxAdd: avoid grouping ALL the resources of a type together.
#it's annoying to find 6 wines together and nowhere else on the map.
added = 0
maxAdd = PRand.randint(0,2);
print "AddBonusType maxadd for %(bt)s = %(ma)d" % {"bt":bonusInfo.getType(),"ma":maxAdd}
for dx in range(-groupRange,groupRange + 1):
for dy in range(-groupRange,groupRange + 1):
#NEW CODE
if(added >= maxAdd):
break
if bonus.currentBonusCount < bonus.desiredBonusCount:
loopPlot = self.plotXY(x,y,dx,dy)
if loopPlot != None:
if loopPlot.getX() == -1:
raise ValueError, "plotXY returns invalid plots plot= %(x)d, %(y)d" % {"x":x,"y":y}
if self.CanPlaceBonusAt(loopPlot,eBonus,False,False):
if PRand.randint(0,99) < bonusInfo.getGroupRand():
#NEW CODE
added += 1
#temporarily remove any feature
featureEnum = loopPlot.getFeatureType()
if featureEnum == featureForest:
featureVariety = loopPlot.getFeatureVariety()
loopPlot.setFeatureType(FeatureTypes.NO_FEATURE,-1)
#place bonus
loopPlot.setBonusType(eBonus)
bonus.currentBonusCount += 1
#restore the feature if possible
if featureEnum == featureForest:
if bonusInfo == None or bonusInfo.isFeature(featureEnum) or (bonusInfo.getTechReveal() != TechTypes.NO_TECH):
loopPlot.setFeatureType(featureEnum,featureVariety)
if bonusPlaced:
break
return bonusPlaced
Actually the indentation is all there, you just need you wrap code tags around it if you want them to display on the forum.
Anyway, thx for that, the insane clustering sometimes annoyed me too sometimes.
But you are limiting placement by a random number from 0 to 2? I think 1-3 resources per cluster should be allowed, and what's the point of placing 0 resources anyway? (Or did I read something wrong there..)
Fact remains that resources simply don't cluster on stock maps the way they do on yours, all resources in a single area just doesn't happen. And we all know AIs underpreform everywhere that doesn't behave like standard, and of course human warmongers don't like it either.
But you have a point, maybe increasing maxAdd to PRand.randint(1,(maxplayers+1)/2) is better, allowing clustering but not single-clusters for all resources of one type.
I would say that trying to make a map script for all Civ-players is kindof like writing a song for all music-lovers. It's not likely to be succesful. Ulitmately, I think it's best for me to be true to my own sensibilities and make a map in the way that I think is ideal.
I think that I will probably have at least one more version before Civ5 comes out, and I think it deserves to have a revamp of the comments portion. This map has gone through a great deal of evolution, and a few of the comments are just plain outdated. It get's more complicated when there are two or more variables that interact with each other. For example I think there are two variables that together control the amount of trees. Sometimes things end up alot more complicated than I intended.
I agree with you that the comments are a mess right now, and I would hate to leave the last version in such a state.
Just wanted to chime in and say this is my favorite mapscript. I don't mind the resource clusters, and I also agree that it seems more natural that way and encourages resource trading (something I rarely do on most maps because I usually already have one of everything).
The only thing that sometimes bothers me is the propensity for most continents to have a large desert area in the center. I like the tactical and strategic impact it has on the game, but I wouldn't mind seeing it occasionally replaced with a massive plains area (ala the Great Plains in the US) or vast jungle (ala the Amazon). These would still have a similar impact on strategy, but it would also add a little more variety to the maps generated.
Just wanted to chime in and say this is my favorite mapscript.
I would say that trying to make a map script for all Civ-players is kindof like writing a song for all music-lovers. It's not likely to be succesful. Ulitmately, I think it's best for me to be true to my own sensibilities and make a map in the way that I think is ideal.
I think that I will probably have at least one more version before Civ5 comes out, and I think it deserves to have a revamp of the comments portion. This map has gone through a great deal of evolution, and a few of the comments are just plain outdated. It get's more complicated when there are two or more variables that interact with each other. For example I think there are two variables that together control the amount of trees. Sometimes things end up alot more complicated than I intended.
I agree with you that the comments are a mess right now, and I would hate to leave the last version in such a state.