Swapping in additional tilesets using patch

Chris H.'s Ultima / ACS-style game development system!

Moderators: Ice Cream Jonsey, joltcountry

rld
Posts: 223
Joined: Sun Jan 25, 2009 2:17 am
Location: Dallas, TX

Swapping in additional tilesets using patch

Post by rld »

I am working on a modification for the ACK mega-patch which will allow multiple tile sets to be swapped in for both the standard and extended (animation) tile sets.

Basically how this works is there would be one or more subdirectories underneath the normal game directory, named TILES<n>, where <n> is the number of the tileset (starting at 1). Each subdirectory would contain the shell of an ACK game (to allow its tiles to be edited/imported using the standard ACK editor), but the only files that would really be used would be the standard tile (TILES<n>.GRP) and extended tile (TILES<n>.GR2) files.

From your game, you would use an extended macro command -

DRAW 999 100 TO <n> 0 OF 0 0

which would cause the engine to reload the standard tile set with \TILES<n>\TILES<n>.GRP. A similar command could be used to reload graphics for the alternate tile set.

This still would not allow you to have more tiles in your game at a given time than the existing engine allows, but it would allow you to have different *sets* of tiles that would be used in different parts of the game. Here are a couple of possible examples.

1) Different graphics in different regions

Let's say you have a number of different dungeon areas in your game, and they all contain common elements such as doors, walls, burning torches, and so on. Now, a stone wall in one dungeon is the same as a stone wall in the next, but you would like them to look different in different dungeons, so dungeon A can have a different visual theme from dungeon B.

With the existing engine, there are two ways to do this. First (and simplest) you create multiple wall objects, multiple door objects, etc. Wall A works the same as wall B, but it uses a different tile. Then, you build dungeon A using wall A, door A, etc. and dungeon B using wall B, door B, etc.

Of course, you rapidly run out of objects doing things this way. You also have the option of using 'set later' graphics, which means that you get away with only using one 'wall' object, one 'door' object, and so forth. But this gets very tedious, because every single time you lay down a dungeon wall tile, you will have to go and select the set later graphic for it.

With the tile-swapping mechanism, you only need one dungeon wall object, but you change the way the tile looks. In your game, there would be a 'common core' set of tiles that look the same in all the tile sets. These tiles would be used for things that travel across regions, like the player, things the player carries, creatures, and common objects that are used in all regions.

So for example, let us say you have decided that tiles 1-100 will always be identical in all your sets. However, tile 101 will represent a dungeon wall. So you only need one dungeon wall object, which uses tile 101. But when you enter dungeon A, you load tile set 1, which contains a tile 101 that looks like a red wall. When the player enters dungeon B, you load tile set 2, which contains a tile 101 that looks like a blue wall.

2) Creatures

You can do the same thing with creatures. If region A contains a certain set of creatures, and region B contains a different set, then when the player enters a region you simply load the tileset that contains the tiles used by creatures in that region.

--

Obviously, this is an optional mechanism and would definitely increase the amount of record-keeping needed when designing games that use it. However, it would also allow an enormous amount of additional flexibility when creating graphics for ACK games.

One potential issue is that if the player saves and restores the game, the default tile sets will always be reloaded. I will need to figure out a straightforward way to ensure that the game has the chance to reload tile sets for a particular region when the game is restored, possibly by calling a dedicated macro.

User avatar
Garth's Equipment Shop
Posts: 638
Joined: Fri Dec 05, 2008 5:55 pm
Location: Festering Foothills
Contact:

Post by Garth's Equipment Shop »

OMG! You have saved the day again rld! Looking forward to trying out the new updated megapatch this weekend. Gonna have to give minecraft a rest for a while. :P
Which of you is interested in my fine wares?

rld
Posts: 223
Joined: Sun Jan 25, 2009 2:17 am
Location: Dallas, TX

Post by rld »

If you are feeling particularly clever, it would also be possible to make a large region (like a worldmap region) that used more than one set of tiles.

Basically, as you are going from one part of the region to another, have a 'transition tunnel' or path portion of the map that a) uses a limited set of tiles and b) forces the player to walk across a certain space before crossing to the new portion of the map.

So, your map looks like

[section A]----[transition tunnel]----[section B]

All three sections use the same 'core' set of tiles (say tiles 0-99), but tiles 100 and up are different in the three map sections. The transition tunnel uses only the tiles in the core set.

