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.

<tacticsmods>
 <action mergemode="add">
    <name stringid="124989">IncreaseSpeedWithBuildingsIncludesEnemies</name>
    <type>LikeBonus</type>
    <modifyratebytype>1</modifyratebytype>
    <modifyabstracttype>LogicalTypeBuildingsNotWallsOrGroves</modifyabstracttype>
    <active mergemode="modify">1</active>
    <maxrange>34</maxrange>
    <rate type="LogicalTypeBuildingsNotWallsOrGroves">0.112</rate>
    <includeally>1</includeally>
    <includeenemy>1</includeenemy>
    <persistent>1</persistent>
    <modifytype>Speed</modifytype>
    <modifybase>1.0</modifybase>
    <modifyratecap>1.112</modifyratecap>
    <modelattachment>effects\ypack_auras\malta_power.xml</modelattachment>
    <modelattachmentbone>bonethatdoesntexist</modelattachmentbone>
  </action>
 </tacticsmods>

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.

<action>
    <name stringid="110152">IncreaseSpeedWithEnemyUnits</name>
    <type>LikeBonus</type>
    <active>1</active>
    <targetenemy>1</targetenemy>
    <modifyratebytype>1</modifyratebytype>
    <modifyabstracttype>Military</modifyabstracttype>
    <maxrange>32</maxrange>
    <rate type="Hero">0.2</rate>
    <rate type="LogicalTypeLandMilitary">0.02</rate>
    <persistent>1</persistent>
    <modifytype>Speed</modifytype>
    <modifybase>1.0</modifybase>
    <modifyratecap>5.0</modifyratecap>
  </action>

<tactic>Defend<action priority="75">BuildingAttack</action>
		<action priority="100">RangedAttack</action>
		<action priority="90">HandAttack</action>
		<action>IncreaseSpeedWithEnemyUnits</action>
		<attacktype>LogicalTypeRangedUnitsAttack</attacktype>
		<autoattacktype>LogicalTypeRangedUnitsAutoAttack</autoattacktype>
		<attackresponsetype>LogicalTypeRangedUnitsAttack</attackresponsetype>
		<runaway>1</runaway>
		<autoretarget>1</autoretarget>
		<idleanim>Idle</idleanim>
		<boredanim>Bored</boredanim>
		<deathanim>Death_by_melee</deathanim>
		<walkanim>Walk</walkanim>
		<joganim>Jog</joganim>
		<runanim>Run</runanim>
	</tactic>
2 Likes

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.