Please Help with Important Trigger Problem

Progesterone

New Member
Reaction score
0
Trigger:
  • Barracks Defense
    • Events
      • Time - Every 3.00 seconds of game time
    • Conditions
    • Actions
      • For each (Integer A) from 1 to 3, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • NumberOfKnights[(Integer A)] Less than or equal to 1
            • Then - Actions
              • Unit - Order Barracks[(Integer A)] to train/upgrade to a Knight
              • Set NumberOfKnights[(Integer A)] = (NumberOfKnights[(Integer A)] + 1)
            • Else - Actions
    • Barracks Defense Assign
      • Events
        • Unit - A unit Finishes training a unit
      • Conditions
        • (Unit-type of (Trained unit)) Equal to Knight
      • Actions
        • Unit - Set the custom value of (Trained unit) to (Custom value of (Triggering unit))
        • Unit - Order (Trained unit) to Attack-Move To (Center of RegionToDefend[(Custom Value of (Triggering Unit))])
        • -------- The Triggering Unit is the Barracks, as far as I can tell. --------
    • Barracks Defense Reduce
      • Events
        • Unit - A unit owned by Player 5 (Yellow) Dies
      • Conditions
        • (Unit-type of (Triggering unit)) Equal to Knight
      • Actions
        • Set NumberOfKnights[(Custom value of (Triggering unit))] = ((Custom value of (Triggering unit)) - 1)


At the start assign each of your barracks a custom value to be used as the index for Arrays. Assign all the regions the same way. The first trigger is the one that begins training, then increases the number of Knights currently existing (regardless of whether it is trained or not). The second one assigns all Knights the custom value of their Barracks, which tells you which Barracks should train another Knight when one dies. The last trigger will reduce the number of Knights of one Barracks currently existing when one Knight dies. This will allow the first trigger to make that Barracks train a new knight. I hope this helped - it used up all 24.2% of my laptop's remaining power.

Hi Kaerf, I have tried your trigger, but it was unable to work as I could not figure out how to "set my newly created variable 'Barracks 1' to be that particular Barracks" (ie, I just created the variables and named them, select type as unit, and click Array, then put '3', but how does the editor recognise that Barracks 1 is one particular barracks ?)
Please help ! Thanks !
 

Progesterone

New Member
Reaction score
0
Oh, on retrospect, I added this trigger to "set the variables"
Trigger:
  • Variable Setting
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Set Barracks[1] = Barracks 0108 <gen>
      • Set RegionToDefend[1] = (Center of FrTopDefAct <gen>)
      • Set NumberOfKnights[1] = (Number of units in (Units in FrTopDefAct <gen>))


But the trigger still can't work ! Did I do something wrong ?
Please help ! Thanks !
 

KaerfNomekop

Swim, fishies. Swim through the veil of steel.
Reaction score
612
Use the action Set Variable, and do Set Barracks[1] = Barracks 0001 <gen>.
For Regions, do Set RegionToDefend[1] = RegionToDefend1 <gen>.
You also need the action Unit - Set Custom Value of Unit. Like this:

Trigger:
  • Map Initialization
    • Events
      • Map Initialization
    • Conditions
    • Actions
      • Set Barracks[1] = Barracks 0001 &lt;gen&gt;
      • Set Barracks[2] = Barracks 0002 &lt;gen&gt;
      • Set Barracks[3] = Barracks 0003 &lt;gen&gt;
      • Set RegionToDefend[1] = RegionToDefend1 &lt;gen&gt;
      • Set RegionToDefend[2] = RegionToDefend2 &lt;gen&gt;
      • Set RegionToDefend[3] = RegionToDefend3 &lt;gen&gt;
      • Set NumberOfKnights[1] = (Number of units in (Units in RegionToDefend1 &lt;gen&gt; matching ((Unit-type of (Matching Unit)) equal to Knight)))
      • Set NumberOfKnights[2] = (Number of units in (Units in RegionToDefend2 &lt;gen&gt; matching ((Unit-type of (Matching Unit)) equal to Knight)))
      • Set NumberOfKnights[3] = (Number of units in (Units in RegionToDefend3 &lt;gen&gt; matching ((Unit-type of (Matching Unit)) equal to Knight)))
      • Unit - Set Custom Value of Barracks 0001 &lt;gen&gt; to 1
      • Unit - Set Custom Value of Barracks 0002 &lt;gen&gt; to 2
      • Unit - Set Custom Value of Barracks 0003 &lt;gen&gt; to 3


I did this in freehand, but if you need, I'll make a test map for you. :)
 

Attachments

  • RegionToDefend Variable.png
    RegionToDefend Variable.png
    7 KB · Views: 296
  • Barracks Variable.png
    Barracks Variable.png
    6.9 KB · Views: 296

Progesterone

New Member
Reaction score
0
Kaerf, thanks !
But I followed your trigger exactly and still cannot work: my first barracks will keep on training knights even when there are more than 2 knights in region 1, while my second and third barracks will not train any knights even when there are lesser than 2 knights in region 2 and 3 respectively.
Can I send you my scenario and you help me find out whats the problem ?
Thanks a lot !
 

Progesterone

