Help needed with some kind of Kodo TAG AI

world23wc3

Member
Reaction score
6
I've ran into some difficulties as a GUI map maker. Recently I've started to work on a kodo TAG like map and now that I have started to work on the "kodo AI"/"chaser AI" I've run into some problems. I've used the same triggers as the post at the bottom of page 1 on this link. The kodos simply get stuck (see picture below) and I can't figure out a way to solve this problem. Is the terrain too advanced for the kodos to handle or is it the blockade?

219wjn6.png
 

Accname

2D-Graphics enthusiast
Reaction score
1,462
Its the default behavior of the wc3 AI.
A unit is trying to attack back at whatever is attacking it. The default AI is not smart enough to understand that it can not reach its target. It is especially not smart enough to understand it has to attack the walls first.
There is not too much you can do. One thing you can try which may or may not work depending on your map is to give your walls an attack too. Make the walls deal 0-0 damage, this way they will get the same priority as the tower. Problem is that units get a higher priority then buildings, so if you have any attacking units behind those walls you will run into the same problem once again.
In that case the only solution is to script the AI by hand which can be a shit ton of work.
 

jonas

You can change this now in User CP.
Reaction score
64
It's the blockades, not the terrain.

You could check if the kodos moved or attacked every once in a while if they are attacked, and if not, make them attack a random target close to them. It's weak, but probably better than having them stuck.

If it is possible to check if a kodo acquired a target on its own, you can monitor whether the kodo gets stuck or not and assign a random new target (in range), possibly targetting walls in specific.

I didn't check the current AI, so I don't know what other options you have.

If you have more time, you could implement a pathfinding algorithm, but you might have to change the map. As nodes, use squared fields. Make sure that you can easily tell whether two adjacent fields have an edge or not. If a unit is to be attacked, make a breadth first search for that unit's field and find the first field on the path with units and attack them... This of course changes the behavior of the kodos ;)
 

world23wc3

Member
Reaction score
6
Its the default behavior of the wc3 AI.
A unit is trying to attack back at whatever is attacking it. The default AI is not smart enough to understand that it can not reach its target. It is especially not smart enough to understand it has to attack the walls first.
There is not too much you can do. One thing you can try which may or may not work depending on your map is to give your walls an attack too. Make the walls deal 0-0 damage, this way they will get the same priority as the tower. Problem is that units get a higher priority then buildings, so if you have any attacking units behind those walls you will run into the same problem once again.
In that case the only solution is to script the AI by hand which can be a shit ton of work.

It's the blockades, not the terrain.

You could check if the kodos moved or attacked every once in a while if they are attacked, and if not, make them attack a random target close to them. It's weak, but probably better than having them stuck.

If it is possible to check if a kodo acquired a target on its own, you can monitor whether the kodo gets stuck or not and assign a random new target (in range), possibly targetting walls in specific.

I didn't check the current AI, so I don't know what other options you have.

If you have more time, you could implement a pathfinding algorithm, but you might have to change the map. As nodes, use squared fields. Make sure that you can easily tell whether two adjacent fields have an edge or not. If a unit is to be attacked, make a breadth first search for that unit's field and find the first field on the path with units and attack them... This of course changes the behavior of the kodos ;)

I've come up with a few triggers, it still does not work as intended.

Okay, so this is the main "get target" trigger which basically tells the "kodos" (I call them "prebens") where to attack move to if they have no target.
Trigger:
  • Prebens chase target
    • Events
      • Time - Every 2.00 seconds of game time
    • Conditions
    • Actions
      • -------- ALL ESCAPERS THAT ARE ALIVE --------
      • Set TempUnitGroup[0] = (Units in (Playable map area))
      • Unit Group - Pick every unit in TempUnitGroup[0] and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Owner of (Picked unit)) Equal to Player 12 (Brown)
            • Then - Actions
              • Unit Group - Remove (Picked unit) from TempUnitGroup[0]
            • Else - Actions
              • Do nothing
      • -------- ALL PREBENS THAT ARE ALIVE --------
      • Set TempUnitGroup[1] = (Units in (Playable map area))
      • Unit Group - Pick every unit in TempUnitGroup[1] and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Owner of (Picked unit)) Not equal to Player 12 (Brown)
            • Then - Actions
              • Unit Group - Remove (Picked unit) from TempUnitGroup[1]
            • Else - Actions
              • Do nothing
      • -------- ISSUE ATTACK FROM TempUnitGroup[1] TO ATTACK TempUnitGroup[0] --------
      • Unit Group - Pick every unit in TempUnitGroup[1] and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Current order of (Picked unit)) Equal to (Order(none))
            • Then - Actions
              • Unit - Order (Picked unit) to Stop
              • Set TempPoint[0] = (Position of (Random unit from TempUnitGroup[0]))
              • Unit - Order (Picked unit) to Attack-Move To TempPoint[0]
              • Custom script: call RemoveLocation (udg_TempPoint[0])
            • Else - Actions
              • Do nothing
      • Custom script: call DestroyGroup (udg_TempUnitGroup[0])
      • Custom script: call DestroyGroup (udg_TempUnitGroup[1])


