• 🏆 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!

How to make computer do these things?

Status
Not open for further replies.
Level 3
Joined
Jun 4, 2015
Messages
21
How to make computer-controlled heroes learn neutral hero spells and would they cast them after learning them when appropriate situations are given? How to make Orc AI also use spirit walkers and upgrade headhunters to berserkers?
 
Level 12
Joined
Jun 15, 2016
Messages
472
For your second question, that requires changing the orc melee AI script to include spirit walkers and berserkers.

For your first question, the answer is a bit more complicated, there is a function in AI scripts that allows you to choose which abilities he will learn and in which level. However, that doesn't guarantee the hero will use those, since ability use is decided in a different set of "AI rules", ones which you can't access. With that said, you can predict how AI heroes will use certain abilities according to the vanilla ability they're based on.
You can consult this tutorial to see which abilities the AI player uses and when.
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,202
You will probably need to script the AI for your heroes.

Break it apart into a tactical component and a strategic component. The tactical component is responsible for casting abilities and other "micro" operations. The strategic part is responsible for deciding where/when to move units, what items to get and other "macro" operations.

Both can be implemented in the form of periodic triggers. Tactical polls area around the hero for possible ability targets. Strategic polls state of finances, item, enemy toughness approximations etc and decides where to move based on them.
 
Level 3
Joined
Jun 4, 2015
Messages
21
Thank you guys for the responses. I also have another question that I should've first included in my first post. How to create or edit an armor type including changing its icon?
 
Level 3
Joined
Jun 4, 2015
Messages
21
You will probably need to script the AI for your heroes.

Break it apart into a tactical component and a strategic component. The tactical component is responsible for casting abilities and other "micro" operations. The strategic part is responsible for deciding where/when to move units, what items to get and other "macro" operations.

Both can be implemented in the form of periodic triggers. Tactical polls area around the hero for possible ability targets. Strategic polls state of finances, item, enemy toughness approximations etc and decides where to move based on them.
Can I only know how to make them consecutively learn the abilities I gave them?
 
Level 12
Joined
Jun 15, 2016
Messages
472
You can do this quite simply by defining a hero's skill set in the AI script. You can even give multiple leveling option for each hero. This is the human melee leveling for example:

JASS:
function set_skills takes nothing returns nothing

   //------------------------------------------------------------------------

   if hero_id == PALADIN then

   //------------------------------------------------------------------------

       set skills1[ 1] = HOLY_BOLT

       set skills1[ 2] = DEVOTION_AURA

       set skills1[ 3] = HOLY_BOLT

       set skills1[ 4] = DIVINE_SHIELD

       set skills1[ 5] = HOLY_BOLT

       set skills1[ 6] = RESURRECTION

       set skills1[ 7] = DEVOTION_AURA

       set skills1[ 8] = DEVOTION_AURA

       set skills1[ 9] = DIVINE_SHIELD

       set skills1[10] = DIVINE_SHIELD

   endif

   //------------------------------------------------------------------------

   if hero_id2 == PALADIN then

   //------------------------------------------------------------------------

       set skills2[ 1] = HOLY_BOLT

       set skills2[ 2] = DIVINE_SHIELD

       set skills2[ 3] = HOLY_BOLT

       set skills2[ 4] = DEVOTION_AURA

       set skills2[ 5] = HOLY_BOLT

       set skills2[ 6] = RESURRECTION

       set skills2[ 7] = DEVOTION_AURA

       set skills2[ 8] = DEVOTION_AURA

       set skills2[ 9] = DIVINE_SHIELD

       set skills2[10] = DIVINE_SHIELD

   endif


   //------------------------------------------------------------------------

   if hero_id == MTN_KING then

   //------------------------------------------------------------------------

       set skills1[ 1] = THUNDER_BOLT

       set skills1[ 2] = BASH

       set skills1[ 3] = THUNDER_BOLT

       set skills1[ 4] = THUNDER_CLAP

       set skills1[ 5] = THUNDER_BOLT

       set skills1[ 6] = AVATAR

       set skills1[ 7] = BASH

       set skills1[ 8] = BASH

       set skills1[ 9] = THUNDER_CLAP

       set skills1[10] = THUNDER_CLAP

   endif

   //------------------------------------------------------------------------

   if hero_id2 == MTN_KING then

   //------------------------------------------------------------------------

       set skills2[ 1] = THUNDER_BOLT

       set skills2[ 2] = BASH

       set skills2[ 3] = THUNDER_BOLT

       set skills2[ 4] = THUNDER_CLAP

       set skills2[ 5] = THUNDER_BOLT

       set skills2[ 6] = AVATAR

       set skills2[ 7] = BASH

       set skills2[ 8] = BASH

       set skills2[ 9] = THUNDER_BOLT

       set skills2[10] = THUNDER_BOLT

   endif


   //------------------------------------------------------------------------

   if hero_id == ARCHMAGE then

   //------------------------------------------------------------------------

       set skills1[ 1] = WATER_ELEMENTAL

       set skills1[ 2] = BRILLIANCE_AURA

       set skills1[ 3] = WATER_ELEMENTAL

       set skills1[ 4] = BLIZZARD

       set skills1[ 5] = WATER_ELEMENTAL

       set skills1[ 6] = MASS_TELEPORT

       set skills1[ 7] = BRILLIANCE_AURA

       set skills1[ 8] = BRILLIANCE_AURA

       set skills1[ 9] = BLIZZARD

       set skills1[10] = BLIZZARD

   endif

   //------------------------------------------------------------------------

   if hero_id2 == ARCHMAGE then

   //------------------------------------------------------------------------

       set skills2[ 1] = WATER_ELEMENTAL

       set skills2[ 2] = BRILLIANCE_AURA

       set skills2[ 3] = WATER_ELEMENTAL

       set skills2[ 4] = BRILLIANCE_AURA

       set skills2[ 5] = WATER_ELEMENTAL

       set skills2[ 6] = MASS_TELEPORT

       set skills2[ 7] = BRILLIANCE_AURA

       set skills2[ 8] = BLIZZARD

       set skills2[ 9] = BLIZZARD

       set skills2[10] = BLIZZARD

   endif

endfunction

Edit:
Also, note that all of the variables you see in ALL_CAPS are static variables in the common.ai file referring to objects from the object editor. For example PALADIN is actually 'hpal' in the object editor. This means you can give any hero any skill according to the AI script, as long as the data in the object editor fits.
 
Last edited:
Status
Not open for further replies.
Top