Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   Future Improvements (https://forums.graalonline.com/forums/forumdisplay.php?f=10)
-   -   Local NPC locations (https://forums.graalonline.com/forums/showthread.php?t=23583)

Kaimetsu 02-12-2002 03:35 AM

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.

G_yoshi 02-12-2002 03:38 AM

Re: Local NPC locations
 
Quote:

Originally posted by Kaimetsu
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.

Ehem...the comment //#SERVERSIDE does not exist -_-

Kaimetsu 02-12-2002 03:42 AM

Re: Re: Local NPC locations
 
Quote:

Originally posted by G_yoshi


Ehem...the comment //#SERVERSIDE does not exist -_-

Neither does the comment "//Hi I am cool" but Graal doesn't object to it. It was there to show people that it's a script with serverside and clientside parts, without them having to see the //#CLIENTSIDE further down.

Anyway, comment on the idea.

G_yoshi 02-12-2002 03:47 AM

Re: Re: Re: Local NPC locations
 
Quote:

Originally posted by Kaimetsu


Neither does the comment "//Hi I am cool" but Graal doesn't object to it. It was there to show people that it's a script with serverside and clientside parts, without them having to see the //#CLIENTSIDE further down.

Anyway, comment on the idea.

[nagging]the script is already serverside until the comment //#CLIENTSIDE is encounterd[/nagging]

I guess it would be neat...I'm not sure what else to say :/

Kaimetsu 02-12-2002 03:50 AM

Re: Re: Re: Re: Local NPC locations
 
Quote:

Originally posted by G_yoshi


[nagging]the script is already serverside until the comment //#CLIENTSIDE is encounterd[/nagging]

Yes I know. I am a scripter, remember? You ignored my point that it was for the reader rather than the Graal scripting engine.

G_yoshi 02-12-2002 03:52 AM

Re: Re: Re: Re: Re: Local NPC locations
 
Quote:

Originally posted by Kaimetsu


Yes I know. I am a scripter, remember? You ignored my point that it was for the reader rather than the Graal scripting engine.

Still...I cannot begin to reiterate enough the number of times it's been said before -_-

Kaimetsu 02-12-2002 03:56 AM

No statement in comments that is not a directive can be described as "wrong" and in this case there was a good reason for its presence. Even if the point has been made with merit in the past, there is no right and wrong on the issue.

So, STEFAN! Read my suggestion!

G_yoshi 02-12-2002 03:58 AM

Quote:

Originally posted by Kaimetsu
No statement in comments that is not a directive can be described as "wrong" and in this case there was a good reason for its presence. Even if the point has been made with merit in the past, there is no right and wrong on the issue.

So, STEFAN! Read my suggestion!

lol, ok ok...no reason to quibble over something like this :p

Kaimetsu 02-13-2002 01:13 AM

I can't believe this fundamental of any online RPG (and arguably any online game at all) is being ignored.

zell12 02-13-2002 03:18 AM

That would be A nice thing to have :D

LiquidIce00 02-13-2002 03:27 AM

im sure he thought of this while making it and decided to make it w/ just clientsided for a purpose

Kaimetsu 02-13-2002 03:32 AM

Quote:

Originally posted by LiquidIce00
im sure he thought of this while making it and decided to make it w/ just clientsided for a purpose
?

I don't think you've understood what I've been saying.

TDK_RC6 02-13-2002 04:30 AM

i think its a good idea

Sym2001 02-13-2002 04:44 AM

You know..
 
That is a great idea. Great for making Bosses anyways. Im sure it could be used in many other ways aswell.

they should make a move command for players aswell, instead of only NPCs.

Kaimetsu 02-25-2002 11:16 PM

Hey Stefan, since you're on a forum spree...

;)


All times are GMT +2. The time now is 07:45 AM.

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