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: 266

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.
  • Ghan Ghan:
    Still lurking
    +3
  • The Helper The Helper:
    I am great and it is fantastic to see you my friend!
    +1
  • The Helper The Helper:
    If you are new to the site please check out the Recipe and Food Forum https://www.thehelper.net/forums/recipes-and-food.220/
  • Monovertex Monovertex:
    How come you're so into recipes lately? Never saw this much interest in this topic in the old days of TH.net
  • Monovertex Monovertex:
    Hmm, how do I change my signature?
  • tom_mai78101 tom_mai78101:
    Signatures can be edit in your account profile. As for the old stuffs, I'm thinking it's because Blizzard is now under Microsoft, and because of Microsoft Xbox going the way it is, it's dreadful.
  • The Helper The Helper:
    I am not big on the recipes I am just promoting them - I use the site as a practice place promoting stuff
    +2
  • Monovertex Monovertex:
    @tom_mai78101 I must be blind. If I go on my profile I don't see any area to edit the signature; If I go to account details (settings) I don't see any signature area either.
  • The Helper The Helper:
    You can get there if you click the bell icon (alerts) and choose preferences from the bottom, signature will be in the menu on the left there https://www.thehelper.net/account/preferences
  • The Helper The Helper:
    I think I need to split the Sci/Tech news forum into 2 one for Science and one for Tech but I am hating all the moving of posts I would have to do
  • The Helper The Helper:
    What is up Old Mountain Shadow?
  • The Helper The Helper:
    Happy Thursday!
    +1
  • Varine Varine:
    Crazy how much 3d printing has come in the last few years. Sad that it's not as easily modifiable though
  • Varine Varine:
    I bought an Ender 3 during the pandemic and tinkered with it all the time. Just bought a Sovol, not as easy. I'm trying to make it use a different nozzle because I have a fuck ton of Volcanos, and they use what is basically a modified volcano that is just a smidge longer, and almost every part on this thing needs to be redone to make it work
  • Varine Varine:
    Luckily I have a 3d printer for that, I guess. But it's ridiculous. The regular volcanos are 21mm, these Sovol versions are about 23.5mm
  • Varine Varine:
    So, 2.5mm longer. But the thing that measures the bed is about 1.5mm above the nozzle, so if I swap it with a volcano then I'm 1mm behind it. So cool, new bracket to swap that, but THEN the fan shroud to direct air at the part is ALSO going to be .5mm to low, and so I need to redo that, but by doing that it is a little bit off where it should be blowing and it's throwing it at the heating block instead of the part, and fuck man
  • Varine Varine:
    I didn't realize they designed this entire thing to NOT be modded. I would have just got a fucking Bambu if I knew that, the whole point was I could fuck with this. And no one else makes shit for Sovol so I have to go through them, and they have... interesting pricing models. So I have a new extruder altogether that I'm taking apart and going to just design a whole new one to use my nozzles. Dumb design.
  • Varine Varine:
    Can't just buy a new heatblock, you need to get a whole hotend - so block, heater cartridge, thermistor, heatbreak, and nozzle. And they put this fucking paste in there so I can't take the thermistor or cartridge out with any ease, that's 30 dollars. Or you can get the whole extrudor with the direct driver AND that heatblock for like 50, but you still can't get any of it to come apart
  • Varine Varine:
    Partsbuilt has individual parts I found but they're expensive. I think I can get bits swapped around and make this work with generic shit though
  • Ghan Ghan:
    Heard Houston got hit pretty bad by storms last night. Hope all is well with TH.
  • The Helper The Helper:
    Power back on finally - all is good here no damage
    +2
  • V-SNES V-SNES:
    Happy Friday!
    +1
  • The Helper The Helper:
    New recipe is another summer dessert Berry and Peach Cheesecake - https://www.thehelper.net/threads/recipe-berry-and-peach-cheesecake.194169/

      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