- Joined
- Sep 12, 2008
- Messages
- 657
hey, i have made a AI for my arena map..
it works perfect, right now it attacks units, moves to heal when needed,
goes into places, etc.
but i wanted to add the code the ability to make heroes learn spells..
i just figured i needed 2d array for that.. ([1, 1] = spell #1 hero #1, [1, 2] = spell #1, hero #2, and so on.)
so i did this instead:
so i tried setting this:
)
ComputerAI_Index[4] = random number between 1 and the herolist count,
so it generates a random hero for each bot.
now i saved it so if i have the player number, i could use it anytime.
and this is my math:
because:
hero #1 * #spell #2 = 1 * 2 = 2, that works.
hero #1 * #anyspellnum works.
hero #2 * #spell #2 = 4. this means it still uses hero #1 spells. which
hero #2 dont posses.
how can i make this work? thx.
it works perfect, right now it attacks units, moves to heal when needed,
goes into places, etc.
but i wanted to add the code the ability to make heroes learn spells..
i just figured i needed 2d array for that.. ([1, 1] = spell #1 hero #1, [1, 2] = spell #1, hero #2, and so on.)
so i did this instead:
-
Actions
-

-------- ------------------------------ --------
-

-------- ------- Edit Here ------ --------
-

-------- ------------------------------ --------
-

Set ComputerAI_HeroList[1] = Paladin
-

Set ComputerAI_HeroList[2] = Blademaster
-

Set ComputerAI_HeroList[3] = Mountain King
-

Set ComputerAI_HeroList[4] = Tauren Chieftain
-

-------- ------------------------------ --------
-

Set ComputerAI_Spells[1] = Divine Shield
-

Set ComputerAI_Spells[2] = Devotion Aura
-

Set ComputerAI_Spells[3] = Holy Light
-

Set ComputerAI_Spells[4] = Resurrection
-

-------- ------------------------------ --------
-

Set ComputerAI_Spells[5] = Wind Walk
-

Set ComputerAI_Spells[6] = Critical Strike
-

Set ComputerAI_Spells[7] = Mirror Image
-

Set ComputerAI_Spells[8] = Bladestorm
-

-------- ------------------------------ --------
-

Set ComputerAI_Spells[9] = Bash
-

Set ComputerAI_Spells[10] = Thunder Clap
-

Set ComputerAI_Spells[11] = Storm Bolt
-

Set ComputerAI_Spells[12] = Avatar
-

-------- ------------------------------ --------
-

Set ComputerAI_Spells[13] = Shockwave
-

Set ComputerAI_Spells[14] = Endurance Aura
-

Set ComputerAI_Spells[15] = War Stomp
-

Set ComputerAI_Spells[16] = Reincarnation
-

-------- ------------------------------ --------
-

Set ComputerAI_SpellsPerHero = 4
-
so i tried setting this:
-
Then - Actions
-

-------- ------------------------------ --------
-

Unit - Create 1 ComputerAI_HeroList[ComputerAI_Index[4]] for (Player(ComputerAI_Index[2])) at ((Player(ComputerAI_Index[2])) start location) facing Default building facing degrees
-

Set ComputerAI_UsedHero[ComputerAI_Index[3]] = (Last created unit)
-

-------- ------------------------------ --------
-

Set ComputerAI_HeroIndex[ComputerAI_Index[3]] = ComputerAI_Index[4]
-

Set Player_HeroIndex[(Player number of (Owner of ComputerAI_UsedHero[ComputerAI_Index[2]]))] = ComputerAI_Index[4]
-
ComputerAI_Index[4] = random number between 1 and the herolist count,
so it generates a random hero for each bot.
now i saved it so if i have the player number, i could use it anytime.
and this is my math:
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-

If - Conditions
-


ComputerAI_HeroState[ComputerAI_Index[5]] Equal to learn spell
-
-

Then - Actions
-


Set ComputerAI_LevelCount = Player_HeroLVLCount[(Player number of (Owner of ComputerAI_CurrentHero))]
-


Set ComputerAI_LearnedSpell = ComputerAI_Spells[(ComputerAI_HeroIndex[ComputerAI_Index[5]] x ComputerAI_LevelCount)]
-


Custom script: call UnitAddAbility(udg_ComputerAI_CurrentHero, udg_ComputerAI_LearnedSpell)
-
-
-
//Yeah yeah, i realise this will work once.. but aslong as it will work, im happy, and add more stuff, like increase level instead of just adding it..
-

Else - Actions
-
because:
hero #1 * #spell #2 = 1 * 2 = 2, that works.
hero #1 * #anyspellnum works.
hero #2 * #spell #2 = 4. this means it still uses hero #1 spells. which
hero #2 dont posses.
how can i make this work? thx.




