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

4 Ai Attack Trigger

Level 3
Joined
Dec 30, 2020
Messages
19
Hey there its me your lost born child needing help. So i have made a map with 4 Ai that have their own wave units (left up down right send units) every wave they are ordered to attack a player position of units that they do but after that they stay still doing noting. Okey so i order them to attack random last know position of a unit every 10sec. They do that but after they kill the player or the unit they always go to the place that the player/unit owner died and i have tried many ways to fix it and i gotten noting so far. So here i am asking help again if some could help me with this Ai attack system. The idea is that when wave starts they chase the players after they have killed the player or their units they will acquire a new target. Since im not good with triggers i cant think of way to do that. So help :.:
ps:im typing this wile very tired
 
Level 18
Joined
Mar 16, 2008
Messages
721
just order them to attack the next player target?

post your triggers so i can see.

[also sounds like it's technically not what i would think of as ai script but just computer player controlled by trigger orders.]
 
Level 3
Joined
Dec 30, 2020
Messages
19
just order them to attack the next player target?

post your triggers so i can see.

[also sounds like it's technically not what i would think of as ai script but just computer player controlled by trigger orders.]
  • Event-Every 5.00 seconds of game time
  • Conditions- None
  • Action - Unit - Group-All All Units Of (Units In (Playable map area) owned by Player 10 (Light Blue)) to WaveGroup
  • Unit Group - Pick every unit in WaveGroup and do (actions)
  • Action - Unit - Order (Picked Unit) to Attack-Move To (Position of (Random unit from (Units Owned by Players.)))
-Players is a variable and WaveGroup

I have never done that trigger commmend so i hope you get it. But thats all i can do
 
Last edited:
Level 18
Joined
Mar 16, 2008
Messages
721
this is ok but can be improved a lot.

how are the units created or are they on the map already?

EDIT: it's fairly clear what you want to happen but can you explain in detail what you want to happen, how many players are there, do the players only control heroes or do the players have more units? maybe give me an idea of your map more and exactly what's going on, and exactly what you want to happen and i can try to help you make triggers.
 
Last edited:
Level 3
Joined
Dec 30, 2020
Messages
19
this is ok but can be improved a lot.

how are the units created or are they on the map already?

EDIT: it's fairly clear what you want to happen but can you explain in detail what you want to happen, how many players are there, do the players only control heroes or do the players have more units? maybe give me an idea of your map more and exactly what's going on, and exactly what you want to happen and i can try to help you make triggers.
Okey so heres how the game works -Player picks a race thats the acolyte after they have picked the race they have 3min to prepare against a wave. Player builds a building in somewere in the map after making ghouls to harvest food then they get units to defend. Wave starts this means left up down right starts spawning enemies (they come from trigger). The ai has been told to go attack random player in the map.
--------------------------------------------------------------------------------------------------------------------------------------------
so what i want is that when a enemy attacks players and kills them theyll start searching for other players after their job is done who ever the ai has choosen. Posted the game its protected. Gives better idea what i mean
 

Attachments

  • Let_the_Evil_Survive_Alpha_0.01a.w3m
    61.5 MB · Views: 1
Level 18
Joined
Mar 16, 2008
Messages
721
I think something like this. Let me know what you think:

  • init
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Set VariableSet player_array[1] = Player 1 (Red)
      • Set VariableSet player_array[2] = Player 2 (Blue)
      • Set VariableSet player_array[3] = Player 3 (Teal)
      • Set VariableSet player_array[4] = Player 4 (Purple)
  • pick target
    • Events
    • Conditions
    • Actions
      • Set VariableSet random_number = (Random integer number between 1 and 4)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (player_array[random_number] slot status) Equal to Is playing
        • Then - Actions
          • Set VariableSet target_point = (Position of (Random unit from (Units owned by player_array[random_number] matching (((Matching unit) is alive) Equal to True).)))
          • Unit Group - Pick every unit in (Units owned by Player 10 (Light Blue).) and do (Actions)
            • Loop - Actions
              • Unit - Order (Picked unit) to Attack-Move To target_point
        • Else - Actions
          • Trigger - Run (This trigger) (ignoring conditions)
          • Skip remaining actions
  • remind attack
    • Events
      • Time - Every 5.00 seconds of game time
    • Conditions
    • Actions
      • Unit Group - Pick every unit in wave_group and do (Actions)
        • Loop - Actions
          • Unit - Order (Picked unit) to Attack-Move To target_point
 

Attachments

  • reaper_test.w3m
    17.5 KB · Views: 1
Level 12
Joined
Jan 10, 2023
Messages
191
@Gnuoy A couple of things about the pick target trigger: Leaking two groups

Inside the 'then' section of the if/then/else you:

1. Make a group of units to pick a random target.
  • Set VariableSet target_point = (Position of (Random unit from (Units owned by player_array[random_number] matching (((Matching unit) is alive) Equal to True).)))
This one is what I would call the sneakier of the two. You make a group to pick a random unit and have no way of referring to that group to destroy it. If we make a new group to reuse for this purpose, we can just clear the group each time we're done with it and then we don't need to delete it. We can clear the group quickly and easily with
  • Set VariableSet target_units = (Units owned by player_array[random_number] matching (((Matching unit) is alive) Equal to True).)
  • Set VariableSet target_point = (Position of (Random unit from (target_units)))
  • Custom script - call GroupClear( udg_target_units )

2. Make a group of all of the AI player's units and order them to move.
  • Unit Group - Pick every unit in (Units owned by Player 10 (Light Blue).) and do (Actions)
    • Loop - Actions
      • Unit - Order (Picked unit) to Attack-Move To target_point
This one is much easier to clean up thanks to some foresight at Blizzard. We can use a built in global boolean variable called "bj_wantDestroyGroup" it works like this:
  • Custom script - set bj_wantDestroyGroup = true
  • Unit Group - Pick every unit in (A group that need not be named but that will be destroyed) and do (Actions)
    • Loop - Actions
      • Unit - Order (Picked unit) to Breakdance

Also, there is no need to skip the remaining actions at the end of the trigger because there are no remaining actions.

An example of how to stop the leaking:
  • pick target
    • Events
    • Conditions
    • Actions
      • Set VariableSet random_number = (Random integer number between 1 and 4)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (player_array[random_number] slot status) Equal to Is playing
        • Then - Actions
          • Set VariableSet target_units = (Units owned by player_array[random_number] matching (((Matching unit) is alive) Equal to True).)
          • Set VariableSet target_point = (Position of (Random unit from (target_units)))
          • Custom script - call GroupClear( udg_target_units )
          • Custom script - set bj_wantDestroyGroup = true
          • Unit Group - Pick every unit in (Units owned by Player 10 (Light Blue).) and do (Actions)
            • Loop - Actions
              • Unit - Order (Picked unit) to Attack-Move To target_point
        • Else - Actions
          • Trigger - Run (This trigger) (ignoring conditions)
 
Level 3
Joined
Dec 30, 2020
Messages
19
@Gnuoy A couple of things about the pick target trigger: Leaking two groups

Inside the 'then' section of the if/then/else you:

1. Make a group of units to pick a random target.
  • Set VariableSet target_point = (Position of (Random unit from (Units owned by player_array[random_number] matching (((Matching unit) is alive) Equal to True).)))
This one is what I would call the sneakier of the two. You make a group to pick a random unit and have no way of referring to that group to destroy it. If we make a new group to reuse for this purpose, we can just clear the group each time we're done with it and then we don't need to delete it. We can clear the group quickly and easily with
  • Set VariableSet target_units = (Units owned by player_array[random_number] matching (((Matching unit) is alive) Equal to True).)
  • Set VariableSet target_point = (Position of (Random unit from (target_units)))
  • Custom script - call GroupClear( udg_target_units )

2. Make a group of all of the AI player's units and order them to move.
  • Unit Group - Pick every unit in (Units owned by Player 10 (Light Blue).) and do (Actions)
    • Loop - Actions
      • Unit - Order (Picked unit) to Attack-Move To target_point
This one is much easier to clean up thanks to some foresight at Blizzard. We can use a built in global boolean variable called "bj_wantDestroyGroup" it works like this:
  • Custom script - set bj_wantDestroyGroup = true
  • Unit Group - Pick every unit in (A group that need not be named but that will be destroyed) and do (Actions)
    • Loop - Actions
      • Unit - Order (Picked unit) to Breakdance

Also, there is no need to skip the remaining actions at the end of the trigger because there are no remaining actions.

An example of how to stop the leaking:
  • pick target
    • Events
    • Conditions
    • Actions
      • Set VariableSet random_number = (Random integer number between 1 and 4)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (player_array[random_number] slot status) Equal to Is playing
        • Then - Actions
          • Set VariableSet target_units = (Units owned by player_array[random_number] matching (((Matching unit) is alive) Equal to True).)
          • Set VariableSet target_point = (Position of (Random unit from (target_units)))
          • Custom script - call GroupClear( udg_target_units )
          • Custom script - set bj_wantDestroyGroup = true
          • Unit Group - Pick every unit in (Units owned by Player 10 (Light Blue).) and do (Actions)
            • Loop - Actions
              • Unit - Order (Picked unit) to Attack-Move To target_point
        • Else - Actions
          • Trigger - Run (This trigger) (ignoring conditions)
Hey. how would i be able to do this, since i have no clue
Set VariableSet target_units = (Units owned by player_array[random_number] matching (((Matching unit) is alive) Equal to True).)
 
Level 18
Joined
Mar 16, 2008
Messages
721
Just enemies that will never stop chasing you or other players after they have killed unit/player
yes i understand that part, i just meant the triggers i posted aren't 100% finished but i wanted to see what you thought before i spent a lot of time making them. the unit group leaks but i wasn't sure how you are spawning the units, normally i would add them to the unit group upon spawning and remove them upon death. but you aren't even concerned about these details at this point.
Hey. how would i be able to do this, since i have no clue
try to open the draft file i posted to familiarize yourself with where these options are in GUI
 
Top