• 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.
  • The Hive's 22nd Icon Contest: Creep Abilities is now concluded, time to vote for your favourite set of icons! Click here to vote!
  • ✅ The POLL for Hive's Texturing Contest #34 is OPEN! Vote for the TOP 3 SKINS! 🔗Click here to cast your vote!
  • ✅ The POLL for Hive's Techtree Contest #20 is OPEN! Vote for the TOP 3 FACTIONS! 🔗Click here to cast your vote!

[AI] Help with JASS CAMPAIGN AI closing the game?

Level 6
Joined
Oct 11, 2020
Messages
40

Detached Tales: The Convict

So I tried doing a wave system for my campaign:
Here are my units:

BUILDINGS:
1 GREAT HALL (o60B)
1 GRIM BARRACKS (o607)
1 HORNED BARRACKS (o608)
4 PIG FARMS (o609)
1 ANSCESTRAL LODGE (o60C)
1 WARFORGE (o60F)

WORKERS:
2 LUMBER TAUREN WORKER (o60I)
3 GOLD TAUREN WORKER (o60I)

BASE DEFENDERS:
1 TAUREN WHISPERER (o602)
1 TAUREN WARCALLER (o604)
2 TAUREN BRUTE (n60K)
2 WARCLAN BRUTE (o60K)
1 WARCLAN SPEARTHROWER (n60M)

My AI attempt:
JASS:
//============================================================================
//  MULH'ARAS OUTPOST (YELLOW) -- AI Script
//============================================================================

globals
    player user = PlayerEx(1) // Player is blue
endglobals

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

    //----------------------------------------------------
    // BUILD ORDER
    //----------------------------------------------------
    call SetBuildUnitEx(1,1,1,'o60B') // Great Hall
    call SetBuildUnitEx(1,1,1,'o607') // Grim Barracks
    call SetBuildUnitEx(1,1,1,'o608') // Horned Barracks
    call SetBuildUnitEx(4,4,4,'o609') // Pig Farms
    call SetBuildUnitEx(1,1,1,'o60C') // Ancestral Lodge
    call SetBuildUnitEx(1,1,1,'o60F') // Warforge

    //----------------------------------------------------
    // WORKERS
    //----------------------------------------------------
    call SetBuildUnitEx(2,2,2,'o60I') // Lumber Tauren Worker
    call SetBuildUnitEx(3,3,3,'o60I') // Gold Tauren Worker

    //----------------------------------------------------
    // BASE DEFENDERS
    //----------------------------------------------------
    call CampaignDefenderEx(1,1,1,'o602') // Tauren Whisperer
    call CampaignDefenderEx(1,1,1,'o604') // Tauren Warcaller
    call CampaignDefenderEx(2,2,2,'n60K') // Tauren Brute
    call CampaignDefenderEx(2,2,2,'o60K') // Warclan Brute
    call CampaignDefenderEx(1,1,1,'n60M') // Warclan Spearthrower

    //----------------------------------------------------
    call WaitForSignal()

    //====================================================
    // INITIAL WAVES
    //====================================================

    // *** WAVE 1 ***
    call InitAssaultGroup()
    call CampaignAttackerEx(3,3,3,'o60K') // Warclan Brute
    call CampaignAttackerEx(1,1,1,'n60K') // Tauren Brute
    call SuicideOnPlayerEx(M1,M1,M1,user)

    // *** WAVE 2 ***
    call InitAssaultGroup()
    call CampaignAttackerEx(2,2,2,'o60K') // Warclan Brute
    call CampaignAttackerEx(2,2,2,'n60K') // Tauren Brute
    call CampaignAttackerEx(1,1,1,'n60M') // Warclan Spearthrower
    call SuicideOnPlayerEx(M2,M2,M2,user)

    // *** WAVE 3 ***
    call InitAssaultGroup()
    call CampaignAttackerEx(2,2,2,'o60K') // Warclan Brute
    call CampaignAttackerEx(2,2,2,'n60M') // Warclan Spearthrower
    call CampaignAttackerEx(1,1,1,'n60K') // Tauren Brute
    call SuicideOnPlayerEx(M2,M2,M2,user)

    //====================================================
    // LOOPING WAVES
    //====================================================
    loop
        // *** WAVE 1 LOOP ***
        call InitAssaultGroup()
        call CampaignAttackerEx(3,3,3,'o60K')
        call CampaignAttackerEx(1,1,1,'n60K')
        call CampaignAttackerEx(1,1,1,'n60M')
        call SuicideOnPlayerEx(M2,M2,M2,user)

        // *** WAVE 2 LOOP ***
        call InitAssaultGroup()
        call CampaignAttackerEx(2,2,2,'o60K')
        call CampaignAttackerEx(1,1,1,'n60K')
        call CampaignAttackerEx(1,1,1,'n60M')
        call CampaignAttackerEx(1,1,1,'o602')
        call SuicideOnPlayerEx(M2,M2,M2,user)

        // *** WAVE 3 LOOP ***
        call InitAssaultGroup()
        call CampaignAttackerEx(4,4,4,'o60K')
        call CampaignAttackerEx(1,1,1,'o604')
        call SuicideOnPlayerEx(M2,M2,M2,user)

        // *** WAVE 4 LOOP ***
        call InitAssaultGroup()
        call CampaignAttackerEx(2,2,2,'o60K')
        call CampaignAttackerEx(2,2,2,'n60K')
        call CampaignAttackerEx(1,1,1,'n60M')
        call SuicideOnPlayerEx(M2,M2,M2,user)
    endloop
