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

[AI] Pause campaign AI

Level 26
Joined
Feb 2, 2006
Messages
1,691
Hi,
in my map I want to add the possibility to disable AI for AI players, so allied user players with shared control can control the AI completely without any automatic AI orders.
In the beginning an AI script with several loops is started.
An attack loop and a loop where gold and lumber workers are set.
I added the following possibilities:
  • Chat command "-aioff X": Disables the AI for player X. Uses
    JASS:
    PauseCompAI
    from common.j. It also disables the attack loop and set worker loop actions in the AI script by setting a boolean flag which is checked.
  • Chat command "-aiignore": Makes the AI ignore all selected units. Uses
    JASS:
    RemoveGuardPosition
    or
    JASS:
    RemoveAllGuardPositions
    from common.j.
  • Chat command "-ainone X": Changes the player controller of player X to NONE. Uses
    JASS:
    SetPlayerController
    from common.j.

Even when using all these commands players have reported to me that the AI still sends back their units to their base automatically.
How can I make the AI stop doing anything?

My feeling is that these functions from common.ai might cause the issue since I did not add any "disabled" flag check here:

JASS:
function CampaignBasics takes nothing returns nothing
    call Sleep(1)
    call CampaignBasicsA()
    call StaggerSleep(1,5)
    loop
        call CampaignBasicsA()
        call Sleep(campaign_basics_speed)
    endloop
endfunction

function BuildLoop takes nothing returns nothing
    call OneBuildLoop()
    call StaggerSleep(1,2)
    loop
        call OneBuildLoop()
        call Sleep(2)
    endloop
endfunction

I wonder what the point of PauseCompAI is.
 
PauseCompAI is used in the Pause all units trigger action, so presumably it pauses the AI as well so that it doesn't break since the units can't move. However, if you unpause all units without first pausing them, it causes the AI to break. I can't help with the rest but hope this gives some insight.
 
Top