Efficient Coding?

BlackRose

Forum User
Reaction score
239
1. I'm aware of all the PolarProjectionBJ's and AngleBetweenPoints, DistanceBetweenPoints... that I maybe use... but please don't say anything.... because I don't know how to do that maths for it....

2. Is this a good way to code a spiralish spell? I use ABC v6.0 and it's the only way I know how to attach a struct to timer thingy... it's for my Arena :)

3. Spoiler is not working?
[del]4. I just realised.... it's not MUI is it? I spammed it like 10 instances, and it stuffed up? Is it because of the unit arrays?[/del]
4. If using array... is it 8192 / ARRAY NUMBER..... so is it 8192 / 10 = 819.2 instances for my spell?

JASS:
scope EnergyVortex initializer Init

    // Spiral of green or yellow energy... Similar to Light Burst
    // Depletes enemy mana, but not yet completed. Effect is.
    // But drain is not.

    globals
        private constant integer SpellID = 'A006'
        private constant integer DumID = 'h001'
        
        private constant real AOE = 400.00
        private constant real Speed = 30.00
        
        private constant real xAngSpeed = 12.00
        private constant real xAOE = 250.00
    endglobals
    
    private struct EV
        unit array Dummy[10]
        timer t
        unit Cast
        player CO
        
        real Height
        real Dist
        
        real TimeOut
        private method onDestroy takes nothing returns nothing
            local integer i = 0
            call DestroyTimer( .t )
            loop
                exitwhen i == 8
                call KillUnit( .Dummy[ i ] )
                set i = i + 1
            endloop
            call ClearTimerStructA( .t )
        endmethod
    endstruct
    
    private struct SD
        unit array SDum[10]
        timer t
        real Height
        real Dist
        
        location CLoc
        real array Ang[10]
        real TickTock
        private method onDestroy takes nothing returns nothing
            local integer i = 0
            call DestroyTimer( .t )
            loop
                exitwhen i == 8
                call KillUnit( .SDum[ i ] )
                set i = i + 1
            endloop
            call ClearTimerStructB( .t )
        endmethod
    endstruct
        
    
    private function Cond takes nothing returns boolean
        return GetSpellAbilityId() == SpellID
    endfunction
    
    private function Callback takes nothing returns nothing
        local timer t = GetExpiredTimer()
        local location NewLoc
        local location DumLoc
        local integer i = 0
        local real Angle = 0.00
        local EV d = GetTimerStructA( t )
                        
        set d.TimeOut = d.TimeOut + 0.04
        
        if ( d.Dist >= AOE ) then
        set d.Height = d.Height + 25.00
            loop
                exitwhen i == 8
                call SetUnitFlyHeight( d.Dummy<i>, d.Height, 1000.00 )
                set i = i + 1
            endloop
        else
        // ELSE ACTIONS
        set d.Dist = d.Dist + 30.00
            loop
                exitwhen i == 8
                set DumLoc = GetUnitLoc( d.Dummy<i> )
                set NewLoc = PolarProjectionBJ( DumLoc, Speed, Angle )
                call SetUnitPositionLoc( d.Dummy<i>, NewLoc )
                
                set Angle = Angle + 45
                set i = i + 1
                
                call RemoveLocation( DumLoc )
                call RemoveLocation( NewLoc )
            endloop
        endif
        
        if ( d.TimeOut == 2 ) then
            call d.destroy()
        endif
        
        set NewLoc = null
        set DumLoc = null
    endfunction
    
    private function SCallback takes nothing returns nothing
        local timer t = GetExpiredTimer()
        local integer i = 0
        local integer II = 0
        local location DumLoc
        local location NewLoc
        local real Angle = 0.00
        local SD x = GetTimerStructB( t )
        
        // Continous SOUND!
        call IssueImmediateOrder( x.SDum<i>, &quot;roar&quot; )
        
        // Ticker and Height upper.
        set x.TickTock = x.TickTock + 0.04
        set x.Height = x.Height + 16.00
        
        // Constant height increase.
        loop
            exitwhen II == 8
            call SetUnitFlyHeight( x.SDum[II], x.Height, 1000.00 )
            set II = II + 1
        endloop
            // If the distance travelled becomes 200.
            // We start spinning.
            if ( x.Dist &gt;= xAOE ) then
                loop
                    exitwhen i == 8
                        set x.Ang<i> = x.Ang<i> + xAngSpeed
                        set DumLoc = GetUnitLoc( x.SDum[ i ] )
                        set NewLoc = PolarProjectionBJ( x.CLoc, 250.00, x.Ang<i> )
                        call SetUnitPositionLoc( x.SDum<i>, NewLoc )
                        set i = i + 1
                endloop   
            // We move the units here.
            else
                set x.Dist = x.Dist + 20
                    loop
                        exitwhen i == 8
                            set DumLoc = GetUnitLoc( x.SDum[ i ] )
                            set NewLoc = PolarProjectionBJ( DumLoc, 20.00, Angle )
                            call SetUnitPositionLoc( x.SDum<i>, NewLoc )

                            set Angle = Angle + 45
                            set i = i + 1
                            call RemoveLocation( DumLoc )
                            call RemoveLocation( NewLoc )
                    endloop    
            endif
        if ( x.TickTock == 2 ) then
            call x.destroy()
        endif
        
        set NewLoc = null
        set DumLoc = null
            
    endfunction
    
    private function Main takes nothing returns nothing
        local EV d = EV.create()
        local SD x = SD.create()
        local real X
        local real Y
        local real Angle = 0
        local integer i = 0
        
        set d.t = CreateTimer()
        set d.Height = 100.00
        set d.TimeOut = 0.00
        
        set d.Dist = 0.00
        
        set d.Cast = GetTriggerUnit()
        set d.CO = GetOwningPlayer( d.Cast )
        
        set x.CLoc = GetUnitLoc( d.Cast )

        set x.t = CreateTimer()
        set x.TickTock = 0.00
        set x.Dist = 0.00
        set x.Height = 100.00
        set x.Ang[ x ] = 0.00
        
        set X = GetUnitX( d.Cast )
        set Y = GetUnitY( d.Cast )
        
            loop    
                exitwhen i == 8
                set Angle = Angle + 45
                set d.Dummy<i> = CreateUnit( d.CO, DumID, X, Y, Angle )
                set i = i + 1
            endloop
            set i = 0
            set Angle = 0
            
            loop    
                exitwhen i == 8
                set Angle = Angle + 45
                set x.SDum<i> = CreateUnit( d.CO, DumID, X, Y, Angle )
                set x.Ang<i> = Angle
                set i = i + 1
            endloop
            
        call TimerStart( x.t, 0.04, true, function SCallback )
        call SetTimerStructB(x.t, d)
            
        call TimerStart( d.t, 0.04, true, function Callback )
        call SetTimerStructA(d.t, d)
    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 Cond ) )
        call TriggerAddAction( t, function Main )
        set t = null
    endfunction
endscope</i></i></i></i></i></i></i></i></i></i></i></i>
 

WolfieeifloW

WEHZ Helper
Reaction score
372
  1. All those aren't really frowned upon.
  2. N/A
  3. AceHart says "It's working exactly as it's supposed to" although what's the point in making a grey box :p .
  4. 8192 isn't safe; I'm pretty sure 8190 is the safest number to go up to in an array.
 

BlackRose

Forum User
Reaction score
239
1. Then tell me the maths stuff.....? I don't get the natives.
2. You are N/A.
3. No COMMENT.
4. Well, is mine safe then?
 

WolfieeifloW

WEHZ Helper
Reaction score
372
  1. I said they aren't frowned upon, meaning you can use them :p .
  2. :eek: , meanie!
  3. Awesome.
  4. I don't really know structs but just don't go beyond 8190 and it's safe.
 
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