Thread: Interpolation
View Single Post
  #14  
Old 03-07-2011, 05:53 AM
fowlplay4 fowlplay4 is offline
team canada
fowlplay4's Avatar
Join Date: Jul 2004
Location: Canada
Posts: 5,200
fowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond repute
Quote:
Originally Posted by Crono View Post
on zodiac if you go into a dungeon and the person hasn't moved yet you don't see them in their real positions
Going need instructions to replicate it, because I've been unsuccessful.

Also... Plug-n-play Player Movement Interpolation system. Obviously customize isOn() to suit your server's needs.

PHP Code:
//#CLIENTSIDE

function onPlayerEnters() {
  if (
isOn()) {
    
checkLevelChange();
    
onTimeout();
  }
}

function 
isOn() {
  return !
client.option_disableinterpolation;
}

function 
onTimeout() {
  if (
isOn()) {
    if (
this.oTimerVar == 0this.oTimeVar timevar2-.05;
    
this.frameTime timevar2-this.oTimeVar;
    
this.oTimeVar timevar2;
    
saveOldPos();
    
lerpPlayers();
    
setTimer(0.05);
  }
}

function 
checkLevelChange() {
  if (
player.level.name != this.oldLevel) {
    for (
pl players) {
      
pl.lerp 0;
      
pl.oldX pl.newX pl.x;
      
pl.oldY pl.newY pl.y;
    }
    
this.oldLevel player.level.name;
    
this.forceupdate true;
  }
}

function 
saveOldPos() {
  for (
pl players) {
    if (
pl == player) continue;
    if (
pl.lerp 0) continue;
    
temp.update this.forceupdate;
    if (
pl.!= pl.oldX) {
      
pl.oldX pl.newX;
      
pl.newX pl.x;
      
temp.update true;
    }
    if (
pl.!= pl.oldY) {
      
pl.oldY pl.newY;
      
pl.newY pl.y;
      
temp.update true;
    }
    if (
temp.update) {
      
temp.distX abs(pl.newX-pl.oldX);
      
temp.distY abs(pl.newY-pl.oldY);
      if ((
temp.distX .25 || temp.distY .25) && (temp.distX && temp.distY 2)) {
        
pl.doLerp true;
        
pl.oldPacketTime pl.newPacketTime;
        
pl.newPacketTime timevar2;
        
pl.lerpDiv pl.newPacketTime-pl.oldPacketTime;
        
pl.lerp 1;
      } else {
        
pl.doLerp false;
      }
    }
  }
  if (
this.forceupdatethis.forceupdate false;
}

function 
lerpPlayers() {
  for (
pl players) {
    if (
pl == player) continue;
    if (!
pl.doLerp) continue;
    if (
pl.lerp >= -.5) {
      
pl.lerp -= .5;
      
pl.linearInterpolateValue(pl.oldXpl.newXabs(1-pl.lerp));
      
pl.linearInterpolateValue(pl.oldYpl.newYabs(1-pl.lerp));
    }
  }
}

function 
linearInterpolateValue(temp.ovtemp.nvtemp.l) {
  return (
temp.ov*(1-temp.l)+temp.nv*temp.l);

__________________
Quote:
Reply With Quote