Platy's Peculiar Pleasant Posh Python

Me again!

So on continues my quest of many headaches, but I am currnetly getting this error message from a bit of code that the J made for me once upon a time to display the 'ranged combat strength' of my units (as range combat is a big part of the mod).

Any idea why this wouldn't be happy in your code?

The file is CvMainInterface

name error

name 'pHeadSelectedUnit' is not defined

Spoiler :
Code:
###combat-aircombat - start
	szLeftBuffer = u""
	szRightBuffer = u""
	[COLOR="Red"]if (pHeadSelectedUnit.getDomainType() != DomainTypes.DOMAIN_AIR) and (pHeadSelectedUnit.airBaseCombatStr()>0):[/COLOR]
		if (pHeadSelectedUnit.canFight()):
			szLeftBuffer = localText.getText("INTERFACE_PANE_RANGED_STRENGTH", ())
			if (pHeadSelectedUnit.isFighting()):
				szRightBuffer = u"?/%d%c" %(pHeadSelectedUnit.airBaseCombatStr(), CyGame().getSymbolID(FontSymbols.STRENGTH_CHAR))
			elif (pHeadSelectedUnit.isHurt()):					
										szRightBuffer = u"%.1f/%d%c" %(((float(pHeadSelectedUnit.airBaseCombatStr() * pHeadSelectedUnit.currHitPoints())) / (float(pHeadSelectedUnit.maxHitPoints()))), pHeadSelectedUnit.airBaseCombatStr(), CyGame().getSymbolID(FontSymbols.STRENGTH_CHAR))                                                               
			else:
				szRightBuffer = u"%d%c" %(pHeadSelectedUnit.airBaseCombatStr(), CyGame().getSymbolID(FontSymbols.STRENGTH_CHAR))

	szBuffer = szLeftBuffer + szRightBuffer
	if ( szBuffer ) and (pHeadSelectedUnit.getDomainType() != DomainTypes.DOMAIN_AIR) and (pHeadSelectedUnit.airBaseCombatStr()>0):
		screen.appendTableRow( "SelectedUnitText" )
		screen.setTableText( "SelectedUnitText", 0, iRow, szLeftBuffer, "", WidgetTypes.WIDGET_HELP_SELECTED, -1, -1, CvUtil.FONT_LEFT_JUSTIFY )
		screen.setTableText( "SelectedUnitText", 1, iRow, szRightBuffer, "", WidgetTypes.WIDGET_HELP_SELECTED, -1, -1, CvUtil.FONT_RIGHT_JUSTIFY )
		screen.show( "SelectedUnitText" )
		screen.show( "SelectedUnitPanel" )		
		iRow += 1						
###combat-aircombat - end
 
How am I supposed to know where you paste the code... Obviously it is not defined in that chunk you posted :D
 
Updates:

Air Strength and Strength both display if relevant for unit panel.
If both are displayed, range info will not be displayed.

Advisors Unit Combat Feats rewrote to allow smooth in game python testing.
 
Ultrapack Advisors

Feats:
Simplified codes further

Advisors Pop Ups:
Relevant item lists stored as global upon loading
Example:
If city is unhappy and needs a happy building, it will only loop through all buildings with happiness and find a best one, rather than loop through all buildings.

Similarly, if city needs to expand, it will just loop through units which can settle, rather than all units. Effectively, in BTS, list of units which can settle == just one item.
 
Very neat solution :)
 
Nothing much actually, since nobody activates advisor pop ups anyway.
Irritating advisors...
 
Well, first you create new ones via XML, which should be obvious.

Then I make the option screen display them, since new graphic options are out of GraphicOptionTypes.NUM_GRAPHICOPTION_TYPES which is hard coded. CvOptionsScreen

Lastly, I added simple codes to set them to default XML value each time the mod is loaded, because they are set to random values, since they are out of GraphicOptionTypes.NUM_GRAPHICOPTION_TYPES, which is pretty idiotic, so if you change any Platy options in the option screen, they will only last for the session until you exit the mod.
 
Well, first you create new ones via XML, which should be obvious.

Then I make the option screen display them, since new graphic options are out of GraphicOptionTypes.NUM_GRAPHICOPTION_TYPES which is hard coded. CvOptionsScreen

Lastly, I added simple codes to set them to default XML value each time the mod is loaded, because they are set to random values, since they are out of GraphicOptionTypes.NUM_GRAPHICOPTION_TYPES, which is pretty idiotic, so if you change any Platy options in the option screen, they will only last for the session until you exit the mod.

I can recreate the XML entries. I can also use C++ to add the new graphic option ( I did that for the GG bar following your example). What I really meant was how did you get the checkboxs to display on the platy tab as opposed to the graphic options tab?
 
Because the option screen will only display up to GraphicOptionTypes.NUM_GRAPHICOPTION_TYPES in the standard Graphic tab.

So I simply define a new Platy tab, and display the new options in that tab instead. The codes are all commented in that file, which is actually quite small.

Thus, if you edit the dll to define new graphic options, thus changing GraphicOptionTypes.NUM_GRAPHICOPTION_TYPES, then automatically, these new ones will be included in standard Graphic tab.

Notes:
Standard Graphic tab
for iOptionLoop in xrange(GraphicOptionTypes.NUM_GRAPHICOPTION_TYPES):

Platy tab
for iOptionLoop in xrange(GraphicOptionTypes.NUM_GRAPHICOPTION_TYPES, GraphicOptionTypes.NUM_GRAPHICOPTION_TYPES + 4):

Thus, new graphic options which are out of the range of GraphicOptionTypes.NUM_GRAPHICOPTION_TYPES, goes to Platy tab
 
Ultrapack

Making advisors more useful...

When Advisors are activated, Tech screen will inform which tech is scientific, cultural etc. This does make the text abit too long and may clash into the prereq techs, if the box is not long enough.



Domestic Advisors are given a new hint section, which functions more in depth than the naggy advisor pop ups.
It will advise you which building is the best to build based on the city's condition.
Of course, some of the calculations involved are estimates, especially for trade, since some values are not exposed to python.
 
Ultrapack Tech Screen



1) Added a Progress Bar and Remove the (Turns Left) Text, to make it shorter...

2) Advisor icons now permanent.

3) Fixed a bug where progress/turns left does not get updated unless you clicked something.
For instance, if turns left for current research is 6, and you exit the screen.
3 turns later, reopening the tech advisor will still display as 6 turns left.
(BTS Bug)
 
How hard would it be to make a tech tree that only displays researchable techs?
 
How hard would it be to make a tech tree that only displays researchable techs?

This techtree already has that option, I believe.

@Platy I was thinking about something, but I don't know python and wanted to know how hard it would be to code. Right now the Great General Bard does nothing when you click on it (My version/BUG). What if when you clicked on it you cycle through any available Great Generals on screen. I always seem to lose track of them. Has it already been done?
 
Press Ctrl F2 to check where your gg led units are.
As for free gg, just check where they are via military advisor?

Edit:
Removed Great People Movie test codes
 
Top Bottom