• 🏆 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!
  • 🏆 Hive's 6th HD Modeling Contest: Mechanical is now open! Design and model a mechanical creature, mechanized animal, a futuristic robotic being, or anything else your imagination can tinker with! 📅 Submissions close on June 30, 2024. Don't miss this opportunity to let your creativity shine! Enter now and show us your mechanical masterpiece! 🔗 Click here to enter!

Bug with Item Permanent Damage Gain and Heroes that Metamorphize/Change Form

Level 4
Joined
Jan 6, 2008
Messages
73
Howdy folks. I'm working on a Warchasers-style dungeon crawling map, and I've been experiencing a bug with one of my types of tomes, Tomes of Prowess, which use the "Item Permanent Damage Gain" (ALAA) ability.

When a Hero picks up a tome of prowess, they gain 2 base damage.

However, if they are a hero with an ability that changes form between one unit and another (e.g. Metamorphosis, Burrow, Chemical Rage, Bear Form, etc), the unit that transforms loses any damage they gained from this type of tome. As near as I can tell this is the only type of tome that this bug occurs with, as all attribute tomes work normally, along with Manuals of Health.

Is there a way I can ensure that units with transforming abilities can keep their permanent damage bonus?
 

Uncle

Warcraft Moderator
Level 65
Joined
Aug 10, 2018
Messages
6,640
How are you adding the 2 base damage? Because there isn't any ability that would add +2 permanent base damage as far as I'm aware.

Edit: Okay, I found it, didn't realize that was a thing, I assumed you were talking about +2 green damage (non-base).

One solution would be to track the number of times the Hero acquires these tomes so that you can subtract the damage upon morphing. On version 1.31+ you can modify a unit's base damage via triggers so it wouldn't be too difficult to manage. In fact, you could trigger all of the damage yourself.

On older versions, you could create and give X "negative" versions of the Tomes to the morphed Hero which subtract 2 base damage.
 
Last edited:

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,217
On older versions, you could create and give X "negative" versions of the Tomes to the morphed Hero which subtract 2 base damage.
It is my understanding that the issue is that the morphed hero loses the damage automatically due to the morphing process. They want it to keep the bonus damage. As such it would be a similar idea but re-applying the damage at the time they lose it, such as when they change form.

Be aware that consumed on pickup "powerup" items die rather than be removed like a when a regular item has all charges consumed. This means that regular TFT tomes leak items when picked up. You need triggers to explicitly remove the tome item after it is picked up and use. This applies to TFT style tomes and powerup runes, but not do RoC style tomes which are charged items used in a unit's inventory.
 

Uncle

Warcraft Moderator
Level 65
Joined
Aug 10, 2018
Messages
6,640
It is my understanding that the issue is that the morphed hero loses the damage automatically due to the morphing process. They want it to keep the bonus damage. As such it would be a similar idea but re-applying the damage at the time they lose it, such as when they change form.

Be aware that consumed on pickup "powerup" items die rather than be removed like a when a regular item has all charges consumed. This means that regular TFT tomes leak items when picked up. You need triggers to explicitly remove the tome item after it is picked up and use. This applies to TFT style tomes and powerup runes, but not do RoC style tomes which are charged items used in a unit's inventory.
Yeah, late night post, what I wanted to say was that you can add both positive/negative tomes to the units as a solution on older versions. I have a feeling that when the unit morphs back to normal it will need to have it's stats reduced with negative tomes but that may not be the case. Depends if the normal form will retain both the original tomes + morphed tomes.
 
Level 4
Joined
Jan 6, 2008
Messages
73
One solution would be to track the number of times the Hero acquires these tomes so that you can subtract the damage upon morphing. On version 1.31+ you can modify a unit's base damage via triggers so it wouldn't be too difficult to manage. In fact, you could trigger all of the damage yourself.
As such it would be a similar idea but re-applying the damage at the time they lose it, such as when they change form.
This was my thought, but I haven't been able to successfully apply the tomes via triggers. I figured that if I used either "Unit starts the effect of an ability" or "Unit finishes casting an ability" and listed all the morph abilities in question, that would work, but so far I haven't been able to get it to function properly.
 

Uncle

Warcraft Moderator
Level 65
Joined
Aug 10, 2018
Messages
6,640
This was my thought, but I haven't been able to successfully apply the tomes via triggers. I figured that if I used either "Unit starts the effect of an ability" or "Unit finishes casting an ability" and listed all the morph abilities in question, that would work, but so far I haven't been able to get it to function properly.
That narrows the Events down to Uses An Item or Acquires An Item. One of them will work.
 
Level 4
Joined
Jan 6, 2008
Messages
73
That narrows the Events down to Uses An Item or Acquires An Item. One of them will work.
I'm not sure what you mean by this as I don't see how a unit acquiring an item would fix this issue. When the unit transforms into another Hero, the stats they would have gained from any damage tomes disappears, so shouldn't the fix relate to the transformation somehow, not the acquisition of the tome?
 

