Need some help making a custom channeling spell

Summoned

New Member
Reaction score
51
I'm working on this spell that's basically a continuous stream of carrion swarms that lasts for as long as the caster does not do anything else. The stream of carrion swarms is the easy part, but I'm having a hard time making it so the caster actually just stands there and channels the spell. Basically what ends up happening is, without continuously spamming the "stop" command every tenth of a second or so, it'll rush off to the nearest enemy and start doing normal attacks while churning out the swarms.

Any ideas?
 
Reaction score
54
So, basically you want to convert Carrion Swarm to a channeling ability, yes?

I find that if you base your spell on Carrion Swarm, a non-channeling ability, you're going to have to deal with the channeling aspects through triggering.


Instead, I would base the spell on Channel. Change Data - Follow through time and the unit should behave as it were channeling.

Trigger:
  • ChannelStart
    • Events
      • Unit - Unit starts the effect of an ability
    • Actions
      • Start DummyTrigger


Trigger:
  • ChannelFinish
    • Events
      • Unit - Unit finishes casting an ability
    • Actions
      • Stop DummyTrigger

Trigger:
  • DummyTrigger:
    • Events
      • Time - Every x seconds
    • Actions
      • Create a dummy that casts carrion swarm toward target of the ability, saved in a variable of course.


Be sure to check for leaks, add conditions, format the channel ability.
 

Summoned

New Member
Reaction score
51
Well, I actually have everything else worked out. Basing it on a normal Channel with "follow-through time" won't work because I want the spell to continue channeling forever as long as the caster has mana. Only problem I have is preventing the casting unit from trying to take a swipe at any enemy that comes into acquisition range without some silly "stop"/"holdposition" spamming. Just wondering if there's any other way of preventing a caster from attacking without outright pausing it.

Explanation: This spell can either target a unit or a point. If targeted on a unit, the stream of carrion swarms will begin following the unit. If targeting a point, it'll just keep shooting at the point.

JASS:
function DI_Constants takes nothing returns nothing
    globals
        integer DI_SPELLID = 'A01L'
        integer DI_WAVEID1 = 'A01N'
        integer DI_WAVEID2 = 'A01O'
        integer DI_SPELLDUMMY = 'n002'
        real DI_MANACOSTBASE = 20
        real DI_MANACOSTMULT = 20
        string DI_WAVEORDER = "carrionswarm"
    endglobals
endfunction

function DI_Target takes nothing returns nothing
    local timer t = GetExpiredTimer()
    local unit caster = H2U(GetHandleHandle(t, "caster"))
    local unit target = H2U(GetHandleHandle(t, "target"))
    local location castloc = GetUnitLoc(caster)
    local location tarloc = GetUnitLoc(target)
    local real angle = AngleBetweenPoints(castloc, tarloc)
    local integer sklvl = GetHandleInt(t, "sklvl")
    local real manacost = (DI_MANACOSTBASE + (DI_MANACOSTMULT * I2R(sklvl))) / 5
    local integer N = GetHandleInt(t, "N")
    
    if (GetUnitState(caster, UNIT_STATE_MANA) < manacost) or (GetUnitState(target, UNIT_STATE_LIFE) <= 0) then
        call PauseTimer(t)
        call IssueImmediateOrder(caster, "stop")
        call SetUnitAnimation(caster, "stand")
        set caster = null
        set target = null
        call RemoveLocation(castloc)
        call RemoveLocation(tarloc)
        call FlushHandleLocals(t)
        call DestroyTimer(t)    
    elseif (GetUnitCurrentOrder(caster) != null) then
        call PauseTimer(t)
        call SetUnitAnimation(caster, "stand")
        set caster = null
        set target = null
        call RemoveLocation(castloc)
        call RemoveLocation(tarloc)
        call FlushHandleLocals(t)
        call DestroyTimer(t)
    else
        set N = N + 1
        call SetHandleInt(t, "N", N)
        call IssueImmediateOrder(caster, "stop")
        call IssueImmediateOrder(caster, "holdposition")
        call SetUnitFacing(caster, angle)
        call SetUnitAnimation(caster, "slam")
        if (ModuloInteger(N, 2) == 0) then
            call SetUnitState(caster, UNIT_STATE_MANA, (GetUnitState(caster, UNIT_STATE_MANA) - manacost))
            set bj_lastCreatedUnit = CreateUnitAtLoc(GetOwningPlayer(caster), DI_SPELLDUMMY, castloc, 0)
            call UnitApplyTimedLife(bj_lastCreatedUnit, 'BTLF', 3)
            call UnitAddAbility(bj_lastCreatedUnit, DI_WAVEID1)
            call SetUnitAbilityLevel(bj_lastCreatedUnit, DI_WAVEID1, sklvl)
            call IssuePointOrderLoc(bj_lastCreatedUnit, DI_WAVEORDER, tarloc)
        
            set bj_lastCreatedUnit = CreateUnitAtLoc(GetOwningPlayer(caster), DI_SPELLDUMMY, castloc, 0)
            call UnitApplyTimedLife(bj_lastCreatedUnit, 'BTLF', 3)
            call UnitAddAbility(bj_lastCreatedUnit, DI_WAVEID2)
            call SetUnitAbilityLevel(bj_lastCreatedUnit, DI_WAVEID2, sklvl)
            call IssuePointOrderLoc(bj_lastCreatedUnit, DI_WAVEORDER, tarloc)
        endif
    endif
    
    set caster = null
    set target = null
    call RemoveLocation(castloc)
    call RemoveLocation(tarloc)
    
