MAPSET question

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

Moderators: Ice Cream Jonsey, joltcountry

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

MAPSET question

Post by joebonk »

Hi,
I'm working on a space flight game. And piloting is entering in 3 numbers x, y, and z coordinates. What I want to do is just have the results always go to one map where the space ship finds itself. So I have like 10 tiles for stars. But would like each of the tiles to show up randomly. Every space would be a star tile. The map would be drawn with standard tiles, while every space has a random chance of being over written with a different style of star tile. (This way it doesn't seem like just going to the same place again.)
So I figure mapset will do it. But in MAPADD the tiles must be 16 tiles within range. Is it the same with MAPSET?
It will save time to repeat the command if the first two numbers are variables. hen repeated for a random number of times. With only one map to write, the game should be very fast to make.
I wonder if there is also a way to make the creature (Bad space ships) that show up be random?
In order to make the bad ships random, i will probably have to make more then one type of this map but with different enemies showing up.

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

Post by rld »

The location you are editing does need to be within about 16 spaces for either MAPSET or MAPADD or any of the other map editing commands if you are in a world map region. If you are in a room-type region, the location needs to be within the current room.

If you want to have one map that can appear as a number of different maps, one way to do this that doesn't involve editing the map on the fly is to have 'empty space' tiles that are only passable when a variable (such as A) is a given value. Then set the space to appear as a star (or some other object) using the DISAPPEAR, REPLACE WITH x WHEN IMPASSABLE terrain setting.

This should allow you to switch tiles on your map back and forth between two different states depending on one or more variable settings, and then you can just set those variables randomly (or based on some formula) before the player's spaceship enters the map.

Admiral Ackguh
Posts: 137
Joined: Sat Nov 03, 2012 11:26 am
Location: Canada
Contact:

Post by Admiral Ackguh »

Hopefully I can be useful here.

Take a large building; each floor is a room-type region of maximal size (4 x 4 rooms). The top three rows of rooms are 16x11; the bottom one is 16x10. Like I said, this is the maximum for room-type maps. This building has a clean-up robot; for simplicity, I have it work around the player, and clean the rooms he is not in. The player never sees the robot, just its results.

So when the player moves to a new room (I have a variable to keep track of this), there is a chance the robot has cleaned it already. If so, I have a "this room is cleaner" message, and I run the cleaning macro.

This macro loops through every square in the room. The Y2 value goes from 1 to 10; X2, 1 to 16. It uses MAPCHK to detect, and MAPDEL to remove, any objects the player had left behind. It also uses MAPSET to repair base terrain (i.e. change a broken window into a whole one) - and make other changes needed, such as opening and closing doors. When finished, it uses MAPSETD on square 1 1 to set a timestamp for that room.

Keep in mind this macro is slow, having to go through 160 squares. Something like this could be used to dynamically generate terrain as well. If you have a region with many rooms, it would be best to set up each room the player enters. You could have a step macro flag that sets up the whole region like this upon region entry, teleporting the player from room to room, then back to the original location. But that would be even slower.

I don't know how well this would work for world-maps.
- A:A:

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

mapset

Post by joebonk »

That sounds like the rampage game someone said they were remaking. Actually, since the maps are simple to make, might as well just make several maps that are randomly chosen from. Whats good about a format like this is I can add updates without changing what is released already. Space flight can be like 16 maps. And then extra maps later for planet landings and space station ventures. And, I was thinking that it is ok to still use map add because the first impression to a new destination is the first sight anyways, and if that is changed around then moving around to just more stars won't clue someone in anyways. Unless they play it for like 30 hours and decide to notice. (theres only like 5 star tiles) Thanx for the help.

Admiral Ackguh
Posts: 137
Joined: Sat Nov 03, 2012 11:26 am
Location: Canada
Contact:

Post by Admiral Ackguh »

I'll also add that some levels of my adventure are randomly created only when the player enters them. For these I use regions with 4x4 rooms, and a similar mechanism to the "cleaning robot" I mentioned earlier. These regions start out empty except for the stairs, and when the player enters an empty room, the step macro calls another macro that fills in the room with walls, floor, and furniture.
- A:A:

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

Post by joebonk »

So the robot fills the room with items? Or if it cleans, does it remove items (revealing others underneath)? Randomly

Admiral Ackguh
Posts: 137
Joined: Sat Nov 03, 2012 11:26 am
Location: Canada
Contact:

Post by Admiral Ackguh »

The cleaning robot (macros) remove stuff from the room. It uses the X and Y variables in a loop, and goes through every square. If the topmost item is on a list of items to remove, then that item is gone. The macro keeps on checking the same square after removing. Basically there are three lists: items to remove, items to replace (broken terrain with undamaged terrain), and items not to touch (basic terrain, floors, walls, furniture.) Precious items are also on the "not to touch" list.
- A:A:

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

mapset

