ID:2340329
 
(See the best response by Spunky_Girl.)
Code:
Lunge()
verb
if(!usr.stunned)
usr.charging = 1 //variable to call damage upon bumping to another mob
speed = 20 //atom speed variable
walk(usr,usr.dir) //Lunge Effect
spawn(30)
usr.charging = 0 //reset to stop bump damage
walk(usr,0) //Stop Lunge
speed = 8 //reset to original speed


Problem description:
I'm probably overthinking this, but I'm struggling to gather my thoughts on how to create this effect. What are other alternative ways I can do it? I've sought through the dev lib didn't see much info.
Best response
Knockback consists of 3 major key points.
- Who is being knocked back
- Direction of the knockback
- Distance of the knockback

This could be further detailed into whether they stop on dense objects, or destroy them and continue going (DBZ style), and whatnot, but that's up to you. MOST games have you stop on dense collision.

Pseudocode
//atom/movable proc? mob proc?
//distance is in #steps since your step_size variable determines how far they will move per step
knockback proc(direction, distance)
lock movement commands if necessary
loop distance to 0 //for loop
step src in direction
sleep delay
unlock movement commands if necessary


Lunging/Dashing is generally the same principle, except you'd want them going in the direction they are facing rather than whatever direction the source of the knockback is facing.

I should mention that you can (and should) play with the sleep delay to get a smooth and visually appealing knockback/lunge effect. I believe animate() and/or flick() is used for anything flashy during the knockback/dash effects.