View Single Post
  #1  
Old 04-25-2006, 12:51 AM
jake13jake jake13jake is offline
Former Classic Staff
jake13jake's Avatar
Join Date: Dec 2002
Location: Northwest Vermont
Posts: 1,452
jake13jake will become famous soon enough
execution of the sleep command

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.this.jump_initx this.jump_dx;
    
player.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?

Last edited by jake13jake; 04-25-2006 at 01:58 AM..
Reply With Quote