Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
Ok so i have a little problem with the AI. I managed to make them level up custom abilities(based on existing ones) using this:
(picture is down it failed to use the link)
It works just fine and they do use the abilities but i would like to change the order in which they level them because as it is they seem to be a little dumb and get them in wrong order(which also seems to stay the same no matter how many restarts you do on the game). Ideas would be appreciated.
The loop is useless there, doesn't do anything, like "Do nothing" too. I would make conditions like if level of the hero is 2 then make it learn a certainly, if level of the hero is 3 then blabla, if 4 blabla and so on...
If you want it more random then make a integer variable "chance" and set it to (random number between 1 and 2) so you have 50% chance to learn other than the same ability, you would have to create more conditions: if chance is 1 then learn ability A, else learn ability B.
The loop is useless there, doesn't do anything, like "Do nothing" too. I would make conditions like if level of the hero is 2 then make it learn a certainly, if level of the hero is 3 then blabla, if 4 blabla and so on...
If you want it more random then make a integer variable "chance" and set it to (random number between 1 and 2) so you have 50% chance to learn other than the same ability, you would have to create more conditions: if chance is 1 then learn ability A, else learn ability B.
Thats why i am asking. I am bit new to this and after a long day of switching and rewriting the "code" i couldnt figure how to exactly do the condition "if hero level is equal to 2 then do this" . I would appreciate an example or tip on how to exactly do that. Thanks in advance.
Looks like you want some sort of preset list of abilities that the AI should learn. In that case, use an ability array (variable). Define the ability order when your map finishes loading:
AI Learn Ability Order
Events
Time - Elapsed game time is 0.00 seconds
Conditions
Actions
Set AI_Ability_Paladin[1] = Holy Light
Set AI_Ability_Paladin[2] = Divine Shield
Set AI_Ability_Paladin[3] = Holy Light
Set AI_Ability_Paladin[4] = Devotion Aura
Set AI_Ability_Paladin[5] = Holy Light
Set AI_Ability_Paladin[6] = Resurrection
-------- etc --------
Then, when the hero gains a level, you check if that hero is the one you want to level up the abilities, and also check if it's a computer occupying that player slot.
Learn
Events
Unit - A unit Gains a level
Conditions
((Triggering player) controller) Equal to Computer
Actions
Set tmp_unit = (Triggering unit)
Set tmp_int = (Hero level of tmp_unit)
-------- Paladin --------
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(Unit-type of tmp_unit) Equal to Paladin
Then - Actions
-------- Wonderful... the GUI "Hero - Learn" function doesn't accept variables. --------
-------- Do note that when using a GUI variable in a custom script, you need the "udg_" prefix before referencing it --------
Else - Actions
That works nicely for a specific hero. Also, don't forget to make it learn its first ability when the hero spawns, because the trigger above works only for level 2+.
However, this is not the best way of making it, because, as you can see, all heroes must be specified in that "Learn" trigger. You can make it easier for you by using a hash table. With it, there's no need to use a stupid amount of if/then/else, because you'll be able to store your unit type (hero), and use the other index to represent the hero level. That certainly will make your list of spells scalable and easy to maintain.
Looks like you want some sort of preset list of abilities that the AI should learn. In that case, use an ability array (variable). Define the ability order when your map finishes loading:
AI Learn Ability Order
Events
Time - Elapsed game time is 0.00 seconds
Conditions
Actions
Set AI_Ability_Paladin[1] = Holy Light
Set AI_Ability_Paladin[2] = Divine Shield
Set AI_Ability_Paladin[3] = Holy Light
Set AI_Ability_Paladin[4] = Devotion Aura
Set AI_Ability_Paladin[5] = Holy Light
Set AI_Ability_Paladin[6] = Resurrection
-------- etc --------
Then, when the hero gains a level, you check if that hero is the one you want to level up the abilities, and also check if it's a computer occupying that player slot.
Learn
Events
Unit - A unit Gains a level
Conditions
((Triggering player) controller) Equal to Computer
Actions
Set tmp_unit = (Triggering unit)
Set tmp_int = (Hero level of tmp_unit)
-------- Paladin --------
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(Unit-type of tmp_unit) Equal to Paladin
Then - Actions
-------- Wonderful... the GUI "Hero - Learn" function doesn't accept variables. --------
-------- Do note that when using a GUI variable in a custom script, you need the "udg_" prefix before referencing it --------
Else - Actions
That works nicely for a specific hero. Also, don't forget to make it learn its first ability when the hero spawns, because the trigger above works only for level 2+.
However, this is not the best way of making it, because, as you can see, all heroes must be specified in that "Learn" trigger. You can make it easier for you by using a hash table. With it, there's no need to use a stupid amount of if/then/else, because you'll be able to store your unit type (hero), and use the other index to represent the hero level. That certainly will make your list of spells scalable and easy to maintain.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.