| 12-28-2004, 09:42 PM | #1 |
I'm having a problem designing the AI for my "Call to Arms" map. I know that I need to use trigger based AI for the more advanced sections; such as race selection, trigger based upgrading, etc--but I'm not sure how to tackle low-level tasks such as casting of abilities, learning hero spells, etc.
What would the best way to approach this? Thanks in advance! |
| 12-29-2004, 03:13 PM | #2 |
I wrote once an article about the pros and cons of triggering and AI scripting. See it here: http://www.hut.fi/~tgustafs/wc3ai.html |
| 12-29-2004, 03:26 PM | #3 |
I guess I'll use triggers for attack and defence, but I don't know what to do for heros. I have 12 custom heros with 5 abilities each (1 passive). I'm not sure how I could (realistically) impliment the shere amount of abilities with triggers, let alone casting them. The majority of the abilities are used similarly to how they were origionally made (ie, attack spells used for healing by negative values)--can I use the default AI for just heros? |
| 12-29-2004, 06:59 PM | #4 |
That's a small problem. AI uses abilities always similarly as the base ability. I can imagine it casting a healing carrion swarm against enemies... But maybe if you are lucky, the original unit ability AI only checks valid targets for the ability, and then uses it when the ability's conditions are met. This way you could have a functional healing spell that is based on an attack spell. |
| 12-30-2004, 04:37 AM | #5 |
I think you misunderstood what I said. Almost all of the abilities I created atleast vaugely resemble their normal uses (aka, there are not damage abilities that heal). What I was asking (since I'm pretty much a n00b at this type of AI) would be to enable the AI for heros. I'm not sure if "Initializing Melee AI" will accomplish this or not. It's the first map I decided to create AI for single player in, so Im rather new at this. |
| 12-30-2004, 01:20 PM | #6 |
Well, generally units should use their abilities, even though you don't initiate any AI for them. However, there are many conditions in which they use them. For example, Storm Bolt is cast only against level 5 (or food 5) and greater targets. Initiating the AI shouldn't do anything. As far as I know, the AI (or more specifically attack and defense captains) only coordinates units' movement around the map. However, it may help if you need to move the units and make them use abilities at the same time (sometimes units don't use their abilities while attack-moving). The AI is, however, very limited and geared towards melee games. Non-melee type AIs run many times into limitations (e.g. only 1 attack group, etc.) |
| 12-30-2004, 11:27 PM | #7 |
I did notice that units were using abilities, but custom heros don't seem to want to. For example, swordsmen defend against piercing, and grunts cast a modified roar going into comments; but heros dont seem to do anything. Once again, I'm sorry I don't know much about AI--I never even thought about implimenting it in a multiplayer map before to this scale. |
| 12-31-2004, 10:15 AM | #8 |
Hmm... I have used one custom enemy hero in a game and he did seem to work fine without any additional stuff: Faceless One Mindflayer in City of the Seven Mithril Golems and Temple of the Old Gods (adventures found in the link in the signature). We did, however, encounter a peculiar problem once (when we were making Temple). All custom units ceased to use any of their abilities, when they were set to other than a Neutral Hostile player. It happened pretty randomly, and we ended up in thinking that something crashed the unit AI. It usually happened after Pause All Units action. We changed all enemy units to Neutral Hostile, and it fixed the bug. Nothing similar happened when we made City of the Seven Mithril Golems, where enemy units are owned by computer players in regular player slots. |
| 01-01-2005, 04:53 AM | #9 |
Im tempted to reveal the entire map as a test to see if heros are using abilities, just not very often. I found it odd that units were preforming so well (such as defending when being attacked by piercing, but not normal attacks without configuration--yet heros did nothing. Maybe there wasnt a problem at all. |
| 01-01-2005, 12:41 PM | #10 |
Did you actually have the heroes learn the abilities (spend the skill points) ? They do not do that automatically. |
| 01-06-2005, 06:05 AM | #11 | |
Guest | Quote:
I met the same problem when I tried to make Elil's Micro Tournament computer players harder to beat. I could not find a function to do it for me, so I had to write one myself. Now, when they actually spend their skill points, I can only beat them half of the time or so. Atleast when I need to spend many skill points on my own heroes.. Anyway, here is the function. Copy/modify/share/abuse as much as you want. This is the first modification I have done on a map, so comments are of course welcome. Code:
function GiveHeroSkills takes unit whichHero returns nothing
local integer array skillsPriority
local integer x
// Neutral heroes
// Sea witch
if (GetUnitTypeId(whichHero) == 'Nngs') then
set skillsPriority[0] = 'ANfa'
set skillsPriority[1] = 'ANms'
set skillsPriority[2] = 'ANfa'
set skillsPriority[3] = 'ANms'
set skillsPriority[4] = 'ANfa'
set skillsPriority[5] = 'ANto'
set skillsPriority[6] = 'ANms'
set skillsPriority[7] = 'ANfl'
set skillsPriority[8] = 'ANfl'
set skillsPriority[9] = 'ANfl'
endif
// Beastmaster
if (GetUnitTypeId(whichHero) == 'Nbst') then
set skillsPriority[0] = 'ANsg'
set skillsPriority[1] = 'ANsq'
set skillsPriority[2] = 'ANsg'
set skillsPriority[3] = 'ANsq'
set skillsPriority[4] = 'ANsg'
set skillsPriority[5] = 'ANst'
set skillsPriority[6] = 'ANsq'
set skillsPriority[7] = 'ANsw'
set skillsPriority[8] = 'ANsw'
set skillsPriority[9] = 'ANsw'
endif
// Dark ranger
if (GetUnitTypeId(whichHero) == 'Nbrn') then
set skillsPriority[0] = 'ANdr'
set skillsPriority[1] = 'ANba'
set skillsPriority[2] = 'ANdr'
set skillsPriority[3] = 'ANba'
set skillsPriority[4] = 'ANdr'
set skillsPriority[5] = 'ANch'
set skillsPriority[6] = 'ANba'
set skillsPriority[7] = 'ANsi'
set skillsPriority[8] = 'ANsi'
set skillsPriority[9] = 'ANsi'
endif
// Pit lord
if (GetUnitTypeId(whichHero) == 'Nplh') then
set skillsPriority[0] = 'ANrf'
set skillsPriority[1] = 'ANca'
set skillsPriority[2] = 'ANrf'
set skillsPriority[3] = 'ANca'
set skillsPriority[4] = 'ANrf'
set skillsPriority[5] = 'ANdo'
set skillsPriority[6] = 'ANca'
set skillsPriority[7] = 'ANht'
set skillsPriority[8] = 'ANht'
set skillsPriority[9] = 'ANht'
endif
// Panda
if (GetUnitTypeId(whichHero) == 'Npbm') then
set skillsPriority[0] = 'ANdh'
set skillsPriority[1] = 'ANbf'
set skillsPriority[2] = 'ANdh'
set skillsPriority[3] = 'ANbf'
set skillsPriority[4] = 'ANdh'
set skillsPriority[5] = 'ANef'
set skillsPriority[6] = 'ANbf'
set skillsPriority[7] = 'ANdb'
set skillsPriority[8] = 'ANdb'
set skillsPriority[9] = 'ANdb'
endif
// Tinker
if (GetUnitTypeId(whichHero) == 'Ntin') then
set skillsPriority[0] = 'ANcs'
set skillsPriority[1] = 'ANsy'
set skillsPriority[2] = 'ANcs'
set skillsPriority[3] = 'ANsy'
set skillsPriority[4] = 'ANcs'
set skillsPriority[5] = 'ANrg'
set skillsPriority[6] = 'ANsy'
set skillsPriority[7] = 'ANeg'
set skillsPriority[8] = 'ANeg'
set skillsPriority[9] = 'ANeg'
endif
// Firelord
if (GetUnitTypeId(whichHero) == 'Nfir') then
set skillsPriority[0] = 'ANlm'
set skillsPriority[1] = 'ANso'
set skillsPriority[2] = 'ANlm'
set skillsPriority[3] = 'ANso'
set skillsPriority[4] = 'ANlm'
set skillsPriority[5] = 'ANvc'
set skillsPriority[6] = 'ANso'
set skillsPriority[7] = 'ANic'
set skillsPriority[8] = 'ANic'
set skillsPriority[9] = 'ANic'
endif
// Alchemist
if (GetUnitTypeId(whichHero) == 'Nalc') then
set skillsPriority[0] = 'ANhs'
set skillsPriority[1] = 'ANcr'
set skillsPriority[2] = 'ANhs'
set skillsPriority[3] = 'ANcr'
set skillsPriority[4] = 'ANhs'
set skillsPriority[5] = 'ANtm'
set skillsPriority[6] = 'ANcr'
set skillsPriority[7] = 'ANab'
set skillsPriority[8] = 'ANab'
set skillsPriority[9] = 'ANab'
endif
// Elven heroes
// Demon hunter
if (GetUnitTypeId(whichHero) == 'Edem') then
set skillsPriority[0] = 'AEim'
set skillsPriority[1] = 'AEev'
set skillsPriority[2] = 'AEev'
set skillsPriority[3] = 'AEmb'
set skillsPriority[4] = 'AEmb'
set skillsPriority[5] = 'AEme'
set skillsPriority[6] = 'AEmb'
set skillsPriority[7] = 'AEev'
set skillsPriority[8] = 'AEim'
set skillsPriority[9] = 'AEim'
endif
// He's jammin'. He's mixin'. He's the Keeper of the Groove. Funky!
if (GetUnitTypeId(whichHero) == 'Ekee') then
set skillsPriority[0] = 'AEfn'
set skillsPriority[1] = 'AEer'
set skillsPriority[2] = 'AEfn'
set skillsPriority[3] = 'AEah'
set skillsPriority[4] = 'AEah'
set skillsPriority[5] = 'AEtq'
set skillsPriority[6] = 'AEah'
set skillsPriority[7] = 'AEer'
set skillsPriority[8] = 'AEfn'
set skillsPriority[9] = 'AEer'
endif
// POTM
if (GetUnitTypeId(whichHero) == 'Emoo') then
set skillsPriority[0] = 'AHfa'
set skillsPriority[1] = 'AEar'
set skillsPriority[2] = 'AHfa'
set skillsPriority[3] = 'AEar'
set skillsPriority[4] = 'AHfa'
set skillsPriority[5] = 'AEsf'
set skillsPriority[6] = 'AEar'
set skillsPriority[7] = 'AEst'
set skillsPriority[8] = 'AEst'
set skillsPriority[9] = 'AEst'
endif
// Warden
if (GetUnitTypeId(whichHero) == 'Ewar') then
set skillsPriority[0] = 'AEfk'
set skillsPriority[1] = 'AEsh'
set skillsPriority[2] = 'AEfk'
set skillsPriority[3] = 'AEbl'
set skillsPriority[4] = 'AEfk'
set skillsPriority[5] = 'AEsv'
set skillsPriority[6] = 'AEsh'
set skillsPriority[7] = 'AEbl'
set skillsPriority[8] = 'AEsh'
set skillsPriority[9] = 'AEbl'
endif
// Human heroes
// Archmage
if (GetUnitTypeId(whichHero) == 'Hamg') then
set skillsPriority[0] = 'AHwe'
set skillsPriority[1] = 'AHbz'
set skillsPriority[2] = 'AHwe'
set skillsPriority[3] = 'AHbz'
set skillsPriority[4] = 'AHwe'
set skillsPriority[5] = 'AHmt'
set skillsPriority[6] = 'AHbz'
set skillsPriority[7] = 'AHab'
set skillsPriority[8] = 'AHab'
set skillsPriority[9] = 'AHab'
endif
// Mountain K
if (GetUnitTypeId(whichHero) == 'Hmkg') then
set skillsPriority[0] = 'AHtb'
set skillsPriority[1] = 'AHtc'
set skillsPriority[2] = 'AHtb'
set skillsPriority[3] = 'AHtc'
set skillsPriority[4] = 'AHtb'
set skillsPriority[5] = 'AHav'
set skillsPriority[6] = 'AHtc'
set skillsPriority[7] = 'AHbh'
set skillsPriority[8] = 'AHbh'
set skillsPriority[9] = 'AHbh'
endif
// Pal
if (GetUnitTypeId(whichHero) == 'Hpal') then
set skillsPriority[0] = 'AHhb'
set skillsPriority[1] = 'AHds'
set skillsPriority[2] = 'AHhb'
set skillsPriority[3] = 'AHds'
set skillsPriority[4] = 'AHhb'
set skillsPriority[5] = 'AHre'
set skillsPriority[6] = 'AHds'
set skillsPriority[7] = 'AHad'
set skillsPriority[8] = 'AHad'
set skillsPriority[9] = 'AHad'
endif
// Blood mage
if (GetUnitTypeId(whichHero) == 'Hblm') then
set skillsPriority[0] = 'AHfs'
set skillsPriority[1] = 'AHdr'
set skillsPriority[2] = 'AHfs'
set skillsPriority[3] = 'AHdr'
set skillsPriority[4] = 'AHfs'
set skillsPriority[5] = 'AHpx'
set skillsPriority[6] = 'AHdr'
set skillsPriority[7] = 'AHbn'
set skillsPriority[8] = 'AHbn'
set skillsPriority[9] = 'AHbn'
endif
// Orc
// Blademaster
if (GetUnitTypeId(whichHero) == 'Obla') then
set skillsPriority[0] = 'AOmi'
set skillsPriority[1] = 'AOcr'
set skillsPriority[2] = 'AOmi'
set skillsPriority[3] = 'AOcr'
set skillsPriority[4] = 'AOmi'
set skillsPriority[5] = 'AOww'
set skillsPriority[6] = 'AOcr'
set skillsPriority[7] = 'AOwk'
set skillsPriority[8] = 'AOwk'
set skillsPriority[9] = 'AOwk'
endif
// Far seer
if (GetUnitTypeId(whichHero) == 'Ofar') then
set skillsPriority[0] = 'AOsf'
set skillsPriority[1] = 'AOcl'
set skillsPriority[2] = 'AOsf'
set skillsPriority[3] = 'AOcl'
set skillsPriority[4] = 'AOcl'
set skillsPriority[5] = 'AOeq'
set skillsPriority[6] = 'AOsf'
set skillsPriority[7] = 'AOfs'
set skillsPriority[8] = 'AOfs'
set skillsPriority[9] = 'AOfs'
endif
// Tauren chief
if (GetUnitTypeId(whichHero) == 'Otch') then
set skillsPriority[0] = 'AOws'
set skillsPriority[1] = 'AOae'
set skillsPriority[2] = 'AOws'
set skillsPriority[3] = 'AOae'
set skillsPriority[4] = 'AOws'
set skillsPriority[5] = 'AOre'
set skillsPriority[6] = 'AOae'
set skillsPriority[7] = 'AOsh'
set skillsPriority[8] = 'AOsh'
set skillsPriority[9] = 'AOsh'
endif
// Shadow hunter
if (GetUnitTypeId(whichHero) == 'Oshd') then
set skillsPriority[0] = 'AOsw'
set skillsPriority[1] = 'AOhw'
set skillsPriority[2] = 'AOsw'
set skillsPriority[3] = 'AOhw'
set skillsPriority[4] = 'AOsw'
set skillsPriority[5] = 'AOvd'
set skillsPriority[6] = 'AOhw'
set skillsPriority[7] = 'AOhx'
set skillsPriority[8] = 'AOhx'
set skillsPriority[9] = 'AOhx'
endif
// Undead
// Death knight
if (GetUnitTypeId(whichHero) == 'Udea') then
set skillsPriority[0] = 'AUdc'
set skillsPriority[1] = 'AUau'
set skillsPriority[2] = 'AUdc'
set skillsPriority[3] = 'AUau'
set skillsPriority[4] = 'AUdc'
set skillsPriority[5] = 'AUan'
set skillsPriority[6] = 'AUau'
set skillsPriority[7] = 'AUdp'
set skillsPriority[8] = 'AUdp'
set skillsPriority[9] = 'AUdp'
endif
// Lich
if (GetUnitTypeId(whichHero) == 'Ulic') then
set skillsPriority[0] = 'AUsl'
set skillsPriority[1] = 'AUcs'
set skillsPriority[2] = 'AUcs'
set skillsPriority[3] = 'AUsl'
set skillsPriority[4] = 'AUcs'
set skillsPriority[5] = 'AUin'
set skillsPriority[6] = 'AUsl'
set skillsPriority[7] = 'AUav'
set skillsPriority[8] = 'AUav'
set skillsPriority[9] = 'AUav'
endif
// Dreadlord
if (GetUnitTypeId(whichHero) == 'Udre') then
set skillsPriority[0] = 'AUfn'
set skillsPriority[1] = 'AUfu'
set skillsPriority[2] = 'AUfn'
set skillsPriority[3] = 'AUfu'
set skillsPriority[4] = 'AUfn'
set skillsPriority[5] = 'AUdd'
set skillsPriority[6] = 'AUfu'
set skillsPriority[7] = 'AUdr'
set skillsPriority[8] = 'AUdr'
set skillsPriority[9] = 'AUdr'
endif
// Crypt lord
if (GetUnitTypeId(whichHero) == 'Ucrl') then
set skillsPriority[0] = 'AUcb'
set skillsPriority[1] = 'AUim'
set skillsPriority[2] = 'AUcb'
set skillsPriority[3] = 'AUim'
set skillsPriority[4] = 'AUcb'
set skillsPriority[5] = 'AUls'
set skillsPriority[6] = 'AUim'
set skillsPriority[7] = 'AUts'
set skillsPriority[8] = 'AUts'
set skillsPriority[9] = 'AUts'
endif
set x = 0
loop
exitwhen GetHeroSkillPoints(whichHero) == 0
call SelectHeroSkill( whichHero, skillsPriority[x] )
set x = x + 1
endloop
endfunctionEdit: (Where did all the blank space above come from?) |
