from CvPythonExtensions import *put,
from zPromotions import *so it should look like,
from CvPythonExtensions import *
from zPromotions import *
class promos(receive):
def __init__(self):
if pWinner.canAcquirePromotionAny():
self.promos().doReceive(pWinner, pLoser, None, pLoser.getX(), pLoser.getY(), ["PROMO_COMBAT", "PROMO_COMBAT_PLOT", "PROMO_LOSER"])
CvEventManager.CvEventManager().onCombatResult(argsList) #Call the default function
if pUnit.canAcquirePromotionAny():
self.promos().doReceive(pUnit, None, pPlot, pPlot.getX(), pPlot.getY(), ["PROMO_PLOT", "PROMO_CITY_BUILDING", "PROMO_NEUTRAL"])
if pPlot.getOwner() != -1:
self.promos().doReceive(pUnit, None, pPlot, pPlot.getX(), pPlot.getY(), ["PROMO_HOMELAND", "PROMO_BARBARIAN", "PROMO_VASSAL", "PROMO_MASTER", "PROMO_FRIENDLY", "PROMO_ENEMY", "PROMO_HOSTILE"])
if pPlot.isCity():
self.promos().doReceive(pUnit, None, pPlot, pPlot.getX(), pPlot.getY(), ["PROMO_CITY_BUILDING"])
CvEventManager.CvEventManager().onUnitMove(argsList) #Call the default function
if unit.canAcquirePromotionAny():
self.promos().doReceive(unit, None, unit.plot(), unit.getX(), unit.getY(), ["PROMO_BUILT"])
CvEventManager.CvEventManager().onUnitBuilt(argsList) #Call the default function
if unit.canAcquirePromotionAny():
if unit.specialCargo() == gc.getInfoTypeForString("SPECIALUNIT_FIGHTER"):
self.promos().doReceive(unit, None, None, unit.getX(), unit.getY(), ["PROMO_AIR_CARRIER"])
CvEventManager.CvEventManager().onUnitSelected(argsList) #Call the default function
self.addPromoType(The Promotion Type,And for you more knowledgeable people here is an API style definition:
The Event That Will Give This Promotion (See Below),
The Chance that it will receive a promotion it can be any number between 0 and 100 where 0 does not give a promotion,
The AND data passed to the event,
The OR data passed to the event,
The unit classes that can receive this promotion,
Set to True (True) if you want the unit to receive the promotion and False (False) if you want the unit to lose the promotion,
Set to True (True) if you want the unit to keep the promotion and False (False) if you want the unit to lose the promotion (see below for more info))
A Unique ID (Used because the event manager has a tendency to reload it self and create a ton of the same events, very slow)
PROMOTION addPromoType(PromotionType promoType, zEvent eventType, INT promoChance, LIST andData, LIST orData, LIST unitData, BOOL receive, BOOL keep, DICTKEY id)Here is an example:
self.addPromoType("PROMOTION_COMBAT5", "PROMO_COMBAT", 10, [], [], [], True, True, "Example1")This sets it so that all units have a 10% chance of receiving a Combat V promotion from combat.
self.addPromoType("PROMOTION_COMBAT5", "PROMO_COMBAT", 10, [], [], [], True, True, "1")
self.addPromoType("PROMOTION_COMBAT5", "PROMO_COMBAT", 10, [], [], [], True, True, 1)
self.addPromoType("PROMOTION_COMBAT5", "PROMO_COMBAT", 10, [], [], [], True, True, Example1)The first two are valid ("1", and 1), but the second (Example1) is not because text must be inside of quote marks (there is one an exception, but it is beyond the scope of these instructions). Unseeing code like in the last example would give a message something to the effect of "Example1 Referenced Before Being Bound".
self.addPromoType("PROMOTION_COVER", "PROMO_COMBAT", 10, ["TECH_ARCHERY", "PROMOTION_COMBATBAT1"], [], [], True, True, "Example2")Now this sets it so that any unit that has the Combat I promotion and who's owner has the Archery tech has a 10% chance of receiving a Cover promotion from combat. Now let's take a closer look at this code. As you may remember from before, the first part that reads "PROMOTION_COVER" is the promotion to be given/removed from the unit. Next we have "PROMO_COMBAT", this tells Civ that the promotion should only be given/removed after a unit wins a battle. Then we have the 10, it tells Civ that there is only a 10% chance that the unit can be given this promotion. Now we come to the and prerequisite list, it tells civ that the unit must have the Combat I promotion and that it's owner must have the tech Archery. Then we come to or prerequisite list and it is empty (if a list is defined like this [ ] it is empty). Then we find the last list, the unit class list, and it to is empty. Then we have the first True, this True tells civ that we want to give the promotion (instead of taking it away), next is another True this True doesn't do anything in this example because the PROMO_COMBAT event doesn't use it (we will see how this is used soon). And last of all is the ID, it is set to the string "Example2" (in python a string is anything inside of quote marks).
self.addPromoType("PROMOTION_COVER", "PROMO_COMBAT_PLOT", 10, ["TECH_ARCHERY", "PROMOTION_COMBATBAT1"], ["FEATURE_JUNGLE", "FEATURE_FOREST"], [], True, True, "Example3")Now let's see if we can create this code on our own. First we copy our previous example, then change the or prerequisite list to hold the 2 features jungle and forest, now it will only accept the feature type (not the feature name), so we go into the Terrain folder inside of our MODs Xml directory and open the CIV4FeatureInfos.xml, then we find the jungle entry and paste it's type inside of the or prerequisite list, while doing this we remember to put the jungles type inside of quote marks. Next we must put a comma after the jungles entry in the or prerequisite list (this tells the civ that we ended the last entry in the list and we are starting a new one) then we continue and use the steps we used to add the jungle to add the forest. Now we have to set the event type to "PROMO_COMBAT_PLOT", this will tell civ that it should check the or prerequisite list before giving the promotion. Last of all we have to set the ID, I have chosen "Example3". Now we have added a new promotion type to the PROMO_COMBAT_PLOT event, so when ever a unit wins a battle that was fought over a plot that had either a jungle or a forest and the unit had Combat 1 and it's owner had Archery, the unit will receive the Cover promotion.
self.addPromoType("PROMOTION_COVER", "PROMO_COMBAT_PLOT", 10, ["TECH_ARCHERY", "PROMOTION_COMBATBAT1"], ["FEATURE_JUNGLE", "FEATURE_FOREST"], ["UNITCLASS_WARRIOR", "UNITCLASS_SPEARMAN"], True, True, "Example4")Now to make these changes we must first find the unit class for warriors, to do this we open the Xml directory inside of our MOD then we open the Units folder and open the CIV4UnitClassInfos.xml. We find the warrior's class (UNITCLASS_WARRIOR), now we paste the unit class into the unit class list not forgetting to put inside of quotes as well. Then we place our comma after the warriors class and follow the previous steps to add the spearman's unit class (UNITCLASS_SPEARMAN). Lastly we change the ID to Example4. If we use this code Spearmen and warriors with Combat 1 and who's owner has Archery will have a 10% chance of receiving Cover if they fight a battle over a plot that is either jungle or forest.
self.addPromoType("PROMOTION_COMBAT1", "PROMO_COMBAT", 10, [], [], [], True, True, "PROMO_COMBAT")
This
code gives all units a 10% chance of receiving Combat 1 from combat.
PROMO_PLOT:
Uses: It
uses the lists. It
checks the or prerequisite list for terrain types, feature types,
improvement types, and bonus types.
Called: When
a unit moves
Example:
self.addPromoType("PROMOTION_COMBAT1", "PROMO_PLOT", 10, [], [], [], True, False, "PROMO_PLOT")This code gives all units a 10% chance of receiving Combat 1 when a unit moves. When the unit moves off of the plot it loses the promotion.
self.addPromoType("PROMOTION_COMBAT1", "PROMO_PLOT", 10, [], [], ["TERRAIN_DESERT", "FEATURE_JUNGLE"], True, True, "PROMO_PLOT")
Gives all units a 10% chance of receiving Combat 1 when a unit moves onto a plot that is desert or has a jungle on it. When the unit moves off of the plot it loses the promotion.
PROMO_LOSER_COMBAT:
Uses:
It uses the and prerequisite list and the unit class list.
Called: After Combat
Example:
self.addPromoType("PROMOTION_COMBAT1", "PROMO_LOSER_COMBAT", 10, [], [], [], True, True, "PROMO_LOSER_COMBAT")This code gives all units a 10% chance of receiving Combat 1 from the loser of combat if the loser already has combat 1.
self.addPromoType("PROMOTION_COMBAT1", "PROMO_COMBAT_PLOT", 10, [], [], [], True, True, "PROMO_COMBAT_PLOT")This code gives all units a 10% chance of receiving Combat 1 from combat.
self.addPromoType("PROMOTION_COMBAT1", "PROMO_COMBAT_PLOT", 10, [], [], ["TERRAIN_DESERT", "FEATURE_JUNGLE"], True, True, "PROMO_COMBAT_PLOT")Gives all units a 10% chance of receiving Combat 1 when a unit wins a battle on a plot that is desert or has a jungle on it.
self.addPromoType("PROMOTION_COMBAT1", "PROMO_HOMELAND", 10, [], [], [], True, False, "PROMO_HOMELAND")This code gives all units a 10% chance of receiving Combat 1 when they move into their cultural borders. When the unit moves off of the plot it loses the promotion.
self.addPromoType("PROMOTION_COMBAT1", "PROMO_NUETRAL", 10, [], [], [], True, False, "PROMO_NUETRAL")This code gives all units a 10% chance of receiving Combat 1 when they move out of their cultural borders. When the unit moves off of the plot it loses the promotion.
self.addPromoType("PROMOTION_COMBAT1", "PROMO_CITY_BUILDING", 10, [], [], [], True, False, "PROMO_CITY_BUILDING")This code gives all units a 10% chance of receiving Combat 1 when they move into a city (owned by it's owner). When the unit moves out of the city it loses the promotion.
self.addPromoType("PROMOTION_COMBAT1", "PROMO_CITY_BUILDING", 10, [], [], ["BUILDING_BARRACKS"], True, False, "PROMO_CITY_BUILDING")This code gives all units a 10% chance of receiving Combat 1 when they move into a city (owned by their owner) that has a barracks. When the unit moves out of the city it loses the promotion.
self.addPromoType("PROMOTION_COMBAT1", "PROMO_BUILT", 10, [], [], [], True, False, "PROMO_BUILT")This code gives all units a 10% chance of receiving Combat 1 when they built. When the unit moves out of the city it loses the promotion.
self.addPromoType("PROMOTION_COMBAT1", "PROMO_BUILT", 10, [], [], ["BUILDING_BARRACKS"], True, False, "PROMO_BUILT")This code gives all units a 10% chance of receiving Combat 1 when they built in a city that has a barracks. When the unit moves out of the city it loses the promotion.
self.addPromoType("PROMOTION_COMBAT1", "PROMO_BARBARIAN", 10, [], [], [], True, False, "PROMO_BARABRIAN")This code gives all units a 10% chance of receiving Combat 1 when they move into the cultural borders of a vassal civ. When the unit moves out of the vassal's culture it loses the promotion.
self.addPromoType("PROMOTION_COMBAT1", "PROMO_MASTER", 10, [], [], [], True, False, "PROMO_MASTER")This code gives all units a 10% chance of receiving Combat 1 when they move into the cultural borders of a master civ. When the unit moves out of the master's culture it loses the promotion.
self.addPromoType("PROMOTION_COMBAT1", "PROMO_FRIENDLY", 10, [], [], [], True, False, "PROMO_FRIENDLY")This code gives all units a 10% chance of receiving Combat 1 when they move into the cultural borders of a civ that has open borders. When the unit moves out of the civ's culture it loses the promotion.
self.addPromoType("PROMOTION_COMBAT1", "PROMO_ENEMY", 10, [], [], [], True, False, "PROMO_ENEMY")This code gives all units a 10% chance of receiving Combat 1 when they move into the cultural borders of a civ that is at war. When the unit moves out of the civ's culture it loses the promotion.
self.addPromoType("PROMOTION_COMBAT1", "PROMO_HOSTILE", 10, [], [], [], True, False, "PROMO_HOSTILE")This code gives all units a 10% chance of receiving Combat 1 when they move into the cultural borders of a civ that doesn't have open borders, is not at war, is not the vassal, and is not the master of the unit's owner. When the unit moves out of the civ's culture it loses the promotion.
self.addPromoType("PROMOTION_COMBAT1", "PROMO_AIR_CARRIER", 10, [], [], [], True, False, "PROMO_AIR_CARRIER")This code gives all units a 10% chance of receiving Combat 1 when they are selected and are carrying a SPECIALUNIT_FIGHTER (Fighter, Jet Fighter).
self.addPromoType("PROMOTION_COMBAT1", "PROMO_COMBAT", 10, [], [], [], False, True, "BOOL1")This will give every unit a 10% chance of losing Combat 1 after combat.
self.addPromoType("PROMOTION_COMBAT1", "PROMO_PLOT", 10, [], [], [], True, True, "BOOL2")This will give all units a 10% chance of receiving Combat 1 when they move onto a plot, and allow them to keep the promotion when it leaves the plot.
self.addPromoType("PROMOTION_HOMELAND2", "PROMO_HOMELAND", 10, [], [], [], True, False, 1)Well after much work I finally got the homeland 2 promotion, but then I moved my unit into my city and I lost homeland 2, it was then that I realized that it would reevaluate a unit when it moved if it decided it should not have the promotion it would remove it (it is supposed to do this). So to fix the problem I changed the code so that you had a 10% chance of receiving and keeping Homeland 2, but I also added PROMO_NUETRAL so that when I left my cultural borders I would have 100% chance of losing homeland 2. My final result code looks like this:
self.addPromoType("PROMOTION_HOMELAND1", "PROMO_HOMELAND", 100, [], [], [], True, False, 2)
self.addPromoType("PROMOTION_HOMELAND2", "PROMO_HOMELAND", 10, [], [], [], True, True, 1)This works in the way that I want, and hopefully helps you from having a crazy day of trying to figure out what is happening. Now remember PROMO_NUETRAL, PROMO_BARBARIAN, PROMO_VASSAL, PROMO_MASTER, PROMO_FRIENDLY, PROMO_ENEMY, and PROMO_HOSTILE all have the same quirck, so try to use code like above.
self.addPromoType("PROMOTION_HOMELAND1", "PROMO_HOMELAND", 100, [], [], [], True, False, 2)
self.addPromoType("PROMOTION_HOMELAND2", "PROMO_NUETRAL", 100, [], [], [], False, False, 2)