• 🏆 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!

Unit movement, cyrcle

Status
Not open for further replies.
Level 13
Joined
Mar 16, 2008
Messages
941
Hi, I have a problem with one of my Spells :>


EDIT: Works now, should wait a bit until I post, after a time I find all bugs myself ...


Oh my god, I wish to die -.- Found the (simple...) mistakes, changed the code for some test but forgot to change it back, but the spell isn't finished yet (or at least the animation isn't):

The units start flying out, but in the moment "Move_Out" gives the units to "Unit_Move" all units start at the same location and start flying, that looks weird, what can I do against it?

JASS:
function Cryptic_Ulti_SpellId takes nothing returns integer
    return 'A002'            //The spells rawcode
endfunction

function Cryptic_Ulti_Missle takes nothing returns integer
    return 'h001'            //The units rawcode
endfunction


function Cryptic_Ulti_Radius takes nothing returns real
    return 300.0             //The radius of the tornado
endfunction

function Cryptic_Ulti_Unit_Height takes nothing returns real
    return 100.0             //Flyingheight difference of the units
endfunction

function Cryptic_Ulti_Unit_Number takes nothing returns integer
    return 8               //Number of units in a cyrcle
endfunction

function Cryptic_Ulti_Rows takes nothing returns integer
    return 5               //Number of rows up
endfunction

function Cryptic_Ulti_Duration takes nothing returns real
    return 20.0              //Duration of the spell
endfunction

function Cryptic_Ulti_Cyrcle_Duration takes nothing returns real
    return 1.0               //Duration for one cyrcle
endfunction

function Cryptic_Ulti_Cyrcle_Steps takes nothing returns real
    return Cryptic_Ulti_Cyrcle_Duration()/0.035
endfunction


function Cryptic_Ulti_Conditions takes nothing returns boolean
    return GetSpellAbilityId() == Cryptic_Ulti_SpellId()
endfunction

function Cryptic_Ulti_Unit_Move takes nothing returns nothing
    local timer tmove = GetExpiredTimer()
    
    local unit caster = GetHandleUnit(tmove, "caster")
    local unit missle = GetHandleUnit(tmove, "missle")
    
    local integer moveindex = GetHandleInt(tmove, "moveindex") + 1
    
    local real random = GetHandleReal(tmove, "random")
    local real distance = Cryptic_Ulti_Radius()
    local real facing = (GetUnitFacing(missle) - 360.0/Cryptic_Ulti_Cyrcle_Steps())*random
    local real angle = (360.0 /Cryptic_Ulti_Cyrcle_Steps() * moveindex + GetHandleReal(tmove, "angle"))*random
    local real mx = GetUnitX(caster) + distance * Cos(angle * bj_DEGTORAD)
    local real my = GetUnitY(caster) + distance * Sin(angle * bj_DEGTORAD)
    
    call SetUnitX(missle, mx)
    call SetUnitY(missle, my)
    call SetUnitFacing(missle, facing)
    
    if (I2R(moveindex) >= 3500) then
        call PauseTimer(tmove)
        call FlushHandleLocals(tmove)
        call DestroyTimer(tmove)
    else
        call SetHandleInt(tmove, "moveindex", moveindex)
    endif
    
    if (GetUnitState(caster, UNIT_STATE_LIFE) <= 0) then
        call PauseTimer(tmove)
        call FlushHandleLocals(tmove)
        call DestroyTimer(tmove)
    endif
    
    if (moveindex == 360) then
        set moveindex = 0
    endif
    
    set tmove = null
    set caster = null
    set missle = null
endfunction

function Cryptic_Ulti_Move_Up takes nothing returns nothing
    local timer tout = GetExpiredTimer()
    
    local unit caster = GetHandleUnit(tout, "caster")
    local unit missle = GetHandleUnit(tout, "missle")
    local real height = GetHandleReal(tout, "height")
    local integer loopindex = GetHandleInt(tout, "loopindex") + 1
    local real tempheight = (height/Cryptic_Ulti_Cyrcle_Steps()) * loopindex
    
    local boolean amrf = GetUnitAbilityLevel(missle, 'Amrf') <= 0
    
    if (amrf) then
        call UnitAddAbility(missle, 'Amrf')
    endif
    call SetUnitFlyHeight(missle, tempheight, 0.0)
    if (amrf) then
        call UnitRemoveAbility(missle, 'Amrf' )
    endif
    
    if (I2R(loopindex) >= Cryptic_Ulti_Cyrcle_Steps()) then
        call PauseTimer(tout)
        call FlushHandleLocals(tout)
        call DestroyTimer(tout)
        
        
    else
        call SetHandleInt(tout, "loopindex", loopindex)
    endif   
    
    if (GetUnitState(caster, UNIT_STATE_LIFE) <= 0) then
        call PauseTimer(tout)
        call FlushHandleLocals(tout)
        call DestroyTimer(tout)
    endif
    
    set tout = null
    set caster = null
    set missle = null  
