Mod-Modders Guide to Fall Further

Hi All --

In other threads the idea that too many Great Commanders/Tacticians/etc. can spawn if a civ is having a lot of armed conflict with another Civ. Some mentioned getting 6 or 7 or more.

I am interested in re-enabling the "Great Military Instructor" Great Person type, and have been able to do so. However, I would like to make this option available only for a Great Commander of Level 6 or greater. I didn't see anything obvious in the XML for the Sidar; can this "Min Level" option be done through the Unit XML or is it hard-coded specifically for the Sidar into the DLL?

Thanks!
 
Hi all,

I'm looking at a way to make the "tech chooser screen" appear on demand even when there are no beakers generated and no techs are actually selected, but I cannot seem to find the way...

Any help here? : )
 
If your current python file doesn't already do it, then first:
Code:
import CvScreensInterface

Then wherever you want to show the screen:

Code:
CvScreensInterface.showTechChooser()
 
If your current python file doesn't already do it, then first:
Code:
import CvScreensInterface

Then wherever you want to show the screen:

Code:
CvScreensInterface.showTechChooser()

Thanks, th'a almost it !
I would like the screen before this one, when we have advise on which tech to choose :)
 
You mean you want a POPUP, not a SCREEN. Crucial difference in the two.

Not actually certain how to go about calling that popup from python without expressely exposing it from the DLL. Closest I can see that is available would be

pPlayer.chooseTech(0, "", false)

Seems like that might be utilized normally to launch the screen. I am accustomed to using it to grant free techs by having a non-zero first value. You can state the reason for opening the window in the "" area if you desire to have a message displayed.
 
Thank you.
actually what is blocking me is a restriction saying this pop-up cannot open is no cities have ever be founded (which is the case in the new Tears version)
 
do you know an easy python+XML-only way of creating global variable to stock data for display which would be calculated only once a turn throught python ?
 
do you know an easy python+XML-only way of creating global variable to stock data for display which would be calculated only once a turn throught python ?

Globals are quite easy to add in python only; Simply define the variable to whatever start value you need at the top of the file (Global x = y, Global is necessary here). In any function where you just CALL the value, you can just refer to it as x. In a function where you want to ALTER the value, however, you must explicitly define it as a global... Meaning you need to list "Global x" in the function, BEFORE you use it.

The only real issue is that the global is NOT saved. In order to get it to save, you must use a bit of DLL in CvPlayer(.cpp and .h). I did this myself, for the Grigori... If you are confident enough with the DLL to clone work and compile, download my files and look up the tag 'Adventurer Spawn' to see how to track the variable, and then check my CustomFunctions.py for the Grigori Adventurer spawn setup to see how to call/alter it. ;)
 
Meaning you need to list "Global x" in the function, BEFORE you use it.

It needs to be "global x", lowercase.

If all you want to do is something like caching a value for the turn:

anymodule.py:
Code:
cachedValue = None

def getCachedValue():
  global cachedValue
  if cachedValue is None:
    cachedValue = doReallyExpensiveCalculation()
  return cachedValue

def clearCachedValue():
  global cachedValue
  cachedValue = None

And clear cachedValue once each turn and when the game is loaded.

That way the doReallyExpensiveCalculation call is only done once per turn or load.

If you need to save the value over game loads you could use the various script data functions. Or, I think, the string returned by the onSaveGame event is given to the onLoadGame event as an argument.

edit:
If you need to access the value as you would any other value, it is possible but a little more involved.
 
I used the following actually, but I don't know the difference :)
Would it by any chance be saved ? :)

Code:
	def setTearsConstants(self):
		absorbed = 0
		for i in range (CyMap().numPlots()):
			pPlot = CyMap().plotByIndex(i)
			if pPlot.getTerrainType() == gc.getInfoTypeForString('TERRAIN_RAW'):
				absorbed = absorbed + 1
			
		percent = round (absorbed * 100.0 / CyMap().numPlots(),3)
		SdToolKitAdvanced.sdSetGlobal("TEAR","ABSORBTION",percent)

	def getAbsorbtionPercent(self):
		percent = SdToolKitAdvanced.sdGetGlobal("TEAR","ABSORBTION")
		if percent < 0:
			percent = 0
		return percent
 
Also, would you know hw I could add a new text info under the awakened percent chance one ? (called SRText)

(happy with the new Tear implementation, but I should add ingame infos to mesure the civ working mecanics)
 
I used the following actually, but I don't know the difference :)
Would it by any chance be saved ? :)

