Casting a spell from a variable

R

Rollo123

Guest
Can someone please tell me the error in this. With this statement my map will not compile anymore. I am noob in jass and am only trying to use it so i can get a AI hero to cast a spell stored as a variable.

call IssueTargetOrderBJ( udg_heroArray[GetForLoopIndexA()], udg_heroSpell[GetForLoopIndexA()], udg_HeroTargetUnit[GetForLoopIndexA()] )

Although all on one line. heroArray is the unit casting the spell, heroSpell is the actual spell (stored in a variable), and heroTargetUnit is the target of the spell.

The two errors i get are invalid argument type, and expected a code statement. Thanks
 

SFilip

Gone but not forgotten
Reaction score
634
you cant do it that way...as a matter of fact you cant do it at all.
you cant give an order to cast something. every spell has a special string order which you must do in order to cast it.
example:
Sleep
raw: AUsl
order: sleep
so if sleep was stored in your variable you would order the unit something like this:
call IssueTargetOrderBJ( udg_heroArray[GetForLoopIndexA()], 'AUsl', udg_HeroTargetUnit[GetForLoopIndexA()] )
this is wrong. should be
call IssueTargetOrderBJ( udg_heroArray[GetForLoopIndexA()], 'sleep', udg_HeroTargetUnit[GetForLoopIndexA()] )
so if you want this to work you would have to make if..then for every spell you have and store the order instead of the raw value.
 
R

Rollo123

Guest
Ok thanks for your reply. So would an if statement ,sorry gui dont really understand jass, would be something like,

If heroSpell(Integer A) = "Ausl" (raw code of spell) then Order heroArray(Integer A) to Cast Sleep On HeroTargetUnit(Integer A) Else Do nothing

If so could you tell me how to find out the raw code of spells please. Thanks for your help.
 

SFilip

Gone but not forgotten
Reaction score
634
actually for gui you dont need raw. just pick the spell you want (if the variable type is ability).
anyway to find the raw value just open object editor and press Ctrl+D.
to find the order (which you also dont need in gui since you have a list) just check Text - Order String - (most likely) Use/Turn On. note that you cant change neither of these.
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top