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

[Spell] Slide like hungry hungry felhounds

Status
Not open for further replies.
Level 3
Joined
Aug 19, 2020
Messages
38
Greetings, I would like to ask if there are any resources that slide like hungry felhounds does
it decelerate when you turn around <-- the main thing that I dont know how to achieve.
Thanks
 
Level 3
Joined
Aug 19, 2020
Messages
38
Of course I have read this thread before.
The question I have is that it does not do something like chasing a target
also it cannot be used... the website he provide is broken already.
 
Last edited:
Level 6
Joined
Dec 29, 2019
Messages
82
Here you go my friend. Btw you don't need to handle target chasing ... just make sure sliding unit is hostile to other units and it will chase them by default :). And yeah this is Lua solution so if you want to use JASS for this you need to recompile it...

Lua:
function SlideUnit_Execute()
    local t = GetExpiredTimer()
    local u = SLIDE_DATA[t].u
    local v = SLIDE_DATA[t].v
    local a = SLIDE_DATA[t].a
  
    SetUnitX(u, GetUnitX(u) + v * Cos(a))
    SetUnitY(u, GetUnitY(u) + v * Sin(a))
  
    if SLIDE_DATA[t].i >= SLIDE_DATA[t].q then
        SLIDE_DATA[t] = nil
        PauseTimer(t)
        DestroyTimer(t)
    else
        SLIDE_DATA[t].i = SLIDE_DATA[t].i + 1
    end
  
    t,u,v,a = nil,nil,nil,nil
end

SLIDE_DATA = {}

function SlideUnit(u,distance,angle,duration)
    local t = CreateTimer()
  
    SLIDE_DATA[t] = {
        u = u
        ,v = distance / duration * 0.01
        ,a = angle * bj_DEGTORAD
        ,q = R2I(duration / 0.01)
        ,i = 0
    }
    TimerStart(t, 0.01, true, SlideUnit_Execute)
  
    t = nil
end

--every time u call slide unit a timer is created which keeps moving unit under angle passed as param, every 0.01 seconds by "(param_distance / param_duration) * 0.01"
--so if you want to move some unit by 500.00 dist over 2 seconds in the current unit facing direction, it will basically move that unit every 0.01 seconds by 2.5 in the direction which that unit faced at the moment you called the slide function
--its set that every 0.1 seconds slide unit function is called which moves unit by 50*factor in current unit facing direction over 1 second
--if unit is turning what happens is that old timers keep moving it in the old direction and new in the new direction, which looks like the unit has been slowed down a little bit

function slide_it()
    local u = CreateUnit(Player(0), FourCC('hfoo'), GetPlayerStartLocationX(Player(0)),GetPlayerStartLocationY(Player(0)), 270)
    local trig = CreateTrigger()
    local factor = 1.0 -- this is what makes unit move faster by time
    TriggerRegisterTimerEventPeriodic(trig, 0.1)
    TriggerAddAction(trig, function()
        SlideUnit(u,50*factor,GetUnitFacing(u),1)
        factor = factor >= 1.6 and factor or factor + 0.005 -- factor incrasing means unit moves faster max factor value is set to 1.6, but you can ofc change logic here a little bit
    end)
end
 

Attachments

  • SlideLikeFelhound.w3m
    16.3 KB · Views: 8
Last edited:
Status
Not open for further replies.
Top