So, as the player walks from section A through the transition tunnel to section B, they will step on a tile which runs a macro which switches the tile set. Because the transition tunnel does not use any of the tiles that were swapped (only the core set), the change will not be apparent until the player crosses over into section B. Similarly, when the player crosses back to section A, the tiles are swapped back appropriately.

The transition tunnel area doesn't need to be that large, just big enough that section A and section B will never be visible in the viewport at the same time.

Garth Lurking

Post by Garth Lurking »

Wow, that is a way cool idea rld!

joebonk
Posts: 112
Joined: Mon Aug 27, 2012 3:16 am
Location: las cruces, nm

Hotswapping tile sets

Post by joebonk »

The secondary tiles don't work?
I used both GRP and GR2
But only the primary tileset works.
Animated object animated the second tile as old tileset.
And "set graphic later" objects used default tileset.
Was able to have the primary tileset objects work.
But this means no torches or light sources. :(
And the animation tiles for monsters won't change.
ADDED:
Here is a problem I have come across.
The secodary tileset does not change.
In this video, the yellow and grey wall is the same tile and object.
The sand and grass are the same.
The water and the green swamp water are the same.
But as you can see, that switching to the blue water only changed the primary tile set,
while the (animation spare) tileset is not changed.
View My Video

joebonk
Posts: 112
Joined: Mon Aug 27, 2012 3:16 am
Location: las cruces, nm

tileset swapping

Post by joebonk »

I fixed it. Here is a detail I missed.
Draw 999 101 to (#) 0 of 0 0

That command loads the secondary tileset (meaning the ones used for animating.)

Was hard to figure out as this thread did not mention it and in the patch readme, scrolling down to patch (12) gave the command for the the primary tiles switching. But at the very beginning of the readme is a summery of the new commands and in the summery it was listed. When first seeing it I assumed it was for restoring original but I was wrong.

So if anyone is looking to use this feature here is what to do from the readme:

There are two sets of tiles to make objects with. Primary ones and secondary ones. Secondary ones used for animating and set tile later option. It is possible with this patch command to only switch one of these. If you want to switch both of these at the same time you will have to use two commands in the macro.

For instance if a town has another appearance of walls and roads, and even different colored water (which may animate), You would type these into that town map's entrance macro:

draw 999 100 to (number) 0 of 0 0
draw 999 101 to (number) 0 of 0 0

The difference above is the 100 and 101. 100 for primary tileset and 101 is for the secondary tileset.

You can ofcourse just switch only one of them, the primary or just the secondary. But if you have monsters and people who you want to look different and have their different tileset in a subfolder, you will want both to be switched at the same time.

To switch both of the tilesets back to the original:

draw 999 100 to 0 0 of 0 0
draw 999 101 to 0 0 of 0 0

The zero where (number) was tells the engine to load the original tileset. The number you would use other then zero is for the numbered subfolder of the additional tileset you are hot swapping. Subfolders titled "TILES1" or "TILES2" or how ever many different sets of tiles you have. It may be easier to just make a new tile set every time you wish to make a new one (for a new region) and in this way you only change which ones you need for that region. It will be less note keeping.

Quote:RLD:...Each subdirectory would contain the shell of an ACK game(to allow its tiles to be edited/imported using the standard ACK editor)...

Not sure what this means. To edit the new tileset I just made a new game called "edittile" and when ever I update the tiles to a new look, I go into the game folder called "edittile" and copy the .grp and gr2 files and paste them into the subfolders of the game I am working on. Does your statement mean that if all of the game's files are there (even the new music files) then the ack editor can select if for editing? Or does a copy of the ack modules have to be found in the subfolders?

User avatar
Garth's Equipment Shop
Posts: 638
Joined: Fri Dec 05, 2008 5:55 pm
Location: Festering Foothills
Contact:

Post by Garth's Equipment Shop »

Thanks Joe

joebonk
Posts: 112
Joined: Mon Aug 27, 2012 3:16 am
Location: las cruces, nm

Post by joebonk »

Additionally, to keep things tidy, you can name the subfolder after the same number of the map using them.
So if it is map 26, then name the subfolder TILES26.
You do not need subfolder 25 or 24 or 23 to make for it.
Subfolders don't have to be sequential.

Post Reply