Changing AI attitude

gautam

Chieftain
Joined
Dec 13, 2005
Messages
24
Hi,

I am trying to change the AI's attitude towards the player in python but it seems like whatever I try it jsut doesn't work. I have the following code but it never gets into the if loop

Code:
	def changeAIAttitude(self, iPlayer):
		
		# change the AI attitude towards the active player
		player = gc.getPlayer(iPlayer)

		if(player.isHuman() == False):
			player = gc.getPlayer(iPlayer)
			

			# get the attitude of the AI to player
			attitude = player.AI_getAttitude(gc.getPlayer(0).getID())
			print "Change AI Attitude called"
			

                                       [b]# Never gets in here[/b]
			# whatever the attitude - do something
			if(attitude != AttitudeTypes.ATTITUDE_FURIOUS):
				iAttitude = player.AI_getAttitudeExtra(gc.getPlayer(0).getID())
				print "Attitude"
				print attitude
				
				player.AI_changeAttitudeExtra(gc.getPlayer(0).getID(), 100)
				print "Attitude"
				print player.AI_getAttitudeExtra(gc.getPlayer(0).getID())

		return

It never seems to go into the inner if loop. Also is there a function called AI_changeAttitude by any chance ? I didn't find it on
http://civilization4.net/files/modding/PythonAPI/

Are there any other ways to modify the AI attitude in runtime.

Thanks
 
If anything it should be setAttitude....
 
Hi,

I searched the PyHelpers.py file and also the site http://civilization4.net/files/modding/PythonAPI/. The only attitude options are with get functions and the AI_changeAttitudeExtra(PlayerType eIndex, INT iChange) function. Nothing at all with set. Thats why I was wondering if there is a way to force a change of the AI attitude.

Thanks
 
This isn't what is causing your problem but you have "player = gc.getPlayer(iPlayer)" twice.


Weird that it doesn't get further than the if. You're comparing an int (attitude) to a string (AttitudeTypes.ATTITUDE_FURIOUS which is the same as "ATTITUDE_FURIOUS") so they should never be the same, thus always returning true because of the !.

What happends if you put a print between the if statement and where you give a value to iAttitude? Does it get printed?
 
I tried getInfoTypeFromString("ATTITUDE_FURIOUS") as well and it gave an error of some CyGlobalContext and ATTIDUE_FURIOUS not found or something.

But I will try what you asked and post soon.

Thanks
 
Back
Top Bottom