Graal Forums  

Go Back   Graal Forums > Development Forums > NPC Scripting > Code Gallery
FAQ Members List Calendar Today's Posts

 
 
Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #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
 


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 03:48 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2026, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.