• 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.
  • It's time for the first HD Modeling Contest of 2025. Join the theme discussion for Hive's HD Modeling Contest #7! Click here to post your idea!

[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)
 
Level 16
Joined
Jul 21, 2008
Messages
1,121
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.
Top