- Joined
- May 11, 2007
- Messages
- 4,650
Hai, just wondered if someone has been able to create custom .ai with custom units? I'm not talking about the AI editor, but rather AI written in Notepad++, like here:
http://blizzardmodding.info/4238/how-to-make-a-campaign-ai/
However, it doesn't seem to want to recognise my custom units, so are the ids wrong, or have I've missed any magical hocus pocus?
In the script, I'm currently just trying to get them to build, they have enough resources.
There is a major bug in the Warcraft AI with the AI Editor, in that when it reaches an enemy unit and kills it, the AI will return to the base and then attack again, I wanted to see if I could create a custom ai that simply proceeds to suicide all of its forces and then rebuilds them.
http://blizzardmodding.info/4238/how-to-make-a-campaign-ai/
However, it doesn't seem to want to recognise my custom units, so are the ids wrong, or have I've missed any magical hocus pocus?
In the script, I'm currently just trying to get them to build, they have enough resources.
JASS:
globals
player MyVictim = Player(5) //orange
constant BUILDING_FOOD_CRYSTAL = n610:npgr
constant BUILDING_towncenter1 = n61Z:ogre
constant BUILDING_towncenter2 = o620:ogre
constant BUILDING_altar_of_light = e608:eate
constant BUILDING_shrineofnaruu = h60I:halt
constant BUILDING_warrior = o61Y:obar
constant BUILDING_warrior_tier2 = o61N:obar
constant BUILDING_siege_tier2 = u60I:ubon
constant BUILDING_cavalry_tier3 = u60H:ubon
//Tier1
constant UNIT_worker = n62O:ndrf
//constant UNIT_scout = 1
//constant UNIT_hunter = 1
//constant UNIT_warrior = 1
//constant UNIT_archer = 2
//constant UNIT_vindicator = 2
//Magic
//constant CASTER_elder = 2
//constant CASTER_healer = 2
//constant CASTER_summoner = 2
//constant CASTER_magi = 2
//Tier2
//constant UNIT_arcanestone = 4
//constant UNIT_peacekeeper = 3
//constant UNIT_immortal = 3
//constant UNIT_kaliri = 2
//Tier3
//constant UNIT_knight = 4
endglobals
function ConfigureAI takes nothing returns nothing
call SetSlowChopping(false) //false
call SetPeonsRepair(true) //AI will repair
call SetSlowChopping(false)
call SetUnitsFlee(false)
call SetHeroesFlee(false)
call SetGroupsFlee(false)
call SetHeroesBuyItems(true)
endfunction
function DifficultyCheck takes nothing returns nothing
call SetTargetHeroes(true)
endfunction
function main takes nothing returns nothing
//call WaitForSignal() //First time run, start harvesting, etc
call CampaignAI (<BUILDING_FOOD_CRYSTAL>, function HeroLevels) //Set food building and hero lvling
call ConfigureAI()
call DifficultyCheck()
//call WaitForSignal //2nd time start attacks
call SetReplacements( 1, 2, 3 )
InitBuildings()
//InitUnits()
//InitAttacks()
endfunction
function InitBuildings takes nothing returns nothing
call SetBuildUnitEx( 1, 1, 1, BUILDING_towncenter1 )
call SetBuildUnit( 6, UNIT_worker )
call SetBuildUnitEx( 2, 2, 2, BUILDING_FOOD_CRYSTAL )
call SetBuildUnitEx( 1, 1, 2, BUILDING_warrior )
call SetBuildUnit( 1, BUILDING_altar_of_light )
call SetBuildUnit( 1, BUILDING_shrineofnaruu )
endfunction
function InitUnits takes nothing returns nothing
endfunction
function InitHeroes takes nothing returns nothing
endfunction
function HeroLevels takes nothing returns integer
local integer hero = GetHeroId()
local integer level = GetHeroLevelAI()
local integer a = 0
if hero == DEMON_HUNTER then
if level == 1 or level == 3 or level == 5 then
set a = IMMOLATION
endif
if level == 2 or level == 4 or level == 7 then
set a = MANA_BURN
endif
if level >= 8 then
set a = EVASION
endif
if level == 6 then
set a = METAMORPHOSIS
endif
endif
return a
endfunction
function InitAttacks takes nothing returns nothing
//Attack waves
call InitAssaultGroup() // <==(1)
call CampaignAttackerEx( 2, 3, 3, ARCHER ) // <==(2)
call CampaignAttackerEx( 0, 1, 2, HUNTRESS )
call CampaignAttackerEx( 0, 1, 1, BALLISTA )
call SuicideOnPlayerEx( M2, M3, M3, MyVictim ) // How long before attacking
endfunction
There is a major bug in the Warcraft AI with the AI Editor, in that when it reaches an enemy unit and kills it, the AI will return to the base and then attack again, I wanted to see if I could create a custom ai that simply proceeds to suicide all of its forces and then rebuilds them.