Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
 Dynamic Towns
#1
Dynamic Towns
by Rast

This tutorial tells you how to create one of those neat built-it-yourself towns where you get to build the town and decide who lives in it. This is a fairly complex task but I'll do my best to break it down into easy-to-understand chunks. Like all of my advanced systems, this uses pointers, so if you need to brush up, go ahead.

Overview

To build a town like this, here's what you'll need to do:

  1. Plan your town
  2. Create outside maps
  3. Create inside maps
  4. Link the maps together
  5. Populate your town
To do this, we'll need a lot of variables. The main ones you'll use a lot are:
  • TownPhase - The current phase of construction of your town. This determines what outdoor map is used, and how many people can live in your town.
  • ExitMap, ExitX, ExitY - Three variables that are set whenever you go into a building so the building knows where the exit is in the town
  • BuildingX - One variable for each dynamic building in your town. These are filled with the ID numbers of your recruitable people. These maps doors to interiors.
And, we'll also need some switches, being:
  • RecruitX - One switch for each recruitable person or set of people that can come to your town. These are used to determine who's walking around outside, and makes them disappear from wherever you recruit them at.
  • TownFull - On if the town is currently full
And of course, some common events.
  • GoToTown - This is called to enter your town from the outside
  • EnterBuilding - Called to enter a building
  • LeaveBuilding - Called to leave a building
  • IsTownFull - Called to see if your town is full or not.
  • RecruitPerson - Call to recruit a person into your town
We'll also be using some special teleports, and a noncommon event that upgrades the town. We'll cover all these events, switches, and variables in more detail later on.

Step 1 - Plan your town

The town we're going to go over building has these characteristics:

  1. Single point of entry into the town
  2. The town is built in phases, with each phase having more dynamic buildings and a different outdoor map.
  3. At least one static building that houses the town builder. You talk to this person to expand the town
  4. Each building has only one way in and out.
  5. People are recruited from other places and then come to your town.
So, to get started, plan out the following in a text file or a piece of paper.

1) How many phases? How many dynamic buildings in each?

Each phase of your town will have more dynamic buildings. Don't overdo it here - you'll need to make a seperate map for each town phase, so I suggest having four phases with 5 extra buildings each. Number these phases starting from 1, and then add a phase 0 that has just the town builder in it. When you're done, your list should look something like this:

Phase 0 - Lander the Unemployed Carpenter and a big field
Phase 1 - 5 houses
Phase 2 - 10 houses
Phase 3 - 15 houses
Phase 4 - 20 houses

2) How many static buildings? What are they?

You'll need at least one static building to house the town builder. You can have as many static buildings as you want - it's up to you for the others though.

For each static building, decide who is in it, what they do, and what phase the building will show up in.

3) Who can come to the town?

Make a list of everyone who can come to your town. Why do they come to your town? What do they do once they're there? Do you need to do anything special to recruit them?

In order to provide some diversity between different player's towns, you should have at least half again as many recruitable people as you have houses to put them in. Try to mix up their quality too - have some people be really nice additions to your town, and others that don't do anything for you. You can also add secret recruitable people to spice it up a bit more.

Assign each person who can come to your town an id number.

Once all that's done, you're finally ready to start!

Step 2 - Create outdoor maps

For this step, it's a lot easier to start at the highest phase and work backwards. Build your town in its most developed phase. Remember that each building can only have one way in and out. Your town can have as many exits as you want, but only one entrance. Don't add any people or doors to it yet, just make the town. Be sure to give it a good name (like, My Town, Phase 4). Assign each building a BuildingX variable. Be sure to keep this list handy, we'll need it to link the buildings to the interiors.