endfunction

It runs, trains the attack groups, but for some reason the game closes or crashes without error whenever it's suppose to go to the player to suicide. I've been stressing over this the whole day. Also, it doesn't recognize lumber gatherers and selects all workers to go on gold. I'm really greatful if anyone would care to help me, basically this whole outpost is preplaced, i just want the AI to train and do wave attacks and have base defenders. I did a outline on how I want it to work:

WAVES LOOPS:

WAVE 1: 3 WARCLAN BRUTE, 1 TAUREN BRUTE, 1 WARCLAN SPEARTHROWER
WAVE 2: 2 WARCLAN BRUTE, 1 TAUREN BRUTE, 1 WARCLAN SPEARTHROWER, 1 TAUREN WHISPERER
WAVE 3: 4 WARCLAN BRUTE, 1 TAUREN WARCALLER
WAVE 4: 2 WARCLAN BRUTE, 2 TAUREN BRUTE, 1 WARCLAN SPEARTHROWER

and I tried implementing this with the code I set up, but no matter what, i can't figure out why it's closing the game.
 
If you're using PlayerEx I believe blue would be 2, but 1 with Player right? Anyway I doubt it makes much difference (unless your AI is the red player maybe) but it's worth trying to modify that
tried it and it still keeps closing the game rip, I'm planning to use a custom function made by Macielos4759 because apparently reforged breaks AI when the map is larger than 224x+ and mine is welll... way above that.. I'll try to see if I see anychanges
 
If you're using PlayerEx I believe blue would be 2, but 1 with Player right? Anyway I doubt it makes much difference (unless your AI is the red player maybe) but it's worth trying to modify that
Hey figured I'd ask but do you have any idea why importing a modified common.ai file into my map bugs out the AI? I can't seem to make it work, even importing the original unmodified version still makes my AI enemies static.
 
Having 2 types of workers shouldn't be a problem, although I recommend using 1 type only, just in case.
Perhaps also use these after call SetReplacements(1, 1, 3):
set campaign_wood_peons = 2
set campaign_gold_peons = 4

And I'd do this:
JASS:
call SetBuildUnitEx(1,1,1,'o60B') // Great Hall
    call SetBuildUnitEx(1,1,1,'o607') // Grim Barracks
    call SetBuildUnitEx(1,1,1,'o608') // Horned Barracks
    call SetBuildUnitEx(4,4,4,'o609') // Pig Farms
    call SetBuildUnitEx(1,1,1,'o60C') // Ancestral Lodge
    call SetBuildUnitEx(1,1,1,'o60F') // Warforge

    //----------------------------------------------------
    // WORKERS
    //----------------------------------------------------
    call SetBuildUnitEx(2,2,2,'o60I') // Lumber Tauren Worker
    call SetBuildUnitEx(3,3,3,'o60I') // Gold Tauren Worker

