- Joined
- Sep 29, 2010
- Messages
- 29
ok so im trying to learn Campaign ai as i wanna make my own campaign.
So i took this template script and edited some what to try and have them attack the player who would be purple team. (reason why their all 60 seconds is for testing)
all they do is just send preplace units for the attack waves and dont build any and wont harvest lumber and if they just start with peasants and a town hall they build all the way up to a barracks dont harvest lumber and one peasant just stands there. Im very confused and would love some help just remember im new to Jass and a bit of a noob
So i took this template script and edited some what to try and have them attack the player who would be purple team. (reason why their all 60 seconds is for testing)
all they do is just send preplace units for the attack waves and dont build any and wont harvest lumber and if they just start with peasants and a town hall they build all the way up to a barracks dont harvest lumber and one peasant just stands there. Im very confused and would love some help just remember im new to Jass and a bit of a noob
JASS:
//******************************************************************************
//* Human Campaign AI *
//* Bloody Stress *
//******************************************************************************
//*
globals
player MyVictim = PlayerEx(4)
endglobals
function ConfigureAI takes nothing returns nothing
call SetSlowChopping( true )
call SetDefendPlayer( false )
call SetRandomPaths( false )
call SetTargetHeroes( true )
call SetPeonsRepair( true )
call SetHeroesFlee( false )
call SetHeroesBuyItems( true )
call SetUnitsFlee( false )
call SetGroupsFlee( false )
call SetWatchMegaTargets( true )
call SetIgnoreInjured( true )
call SetHeroesTakeItems( true )
call SetSlowChopping( true )
call SetCaptainChanges( false )
call SetSmartArtillery( true )
endfunction
function hero_levels takes nothing returns integer
local integer hero = GetHeroId()
local integer level = GetHeroLevelAI()
local integer a = 0
if hero == PALADIN then
if level == 1 or level == 3 or level == 5 then
set a = HOLY_BOLT
endif
if level == 2 or level == 4 or level == 7 then
set a = DIVINE_SHIELD
endif
if level >= 8 then
set a = DEVOTION_AURA
endif
if level == 6 then
set a = RESURRECTION
endif
endif
return a
endfunction
function HarvestPriorities takes nothing returns nothing
local integer mine = TownWithMine()
local integer allGold = GetUnitCountDone('hpea')
local integer allWood = GetUnitCountDone('hpea')
local integer numWorkers
set numWorkers = 5
call HarvestGold( 0, numWorkers )
set numWorkers = 5
call HarvestWood( 0, numWorkers )
set numWorkers = 5
call HarvestGold( 1, numWorkers )
set numWorkers = 4
call HarvestWood( 0, numWorkers )
endfunction
function main takes nothing returns nothing
call CampaignAI( HOUSE, function hero_levels )
call ConfigureAI( )
// **********************************
// * Building Strategy *
// **********************************
//
// Tier 1 Buildings
call SetReplacements( 1, 2, 3 )
call SetBuildUnitEx( 1, 1, 1, TOWN_HALL )
call SetBuildUnit( 7, PEASANT )
call ClearHarvestAI( )
call HarvestPriorities( )
call SetBuildUnitEx( 1, 2, 3, HOUSE )
call SetBuildUnitEx( 1, 2, 3, BARRACKS )
call SetBuildUnit( 1, HUMAN_ALTAR )
call SetBuildUnit( 1, LUMBER_MILL )
call SetBuildUnit( 1, BLACKSMITH )
call CampaignDefenderEx( 3, 4, 5, FOOTMAN )
call CampaignDefenderEx( 2, 2, 2, RIFLEMAN )
call SetBuildUnitEx( 3, 4, 5, WATCH_TOWER )
// Tier 2 buildings
call SetBuildUnit( 1, KEEP )
call SetBuildUnitEx( 1, 2, 2, SANCTUM )
call SetBuildUnit( 1, WORKSHOP )
// Tier 3 buildings
call SetBuildUnit( 1, CASTLE )
call SetBuildUnitEx( 0, 1, 1, ARCANE_VAULT )
// **********************************
// * End Building Strategy *
// **********************************
// **********************************
// * Attack Strategy *
// **********************************
//*** WAVE 1 *** AI will begin to attack in 5 minutes
call InitAssaultGroup()
call CampaignAttackerEx( 2, 3, 3, FOOTMAN )
call CampaignAttackerEx( 0, 1, 2, RIFLEMAN )
call SuicideOnPlayerEx( 30, 30, 30, MyVictim )
call SetBuildUpgrEx( 1, 2, 3, UPG_MELEE )
call SetBuildUpgrEx( 1, 2, 3, UPG_RANGED )
call SetBuildUpgrEx( 1, 2, 3, UPG_LEATHER )
//*** WAVE 2 *** Between 2 or 3 minutes after Wave 1
call InitAssaultGroup()
call CampaignAttackerEx( 3, 4, 4, FOOTMAN )
call CampaignAttackerEx( 1, 2, 3, RIFLEMAN )
call SuicideOnPlayerEx( 60, 60, 60, MyVictim )
//*** WAVE 3 *** Between 2 or 3 minutes after Wave 2
call InitAssaultGroup()
call CampaignAttackerEx( 3, 4, 4, FOOTMAN )
call CampaignAttackerEx( 1, 2, 3, RIFLEMAN )
call CampaignAttackerEx( 1, 1, 1, PALADIN )
call SuicideOnPlayerEx( 60, 60, 60, MyVictim )
//*** WAVE 4 *** Between 2 or 3 minutes after Wave 3
call InitAssaultGroup()
call CampaignAttackerEx( 3, 4, 4, FOOTMAN )
call CampaignAttackerEx( 1, 2, 3, RIFLEMAN )
call CampaignAttackerEx( 0, 1, 1, PRIEST )
call CampaignAttackerEx( 1, 1, 1, PALADIN )
call SuicideOnPlayerEx( 60, 60, 60, MyVictim )
call SetBuildUpgrEx( 1, 1, 1, UPG_SORCERY )
//*** WAVE 5 *** Between 3 or 4 minutes after Wave 4
call InitAssaultGroup()
call CampaignAttackerEx( 3, 3, 3, FOOTMAN )
call CampaignAttackerEx( 2, 2, 2, RIFLEMAN )
call CampaignAttackerEx( 1, 1, 1, PALADIN )
call CampaignAttackerEx( 0, 1, 2, PRIEST )
call SuicideOnPlayerEx( 60, 60, 60, MyVictim )
//*** WAVE 6 *** Between 3 or 4 minutes after Wave 5
call InitAssaultGroup()
call CampaignAttackerEx( 3, 3, 3, FOOTMAN )
call CampaignAttackerEx( 2, 2, 2, RIFLEMAN )
call CampaignAttackerEx( 1, 1, 1, PALADIN )
call CampaignAttackerEx( 1, 2, 3, PRIEST )
call CampaignAttackerEx( 0, 1, 2, SORCERESS )
call SuicideOnPlayerEx( 60, 60, 60, MyVictim )
//*** chimaera Upgrade
call SetBuildUpgrEx( 0, 0, 1, UPG_BREEDING )
loop //Init the infinite attack loop
//*** WAVE 7 *** Between 3 or 5 minutes after Wave 6
call InitAssaultGroup()
call CampaignAttackerEx( 2, 2, 2, FOOTMAN )
call CampaignAttackerEx( 2, 2, 2, RIFLEMAN )
call CampaignAttackerEx( 1, 1, 1, PALADIN )
call CampaignAttackerEx( 1, 2, 3, PRIEST )
call CampaignAttackerEx( 0, 1, 2, SORCERESS )
call CampaignAttackerEx( 0, 1, 2, MORTAR )
call SuicideOnPlayerEx( 60, 60, 60, MyVictim )
//*** WAVE 8 *** Between 3 or 5 minutes after Wave 7
call InitAssaultGroup()
call CampaignAttackerEx( 2, 2, 2, FOOTMAN )
call CampaignAttackerEx( 2, 2, 2, RIFLEMAN )
call CampaignAttackerEx( 1, 1, 1, PALADIN )
call CampaignAttackerEx( 1, 2, 3, PRIEST )
call CampaignAttackerEx( 0, 1, 2, SORCERESS )
call SuicideOnPlayerEx( 60, 60, 60, MyVictim )
//*** WAVE 9 *** Between 4 or 6 minutes after Wave 8
call InitAssaultGroup()
call CampaignAttackerEx( 2, 2, 2, FOOTMAN )
call CampaignAttackerEx( 2, 2, 2, RIFLEMAN )
call CampaignAttackerEx( 1, 1, 1, PALADIN )
call CampaignAttackerEx( 1, 2, 3, PRIEST )
call CampaignAttackerEx( 0, 1, 2, SORCERESS )
call CampaignAttackerEx( 0, 1, 2, MORTAR )
call CampaignAttackerEx( 1, 1, 2, KNIGHT )
call SuicideOnPlayerEx( 60, 60, 60, MyVictim )
endloop
// **********************************
// * Attack Strategy never ends *
// **********************************
endfunction