Spell Thunder wheel

Trollvottel

never aging title
Reaction score
262
Import Difficulty: low-middle
GUI/Jass: Jass
vJass: yes, my first vJass spell
Leakless: I think so

Creates a thunder wheel of three bolts circling around the caster. Enemy units hit by the wheel will be chain lighted.

Screenshot:

First(standart):
91634481ne2.jpg

Second(with lifedrain):
41594497ad4.jpg


Third(with lifedrain and transparency):
46716267qx1.jpg

Code:

JASS:
scope ThunderWheel

// ################################################################
// #How to implement:                                             #
// #1. copy the spell trigger and if necessary the handle system  #
// #2. copy the ability and the dummy and the dummy ability       #
// #3. change the raw codes below                                 # 
// #4. change the values to anything you want                     #
// #5. have fun and merry christmas                               #
// ################################################################
    globals
        private constant integer spellraw = 'A000' // Spell raw code
        private constant integer dummyspellraw = 'A001' // dummy ability's raw code
        private constant integer dummyrawcode = 'h000' // dummy's raw code
        private constant real duration = 10.00 // spell duration
        private constant real incr = 5.00 // speed
        private constant real maxr = 400.00 // max radius
        private constant string ligh = "CLPB"  // lightning code
        private constant real trans = 1 // transparency (0 = invisible)
    endglobals
    // Codes for the lightning-color:
    // Chain lightning "CLPB"
    // Drain "DRAB"
    // Life drain "DRAL"
    // Mana drain "DRAM"
    // Death finger "AFOD"
    // Forked lightning "FORK"
    // Healing wave "HWPB"
    // Magic lasso "LEAS"
    // mana burn "MBUR"
    // mana lightning  "MFPB"
    // dunno the name <img src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" class="smilie smilie--sprite smilie--sprite8" alt=":D" title="Big Grin    :D" loading="lazy" data-shortname=":D" /> &quot;SPLK&quot;
    //o0o0o0o0o0o0o0o0o0o0o0o0o0o0o0o0o0o0o0o0o0o0o0o0o0o0o0o0o0o0o0o0o0o0o0o0o0o0o0o0o0o0o0o0o0o0o0o0o0o0o0o0o0o0o0

    private function Trig_Spell_Conditions takes nothing returns boolean
        return GetSpellAbilityId() == spellraw
    endfunction

    function fx takes nothing returns nothing
        local trigger t = GetTriggeringTrigger()
        local lightning l = GetHandleLightning(t, &quot;light&quot;)
        local unit u = GetHandleUnit(t, &quot;u&quot;)
        call PolledWait(1.5)
        call DestroyLightning(l)
        call SetUnitUserData(u, 0)
        set l = null
        set t = null
    endfunction

    function blitz takes unit u returns nothing
            local lightning array lz
            local real x0 = GetUnitX(u)
            local real x1
            local real x2
            local real y0 = GetUnitY(u)
            local real y1
            local real y2
            local integer int = 0
                loop
                    exitwhen int &gt; 10
                    set int = int + 1
                    
                    set x1 = x0 + 50 * Cos(int    *36.00 * bj_DEGTORAD)
                    set y1 = y0 + 50 * Sin(int    *36.00 * bj_DEGTORAD)
                    set x2 = x0 + 50 * Cos((int-1)*36.00 * bj_DEGTORAD)
                    set y2 = y0 + 50 * Sin((int-1)*36.00 * bj_DEGTORAD)
                    set lz[int] = AddLightning(ligh, false, x1, y1, x2, y2)
                    call SetLightningColor(lz[int], 1,1,1,trans)
                    call SetHandleHandle(GetTriggeringTrigger(), &quot;light&quot;, lz[int])
                    call SetHandleHandle(GetTriggeringTrigger(), &quot;u&quot;, u)
                    call ExecuteFunc(&quot;fx&quot;)
                    call FlushHandleLocals(GetTriggeringTrigger())
                endloop
            set u = null
    endfunction

    //-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_

    private struct thing
        unit C
        unit T
        real x
        real y
        real x2
        real y2
        real angle = 240
        real angle2 = 120
        real angle3 = 0
        real an
        real dis = 50
        real maxdis = 500
        real inc = 5
        integer laber = 0
        lightning l
        lightning ll
        lightning l2
        lightning ll2
        lightning l3
        lightning ll3
        static method create takes nothing returns thing
            local thing init= thing.allocate()
            set init.l = AddLightning(ligh, false, GetUnitX(init.C), GetUnitY(init.C), init.x, init.y)
            call SetLightningColor(init.l, 1,1,1,trans)
            set init.l2 = AddLightning(ligh, false, GetUnitX(init.C), GetUnitY(init.C), init.x, init.y)
            call SetLightningColor(init.l2, 1,1,1,trans)
            set init.l3 = AddLightning(ligh, false, GetUnitX(init.C), GetUnitY(init.C), init.x, init.y)
            call SetLightningColor(init.l3, 1,1,1,trans)
            set init.x = GetUnitX(init.C) + init.dis * Cos(init.angle * bj_DEGTORAD)
            set init.y = GetUnitY(init.C) + init.dis * Sin(init.angle * bj_DEGTORAD)
            set init.ll = AddLightningEx(ligh, false, init.x, init.y, 0.00, init.x, init.y, 1200)
            call SetLightningColor(init.ll, 1,1,1,trans)
            set init.ll2 = AddLightningEx(ligh, false, init.x, init.y, 0.00, init.x, init.y, 1200)
            call SetLightningColor(init.ll2, 1,1,1,trans)
            set init.ll3 = AddLightningEx(ligh, false, init.x, init.y, 0.00, init.x, init.y, 1200)
            call SetLightningColor(init.ll3, 1,1,1,trans)
            return init
        endmethod
        
        method MoveIt takes nothing returns nothing
                set this.angle = this.angle + this.inc
                set this.angle2 = this.angle2 + this.inc
                set this.angle3 = this.angle3 + this.inc
                set this.x = GetUnitX(this.C) + this.dis * Cos(this.angle * bj_DEGTORAD)
                set this.y = GetUnitY(this.C) + this.dis * Sin(this.angle * bj_DEGTORAD)
                call MoveLightningEx(this.ll, false, this.x, this.y, 0.00, this.x, this.y, 1200)
                call MoveLightning(this.l, false, GetUnitX(this.C), GetUnitY(this.C), this.x,this.y)
                set this.an = this.angle
                call this.EnumIt()
                set this.x = GetUnitX(this.C) + this.dis * Cos(this.angle2 * bj_DEGTORAD)
                set this.y = GetUnitY(this.C) + this.dis * Sin(this.angle2 * bj_DEGTORAD)
                call MoveLightningEx(this.ll2, false, this.x, this.y, 0.00, this.x, this.y, 1200)
                call MoveLightning(this.l2, false, GetUnitX(this.C), GetUnitY(this.C), this.x,this.y)
                set this.an = this.angle2
                call this.EnumIt()
                set this.x = GetUnitX(this.C) + this.dis * Cos(this.angle3 * bj_DEGTORAD)
                set this.y = GetUnitY(this.C) + this.dis * Sin(this.angle3 * bj_DEGTORAD)
                call MoveLightningEx(this.ll3, false, this.x, this.y, 0.00, this.x, this.y, 1200)
                call MoveLightning(this.l3, false, GetUnitX(this.C), GetUnitY(this.C), this.x,this.y)
                set this.an = this.angle3
                call this.EnumIt()
        endmethod
        
        method EnumIt takes nothing returns nothing
            local group g = CreateGroup()
            local unit u 
            local integer i = 1
            local real x = GetUnitX(this.C)
            local real y = GetUnitY(this.C)
            loop
                set i = i + 20
                exitwhen i &gt;= this.dis
                set x = x + 20 * Cos(this.an * bj_DEGTORAD)
                set y = y + 20 * Sin(this.an * bj_DEGTORAD)
                call GroupEnumUnitsInRange(g, x, y, 100, null)
                loop
                    set this.T = FirstOfGroup(g)
                    call GroupRemoveUnit(g, this.T)
                    exitwhen this.T == null 
                    if this.T != null and GetUnitUserData(this.T) != 1 and IsUnitEnemy(this.T, GetOwningPlayer(this.C)) and GetUnitState(this.T, UNIT_STATE_LIFE) &gt; 0 then
                        call SetUnitUserData(this.T, 1)
                        set u = CreateUnit(GetOwningPlayer(this.C), dummyrawcode, this.x, this.y, 0)
                        call UnitApplyTimedLife(u, &#039;BTLF&#039;, 2.00) 
                        call UnitAddAbility(u, dummyspellraw)
                        call SetUnitAbilityLevel(u, dummyspellraw, GetUnitAbilityLevel(this.C, spellraw))
                        call IssueTargetOrder(u, &quot;chainlightning&quot;, this.T)
                        call blitz(this.T)
                    endif
                endloop
                set u = null
                call DestroyGroup(g)
                set g = CreateGroup()
            endloop
            set g = null
        endmethod

        method onDestroy takes nothing returns nothing
            call DestroyLightning(this.l)
            call DestroyLightning(this.ll)
            call DestroyLightning(this.l2)
            call DestroyLightning(this.ll2)
            call DestroyLightning(this.l3)
            call DestroyLightning(this.ll3)
            set this.ll = null
            set this.ll2 = null
            set this.l = null
            set this.l2 = null
            set this.l3 = null
            set this.ll3 = null
            set this.T = null
        endmethod

    endstruct
    //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
    private function times takes nothing returns nothing
        local timer t = GetExpiredTimer()
        local thing ding = thing(GetHandleInt(t,&quot;struct&quot;))
        call ding.MoveIt()
        set ding.laber = ding.laber + 10
        if ding.laber &gt; ding.maxdis then
            if ding.dis &gt;= 60 then
                set ding.dis = ding.dis - 10
            else
                set ding.laber = 0
            endif
        else 
            set ding.dis = ding.dis + 10
        endif
        set t = null
    endfunction

    private function Trig_Spell_Actions takes nothing returns nothing
        local thing ding = thing.create()
        local timer t = CreateTimer()
        set ding.C = GetTriggerUnit()
        set ding.maxdis = maxr
        set ding.inc = incr
        
        call SetHandleInt(t, &quot;struct&quot;, ding)
        call TimerStart(t, 0.03, true, function times)
        call PolledWait(duration)
        call FlushHandleLocals(t)
        call DestroyTimer(t)
        //call ding.OnDestroy()
        call ding.destroy()
        set t = null
    endfunction

    //==============================================================================================
    function InitTrig_Spell takes nothing returns nothing
        set gg_trg_Spell = CreateTrigger(  )
        call TriggerRegisterAnyUnitEventBJ( gg_trg_Spell, EVENT_PLAYER_UNIT_SPELL_EFFECT )
        call TriggerAddCondition( gg_trg_Spell, Condition( function Trig_Spell_Conditions ) )
        call TriggerAddAction( gg_trg_Spell, function Trig_Spell_Actions )
    endfunction
endscope

*update: you can now choose the lightning art and the lightning transparency, added a list with the lightning-codes
Have fun <3
I began using vJass this morning please say if and how I can make the coding better
 

Attachments

  • Thunder Wheel.w3x
    17.1 KB · Views: 382
D

Dark_Dude

Guest
WEll I cant check the code for leaks cuz I cant write/read Jass but the spell looks bloody mental xoD!!!!
I tried casting it 10 times and it didnt lagg so I think its leakless
if its leakless its a 7/10 here!!
 
Reaction score
456
Well.. you should learn few things first.

1. How to use scopes.
2. What are Private/Public members
3. Instead of method "CreateIt", you could use static method create. Learn it.
4. Learn how to use global blocks.
5. Instead of KaTTaNa's system, use some struct attachment system.
6. More descriptive names for variables and functions
7. Learn to intend lines.
 

Trollvottel

never aging title
Reaction score
262
Thanks for replies, fixed it a bit, i hope it is better now could you make an example for other attachment systems?
and i indented the code, whats wrong with it
 
Reaction score
456
Example of ABC:

JASS:
scope UltimateDestruction
    private struct UDdata
        unit caster
        timer myTimer = CreateTimer()
        integer ticks = 5
        
        static method create takes unit caster returns UDdata
            local UDdata dat = UDdata.allocate()
            set dat.caster = caster
            return dat
        endmethod
        
        method onDestroy takes nothing returns nothing
            call ClearTimerStructA(.myTimer)        
        endmethod
    endstruct
    
    private function UltimateDestructionHandler_actions takes nothing returns nothing
        local timer exprTimer = GetExpiredTimer()
        local UDdata dat = GetTimerStructA(exprTimer)
        
        if (dat.ticks &lt;= 0) then
            call dat.destroy()
        else
            set dat.ticks = dat.ticks - 1
            call BJDebugMsg(GetUnitName(dat.caster))
        endif
    endfunction
    
    private function UltimateDestruction_conditions takes nothing returns boolean
        return GetSpellAbilityId() == &#039;Ulti&#039;
    endfunction    
    
    private function UltimateDestruction_actions takes nothing returns nothing
        local UDdata dat = UDdata.create(GetTriggerUnit())
        call SetTimerStructA(dat.myTimer, dat)
        call TimerStart(dat.myTimer, 0.05, true, function UltimateDestructionHandler_actions)
    endfunction    
    
    function InitTrig_Ultimate_Destruction takes nothing returns nothing
        local trigger trig = CreateTrigger()
        call TriggerRegisterAnyUnitEventBJ(trig, EVENT_PLAYER_UNIT_SPELL_EFFECT)
        call TriggerAddAction(trig, function UltimateDestruction_actions)
        call TriggerAddCondition(trig, Condition(function UltimateDestruction_conditions))
        set trig = null
    endfunction
endscope


SetTimerStructA/B/C(timer, struct) //Attaches A structure to timer.
GetTimerStructA/B/C(timer) //Returns the A structure of the timer.
ClearTimerStructA/B/C(timer) //Clears the A structure of the timer.

Read the instructions for more info.
 

Trollvottel

never aging title
Reaction score
262
yes i posted it in the wrong section but noticed it too late. if a mod would move it.... :)
 