When you're done with your town, copy and paste (by selecting the map in the map tree, pressing CTRL-C, then CTRL-V). Rename your map so you know it's the next lowest phase. Knock out the extra buildings and downgrade your town a bit. DO NOT MOVE THE TOWN ENTRANCE. DO NOT CHANGE THE SIZE OF THE MAP. DO NOT MOVE THE STATIC BUILDING WITH THE TOWN BUILDER IN IT. If you want to make your map smaller, just prevent the player from walking out of your bounds. You can move other buildings, but I don't recommend it (it will make linking your maps together much more confusing later).

Rinse, repeat for each phase. When you get down to phase 0, all you should have is the building with the town's builder in it.

Step 3 - Create indoor maps

First, make an empty building. This is what your players will get if they walk into a building that doesn't have anyone in it yet. Remember that it can only have one way in and out.

Next, make a building for each recruitable person or group. Go ahead and put them in the building doing whatever it is you want them to do. Remember to save some of your people so they can wander around outside - it helps to have people come to your town in small groups instead of alone - you can use a single ID number and switch for everyone in the group. Don't link the entrance to anything yet, we're coming to that.

Step 4 - Link your maps together

This is the hardest part. Right now you have a bunch of maps but they're not linked together, certainly not in any way that makes a buildable town. There's several events we have to make in order for it to work.

GoToTown

This event is called when the player enters the town from the outside. It is a common event that should be called by every teleport that takes your player into the town. It does the following:

  1. Erase Screen (using your favorite transition)
  2. Do a Conditional Branch for each phase of your town, and load ExitMap with the ID Number of the town map corresponding to that phase. You can get this by going to the Map Properties of that town map (by right-clicking it in the map tree and choosing "Map Properties") and looking at the title bar of the window.
  3. Load ExitX and ExitY with the coordinates of your town's entrance. You can get these by going to one of your town maps, switching to Event Layer Editing Mode (F7), and clicking your town's entrance. The coordinates will show up along the bottom of the window.
  4. Do a Recall to Memorized Position on ExitMap, ExitX, and ExitY.
  5. Show Screen (again, using any transition)
Presto, you're in your town, on the right map for the current phase.

You can leave your town via normal teleports.

IsTownFull

As each town phase has a set number of dynamic buildings, you can check to see if they are full by checking to see if anyone is in the last house that that phase has - in other words, if your town is in phase 1, and phase 1 has 5 buildings, your phase 1 town would be full if there is someone is house #5.

Every town is different so I can't give you step-by-step directions, but you should do a Conditional Branch for each phase of your town, and check to see if the current phase is full, using the method above. Turn on TownFull if the town is full, otherwise turn it off. The next event will use this switch.

RecruitPerson

This is called by your unrecruited people when they are being recruited. It's purpose is to link the person's building into your town in the first available house. It has some of it's own variables...
  • RecruitedPerson - This is set to the ID number of the person being recruited by the unrecruited person's event prior to calling
  • BuildingPointer - this is a pointer that you'll use to find the first available house.
  • BuildingValue - This is the value of the variable that BuildingPointer is pointing at.
Now, we do this to get them into your town.
  1. Set BuildingPointer to the ID number of your first BuildingX variable
  2. Loop:
    1. Set BuildingValue to the value stored in the index of BuildingPointer
    2. If BuildingValue is zero, break the loop
    3. Increment BuildingPointer by one
  3. At this point, BuildingPointer should be pointing at the first empty house in your town. Set this variable reference equal to RecruitedPerson.
And now this person's building is linked into your town in the first empty house.

Unrecruited people

This is the event for the people that can come to your town. For each person's actions, first call IsTownFull, and if the town is full, have them lament about how much their life sucks or whatever is you want them to do if they can't come to your town, and if it is on, have them do whatever it is you want them to do if they can come to your town, and then have the player make a choice as to whether or not they want to recruit them.

