Help creating promotion lists in military advisor

NotSoGood

Emperor
Joined
Jan 25, 2009
Messages
1,077
Location
Finland
I'm creating a hire unit screen to military acvisor and now I'm trying to add promotion lists where you can choose which promotions you want the new hired unit to have. (they will cost money ofcourse) I'm not sure yet if I can create the lists because I can't check if the unit can acquire those promotions. I have the unit's int but I have no idea how I can call functions from it. Every idea is welcome.
 
I have no clue as to your actual question, but I like your idea and have this to add:

Why not have "training time" as a additional feature? So if you want crack troops out of the box, you'll have to wait for them to be fully trained before you can put them into action.

Or, you could purchase XP instead. But every level worth of XP takes one turn to gain, and the unit will only gain this "training" if its idle for an entire turn (while the training takes place). Once the troops are fully trained you can spend all that XP on whatever promotions are available to the unit. Or, in an all-out war situation, you might put that unit into action prematurely and gain the additional XP from actual combat experience instead.

Or, you could buy XP for any unit, up to a limit. So you could basically buy a unit (the equipment and personnel) and then spend additional gold on the training. The unit would forfeit its turn with this action.

Do with it whatever you like, just a suggestion. :)
 
Your first question, given a unit, how to call functions on it, is answered generally by gc.getXYZ(). For example, given a player int "iPlayer", to get the CyPlayer object "pPlayer":

pPlayer = gc.getPlayer(iPlayer)

To find appropriate promotions, I always just scan through the python API descriptions to find something that looks relevant. So, I found CyUnit.canAcquirePromotion(ePromotion). However, I suppose at this point you have not created an actual unit, all you have is a unit type such as UNIT_WARRIOR. Is that correct? If you have an actual unit, get the pUnit pointer with write a loop over getNumPromotions; for each one call pUnit.canAcquirePromotion, and if it passes, add it to the list.

If you have only a unit type, it may not be easy to find the legal promotions. You can check for matching unitcombats, and make sure the promotion has no prereqs, but there could still be complex cases where for example, a unit has a free promotion due to traits or due to the unit itself. Then a promotion such as Combat II might actually be available.

Baldyr suggested buying experience instead. Dune Wars has a "homeworld reinforcements" screen which does something similar. Some random percentage of units are declared as "elite". They come with 5 XP, you can use the normal promotion buttons once they are purchased. This avoids having to figure out which promotions are possible.
 
*deleted*

wrong answer to wrong question...
 
If you have only a unit type, it may not be easy to find the legal promotions. You can check for matching unitcombats, and make sure the promotion has no prereqs, but there could still be complex cases where for example, a unit has a free promotion due to traits or due to the unit itself. Then a promotion such as Combat II might actually be available.
That was my problem, I couldn't find a way to call canAcquirePromotion. Sorry if I wasn't clear enough.

Or, you could buy XP for any unit, up to a limit. So you could basically buy a unit (the equipment and personnel) and then spend additional gold on the training. The unit would forfeit its turn with this action.

This does actually solve the problem. I don't have to play with promotion lists if I let you buy pure xp. For some reason I nerver even considered that. Thank you very much.
 
This does actually solve the problem. I don't have to play with promotion lists if I let you buy pure xp. For some reason I nerver even considered that. Thank you very much.
Yeah, more suggestions:

You can only buy XP for units up to a certain level.

Units have to be inside domestic borders and have not moved.

The unit could have to be on a tile containing a Fort - a military installation. If you wanna make Forts more useful inside a city BFC you could have any Military Instructor present in the city lower the cost. (There should be some methods for checking whether or not a plot is within BFC and/or worked by a city.)

Or you could limit the buy XP feature to cities with Barracks only.

And lastly, the units that are eligible for "training" could have a "worker action" associated with them - "Train". So the time to complete the "work" would be dependent on the amount of XP bought. (Or on the level this XP will amount to.)
 
Back
Top Bottom