ID:1304426
 
(See the best response by Khye.)
Problem description: So i'm using forum_account's AI library/demo as a guide for my NPC AI. I'm only using the very basic AI at the moment as I don't have the need to adapt further yet. But for some reason when my NPC's move their movement is jerky and the icon's do have movement states. Any idea what the cause of this would be?

Code:
mob
proc/AI()

ai
New()
..()
spawn(10) AI()

AI()
step_rand(src)

// There is a one second delay between AI cycles. It's important to have
// some delay, even if it's short.
spawn(10) AI()

enemy
icon = 'enemy.dmi'




Are the NPCs using pixel movement? That combined with spawn/sleep in their AI procs tend to make it look very jerky. Especially with a full second of delay in the AI proc.

I find it's best to use the delay argument within whatever type of movement proc you're calling. For the smoothest transition, you'll want either 0 delay with a tiny step size(half the step size of players), or a tiny delay (1 or 2) with a large step size.
Yes I'm using pixel movement. I'm not sure what you meant by the delay in the movement proc, but i'm assuming something like this.

AI()
step_rand(src,0)

// There is a one second delay between AI cycles. It's important to have
// some delay, even if it's short.
spawn(10) AI() //tried to set this to spawn(0) at first made my game incredibly laggy lol.

enemy
step_size = 4
icon = 'rogue.dmi'


This makes it less jerky but the NPC takes tiny steps and I'm not quite sure how to get the right balance. players pixel_movement is set to 8.
Best response
Have you redefined mob/Move() at all?

If not, I'm quite sure that changing the spawn()'s in your AI proc to 2 will make it significantly smoother. A full second of delay is kind of superfluous.
Setting it to 2 made it smoother but moved around really fast. Setting spawn to 1 and playing around finally got a smooth and steady pace (thank god)

        AI()
step_rand(src,4)

// There is a one second delay between AI cycles. It's important to have
// some delay, even if it's short.
spawn(1) AI()

enemy
step_size = 2
icon = 'rogue.dmi'


Also i did redefine Move(). But nothing that I don't think would stop it from doing what it's supposed to do. Especially since i redefined Move() after I'd implemented the AI.

Yeah, the pixel movement doesn't blend well with the delays. Glad you got it fixed. ^^
Thankyou and thanks for the help :)