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 04-08-2006, 01:25 AM
Googi Googi is offline
A Serious Epidemic
Googi's Avatar
Join Date: Oct 2001
Location: Canada
Posts: 18,866
Googi has much to be proud ofGoogi has much to be proud ofGoogi has much to be proud ofGoogi has much to be proud ofGoogi has much to be proud ofGoogi has much to be proud of
Send a message via AIM to Googi
Tile replacing

So say I want to replace all bushes and swamp in a level with normal grass tiles. Both bushes and swamp patches are comprised of 4 different tiles (8 in total) so using fill is not possible. I want to do this for several levels so using the level editor to replace them would be too time consuming. So I write a loop to check if each tile in a level is one of the 8 different tiles I want to replace, and if so it uses "tiles[x,y] =" to replace it. This works. The problem is that when I hit F4 and go back to the level editor, all the replaced tiles have reverted to their original form. Is there a way around this? If there isn't, there should be.
__________________
Reply With Quote
  #2  
Old 04-08-2006, 03:04 AM
napo_p2p napo_p2p is offline
oh snaps
napo_p2p's Avatar
Join Date: Sep 2003
Location: Pismo Beach, California
Posts: 2,118
napo_p2p has a spectacular aura aboutnapo_p2p has a spectacular aura about
Send a message via AIM to napo_p2p Send a message via MSN to napo_p2p
Update the board.

updateboard x,y,width,height;

I haven't done anything of this sort in a while, but I am thinking at the end you can do (at the end):
PHP Code:
updateboard 0,0,64,64
or (asumming you are using nested 'for' loops with the variables: 'this.bx' and 'this.by'), then you can do after each tile update:
PHP Code:
updateboard this.bx,this.by,1,1
__________________
Scito hoc super omnia.
Haec vita est tua una sola.
Dum vita superest, utere maxime quoque puncto, momento, et hora quae habes.
Tempus neminem non manet.
Noli manere tempus.
Carpe Diem

Seize the Day.
Reply With Quote
  #3  
Old 04-08-2006, 03:35 AM
ZeLpH_MyStiK ZeLpH_MyStiK is offline
Scripter
ZeLpH_MyStiK's Avatar
Join Date: May 2003
Location: NYC
Posts: 553
ZeLpH_MyStiK is on a distinguished road
Send a message via MSN to ZeLpH_MyStiK Send a message via Yahoo to ZeLpH_MyStiK
updateboard doesn't save the tiles into the level file. updateboard2 does.
__________________
Reply With Quote
  #4  
Old 04-08-2006, 04:34 AM
Googi Googi is offline
A Serious Epidemic
Googi's Avatar
Join Date: Oct 2001
Location: Canada
Posts: 18,866
Googi has much to be proud ofGoogi has much to be proud ofGoogi has much to be proud ofGoogi has much to be proud ofGoogi has much to be proud ofGoogi has much to be proud of
Send a message via AIM to Googi
I tried both updateboard and updateboard2 and nothing happened. I made a simple version of the script (intended to replace only one tile) and that didn't work either.

NPC Code:

if (playerenters) {
if (tiles[1,1] == 0x18E) {
tiles[1,1] = 0x0;
updateboard2 1,1,1,1;
}
}



The tile is changed while I'm playing on the level, but still reverts when I go back to the level editor.
__________________
Reply With Quote
  #5  
Old 04-08-2006, 08:05 AM
Andy0687 Andy0687 is offline
Enigma
Join Date: Feb 2002
Posts: 1,072
Andy0687 is on a distinguished road
Quote:
Originally Posted by Googi
...
updateboard2 is serverside, the way you are doing it on the editor is the only way you will be able to do it, the only way to save those level changes is with the save button.
Reply With Quote
  #6  
Old 04-08-2006, 08:43 PM
ZeLpH_MyStiK ZeLpH_MyStiK is offline
Scripter
ZeLpH_MyStiK's Avatar
Join Date: May 2003
Location: NYC
Posts: 553
ZeLpH_MyStiK is on a distinguished road
Send a message via MSN to ZeLpH_MyStiK Send a message via Yahoo to ZeLpH_MyStiK
Quote:
Originally Posted by Andy0687
updateboard2 is serverside, the way you are doing it on the editor is the only way you will be able to do it, the only way to save those level changes is with the save button.
Using the word "only" is kind of harsh as well as incorrect. It can be easily done.
-Create a dbnpc
-Create a list of levels that you want to change, and set it to a string such as this.levels
-Have the dbnpc warpto each level on creation with a for loop.
-In every instant of the loop, have the dbnpc check for each tile on the level
-If the tile is what you're searching for use tiles[tx,ty] to set the tile
-Now you can either update the tile each time the dbnpc sets it by doing updateboard2 tx,ty,1,1; or you can have the dbnpc update the whole level at the end of each for loop instance by doing updateboard2 0,0,64,64;
__________________
Reply With Quote
  #7  
Old 04-08-2006, 08:57 PM
Skyld Skyld is offline
Script-fu
Skyld's Avatar
Join Date: Jan 2002
Location: United Kingdom
Posts: 3,914
Skyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud of
Send a message via AIM to Skyld
Quote:
Originally Posted by ZeLpH_MyStiK
Using the word "only" is kind of harsh as well as incorrect. It can be easily done.
-Create a dbnpc
-Create a list of levels that you want to change, and set it to a string such as this.levels
-Have the dbnpc warpto each level on creation with a for loop.
-In every instant of the loop, have the dbnpc check for each tile on the level
-If the tile is what you're searching for use tiles[tx,ty] to set the tile
-Now you can either update the tile each time the dbnpc sets it by doing updateboard2 tx,ty,1,1; or you can have the dbnpc update the whole level at the end of each for loop instance by doing updateboard2 0,0,64,64;
But you cannot do any of this in the editor, which is what he was saying.
Quote:
Originally Posted by Andy0687
updateboard2 is serverside, the way you are doing it on the editor is the only way you will be able to do it, the only way to save those level changes is with the save button.
__________________
Skyld
Reply With Quote
  #8  
