Stopping a spell in action

Exfyre

hmm...
Reaction score
60
hey, i was making a spell to increase my minimal knowledge of JASS, and i was wondering why i can't press 'stop' while this is running to stop it.

the spell teleports the caster to the target every x seconds dealing x damage.

how can i make it so pressing 'stop' will stop it?

JASS:
function Trig_Followup_Slash_Conditions takes nothing returns boolean
    if GetSpellAbilityId() == 'A000' then
        return true
    endif
    return false
endfunction

function Trig_Followup_Slash_Actions takes nothing returns nothing
    local unit caster = GetSpellAbilityUnit()
    local unit target = GetSpellTargetUnit()
    local integer hits = 5
    local real TimeBetweenHits = .1
    local location targetloc = GetUnitLoc(target)
    local location casterloc = GetUnitLoc(caster)
    local integer damage = 25
    local real angle = AngleBetweenPoints(targetloc, casterloc)
    local location temploc
    loop
        exitwhen hits == 0 or GetUnitState(caster, UNIT_STATE_LIFE) <= 0 ==
true or GetUnitState(target, UNIT_STATE_LIFE) <= 0 == true or
OrderId2String(GetUnitCurrentOrder(caster)) == "Stop"
        set targetloc = GetUnitLoc(target)
        set temploc = PolarProjectionBJ(targetloc, 78, angle) 
        call SetUnitPositionLoc(caster, temploc)    
        call UnitDamageTarget(caster, target, damage, true, false, ATTACK_TYPE_CHAOS, DAMAGE_TYPE_NORMAL, WEAPON_TYPE_ROCK_HEAVY_BASH)
        call SetUnitAnimation(caster, "attack")
        call RemoveLocation(temploc)
        call RemoveLocation(targetloc)
        call TriggerSleepAction(TimeBetweenHits)
        set hits = hits - 1
    endloop
    call RemoveLocation(casterloc)    
    set casterloc = null
    set temploc = null
    set caster = null
    set target = null
    set targetloc = null
endfunction

//==== Init Trigger NewTrigger ====
function InitTrig_Followup_Slash takes nothing returns nothing
    set gg_trg_Followup_Slash = CreateTrigger()
    call TriggerRegisterAnyUnitEventBJ(gg_trg_Followup_Slash, EVENT_PLAYER_UNIT_SPELL_EFFECT)
    //call TriggerRegister__(gg_trg_NewTrigger, )
    call TriggerAddCondition(gg_trg_Followup_Slash, Condition(function Trig_Followup_Slash_Conditions))
    call TriggerAddAction(gg_trg_Followup_Slash, function Trig_Followup_Slash_Actions)
endfunction
 

Ghostwind

o________o
Reaction score
172
Make a trigger inside this trigger that responds to the event that a unit is given an order with no target (convert it from GUI to get the event) and then turn off the gg_trg_Followup_Slash when the order is 'stop'.

Hope that helps! :)
 

Exfyre

hmm...
Reaction score
60
well, i want it to be able to be cast again. that just disables trigger for whole game, right?
 

Luth

Lex Luthor!
Reaction score
41
If you're not using CustomUnitValues, you can do what Ghostwind says and instead of turning off the trigger, you can set a value on the unit, and have an exit condition: CustomUnitValue == whatever you set it to. Just be sure to clear the CUV when you're done.
 

Flare

Stops copies me!
Reaction score
662
JASS:
OrderId2String(GetUnitCurrentOrder(caster)) == "Stop"


Use != "order string of your ability" instead. if you order an attack, move, patrol or any other order that isnt stop, that condition probably wont register

so:
JASS:
OrderId2String (GetUnitCurrentOrder (caster)) != "channel"
//That's just an example, just find the relevant order string in Object Editor
 

Exfyre

hmm...
Reaction score
60
-flare
i originally based the ability off of cripple and set duration to .01
so would your suggestion not work because the spell is finished after .01 seconds?
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top