This trigger is supposed to check if a kodo stands still or not by comparing x- and y-coordinates, 3 second interval. If the kodo stands still it will try to find a target. The target aquiering mechanism has two possible ways. If "target"(explained in the 3rd trigger) is alive the trigger will order the kodo to move to the target (note that walls have 1-1 dmg (couldn't make it 0-0 dmg) and will make kodos attack them if they come close). If "target" is dead the trigger will try to find a new target within 1000 range of the kodo and order the kodo to attack it.

Improvements:
*Check if kodo has attacked lately
Trigger:
  • Untitled Trigger 001
    • Events
      • Time - Every 4.00 seconds of game time
    • Conditions
    • Actions
      • Unit Group - Pick every unit in (Units in (Playable map area) owned by Player 12 (Brown)) and do (Actions)
        • Loop - Actions
          • Set WriteIndex[0] = (WriteIndex[0] + 1)
          • Set unit[WriteIndex[0]] = (Picked unit)
          • Set y_coordinate[WriteIndex[0]] = (Y of (Position of (Picked unit)))
          • Set x_coordinate[WriteIndex[0]] = (X of (Position of (Picked unit)))
      • Wait 3.00 seconds
      • For each (Integer A) from 1 to WriteIndex[0], do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • And - All (Conditions) are true
                • Conditions
                  • (X of (Position of unit[(Integer A)])) Equal to x_coordinate[(Integer A)]
                  • (Y of (Position of unit[(Integer A)])) Equal to y_coordinate[(Integer A)]
            • Then - Actions
              • Set TempPoint[1] = (Position of unit[(Integer A)])
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (target is alive) Equal to True
                • Then - Actions
                  • Unit - Order unit[(Integer A)] to Move To (Position of target)
                • Else - Actions
                  • Unit - Order unit[(Integer A)] to Attack (Random unit from (Units within 1000.00 of TempPoint[1] matching (((Matching unit) belongs to an enemy of Player 12 (Brown)) Equal to True)))
              • Custom script: call RemoveLocation (udg_TempPoint[1])
            • Else - Actions
              • Do nothing
      • Set WriteIndex[0] = 0


This trigger is supposed to help kodos find a "target" by "marking" (storing a unit as a variable) a nearby building from the building that died recently.

Note that this trigger is not ready for "global" use (1-base limit for now)
Trigger:
  • Untitled Trigger 003
    • Events
      • Unit - A unit Dies
    • Conditions
      • (Owner of (Killing unit)) Equal to Player 12 (Brown)
    • Actions
      • Set TempPoint[2] = (Position of (Dying unit))
      • Set target = (Random unit from (Units within 150.00 of TempPoint[2] matching (((Matching unit) belongs to an enemy of Player 12 (Brown)) Equal to True)))
 
Last edited:

world23wc3

Member
Reaction score
6
I've come up with a few triggers, it still does not work as intended.

Okay, so this is the main "get target" trigger which basically tells the "kodos" (I call them "prebens") where to attack move to if they have no target.
Trigger:
  • Prebens chase target
    • Events
      • Time - Every 2.00 seconds of game time
    • Conditions
    • Actions
      • -------- ALL ESCAPERS THAT ARE ALIVE --------
      • Set TempUnitGroup[0] = (Units in (Playable map area))
      • Unit Group - Pick every unit in TempUnitGroup[0] and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Owner of (Picked unit)) Equal to Player 12 (Brown)
            • Then - Actions
              • Unit Group - Remove (Picked unit) from TempUnitGroup[0]
            • Else - Actions
              • Do nothing
      • -------- ALL PREBENS THAT ARE ALIVE --------
      • Set TempUnitGroup[1] = (Units in (Playable map area))
      • Unit Group - Pick every unit in TempUnitGroup[1] and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Owner of (Picked unit)) Not equal to Player 12 (Brown)
            • Then - Actions
              • Unit Group - Remove (Picked unit) from TempUnitGroup[1]
            • Else - Actions
              • Do nothing
      • -------- ISSUE ATTACK FROM TempUnitGroup[1] TO ATTACK TempUnitGroup[0] --------
      • Unit Group - Pick every unit in TempUnitGroup[1] and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Current order of (Picked unit)) Equal to (Order(none))
            • Then - Actions
              • Unit - Order (Picked unit) to Stop
              • Set TempPoint[0] = (Position of (Random unit from TempUnitGroup[0]))
              • Unit - Order (Picked unit) to Attack-Move To TempPoint[0]
              • Custom script: call RemoveLocation (udg_TempPoint[0])
            • Else - Actions
              • Do nothing
      • Custom script: call DestroyGroup (udg_TempUnitGroup[0])
      • Custom script: call DestroyGroup (udg_TempUnitGroup[1])