Code:
        def setTearsConstants(self):
        absorbed = 0
        for i in range (CyMap().numPlots()):
            pPlot = CyMap().plotByIndex(i)
            if pPlot.getTerrainType() == gc.getInfoTypeForString('TERRAIN_RAW'):
                absorbed = absorbed + 1
            
        percent = round (absorbed * 100.0 / CyMap().numPlots(),3)
        SdToolKitAdvanced.sdSetGlobal("TEAR","ABSORBTION",percent)

    def getAbsorbtionPercent(self):
        percent = SdToolKitAdvanced.sdGetGlobal("TEAR","ABSORBTION")
        if percent < 0:
            percent = 0
        return percent

I don't believe so, but I'll let Odalrick answer. He knows more python than I do. :p

Also, would you know hw I could add a new text info under the awakened percent chance one ? (called SRText)

(happy with the new Tear implementation, but I should add ingame infos to mesure the civ working mecanics)

Just add an Else statement to the Civilization type check.

Simpler to just show you what I mean, I think.... Here's what I used to get Scions/Grigori working.

Code:
[B]if pPlayer.getCivilizationType() == gc.getInfoTypeForString('CIVILIZATION_SCIONS') and pPlayer.getNumCities() > 0:
[/B]            
 #figuring spawn chance

    fSpawnOdds = cf.doChanceAwakenedSpawn(-1)
    fFirstPart = fSpawnOdds / 100
     fSecondPart = fSpawnOdds - (fFirstPart * 100)
#/figuring spawn chance
    if fFirstPart + fSecondPart > 0:

        SRstr = u"<font=2i>%s</font>" %(str(" ") + str(fFirstPart) + str(".") + str(fSecondPart) + str("% "))
        screen.setImageButton("Awakenedchance", "Art/Interface/Buttons/Units/Scions/awake.dds", 84, 106, 16, 16, WidgetTypes.WIDGET_GENERAL, -1, -1 )
        screen.setText( "SRText", "Background", SRstr, CvUtil.FONT_LEFT_JUSTIFY, 103, 104, 0.5, FontTypes.GAME_FONT, WidgetTypes.WIDGET_GENERAL, -1, -1 )
        screen.setHitTest( "SRText", HitTestTypes.HITTEST_NOHIT )
    else:
        screen.hide( "Awakenedchance" )
        screen.hide( "SRText" )
#/Awakened display
#Adventurer display
[B]elif pPlayer.getCivilizationType() == gc.getInfoTypeForString('CIVILIZATION_GRIGORI') and pPlayer.getNumCities() > 0:
[/B]            
 #figuring spawn chance

    fGrigoriSpawn = (pPlayer.getGrigoriSpawn() / 100)
    fGrigoriActual = pPlayer.getGrigoriSpawn()
    fGrigoriMod = (pPlayer.getGrigoriMod() / 100)
                
    fSecondPart = fGrigoriActual - (fGrigoriSpawn * 100)
#/figuring spawn chance
    if fGrigoriSpawn > 0:

        SRstr = u"<font=2i>%s</font>" %(str(" ") + str(fGrigoriSpawn) + str(".") + str(fSecondPart) + str(" / ") + str(fGrigoriMod) + str(" "))
        screen.setImageButton("Adventurerchance", "Art/Interface/Buttons/Units/Adventurer.dds", 167, 7, 16, 16, WidgetTypes.WIDGET_GENERAL, -1, -1 )
        screen.setText( "SRText", "Background", SRstr, CvUtil.FONT_LEFT_JUSTIFY, 179, 5, 0.5, FontTypes.GAME_FONT, WidgetTypes.WIDGET_GENERAL, -1, -1 )
                    screen.setHitTest( "SRText", HitTestTypes.HITTEST_NOHIT )
    else:
        screen.hide( "Adventurerchance" )
        screen.hide( "SRText" )
#/Adventurer display
The bold lines are the starting point for each display. If you compare the 'Screen.set...' lines, the difference in values shifts the display from beside the mana bar, to beside the gold display.

The 'firstpart/secondpart' stuff is needed for an accurate decimal display... If you don't want a decimal, you can drop it easily.
 
I used the following actually, but I don't know the difference :)
Would it by any chance be saved ? :)

The SdToolKitAdvanced puts an extra layer around script data, so that it easier to use. Kael doesn't like it because it's "slow", but a single value shouldn't make much difference. And I'm not convinced it is noticeably slow anyway.

Yep, it is saved.
 
Have an issue with the <fFreeXPCap> and <iFreeXPPerTurn> tags that I'm not sure how to fix....

Basically, BOTH tags are additive, while only the second should be.

A warrior with Hero and a dummy promo which gives 3 XP per turn till 20 will gain 4 XP per turn till 120.... It SHOULD be gaining the 4 xp, 3 of that should stop at 20xp, with the remaining 1 going on to 1xp. Is there anyway I can maintain the caps seperately? The only way I can think of involves use of a system that's not even coded yet... Sure you can figure out what that is, as you're the one behind it. :lol:
 
Top Bottom