Uncle

Warcraft Moderator
Level 65
Joined
Aug 10, 2018
Messages
6,640
I'm not sure what you mean by this as I don't see how a unit acquiring an item would fix this issue. When the unit transforms into another Hero, the stats they would have gained from any damage tomes disappears, so shouldn't the fix relate to the transformation somehow, not the acquisition of the tome?
I thought you were saying that you couldn't detect when a tome was used.

The solution I suggested was to detect whenever a tome is used and keep track of the bonuses in variables, this way when the unit finally morphs into it's alternate form you can re-apply the tomes based on this information.

Here's the idea:
  • Track Tome Bonus Damage
    • Events
      • Unit - A unit Acquires an item
    • Conditions
      • (Item-type of (Item being manipulated)) Equal to Tome of Prowess
    • Actions
      • Set Variable PN = (Player number of (Owner of (Triggering unit)))
      • Set Variable Player_Prowess_Count[PN] = (Player_Prowess_Count[PN] + 1)
^ Have an Integer array variable for tracking each Player's total number of Prowess Tomes used. This assumes that each Player only has one Hero that can use these Tomes.

Then upon morphing, which needs to be handled with special care, re-apply the tomes using the aforementioned variable:
  • Bear Form Is Used
    • Events
      • Unit - A unit Is issued an order with no target
    • Conditions
      • (Issued order) Equal to (Order(bearform))
    • Actions
      • Wait 0.20 seconds of game-time
      • Trigger - Turn off Track Tome Bonus Damage <gen>
      • Set Variable PN = (Player number of (Owner of (Triggering unit))
      • For each integer (Integer A) from 1 to Player_Prowess_Count[PN] do (Actions)
        • Loop - Actions
          • Item - Create Tome of Prowess and give it to (Triggering unit)
      • Trigger - Turn on Track Tome Bonus Damage <gen>
So you'd need a trigger for each of your different types of Morphing abilities.

You may need to add an extra Condition to check the specific type of unit that is morphing:
  • (Unit-type of (Triggering unit)) Equal to Druid of the Claw (Normal Form)
Also, you may need to adjust the duration of the Wait to give the unit enough time to morph. There are various threads regarding how to properly detect morph abilities that you can reference to get it working. Notably, Bribe's GUI Unit Event system has an Event for detecting when a unit morphs which does most of the hard work for you. It has the added bonus of coming with a Unit Indexer system which would allow you to track Tomes on a per-Hero basis (if that is needed).
 
Last edited:
Level 4
Joined
Jan 6, 2008
Messages
73
I thought you were saying that you couldn't detect when a tome was used.

The solution I suggested was to detect whenever a tome is used and keep track of the bonuses in variables, this way when the unit finally morphs into it's alternate form you can re-apply the tomes based on this information.

Here's the idea:
  • Track Tome Bonus Damage
    • Events
      • Unit - A unit Acquires an item
    • Conditions
      • (Item-type of (Item being manipulated)) Equal to Tome of Prowess
    • Actions
      • Set Variable PN = (Player number of (Owner of (Triggering unit)))
      • Set Variable Player_Prowess_Count[PN] = (Player_Prowess_Count[PN] + 1)
^ Have an Integer array variable for tracking each Player's total number of Prowess Tomes used. This assumes that each Player only has one Hero that can use these Tomes.

Then upon morphing, which needs to be handled with special care, re-apply the tomes using the aforementioned variable:
  • Bear Form Is Used
    • Events
      • Unit - A unit Is issued an order with no target
    • Conditions
      • (Issued order) Equal to (Order(bearform))
    • Actions
      • Wait 0.20 seconds of game-time
      • Trigger - Turn off Track Tome Bonus Damage <gen>
      • Set Variable PN = (Player number of (Owner of (Triggering unit))
      • For each integer (Integer A) from 1 to Player_Prowess_Count[PN] do (Actions)
        • Loop - Actions
          • Item - Create Tome of Prowess and give it to (Triggering unit)
      • Trigger - Turn on Track Tome Bonus Damage <gen>
So you'd need a trigger for each of your different types of Morphing abilities.

You may need to add an extra Condition to check the specific type of unit that is morphing:
  • (Unit-type of (Triggering unit)) Equal to Druid of the Claw (Normal Form)
Also, you may need to adjust the duration of the Wait to give the unit enough time to morph. There are various threads regarding how to properly detect morph abilities that you can reference to get it working. Notably, Bribe's GUI Unit Event system has an Event for detecting when a unit morphs which does most of the hard work for you. It has the added bonus of coming with a Unit Indexer system which would allow you to track Tomes on a per-Hero basis (if that is needed).

All of this is very helpful, thank you. I appreciate your help

I will probably need to use the GUI unit event system, as it does matter on a per-Hero basis as to who has these tomes in some specific circumstances (normally, one player controls one Hero, however in One-player mode, they control 4 heroes, and in two-player mode each player controls two heroes.) With that said, I don't actually know how to implement said Unit Indexer system, any insight?
 
Random question that might be totally unhelpful:

Does the "UnitMakeAbilityPermanent" native apply in this case, wherein you could have a trigger that when a unit collects the tome, make the Item Permanent Damage Gain ability flagged as permanent so it wouldnt go away upon morphing?

It's possible that this idea doesn't work and doesn't help, but i was curious if you had tried

Edit: As in, I wrote this in passing, without testing for myself

Edit 2: after i said it, I tested it and it doesn't work. I suppose this is logical, as the ability is most likely lost upon consumption of the tome
 
Last edited:

Uncle

Warcraft Moderator
Level 65
Joined
Aug 10, 2018
Messages
6,640
All of this is very helpful, thank you. I appreciate your help

I will probably need to use the GUI unit event system, as it does matter on a per-Hero basis as to who has these tomes in some specific circumstances (normally, one player controls one Hero, however in One-player mode, they control 4 heroes, and in two-player mode each player controls two heroes.) With that said, I don't actually know how to implement said Unit Indexer system, any insight?
So after looking into it, GUI Unit Event comes with a Unit Indexer built into it, so you really only need this "one system".

All you have to do is copy and paste the Unit Event folder into your map.
copysystem.png

After that, the system will automatically run in the background when your game starts.

Two important rules:
1) This system won't become fully active until AFTER Map Initialization, but there's a good chance that you don't have to worry about that.
2) You must never use this Action yourself:
  • Unit - Set the custom value of (Triggering unit) to 0
