• 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.

Cancel Blink

Status
Not open for further replies.
Level 17
Joined
Feb 11, 2011
Messages
1,860
Hi guys,

I am having strange issues with cancelling Blink. I want it to be cancelled if the target point is in a specific region. The "system" works, except the unit still loses mana for casting the spell, even though it gets cancelled by being ordered to stop. If I pause it, order it to stop and then unpause it, the unit is magically moved to the centre of the map :/

Any ideas on how to properly cancel a unit from Blinking? By the way, this is the item version of Blink.

Thanks,

Mr_Bean
 
Level 11
Joined
Jul 9, 2009
Messages
927
A unit starts the effect of an ability, if ability being cast = blink, set BlinkMana = Mana of triggering unit.

A unit is issued a target point, if point = boundariesRegion, order triggering unit to stop, set mana of triggering unit to Blink Mana.

Try it. I think it might work. :) They are two separate triggers.
 
Level 33
Joined
Mar 27, 2008
Messages
8,035
This works just great ?
  • Melee Initialization
    • Events
      • Unit - A unit Begins casting an ability
    • Conditions
      • (Ability being cast) Equal to Blink
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Cancel Blink <gen> contains (Target point of ability being cast)) Equal to True
        • Then - Actions
          • Unit - Order (Triggering unit) to Stop
        • Else - Actions
 
Level 17
Joined
Feb 11, 2011
Messages
1,860
Hmmm, I probably should trigger it :p

My code:

JASS:
scope RestrictBlink initializer onInit

    private function CheckSpell takes nothing returns boolean
        
        if GetSpellAbilityId() == 'A03H' and levelBegun and RectContainsPoint(gg_rct_WholeBase, GetSpellTargetX(), GetSpellTargetY()) then
        
            call SimError(GetTriggerPlayer(), "Cannot blink there")
            call IssueImmediateOrder(GetTriggerUnit(), "stop")
        
        elseif GetSpellAbilityId() == 'A03H' and not levelBegun then
        
            call SimError(GetTriggerPlayer(), "Cannot blink there")
            call IssueImmediateOrder(GetTriggerUnit(), "stop")   
            
        endif
        
        return false
    endfunction

    private function onInit takes nothing returns nothing
        local trigger t = CreateTrigger()
        call TriggerAddCondition(t, Condition(function CheckSpell))
        call TriggerRegisterAnyUnitEventBJ(t, EVENT_PLAYER_UNIT_SPELL_CAST)
        set t = null
    endfunction

endscope

levelBegun is just a boolean to determine whether a level is in progress. The hero cannot blink to base when the level has begun, and cannot blink at all when a level is not in progress.
 
Status
Not open for further replies.
Top