• 🏆 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] MUIism problem

Status
Not open for further replies.
Level 7
Joined
Nov 6, 2009
Messages
279
Heres the code:
JASS:
//===========================================================================
//==============Knockback Engine by DevilDuke==========================================
//===========================================================================
library KnockbackEngine requires Functions, LastOrder

    scope Knockback
         
         struct KnockbackEngine                  
                        
            unit caster = null
            unit target = null
            real angle = 0
            real distance = 0
            real duration = 0
            real runs = 0
            real speed = 0
            real friction =0
            real x = 0
            real y = 0
            real x2 = 0
            real y2 = 0
            
            private static method ExecuteKnockbackTarget takes nothing returns nothing
                local timer t = GetExpiredTimer()
                local KnockbackEngine data = LoadInteger(Hash, GetHandleId(t), StringHash("data"))
                set data.x = GetUnitX(data.target)
                set data.y = GetUnitY(data.target)
                set data.x2 = PolarProjectionX(data.x, data.speed, data.angle)
                set data.y2 = PolarProjectionY(data.y, data.speed, data.angle)
                set data.friction = data.speed / data.runs
                if data.distance > 0  and IsTerrainPathingType(PolarProjectionX(data.x, 6*data.speed, data.angle), PolarProjectionY(data.y, 6*data.speed, data.angle), TERRAIN_PATHING_WALKABLE) and GetWidgetLife(data.target) > 0.405 then
                    call SetUnitX(data.target, data.x2)
                    call SetUnitY(data.target, data.y2)
                    call DestroyEffect(AddSpecialEffect("KnockbackDust.mdx", data.x, data.y))
                    call BJDebugMsg(R2S(data.speed))
                    set data.distance = data.distance - data.speed
                    set data.speed = data.speed - data.friction
                    call SaveInteger(Hash, GetHandleId(t), StringHash("data"), data)
                else
                    call PauseUnit(data.target, false)
                    call SetUnitPathing(data.target, true)
                    call IssueLastOrder(data.target)
                    call DestroyTimer(t)
                    call FlushChildHashtable(Hash, GetHandleId(t))
                    call BJDebugMsg("end")
                endif
                set t = null
                call data.destroy()
            endmethod                
            
            method UnitKnockbackTarget takes unit target, real distance, real duration,  real angle returns nothing
                local timer t = CreateTimer()
                local KnockbackEngine data = KnockbackEngine.create()
                set data.target = target
                set data.distance = distance
                set data.duration = duration
                set data.runs = data.duration / INTERVAL
                set data.speed = 2 * data.distance / (data.runs + 1)
                set data.angle = angle
                call SaveInteger(Hash, GetHandleId(t), StringHash("data"), data)
                call PauseUnit(data.target, true)
                call SetUnitPathing(data.target, false)
                call TimerStart(t, INTERVAL, true, function KnockbackEngine.ExecuteKnockbackTarget)
                call data.destroy()
                call BJDebugMsg("start")
                set t = null
            endmethod
            
        endstruct
        
    endscope
    
endlibrary

I could copy some code from other spells/systems but i wouldnt understand it so plz help.

INTERVAL is 0.035.

Any irrelevant suggestions that would improve this are welcome.
 
Level 7
Joined
Nov 6, 2009
Messages
279
Thx Justify its MUI now and i did that cause i thought it would leak and no tutorial explains that...

I cant give u rep cause i gotta spread bla bla bla
 
Status
Not open for further replies.
Top