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

[Trigger] Keep Attacking Trigger

Status
Not open for further replies.
Level 7
Joined
Jul 21, 2015
Messages
103
Round 1 Part 2
Events
Time - Every 1.50 seconds of game time
Conditions
Actions
Unit Group - Pick every unit in (Units owned by Player 12 (Brown) matching ((Current order of (Matching unit)) Not equal to (Order(attack)))) and do (Actions)
Loop - Actions
Unit - Order (Matching unit) to Attack-Move To (Position of (Random unit from (Units owned by (Random player from (All players controlled by a User player)) matching (((Matching unit) is A structure) Equal to False))))


I am having trouble with this trigger. I want it to make units from a computer that aren't attacking anything to attack=move to the point of a random user-controlled player unit, but either it does it one at a time or they don't go at all. Is there a way to fix this? I have tried chaninging the Matching Unit to Picked Unit also but it doesn't work.

Can anyone help? Thanks
 
Level 7
Joined
Jul 21, 2015
Messages
103
Might have to disable guarding on the units first. Also be aware that trigger leaks very badly and has a complexity of order n^2 with respect to units.

Hey Dr Super Good, I fixed the guard distance and changed the trigger to look like this:

Round 1 Part 2
Events
Time - Every 1.50 seconds of game time
Conditions
Actions
Unit Group - Pick every unit in (Units owned by Player 12 (Brown) matching ((Current order of (Matching unit)) Not equal to (Order(attack)))) and do (Actions)
Loop - Actions
Unit - Order (Matching unit) to Attack-Move To (Position of (Random unit from (Units owned by (Random player from (All players controlled by a User player)) matching (((Matching unit) is A structure) Equal to False))))
Set PointOfAttack = (Target point of issued order)
Custom script: call RemoveLocation (udg_PointOfAttack)

Does that fix the leaks? Also they don't return which is good but also they don't all go at once...
 

Dr Super Good

Spell Reviewer
Level 63
Joined
Jan 18, 2005
Messages
27,197
Does that fix the leaks?
No, it still leaks 1 group + 1 group for every matching Player 12 unit + 1 force (player group) for every matching Player 12 unit.

Be aware that the WC3 game engine is limited to moving 1 unit per game frame per player. Hence if one orders 500 units owned by a single player to attack move around the map the result will be most units standing around most of the time.

Due to its high complexity it might be hitting the op limit, if it is possible with that kind of loop. It is also possible that the units have an attack order but are sitting around for some reason.
 
Level 12
Joined
Jun 15, 2016
Messages
472
You want all of a certain player's units to attack a random target? That is classic AI behaviour. Try using a script like this for your map:

JASS:
//==================================================================================================
//  $Id: o03Bx04.ai,v 1.1 2003/09/02 13:58:08 smercer Exp $
//==================================================================================================
globals
    integer user = 7
endglobals

function main takes nothing returns nothing
    call CampaignAI(BURROW,null) // The "CampaignAI" part doesn't really matter, this also works for non-campaign maps
   
   call PrepFullSuicide()
    loop
       loop
           exitwhen CommandsWaiting() == 0
           set user = GetLastCommand()
           call PopLastCommand()
       endloop
        call SuicideUnitB(GRUNT,user)
        call SuicideUnitB(SHAMAN,user)
        call SuicideUnitB(RAIDER,user)
        call SuicideUnitB(KODO_BEAST,user)
       call SuicideUnitB(CATAPULT,user)
    endloop

endfunction

You just need to set up triggers to send your AI which player to attack for each wave, set the units in the AI files and you're set to go.
 
Status
Not open for further replies.
Top