• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

AI spell order

Status
Not open for further replies.
Level 2
Joined
Apr 9, 2014
Messages
8
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:
KcWEk9j
(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.
 

Attachments

  • Help.png
    Help.png
    16.9 KB · Views: 73

Wrda

Spell Reviewer
Level 25
Joined
Nov 18, 2012
Messages
1,870
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.
 
Level 2
Joined
Apr 9, 2014
Messages
8
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.
 
Level 13
Joined
May 10, 2009
Messages
868
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. --------
          • Custom script: call SelectHeroSkill(udg_tmp_unit, udg_AI_Ability_Paladin[udg_tmp_int])
          • -------- 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.
 
Level 2
Joined
Apr 9, 2014
Messages
8
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. --------
          • Custom script: call SelectHeroSkill(udg_tmp_unit, udg_AI_Ability_Paladin[udg_tmp_int])
          • -------- 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.


Thank you. I tested it and it worked beautifully. I will look into the hash table and see what i can do. In the meantime you saved me :)
 
Status
Not open for further replies.
Top