HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Swirls

02-13-2007, 01:03 AM#1
Joker
How would you move to make a swirl like this? I havent learned much geometry things yet.
02-13-2007, 01:08 AM#2
Ammorth
A circle with an increasing/decreasing radius. The lazy way is to use a polar offset and increase the angle and distance for each iteration.
02-13-2007, 01:27 AM#3
Vexorian
Kinda, just make the angle increment (1/currentradius)*SomeSpeedValue you need another speed value for radius increase.
02-14-2007, 12:16 AM#4
Joker
Ok, i just confused myself even more trying to attempt that. How would you make a circle..
02-14-2007, 12:29 AM#5
Ammorth
All you do is use the polar offset function and increase the angle every time.
02-14-2007, 12:32 AM#6
Joker
what if i dont use the polar offset?
02-14-2007, 01:26 AM#7
Ammorth
Then use that method instead of asking for help?
02-14-2007, 09:54 AM#8
RaptorTeak
Anyway I don't think it's possible without using polar offset, and whenever it is, you'll crush your head before find how to.

So just use a loop incrementing the angle with a polar offset, best and easiest way.
02-14-2007, 12:04 PM#9
Vexorian
Sure it is possible.

But with the inherent Jass (and therefore GUI) slowness, optimizing math doesn't pay as much as it pays in real life.
02-15-2007, 09:41 PM#10
Joker
Collapse JASS:
//************************************************************************//
//           Constant Function (acts like global variables)               //
//************************************************************************//

constant function Trig_Rotating_Knives_AbilityId takes nothing returns integer
    return 'A006'
endfunction

constant function Trig_Rotating_Knives_KnifeId takes nothing returns integer
    return 'e001'
endfunction

constant function Trig_Rotating_Knives_KnifeAoE takes nothing returns real
    return 20.
endfunction


//************************************************************************//
//                        Spell Functions                                 //
//************************************************************************//

function Trig_Rotating_Knives_Conditions takes nothing returns boolean
    return GetSpellAbilityId() == 'A006'
endfunction

function Trig_Rotating_Knives_Actions_Effect_Condition takes nothing returns boolean
    return GetUnitState( GetFilterUnit(), UNIT_STATE_LIFE ) > 1
endfunction

function Trig_Rotating_Knives_Actions_Effect_Core takes timer t returns nothing
    local unit caster = GetHandleUnit( t, "caster" )
    local unit k1 = GetHandleUnit( t, "k1" )
    local unit k2 = GetHandleUnit( t, "k2" )
    local integer lvl = GetUnitAbilityLevel( caster, Trig_Rotating_Knives_AbilityId() )
    local real facing = GetUnitFacing( caster )
    local real kx1 = GetUnitX(k1)
    local real ky1 = GetUnitY(k1)
    local real kx2 = GetUnitX(k2)
    local real ky2 = GetUnitY(k2)
    local real x1 = kx1 + 5 * Cos(facing * bj_DEGTORAD)
    local real y1 = ky1 + 5 * Sin(facing * bj_DEGTORAD)
    local real x2 = kx2 + 5 * Cos(facing * bj_DEGTORAD)
    local real y2 = ky2 + 5 * Sin(facing * bj_DEGTORAD)
    local group g1 = CreateGroup()
    local group g2 = CreateGroup()
    local unit f1
    local unit f2
    local boolexpr filter = Condition( function Trig_Rotating_Knives_Actions_Effect_Condition )
        
    call GroupAddUnit( g1 , null )
    call GroupAddUnit( g2 , null )
    call GroupClear( g1 )
    call GroupClear( g2 )
                       
    if GetHandleInt( t, "counter" ) <  125 * lvl then
        call SetUnitPosition( k1, x1, y1 )
        call SetUnitPosition( k2, x2, y2 )
        
        call GroupEnumUnitsInRange( g1, kx1, ky1, Trig_Rotating_Knives_KnifeAoE(), filter )
        call GroupEnumUnitsInRange( g2, kx2, ky2, Trig_Rotating_Knives_KnifeAoE(), filter )
        
        loop
            set f1 = FirstOfGroup( g1 )
            set f2 = FirstOfGroup( g2 )
            exitwhen f1 == null or f2 == null
            call UnitDamageTarget( k1, f1, lvl * 10, false, true, ATTACK_TYPE_MELEE, DAMAGE_TYPE_NORMAL, WEAPON_TYPE_WHOKNOWS )
            call UnitDamageTarget( k2, f2, lvl * 10, false, true, ATTACK_TYPE_MELEE, DAMAGE_TYPE_NORMAL, WEAPON_TYPE_WHOKNOWS )
            call DestroyEffect( AddSpecialEffect( "Abilities\\Spells\\Other\\Stampede\\StampedeMissileDeath.mdl", kx1, ky1 ) )
            call DestroyEffect( AddSpecialEffect( "Abilities\\Spells\\Other\\Stampede\\StampedeMissileDeath.mdl", kx2, ky2 ) )
        endloop
    else
        call PauseTimer( t )
        call DestroyTimer( t )
        call FlushHandleLocals( t )
    endif
    
    call DestroyBoolExpr( filter )
    call DestroyGroup( g1 )
    call DestroyGroup( g2 ) 
    set caster = null
    set k1 = null
    set k2 = null
    set f1 = null
    set f2 = null
endfunction
        

function Trig_Rotating_Knives_Actions_Effect takes nothing returns nothing
    call Trig_Rotating_Knives_Actions_Effect_Core( GetExpiredTimer() )
endfunction

function Trig_Rotating_Knives_Actions_Core takes timer t returns nothing
    local unit caster = GetSpellAbilityUnit()
    local unit knife1 = CreateUnit( GetOwningPlayer(caster), Trig_Rotating_Knives_KnifeId(), GetUnitX(caster) - 50, GetUnitY(caster), GetUnitFacing(caster) )
    local unit knife2 = CreateUnit( GetOwningPlayer(caster), Trig_Rotating_Knives_KnifeId(), GetUnitX(caster) + 50, GetUnitY(caster), GetUnitFacing(caster) - 180 )

    call SetHandleHandle( t, "caster", caster )
    call SetHandleHandle( t, "k1", knife1 )
    call SetHandleHandle( t, "k2", knife2 )
    call SetHandleInt( t, "counter", 0 )
    call TimerStart( t, 0.03, true, function Trig_Rotating_Knives_Actions_Effect )
endfunction

function Trig_Rotating_Knives_Actions takes nothing returns nothing
    call Trig_Rotating_Knives_Actions_Core( CreateTimer() )
endfunction

//===========================================================================
function InitTrig_Rotating_Knives takes nothing returns nothing
    set gg_trg_Rotating_Knives = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_Rotating_Knives, EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddCondition( gg_trg_Rotating_Knives, Condition( function Trig_Rotating_Knives_Conditions ) )
    call TriggerAddAction( gg_trg_Rotating_Knives, function Trig_Rotating_Knives_Actions )
    call Preload( "Abilities\\Spells\\Other\\Stampede\\StampedeMissileDeath.mdl" )
endfunction

I cant seem to get the circle thing right...how can i fix this? Also, the unit group doesnt work