Graal Forums

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

theHAWKER 05-09-2007 05:54 AM

strange tiles...
 
i am having some truble under standing thies tiles...

in the script "dirt path" found in levels/npcs it uses numbers and letters (0xaa)

how do thise number-letter-combonations corospond to the tile set, so i can make bush generators, or things like tree genorators :D

Edit: here is a bigger example:
PHP Code:

function laypath() {
  
sandtiles = {0xaa,0xab,0x12d,0x8,0xf};
  
grasstiles = {0x0,0x1,0x10,0x1ff,0x3ff,0x7ff,0x835,0x836,0x837};
  
sandspot = {
    
0x176,0x166,0x177,
    
0x1a70xaa,0x197,
    
0x188,0x178,0x169
    
}; 


DustyPorViva 05-09-2007 06:23 AM

They're the hex-code of the tile. If you open the level editor and select tiles, and click the button at the top that looks like a circle divided into 4 parts, it'll give you the hex-codes of all the tiles you selected.

theHAWKER 05-09-2007 06:28 AM

Quote:

Originally Posted by DustyPorViva (Post 1306508)
They're the hex-code of the tile. If you open the level editor and select tiles, and click the button at the top that looks like a circle divided into 4 parts, it'll give you the hex-codes of all the tiles you selected.

ah, thank you^^

Deadly_Killer 05-09-2007 06:47 AM

1 Attachment(s)
I have never experimented with these npcs before, but I think I made a bush one as you requested. (Attached)

Enjoy.

theHAWKER 05-09-2007 07:18 AM

Quote:

Originally Posted by Deadly_Killer (Post 1306513)
I have never experimented with these npcs before, but I think I made a bush one as you requested. (Attached)

Enjoy.

wow cool, can u explane the script cause it uses alot of random crap. for example:
PHP Code:

for (tx pxtx px 6tx++) { 


Deadly_Killer 05-09-2007 07:25 AM

Quote:

Originally Posted by theHAWKER (Post 1306516)
wow cool, can u explane the script cause it uses alot of random crap. for example:
PHP Code:

for (tx pxtx px 6tx++) { 


That does not exist in the script.

BUT:

This checks if a square (4 tiles) are grass ( if not, it stops )
PHP Code:

  for (tx pxtx px 2tx++) {
    for (
ty pyty py 2ty++) {
      if (!(
tiles[txtyin grasstiles)) return;
    }
  } 

This actually sets the tiles one by one.
PHP Code:

  i 0;
  for (
tx pxtx px 2tx++) {
    for (
ty pyty py 2ty++) {
      
tiles[tx,ty] = bushtiles[i];
      
i++;
    }
  } 


theHAWKER 05-09-2007 04:19 PM

so if i wanted it to set somthing down that was 4 tiles by 4 tiles would i do:
PHP Code:

0;
  for (
tx pxtx px 4tx++) {
    for (
ty pyty py 4ty++) {
      
tiles[tx,ty] = bushtiles[i];
      
i++;
    }
  } 

or like:
PHP Code:

0;
  for (
tx pxtx px 2tx++) {
    for (
ty pyty py 2ty++) {
      for (
ty pyty py 2ty++) {
          
tiles[tx,ty] = bushtiles[i];
          
i++;
    }
  } 


DustyPorViva 05-09-2007 06:03 PM

I think you're getting way over your head.

Crow 05-09-2007 06:40 PM

Quote:

Originally Posted by DustyPorViva (Post 1306565)
I think you're getting way over your head.

I thought exactly the same. Hawker...before you are trying to do something like that, try to learn some basic scripting.

DustyPorViva 05-09-2007 06:50 PM

So I don't come off as a complete ass(I'm an incomplete ass).
You're trying to learn something simple like placing tiles from a script that does way more, thus, is a lot more complex and can mislead you. What you posted serves more than to just lay tiles down, it also is used to calculate what specific tiles to place and where, to generate a path(though it doesn't do all that in the bit you posted, it's written to do so). It's all very complex.

If you have the array of the bush already, which would be 4 tiles, you could do something like.
PHP Code:

for (i=0;i<4;i++) {
  
tiles[mousex+i%2,mousey+int(i/2)]=bushtiles[i];
}
updateboard mousex,mousey,2,2


Chandler 05-09-2007 06:59 PM

Make the object an image, use a class.
HTML Code:

function onCreated()
{
  this.dropObject = (this.dropObject? this.dropObject: "block.png");
 
  this.showCharacter();
  this.setCharAni("myplaceholder", this.dropObject);
}

HTML Code:

function onCreated()
{
  //Make this a database
  //Change the random(0, THISRANDOM) to the overworld size * 64
  this.warpto(this.level.name, random(0, THISRANDOM), random(0, THISRANDOM));
  while if (onwall2(this.x, this.y, 2, 2))
  {
    this.warpto(this.name, random(0, THISRANDOM), random(0, THISRANDOM));
  }
  this.dropObject(randomstring("bush", "tree", "plant"));

  scheduleevent(10, "Created", "");
  //Repeat this process every 10 seconds.
}   
function dropObject(objectName)
{
  with(putnpc2(objectx, objecty, "join objectHolder;"))
  {
    this.dropObject = thiso.objectName @ ".png";
  }
}


DustyPorViva 05-09-2007 07:30 PM

O.o?

Chandler 05-09-2007 07:32 PM

Instead of replacing tiles for laying objects, just make an object layer making the tiles that you want into images. Seems more logical to me.

DustyPorViva 05-09-2007 07:50 PM

Not for this purpose. This is an editor NPC, like the path generator.

Deadly_Killer 05-09-2007 09:40 PM

Quote:

Originally Posted by DustyPorViva (Post 1306580)
PHP Code:

for (i=0;i<4;i++) {
  
tiles[mousex+i%2,mousey+int(i/2)]=bushtiles[i];
}
updateboard mousex,mousey,2,2


hm, yeah, I could of done that. I just stuck with Stefan's way of doing it.

Chandler 05-09-2007 11:57 PM

Oh, I see!
Thanks

cbk1994 05-10-2007 12:26 AM

theHAWKER, look before you leap. You're way over your head. First do some basic stuff, such as staff tools, and basic triggering scripts.

DustyPorViva 05-10-2007 12:58 AM

Ya, this would be a simpler way to look at making a bush generator:
PHP Code:

// NPC made by Dusty
if (mousedowntimeout=0.05;
if (
timeout && leftmousebutton) {
  
grasstiles={0x0,0x1,0x10,0x1ff,0x3ff,0x7ff,0x835,0x836,0x837};
  
bushtiles={0x2,0x3,0x12,0x13};
  
ongrass=0;
  for (
i=0;i<4;i++) {
    if (
tiles[mousex-1+i%2,mousey-1+int(i/2)] in grasstilesongrass++;
  }
  if (
ongrass==4) {
    for (
i=0;i<4;i++) tiles[mousex-1+i%2,mousey-1+int(i/2)]=bushtiles[i];
  }
  
updateboard mousex-1,mousey-1,2,2;
  
timeout=0.05;



Deadly_Killer 05-10-2007 02:22 AM

Quote:

Originally Posted by DustyPorViva (Post 1306650)
Ya, this would be a simpler way to look at making a bush generator:
PHP Code:

// NPC made by Dusty
if (mousedowntimeout=0.05;
if (
timeout && leftmousebutton) {
  
grasstiles={0x0,0x1,0x10,0x1ff,0x3ff,0x7ff,0x835,0x836,0x837};
  
bushtiles={0x2,0x3,0x12,0x13};
  
ongrass=0;
  for (
i=0;i<4;i++) {
    if (
tiles[mousex-1+i%2,mousey-1+int(i/2)] in grasstilesongrass++;
  }
  if (
ongrass==4) {
    for (
i=0;i<4;i++) tiles[mousex-1+i%2,mousey-1+int(i/2)]=bushtiles[i];
  }
  
updateboard mousex-1,mousey-1,2,2;
  
timeout=0.05;



Doing ongrass++ is retarded. Just end the loop completely if it isn't grass.

DustyPorViva 05-10-2007 02:40 AM

Doesn't work that easy, but if you'd like to edit my script to show what you mean go ahead.

cbk1994 05-10-2007 02:42 AM

Quote:

Originally Posted by DustyPorViva (Post 1306650)
Ya, this would be a simpler way to look at making a bush generator:
PHP Code:

// NPC made by Dusty
if (mousedowntimeout=0.05;
if (
timeout && leftmousebutton) {
  
grasstiles={0x0,0x1,0x10,0x1ff,0x3ff,0x7ff,0x835,0x836,0x837};
  
bushtiles={0x2,0x3,0x12,0x13};
  
ongrass=0;
  for (
i=0;i<4;i++) {
    if (
tiles[mousex-1+i%2,mousey-1+int(i/2)] in grasstilesongrass++;
  }
  if (
ongrass==4) {
    for (
i=0;i<4;i++) tiles[mousex-1+i%2,mousey-1+int(i/2)]=bushtiles[i];
  }
  
updateboard mousex-1,mousey-1,2,2;
  
timeout=0.05;



Why not just set ongrass = 1; in the beginning, then set it to 0 if its not? And you should just put the if(leftmousebutton) on the timeout = 0.05;, I dislike if (event && lol), but I guess that's why GS2 was made.

DustyPorViva 05-10-2007 02:47 AM

I could have, and I guess it would have made a little sense. But either way the result is the same--I'm checking whether or not the four tiles are grass.
PHP Code:

// NPC made by Dusty
if (mousedowntimeout=0.05;
if (
timeout && leftmousebutton) {
  
grasstiles={0x0,0x1,0x10,0x1ff,0x3ff,0x7ff,0x835,0x836,0x837};
  
bushtiles={0x2,0x3,0x12,0x13};
  
ongrass=1;
  for (
i=0;i<4;i++) {
    if (!(
tiles[mousex-1+i%2,mousey-1+int(i/2)] in grasstiles)) ongrass=0;
  }
  if (
ongrass==1) {
    for (
i=0;i<4;i++) tiles[mousex-1+i%2,mousey-1+int(i/2)]=bushtiles[i];
    
updateboard mousex-1,mousey-1,2,2;
  }
  
timeout=0.05;


Also, I suppose the event && blah is just preference.

Chandler 05-10-2007 08:05 AM

Quote:

Originally Posted by cbkbud (Post 1306680)
I dislike if (event && lol), but I guess that's why GS2 was made.

No... that's called styling preference. rofl

Deadly_Killer 05-10-2007 09:23 PM

Quote:

Originally Posted by Chandler (Post 1306723)
No... that's called styling preference. rofl

Haha. I find that funny because he yells at anyone who bashes his style and shows his 'style thread'. ( which I would prefer Skyld's over his )

Crow 05-11-2007 01:04 PM

<3 Skyld's style.


All times are GMT +2. The time now is 09:36 AM.

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