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

[Trigger] Why is my AI not creeping?

Status
Not open for further replies.
Level 2
Joined
Jan 1, 2018
Messages
9
I've been trying to get an AI-controlled hero to farm creeps within a contained region for a while. Here is my latest failed attempt and I don't see why the trigger is broken.

  • Farming Central New Copy
    • Events
      • Unit - A unit Dies
    • Conditions
      • (Central Creeps <gen> contains (Triggering unit)) Equal to True
      • (Owner of (Killing unit)) Equal to Player 4 (Purple)
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Number of units in (Units within 512.00 of (Position of |c007900f2Black Arrow|r 0291 <gen>) matching ((Owner of (Matching unit)) Equal to Neutral Hostile))) Equal to 0
          • Central_Creeps Greater than 0
          • BA_Farming Equal to True
          • Life_Drain Equal to False
        • Then - Actions
          • Unit - Order |c007900f2Black Arrow|r 0291 <gen> to Attack-Move To (Position of (Random unit from (Units in Central Creeps <gen> owned by Neutral Hostile)))
        • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Number of units in (Units within 512.00 of (Position of |c007900f2Black Arrow|r 0291 <gen>) matching ((Owner of (Matching unit)) Equal to Neutral Hostile))) Equal to 0
              • Central_Creeps Equal to 0
              • BA_Farming Equal to True
              • Life_Drain Equal to False
            • Then - Actions
              • Set BA_Farming = False
              • Unit - Order |c007900f2Black Arrow|r 0291 <gen> to Move To (Center of Undead Spawn 1 <gen>)
            • Else - Actions

Overview: to start with, a different trigger makes the hero, "Black Arrow", attack-move to the position of a random creep within the region "Central Creeps." The above trigger is then (theoretically) fired when the first creep in Central Creeps is killed by the hero. At that point, one of two things is meant to happen...

1

If the number of creeps within a set range of Black Arrow is 0, i.e. BA has finished killing off an entire group of creeps
AND
If Central_Creeps (a previously defined integer variable that I know to be working) is greater than 0, i.e. there are more creeps left to kill in the region
--don't worry about the other conditions--
THEN
BA will attack-move to another creep in the region, and hopefully will keep doing so, bouncing from one cluster of creeps to the next.

2, The alternative

If the number of creeps within a set range of Black Arrow is 0, i.e. BA has finished killing off a group of creeps
AND
If Central_Creeps = 0, i.e. no creep groups are left to kill within the region
THEN
BA returns to base

What is happening when I test it is BA kills the first group of creeps she is sent to, then stands there like a lemon. The trigger is supposed to detect that there are no creeps in her range and make her move onto another random group. But it isn't.

My suspicion is that the broken part in the trigger is the "number of units within 500 of BA matching (matching unit owned by Neutral Hostile) = 0" bit. All the other components, variables etc. are being used in other correctly functioning triggers, so... Thoughts? Prayers?
 
Level 2
Joined
Jan 1, 2018
Messages
9
Okay, but you get what I'm trying to achieve here, right? BA goes around killing creeps until there are none left in the region, then return to base.

How would you trigger that?
 
Level 18
Joined
Nov 21, 2012
Messages
835
You can use "waits" in AI trigger: make a loop, check for conditions, queue hero behavior. Original Blizzard melee AI scripts also use "Sleep" many times so it is fine for AI trigger.

In your case problem may be with checking if creep is alive which is not done. Apply it when ordering, and counting units in group.
 
Status
Not open for further replies.
Top