ID:1304680
 
(See the best response by Neimo.)
Code:
walk_away(V,A,5,0,32)


Problem description:
I'm quite positive I have the arguments correct. I'm theory-crafting and experimenting on a decent knockback proc that'll work with my combat system, and I thought I'd try to use walk_away(). Rather than take them 5 tiles away though, as designated, it carries the mob endlessly in the opposite direction of A. It's a bit annoying. Any advice on a way to fix this? Or perhaps I'm misinterpretting it's use? Is there a better alternative?

Best response
You could create a for() look and have them step() respectively. When you use walk_away() it'll walk continuously until you call walk(ref, 0).
Ah I see. I do remember reading that, but I was thrown off by the max distance argument. What's the point of that argument then?

Would it be possible to keep track of the amount of steps taken in the walk_away() proc and then call walk(ref,0) to halt it at the appropriate distance?
Alright so this is what I came up with:

Knockback(var/mob/V,var/mob/A)
var/dis = 10
V.immobilized = 1
V.icon_state = "Knockback"
V.combo = 0
walk_away(V,A,dis,0,26)
spawn(4)
walk(V,0)
V.immobilized = 0
icon_state = ""
V.dir = get_dir(V,A)


This works pretty smoothly. Only kink I'm trying to iron out is that while being knocked back, someone can simply walk away to end it. At first I thought I could counter that by redefining Move() to return 0 if immobilized was 1. However, I came to realize that walk_away() calls upon the move proc. Can anyone see a work around for this?
In response to Khye
You could just create a loop that calls either step() or Move() forcefully. If you call Move() you can add a third argument to bypass what you're having a problem with.
In response to Khye
Like this:

client/North()
if(src.mob.immobolized) return 0


You'd do that for each key, if it isn't obvious already lol.
In response to FKI
FKI wrote:
Like this:

client/North()
> if(src.mob.immobolized) return 0

You'd do that for each key, if it isn't obvious already lol.

I was considering this, but I don't like that those procs are only defined under client. I was hoping there'd be a solution that'd stop NPC's from walking out of it too. Though I suppose I could add a statement into the AI(). Thanks for your help guys.
Oh, one last question. With the current knockback code how it is, when the NPC hits me, it only sends me flying in a diagonal direction, which I find odd. Though when I hit an NPC, it'll do all 8 directions. Anyone know why this is?
Bump. Is it possible that my NPCs are only capable of facing 4 directions?
You could force it when ever they try to step non-cardinally by using the Dir argument in Move() and changing it before the ..().