Please help with trigger problem !

Progesterone

New Member
Reaction score
0
Dear all,
I need to create a trigger (for computer player) that starts off when a unit (Captain) dies. Once it starts, whenever there are lesser than 2 knights in Region "FrTopDefAct", the Barracks will train one knight and order the trained knight to move to the centre of Region "FrTopDefAct".
The trigger that I created are as follows:

1)Trigger A1
Event
Unit - Captain 0340 <gen> Dies
Condition
(Owner of (Triggering unit)) Equal to Player 5 (Yellow)
Action
Trigger - Turn on Top Def A2 <gen>

2)Trigger A2
Event
Time - Every 3.00 seconds of game time
Condition
(Number of units in (Units in FrTopDefAct <gen> matching ((Unit-type of (Matching unit)) Equal to Knight))) Less than 2
Action
Unit - Order Barracks 0108 <gen> to train/upgrade to a Knight

3)Trigger A3
Event
Unit - Barracks 0108 <gen> Finishes training a unit
Condition
(Unit-type of (Trained unit)) Equal to Knight
Action
Unit - Order (Trained unit) to Attack-Move To (Center of FrTopDefAct <gen>)

The problem I have: even though there were already more than TWO knights in region "FrTopDefAct", the barracks KEPT ON TRAINING MORE KNIGHTS.

Can someone please help me ?
Thanks !
 

Yoww89

New Member
Reaction score
0
Ok Progesterone, I'm not a WE master but i'll try to help you since none else did.

Lets see whats happening:

