• 🏆 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!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

I need help with my messed up triggers

Status
Not open for further replies.
Level 5
Joined
Oct 4, 2008
Messages
149
Hey there. It's been a very long time since I've last posted here. Before I explain my problem, I'd like to emphasize that I'm very bad at this and my triggering skills are basic at best, so bear with me.

Anyway... there are two things that I need help with. The map is very basic. I wanted to create a map where one player controls a citadel with a gold mine and some towers, while another controls three dragon roosts that train red dragons, drakes and whelps and gets automated income every second. My first obstacle was the leaderboard for the player who's in charge of the dragons. My intention was to have that player gain one extra gold per second for every 10 units killed, and one extra lumber for every 5 buildings razed (starting income is 10/5), and to have the leaderboard updated accordingly. While I managed to end up doing what I wanted, it's very sloppy, and it revolves using if/then/else triggers with conjunction with disabled triggers that add income and update the leaderboard.

The main problem with my approach is that it involves a lot of c/p, and that there's a limit to how many extra income it generates, and I'm sure there has to be a better way to do it. Anyway it looks like this:

  • Resource2
    • Events
      • Time - Every 0.10 seconds of game time
    • Conditions
    • Actions
      • If ((Player 11 (Dark Green) Units Killed) Equal to 10) then do (Trigger - Turn on Resource trigger1 <gen>) else do (Do nothing)
      • If ((Player 11 (Dark Green) Units Killed) Equal to 20) then do (Trigger - Turn on Resource trigger2 <gen>) else do (Do nothing)
      • If ((Player 11 (Dark Green) Units Killed) Equal to 30) then do (Trigger - Turn on Resource trigger3 <gen>) else do (Do nothing)
      • If ((Player 11 (Dark Green) Units Killed) Equal to 40) then do (Trigger - Turn on Resource trigger4 <gen>) else do (Do nothing)
      • If ((Player 11 (Dark Green) Units Killed) Equal to 50) then do (Trigger - Turn on Resource trigger5 <gen>) else do (Do nothing)
      • If ((Player 11 (Dark Green) Units Killed) Equal to 60) then do (Trigger - Turn on Resource trigger6 <gen>) else do (Do nothing)
      • If ((Player 11 (Dark Green) Units Killed) Equal to 70) then do (Trigger - Turn on Resource trigger7 <gen>) else do (Do nothing)
      • If ((Player 11 (Dark Green) Units Killed) Equal to 80) then do (Trigger - Turn on Resource trigger8 <gen>) else do (Do nothing)
      • If ((Player 11 (Dark Green) Units Killed) Equal to 90) then do (Trigger - Turn on Resource trigger9 <gen>) else do (Do nothing)
      • If ((Player 11 (Dark Green) Units Killed) Equal to 100) then do (Trigger - Turn on Resource trigger10 <gen>) else do (Do nothing)
      • If ((Player 11 (Dark Green) Units Killed) Equal to 110) then do (Trigger - Turn on Resource trigger11 <gen>) else do (Do nothing)
      • If ((Player 11 (Dark Green) Units Killed) Equal to 120) then do (Trigger - Turn on Resource trigger12 <gen>) else do (Do nothing)
      • If ((Player 11 (Dark Green) Units Killed) Equal to 130) then do (Trigger - Turn on Resource trigger13 <gen>) else do (Do nothing)
      • If ((Player 11 (Dark Green) Units Killed) Equal to 140) then do (Trigger - Turn on Resource trigger14 <gen>) else do (Do nothing)
      • If ((Player 11 (Dark Green) Units Killed) Equal to 150) then do (Trigger - Turn on Resource trigger15 <gen>) else do (Do nothing)
      • If ((Player 11 (Dark Green) Units Killed) Equal to 160) then do (Trigger - Turn on Resource trigger16 <gen>) else do (Do nothing)
      • If ((Player 11 (Dark Green) Units Killed) Equal to 170) then do (Trigger - Turn on Resource trigger17 <gen>) else do (Do nothing)
      • If ((Player 11 (Dark Green) Units Killed) Equal to 180) then do (Trigger - Turn on Resource trigger18 <gen>) else do (Do nothing)
      • If ((Player 11 (Dark Green) Units Killed) Equal to 190) then do (Trigger - Turn on Resource trigger19 <gen>) else do (Do nothing)
      • If ((Player 11 (Dark Green) Units Killed) Equal to 200) then do (Trigger - Turn on Resource trigger20 <gen>) else do (Do nothing)
  • Resource trigger1
    • Events
      • Time - Every 1.00 seconds of game time
    • Conditions
    • Actions
      • Player - Add 1 to Player 11 (Dark Green) Current gold
      • Leaderboard - Change the value for Player 5 (Yellow) in (Last created leaderboard) to 11
  • Resource trigger2
    • Events
      • Time - Every 1.00 seconds of game time
    • Conditions
    • Actions
      • Player - Add 1 to Player 11 (Dark Green) Current gold
      • Leaderboard - Change the value for Player 5 (Yellow) in (Last created leaderboard) to 12
