[BTS Python/XML] StackAid Promotion Mod

GIR

It'sNotStupidIt'sAdvanced
Joined
Jul 12, 2005
Messages
885
Location
EU
Here is another spin-off mini mod:

StackAid Promotion Mod

It adds new Promotions: StackAids (idea/python code by Zuul, modified by GIR)
It also adds a little python code:

The new Promotions come with a new system, the StackAid system (see pic for new Promotions). You can’t promote your units with this Promotions, but units will get this Promotions depending on the Stack they are in:
e.g. a stack of melee units will get the Heavy Aid Promotion. If a unit will get the HeavyAid_I, or HeavyAid_II or HeavyAid_III Promotion depends on the base strength of the unit and the total strength of the melee units in the whole stack. That means a bigger stack give your units higher StackAid Promotions and weaker units will get easier higher Aid Promotions like strong units.
Of course you can mix your units and they will get different StackAid Promotions: e.g if you have a stack with melee units, scouts and archery units your units will get HeavyAid, ScoutAid and RangeAid Promotions.
Note: Stacks that are too big lose the benefits from StackAid Promotions. For more info see spoiler.

I decided to only give weak effects to the Aid Promotions so it only has a small impact on the gameplay but you can change the Promotion effects in the Promotion.xml file.

Spoiler :

Stacks that are too big lose the benefits from StackAid Promotions:
minus one Aid-lvl if stack > 20 units
minus two Aid-lvl if stack > 40 units
minus three Aid-lvl if stack > 60 units
give crowded Promotion if stack > 80 units
(values can be changed in the top of the StackAid.py file)


Q: I have a stack with 1 Swordsman, 2 Axeman and 2 Archer and 1 Medic Scout. How many catapults I need to get a SiegeAid_II Promotion for my Axemen?

A:

A unit will get an Aid1 of a certain kind if the stack_strength combat_type > unit_strength * 1.
Aid2 with stack_strength combat type > unit_strength * 4.
Aid3 with stack_strength combat type > unit_strength * 12.

That means if you want to have a SiegeAid_II Promotion for your Axemen you need:

stack_strength Catapult(Str:5) > Axeman(Str:5) * 4
x * 5 > 5 * 4
x > 4

--> that means you need 5 Catapults to get SiegeAid_II Promotion for your Axemen.

Q: What promotions will my Axemen get in this stack?

A:

Let’s get the stack strength of the different combat types:

stack_range: 3+3 = 6
stack_scout: 1
stack_siege: 5*5 = 25
stack_heavy: 6+5+5 = 16

Will it get a RangeAid1?
stack_strength combat_type > unit_strength * 1
stack_strength_Range > Axemen * 1
6 > 5
Will it get a RangeAid2 (RangeAid2 replace RangeAid1)?
6 > 5*4 = 6 > 20 --> wrong (no RangeAid2, only RangeAid1)

Will it get a ScoutAid1?
1 > 5 --> wrong (no ScoutAid)

We know it will get a SiegeAid2

The Axemen is a melee unit (-> stack_heavy) and for balancing issues you have to subtract the base_strength from the stack_strength of the own kind, in this case of the heavy_stack_strength:
relative_stack_heavy: 16-5 = 11
Will it get a HeavyAid1?
relative_stack_strength_Heavy > Axemen * 1
11 > 5 --> right
Will it get a HeavyAid2?
11 > 5 * 4
11 > 20 --> wrong (only HeavyAid1)

--> the Axeman will get a RangeAid1, HeavyAid1 and a SiegeAid2 Promotion in this Stack!



Some pics:



Have fun!

File:
http://forums.civfanatics.com/downloads.php?do=file&id=6925




 
I've been toying with the idea of adding Zuul's old stackaid code to my JUnitTileLimit mod, this will make it alot easyer. Thanx GIR. :cool:
 
I merged the Stack Aid into a mod that I previously added a 40 civs DLL to it. Of course it gave me a python error. It might be nice to mention that currently it only supports 18 civs. It is clear in the code and I was able to change it to work with 40 civs. Thanks a lot for both Zuul and Gir for this good work.
 
Looks good but can you expand the warlord promotions like 50% more exp on that tile and 30% withdrawal and so on
 
what exactly do you have in mind?

As in if my warlord has leadership/tactics/morale everyone in the stack gain the bonus.
 
I see that you have improved the code so that it doesn't recalculate all surrounding plots when a unit moves. I still see some redundancy, however.


- you don't need onUnitBuilt, onUnitCreated and onUnitKilled. A unit that is created (no matter how) always triggers the onUnitSetXY callback, and a unit that dies always triggers onUnitLost. Hence, you're calculating the stack aid promotions for a plot twice or three times every time.

- the same applies to onUnitMove, with the exception that you will want to recalculate pOldPlot to possibly remove a promotion from the old stack. I would leave "self.updatePlot(pOldPlot..." in and remove "self.updatePlot(pPlot..." from onUnitMove. The new plot will be calculated in the onUnitSetXY event.

- I'm also wondering what you want to happen when there are units of different civilizations on the same tile. Personally, I would include a check whether the units in the loop are from the same owner, or at least allies.
 
I tried to download this file from civfanatics downloads and got error - file not found. Could you re-upload? I've been trying to find a standalone stack aid for use in HephMod to make my mod merging easier.

Thanks a bunch
 
I merged the Stack Aid into a mod that I previously added a 40 civs DLL to it. Of course it gave me a python error. It might be nice to mention that currently it only supports 18 civs. It is clear in the code and I was able to change it to work with 40 civs. Thanks a lot for both Zuul and Gir for this good work.

What do I need to do to modify this? I'm currently using jdog's Revolution as the DLL basis for HephMod, which supports 34 civs and would like to incorporate StackAid.

Is your Python error an "Index error: list index out of range" error? I'm getting a lot of those using the mod as is, though it seems to function well enough in that my units are getting stackaid promotions when they're supposed to.
 
I also would like to see this reuploaded.

Until GIR gets around to this, I've attached a zip of this mod to my post.
 

Attachments

  • StackAid.zip
    65.7 KB · Views: 218
I merged the Stack Aid into a mod that I previously added a 40 civs DLL to it. Of course it gave me a python error. It might be nice to mention that currently it only supports 18 civs. It is clear in the code and I was able to change it to work with 40 civs. Thanks a lot for both Zuul and Gir for this good work.

I just wanted to bump my request for instructions on how to do this to mod StackAid to work with a 34 civ DLL, in case anyone is still watching this thread ... :(
 
I can't see why the mods should be incompatible. Can you copy & paste the python error you get when trying to merge them?
 
I can't see why the mods should be incompatible. Can you copy & paste the python error you get when trying to merge them?

CvEventInterface line 30 in onEvent
CvCustomEventManager line 149 in handleEvent
CvCustomEventManager line 164 in_handleDefaultEvent
CvStackAidEventManager line 25 in onUnitMove
StackAid line 247 in onUnitMove
StackAid line 67 in updatePlot

Index Error: list index out of range

I don't get this error when using the 18-civ DLL.
 
Alright, now I see what's wrong. Check lines 50-54 - each list has a length of (slighly more than) 18. Just expand these lists so that their length matches the numbers of players you want.
 
Top Bottom