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

AI Problem

Status
Not open for further replies.
Level 7
Joined
May 23, 2011
Messages
179
Recently i was making a Map and the Leader of Microtriggers Ent. Here comes a problem. I am making a hero defense AI. The problem with the AI is that the AI will sometimes disobey the trigger :
commands
  • Unit Attaked Admiral Config AI
    • Events
      • Unit - A unit Is attacked
    • Conditions
      • Or - Any (Conditions) are true
        • Conditions
          • (Owner of (Triggering unit)) Equal to Player 1 (Red)
          • (Owner of (Triggering unit)) Equal to Player 2 (Blue)
          • (Owner of (Triggering unit)) Equal to Player 3 (Teal)
          • (Owner of (Triggering unit)) Equal to Player 4 (Purple)
          • (Owner of (Triggering unit)) Equal to Player 5 (Yellow)
      • ((Owner of (Triggering unit)) controller) Equal to Computer
      • ((Triggering unit) is A Hero) Equal to True
    • Actions
      • -------- Hero --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • ((Owner of (Triggering unit)) controller) Equal to Computer
          • ((Triggering unit) is A Hero) Equal to True
          • (Percentage life of (Triggering unit)) Greater than or equal to 38.00
        • Then - Actions
          • Unit - Order (Triggering unit) to Attack (Attacking unit)
        • Else - Actions
          • Unit - Order (Triggering unit) to Hold Position
      • -------- Tower --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • ((Owner of (Triggering unit)) controller) Equal to Computer
          • ((Triggering unit) is A Hero) Equal to True
          • (Percentage life of (Triggering unit)) Greater than or equal to 42.00
          • Or - Any (Conditions) are true
            • Conditions
              • (Unit-type of (Attacking unit)) Equal to Guard Tower
              • (Unit-type of (Attacking unit)) Equal to Eilite Guard Tower
        • Then - Actions
          • Unit - Order (Triggering unit) to Attack (Attacking unit)
        • Else - Actions
          • Wait until (((Percentage life of (Triggering unit)) Equal to 40.00) or ((Percentage life of (Triggering unit)) Greater than or equal to 39.00)), checking every 0.10 seconds
          • Unit - Order (Triggering unit) to Move To (Center of Sprawn Hero Admiral Army <gen>)
          • Wait 2.00 seconds
          • Unit - Order (Triggering unit) to Move To (Position of (Attacking unit))
      • -------- Creeps --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • ((Owner of (Triggering unit)) controller) Equal to Computer
          • ((Triggering unit) is A Hero) Equal to True
          • ((Attacking unit) is A Hero) Equal to True
          • (Percentage life of (Triggering unit)) Greater than or equal to 30.00
          • Or - Any (Conditions) are true
            • Conditions
              • (Unit-type of (Attacking unit)) Equal to Rugbyboys
              • (Unit-type of (Attacking unit)) Equal to Rugbyboys Slasher
        • Then - Actions
          • Unit - Order (Triggering unit) to Attack (Attacking unit)
        • Else - Actions
          • Wait until ((Percentage life of (Triggering unit)) Less than or equal to 30.00), checking every 0.10 seconds
          • Unit - Order (Triggering unit) to Move To (Center of Sprawn Hero Admiral Army <gen>)
          • Wait 2.00 seconds
          • Unit - Order (Triggering unit) to Move To (Position of Cheftain's Camp 0033 <gen>)
      • -------- Retreat --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • ((Owner of (Triggering unit)) controller) Equal to Computer
          • ((Triggering unit) is A Hero) Equal to True
          • (Percentage life of (Triggering unit)) Less than or equal to 25.00
        • Then - Actions
          • Wait until ((Percentage life of (Triggering unit)) Less than or equal to 25.00), checking every 0.10 seconds
          • Unit - Order (Triggering unit) to Move To (Center of Sprawn Hero Admiral Army <gen>)
          • Wait until ((Life of (Triggering unit)) Greater than or equal to 99.00), checking every 0.10 seconds
          • Unit - Order (Triggering unit) to Move To (Position of Cheftain's Camp 0033 <gen>)
        • Else - Actions
          • Wait until ((Percentage life of (Triggering unit)) Greater than or equal to 99.00), checking every 0.10 seconds
          • Unit - Order (Triggering unit) to Attack (Attacking unit)
Sometimes they will be confused of the Commands.. Please help... What me do?
Map Attached... Please check... The other triggers in my map is smooth and no leaks but the AI is my problem.....:vw_sad::vw_sad::vw_sad::goblin_boom:
 

Attachments

  • Triggers AI.jpeg
    Triggers AI.jpeg
    354.3 KB · Views: 78
  • AI Problem.w3x
    22.7 KB · Views: 35
Last edited:
Level 7
Joined
May 13, 2011
Messages
310
Well, I'm not a pro with this, but from what I've heard, you shouldn't use triggers to make AI. It'd probably be a better idea to use the AI Editor. I haven't used it, so don't ask me what to do, but I'm guessing it'll be more effective and efficient that using triggers.

What's more, one of the reasons your triggers aren't always working may be because of conflict with the default AI. Modifying the AI wouldn't have this problem.
 
Level 20
Joined
Feb 24, 2009
Messages
2,999
What exactly does it do that's it not supposed to? We can't begin to guess what's going wrong without more information.

Puggsoy, the AI Editor is great for creating 'melee' (normal warcraft games) AI but triggers should indeed be used for custom maps as I'm assuming this one is?
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,201
I advise breaking the trigger apart as you currently evaluate if the player is a computer far too much than needed.

There is also a bug where because you use waits, it will evaluate some of the conditions later so it is possible that they will be valid later and so carried out. Make sure that after 1 brach runs the function ends.
 
Level 7
Joined
May 23, 2011
Messages
179
I disabled now the Melee AI but there is still a bit problem when the Heroes life is 25% and bellow the do not retreat to the Fountain..... Please check my triggers.. I attached all the AI triggers above in a map...

Thanks Guys for the help...... :vw_sleep::goblin_good_job::goblin_good_job:
I really appreciated all your help....:goblin_cry::goblin_cry::goblin_cry::goblin_cry:
 
Level 37
Joined
Mar 6, 2006
Messages
9,240
You need to get rid of the waits, like this:


  • Unit Attaked Admiral Config AI Copy 2
    • Events
      • Unit - A unit Is attacked
    • Conditions
      • Or - Any (Conditions) are true
        • Conditions
          • (Triggering player) Equal to Player 1 (Red)
          • (Triggering player) Equal to Player 2 (Blue)
          • (Triggering player) Equal to Player 3 (Teal)
          • (Triggering player) Equal to Player 4 (Purple)
          • (Triggering player) Equal to Player 5 (Yellow)
      • ((Triggering player) controller) Equal to Computer
      • ((Triggering unit) is A Hero) Equal to True
    • Actions
      • -------- Retreat --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Percentage life of (Triggering unit)) Less than or equal to 25.00
        • Then - Actions
          • Unit Group - Add (Triggering unit) to HealGroup
          • Set point = (Random point in Fountain <gen>)
          • Unit - Order (Triggering unit) to Move To point
          • Custom script: call RemoveLocation(udg_point)
          • Trigger - Turn on Healers <gen>
        • Else - Actions
  • Healers
    • Events
      • Time - Every 1.00 seconds of game time
    • Conditions
    • Actions
      • Unit Group - Pick every unit in HealGroup and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Percentage life of (Picked unit)) Greater than 0.95
            • Then - Actions
              • Set point = (Random point in Region 002 <gen>)
              • Unit - Order (Picked unit) to Attack-Move To point
              • Custom script: call RemoveLocation(udg_point)
              • Unit Group - Remove (Picked unit) from HealGroup
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (HealGroup is empty) Equal to True
                • Then - Actions
                  • Trigger - Turn off (This trigger)
                • Else - Actions
            • Else - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • ((Picked unit) is dead) Equal to True
                • Then - Actions
                  • Unit Group - Remove (Picked unit) from HealGroup
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • (HealGroup is empty) Equal to True
                    • Then - Actions
                      • Trigger - Turn off (This trigger)
                    • Else - Actions
                • Else - Actions


The player conditons could be simplified to Player number of triggering player < 6.

http://www.hiveworkshop.com/forums/pastebin.php?id=zmnu8c
 
Status
Not open for further replies.
Top