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

How to check who controls a gold mine?

Status
Not open for further replies.
Level 12
Joined
Feb 5, 2018
Messages
521
  • Gold Mine ini
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Unit Group - Add Gold Mine 0000 <gen> to GoldmineEngland_UG

  • Control GoldMine
    • Events
      • Unit - A unit Is issued an order targeting an object
    • Conditions
      • (Issued order) Equal to (Order(harvest))
      • (Unit-type of (Target unit of issued order)) Equal to Gold Mine
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • ((Target unit of issued order) is in GoldmineEngland_UG.) Equal to True
        • Then - Actions
          • Game - Display to (All players) the text: (Parse ((Name of (Owner of (Triggering unit))) + ( owns + England!)))
        • Else - Actions
      • Trigger - Turn off (This trigger)

A quick draft like this, just tested in game. Works fine :)
 
Level 12
Joined
Nov 3, 2013
Messages
989
I didn't check, but in case the above suggestion can be abused (imagine if just having a worker and clicking harvest on a random gold mine on the map made it "yours"), you might have to first check which units are ordered to harvest, then check when they're ordered to return the resources, and that's when you would know that the player "owns" that gold mine since for the unit to have been ordered to both harvest and then return resources they must've come out of the goldmine.
 
Level 12
Joined
Feb 5, 2018
Messages
521
I didn't check, but in case the above suggestion can be abused (imagine if just having a worker and clicking harvest on a random gold mine on the map made it "yours"), you might have to first check which units are ordered to harvest, then check when they're ordered to return the resources, and that's when you would know that the player "owns" that gold mine since for the unit to have been ordered to both harvest and then return resources they must've come out of the goldmine.

You are propably right, thats why I wrote it was a quick draft, just to give direction.
 

Wrda

Spell Reviewer
Level 26
Joined
Nov 18, 2012
Messages
1,887
  • Claim
    • Events
      • Unit - A unit Is issued an order targeting an object
      • Unit - A unit Is issued an order targeting a point
      • Unit - A unit Is issued an order with no target
    • Conditions
      • (Issued order) Equal to (Order(resumeharvesting))
    • Actions
      • Game - Display to (All players) the text: ((Name of (Triggering player)) + GOLDMINE IS YOURS)
      • Unit Group - Pick every unit in (Units within 600.00 of (Position of (Triggering unit)).) and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Unit-type of (Picked unit)) Equal to Gold Mine
            • Then - Actions
              • -------- do stuff here --------
            • Else - Actions
Actually the resumeharversting order is an order with no target.
 
Level 12
Joined
Nov 3, 2013
Messages
989
  • Claim
    • Events
      • Unit - A unit Is issued an order targeting an object
      • Unit - A unit Is issued an order targeting a point
      • Unit - A unit Is issued an order with no target
    • Conditions
      • (Issued order) Equal to (Order(resumeharvesting))
    • Actions
      • Game - Display to (All players) the text: ((Name of (Triggering player)) + GOLDMINE IS YOURS)
      • Unit Group - Pick every unit in (Units within 600.00 of (Position of (Triggering unit)).) and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Unit-type of (Picked unit)) Equal to Gold Mine
            • Then - Actions
              • -------- do stuff here --------
            • Else - Actions
Actually the resumeharversting order is an order with no target.
What OP need to do is first check for harvest order like @DoomBlade showed, except add the units to some unit group or array or hashtable, and then check resumeharvesting order.

It might be arguable the worker even has to return to the townhall and use harvest on the same goldmine again to avoid players from abusing this mechanic
 

Wrda

Spell Reviewer
Level 26
Joined
Nov 18, 2012
Messages
1,887
What OP need to do is first check for harvest order like @DoomBlade showed, except add the units to some unit group or array or hashtable, and then check resumeharvesting order.

It might be arguable the worker even has to return to the townhall and use harvest on the same goldmine again to avoid players from abusing this mechanic
Goldmine ownership time is 2 seconds without any changes in gameplay constants. The thing is using harvest order to claim a goldmine is bad, because you can spam it and it would change ownership constantly. that's why you must use resumeharvesting to claim, and then check for harvest order for other players to know that it was already claimed. Depending on the map, changing the mentioned ownership time in gameplay constants might be useful.
 
Status
Not open for further replies.
Top