I think you should qualify the object-local variables with 'this.'. I dont really know the default scope of unqualified variable in the body of functions/events, but i think it either makes them class local, or even global variables.
NPC Code:
this.acceleration = 1;
this.granularity = 0.05;
... etc
and i think the general convention for function local-variable, is to just make them members of the temp object, like:
NPC Code:
function foo(x,y) {
temp.baz = x*y;
this.bar = temp.baz * 11;
}
to avoid unintentionally over writing global variables with the same name.