• 🏆 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!

Can i shrink this trigger?

Status
Not open for further replies.
Level 17
Joined
Jun 2, 2009
Messages
1,137
Hello everyone. I have created AI system for my map and it seems it is not good because i am doing this for all 10 slots. Can i shrink this trigger somehow?
There are 3 lanes, 5 computers available.

  • LaneKararTakim1
    • Events
      • Time - Every 0.25 seconds of game time
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
        • Then - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Random integer number between 1 and 3) Equal to 1
              • zDevilSayiBot Not equal to 2
              • (Player 2 (Blue) controller) Equal to Computer
              • LaneKararBOT[2] Not equal to True
            • Then - Actions
              • Set zDevilSayiBot = (zDevilSayiBot + 1)
              • Set LaneKararBOT[2] = True
              • Unit Group - Add aiHero[2] to zDevilBotlaner
              • Unit - Order aiHero[2] to Attack-Move To (Center of DevilAltKule)
            • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Random integer number between 1 and 3) Equal to 2
              • zDevilSayiMid Not equal to 1
              • (Player 2 (Blue) controller) Equal to Computer
              • LaneKararBOT[2] Not equal to True
            • Then - Actions
              • Set zDevilSayiMid = (zDevilSayiMid + 1)
              • Set LaneKararBOT[2] = True
              • Unit Group - Add aiHero[2] to zDevilMidlaner
              • Unit - Order aiHero[2] to Attack-Move To (Center of DevilOrtaKule)
            • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Random integer number between 1 and 3) Equal to 3
              • zDevilSayiTop Not equal to 1
              • (Player 2 (Blue) controller) Equal to Computer
              • LaneKararBOT[2] Not equal to True
            • Then - Actions
              • Set zDevilSayiTop = (zDevilSayiTop + 1)
              • Set LaneKararBOT[2] = True
              • Unit Group - Add aiHero[2] to zDevilToplaner
              • Unit - Order aiHero[2] to Attack-Move To (Center of DevilUstKule)
            • Else - Actions
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
        • Then - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Random integer number between 1 and 3) Equal to 1
              • zDevilSayiBot Not equal to 2
              • (Player 3 (Teal) controller) Equal to Computer
              • LaneKararBOT[3] Not equal to True
