[Trigger] Detect last casted spell for a unit

Status
Not open for further replies.
Level 5
Joined
Feb 18, 2016
Messages
96
Hello
Is it possible to save as a variable or detect the last ability casted by a unit to trigger it as an issue order?


  • Event
    • Unit begins channeling an ability
  • Condition
    • (Targer unit ability being cast) Equal to <Unit>
  • Action
    • Order <casting unit> to use <spell> on <random unit in group>
Because i am trying to make the caster unable to use abilities on a certain unit and cast it on another random unit
 
Level 7
Joined
Mar 10, 2013
Messages
366
Well, you need to detect if the ability beign cast is the one you want to control, just verify if the targetting unit is the unit that shouldn't be targeted.


  • Example Trigger
    • Events
      • Unit - A unit Begins casting an ability
    • Conditions
      • (Ability being cast) Equal to Frost Nova
      • (Unit-type of (Target unit of ability being cast)) Equal to Footman
    • Actions
      • Unit - Order (Triggering unit) to Stop
      • Unit - Order (Triggering unit) to Undead Lich - Frost Nova (Random unit from (Units in (Playable map area)))
 
Last edited:
Level 7
Joined
Mar 10, 2013
Messages
366
But can i detect the ability or i need to specify it?
If you want to recast it on another unit, if must be specific, there's no such thing as a generic ability. We can do something more generic all well but It wouldn't be much GUI friendly and it would take up a bit of JASS to make this work.
 
Level 8
Joined
Jun 13, 2010
Messages
344
Just a thought here.

Would it be possible to make a spell variable:

Event:
A unit begins casting an ability
Action:
Set casting unit to variable
Set ability to variable
Make variable unit stop casting
Unit group pick random unit within range
Condition checks
Make variable unit cast on random unit

Dunno.
 
Level 7
Joined
Mar 10, 2013
Messages
366
Just a thought here.

Would it be possible to make a spell variable:

Event:
A unit begins casting an ability
Action:
Set casting unit to variable
Set ability to variable
Make variable unit stop casting
Unit group pick random unit within range
Condition checks
Make variable unit cast on random unit

Dunno.
It's not that simple. Basically you will have to get the id of the ability beign cast, and recast it again using the IssueOrderUnit function.

JASS:
local group AllUnitsInPlayableMapArea

// Creating group with all units
set AllUnitsInPlayableMapArea = CreateGroup()
GroupEnumUnitsInRect(AllUnitsInPlayableMapArea, bj_mapInitialPlayableArea, null)

set udg_TargetUnit = GroupPickRandomUnit(AllUnitsInPlayableMapArea) // Bj function, could be changed
set udg_AbilitBeignCastId =  GetSpellAbilityId() // ( Ability Beign Cast Id )

call IssueTargetOrder(GetTriggerUnit(), udg_AbilityBeignCastId, udg_TargetUnit) // Re Issue triggering unit to recast it on a another target

call DestroyGroup(AllUnitsInPlayableMapArea) // clear group so it won't leak
 
Last edited:
Status
Not open for further replies.
Top