HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Jumping to Location is not working

05-16-2009, 03:07 PM#1
wraithseeker
Collapse JASS:
  elseif not .ToTarget and  .PointX != 0. and .PointY != 0. then
            if SquareRoot((.PointX - x) * (.PointX - x) + (.PointY - y) * (.PointY - y)) <= 100 then   
                if .OnStop.exists then
                    call .OnStop.execute()
                endif
                call .destroy()
                set .Count = .Count - 1
                set .Entries[id] = .Entries[id] - 1
                if .Count > 0 then
                    set .D[i]= .D[.Count]
                set i = i - 1 
            else 
                call PauseTimer(.Timer) 
            endif
        endif

x and y is calculated above this function.

And for the child struct

Collapse JASS:
scope Tsmash initializer Init

private struct data extends Knock

static method create takes nothing returns data
    local data d
    local unit u = GetTriggerUnit()
    local real x = GetUnitX(u)
    local real y = GetUnitY(u)
    local location L = GetSpellTargetLoc()
    local real lx = GetLocationX(L)
    local real ly = GetLocationY(L)
    local real angle = Atan2(ly-y,lx-x)
    set d = data.allocate(u,u,angle,600,6)
    set d.fly = true
    set d.Move = true
    set d.PointX = lx
    set d.PointY = ly
    set u = null
    return d
endmethod

method OnStop takes nothing returns nothing
    local unit dummy 
    local integer i = 0
    loop
        exitwhen i > 5
        call TriggerSleepAction(0.1)
        set dummy = CreateUnit(GetOwningPlayer(.target),'hfoo',GetUnitX(.target),GetUnitY(.target),0)
        call UnitAddAbility(dummy,'A002')
        call IssueImmediateOrder(dummy,"thunderclap")
        call UnitApplyTimedLife(dummy,'BTLF',1)
        set i = i + 1
    endloop
    set dummy = null
endmethod
endstruct

globals
    private constant integer SPELL = 'A000'
endglobals

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

private function Actions takes nothing returns nothing
    local data d = data.create()
endfunction

//===========================================================================
private function Init takes nothing returns nothing
    local trigger t = CreateTrigger()
    call TriggerRegisterAnyUnitEventBJ( t, EVENT_PLAYER_UNIT_SPELL_EFFECT)
    call TriggerAddAction(t, function Actions)
    call TriggerAddCondition(t,Condition(function Conditions))
endfunction

endscope


Basically right now, the effect is created and the unit isn't flying.
05-16-2009, 04:29 PM#2
Ammorth
I would say that the unit isn't moving due to the fact you are not changing its location. You may be in other parts of the script, but with the snippets you provided, it is impossible to tell.
05-16-2009, 04:35 PM#3
wraithseeker
Collapse JASS:
 loop
        exitwhen i >= .Count
        set this = .D[i]
        set id = GetUnitId(.target)
        set x = GetUnitX(.target)
        set y = GetUnitY(.target)

I am moving the unit in deeper part of the function which works well. If i remove those lines the system works perfectly.