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

Change AI for a player mid game OR help me code what I need?

Level 4
Joined
Aug 8, 2019
Messages
37
I want a computer to work with an AI. I have it written here:

JASS:
globals
    player user = Player(22)
    player saurus = Player(1)
    
    constant integer HALBERDIER = 'h600'
    constant integer OUTRIDER = 'n608'
    constant integer WORKER = 'h005'
    constant integer SETTLEMENT = 'h000'
    constant integer ESTFARM = 'h001'
    constant integer ESTBARRACKS = 'h002'
    constant integer ESTBLACKSMITH = 'h003'
    constant integer ESTTOWER = 'h004'
endglobals

function main takes nothing returns nothing
        call CampaignAI(HOUSE, null)
        set campaign_wood_peons = 2
        set campaign_gold_peons = 3
        call SetReplacements(99,99,99)
        call SetSlowChopping(true)
        call SetPeonsRepair(true)
 
        call WaitForSignal()
        loop
            call InitAssaultGroup()
            call CampaignAttackerEx(3,3,3, HALBERDIER)
            call CampaignAttackerEx(1,1,1, OUTRIDER)
            call SuicideOnPlayer(60, saurus)
        endloop
        
endfunction

WHAT I NEED: I want to have that loop end and start a new loop when a quest is completed. I tried looking up how to do it, but I just could not figure it out. I don't know how to use the command "exitwhen" properly, so I was stuck.
JASS:
        loop
            call InitAssaultGroup()
            call CampaignAttackerEx(4,4,4, HALBERDIER)
            call CampaignAttackerEx(2,2,2, OUTRIDER)
            call SuicideOnPlayer(60, user)
        endloop
WHAT I TRIED: I though maybe then I could write another code in a different file and use the trigger to star an AI script after the quest was completed. I though this would essentially REPLACE the first ai script and start using the second one, but it did not work. It continued sending waves like the first script said.
 
Level 21
Joined
Mar 16, 2008
Messages
955
...essentially REPLACE the first ai script and start using the second one...
You would need to put it all in 1 script then you could switch from "mode 1" to "mode 2" then put the first script under a condition for "mode 1" then the second script under a condition for "mode 2."

This technique is explained in InsaneMonster's campaign AI guide under the "commands" or tier section, though it also works with melee AIs: Creating AI workflow. Sorry I can't explain it better myself. It's been about a year since I added it to my map. You could look at the AI script from my Kings and Knights map if you want another example though. I called the variables "tier" in that AI script. Hope that helps.
 
Level 4
Joined
Aug 8, 2019
Messages
37
You would need to put it all in 1 script then you could switch from "mode 1" to "mode 2" then put the first script under a condition for "mode 1" then the second script under a condition for "mode 2."

This technique is explained in InsaneMonster's campaign AI guide under the "commands" or tier section, though it also works with melee AIs: Creating AI workflow. Sorry I can't explain it better myself. It's been about a year since I added it to my map. You could look at the AI script from my Kings and Knights map if you want another example though. I called the variables "tier" in that AI script. Hope that helps.
I think this might be exactly what I keed and then some. Thank you so much!
 
Top