Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   Tile replacing (https://forums.graalonline.com/forums/showthread.php?t=65247)

Googi 04-08-2006 01:25 AM

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.

napo_p2p 04-08-2006 03:04 AM

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


ZeLpH_MyStiK 04-08-2006 03:35 AM

updateboard doesn't save the tiles into the level file. updateboard2 does.

Googi 04-08-2006 04:34 AM

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.

Andy0687 04-08-2006 08:05 AM

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.

ZeLpH_MyStiK 04-08-2006 08:43 PM

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;

Skyld 04-08-2006 08:57 PM

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.


Googi 04-09-2006 01:49 AM

Wait, so there's no way for an offline NPC to make permanent changes to a level?

xXziroXx 04-09-2006 02:05 AM

Negative.

napo_p2p 04-09-2006 02:15 AM

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.

Googi 04-09-2006 02:30 AM

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.

Yen 04-09-2006 02:38 AM

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. :(

Riot 04-09-2006 03:30 AM

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.


All times are GMT +2. The time now is 04:02 AM.

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