Mod Component Requests Thread

I would like to restrict the training of units that have resource requirements to a certain number of units per instance of the resource controlled. can anyone point me to a mod that does this where I might be able borrow code?
 
I think RevDCM or Legends of Revolution or Fall from heaven II maybe does this. I'm not totally sure.
 
I would like to restrict the training of units that have resource requirements to a certain number of units per instance of the resource controlled. can anyone point me to a mod that does this where I might be able borrow code?

I think RevDCM or Legends of Revolution or Fall from heaven II maybe does this. I'm not totally sure.

I know that FfH2 does not have this. I'm not sure about the others.


It should be relatively easy to do, by adding code like this to CvGameUtils.py:
Code:
	def cannotTrain(self,argsList):
		pCity = argsList[0]
		eUnit = argsList[1]
		bContinue = argsList[2]
		bTestVisible = argsList[3]
		bIgnoreCost = argsList[4]
		bIgnoreUpgrades = argsList[5]

[COLOR="Red"]		ePlayer = pCity.getOwner()
		pPlayer = gc.getPlayer(ePlayer)
		info = gc.getUnitInfo(eUnit)
		eUnitClass = info.getUnitClassType()
		iBonus = info.getBonusPrereq()
		iNumPerBonus = 3
		if iBonus != -1:
			if pPlayer.getUnitClassCount(eUnitClass) > iNumPerBonus * pPlayer.getNumAvailableBonuses(iBonus):
				return True

		return False

That should work if you want to allow only 3 units per bonus source for each resource.


edit:
I just remembered that getBonusPrereq() is what Promotions use in FfH2. With units, you have to deal with both getPrereqAndBonus() and getPrereqOrBonuses(i)

Code:
	def cannotTrain(self,argsList):
		pCity = argsList[0]
		eUnit = argsList[1]
		bContinue = argsList[2]
		bTestVisible = argsList[3]
		bIgnoreCost = argsList[4]
		bIgnoreUpgrades = argsList[5]

		[COLOR="Red"]ePlayer = pCity.getOwner()
		pPlayer = gc.getPlayer(ePlayer)
		info = gc.getUnitInfo(eUnit)
		eUnitClass = info.getUnitClassType()
		iBonus = info.getPrereqAndBonus()
		iNumPerBonus = 3
		if iBonus != -1:
			if pPlayer.getUnitClassCount(eUnitClass) > iNumPerBonus * pPlayer.getNumAvailableBonuses(iBonus):
				return True[/COLOR]
		[COLOR="DarkOrange"]for i in range(gc.getNUM_UNIT_PREREQ_OR_BONUSES()):
			if info.getPrereqOrBonuses(i):
				if pPlayer.getUnitClassCount(eUnitClass) > iNumPerBonus * pPlayer.getNumAvailableBonuses(i):
					return True[/COLOR]

		return False
I'm less sure about that orange part. It is probably rather inefficient. It would probably run better if you only place the limits on units with and prereqs.
 
thanks for the replies.

do I need to do something in the DLL to ensure that method is called? I guess I have to set USE_CANNOT_TRAIN_CALLBACK to 1 in PythonCallbackDefines.xml?

edit: I have it working. now for the tooltip...
 
Code:
		for i in range(gc.getNUM_UNIT_PREREQ_OR_BONUSES()):
			if info.getPrereqOrBonuses(i):
				if pPlayer.getUnitClassCount(eUnitClass) > iNumPerBonus * pPlayer.getNumAvailableBonuses(iBonus):
					return True
Looks weird.
info.getPrereqOrBonuses(i) will just return the Or Bonus type if any.
Then what does that gotta do with the Pre Requisite?
 
I have got two requested but can't make them myself because I can't do Python.
1)I would like a mod where every leader has a unique unit instead of the civ. So England would have no UU but Victoria could have the Redcoat, Churchill Commonwealth infantry, and so on. I'm sure I found something like this before, but couldn't find it. Could someone either make this or if it already exists give me the link?
2) This has been made for 3.17, but could someone make dynamic civ names for BTS 3.19, possibly using the python the same way as RFC, and making it easy to change names through text files and add new civs. Also maybe dynamic flags?

Thanks alot if anyone can help,
 
This terrain will allow land units and ships to pass, but land units can not stay in the channel.
How to add it ? Thank you!
 
Hi, all :) I have a request. I need a building (world wonder), which, if your empire have state religion Tao and will be attacked, wonder generate to the game two units xy_unit. Is such a thing possible?
 
Hi, all :) I have a request. I need a building (world wonder), which, if your empire have state religion Tao and will be attacked, wonder generate to the game two units xy_unit. Is such a thing possible?

Possible
 
Could someone be able to enable only certain civilizations to build cities on mountains and have their units be able to move onto mountains? This would be really appreciated, thanks. :)
 
Hello nudibranch molluscs. I've got a specific problem - an elegant way of turning the vanilla Gunship art into an air unit. I would be amazed if someone hadn't tried it before. It performs well as a striking air unit, but doesn't show up in the pedia, well, ok just the lowest bit of the model. I'd appreciate some feedback.
 
Top Bottom