Old 04-09-2006, 01:49 AM
Googi Googi is offline
A Serious Epidemic
Googi's Avatar
Join Date: Oct 2001
Location: Canada
Posts: 18,866
Googi has much to be proud ofGoogi has much to be proud ofGoogi has much to be proud ofGoogi has much to be proud ofGoogi has much to be proud ofGoogi has much to be proud of
Send a message via AIM to Googi
Wait, so there's no way for an offline NPC to make permanent changes to a level?
__________________
Reply With Quote
  #9  
Old 04-09-2006, 02:05 AM
xXziroXx xXziroXx is offline
Malorian
xXziroXx's Avatar
Join Date: May 2004
Posts: 5,289
xXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant future
Negative.
__________________
Follow my work on social media post-Graal:Updated august 2025.
Reply With Quote
  #10  
Old 04-09-2006, 02:15 AM
napo_p2p napo_p2p is offline
oh snaps
napo_p2p's Avatar
Join Date: Sep 2003
Location: Pismo Beach, California
Posts: 2,118
napo_p2p has a spectacular aura aboutnapo_p2p has a spectacular aura about
Send a message via AIM to napo_p2p Send a message via MSN to napo_p2p
Quote:
Originally Posted by Googi
Wait, so there's no way for an offline NPC to make permanent changes to a level?
The 'editnpc' scripts in the levels\npcs\ folder are offline scripts that make permanent changes. They use updateboard.

If nothing is working, try testing your scripts as an 'editnpc' one.
__________________
Scito hoc super omnia.
Haec vita est tua una sola.
Dum vita superest, utere maxime quoque puncto, momento, et hora quae habes.
Tempus neminem non manet.
Noli manere tempus.
Carpe Diem

Seize the Day.
Reply With Quote
  #11  
Old 04-09-2006, 02:30 AM
Googi Googi is offline
A Serious Epidemic
Googi's Avatar
Join Date: Oct 2001
Location: Canada
Posts: 18,866
Googi has much to be proud ofGoogi has much to be proud ofGoogi has much to be proud ofGoogi has much to be proud ofGoogi has much to be proud ofGoogi has much to be proud of
Send a message via AIM to Googi
Quote:
Originally Posted by napo_p2p
The 'editnpc' scripts in the levels\npcs\ folder are offline scripts that make permanent changes. They use updateboard.

If nothing is working, try testing your scripts as an 'editnpc' one.
Yeah, this worked.
__________________
Reply With Quote
  #12  
Old 04-09-2006, 02:38 AM
Yen Yen is offline
Banned
Yen's Avatar
Join Date: Oct 2005
Location: Nova Scotia, Canada
Posts: 1,085
Yen is an unknown quantity at this point
Send a message via AIM to Yen Send a message via MSN to Yen
It would be nice if Stefan would tell us the mechanics behind how tiles are saved in text format. We could make a script to write directly to the level as text.
Reply With Quote
  #13  
Old 04-09-2006, 03:30 AM
Riot Riot is offline
Delteria Management
Join Date: Nov 2003
Location: Seminole County, Florida
Posts: 280
Riot is on a distinguished road
Quote:
Originally Posted by Yen
It would be nice if Stefan would tell us the mechanics behind how tiles are saved in text format. We could make a script to write directly to the level as text.
Something like this?
Quote:
Originally Posted by newfeatures2001.txt
- new file format (exists since beginning of 2000 but was
only available for newworld team):
The new level format is text based. If you want to edit it
outside of Graal, use a text editor which doesn't wrap lines.
You automatically produce a file in the new format when you
save to a file with ending .nw
Those files are bigger than .graal files, but because it is
text-based it is easier to edit parts of it (e.g. ncp script)
without opening the game, or to write tools that
do changes to the levels, like adding npcs to levels. The
graal servers support that file format too, the data sent to
the player is the same size like when using .graal files, so it
will not make the game laggier

Format:
It begins with the signature GLEVNW01.
It can contain following data types:

- board lines:

BOARD x y width layerindex <tilesdata>

This is one line of the background layer. 'tilesdata' has a length if w*2
characters; each tile is a 12bit-index into the tile list (pics1.png) and is
encoded in two base64 characters (upper 6 bit first)
base64: String = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvw xyz0123456789+/'
so AA is tile 0, AB is tile 1, AC is tile 2, // is tile 4095 (=0xFFF)

- level links:

LINK <destination-level> x y width height newx newy

The link attributes are the same like in the link options window in Graal.
destination-level, newx and newy must not contain spaces.

- signs:

SIGN x y
text
...
SIGNEND

Signs may be empty, but SIGNEND must always be there.

- npcs:

NPC imagefilename x y
script
...
NPCEND

If the npc doesn't have a filename (invisible npc), then write '-' for imagefilename.
x and y may be floating point values. The npc script may be empty, but NPCEND
must always be there

- baddies:

BADDY x y type
attackverse
hurtverse
winverse
BADDYEND

'type' is the baddy name (graysoldier ... dragon ) or index (0...9). You don't need
to write all 3 verses, it's also possible to only write attackverse+hurtverse or only
attackverse, but BADDYEND must always be there.

- chests:

CHEST x y item signindex

item is the item name (greenrupee ... spinattack) or item index (0...24)
Gotta love those newfeatures files.
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 07:04 AM.


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