[XML + Python] Bamyan Buddha States

cybrxkhan

Asian Xwedodah
Joined
Aug 10, 2006
Messages
9,687
Location
The Universe

NOTE: THIS MODCOMP DOES NOT WORK PROPERLY AT THE MOMENT, EVEN THOUGH IT DID WORK PREVIOUSLY IN WORLD OF LEGENDS. IF YOU WISH TO DOWNLOAD IT, PLEASE WAIT UNTIL WE CAN SORT THIS OUT. THANK YOU!


The Bamyan Buddha Statues modcomp features the Bamyan Buddha Statues wonder that was originally found in cybrxkhan's World of Legends mod/uxp. It will also be introduced into The Capo's upcoming mod, Diplomacy II. Check them out!

The Bamyan Buddha States increases the amount of missionaries a civ can have at one time from three to five.

To help modders, all relevant coding in the xml and python are marked with "Bamyan Buddha Statues".

If you would like to put this in your mod, feel free to - just remember to give proper credit to everybody!


Credits go to:
- tsentom1 for the original HERC Factory Next War Wonder that the Bamyan Buddha Statues is based on
- The J for taking the code and converting it to work with missionaries (he deserves a lot of credit!)
- The Capo for the wonder nif/model
- Arian for the wondermovie
- Cybrxkhan for putting it all together


Screenshots:









 
Cool, I'm glad that model actually worked. That's the first building I've made. Well the first one that I made and got released that is.
 
Hey I was looking at the code for this wonder, and it seems to me like there are some indentation issues here. Can anyone let me know if that would be an issue.

Code:
	def canTrain(self,argsList):
		pCity = argsList[0]
		eUnit = argsList[1]
		bContinue = argsList[2]
		bTestVisible = argsList[3]
		bIgnoreCost = argsList[4]
		bIgnoreUpgrades = argsList[5]
## BAMYAN BUDDHA STATUES Start ##
                iMissionary = []
                iMissionary.append (CvUtil.findInfoTypeNum(gc.getUnitInfo,gc.getNumUnitInfos(),'UNIT_JEWISH_MISSIONARY'))
		iMissionary.append (CvUtil.findInfoTypeNum(gc.getUnitInfo,gc.getNumUnitInfos(),'UNIT_CHRISTIAN_MISSIONARY'))
		iMissionary.append (CvUtil.findInfoTypeNum(gc.getUnitInfo,gc.getNumUnitInfos(),'UNIT_ISLAMIC_MISSIONARY'))
		iMissionary.append (CvUtil.findInfoTypeNum(gc.getUnitInfo,gc.getNumUnitInfos(),'UNIT_HINDU_MISSIONARY'))
		iMissionary.append (CvUtil.findInfoTypeNum(gc.getUnitInfo,gc.getNumUnitInfos(),'UNIT_BUDDHIST_MISSIONARY')    )
		iMissionary.append (CvUtil.findInfoTypeNum(gc.getUnitInfo,gc.getNumUnitInfos(),'UNIT_CONFUCIAN_MISSIONARY'))
		iMissionary.append (CvUtil.findInfoTypeNum(gc.getUnitInfo,gc.getNumUnitInfos(),'UNIT_TAOIST_MISSIONARY'))
		iMoreMissionariesWonder = CvUtil.findInfoTypeNum(gc.getBuildingInfo,gc.getNumBuildingInfos(),'BUILDING_BAMYAN')
		obsoleteTech = gc.getBuildingInfo(iMoreMissionariesWonder).getObsoleteTech()

		pPlayer = gc.getPlayer(pCity.getOwner())
		NumReligions = 7
		for i in range (NumReligions):
                        if eUnit == iMissionary[i]:
                                if pCity.isHasReligion(i):
                                        pUnit = gc.getUnitInfo (eUnit)
                                        Class = pUnit.getUnitClassType ()
                                        MissionaryCount = pPlayer.getUnitClassCount(Class)
                                        if MissionaryCount <5:
                                                if (gc.getTeam(pPlayer.getTeam()).isHasTech(obsoleteTech) == false or obsoleteTech == -1 ):
                                                        for iCity in range(pPlayer.getNumCities()):
                                                                ppCity = pPlayer.getCity(iCity)
                                                                if ppCity.getNumActiveBuilding(iMoreMissionariesWonder) == true:
                                                                        return True

## BAMYAN BUDDHA STATUES End ##

Doesn't look like it so much there, but here's an image (attached) with some helpful red arrows. :goodjob:
 