And here is the another one. It is huge. I am not good at that.

  • BlazeLightningCastAIL
    • Events
      • Time - Every 2.00 seconds of game time
    • Conditions
    • Actions
      • Unit Group - Pick every unit in (Units within 800.00 of (Position of aiHero[2]) matching ((((Matching unit) is A Hero) Equal to True) and (((Matching unit) belongs to an enemy of ClanDevilPlayer) Equal to True))) and do (Actions)
        • Loop - Actions
          • Set TempUnit = (Picked unit)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Level of Blaze Lightning // for aiHero[2]) Equal to 1
              • (Life of TempUnit) Less than or equal to 400.00
              • (aiHero[2] is in zKacanlarDevil) Equal to False
            • Then - Actions
              • Unit - Order aiHero[2] to Special Archimonde - Finger Of Death TempUnit
              • Wait 0.75 seconds
              • Unit - Order aiHero[2] to Attack-Move To (Center of NextTarget[2])
              • Set TempUnit = No unit
            • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Level of Blaze Lightning // for aiHero[2]) Equal to 2
              • (Life of TempUnit) Less than or equal to 600.00
              • (aiHero[2] is in zKacanlarDevil) Equal to False
            • Then - Actions
              • Unit - Order aiHero[2] to Special Archimonde - Finger Of Death TempUnit
              • Wait 0.75 seconds
              • Unit - Order aiHero[2] to Attack-Move To (Center of NextTarget[2])
              • Set TempUnit = No unit
            • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Level of Blaze Lightning // for aiHero[2]) Equal to 3
              • (Life of TempUnit) Less than or equal to 600.00
              • (aiHero[2] is in zKacanlarDevil) Equal to False
            • Then - Actions
              • Unit - Order aiHero[2] to Special Archimonde - Finger Of Death TempUnit
              • Wait 0.75 seconds
              • Unit - Order aiHero[2] to Attack-Move To (Center of NextTarget[2])
              • Set TempUnit = No unit
            • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Level of Blaze Lightning // for aiHero[2]) Equal to 4
              • (Life of TempUnit) Less than or equal to 800.00
              • (aiHero[2] is in zKacanlarDevil) Equal to False
            • Then - Actions
              • Unit - Order aiHero[2] to Special Archimonde - Finger Of Death TempUnit
              • Wait 0.75 seconds
              • Unit - Order aiHero[2] to Attack-Move To (Center of NextTarget[2])
              • Set TempUnit = No unit
            • Else - Actions
      • Unit Group - Pick every unit in (Units within 800.00 of (Position of aiHero[3]) matching ((((Matching unit) is A Hero) Equal to True) and (((Matching unit) belongs to an enemy of ClanDevilPlayer) Equal to True))) and do (Actions)
        • Loop - Actions
          • Set TempUnit = (Picked unit)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Level of Blaze Lightning // for aiHero[3]) Equal to 1
              • (Life of TempUnit) Less than or equal to 400.00
              • (aiHero[3] is in zKacanlarDevil) Equal to False
            • Then - Actions
              • Unit - Order aiHero[3] to Special Archimonde - Finger Of Death TempUnit
              • Wait 0.75 seconds
              • Unit - Order aiHero[3] to Attack-Move To (Center of NextTarget[3])
              • Set TempUnit = No unit
            • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Level of Blaze Lightning // for aiHero[3]) Equal to 2
              • (Life of TempUnit) Less than or equal to 600.00
              • (aiHero[3] is in zKacanlarDevil) Equal to False
            • Then - Actions
              • Unit - Order aiHero[3] to Special Archimonde - Finger Of Death TempUnit
              • Wait 0.75 seconds
              • Unit - Order aiHero[3] to Attack-Move To (Center of NextTarget[3])
              • Set TempUnit = No unit
            • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Level of Blaze Lightning // for aiHero[3]) Equal to 3
              • (Life of TempUnit) Less than or equal to 600.00
              • (aiHero[3] is in zKacanlarDevil) Equal to False
            • Then - Actions
              • Unit - Order aiHero[3] to Special Archimonde - Finger Of Death TempUnit
              • Wait 0.75 seconds
              • Unit - Order aiHero[3] to Attack-Move To (Center of NextTarget[3])
              • Set TempUnit = No unit
            • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Level of Blaze Lightning // for aiHero[3]) Equal to 4
              • (Life of TempUnit) Less than or equal to 800.00
              • (aiHero[3] is in zKacanlarDevil) Equal to False
            • Then - Actions
              • Unit - Order aiHero[3] to Special Archimonde - Finger Of Death TempUnit
              • Wait 0.75 seconds
              • Unit - Order aiHero[3] to Attack-Move To (Center of NextTarget[3])
              • Set TempUnit = No unit
            • Else - Actions
      • Unit Group - Pick every unit in (Units within 800.00 of (Position of aiHero[4]) matching ((((Matching unit) is A Hero) Equal to True) and (((Matching unit) belongs to an enemy of ClanDevilPlayer) Equal to True))) and do (Actions)
        • Loop - Actions
          • Set TempUnit = (Picked unit)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Level of Blaze Lightning // for aiHero[4]) Equal to 1
              • (Life of TempUnit) Less than or equal to 400.00
              • (aiHero[4] is in zKacanlarDevil) Equal to False
            • Then - Actions
              • Unit - Order aiHero[4] to Special Archimonde - Finger Of Death TempUnit
              • Wait 0.75 seconds
              • Unit - Order aiHero[4] to Attack-Move To (Center of NextTarget[4])
              • Set TempUnit = No unit
            • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Level of Blaze Lightning // for aiHero[4]) Equal to 2
              • (Life of TempUnit) Less than or equal to 600.00
              • (aiHero[4] is in zKacanlarDevil) Equal to False
            • Then - Actions
              • Unit - Order aiHero[4] to Special Archimonde - Finger Of Death TempUnit
              • Wait 0.75 seconds
              • Unit - Order aiHero[4] to Attack-Move To (Center of NextTarget[4])
              • Set TempUnit = No unit
            • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Level of Blaze Lightning // for aiHero[4]) Equal to 3
              • (Life of TempUnit) Less than or equal to 600.00
              • (aiHero[4] is in zKacanlarDevil) Equal to False
            • Then - Actions
              • Unit - Order aiHero[4] to Special Archimonde - Finger Of Death TempUnit
              • Wait 0.75 seconds
              • Unit - Order aiHero[4] to Attack-Move To (Center of NextTarget[4])
              • Set TempUnit = No unit
            • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Level of Blaze Lightning // for aiHero[4]) Equal to 4
              • (Life of TempUnit) Less than or equal to 800.00
              • (aiHero[4] is in zKacanlarDevil) Equal to False
            • Then - Actions
              • Unit - Order aiHero[4] to Special Archimonde - Finger Of Death TempUnit
              • Wait 0.75 seconds
              • Unit - Order aiHero[4] to Attack-Move To (Center of NextTarget[4])
              • Set TempUnit = No unit
            • Else - Actions
      • Unit Group - Pick every unit in (Units within 800.00 of (Position of aiHero[5]) matching ((((Matching unit) is A Hero) Equal to True) and (((Matching unit) belongs to an enemy of ClanDevilPlayer) Equal to True))) and do (Actions)
        • Loop - Actions
          • Set TempUnit = (Picked unit)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Level of Blaze Lightning // for aiHero[5]) Equal to 1
              • (Life of TempUnit) Less than or equal to 400.00
              • (aiHero[5] is in zKacanlarDevil) Equal to False
            • Then - Actions
              • Unit - Order aiHero[5] to Special Archimonde - Finger Of Death TempUnit
              • Wait 0.75 seconds
              • Unit - Order aiHero[5] to Attack-Move To (Center of NextTarget[5])
              • Set TempUnit = No unit
            • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Level of Blaze Lightning // for aiHero[5]) Equal to 2
              • (Life of TempUnit) Less than or equal to 600.00
              • (aiHero[5] is in zKacanlarDevil) Equal to False
            • Then - Actions
              • Unit - Order aiHero[5] to Special Archimonde - Finger Of Death TempUnit
              • Wait 0.75 seconds
              • Unit - Order aiHero[5] to Attack-Move To (Center of NextTarget[5])
              • Set TempUnit = No unit
            • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Level of Blaze Lightning // for aiHero[5]) Equal to 3
              • (Life of TempUnit) Less than or equal to 600.00
              • (aiHero[5] is in zKacanlarDevil) Equal to False
            • Then - Actions
              • Unit - Order aiHero[5] to Special Archimonde - Finger Of Death TempUnit
              • Wait 0.75 seconds
              • Unit - Order aiHero[5] to Attack-Move To (Center of NextTarget[5])
              • Set TempUnit = No unit
            • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Level of Blaze Lightning // for aiHero[5]) Equal to 4
              • (Life of TempUnit) Less than or equal to 800.00
              • (aiHero[5] is in zKacanlarDevil) Equal to False
            • Then - Actions
              • Unit - Order aiHero[5] to Special Archimonde - Finger Of Death TempUnit
              • Wait 0.75 seconds
              • Unit - Order aiHero[5] to Attack-Move To (Center of NextTarget[5])
              • Set TempUnit = No unit
            • Else - Actions
      • Unit Group - Pick every unit in (Units within 800.00 of (Position of aiHero[6]) matching ((((Matching unit) is A Hero) Equal to True) and (((Matching unit) belongs to an enemy of ClanDevilPlayer) Equal to True))) and do (Actions)
        • Loop - Actions
          • Set TempUnit = (Picked unit)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Level of Blaze Lightning // for aiHero[6]) Equal to 1
              • (Life of TempUnit) Less than or equal to 400.00
              • (aiHero[6] is in zKacanlarDevil) Equal to False
            • Then - Actions
              • Unit - Order aiHero[6] to Special Archimonde - Finger Of Death TempUnit
              • Wait 0.75 seconds
              • Unit - Order aiHero[6] to Attack-Move To (Center of NextTarget[5])
              • Set TempUnit = No unit
            • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Level of Blaze Lightning // for aiHero[6]) Equal to 2
              • (Life of TempUnit) Less than or equal to 600.00
              • (aiHero[6] is in zKacanlarDevil) Equal to False
            • Then - Actions
              • Unit - Order aiHero[6] to Special Archimonde - Finger Of Death TempUnit
              • Wait 0.75 seconds
              • Unit - Order aiHero[6] to Attack-Move To (Center of NextTarget[5])
              • Set TempUnit = No unit
            • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Level of Blaze Lightning // for aiHero[6]) Equal to 3
              • (Life of TempUnit) Less than or equal to 600.00
              • (aiHero[6] is in zKacanlarDevil) Equal to False
            • Then - Actions
              • Unit - Order aiHero[6] to Special Archimonde - Finger Of Death TempUnit
              • Wait 0.75 seconds
              • Unit - Order aiHero[6] to Attack-Move To (Center of NextTarget[5])
              • Set TempUnit = No unit
            • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Level of Blaze Lightning // for aiHero[6]) Equal to 4
              • (Life of TempUnit) Less than or equal to 800.00
              • (aiHero[6] is in zKacanlarDevil) Equal to False
            • Then - Actions
              • Unit - Order aiHero[6] to Special Archimonde - Finger Of Death TempUnit
              • Wait 0.75 seconds
              • Unit - Order aiHero[6] to Attack-Move To (Center of NextTarget[5])
              • Set TempUnit = No unit
            • Else - Actions
      • Unit Group - Pick every unit in (Units within 800.00 of (Position of aiHero[8]) matching ((((Matching unit) is A Hero) Equal to True) and (((Matching unit) belongs to an enemy of ClanReaperPlayer) Equal to True))) and do (Actions)
        • Loop - Actions
          • Set TempUnit = (Picked unit)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Level of Blaze Lightning // for aiHero[8]) Equal to 1
              • (Life of TempUnit) Less than or equal to 400.00
              • (aiHero[8] is in zKacanlarReaper) Equal to False
            • Then - Actions
              • Unit - Order aiHero[8] to Special Archimonde - Finger Of Death TempUnit
              • Wait 0.75 seconds
              • Unit - Order aiHero[8] to Attack-Move To (Center of NextTarget[8])
              • Set TempUnit = No unit
            • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Level of Blaze Lightning // for aiHero[8]) Equal to 2
              • (Life of TempUnit) Less than or equal to 600.00
              • (aiHero[8] is in zKacanlarReaper) Equal to False
            • Then - Actions
              • Unit - Order aiHero[8] to Special Archimonde - Finger Of Death TempUnit
              • Wait 0.75 seconds
              • Unit - Order aiHero[8] to Attack-Move To (Center of NextTarget[8])
              • Set TempUnit = No unit
            • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Level of Blaze Lightning // for aiHero[8]) Equal to 3
              • (Life of TempUnit) Less than or equal to 800.00
              • (aiHero[8] is in zKacanlarReaper) Equal to False
            • Then - Actions
              • Unit - Order aiHero[8] to Special Archimonde - Finger Of Death TempUnit
              • Wait 0.75 seconds
              • Unit - Order aiHero[8] to Attack-Move To (Center of NextTarget[8])
              • Set TempUnit = No unit
            • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Level of Blaze Lightning // for aiHero[8]) Equal to 4
              • (Life of TempUnit) Less than or equal to 1000.00
              • (aiHero[8] is in zKacanlarReaper) Equal to False
            • Then - Actions
              • Unit - Order aiHero[8] to Special Archimonde - Finger Of Death TempUnit
              • Wait 0.75 seconds
              • Unit - Order aiHero[8] to Attack-Move To (Center of NextTarget[8])
              • Set TempUnit = No unit
            • Else - Actions
      • Unit Group - Pick every unit in (Units within 800.00 of (Position of aiHero[9]) matching ((((Matching unit) is A Hero) Equal to True) and (((Matching unit) belongs to an enemy of ClanReaperPlayer) Equal to True))) and do (Actions)
        • Loop - Actions
          • Set TempUnit = (Picked unit)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Level of Blaze Lightning // for aiHero[9]) Equal to 1
              • (Life of TempUnit) Less than or equal to 400.00
              • (aiHero[9] is in zKacanlarReaper) Equal to False
            • Then - Actions
              • Unit - Order aiHero[9] to Special Archimonde - Finger Of Death TempUnit
              • Wait 0.75 seconds
              • Unit - Order aiHero[9] to Attack-Move To (Center of NextTarget[9])
              • Set TempUnit = No unit
            • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Level of Blaze Lightning // for aiHero[9]) Equal to 2
              • (Life of TempUnit) Less than or equal to 600.00
              • (aiHero[9] is in zKacanlarReaper) Equal to False
            • Then - Actions
              • Unit - Order aiHero[9] to Special Archimonde - Finger Of Death TempUnit
              • Wait 0.75 seconds
              • Unit - Order aiHero[9] to Attack-Move To (Center of NextTarget[9])
              • Set TempUnit = No unit
            • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Level of Blaze Lightning // for aiHero[8]) Equal to 3
              • (Life of TempUnit) Less than or equal to 800.00
              • (aiHero[9] is in zKacanlarReaper) Equal to False
            • Then - Actions
              • Unit - Order aiHero[9] to Special Archimonde - Finger Of Death TempUnit
              • Wait 0.75 seconds
              • Unit - Order aiHero[9] to Attack-Move To (Center of NextTarget[9])
              • Set TempUnit = No unit
            • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Level of Blaze Lightning // for aiHero[8]) Equal to 4
              • (Life of TempUnit) Less than or equal to 1000.00
              • (aiHero[9] is in zKacanlarReaper) Equal to False
            • Then - Actions
              • Unit - Order aiHero[9] to Special Archimonde - Finger Of Death TempUnit
              • Wait 0.75 seconds
              • Unit - Order aiHero[9] to Attack-Move To (Center of NextTarget[9])
              • Set TempUnit = No unit
            • Else - Actions
      • Unit Group - Pick every unit in (Units within 800.00 of (Position of aiHero[10]) matching ((((Matching unit) is A Hero) Equal to True) and (((Matching unit) belongs to an enemy of ClanReaperPlayer) Equal to True))) and do (Actions)
        • Loop - Actions
          • Set TempUnit = (Picked unit)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Level of Blaze Lightning // for aiHero[10]) Equal to 1
              • (Life of TempUnit) Less than or equal to 400.00
              • (aiHero[10] is in zKacanlarReaper) Equal to False
            • Then - Actions
              • Unit - Order aiHero[10] to Special Archimonde - Finger Of Death TempUnit
              • Wait 0.75 seconds
              • Unit - Order aiHero[10] to Attack-Move To (Center of NextTarget[10])
              • Set TempUnit = No unit
            • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Level of Blaze Lightning // for aiHero[10]) Equal to 2
              • (Life of TempUnit) Less than or equal to 600.00
              • (aiHero[10] is in zKacanlarReaper) Equal to False
            • Then - Actions
              • Unit - Order aiHero[10] to Special Archimonde - Finger Of Death TempUnit
              • Wait 0.75 seconds
              • Unit - Order aiHero[10] to Attack-Move To (Center of NextTarget[10])
              • Set TempUnit = No unit
            • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Level of Blaze Lightning // for aiHero[10]) Equal to 3
              • (Life of TempUnit) Less than or equal to 800.00
              • (aiHero[10] is in zKacanlarReaper) Equal to False
            • Then - Actions
              • Unit - Order aiHero[10] to Special Archimonde - Finger Of Death TempUnit
              • Wait 0.75 seconds
              • Unit - Order aiHero[10] to Attack-Move To (Center of NextTarget[10])
              • Set TempUnit = No unit
            • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Level of Blaze Lightning // for aiHero[10]) Equal to 4
              • (Life of TempUnit) Less than or equal to 1000.00
              • (aiHero[10] is in zKacanlarReaper) Equal to False
            • Then - Actions
              • Unit - Order aiHero[10] to Special Archimonde - Finger Of Death TempUnit
              • Wait 0.75 seconds
              • Unit - Order aiHero[10] to Attack-Move To (Center of NextTarget[10])
              • Set TempUnit = No unit
            • Else - Actions
      • Unit Group - Pick every unit in (Units within 800.00 of (Position of aiHero[11]) matching ((((Matching unit) is A Hero) Equal to True) and (((Matching unit) belongs to an enemy of ClanReaperPlayer) Equal to True))) and do (Actions)
        • Loop - Actions
          • Set TempUnit = (Picked unit)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Level of Blaze Lightning // for aiHero[11]) Equal to 1
              • (Life of TempUnit) Less than or equal to 400.00
              • (aiHero[11] is in zKacanlarReaper) Equal to False
            • Then - Actions
              • Unit - Order aiHero[11] to Special Archimonde - Finger Of Death TempUnit
              • Wait 0.75 seconds
              • Unit - Order aiHero[11] to Attack-Move To (Center of NextTarget[11])
              • Set TempUnit = No unit
            • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Level of Blaze Lightning // for aiHero[11]) Equal to 2
              • (Life of TempUnit) Less than or equal to 600.00
              • (aiHero[11] is in zKacanlarReaper) Equal to False
            • Then - Actions
              • Unit - Order aiHero[11] to Special Archimonde - Finger Of Death TempUnit
              • Wait 0.75 seconds
              • Unit - Order aiHero[11] to Attack-Move To (Center of NextTarget[11])
              • Set TempUnit = No unit
            • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Level of Blaze Lightning // for aiHero[11]) Equal to 3
              • (Life of TempUnit) Less than or equal to 800.00
              • (aiHero[11] is in zKacanlarReaper) Equal to False
            • Then - Actions
              • Unit - Order aiHero[11] to Special Archimonde - Finger Of Death TempUnit
              • Wait 0.75 seconds
              • Unit - Order aiHero[11] to Attack-Move To (Center of NextTarget[11])
              • Set TempUnit = No unit
            • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Level of Blaze Lightning // for aiHero[11]) Equal to 4
              • (Life of TempUnit) Less than or equal to 1000.00
              • (aiHero[11] is in zKacanlarReaper) Equal to False
            • Then - Actions
              • Unit - Order aiHero[11] to Special Archimonde - Finger Of Death TempUnit
              • Wait 0.75 seconds
              • Unit - Order aiHero[11] to Attack-Move To (Center of NextTarget[11])
              • Set TempUnit = No unit
            • Else - Actions
      • Unit Group - Pick every unit in (Units within 800.00 of (Position of aiHero[12]) matching ((((Matching unit) is A Hero) Equal to True) and (((Matching unit) belongs to an enemy of ClanReaperPlayer) Equal to True))) and do (Actions)
        • Loop - Actions
          • Set TempUnit = (Picked unit)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Level of Blaze Lightning // for aiHero[12]) Equal to 1
              • (Life of TempUnit) Less than or equal to 400.00
              • (aiHero[12] is in zKacanlarReaper) Equal to False
            • Then - Actions
              • Unit - Order aiHero[12] to Special Archimonde - Finger Of Death TempUnit
              • Wait 0.75 seconds
              • Unit - Order aiHero[12] to Attack-Move To (Center of NextTarget[12])
              • Set TempUnit = No unit
            • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Level of Blaze Lightning // for aiHero[12]) Equal to 2
              • (Life of TempUnit) Less than or equal to 600.00
              • (aiHero[12] is in zKacanlarReaper) Equal to False
            • Then - Actions
              • Unit - Order aiHero[12] to Special Archimonde - Finger Of Death TempUnit
              • Wait 0.75 seconds
              • Unit - Order aiHero[12] to Attack-Move To (Center of NextTarget[12])
              • Set TempUnit = No unit
            • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Level of Blaze Lightning // for aiHero[12]) Equal to 3
              • (Life of TempUnit) Less than or equal to 800.00
              • (aiHero[12] is in zKacanlarReaper) Equal to False
            • Then - Actions
              • Unit - Order aiHero[12] to Special Archimonde - Finger Of Death TempUnit
              • Wait 0.75 seconds
              • Unit - Order aiHero[12] to Attack-Move To (Center of NextTarget[12])
              • Set TempUnit = No unit
            • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Level of Blaze Lightning // for aiHero[12]) Equal to 4
              • (Life of TempUnit) Less than or equal to 1000.00
              • (aiHero[12] is in zKacanlarReaper) Equal to False
            • Then - Actions
              • Unit - Order aiHero[12] to Special Archimonde - Finger Of Death TempUnit
              • Wait 0.75 seconds
              • Unit - Order aiHero[12] to Attack-Move To (Center of NextTarget[12])
              • Set TempUnit = No unit
            • Else - Actions
 