1- Your captain dies. This will turn on Top Def A2 (shouldn't it be Trigger A2? Look carefully at your thread)

2- After 3 seconds your captain died there will be only 2 knights in FrTopDefAct <gen> so the Barracks 0108 will start training a knight.

3- After 6 seconds your captain died there will STILL BE ONLY 2 KNIGHTS IN FrTopDefAct <gen> so the Barracks will add another train knight order into the queue.

So it's going to keep happening after 9 seconds, 12, 15... until the first trained knight get to FrTopDefAct <gen>. Then the Barracks will stop ADDING train knight orders to the queue. But the train orders previously added in the seconds 6, 9, 12, 15 ... won't simply dissapear. That's why you're getting more than one knight.

I hope you understand my explanation.
Once you get it it's pretty easy to fix.

Maybe some rep? u.u
 

Happy

Well-Known Member
Reaction score
71
Yoww89 you understood the problem but you havent helped because you gave no solution ^^ but no problem happy helps xD

first of all remove the condition of the second trigger. and make the second trigger check every 0.03 seconds. (or at least every 0.1 seconds)...

then to create just one knight you just have to add an check value...can be a boolean/integer variable for example...if a knight dies turn it true/1 . then check in the second trigger whether the value is true/1 or not. if it is true/1 add one knight to queue and turn it false/0 if its not do nothing. this way it just creates one everytime one knight dies.

i hope it helps ^-^

and Yoww89....dont ask for rep^^ the people will give you some rep if they want to ^^
 

dianamod27

Member
Reaction score
1
Let's say the captain dies and you have one knight in that region.
Then, every 3 seconds, you give the order to train a knight.
If your knights' training time isn't below 3 seconds, then this would queue one knight every 3 seconds.

Edit: Mistook Happy for Progesterone, lol.
 

Yoww89

New Member
Reaction score
0
Yoww89 you understood the problem but you havent helped because you gave no solution ^^ but no problem happy helps xD

first of all remove the condition of the second trigger. and make the second trigger check every 0.03 seconds. (or at least every 0.1 seconds)...

then to create just one knight you just have to add an check value...can be a boolean/integer variable for example...if a knight dies turn it true/1 . then check in the second trigger whether the value is true/1 or not. if it is true/1 add one knight to queue and turn it false/0 if its not do nothing. this way it just creates one everytime one knight dies.

i hope it helps ^-^

and Yoww89....dont ask for rep^^ the people will give you some rep if they want to ^^

Ok. Second post you make after me, says almost the same thing and plays Mr. Wisdom.
IF I POINTED HIM THE PROBLEM HE WASN'T SEEING, YES I THINK I HELPED. I don't need to solve his problem to be of some help.

And thank you, i started posting cause i thought i could help some people, but you made me remember how much dushs there're out there.
 

Progesterone

New Member
Reaction score
0
Happy, regarding your boolean value solution, how exactly do I use that ? Will it still work if the same player has many knights elsewhere ?
Also, is there a condition that specifies "when there are eg. 5 units (eg. knights) owned by Player 1 in region Y"? Coz I can't seem to find a condition that has all the above variables (ie, the ones I find only has some, but not all)
 

Happy

Well-Known Member
Reaction score
71
if you use a control boolean it doesnt matter where the knights are...if he reached the maximum number you turn it false and then if one knight dies you turn if true and the second trigger checks every 0.03 seconds whether its true and if so he adds one knight to queue and turns it to false.

would look like this:

Code:
Trigger A1
Event
Unit - Captain 0340 <gen> Dies
Condition
(Owner of (Triggering unit)) Equal to Player 5 (Yellow)
Action
Set Control_Boolean = True
Trigger - Turn on Top Def A2 <gen>

Code:
Trigger A2
Event
Time - Every 0.03 seconds of game time
Condition
Action
if Control_Boolean = True
then Unit - Order Barracks 0108 <gen> to train/upgrade to a Knight
         Set Control_Boolean = False
else

Code:
Trigger A3
Event
Unit - Barracks 0108 <gen> Finishes training a unit
Condition
(Unit-type of (Trained unit)) Equal to Knight
Action
Unit - Order (Trained unit) to Attack-Move To (Center of FrTopDefAct <gen>)
 

Progesterone

New Member
Reaction score
0
Thanks for the detailed reply, but my situation is actually like this: there are three different areas in which the computer needs to defend (let's name it Area A, B and C)
In each area, there is a barracks, a captain and at least one knight.
What I need the computer player to do is that if the captain dies, the computer will ensure there is at least two knight defending each area, hence the trigger for the SPECIFIC area to train a knight and move it to the respective areas when there are lesser than 2 knights in that SPECIFIC area.
How do I accomplish that ?
Thanks ! :)
 

Happy

Well-Known Member
Reaction score
71
okay...makes it a bit bigger but okay...^^

first set the control boolean an array....also make an unit variable containing the barracks...and then do this:


Code:
Trigger A1
Event
Unit - Captain 0340 <gen> Dies
Condition
(Owner of (Triggering unit)) Equal to Player 5 (Yellow)
Action
if died unit is in Area A 
then Set Control_Boolean[1] = True
Trigger - Turn on Top Def A2 <gen>
else
if died unit is in area B
then Set Control_Boolean[2] = True
Trigger - Turn on Top Def A2 <gen>
else
if died unit is in area C
then Set Control_Boolean[3] = True
Trigger - Turn on Top Def A2 <gen>
else

Code:
Trigger A2
Event
Time - Every 0.03 seconds of game time
Condition
Action
integer A from 1 to 3
    if Control_Boolean [integer A] = True
    then Unit - Order Barracks [Integer A] to train/upgrade to a Knight
         Set Control_Boolean [integer A] = False
else

Code:
Trigger A3
Event
Unit - Barracks [1] Finishes training a unit
Condition
(Unit-type of (Trained unit)) Equal to Knight
Action
Unit - Order (Trained unit) to Attack-Move To (Center of Area A)


Code:
Trigger A4
Event
Unit - Barracks [2] Finishes training a unit
Condition
(Unit-type of (Trained unit)) Equal to Knight
Action
Unit - Order (Trained unit) to Attack-Move To (Center of Area B)


Code:
Trigger A5
Event
Unit - Barracks [3] Finishes training a unit
Condition
(Unit-type of (Trained unit)) Equal to Knight
Action
Unit - Order (Trained unit) to Attack-Move To (Center of Area C)
 

dianamod27

Member
Reaction score
1
Well, you could just make the same trigger three times with their own variables, specifying the different regions. Or you could pack it in one trigger with if/then/else
 

Progesterone

New Member
Reaction score
0
Please forgive my noob-ness in trigger editing, but how do I translate your triggers into world editor ? Coz eg. I have difficulty finding the option where I can choose "if died unit is in area A" after I clicked "new Action"
Also how do I "first set the control boolean an array....also make an unit variable containing the barracks"?
Thanks !
 

HydraRancher

Truth begins in lies
Reaction score
197
Please forgive my noob-ness in trigger editing, but how do I translate your triggers into world editor ? Coz eg. I have difficulty finding the option where I can choose "if died unit is in area A" after I clicked "new Action"
Also how do I "first set the control boolean an array....also make an unit variable containing the barracks"?
Thanks !

Unit is in region is a boolean. So it's a condition. It is written in free-hand so the actual thing would look like an if/then/else.

What he is talking about is variables. Click the yellow X in the trigger editor to create them.
 

Progesterone

New Member
Reaction score
0
Thanks for the reply! How do I write free-text in Trigger Editor ? Also, what exactly do I need to do to "create the variable", ie, does that referring to creating the names "barracks 1, 2 etc" ?
 

Progesterone

New Member
Reaction score
0
hi, can please teach me how to write "free-text" in Trigger Editor so that I can try out the trigger sequence provided by Happy ? Thanks !
 

KaerfNomekop

Swim, fishies. Swim through the veil of steel.
Reaction score
613
Just create a new trigger. Then, under, Edit, select Convert to Custom Text.
 

Progesterone

New Member
Reaction score
0
Thanks, but i tried converting to custom text and there were a long string of words that didn't really make sense to me. Do I copy and paste the trigger suggestion OVER all those words in the respective categories of Events, Conditions and Actions ?
 

KaerfNomekop

Swim, fishies. Swim through the veil of steel.
Reaction score
613
Happy's trigger doesn't need JASS, and I'm not even sure it would work if it was implemented in JASS. You should just remake the trigger in GUI.
 

Progesterone

New Member
Reaction score
0
How do I do that ?
Is there a simpler way of using the "trigger" options in trigger editor instead of having to write all free-text ?
Thanks !
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top