• 🏆 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!

[Solved] Setting Gold of a Custom Haunted Gold Mine via trigger? (1.28)

Status
Not open for further replies.
Level 10
Joined
May 31, 2019
Messages
139
Here I've made a custom 'Haunted' Gold Mine for the Zerg race.

It works pretty well, but it doesn't currently respect the amount of gold in the mine that it is built over, it just gets the max gold value in the Gold Mine ability.

I've worked out a system that I feel should do the job. At the start of the game, there's a dummy counter unit created on each gold mine, and periodically its life is updated to match the gold of its associated gold mine.

Then, when a Zerg Gold Extractor finishes construction, its gold is to be set to the value held by the dummy unit.

  • StarCraft Mine Finish
    • Events
      • Unit - A unit Finishes construction
    • Conditions
      • (Unit-type of (Constructed structure)) Equal to Zerg Extractor (Gold Mine)
    • Actions
      • Set tmpUnitHandle = (Triggering unit)
      • Set tmpPoint = (Position of tmpUnitHandle)
      • Custom script: set bj_wantDestroyGroup = true
      • Unit Group - Pick every unit in (Units within 256.00 of tmpPoint matching ((Unit-type of (Matching unit)) Equal to Gold Accountant (Dummy))) and do (Actions)
        • Loop - Actions
          • Set tmpInt = (Integer((Life of (Picked unit))))
          • Game - Display to (All players) the text: (Gold Accountant Found with value + (String(tmpInt)))
          • Neutral Building - Set tmpUnitHandle to tmpInt gold
      • Custom script: call RemoveLocation(udg_tmpPoint)

I couldn't figure out why the custom mine was still not getting set to the correct gold amount, so I tried replacing the mine with a non-custom Haunted Gold Mine.
This time, setting the gold actually worked!

  • -------- Testing Haunted Gold mine to see if gold can be set to it via trigger --------
  • Unit - Replace tmpUnitHandle with a Haunted Gold Mine using The old unit's relative life and mana
  • Neutral Building - Set (Last replaced unit) to tmpInt gold

So the issue seems to be that the Set Resources action (and its JASS native version) is hard-coded to only work with standard war3 mines. Is there any way around this restriction? I do not want to modify the Haunted Gold Mine, as it's important that the Undead be able to co-exist with the Zerg on the same map.

EDIT: It seems I was mistaken. Now I have it working by storing the desired gold amount before construction is finished, and then setting it once construction is finished. The dummy was getting updated the moment construction finished, which by default made it have the gold mine ability's Max Gold value.

So now I have two triggers, and it appears to all be working correctly.

  • StarCraft Mine Begin
    • Events
      • Unit - A unit Begins construction
    • Conditions
      • Or - Any (Conditions) are true
        • Conditions
          • (Unit-type of (Triggering unit)) Equal to Zerg Extractor (Gold Mine)
    • Actions
      • Set tmpPoint = (Position of (Triggering unit))
      • Custom script: set bj_wantDestroyGroup = true
      • Unit Group - Pick every unit in (Units within 256.00 of tmpPoint matching ((Unit-type of (Matching unit)) Equal to Gold Accountant (Dummy))) and do (Actions)
        • Loop - Actions
          • Game - Display to (All players) the text: (Gold Accountant Found with value + (String((Life of (Picked unit)))))
          • Unit - Set the custom value of (Picked unit) to (Integer((Life of (Picked unit))))
      • Custom script: call RemoveLocation(udg_tmpPoint)
  • StarCraft Mine Finish
    • Events
      • Unit - A unit Finishes construction
    • Conditions
      • Or - Any (Conditions) are true
        • Conditions
          • (Unit-type of (Constructed structure)) Equal to Zerg Extractor (Gold Mine)
    • Actions
      • Set tmpUnitHandle = (Triggering unit)
      • Set tmpPoint = (Position of tmpUnitHandle)
      • Custom script: set bj_wantDestroyGroup = true
      • Unit Group - Pick every unit in (Units within 256.00 of tmpPoint matching ((Unit-type of (Matching unit)) Equal to Gold Accountant (Dummy))) and do (Actions)
        • Loop - Actions
          • Set tmpInt = (Custom value of (Picked unit))
          • Custom script: call SetResourceAmount(udg_tmpUnitHandle, udg_tmpInt)
      • Custom script: call RemoveLocation(udg_tmpPoint)
 
Last edited:
Status
Not open for further replies.
Top