HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Unusual bug with my AI, and changing scripts.

07-03-2006, 05:59 AM#1
Sardius
1.) Just curious... In this attack wave.

//*** WAVE 5 ***
call InitAssaultGroup()
call CampaignAttackerEx( 8,8,9, WYVERN )
call SuicideOnPlayerEx(M3,M3,M3,user)

User being player one, this is the only all air assault wave, they take an unusual route to my base and on the way they encounter an npc base "neutral to the user, enemy to them" their wyvern's attack and destroy one of their structures, and then abandon their attack all together and return to their base... The next wave, all those wyvern attack along side all the units belonging to wave 6... Making for an extremely devastating attack.

Any idea why this happens? I've seen it happen in the official campaign as well.

2.) Also, is it possible to switch a computer's AI script from one to another?

Initially player 6 starts 01_orange1.ai but after the shipyards get destroyed, they are suppose to start 01_orange2.ai, which is a more aggressive AI script.

Yet it doesn't seem to work, they seem to ignore it and continue using the previous AI script that was activated early in the level... Can their AI script not be replaced mid map?
07-03-2006, 05:14 PM#2
Sardius
Also, if it is not possible to switch a players AI script mid map, is it possible to add in a condition to switch to a different part of the AI script, like have two sections of AI in one script? And the second part becomes active after a certain condition is met?

I've seen this done for level 9 of the original human campaign, that Mal'Ganis' undead have two seperate ai sections in the same script, one is active before you get Frostmourn, and the other becomes active after you get Frostmourn.

But I'm not sure how its done. It didn't make much sense to me, but I'll post that AI.

Collapse JASS:
//============================================================================
//  after_sword
//============================================================================
function after_sword takes nothing returns nothing

    // grab all the upgrades we're ever going to get
    // post-sword, then start a post-sword loop
    //
    call SetBuildUpgr  ( 1,     UPG_FIEND_WEB     )
    call SetBuildUpgrEx( 1,1,1, UPG_CANNIBALIZE   )
    call SetBuildUpgrEx( 1,1,1, UPG_SKEL_LIFE     )
    call SetBuildUpgrEx( 1,1,1, UPG_GHOUL_FRENZY  )
    call SetBuildUpgrEx( 1,1,1, UPG_STONE_FORM    )
    call SetBuildUpgrEx( 1,1,1, UPG_PLAGUE        )
    call SetBuildUpgrEx( 1,1,1, UPG_WYRM_BREATH   )
    call SetBuildUpgrEx( 2,2,2, UPG_NECROS        )
    call SetBuildUpgrEx( 2,2,3, UPG_UNHOLY_STR    )
    call SetBuildUpgrEx( 2,2,3, UPG_UNHOLY_ARMOR  )
    call SetBuildUpgrEx( 2,2,3, UPG_CR_ATTACK     )
    call SetBuildUpgrEx( 2,2,3, UPG_CR_ARMOR      )

    loop
        //*** WAVE 9+ ***
        call InitAssaultGroup()
        call CampaignAttackerEx( 1,1,1, MALGANIS     )
        call CampaignAttackerEx( 2,2,2, CRYPT_FIEND  )
        call CampaignAttackerEx( 2,2,2, ABOMINATION  )
        call CampaignAttackerEx( 2,2,2, NECRO        )
        call CampaignAttackerEx( 2,2,2, MEAT_WAGON   )
        call SuicideOnPlayerEx(M7,M7,M6,user)

        call InitAssaultGroup()
        call CampaignAttackerEx( 1,1,1, MALGANIS     )
        call CampaignAttackerEx( 2,2,2, ABOMINATION  )
        call CampaignAttackerEx( 4,4,4, GARGOYLE     )
        call CampaignAttackerEx( 1,1,1, FROST_WYRM   )
        call CampaignAttackerEx( 1,1,1, MEAT_WAGON   )
        call SuicideOnPlayerEx(M6,M6,M5,user)

        call InitAssaultGroup()
        call CampaignAttackerEx( 1,1,1, MALGANIS     )
        call CampaignAttackerEx( 3,3,3, ABOMINATION  )
        call CampaignAttackerEx( 2,2,2, MEAT_WAGON   )
        call CampaignAttackerEx( 1,1,1, CRYPT_FIEND  )
        call CampaignAttackerEx( 1,1,1, NECRO        )
        call CampaignAttackerEx( 1,1,1, GHOUL        )
        call SuicideOnPlayerEx(M7,M6,M5,user)

        call InitAssaultGroup()
        call CampaignAttackerEx( 1,1,1, MALGANIS     )
        call CampaignAttackerEx( 6,6,6, GARGOYLE     )
        call CampaignAttackerEx( 2,2,2, FROST_WYRM   )
        call SuicideOnPlayerEx(M6,M6,M5,user)
    endloop
