Graal Forums  

Go Back   Graal Forums > Development Forums > Future Improvements
FAQ Members List Calendar Search Today's Posts Mark Forums Read

 
 
Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 02-12-2002, 03:35 AM
Kaimetsu Kaimetsu is offline
Script Monkey
Kaimetsu's Avatar
Join Date: May 2001
Posts: 18,222
Kaimetsu will become famous soon enough
Local NPC locations

Let's say I have an NPC that follows a simple movement pattern. It just moves towards the player in a straight line at a fixed speed, like this:

NPC Code:

if(playerenters){showcharacter; setcharani walk,; timeout=0.05;}
if(timeout){
timeout=0.05;
dx=playerx-x; dy=playery-y;
mag=(dx^2+dy^2)^0.5;
x+=dx/mag; y+=dy/mag;
}



Simple stuff. However, I can't use the move command for this since the bad guy's movement changes whenever you move, and if I just let it work on updates from the server then it'll be really horrible-looking (which is why move was created in the first place). So, here's what I propose: A set of variables that define where the NPC is drawn on the clientside (call them drawx and drawy for the sake of argument). These can be changed all the time and stuff by clientside scripts, but whenever the client recieves x/y data from the server, they jump to that x/y. So I could do something like this:

NPC Code:

//#SERVERSIDE
if(created){showcharacter; setcharani walk,; timeout=0.1;}
if(timeout){
timeout=0.1;
dx=players[0].x-x; dy=players[0].y-y;
mag=(dx^2+dy^2)^0.5;
x+=dx/mag; y+=dy/mag;
}
//#CLIENTSIDE
if(timeout||playerenters){
timeout=0.05;
dx=playerx-x; dy=playery-y;
mag=(dx^2+dy^2)^0.5;
drawx+=dx/mag; drawy+=dy/mag;
}



Because then, y'see, the client could make guesses at where the NPC should be at that time. Sometimes these guesses will be wrong, but with simple movement systems they'll usually get it right and it eliminates the jumpy movement stuff. And since it's all clientside, there's no risk of people abusing it in any way to cheat.
__________________
Reply With Quote
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 07:36 PM.


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