• 🏆 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 attack waves mixing

Status
Not open for further replies.
Level 13
Joined
Dec 19, 2020
Messages
237
Hello everyone!

In my map, I'm using several JASS AI Scripts. Most of them work fine. One of them however, has been working fine for weeks, but now it starts making mistakes. It's sending attack waves but they suddenly retreat to the base. Later it sends two waves of attacks at the same time (indeed the old one and the scripted one). I can't figure out why it suddenly is acting strange.
Could someone take a look at the script and tell me what i'm doing wrong?
Thanks in advance!

Code:
// ==========================================================================
// Citadel Guard - Blue
// ==========================================================================
globals
player user = PlayerEx(1)
player Blood_Orc = PlayerEx(5)
player Ogre = PlayerEx(6)

constant integer Elite_Spearthrower = 'n010'
constant integer Mage_Tower = 'h005'
constant integer Lord_Edmund = 'H00H'
constant integer Lord_Darian = 'H00G'
constant integer Elite_Chaplain = 'n00Z'
constant integer Elite_Hydromancer = 'n011'
constant integer Silver_Hand = 'h00D'
constant integer Elite_Peasant = 'h00C'
constant integer Swordmaster = 'h00B'

endglobals

//============================================================================
// main
//============================================================================
function main takes nothing returns nothing
   call CampaignAI(HOUSE, null)
   call SetReplacements(5,5,5)
   call SetPeonsRepair (true)
   call SetSlowChopping (false)
   
    //*****************************
    //*Building/Defense
    //*****************************
    
    call SetBuildUnitEx(1,1,1, TOWN_HALL)
    call SetBuildUnitEx(2,2,2, Elite_Peasant)
    call SetBuildUnitEx(1,1,1, BARRACKS)
    call SetBuildUnitEx(12,12,12, HOUSE)
    call SetBuildUnitEx(1,1,1, BLACKSMITH)
    call SetBuildUnitEx(1,1,1,LUMBER_MILL)
    call SetBuildUnitEx(1,1,1, HUMAN_ALTAR)
    call SetBuildUnitEx(1,1,1, Mage_Tower)
    call SetBuildUnitEx(12,12,12, Elite_Peasant)
    
    call CampaignDefenderEx(2,2,2, Silver_Hand)
    call CampaignDefenderEx(3,3,3, KNIGHT)
    call CampaignDefenderEx(3,3,3, Elite_Spearthrower)
    call CampaignDefenderEx(4,4,4, Swordmaster)
    call CampaignDefenderEx(2,2,2, Elite_Chaplain)
    call CampaignDefenderEx(2,2,2, Elite_Hydromancer)
    call CampaignDefenderEx(1,1,1, Lord_Darian)
    call CampaignDefenderEx(1,1,1, Lord_Edmund)
    
    call WaitForSignal ()
    
    //[B]*WAVE 1 *[/B]
    call InitAssaultGroup()
    call CampaignAttackerEx(1,1,1, Lord_Edmund)
    call CampaignAttackerEx(4,4,4, Swordmaster)
    call CampaignAttackerEx(4,4,4, Elite_Spearthrower)
    call CampaignAttackerEx(2,2,2, Elite_Chaplain)
    call CampaignAttackerEx(1,1,1, Elite_Hydromancer)
    call SuicideOnPlayer(M10,PlayerEx(6))
    
    //[B]*WAVE 2 *[/B]
    call InitAssaultGroup()
    call CampaignAttackerEx(1,1,1, Lord_Darian)
    call CampaignAttackerEx(2,2,2, Silver_Hand)
    call CampaignAttackerEx(4,4,4, KNIGHT)
    call CampaignAttackerEx(3,3,3, Elite_Spearthrower)
    call CampaignAttackerEx(1,1,1, Elite_Chaplain)
    call CampaignAttackerEx(1,1,1, Elite_Hydromancer)
    call SuicideOnPlayer(M12,PlayerEx(6))
    
    loop
    //[B]*WAVE 3 *[/B]
    call InitAssaultGroup()
    call CampaignAttackerEx(1,1,1, Lord_Edmund)
    call CampaignAttackerEx(4,4,4, Swordmaster)
    call CampaignAttackerEx(4,4,4, Elite_Spearthrower)
    call CampaignAttackerEx(2,2,2, Elite_Chaplain)
    call CampaignAttackerEx(1,1,1, Elite_Hydromancer)
    call SuicideOnPlayer(M10,PlayerEx(6))
    
    //[B]*WAVE 4 *[/B]
    call InitAssaultGroup()
    call CampaignAttackerEx(1,1,1, Lord_Darian)
    call CampaignAttackerEx(2,2,2, Silver_Hand)
    call CampaignAttackerEx(4,4,4, KNIGHT)
    call CampaignAttackerEx(3,3,3, Elite_Spearthrower)
    call CampaignAttackerEx(1,1,1, Elite_Chaplain)
    call CampaignAttackerEx(1,1,1, Elite_Hydromancer)
    call SuicideOnPlayer(M12,PlayerEx(6))
    
       //[B]*WAVE 5 *[/B]
    call InitAssaultGroup()
    call CampaignAttackerEx(1,1,1, Lord_Edmund)
    call CampaignAttackerEx(4,4,4, Swordmaster)
    call CampaignAttackerEx(4,4,4, Elite_Spearthrower)
    call CampaignAttackerEx(2,2,2, Elite_Chaplain)
    call CampaignAttackerEx(1,1,1, Elite_Hydromancer)
    call SuicideOnPlayer(M10,PlayerEx(6))
    
    //[B]*WAVE 6 *[/B]
    call InitAssaultGroup()
    call CampaignAttackerEx(1,1,1, Lord_Darian)
    call CampaignAttackerEx(2,2,2, Silver_Hand)
    call CampaignAttackerEx(4,4,4, KNIGHT)
    call CampaignAttackerEx(3,3,3, Elite_Spearthrower)
    call CampaignAttackerEx(1,1,1, Elite_Chaplain)
    call CampaignAttackerEx(1,1,1, Elite_Hydromancer)
    call SuicideOnPlayer(M12,PlayerEx(6))
    
    //[B]*WAVE 7 *[/B]
    call InitAssaultGroup()
    call CampaignAttackerEx(1,1,1, Lord_Edmund)
    call CampaignAttackerEx(4,4,4, Swordmaster)
    call CampaignAttackerEx(4,4,4, Elite_Spearthrower)
    call CampaignAttackerEx(2,2,2, Elite_Chaplain)
    call CampaignAttackerEx(1,1,1, Elite_Hydromancer)
    call SuicideOnPlayer(M10,PlayerEx(6))
    
    //[B]*WAVE 8 *[/B]
    call InitAssaultGroup()
    call CampaignAttackerEx(1,1,1, Lord_Darian)
    call CampaignAttackerEx(2,2,2, Silver_Hand)
    call CampaignAttackerEx(4,4,4, KNIGHT)
    call CampaignAttackerEx(3,3,3, Elite_Spearthrower)
    call CampaignAttackerEx(1,1,1, Elite_Chaplain)
    call CampaignAttackerEx(1,1,1, Elite_Hydromancer)
    call SuicideOnPlayer(M12,PlayerEx(6))
    
    endloop
    endfunction
 
Level 13
Joined
Dec 19, 2020
Messages
237
I didn't try reading through this, but if you can't find the problem you should try disabling the code you added in the last few weeks and re-adding it bit by bit to isolate the clashing part.

Thanks for your tip! I know the problem only happens with the uneven attack waves. Those do retreat and combine with the even attack waves later. The real problem is that I can´t find out why those attack waves don´t work as planned. It becomes even stranger when you realise that this script worked fine before and now starts bugging. Could you find a possible bug in the script?
 
Level 13
Joined
Dec 19, 2020
Messages
237
Attack waves that are suicided are never meant to retreat. Somehow it could be adding those units from suicided attack waves to the next attack wave causing them to go to the gather point.

This could be an explanation, although it is kind of strange. Half of the retreating units are units which are not meant to be part of the second wave. The next wave which resembles the first wave is suiciding 15 minutes later.
 
Status
Not open for further replies.
Top