If they do recruit this person, set their Recruit switch on (which should make them vanish at their recruiting location - be sure to transition this somehow so they don't just pop out of existance), then set RecruitedPerson (for the RecruitPerson event) equal to the recruited person's ID number and call RecruitPerson.

Enter Static Building

To go into a static building (a building that never changes and is always there), build your teleport like this:

  1. Memorize Position into ExitMap, ExitX, and ExitY
  2. Teleport to your static building
Nothing hard here. Onward!

Enter Dynamic Building

This one's a bit trickier. Create a dummy Enter Dynamic Building common event - we'll come back to this in a moment, as first, we have to make the building's door events.

We'll need another variable to make this work, too. We'll call it BuildingToEnter.

Get out the list of you made earlier mapping the buildings to their buildingX variables. Go to the outdoor map for the highest phase of your town, and for each door, make an event that does the following:

  1. Loads BuildingToEnter with the value of the BuildingX variable assigned to this building
  2. Call Enter Dynamic Building
Now, the EnterDynamicBuilding event takes over, and it does the following:
  1. Erase Screen with your favorite transition
  2. Memorize Position into ExitMap, ExitX, and ExitY
  3. Now it does a conditional branch on BuildingToEnter for the ID number of each recruitable person or group that can come to your town, and zero. If it's zero, send them to your empty building, otherwise, send them to building that that ID number is assigned to.
  4. Show Screen with your favorite transition
Now, when you go through a door, you will end up in the interior of the person who it belongs to, or the empty building if it's unassigned.

You can easily get your building door events onto all your town phases by simply selecting one, copying it (CTRL-C), then switching to another town phase and pasting it (CTRL-V) into the door of that building in that phase. Do this for all doors and all phases.

LeaveBuilding

This is a simple event you use to teleport people out of your buildings. This is the teleport for all your buildings, whether they are static or dynamic.

  1. Erase Screen
  2. Recall to Memorized Position at ExitMap, ExitX, and ExitY
  3. Show Screen
And now you're back out in the town again.

Upgrade Town

This is your town builder event. This guy should have a page for each phase of your town. On each page, he shoul call IsTownFull, and if the town is full, he should offer to upgrade to your town. If the town isn't full, have him do whatever you want him to do.

You can do whatever special effects you want, but to upgrade your town to the next phase, there's only two things you have to do.
  • Increment the TownPhase variable by 1
  • Change the ExitMap variable the ID number of the map that corresponds to the new phase of the town (you can find this the same way we did when we were making the GoToTown event)
And now, when you go outside, the town will be in it's next phase.

Step 5 - Populate your town

At this point you have a town that works but the outside map is still missing people wandering around. This is where we use the RecruitX switches.

For each phase of your town, place each person you want wandering around, keyed on by their RecruitX switch. How you do this is up to you - you can have different people in different phases, you can have them say different things in different phases, etc. The easiest way it to just create them in the first phase, and copy and paste them into all the other phases. Since they're keyed on by their RecruitX switch, they will only appear after they have been recruited, and unrecruited people won't appear.

The obligatory conclusion

In this tutorial, I've outlined how to create a basic dynamic town. You can trick this out a lot once you get the basics down - the town I based this on has multiple buildable areas and some neat optional objects you can get, but you should be able to figure out how to do these more advanced things easily enough once you master all this. I hope you find this tut useful in your own games.

Up is down, left is right and sideways is straight ahead. - Cord "Circle of Iron", 1978 (written by Bruce Lee and James Coburn... really...)
[Image: QrnbKlx.jpg]
[Image: sGz1ErF.png] [Image: liM4ikn.png] [Image: fdzKgZA.png] [Image: sj0H81z.png]
[Image: QL7oRau.png] [Image: uSqjY09.png] [Image: GAA3qE9.png] [Image: 2Hmnx1G.png] [Image: BwtNdKw.png%5B]
Above are clickable links

Reply }


Possibly Related Threads…
Thread Author Replies Views Last Post
   The Development of Towns in D&D DerVVulfman 0 2,890 08-17-2018, 04:25 AM
Last Post: DerVVulfman



Users browsing this thread: