Forcing Peace

Jarlaxe Baenre

Emperor
Joined
Feb 17, 2010
Messages
1,959
Location
Calgary, Alberta, Canada
I'm stumped on how to finish this. What, instead of iPlayer, iBarbarians goes in makePeace?

PHP:
		iBarbTrait = gc.getInfoTypeForString('TRAIT_BARBARIC')
		pPlayer = gc.getPlayer(iPlayer)
		iBarbarians = gc.getInfoTypeForSTring('CIVILIZATION_BARBARIAN')
		

		if (pPlayer.hasTrait(iBarbTrait)):

			makePeace (iPlayer, iBarbarians)
 
The makePeace() method belongs to the CyTeam class. This means that you need an instance of this class to invoke it on. Also, it takes one single parameter - which is a TeamType value.
Code:
VOID makePeace (TeamType eTeam)
iPlayer and iBarbarians are integer values corresponding to the PlayerTypes and useless for this.

What you need then, is this:
PHP:
iTeam = pPlayer.getTeam() # get TeamType from CyPlayer instance
pTeam = gc.getTeam(eTeam) # get CyTeam instance from TeamType
pBarbarianPlayer = gc.getPlayer(iBarbarian) # get CyPlayer instance from PlayerType
iBarbarianTeam = pBarbarianPlayer.getTeam() # get TeamType from CyPlayer instance
pTeam.makePeace(iBarbarianTeam) # invoke the method on the CyTeam instance
You need to be able to read the API in order to use it. Just guessing will get you nowhere. And its not like its hard to learn how to do it either.
 
I have 2 (hopefully helpful) comments:
1. You have getInfoTypeForSTring (with a capital 'T') instead of getInfoTypeForString
2. Are you sure that 'barbarian' is also a trait of a player? Traits are 'financial', 'aggressive' etc.
 
You can find out if a player is barbarian by using pPlayer.isBarbarian().

Mind that it is used on an actual PyPlayer object, not an integer like iPlayer (as Baldyr already said).
 
Also, I'm not entirely sure what forced peace with the Barbarians will do... :eek2: It simply might not work, or worse.

Asaf: I believe its one of those XML tricks to use unique traits as identifiers. Never tried it myself though. It shouldn't be necessary when scripting Python in any case. :p
 
As a sidenote, this is what a "helper function" that is used as in the OP would look like:
Code:
def makePeace(ePlayer1, ePlayer2):
	gc.getTeam(gc.getPlayer(ePlayer1).getTeam()).makePeace(gc.getPlayer(ePlayer2).getTeam())
In other words; makePeace(iPlayer, iBarbarians) would work with this function definition present in the module where it is called.
 
Also, I'm not entirely sure what forced peace with the Barbarians will do... :eek2: It simply might not work, or worse.

You should play some more mods ;).
It works in the barbarian alliance mod, and it works in FfH2 as trait, so there's no reason why it should not work ;).
 
The_J, while you're right about me not playing enough mods (I haven't played any game in some 16 months by now) I was thinking specially about what the makePeace() Python method does - and doesn't do - in regard to Barbarians.

I'm sure just about anything is possible with C++ modding though.
 
This is what I'm interpreting The_J's answer as... But there is a way to find out, after all... ;)
 
Top Bottom