Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   move (https://forums.graalonline.com/forums/showthread.php?t=50241)

adam 01-07-2004 11:28 PM

move
 
This is most likely a bug but I thought I would just post it here first.

NPC Code:

if ( created ){
this.speed = 0.5;
message Ask me to "Come Here".;
}

if ( playerchats ){
if ( strequals( #c , Come Here ) ){
this.movex = playerx + vecx( playerdir ) * 2;
this.movey = playery + vecy( playerdir ) * 2;
move();
message Coming sir.;
}
}

function move(){
this.dx = this.movex - x;
this.dy = this.movey - y;
this.dis = ( this.dx ^ 2 + this.dy ^ 2 ) ^ 0.5;
this.time = this.dis * this.speed;
setcharani walk,;
move this.dx , this.dy , this.time , 1 + 4 + 8 + 16;
}

if ( movementfinished ){
if ( x != this.movex || y != this.movey ){
message A wall is in the way.;
}else{
message Here.;
}
setcharani idle,;
}

//#CLIENTSIDE

if ( created ) {
// Initialize the attributes
showcharacter;
setcharprop #3 , head212.png;
setcharprop #C0 , orange;
setcharprop #C1 , black;
setcharprop #C2 , black;
setcharprop #C3 , black;
setcharprop #C4 , black;
setcharprop #2 , no-shield.png;
setcharprop #n , Bob;
shieldpower = 1;
dir = 2;
}



This is a basic npc, it uses the move command to come to you when you ask it too. It is serverside.

It works fine offline. But online it will stop moving, but continue to walk at a standstill. And when called to move again it will warp to the spot it was trying to get to and continue from there.

I really want the move command to work here. :-/ Suggestions? Common ailments? Have you encountered the same?

Hevaricubed 01-07-2004 11:46 PM

ew. whitespace.

I always have trouble with move, i just assumed its buggy, i never move more than one tile distance at a time.

adam 01-07-2004 11:47 PM

I have been informed by a few people that it is move.

Move must be fixed! It has a lot of potential if the serverside can work like the clientside. :-/

Python523 01-07-2004 11:54 PM

NPC Code:

if (created){
message Ask me to "Come Here".;
}

if (playerchats){
if (strequals(#c,Come Here)){
move();
message Coming sir.;
}
}

function move(){
this.dx = playerx-x;
this.dy = playery-y;
this.dis = (this.dx^2 + this.dy^2)^0.5;
this.angle = getangle(this.dx,this.dy);
i = 0;
gox = x;
goy = y;
while (i<this.dis){
newx = gox + cos(this.angle);
newy = goy - sin(this.angle);
if (onwall(newx+1.5,newy+2) || onwater(newx+1.5,newy+2))
break;
gox = newx;
goy = newy;
i++;
}
if (i > 0) {
setcharani walk,;
move gox-x,goy-y,2,1+4+8+16;
}
}

if (movementfinished){
message Here.;
setcharani idle,;
}


adam 01-08-2004 01:54 AM

A temporary solution at best, Half the point of move is so I can do all that without having to run extensive wall checks servside.

ZeLpH_MyStiK 01-08-2004 03:10 AM

Quote:

Originally posted by adam
A temporary solution at best, Half the point of move is so I can do all that without having to run extensive wall checks servside.
How does move imply that you don't have to do wall checks?

Python523 01-08-2004 03:33 AM

Quote:

Originally posted by adam
A temporary solution at best, Half the point of move is so I can do all that without having to run extensive wall checks servside.
The move wall check isn't even that good clientside, if I remember correctly

Hevaricubed 01-08-2004 04:37 AM

move checks onwall after movement has finnished x.x

adam 01-08-2004 04:46 AM

Quote:

Originally posted by Python523


The move wall check isn't even that good clientside, if I remember correctly

Neither was the temporary solution you gave me. And trying to do it any better would use far too much of the server's resources for my taste. I do plan on having lot's of things all over the server move. And having the move function work correctly would help.

Hevaricubed 01-08-2004 04:54 AM

jagens move thing works fine

offline + running in a timeout of 0.05, according to my debugger it uses 0.0234215 or something of my cpu usage, and i have a very crappy machine.

-Ramirez- 01-08-2004 06:46 AM

Quote:

Originally posted by adam
Neither was the temporary solution you gave me. And trying to do it any better would use far too much of the server's resources for my taste. I do plan on having lot's of things all over the server move. And having the move function work correctly would help.
That's the EXACT same problem I have. Doing extensive checking to make sure things don't hit a wall (ACCURATELY) is very resource intensive... compared to other scripts at least.

osrs 01-08-2004 05:41 PM

Jagen's script edit. :D

NPC Code:

if (created){
showcharacter;
setcharprop #3,bomy_golg0.png;
setcharani g2k2bomy_idle,;
setstring this.name,Bomy;
message Ask me to "Come Here".;
timeout = 0.05;
}
if (playerchats){
if (strequals(#c,Come Here)){
move();
message Coming sir.;
}
}

function move(){
this.dx = playerx-x;
this.dy = playery-y;
this.dis = (this.dx^2 + this.dy^2)^0.5;
this.angle = getangle(this.dx,this.dy);
i = 0;
gox = x;
goy = y;
while (i<this.dis){
newx = gox + cos(this.angle);
newy = goy - sin(this.angle);
if (onwall(newx+1.5,newy+2) || onwater(newx+1.5,newy+2))
break;
gox = newx;
goy = newy;
i++;
}
if (i > 0) {
setcharani g2k2bomy_walk,;
move gox-x,goy-y,2,1+4+8+16;
}
}
if (movementfinished){
message Here.;
setcharani g2k2bomy_idle,;
}

if(timeout){
showtext 0,x+0.3,y+2.5,,,#s(this.name);
changeimgzoom 0,0.8;
changeimgvis 0,1;
timeout = 0.05;
}


D1ce2 01-09-2004 01:51 PM

I could make it worse but I'm not up to the challenge :p

Python523 01-09-2004 03:20 PM

Quote:

Originally posted by osrs
Jagen's script edit. :D

NPC Code:

stuff


Why didn't you just do setcharprop #n eludes me...

osrs 01-09-2004 04:05 PM

Quote:

Originally posted by Python523
Why didn't you just do setcharprop #n eludes me...
Because it looks better :)


All times are GMT +2. The time now is 09:34 PM.

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