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
613
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: 308
  • Barracks Variable.png
    Barracks Variable.png
    6.9 KB · Views: 305

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
613
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: 254

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
613
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: 253

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
613
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: 266
General chit-chat
Help Users
  • No one is chatting at the moment.
  • The Helper The Helper:
    I am great and it is fantastic to see you my friend!
    +1
  • The Helper The Helper:
    If you are new to the site please check out the Recipe and Food Forum https://www.thehelper.net/forums/recipes-and-food.220/
  • Monovertex Monovertex:
    How come you're so into recipes lately? Never saw this much interest in this topic in the old days of TH.net
  • Monovertex Monovertex:
    Hmm, how do I change my signature?
  • tom_mai78101 tom_mai78101:
    Signatures can be edit in your account profile. As for the old stuffs, I'm thinking it's because Blizzard is now under Microsoft, and because of Microsoft Xbox going the way it is, it's dreadful.
  • The Helper The Helper:
    I am not big on the recipes I am just promoting them - I use the site as a practice place promoting stuff
    +2
  • Monovertex Monovertex:
    @tom_mai78101 I must be blind. If I go on my profile I don't see any area to edit the signature; If I go to account details (settings) I don't see any signature area either.
  • The Helper The Helper:
    You can get there if you click the bell icon (alerts) and choose preferences from the bottom, signature will be in the menu on the left there https://www.thehelper.net/account/preferences
  • The Helper The Helper:
    I think I need to split the Sci/Tech news forum into 2 one for Science and one for Tech but I am hating all the moving of posts I would have to do
  • The Helper The Helper:
    What is up Old Mountain Shadow?
  • The Helper The Helper:
    Happy Thursday!
    +1
  • Varine Varine:
    Crazy how much 3d printing has come in the last few years. Sad that it's not as easily modifiable though
  • Varine Varine:
    I bought an Ender 3 during the pandemic and tinkered with it all the time. Just bought a Sovol, not as easy. I'm trying to make it use a different nozzle because I have a fuck ton of Volcanos, and they use what is basically a modified volcano that is just a smidge longer, and almost every part on this thing needs to be redone to make it work
  • Varine Varine:
    Luckily I have a 3d printer for that, I guess. But it's ridiculous. The regular volcanos are 21mm, these Sovol versions are about 23.5mm
  • Varine Varine:
    So, 2.5mm longer. But the thing that measures the bed is about 1.5mm above the nozzle, so if I swap it with a volcano then I'm 1mm behind it. So cool, new bracket to swap that, but THEN the fan shroud to direct air at the part is ALSO going to be .5mm to low, and so I need to redo that, but by doing that it is a little bit off where it should be blowing and it's throwing it at the heating block instead of the part, and fuck man
  • Varine Varine:
    I didn't realize they designed this entire thing to NOT be modded. I would have just got a fucking Bambu if I knew that, the whole point was I could fuck with this. And no one else makes shit for Sovol so I have to go through them, and they have... interesting pricing models. So I have a new extruder altogether that I'm taking apart and going to just design a whole new one to use my nozzles. Dumb design.
  • Varine Varine:
    Can't just buy a new heatblock, you need to get a whole hotend - so block, heater cartridge, thermistor, heatbreak, and nozzle. And they put this fucking paste in there so I can't take the thermistor or cartridge out with any ease, that's 30 dollars. Or you can get the whole extrudor with the direct driver AND that heatblock for like 50, but you still can't get any of it to come apart
  • Varine Varine:
    Partsbuilt has individual parts I found but they're expensive. I think I can get bits swapped around and make this work with generic shit though
  • Ghan Ghan:
    Heard Houston got hit pretty bad by storms last night. Hope all is well with TH.
  • The Helper The Helper:
    Power back on finally - all is good here no damage
    +2
  • V-SNES V-SNES:
    Happy Friday!
    +1
  • The Helper The Helper:
    New recipe is another summer dessert Berry and Peach Cheesecake - https://www.thehelper.net/threads/recipe-berry-and-peach-cheesecake.194169/

      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