Dynamic Towns - Printable Version +- Save-Point (https://www.save-point.org) +-- Forum: Games Development (https://www.save-point.org/forum-4.html) +--- Forum: Tutorials (https://www.save-point.org/forum-19.html) +--- Thread: Dynamic Towns (/thread-3482.html) |
Dynamic Towns - DerVVulfman - 05-17-2011 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:
Step 1 - Plan your town The town we're going to go over building has these characteristics:
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:
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...
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:
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:
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.
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.
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. |