endfunction

function DI_Target_Start takes unit caster, unit target, integer sklvl returns nothing
    local timer t = CreateTimer()
    call SetHandleHandle(t, "caster", caster)
    call SetHandleHandle(t, "target", target)
    call SetHandleInt(t, "sklvl", sklvl)
    call TimerStart(t, 0.1, true, function DI_Target)
endfunction

function DI_Point takes nothing returns nothing
    local timer t = GetExpiredTimer()
    local unit caster = H2U(GetHandleHandle(t, "caster"))
    local real angle = GetHandleReal(t, "angle")
    local location castloc = GetUnitLoc(caster)
    local location tarloc = PolarProjectionBJ(castloc, 50, angle)
    local integer sklvl = GetHandleInt(t, "sklvl")
    local real manacost = (DI_MANACOSTBASE + (DI_MANACOSTMULT * I2R(sklvl))) / 5
    local integer N = GetHandleInt(t, "N")
    
    if (GetUnitState(caster, UNIT_STATE_MANA) < manacost) then
        call IssueImmediateOrder(caster, "stop")
        call SetUnitAnimation(caster, "stand")
        call PauseTimer(t)
        set caster = null
        call RemoveLocation(castloc)
        call RemoveLocation(tarloc)
        call FlushHandleLocals(t)
        call DestroyTimer(t)
    elseif (GetUnitCurrentOrder(caster) != null) then
        call PauseTimer(t)
        call SetUnitAnimation(caster, "stand")
        set caster = null
        call RemoveLocation(castloc)
        call RemoveLocation(tarloc)
        call FlushHandleLocals(t)
        call DestroyTimer(t)
    else
        set N = N + 1
        call SetHandleInt(t, "N", N)
        call IssueImmediateOrder(caster, "stop")
        call IssueImmediateOrder(caster, "holdposition")
        call SetUnitFacing(caster, angle)
        call SetUnitAnimation(caster, "slam")
        if (ModuloInteger(N, 2) == 0) then
            call SetUnitState(caster, UNIT_STATE_MANA, (GetUnitState(caster, UNIT_STATE_MANA) - manacost))
            set bj_lastCreatedUnit = CreateUnitAtLoc(GetOwningPlayer(caster), DI_SPELLDUMMY, castloc, 0)
            call UnitApplyTimedLife(bj_lastCreatedUnit, 'BTLF', 3)
            call UnitAddAbility(bj_lastCreatedUnit, DI_WAVEID1)
            call SetUnitAbilityLevel(bj_lastCreatedUnit, DI_WAVEID1, sklvl)
            call IssuePointOrderLoc(bj_lastCreatedUnit, DI_WAVEORDER, tarloc)
        
            set bj_lastCreatedUnit = CreateUnitAtLoc(GetOwningPlayer(caster), DI_SPELLDUMMY, castloc, 0)
            call UnitApplyTimedLife(bj_lastCreatedUnit, 'BTLF', 3)
            call UnitAddAbility(bj_lastCreatedUnit, DI_WAVEID2)
            call SetUnitAbilityLevel(bj_lastCreatedUnit, DI_WAVEID2, sklvl)
            call IssuePointOrderLoc(bj_lastCreatedUnit, DI_WAVEORDER, tarloc)
        endif
    endif
    
    set caster = null
    call RemoveLocation(castloc)
    call RemoveLocation(tarloc)
