• 🏆 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] Instant slide ?

Status
Not open for further replies.

Rmx

Rmx

Level 19
Joined
Aug 27, 2007
Messages
1,164
The unit doesn't slide ... but teleports to the location instantly :eekani:

JASS:
scope Slide initializer Init


    globals
        real DISTANCE = 500
        real INTERVAL = 0.02
        real SPEED = 15
        integer array Ar
        string Thunder = "Abilities\\Spells\\Human\\ThunderClap\\ThunderClapCaster.mdl"
    endglobals
//===============================================================================

    struct DATA
        unit u
        real dist
        real distInc
        real time
        real formula
        real cos
        real sin
        string Special
        static integer P = 0
        static timer t = CreateTimer()
        static method Loop takes nothing returns nothing
            local DATA dat
            local integer i = 0
            local integer Spam = 0
            local real x1
            local real y1
            local real x2
            local real y2
            loop
                exitwhen i >= dat.P
                set dat = Ar[i]
                if dat.dist <= 0 then
                    call SetUnitPathing(dat.u, true)
                    set dat.u = null
                    call BJDebugMsg("Yes")
                    set Ar[i] = Ar[dat.P - 1]
                    set dat.P = dat.P - 1
                else
                    call BJDebugMsg("YO")
                    set x1 = GetUnitX(dat.u)
                    set y1 = GetUnitY(dat.u)
                    set x2 = x1 + dat.distInc * dat.cos
                    set y2 = y1 + dat.distInc * dat.sin
                    call SetUnitPosition(dat.u, x2, y2)
                    set Spam = Spam + 1
                    if Spam == 5 then
                        call DestroyEffect(AddSpecialEffect( dat.Special, x1, y1))
                        set Spam = 0
                    endif
                    set dat.dist = dat.dist - dat.distInc
                endif
            endloop
            if dat.P == 0 then
                call PauseTimer(dat.t)
            endif
            endmethod
        static method Create takes unit ME, real a, real d, real f, string rr returns DATA
            local DATA dat = DATA.allocate()
            set dat.u = ME
            call SetUnitPosition(dat.u, GetUnitX(dat.u), GetUnitY(dat.u))
            call SetUnitPathing(dat.u, false)
            set dat.cos = Cos(a * bj_DEGTORAD)
            set dat.sin = Sin(a * bj_DEGTORAD)
            set dat.dist = d
            set dat.distInc = f
            set dat.formula = d / f
            set dat.Special = rr
            if dat.P == 0 then            
                call TimerStart(dat.t, INTERVAL, true, function DATA.Loop)
            endif
            set dat.P = dat.P + 1
            set Ar[dat.P - 1] = dat
            return dat
        endmethod
    endstruct
            
            
            
        
//===============================================================================    
    function Con takes nothing returns boolean
        return GetSpellAbilityId() == 'X1X2'
    endfunction

    function Yo takes nothing returns nothing
    local DATA dat = DATA.Create(GetSpellAbilityUnit(), GetUnitFacing(GetSpellAbilityUnit()), DISTANCE, SPEED, Thunder)
    endfunction

    //===========================================================================
    function Init takes nothing returns nothing
        local trigger t = CreateTrigger( )
        call TriggerRegisterAnyUnitEventBJ( t, EVENT_PLAYER_UNIT_SPELL_EFFECT )
        call TriggerAddCondition( t, Condition( function Con ) )
        call TriggerAddAction( t, function Yo )
        set t = null
    endfunction

endscope
 
Status
Not open for further replies.
Top