I'm not sure what you mean by indentation issues. So far as I know, the Bamyan Buddha Statues seemed to have worked fine, even with the 'indentation issues'... But if they do cause something weird, please do tell me.
 
I added an image.

I guess I'll just go for it, but I don't like putting in incorrect code, it worries me, so I'm worried.
 
That's interesting. The code looks perfectly fine when I open it up using notepad.
 
Alright, this did not work for me. Here is the code I used:

Code:
## Sid Meier's Civilization 4
## Copyright Firaxis Games 2005
##
## Implementaion of miscellaneous game functions

import CvUtil
from CvPythonExtensions import *
import CvEventInterface

# globals
gc = CyGlobalContext()

class DiplomacyGameUtils:
	def canTrain(self,argsList):
		pCity = argsList[0]
		eUnit = argsList[1]
		bContinue = argsList[2]
		bTestVisible = argsList[3]
		bIgnoreCost = argsList[4]
		bIgnoreUpgrades = argsList[5]
## BAMYAN BUDDHA STATUES Start ##
		iMissionary = []
		iMissionary.append (CvUtil.findInfoTypeNum(gc.getUnitInfo,gc.getNumUnitInfos(),'UNIT_JEWISH_MISSIONARY'))
		iMissionary.append (CvUtil.findInfoTypeNum(gc.getUnitInfo,gc.getNumUnitInfos(),'UNIT_CHRISTIAN_MISSIONARY'))
		iMissionary.append (CvUtil.findInfoTypeNum(gc.getUnitInfo,gc.getNumUnitInfos(),'UNIT_ISLAMIC_MISSIONARY'))
		iMissionary.append (CvUtil.findInfoTypeNum(gc.getUnitInfo,gc.getNumUnitInfos(),'UNIT_HINDU_MISSIONARY'))
		iMissionary.append (CvUtil.findInfoTypeNum(gc.getUnitInfo,gc.getNumUnitInfos(),'UNIT_BUDDHIST_MISSIONARY'))
		iMissionary.append (CvUtil.findInfoTypeNum(gc.getUnitInfo,gc.getNumUnitInfos(),'UNIT_CONFUCIAN_MISSIONARY'))
		iMissionary.append (CvUtil.findInfoTypeNum(gc.getUnitInfo,gc.getNumUnitInfos(),'UNIT_TAOIST_MISSIONARY'))
		iMissionary.append (CvUtil.findInfoTypeNum(gc.getUnitInfo,gc.getNumUnitInfos(),'UNIT_OLYMP_MISSIONARY'))
		iMissionary.append (CvUtil.findInfoTypeNum(gc.getUnitInfo,gc.getNumUnitInfos(),'UNIT_ASEN_MISSIONARY'))
		iMissionary.append (CvUtil.findInfoTypeNum(gc.getUnitInfo,gc.getNumUnitInfos(),'UNIT_VOODOO_MISSIONARY'))
		iMissionary.append (CvUtil.findInfoTypeNum(gc.getUnitInfo,gc.getNumUnitInfos(),'UNIT_SHINTO_MISSIONARY'))
		iMissionary.append (CvUtil.findInfoTypeNum(gc.getUnitInfo,gc.getNumUnitInfos(),'UNIT_ZORO_MISSIONARY'))
		iMissionary.append (CvUtil.findInfoTypeNum(gc.getUnitInfo,gc.getNumUnitInfos(),'UNIT_RA_MISSIONARY'))
		iMissionary.append (CvUtil.findInfoTypeNum(gc.getUnitInfo,gc.getNumUnitInfos(),'UNIT_TOLTEC_MISSIONARY'))
		iMissionary.append (CvUtil.findInfoTypeNum(gc.getUnitInfo,gc.getNumUnitInfos(),'UNIT_SHAMAN_MISSIONARY'))
		iMissionary.append (CvUtil.findInfoTypeNum(gc.getUnitInfo,gc.getNumUnitInfos(),'UNIT_LEVANT_MISSIONARY'))
		iMissionary.append (CvUtil.findInfoTypeNum(gc.getUnitInfo,gc.getNumUnitInfos(),'UNIT_DRUID_MISSIONARY'))
		iMissionary.append (CvUtil.findInfoTypeNum(gc.getUnitInfo,gc.getNumUnitInfos(),'UNIT_ANUNNAKI_MISSIONARY'))        
		iMoreMissionariesWonder = CvUtil.findInfoTypeNum(gc.getBuildingInfo,gc.getNumBuildingInfos(),'BUILDING_BAMYAN')
		obsoleteTech = gc.getBuildingInfo(iMoreMissionariesWonder).getObsoleteTech()

		pPlayer = gc.getPlayer(pCity.getOwner())
		NumReligions = 7
		for i in range (NumReligions):
						if eUnit == iMissionary[i]:
								if pCity.isHasReligion(i):
										pUnit = gc.getUnitInfo (eUnit)
										Class = pUnit.getUnitClassType ()
										MissionaryCount = pPlayer.getUnitClassCount(Class)
										if MissionaryCount <5:
												if (gc.getTeam(pPlayer.getTeam()).isHasTech(obsoleteTech) == false or obsoleteTech == -1 ):
														for iCity in range(pPlayer.getNumCities()):
																ppCity = pPlayer.getCity(iCity)
																if ppCity.getNumActiveBuilding(iMoreMissionariesWonder) == true:
																		return True