This trigger is supposed to check if a kodo stands still or not by comparing x- and y-coordinates, 3 second interval. If the kodo stands still it will try to find a target. The target aquiering mechanism has two possible ways. If "target"(explained in the 3rd trigger) is alive the trigger will order the kodo to move to the target (note that walls have 1-1 dmg (couldn't make it 0-0 dmg) and will make kodos attack them if they come close). If "target" is dead the trigger will try to find a new target within 1000 range of the kodo and order the kodo to attack it.

Improvements:
*Check if kodo has attacked lately
Trigger:
  • Untitled Trigger 001
    • Events
      • Time - Every 4.00 seconds of game time
    • Conditions
    • Actions
      • Unit Group - Pick every unit in (Units in (Playable map area) owned by Player 12 (Brown)) and do (Actions)
        • Loop - Actions
          • Set WriteIndex[0] = (WriteIndex[0] + 1)
          • Set unit[WriteIndex[0]] = (Picked unit)
          • Set y_coordinate[WriteIndex[0]] = (Y of (Position of (Picked unit)))
          • Set x_coordinate[WriteIndex[0]] = (X of (Position of (Picked unit)))
      • Wait 3.00 seconds
      • For each (Integer A) from 1 to WriteIndex[0], do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • And - All (Conditions) are true
                • Conditions
                  • (X of (Position of unit[(Integer A)])) Equal to x_coordinate[(Integer A)]
                  • (Y of (Position of unit[(Integer A)])) Equal to y_coordinate[(Integer A)]
            • Then - Actions
              • Set TempPoint[1] = (Position of unit[(Integer A)])
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (target is alive) Equal to True
                • Then - Actions
                  • Unit - Order unit[(Integer A)] to Move To (Position of target)
                • Else - Actions
                  • Unit - Order unit[(Integer A)] to Attack (Random unit from (Units within 1000.00 of TempPoint[1] matching (((Matching unit) belongs to an enemy of Player 12 (Brown)) Equal to True)))
              • Custom script: call RemoveLocation (udg_TempPoint[1])
            • Else - Actions
              • Do nothing
      • Set WriteIndex[0] = 0


This trigger is supposed to help kodos find a "target" by "marking" (storing a unit as a variable) a nearby building from the building that died recently. It kinda tells the kodo that there is nothing in the way to attack "target"

Note that this trigger is not ready for "global" use (1-base limit for now)
Trigger:
  • Untitled Trigger 003
    • Events
      • Unit - A unit Dies
    • Conditions
      • (Owner of (Killing unit)) Equal to Player 12 (Brown)
    • Actions
      • Set TempPoint[2] = (Position of (Dying unit))
      • Set target = (Random unit from (Units within 150.00 of TempPoint[2] matching (((Matching unit) belongs to an enemy of Player 12 (Brown)) Equal to True)))

Sorry for all the bad variable naming.
I will try to upload my map shortly to give you guys a chance to try things out
 

world23wc3

Member
Reaction score
6
I'm not sure. Triggers didn't turn out as I wanted them. AI is a bit to hard for me to handle when it comes to GUI triggers.
 

Accname

2D-Graphics enthusiast
Reaction score
1,462
You need to be more specific if you want to get any help. I can not know what "didnt turn out as I wanted" means.
 

world23wc3

Member
Reaction score
6
You need to be more specific if you want to get any help. I can not know what "didnt turn out as I wanted" means.

I've decided to stop my "AI"-development. I figured out that I might aswell share how far I came and what ideas I had in mind. I cannot be more specific on what is working or not nor am I asking for any help with it. If you want to continue the development feel free to do so.
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Staff online

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top