• 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.

How to get building being upgraded?

mdl

mdl

Level 3
Joined
Sep 19, 2024
Messages
12
I have a building that upgrades into another building but the Triggering Unit of the "begins an upgrade" event is the new building. How do i get the building that is being upgraded, not what it's being upgraded to?

Thank you, so very much :)
 

mdl

mdl

Level 3
Joined
Sep 19, 2024
Messages
12
If I understood correctly, this is one way to reference your desired type of building.
Not quite. I want to get a reference to the building that is currently being upgraded. For example: When I click upgrade to keep on a town hall I want to get a reference to the Town hall building type, not the keep unit or type
 
Level 45
Joined
Feb 27, 2007
Messages
5,578
You just don't have the full picture.

There is only one unit: the one that is being upgraded. At the moment you click on it to order it to upgrade the unit instantly changes its unit-type and begins the upgrade animation. If you check its unit-type it will change once the upgrade begins but never again (because it's already the new type). The unit itself never goes anywhere (it isn't literally replaced) so there is no other unit to refer to.

If you want to learn the unit-type the unit used to be before the upgrade, you will have to either detect the order the instant it is given or build a database (hashtable) to return parent buildings. The approaches differ so it's important to ask directly: why do you need to know this? When will this information be used? What are you trying to achieve? Perhaps there is a better or more straightforward way. The order might be the easiest method but I'm not certain it works because the upgrade orders are effectively instant.
 

mdl

mdl

Level 3
Joined
Sep 19, 2024
Messages
12
You just don't have the full picture.

There is only one unit: the one that is being upgraded. At the moment you click on it to order it to upgrade the unit instantly changes its unit-type and begins the upgrade animation. If you check its unit-type it will change once the upgrade begins but never again (because it's already the new type). The unit itself never goes anywhere (it isn't literally replaced) so there is no other unit to refer to.

If you want to learn the unit-type the unit used to be before the upgrade, you will have to either detect the order the instant it is given or build a database (hashtable) to return parent buildings. The approaches differ so it's important to ask directly: why do you need to know this? When will this information be used? What are you trying to achieve? Perhaps there is a better or more straightforward way. The order might be the easiest method but I'm not certain it works because the upgrade orders are effectively instant.
Hi. Thanks for responding.

I see. I figured that when the unit type changes its a new unit, I see now how I can solve my problem. I'll just store the unit and its type and then compare as the upgrade has begun.

The purpose was to track the unit count of each type.

Thanks!
 
Top