As you can see, the first trigger is responsible for enabling "resource triggers" whenever the dark green player reaches a certain kill threshold. The resource trigger then gives 1 more gold for the player and updates the leaderboard (player yellow is actually "gold income"). So, what's a better way for this?

My second problem for this map is that I wanted a functioning AI that could train and send dragons if CPU is in control of dark green slot. First I tried using AI editor, but when that failed miserably, I turned to triggers. Triggers look like this:

  • AI
    • Events
      • Time - Every 1.00 seconds of game time
    • Conditions
      • (Player 11 (Dark Green) controller) Equal to Computer
    • Actions
      • Unit - Order Red Dragon Roost 0009 <gen> to train/upgrade to a Red Dragon
  • AI2
    • Events
      • Time - Every 12.00 seconds of game time
    • Conditions
      • (Player 11 (Dark Green) controller) Equal to Computer
      • (Number of living Red Drake units owned by Player 11 (Dark Green)) Less than 6
    • Actions
      • Unit - Order Red Dragon Roost 0101 <gen> to train/upgrade to a Red Drake
  • AI3
    • Events
      • Time - Every 25.00 seconds of game time
    • Conditions
      • (Player 11 (Dark Green) controller) Equal to Computer
      • (Number of living Red Dragon Whelp units owned by Player 11 (Dark Green)) Less than 6
    • Actions
      • Unit - Order Red Dragon Roost 0102 <gen> to train/upgrade to a Red Dragon Whelp
  • AI4
    • Events
      • Time - Every 180.00 seconds of game time
    • Conditions
      • (Player 11 (Dark Green) controller) Equal to Computer
    • Actions
      • Unit Group - Pick every unit in (Units in Dragons <gen>) and do (Unit - Order (Picked unit) to Attack-Move To (Center of Citadel <gen>))
So, my problem with this is again twofold. The idea was to assign each dragon roost to train a predetermined kind of dragon, with priority for the strongest one (dragon). The game checks each second if there are resources available for red dragon, every 12 seconds for red drake and every 25 secs for whelp. However this turned out exactly as I expected, CPU eventually had 10-12 dragon whelps, 3-4 drakes and no red dragons. So, I put limits in place, which is the second condition, limiting the ownership of drakes and whelps. Yet, I still end up having way more whelps because they're the cheapest of the three, and the condition doesn't apply for those that are pending for training.

The second problem is this last trigger, which is supposed to force all dragons in the area to charge. It does work, but CPU simply overrides this command few seconds later, and forces all dragons to return to the roosts. Any help is much appreciated.
 
Level 25
Joined
Sep 26, 2009
Messages
2,378
Dunno atm about the AI (this would require more thinking), but for your first problem (the problem with gold). There is actually far easier and far more efficient way to do this:

Just make a 1-second periodic trigger. Make that trigger increase (=add to) player yellow's gold by (Killed units amount/10).
Since the calculation is using integer numbers only, it won't have any value after decimal point. For example 59/10 = 5, because there is simply no .9 number as that does not exist in integers - for integers, anything after decimal point is lost (the integer does not get rounded up). This plays really well into your hands.
 
Level 5
Joined
Oct 4, 2008
Messages
149
Could you elaborate on this a bit? It would help if you'd make your own trigger about this so I know what to do. :p
 
Level 5
Joined
Oct 4, 2008
Messages
149
Wow. This is so simple, and I manage to over complicate it to no end. Thanks a bunch.
 
Status
Not open for further replies.
Top