Graal Forums

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

Devil_Lord2 04-05-2012 02:51 AM

WallBlocking Serverside??
 

I don't understand why there does not have to be anything blocking in the way, yet it keeps returning blocking...
Does onwall not work serverside / in a class?

Currently I have it commented off as shown below or it would just keep turning around.

PHP Code:

function onTimeout(){
  if (
this.mode == WALK) {
    if (
players.size() > 0) {
      
setTimer(.1);
    }
    else {
      
setTimer(0);
    }
    
this.to_check findnearestplayer(this.xthis.y);
    
temp.newx this.vecx(this.dir) * this.mov_speed;
    
temp.newy this.vecy(this.dir) * this.mov_speed;
    
//this.chat = this.x SPC this.y SPC "New is" SPC new_x SPC new_y;
    
this.count--;
    if (
this.count 0) {
      if (
this.ani != "sl_animal_cow-walk") {
        
setcharani("sl_animal_cow-walk",null);
      }
      
temp.testx newx 1.5 vecx(this.dir);
      
temp.testy newy vecy(this.dir);  
      
/*
      if (checkBlockedTile(testx,testy)){
        this.dir = (this.dir + 2) % 4;
      }   
      */      
      //else {
        
this.newx;
        
this.newy;
      
//}
    


PHP Code:

function checkBlockedTile(xValueyValue) { //Check if tile is not walkable 
  
if (onwall(xValueyValue) || onwater(xValueyValue)) {
    
this.chat "test";
    return 
true;
  }
  else {
    
//this.chat = "not blocking";
    
this.chat "yesy";
    return 
false;
  }



DustyPorViva 04-05-2012 03:00 AM

Onwall only checks a single pixel. Use onwall2(posx,posy,width,height);

Devil_Lord2 04-05-2012 03:02 AM

Quote:

Originally Posted by DustyPorViva (Post 1691123)
Onwall only checks a single pixel. Use onwall2(posx,posy,width,height);

It sets off both water and wall,
should I only have it check walls?

onwall2(xvalue,yvaluse,16,16); ?

Is it counting it self a wall?

I tried onwall(xvalue+.8,yvaluse+.8);
but that didn't seem to work haha..

DustyPorViva 04-05-2012 03:22 AM

Quote:

Originally Posted by Devil_Lord2 (Post 1691125)
It sets off both water and wall,
should I only have it check walls?

onwall2(xvalue,yvaluse,16,16); ?

Is it counting it self a wall?

I tried onwall(xvalue+.8,yvaluse+.8);
but that didn't seem to work haha..

PHP Code:

if (!onwall2(newx,newy,3,4)) {
  
// proceed with walking


Onwall2 width and height is in tiles. Just adjust the 3 and 4 to the specific size of the cow, especially for each direction where the NPCs proportions change.

Devil_Lord2 04-05-2012 03:23 AM

Quote:

Originally Posted by DustyPorViva (Post 1691127)
PHP Code:

if (!onwall2(newx,newy,3,4)) {
  
// proceed with walking


Onwall2 width and height is in tiles. Just adjust the 3 and 4 to the specific size of the cow, especially for each direction where the NPCs proportions change.

Alright! I shall see if this works, thank you for now!


I've tried both ways with no luck.. testx and y, and newx and y
I can now understand why Zodiac doesn't have wall checking. x.x;;

PHP Code:

if (this.count 0) {
      if (
this.ani != "sl_animal_cow-walk") {
        
setcharani("sl_animal_cow-walk",null);
      }
      
temp.testx newx 1.5 vecx(this.dir);
      
temp.testy newy vecy(this.dir);  
      
/*
      if (checkBlockedTile(testx,testy)){
        this.dir = (this.dir + 2) % 4;
      }   
            
      else {
        this.x = newx;
        this.y = newy;
      } 
      */
      
if (dir == && !onwall2(testx,testy,3,4)) {
        
this.newx;
        
this.newy;
      }
      else if (
dir == && !onwall2(testx,testy,5,4)) {
        
this.newx;
        
this.newy;
      }
      else if (
dir == && !onwall2(testx,testy,3,4)) {
        
this.newx;
        
this.newy;
      }
      else if (
dir == && !onwall2(testx,testy,5,4)) {
        
this.newx;
        
this.newy;
      }
      else{
        
this.dir = (this.dir 2) % 4;
      } 
    } 


DustyPorViva 04-05-2012 03:36 AM

I didn't use testx for a reason, newx would have sufficed lol. The only position you need to check is its intended(new) position. The testx/testy stuff is for onwall use, because as it was previously mentioned, only checks a single pixel; so typically you'd center the check in the player and then offset the check by half the size of the player. There's no reason to do any of that more complicated checking here.

I feel this is an instance of you using preexisting code and hacking it up but not actually being aware of what any of it does. Examine what you're doing logistically and this sort of stuff will make sense.

Devil_Lord2 04-05-2012 03:42 AM

Quote:

Originally Posted by DustyPorViva (Post 1691132)
I didn't use testx for a reason, newx would have sufficed lol. The only position you need to check is its intended(new) position.

Either way it has mad cow and keeps changing directions. D:

PHP Code:

    temp.newx this.vecx(this.dir) * this.mov_speed;
    
temp.newy this.vecy(this.dir) * this.mov_speed;
    
//this.chat = this.x SPC this.y SPC "New is" SPC new_x SPC new_y;
    
this.count--;
    if (
this.count 0) {
      if (
this.ani != "sl_animal_cow-walk") {
        
setcharani("sl_animal_cow-walk",null);
      }
      
temp.testx newx 1.5 vecx(this.dir);
      
temp.testy newy vecy(this.dir);  
      
/*
      if (checkBlockedTile(testx,testy)){
        this.dir = (this.dir + 2) % 4;
      }   
            
      else {
        this.x = newx;
        this.y = newy;
      } 
      */
      
if (dir == && !onwall2(newx,newy,3,4)) {
        
this.newx;
        
this.newy;
      }
      else if (
dir == && !onwall2(newx,newy,5,4)) {
        
this.newx;
        
this.newy;
      }
      else if (
dir == && !onwall2(newx,newy,3,4)) {
        
this.newx;
        
this.newy;
      }
      else if (
dir == && !onwall2(newx,newy,5,4)) {
        
this.newx;
        
this.newy;
      }
      else{
        
this.dir = (this.dir 2) % 4;
      } 
    } 

Quote:

Originally Posted by DustyPorViva (Post 1691132)
I feel this is an instance of you using preexisting code and hacking it up but not actually being aware of what any of it does. Examine what you're doing logistically and this sort of stuff will make sense.

I feel the exact same way since there really isn't any other way to learn onwall..

Honestly I didn't even know why one would use the function for onwall check when you could do it in the original code, but either way it would not work so I kept the original baddy format.

If I knew how to do serverside onwall support my pet system would have been finished 6 months ago. :D Since onwall was the only thing missing.


Anyway, all I wanted was the random walking and wall check. Apparently that doesn't work sadly and so far nothing has fixed it, once again like my pet system, I'll leave it alone for a while. x.x;;


Oh sorry, yeah I missed a part, I know what is going on up until why it keeps thinking it hits a wall. I've tried debugging it and onwater and onwall keep going off over and over and over.

I mean I haven't had it check the tiles and have it chat which tiles are being checked, but I also feel I should not have to go that far.. D:

DustyPorViva 04-05-2012 03:58 AM

It's never too far to debug your own code when you're encountering a problem.

Devil_Lord2 04-05-2012 04:05 AM

I can give you a video of me debugging it if you'd like. It takes the tile in front of it, the x and y, and still says that it is water and wall tile... From there I don't understand how one could debug it further, it sounds like a server error..

DustyPorViva 04-05-2012 04:14 AM

Well a lot of the problem is coming from you Frankenstein scripts together. For example, you're using an enumerator, and I'm almost positive you have no idea what that is or how to use it. An enumerator for something this simple(with two modes) is kind of a waste. You're also not prefixing some variables correctly, or at all, indicating they're copied from the GS1 scripts, and you're showing signs of using things that you have no idea what their actual purpose is.

Learning from existing code is not wrong. In fact, it's how I learned, and the only way some people like myself can learn. However you're not learning anything. You're jumping right from having no scripts of your own, to pasting in existing scripts together to get what you desire, then not knowing why all of this stuff you're not familiar with isn't working. You need to take a step back and analyze what the hell you're actually doing and working with. You're using scripts and formulations that you have no idea what they actually do, and if you did you'd probably see what the problem is.

Yes, Graal documentation is poor but the gscript wiki is still decent enough to use while analyzing existing scripts and learning from them. Once you analyze the scripts you're using and figure out why they're doing what they're doing, and come to an understanding of how your script functions, you'll have a much easier time progressing.

Devil_Lord2 04-05-2012 04:22 AM

Quote:

Originally Posted by DustyPorViva (Post 1691138)
Well a lot of the problem is coming from you Frankenstein scripts together. For example, you're using an enumerator, and I'm almost positive you have no idea what that is or how to use it. An enumerator for something this simple(with two modes) is kind of a waste. You're also not prefixing some variables correctly, or at all, indicating they're copied from the GS1 scripts, and you're showing signs of using things that you have no idea what their actual purpose is.

Learning from existing code is not wrong. In fact, it's how I learned, and the only way some people like myself can learn. However you're not learning anything. You're jumping right from having no scripts of your own, to pasting in existing scripts together to get what you desire, then not knowing why all of this stuff you're not familiar with isn't working. You need to take a step back and analyze what the hell you're actually doing and working with. You're using scripts and formulations that you have no idea what they actually do, and if you did you'd probably see what the problem is.

Yes, Graal documentation is poor but the gscript wiki is still decent enough to use while analyzing existing scripts and learning from them. Once you analyze the scripts you're using and figure out why they're doing what they're doing, and come to an understanding of how your script functions, you'll have a much easier time progressing.

I didn't paste my whole script since I don't really want anyone taking them lol.. Enumerators "which I talked about on the learn to script school"
http://scriptingschool.forumotion.co...-and-constants

are just constant strings / variables.. I was only using it as a cool looking topic header. :D

Anyway, uploading the error which still makes no sense and I still feel is a server error...
I found a stupid solution which you can see my debugging process.. and a crazy idea.


95% complete

DustyPorViva 04-05-2012 04:27 AM

This is something you could probably just switch over to clientside and see if the issue persists, and debug/refine the code there. This would be preferable since you can debug with easier methods, such as displaying images/polygons at the collision checks for visual reference, etc.

Devil_Lord2 04-05-2012 04:29 AM

Quote:

Originally Posted by DustyPorViva (Post 1691140)
This is something you could probably just switch over to clientside and see if the issue persists, and debug/refine the code there. This would be preferable since you can debug with easier methods, such as displaying images/polygons at the collision checks for visual reference, etc.

I believe it worked clientside but I don't remember lol..
I went past that after some reason.. My memory isn't too great.
Check the video, it seems like the type of grass is blocking...
Still makes no sense to me.. :c

I don't know how to use polygons and not sure how images would help checking o.o;;


Video is up... for some reason the grass is blocking and I still don't know why..
I mean, would it be appropriate to do
PHP Code:

 if (checkBlockedTile(newx,newy) && tile[newx,newy] != 533){
        
this.dir = (this.dir 2) % 4;
      } 

Seems like something that shouldn't need to be done..


PHP Code:

      if (checkBlockedTile(newx,newy) && tiles[newx,newy] != 511){
        
this.dir = (this.dir 2) % 4;
      } 

Well it works now, wasn't the type of solution I was expecting but whatever...

DustyPorViva 04-05-2012 04:46 AM

Post your tileset?

Devil_Lord2 04-05-2012 04:51 AM

1 Attachment(s)
*Advisory Warning
This is the Shaded Legends tileset, and is meant to be used only on Shaded Legends as far as I know. By posting this image I am not giving the right for anyone to use it on other servers.



So, here is the tileset, type0, yet it walks on fences and says water every once in a while... I don't think it can walk on ... I don't know it just confuses me and I still think it is a server thing..

Oops wait that is my type1, let me change that lol..
That isn't the one being used hold on.

-EDIT-
The tileset being used is posted.
I'm overall just confused now lol.. It shows water sometimes randomly, and I think the +1.5 and stuff wasn't needed and is checking slightly further than needed.


All times are GMT +2. The time now is 01:16 AM.

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