• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

(GUI) A unit finishes an upgrade

Status
Not open for further replies.
Level 7
Joined
Dec 9, 2014
Messages
92
In the 'A unit finishes an upgrade' event, Triggering Unit refers to the new upgraded unit. How do i refer to the old unit in this event? I need to get it's point value when the upgrade is finished.
 

Uncle

Warcraft Moderator
Level 73
Joined
Aug 10, 2018
Messages
7,918
I couldn't get the Upgrade Events to work properly either. For some reason Triggering Unit always refers to the newly upgraded unit.

Luckily, there is a workaround. Using Order events and a Unit Indexer you can easily keep track of the Point Value of the original unit. Make sure to add your specific string id's to the conditions, I use Order(keep) as an example of a Town Hall upgrading to a Keep.
  • Begin Upgrade
    • Events
      • Unit - A unit Is issued an order with no target
    • Conditions
      • (Issued order) Equal to (Order(keep))
    • Actions
      • Set CV = (Custom value of (Triggering unit))
      • Set UnitPointValue[CV] = (Point-value of (Triggering unit))
      • Game - Display to (All players) for 30.00 seconds the text: (String(UnitPointValue[CV]))
  • Finish Upgrade
    • Events
      • Unit - A unit Finishes an upgrade
    • Conditions
    • Actions
      • Set CV = (Custom value of (Triggering unit))
      • Set PointValue = UnitPointValue[CV]
      • Game - Display to (All players) for 30.00 seconds the text: (String(PointValue))
 

Attachments

  • Upgrade.w3x
    21.5 KB · Views: 36
When a unit upgrades, it is still the same unit as before. A new unit isn't created, the old unit simply has its type changed. You can do what you want by storing a unit's type whenever it enters the playable map area. When it upgrades, you have access to the old type, and then you can update it to the type it just upgrade to (for future upgrades).

You can't change the point value of a unit, so its point value will always be the point value of its type.

You could also save the type of a unit when the "unit begins an upgrade" event occurs.
 
Status
Not open for further replies.
Top