• 🏆 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 An AI Cast An Custom Spell

Status
Not open for further replies.
It's not hard; you just have to check the order string of your ability. Go to your ability and scroll to Text - Order String - Use/Turn on.
Now, if your ability's target type is "No target" (e.g. Howl of Terror/ Roar/ Battle Roar...), use this:
  • Custom script: call IssueImmediateOrder (yourunit, "orderstring")
If the order string is for example "roar", the script above would look like this
  • Custom script: call IssueImmediateOrder (yourunit, "roar")
For point-target type abilities
  • Custom script: call IssuePointOrderLoc (yourunit, "orderstring", location)
For unit-target type abilities
  • Custom script: call IssueTargetOrder (yourunit, "orderstring", targetunit)
For the script above, you can also use instead of unit (for the target) a destructible too. This is the script to issue a harvest for example too, except for a Frost Nova cast.
 
Level 7
Joined
May 21, 2009
Messages
289
I have a question about this, what do you put for "yourunit" like if I wanted a footman to cast a custom "Summon Treant" spell, because I can't get it to work.

I tried many ways but here are some- Custom Script: call IssueImmediateOrder (Footman, "Summon Treant") and call IssueImmediateOrder (Footman<#placed on map>, "Summon Treant") and call IssueImmediateOrder (Footman, Summon Treant)

could someone explain what I'm doing wrong? thanks
 
Level 10
Joined
May 27, 2009
Messages
494
you could also make an AI cast automatically by adding the Ability through triggers by their ability ID..

i forgot the function T_T...

but its a customized
  • Unit - Add Ability
and when converted to jass, change the strings in the ( ) to your ability's ID.

You could see your ability's ID by pressing Ctrl+D in the object editor..
Please post that function.. I forgot it @.@

usually, melee AIs use the abilities that are available to them. You could leveled up also the ability if you want. You need still to run at initialization a function (optional, but recommended) to make it work perfectly. I can't find that thread at wc3c on how to do it though....

but you could also use what pharoah_ said..
 
Level 22
Joined
Feb 3, 2009
Messages
3,292
No need to do anything, AIs use spells according to their use. So never make a damaging spell out of heal for example, else he will use it only on his units, and if you make it enemy only, then he won't use it at all. But aslong as you make only a custom version of Summon Treant, he will use it with no problems.
But off course don't forget to add the unit type of the custom Summon Treant to the AIs attacking forces, else he won't use the summoned units.

Hope this helps.
 
Level 7
Joined
May 21, 2009
Messages
289
lol wow that didnt help me at all. (no offense)- I was hoping for more like Pharaoh_ did jim7777, with a lot of examples pasted in.

And as far as I know Barathrum my AI never casts anything other than Auto-cast spells in a custom map.
EDIT:
unless your talking about an AI editor import?
 
in fact, barathum only talks about setting AI-guided player slots to be filles with a computer player. even without AI, a computer player on a slot will activate a rudimentary ai (The AI of Neutral Hostile without the follow target only x seconds or y meters) wich will cast spells if it thinks its neccesary (for example, multi-target or aoe spells are casted on groups of enemies, nuke spells like death coil are cast on the foe with the highest health). However, this will only work if the spells still have mainly the same effect as the original spells. So if you base all spells on channel, the ai wont do anything, because channel has no effect.
PS: summon treant is a very 'complicated' spell, it could be that the ai never sees an opportunity to cast it.
PSS: excuse me if i sound rude, but have you checked the mana costs? a footman has no mana, so he may not be able to cast.
 
Level 7
Joined
May 21, 2009
Messages
289
The footman was an example I'm not actually using one. What I'm trying to get at is that I need a trigger that tells the AI to cast a spell from an event, because mine n-e-v-e-r cast anything other than auto-cast spells in my map, not just Summon Treant, (a custom spell by the way which has nothing to with trees, its a "summon" spell) in my experence in mapmaking.

So I would just like someone to answer my question on what I'm doing wrong on my custom script? Or am I missing the point completely?
 
Level 10
Joined
Mar 6, 2010
Messages
691
if you did it just like your examples with the jass i think you would need the raw data, go to object editor and press ctrl-D, this will display as raw data.

so instead of
JASS:
call IssueImmediateOrder (Footman, "Summon Treant")
you would need to use (custom abillities always starts from A000, therefore if it was the first custom abillity you made)
JASS:
call IssueImmediateOrder ('hfoo', 'A000')
 
Status
Not open for further replies.
Top