## BAMYAN BUDDHA STATUES End ##


		return False

And I have attached an image showing it doesn't work (I not only built the wonder, but I built it in the city I am showing this image from).

EDIT: I think I noticed it says NumReligions = 7, I have to change this for all the other religions I made right? But shouldn't it have worked on the first seven religions then? (Judaism is the first in the list and that's the one I tried it with.)
 
Hm, sry of it's a dumb question, but you had the jewish monastery or organized religion there, right?

Oh and this gives me an idea.
This is really a little weak right now. Maybe it would enable the builder to make your missionaries without any requirements?
 
Capo,

Did you put the code into your mod via a CustomGameUtils? or just put the edited one in the python directory.

I only ask, because if using the BUG mod, I dont believe that edited CvGameUtils.py files load or work, a CustomGameUtils.py file (or whatever you want to name it), has to be created, and loaded through BUGs modular python loading system.
 
Hm, sry of it's a dumb question, but you had the jewish monastery or organized religion there, right?

Oh and this gives me an idea.
This is really a little weak right now. Maybe it would enable the builder to make your missionaries without any requirements?

I had Organized Religion as a civic.

Capo,

Did you put the code into your mod via a CustomGameUtils? or just put the edited one in the python directory.

I only ask, because if using the BUG mod, I dont believe that edited CvGameUtils.py files load or work, a CustomGameUtils.py file (or whatever you want to name it), has to be created, and loaded through BUGs modular python loading system.

Yes I did.
 
Nice to see it released :goodjob:.

@Capo: Are you not able run the modcomp as mod itself to check it :confused:?
Your second arrow shouldn't harm anything. For the first: Well, could also be a problem with your programm and the intendation, but could also be an intendation error.
But this one should already throw an exception when loading the mod, so if you don't get one, there's no error at this point.
 
Nice to see it released :goodjob:.

@Capo: Are you not able run the modcomp as mod itself to check it :confused:?
Your second arrow shouldn't harm anything. For the first: Well, could also be a problem with your programm and the intendation, but could also be an intendation error.
But this one should already throw an exception when loading the mod, so if you don't get one, there's no error at this point.

I haven't done that yet, but I figured that whoever released it would have.

I guess I could, but that won't really help me out too much now will it? If it works on its own and not in my mod what's the difference? I just wanted to ask if it has been tested yet and for whatever reason nobody has been able to tell me. You'd THINK the person who posted it would be able to answer this pretty easily. But apprently not, so I'll go check it.
 
Er... I wouldn't mind if you called me "cybrxkhan"...

Anyhow, sorry for not testing it earlier, I was too much in a rush to get it out that I forgot to test to see if actually works.

Anyhow, BAD NEWS -

Unfortunately, it DOESN'T work, and I'm not sure why, frankly, because it worked in WoL (or at least when I tested WoL). Since I am horridly incapable of python... I guess I'll have to default to The J...? Um, can you please help us? Please? :sad:
 
Unfortunately, it DOESN'T work, and I'm not sure why, frankly, because it worked in WoL (or at least when I tested WoL). Since I am horridly incapable of python... I guess I'll have to default to The J...? Um, can you please help us? Please? :sad:

Can't do anything myself here atm, but if you want to try to fix it:
The 2 lines marked by the_Capo are the problems.
Just move both with backspaces to the beginning of the line, and intend them both with tabs to the right position (= matches the lines above and under these lines).
Edit: Edgecrusher under me is right. First try the XML, then the python.
 
I corrected that, The_J, and it still didn't work. See image.

EC might be right about the callback, I didn't think about that.
 
Top Bottom