Trying to add "Purchase Promotions Future"

seitan2102

Chieftain
Joined
Feb 4, 2008
Messages
52
Hi there, i could need some help over here. If someone knows how-to, i would be very grateful.

There is a feature in one BTS mods, "Broken Star" where you can purchase upgrades for any unit you build or using. I want to take this feature and add it to the "Next War" mod of BTS.

Anyway this is possible? Both of those mods are implemented in vanilla BTS.

Thanks in advance.
 
It appears to be possible via Python, as the mod has no custom dll.

From a quick glance, I'd say you need these code parts

From BrokenStar.py

Spoiler :
Code:
	def onModNetMessage(self, argsList):
		'Called whenever CyMessageControl().sendModNetMessage() is called - this is all for you modders!'
		
		iData1, iData2, iData3, iData4, iData5 = argsList
		
		iNetMessageType = iData1
		
		# Identify what this NetMessage is actually doing
		if (iNetMessageType == self.iNetMessage_BuyPromotion):
			
			iPlayer = iData2
			iUnitID = iData3
			self.promoteUnit(iPlayer, iUnitID)
			
		elif (iNetMessageType == self.iNetMessage_BuyUnit):
			
			iPlayer = iData2
			iUnitType = iData3
			
			self.purchaseUnit(iUnitType, iPlayer)

	def promoteUnit(self, iPlayer, iUnitID):
#		pHeadSelectedUnit = CyInterface().getHeadSelectedUnit()
#		pPlayer = gc.getPlayer(iPlayer)
		player = PyPlayer(iPlayer)
		pHeadSelectedUnit = gc.getPlayer(iPlayer).getUnit(iUnitID)
		
		cost = 75
		expBought = 5
		gold = player.getGold()
		if gold >= cost:
			pHeadSelectedUnit.changeExperience(expBought, 900, false, false, false)
			player.setGold(gold - cost)
			#CvGameUtils.CvGameUtils().addPopup("Experience",str(pHeadSelectedUnit.getExperience()))
			if pHeadSelectedUnit.getExperience() >= pHeadSelectedUnit.experienceNeeded():
				pHeadSelectedUnit.setPromotionReady(1)
						
		else:
#			print("Player is %d. Activate Player is %d. " %(iPlayer, CyGame().getActivePlayer()))
			iActivePlayer = CyGame().getActivePlayer()
			if(iPlayer == iActivePlayer):
				CvGameUtils.CvGameUtils().addPopup(localText.getText("TXT_KEY_BROKEN_STAR_GOLD_NOT_ENOUGH", ()), localText.getText("TXT_KEY_BROKEN_STAR_GOLD_NOT_ENOUGH_MESSAGE", ()))
#				CvGameUtils.CvGameUtils().addPopup("TXT_KEY_BROKEN_STAR_GOLD_NOT_ENOUGH", "TXT_KEY_BROKEN_STAR_GOLD_NOT_ENOUGH_MESSAGE")
			
		return

From CvModEvents.py

Spoiler :
Code:
	def onModNetMessage(self, argsList):
		'Called whenever CyMessageControl().sendModNetMessage() is called - this is all for you modders!'
		
		iData1, iData2, iData3, iData4, iData5 = argsList
		
		BrokenStar.BrokenStar().onModNetMessage(argsList)

Not sure that this is everything you need though, also I do not know Python (but some other programming languages), so beware (i.e. if you do not know Python either, I'd think twice about giving it a try) ;)

You'll probably need some more methods from the BrokenStar code, I just checked what called promoteUnit, not whether the other methods called by the routines I found called some more routines which are missing in the standard Python code.
 
I see, don't know Python either. I' trying to make this work using my... sense! :)

I don't even know where to paste the code you game me. LOL!

Anyway, I hope someone's tries to make a mod with it or tell us a little bit bore on how to do it ourselves.

Tricky, isn't it?
 
advanced start feature .... It allows to purchase plenty of items ! I might be possible to add a similar function to the length of the game.

If someone could figure out how to do this, I would be greatly obliged because it would really help with a scenario I going to release soon.
 
Actuall, this script already exists on vanilla BTS. That's pretty important as AI will know how to use it too, bringing balanve to the game.

Anyway, being able to purchase promotions is actually realistic. It would give us a reason to work on economy.

Think of it like this: Is it fair, a poor civilization to possess as advanced fighters as a rich one? Plus, it would be a good reason to reduce numbers over quality.

The promotions should be a little expensive (300-800 gold depending on the kind of promotion) for further balance.

Hope we all can work something out. Still trying myself, I need help though... much of it! :)
 
Perhaps it could be slightly cheaper, but make the unit unavailable to do anything for a turn or two (as training the new ability)
 
Back
Top Bottom