Modify Attribute (attack) Doesn't Work For Yet-to-be-created Units?! BUG?!

I need the attack of certain units to increase by 3 every 30 minutes. For the sake of this post, let’s say I want to increase the attack of longbowmen, and let’s say that the base attack of longbowmen is 10.

At the appropriate time, I make a trigger to increase the attack of the longbowmen by 3, by doing a Modify Attribute trigger and ADD 3 for attack for a total of 13. This works for longbowmen already on the map–they all increase attack by 3 to a total of 13. But NEW longbowmen still have an attack of 10.

Needless to say, that’s a problem. I need all longbowmen both already on the map and yet to be created to have an attack of 13. And then later on, an attack of 16, etc. I do not want to use SET instead of ADD, because (long story short) I am not always going to know the current attack amount at the time the trigger fires. So I have to use ADD, SUBTRACT, MULTIPLY or DIVIDE.

For buildings this doesn’t seem to be a problem. If I make the HP of a barracks +20% (doing a modify attribute HP MULTIPLY by 12 and then a modify attribute HP DIVIDE by 10), it adjusts HP for all barracks on the map and all barracks yet to be created by +20%.

The same does not seem to hold true of units. Am I missing something? Have I made a mistake, or is this is a known issue and is supposed to work like this? If it is supposed to work like this, is there a workaround?

Hi,
Just wondering - you can re-run the trigger that adds HP to your units post creation of the units. So for example if you have a trigger - [AddHitPoints] and then when you are creating the object using something like [CreateObjects] - can you use the “Activate Trigger” option to recursively call the [AddHitPoints] to add the current “hitpoint” rate to all the longbowmen in your example ?
Note - I have not elaborated on the functions [AddHitPoints] and [CreateObjects] .They might involved fine tuning and management using Variables.

1 Like

@PentuDuckling thank you for your response!

To be clear, I don’t have any issues updating HP when using Change Object HP. However I wish to use Modify Attribute to make a universal and permanent change in the HP of a unit for the rest of the game. Change Object HP is a one time use sort of change, affecting only certain units or units in certain areas.

As for my original problem, I have narrowed down the issue somewhat. So, most units are maintaining their attack buff of 3 after I fire the trigger. Both units on the map, and future units I train, maintain the buff. The only apparent exceptions are the elite versions of unique units trained in castles. They are not affected by the trigger. My trigger only modifies the attack for the elite version of the units, not the regular version, because my scenario only has the elite version of unique units.

However I was told by an editing guru that the train button in the castle creates the regular version of a unique unit and then it is “transformed” into an elite unit I suppose? My trigger currently modifies only elite units, not their “regular” counter parts. So I would need to create, for example, a modify attribute trigger for a regular teutonic knight and an elite teutonic knight, even though an elite teutonic knight actually comes out of the castle after training! Very counter intuitive. I tested this theory and it seems to be working. I will finish my trigger and make sure it works for all units, then report back here.

1 Like

Well, I’m afraid that I could not be helpful… Just my two cents:

Did you set the Attack/Armor Type? The trigger effect “Modify Attribute” requires further levels of adjusting stats unlike the effect Change Object Attack/Armor/etc.
If you want to change the base or given attack of the Longbowmen, then you have to set the Attack Type as 3. 3 is for basic piercing attacks.

So, set the Attack/Armor Type as “3”, and have the attack of your Longbowmen +3 with “add”.

The same goes for close-combating units such as Swordsmen or Knights. They require the Type as “4”.

With the assistance of some talented helpers on the AOE “AI Scriptures” #Modding Discord channel, I was able to solve this issue.

To recap, I was having a problem with just about any castle created unique Elite Units not experiencing a Modify Attribute change after I’d fired a trigger to modify an attribute–even though unique Elite Units already on the map when the game began, because I placed them on the map in the editor did experience a change.

Example Of The Problem:
–I fire a trigger increasing attack for Elite Longbowman.
–Elite Longbowman already on the map which were placed there by me in the editor experience +2 attack as expected.
–Elite Longbowman subsequently created by training them in the castle, after the above trigger fired, resulted in those units not experiencing a +2 attack as expected.
–I described the above phenomenon as “modifying attribute” not affecting "yet to be created” units in my original post.

Background Info:
My scenario is Post-Imperial, and there were already Elite Longbowman on the map which were placed there by me in the scenario editor. A player playing the scenario would also likely choose to create Elite Longbowman while playing the scenario.

The Fix:
When I made the scenario Post-Imperial, I knew that meant there would never be non-elite version of units on the map. That is, there would never be a “regular” Longbowman on the map. There would only ever be Elite Longbowman because Post-Imperial of course means that all technologies have been researched, including the one that upgrades Longbowman to Elite Longbowman.

So considering there would never be any regular Longbowman on the map, when I made my trigger to Modify Attribute (increase attack by +2), I only made a trigger to increase attack for Elite Longbowman (Unit ID 530), and likewise for all the other unique Elite Units. After all, why would I make a trigger increasing attack for the regular version of those unique units when my scenario was Post-Imperial age?

However as it turns out, when you click Train Elite Longbowman in the Castle, the game code appears to create a REGULAR Longbowman (Unit ID 8) at the moment you hit the train button, and at some point between that moment and the moment when it actually pops out of the castle, upgrade it to an Elite Longbowman—and the unit which pops out of the castle maintains its Unit ID of 8—it does not pop out as Unit ID 530 as you might expect even though it is an Elite Longbowman. It is likewise for all unique units which are created in the castle. Since my trigger affected only Unit ID 530 (Elite Longbowman which were placed by me in the editor), any units with Unit ID 8 (Elite Longbowman trained by me while playing the scenario) were not affected.

So, if you are Modifying Attribute of any castle created units in the editor, even if your scenario is Post-Imperial you need a trigger that has effects for both the regular version of the unit as well as the elite version of the unit. Again, in this example, my trigger needed to have an effect to Modify Attribute (increase attack +2) for both Unit ID 530 and Unit ID 8.

Notes:
This issue appears to be related to castle created units only. If you wanted to create a trigger to increase attack of an Elite Skimisher which is created in the archery range, you would only need a trigger to modify attack of Elite Skimishers, and not regular Skirmishers.

If you do not know the Unit IDs of both the regular and elite versions of units for which you want to Modify Attribute, you can find that information in the Advanced Genie Editor which comes standard with AOE 2 Definitive Edition.

If you have a problem along the lines of what I have described here go ahead and reply in the comments and I will do my best to help you.

1 Like

Thanks. I will try this in my own version of Barbarossa campaign.

Let me know if you run into any issues and I’ll try to help.