Promotion Bonuses on newly built units

PsiCorps

FF: Babylon 5 mod team
Joined
Dec 30, 2007
Messages
1,455
Location
Vietnam
At present in the FFB5 mod we have a situation where units are available to build but get no promotions. As the game progresses some of the new techs that get researched allow access to new promotions ie increases in Visibility range, increase in movement. What i would like to do is ensure that once the promotion is available the following happens:-
1.Existing units need to either pay credits (preferred) to get the upgraded visibility/improved engines or use their experience promotion.
2. Newly built units automatically gain the Visibility/improved engines promotions.
This would reflect real life situations a little better.

I know how to increase a units movement as the result of researching a tech but this is applied across the board when the research is completed, thus all units with a speed of 1 are now speed 2 and all units that were speed zero are now speed 1 (even though it is a non mobile unit) Just writing this bit down has got me thinking about a method of incorporating the added movement point to 0 movement units.

Any suggestions/ideas are more than welcome.
 
> 2. Newly built units automatically gain

Here is some rough python code:

Code:
    def onUnitCreated(self, argsList):
          pUnit = argsList[0]
          iPlayerID = pUnit.getOwner()
          pPlayer = gc.getPlayer(iPlayerID)
          pTeam = gc.getTeam(pPlayer.getTeam())
          iSeeFurther = gc.getInfoTypeForString('TECH_SEE_FURTHER')          
	  if ( pTeam.isHasTech(iSeeFurther) :
                        iPromo = tech2promoHash['TECH_SEE_FURTHER']
		        pUnit.setHasPromotion(iPromo, True)

Since I don't know how to determine which tech grants which promo, the mapping would be added statically. Possibly in the _init_ section the tech2promoHash would be populated.
eg)
iPromoSeeFurther = gc.getInfoTypeForString('PROMOTION_SEE_FURTHER')
tech2promoHash = {'TECH_SEE_FURTHER':iPromoSeeFurther,'TECH_MOVE_FURTHER':iPromoMoveFurther}


Another way, which is probably faster, is to store scriptdata foreach player to keep which techs he has that enable new promotions. The data stored could be the ID for the promo, so the code would just loop through the list (retrieved from the player's scriptdata) and apply any promos found to a new unit. That is probably a cleaner method, especially if there are a lot of promos.
 
Back
Top Bottom