endfunction

function DI_Point_Start takes unit caster, real angle, integer sklvl returns nothing
    local timer t = CreateTimer()
    call SetHandleHandle(t, "caster", caster)
    call SetHandleReal(t, "angle", angle)
    call SetHandleInt(t, "sklvl", sklvl)
    call TimerStart(t, 0.1, true, function DI_Point)
endfunction

function Trig_Darkness_Inferno_Actions takes nothing returns nothing
    local integer sklvl
    local unit caster
    local unit target
    local real angle
    local location castloc
    local location tarloc
    if (GetSpellAbilityId() == DI_SPELLID) then
        set caster = GetTriggerUnit()
        set sklvl = GetUnitAbilityLevel(caster, DI_SPELLID)
        if (GetSpellTargetUnit() != null) then
            set target = GetSpellTargetUnit()
            call IssueImmediateOrder(caster, "holdposition")
            call DI_Target_Start(caster, target, sklvl)
        else
            set castloc = GetUnitLoc(caster)
            set tarloc = GetSpellTargetLoc()
            set angle = AngleBetweenPoints(castloc, tarloc)
            call RemoveLocation(castloc)
            call RemoveLocation(tarloc)
            call IssueImmediateOrder(caster, "holdposition")
            call DI_Point_Start(caster, angle, sklvl)
        endif
        set caster = null
    endif
endfunction

//===========================================================================
function InitTrig_Darkness_Inferno takes nothing returns nothing
    set gg_trg_Darkness_Inferno = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_Darkness_Inferno, EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddAction( gg_trg_Darkness_Inferno, function Trig_Darkness_Inferno_Actions )
endfunction
 

Silver

New Member
Reaction score
21
You could freeze the unit, this will stop it from attacking but it will also stop animating. Might look weird (but you could add to the tooltip that this is a side effect, find a way to make it fit in?)

You could change ownership but retain colour, give it to neutral passive?

Of course, what might be best is to base the spell off channel, and change its effects (mainly to make it a dummy ability but keeping the channeled part), then add the carrion swarm via triggers.
 

Summoned

New Member
Reaction score
51
You could freeze the unit, this will stop it from attacking but it will also stop animating. Might look weird (but you could add to the tooltip that this is a side effect, find a way to make it fit in?)

You could change ownership but retain colour, give it to neutral passive?
Freezing the unit or changing ownership causes major issues, mainly I want the player to be able to break the channeling effect by moving or attacking or casting another spell, etc.

Of course, what might be best is to base the spell off channel, and change its effects (mainly to make it a dummy ability but keeping the channeled part), then add the carrion swarm via triggers.
This won't work because the "channeling" has a fixed duration. It also seems to automatically break the spell because the game considers the channel follow-through to be a type of non-null order?

Thanks for trying to help, though. I think I'll stick with the silly jerk action spell for now.
 
Reaction score
54
Not yet!

Are you ok with disabling the unit attack for the duration of the spell?
If so, have a dummy cast Drunken Haze on it, and remove it when spell is over.
 

Summoned

New Member
Reaction score
51
Actually, that sounds like a nice idea. Going to give it a try.

EDIT: Seems to work alright. Looks a bit weird with the attack button disappearing and all, but much better than spamming stop and hold position over and over and over.
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top