Post by joebonk »

With that method, you could make one room into many rooms. And if a town was under attack (burning maybe) then
then room can change appearances to accommodate it.
In a space game, an item not to touch could be a planet tile but the stars near it could be different.
I wonder if mapset could place people. Probably won't have dialogues.
I also wonder if mapset could make random items appear under a chest. So that if a chest if left by a monster, like in ultima 5, then one you examine the chest, the macro disappears the chest, but places random loot. random loot would be awesome. I have shelves and vase objects. And this will give abilities to read books that become available when level increases, but would love for a mapset command that could place random loot on an object. Maybe the macro would look for instances of a chest, then finding that out, know to place random loot in that location.

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

mapset

Post by joebonk »

(From the bug reporting topic)
Here is what I have done with summon creature.
I made a macro that sets three variables and places an obstacle on the map. It sets j2 = loc[x] +1
k2 = loc[y]
l2 = (mapchk j2 k2 l2) which sets l2 to the terrain the obstacle is being placed on. which would be grass or sand or snow or brick etc.
Then places the tied up sheep in the map (obstacle)
If you gather from this or attack this, or whatever the action
is then a demon appears. If I do not set the tied up sheep to disappear the demon shows up. But if I set it to disappear then the demon disappears too (because he is on it and hasn't moved off of it yet.)

So I set another macro to run when the object disappears,
but this will only run if the object gets destroyed (which it can if it is attacked), but if the demon is still on it, it will disappear. Also the macro to run ask what l2 is (which was set to the type of terrain the sheep was placed on)
Since I couldn't use the last number in mapset as a variable, I instead just ask 20 times if l2 = grass or l2 = sand or l2 equals brick then go to this line number.
The line number says
mapset j2 k2 (number for terrain) either grass sand or whatever.
But this doesn't happen. It just turns black when attacked.
In other words the macro that says to run if destroyed isn't running.
I experimented. I set the trigger of the obstacle to if gathered from to summon the demon and if does.
Then I attacked the sheep, and it disappears but no mapset tile replacement (because I think the macro isn't running)
Also The macro won't be set to run at all anyways if you do not give the obstacle hit points. If the obsticle has no hit points it never disappears.

To sum it up:
1)The macro to run when destroyed does not run. which activates the mapset macro to replace it again with the tile.
2)If it is set to disappear by action triggered, it overwrites the summoned creature. (if it hasn't moved off the tile) and won't have a chance to run the macro anyways.
It might be that l2 is not getting set with the first macro
mapchk j2 k2 l2
I guess the only hope in the end is wait for an update to the patch which will allow hand held objects to summon creatures. If this ever happens I hope that also this object action can be called from a macro too, instead of just a map placed object.
I have other instances with summon creature, an ncp the player talks to and I am going to try to see if talking to the person I can have the replace tile macro run at "intro."

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

Re: mapset

Post by Garth's Equipment Shop »

joebonk wrote:Here is what I have done with summon creature. I made a macro that sets three variables and places an obstacle on the map. It sets j2 = loc[x] +1
k2 = loc[y]
l2 = (mapchk j2 k2 l2) which sets l2 to the terrain the obstacle is being placed on. which would be grass or sand or snow or brick etc.
Been a long day so really dont feel like putting in the effort to untangle that web of a macro but I did notice something odd right away at the beginning. Did you mean for l2 to pass itself to itself there? Im thinking that in this particular context that might be a mistake though like I said, too tired to wrap my brain around the entire macro so correct me if i missed something.

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

Post by joebonk »

Thank you, and I don't blame you. A hand held item, once used would summon a creature. But this item is not on the map so this won't work (Because where would the creature be summoned, in the inventory?) No, So I had a macro run that first found out the tile that was in the direction of the user (left right up down), and then find out if it is a space tile. If it is a space tile then this action will work. If obstacle then not. If it is a space, record before hand what the tile is (for later use). Now have this tile replaced with an object that will summon a creature. Being on the map an obstacle can summon a creature. How it does is important. Once it does it needs to turn back into the tile it used to be (like grass).
And it knows what it used to be because the first macro found out.
But turning back into what it was (overwriting its map location) also overwrites the creature being summoned.
Also the destroy macro wasn't doing the job of having it replaced and I think it was because another action was summoning a creature.
I won't use this method as the best way to do this would be to to have the ability to summon creatures from the inventory item. And this can't happen yet. But thats ok.
Really my game had it's own version of the Orb Of Cheating, which was a genie summoned from a lamp. But you can't talk to summoned creatures anyways.
A good patch addition would be the ability to somehow fix dialogues with creatures, regardless of how they are placed on the map.
A better way is to make an animated obstacle that looks like a person. Because objects can always trigger a dialogue.

The whole dilemma is that you can't use a variable to be the holder of what tile to draw with mapadd. say, set z = 104 (grass). then mapadd 3 12 z. The macro editor won't allow a letter to be the last entry. You can type mapadd z y 104 or mapadd 5 z 122 but not a letter in the last slot.
Last edited by joebonk on Sun Jul 21, 2013 9:19 pm, edited 2 times in total.

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

Post by joebonk »

Gotta new question. I want to make say 90x90 tile maps that are space. (started a new space pirate game called cosmic enterprise) Or something. I got the tiles and people and vehicles done, weapons and armor. Now just need the maps. and populate them.
I have 2 4x4 galaxy tiles.
1 star cluster
4 close larger stars
8 blinky star tiles.
And made all the planets, moons, space stations into portals.

Technically, if I could manage it, the whole space area could be one giant map. And portals could be covered by mics objects that get removed depending on where the game thinks you are. But for them to get removed they would already be on the map. And they would 'blink' into view was a space was crossed. Maybe just make lots of maps anyways.

Another question is, is there a way to have maps written in an external fashion, that could take a selection of objects (space tiles) and then randomly arrange them into a map?
I know its a long shot. A great addition would be, and for space games a great plus, is a way to have giant maps written by a few commands. Set the tiles you want the map to be randomly made with, then hit the execute button. Then hundreds of tiles could be placed and all in a random fashion. If this could be built into the map editor, then possibly it could be built into game play, and every time the map was visited, the tiles all would randomly build.

I was thinking of making player option 2 (human dwarf or cleric) a macro user. I could use a save game to build the maps by designing a macro that could randomly build the map as the player walked on them. The macro would use map add to place randomly the star tiles. Then, copy the built maps to the actual game folder from the savegame folder. I could go over it with the actual map builder to fine tune it. Does this sound plausible?
Image
This macro sets a space to a random space tile, a potential time saver. The save game saves the tiles drawn with mapadd, can I copy the map in the save game folder and paste it in the game folder? All I see is map.x1 and .y1 and .z1 and these don't change the original game map version. This way the maps drawn in gameplay with the macro can be the actual map copied and pasted (hopefully).

Otherwise, it's very long tedious work to randomly place 8 space tiles with only 4 tile drawing buttons. Much longer then building grass here, then mountains there.

Maybe chunks is the answer. If I made several chunks, then have them recycled, perhaps that could save time. But how do you set a chunk as a chunk and then how do you have it repeat?

Space games are fun. I wonder too, if it is possible to have a bmp be the backdrop of all transparency? So I could have giant galaxies and other cosmic stuff appear just in the fringe of transparency. That would probably be hard to do though.

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

Mapset Solved

Post by joebonk »

SOLVED: Great news. We can draw maps during game play!!!
I made a STEP macro that draws a random tile on the map as the person passes. Here is an example of the macro used:
Macro 3: ON SPOT
1: SET A = RND(8)
2: IF A = 1 THEN 15
3: IF A = 2 THEN 17
4: IF A = 3 THEN 19
5: IF A = 4 THEN 21
6: IF A = 5 THEN 23
7: IF A = 6 THEN 25
8: IF A = 7 THEN 27
9: IF A = 8 THEN 29
15: MAPSET LOC[X] LOC[Y] #104-SPACE
16: STOP
17: MAPSET LOC[X] LOC[Y] #105-SPACE
18: STOP
19: MAPSET LOC[X] LOC[Y] #106-SPACE
20: STOP
21: MAPSET LOC[X] LOC[Y] #107-SPACE
22: STOP
23: MAPSET LOC[X] LOC[Y] #108-SPACE
24: STOP
25: MAPSET LOC[X] LOC[Y] #109-SPACE
26: STOP
27: MAPSET LOC[X] LOC[Y] #110-SPACE
28: STOP
29: MAPSET LOC[X] LOC[Y] #111-SPACE
30: STOP
Here there are 8 tiles to draw. MAPSET draws them randomly. Once the map is covered with random tiles, save it as a save game. Then go into the save game folder and copy the files of that map ending with the x#.
Rename the x#0 to A#. Then paste it in the original game folder and the original map is replaced with new tile drawn map. It may just be that x# are modified copies of a#. Otherwise why would this work?
This will save me a ton of tile drawing. I have 8 star tiles, 4 close up large star tiles and then several larger art work.
I will do the artwork in the actual map editor. But the stars will all be drawn with the macro during game play. This saves me loads and loads of time.
I could then go on to making temporary misc objects that will draw other features, like a galaxy which uses four tiles

Update: Just copied the file ending in .x1 and renamed it to .a1 and the tiles were added to the actual map. No misc stacked items were added. Renaming y1 and z1 to b1 and c1 did not add misc stacked items. If you try this trick only rename the .x1 to .a1 (or whatever number it is. The number is map number, if your 33rd map is a dungeon look for the .x33)

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 »

Wow that is super cool stuff Joe thanks!

Post Reply