Spell Regenerative Cyclone

GFreak45

I didnt slap you, i high 5'd your face.
Reaction score
130
Regenerative Cyclone

Description:
Your caster summons powerful winds to push her enemies away and heal nearby allies for 10+(40*Level of Ability) in a 450 range.

Uses:
Only Jass NewGen

Settings:

SPELL_ID (integer) = the spell id of the base spell used for the ability, this can be any ability you want as order strings do not matter and targets do not matter.

MOVE_TO_MAX (boolean) = if true this ability will push units to the max range, but not past. if false, this will push units the distance of the max range from their current point, resulting in a farther and longer push

IGNORE_UNIT_PATHING[/color] (boolean) = if true this ability's push will ignore pathing of units for the pushed targets

IGNORE_PATHING (boolean) = if true this overrides IGNORE_UNIT_PATHING because the pushed units will have pathing turned off until they complete the push

DURATION (real) = the duration of the push, if set to 0 the push will be instant or nearly instant

INTERVAL (real) = the interval at which units are moved for the push, currently 0.02 seconds for a smooth push

STUN (boolean) = if true the units will be pause for the duration of the push, best for unruly units who want to move the way opposite the stun

implimentation:
step 1: create a new spell
step 2: get spell id (check the view option view as raw data and find the spell, ID next to name)
step 3: create a trigger, convert to custom text in edit, and replace with below code
step 4: set [ljass]private constant integer SPELL_ID = '[Your Spell id replaces these brackets]'[/ljass]

Code:
JASS:
scope RejuvenationCyclone initializer OnInit
    
    globals
        private constant integer SPELL_ID = 'A000'
//this is the spell ID (under the view tab, check view raw data and find your spell to get this)

        private constant boolean MOVE_TO_MAX = false
//if true this will move units to max range and not past it

        private constant boolean IGNORE_UNIT_PATHING = true
//if true this push will ignore unit pathing

        private constant boolean IGNORE_PATHING = false
//if this is true the push will ignore pathing period

        private constant real DURATION = 0.5
//this is the max duration of  the push, when set to 0 it will be instant

        private constant real INTERVAL = 0.02
//CAN NOT BE 0.00, this is the interval at which the push is issued, frequency relates directly with smoothness and lag

        private constant boolean STUN = true
