Chiyo-chan
Chieftain
- Joined
- Jul 18, 2010
- Messages
- 10
Hi, this is for a modmod of FFH but i figure this is the same process for the main game its self,
I have got this code in use which promotes units with a "Hidden" promotion:
in short this gives a chance to give units the listed promotion,
I was trying to add to this code to make it so units of a class type could get promotions on chance,
So for example, When training a Melee unit, it has a chance of say 20% of coming with a certain promotion.
I tried the following code though this doesn't work so i guess i was off the mark;
TLDR; Does anyone know how to code a building to offer a chance (x% can be changed) for unit class types (Melee, mounted etc) have promotions on creation so it isn't universal for all units but only units of the said class type (in this case, Melee).
Additionally, is it possible to add a chance to give a random promotion? (this isn't key, just a bonus i wouldn't mind knowing without having to specify every promotion one by one).
I have got this code in use which promotes units with a "Hidden" promotion:
Code:
if city.getNumRealBuilding(gc.getInfoTypeForString('BUILDING_Magical_Hub')) > 0:
if unit.isAlive():
if isWorldUnitClass(unit.getUnitClassType()) == False:
if CyGame().getSorenRandNum(100, "Bob") <= 20:
unit.setHasPromotion(gc.getInfoTypeForString('PROMOTION_HIDDEN'), True)
in short this gives a chance to give units the listed promotion,
I was trying to add to this code to make it so units of a class type could get promotions on chance,
So for example, When training a Melee unit, it has a chance of say 20% of coming with a certain promotion.
I tried the following code though this doesn't work so i guess i was off the mark;
Code:
if city.getNumRealBuilding(gc.getInfoTypeForString('BUILDING_Magical_Hub')) > 0:
if unit.isAlive():
if isWorldUnitClass(unit.getUnitClassType()) == False:
if unit.getUnitCombatType() != gc.getInfoTypeForString('UNITCOMBAT_MELEE'):
if CyGame().getSorenRandNum(100, "Bob") <= 30:
unit.setHasPromotion(gc.getInfoTypeForString('PROMOTION_MUTATED'), True)
TLDR; Does anyone know how to code a building to offer a chance (x% can be changed) for unit class types (Melee, mounted etc) have promotions on creation so it isn't universal for all units but only units of the said class type (in this case, Melee).
Additionally, is it possible to add a chance to give a random promotion? (this isn't key, just a bonus i wouldn't mind knowing without having to specify every promotion one by one).