Counting Expansions/bases

Molinski

New Member
Reaction score
0
I have poked around the built in library a little bit. I am looking for a way to count how many bases are mining, but it seems to allude me. I was curious if some of the more experienced developers knew of some way to count bases, or to determine which base/building a worker was returning minerals? I saw something about towns but wasn't well explained and was for the AI rather then a generic function. I need this function available for every player.

thanks
 

Dave312

Censored for your safe viewing
Reaction score
269
Something like this should do the trick:
Trigger:
  • GetExpansionBases
    • Options: Function
    • Return Type: Integer
    • Parameters
      • Player = 0 <Integer>
    • Grammar Text: GetExpansionBases(Player)
    • Hint Text: (None)
    • Custom Script Code
    • Local Variables
      • Towns = 0 <Integer>
      • ExclusionZone = No Region <Region>
      • ExclusionSize = 7.0 <Real>
    • Actions
      • Unit Group - Pick each unit in (Any units in (Entire map) owned by player Player matching Required: Worker; Excluded: Missile, Dead, Hidden, with at most Any Amount) and do (Actions)
        • Actions
          • General - If (Conditions) then do (Actions) else do (Actions)
            • If
              • ((Picked unit) is in ExclusionZone) == false
              • (Ability command for ((Picked unit) order at index 0)) == SCV - Gather
            • Then
              • Variable - Modify Towns: + 1
              • Region - Add a Positive circle centered at (Position of (Picked unit)) with radius ExclusionSize to ExclusionZone
            • Else
      • General - Return Towns


Basically what this function does is pick every worker owned by a player and checks if they are using the gather ability. If they are, then it assumes the unit is gathering mineral/gas at a base and adds 1 to the number of bases owned by a player. In order to not count the same base twice, I create a circle of radius ExclusionSize around the unit which gets added to the ExclusionZone region. Then as each worker is picked, it also checks whether the worker is in this exclusion zone (if they are then they are considered to be mining form the same base).

It is probably not perfect but should be accurate most of the time. You might just need to change the size of the exclusion zone radius depending on the size/layout of your map.
 

Molinski

New Member
Reaction score
0
@Dave312
Thanks for the input :thup:

I actually thought about this same idea but initially thought it would be intensive for multi player maps with hundred of workers. I may very well be wrong. I will have to test it. I do like the radius limiting idea. This will unfortunately not work well for bases that are very close together. I try this until a more clever way can be determined.

Do building have unique ID that can be checked or can we determine when a building receives some resource? One last question, I haven't worked with regions much, is there a easy way to see the zones created while playing so I can 'debug' and refine this idea?
 

X-maul

AKA: Demtrod
Reaction score
201
@Dave312
One last question, I haven't worked with regions much, is there a easy way to see the zones created while playing so I can 'debug' and refine this idea?
The only way I know of, that wont require triggering will be to put some doodads of some kind at the outer line of your region.
 

Dave312

Censored for your safe viewing
Reaction score
269
I know there are a few issues with the function and it would require some tweaking depending on your circumstances. Also if your command center was some distance away from the resource, it would count it as being multiple expansion bases rather than just the one.

You can use the Unit Uses Ability event to to detect when a resource has been dropped off. I suppose you could use it to determine how many command centers have had a resource dropped off recently. It would however require a lot more scripting to get it to work properly (you would need to handle events of new command centers being created and others being destroyed).
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top