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 07-22-2008, 04:41 AM
Switch Switch is offline
o.o
Switch's Avatar
Join Date: Jan 2007
Location: Philadelphia
Posts: 3,038
Switch has a spectacular aura about
Send a message via MSN to Switch
Tile Checking

As I'm trying to fix the shovel on Zenkou, which I'm almost done fixing for the known bugs, I need to know how to check if one tile is in the same level as another.

I know it sounds wierd but let me explain.
If you're digging for a shell (diggable in sand only) and you're in the middle of the jungle and dig on sand, you can still get a shell. That's kind of improbable in real terms. So what I'm trying to do is find out how to check in the sand tile is in the same level as a deepwater tile.

All I really need to know is how to check the tile in a script.
For example, these 2 tiles are grass tiles on Zenkou.
PHP Code:
0x31,0x1A4 
So I see that a tile can be either a "number x(by) number" or "number x(by) letters/numbers".
This is confusing to me because I've never worked with tiles I didn't already have in a script.

What I'm asking for is help with figuring out what a certain tile is.
__________________
Oh squiggly line in my eye fluid. I see you lurking there on the peripheral of my vision.
But when I try to look at you, you scurry away.
Are you shy, squiggly line?
Why only when I ignore you, do you return to the center of my eye?
Oh, squiggly line, it's alright, you are forgiven.
Reply With Quote
  #2  
Old 07-22-2008, 04:50 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 you can run a loop when the player enters a level like...

