- Joined
- Feb 15, 2006
- Messages
- 851
Well, GUI AI editor has its limitations.Seriously, if only melee AI creation, its still best and easy to configure it in GUI mode, and
just do the rest of the attacking/engaging in triggers, but good tutorials anyway...
About the second point, it seems it's a bug with the jass script of the site, I tried to edit it, but nothing changesGreat tutorial. Nice explanations and great for those who want to learn how to create an AI using the common.ai scripts. =)
This is in an approvable state, but two things should be fixed first:
1) The links to JassCraft and Jass Shop Pro link to random hive maps. (lol) Replace those links with the ones from wc3c.net
2) One of the JASS tags has everything on one line. Under the category "Attacking Strategy"
Once those changes have been made this will be approved!
function main takes nothing returns nothing
local unit crp
// Building code goes here
//*** WAVE 1 ***
call InitAssaultGroup()
set crp = GetCreepCamp(0,9,false) // Stores the target unit
call CampaignAttackerEx( 2, 3, 3, ARCHER )
call CampaignAttackerEx( 0, 1, 2, HUNTRESS )
call Sleep( M3 ) // Waits 3 minutes before attacking
call AttackMoveKillA(crp) // Order assault group to attack that unit
endfunction
How about this? You could also try copying the code into something like WordPad before pasting it into your post.JASS:function main takes nothing returns nothing local unit crp // Building code goes here //*** WAVE 1 *** call InitAssaultGroup() set crp = GetCreepCamp(0,9,false) // Stores the target unit call CampaignAttackerEx( 2, 3, 3, ARCHER ) call CampaignAttackerEx( 0, 1, 2, HUNTRESS ) call Sleep( M3 ) // Waits 3 minutes before attacking call AttackMoveKillA(crp) // Order assault group to attack that unit endfunction
globals
player AttackTo = Player(12) //attacking
endglobals
function ConfigureAI takes nothing returns nothing
call SetSlowChopping( true )
call SetPeonsRepair( true )
call SetHeroesTakeItems (true)
call SetHeroesBuyItems(true)
endfunction
function hero_levels takes nothing returns integer
local integer hero = GetHeroId()
local integer level = GetHeroLevelAI()
local integer a = 0
if hero == BLADE_MASTER then
if level == 1 or level == 3 or level == 5 then
set a = MIRROR_IMAGE
endif
if level == 2 or level == 4 or level == 7 then
set a = CRITICAL_STRIKE
endif
if level >= 8 then
set a = WIND_WALK
endif
if level == 6 then
set a = BLADE_STORM
endif
endif
return a
endfunction
function main takes nothing returns nothing
call CampaignAI( BURROW, function hero_levels )
call ConfigureAI( )
//============================
call SetBuildUnit( 3, PEON )
call SetBuildUnit( 1, GREAT_HALL )
call SetBuildUnit( 2, BURROW )
call SetBuildUnit( 1, ORC_ALTAR )
call SetBuildUnit( 4, PEON )
call SetBuildUnit( 3, BURROW )
call SetBuildUnit( 1, ORC_BARRACKS )
call SetBuildUnit( 5, PEON )
call SetBuildUnit( 1, BLADE_MASTER )
call SetBuildUnit( 1, GRUNT )
call SetBuildUnit( 4, BURROW )
call SetBuildUnit( 6, PEON )
call SetBuildUnit( 2, ORC_BARRACKS )
call SetBuildUnit( 2, GRUNT )
call SetBuildUnit( 3, GRUNT )
call SetBuildUnit( 4, GRUNT )
call SetBuildUnit( 5, GRUNT )
call SetBuildUnit( 6, GRUNT )
call SetBuildUnit( 7, GRUNT )
loop
call InitAssaultGroup()
call CampaignAttackerEx( 1, 1, 1, BLADE_MASTER )
call CampaignAttackerEx( 3, 3, 3, GRUNT )
call SuicideOnPlayerEx( 10, 10, 10, AttackTo )
//============================
call InitAssaultGroup()
call CampaignAttackerEx( 1, 1, 1, BLADE_MASTER )
call CampaignAttackerEx( 4, 4, 4, GRUNT )
call SuicideOnPlayerEx( 10, 10, 10, AttackTo )
//============================
call InitAssaultGroup()
call CampaignAttackerEx( 1, 1, 1, BLADE_MASTER )
call CampaignAttackerEx( 5, 5, 5, GRUNT )
call SuicideOnPlayerEx( 10, 10, 10, AttackTo )
//============================
call InitAssaultGroup()
call CampaignAttackerEx( 1, 1, 1, BLADE_MASTER )
call CampaignAttackerEx( 6, 6, 6, GRUNT )
call SuicideOnPlayerEx( 10, 10, 10, AttackTo )
endloop
endfunction
IDK if it's just me but the loop in this code doent work at all...
The AI builds and trains and first attack is OK, but it doent loop...
JASS:globals player AttackTo = Player(12) //attacking endglobals function ConfigureAI takes nothing returns nothing call SetSlowChopping( true ) call SetPeonsRepair( true ) call SetHeroesTakeItems (true) call SetHeroesBuyItems(true) endfunction function hero_levels takes nothing returns integer local integer hero = GetHeroId() local integer level = GetHeroLevelAI() local integer a = 0 if hero == BLADE_MASTER then if level == 1 or level == 3 or level == 5 then set a = MIRROR_IMAGE endif if level == 2 or level == 4 or level == 7 then set a = CRITICAL_STRIKE endif if level >= 8 then set a = WIND_WALK endif if level == 6 then set a = BLADE_STORM endif endif return a endfunction function main takes nothing returns nothing call CampaignAI( BURROW, function hero_levels ) call ConfigureAI( ) //============================ call SetBuildUnit( 3, PEON ) call SetBuildUnit( 1, GREAT_HALL ) call SetBuildUnit( 2, BURROW ) call SetBuildUnit( 1, ORC_ALTAR ) call SetBuildUnit( 4, PEON ) call SetBuildUnit( 3, BURROW ) call SetBuildUnit( 1, ORC_BARRACKS ) call SetBuildUnit( 5, PEON ) call SetBuildUnit( 1, BLADE_MASTER ) call SetBuildUnit( 1, GRUNT ) call SetBuildUnit( 4, BURROW ) call SetBuildUnit( 6, PEON ) call SetBuildUnit( 2, ORC_BARRACKS ) call SetBuildUnit( 2, GRUNT ) call SetBuildUnit( 3, GRUNT ) call SetBuildUnit( 4, GRUNT ) call SetBuildUnit( 5, GRUNT ) call SetBuildUnit( 6, GRUNT ) call SetBuildUnit( 7, GRUNT ) loop call InitAssaultGroup() call CampaignAttackerEx( 1, 1, 1, BLADE_MASTER ) call CampaignAttackerEx( 3, 3, 3, GRUNT ) call SuicideOnPlayerEx( 10, 10, 10, AttackTo ) //============================ call InitAssaultGroup() call CampaignAttackerEx( 1, 1, 1, BLADE_MASTER ) call CampaignAttackerEx( 4, 4, 4, GRUNT ) call SuicideOnPlayerEx( 10, 10, 10, AttackTo ) //============================ call InitAssaultGroup() call CampaignAttackerEx( 1, 1, 1, BLADE_MASTER ) call CampaignAttackerEx( 5, 5, 5, GRUNT ) call SuicideOnPlayerEx( 10, 10, 10, AttackTo ) //============================ call InitAssaultGroup() call CampaignAttackerEx( 1, 1, 1, BLADE_MASTER ) call CampaignAttackerEx( 6, 6, 6, GRUNT ) call SuicideOnPlayerEx( 10, 10, 10, AttackTo ) endloop endfunction
Sorry I really didnt get your answer, you mean to say that I should increase the wait?, I already did that for 60,120 etc... and it doesnt work...According to your code you give 10 seconds to the units to do the attack. SuicideOnPlayerEx does a wait in the for that time while the AI does the job.
I mean this :Sorry I really didnt get your answer, you mean to say that I should increase the wait?, I already did that for 60,120 etc... and it doesnt work...
SuicideOnPlayerEx calls many sub functions so I went to the root of it (CommonSuicideOnPlayer), unfortunately IDK how those function works after that...
And again, ONLY the loop doesnt work, the first attack is OK...
call SuicideOnPlayerEx( 10, 10, 10, AttackTo ) // right now the AI wait 10 seconds, you need minutes in order to let the AI do the job
call SuicideOnPlayerEx( M10, M10, M10, AttackTo )
coz M1=60, M2=120I already did that for 60,120 etc... and it doesnt work...
loop
// some actions ...
endloop
// some actions
endloop
function main takes nothing returns nothing
call DisplayTextToPlayer(Player(0),0,0,"AI started")
// Start you AI
endfunction
//******************************************************************************
//* Human Campaign AI *
//* By wa666r *
//******************************************************************************
//*
globals
player MyVictim = Player( 0 )
endglobals
function ConfigureAI takes nothing returns nothing
call SetSlowChopping( false )
call SetPeonsRepair( true )
endfunction
function hero_levels takes nothing returns integer
local integer hero = GetHeroId()
local integer level = GetHeroLevelAI()
local integer a = 0
if hero == 'Hpal' then
if level == 1 or level == 3 or level == 5 then
set a = 'AHhb'
endif
if level == 2 or level == 4 or level == 7 then
set a = 'AHds'
endif
if level >= 8 then
set a = 'AHad'
endif
if level == 6 then
set a = 'AHre'
endif
endif
if hero == 'Hamg' then
if level == 1 or level == 3 or level == 5 then
set a = 'AHbz'
endif
if level == 2 or level == 4 or level == 7 then
set a = 'AHad'
endif
if level >= 8 then
set a = 'AHwe'
endif
if level == 6 then
set a = 'AHmt'
endif
endif
return a
endfunction
function main takes nothing returns nothing
call CampaignAI( 'hhou', function hero_levels )
call ConfigureAI( )
// **********************************
// * Building Strategy *
// **********************************
//
// Tier 1 Buildings
call SetReplacements( 1, 2, 3 )
call SetBuildUnitEx( 1, 1, 1, 'htow' )
call SetBuildUnit( 15, 'hpea' )
call SetBuildUnitEx( 1, 2, 3, 'hhou' )
call SetBuildUnitEx( 1, 2, 2, 'hbar' )
call SetBuildUnit( 1, ) //Here's your mistake.... missing arguments...
call SetBuildUnit( 1, 'hbla' )
call CampaignDefenderEx( 2, 2, 3, 'hfoo' )
call CampaignDefenderEx( 1, 1, 1, 'hrif' )
call SetBuildUnitEx( 1, 2, 3, 'hwtw' )
// Tier 2 buildings
call SetBuildUnit( 1, 'hkee' )
call SetBuildUnitEx( 1, 2, 2, 'hars' )
call SetBuildUnit( 1, 'harm' )
// Tier 3 buildings
call SetBuildUnit( 1, 'hcas' )
call SetBuildUnitEx( 0, 1, 1, 'hcas' )
// **********************************
// * End Building Strategy *
// **********************************
// **********************************
// * Attack Strategy *
// **********************************
//*** WAVE 1 *** AI will begin to attack in 5 minutes
call InitAssaultGroup()
call CampaignAttackerEx( 2, 3, 3, 'hfoo')
call CampaignAttackerEx( 0, 1, 2, 'hrif' )
call SuicideOnPlayerEx( M5, M5, M5, MyVictim )
//*** Basic upgrades from HUNTERS HALL ***
call SetBuildUpgrEx( 1, 2, 3, 'Rhme' )
call SetBuildUpgrEx( 1, 2, 3, 'Rhar' )
call SetBuildUpgrEx( 1, 2, 3, 'Rhla' )
call SetBuildUpgrEx( 1, 2, 3, 'Rhra' )
//*** WAVE 2 *** Between 2 or 3 minutes after Wave 1
call InitAssaultGroup()
call CampaignAttackerEx( 3, 4, 4, 'hfoo' )
call CampaignAttackerEx( 1, 2, 3, 'hrif' )
call SuicideOnPlayerEx( M3, M2, M2, MyVictim )
//*** WAVE 3 *** Between 2 or 3 minutes after Wave 2
call InitAssaultGroup()
call CampaignAttackerEx( 3, 4, 4, 'hfoo' )
call CampaignAttackerEx( 1, 2, 3, 'hrif' )
call CampaignAttackerEx( 1, 1, 1, 'Hpal' )
call SuicideOnPlayerEx( M3, M2, M2, MyVictim )
//*** WAVE 4 *** Between 2 or 3 minutes after Wave 3
call InitAssaultGroup()
call CampaignAttackerEx( 3, 4, 4, 'hfoo' )
call CampaignAttackerEx( 1, 2, 3, 'hrif' )
call CampaignAttackerEx( 0, 1, 1, 'hmtm' )
call CampaignAttackerEx( 1, 1, 1, 'Hpal' )
call SuicideOnPlayerEx( M3, M2, M2, MyVictim )
//*** Dryad Upgrade
call SetBuildUpgrEx( 1, 1, 1, 'Rhde' )
//*** WAVE 5 *** Between 3 or 4 minutes after Wave 4
call InitAssaultGroup()
call CampaignAttackerEx( 3, 3, 3, 'hfoo' )
call CampaignAttackerEx( 2, 2, 2, 'hrif' )
call CampaignAttackerEx( 1, 1, 1, 'Hpal' )
call CampaignAttackerEx( 0, 1, 2, 'hmpr' )
call SuicideOnPlayerEx( M4, M3, M3, MyVictim )
//*** Druid of the Claw Upgrade
call SetBuildUpgrEx( 0, 1, 2, 'Rhpt' )
//*** WAVE 6 *** Between 3 or 4 minutes after Wave 5
call InitAssaultGroup()
call CampaignAttackerEx( 2, 2, 2, 'Hrif' )
call CampaignAttackerEx( 1, 1, 1, 'Hpal' )
call CampaignAttackerEx( 1, 1, 1, 'Hamg' )
call CampaignAttackerEx( 1, 2, 3, 'hmpr' )
call CampaignAttackerEx( 0, 1, 2, 'hkni' )
call SuicideOnPlayerEx( M4, M3, M3, MyVictim )
//*** chimaera Upgrade
call SetBuildUpgrEx( 0, 0, 1, 'Rhri' )
loop //Init the infinite attack loop
//*** WAVE 7 *** Between 3 or 5 minutes after Wave 6
call InitAssaultGroup()
call CampaignAttackerEx( 2, 2, 2, 'hfoo' )
call CampaignAttackerEx( 1, 1, 1, 'Hpal' )
call CampaignAttackerEx( 1, 1, 1, 'Hamg' )
call CampaignAttackerEx( 1, 2, 3, 'hkni' )
call CampaignAttackerEx( 0, 1, 2, 'hrif' )
call CampaignAttackerEx( 0, 1, 2, 'hsor' )
call SuicideOnPlayerEx( M5, M4, M3, MyVictim )
//*** WAVE 8 *** Between 3 or 5 minutes after Wave 7
call InitAssaultGroup()
call CampaignAttackerEx( 2, 2, 2, 'hfoo' )
call CampaignAttackerEx( 1, 1, 1, 'Hpak')
call CampaignAttackerEx( 1, 1, 1, 'Hamg' )
call CampaignAttackerEx( 1, 2, 3, 'hmpr' )
call CampaignAttackerEx( 0, 1, 2, 'hsor' )
call SuicideOnPlayerEx( M5, M4, M3, MyVictim )
//*** WAVE 9 *** Between 4 or 6 minutes after Wave 8
call InitAssaultGroup()
call CampaignAttackerEx( 2, 2, 2, 'hrif' )
call CampaignAttackerEx( 1, 1, 1, 'Hpal' )
call CampaignAttackerEx( 1, 1, 1, 'Hamg' )
call CampaignAttackerEx( 1, 2, 3, 'hfoo' )
call CampaignAttackerEx( 0, 1, 2, 'hsor' )
call CampaignAttackerEx( 0, 1, 2, 'hmpr' )
call CampaignAttackerEx( 1, 1, 2, 'hspt' )
call CampaignAttackerEx( 0, 1, 2, 'hgry' )
call SuicideOnPlayerEx( M6, M5, M4, MyVictim )
endloop
// **********************************
// * Attack Strategy never ends *
// **********************************
endfunction
It works!!
Thanks a lot man!
But hey, how would you upgrade towers, would it just be: call SetBuildUnit( 1, 'hgtw''' ) ?
Hey man, its me again, I was wondering if there is any special codes I would have to put for a costume race.
In the object Editor Press CTRL+D and check the rawcodes of the units/buildings/abilities. Those can be used in your custom race and it will work for you.Hey man, its me again, I was wondering if there is any special codes I would have to put for a costume race.
In the object Editor Press CTRL+D and check the rawcodes of the units/buildings/abilities. Those can be used in your custom race and it will work for you.
Starquizer... you won me in the answer
What does it mean when the custom AI gathering 10 gold instead of the slow harvest 1 gold? Even if I have this: call SetSlowChopping( true )
call CampaignAI('otrb',null)
call SetReplacements(1,1,3)
call CampaignDefenderEx( 3,3,5, 'nsko' )
call CampaignDefenderEx( 1,2,2, 'nsog' )
call CampaignDefenderEx( 0,0,1, 'nsoc' )
call CampaignDefenderEx( 0,0,1, 'nsm' ) // Here I'm pretty sure there's one mistake
function ConfigureAI takes nothing returns nothing
function main takes nothing returns nothing
call WaitForSignal()
is there a place in the site where we can download pre-made AI? i've been looking for a while but it seems like no..
This tutorial helped me a lot. However I managed to learn basic AI script thanks to Demo Custom Campaign made by Blizzard Entertainment. They provided basic script there which is used for Humans in first chapter. However yes, JASS AI making surely is the best. I'm still trying to get it under hand, so far so good.
If you also need to know the description of most of the AI natives go here (the AI manual) as well.
With those 2 tutorial you could master your AI scripting skills.
and demo campaign made by Blizzard.
Which demo campaign?