I am trying to rescript parts of my action system. It currently runs on timeouts, but I'm trying to separate it into functions that I can put into the main part of my movement system (I know there are bugs in this version of the function, but unrelated).
I have:
PHP Code:
public function attemptJump() {
if (testJump(NULL)) {
this.jump_initx = player.x;
this.jump_inity = player.y;
this.jump_a = 2*(this.jump_dy-this.jump_v*this.jumpDestMax)/this.jumpDestMax^2;
this.jump_v = -1.25 ;
play("jump.wav");
while (this.jumpDestCounter < this.jumpDestMax) {
this.jump_v += this.jump_a;
player.x += this.jump_dx/clientr.movement_jumptime*0.05;
player.y += this.jump_v;
drawJumpShadow(true);
this.jumpDestCounter++;
player.chat = this.jumpDestCounter;
sleep(0.05);
}
drawJumpShadow(false);
player.x = this.jump_initx + this.jump_dx;
player.y = this.jump_inity + this.jump_dy;
system_gani.updateAni();
this.jumpDestCounter = 0;
return true;
}
return false;
}
On the first execution of the function:
the while-sleep loop continues, but all other scripts also continue.
On subsequent executions it only executes one iteration.
The setTimer in the movement NPC isn't being set until after all script execution is completed in the timeout loop.
movement system calls attemptAction(), attemptAction() calls attemptJump()
This is quite nasty I think. Why shouldn't I be able to delay stack execution within a timeout?