Last edited:

Uncle

Warcraft Moderator
Level 64
Joined
Aug 10, 2018
Messages
6,537
Regarding your first trigger, assuming each Computer player is basically the same, you can do something like this:
  • Example
    • Events
      • Time - Every 0.25 seconds of game time
    • Conditions
    • Actions
      • Player Group - Pick every player in ComputerGroup and do (Actions)
        • Loop - Actions
          • Set Variable PN = (Player number of (Picked player))
          • Set Variable Roll = (Random integer number between 1 and 3)
          • -------- --------
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • Roll Equal to 1
            • Then - Actions
              • Unit - Order aiHero[PN] to Attack-Move To AttackPoint1[PN]
            • Else - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • Roll Equal to 2
                • Then - Actions
                  • Unit - Order aiHero[PN] to Attack-Move To AttackPoint2[PN]
                • Else - Actions
                  • -------- Roll must be 3 if it's not equal to 1 or 2 --------
                  • Unit - Order aiHero[PN] to Attack-Move To AttackPoint3[PN]
Variables:
PN = Integer
Roll = Integer
ComputerGroup = Player Group
AttackPoint1/2/3 = Point (array)

You would set AttackPoint1/2/3 and Add all of the Computer players to the ComputerGroup at the start of the game. Use the computer's Player number (PN) as the [Index] in your Arrays to create clean triggers like this that remove the need to copy and paste things once for each player. This also removes a lot of unnecessary Conditions and makes your triggers much more efficient.

