• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!

A trigger which don't let the worker build in a region

Status
Not open for further replies.
Level 4
Joined
Jul 9, 2011
Messages
82
People, I'd like to do a trigger for the workers to not build (in a certain region) there unless they had a certain item , how do I do that ?!?
 

Chaosy

Tutorial Reviewer
Level 40
Joined
Jun 9, 2011
Messages
13,183
i belive this is what you want
  • test
    • Events
      • Unit - A unit Begins construction
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • ((Triggering unit) has an item of type Tome of Experience) Equal to True
          • (Region 000 <gen> contains (Triggering unit)) Equal to True
        • Then - Actions
        • Else - Actions
          • Unit - Remove (Constructing structure) from the game
 
Level 4
Joined
Jul 9, 2011
Messages
82
i belive this is what you want
  • test
    • Events
      • Unit - A unit Begins construction
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • ((Triggering unit) has an item of type Tome of Experience) Equal to True
          • (Region 000 <gen> contains (Triggering unit)) Equal to True
        • Then - Actions
        • Else - Actions
          • Unit - Remove (Constructing structure) from the game

OK, I'll try it !
 
Level 4
Joined
Jul 9, 2011
Messages
82
i belive this is what you want
  • Problem
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Region 000 <gen> contains (Triggering unit)) Equal to True

I'm having problem with this part I just found "(Position of (Triggering unit))" and not only "(Triggering unit))"
 
Level 11
Joined
Nov 15, 2007
Messages
781
Fack, that's so complicated... : /

Not really.

  • Set Point = Position of (triggering unit)
  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
    • If - Conditions
      • (Your region <gen> contains (Point)) Equal to True
    • Then - Actions
      • ------- Your actions -------
  • Custom script: call RemoveLocation(udg_Point)
 
Level 4
Joined
Jul 9, 2011
Messages
82
Not really.

  • Set Point = Position of (triggering unit)
  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
    • If - Conditions
      • (Your region <gen> contains (Point)) Equal to True
    • Then - Actions
      • ------- Your actions -------
  • Custom script: call RemoveLocation(udg_Point)

It didn't worked.... Can you do a sample map ?
 
Level 5
Joined
Sep 30, 2011
Messages
178
I believe Meticulous is posting a trigger with variable, maybe you don't know that yet. The variable can be access by the x icon in the trigger editor
 
Level 4
Joined
Jul 9, 2011
Messages
82
I believe Meticulous is posting a trigger with variable, maybe you don't know that yet. The variable can be access by the x icon in the trigger editor

I know how variable works, I did the variable point named "point" BUT it's still not working : /
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,202
What is not working... You keep referencing somethiing without showing us what and in what way. Without more detail we can not help you.

1. Post piece of script (eithor GUI or JASS).
2. Post fault description (syntax error, logical fault etc).

Then we can help you.
 
Level 4
Joined
Jul 9, 2011
Messages
82
What is not working... You keep referencing somethiing without showing us what and in what way. Without more detail we can not help you.

1. Post piece of script (eithor GUI or JASS).
2. Post fault description (syntax error, logical fault etc).

Then we can help you.

Ok, I'm sorry, I'll post it now....

  • Events
    • Unit - A unit Begins construction
  • Conditions
  • Actions
    • Set Posicao = (Position of (triggering unit))
    • If (All conditions are true) then do (then actions) else do (else actions)
      • If - Conditions
        • ((triggering unit) has an item of type Key01) equal to true
        • (Region120<gen> contains Posicao) equal to true
      • Then - Actions
        • Do nothing
      • Else - Actions
        • Unit - Remove (constructing structure) from the game
 
Level 11
Joined
Nov 15, 2007
Messages
781
Ok, I'm sorry, I'll post it now....

  • Events
    • Unit - A unit Begins construction
  • Conditions
  • Actions
    • Set Posicao = (Position of (triggering unit))
    • If (All conditions are true) then do (then actions) else do (else actions)
      • If - Conditions
        • ((triggering unit) has an item of type Key01) equal to true
        • (Region120<gen> contains Posicao) equal to true
      • Then - Actions
        • Do nothing
      • Else - Actions
        • Unit - Remove (constructing structure) from the game

