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
  #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
 


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 04:42 PM.


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