if (iGameTurn >= ( self.MaxTurns[0] / 4 )) and not (iGameTurn >= self.MaxTurns[0]) and (iGameTurn % (self.MaxTurns[0] / 100) == 0):
if CyGame().getSorenRandNum(100,"BonusSpawn") <= self.iAppearanceBanana:
def onBeginGameTurn(self, argsList):
'Called at the beginning of the end of each turn'
iGameTurn = argsList[0]
CvTopCivs.CvTopCivs().turnChecker(iGameTurn)
# isenchine for keldath: FeatureBonusSpawn Start
iFeature = gc.getInfoTypeForString("FEATURE_JUNGLE")
iBonus = gc.getInfoTypeForString("BONUS_BANANA")
for iPlotLoop in xrange(CyMap().numPlots()):
pPlot = CyMap().plotByIndex(iPlotLoop)
if (pPlot.getFeatureType() == iFeature) and (pPlot.getBonusType(-1) == -1):
pPlot.setBonusType(iBonus)
# isenchine for keldath: FeatureBonusSpawn End
I added bold text to remove the bonus if the feature is gone. It's not ideal and bonus add/remove will not take place until the next turn if a feature is added/removed, but it should get the job done.In your case, it's much more simple, just add this in CvEventManager:
Code:def onBeginGameTurn(self, argsList): 'Called at the beginning of the end of each turn' iGameTurn = argsList[0] CvTopCivs.CvTopCivs().turnChecker(iGameTurn) # isenchine for keldath: FeatureBonusSpawn Start iFeature = gc.getInfoTypeForString("FEATURE_JUNGLE") iBonus = gc.getInfoTypeForString("BONUS_BANANA") for iPlotLoop in xrange(CyMap().numPlots()): pPlot = CyMap().plotByIndex(iPlotLoop) if (pPlot.getFeatureType() == iFeature) and (pPlot.getBonusType(-1) == -1): pPlot.setBonusType(iBonus) [B]elif (pPlot.getFeatureType() != iFeature) and (pPlot.getBonusType(-1) == iBonus): pPlot.setBonusType(iBonus)[/B] # isenchine for keldath: FeatureBonusSpawn End
void CvPlot::setFeatureBonus()
{
if (getFeatureType() == FEATURE_DUMMY && getBonusType() == NO_BONUS)
{
setBonus(BONUS_DUNNY);
}
else if (getFeatureType() != FEATURE_DUMMY && getBonusType() == BONUS_DUNNY)
{
setBonusType(NO_BONUS);
}
}
Err... somehow failure to tell python from C++ worries me if you intend to modify the DLL. But yeah, it's C++ code for the DLL and it should add and remove when the feature on the plot updates.Nightinggale-
the dll code that you wrote?
this code - does the same thing? in the _dummy - i state the feature or bonus i desire and thats it?
just use this part of code? will it also remove the bonus after? and wher in the plot.cpp should i set it?
if (getFeatureType() == GC.getDefineINT("FEATURE_DUMMY") && getBonusType() == NO_BONUS)
def onPlotFeatureRemoved(self, argsList):
'Plot Revealed'
pPlot = argsList[0]
iFeatureType = argsList[1]
pCity = argsList[2] # This can be null
iFeature = gc.getInfoTypeForString("FEATURE_JUNGLE")
iBonus = gc.getInfoTypeForString("BONUS_BANANA")
if (pPlot.getFeatureType() == iFeature) and (pPlot.getBonusType(-1) == iBonus):
pPlot.setBonusType([B]-1[/B])
Yeah, it's the same. I see the python code is using gc.getInfoTypeForString("FEATURE_JUNGLE"). The DLL code can use GC.getInfoTypeForString("FEATURE_JUNGLE"). I'm not 100% sure when each one is correct to use, but my experience tells me that they are often interchangable. Perhaps it would be most correct to only use getInfoTypeForString for this usage.oh also if you fixed the feature to gc.getdfineint,
then :
setBonus(BONUS_DUNNY) should be setBonus("BONUS_DUNNY")?
and - no need for something like - gc.getdfineint for the bonues?
setBonus(GC.getInfoTypeForString("FEATURE_DUMMY"))
// cache variables
static FeatureTypes eFeature = (FeatureTypes)GC.getInfoTypeForString("FEATURE_DUMMY");
static BonusTypes eBonus = (BonusTypes)GC.getInfoTypeForString("BONUS_DUMMY");
if (getFeatureType() == eFeature && getBonusType() == NO_BONUS)
{
setBonus(eBonus);
}
else if (getFeatureType() != eFeature && getBonusType() == eBonus)
{
setBonusType(NO_BONUS);
}
There is a python function onPlotFeatureRemoved which you can use instead of Nightingale's suggested code changes in bold. It will not make any difference to game speed but it would happen when the feature is lost. Something like:-
Code:def onPlotFeatureRemoved(self, argsList): 'Plot Revealed' pPlot = argsList[0] iFeatureType = argsList[1] pCity = argsList[2] # This can be null iFeature = gc.getInfoTypeForString("FEATURE_JUNGLE") iBonus = gc.getInfoTypeForString("BONUS_BANANA") if (pPlot.getFeatureType() == iFeature) and (pPlot.getBonusType(-1) == iBonus): pPlot.setBonusType([B]-1[/B])
Note. is suggested changes were not right as it would add the bonus again not remove it. I think![]()
iFeatureType = argsList[2]
pCity = argsList[1]
I was thinking of the issue of existing bonuses, but didn't think of hidden bonuses. None of the proposed solutions are any goodBoth the dll and python methods will lead to side effects.
Informing the player which jungle has an unrevealed resource, since that jungle will not have the usual resource and is barren.
The problem is that say we add BONUS_FEATURE to all the plots with the feature in question and then if there is BONUS_URANIUM on the plot. You can use the feature bonus, but not uranium, meaning if a plot with the feature produces no resources, you know it has an undiscovered bonus, in this example uranium, though it could be any undiscovered bonus. This is unavoidable if the code design is based on adding the bonus. Well, alternatively it can overwrite the bonuses on the plots, in which case the uranium would be lost. I'm not sure that would be ideal either.As for informing a player, and hidden bonus,
Since ill set thr tech reveal in the feature and the bonus to the same tech, along with trade tech, there wont be an issue with hidden ones.
Hey guys, i see youve been busy,
Im at wirk so ill refer briefly.
As for informing a player, and hidden bonus,
Since ill set thr tech reveal in the feature and the bonus to the same tech, along with trade tech, there wont be an issue with hidden ones.
Ai, ai should refer to the plot normal, aling with the improvement it will be build upon.
Basically, if this getting complicated. The no need,
Just make the feature dissapear right after bonus was created,
Ican combine platyings depletion mod to removevthe bonus upon usege.
So i guess that would be the easiest way, just make that appearnce of a feature, on game generation and growth on a plot transforms intona bonus, that will be perfect also.
What do you think?
One more thing, no need to inform a player on bonus popup, the feature growth allready does it.
And upon map generation, or first turn, all the features are transfirned to the bonus so the ai and player seas it as a regular bonus.