You can apply this same logic to your second trigger, although the Waits could make things more complicated since those Waits will delay every other Action in the trigger. I didn't look over the entire trigger (wall of text scared me away) so I could be missing something.

You probably want to look into memory leaks as well: Things That Leak
 
Last edited:
Level 17
Joined
Jun 2, 2009
Messages
1,137
Wow. You saved me from a lot of trouble. Thank you SO much for your help. Here is the current trigger.

  • LaneKararTakim1 Copy
    • Events
      • Time - Every 0.25 seconds of game time
    • Conditions
    • Actions
      • Player Group - Pick every player in ClanDevilPlayers and do (Actions)
        • Loop - Actions
          • Set PN = (Player number of (Picked player))
          • Set Roll = (Random integer number between 1 and 3)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
            • Then - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • Roll Equal to 1
                  • zDevilSayiBot Not equal to 2
                  • ((Picked player) controller) Equal to Computer
                  • LaneKararBOT[(Player number of (Picked player))] Not equal to True
                • Then - Actions
                  • Set zDevilSayiBot = (zDevilSayiBot + 1)
                  • Set LaneKararBOT[(Player number of (Picked player))] = True
                  • Unit Group - Add aiHero[(Player number of (Picked player))] to zDevilLanerBOT
                  • Unit - Order aiHero[(Player number of (Picked player))] to Attack-Move To (Center of DevilAltKule)
                • Else - Actions
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • Roll Equal to 2
                      • zDevilSayiTop Not equal to 2
                      • ((Picked player) controller) Equal to Computer
                      • LaneKararBOT[(Player number of (Picked player))] Not equal to True
                    • Then - Actions
                      • Set zDevilSayiTop = (zDevilSayiTop + 1)
                      • Set LaneKararBOT[(Player number of (Picked player))] = True
                      • Unit Group - Add aiHero[(Player number of (Picked player))] to zDevilLanerTOP
                      • Unit - Order aiHero[(Player number of (Picked player))] to Attack-Move To (Center of DevilUstKule)
                    • Else - Actions
                      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                        • If - Conditions
                          • Roll Equal to 3
                          • zDevilSayiMid Not equal to 1
                          • ((Picked player) controller) Equal to Computer
                          • LaneKararBOT[(Player number of (Picked player))] Not equal to True
                        • Then - Actions
                          • Set zDevilSayiMid = (zReaperSayiMid + 1)
                          • Set LaneKararBOT[(Player number of (Picked player))] = True
                          • Unit Group - Add aiHero[(Player number of (Picked player))] to zDevilLanerMID
                          • Unit - Order aiHero[(Player number of (Picked player))] to Attack-Move To (Center of DevilOrtaKule)
                        • Else - Actions
            • Else - Actions
There are 3 lanes within my map. And i am turning off this trigger after few seconds. Each computer have been selecting for specific lanes. This includes only team 1 (for 5 ai heroes) and i will do it for other team too.

Thank you for your help my friend. Now i am trying to shorten my other trigger that posted below of my post.

Edit: Ah let me explain something about second trigger. I just want to make them cast X spell to picked enemy if they are below X health. Wait is not necessary actually. Trigger is works well but it is huge...
 
Last edited:

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,198
Edit: Ah let me explain something about second trigger. I just want to make them cast X spell to picked enemy if they are below X health. Wait is not necessary actually. Trigger is works well but it is huge...
Periodically for each AI controlled unit with the spell you would need to scan nearby units and check their health. If at least 1 target is found then try to cast the ability at them. This is usually referred to as tactical AI.

