Graal Forums  

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

 
 
Thread Tools Search this Thread Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 05-10-2001, 07:34 AM
Admins Admins is offline
Graal Administration
Join Date: Jan 2000
Location: Admins
Posts: 11,693
Admins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud of
Hehe trueheat no need for deleting your own
messages :-)

With the new Graal version there is the
command 'move', which is very powerful
when you want to make smoothly moving npcs.
Of course you can still move npcs by
updating the x and y position, but in most
cases you can use 'move' to get better results:

- less lag

Only the movement delta x, delta y and time
the movement takes need to be sent to the
player

- smoother movement

The npc is automatically moved on the
client side which the maximum possible
'smoothness':
all 0.05 seconds, high resolution
instead of the 0.5 tiles resolution when npc
positions are send by the npcserver, and
at constant speed

- faster server

The server still moves the npc on server-side
(so that playertouchsme etc. work correctly),
but the script itself doesn't need to be called,
and the positions doesn't need to be sent to
the players, so less work

The move command should have a maximum
compability, e.g. when a player enters the
room in the middle of a move then the server
sends the half movement so that it is correct,
and with each new move the starting position
is sent again so that the npc cannot move
to a wrong position (when there are sliglthy
differences in the resolution of the movement)

Here a nice example for a randomly walking
npc (when it hits a wall or after some time it
changes the direction):

NPC Code:

if (created) {
showcharacter;
setcharani walk,;
}
if (created || movementfinished) {
i = int(random(0,4));
len = random(2,10);
move vecx(i)*len,
vecy(i)*len,
len/8,
4+8+16;
}



You see that the command move is called
with random values for delta x and delta y,
a movement time based on the distance
of the way (8 tiles = 1 second),
and the options for stopping when hitting
a wall and calling the script again when stopped
walking (option 8 -> calls the script with
flag 'movementfinished' set). The option '16'
is for setting the direction automatically
on client-side so that the npc changes the
direction in the same moment when the new
move starts. This is not really important in this
case because it doesn't use caching, but when
you use the option '1' for caching then it
is better to let the direction automatically be
set. For random walking (+option 8) it is better
to not use caching since the the npc should
change the movement as soon as the
server sends a new movement (to anothe direction)
and not finish the current movement.

Godspeed already suggested to add a new
option: +32 for automatically animation change
(to idle,walkslow, walk, swim, depending on
if the npc moves or swims or so)
 


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 01:28 AM.


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