Hello everyone,
I am looking for little help.
I did a targeting system, when your hero (you are controlling only one unit all the time) mark his target by simple righ-clicking. This is just example:
Now I want all his spells go for the targeted victim. I made all his spells based on channel spell with "No target" option, and want to check all conditions by myself (distance, unit-type of targeted unit and so on). Now there is my problem. Once I find out he shouldnt be able to cast the spell (target is too far away, he is not facing the target...) I want to show some warning message and stop his cast. I tried this:
He will stop the cast, spell cooldown is ok but his mana is already spent. Any ideas how to interrupt casting before he spend a mana for this spell??
I am looking for little help.
I did a targeting system, when your hero (you are controlling only one unit all the time) mark his target by simple righ-clicking. This is just example:
JASS:
function Targeting_Conditions takes nothing returns boolean
return GetOwningPlayer(GetTriggerUnit()) == Player(0)
endfunction
function Targeting_Actions takes nothing returns nothing
set udg_Target = GetOrderTargetUnit()
endfunction
//===========================================================================
function InitTrig_Targeting takes nothing returns nothing
local trigger Targeting = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( Targeting, EVENT_PLAYER_UNIT_ISSUED_TARGET_ORDER )
call TriggerAddCondition( Targeting, Condition( function Targeting_Conditions ) )
call TriggerAddAction( Targeting, function Targeting_Actions )
set Targeting = null
endfunction
Now I want all his spells go for the targeted victim. I made all his spells based on channel spell with "No target" option, and want to check all conditions by myself (distance, unit-type of targeted unit and so on). Now there is my problem. Once I find out he shouldnt be able to cast the spell (target is too far away, he is not facing the target...) I want to show some warning message and stop his cast. I tried this:
JASS:
function Fireball_Conditions takes nothing returns boolean
return GetSpellAbilityId() == 039;A001039;
endfunction
function Fireball_Actions takes nothing returns nothing
call IssueImmediateOrder(GetTriggerUnit(), "stop")
endfunction
//===========================================================================
function InitTrig_Fireball_Copy takes nothing returns nothing
local trigger Fireball = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( Fireball, EVENT_PLAYER_UNIT_SPELL_CHANNEL )
call TriggerAddCondition( Fireball, Condition( function Fireball_Conditions ) )
call TriggerAddAction( Fireball, function Fireball_Actions )
set Fireball = null
endfunction
He will stop the cast, spell cooldown is ok but his mana is already spent. Any ideas how to interrupt casting before he spend a mana for this spell??