Checking nearby units can be expensive so the approach might not scale well to hundreds of units that need to cast the ability. If such scaling is needed you would need to stagger the checks over some period of time rather than performing them all at once.
 
Level 25
Joined
Sep 26, 2009
Messages
2,378
I chose a different approach - your triggers have a lot of duplicate actions and conditions and I tried to eliminate that.
Also, I see that you are leaking points and unit groups (see Things That Leak) as Uncle pointed out.

In the first trigger, your conditions are basically same (just the comparing values are different). What the conditions/actions depend on is player's number and the randomly chosen number between 1 and 3.
So in my approach I prepared the comparing values in an array, where the array's indices match the randomly chosen number.
This is how the trigger would look like:

  • LaneKararTakim
    • Events
      • Time - Every 0.25 seconds of game time
    • Conditions
    • Actions
      • -------- This should be in some MapInitialization trigger --------
      • -------- The array indices match the random number --------
      • Set VariableSet zDevilSayiBotChecks[1] = 2
      • Set VariableSet zDevilSayiBotChecks[2] = 1
      • Set VariableSet zDevilSayiBotChecks[3] = 1
      • Set VariableSet targetRegions[1] = DevilAltKule <gen>
      • Set VariableSet targetRegions[2] = DevilOrtaKule <gen>
      • Set VariableSet targetRegions[3] = DevilUstKule <gen>
      • -------- ---------------------------------- --------
      • -------- The actual trigger --------
      • Player Group - Pick every player in ClanDevilPlayers and do (Actions)
        • Loop - Actions
          • Set VariableSet randomNumber = (Random integer number between 1 and 3)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • ((Picked player) controller) Equal to Computer
              • LaneKararBOT[(Player number of (Picked player))] Not equal to True
              • zDevilSayiBot Not equal to zDevilSayiBotChecks[randomNumber]
            • Then - Actions
              • Set VariableSet zDevilSayiBot = (zDevilSayiBot + 1)
              • Set VariableSet LaneKararBOT[(Player number of (Picked player))] = True
              • Unit Group - Add aiHero[(Player number of (Picked player))] to zDevilLanerBot
              • Set VariableSet tempLoc = (Center of targetRegions[randomNumber])
              • Unit - Order aiHero[(Player number of (Picked player))] to Attack-Move To tempLoc
              • Custom script: call RemoveLocation(udg_tempLoc)
            • Else - Actions


In the second trigger, I see that all the conditions and actions are the same for each player. The only difference I noticed is that the health requirement for using Finger of Death is different for players 2-6 (400/600/600/800) than for players 8-12 (400/600/800/1000).
The approach I chose was to create two player groups (one for players 2-6, second for players 8-12) and put the groups in an array to help me calculate index for healthRequirement. While the setup is in the same trigger, it should definitely be in some map initialization.
The reason why I chose to create two player groups is because those groups can be used in any other trigger where some conditions depend on whether the AI belongs to one group or another.
Also, in this second trigger I didn't really bother cleaning up leaks, because the waits in the loops break everything (basically, since the trigger runs every 2 seconds, but the "pick every unit within..." action has a 0.75 second wait for each picked unit, then all you need is at least 3 units to get a total wait time of over 2.25 seconds which will cause leaks anyway).

  • BlazeLightningCastAIL
    • Events
      • Time - Every 2.00 seconds of game time
    • Conditions
    • Actions
      • -------- This should be in some MapInitialization trigger --------
      • -------- The array indices match the level of Blaze Lightning --------
      • -------- group 1 = players 2-6 --------
      • Set VariableSet healthRequirement[1] = 400.00
      • Set VariableSet healthRequirement[2] = 600.00
      • Set VariableSet healthRequirement[3] = 600.00
      • Set VariableSet healthRequirement[4] = 800.00
      • Player Group - Add Player 2 (Blue) to aiPlayerGroup1
      • -------- ... set other players here... --------
      • Player Group - Add Player 6 (Orange) to aiPlayerGroup1
      • -------- ---------------------------------- --------
      • -------- The array indices match the level of Blaze Lightning + 4 --------
      • -------- group 2 = players 8-12 --------
      • Set VariableSet healthRequirement[5] = 400.00
      • Set VariableSet healthRequirement[6] = 600.00
      • Set VariableSet healthRequirement[7] = 800.00
      • Set VariableSet healthRequirement[8] = 1000.00
      • Player Group - Add Player 8 (Pink) to aiPlayerGroup2
      • -------- ... set other players here... --------
      • Player Group - Add Player 12 (Brown) to aiPlayerGroup2
      • -------- ---------------------------------- --------
      • -------- add both player groups to the player group array. --------
      • -------- We will use the array's index to calculate indices for the health requirements --------
      • Set VariableSet aiPlayerGroups[1] = aiPlayerGroup1
      • Set VariableSet aiPlayerGroups[2] = aiPlayerGroup2
      • -------- ---------------------------------- --------
      • -------- ---------------------------------- --------
      • -------- The actual trigger --------
      • For each (Integer playerGroupIndex) from 1 to 2, do (Actions)
        • Loop - Actions
          • Player Group - Pick every player in aiPlayerGroups[playerGroupIndex] and do (Actions)
            • Loop - Actions
              • Set VariableSet tempLoc = (Position of aiHero[(Player number of (Picked player))])
              • Custom script: set bj_wantDestroyGroup = true
              • Unit Group - Pick every unit in (Units within 800.00 of tempLoc matching ((((Matching unit) is A Hero) Equal to True) and (((Matching unit) belongs to an enemy of ClanDevilPlayer.) Equal to True)).) and do (Actions)
                • Loop - Actions
                  • Set VariableSet TempUnit = (Picked unit)
                  • Set VariableSet abilityLevel = (Level of Blaze Lightning for TempUnit)
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • abilityLevel Greater than 0
                      • (Life of TempUnit) Less than or equal to healthRequirement[(abilityLevel + (4 x (playerGroupIndex - 1)))]
                      • (aiHero[(Player number of (Picked player))] is in zKacanlarDevil.) Equal to False
                    • Then - Actions
                      • Unit - Order aiHero[(Player number of (Picked player))] to Special Archimonde - Finger Of Death TempUnit
                      • Wait 0.75 seconds
                      • Unit - Order aiHero[(Player number of (Picked player))] to Move To (Center of NextTarget[(Player number of (Picked player))])
                    • Else - Actions
 
Level 17
Joined
Jun 2, 2009
Messages
1,137
I chose a different approach - your triggers have a lot of duplicate actions and conditions and I tried to eliminate that.
Also, I see that you are leaking points and unit groups (see Things That Leak) as Uncle pointed out.

