Limit one structure type per region?

cstorm

New Member
Reaction score
1
In my map I have region in which you have to build a "Square Holder" to take control of that region. But I dont want people to be able to build another in the region inless the first is destroyed. I dont know how to set up triggers to prevent people from just building another "Square Holder" until the first is destroyed.
Note: there are 25 of these regions
 

FannyShaver

Well-Known Member
Reaction score
31
Well, I am not sure whether you need 25 triggers on not, but I'd do that:

Region 1:

event;Unit enters region
condition;region1
action;set sqhol1 = 1
action; if/then/else
condition; if sqhol1 equals 1 equal to true
then; order building unit to stop
else; do nothing

You got my idea or need trigger?
 

cstorm

New Member
Reaction score
1
Well, I am not sure whether you need 25 triggers on not, but I'd do that:

Region 1:

event;Unit enters region
condition;region1
action;set sqhol1 = 1
action; if/then/else
condition; if sqhol1 equals 1 equal to true
then; order building unit to stop
else; do nothing

You got my idea or need trigger?

uhhh trigger would be nicer and easier to follow lol
 

FannyShaver

Well-Known Member
Reaction score
31
Trigger:
  • Region 1
    • Events
      • Unit - A unit Begins construction
    • Conditions
      • (Unit-type of (Triggering unit)) Equal to Square Holder
      • ((Region1) contains (Triggering unit)) Equal to True
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Number of units in (Units in (Region1) matching ((Unit-type of (Matching unit)) Equal to Square Holder))) Equal to 2
        • Then - Actions
          • Unit - Remove (Triggering unit) from the game
          • Game - Display to (Player group((Owner of (Triggering unit)))) the text: You can build only one Square Holder per region.
        • Else - Actions
          • Do nothing


All I do I probably do in a quite a long way, but that is just a way I find it easier. I'd just do myself 25 triggers, but there's probably an easier way tho.
 

Inflicted

Currently inactive
Reaction score
63
what FannyShaver said would work.

but i still think this line is unnecessary:

Trigger:
  • Do nothing


All I do I probably do in a quite a long way, but that is just a way I find it easier. I'd just do myself 25 triggers, but there's probably an easier way tho.

um couldnt u just make and set region arrays?
would make it ALOT easier imo.
 

FannyShaver

Well-Known Member
Reaction score
31
I've said that is my way, and my way involves lots of triggers, still - more triggers makes easier to control and edit for me personally. And yes, do nothing isn't necessary, but takes no problems involved having it as well.
 

Sirroelivan

Gunnerkrigg Court
Reaction score
95
Code:
Holder
    Events
        Unit - A unit Begins construction
    Conditions
        (Unit-type of (Constructing structure)) Equal to Farm
    Actions
        Set TempPoint = (Position of (Constructing structure))
        For each (Integer A) from 1 to NbOfHolderRegions, do (Actions)
            Loop - Actions
                If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    If - Conditions
                        (HolderRegion[(Integer A)] contains TempPoint) Equal to True
                    Then - Actions
                        Set TempUnitGroup = (Units in HolderRegion[(Integer A)] matching ((Unit-type of (Matching unit)) Equal to Farm))
                        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                            If - Conditions
                                (Number of units in TempUnitGroup) Greater than or equal to 2
                            Then - Actions
                                Unit - Remove (Constructing structure) from the game
                            Else - Actions
                        Custom script:   call DestroyGroup(udg_TempUnitGroup)
                    Else - Actions
        Custom script:   call RemoveLocation(udg_TempPoint)

Something like this should do the trick. Replace Farm with your building. Add all regions you want to check for to the HolderRegion array. Replace NbOfHolderRegions with the number of regions you're checking for.
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Staff online

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top