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.

      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