ID:2170552
 
How do I implement a knockback effect using animate. Something that sends a mob flying .

Lol I have no idea
mob/proc/
Knockback(dir,mob/hit,duration)
hit.knocking=1
spawn(duration)hit.knocking=0
while(hit&&hit.knocking)
sleep(1)

if(dir==NORTH)
hit.dir=SOUTH
hit.y++
if(dir==SOUTH)
hit.dir=NORTH
hit.y--
if(dir==EAST)
hit.dir=WEST
hit.x++
if(dir==WEST)
hit.dir=EAST
hit.x--
hit.Create_Trail()
Ohhh my Goood! why you use if(dir....)
just define in step proc direction...
mob/proc/KnockBack(var/mob/M,var/Dist,var/Dir)
spawn(-1)
var/Counter=1
while(M && Counter<=Dist)
M.icon_state="KnockBack"
step(M,Dir);Counter+=1
sleep(1)
if(M)
M.dir=turn(M.dir,180)
M.icon_state=""

In response to Marekssj3
Because I want the mob getting hit to face the usrs direction before flying back, then fly back while facing the usr in their direction
Oh you can just change icon_state


Also if you use pixel movement just change step_x / step_y no x/y vars.
@Edit:
Hmmmmm i'm confused couse i will drill and i have question
Is posible to block animate movement state?
This code also doesn't suport ByOND collison system, :( why?
proc/My_slide(var/atom/movable/Ref,var/Dir,var/Speed=0)
if(!Ref) return
if(!Dir) Dir=Ref.dir
if(!Speed) Speed=Ref.step_size
switch(Dir)
if(NORTH) {Ref.step_y+=Speed}
if(SOUTH) {Ref.step_y-=Speed}
if(EAST) {Ref.step_x+=Speed}
if(WEST) {Ref.step_x-=Speed}

mob/proc/KnockBack(var/mob/M,var/Dist,var/Dir)
var/Counter=1
while(M && Counter<=Dist)
My_slide(M,Dir,5);Counter+=1
sleep(world.tick_lag)

mob/verb/_Test()
KnockBack(src,12,turn(src.dir,180))

In response to Marekssj3
Marekssj3 wrote:

@Edit:
Hmmmmm i'm confused couse i will drill and i have question
Is posible to block animate movement state?
This code also doesn't suport ByOND collison system, :( why?
> proc/My_slide(var/atom/movable/Ref,var/Dir,var/Speed=0)
> if(!Ref) return
> if(!Dir) Dir=Ref.dir
> if(!Speed) Speed=Ref.step_size
> switch(Dir)
> if(NORTH) {Ref.step_y+=Speed}
> if(SOUTH) {Ref.step_y-=Speed}
> if(EAST) {Ref.step_x+=Speed}
> if(WEST) {Ref.step_x-=Speed}
>
> mob/proc/KnockBack(var/mob/M,var/Dist,var/Dir)
> var/Counter=1
> while(M && Counter<=Dist)
> My_slide(M,Dir,5);Counter+=1
> sleep(world.tick_lag)
>
> mob/verb/_Test()
> KnockBack(src,12,turn(src.dir,180))
>



BUMP?
cause youre manually changing step_x/y so it's not calling move which is what calls all the built in collision stuff