Spell Rune Ritual

Reaction score
341
Rune Ritual
TriggerHappy

(Video) (Screenshot)

Spell Description
The caster channels his inner darkness, causing runes to circle around him.
It drags the nearest four units towards the runes and they are struck with lightning periodicly.

Requirements

Code
JASS:
//===============================================================================\\
//                                                                               \\
//                              Rune Ritual                                      \\
//                                  by                                           \\
//                              TriggerHappy                                     \\
//                                                                               \\
//                                                                               \\
//===============================================================================\\
//                                                                               \\
// The caster channels his inner darkness, causing runes to circle around him.   \\
// It drags the nearest four units towards the runes and they are struck with    \\
// lightning periodicly.                                                         \\
//                                                                               \\
//===============================================================================\\
//                                                                               \\
//  Requires:                                                                    \\
//    +TimerUtils                                                                \\
//    +UnitStatus                                                                \\
//    +SimError (optional)                                                       \\
//                                                                               \\
//===============================================================================\\
 
scope RuneRitual initializer onInit //requires TimerUtils, UnitStatus optional SimError
    
    globals
        private constant integer SPELL_RAW_CODE = 'A000' // The spells raw code
        private constant integer RUNE_DUMMY     = 'h000' // The rune dummies raw code
        private constant integer DMG_TICKS      = 100 // How many timer intervals before the units get damaged
        private constant real RUNE_DISTANCE     = 300 // How far the units are made from the caster
        private constant real TIMER_PERIOD      = 0.03 // How far the units are made from the caster
        private constant real SPIN_SPEED        = 0.03 // how fast the runes spin
        private constant boolean REQUIRE_UNITS  = false // Displays an error if there are no enemy units around
        private constant string DAMAGE_EFFECT   = "Abilities\\Spells\\Other\\Monsoon\\MonsoonBoltTarget.mdl" // the effect when a unit is damaged
        private constant attacktype ATTACK_TYPE = ATTACK_TYPE_NORMAL
        private constant damagetype DAMAGE_TYPE = DAMAGE_TYPE_NORMAL
    endglobals
    
    private constant function AOE takes integer level returns real
        return (level*400.0)-((level-1)*100.0)
    endfunction
    
    private constant function DURATION takes integer level returns real
        return level*5.00-(level)
    endfunction
    
    private constant function DAMAGE takes integer level returns real
        return level*50.00
    endfunction
    
    //===============================================================================\\
    //                  DO NOT EDIT BELOW THIS LINE                                  \\ 
    //===============================================================================\\
    
    private keyword data
    globals
        private group GLOBAL_GROUP = CreateGroup()
        private player TEMP_PLAYER
        private data TEMP_DATA
        private hashtable HASH = InitHashtable()
    endglobals
    
    native UnitAlive takes unit id returns boolean
    
    private struct data
        unit array rune[4]
        unit array picked[4]
        unit caster
        real x
        real y
        real spin = 0.00
        integer level
        integer in = 0
        integer ticks = DMG_TICKS
        real array runeX[4]
        real array runeY[4]
        timer t
        
        static method callback takes nothing returns nothing
            local data this = GetTimerData(GetExpiredTimer())
            local integer i = 0
            set this.ticks = this.ticks + 1
            loop
                exitwhen i > 4
                set this.runeX<i> = this.x+RUNE_DISTANCE*Cos((i*90) * bj_DEGTORAD+this.spin)
                set this.runeY<i> = this.y+RUNE_DISTANCE*Sin((i*90) * bj_DEGTORAD+this.spin)
                call SetUnitX(this.rune<i>, this.runeX<i>)
                call SetUnitY(this.rune<i>, this.runeY<i>)
                if this.picked<i> != null then
                    call SetUnitX(this.picked<i>, this.runeX<i>)
                    call SetUnitY(this.picked<i>, this.runeY<i>)
                endif
                if this.ticks &gt;= DMG_TICKS and UnitAlive(this.picked<i>) then
                    call DestroyEffect(AddSpecialEffectTarget(DAMAGE_EFFECT, this.picked<i>, &quot;origin&quot;))
                    call UnitDamageTarget(this.caster, this.picked<i>, DAMAGE(this.level), true, false, ATTACK_TYPE, DAMAGE_TYPE, null)
                endif
                set i = i + 1
            endloop
            if this.ticks &gt;= DMG_TICKS then
                set this.ticks = 0
            endif
            set this.spin = this.spin+SPIN_SPEED
        endmethod
        
        static method Enemies takes nothing returns boolean
            local unit u = GetFilterUnit()
            local boolean b = IsUnitEnemy(u, TEMP_PLAYER) and UnitAlive(u) and not LoadBoolean(HASH, GetHandleId(u), 0)
            
            if TEMP_DATA.in &lt; 4 and b then
                set TEMP_DATA.picked[TEMP_DATA.in] = u
                call StunUnit(u, true)
                call SetUnitX(u, TEMP_DATA.runeX[TEMP_DATA.in])
                call SetUnitY(u, TEMP_DATA.runeY[TEMP_DATA.in])
                set TEMP_DATA.in = TEMP_DATA.in + 1
                call SaveBoolean(HASH, GetHandleId(u), 0, true)
            endif
            set u = null
            return b
        endmethod
        
        static method end takes nothing returns nothing
            local timer t = GetExpiredTimer()
            local data this = GetTimerData(t)
            call ReleaseTimer(this.t)
            set this.t = t
            call this.destroy()
        endmethod
        
        static method create takes unit u returns data
            local data this = data.allocate()
            local integer i = 0
            local real x
            local real y
            local real d
            local timer t   = NewTimer()
            
            set this.caster = u
            set this.y      = GetUnitY(this.caster)
            set this.x      = GetUnitX(this.caster)
            set this.level  = GetUnitAbilityLevel(this.caster, SPELL_RAW_CODE)
            set this.t      = t
            
            set d           = DURATION(this.level)
            
            call SaveBoolean(HASH, GetHandleId(u), 0, true)
            
            set TEMP_DATA = this
            set TEMP_PLAYER = GetOwningPlayer(this.caster)
            call GroupEnumUnitsInRange(GLOBAL_GROUP, this.x, this.y, AOE(this.level), Filter(function data.Enemies))
            
            static if REQUIRE_UNITS then
                set bj_groupCountUnits = 0
                call ForGroup(GLOBAL_GROUP, function CountUnitsInGroupEnum)
                if bj_groupCountUnits == 0 then
                    static if LIBRARY_SimError then
                        call SimError(TEMP_PLAYER, &quot;There are no enemy units around.&quot;)
                    else
                        call DisplayTimedTextToPlayer(TEMP_PLAYER, 0.52, 0.96, 2.00, &quot;\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n|cffffcc00There are no enemy units around.|r&quot;)
                    endif
                    call this.destroy()
                    return 0
                endif
            endif
            
            loop
                exitwhen i &gt; 3
                set x = this.x + RUNE_DISTANCE * Cos((i*90) * bj_DEGTORAD)
                set y = this.y + RUNE_DISTANCE * Sin((i*90)* bj_DEGTORAD)
                set this.rune<i> = CreateUnit(TEMP_PLAYER, RUNE_DUMMY, x, y, 0)
                set i = i + 1
            endloop
            
            call SetTimerData(t, this)
            call TimerStart(t, TIMER_PERIOD, true, function data.callback)
            set t = NewTimer()
            call SetTimerData(t, this)
            call TimerStart(t, DURATION(this.level), false, function data.end)
            return this
        endmethod
        
        method onDestroy takes nothing returns nothing
            local integer i = 0
            call ReleaseTimer(this.t)
            call SaveBoolean(HASH, GetHandleId(this.caster), 0, false)
            loop
                exitwhen i &gt; 4
                call RemoveUnit(this.rune<i>)
                if this.picked<i> != null then
                    call SaveBoolean(HASH, GetHandleId(this.picked<i>), 0, false)
                    call StunUnit(this.picked<i>, false)
                    set this.picked<i> = null
                endif
                set i = i + 1
            endloop
        endmethod
        
    endstruct
    
    private function Actions takes nothing returns boolean
        local unit u = GetTriggerUnit()
        
        if GetSpellAbilityId() == SPELL_RAW_CODE then
            if LoadBoolean(HASH, GetHandleId(u), 0) then
                static if LIBRARY_SimError then
                    call SimError(GetOwningPlayer(u), &quot;You already have a rune ritual running.&quot;)
                else
                    call DisplayTimedTextToPlayer(GetOwningPlayer(u), 0.52, 0.96, 2.00, &quot;\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n|cffffcc00You already have a rune ritual running.|r&quot;
                endif
                set u = null
                return false
            else
                call data.create(u)
            endif
        endif
        
        set u = null
        return false
    endfunction
    
    private function onInit takes nothing returns nothing
        local trigger t = CreateTrigger()
        call TriggerRegisterAnyUnitEventBJ(t, EVENT_PLAYER_UNIT_SPELL_EFFECT)
        call TriggerAddCondition(t, Condition(function Actions))
    endfunction

endscope</i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i>
 

Attachments

  • Rune Ritual.w3x
    72.6 KB · Views: 262

Nherwyziant

Be better than you were yesterday :D
Reaction score
96
Hehe, I didn't know that there was a video, anyways, I tested it, it was awesome but i don't know if this is a bug, the red mark thingy stops from going around the caster and remains at the spot for the rest of your life.
 
Reaction score
341
Yes, It's supposed to remain.
I'll think about making it follow. Let me do some testing.

EDIT: I don't like how it looks =(
 

Weep

Godspeed to the sound of the pounding
Reaction score
400
Like scorpion182 on THW, I'm also seeing corpses being dragged around.
 

Mr.Tutorial

Hard in the Paint.
Reaction score
42
Looks awesome from the video, but I think you should make the units slide to their rune positions instead of instantly move. I don't know why but that bugs me.
 

HydraRancher

Truth begins in lies
Reaction score
197
I agree with Mr Tutorial, it seems awkward for them to bounce into the place of the runes.
 

BlackRose

Forum User
Reaction score
239
I also think it is strange that it just moves instantly.
Also, "R" tooltip for Learn isn't working.
 

saw792

Is known to say things. That is all.
Reaction score
280
JASS:
//
    private constant function AOE takes integer level returns real
        return (level*400.0)-((level-1)*100.0)
    endfunction
    
    private constant function DURATION takes integer level returns real
        return level*5.00-(level)
    endfunction
->
JASS:
//
    private constant function AOE takes integer level returns real
        return level*300.00 + 100.00
    endfunction
    
    private constant function DURATION takes integer level returns real
        return level*4.00
    endfunction
 

Komaqtion

You can change this now in User CP.
Reaction score
469
These two are not the same:
JASS:
    private constant function DURATION takes integer level returns real
        return level*5.00-(level)
    endfunction


JASS:
    private constant function DURATION takes integer level returns real
        return level*4.00
    endfunction


If "level" is 2, then the first one returns 6, and the second one returns 8...
 

tooltiperror

Super Moderator
Reaction score
231
I thought you can use parenthesis to work around PEMDAS?

Maybe I'm just thinking of middle school math.

Anyway, sliding would be nice, it looks very awkward.
 
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