Graal Forums  

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

 
 
Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #7  
Old 03-19-2001, 01:35 AM
JoMomma JoMomma is offline
Registered User
Join Date: Mar 2001
Posts: 43
JoMomma is on a distinguished road
Quote:
Originally posted by kyle0654
First, you need to understand how it works:

board[x + y * 64] = tilex + tiley * 16;

The y will always get bigger, while the x goes from 0 to 15 then loops back to 0. If you run your mouse over the tileset on the right side, you'll see the values in the bottom right change. It tells you the tilex and tiley of the tile you are hovering over. If you go from left to right in a straight line, you'll notice that the tilex will go to 15 then to 0, and the tiley will jump up a lot. Well, this is because the tileset isn't arranged from left to right, it's arranged in strips that are 16 tiles wide and however many tiles tall.

Okay, too many words eh? Anyways, back to what I was gonna say. If you want to change a board tile, you must know what tile you are replacing with in terms of its tilex and tiley on the tileset. once you know that, you can use the equation above to set it. Then update the board using this:

updateboard x, y, 1, 1;

That will load the current tile at that position. Of course, this is all client-side, and only certain tiles will work well online. Bushes to stumps, Rocks to holes, and signs to holes I think will work.

Anyway, if you want to know the tilex and tiley of what tile you're standing on:

boardvalue = board[playerx + playery * 64];
setplayerprop #c,tilex: #v(boardvalue%16), tiley: #v(int(boardvalue/16));

And of course use that in a timeout script.

Btw, doing %16 or %# just find the remainder of the number when you divide it by 16, if you didn't know that already.


Now, as for global tile changes using an npc server...I know how you would do it, but you better ask Stefan, cuz I don't think the command is really open to public as of yet, and it's server-side too, meaning it won't work offline.


Well, did I thoroughly confuse you? As Tyhm said, a great example to look at is the shovel or hammer script if you want to see it in action.
It did at first. Then I looked at the hammer code and kinda understood it... then I decided to open graal and I finally got it... I'm glad you said "tilex" cause someone else said "x" when they tried to explain what the value was. But these tiles are all over the place so I'm not sure what I'll do. Basically I was gonna make a weather system that changes the tiles to snow ones if it's snowing... Possible? More than likely, yes. Easy? No, mainly cause the values of the grass tiles aren't next to each other, and I don't think I can modify/chec them with math (ie: add 200 to make it a grass tile, or if it's between 100 and 150 it's a grass tile... that just ain't gonna work).

But I do wonder how tiles that are on the 1/2 mark of a coordinate (ie: x of 25.5) are gonna be read. Does the array somehow accept floating point numbers as an index?
__________________
Temporary disabled
Stefan Knorr
Reply With Quote
 


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 01:26 PM.


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