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

Ordering AI to charge at heroes.

Status
Not open for further replies.
Level 11
Joined
Jul 17, 2013
Messages
544
Hi my map is rpg, its actually fellowship of the ring, im describing it so its easier to show issue. I have 9 heroes at my map


1660775503868.png



yellow dots - wolves spawn location, green place - fellowship starts there FELLOWSHIP CAN MOVE OVER ALL AREA! it can go up down, etc everywhere.


Wolves spawn every 60 seconds and the main point is they should charge at heroes, remember also that heroes can split and go every walkable point in the area. I gave wolves 20k agro range and whole vision over area but there is issue only the nearbiest wolves are attacking heroes :(
1660775477397.png


this is what i mean if heroes are in green area then only wolves that spawn at these nearby caves brother to attack heroes. how to fix this? its my main issue wolves dont want to attack fellowship they should always attack the nearbiest hero to their location.


wolves arent owned by neutral hostile, computer player has whole vision of area andheroes, wolves have 20k agro



what i mean is
1660775435856.png


these wolves at down cave keep walking beetwen these 2 points they go there then back to their cave, it shouldnt be like this it looks like something always stops them halfway from aiming heroes.


dont mind the ice blocks at screen it looks like they block pacht but they dont, its randomized its like a maze.


i also removed the guard position for units when i spawn them and still issue exits!



1660775111601.png


currently if heroes stand at green dots then all of these yellow circle caves get bugged wolvs care to walk only halfway to heroes and then they go back! i assume if heroes move up then the upside spawns will work ok but then middle spawn will get bugged.


i need some smart way for wolves to aim heroes, heroes cant split or change their locations so i cant order wolves to aim predefinited point or hero



this is how my triggers look
1660775265588.png
 

Uncle

Warcraft Moderator
Level 64
Joined
Aug 10, 2018
Messages
6,557
So how about after creating the Wolves you immediately order them to Attack-Move to the position of a random Hero?

You can also find the closest Hero to the Wolf if that is more ideal.

Then you can repeat this process periodically.

 
Last edited:
Level 11
Joined
Jul 17, 2013
Messages
544
So how about after creating the Wolves you immediately order them to Attack-Move to the position of a random Hero?

You can also find the closest Hero to the Wolf if that is more ideal.

If i order them to aim random hero then wont they want to over target that hero?

What i mean other Heroes keep attack wolves and they dont care but charge and aim that random hero.
 

Uncle

Warcraft Moderator
Level 64
Joined
Aug 10, 2018
Messages
6,557
No, you order them to Attack-Move to the POSITION of the random Hero. You can also get the closest Hero to them so that they don't go after a Hero across the map.

When you order a unit to Attack-Move to a Point they will attack anything they find on the way.

[EDIT]
Here's some triggers for handing the AI.
[EDIT 2]
I overcomplicated the first trigger in my earlier edit. I updated it to be more simple.

This basic trigger tells each individual wolf to attack towards a random hero:
  • Wolf Attack Loop
    • Events
      • Time - Every 10.00 seconds of game time
    • Conditions
    • Actions
      • Unit Group - Pick every unit in WolfGroup and do (Actions)
        • Loop - Actions
          • Set VariableSet WolfUnit = (Picked unit)
          • Set VariableSet WolfPoint = (Position of (Random unit from FellowshipGroup))
          • Unit - Order WolfUnit to Attack-Move To WolfPoint
          • Custom script: call RemoveLocation(udg_WolfPoint)
This more advanced trigger splits up the wolves into groups and tells each group of wolves to attack towards a random hero:
  • Wolf Attack Loop 2
    • Events
      • Time - Every 10.00 seconds of game time
    • Conditions
    • Actions
      • -------- [ IMPORTANT ] Set this to the total number of groups you want to divide the wolves into: --------
      • Set VariableSet WolfTotalGroups = 3
      • -------- --------
      • -------- Get how many wolves will be placed in each group: --------
      • Set VariableSet WolfCount = ((Number of units in WolfGroup) / WolfTotalGroups)
      • -------- --------
      • -------- If there's enough wolves then proceed to order them to attack: --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • WolfCount Greater than 0
        • Then - Actions
          • -------- Copy the Fellowship group so we can use them as random targets later: --------
          • Set VariableSet FellowshipCount = (Number of units in FellowshipGroup)
          • Unit Group - Pick every unit in FellowshipGroup and do (Actions)
            • Loop - Actions
              • Unit Group - Add (Picked unit) to FellowshipGroupCopy
          • -------- --------
          • -------- Create the wolf groups and then order each group of wolves to attack: --------
          • For each (Integer WolfLoop) from 1 to WolfTotalGroups, do (Actions)
            • Loop - Actions
              • -------- Find a random unit that hasn't been targeted yet (if able): --------
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • FellowshipCount Greater than 0
                • Then - Actions
                  • Set VariableSet WolfTarget = (Random unit from FellowshipGroupCopy)
                  • Unit Group - Remove WolfTarget from FellowshipGroupCopy.
                  • Set VariableSet FellowshipCount = (FellowshipCount - 1)
                • Else - Actions
                  • Set VariableSet WolfTarget = (Random unit from FellowshipGroup)
              • Set VariableSet WolfPoint = (Position of WolfTarget)
              • -------- --------
              • -------- Finally, create a new wolf group and order them to attack-move towards their target: --------
              • Set VariableSet WolfGroups[WolfLoop] = (Random WolfCount units from WolfGroup)
              • Unit Group - Pick every unit in WolfGroups[WolfLoop] and do (Actions)
                • Loop - Actions
                  • Set VariableSet WolfUnit = (Picked unit)
                  • Unit Group - Remove WolfUnit from WolfGroup.
                  • Unit - Order WolfUnit to Attack-Move To WolfPoint
              • Custom script: call RemoveLocation(udg_WolfPoint)
          • -------- --------
          • -------- During the creation of WolfGroups[] the wolves were temporarily removed from WolfGroup. Add them back now: --------
          • For each (Integer WolfLoop) from 1 to WolfTotalGroups, do (Actions)
            • Loop - Actions
              • Unit Group - Pick every unit in WolfGroups[WolfLoop] and do (Actions)
                • Loop - Actions
                  • Unit Group - Add (Picked unit) to WolfGroup
              • Custom script: call DestroyGroup(udg_WolfGroups[udg_WolfLoop])
        • Else - Actions
IMPORTANT:
  • Your Wolves need to be added to WolfGroup after you create them. Then you need to remove them from WolfGroup when they die.
  • FellowshipGroup is meant to contain all of the Heroes that are targeted by the Wolves.
  • Make sure to set the Size of your WolfGroups array to 3 or whatever WolfTotalGroups is set to. This only matters if you plan on using the second trigger.
 

Attachments

  • Wolf AI.w3m
    17.5 KB · Views: 7
Last edited:
Level 11
Joined
Jul 17, 2013
Messages
544
1660863358565.png

ty for help for now i ordered them to aim random unit to see if it will work like intended, it works better but not perfect. i give order to wolves every 10 seconds maybe it needs to be done more often? orange dots is how the walkable pacht got randomized i mean orange places wasnt blocked ice got removed, but 2-3 wolves stayed near their caves and were walking around yellow points i really wonder why does it happen :( ai sucks at finding walkable pacht? even tho its not blocked they simply have real issues with getting there. now at least 90% of wolves attack and 10% stay in place
 

Uncle

Warcraft Moderator
Level 64
Joined
Aug 10, 2018
Messages
6,557
Does the computer have vision of the entire map? That could possibly help.

If you give them orders too often they may start to act stupid, like turning back and forth constantly because they want to attack towards two heroes that are in the opposite direction of one another.
 
Level 11
Joined
Jul 17, 2013
Messages
544
Yes he does he has vision of heroes and all area i even brothered to check replay of game, just to look at perspective of AI, meh its so stupid wolves still wanna go back to spawn position just some of them like 10% in total. but i remove guard position
Does the computer have vision of the entire map? That could possibly help.

If you give them orders too often they may start to act stupid, like turning back and forth constantly because they want to attack towards two heroes that are in the opposite direction of one another.
 
Level 11
Joined
Jul 17, 2013
Messages
544
For a test i gave units to neutral hostile and changed these values
1660943097371.png
ow it works perfectly even without ordering them, but i cannot keep these values at max because it will break other places in my map :( is it possible that the function i used is bugged and does not remove guard position at all or i did it in wrong way?
 
Level 11
Joined
Jul 17, 2013
Messages
544
I really have to get this working :( im attachting test map




i forgot to give vision over area / units to AI so if u can do it urself or either type iseedeadpeople code, uploading map takes some time for me.

1660953823163.png

area to spawn wolves is at down mid of map








1660953861860.png



I also placed units like that, wolf is going to stop in his halfway and never reach the hero thats the issue, how can i change it without changing gameplay constans?
 
Status
Not open for further replies.
Top