• 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.

[Solved] Unit restriction

Status
Not open for further replies.
Level 6
Joined
Sep 24, 2015
Messages
174
Hi, in my trigger i want that if i build more than 1 lumberbase level 1 it removes the second lumberbase from the game (like not being able to construct more than one) and display a floating text on the head of the builder of this unit.

I tried this trigger but it doesn't works and i really don't know why...

  • lb1 restriction
    • Events
    • Conditions
      • (Number of units in (Units owned by (Owner of (Picked unit)))) Superior to 1
      • (Unit-type of (Picked unit)) Equal to Lumber Base 1 good one
    • Actions
      • Custom script: set bj_wantDestroyGroup = true
      • Unit groupe - Pick every unit in (Units owned by (Owner of (Picked unit))) and do (Actions)
        • Loop - Actions
          • Floating text - Create floating text that reads You can only build ... at (Position of (Picked unit)) with Z offset 0.00, using font size 10.00, color (100.00%, 0.00%, 0.00%), and 0.00% transparency
          • Unit - Remove (Picked unit) from the game
  • [ /trigger]
Edit: is it the picked unit who messes up the code?
 
Level 25
Joined
May 11, 2007
Messages
4,650
It doesn't have any event triggering it..
And yes, you can't use picked unit in the conditions.

Anyhow, pseudo code for fixing it:

Set the action to "a unit begins construction"
set conditions to "unit type of constructed building == lumber mill"
actions:
set tempGroup1 = units of type Lumber mill owned by owner of constructed building.

if (number of units in tempGroup1 > 1)
{
set tempPoint1 = position of constructed building
show floating text at tempPoint1
kill constructed building
}
 
Level 6
Joined
Sep 24, 2015
Messages
174
So now I did like that and it's still not working, i'm still able to build more than one lumberbase level 1.

  • lb1 restriction
    • Events
      • Units - A unit Begin a construction
    • Conditions
      • (Unit-type of (Constructed structure)) Equal to Lumber Base 1 good one
    • Actions
      • Set tempGroup1 = (Units owned by (Owner of (Constructed structure)) of type Lumber Base 1 good one)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Number of units in tempGroup1) Superior to 1
        • Then - Actions
          • Set TempPoint1 = (Position of (Constructed structure))
          • Texte flottant - Create floating text that reads You can only build ... at TempPoint1 with Z offset 0.00, using font size 10.00, color (100.00%, 0.00%, 0.00%), and 0.00% transparency
          • Units - Kill (Constructed structure)
        • Else - Actions
 
Level 6
Joined
Sep 24, 2015
Messages
174
thank you for your help here's the way I did :

  • lb1 restriction
    • Events
      • Unit - A unit Commence la construction
    • Conditions
      • (Unit-type of (Constructing structure)) Equal to Lumber Base 1 good one
    • Actions
      • Set tempGroup1 = (Units owned by (Owner of (Constructing structure)) of type Lumber Base 1 good one)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Number of units in tempGroup1) Supérieur à 1
        • Then - Actions
          • Set LocPoint1 = (Position of (Constructing structure))
          • Unit - Kill (Constructing structure)
        • Else - Actions
 
Status
Not open for further replies.
Top