• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.
  • 💡 We're thrilled to announce that our upcoming texturing contest is in the works, and we're eager to hear your suggestions! Please take this opportunity to share your ideas in this theme discussion thread for the Texturing Contest #34!
  • 🏆 Hive's 7th HD Modeling Contest: Icecrown Creature is now open! The frozen wastes of Icecrown are home to some of Azeroth’s most terrifying and resilient creatures. For this contest, your challenge is to design and model a HD 3D monster that embodies the cold, undead, and sinister essence of Icecrown! 📅 Submissions close on April 13, 2025. Don't miss this opportunity to let your creativity shine! Enter now and show us your frozen masterpiece! 🔗 Click here to enter!

[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