• 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!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

[JASS] how do i force a unit to cast a spell?

Status
Not open for further replies.
Level 3
Joined
Sep 14, 2007
Messages
43
hello, i am new here and also new to jass and i want to know how do i force a unit to cast a spell i made.

and does the unit has to have the spell on her ability list to use it or can i force the unit to use any spell i want?

for example i want my unit to summon another unit and its all a part of a bigger spell than just summoning a unit, how do i force the unit to summon?

thanks for your help :)

edit: i added another question scroll down and see it, thanks for any kind of help :D
 
Last edited:
Level 5
Joined
Jan 15, 2007
Messages
199
call UnitAddAbility(*Caster*,*Rawcode*)
call IssueImmediateOrder(*Caster*,*OrderString*)
call TriggerSleepAction(0)
call UnitRemoveAbility(*Caster*,*Rawcode*)

i dunno if u have to use the wait though
 
Level 3
Joined
Sep 14, 2007
Messages
43
thanks.
I got some problem with my code.
the trigger suppose to create a unit 1 after the other and make it move to a random location, when the unit is there it disappears (i will make it explode later on).
After the unit disappears another is created and so on.
right now only one unit is created and doesnt dissappear what i think is that the small loop never closes, but i dont know why.
so can you tell me why?
this is the action func:

Code:
function Trig_Monsters_Of_The_Void_Actions takes nothing returns nothing
local timer Monster_Max_Time = CreateTimer()
local timer Spell_Time = CreateTimer()
local unit u = GetTriggerUnit() 
local integer Ability_Level = GetUnitAbilityLevel(u, Ability_ID()) 
local unit Void_Monster = null
local unit Target_Unit = Random_Enemy(Ability_Level)
local real Explode = 1.0
call StartTimerBJ( Spell_Time, false, I2R(Time_Of_Ability(Ability_Level)))
call StartTimerBJ( Monster_Max_Time, false, 6.0)
loop
if (Target_Unit!= null) then
set Void_Monster = Create_Monster()
call SetUnitPathing( Void_Monster, false )
call IssueTargetOrderBJ( Void_Monster, "move", Target_Unit )
loop
if (TimerGetRemaining(Monster_Max_Time) == 0.0) then
set Explode = 0.0
elseif ((Get_Distance(GetUnitX(Void_Monster),GetUnitY(Void_Monster),GetUnitX(Target_Unit),GetUnitY(Target_Unit)))<=100.0) then
set Explode = 0.0
endif
exitwhen (Explode==0.0)
endloop
endif
call RemoveUnit(Void_Monster)
set Explode = 1.0
call StartTimerBJ( Monster_Max_Time, false, 6.0)
set Target_Unit = Random_Enemy(Ability_Level)
if(Target_Unit!=null) then
set Void_Monster = Create_Monster()
endif
exitwhen (TimerGetRemaining(Spell_Time) == 1.0)
endloop
endfunction
 
Level 3
Joined
Sep 14, 2007
Messages
43
thanks, i understand what you mean but i dont think thats the reason why only one monster is summoned.

if the enemy is too close to the caster it will summon monsters nonstop and will make the game crash but there are times where the enemy is far away from the caster and still only 1 monster is summoned :(
notice that the small loop ends only when the monster is in a certain range from the enemy unit.
 
Status
Not open for further replies.
Top