- Joined
- Jan 22, 2013
- Messages
- 11
Hello readers!
So, for the past week or so I've been going through some JASS to make some A.I for my campaign and I'm using some A.I made by Blizzard as references to see if I'm on the right track with what I want. I have looked up some tutorials and one in particular seemed helpful however the 'helpfulness' was short lived as it just didn't help, sadly.
My script is supposed to be a simple A.I that attacks, leaves defenders and replaces destroyed buildings and units. The A.I doesn't go looking for bases to expand to, even for difficulty reasons since it's not that kind of map. So yeah, easy.
Here's what it looks like.
Here is the reference script from the fifth Undead mission in Reign of Chaos
Which, to make it easier on me, I cut down to this...
Now, the reference scripts (including the one I cut down) work 100% fine and despite the fact my script is pretty identical to them, it doesn't work.
My peasants just mine gold and idle otherwise. Heck, I've even gotten rid of
to see if it'd work and no change.
I was hoping someone here could help me with this issue as it's really starting to annoy me that I can't seem to write my own A.I from scratch, I'd hate and refuse to grab someone elses and edit it for use. A free Tic Tac for anyone that helps out in anyway.
Thanks in advance and sorry if this is something super simple and I'm just dumb.
So, for the past week or so I've been going through some JASS to make some A.I for my campaign and I'm using some A.I made by Blizzard as references to see if I'm on the right track with what I want. I have looked up some tutorials and one in particular seemed helpful however the 'helpfulness' was short lived as it just didn't help, sadly.
My script is supposed to be a simple A.I that attacks, leaves defenders and replaces destroyed buildings and units. The A.I doesn't go looking for bases to expand to, even for difficulty reasons since it's not that kind of map. So yeah, easy.
Here's what it looks like.
JASS:
//============================================================================
//highelf 05 -- High Elven Ranger Corps. - Blue
//============================================================================
globals
player red Player(0)
endglobals
//============================================================================
// main
//============================================================================
function main takes nothing returns nothing
call CampaignAI(ELF_FARM, null)
set campaign_wood_peons = 5
call SetReplacements(1,1,3)
//************************
//* Building/Defense Strat
//************************
call SetBuildUnitEx( 2,2,2, PEASANT)
call SetBuiltUnitEx( 1,2,3, ELF_FARM)
call SetBuildUnitEx( 0,0,1, ELF_HIGH_BARRACKS)
call SetBuildUnitEx( 0,1,2, HIGH_GUARD_TOWER)
call SetBuildUnitEx( 0,0,1, ARCANE_SANCTUM)
call setBuildUnitEx( 5,5,5, PEASANT)
call CampaignDefenderEx(4,5,5,HIGH_SWORDSMAN)
call CampaignDefenderEx(4,5,5,HIGH_ARCHER)
call CampaignDefenderEx(2,2,3, PRIEST)
call CampaignDefenderEx(1,1,1, 'H601')
call CampaignDefenderEx(1,2,2, 'e600')
//************************
//* Building/Defense Strat end
//* Attacking Strat
//************************
loop
//*** WAVE 1 ***
call InitAssaultGroup()
call CampaignAttackerEx( 4,5,5, HIGH_SWORDSMAN )
call CampaignAttackerEx( 3,4,6, HIGH_ARCHER )
call CampaignAttackerEx( 1,2,2, PRIEST )
call CampaignAttackerEx( 0,1,1, 'e600' )
call CampaignAttackerEx( 0,1,1, 'H601' )
call SuicideOnPlayerEx( M2,M3,M3, red )
endloop
//************************
//* Attacking Strat end
//************************
endfunction
Here is the reference script from the fifth Undead mission in Reign of Chaos
JASS:
//============================================================================
// Undead 05 -- blue player -- AI Script
//============================================================================
globals
player user = Player(3)
endglobals
//============================================================================
// main
//============================================================================
function main takes nothing returns nothing
call CampaignAI(ELF_FARM,null)
set do_campaign_farms = false
call SetReplacements(1,1,3)
call SetBuildUnitEx( 0,0,1, TOWN_HALL )
call SetBuildUnitEx( 2,2,2, PEASANT )
call SetBuildUnitEx( 0,0,1, ELF_HIGH_BARRACKS )
call SetBuildUnitEx( 0,0,8, ELF_FARM )
call SetBuildUnitEx( 5,5,5, PEASANT )
call CampaignDefenderEx( 1,1,1, HIGH_SWORDMAN )
call CampaignDefenderEx( 1,1,1, HIGH_ARCHER )
call CampaignDefenderEx( 0,0,1, SORCERESS )
call CampaignDefenderEx( 0,0,1, SYLVANUS )
call WaitForSignal()
//*** WAVE 1 ***
call InitAssaultGroup()
call CampaignAttackerEx( 1,1,2, HIGH_SWORDMAN )
call CampaignAttackerEx( 2,2,4, HIGH_ARCHER )
call SuicideOnPlayer(0,user)
call SetBuildUpgrEx( 1,1,1, UPG_SORCERY )
call SetBuildUpgrEx( 1,1,1, UPG_PRAYING )
//*** WAVE 2 ***
call InitAssaultGroup()
call CampaignAttackerEx( 1,1,3, HIGH_SWORDMAN )
call CampaignAttackerEx( 3,3,3, HIGH_ARCHER )
call CampaignAttackerEx( 1,1,1, SYLVANUS )
call SuicideOnPlayerEx(M6,M6,M5,user)
call SetBuildUpgrEx( 1,1,1, UPG_DEFEND )
//*** WAVE 3 ***
call InitAssaultGroup()
call CampaignAttackerEx( 1,1,4, HIGH_SWORDMAN )
call CampaignAttackerEx( 3,3,4, HIGH_ARCHER )
call CampaignAttackerEx( 1,1,1, PRIEST )
call CampaignAttackerEx( 0,0,1, SORCERESS )
call CampaignAttackerEx( 1,1,2, BALLISTA )
call SuicideOnPlayerEx(M7,M7,M4,user)
//*** WAVE 4 ***
call InitAssaultGroup()
call CampaignAttackerEx( 4,4,4, HIGH_SWORDMAN )
call CampaignAttackerEx( 2,2,4, HIGH_ARCHER )
call CampaignAttackerEx( 1,1,1, PRIEST )
call CampaignAttackerEx( 1,1,1, SYLVANUS )
call SuicideOnPlayerEx(M7,M7,M5,user)
call SetBuildUpgrEx( 0,0,2, UPG_SORCERY )
call SetBuildUpgrEx( 0,0,2, UPG_PRAYING )
//*** WAVE 5 ***
call InitAssaultGroup()
call CampaignAttackerEx( 3,3,4, HIGH_SWORDMAN )
call CampaignAttackerEx( 3,3,4, HIGH_ARCHER )
call CampaignAttackerEx( 1,1,2, PRIEST )
call CampaignAttackerEx( 0,0,1, SORCERESS )
call CampaignAttackerEx( 0,0,1, SYLVANUS )
call CampaignAttackerEx( 1,1,1, BALLISTA )
call SuicideOnPlayerEx(M6,M6,M4,user)
loop
//*** WAVE 6+ ***
call InitAssaultGroup()
call CampaignAttackerEx( 2,2,2, HIGH_SWORDMAN)
call CampaignAttackerEx( 5,5,7, HIGH_ARCHER )
call CampaignAttackerEx( 1,1,2, PRIEST )
call CampaignAttackerEx( 1,1,1, SORCERESS )
call CampaignAttackerEx( 1,1,1, SYLVANUS )
call SuicideOnPlayerEx(M7,M7,M5,user)
//*** WAVE 7+ ***
call InitAssaultGroup()
call CampaignAttackerEx( 4,4,4, HIGH_SWORDMAN)
call CampaignAttackerEx( 2,2,2, HIGH_ARCHER )
call CampaignAttackerEx( 3,3,4, PRIEST )
call CampaignAttackerEx( 0,0,1, SORCERESS )
call CampaignAttackerEx( 1,1,2, BALLISTA )
call SuicideOnPlayerEx(M6,M6,M4,user)
//*** WAVE 8+ ***
call InitAssaultGroup()
call CampaignAttackerEx( 2,2,3, HIGH_SWORDMAN)
call CampaignAttackerEx( 3,3,3, HIGH_ARCHER )
call CampaignAttackerEx( 1,1,2, PRIEST )
call CampaignAttackerEx( 2,2,2, SORCERESS )
call CampaignAttackerEx( 1,1,1, SYLVANUS )
call SuicideOnPlayerEx(M7,M7,M5,user)
endloop
endfunction
Which, to make it easier on me, I cut down to this...
JASS:
//============================================================================
// Undead 05 -- blue player -- AI Script
//============================================================================
globals
player user = Player(3)
endglobals
//============================================================================
// main
//============================================================================
function main takes nothing returns nothing
call CampaignAI(ELF_FARM,null)
set do_campaign_farms = false
call SetReplacements(1,1,3)
call SetBuildUnitEx( 0,0,1, TOWN_HALL )
call SetBuildUnitEx( 2,2,2, PEASANT )
call SetBuildUnitEx( 0,0,1, ELF_HIGH_BARRACKS )
call SetBuildUnitEx( 0,0,8, ELF_FARM )
call SetBuildUnitEx( 5,5,5, PEASANT )
call CampaignDefenderEx( 1,1,1, HIGH_SWORDMAN )
call CampaignDefenderEx( 1,1,1, HIGH_ARCHER )
call CampaignDefenderEx( 0,0,1, SORCERESS )
call CampaignDefenderEx( 0,0,1, SYLVANUS )
loop
//*** WAVE 8+ ***
call InitAssaultGroup()
call CampaignAttackerEx( 2,2,3, HIGH_SWORDMAN)
call CampaignAttackerEx( 3,3,3, HIGH_ARCHER )
call CampaignAttackerEx( 1,1,2, PRIEST )
call CampaignAttackerEx( 2,2,2, SORCERESS )
call CampaignAttackerEx( 1,1,1, SYLVANUS )
call SuicideOnPlayerEx(M7,M7,M5,user)
endloop
endfunction
Now, the reference scripts (including the one I cut down) work 100% fine and despite the fact my script is pretty identical to them, it doesn't work.
My peasants just mine gold and idle otherwise. Heck, I've even gotten rid of
JASS:
set campaign_wood_peons = 5
set campaign_gold_peons = 4
I was hoping someone here could help me with this issue as it's really starting to annoy me that I can't seem to write my own A.I from scratch, I'd hate and refuse to grab someone elses and edit it for use. A free Tic Tac for anyone that helps out in anyway.

Thanks in advance and sorry if this is something super simple and I'm just dumb.

Last edited: