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.

xXziroXx 04-05-2012 06:52 AM

No one wants to steal your ****, if you genuinly want help you need to start acting like it. ****.

Devil_Lord2 04-05-2012 12:37 PM

Quote:

Originally Posted by xXziroXx (Post 1691150)
No one wants to steal your ****, if you genuinly want help you need to start acting like it. ****.

What is it that I want to help with in this thread?
There are some things I want to teach, and some things I do not, and if you'd like to get somewhere in this world, you should learn not to give away everything you come across or you won't have any kind of advantage in this world... I don't suppose I should suggest to you to give up anything you make to the Graal community as well?

Is this new? No, but for the most part I've made it my self excluding the onwall functionality that doesn't even work (could be me). And that makes me happy as well as self appreciation that I've accomplished something.

I'm going to try a few other things but if it doesn't work, I'll probably ditch onblock once again.



As far as I know, anything that uses showcharacter(); is 32x32 but I guess I'll try the size of the cow sometime today. :D

Crow 04-05-2012 01:37 PM

Quote:

Originally Posted by Devil_Lord2 (Post 1691154)
As far as I know, anything that uses showcharacter(); is 32x32 but I guess I'll try the size of the cow sometime today. :D

showCharacter() just moves the actualy shape to the dotted rectangle you can see in GraalShop (the gani editor). It's, however, changeable using setShape() just as well.

Devil_Lord2 04-05-2012 02:30 PM

Quote:

Originally Posted by Crow (Post 1691155)
showCharacter() just moves the actualy shape to the dotted rectangle you can see in GraalShop (the gani editor). It's, however, changeable using setShape() just as well.

OH!!!
I was asking yesterday if Setshape and showCharacter(); could be used together... Wow that would have been amazingly simpler putting the ganis together using setshape lol... looks like I'll have to redo it a bit and retry the onwall test.

Thank you both Crow and Dusty!
I guess I'll find out if the onwall works afterwards.
If not at least the collision will match more smoothly..


-Edit-
I owe you both rep but I cannot do it until I "spread rep".
I normally don't give negative rep but today I have since the problem occurs often between two people.

Devil_Lord2 04-08-2012 08:33 AM

Thyme Cypher is creating a baddy and helped me solved the problem...

//newtilesets=true
#newtilesetlevels=level names comma separated

We commended that out and restarted the NPC Server.
So I was semi right about it using type1...

Works perfectly.. can anyone let me know why I needed to do this, and what it would do for type1 levels?

He doesn't know, I don't know, both our things work fine now..

cbk1994 04-08-2012 05:49 PM

From the wiki:

Quote:

HTML Code:

newtilesets=true/false
newtilesetlevels=comma seperated list of levels

Whether all levels will use the new tileset layout, or a match list of levels that shall. This will influence collision behavior (onwall script function, serverside projectile hit detection, etc.) on server-side only.

You can specify just the start of the level name if you want to include a lot of levels at once (newtilesetlevels=myquest will switch on new tileset onwall behavior on server-side for myquest1.nw, myquest2.nw etc.).

DustyPorViva 04-08-2012 06:25 PM

I had a suspicion that was the problem, hence why I asked about the tileset you were using.

Devil_Lord2 04-08-2012 09:06 PM

Quote:

Originally Posted by DustyPorViva (Post 1691491)
I had a suspicion that was the problem, hence why I asked about the tileset you were using.

I see... yeah I thought it was type one, but I didn't understand how you could even set it...

Quote:

Originally Posted by cbk1994 (Post 1691487)
From the wiki:

I've seen this but I don't get it... do you leave it false and say which levels are true, or do you put it true and say which levels are true? And I'm not sure why ours has an # in front of the levels part... That description didn't help me at all which is why I prefer not to use the wiki lol

DustyPorViva 04-08-2012 09:22 PM

Quote:

Originally Posted by Devil_Lord2 (Post 1691504)
I've seen this but I don't get it... do you leave it false and say which levels are true, or do you put it true and say which levels are true? And I'm not sure why ours has an # in front of the levels part... That description didn't help me at all which is why I prefer not to use the wiki lol

You don't, they don't go together(that's why one is commented out). The first one(Boolean, or true/false) is for servers like Era that don't use pics1 at all. They can just set it globally without worrying about defining each level that uses a type 1 tileset. The second one is for servers in your instance, where you use type 0 and type 1 at the same time. The problems you encountered are exactly why that one exists.

cbk1994 04-08-2012 09:55 PM

Quote:

Originally Posted by Devil_Lord2 (Post 1691504)
I've seen this but I don't get it... do you leave it false and say which levels are true, or do you put it true and say which levels are true? And I'm not sure why ours has an # in front of the levels part... That description didn't help me at all which is why I prefer not to use the wiki lol

It is not ambiguous, but maybe not the most direct—I'm surprised you have trouble understanding it, since it's written much like your posts are (overly verbose and not very clear).
Quote:

Whether all levels will use the new tileset layout, or match list of levels that shall. This will influence collision behavior (onwall script function, serverside projectile hit detection, etc.) on server-side only.
If all your levels use type 1, newtilesets=true
If none or some of your levels use type 1, newtilesets=false

If some of your levels use type 1, newtilesetlevels=level1.nw,level2.nw,level3.nw

I'd guess it only checks the level start in newtilesetlevels, but haven't tested.

xXziroXx 04-08-2012 10:01 PM

Quote:

Originally Posted by cbk1994 (Post 1691508)
I'd guess it only checks the level start in newtilesetlevels, but haven't tested.

You can check for both level start and actual level names.

Mark Sir Link 04-08-2012 10:22 PM

Quote:

Originally Posted by xXziroXx (Post 1691509)
You can check for both level start and actual level names.

but if level1.nw were in there and there was a level stupidly named level1.nwlevel.nw it would probably also count

xXziroXx 04-08-2012 10:23 PM

Quote:

Originally Posted by Mark Sir Link (Post 1691514)
but if level1.nw were in there and there was a level stupidly named level1.nwlevel.nw it would probably also count

Well, yes, but that'd be a pretty stupid thing to name a level in the first place.

Mark Sir Link 04-08-2012 10:26 PM

Quote:

Originally Posted by xXziroXx (Post 1691515)
Well, yes, but that'd be a pretty stupid thing to name a level in the first place.

obv but the underlying point is to be explicit with what you're doing and avoid stupid naming conventions

Devil_Lord2 04-09-2012 12:07 AM

Quote:

Originally Posted by DustyPorViva (Post 1691505)
You don't, they don't go together(that's why one is commented out). The first one(Boolean, or true/false) is for servers like Era that don't use pics1 at all. They can just set it globally without worrying about defining each level that uses a type 1 tileset. The second one is for servers in your instance, where you use type 0 and type 1 at the same time. The problems you encountered are exactly why that one exists.

Ooh I see, well I'm glad they added that in lol..



Quote:

Originally Posted by cbk1994 (Post 1691508)
It is not ambiguous, but maybe not the most direct—I'm surprised you have trouble understanding it, since it's written much like your posts are (overly verbose and not very clear).


If all your levels use type 1, newtilesets=true
If none or some of your levels use type 1, newtilesets=false

If some of your levels use type 1, newtilesetlevels=level1.nw,level2.nw,level3.nw

I'd guess it only checks the level start in newtilesetlevels, but haven't tested.

I give examples and show things... much like you just did which was perfectly understandable and would have been helpful if Dusty had not have already done so lol..

You say you never I don't understand how you can say you don't yet answer things dead on usually. D: I must have written it lengthy enough to explain it enough.. usually simple is good, but I want people to fully understand so I tend to write more...


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

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