Mod-Modders Guide to Fall Further

You are both a gentleman and a scholar -thank you for the responses.
 
Since I added this to the code i posted on the last page:

Code:
								if pPlot().getPlotCounter() > 9:
									iHell = iHell +1

I keep getting this in PythonErr.log:

Code:
TypeError: 'CyPlot' object is not callable
ERR: Python function AI_chooseTech failed, module CvGameInterface
Traceback (most recent call last):

  File "CvGameInterface", line 179, in AI_chooseTech

  [B]File "CvGameUtils", line 1412, in AI_chooseTech[/B]

The line in bold just so happens to be the line about the plot counter, any ideas?
 
2) Is there a promotion field to give units access to weapon tiers (bronze/mithril/iron?)

The Blacksmith trait from Fall Further Plus gives most units a promotion that enables them to get Bronze, Iron and Mithril weapons.
 
There is something wrong with the line in bold, and possibly the one above it. This code is supposed to check the civs the AI are at war with, and react accordingly.

Code:
		#Assess the enemy
		if eTeam.getAtWarCount(True) >= 1:
			if eTeam.isHasTech(gc.getInfoTypeForString('TECH_ARCHERY')) == False or eTeam.isHasTech(gc.getInfoTypeForString('TECH_BRONZE_WORKING')) == False:
				iGetMilitary = 0
				for iTeam2 in range(gc.getMAX_PLAYERS()):
					eTeam2 = gc.getTeam(iTeam2)
					iTeam = (pPlayer.getTeam())
[B]					if eTeam2.isAtWar(gc.getTeam(iTeam)):[/B]
						if eTeam2.isHasTech(gc.getInfoTypeForString('TECH_BRONZE_WORKING')):
							iGetMilitary = iGetMilitary +1
						if eTeam2.isHasTech(gc.getInfoTypeForString('TECH_ARCHERY')):	
							iGetMilitary = iGetMilitary +1
						if eTeam2.isHasTech(gc.getInfoTypeForString('TECH_CONSTRUCTION')):	
							iGetMilitary = iGetMilitary +1
						if eTeam2.isHasTech(gc.getInfoTypeForString('TECH_WARFARE')):	
							iGetMilitary = iGetMilitary +1
						if eTeam2.hasBonus(gc.getInfoTypeForString('BONUS_COPPER')):
							iGetMilitary = iGetMilitary +1
				if iGetMilitary > 1: 
					print ("Enemy are superior, be defensive!") 
					iTech = gc.getInfoTypeForString('TECH_ARCHERY')
					if eTeam.isHasTech(iTech) == True:
						if pPlayer.getCivilizationType() != gc.getInfoTypeForString('CIVILIZATION_SVARTALFAR'):
							if pPlayer.getCivilizationType() != gc.getInfoTypeForString('CIVILIZATION_LJOSALFAR'):
								iTech = gc.getInfoTypeForString('TECH_CONSTRUCTION')
								if eTeam.isHasTech(iTech) == True:
 
Why don't you use:
Code:
if eTeam2.isAtWar(eTeam):
Since I get it that eTeam refers to pPlayer team.

If not, what is the actual error?
 
Coding at 3am = bad code! Can you tell im a noob yet? :lol:

Thanks again.

Edit: Still getting an error in PythonErr.log
Code:
ArgumentError: Python argument types in
    CyTeam.isAtWar(CyTeam, CyTeam)
did not match C++ signature:
    isAtWar(class CyTeam {lvalue}, int)
 
Some of my best ideas have happened coding past midnight.
I have also made Civ crash the most coding past midnight >_>
 
Coding at 3am = bad code! Can you tell im a noob yet? :lol:

Thanks again.

Edit: Still getting an error in PythonErr.log
Code:
ArgumentError: Python argument types in
    CyTeam.isAtWar(CyTeam, CyTeam)
did not match C++ signature:
    isAtWar(class CyTeam {lvalue}, int)

make a find of isAtWar in the whole python directories to find an exemple (it seems you need an int as second parameter)
 
