Sectoring Tutorial
Winnings: $851
Has my first loss with the system. Nearly $600. Was prepared for it, but comes at a bad time when I am flying out of the country next week: gave me a cash-flow belt. O well, could rant about it but have to be philosophical, if I lose $600 to make $1400 regularly, its a good deal no matter how shitty the losses feel. Most of the $1400 was made $50 at a time, so its like 25+ wins to one loss. Starting at $600 again (where I have 'upped the ante so I am winning $100 instead of $50, and risking $600 instead of $400), I would only need 6 wins to get that money back. Of course a couple more losses like that and I will throw it in, as I said, won't throw good money after bad.
Now, a tutorial...
Today, we are going to sector a new map from beginning to end. This will allow people to use ToEEWB easily, where atm it may seem a scary and daunting task. Its not, if you actually take the time to RTFM and do the tutorials - ALLANON for instance threw himself into the task and come out with a very nice (and very useful) Forest map that will grace KotB and earn him unending glory. (I also want him to sector a swamp map for me when I have hacked the jpg together - I haven't forgotten dude!)
You will need:
- a new map .jpg
- the latest copy of ToEEWB
- a copy of ed.py in your sec folder
- thats about it
I am doing the ground floor of one of the towers by the Keep Gate. Afficianados will remember this has 12 men-at-arms in its garrison, 3 floors and the roof. Will all 3 floors make it in? Probably not, there is just nothing going on in there... what we ARE going to do is quarter the Corporal of the Watch here (the guy who meets you at the front Gate). The module details where the various officers live, but not this guy - it seems reasonable he should live here. Screeg has done a very useful ground floor map with his quarters, and that is what we shall be concentrating on today. The map looks like this.
First of all, we need somewhere to put the map, so we pop open maplist.mes in the modules/KotB/rules folder. We want an original Hommlet map (ie area 1 in the game) to go over, so lets use the map 5033, the Moneychanger. We'll rename it GateTower-first. The maplist.mes now reads:
{5033}{Map50-Keep-GateTower-first, 482, 485, Flag: DAYNIGHT_XFER, Flag: UNFOGGED}
The numbers are way wrong but its pretty much irrelevant: those are only there for moving by WorldMap, and we ain't gonna be doing that to get in here! We will come in by the door (or down the stairs) and will use the Jumppoint.tab to control that. But lets not get ahead of ourselves.
Now we need to name our map, so we pop Map_names.mes and at line 5033 we modify it thusly:
{5033}{Gate Tower - First Floor}
We can type anything here, its not important, it just shows up in a few places like your little map list in the 'WorldMap' bit of the interface.
Next we do Maplimits.mes. This is currently in modules/KotB/rules, but Agetian tells me the game is not drawing from there and it is the wrong place! Well, its a concern, but thus far it works (drawing from the current one I guess) and you'll forgive me if there are more important things to do: I WILL fix it before the end - Agetian has gone to great lengths to understand the parameters used here - and I will certainly fix it at some point. As I said though, atm it works, and thats all that matters.
What I do here is modify the limits to match the Main Floor map of the Hommlet Church. This is my 'base' map for practically everything I am doing, (a few larger maps being the exceptions) so most of the KotB maplimit parameters are identical. 5033 is now changed to match there, so it now says:
{5033}{1020,-12544,-780,-14084}
What do those limits mean? Well, I do know (because Agetian explained it to me at great length, complete with diagrams), but this tutorial is going to be long enough! Suffice it to say they set the limits where the map stops scrolling.
What next? Well, we need our new map to be accessable by the game. This involves two new folders:
One has the graphics.
One has the other files.
First the graphics. Our new map is defined in maplist.mes as Map50-Keep-GateTower-first, so thats what our Folders will be called. The first one goes in the modules/KotB/art/ground folder, the second in modules/KotB/maps folder. First things first.
I make a new folder in modules/KotB/art/ground called Map50-Keep-GateTower-first. This is where all the actual backround map graphics are kept. There is also a file in that folder called ground.mes - this is the control file that tells the game what maps to look out. Its done in rather a funky way, but we'll get into that in a minute. For the moment, lets just copy over the money-changer's map entry, number 52. Then we will go down to number 1052 and make the same entry. They now read:
{0052}{Map50-Keep-GateTower-first}
{1052}{Map50-Keep-GateTower-first}
These are the day and night entries. Since this is a military tower with no windows, we don't bother with day and night entries, the place is identical inside needing artificial light at all times. Some maps, such as the pub or the outdoor ones, have seperate day and night graphics to differentiate them, and Screeg has done a fantastic job for them. If we WERE to do day and night, we would call them:
{0052}{Map50-Keep-GateTower-first-day}
{1052}{Map50-Keep-GateTower-first-night}
and we would have TWO appropriately-named folders in the modules/KotB/art/ground folder, with different jpgs.
Did I mention I learnt all this bit from Jota's map tutorial in the Co8 forum? Good for him! On the shoulders of giants, I tells ya...
Next, we need our modules/KotB/maps folder, so we make one in there called Map50-Keep-GateTower-first. This folder will contain our sec files, mobs, those recently tamed svbs, lighting files etc, and a sexy little device called map.prp.
What does this file do? I have no idea! Thats another Agetian question. What I have done with it is simply modify one number to get it to point at a different set of jpg images. Thats what we are going to do with it now.
Grab an map.prp from a nearby folder and copy it into our new folder. Open it with a hex editor (this is where we modders earn our money). You'll see a bunch of numbers - the amount can change, I think its because the hex-editor itself will sometimes pad out the file with zeros. Some of the numbers (like c0 03) look familiar from countless hex-hacks of mob files, but in fact the only number we need is the first one. Mine is 30: I'm changing it to 34, thats 0052 in hex. Soooooooooo, lets recap:
Maplist.mes tells the game there is a new map referred to by the title Map50-Keep-GateTower-first and the number 5033. Map_names.mes gives the map a title for when that is necessary.
When you access this map (by teleporting to map 5033, say) the map looks for a folder in the maps folder similarly designated Map50-Keep-GateTower-first.
Inside that folder is map.prp: the game reads this, and hits the number 52 (hex 34). It then goes to art/ground/ground.mes entry 52 (or 1052 at night) to access the appropriate graphics files for the background image of the map. These, entry 52 tells it, are found in the folder Map50-Keep-GateTower-first of the ground folder. So it goes off and gets them, and thus we have our background map onscreen.
That will get our background jpg up on the screen. Lets prepare it.
First, I take the pic and I resize it for the game. In the past, this has involved getting a map from ToEE and comparing it in Photoshop to the new one, then resizing the new one and running a character around on it and seeing if it fits. Try using something like a chair or something definite (again, I use the main Floor map of St Cuthbert's church, some of the furniture in the side room can nicely be compared to the furniture on the new map). There is some trial and error of course, and on occasion Screeg has had to redo stuff (which he has been good about).
For this map, it is on the same scale as the Bailiff's tower so I just have to match that - easy. However, so you know how to do it... the game maps are of course kept in the folders in module/ToEE/art/ground. If you have a look in there though, u find they are all hacked up into little jpgs of identical size. How do we combine them into one map to work off?
Thats where ToEEWB comes in. Run it, and click on '2d Maps'. We want to recombine THE BIG MAP, so do this: click it (go on!) Then navigate to wherever you have unpacked ToEE.dat and find art/ground and whatever map you want to recombine. Note if you wanna recombine the main Hommlet map, u better have a lot of processing power and RAM and some time on your hands ;-) Early P4s with 512Mb (like mine), don't bother!
Now, I don't need to do that, but I DO have to have already done it (hows that for a pluperfect) for reasons we will soon see. I am doing the opposite, instead of combining a map I am splitting it for the game to read from art/ground. So, I resize my map in Photoshop to match the existing tower one and save it into the ToEEWB/2D Maps Folder.
At this point I have a surreal experience - its already there. Apparently I did all this when Screeg first sent me the map becuase I was excited to get it. Hmmmm...
Well I haven't split it, thats for darn sure! Still got ToEEWB open? Yes? Good. Click 'split'. It should bring up the ToEEWB/2D Maps folder. If your jpg isn't in there, stick it in. But don't click split yet.
The reason why I suggested recombining a map first is it will create a .txt file named from that map, explaining how wide and long the map is. When u split your map, u need such a text file to tell ToEEWB how many files to split it into and how to 'name them'. Make sense? No? Trust me... if u open ToEE/art/ground and pop a map, you will see they start with names like 001F001D.jpg. Without the .txt file, ToEEWB will start numbering them as 00000001,jpg, and the game will not know what to do with them. So whatever map u r 'emulating' (as I am with Map-5-Main-Floor in the church), recombine it first for the .txt file!
Now... I copy this .txt file and rename it to match my .jpg - gate_tower_ground.txt in this case (this is for the internal workings of ToEEWB, doesn't have to match the map names of the in-game folders or anything.) NOW I can click split.
Some seconds later (for a map this size) and we now have a new folder in ToEEWB/2D Maps called gate_tower_ground. Copy its contents over to the modules/KotB/art/ground folder, into our folder Map50-Keep-GateTower-first (shoulda called that GateTower-ground - o well, live and learn).
Now it should work. Power up the game. Got ed.py installed in your scr folder? Yes? If not, get it from ToEEWB. Run the game, new party (or whatever) and teleport to our new map, 5033 (go to 500,500, thats always safe). To do this for the newcomers, open the console and enter:
from ed import *
Then hit enter, that loads in the ed.py file. Now type:
tp (5033,500,500)
and hit enter, that teleports you nice n simply :-)
Done it? Yes? No? Well I just did, and it worked - woohoooo!!! After a few seconds running around, I saw this:
All looks a bit cramped to me, but the perspective is right, and after all, its a barracks - not meant to be wide open spaces or anything.
Ok, all good so far, we have a new map and we can run around on it. BUT... we can run around on it a bit too much, straight through walls etc. Lets start sectoring!
This is where ToEEWB comes into its own. With ed.py in there, we can sector in walls etc, and other unpassable areas just by running a character over them in the game. Couldn't have an easier method if u tried (and there is an easy method in ToEEWB itself done by painting, we'll see that in a minute).
To get ed.py to function, once again we type into the console:
from ed import *
and hit enter. Note that you only have to do this once per 'sitting', though if you reload a game u have to do it again (though it will be in the console memory and u only have to scroll up, find it and hit enter).
What we are going to do first is outline the edges of the map: ie, the walls where you want the player to stop. First we are going to activate the script that records the position of the walls as we are going to define them, then we are going to actually define them by moving the leader (the PC in the leftmost position in your party roster at the bottom of the screen) around the places we later want to be 'walls', ie unmovable. So, the first thing to do is move the leader to the edge of a wall, thusly.
Then, we activate the script by typing in
blk_on()
This means we are turning on 'blocking' - marking areas that block all movement (you can't walk through them, fly a familiar over them, shoot through them etc). Walls, for instance. There are also areas you can fly over but not walk over, and areas that provide cover (-4 to hit). We can also define water this way.
If it worked, you should see the following in your console:
If it didn't work, you will see something about an unnamed string or something - its pretty clearly an error, and means you either didn't activate ed.py as above, or there was a typo somewhere.
Once you have it up and running, you then run the character where you want the wall to be, eg:
Be careful, u can't undo mistakes in-game, u have to manually open the sector in ToEEWB and fiddle it. We will do this next, but its a pita, so for the moment just don't make mistakes. Using this method, u should be able to do a nice square around the outside of the room. To turn off blocking, you type:
blk_off()
and should get the following reponse:
Again, u can just scroll up to reuse these commands, you don't have to type them over and over.
If you want to add a single tile, instade of painting an area, just type in
blk()
The other commands are fly() and cov() for fly-over and cover respectively, ditto fly_on(), fly_off(), cov_on() and cov_off(). Run around the map making the desks and beds etc fly-over (or providing cover, if u r nasty enough ;-)). Add puddles (if your map has the graphix for it) with wtr().
Pretty soon, your console will look something like this:
Now we can have a look at what we have done in ToEEWB. The files have automatically been writing themselves in the /sectors folder. To see what you have done, click on the Sectors tab in ToEEWB (second from left), then open - there should be two new sectors in there. Open the first one, then click tools/visual sector analyzer. When it comes up, hit refresh down in the bottom corner: there's a visual image of what you have just made! So easy to use... the blue bits are blocked, light green are providing cover, dark green are fly over etc. Mine looks like this:
I then clean it up a bit, using the painting command. To paint, on the right click on 'paint mode' then what you want to paint ('fully impassable' ie blocked, 'fly over' etc). Note that 'fully passable' can be used now to correct errors. Doorways need to be two tiles wide to get through, btw. Once cleaned up, it looks like this:
After you have cleaned it up or made whatever changes you want to make in the painting tool, don't forget to SAVE THE SECTOR! You can switch off the painter bit without losing anything btw, but save the sector on the ToEEWB interface proper.
Now, to test it, I copy it to the modules\KotB\maps\Map50-Keep-GateTower-first folder: the folder that atm should only have map.prp in it. Just copy it, don't move it - that way while you are testing, if there is anything you want to change, the files are right there in the sectors folder to be easily modified.
Run the game and don't forget to clean the map cache! Then teleport to the map and run around it.
You can't - there are walls to stop u! So teleport this time to 508,487: that should put you comfortably in the room.
Ok... now things get funky. We are going to use the .svbs to make our characters grey out when they are behind walls (so we have a '3d'(ish) interactive environment not just a painted background our characters walk over).
If you haven't read the tutorials in the ToEEWB about svbs, do so - they are very short, and provide one brilliant idea. That is, to see where you want to do your svbs, you should paint them on the map using ed.py by marking them as water.
See, these different things are stored in different files. Sectoring stuff like we have done is stored in the .sec files, svbs in the .svb file, and water in the .hsd file. So, u run around marking everything as water where u want the model to grey out, then in ToEEWB you paint it up as svbs, then presto, just delete the .hsd file (or never copy it over to the map folder) and the water is gone.
We have to do this because svbs can't be painted using ed.py, they can only be added with ToEEWB; so we need a frame of reference so we know where we are putting them. So paint them as water, and you're set.
So what do we do? Well, on the map, put your leader somewhere that s/he should be covered by a wall. Then enter:
wtr_on()
and run around behind the wall, everywhere. When you are finished, do wtr_off(). To do individual tiles, use wtr(). Get out and open the file in ToEEWB. Now, (make sure ur ToEEWB is up to date, only the most recent versions support this!!!) where it says
Sector Visibility Blocking (will be painted over existing tile data)
go into paint mode and click on + extend +. Paint OVER your water tiles (the ones with little light blue squares) and notice you are now ADDING little brown squares to indicate that the .svb dfile is acknowledging this tile (the file will now be created of course). You are not replacing what is already there.
When u have marked up all the 'water' tiles, and any others you may hjave missed or wish to add, you should ALSO do ALL the relevant walls that the player is behind, that is, the wall that is blocking players visibility. Svbs don't just grey out the models so they look like the player is behind a wall, they also (when the map is properly lit) prevent the far side of the wall being lit / seen, to prevent u seeing through walls, very handy.
Here is a pic of what I have done for my map. Note the water tiles I have painted over (and in some additional cases where I have allowed for the leader not being able to 'run' as accurately as I would have liked) and how the southern walls in each room have also been svbed as well as the areas the player runs around in.
I have also done the 'ceilings' (the long black bits indicating the tops of walls - the long lines in each direction).
And here is an image of it all done, with greyed out models in place:
Bit hard to tell from the pic, but when you go from 'normal' to 'behind wall', it is quite noticeable. Ok, lets add an internal door. {Edit: Forgot I did 'internal door sectoring' when I uploaded the pix of the doors! Thought it all felt familiar... o well, you've had the theory, here it is in practise 9^D } First we have to decide where to put it, so we power up the game, go to the map, run our leader to where we want the door to appear, and (with ed.py activated of course) type:
loc()
in the console and hit enter. (You probably knew to do that by now, its a common command). Apparently my door is going at 499, 477.
Now go to ToEEWB and prepare to create a new object. We need a door, so check out THIS tutorial and find one to suit you. I am gonna try one of the first couple. The rotation will be the same as any other mob, lets call it 2.3 for the moment. Lets leave it simple. We'll fiddle it momentarily. Here's all you need:
Your GUID will be different of course ;-) When u r finished, click 'embed'. This writes the door INTO the .sec file (it doesn't save it as a .mob). You CAN save it as a mob if u wanna work on it later, but its not gonna run in the game that way. O and u don't have to click 'save' if u have the sector open or anything: in fact, if you DID have the sector open, click embed, then click save, you will save your already open sector OVER the one with the newly embedded door and it would disappear (done that more than once while fiddling exact door locations. We'll do that in a minute).
Ok, I am gonna copy mine into the game's maps folder and see what it looks like in the game.
Oops... got the rotation WAY wrong... must've been thinking of something else entirely. Lemme see, where have I used a perpendicular door to this? The Guild building? Can't remember... pity, because Screeg's maps tend to be the same camera-angle, so once u have fiddled around getting the rotation perfect once, u can transport that number to other doors (I have that luxury, yay Screeg!).
O well, trial and error time. Lets get the rotation correct before we nudge it into the right location.
I am trying 3.9 this time (shifting the door from SE facing to SW facing). Ok, embed the new door.
Trouble is, now we have two! So, we open the sector file, and click on 'static objects'. There are our 2 doors.
So delete the top one. Now we have one door, our latest one. SAVE the modified sec file, and copy it over to the game.
Run the game (clear the map cache!) and lets take a look.
Ooo nice! Before we see if it needs any minor rotational adjusting, lets get it in the doorframe properly. Have a look at your 'Isometric Schematic View' in the sector section (Agetian thinks of everything ;-)) We want to move our door slightly forward on the x axis, and slightly back on the y. So, we now use the offsets, and I'll do 'em both by 10 for starters. Btw, if u keep the door as the open object in ToEEWB (as I am here) then u can keep fiddling it and re-rembedding it. If not - if u go back and change an embedded object later - u have to extract it as a temporary mob to play with. ToEEWB talks you through it though, its easy enough.
Oooooooooo, so close! Its just a weeee bit too far up the y axis, and sitting off the ground (at least from our perspective, not really of course!) Lets tweak the y by 2 and move it down the z axis by 10.
Don't forget to open the sec file after u have embedded the changes and delete the old door, then save again! Bet u forget to do that at least once... if there is more than one door on the map, thats why! If you go to copy a tinkered .sec file over to the game and it has grown in size even though u have only fiddled the door, not added more stuff, thats a dead giveaway you forgot to delete the old one.
Anyways, that last tweak'll do nicely! (Though I had a screenie of it but apparently not.) The door doesn't actually fit the frame perfectly - slightly too short, tiny gap at top - but seriously, there's nothing we can do about that. The one time I tried to resize an embedded obj like you can resize a mob (to turn lizards into dragons, or quasits into Daemons etc) the game CTDed, alas. An ill-fitting door is a small price to pay though: at least its straight. I AM gonna move the door up ever so slightly to spread the gap AROUND it not just have it at the top like that, but otherwise I think its fine.
Lets leave it there. Later I will probably make the door lockable, give the key to the Corporal, etc - I will also add door and stair icons to allow you to leave the room ;-) and get the Corporal to head off to the pub by night and be here by day (and get rid of him from the front gate!) But thats for later.