In the first trigger, your conditions are basically same (just the comparing values are different). What the conditions/actions depend on is player's number and the randomly chosen number between 1 and 3.
So in my approach I prepared the comparing values in an array, where the array's indices match the randomly chosen number.
This is how the trigger would look like:

  • LaneKararTakim
    • Events
      • Time - Every 0.25 seconds of game time
    • Conditions
    • Actions
      • -------- This should be in some MapInitialization trigger --------
      • -------- The array indices match the random number --------
      • Set VariableSet zDevilSayiBotChecks[1] = 2
      • Set VariableSet zDevilSayiBotChecks[2] = 1
      • Set VariableSet zDevilSayiBotChecks[3] = 1
      • Set VariableSet targetRegions[1] = DevilAltKule <gen>
      • Set VariableSet targetRegions[2] = DevilOrtaKule <gen>
      • Set VariableSet targetRegions[3] = DevilUstKule <gen>
      • -------- ---------------------------------- --------
      • -------- The actual trigger --------
      • Player Group - Pick every player in ClanDevilPlayers and do (Actions)
        • Loop - Actions
          • Set VariableSet randomNumber = (Random integer number between 1 and 3)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • ((Picked player) controller) Equal to Computer
              • LaneKararBOT[(Player number of (Picked player))] Not equal to True
              • zDevilSayiBot Not equal to zDevilSayiBotChecks[randomNumber]
            • Then - Actions
              • Set VariableSet zDevilSayiBot = (zDevilSayiBot + 1)
              • Set VariableSet LaneKararBOT[(Player number of (Picked player))] = True
              • Unit Group - Add aiHero[(Player number of (Picked player))] to zDevilLanerBot
              • Set VariableSet tempLoc = (Center of targetRegions[randomNumber])
              • Unit - Order aiHero[(Player number of (Picked player))] to Attack-Move To tempLoc
              • Custom script: call RemoveLocation(udg_tempLoc)
            • Else - Actions


In the second trigger, I see that all the conditions and actions are the same for each player. The only difference I noticed is that the health requirement for using Finger of Death is different for players 2-6 (400/600/600/800) than for players 8-12 (400/600/800/1000).
The approach I chose was to create two player groups (one for players 2-6, second for players 8-12) and put the groups in an array to help me calculate index for healthRequirement. While the setup is in the same trigger, it should definitely be in some map initialization.
The reason why I chose to create two player groups is because those groups can be used in any other trigger where some conditions depend on whether the AI belongs to one group or another.
Also, in this second trigger I didn't really bother cleaning up leaks, because the waits in the loops break everything (basically, since the trigger runs every 2 seconds, but the "pick every unit within..." action has a 0.75 second wait for each picked unit, then all you need is at least 3 units to get a total wait time of over 2.25 seconds which will cause leaks anyway).

  • BlazeLightningCastAIL
    • Events
      • Time - Every 2.00 seconds of game time
    • Conditions
    • Actions
      • -------- This should be in some MapInitialization trigger --------
      • -------- The array indices match the level of Blaze Lightning --------
      • -------- group 1 = players 2-6 --------
      • Set VariableSet healthRequirement[1] = 400.00
      • Set VariableSet healthRequirement[2] = 600.00
      • Set VariableSet healthRequirement[3] = 600.00
      • Set VariableSet healthRequirement[4] = 800.00
      • Player Group - Add Player 2 (Blue) to aiPlayerGroup1
      • -------- ... set other players here... --------
      • Player Group - Add Player 6 (Orange) to aiPlayerGroup1
      • -------- ---------------------------------- --------
      • -------- The array indices match the level of Blaze Lightning + 4 --------
      • -------- group 2 = players 8-12 --------
      • Set VariableSet healthRequirement[5] = 400.00
      • Set VariableSet healthRequirement[6] = 600.00
      • Set VariableSet healthRequirement[7] = 800.00
      • Set VariableSet healthRequirement[8] = 1000.00
      • Player Group - Add Player 8 (Pink) to aiPlayerGroup2
      • -------- ... set other players here... --------
      • Player Group - Add Player 12 (Brown) to aiPlayerGroup2
      • -------- ---------------------------------- --------
      • -------- add both player groups to the player group array. --------
      • -------- We will use the array's index to calculate indices for the health requirements --------
      • Set VariableSet aiPlayerGroups[1] = aiPlayerGroup1
      • Set VariableSet aiPlayerGroups[2] = aiPlayerGroup2
      • -------- ---------------------------------- --------
      • -------- ---------------------------------- --------
      • -------- The actual trigger --------
      • For each (Integer playerGroupIndex) from 1 to 2, do (Actions)
        • Loop - Actions
          • Player Group - Pick every player in aiPlayerGroups[playerGroupIndex] and do (Actions)
            • Loop - Actions
              • Set VariableSet tempLoc = (Position of aiHero[(Player number of (Picked player))])
              • Custom script: set bj_wantDestroyGroup = true
              • Unit Group - Pick every unit in (Units within 800.00 of tempLoc matching ((((Matching unit) is A Hero) Equal to True) and (((Matching unit) belongs to an enemy of ClanDevilPlayer.) Equal to True)).) and do (Actions)
                • Loop - Actions
                  • Set VariableSet TempUnit = (Picked unit)
                  • Set VariableSet abilityLevel = (Level of Blaze Lightning for TempUnit)
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • abilityLevel Greater than 0
                      • (Life of TempUnit) Less than or equal to healthRequirement[(abilityLevel + (4 x (playerGroupIndex - 1)))]
                      • (aiHero[(Player number of (Picked player))] is in zKacanlarDevil.) Equal to False
                    • Then - Actions
                      • Unit - Order aiHero[(Player number of (Picked player))] to Special Archimonde - Finger Of Death TempUnit
                      • Wait 0.75 seconds
                      • Unit - Order aiHero[(Player number of (Picked player))] to Move To (Center of NextTarget[(Player number of (Picked player))])
                    • Else - Actions
Wow you are amazing. Tonight i am going to check it. Let me explain what should i need for my ai.
I have created AI system for my AoS/Moba game. The hero that i mentioned are casting Finger of Death to random enemy hero below x health.
This is only for one hero. I just want to make AI heroes to cast spells on enemy heroes and i need a good template about that. At first i am not going to create advanced system. I just want to expecting that.

Both of the teams have 5 players. It doesn't matter which ai hero casts the spell i have specified on which enemy hero. By the way values are incorrect. It has 400/600/800/1000 my bad.

Tonight i will read your post carefully and try to implement it and let you know about it.

Edit: It seems you are calculation hit point of caster. I am looking for the target HP Threshold. Still working on it.
Edit2: Currently i cannot test it with my current computer. Is it gonna work? I think i can calculate 10 players at once this time.

  • BlazeLightningCastAIL Copy 2
    • Events
      • Time - Every 2.00 seconds of game time
    • Conditions
    • Actions
      • -------- Picking every unit which learned Blaze Lightning spell --------
      • Unit Group - Pick every unit in AISpellBlazeLightning and do (Actions)
        • Loop - Actions
          • -------- Setting temporary location of unit which have Blaze Lightning --------
          • Set TempLoc = (Position of aiHero[(Player number of (Picked player))])
          • -------- Checking enemies within 800 range of Blaze Lightning caster --------
          • Unit Group - Pick every unit in (Units within 800.00 of TempLoc matching ((((Matching unit) is A Hero) Equal to True) and (((Matching unit) belongs to an enemy of (Owner of (Picked unit))) Equal to True))) and do (Actions)
            • Loop - Actions
              • -------- Enemy hero found --------
              • Set BlazeLightningTarget = (Picked unit)
              • -------- Now we will detect health threshold for the cast spell. --------
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Level of Blaze Lightning // for TempUnit) Equal to 1
                  • (Life of BlazeLightningTarget) Less than or equal to 400.00
                • Then - Actions
                  • Unit - Order TempUnit to Special Archimonde - Finger Of Death BlazeLightningTarget
                  • Wait 0.75 seconds
                  • Unit - Order aiHero[(Player number of (Owner of (Picked unit)))] to Attack-Move To (Center of NextTarget[(Player number of (Owner of (Picked unit)))])
                  • Game - Display to (All players) the text: ehe oldu mu
                  • Set TempUnit = No unit
                • Else - Actions
  • BlazeLightningCastSetupYeni Copy
    • Events
      • Unit - A unit Learns a skill
    • Conditions
      • (Learned Hero Skill) Equal to Blaze Lightning //
    • Actions
 