Sorry, "Triggering unit" for this event refers to the building being constructed, not the unit constructing it. I should've caught that sooner, my bad. You'll have to use "Issued order" for this, and it'll require 2 triggers.


  • Trigger1
    • Events
      • Unit - A unit Is issued an order targeting a point
    • Conditions
      • (Issued order) Equal to (Order(farm))
    • Actions
      • Set point = Target point of issued order
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • ((Triggering unit) has an item of type Key) Equal to True
          • (Your region <gen> contains (point)) Equal to True
        • Then - Actions
          • Set BuildOn[(Player number of (Owner of (Triggering unit)))] = True
        • Else - Actions
          • Set BuildOn[(Player number of (Owner of (Triggering unit)))] = False
The above trigger sets a Boolean variable to true or false to decide whether the player is allowed to build or not. It's an array so that you can have a different value for every player, in case one player has the key and another doesn't (just assuming it's a multiplayer map). Set the size of the array to the number of players in the game.


  • Trigger2
    • Events
      • Unit - A unit Begins construction
    • Conditions
      • BuildOn[(Player number of (Owner of (Triggering unit)))] Equal to False
    • Actions
      • Unit - Remove (Triggering unit) from the game
This trigger removes the building if the player isn't allowed to build it.

Keep in mind if your unit is an Orc or Night Elf builder, they will be stuck hidden if a building they're building is removed. You can circumvent this by first killing and then removing the building.
 
Level 4
Joined
Jul 9, 2011
Messages
82
Sorry, "Triggering unit" for this event refers to the building being constructed, not the unit constructing it. I should've caught that sooner, my bad. You'll have to use "Issued order" for this, and it'll require 2 triggers.


  • Trigger1
    • Events
      • Unit - A unit Is issued an order targeting a point
    • Conditions
      • (Issued order) Equal to (Order(farm))
    • Actions
      • Set point = Target point of issued order
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • ((Triggering unit) has an item of type Key) Equal to True
          • (Your region <gen> contains (point)) Equal to True
        • Then - Actions
          • Set BuildOn[(Player number of (Owner of (Triggering unit)))] = True
        • Else - Actions
          • Set BuildOn[(Player number of (Owner of (Triggering unit)))] = False
The above trigger sets a Boolean variable to true or false to decide whether the player is allowed to build or not. It's an array so that you can have a different value for every player, in case one player has the key and another doesn't (just assuming it's a multiplayer map). Set the size of the array to the number of players in the game.


  • Trigger2
    • Events
      • Unit - A unit Begins construction
    • Conditions
      • BuildOn[(Player number of (Owner of (Triggering unit)))] Equal to False
    • Actions
      • Unit - Remove (Triggering unit) from the game
This trigger removes the building if the player isn't allowed to build it.

Keep in mind if your unit is an Orc or Night Elf builder, they will be stuck hidden if a building they're building is removed. You can circumvent this by first killing and then removing the building.

I'm having a big problem to find these triggers, I mean this's Farm or Build ?
  • Conditions
    • (Issued order) Equal to (Order(farm))
And which variable is that
  • Set point = Target point of issued order
It's point variable right ? But I didnt find any "Target point of issued order"
 
Level 11
Joined
Nov 15, 2007
Messages
781
I'm having a big problem to find these triggers, I mean this's Farm or Build ?
  • Conditions
    • (Issued order) Equal to (Order(farm))
And which variable is that
  • Set point = Target point of issued order
It's point variable right ? But I didnt find any "Target point of issued order"

Woops, was in a rush and forgot to explain. Sorry!

The order string for building is a semi-hidden string value of the building being built. farm is the order string to build a farm, scouttower to build a scouttower, orcburrow to build a burrow, etc. However, custom units have different values. Open the object editor and select "View - Display values as raw data", and the unit's name in the list will show something like "h000" "u000" "e000" etc. The order string will be custom_h000 where h000 is whatever the value displayed is. If you need to make the trigger check for multiple buildings, use "Or, multiple conditions" as a condition, and create an order string check for every building you want to be buildable in the area.

Point is a point variable. Target point of issued order will be "Event Response - Target point of issued order" in the list.

Also, add
  • Custom script: call RemoveLocation(udg_Point)
at the end of the trigger. I forgot to add that as well, it cleans up a memory leak (memory leaks are bad)
 
Level 4
Joined
Jul 9, 2011
Messages
82
  • Conditions
  • BuildOn[(Player number of (Owner of (Triggering unit)))] Equal to False
Which variable is buildon ???

And wich function is that ?


------------------------

And when I gonna save it gives a error " call RemoveLocation(udg_Point)"
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,202
hbadotti, I advise skipping straight to scripting instead of trying to use GUI. GUI is very illogical so you may find the script easier to use in your case.

And when I gonna save it gives a error " call RemoveLocation(udg_Point)"
That is called a syntax error, the parser says that piece of script does not make sense. You will need to change it so your script obeys the rules of the JASS scripting language inorder for the map to run.
 
Level 4
Joined
Jul 9, 2011
Messages
82
hbadotti, I advise skipping straight to scripting instead of trying to use GUI. GUI is very illogical so you may find the script easier to use in your case.


That is called a syntax error, the parser says that piece of script does not make sense. You will need to change it so your script obeys the rules of the JASS scripting language inorder for the map to run.


:O


So, can you do a LOGICAL trigger to me ? I mean, a mini map which contains the trigger which I want. Please ?
 
Level 11
Joined
Nov 15, 2007
Messages
781
  • Conditions
  • BuildOn[(Player number of (Owner of (Triggering unit)))] Equal to False
Which variable is buildon ???

And wich function is that ?


------------------------

And when I gonna save it gives a error " call RemoveLocation(udg_Point)"

BuildOn is a Boolean variable, and the condition is a Boolean comparison.

Replace "Point" with whatever you named your point variable. udg_Whatever. Remember capitalization matters.
 
Level 4
Joined
Jul 9, 2011
Messages
82
BuildOn is a Boolean variable, and the condition is a Boolean comparison.

Replace "Point" with whatever you named your point variable. udg_Whatever. Remember capitalization matters.


OK,

Replace "Point" with whatever you named your point variable. udg_Whatever. Remember capitalization matters. DONE

BuildOn is a Boolean variable. DONE


and the condition is a Boolean comparison. PROBLEM ! >>>>> So I found the Boolean comparison but the command "Player number of" is just for intergers what can I do now ?
  • Conditions
  • BuildOn[(Player number of (Owner of (Triggering unit)))] Equal to False
 
Level 11
Joined
Nov 15, 2007
Messages
781
OK,

Replace "Point" with whatever you named your point variable. udg_Whatever. Remember capitalization matters. DONE

BuildOn is a Boolean variable. DONE


and the condition is a Boolean comparison. PROBLEM ! >>>>> So I found the Boolean comparison but the command "Player number of" is just for intergers what can I do now ?
  • Conditions
  • BuildOn[(Player number of (Owner of (Triggering unit)))] Equal to False

BuildOn is an ARRAY variable. When you create a variable there will be a check box asking if you want to make it an array. Check it, and set the size of the array to the number of players in your map. If your map is only for one player you don't need to make it an array. The number of the array is the integer.
 
Level 4
Joined
Jul 9, 2011
Messages
82
OK, the trigger is 100% like yours now BUT when I gonna build in the REGION and with the KEY, the game removes the building unit (And I don't get refund) and when I'm in the REGION without the key, the same happens AND when I'm out of the region and with or without the key, the same thing happens....
 
Status
Not open for further replies.
Top