endfunction

function Cryptic_Ulti_Move_Out takes nothing returns nothing
    local timer tout = GetExpiredTimer()
    local timer tmove = null
    
    local unit caster = GetHandleUnit(tout, "caster")
    local unit missle = GetHandleUnit(tout, "missle")
    
    local integer moveindex = GetHandleInt(tout, "moveindex") + 1
    
    local real random = GetHandleReal(tout, "random")
    local real distance = (Cryptic_Ulti_Radius()/Cryptic_Ulti_Cyrcle_Steps())*moveindex
    local real facing = (GetUnitFacing(missle) - 360.0/Cryptic_Ulti_Cyrcle_Steps())*random
    local real angle = (360.0 /Cryptic_Ulti_Cyrcle_Steps() * moveindex + GetHandleReal(tout, "angle"))*random
    local real mx = GetUnitX(caster) + distance * Cos(angle * bj_DEGTORAD)
    local real my = GetUnitY(caster) + distance * Sin(angle * bj_DEGTORAD)
    
    call SetUnitX(missle, mx)
    call SetUnitY(missle, my)
    call SetUnitFacing(missle, facing)
    
    if (I2R(moveindex) >= Cryptic_Ulti_Cyrcle_Steps()) then
        call PauseTimer(tout)
        call FlushHandleLocals(tout)
        call DestroyTimer(tout)
        
        set tmove = CreateTimer()
        call SetHandleInt(tmove, "moveindex", moveindex)
        call SetHandleHandle(tmove, "missle", missle)
        call SetHandleReal(tmove, "random", random)
        call SetHandleHandle(tmove, "caster", caster)
        call TimerStart(tmove, 0.035, true, function Cryptic_Ulti_Unit_Move)
    else
        call SetHandleInt(tout, "moveindex", moveindex)
    endif
    
    if (GetUnitState(caster, UNIT_STATE_LIFE) <= 0) then
        call PauseTimer(tout)
        call FlushHandleLocals(tout)
        call DestroyTimer(tout)
    endif
    
    set tout = null
    set caster = null
    set missle = null
endfunction

function Cryptic_Ulti_Actions takes nothing returns nothing
    local timer tout = null
    
    local unit caster = GetSpellAbilityUnit()
    local unit missle = null
    
    local player owner = GetOwningPlayer(caster)
    
    local real cx = GetUnitX(caster)
    local real cy = GetUnitY(caster)
    local real angle = 0.0
    local real angleadd = 360.0/I2R(Cryptic_Ulti_Unit_Number())
    local real height = 0.0
    local real baseheight = Cryptic_Ulti_Unit_Height()
    
    local integer missleid = Cryptic_Ulti_Missle()
    local integer loopindex = 0
    local integer loopindexend = Cryptic_Ulti_Unit_Number()
    local integer flyindex = 0
    local integer flyindexend = Cryptic_Ulti_Rows()
    
    loop
        exitwhen flyindex >= flyindexend
        set loopindex = 0
        set height = baseheight * flyindex
        loop
            exitwhen loopindex >= loopindexend
            
            if (GetUnitState(caster, UNIT_STATE_LIFE) >= 0) then
                set tout = CreateTimer()
                set missle = CreateUnit(owner, missleid, cx, cy, angle)
                call SetHandleReal(tout, "random", GetRandomReal(1.0, 1.4))
                call SetHandleReal(tout, "angle", angle)
                call SetHandleReal(tout, "height", height)
                call SetHandleHandle(tout, "missle", missle)
                call SetHandleHandle(tout, "caster", caster)
                call TimerStart(tout, 0.035, true, function Cryptic_Ulti_Move_Out)
                set tout = null
                
                if (height > 0.0) then
                    set tout = CreateTimer()
                    call SetHandleReal(tout, "height", height)
                    call SetHandleHandle(tout, "missle", missle)
                    call SetHandleHandle(tout, "caster", caster)
                    call TimerStart(tout, 0.035, true, function Cryptic_Ulti_Move_Up) 
                    set tout = null
                endif
                
                set missle = null                
            endif
            set angle = angle + angleadd
            set loopindex = loopindex + 1
        endloop
        set flyindex = flyindex + 1
    endloop
    
    set caster = null
endfunction

//===========================================================================
function InitTrig_Cryptic_Ulti takes nothing returns nothing
    set gg_trg_Cryptic_Ulti = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_Cryptic_Ulti, EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddCondition( gg_trg_Cryptic_Ulti, Condition( function Cryptic_Ulti_Conditions ) )
    call TriggerAddAction( gg_trg_Cryptic_Ulti, function Cryptic_Ulti_Actions )
endfunction


Greets, Justify
 
Last edited:
Status
Not open for further replies.
Top