• Check out the results of the Techtree Contest #19!
  • 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.
  • Create a void inspired texture for Warcraft 3 and enter Hive's 34th Texturing Contest: Void! Click here to enter!
  • The Hive's 22nd Icon Contest: Creep Abilities is now concluded, time to vote for your favourite set of icons! Click here to vote!

[GUI] City-building Condition Trigger

Status
Not open for further replies.
Level 5
Joined
Apr 8, 2007
Messages
116
(SOLVED)


Hey all,

so my trigger is supposed to cause players to be unable to build a city within 700 distance units from any pre-existing cities.

So far, I have it as:

Event:
Unit begins construction

Action:
If [All conditions are true] Then do [then actions] else do [else actions]
If Conditions:
-unit-type of constructing city = city
-number of units in [units within 700.00 of [position of constructing unit] matching [unit type of matching unit Equal to City] Greater than or Equal to 1

Then:
Unit - remove constructing unit
Player - add 400 gold to owner of constructing unit
Game - display text to owner of constructing unit [Error cities must be built within blah blah]
Else: Do nothing


However, the problem is that the "error" trigger pops up no matter where the city is targeted, even if the nearest one is all the way across the 256 x 256 map.


I have another building-conditions for houses, which is the fact that they must be built within 600 range of cities, similarly formatted - but it functions perfectly fine...

Anyways, thanks in Advance
 
Last edited:
  • Tg
  • Events
    • Unit - A unit begins a construction
  • Conditions
    • ((Unit-type) of (Constructing structure)) Equal to X
  • Actions
    • Set Point1 = (Position of (Constructing Structure))
    • Set Temp_Group = (Units within 700.00 of (Point1) matching ((Matching unit) is a structure) Equal to True)
    • If/ Then/ Else
      • If (Conditions)
        • (Number of units in (Temp_Group)) Greater than or Equal to 1
      • Then (Actions)
        • Unit - Remove (Constructing structure)
        • Player - Add 400 gold to (Owner of (Constructing unit))
        • Game - Display ...
    • Custom script: call RemoveLocation (udg_Point1)
    • Custom script: call DestroyGroup (udg_Temp_Group)
 
Trigger above isn't working because trigger fires when structure begins construction. Trigger adds constructing structure to your Unit Group. Now, Unit Group is Greater Than or Equal to 1 and actions automatically destroy building and add resources.

Try this trigger:
  • Trigger
    • Events
      • Unit - A unit Begins construction
    • Conditions
      • (Unit-type of (Constructing structure)) Equal to <Your Building>
    • Actions
      • Set TempPoint = (Position of (Constructing structure))
      • Set TempGroup = (Units within <Range> of TempPoint matching ((Unit-type of (Matching unit)) Equal to <Your Building>))
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Number of units in TempGroup) Greater than 1
        • Then - Actions
          • Unit - Kill (Constructing structure)
          • Player - Add <Gold Cost> to (Owner of (Constructing structure)) Current gold
          • Player - Add <LumberCost> to (Owner of (Constructing structure)) Current lumber
          • Game - Display to (All players) the text: <Text>
        • Else - Actions
        • Custom script: call DestroyGroup(udg_TempGroup)
        • Custom script: call RemoveLocation(udg_TempPoint)
 
Last edited:
Status
Not open for further replies.
Back
Top