^ The Unit Indexer assigns custom values to units automatically, if you adjust it yourself you will break the system.


The next step is to learn how to use the Unit Indexer and GUI Unit Event system. Fortunately, both of these systems have demo maps, extensive documentation, and a million examples on Hive. But I'll give you a demonstration pertaining to the triggers I posted earlier:
  • Track Tome Bonus Damage NEW
    • Events
      • Unit - A unit Acquires an item
    • Conditions
      • (Item-type of (Item being manipulated)) Equal to Tome of Prowess
    • Actions
      • Set Variable CV = (Custom value of (Triggering unit))
      • Set Variable Hero_Prowess_Count[CV] = (Hero_Prowess_Count[CV] + 1)
  • Bear Form Is Used NEW
    • Events
      • Unit - A unit Is issued an order with no target
    • Conditions
      • (Issued order) Equal to (Order(bearform))
    • Actions
      • Wait 0.20 seconds of game-time
      • Trigger - Turn off Track Tome Bonus Damage <gen>
      • Set Variable CV = (Custom value of (Triggering unit))
      • For each integer (Integer A) from 1 to Hero_Prowess_Count[CV] do (Actions)
        • Loop - Actions
          • Item - Create Tome of Prowess and give it to (Triggering unit)
      • Trigger - Turn on Track Tome Bonus Damage <gen>
These two triggers have been modified to use the Unit Indexer instead of relying on the Player Number. This allows us to save data directly to our Unit whenever it uses a tome as well as load that saved data whenever it morphs. Notice how this method relies on the unit's Custom Value as the [index] in our Array. This is a unique Integer value that the Unit Indexer assigns to each Unit upon creation. The system is basically giving each of our Units their own unique ID number.

This is similar to how each Player has their own unique Player Number (Red = 1, Blue = 2, Teal = 3). This system simply expands that concept to Units by giving each of them their own unique number in the form of a Custom Value. So by taking advantage of this you can use Array variables to attach data to a specific Unit or Player by using their (custom value) or (player number) as the [index] in your Array.


Then by using the GUI Unit Event system we can replace the above Bear Form Is Used trigger with this:
  • On Transform
    • Events
      • Game - UnitTypeEvent becomes Equal to 1.00
    • Conditions
    • Actions
      • Trigger - Turn off Track Tome Bonus Damage <gen>
      • For each integer (Integer A) from 1 to Hero_Prowess_Count[UDex] do (Actions)
        • Loop - Actions
          • Item - Create Tome of Prowess and give it to UDexUnits[UDex]
      • Trigger - Turn on Track Tome Bonus Damage <gen>
This is a custom Event that runs whenever a unit is finished morphing/transforming. This removes the need for the inconsistent Wait action and the Condition from before. The UDex variables are a way for you to reference the Unit and it's Custom Value, think of them like a custom version of (Triggering unit).

Note that I never actually tested any of these triggers but I believe they will work, and if not, I believe they can be made to work with some slight tweaks.
 
Last edited:
Top