Seems more that you put two parameters instead of just one. According to the DLL, you just need to put a TeamTypes as parameter.
 
Here is my code:

Code:
					if eTeam.isAtWar(eTeam2):

Here is another example of a similar check elsewhere:

Code:
		if eTeam.isAtWar(iSvartalfarTeam):

I might just try constructing it in a different manner.
 
Try with just "iTeam". With no "gc.getTeam()"; seems you just need the integer, not the TeamTypes.
 
There anyway to effecively remove all of a stackeffect promotion via python? I've got something that APPEARS to work, only showing the correct number on the unit each turn even if I add/subtract some mana, which it is dependent on... However, the actual EFFECTS of the promotions don't appear to be removed.

I suppose I could make a new unit, copying level/xp/name/all promotions aside from the stack effect..... But that is VERY clunky.
 
Got it it working, although I'd prefer a cleaner method... Ended up going the 'new unit' route, which is a pain if you had an item on the unit. Have to pick it up again each turn.

Is there anyway to do just a standard loop in python? As in, continue running a codeblock until certain reqs are met?

What I'd like is essentially:

Code:
loop
if unit has promotion:
    remove promotion
    if unit does NOT have promotion:
          End
    Return

Hoping thus is possible? Only loops I've seen either loop through a file (units, promotions, etc) or loop over the map.
 
how about
Code:
while unit.hasPromotion()
    promotion.remove()

I haven't done much modding, but I've coded in python before, and this should work - apart from the obvious pseudocode :)
 
Python has two kinds of loop, for and while.

while loops work pretty much like while loops in, for instance, c. The equivalent of python for loops are usually called "for each" in other languages.

You may also be interested in the other control structures for loops:

Spoiler :
4.4 break and continue Statements, and else Clauses on Loops

The break statement, like in C, breaks out of the smallest enclosing for or while loop.

The continue statement, also borrowed from C, continues with the next iteration of the loop.

Loop statements may have an else clause; it is executed when the loop terminates through exhaustion of the list (with for) or when the condition becomes false (with while), but not when the loop is terminated by a break statement. This is exemplified by the following loop, which searches for prime numbers:

Code:
>>> for n in range(2, 10):
...     for x in range(2, n):
...         if n % x == 0:
...             print n, 'equals', x, '*', n/x
...             break
...     else:
...         # loop fell through without finding a factor
...         print n, 'is a prime number'
... 
2 is a prime number
3 is a prime number
4 equals 2 * 2
5 is a prime number
6 equals 2 * 3
7 is a prime number
8 equals 2 * 4
9 equals 3 * 3
 
Python has two kinds of loop, for and while.

while loops work pretty much like while loops in, for instance, c. The equivalent of python for loops are usually called "for each" in other languages.

You may also be interested in the other control structures for loops:

Spoiler :
4.4 break and continue Statements, and else Clauses on Loops

The break statement, like in C, breaks out of the smallest enclosing for or while loop.

The continue statement, also borrowed from C, continues with the next iteration of the loop.

Loop statements may have an else clause; it is executed when the loop terminates through exhaustion of the list (with for) or when the condition becomes false (with while), but not when the loop is terminated by a break statement. This is exemplified by the following loop, which searches for prime numbers:

Code:
>>> for n in range(2, 10):
...     for x in range(2, n):
...         if n % x == 0:
...             print n, 'equals', x, '*', n/x
...             break
...     else:
...         # loop fell through without finding a factor
...         print n, 'is a prime number'
... 
2 is a prime number
3 is a prime number
4 equals 2 * 2
5 is a prime number
6 equals 2 * 3
7 is a prime number
8 equals 2 * 4
9 equals 3 * 3

I KNEW there had to be a loop other than the for loop; Was looking all last night for one. :lol:

Code:
for i in range(pUnit.countHasPromotion(iProm)):
    pUnit.setHasPromotion(iProm, false)

And I knew there'd be a simple way. Thanks!

That strips all of the stacked promotions from a unit
 
Back
Top Bottom