- Joined
- May 14, 2018
- Messages
- 27
Intro
I was recently trying to build a map with "improved resource gathering" upgrades. This is very simple for Human and Orc (based off the Human "Improved Lumber Harvesting" upgrade), and semi-simple for Night Elf (the upgrade has to use a separate effect called "Gold harvesting bonus (Entangled)", or something close to that). However, it is ridiculously hard to implement for Undead. Hence, this tutorial will help explain why, and guide you through correct implementation of an effective Undead "Gold gathering upgrade".
Credits
To start with, I had found this sample map posted by Jampion: post. It worked fairly well; however, the trigger structure was a bit convoluted and confusing (especially the part where he sets a Unit-Group variable to "all units in playable map area" and then subsequently empties it). So I spent some time reverse-engineering it and refactoring it to make it A) more understandable, and B) much cleaner. The main problem with it, as I discovered, was the use of a nested "Pick every unit" loop, i.e. one inside another -- the references to "Picked Unit" inside the inner loop would not always refer to the correct unit.
Another helpful tip came from this thread (@ thehelper.net, not here, fair warning), where they posed the idea of using begins-construction & finishes-construction events to toggle a switch-value for a given building so that it could be checked by another trigger, e.g. so I could detect if it was still under construction or not.
Now, let's get into it.
What You Need
TL;DR
If you truly want to "just get going" and start playing around with the sample map and triggers, download them! You can choose between the full WCX, or just the triggers.zip file, which contains the WCT & WTG dump of the triggers, which you can import into any map using the Trigger Editor's "file \ import triggers" menu option.
A Quick Recap
If you're keeping things balanced, your other races will also have "resource gathering upgrades"; and as I said, it's quite simple for Human, Orc, and Night Elf. Use the Human "Improved Lumber Harvesting" (image 'R1') upgrade as a base. Copy and paste. Change the "Race" property, the requirements, names and tooltips. A few examples are shown at the end (not to detract from the main point of this guide). 'R2' shows the Human Gold Mining upgrade; as you can see, I just changed the "Data- Effect 1" to "Gold Harvest Bonus", and edited all the other stuff appropriately. 'R3' shows the Night Elf gold upgrade, in which I've circled the different Effect that you need to pick - "Gold Harvest Bonus (Entangle)".
Finally, the key thing you need to do to ensure this works, is to add the Upgrade to the Unit which will use it! In Human & Orcs, that's the Peasant or Peon. For Undead lumber, that's Ghoul (for Undead Gold, it's complicated, and that's hopefully why you're reading this tutorial!). For Night Elf, the Wisp gets the "improved lumber" upgrade, BUT the "improved gold harvesting (entangle)" upgrade goes on the Entangled Gold Mine building! See? Little tricksy, not bad. With that out of the way, we can move on to the main point of this tutorial!
Starting with Objects
First, we'll need a new Custom Ability, based on the Undead "Blighted Gold Mine Ability". This is an ability that the Haunted Gold Mine (hereafter abbreviated as 'HGM') has, which has no UI (no icon or displayed text or tooltip), but which contains the data that governs the Acolytes' gold-gathering mechanics. See "Step 1" image. Note that you can (in theory) change other properties like "Max # of miners" and "Interval duration", but for simplicity, we're just going to double the "Gold per Interval", i.e. the 'gather rate', to 20.
Second, we need to create a new Custom Unit, based on the Undead "Haunted Gold Mine". Moar copy-pasta! Let's name the new unit "Haunted Gold Mine 2", to keep it simple. We edit its "Abilities - Normal" field to remove the default "Blighted Gold Mine Ability", and add our new one, "Blighted Gold Mine Ability 2". See "Step 2" image. Make sure to set its "Techtree - Requirements" to require the
Third, we'll add this new building to the "Structures Built" field for our Acolyte. See "Step 3". While this technically exceeds the available build-slots for a builder unit (you can only have up to 11 visible on the command-card), it doesn't matter because A) it's in the same spot as the default HGM, which overrides it, and B) it won't be available to build until the upgrade is researched (which we'll get to in Step 5).
Fourth, we finally get to create our new Custom Upgrade! Here, we copy-paste from the Orc "Berserker Upgrade" upgrade. See "Step 4" image. We use this one because it's a built-in "unit swapper" upgrade, i.e. it replaces all existing units of one type with another type, while also making the first type "UNavailable" (to build/train) and the second "Available".
Fifth, just to be thorough, we go back to the HGM2 building and make it "require" this upgrade in its "Techtree - Requirements" field. See "Step 5" image. In practice, this is not 100% required, but it makes things easier for the game to understand and helps keep our build-tree normal.
Step '5b', we have to actually assign the upgrade-research as an "Available Research" to a building where we want to research it from! The sample map puts it under the Necropolis, but this screenshot shows adding it to the Graveyard, since that's probably more appropriate. You can decide!
And Now the Hard Part: Triggers!
They're not really hard, just a little convoluted. The reasons behind this are complex, partially having to do with how Blizzard implemented the UD gold mine mechanics (and gold mines in general), and partially because we want to make the upgrade as seamless as possible to the user -- i.e. the player shouldn't need to know or be aware of how the unit-swapping and gold-gathering-rates are being done behind-the-scenes, nor should they have to worry about re-assigning their currently harvesting Acolytes to re-start harvesting on the new HGM2's! It should all "just work", like magic. And that's why you're here, because I spent over 12 hours futzing with and play-testing these triggers to make sure I covered as many use-cases and scenarios as I could!
In Step 6a, I set up my new trigger folder, some notes at the top of an empty trigger to provide some background and "issues". And in Step 6b, I create my variables -- probably the most important step.
Briefly, the purpose of each is as follows:
Now we get to real gory details of this operation. Step 7 is the "Research" trigger, which fires after the new "Gold Mine Upgrade" upgrade is done.. (OR after a new HGM is constructed, if it was not finished by the time the upgrade was done -- but we'll get to that later). I have provided copious notes about what it does and why, including some explanation of why things seem a little strange but are necessary for it to work out. If you aren't sure of how to find any particular Trigger Action in the menus, use the "search" feature, or just ask.
There are two main loops here, the "For each Unit of type HGM", aka the "HGM finder loop", and then the "For each Integer A" loop, aka the "Unit finder loop". As stated in the notes, we first have to find all existing HGM's for the player, and set some variables to store their positions and properties. Once that's all done, we proceed to set up the Unit-groups. We have "Nearby Units" (all non-structure units within 300 points of the HGM), which we have to HIDE so that they're not "in the way" when we go to create the new HGM2's later (i.e. they can't block placement of the new building). And of course we have "Active Miners", which we want to hide too, but also, we want to re-issue their "Harvest" orders once the new HGM2 is in-place.
Step 8 shows the "Replace" trigger, which is fired after the "Research" trigger finishes and sets off 'TimerZero'. Here, we are looping through the previously determined set of HGM's (which, having been removed, now just have a standard Gold Mine in their place on the map), and replacing them with HGM2's with the appropriate life/gold-amount. Then, we UN-hide all the units that were hidden before. And finally, we re-issue the "Harvest" order to all previously detected harvesting Acolytes for the HGM (now HGM2!).
With me so far? Don't worry, it's almost over!
Step 9 is more of a convenience than anything else. Because when you right-click to order a Unit to do something (its default action against whatever target that is), it's called a "Smart" order. But remember back in Step 7 where we had that disabled "Or" condition-block in the middle of our "unit-hiding loop"? This trigger makes it so we don't have to worry about that. Alternatively, we could remove this trigger and go back and enable that "Or" block instead, while also disabling/removing the single condition just above it ("Current order of picked unit equal to order(harvest)"). But I digress.
The whole reason we do this is so that very first "If" condition in our big "HGM finder loop" can be checked -- we only want to find (and thus replace) HGM's if they're fully constructed.
--------------------------------------------------
Phew! You did it, congratulations. You can now go forth and make your very own map with an Undead gold-harvesting-bonus upgrade, just like all the other races. Speaking of, here are the "recap" pics of sample upgrades for Human & Night Elf. As stated before, Orc would be same as Human for both kinds.
Thanks again to all the folks here at HiveWorkshop and elsewhere whose ideas and posts from the past helped me fully and completely understand how to get this working and how to explain it in plain English. GL HF!
I was recently trying to build a map with "improved resource gathering" upgrades. This is very simple for Human and Orc (based off the Human "Improved Lumber Harvesting" upgrade), and semi-simple for Night Elf (the upgrade has to use a separate effect called "Gold harvesting bonus (Entangled)", or something close to that). However, it is ridiculously hard to implement for Undead. Hence, this tutorial will help explain why, and guide you through correct implementation of an effective Undead "Gold gathering upgrade".
Credits
To start with, I had found this sample map posted by Jampion: post. It worked fairly well; however, the trigger structure was a bit convoluted and confusing (especially the part where he sets a Unit-Group variable to "all units in playable map area" and then subsequently empties it). So I spent some time reverse-engineering it and refactoring it to make it A) more understandable, and B) much cleaner. The main problem with it, as I discovered, was the use of a nested "Pick every unit" loop, i.e. one inside another -- the references to "Picked Unit" inside the inner loop would not always refer to the correct unit.
Another helpful tip came from this thread (@ thehelper.net, not here, fair warning), where they posed the idea of using begins-construction & finishes-construction events to toggle a switch-value for a given building so that it could be checked by another trigger, e.g. so I could detect if it was still under construction or not.
Now, let's get into it.
What You Need
- World Editor (duh)
- Familiarity with Object Editor and Trigger Editor.
TL;DR
If you truly want to "just get going" and start playing around with the sample map and triggers, download them! You can choose between the full WCX, or just the triggers.zip file, which contains the WCT & WTG dump of the triggers, which you can import into any map using the Trigger Editor's "file \ import triggers" menu option.
A Quick Recap
If you're keeping things balanced, your other races will also have "resource gathering upgrades"; and as I said, it's quite simple for Human, Orc, and Night Elf. Use the Human "Improved Lumber Harvesting" (image 'R1') upgrade as a base. Copy and paste. Change the "Race" property, the requirements, names and tooltips. A few examples are shown at the end (not to detract from the main point of this guide). 'R2' shows the Human Gold Mining upgrade; as you can see, I just changed the "Data- Effect 1" to "Gold Harvest Bonus", and edited all the other stuff appropriately. 'R3' shows the Night Elf gold upgrade, in which I've circled the different Effect that you need to pick - "Gold Harvest Bonus (Entangle)".
Finally, the key thing you need to do to ensure this works, is to add the Upgrade to the Unit which will use it! In Human & Orcs, that's the Peasant or Peon. For Undead lumber, that's Ghoul (for Undead Gold, it's complicated, and that's hopefully why you're reading this tutorial!). For Night Elf, the Wisp gets the "improved lumber" upgrade, BUT the "improved gold harvesting (entangle)" upgrade goes on the Entangled Gold Mine building! See? Little tricksy, not bad. With that out of the way, we can move on to the main point of this tutorial!
Starting with Objects
First, we'll need a new Custom Ability, based on the Undead "Blighted Gold Mine Ability". This is an ability that the Haunted Gold Mine (hereafter abbreviated as 'HGM') has, which has no UI (no icon or displayed text or tooltip), but which contains the data that governs the Acolytes' gold-gathering mechanics. See "Step 1" image. Note that you can (in theory) change other properties like "Max # of miners" and "Interval duration", but for simplicity, we're just going to double the "Gold per Interval", i.e. the 'gather rate', to 20.
Second, we need to create a new Custom Unit, based on the Undead "Haunted Gold Mine". Moar copy-pasta! Let's name the new unit "Haunted Gold Mine 2", to keep it simple. We edit its "Abilities - Normal" field to remove the default "Blighted Gold Mine Ability", and add our new one, "Blighted Gold Mine Ability 2". See "Step 2" image. Make sure to set its "Techtree - Requirements" to require the
Third, we'll add this new building to the "Structures Built" field for our Acolyte. See "Step 3". While this technically exceeds the available build-slots for a builder unit (you can only have up to 11 visible on the command-card), it doesn't matter because A) it's in the same spot as the default HGM, which overrides it, and B) it won't be available to build until the upgrade is researched (which we'll get to in Step 5).
Fourth, we finally get to create our new Custom Upgrade! Here, we copy-paste from the Orc "Berserker Upgrade" upgrade. See "Step 4" image. We use this one because it's a built-in "unit swapper" upgrade, i.e. it replaces all existing units of one type with another type, while also making the first type "UNavailable" (to build/train) and the second "Available".
Fifth, just to be thorough, we go back to the HGM2 building and make it "require" this upgrade in its "Techtree - Requirements" field. See "Step 5" image. In practice, this is not 100% required, but it makes things easier for the game to understand and helps keep our build-tree normal.
Step '5b', we have to actually assign the upgrade-research as an "Available Research" to a building where we want to research it from! The sample map puts it under the Necropolis, but this screenshot shows adding it to the Graveyard, since that's probably more appropriate. You can decide!
And Now the Hard Part: Triggers!
They're not really hard, just a little convoluted. The reasons behind this are complex, partially having to do with how Blizzard implemented the UD gold mine mechanics (and gold mines in general), and partially because we want to make the upgrade as seamless as possible to the user -- i.e. the player shouldn't need to know or be aware of how the unit-swapping and gold-gathering-rates are being done behind-the-scenes, nor should they have to worry about re-assigning their currently harvesting Acolytes to re-start harvesting on the new HGM2's! It should all "just work", like magic. And that's why you're here, because I spent over 12 hours futzing with and play-testing these triggers to make sure I covered as many use-cases and scenarios as I could!
In Step 6a, I set up my new trigger folder, some notes at the top of an empty trigger to provide some background and "issues". And in Step 6b, I create my variables -- probably the most important step.
Briefly, the purpose of each is as follows:
- HGM_Counter, integer: keep track of the # of HGM's found for a player during a Research-finished or Construction-finished event run (the Research trigger).
- Replace_Loop, integer: keep track of the HGM's replaced by HGM2's during the Replace trigger.
- HGM_Owner, Player array: keep track of player ownership of HGM's.
- TempPosition, point: current position of the HGM/GoldMine being replaced inside the Replace loop.
- HGM_Position, point array: all HGM positions found during the Research loop.
- HGM_Life, real array: hit-points for each HGM found during the Research loop.
- TimerZero, timer: used to signal the end of the Research trigger and fire the Replace trigger.
- TempGoldMine, unit: the currently-being-replaced Gold Mine in the Replace loop.
- HauntedMines, unit array: all HGM2's created during the Replace loop.
- Grp_ActiveMiners, unit group array: for each HGM, a group of its surrounding actively-mining Acolytes.
- Grp_NearbyUnits, unit group array: for each HGM, a group of all nearby units (not structures).
Now we get to real gory details of this operation. Step 7 is the "Research" trigger, which fires after the new "Gold Mine Upgrade" upgrade is done.. (OR after a new HGM is constructed, if it was not finished by the time the upgrade was done -- but we'll get to that later). I have provided copious notes about what it does and why, including some explanation of why things seem a little strange but are necessary for it to work out. If you aren't sure of how to find any particular Trigger Action in the menus, use the "search" feature, or just ask.
There are two main loops here, the "For each Unit of type HGM", aka the "HGM finder loop", and then the "For each Integer A" loop, aka the "Unit finder loop". As stated in the notes, we first have to find all existing HGM's for the player, and set some variables to store their positions and properties. Once that's all done, we proceed to set up the Unit-groups. We have "Nearby Units" (all non-structure units within 300 points of the HGM), which we have to HIDE so that they're not "in the way" when we go to create the new HGM2's later (i.e. they can't block placement of the new building). And of course we have "Active Miners", which we want to hide too, but also, we want to re-issue their "Harvest" orders once the new HGM2 is in-place.
Step 8 shows the "Replace" trigger, which is fired after the "Research" trigger finishes and sets off 'TimerZero'. Here, we are looping through the previously determined set of HGM's (which, having been removed, now just have a standard Gold Mine in their place on the map), and replacing them with HGM2's with the appropriate life/gold-amount. Then, we UN-hide all the units that were hidden before. And finally, we re-issue the "Harvest" order to all previously detected harvesting Acolytes for the HGM (now HGM2!).
With me so far? Don't worry, it's almost over!
Step 9 is more of a convenience than anything else. Because when you right-click to order a Unit to do something (its default action against whatever target that is), it's called a "Smart" order. But remember back in Step 7 where we had that disabled "Or" condition-block in the middle of our "unit-hiding loop"? This trigger makes it so we don't have to worry about that. Alternatively, we could remove this trigger and go back and enable that "Or" block instead, while also disabling/removing the single condition just above it ("Current order of picked unit equal to order(harvest)"). But I digress.
Step 10 a/b are a pair of triggers that fixe the "bug" in the original wherein, if an HGM is under construction and the Gold Mine Upgrade is researched before said HGM is finished, it gets replaced with a full-on HGM2 instantly, instead of having to wait for construction to finish. Here, we use the unit's "Custom Value" (which is an Integer) -- we set it to '1' if it's under construction, and only when it finishes do we set it back to '0'. (It's actually un-initialized, by default, so it's neither 0 nor 1 nor any other number, on a unit that it's never touched for, but I digress. Again.)
The whole reason we do this is so that very first "If" condition in our big "HGM finder loop" can be checked -- we only want to find (and thus replace) HGM's if they're fully constructed.
--------------------------------------------------
Phew! You did it, congratulations. You can now go forth and make your very own map with an Undead gold-harvesting-bonus upgrade, just like all the other races. Speaking of, here are the "recap" pics of sample upgrades for Human & Night Elf. As stated before, Orc would be same as Human for both kinds.
Thanks again to all the folks here at HiveWorkshop and elsewhere whose ideas and posts from the past helped me fully and completely understand how to get this working and how to explain it in plain English. GL HF!
Attachments
Last edited: