Hi all programmers!!
Help Please...
I made building which has add to the water units promotion for multiple attack.
Can someone write in python code for it, please?
Thank you very much
Giving promotion only to currently existing units is quite simple:
Ex.:
Spoiler:
player = gc.getPlayer(iPlayer)
promotion = CvUtil.findInfoTypeNum(gc.getPromotionInfo,gc.getNumPromotionInfos(),'PROMOTION_BLITZ')
unitCombatNaval = gc.getInfoTypeForString("UNITCOMBAT_NAVAL")
(unit, iter) = player.firstUnit(false)
while (unit):
if unit.getUnitCombatType() == unitCombatNaval:
unit.setHasPromotion(promotion,true)
(unit, iter) = player.nextUnit(iter, false)
If you want an effect that gives that promotion to both existing and future units of a certain type (like the Axeman Shock event).....
If you want to do it in Python, this is a bit more difficult, and I'm currently in trouble too.
Maybe, the easiest way to have a similar effect is to use an event, which is triggered when you have that building, and has this effect in the Event infos:
WOW, thanks, ViterboKnight.
Unfortunately I´m not programmer and don´t know where I must paste your code. Can you, please, advice me more?
In BtS is not possibility give to naval unit PROMOTION_BLITZ and I very desire set right this game error by my new national wander.
I tried set it in xml but game give in place of blitz Promotion Medic I
Ok, you can do this:
in the Python\EntryPoints folder, you can create your file, copying one of the existing ones and renaming it as you like (eg, MyPythonScripts.py).
Here, you can write the headings
Spoiler:
import CvUtil
from CvPythonExtensions import *
gc = CyGlobalContext()
localText = CyTranslator()
and your functions
Spoiler:
def GivePromotionToNavalUnits(iPlayer):
player = gc.getPlayer(iPlayer)
promotion = CvUtil.findInfoTypeNum(gc.getPromotionInfo,gc.getN umPromotionInfos(),'PROMOTION_BLITZ')
unitCombatNaval = gc.getInfoTypeForString("UNITCOMBAT_NAVAL")
(unit, iter) = player.firstUnit(false)
while (unit):
if unit.getUnitCombatType() == unitCombatNaval:
unit.setHasPromotion(promotion,true)
(unit, iter) = player.nextUnit(iter, false)
Now, all you have to do is call this function every time a new turn starts for each player.
In the CvEventManager.py file, you can find these events.
Edit this file, and first add a reference to your new file, adding a new "import" clause.
Awesome, I will try it today evening at home. Thank you very much.
How can the game check out that just in the city with this building is the possibility to give promotion blitz to the water unit? Please?
Hi, Ekmek. I want not blitz for all water units. I've been thinking that advanced national wander what give blitz to units trained in one city per nation with wander is good solution...
Problem is that I himself can not write it... I´m not programmer
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.