help with spiral D:

Laiev

Hey Listen!!
Reaction score
188
based on spell (rewrited everything) at wc3c by dextreme, the sacred circlet...

my friend want it to create a spiral and after 50% of channeling time it start a closing spiral...

basically you create a spiral... when spiral reach 5 second of channeling, get the last point of that spiral and start a new spiral closing the spiral....

here the trigger and if need, i can post an image

JASS:
scope SacredCirclet initializer init //requires TimerUtils


native UnitAlive takes unit id returns boolean //remove this if you already got it

    globals
        private constant integer    ABILITY_ID        = 'A000'                            //Ability ID
        private constant integer    DAMAGE_PER_LEVEL  = 100                               //Damage dealt per level
        private constant real       STRIKE_INTERVAL   = .04                               //Interval per strike
        private constant real       STRIKE_PER_LEVEL  = .0                                //Interval per level
        private constant real       DAMAGE_RADIUS     = 175.                              //Damage radius
        private constant real       DAMAGE_RADIUS_LVL = .0                                //Damage radius per lvl
        private constant string     EFFECT_ART        = "war3mapImported\\HolyStrike.mdx" //Model of effect
        private constant attacktype ATTACK_TYPE       = ATTACK_TYPE_CHAOS                 //Type of attack
        private constant damagetype DAMAGE_TYPE       = DAMAGE_TYPE_FIRE                  //Type of damage
        private constant weapontype WEAPON_TYPE       = null                              //Type of weapon
    endglobals

    private struct data
        unit     u
        timer    t
        integer  i     = 0
        real     x     = 0.
        real     y     = 0.
        real     cx    = 0.
        real     cy    = 0.
        real     angle = 0.
        real     r     = 0.
        unit     ta
        player   p
        group    g
        integer  count = 0
        
        method onDestroy takes nothing returns nothing
            call ReleaseTimer(.t)
            
            set .ta = null
            set .g = null
            set .p = null
            set .u = null
        endmethod
    endstruct

    private function CheckMagicImmune takes unit targ returns boolean
        return not IsUnitType(targ, UNIT_TYPE_MAGIC_IMMUNE)
    endfunction

    private function CheckEnemy takes unit targ, player p returns boolean
        return IsUnitEnemy(targ, p)
    endfunction

    private function Acts takes nothing returns nothing
        local data d = GetTimerData(GetExpiredTimer())
        
        set d.cx = GetUnitX(d.u)
        set d.cy = GetUnitY(d.u)
        
        set d.count = d.count + 1
        
        if d.count >= 50 then
            set d.x = d.cx + (50 - d.r * 5) * Cos(d.angle * bj_DEGTORAD) //~~~~~~~~~~~
            set d.y = d.cy + (50 - d.r * 5) * Sin(d.angle * bj_DEGTORAD) //~~~~~~~~~~~
        else
            set d.x = d.cx + (50 + d.r * 10) * Cos(d.angle * bj_DEGTORAD)
            set d.y = d.cy + (50 + d.r * 10) * Sin(d.angle * bj_DEGTORAD)
        endif
        
        if GetUnitCurrentOrder(d.u) != 852183 then
            call d.destroy()
            return
        endif

        set d.g = CreateGroup()
        set d.p = GetOwningPlayer(d.u)
        
        call DestroyEffect(AddSpecialEffect(EFFECT_ART, d.x, d.y))
        call GroupEnumUnitsInRange(d.g, d.x, d.y, DAMAGE_RADIUS + DAMAGE_RADIUS_LVL * d.i, null)
        
        loop
            set d.ta = FirstOfGroup(d.g)
            exitwhen d.ta == null

            if d.ta != d.u and CheckEnemy(d.ta, d.p) and CheckMagicImmune(d.ta) and UnitAlive(d.u) then
                call UnitDamageTarget(d.u, d.ta, DAMAGE_PER_LEVEL * d.i, true, false, ATTACK_TYPE, DAMAGE_TYPE, WEAPON_TYPE)
            endif
            
            call GroupRemoveUnit(d.g, d.ta)
            set d.ta = null
        endloop
        
        set d.angle = d.angle + 24. - d.r / 6.
        set d.r = d.r + 1.
        
        call DestroyGroup(d.g)
    endfunction

    private function Actions takes nothing returns nothing
        local data d = data.create()
        set d.t = NewTimer()
        set d.u = GetTriggerUnit()
        set d.i = GetUnitAbilityLevel(d.u, ABILITY_ID)

        call SetTimerData(d.t, d)
        call TimerStart(d.t, STRIKE_INTERVAL - STRIKE_PER_LEVEL * d.i, true, function Acts)
    endfunction

    private function Conditions takes nothing returns boolean
        return GetSpellAbilityId() == ABILITY_ID
    endfunction

    private function init takes nothing returns nothing
        local trigger t = CreateTrigger()
    
        call TriggerRegisterAnyUnitEventBJ(t, EVENT_PLAYER_UNIT_SPELL_EFFECT)
        call TriggerAddCondition(t, Condition(function Conditions))
        call TriggerAddAction(t, function Actions)
        call Preload(EFFECT_ART)
    endfunction
    
endscope


any help is welcome :thup:
 

Bribe

vJass errors are legion
Reaction score
67
I've cleaned it up:

JASS:
library SacredCirclet initializer init requires TimerUtils
    
// Excess natives are auto-deleted by JASSHelper and don&#039;t need to be manually deleted <img src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" class="smilie smilie--sprite smilie--sprite1" alt=":)" title="Smile    :)" loading="lazy" data-shortname=":)" />
native UnitAlive takes unit id returns boolean
    
    globals
        private constant integer    ABILITY_ID        = &#039;A000&#039;                            //some of your descriptions here were just straight copies of the variable name??
                                                                                          //I like to think people can figure that out <img src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" class="smilie smilie--sprite smilie--sprite7" alt=":p" title="Stick Out Tongue    :p" loading="lazy" data-shortname=":p" />
        private constant real       DAMAGE_PER_LEVEL  = 100.
                        
        //Using 0 before decimal is a common practice and is therefore helpful for OCD people.
                        
        private constant real       STRIKE_INTERVAL   = 0.04                              //Interval per strike
        private constant real       STRIKE_PER_LEVEL  = 0.                                //Interval per level
        private constant real       DAMAGE_RADIUS     = 175.
        private constant real       DAMAGE_RADIUS_LVL = 0.                                //Damage radius per lvl
        private constant string     EFFECT_ART        = &quot;war3mapImported\\HolyStrike.mdx&quot; //Model of effect
        private constant attacktype ATTACK_TYPE       = ATTACK_TYPE_CHAOS
        private constant damagetype DAMAGE_TYPE       = DAMAGE_TYPE_FIRE
    endglobals
    
    private struct data
        static group    filtGroup = CreateGroup()   // Group destroy is a thing of the past.
        static thistype d                           // Global integers are easier to work with so you can use them in filters.
        static unit     ta                          // Doesn&#039;t need to be an array.
    
        unit     u
        timer    t
        integer  i     = 0
        real     x     = 0.
        real     y     = 0.
        real     cx    = 0.
        real     cy    = 0.
        real     angle = 0.
        real     r     = 0.
        player   p
        integer  count = 0
        
        // you don&#039;t need an onDestroy method for the way you have this set up.
    endstruct
    
    // Magic immune shouldn&#039;t be a filter you need to waste CPU on -- just exclude magic immune from the map as it is boring as hell.
    
    private function GroupFilter takes nothing returns boolean
        // Group Filters are faster than inlined loops
        set .ta = GetFilterUnit()
        if IsUnitEnemy(.ta, d.p) and UnitAlive(.ta) then
            call UnitDamageTarget(d.u, .ta, DAMAGE_PER_LEVEL * d.i, true, false, ATTACK_TYPE, DAMAGE_TYPE, WEAPON_TYPE_WHOKNOWS)
        endif
        return false
    endfunction
    
    private function doLoop takes nothing returns nothing
        local real multiplier
        set d = GetTimerData(GetExpiredTimer())
        
        set d.cx = GetUnitX(d.u)
        set d.cy = GetUnitY(d.u)
        
        set d.count = d.count + 1
        
        if d.count &gt;= 50 then
            set multiplier = 5.
        else
            set multiplier = 10.
        endif
        set d.x = d.cx + (50. - d.r * multiplier) * Cos(d.angle) //~~~~~~~~~~~
        set d.y = d.cy + (50. - d.r * multiplier) * Sin(d.angle) //~~~~~~~~~~~
        
        if GetUnitCurrentOrder(d.u) != 852183 then
            call ReleaseTimer(d.t)
            call d.destroy()
            return
        endif
        
        call GroupEnumUnitsInRange(.filtGroup, d.x, d.y, DAMAGE_RADIUS + DAMAGE_RADIUS_LVL * d.i,Filter(function GroupFilter))
        call DestroyEffect(AddSpecialEffect(EFFECT_ART, d.x, d.y))
        
                            //   v---- I removed bj_DEGTORAD and replaced your 24. with the radian equivelant.
        set d.angle = d.angle + 0.41888 - d.r / 6.
        set d.r = d.r + 0.0174533
    endfunction
    
    private function Conditions takes nothing returns boolean
        if GetSpellAbilityId() == ABILITY_ID then
            set d   = data.create()
            set d.t = NewTimer()
            set d.u = GetTriggerUnit()
            set d.i = GetUnitAbilityLevel(d.u, ABILITY_ID)
            set d.p = GetTriggerPlayer()

            call SetTimerData(d.t, d)
            call TimerStart(d.t, STRIKE_INTERVAL - STRIKE_PER_LEVEL * d.i, true, function doLoop)
        endif
        return false
    endfunction
    
    private function init takes nothing returns nothing
        local trigger t = CreateTrigger()
    
        call TriggerRegisterAnyUnitEventBJ(t, EVENT_PLAYER_UNIT_SPELL_EFFECT)
        call TriggerAddCondition(t, Condition(function Conditions))
        call Preload(EFFECT_ART)
    endfunction
    
endlibrary
 

Laiev

Hey Listen!!
Reaction score
188
Laiev, is this spell your idea? Sorry it's abit offtopic..

no, the spell are made by daxtreme from wc3c

my friend just call me to help him to improve this (because the spell is too old and use kattana handle's) and make the spiral close with the same effect of open :p

if you wanna see what is it, change the effect to anyother and create a ability with no target (like, warstomp, thunder clap, etc)
 

Bribe

vJass errors are legion
Reaction score
67
thx for try but your code don't compile :p

For the love of Pete, man, why don't you just do it all in structs like the sensible way? This compiles:

JASS:
library SacredCirclet requires TimerUtils
    
// Excess natives are auto-deleted by JASSHelper and don&#039;t need to be manually deleted <img src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" class="smilie smilie--sprite smilie--sprite1" alt=":)" title="Smile    :)" loading="lazy" data-shortname=":)" />
native UnitAlive takes unit id returns boolean
    
    globals
        private constant integer    ABILITY_ID        = &#039;A000&#039;                            //some of your descriptions here were just straight copies of the variable name??
                                                                                          //I like to think people can figure that out <img src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" class="smilie smilie--sprite smilie--sprite7" alt=":p" title="Stick Out Tongue    :p" loading="lazy" data-shortname=":p" />
        private constant real       DAMAGE_PER_LEVEL  = 100.
                        
        //Using 0 before decimal is a common practice and is therefore helpful for OCD people.
                        
        private constant real       STRIKE_INTERVAL   = 0.04                              //Interval per strike
        private constant real       STRIKE_PER_LEVEL  = 0.                                //Interval per level
        private constant real       DAMAGE_RADIUS     = 175.
        private constant real       DAMAGE_RADIUS_LVL = 0.                                //Damage radius per lvl
        private constant string     EFFECT_ART        = &quot;war3mapImported\\HolyStrike.mdx&quot; //Model of effect
        private constant attacktype ATTACK_TYPE       = ATTACK_TYPE_CHAOS
        private constant damagetype DAMAGE_TYPE       = DAMAGE_TYPE_FIRE
    endglobals
    
    private struct data
        static group    filtGroup = CreateGroup()   // Group destroy is a thing of the past.
        static thistype d                           // Global integers are easier to work with so you can use them in filters.
        static unit     ta                          // Doesn&#039;t need to be an array.
    
        unit     u
        timer    t
        integer  i     = 0
        real     x     = 0.
        real     y     = 0.
        real     cx    = 0.
        real     cy    = 0.
        real     angle = 0.
        real     r     = 0.
        player   p
        integer  count = 0
        
        // you don&#039;t need an onDestroy method for the way you have this set up.
    
    // Magic immune shouldn&#039;t be a filter you need to waste CPU on -- just exclude magic immune from the map as it is boring as hell.
    
    static method GroupFilter takes nothing returns boolean
        // Group Filters are faster than inlined loops
        set .ta = GetFilterUnit()
        if IsUnitEnemy(.ta, d.p) and UnitAlive(.ta) then
            call UnitDamageTarget(d.u, .ta, DAMAGE_PER_LEVEL * d.i, true, false, ATTACK_TYPE, DAMAGE_TYPE, WEAPON_TYPE_WHOKNOWS)
        endif
        return false
    endmethod
    
    static method doLoop takes nothing returns nothing
        local real multiplier
        set d = GetTimerData(GetExpiredTimer())
        
        set d.cx = GetUnitX(d.u)
        set d.cy = GetUnitY(d.u)
        
        set d.count = d.count + 1
        
        if d.count &gt;= 50 then
            set multiplier = 5.
        else
            set multiplier = 10.
        endif
        set d.x = d.cx + (50. - d.r * multiplier) * Cos(d.angle) //~~~~~~~~~~~
        set d.y = d.cy + (50. - d.r * multiplier) * Sin(d.angle) //~~~~~~~~~~~
        
        if GetUnitCurrentOrder(d.u) != 852183 then
            call ReleaseTimer(d.t)
            call d.destroy()
            return
        endif
        
        call GroupEnumUnitsInRange(.filtGroup, d.x, d.y, DAMAGE_RADIUS + DAMAGE_RADIUS_LVL * d.i,Filter(function thistype.GroupFilter))
        call DestroyEffect(AddSpecialEffect(EFFECT_ART, d.x, d.y))
        
                            //   v---- I removed bj_DEGTORAD and replaced your 24. with the radian equivelant.
        set d.angle = d.angle + 0.41888 - d.r / 6.
        set d.r = d.r + 0.0174533
    endmethod
    
    static method Conditions takes nothing returns boolean
        if GetSpellAbilityId() == ABILITY_ID then
            set d   = data.create()
            set d.t = NewTimer()
            set d.u = GetTriggerUnit()
            set d.i = GetUnitAbilityLevel(d.u, ABILITY_ID)
            set d.p = GetTriggerPlayer()

            call SetTimerData(d.t, d)
            call TimerStart(d.t, STRIKE_INTERVAL - STRIKE_PER_LEVEL * d.i, true, function thistype.doLoop)
        endif
        return false
    endmethod
    
    static method onInit takes nothing returns nothing
        local trigger t = CreateTrigger()
    
        call TriggerRegisterAnyUnitEventBJ(t, EVENT_PLAYER_UNIT_SPELL_EFFECT)
        call TriggerAddCondition(t, Condition(function thistype.Conditions))
        call Preload(EFFECT_ART)
    endmethod

endstruct

endlibrary
 

Laiev

Hey Listen!!
Reaction score
188
this don't work....

i don't need to rewrite it, just want to change the angle of the spiral with closing move....
 

Bribe

vJass errors are legion
Reaction score
67
I said I cleaned it up, I didn't say I fixed it. They are optimizations I made.
 
General chit-chat
Help Users
  • No one is chatting at the moment.
  • Monovertex Monovertex:
    How are you all? :D
    +1
  • Ghan Ghan:
    Howdy
  • 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!
  • 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

      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