PHP Code:
function onPlayerenters() {
  for (
i=0;i<64*64;i++) { // check every tile in the level
    
if (tiles[i%64,int(i/64)] == watertilehex) { // this would have to be edited to check the current level, as on a gmap this would just check the top left corner
      
this.levelcontainswater true// yes, there's water in the level
      
break; // no need to check for more water, right? So let's stop checking!
    
}
  }

The problem with this is the fact that depending on the levels, you could be right next to water, but there will actually be no water in your current level(because of gmaps), so it could end up reading as false. So instead of checking the level, just check the tiles surrounding the player?

An even simpler method would just be using level.vars!
Reply With Quote
  #3  
Old 07-22-2008, 04:54 AM
Switch Switch is offline
o.o
Switch's Avatar
Join Date: Jan 2007
Location: Philadelphia
Posts: 3,038
Switch has a spectacular aura about
Send a message via MSN to Switch
Quote:
Originally Posted by DustyPorViva View Post
Well you can run a loop when the player enters a level like...

PHP Code:
function onPlayerenters() {
  for (
i=0;i<64*64;i++) {
    if (
tiles[i%64,int(i/64)] == watertilehex) {
      
this.levelcontainswater true;
      break; 
// no need to check for more water, right?
    
}
  }

I guess, but I want it to be a little more simple to blend with the script it'll be put into, so I just want to know how to find a tile "blank"x"blank"
__________________
Oh squiggly line in my eye fluid. I see you lurking there on the peripheral of my vision.
But when I try to look at you, you scurry away.
Are you shy, squiggly line?
Why only when I ignore you, do you return to the center of my eye?
Oh, squiggly line, it's alright, you are forgiven.
Reply With Quote
  #4  
Old 07-22-2008, 04:55 AM
cbk1994 cbk1994 is offline
the fake one
cbk1994's Avatar
Join Date: Mar 2003
Location: San Francisco
Posts: 10,718
cbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond repute
Send a message via AIM to cbk1994
Quote:
Originally Posted by Switch View Post
I guess, but I want it to be a little more simple to blend with the script it'll be put into, so I just want to know how to find a tile "blank"x"blank"
tiles[ dx, dy ]
__________________
Reply With Quote
  #5  
Old 07-22-2008, 05:13 AM
Switch Switch is offline
o.o
Switch's Avatar
Join Date: Jan 2007
Location: Philadelphia
Posts: 3,038
Switch has a spectacular aura about
Send a message via MSN to Switch
Quote:
Originally Posted by cbk1994 View Post
tiles[ dx, dy ]
explain what the d is, please?
__________________
Oh squiggly line in my eye fluid. I see you lurking there on the peripheral of my vision.
But when I try to look at you, you scurry away.
Are you shy, squiggly line?
Why only when I ignore you, do you return to the center of my eye?
Oh, squiggly line, it's alright, you are forgiven.
Reply With Quote
  #6  
Old 07-22-2008, 05:16 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
Heh... nothing. Typically it's for delta but there is no delta in this case.

Tiles[x,y] is what you're looking for... which is the same. Now what you do is...

tiles[x,y](x and y are... well, the x and y you're checking) == hex.

So...
if (tiles[x,y] in {0x31,0x1A4}) {}
Would check if the tiles at the given position match what you provided in the original post.
Reply With Quote
  #7  
Old 07-22-2008, 05:20 AM
Loriel Loriel is offline
Somewhat rusty
Loriel's Avatar
Join Date: Mar 2001
Posts: 5,059
Loriel is a name known to allLoriel is a name known to allLoriel is a name known to allLoriel is a name known to all
Quote:
Originally Posted by Switch View Post
PHP Code:
0x31,0x1A4 
Those are hexadecimal numbers. That is just fancy syntax for regular numbers. The "0x" just means that the number is given in base 16, not base 10 as numbers usually are. You can look up the details on the internet, but as you are not going to do math with them manually, you do not really have to care because you can stuff them into variables or whatever and use them like regular numbers.

You use tiles[x, y] to check the number (as above) of the tile at x, y in the current level. You can compare it against the number of your water tile or whatever.

Checking whether a given tile is present in the current level is not going to get any easier than for-loops to check every tile on its own. Just put it into a function.

It might be easier to just flag all levels that are supposed to yield shells by putting an NPC that does something like level.canDigForShells = true, or however that works.
Reply With Quote
  #8  
Old 07-22-2008, 07:04 AM
haro41 haro41 is offline
zenkou
haro41's Avatar
Join Date: Jul 2003
Location: Sol Grotto
Posts: 689
haro41 will become famous soon enough
Send a message via AIM to haro41
yes but this will be a fairly large list of levels, given the style of our playerworld. completed, this list could top 300+

i guess an alternative we could do is to rename all the levels that would have seashells to end with beach.nw
i guess that wouldnt take to long, and then also we would have to edit the gmap file. anything else with this solution?
__________________

Zenkou for life
Reply With Quote
  #9  
Old 07-22-2008, 07:38 AM
WhiteDragon WhiteDragon is offline
Banned
Join Date: Feb 2007
Posts: 1,002
WhiteDragon is a splendid one to beholdWhiteDragon is a splendid one to beholdWhiteDragon is a splendid one to beholdWhiteDragon is a splendid one to beholdWhiteDragon is a splendid one to behold
You could just drop a
PHP Code:
join("spawn_seashells"); 
NPC in the level and then alter the shovel accordingly.



Or, you could check outwards from the point to a certain radius on the tiles.

PHP Code:
// Archimedean spiral
this.1// turns the spiral
this.1// distance between successive turns
this.thetaMax pi// increasing this will make it spiral out farther
this.tileRange = {0x31,0x1A4};
function 
polarToCartesian(temp.polarCoord) {
  return {
            
temp.polarCoord[0]*cos(temp.polarCoord[1]),
            
temp.polarCoord[0]*sin(temp.polarCoord[1])
           };
}
function 
onDig(temp.coord) { // no idea how you're doing this, but let's say onDig() get's called with {x,y} of the dig spot
  
for (temp.theta 0temp.theta this.thetaMaxtemp.theta+= pi/16) {
    
temp.normalizedCoord polarToCartesian({this.this.b*temp.thetatemp.theta});
    if (
tiles[temp.normalizedCoord[0]+temp.coord[0], temp.normalizedCoord[1]+temp.coord[1]] in this.tileRange) {
      
this.closeToWater true;
      break;
    }
  }
  if (
this.closeToWater) {
    
//woot
  
}

No idea if this will actually work, but the concept is there.

Probably the first way would be easier.

Last edited by WhiteDragon; 07-22-2008 at 08:56 AM..
Reply With Quote
  #10  
Old 07-22-2008, 01:46 PM
Loriel Loriel is offline
Somewhat rusty
Loriel's Avatar
Join Date: Mar 2001
Posts: 5,059
Loriel is a name known to allLoriel is a name known to allLoriel is a name known to allLoriel is a name known to all
Quote:
Originally Posted by haro41 View Post
yes but this will be a fairly large list of levels, given the style of our playerworld. completed, this list could top 300+
Adding NPCs to levels does not take that long

Quote:
i guess an alternative we could do is to rename all the levels that would have seashells to end with beach.nw
i guess that wouldnt take to long, and then also we would have to edit the gmap file. anything else with this solution?
Well, it is ugly, and if you want to do something similar for another item again you have to do it differently anyway. Changing all the names, links, gmap entries and other levels that setlevel2 to those levels is probably going to take longer than having a batch file add another NPC.
Reply With Quote
  #11  
Old 07-22-2008, 05:28 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
Quote:
Originally Posted by haro41 View Post
yes but this will be a fairly large list of levels, given the style of our playerworld. completed, this list could top 300+
That's what you have lackies for.
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 06:18 PM.


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