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
 
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 ;)
 
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:
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
 
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.
 
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.
 
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.
  • Varine Varine:
    I don't care.
  • Varine Varine:
    Fuck I need more saturday nights off. Turns out I'm much cooler to drunk girls. If I hang out with enough people like that, eventually I'll meet one that likes me sober too
  • Varine Varine:
    idk if anyone has ever done IT. I am not IT but I just got off a 20 minute phone call with the general manager asking me how to make her new computer print. I do adore her, like I know her personally, but I asked three times if the printer was on. She apologized for bothering me, and Chef Ben walked in a few minutes later, turned the printer on apparently, and then called to ask if I was trying to print shit from my house again
  • Varine Varine:
    So I have a newfound appreciation
  • Varine Varine:
    And also I'm going to remove that one from my secondary career options
  • Varine Varine:
    As I get older I'm not thinking I can do this forever anymore, and I'm kind of dead end right now. I get a fine salary and fair raises, like I can easily live my lifestyle on this normally, but I don't know if I can do this in ten years, and I don't think I want to. I don't really have any desire to take over another restaurant, and I don't want to try and own one, and I doubt I'll luck out like I did with that taco place in Texas
  • Varine Varine:
    I have a math degree but that was a while ago and I'm not positive I actually deserved that. It was kind of just given to me I feel like cuz I was in school so long. Like for a bit as a teenager I got real into the mormon thing, and my dad grew up kind of similarly. Much like he fell out of it
  • Varine Varine:
    Anyway he started coming to church with me for a bit, and they gave home the I think Melchizedek? idk how to spell it, but it's the 'upper' priesthood, like he had a whole blessing thing after I got baptized, and it WAS a very neat experience. And the only reason I think they did they did that was cuz he was like late 30s, and that is kind of the age that they have the last chance at that
  • Varine Varine:
    And I mean its not, but like... I'm pretty well set in my lack of religious beliefs, I guess. And I'm a bit younger than my dad would have been then.
  • Varine Varine:
    And then I got real into, he got bored and was like you do you dude, and that's how I got a huge amount of freedom when I started doing drugs as a teenager
  • Varine Varine:
    In hindsight my parents were fantastic. but they were too fucking tired to raise kids like me. And their jobs were easier with better benefits.
  • Varine Varine:
    Anyway idk where I'm going here, but I asked ChatGPT some of the same things and holy shit was it way more strict and just gave me (importantly the wrong) phone number to a hotline
  • Varine Varine:
    TH, I gotta say, though, I'm amazed you keep this up. I feel like there are you and Ghan doing whatever you're doing, Tom posting news, and then me using the chatbox as a journal every once in a while.
    +1
  • Varine Varine:
    Thanks for letting me do that, also. I know I'm not using it correctly, but somewhere along the line I went from arguing with Cheshire to using this as a kind of void for my frustrations and hopes. I like to think of the whole thing as an enigma of sorts
  • Varine Varine:
    It's not, you guys could probably blackmail me if you went back far enough. I doubt anyone would, you've always been very kind, and I'm glad to have been a part of all this! I hope you enjoy me too, cuz I'm going to keep doing it.
    +1
  • Varine Varine:
    In my defense I was high for a lot of that though
  • V-SNES V-SNES:
    Thanks for sharing @Varine
  • The Helper The Helper:
    Brother how long we been here together? You guys are some of my best friends and I have never even met any of you. I dont know what I would if I did not have my Varine rant to look at when I get on. How could I possibly ever shut this site down? We have been here in this little chat box through a lot of shit for a long time. I love you guys!
    +2
  • tom_mai78101 tom_mai78101:
    I missed out on a lot of chat messages. But yeah, we're planning for my mom's funeral back in Taiwan. I'm really glad I work remotely, so I can try to leverage that and go to places outside of US while still working in US.
    +1
  • tom_mai78101 tom_mai78101:
    If it wasn't for my mom, I wouldn't be able to work in the US. Let alone being able to work until our office closed, and I became a full-time remote employee.
  • tom_mai78101 tom_mai78101:
    Really important though, get your wills and last testaments ready. We avoided like 2 to 3 months of waiting for probate court to get back to us.
    +2
  • The Helper The Helper:
    V-SNES I got good news I got your stuff packed for shipping and just need to get to the post office to get shipping cost!
    +1
  • jonas jonas:
    Oh man Cheshire, I often wonder what happened to her and most of the other people who used to be here
  • V-SNES V-SNES:
    @The Helper that's great! Looking forward to getting them!
  • The Helper The Helper:
    Firecat stopped in a few years ago and said whats up then split :)

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials
      Top