• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

[Trigger] Prevent players to build on specific areas

Status
Not open for further replies.
Level 2
Joined
Aug 4, 2010
Messages
23
On my map players can build a flag called "Territory sign". I want to prevent players from building in places near this flag. Only player who own this flag can build near it.

This trigger will look like this:
  • BuildTerritoryCheck
    • Events
      • Unit - A unit Begins construction
    • Conditions
    • Actions
      • Set TempLoc = (Position of (Triggering unit))
      • Custom script: set bj_wantDestroyGroup = true
      • Unit Group - Pick every unit in (Units within TerritoryRange of TempLoc matching ((Unit-type of (Matching unit)) Equal to Territory sign)) and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Owner of (Picked unit)) Equal to (Owner of (Triggering unit))
            • Then - Actions
            • Else - Actions
              • Unit - Remove (Triggering unit) from the game
      • Custom script: call RemoveLocation(udg_TempLoc)
And all is fine except one. Player is loosing resources if he is build in wrong places. I want refund back all his resources. Unfortunately there is no action such as unit - unit Gold Cost and unit - unit Wood cost so i don't know how to do this.
 
Level 25
Joined
Jul 10, 2006
Messages
3,315
Oh dear.

There's another workaround: you can detect when a builder is ordered to construct the building. The order string is the unit's raw name.

So make a new trigger; event - generic unit is ordered targeting a point
then put every building in the map in a unit type array, and check whether the order is any of the listed buildings, if it is, order the builder to stop.
 
Level 2
Joined
Aug 4, 2010
Messages
23
I see strange problem. If i make that trigger:
  • kill
    • Events
      • Unit - A unit Is issued an order targeting a point
    • Conditions
    • Actions
      • Unit - Kill (Triggering unit)
Unit will die and this is working, but if i make:

  • stop
    • Events
      • Unit - A unit Is issued an order targeting a point
    • Conditions
    • Actions
      • Unit - Order (Triggering unit) to Stop
or

  • hold
    • Events
      • Unit - A unit Is issued an order targeting a point
    • Conditions
    • Actions
      • Unit - Order (Triggering unit) to Hold Position
Unit is still moving. Why?
 
Level 2
Joined
Aug 4, 2010
Messages
23
This is crashing wc3
  • trig
    • Events
      • Unit - A unit Is issued an order targeting a point
    • Conditions
    • Actions
      • Unit - Order (Triggering unit) to Move To (Position of SOME_UNIT)
This is working but after teleport unit still trying to reach previous point order.
  • trig2
    • Events
      • Unit - A unit Is issued an order targeting a point
    • Conditions
    • Actions
      • Unit - Move (Triggering unit) instantly to (Position of SOME_UNIT)
I think in first trigger wc3 is entering into infinite loop that why is crashing. Because Order to move to another unit is
a "Unit - A unit Is issued an order targeting a point" too
 
Level 2
Joined
Aug 4, 2010
Messages
23
Thanks my trigger is done.
I checked what order string is for building things by this function:
  • Game - Display to (All players) the text: ((Name of (Triggering unit)) + ( + (String((Issued order)))))
And i get that results:
NoFmG.jpg

smart is when you are moving and those custom_**** are building orders. It seems like each building has his own string.

So my whole working trigger look like this:
  • BuildTerritoryCheck
    • Events
      • Unit - A unit Is issued an order targeting a point
    • Conditions
      • Or - Any (Conditions) are true
        • Conditions
          • (Issued order) Equal to (Order(custom_o00A))
          • (Issued order) Equal to (Order(custom_h001))
          • (Issued order) Equal to (Order(custom_h00P))
          • (Issued order) Equal to (Order(custom_h00S))
          • (Issued order) Equal to (Order(custom_u000))
          • (Issued order) Equal to (Order(custom_h01B))
          • (Issued order) Equal to (Order(custom_u006))
          • (Issued order) Equal to (Order(custom_u005))
          • (Issued order) Equal to (Order(custom_h00N))
          • (Issued order) Equal to (Order(custom_e000))
          • (Issued order) Equal to (Order(custom_e00B))
          • (Issued order) Equal to (Order(custom_e00A))
          • (Issued order) Equal to (Order(custom_e00C))
          • (Issued order) Equal to (Order(custom_e00D))
          • (Issued order) Equal to (Order(custom_e00E))
          • (Issued order) Equal to (Order(custom_e00F))
          • (Issued order) Equal to (Order(custom_e00G))
    • Actions
      • Set TempLoc = (Target point of issued order)
      • Custom script: set bj_wantDestroyGroup = true
      • Unit Group - Pick every unit in (Units within TerritoryRange of TempLoc matching ((Unit-type of (Matching unit)) Equal to Territory sign)) and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Owner of (Picked unit)) Equal to (Triggering player)
            • Then - Actions
            • Else - Actions
              • Unit - Replace (Triggering unit) with a (Unit-type of (Triggering unit)) using The old unit's life and mana
              • Selection - Select (Last replaced unit) for (Owner of (Triggering unit))
      • Custom script: call RemoveLocation(udg_TempLoc)
And this is fine.
 
Status
Not open for further replies.
Top