Hatebreeder

So many apples
Reaction score
381
I Looooooooooove this Spell <3<3<3
So many sexy Lightning effects ^^
Some Mod, APPROVE this !!
Definatly a +Rep from me ^^
 

Sim

Forum Administrator
Staff member
Reaction score
534
Neat idea.

Problem is, there is way too much pointless lightning. The wheel popping on units is a bit... off. :) You should only make a small electrifying effect on any unit hit. Also, units don't always get hit by the 3 pillars of lightning. It "hits" them but there is no damage done nor any wheel popping out.
 

Sim

Forum Administrator
Staff member
Reaction score
534
There is still an excess of lightning. You can't see anything while walking except blue lightning bolts popping everywhere!
 

Sim

Forum Administrator
Staff member
Reaction score
534
That is far better! :)

I suggest you update your screenshots as well.
 

irgan

New Member
Reaction score
3
im having trouble with implimenting this into my map. in the syntax checker it says there's something wrong with every line that deals with some "Handle". i.e.
Code:
        local lightning l= GetHandleLightning(t , "light")

or
Code:
        local unit u= GetHandleUnit(t , "u")

or
Code:
                    call SetHandleHandle(GetTriggeringTrigger() , "light" , lz[int])
why is that?
 

irgan

New Member
Reaction score
3
im using NewJassGenPack v. 1.5 and yes i thought i followed the instructions correctly.
 
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

      Staff online

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top