• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

[General] making unit attacks use different upgrades for each attack

Level 25
Joined
Sep 26, 2009
Messages
2,378
No, abilities do not use upgrades to modify its own data. Techs in abilities are used purely as a requirement (i.e. must have tech X of level Y to be able to use the ability).

One possible solution is to use ability levels:
  • Set Flak Cannons as 2 level ability. First level is the default, second level has extended range
  • Create new tech/upgrade, set the following fields like this:
    • Data - Effect N: Ability Level Bonus
    • Data - Effect N - Ability Affected: Flak Cannons
    • Data - Effect N - Ability Level Bonus - Base/Increment: Both to 1
  • Give this upgrade to Flying Machine unit
  • Create trigger that fires when any unit finishes researching Long Rifles. As action, just set level of your new tech for Flak Cannons to level 1
    • Tech Finished
      • Events
        • Unit - A unit Finishes research
      • Conditions
        • (Researched tech-type) Equal to Long Rifles
      • Actions
        • Player - Set the current research level of Long Rifles (Flak Cannon) to 1 for (Triggering player)
    • In this example, the 'Long Rifles (Flak Cannon)' is the tech that increases ability level of Flak Cannons
 
Ok, let me rephrase the issue a bit as it had not much to do with abilities.

Ogre mage uses melee attack against ground units. (attack 1)
also launches magic missiles against air units. (attack 2)
Its set to use Steel Melee Weapons, which upgrades both attacks.
The ranged attack is not supposed to get affected by the upgrade.
Aslong this upgrade is affecting the unit both attacks get upgraded.
The upgrade is supposed to affect only melee attack of the unit.

Is there any way this can be done ?
 
Level 25
Joined
Sep 26, 2009
Messages
2,378
What you want is not really possible.

First, it does not matter how an upgrade is called - for example Steel Melee Weapons is really just a name so that its easier to understand which units would benefit from it, but the upgrade itself applies the damage bonus to both Attack 1 and Attack 2.

Second, I tried to use trigger actions to modify unit's damage. My thought process was that while upgrade applies to both attacks, it could be possible to lower the damage of just one of the attacks back to its previous value, that way it would seem as if no upgrade was applied to that attack.
The action in question was added in Reforged:
  • Unit - Set Unit: your_unit's Weapon Integer Field: Attack Damage Number Of Dice ('ua1d')at Index:X to Value: Y
However it seems to be buggy. It increased unit's damage, but not by the amount I set. It also worked only for Attack 1. This "set" method seems to use one-based indexes, while its "get" counterpart uses zero-based indexes. Using jass to change the field ID from 'ua1d' to 'ua2d' did not work either :/

Even if the action worked, there would still be one confusing thing - The attack's icon in unit's UI in game has that small number in the corner that shows the level of upgrade that was applied to the attack. While the trigger action would change the damage amount, it would not change the number.
That could be confusing, since both attacks would for example have the number 3, but only one of the would have increased damage.

Third, the only option I found that increases damage of each attack "kind-of" separately is the Damage Upgrade Amount. Each attack in object editor specifies this value and by default those values are 0 (the field is Combat - Attack N - Damage Upgrade Amount).
You can create an upgrade with effect 'Apply Attack Upgrade Bonus'. Once researched, it will increase each attack's damage by the upgrade bonus.
There are few things of note:
  • This basically increases the 'Base Damage' of a unit, while standard upgrades increase 'Damage Number of Dice'.
    • For comparison, if you had unit with the following damage fields:
      • Damage Base: 28
      • Number of Dice: 2
      • Sides per Die: 5
    • then its actual damage would be 30-38
    • after increasing Number of Dice by 1 via upgrade like Steel Melee Weapons, its damage would be 31-43
    • while increasing its damage via Damage Upgrade Amount = 1 would change it to 31-39 damage
  • This upgrade does not display the upgrade level in unit's UI
  • You cannot have one such upgrade for attack 1 and another such upgrade for attack 2, since the upgrade itself does not choose which attacks to upgrade - it updates both. The only advantage is that you can set the upgrade amount for each attack in unit's object data
 
Top