Last edited:
Level 13
Joined
Oct 16, 2010
Messages
731
Sorry I didn't really look over much of this but I did notice that you are using waits to order them to move after casting spells. Instead you could have a seperate trigger that catches a finished or cancelled spell and orders their next movement from that? That would remove the waits?
 
Level 25
Joined
Sep 26, 2009
Messages
2,378
Edit2: Currently i cannot test it with my current computer. Is it gonna work? I think i can calculate 10 players at once this time.
The waits in your trigger will cause your trigger to not behave as expected, because the waits stack on top of each other.
It also makes it harder to clean up any memory leaks. In your latest trigger, you create 2 memory leaks per unit in AISpellBlazeLightning every 2 seconds.
While that may not be much, if your map's other triggers also do not clean up leaks, then this may affect your map's performance after a while (i.e. in late game).

Apart from that, the trigger won't do anything, because you are ordering TempUnit to cast Finger of Death, but you did not set who TempUnit is.

Also, this is confusing to me:
  • Unit - Order aiHero[(Player number of (Owner of (Picked unit)))] to Attack-Move To (Center of NextTarget[(Player number of (Owner of (Picked unit)))])
In your first trigger you ordered the aiHero[x] to cast Finger of Death on TempUnit, then ordered aiHero[x] to attack-move to NextTarget[x].
In your latest trigger you actually order aiHero[owner of BlazeLightningTarget] to attack-move to NextTarget[owner of BlazeLightningTarget]

Edit: It seems you are calculation hit point of caster. I am looking for the target HP Threshold. Still working on it.
Well, I was just using the same variable names as you had in your original trigger - I don't know how you want this to work or what each variable represents in your map

Both of the teams have 5 players. It doesn't matter which ai hero casts the spell i have specified on which enemy hero. By the way values are incorrect. It has 400/600/800/1000 my bad.
That's why it is always best approach to have these values defined somewhere only once (be it in a condition or in an array) - that way there is only a single source of truth and you avoid misconfigurations like this :)
I prefer setting up the values in some variable beforehand and use the variable in conditions rather than using raw values in conditions, because if I need to change a value, I don't have to scroll through hundred lines of code to find it.

