• 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.

Instantly attack after finishing training?

Status
Not open for further replies.
Level 30
Joined
Feb 18, 2014
Messages
3,623
Greetings,

I would like to know if it is possible to make a unit instantly attack after it finishes training without timer, because afaik, when units finishes training they usually gather arround the gold mine and townhall and wait, but what if I want they to directly attack the enemy base after been trained/spawned?
I noticed in the last mission of Rexxar's campaign that units uses AI instead of triggers after they spawn but apprently it seems to be JASS AI...
And yes I'm aware I can use Triggers to set the attack locations but that will take long due to the design of the map, so I wanna know if it possible to make it with AI?

Edit : Nvm, I found a solution.
 
Last edited:
Level 13
Joined
May 10, 2009
Messages
868
Probably something like this:
  • OrderTrainedToAttack
    • Events
      • Unit - A unit Finishes training a unit
    • Conditions
      • -------- Filter out other units --------
      • (Unit-type of (Trained unit)) Equal to Unit-Type
    • Actions
      • Set p = (Center of PathToEnemyBase <gen>)
      • Unit - Order (Trained unit) to Attack-Move To p
      • Custom script: call RemoveLocation(udg_p)
Or, perhaps, he used the following function
JASS:
native AttackMoveXY takes integer x,integer y returns nothing
 
Level 30
Joined
Feb 18, 2014
Messages
3,623
whats the solution mate?
I used JASS Script, here's an example :
JASS:
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(KNIGHT,user)
        call SuicideUnitB(PRIEST, user)
        call SuicideUnitB(MORTAR,user)
    endloop

endfunction
 
Status
Not open for further replies.
Top