• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

[JASS] Inward Spiral unit movement

Status
Not open for further replies.
Level 20
Joined
Jul 14, 2011
Messages
3,213
I'm trying to make a Summing Spell where the caster selects a target point of the ability, and channels while energy balls are created and move towards the casting point following an spiral. Then i plan to make a big charge at the center that grows with each charge and do other stuff later. For the moment i'm having problem with the spiral movement.

The main trigger just creates the timer (that repeats every 1 second to create the charges) and saves the TargetPoint X and Y (locx and locy) in the charge handle. This is where movement is made but the units doesn't move for a while, then starts accelerating (some do, some others don't) OUTWARDS untill map crashes.

JASS:
function DA_LoopC takes nothing returns nothing
    local unit u = GetEnumUnit()
    local integer id = GetHandleId(u)
    local real ux = GetUnitX(u)
    local real uy = GetUnitY(u)
    local real locx = LoadReal(Hash, id, 0)
    local real locy = LoadReal(Hash, id, 1)
    local real dx = ux - locx
    local real dy = uy - locy
    local real disoff = SquareRoot(dx * dx + dy * dy)
    local real r2
    local real r3
    local real r4
    local real polx
    local real poly

    if disoff < 128 then
        call RemoveUnit(u)
    else
        set r2 = ( 1.00 - ( disoff / DA_PullDist ) )
        set r3 = bj_RADTODEG * Atan2(dy, dx) - ( r2 * DA_SpinAngle )
        set r4 = r3*bj_DEGTORAD
        set disoff = ( disoff - ( DA_PullSpeed * r2 ) )
        set polx = locx + disoff * Cos(r4)
        set poly = locy + disoff * Sin(r4)
        call SetUnitX(u, polx)
        call SetUnitY(u, poly)
    endif
    
    set u = null
endfunction

function DA_LoopB takes nothing returns nothing
    set bj_lastCreatedUnit = FirstOfGroup(DA_Vortex)
    if bj_lastCreatedUnit == null then
        call BJDebugMsg("Disabling Trigger. Group Empty")
        call DisableTrigger(gg_trg_DarkArisal_Loop)
    else
        call ForGroup(DA_Vortex, function DA_LoopC)
    endif
endfunction

//===========================================================================
function InitTrig_DarkArisal_Loop takes nothing returns nothing
    set gg_trg_DarkArisal_Loop = CreateTrigger(  )
    call TriggerRegisterTimerEvent( gg_trg_DarkArisal_Loop, 0.03, true )
    call TriggerAddAction( gg_trg_DarkArisal_Loop, function DA_LoopB )
endfunction
 

Attachments

  • Grid and DarkArisal.w3x
    104.9 KB · Views: 32
Status
Not open for further replies.
Top