The hero that i mentioned are casting Finger of Death to random enemy hero below x health.
This is only for one hero. I just want to make AI heroes to cast spells on enemy heroes and i need a good template about that. At first i am not going to create advanced system. I just want to expecting that.
Alright, correct me if I am wrong, but your Finger of Death has cooldown and should be used on a single unit at a time, right?
This trigger may be close to what you want - notice that I create a unit group (tempGroup) - this unit group already checks if unit has low enough health to be valid target for the spell, and then I just pick a single random unit from the unit group.
  • Untitled Trigger 001
    • Events
      • Time - Every 2.00 seconds of game time
    • Conditions
    • Actions
      • Set VariableSet healthRequirement[1] = 400.00
      • Set VariableSet healthRequirement[2] = 600.00
      • Set VariableSet healthRequirement[3] = 800.00
      • Set VariableSet healthRequirement[4] = 1000.00
      • Unit Group - Pick every unit in AISpellBlazeLightning and do (Actions)
        • Loop - Actions
          • Set VariableSet abilityLevel = (Level of Blaze Lightning for (Picked unit))
          • Set VariableSet tempPoint = (Position of (Picked unit))
          • -------- Note: the text is cut off in the action below, but what I do is also check if health of (Matching unit) less than or equal to healthRequirement[abilityLevel] --------
          • Set VariableSet tempGroup = (Units within 800.00 of tempPoint matching ((((Triggering unit) is A Hero) Equal to True) and ((((Matching unit) belongs to an enemy of (Owner of (Picked unit)).) Equal to True) and ((Life of (Matching unit)) Less than or equal to healthRequirement[abilityLev
          • Set VariableSet tempUnit = (Random unit from tempGroup)
          • Custom script: call RemoveLocation(udg_tempPoint)
          • Custom script: call DestroyGroup(udg_tempGroup)
          • Unit - Order (Picked unit) to Special Archimonde - Finger Of Death tempUnit
          • Wait 0.75 seconds
          • Set VariableSet tempPoint = (Center of NextTarget[(Player number of (Picked player))])
          • Unit - Order (Picked unit) to Attack-Move To tempPoint
          • Custom script: call RemoveLocation(udg_tempPoint)
But the trigger will probably be still buggy due to the 0.75 second wait, because if I remember correctly, (Picked unit) is a global variable. If I am correct, then two instances of this trigger running at the same time would overwrite who the (picked unit) is.
I would actually solve this issue by using a MUI indexing/deindexing approach.
The trigger would look like this:
  • Untitled Trigger 001
    • Events
      • Time - Every 2.00 seconds of game time
    • Conditions
    • Actions
      • Set VariableSet healthRequirement[1] = 400.00
      • Set VariableSet healthRequirement[2] = 600.00
      • Set VariableSet healthRequirement[3] = 800.00
      • Set VariableSet healthRequirement[4] = 1000.00
      • Unit Group - Pick every unit in AISpellBlazeLightning and do (Actions)
        • Loop - Actions
          • Set VariableSet abilityLevel = (Level of Blaze Lightning for (Picked unit))
          • Set VariableSet tempPoint = (Position of (Picked unit))
          • -------- Note: the text is cut off in the action below, but what I do is also check if health of (Matching unit) less than or equal to healthRequirement[abilityLevel] --------
          • Set VariableSet tempGroup = (Units within 800.00 of tempPoint matching ((((Triggering unit) is A Hero) Equal to True) and ((((Matching unit) belongs to an enemy of (Owner of (Picked unit)).) Equal to True) and ((Life of (Matching unit)) Less than or equal to healthRequirement[abilityLev
          • Set VariableSet tempUnit = (Random unit from tempGroup)
          • Custom script: call RemoveLocation(udg_tempPoint)
          • Custom script: call DestroyGroup(udg_tempGroup)
          • Unit - Order (Picked unit) to Special Archimonde - Finger Of Death tempUnit
          • -------- ------------------------------------------------------ --------
          • -------- Index the picked unit, the delay and the target location --------
          • Set VariableSet delayedAttackMoveIndex = (delayedAttackMoveIndex + 1)
          • Set VariableSet delayedAttackMoveUnit[delayedAttackMoveIndex] = (Picked unit)
          • Set VariableSet delayedAttackMoveTimeLeft[delayedAttackMoveIndex] = 0.75
          • Set VariableSet delayedAttackMoveLocation[delayedAttackMoveIndex] = (Center of NextTarget[(Player number of (Picked player))])
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • delayedAttackMoveIndex Equal to 1
            • Then - Actions
              • Trigger - Turn on (This trigger)
            • Else - Actions
And the trigger below would serve to replace the original Wait XX seconds actions:
  • Delayed AttackMove Loop
    • Events
      • Time - Every 0.25 seconds of game time
    • Conditions
    • Actions
      • -------- This trigger is TURNED OFF by default --------
      • For each (Integer loopIndex) from 1 to delayedAttackMoveIndex, do (Actions)
        • Loop - Actions
          • Set VariableSet delayedAttackMoveTimeLeft[loopIndex] = (delayedAttackMoveTimeLeft[loopIndex] - 0.25)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • delayedAttackMoveTimeLeft[loopIndex] Less than or equal to 0.00
            • Then - Actions
              • -------- Order unit to attack move to target location --------
              • Unit - Order delayedAttackMoveUnit[loopIndex] to Attack-Move To delayedAttackMoveLocation[loopIndex]
              • -------- Remove the location to prevent memory leak --------
              • Custom script: call RemoveLocation(udg_delayedAttackMoveLocation[udg_loopIndex])
              • -------- Deindex unit --------
              • Set VariableSet delayedAttackMoveLocation[loopIndex] = delayedAttackMoveLocation[delayedAttackMoveIndex]
              • Set VariableSet delayedAttackMoveTimeLeft[loopIndex] = delayedAttackMoveTimeLeft[delayedAttackMoveIndex]
              • Set VariableSet delayedAttackMoveUnit[loopIndex] = delayedAttackMoveUnit[delayedAttackMoveIndex]
              • Set VariableSet delayedAttackMoveIndex = (delayedAttackMoveIndex - 1)
              • Set VariableSet loopIndex = (loopIndex - 1)
            • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • delayedAttackMoveIndex Equal to 0
        • Then - Actions
          • Trigger - Turn off (This trigger)
        • Else - Actions
But alas, someone else may know of a better way to do a delayed action that would not block the first trigger
 
Level 17
Joined
Jun 2, 2009
Messages
1,137

First of all i want to thank you so much and i owe you apologize. Actually i don't need the wait trigger. I just wanted to make it sure it will wait for the cast animation. Now i am going to work on it now. By the way my method probably not the best. That means you can suggest me anything. I just want to make them cast finger of death to random enemy hero within range. Now i am going to read your message carefully and start to work on it. English is not my native language and it would take some time for me. I will show you the final version after i done. I know there are few questions still i haven't answered, first let my brain process the trigger and your message :D

But alas, someone else may know of a better way to do a delayed action that would not block the first trigger
If we are talking about the wait, it is not required actually.
 
Level 25
Joined
Sep 26, 2009
Messages
2,378
If we are talking about the wait, it is not required actually.
Well, it kind of is required.
If you do just this in your trigger:
  • Unit - Order (Picked unit) to Special Archimonde - Finger Of Death tempUnit
  • Unit - Order (Picked unit) to Attack-Move To tempPoint
then the first order (casting finger of death) is immediately overwritten by the second order (attack-move to point) - meaning the unit would never cast finger of death.

But @Karzama made a good point. You could have a second trigger that is fired after unit casts the Blaze Lightning ability and order the unit to attack-move somewhere.
Something like this:
  • Untitled Trigger 001
    • Events
      • Unit - A unit Stops casting an ability
    • Conditions
      • (Ability being cast) Equal to Blaze Lightning
      • ((Triggering unit) is in AISpellBlazeLightning.) Equal to True
    • Actions
      • Set VariableSet tempLoc = (Center of NextTarget[(Player number of (Owner of (Triggering unit)))])
      • Unit - Order (Triggering unit) to Attack-Move To tempLoc
      • Custom script: call RemoveLocation(udg_tempLoc)
This will trigger when unit successfully finishes casting an ability OR when unit is interrupted while casting the ability (i.e. getting stunned)
 
Level 17
Joined
Jun 2, 2009
Messages
1,137
Well, it kind of is required.
If you do just this in your trigger:
  • Unit - Order (Picked unit) to Special Archimonde - Finger Of Death tempUnit
  • Unit - Order (Picked unit) to Attack-Move To tempPoint
then the first order (casting finger of death) is immediately overwritten by the second order (attack-move to point) - meaning the unit would never cast finger of death.

But @Karzama made a good point. You could have a second trigger that is fired after unit casts the Blaze Lightning ability and order the unit to attack-move somewhere.
Something like this:
  • Untitled Trigger 001
    • Events
      • Unit - A unit Stops casting an ability
    • Conditions
      • (Ability being cast) Equal to Blaze Lightning
      • ((Triggering unit) is in AISpellBlazeLightning.) Equal to True
    • Actions
      • Set VariableSet tempLoc = (Center of NextTarget[(Player number of (Owner of (Triggering unit)))])
      • Unit - Order (Triggering unit) to Attack-Move To tempLoc
      • Custom script: call RemoveLocation(udg_tempLoc)
This will trigger when unit successfully finishes casting an ability OR when unit is interrupted while casting the ability (i.e. getting stunned)
Hmm ok that explains why i have put wait in here. By the way currently i am working on ai stuck on specific regions. It is tedious and difficult task to do. I would like to share the trigger with you but all triggers are interconnected and i have to share dozens of triggers as you can imagine. Since 2002 i have created many maps and creating ai, telling it how to run, when to fallback and where to fallback etc etc is definitely most difficult thing to me. When i am done probably i will share it as "ai system" in the hive.
 
Level 17
Joined
Jun 2, 2009
Messages
1,137
Sorry i was working on my ai lanes since 2 days and it is difficult task. Now here is the final form of my trigger. Is there any downside of this one? Your system far more advanced than mine i can see that. But what about this one?

  • BlazeLightningCastZEKIHALI
    • Events
      • Time - Every 2.00 seconds of game time
    • Conditions
    • Actions
      • Unit Group - Pick every unit in (Random 10 units from BlazeLightningGroup) and do (Actions)
        • Loop - Actions
          • Unit Group - Pick every unit in (Units within 800.00 of (Position of (Picked unit)) matching ((((Matching unit) is A Hero) Equal to True) and (((Matching unit) belongs to an enemy of (Owner of (Picked unit))) Equal to True))) and do (Actions)
            • Loop - Actions
              • Set TempUnit = (Picked unit)
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Level of Blaze Lightning // for (Picked unit)) Equal to 1
                  • (Life of TempUnit) Less than or equal to 400.00
                • Then - Actions
                  • Unit - Order (Picked unit) to Special Archimonde - Finger Of Death TempUnit
                  • Wait 0.75 seconds
                  • Unit - Order (Picked unit) to Attack-Move To (Center of NextTarget[(Player number of (Owner of (Picked unit)))])
                  • Set TempUnit = No unit
                • Else - Actions
I know there are many flaws on his trigger but it has not to be a "perfect" i just want to make them cast spells on enemy heroes. Making it perfect is my next goal. By the way i would like to share my ai system with yours but it is huge and i have to share many triggers about it. Now i will work on this trigger ad let you know about it. By the way i believe @Nichilus is right. Wait action in the loop making the code not working. I have tested it by myself.

  • DevilAttackYeniDenemeOrj
    • Events
      • Time - Every 2.00 seconds of game time
    • Conditions
    • Actions
      • For each (Integer A) from 1 to 12, do (Actions)
        • Loop - Actions
          • Unit Group - Pick every unit in (Units within 500.00 of (Position of aiHero[(Integer A)]) matching ((((Matching unit) is in zCreepsDevil) Equal to True) and ((((Matching unit) is alive) Equal to True) and (((Matching unit) belongs to an ally of (Owner of aiHero[(Integer A)])) Equal to True) and do (Actions)
            • Loop - Actions
              • Wait 0.70 seconds
              • Game - Display to (All players) for 1.00 seconds the text: (Name of (Picked unit))
              • Set TempLoc = (Center of NextTarget[(Integer A)])
              • Unit - Order aiHero[(Integer A)] to Attack-Move To TempLoc
              • Custom script: call RemoveLocation (udg_TempLoc)
This trigger is works when i remove Wait 0.70 seconds.
 
Last edited:
Status
Not open for further replies.
Top