HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Force AI Attack

07-05-2009, 09:10 PM#1
Mystiq
Is there any way to force the AI to attack no matter what? I changed the attack thread code in an exported melee script to this:

Collapse JASS:
function AttackAssignment takes nothing returns nothing
    call StaggerSleep( 0, 2 )
    if (attackWave == 1) then
        call AttackWaveDelay( 0 )
    endif
    loop
        //loop
            //call UpdateConditions(  )
            //exitwhen (HaveMinimumAttackers() and not CaptainRetreating())
            call Sleep( 2 )
        //endloop
        call ResetAttackUnits(  )
        call PrepareForces(  )
        call LaunchAttack(  )
    endloop
endfunction

...in the hopes that it would try to attack incredibly often but as long as there's one unit still attacking from the previous force, it won't send a new one. The only way around this seems to be Unit - Create, which the AI ignores, and attack with those. Trying to order existing units results in it pulling them back after a couple seconds after they start doing the attack. This worked in Starcraft. Using Guard Position doesn't work.

My goal here is to mimic the attack logic of Starcraft. As a plus I could mimic the Starcraft individual unit AI but alas, I'm pretty sure Starcraft is a little more intelligent in reference to that than Warcraft 3 and you have virtually no control over unit AI in War3 anyway. (My nitpick here is that long-range units have no problem closing up in melee range and staying there, even ones with a minimum range, like catapults.)
07-07-2009, 12:05 AM#2
Mystiq
I've changed my mind. I'm ok with the AI doing the above, but I'd like to at least let it leave alone units placed with Unit - Create, which I can't seem to do, either. They'll attack the player then seemingly at random be pulled back by the AI to their own base.
07-14-2009, 08:52 AM#3
daPanda
I'm not exactly sure what you want the AI to do. do you not want the Captain to retreat and stay in battle until all units are dead (suicide units)?

if so, you need to set the AI to do this with things like SetUnitsFlee(false), SetGroupsFlee(false), and SetHeroesFlee(false). you can also change your call to FormGroup(seconds, testReady) to set the timeout for forming a group and ignore whether units are healthy enough for battle.

regardless of what you do in the loop there, you still have to wait until AttackMoveKillA() (or whatever Attack function you are using) returns. unless of course, you just want to suicide every unit as it is created.


and I wouldn't comment out the UpdateConditions() since this updates your var values. you're skipping important code.