Graal Forums  

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

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 08-26-2007, 12:53 AM
coreys coreys is offline
N-Pulse Assistant Manager
coreys's Avatar
Join Date: Mar 2005
Posts: 2,180
coreys has a spectacular aura about
Send a message via AIM to coreys Send a message via MSN to coreys Send a message via Yahoo to coreys
Wall checking between two points

I was wondering if there was an easy and/or non-lag-intensive way to check if there's a wall in between two points. I'm working on a baddy script, and when in the "searching" or "chasing" mode I want it to check if there's a wall between two points (the baddy's x/y and a players x/y). This would be happening every .1 seconds when in those modes, so yeah not being laggy would be a pretty important thing. Anyone know?
__________________

Quote:
*SlikRick: so should I even ask about your aim status?
*Xor: well if you want to
*Xor: but i am LARPING
*SlikRick: While on a computer?
*Xor: yes
*Xor: in my living room
*SlikRick: ahh
*Xor: i have a fort setup to hide from beasts
Reply With Quote
  #2  
Old 08-26-2007, 01:23 AM
DustyPorViva DustyPorViva is offline
Will work for food. Maybe
DustyPorViva's Avatar
Join Date: Sep 2003
Location: Maryland, USA
Posts: 9,589
DustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond repute
Send a message via AIM to DustyPorViva Send a message via MSN to DustyPorViva
Well, there's no function for it(see my suggestion thread about onwall3), but the only way to do it is to do something like I did for my lighting script...
PHP Code:
accuracy=.25;
onwall=0;
while (
i<dist/accuracy) {
  
onwall=onwall(x+dx*i,y+dx*i);
  if (
onwall==1) break;
  
i+=accuracy;

This isn't going to be too] tax-worthy on CPU, but a lot of baddies doing it might slow it down... but there's no other way.
Reply With Quote
  #3  
Old 08-26-2007, 02:09 AM
Googi Googi is offline
A Serious Epidemic
Googi's Avatar
Join Date: Oct 2001
Location: Canada
Posts: 18,866
Googi has much to be proud ofGoogi has much to be proud ofGoogi has much to be proud ofGoogi has much to be proud ofGoogi has much to be proud ofGoogi has much to be proud of
Send a message via AIM to Googi
The best way to do it would probably be to have the baddy already know the x and y of each wall tile in the area, and have precomputed paths to get around them, but that can be a pain for the scripters (though you could have a one-time function to compute and store the information). There's also Kaimetsu's checkpath function (would need to be adapted, it's for determining where a projectile would stop).

PHP Code:
function CheckPath() {
 
tx int(arg[0]); ty int(arg[1]);

 
stepx vxstepy vy;

 if (
stepx 0) {dirx = -1stepx = -stepx; }
 else 
dirx 1;
 if (
stepy 0) {diry = -1stepy = -stepy; }
 else 
diry 1;

 
tempx arg[0] - tx; if (dirx == -1tempx 1-tempx;
 
tempy arg[1] - ty; if (diry == -1tempy 1-tempy;
 
bankx stepx * (1-tempx);
 
banky stepy * (1-tempy);

 
dist 0;

 while(
true) {
  if (
bankx banky) {dist += bankxtemp 0;}
  else {
dist += bankytemp 1;}
  if (
dist mag) break;
  if (
temp == 0) {
   
banky -= bankxbankx stepx;
   
tx+=dirx;
  }
  else {
   
bankx -= bankybanky stepy;
   
ty+=diry;
  }

  if (
tx || tx 63 || ty || ty 63) break;
  if (
onwall(txty)) {
   
tx arg[0] + vx dist;
   
ty arg[1] + vy dist;
   if(
temp == 0) {tempx dirxtempy 0;}
   else {
tempx 0tempy diry;}
   
= {txtytempxtempy}; 0;
   return;
  }
 }
 
= -1;

__________________
Reply With Quote
  #4  
Old 08-26-2007, 02:44 AM
Crow Crow is offline
ǝɔɐɹq ʎןɹnɔ
Crow's Avatar
Join Date: Dec 2006
Location: Germany
Posts: 5,153
Crow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond repute
Since when do you script Googi?O.o
Reply With Quote
  #5  
Old 08-26-2007, 02:51 AM
xXziroXx xXziroXx is offline
Malorian
xXziroXx's Avatar
Join Date: May 2004
Posts: 5,289
xXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant future
Since before you were born son.
__________________
Follow my work on social media post-Graal:Updated august 2025.
Reply With Quote
  #6  
Old 08-26-2007, 03:14 AM
Crow Crow is offline
ǝɔɐɹq ʎןɹnɔ
Crow's Avatar
Join Date: Dec 2006
Location: Germany
Posts: 5,153
Crow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond repute
I guess I missed a pretty large part of Graal's history here. Btw, Graal didnt even exist when I was born ;o
Reply With Quote
  #7  
Old 08-26-2007, 03:16 AM
Kyranki Kyranki is offline
Freelance Coder
Join Date: Aug 2007
Location: At the end of the rainbow, in the pot of gold.
Posts: 202
Kyranki is on a distinguished road
Send a message via AIM to Kyranki Send a message via MSN to Kyranki
Erm,

PHP Code:
....
if (
onwall(obj.temp.gotoxobj.temp.gotoy)) {
.... 
__________________
Stan.
Reply With Quote
  #8  
Old 08-26-2007, 03:30 AM
DustyPorViva DustyPorViva is offline
Will work for food. Maybe
DustyPorViva's Avatar
Join Date: Sep 2003
Location: Maryland, USA
Posts: 9,589
DustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond repute
Send a message via AIM to DustyPorViva Send a message via MSN to DustyPorViva
He wants to check between those two points, the destination.
Reply With Quote
  #9  
Old 08-26-2007, 03:50 AM
Kyranki Kyranki is offline
Freelance Coder
Join Date: Aug 2007
Location: At the end of the rainbow, in the pot of gold.
Posts: 202
Kyranki is on a distinguished road
Send a message via AIM to Kyranki Send a message via MSN to Kyranki
Ahhhh,
__________________
Stan.
Reply With Quote
  #10  
Old 08-26-2007, 04:17 AM
coreys coreys is offline
N-Pulse Assistant Manager
coreys's Avatar
Join Date: Mar 2005
Posts: 2,180
coreys has a spectacular aura about
Send a message via AIM to coreys Send a message via MSN to coreys Send a message via Yahoo to coreys
Quote:
Originally Posted by DustyPorViva View Post
Well, there's no function for it(see my suggestion thread about onwall3), but the only way to do it is to do something like I did for my lighting script...
PHP Code:
accuracy=.25;
onwall=0;
while (
i<dist/accuracy) {
  
onwall=onwall(x+dx*i,y+dx*i);
  if (
onwall==1) break;
  
i+=accuracy;

This isn't going to be too] tax-worthy on CPU, but a lot of baddies doing it might slow it down... but there's no other way.
Didn't work.
__________________

Quote:
*SlikRick: so should I even ask about your aim status?
*Xor: well if you want to
*Xor: but i am LARPING
*SlikRick: While on a computer?
*Xor: yes
*Xor: in my living room
*SlikRick: ahh
*Xor: i have a fort setup to hide from beasts
Reply With Quote
  #11  
Old 08-26-2007, 04:27 AM
DustyPorViva DustyPorViva is offline
Will work for food. Maybe
DustyPorViva's Avatar
Join Date: Sep 2003
Location: Maryland, USA
Posts: 9,589
DustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond repute
Send a message via AIM to DustyPorViva Send a message via MSN to DustyPorViva
EDIT: here's a fixed version, my mistake!
PHP Code:
function onTimeout() {
  
temp.delta={playerx-x,playery-y,(temp.delta[0]^2+temp.delta[1]^2)^.5}; // get the delta's and distance
  
temp.onwall=i=0// reset i and onwall check
  
while (i<temp.delta[0]) { // while i is less than the distance between player and NPC
    
temp.onwall=onwall(x+(temp.delta[0]/temp.delta[2])*i,y+(temp.delta[1]/temp.delta[2])*i);
    if (
temp.onwall==1) break;
    
i++;
  }

  
setTimer(0.05);

Key mistakes I fixed were resetting i before the loop, or else it'd grow beyond the actual distance! And also fixed the wall check, I was multiplaying i*dx/dy, and that 'cause it to check way farther than needed. You needed to divide the dx/dy by the distance, then multiply by i. This one however doesn't have a check for accuracy, though that would be easy enough to figure out(i+=accuracy )

Last edited by DustyPorViva; 08-26-2007 at 04:39 AM..
Reply With Quote
  #12  
Old 08-26-2007, 04:52 AM
coreys coreys is offline
N-Pulse Assistant Manager
coreys's Avatar
Join Date: Mar 2005
Posts: 2,180
coreys has a spectacular aura about
Send a message via AIM to coreys Send a message via MSN to coreys Send a message via Yahoo to coreys
I edited to this:
PHP Code:
function checkPath(oxdxoydy) {
  
temp.delta = {dx oxdy oy, (temp.delta[0]^2+temp.delta[1]^2)^.5}; // get the delta's and distance
  
0;
  
temp.onwall false;
  while (
temp.delta[0]) { // while i is less than the distance between player and NPC
    
temp.onwall onwall2(ox+(temp.delta[0]/temp.delta[2])*i,oy+(temp.delta[1]/temp.delta[2])*i11);
    if (
temp.onwall) break;
    
i++;
  }
  return 
temp.onwall;

And it's still not working. =o
__________________

Quote:
*SlikRick: so should I even ask about your aim status?
*Xor: well if you want to
*Xor: but i am LARPING
*SlikRick: While on a computer?
*Xor: yes
*Xor: in my living room
*SlikRick: ahh
*Xor: i have a fort setup to hide from beasts
Reply With Quote
  #13  
Old 08-26-2007, 04:56 AM
xXziroXx xXziroXx is offline
Malorian
xXziroXx's Avatar
Join Date: May 2004
Posts: 5,289
xXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant future
You cant break a 'while' dumbnuts!

PHP Code:
while (this.foo == false) {
  
player.chat "I've failed" SPC temp.bar SPC "times!";
  
temp.bar ++;
  if (
temp.bar == 10) {
    
player.chat "I didnt fail, yay!";
    
temp.foo true;  // Automaticly breaks the 'while' since the reason its being run is now invalid.
  
}

__________________
Follow my work on social media post-Graal:Updated august 2025.
Reply With Quote
  #14  
Old 08-26-2007, 05:00 AM
DustyPorViva DustyPorViva is offline
Will work for food. Maybe
DustyPorViva's Avatar
Join Date: Sep 2003
Location: Maryland, USA
Posts: 9,589
DustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond repute
Send a message via AIM to DustyPorViva Send a message via MSN to DustyPorViva
Err, why can't you? It's a loop, and I just tested it and it works fine...
EDIT: My mistake while converting it to GS2...
change:
while (i < temp.delta[0]) {
to:
while (i < temp.delta[2]) {
Reply With Quote
  #15  
Old 08-26-2007, 05:13 AM
coreys coreys is offline
N-Pulse Assistant Manager
coreys's Avatar
Join Date: Mar 2005
Posts: 2,180
coreys has a spectacular aura about
Send a message via AIM to coreys Send a message via MSN to coreys Send a message via Yahoo to coreys
Okay, well I have this now:
PHP Code:
function checkPath(oxdxoydy) {
  
temp.delta = {dx oxdy oy, (temp.delta[0]^2+temp.delta[1]^2)^.5};
  
0;
  
temp.onwall false;
  while (
temp.delta[2]) {
    
this.chat onwall2(ox+(temp.delta[0]/temp.delta[2])*i,oy+(temp.delta[1]/temp.delta[2])*i11);
    if (
onwall2(ox+(temp.delta[0]/temp.delta[2])*i,oy+(temp.delta[1]/temp.delta[2])*i11)) {
      
temp.onwall true;
      
temp.delta[0];
    }
    else 
i++;
  }
  return 
temp.onwall;

aaaand, nothin...isn't even setting this.chat o.0
__________________

Quote:
*SlikRick: so should I even ask about your aim status?
*Xor: well if you want to
*Xor: but i am LARPING
*SlikRick: While on a computer?
*Xor: yes
*Xor: in my living room
*SlikRick: ahh
*Xor: i have a fort setup to hide from beasts
Reply With Quote
  #16  
Old 08-26-2007, 05:27 AM
xXziroXx xXziroXx is offline
Malorian
xXziroXx's Avatar
Join Date: May 2004
Posts: 5,289
xXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant future
try changing 'i' to something else, another script is most likely interfering.
__________________
Follow my work on social media post-Graal:Updated august 2025.
Reply With Quote
  #17  
Old 08-26-2007, 05:40 AM
DustyPorViva DustyPorViva is offline
Will work for food. Maybe
DustyPorViva's Avatar
Join Date: Sep 2003
Location: Maryland, USA
Posts: 9,589
DustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond repute
Send a message via AIM to DustyPorViva Send a message via MSN to DustyPorViva
It's not that. This is what I get for posting a script I haven't tested... it had to do with the array I was using, apparently you can't grab values from the same array you're setting. Used to be able to.
Here:
PHP Code:
function checkPath(oxdxoydy) {
  
temp.dx=dx ox;
  
temp.dy=dy oy;
  
temp.delta=((temp.dx^2)+(temp.dy^2))^.5;
  
0;
  
temp.onwall false;
  while (
temp.delta) {
    
temp.onwall=onwall2(ox+(temp.dx/temp.delta)*i,oy+(temp.dy/temp.delta)*i,1,1);
    if (
temp.onwall) break;
    
i++;
  }
  return 
temp.onwall;

Reply With Quote
  #18  
Old 08-26-2007, 05:46 AM
coreys coreys is offline
N-Pulse Assistant Manager
coreys's Avatar
Join Date: Mar 2005
Posts: 2,180
coreys has a spectacular aura about
Send a message via AIM to coreys Send a message via MSN to coreys Send a message via Yahoo to coreys
Works, but damn it looks like for him to stop suddenly when you're like slightly, slightly behind a wall. xD
I could script it to find ways around walls but it would be super laggy, most likely.
__________________

Quote:
*SlikRick: so should I even ask about your aim status?
*Xor: well if you want to
*Xor: but i am LARPING
*SlikRick: While on a computer?
*Xor: yes
*Xor: in my living room
*SlikRick: ahh
*Xor: i have a fort setup to hide from beasts
Reply With Quote
  #19  
Old 08-26-2007, 05:53 AM
Googi Googi is offline
A Serious Epidemic
Googi's Avatar
Join Date: Oct 2001
Location: Canada
Posts: 18,866
Googi has much to be proud ofGoogi has much to be proud ofGoogi has much to be proud ofGoogi has much to be proud ofGoogi has much to be proud ofGoogi has much to be proud of
Send a message via AIM to Googi
Quote:
Originally Posted by Crow View Post
Since when do you script Googi?O.o
I used to but I stopped a long time ago.

The method you guys are using can return false negatives in a situation like this:



Even though the line that's being checked crosses over two wall tiles, there's a good chance of both being "missed" because not enough points along the line are checked.

There's also potential problems with gaps in the wall that are too small for the baddy to fit through, but that's more of a problem of the script's scope rather than it not correctly doing what it's suppose to do (check if a line intersects with a wall).
__________________
Reply With Quote
  #20  
Old 08-26-2007, 06:00 AM
DustyPorViva DustyPorViva is offline
Will work for food. Maybe
DustyPorViva's Avatar
Join Date: Sep 2003
Location: Maryland, USA
Posts: 9,589
DustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond repute
Send a message via AIM to DustyPorViva Send a message via MSN to DustyPorViva
There's no real way to avoid that other than upping the check. Actually, his script is using onwall2, and checking a whole tile rather than a single pixel, so that's a good step in avoiding that problem. I believe this is the simplest way to do this other than doing a lot of of CPU hogging loops.
As for going around walls, I've done something similar, which I posted in the code gallery if you want to check it out. Instead of doing pathfinding like A*, it simple logged the players movements and 'followed' them. It was kind of cheating, but it worked, if you want to get ideas from it.
Reply With Quote
  #21  
Old 08-26-2007, 06:10 AM
Googi Googi is offline
A Serious Epidemic
Googi's Avatar
Join Date: Oct 2001
Location: Canada
Posts: 18,866
Googi has much to be proud ofGoogi has much to be proud ofGoogi has much to be proud ofGoogi has much to be proud ofGoogi has much to be proud ofGoogi has much to be proud of
Send a message via AIM to Googi
Quote:
Originally Posted by DustyPorViva View Post
There's no real way to avoid that other than upping the check. Actually, his script is using onwall2, and checking a whole tile rather than a single pixel, so that's a good step in avoiding that problem.
Thinking about it further, that problem wouldn't actually happen except under very rare circumstances, and can be eliminated entirely by increasing size of the area checked to 1.1,1.1. A greater problem would be the potential for the script to break down when the player is right up against a wall (shouldn't be a problem with 1,1, but would be with 1.1,1.1) or worse, "half" on a wall, as I'm sure you know is entirely possible (and would cause a breakdown even with 1,1).
__________________
Reply With Quote
  #22  
Old 08-26-2007, 06:14 AM
DustyPorViva DustyPorViva is offline
Will work for food. Maybe
DustyPorViva's Avatar
Join Date: Sep 2003
Location: Maryland, USA
Posts: 9,589
DustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond repute
Send a message via AIM to DustyPorViva Send a message via MSN to DustyPorViva
Well that can be fixed by upping the check, for example:
PHP Code:
while (i<dist/.5) {
  
onwall2(x+(dx/(dist/.5))*i,x+(dx/(dist/.5))*i),1,1);
  
i+=.5;

But that only increases the loop substantially. A simple fix would be to do a seperate check BEFORE doing the check between the two points, that involves checking for a wall in the direction of the player, but only half a tile away. If there is no wall, carry on with checking between them.
Reply With Quote
  #23  
Old 08-26-2007, 06:16 AM
coreys coreys is offline
N-Pulse Assistant Manager
coreys's Avatar
Join Date: Mar 2005
Posts: 2,180
coreys has a spectacular aura about
Send a message via AIM to coreys Send a message via MSN to coreys Send a message via Yahoo to coreys
Well the way my baddy class works, a player getting up next to a wall, or even half on one, isn't a problem.

But now I'm having trouble with the pathcheck...in some cases it thinks theres a wall in between us, when there isn't...O.o
__________________

Quote:
*SlikRick: so should I even ask about your aim status?
*Xor: well if you want to
*Xor: but i am LARPING
*SlikRick: While on a computer?
*Xor: yes
*Xor: in my living room
*SlikRick: ahh
*Xor: i have a fort setup to hide from beasts
Reply With Quote
  #24  
Old 08-26-2007, 06:38 AM
Googi Googi is offline
A Serious Epidemic
Googi's Avatar
Join Date: Oct 2001
Location: Canada
Posts: 18,866
Googi has much to be proud ofGoogi has much to be proud ofGoogi has much to be proud ofGoogi has much to be proud ofGoogi has much to be proud ofGoogi has much to be proud of
Send a message via AIM to Googi
Quote:
Originally Posted by coreys View Post
Well the way my baddy class works, a player getting up next to a wall, or even half on one, isn't a problem.
It would cause the script to return what would more or less be false positives.

Quote:
Originally Posted by coreys View Post
But now I'm having trouble with the pathcheck...in some cases it thinks theres a wall in between us, when there isn't...O.o
Perhaps the line it's checking partially intersects a wall? Try having it put something (putnpc, showimg, even putbomb) at each point it checks along the line.

Regarding pathfinding and CPU usage, I don't know much about the limitations Graal servers have to work under, but Yen has claimed that pathfinding is impossible to do for every baddy without crashing the server.

If I were going to try to make a pathfinding script, I'd have it have two "levels". Macro and micro. First I'd divide each level into sectors (like in the attachment) and have the baddy first determine which sector the player is in. Each baddy would have a preprogrammed path to each sector within its level and it would follow its preprogrammed path (while checking if the player changes sectors and adjusting its path accordingly by determining the best route to get to the preprogrammed path to the new sector). Once it got to the same sector as the player then it would go into "micro" mode and do normal shortest-distance-to-the-player pathfinding. There's minor problems like the player changing sectors while the baddy is in micro mode, but they wouldn't be too hard to solve. The biggest problem would be that it's hard on the scripters as unique preprogrammed paths would have to be created for every single baddy.
Attached Thumbnails
Click image for larger version

Name:	sectors.jpg
Views:	181
Size:	119.2 KB
ID:	42614  
__________________
Reply With Quote
  #25  
Old 08-26-2007, 06:45 AM
DustyPorViva DustyPorViva is offline
Will work for food. Maybe
DustyPorViva's Avatar
Join Date: Sep 2003
Location: Maryland, USA
Posts: 9,589
DustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond repute
Send a message via AIM to DustyPorViva Send a message via MSN to DustyPorViva
Kaimetsu had a good theory on pathfinding. Instead of actually calculating tiles, he said that it would be easier to predefine nodes in levels, and have the NPC 'pathfind' through the nodes instead of the tiles. This means you'd be able to up the accuracy in tight spots by placing more nodes, and get lax in large spaces by only placing a couple nodes. I'd honestly put aside pathfinding though, it's way too much for something so simple.

I made a baddy, that instead of going in the direction of the player, moved left or right/up or down, depending on the player's position. This meant that instead of running straight into a wall and stopping, he'd run into the wall, but if the player was still lower than him keep running down and around the obstacle. Of course this wouldn't work in messy levels, and not too effective if the player is still right in front of the baddy, but it was better than the average running towards the player script.
Reply With Quote
  #26  
Old 08-26-2007, 07:03 AM
Inverness Inverness is offline
Incubator
Inverness's Avatar
Join Date: Aug 2004
Location: Houston, Texas
Posts: 3,613
Inverness is a jewel in the roughInverness is a jewel in the rough
Predefining nodes is how its done in most 3D games. Its certainly a good option.
PHP Code:
//#CLIENTSIDE
function onCreated() {
  
this.level.nodes = {
    {
5130},
    {
20240},
    {
30300},
  };

It could be defined in that manner for compatibility with the vector functions.

Or probably a better idea for nodes is to store them all serverside in a database and have them sent to player on login or such. Also you could make some staff tool that highlights nodes in levels with lights and allows you to place new ones and such.
__________________
Reply With Quote
  #27  
Old 08-26-2007, 07:29 AM
coreys coreys is offline
N-Pulse Assistant Manager
coreys's Avatar
Join Date: Mar 2005
Posts: 2,180
coreys has a spectacular aura about
Send a message via AIM to coreys Send a message via MSN to coreys Send a message via Yahoo to coreys
Damn that's a pain in the ass.

And no, it's having problems even when there IS no wall in between the player and the baddy. But only sometimes. o.0
__________________

Quote:
*SlikRick: so should I even ask about your aim status?
*Xor: well if you want to
*Xor: but i am LARPING
*SlikRick: While on a computer?
*Xor: yes
*Xor: in my living room
*SlikRick: ahh
*Xor: i have a fort setup to hide from beasts
Reply With Quote
  #28  
Old 08-26-2007, 07:41 AM
Twinny Twinny is offline
My empire of dirt
Twinny's Avatar
Join Date: Mar 2006
Location: Australia
Posts: 2,422
Twinny is just really niceTwinny is just really nice
Send a message via AIM to Twinny
I set up nodes all over my gmaps while using dynamic a* to navigate between nodes. I figured that using a* for a whole gmap would quickly set fire to the NPC-Server .
Reply With Quote
  #29  
Old 08-26-2007, 08:53 AM
Googi Googi is offline
A Serious Epidemic
Googi's Avatar
Join Date: Oct 2001
Location: Canada
Posts: 18,866
Googi has much to be proud ofGoogi has much to be proud ofGoogi has much to be proud ofGoogi has much to be proud ofGoogi has much to be proud ofGoogi has much to be proud of
Send a message via AIM to Googi
Quote:
Originally Posted by coreys View Post
Damn that's a pain in the ass.

And no, it's having problems even when there IS no wall in between the player and the baddy. But only sometimes. o.0
Does it happen when there isn't a single wall tile in the entire level?
__________________
Reply With Quote
  #30  
Old 08-26-2007, 03:52 PM
coreys coreys is offline
N-Pulse Assistant Manager
coreys's Avatar
Join Date: Mar 2005
Posts: 2,180
coreys has a spectacular aura about
Send a message via AIM to coreys Send a message via MSN to coreys Send a message via Yahoo to coreys
Quote:
Originally Posted by Googi View Post
Does it happen when there isn't a single wall tile in the entire level?
Well I hadn't tried that. I naturally kinda figured that it was just checking in the wrong places. And I can't do a showimg where it's checking since this is all serverside.

Edit:
Also, if I used putnpc2() I'd most likely crash the server.

Edit:
I made it so it would only use putnpc2() to show where it's checking the path ONCE, so it wouldn't crash the server. It's pretty off. o.o
__________________

Quote:
*SlikRick: so should I even ask about your aim status?
*Xor: well if you want to
*Xor: but i am LARPING
*SlikRick: While on a computer?
*Xor: yes
*Xor: in my living room
*SlikRick: ahh
*Xor: i have a fort setup to hide from beasts

Last edited by coreys; 08-26-2007 at 04:14 PM..
Reply With Quote
  #31  
Old 08-26-2007, 04:35 PM
PrinceOfKenshin PrinceOfKenshin is offline
That guy with a beard
PrinceOfKenshin's Avatar
Join Date: May 2004
Location: Ontario, Canada
Posts: 819
PrinceOfKenshin has a spectacular aura aboutPrinceOfKenshin has a spectacular aura about
Cool

Quote:
Originally Posted by Twinny View Post
I set up nodes all over my gmaps while using dynamic a* to navigate between nodes. I figured that using a* for a whole gmap would quickly set fire to the NPC-Server .
hehe 10 points for Twinny <3

I hate scripting baddys they are a pain. I'm trying to work on some IRC for atrius and boy does my head hurt
__________________


Quote:
Game Master (Server): Greetings PrinceOfKenshin, there are new posts on the forums that demand your urgent attention! God speed, the fate of the world is in your hands. If you fail, middle earth will forever be in the darkness and your children will be enslaved by McKain.
Reply With Quote
  #32  
Old 08-26-2007, 10:11 PM
coreys coreys is offline
N-Pulse Assistant Manager
coreys's Avatar
Join Date: Mar 2005
Posts: 2,180
coreys has a spectacular aura about
Send a message via AIM to coreys Send a message via MSN to coreys Send a message via Yahoo to coreys
This is what I have now.

PHP Code:
function checkPath(oxdxoydy) {
  
temp.dx = (dx 1.25) - (ox 1.25);
  
temp.dy = (dy 1.25) - (oy 1.25);
  
temp.delta getDist((ox 1.25), (oy 1.25), (dx 1.25), (dy 1.25));
  
0;
  
temp.onwall false;
  while (
temp.delta) {
    
this.chat temp.onwall;
    
//putnpc2((ox + 1.25) + ((temp.dx/temp.delta) * i), (oy + 1.25) + ((temp.dy/temp.delta) * i), "join(\"object_chair\");");
    
if (onwall2((ox 1.25) + ((temp.dx/temp.delta) * i), (oy 1.25) + ((temp.dy/temp.delta) * i),.5,.5)) {
      
temp.onwall true;
      
this.chat temp.onwall;
      break;
    }
    
+= .75;
  }
  return 
temp.onwall;

It's always returning true, and it isn't always working correctly.

All the + 1.25 and all that is so that it's centered from the center of the baddy to the center of the player, so that it's not going from the left corner of the baddy to the left corner of the player.
__________________

Quote:
*SlikRick: so should I even ask about your aim status?
*Xor: well if you want to
*Xor: but i am LARPING
*SlikRick: While on a computer?
*Xor: yes
*Xor: in my living room
*SlikRick: ahh
*Xor: i have a fort setup to hide from beasts
Reply With Quote
  #33  
Old 08-26-2007, 10:15 PM
DustyPorViva DustyPorViva is offline
Will work for food. Maybe
DustyPorViva's Avatar
Join Date: Sep 2003
Location: Maryland, USA
Posts: 9,589
DustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond repute
Send a message via AIM to DustyPorViva Send a message via MSN to DustyPorViva
You can't have i increasing by .75, it has to be by one unless you go through the trouble of increasing the loop and distance between each check(I described how to do that up there). I don't really see a reason to lower it below 1 though.

I've ran tests on the last script I posted and I'm not having any such problems with it, this is on a gmap as well.

Also, you might want to do the checks for finding the 'center' of the player/npc BEFORE the function, and send them through the parameters, instead of doing all that in the function.
Reply With Quote
  #34  
Old 08-26-2007, 10:31 PM
coreys coreys is offline
N-Pulse Assistant Manager
coreys's Avatar
Join Date: Mar 2005
Posts: 2,180
coreys has a spectacular aura about
Send a message via AIM to coreys Send a message via MSN to coreys Send a message via Yahoo to coreys
Quote:
Originally Posted by DustyPorViva View Post
You can't have i increasing by .75, it has to be by one unless you go through the trouble of increasing the loop and distance between each check(I described how to do that up there). I don't really see a reason to lower it below 1 though.

I've ran tests on the last script I posted and I'm not having any such problems with it, this is on a gmap as well.

Also, you might want to do the checks for finding the 'center' of the player/npc BEFORE the function, and send them through the parameters, instead of doing all that in the function.
Well it seems like onwall2() is returning true when it shouldn't, sometimes...
__________________

Quote:
*SlikRick: so should I even ask about your aim status?
*Xor: well if you want to
*Xor: but i am LARPING
*SlikRick: While on a computer?
*Xor: yes
*Xor: in my living room
*SlikRick: ahh
*Xor: i have a fort setup to hide from beasts
Reply With Quote
  #35  
Old 08-27-2007, 12:07 AM
Googi Googi is offline
A Serious Epidemic
Googi's Avatar
Join Date: Oct 2001
Location: Canada
Posts: 18,866
Googi has much to be proud ofGoogi has much to be proud ofGoogi has much to be proud ofGoogi has much to be proud ofGoogi has much to be proud ofGoogi has much to be proud of
Send a message via AIM to Googi
Quote:
Originally Posted by coreys View Post
Well it seems like onwall2() is returning true when it shouldn't, sometimes...
Have you tried it in a level with no wall tiles yet?
__________________
Reply With Quote
  #36  
Old 08-27-2007, 01:25 AM
coreys coreys is offline
N-Pulse Assistant Manager
coreys's Avatar
Join Date: Mar 2005
Posts: 2,180
coreys has a spectacular aura about
Send a message via AIM to coreys Send a message via MSN to coreys Send a message via Yahoo to coreys
Yes, just did, it's returning true o.0
__________________

Quote:
*SlikRick: so should I even ask about your aim status?
*Xor: well if you want to
*Xor: but i am LARPING
*SlikRick: While on a computer?
*Xor: yes
*Xor: in my living room
*SlikRick: ahh
*Xor: i have a fort setup to hide from beasts
Reply With Quote
  #37  
Old 08-27-2007, 01:33 AM
DustyPorViva DustyPorViva is offline
Will work for food. Maybe
DustyPorViva's Avatar
Join Date: Sep 2003
Location: Maryland, USA
Posts: 9,589
DustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond repute
Send a message via AIM to DustyPorViva Send a message via MSN to DustyPorViva
No idea... maybe it's your server. The script I posted works fine, and it used onwall2...
Reply With Quote
  #38  
Old 08-27-2007, 02:03 AM
coreys coreys is offline
N-Pulse Assistant Manager
coreys's Avatar
Join Date: Mar 2005
Posts: 2,180
coreys has a spectacular aura about
Send a message via AIM to coreys Send a message via MSN to coreys Send a message via Yahoo to coreys
I'm getting this sort of thing...(the red square represents where it's checking)
Also, in a completely blank level, sometimes the onwalls returns true sometimes false. It should ALWAYS return false. ._.

EDIT:
Actually it's returning true unless the player is to the npcs left, or below it. o.0
OH I SEE, it's a problem with negatives.
Attached Images
 
__________________

Quote:
*SlikRick: so should I even ask about your aim status?
*Xor: well if you want to
*Xor: but i am LARPING
*SlikRick: While on a computer?
*Xor: yes
*Xor: in my living room
*SlikRick: ahh
*Xor: i have a fort setup to hide from beasts
Reply With Quote
  #39  
Old 08-29-2007, 02:50 AM
bscharff bscharff is offline
Bloo
bscharff's Avatar
Join Date: Sep 2006
Location: San Antonio, Texas
Posts: 185
bscharff has a little shameless behaviour in the past
Send a message via AIM to bscharff Send a message via MSN to bscharff Send a message via Yahoo to bscharff
Fairly Simple - Not Sure If It Would Work In Your Situation...
I've Only Read The First Page - Too Lazy
Of Course Add Timeout Etc Blah Blah:

PHP Code:

this
.width = (this.player.x);
this.height 2;

if (
onwall2(this.x,this.y,this,width,this.height)){

}else{
this.mode "idle"//Whatever Your Go Into Idle Is

__________________
Trying to be nice now...
Reply With Quote
  #40  
Old 08-29-2007, 03:47 AM
coreys coreys is offline
N-Pulse Assistant Manager
coreys's Avatar
Join Date: Mar 2005
Posts: 2,180
coreys has a spectacular aura about
Send a message via AIM to coreys Send a message via MSN to coreys Send a message via Yahoo to coreys
Not nearly accurate enough.
__________________

Quote:
*SlikRick: so should I even ask about your aim status?
*Xor: well if you want to
*Xor: but i am LARPING
*SlikRick: While on a computer?
*Xor: yes
*Xor: in my living room
*SlikRick: ahh
*Xor: i have a fort setup to hide from beasts
Reply With Quote
Reply


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 11:19 PM.


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