• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

Spawns / Attack Waves {like "Blaze of Glory" of the TFT Orc Campaign}

Status
Not open for further replies.
Level 3
Joined
Dec 22, 2007
Messages
38
Hey again, one more I return with a question! :mwahaha: What I would like to know is how to make attack waves / spawn units to go and attack the enemy like in Mission 3: A Blaze of Glory. (The Orc's campaign in Frozen Throne.) Does anybody know how to do this?
 
Level 17
Joined
Jun 28, 2008
Messages
776
  • Spwan Creeps
    • Events
      • Time - "Every Your time interval" seconds of game time
    • Conditions
    • Actions
      • Unit - Create 1 Your Unit for Your Player at Your Point facing Default building facing degrees
      • Unit Group - Pick every unit in (Last created unit group) and do (Actions)
        • Loop - Actions
          • Unit - Order (Picked unit) to Attack-Move To Your Attack point
Hope it helps
 
Level 9
Joined
Apr 10, 2022
Messages
67
  • Spwan Creeps
    • Events
      • Time - "Every Your time interval" seconds of game time
    • Conditions
    • Actions
      • Unit - Create 1 Your Unit for Your Player at Your Point facing Default building facing degrees
      • Unit Group - Pick every unit in (Last created unit group) and do (Actions)
        • Loop - Actions
          • Unit - Order (Picked unit) to Attack-Move To Your Attack point
Hope it helps
there's just one problem: Occasionally some of the spawning units will go back to their spawning point and do absolutely nothing there. If waited long enough, they will began piling up and it's very annoying...
 
Level 18
Joined
Oct 17, 2012
Messages
849
there's just one problem: Occasionally some of the spawning units will go back to their spawning point and do absolutely nothing there. If waited long enough, they will began piling up and it's very annoying...
An easy fix for that is to temporarily change ownership of the unit to a player that you are not using for 5 seconds, since that is the default guard time in Gameplay Constants.
 
Level 18
Joined
Oct 17, 2012
Messages
849
  • PreventReturn
    • Events
      • Player - Player 1 (Red) skips a cinematic sequence
    • Conditions
    • Actions
      • Unit - Create 1 Furbolg for Neutral Hostile at ((Center of (Playable map area)) offset by 1000.00 towards 0.00 degrees.) facing Default building facing degrees
      • Unit - Wake up (Last created unit)
      • -------- Change ownership of unit to an unused player --------
      • Unit - Change ownership of (Last created unit) to Player 2 (Blue) and Retain color
      • Trigger - Run Order <gen> (ignoring conditions)
  • Order
    • Events
    • Conditions
    • Actions
      • Unit - Order (Last created unit) to Attack-Move To (Center of (Playable map area))
      • -------- After 5 seconds, change the ownership of unit back to original --------
      • Wait 5.00 seconds
      • Unit - Change ownership of (Last created unit) to Neutral Hostile and Retain color
 

Attachments

  • PreventSpawnReturn.w3m
    17.2 KB · Views: 14
Last edited:
Level 9
Joined
Apr 10, 2022
Messages
67
  • PreventReturn
    • Events
      • Player - Player 1 (Red) skips a cinematic sequence
    • Conditions
    • Actions
      • Unit - Create 1 Furbolg for Neutral Hostile at ((Center of (Playable map area)) offset by 1000.00 towards 0.00 degrees.) facing Default building facing degrees
      • Unit - Wake up (Last created unit)
      • -------- Change ownership of unit to an unused player --------
      • Unit - Change ownership of (Last created unit) to Player 2 (Blue) and Retain color
      • Trigger - Run Order <gen> (ignoring conditions)
  • Order
    • Events
    • Conditions
    • Actions
      • Unit - Order (Last created unit) to Attack-Move To (Center of (Playable map area))
      • -------- After 5 seconds, change the ownership of unit back to original --------
      • Wait 5.00 seconds
      • Unit - Change ownership of (Last created unit) to Neutral Hostile and Retain color
what's like one unit. what about unit groups? Like example 5 skeletons and 1 skeleton archer?

Thank you anyways!
 
Level 29
Joined
Feb 18, 2014
Messages
3,595
It would be wise to use an AI Script rather than triggers because ordering units to attack move will result in units refusing to follow orders or returning to their spawn location as you already know.

Anyway, here's the AI that blizzard used in the last mission of the TFT orc campaign.
JASS:
//==================================================================================================
//  $Id: o03Bx09.ai,v 1.3 2003/09/02 16:30:41 smercer Exp $
//==================================================================================================
globals
    integer user = 4
endglobals

function main takes nothing returns nothing
    call CampaignAI(HOUSE,null)
   
    call PrepFullSuicide()
    loop
        loop
            exitwhen CommandsWaiting() == 0
            set user = GetLastCommand()
            call PopLastCommand()
        endloop
        call SuicideUnitB(FOOTMAN,user)
        call SuicideUnitB('h004',user)
        call SuicideUnitB(RIFLEMAN,user)
        call SuicideUnitB('h005',user)
        call SuicideUnitB(KNIGHT,user)
        call SuicideUnitB('h006',user)
        call SuicideUnitB('h007',user)
        call SuicideUnitB('nchp',user)
        call SuicideUnitB('nhym',user)
    endloop

endfunction
To explain:
JASS:
integer user = 4
This represent the player which the AI has to attack. For example here 4 is Player (4) Purple
JASS:
call SuicideUnitB(FOOTMAN,user)
This tells the AI which unit it will send to attack. FOOTMAN is a constant that you can find inside Common.ai and 'h004' is a rawcode that you can find by pressing CTRL + D in the Object Editor.

Using an AI is ten times better because you don't have to worry about creating thousands of regions and ordering units to attack them using triggers. The AI will automatically find all the enemies on the map and attack them. You just need to edit the script above with a text editor and import it to your map.
 
Level 9
Joined
Apr 10, 2022
Messages
67
It would be wise to use an AI Script rather than triggers because ordering units to attack move will result in units refusing to follow orders or returning to their spawn location as you already know.

Anyway, here's the AI that blizzard used in the last mission of the TFT orc campaign.
JASS:
//==================================================================================================
//  $Id: o03Bx09.ai,v 1.3 2003/09/02 16:30:41 smercer Exp $
//==================================================================================================
globals
    integer user = 4
endglobals

function main takes nothing returns nothing
    call CampaignAI(HOUSE,null)
  
    call PrepFullSuicide()
    loop
        loop
            exitwhen CommandsWaiting() == 0
            set user = GetLastCommand()
            call PopLastCommand()
        endloop
        call SuicideUnitB(FOOTMAN,user)
        call SuicideUnitB('h004',user)
        call SuicideUnitB(RIFLEMAN,user)
        call SuicideUnitB('h005',user)
        call SuicideUnitB(KNIGHT,user)
        call SuicideUnitB('h006',user)
        call SuicideUnitB('h007',user)
        call SuicideUnitB('nchp',user)
        call SuicideUnitB('nhym',user)
    endloop

endfunction
To explain:
JASS:
integer user = 4
This represent the player which the AI has to attack. For example here 4 is Player (4) Purple
JASS:
call SuicideUnitB(FOOTMAN,user)
This tells the AI which unit it will send to attack. FOOTMAN is a constant that you can find inside Common.ai and 'h004' is a rawcode that you can find by pressing CTRL + D in the Object Editor.

Using an AI is ten times better because you don't have to worry about creating thousands of regions and ordering units to attack them using triggers. The AI will automatically find all the enemies on the map and attack them. You just need to edit the script above with a text editor and import it to your map.
It's alright. But my problem is that every Jass code I did never works. Plus if you need to know. I'm using a 1.26 version of WC3.
 
Level 29
Joined
Feb 18, 2014
Messages
3,595
It's alright. But my problem is that every Jass code I did never works. Plus if you need to know. I'm using a 1.26 version of WC3.
You don't need experience in JASS to make an AI script, even I don't know much about JASS. You just have to remember what the functions do. The code I showed you is very simple, all you have to do is copy paste it in Notepad and change interger user 4 to the player you want to attack and add your units to the list. After that save the file as MyAIScript.ai and import it to your map then run it.
 
Level 9
Joined
Apr 10, 2022
Messages
67
I
You don't need experience in JASS to make an AI script, even I don't know much about JASS. You just have to remember what the functions do. The code I showed you is very simple, all you have to do is copy paste it in Notepad and change interger user 4 to the player you want to attack and add your units to the list. After that save the file as MyAIScript.ai and import it to your map then run it.
tried it and something stranged happened. All of the preplaced units (knights and footman) all charged at my base.

I don't know what I did wrong?
 
Level 18
Joined
Oct 17, 2012
Messages
849
How heavy is your base's defense compared to the rest of the map? I am guessing your enemies (preplaced units) are attracted to your base because it contains most of your units. That is the price of automation. In order to control the AI behavior, you will still have to code the specific parts.

For something as simple as preventing units from returning to spawn point, there is no need for AI scripts.
Simply setting the owner of the unit to an unused player will prevent this creep behavior. As I found out, you don't even need to change ownership.
Now if you wanted to keep the aggression of Neutral Hostile, then changing ownership will be necessary.

In the following test map, several creeps get spawned and are ordered to move. These creeps never return to spawn point.
 

Attachments

  • PreventSpawnReturn.w3m
    17.2 KB · Views: 5
Last edited:
Level 9
Joined
Apr 10, 2022
Messages
67
How heavy is your base's defense compared to the rest of the map? I am guessing your enemies (preplaced units) are attracted to your base because it contains most of your units. That is the price of automation. In order to control the AI behavior, you will still have to code the specific parts.

For something as simple as preventing units from returning to spawn point, there is no need for AI scripts.
Simply setting the owner of the unit to an unused player will prevent this creep behavior. As I found out, you don't even need to change ownership.
Now if you wanted to keep the aggression of Neutral Hostile, then changing ownership will be necessary.

In the following test map, several creeps get spawned and are ordered to move. These creeps never return to spawn point.
Wait... Is that map attachment a reforge? Because im using classic 1.26
 
Level 18
Joined
Oct 17, 2012
Messages
849
The key point is the owner of the unit. Everything else is just superfluous. You just have to apply the key point to your own triggers and code.

  • PreventReturn
    • Events
      • Player - Player 1 (Red) skips a cinematic sequence
    • Conditions
    • Actions
      • For each (Integer LoopInteger) from 1 to 10, do (Actions)
        • Loop - Actions
          • Unit - Create 1 Furbolg for Player 24 (Peanut) at ((Center of (Playable map area)) offset by 1000.00 towards 0.00 degrees.) facing Default building facing degrees
          • Unit - Wake up (Last created unit)
          • Trigger - Run Order <gen> (ignoring conditions)
  • Order
    • Events
    • Conditions
    • Actions
      • Unit - Order (Last created unit) to Attack-Move To (Center of (Playable map area))
 
Last edited:
Level 9
Joined
Apr 10, 2022
Messages
67
Perhaps you set the wrong player? Which player do you want the AI to attack exactly?
globals
integer user = 7
endglobals

function main takes nothing returns nothing
call CampaignAI(HOUSE,null)

call PrepFullSuicide()
loop
loop
exitwhen CommandsWaiting() == 0
set user = GetLastCommand()
call PopLastCommand()
endloop
call SuicideUnitB(FOOTMAN,user)
call SuicideUnitB(FOOTMAN,user)
call SuicideUnitB(FOOTMAN,user)
call SuicideUnitB(FOOTMAN,user)
call SuicideUnitB(FOOTMAN,user)
call SuicideUnitB(KNIGHT,user)
call SuicideUnitB(KNIGHT,user)
endloop

endfunction


(something like this, I thought this would "train and attack" but instead it all knights and footman that are preplaced attack at my base. )
 
Level 29
Joined
Feb 18, 2014
Messages
3,595
Ah, you want the AI to attack your base not vice versa, I see. Well, that's how this AI is supposed to work. It picks all units on the map (including preplaced units) and order them to attack enemy structures, it doesn't however train them unless you tell the AI to do so. In the final mission of the orc bonus campaign units aren't trained but rather spawned using triggers. If you want to know how to train units I will gladly help.

By the way, there is no need to duplicate call SuicideUnitB(FOOTMAN, user) one is enough.
 
Level 9
Joined
Apr 10, 2022
Messages
67
Ah, you want the AI to attack your base not vice versa, I see. Well, that's how this AI is supposed to work. It picks all units on the map (including preplaced units) and order them to attack enemy structures, it doesn't however train them unless you tell the AI to do so. In the final mission of the orc bonus campaign units aren't trained but rather spawned using triggers. If you want to know how to train units I will gladly help.

By the way, there is no need to duplicate call SuicideUnitB(FOOTMAN, user) one is enough.
If it DOES involve triggers, can you alteast show a trigger demonstration? (Sorry if I sound a bit abrasive)
 
Level 29
Joined
Feb 18, 2014
Messages
3,595
  • Auto Spawn
    • Events
      • Time - Every 2.00 seconds of game time
    • Conditions
    • Actions
      • Set TempPoint = (Center of (Playable map area))
      • Unit - Create 1 Footman for Player 1 (Red) at TempPoint facing Default building facing degrees
      • Custom script: call RemoveLocation (udg_TempPoint)
Or
  • Auto Train
    • Events
      • Time - Every 2.00 seconds of game time
    • Conditions
    • Actions
      • Unit - Order Barracks 0000 <gen> to train/upgrade to a Footman
Now everytime a footman is trained/spawned it will automatically attack the enemy base.
PS: I'm using TempPoint to remove memory leaks.
 
Level 3
Joined
Sep 12, 2022
Messages
26
I already used trigger "ai ignore guard trigger" to prevent unit return to base its working but the problem is Unit is stop walking and just stand there especially Mountain giant,Necromancer, druid of claw
 
Status
Not open for further replies.
Top