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 03-18-2001, 02:44 AM
JoMomma JoMomma is offline
Registered User
Join Date: Mar 2001
Posts: 43
JoMomma is on a distinguished road
Question

Horay I finally get to post on here! I think... Anyway...

Ok, from what I understand, board[] contains information about the tiles that are on that level. Now I decided to make a stupid little npc that does:
setplayerprop #c,#v(board[playerx+playery*64]);

With this, I could actually look at what types of values are in the array. I'd expect things like 10, or 20, or maybe 200... but here I get like 2096 (or something close to that) for grass.

Anyway my 3 questions are as follows:
1) Since it's a 64x64 array but there can be really 4 tiles per section of that board, what determines the value? is it an "anded" value of the 4 tiles? And if so, what order is it in?

2) How exactly does changing tiles work? I kinda understand updateboard, but don't fully get it. I'd also like to know if maybe putting this type of code in the NPC server would make it global to all users. I've heard that it's only really local, but the documentation does say it's temporaray.

3) What actually determines the values? Like what makes grass 2096 (or whatever it was)? Is it the position they're in the pics1.png?

Happily making his first post (since the damn thing didn't send me a verification code right away!)

-- JoMomma
__________________
Temporary disabled
Stefan Knorr
Reply With Quote
  #2  
Old 03-18-2001, 03:02 AM
Lion'el-Jonson Lion'el-Jonson is offline
Please Wait....
Lion'el-Jonson's Avatar
Join Date: Mar 2001
Location: I like to eat food samples at price club.
Posts: 1,663
Lion'el-Jonson will become famous soon enough
Send a message via AIM to Lion'el-Jonson Send a message via Yahoo to Lion'el-Jonson
Question

. . .
__________________


"My words are like weaponry on a record"
Reply With Quote
  #3  
Old 03-18-2001, 04:31 AM
Fai Fai is offline
!!!!!!!!!!!!!!!!!!!!!!!!!
Fai's Avatar
Join Date: Mar 2001
Location: New York
Posts: 4,491
Fai will become famous soon enough
Send a message via ICQ to Fai Send a message via AIM to Fai
NPC Code:
if (playertouchsme) {
shootball;
}

__________________
SIGNATURE
Reply With Quote
  #4  
Old 03-18-2001, 05:27 AM
Tyhm Tyhm is offline
Psionic Youth
Tyhm's Avatar
Join Date: Mar 2001
Location: Babord, West Graal Deaths:1009 Kills:1
Posts: 5,635
Tyhm has a spectacular aura about
Open hammer.txt or shovel.txt
It explains it rather better than I can.
One number in the value of the array is the first coordinate when you mousover the tiling pallette, the other is (naturally) the other coordinate.
And of course, one value in the array's index calculator is the x, the other is the y.
I always get them confused though, and what numbers one is supposed to multiply by...
__________________
"Whatever," said Bean, "I was just glad to get out of the toilet."

"Power does not corrupt. Fear corrupts, perhaps the fear of a loss of power."- John Steinbeck
"I'm only acting retarded, what's your excuse?" queried the Gord.
- My pet, the Levelup Gnome

http://forums.graalonline.com/forums...&postcount=233
Reply With Quote
  #5  
Old 03-18-2001, 05:58 AM
freddyfox freddyfox is offline
Banned
freddyfox's Avatar
Join Date: Mar 2001
Posts: 6,705
freddyfox is on a distinguished road
I suppose I will eventually have to figure out what that means. *Heads spins*
Reply With Quote
  #6  
Old 03-18-2001, 07:40 AM
kyle0654 kyle0654 is offline
-. .`
kyle0654's Avatar
Join Date: Mar 2001
Posts: 1,000
kyle0654 will become famous soon enough
1) Since it's a 64x64 array but there can be really 4 tiles per section of that board, what determines the value? is it an "anded" value of the 4 tiles? And if so, what order is it in?

2) How exactly does changing tiles work? I kinda understand updateboard, but don't fully get it. I'd also like to know if maybe putting this type of code in the NPC server would make it global to all users. I've heard that it's only really local, but the documentation does say it's temporaray.

3) What actually determines the values? Like what makes grass 2096 (or whatever it was)? Is it the position they're in the pics1.png?

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.
Reply With Quote
  #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
  #8  
Old 03-19-2001, 04:04 AM
kyle0654 kyle0654 is offline
-. .`
kyle0654's Avatar
Join Date: Mar 2001
Posts: 1,000
kyle0654 will become famous soon enough
oops, sorry. Like an array, you must first do int(x) on the boardx you are checking to make sure that you are checking the tile on that array position. It stores whole number values for tile positions, not decimals, so you need to truncate it (what int does...cuts off decimals)

A weather system that does that would be pretty cool, and I think I know how you could achieve it pretty simply....although to actually implement it and have it work online would be another story...

Use two arrays, one called weather.grasstiles, and the other called weather.snowtiles. Store corresponding tiles in the same position in the array (you're gonna need ta know arrays pretty well), and just check for both positions every timeout and replace based on the season.

Here, I'll give you a little example. Say that 2000 is normal grass, 3000 is normal snow, 2001 is a grass corner, and 3001 is the same type of corner, but with snow:

NPC Code:

if (created) {
weather.grasstiles = {2000, 2001};
weather.snowtiles = {3000, 3001};
weather.season = 0;
// Seasons:
// 0 - Summer
// 1 - Winter
timeout = .1;
}
if (timeout) {
for (this.x = 0; this.x <= 64; this.x++) {
for (this.y = 0; this.y <=64; this.y++) {
this.boardvalue = board[this.x + this.y * 64];
if (this.boardvalue in weather.grasstiles || this.boardvalue in weather.snowtiles) {
getarrayposition();
board[this.x + this.y * 64] == (weather.season == 0)? weather.grasstiles[this.arraypos] : weather.snowtiles[this.arraypos]);
}
}
}
updateboard 0, 0, 64, 64;
timeout = 5;
}

function getarrayposition() {
for (this.arraypos = 0; this.arraypos < arraylen(weather.grasstiles); this.arraypos++) {
if (this.boardvalue == weather.grasstiles[this.arraypos] || this.boardvalue == weather.snowtiles[this.arraypos]) break;
}
}



That uh....should work.....not entirely sure it will. If it doesn't, tell me and I'll go find my old random tile replacing script I did one day when I was bored. Just whatever you do, do a timeout at about 5 or more if you're doing updateboard, I'd even suggest 10 or 20 maybe...

If that break in the function doesn't work, replace it with something like this.ap = this.arraypos and make sure you replace the things up above. This script is longer than necessary, but better for showing how things are done.
Reply With Quote
  #9  
Old 03-19-2001, 09:17 AM
JoMomma JoMomma is offline
Registered User
Join Date: Mar 2001
Posts: 43
JoMomma is on a distinguished road
Quote:
Originally posted by kyle0654
oops, sorry. Like an array, you must first do int(x) on the boardx you are checking to make sure that you are checking the tile on that array position. It stores whole number values for tile positions, not decimals, so you need to truncate it (what int does...cuts off decimals)
Ok but... what if we have say...

plain grass, red flower
grass blade left, grass blade right

That's 4 "tiles" which is one unit in the board array. So which one would come up? And how do I get the other ones? Or is the array even bigger than I thought?
__________________
Temporary disabled
Stefan Knorr
Reply With Quote
  #10  
Old 03-19-2001, 08:20 PM
Thak2 Thak2 is offline
:]
Join Date: Mar 2001
Location: BC
Posts: 1,344
Thak2 is on a distinguished road
Send a message via AIM to Thak2
If it has a
green tile,flower tile,
leftgrass tile, rightgrass tile
then it would be a 2x2 square, so if you were just using that you would have this.x+64*this.y for your top left one, this.x+1+64*this.y for the top right, and this.x+1+64*(this.y+1) for the bottom right, and so on...

But to have the tiles cover the whole screen in a 2x2 square pattern I am not sure how to do it... could there be a way to skip every other number, or use even numbers only/odd numbers only?
Reply With Quote
  #11  
Old 03-19-2001, 11:45 PM
vergil vergil is offline
Registered User
vergil's Avatar
Join Date: Mar 2001
Posts: 1,408
vergil will become famous soon enough
Send a message via ICQ to vergil
Quote:
Originally posted by Fai
NPC Code:
if (playertouchsme) {
shootball;
}

Absolutely brilliant.. i never would have thought of it..
Reply With Quote
  #12  
Old 03-20-2001, 03:03 AM
JoMomma JoMomma is offline
Registered User
Join Date: Mar 2001
Posts: 43
JoMomma is on a distinguished road
Oh wait I see what my problem was: I didn't realize that something like x of 2.5 was in the MIDDLE of a tile... doy! I thought a 2 tile by 2 tile "object" took up one unit... duh for me!
__________________
Temporary disabled
Stefan Knorr
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 01:43 AM.


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