endfunction

//============================================================================
//  test_sword
//============================================================================
function test_sword takes nothing returns nothing
    if CommandsWaiting() > 0 then
        call after_sword()
    endif
endfunction 

//============================================================================
//  main
//============================================================================
function main takes nothing returns nothing
    call CampaignAI(ZIGGURAT_1,null)
    call SetReplacements(1,1,3)

    set campaign_wood_peons = 1

    call SetBuildUnitEx( 1,1,1, NECROPOLIS_1    )
    call SetBuildUnitEx( 1,1,1, ACOLYTE            )
    call SetBuildUnitEx( 1,1,1, UNDEAD_MINE        )
    call SetBuildUnitEx( 1,1,1, GRAVEYARD        )
    call SetBuildUnitEx( 8,8,8, ZIGGURAT_1        )
    call SetBuildUnitEx( 1,1,1, NECROPOLIS_2    )
    call SetBuildUnitEx( 1,1,1, CRYPT           )
    call SetBuildUnitEx( 1,1,1, SLAUGHTERHOUSE    )
    call SetBuildUnitEx( 1,1,1, DAMNED_TEMPLE    )
    call SetBuildUnitEx( 1,1,1, NECROPOLIS_3    )
    call SetBuildUnitEx( 1,1,1, SLAUGHTERHOUSE    )
    call SetBuildUnitEx( 5,5,5, ACOLYTE            )
    call SetBuildUnitEx( 8,8,8, ZIGGURAT_2        )

    call CampaignDefenderEx( 1,1,1, ABOMINATION    )
    call CampaignDefenderEx( 1,1,1, NECRO        )
    call CampaignDefenderEx( 1,1,1, GHOUL        )
    call CampaignDefenderEx( 1,1,1, GARGOYLE    )
    call CampaignDefenderEx( 1,1,1, CRYPT_FIEND    )
    call CampaignDefenderEx( 1,1,1, MALGANIS    )

    call WaitForSignal()

    //*** WAVE 1 ***
    call InitAssaultGroup()
    call CampaignAttackerEx( 4,4,6, GHOUL        )
    call CampaignAttackerEx( 2,2,3, ABOMINATION  )
    call CampaignAttackerEx( 1,1,2, NECRO        )
    call SuicideOnPlayerEx(M6,M5,M5,user)
    call test_sword()

    call SetBuildUpgr( 1, UPG_FIEND_WEB     )
    call SetBuildUpgrEx( 1,1,1, UPG_CANNIBALIZE   )
    call SetBuildUpgrEx( 1,1,1, UPG_UNHOLY_STR    )

    //*** WAVE 2 ***
    call InitAssaultGroup()
    call CampaignAttackerEx( 3,3,4, GHOUL        )
    call CampaignAttackerEx( 3,3,4, CRYPT_FIEND  )
    call CampaignAttackerEx( 2,2,3, GARGOYLE     )
    call SuicideOnPlayerEx(M5,M5,M5,user)
    call test_sword()
    
    //*** WAVE 3 ***
    call InitAssaultGroup()
    call CampaignAttackerEx( 6,6,12, GHOUL       )
    call CampaignAttackerEx( 1,1,2, NECRO        )
    call CampaignAttackerEx( 3,3,3, CRYPT_FIEND  )
    call SuicideOnPlayerEx(M6,M5,M4,user)
    call test_sword()
    
    call SetBuildUpgrEx( 1,1,1, UPG_CR_ATTACK     )
    call SetBuildUpgrEx( 1,1,1, UPG_SKEL_LIFE     )

    //*** WAVE 4 ***
    call InitAssaultGroup()
    call CampaignAttackerEx( 3,3,3, CRYPT_FIEND  )
    call CampaignAttackerEx( 2,2,3, ABOMINATION  )
    call CampaignAttackerEx( 2,2,3, MEAT_WAGON   )
    call SuicideOnPlayerEx(M5,M5,M5,user)
    call test_sword()

    call SetBuildUpgrEx( 1,1,1, UPG_PLAGUE        )
    call SetBuildUpgrEx( 1,1,1, UPG_UNHOLY_ARMOR  )
    call SetBuildUpgrEx( 1,1,1, UPG_CR_ARMOR      )
    call SetBuildUpgrEx( 1,1,1, UPG_NECROS        )

    //*** WAVE 5 ***
    call InitAssaultGroup()
    call CampaignAttackerEx( 2,2,2, ABOMINATION  )
    call CampaignAttackerEx( 3,3,3, GARGOYLE     )
    call CampaignAttackerEx( 1,1,1, MEAT_WAGON   )
    call SuicideOnPlayerEx(M6,M5,M4,user)
    call test_sword()

    call SetBuildUpgrEx( 2,2,2, UPG_UNHOLY_STR        )
    call SetBuildUpgrEx( 2,2,2, UPG_CR_ATTACK        )
    call SetBuildUpgrEx( 1,1,1, UPG_GHOUL_FRENZY    )

    //*** WAVE 6 ***
    call InitAssaultGroup()
    call CampaignAttackerEx( 6,6,6, GARGOYLE        )
    call CampaignAttackerEx( 1,1,2, FROST_WYRM        )
    call SuicideOnPlayerEx(M5,M5,M5,user)
    call test_sword()

    call SetBuildUpgrEx( 2,2,2, UPG_UNHOLY_ARMOR  )
    call SetBuildUpgrEx( 2,2,2, UPG_CR_ARMOR      )
    call SetBuildUpgrEx( 1,1,1, UPG_STONE_FORM    )
    call SetBuildUpgrEx( 2,2,2, UPG_NECROS        )
    call SetBuildUpgrEx( 1,1,1, UPG_WYRM_BREATH   )


    loop
        //*** WAVE 9+ ***
        call InitAssaultGroup()
        call CampaignAttackerEx( 4,4,4, CRYPT_FIEND  )
        call CampaignAttackerEx( 1,1,1, ABOMINATION  )
        call CampaignAttackerEx( 1,1,1, NECRO        )
        call CampaignAttackerEx( 2,2,2, MEAT_WAGON   )
        call SuicideOnPlayerEx(M5,M5,M4,user)
        call test_sword()

        call InitAssaultGroup()
        call CampaignAttackerEx( 1,1,2, ABOMINATION  )
        call CampaignAttackerEx( 4,4,5, GARGOYLE     )
        call CampaignAttackerEx( 1,1,2, FROST_WYRM   )
        call CampaignAttackerEx( 0,0,1, MEAT_WAGON   )
        call SuicideOnPlayerEx(M6,M5,M5,user)
        call test_sword()

    endloop
endfunction
07-05-2006, 08:16 PM#3
Sardius
Does no one have an answer to this question? I am more concerned with changing the AI scripts mid map or making two sections in one script, triggered by an event... This is very important in this map and will grow increasingly import in the later levels.

I'd like to release my demo soon and this is probably the most pressing issue in getting my first RTS level... I know it can be done, as seen in level 9 of the Reign of Chaos Human campaign... I just don't know how it was done.
07-05-2006, 11:13 PM#4
Vexorian
JASS tag does work for AI scripts ...

About the AI change, maybe you have to stop the AI before running the second one? I do not understand the first question (what's the problem?)
07-06-2006, 12:37 AM#5
Sardius
There is no trigger for "stop AI" though, just "start AI"
07-06-2006, 02:20 AM#6
Vexorian
hmnn I dunno:

Collapse JASS:
native PauseCompAI          takes player p,   boolean pause                 returns nothing
07-06-2006, 05:57 AM#7
Sardius
Hm is that suppose to be a custom script for a trigger that would stop their AI script?