Trying to mod a speed buff ability. Need help

I’m trying to code a speed buff ability for handcavalry when close to enemy units. This ability has to be timed to avoid abuses. The idea is to give them something to close in to enemy units, just like the cavalry in AoE4.

I’m not coding it like Bayonet Charge/Carolean Charge because melee for these units its not an accessory, its their main method of dealing damage, and otherwise it could be used for running away instead of closing in (I call it the “reverse blitzkrieg” problem)

I’ve moded a handcavalry.tactics file, exporting the code from the hospitaller ability to move faster close to buildings.

 <action mergemode="add">
    <name stringid="124989">IncreaseSpeedWithBuildingsIncludesEnemies</name>
    <active mergemode="modify">1</active>
    <rate type="LogicalTypeBuildingsNotWallsOrGroves">0.112</rate>

As of now, I haven’t been able to make it work and I’m not sure why.

Of course, if there is an ability already in the game that does something like this, I’ll be glad to hear from it. The hospitaller ability is the closest thing I’ve found.

You added the action, but did you also enable the action on all their tactics i.e. Melee, Defend, Stand Ground? If you didn’t then that should be the prime reason it isn’t working I believe. Doing some quick testing, I was able to get it to work by copying the IncreaseHPWithEnemyUnits action out of emir.tactics and swapping it to Speed, but you’ll have to tinker with the rate numbers to get the right amount you want.

1 Like

Can you show me the code?

I checked the hospitaller code and the passive ability (aura of courage) desn’t show up in their formations or in the protoaction section

You would have to have a powermods if you want a new icon/rollover and an abilitymods to add that power to any proto unit you want it to be displayed on, but for passives it’s just visual and a way to inform the player it exists and give them something to mouse over and read what it does.

Edit: And remember, all new Actions in the tactics file have to be added to all the tactics at the bottom that you want it to be usable in, so if a speed boost is only for Trample mode you would only add it to that tactic but if it’s for any mode it needs to be in every tactic.

    <name stringid="110152">IncreaseSpeedWithEnemyUnits</name>
    <rate type="Hero">0.2</rate>
    <rate type="LogicalTypeLandMilitary">0.02</rate>

<tactic>Defend<action priority="75">BuildingAttack</action>
		<action priority="100">RangedAttack</action>
		<action priority="90">HandAttack</action>

Awasome, it works!
Thank you, I can now understand how to code the passive abilities.

Another question. Can I add a condition to the ability? My idea is the following:

  1. Speed bonus near enemy units
  2. If the unit attacks, the unit loses the bonus and the ability starts a cooldown.