//set to false if you dont want the units to be stunned while pushed

        private timer RCLLTIMER = CreateTimer() //DO NOT CHANGE
    endglobals
    
    struct RCLL extends array
        unit pushTarget
        real changeX
        real changeY
        integer changeCount
        
        integer next
        integer previous
        
        static integer array recycleList
        static integer lastRecycled = 0
        static integer listSize = 0
        
        private static method Allocate takes nothing returns thistype
            local integer i = RCLL.recycleList[0]
            if (i == 0) then
                set RCLL.listSize = RCLL.listSize + 1
                return RCLL.listSize
            endif
            set RCLL.recycleList[0] = RCLL.recycleList<i>
            set RCLL.recycleList<i> = 0
            return i
        endmethod
        
        static method linkUnit takes unit u, real x, real y returns nothing
            local thistype this = thistype.Allocate()
            set this.pushTarget = u
            set this.changeX = x
            set this.changeY = y
            set this.changeCount = 0
            set this.next = 0
            set this.previous = thistype[0].previous
            set thistype[thistype[0].previous].next = this
            set thistype[0].previous = this
        endmethod
    
        static method removeLink takes integer i returns nothing
            set thistype[thistype<i>.previous].next = thistype<i>.next
            set thistype[thistype<i>.next].previous = thistype<i>.previous
            set thistype.recycleList[thistype.lastRecycled] = i
            set thistype.lastRecycled = i
            set thistype.recycleList<i> = 0
        endmethod
    endstruct

    private function Core takes nothing returns nothing
        local integer i = RCLL[0].next
        local location a
        local real x
        local real y
        loop
            if RCLL[0].next == 0 then
                call PauseTimer(RCLLTIMER)
            endif
            exitwhen i == 0
            if IGNORE_UNIT_PATHING == true then
                call SetUnitPathing(RCLL<i>.pushTarget, false)
            elseif IGNORE_PATHING == true then
                call SetUnitPathing(RCLL<i>.pushTarget, false)
            endif
            if STUN then
                call PauseUnit(RCLL<i>.pushTarget, true)
            endif
            set a = GetUnitLoc(RCLL<i>.pushTarget)
            set x = GetLocationX(a)
            set y = GetLocationY(a)
            call SetUnitX(RCLL<i>.pushTarget, RCLL<i>.changeX + x)
            call SetUnitY(RCLL<i>.pushTarget, RCLL<i>.changeY + y)
            if IGNORE_PATHING == false then
            if IGNORE_UNIT_PATHING == false then
                call SetUnitPathing(RCLL<i>.pushTarget, true)
            endif
            endif
            set RCLL<i>.changeCount = RCLL<i>.changeCount + 1
            if RCLL<i>.changeCount == R2I(DURATION / INTERVAL) then
                if IGNORE_PATHING or IGNORE_UNIT_PATHING then
                    call SetUnitPathing(RCLL<i>.pushTarget, true)
                endif
                if STUN then
                    call PauseUnit(RCLL<i>.pushTarget, false)
                endif
                call RCLL.removeLink(i)
            endif
            set a = null
            set i = RCLL<i>.next
        endloop
    endfunction
    
    private function GroupFilter takes nothing returns boolean
        local boolean bool
        set bool = not IsUnitType(GetFilterUnit(), UNIT_TYPE_MAGIC_IMMUNE)
        set bool = bool and not IsUnitType(GetFilterUnit(), UNIT_TYPE_FLYING)
        set bool = bool and not IsUnitType(GetFilterUnit(), UNIT_TYPE_MECHANICAL)
        set bool = bool and not IsUnitType(GetFilterUnit(), UNIT_TYPE_STRUCTURE)
        set bool = bool and not IsUnitType(GetFilterUnit(), UNIT_TYPE_DEAD)
        return bool
    endfunction
    
    private function OnInitActions takes nothing returns boolean
        local real rx
        local real ry
        local group g = CreateGroup()
        local unit u
        local real x = GetUnitX(GetTriggerUnit())
        local real y = GetUnitY(GetTriggerUnit())
        local real bx
        local real by
        local real r
        if GetSpellAbilityId() == SPELL_ID then
             call GroupEnumUnitsInRange(g, x, y, 450, Filter(function GroupFilter))
             loop
                 set u = FirstOfGroup(g)
                 exitwhen (u == null)
                 if IsUnitEnemy(u,GetOwningPlayer(GetTriggerUnit())) then
                     set bx = GetUnitX(u)
                     set by = GetUnitY(u)
                         set r = bj_RADTODEG * Atan2(by - y, bx - x)
                     if (MOVE_TO_MAX == true) then
                         set rx = bx + 450 * Cos(r * bj_DEGTORAD)
                         set ry = by + 450 * Sin(r * bj_DEGTORAD)
                     elseif (MOVE_TO_MAX == false) then
                         set rx = x + 450 * Cos(r * bj_DEGTORAD)
                         set ry = y + 450 * Sin(r * bj_DEGTORAD)
                     endif
                     set rx = ((rx - x) /(DURATION / INTERVAL))
                     set ry = ((ry - y)/(DURATION / INTERVAL))
                     call RCLL.linkUnit(u, rx, ry)
                 elseif (IsPlayerAlly(GetOwningPlayer(GetTriggerUnit()), GetOwningPlayer(u)) == true) then
                     call SetUnitState(u, UNIT_STATE_LIFE, (GetUnitState(u, UNIT_STATE_LIFE) + 10.0 + (40.0 * GetUnitAbilityLevel(GetTriggerUnit(), SPELL_ID))))
                 endif
                 call GroupRemoveUnit(g, u)
             endloop
        call TimerStart(RCLLTIMER, INTERVAL, true, function Core)
        endif
        call DestroyGroup(g)
        set g = null
        set u = null
        return true
    endfunction
    
    private function OnInit takes nothing returns nothing
        local trigger t = CreateTrigger()
        call TriggerRegisterAnyUnitEventBJ(t, EVENT_PLAYER_UNIT_SPELL_EFFECT)
        call TriggerAddCondition(t, Filter(function OnInitActions))
        set t = null
    endfunction
endscope</i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i>


Change Log and Soon to come
Change Log:
  • v1.00 - release - 12/3/2011

Soon to come:
  • Special Effects options
  • Healing function options
  • Damage Options
  • Propper Stun Option without glitch possiblities
 

Attachments

  • Regenerative Cyclone.w3x
    21.5 KB · Views: 375

luorax

Invasion in Duskwood
Reaction score
67
That filter should use comments ([ljass]/* */[/ljass]) instead of that local boolean.
 

Dirac

22710180
Reaction score
147
Not using existant libraries doesn't make the spell better, actually it makes it a lot worse
Remember that these libraries were written and revised by people who are experienced using vJass and their only purpose is to improve your code.
Haven't tested it yet, will when i have the time.
 

luorax

Invasion in Duskwood
Reaction score
67
All the functions should be merged into the struct, and by using the struct's initializer you could get rid of the library initializer. Also, indent the comments below the configurables.

This is a cool snippet.
 
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