Like that:


JASS:
    call SetBuildUnitEx(1,1,1,'o60B') // Great Hall
    call SetBuildUnitEx(1,1,1,'o60I') // Lumber Tauren Worker
    call SetBuildUnitEx(1,1,1,'o60I') // Gold Tauren Worker
    call SetBuildUnitEx(1,1,1,'o607') // Grim Barracks
    call SetBuildUnitEx(1,1,1,'o608') // Horned Barracks
    call SetBuildUnitEx(4,4,4,'o609') // Pig Farms
    call SetBuildUnitEx(1,1,1,'o60C') // Ancestral Lodge
    call SetBuildUnitEx(1,1,1,'o60F') // Warforge

    //----------------------------------------------------
    // WORKERS
    //----------------------------------------------------
    call SetBuildUnitEx(2,2,2,'o60I') // Lumber Tauren Worker
    call SetBuildUnitEx(3,3,3,'o60I') // Gold Tauren Worker

And perhaps use -> call SuicideOnPlayer(M2,user), instead of call SuicideOnPlayerEx(M2,M2,M2,user)
(This shouldn't be the issue, but trying won't hurt)
 
Having 2 types of workers shouldn't be a problem, although I recommend using 1 type only, just in case.
Perhaps also use these after call SetReplacements(1, 1, 3):
set campaign_wood_peons = 2
set campaign_gold_peons = 4

And I'd do this:
JASS:
call SetBuildUnitEx(1,1,1,'o60B') // Great Hall
    call SetBuildUnitEx(1,1,1,'o607') // Grim Barracks
    call SetBuildUnitEx(1,1,1,'o608') // Horned Barracks
    call SetBuildUnitEx(4,4,4,'o609') // Pig Farms
    call SetBuildUnitEx(1,1,1,'o60C') // Ancestral Lodge
    call SetBuildUnitEx(1,1,1,'o60F') // Warforge

    //----------------------------------------------------
    // WORKERS
    //----------------------------------------------------
    call SetBuildUnitEx(2,2,2,'o60I') // Lumber Tauren Worker
    call SetBuildUnitEx(3,3,3,'o60I') // Gold Tauren Worker

Like that:


JASS:
    call SetBuildUnitEx(1,1,1,'o60B') // Great Hall
    call SetBuildUnitEx(1,1,1,'o60I') // Lumber Tauren Worker
    call SetBuildUnitEx(1,1,1,'o60I') // Gold Tauren Worker
    call SetBuildUnitEx(1,1,1,'o607') // Grim Barracks
    call SetBuildUnitEx(1,1,1,'o608') // Horned Barracks
    call SetBuildUnitEx(4,4,4,'o609') // Pig Farms
    call SetBuildUnitEx(1,1,1,'o60C') // Ancestral Lodge
    call SetBuildUnitEx(1,1,1,'o60F') // Warforge

    //----------------------------------------------------
    // WORKERS
    //----------------------------------------------------
    call SetBuildUnitEx(2,2,2,'o60I') // Lumber Tauren Worker
    call SetBuildUnitEx(3,3,3,'o60I') // Gold Tauren Worker

And perhaps use -> call SuicideOnPlayer(M2,user), instead of call SuicideOnPlayerEx(M2,M2,M2,user)
(This shouldn't be the issue, but trying won't hurt)
sadly its still crashing when its about to send its first attack wave to the player, i feel like the only option i can think of rn is lessen the size of the map and see if that'll work

EDIT: 100% map size was the problem, thanks for trying to help guys
 
Last edited:
Still have an issue with the common.ai?

If so, share it here, I have a suspicion.
I tried to replace the old suicide function with the new one provided by macielas, but the original unedited version and the modified bugs out the AI. I attached the new function along with a modified and unmodified common ai
 

Attachments

Hm now that you remind me, perhaps certain patches have this map size bug.
I remember my finale on the scourge of lordaeron reworked crashed whenever any AI would send its first attack wave on patch 1.29.2, but it would work perfectly on patch 1.31
Yeah, its super weird I cant understand why this is an issue. Anyways, I decided to just make the map smaller, thanks all for trying :peasant-blushing:
 
Back
Top