New Member
Reaction score
0
Sorry correction, I tried your trigger exactly but now my Barracks 1 just initially trained to get 2 knights in Region 1, but then subsequently, when the knights die, Barracks 1 didn't train anymore.
 

KaerfNomekop

Swim, fishies. Swim through the veil of steel.
Reaction score
612
Here, test map completed about 12.30 am early today. You'll find instructions in the respective trigger comments above the triggers themselves.
 

Attachments

  • Barracks Defense Test Map.w3x
    22.3 KB · Views: 246

Progesterone

New Member
Reaction score
0
Here, test map completed about 12.30 am early today. You'll find instructions in the respective trigger comments above the triggers themselves.

Thanks Kaerf for the map.
I will need some time to test whether it can work on my scenario.
Will get back to you !
By the way, do you use MSN ? Can I add you on MSN for easier contact ?
 

Progesterone

New Member
Reaction score
0
Hi Kaerf, I copied your trigger and modified the necessary values to fit in my scenario, but the same problem still occur !
What's your email address ? Can I email you my scenario and you help me see what's wrong ?
Thanks a lot !
 

evilwolf

Member
Reaction score
11
Well, you(blizzard, actually) made a simple issue a tough problem.
Could you just do this?
Create a trigger that checks if there are 2 knights
And a trigger that has no event but it has a action to train a knight.
If there are less than 2 knights in an area run trigger No.2 (the one with the train knight action)
If it has +2 knights then don't run the trigger.
It works...
 

KaerfNomekop

Swim, fishies. Swim through the veil of steel.
Reaction score
612
I got the problems. One was because I made a mistake in the alternative trigger, which I didn't notice since it wasn't active in my test map. Sorry about that.

1st problem:
Trigger:
  • Train
    • Events
      • Time - Every 3.00 seconds of game time
    • Conditions
    • Actions
      • For each (Integer A) from 1 to 3, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • NumberOfKnights[(Integer A)] Less than 2
            • Then - Actions
              • Unit - Order Barracks[(Integer A)] to train/upgrade to a Knight
              • Set NumberOfKnights[(Custom value of (Ordered unit))] = (NumberOfKnights[(Custom value of (Ordered unit))] + 1)
            • Else - Actions

There was no Ordered Unit in this trigger. Replace (Custom Value of (Ordered unit)) with (Integer A).

2nd problem:
Trigger:
  • Init
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Set Barracks[1] = Barracks 0108 &lt;gen&gt;
      • Set Barracks[2] = Barracks 0095 &lt;gen&gt;
      • Set Barracks[3] = Barracks 0057 &lt;gen&gt;
      • Set RegionToDefend[1] = FrTopDefAct &lt;gen&gt;
      • Set RegionToDefend[2] = FrEastDefAct &lt;gen&gt;
      • Set RegionToDefend[3] = FrBottomDefAct &lt;gen&gt;
      • For each (Integer A) from 1 to 3, do (Actions)
        • Loop - Actions
          • Unit - Set the custom value of Barracks[(Integer A)] to (Integer A)
          • -------- Assuming that you may have placed knights in the region beforehand, this will also try to account for them. --------
          • Set NumberOfKnights[(Integer A)] = (Number of units in (Units in RegionToDefend[(Integer A)] matching ((Unit-type of (Matching unit)) Equal to Knight)))
      • Trigger - Turn off (This trigger)

This trigger did not take into account the fact that preplaced knights have no custom value assigned. Therefore, I added this action:
Trigger:
  • Unit Group - Pick every unit in (Units in RegionToDefend[(Integer A)] matching ((Unit-type of (Matching unit)) Equal to Knight)) and do (Actions)
    • Loop - Actions
      • Unit - Set the custom value of (Picked unit) to (Integer A)


New test map is attached. Works perfectly.

@evilwolf: Did you even bother to read the rest of the thread and find out the exact problems he was facing?
 

Attachments

  • Map Test File Changed.w3x
    184.8 KB · Views: 239

Progesterone

New Member
Reaction score
0
yupz it works perfectly fine now ! Really thanks a lot, kaerf ! Wanted to add one more reputation to you but the system doesn't allow me to. Now I can go designing the rest of the scenario and triggers already ! This trigger set will certainly help me a lot as I need to reproduce this concept in various other forms !
 

Progesterone

New Member
Reaction score
0
Dear all and Kaerf,
I have tried replicating your triggers to another player (Player 2 in my map) and situation, but experienced problems with it:
1) The trained orc (ie, "Bandit Henchman" in my map) will move to point, then go back automatically to barracks
2) When there are lesser than 2 Bandit Henchman in region Top HM 2 and Top HM 3, the barracks does not train more to replace.
I've attached my map.
Can please kindly help me see what's wrong with it ?
Would appreciate your help lots !
View attachment Moon Glade Updated.w3x
 

KaerfNomekop

Swim, fishies. Swim through the veil of steel.
Reaction score
612
I added this action to the Assign trigger:
Trigger:
  • AI - Ignore (Trained unit)&#039;s guard position

I think it was some problem with the AIs, since this fixed it. Also, you set one of the regions wrongly. I corrected it for you.

@evilwolf: Did you even check to see if there was such an action in the map?
 

Attachments

  • Moon Glade Updated 2.w3x
    187.1 KB · Views: 253
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