• New Horizons on Maelstrom
    Maelstrom New Horizons


    Visit our website www.piratehorizons.com to quickly find download links for the newest versions of our New Horizons mods Beyond New Horizons and Maelstrom New Horizons!

Random location generator (experimental)

CouchcaptainCharles

COO (Chief Oddity Officer)
Storm Modder
Pirate Legend
Note: Because this mod may be helpful to all who currently make new locations or islands I have uploaded a work-in-progress version of this mod.(FTP server, folder cccXperimentMods, NewOxbayAndRandLocs.zip) It basically works (at least on my codebase) but there may be loose ends and many dialogs and miniquests are still missing. Please do not use this preliminary mod if you want your game to be perfect ! I will resume working on this in a few weeks, I hope.




By now we have the knowledge to enlarge the PotC gameworld with new locations, locationtypes, towns and even new islands. But it would be a lot of work and probably a heavy tax on the program to make dozens of individual houses/junglelocations for each new town/island. A possible solution would be a generator that creates RANDOM locations to fill the empty spaces automatically. Random means that you can't tell in advance which location you will find after an exit, and the location will also not be permanent. That means that using ONLY random locations doesn't make much sense. But one could compose a town out of a few permanent questlocations (and maybe the stores) and many random locations.

(BTW, the same is valid for townpopulations: as soon as you create a location of the type "town" or "house" the VC mod will fill it automatically with citizens and occupants. I plan to add generated tavernkeepers and merchants etc. as well, so that as soon as someone makes a town it will automatically be populated, and only a few individual keycharacters need to be created)


Here is a first raw experimental housegenerator that connects EVERY unused door in a town with a house (so that you will never stand in front of closed doors anymore if you need help, shelter or plunder <img src="http://www.piratesahoy.com/forum/style_emoticons/<#EMO_DIR#>/smile.gif" style="vertical-align:middle" emoid=":)" border="0" alt="smile.gif" /> )

In the file characters\characters_events.c you find the function void chrCharacterEntryToLocator(), which runs whenever a character steps on a locator. If the player steps on a locator of the "reload" type (exits) that has NO connection with another location this code displays the "closed padlock" icon:


case "reload":
chrWaitReloadIsNoLink = false;
....
if(result != 1)
{
chrWaitReloadIsNoLink = true;
if(result == 0) Log_SetActiveAction("Closed");
break;
}
....

To make the player aware that the formerly closed door leads now to a random location we display some screenmessage like:


chrWaitReloadIsNoLink = true;
if(result == 0) Log_SetActiveAction("Closed");

logit("You could pry this door open, but you never know what's waiting behind!"); // ccc random locs

break;




If the player now presses the action key this function further down runs:

void chrCharacterKeys()
{
string controlName = GetEventData();
....
if(noReload)
{
if(chrWaitReloadLocator != "")
{
PlayStereoSound("knock");
}
return;
}
//trace(" &&&&&&&&&&&&&&&&&&&&&&&&&&& ");
...
chrWaitReloadIsNoLink = false;
}


What is of interest to us is the command 'PlayStereoSound("knock");', which plays the knock sound if a door is closed. Instead of doing that we'll call a function that we will name 'GoToRandomLoc()'


void chrCharacterKeys()
{
string controlName = GetEventData();
....
if(noReload)
{
if(chrWaitReloadLocator != "")
{
// ccc random locs PlayStereoSound("knock");
GoToRandomLoc() // ccc random locs
}
return;
}
//trace(" &&&&&&&&&&&&&&&&&&&&&&&&&&& ");
...
chrWaitReloadIsNoLink = false;
}

Into that GoToRandomLoc() function we will put the code for our future Random Location Generator. For convenience's sake I currently put it at the end of this characters\characters_events.c file. Over time we can add to this locationspecific code that sends you to houses if you are in a town, or jungles outside, or bedrooms, kitchens or studies from the entrance hall of a mansion, or into a maze if you are in a dungeon... Once again, PotC offers almost unlimited possibilities.

But for a simple start we'll just teleport the player to one of 14 random locations which I put into locations\init\cccRandomLocations.c :

void GoToRandomLoc() // ccc random locs
{
string randloc = "randomhouse"+rand(13); // selects a randomlocation

DoQuestReloadToLocation(randloc, "reload", "reload1" ,""); // teleport to rancloc

Log_SetActiveAction("Nothing"); // deletes padlock icon
}


So every formerly unused door now leads to some location if you press your ACTION KEY (F3 doesn't work ). If we use for those random locations some bigger houses, residences, shops etc. the random towns will even be more interesting than Akella's little huts.

So much for getting in. What will happen if you try to leave one of those new random locations? Right, because the doors of those can not be connected to any "normal" location (which one?) you will get to the next randloc, and from there to the next... Kind of an open ended game , but surely not really what we want. In order to allow the player to return from the random locations to the "normal" location he came from we must find a way to store from where he entered. The solution, as so often, are attributes. We add the names of the location and locator where the player entered as attributes ".lastlocation" and ".lastlocator" to the maincharacter.

Remember that we added the "pry open" screenmessage in void chrCharacterEntryToLocator() ? Well, I messed with that function not only for that message but because it already determines all the data we need: the maincharacter "mc", the locatorname "locator" and the location ID "loc.id". We save all that as attributes to the player mc , also the townsack attribute for townbased functions.

if(result != 1)
{
chrWaitReloadIsNoLink = true;
if(result == 0) Log_SetActiveAction("Closed");
logit("You could pry this door open, but you never know what's waiting behind!");
if(!CheckAttribute(loc, "randloc")) // not in random locations
{
mc.lastlocation = loc.id; // last "normal" location before random loc
mc.lastlocator = locator; // last locator in "normal" loc
if(CheckAttribute(loc,"townsack") ) mc.lasttownsack = loc.townsack;
}
break;
}


So we have now stored from where we entered the randlocs. Now we need to make a returnprocedure. For that I made an assumption. Please check it carefully in case I made a mistake there, which is quite possible. (If you are not in the mood for checking my twisted logic skip the next two paragraphs )

Assumption:
1. If a location has a locator with the name "reload1" it is usually the main entry. Therefore there will be almost no unconnected "reload1" locators in the "normal" locations.
2. For random locations, which WE create, we can ensure that "reload1" WILL always be the first entry point.
3. The first ENTRYpoint is also the point where one would expect the EXIT back to the former "normal" location.
1+2+3: An unconnected "reload1" is usually a locator from where the player wants to return to to a normal location.

Does that make sense? .... Well, never mind, a bit of playtesting is better than any theorizing. Should I be wrong we'll just relabel one locator in each random location as "return_spot"
BTW, you may wonder why I make so much fuss about the right return spot. Well, if you have as random location only a shabby hut it's easy: the one and only door is the return spot. But this shall also work for vast mansions with one room after the other. Or for the jungles of Cuba, where your buccaneer expedition marches through a dozen junglelocations before reaching some inland town, goldmine or palace/temple. So the random teleport procedure must somehow determine whether the player wants to march further inland(i.e. yet another randloc) or if he wants to abort his expedition(back to last normal loc, which will be in one leap the way I write it, no marching through all the locs again)

Whatever, i wrote my "return to normal" procedure so that it is triggered if you step on a UNCONNECTED "reload1" locator. It will then teleport you back to the stored ".lastlocation":

if(chrWaitReloadLocator != "")
{
// ccc random locs PlayStereoSound("knock");

if(chrWaitReloadLocator != "reload1") { GoToRandomLoc(); } // ccc random locs
else { DoQuestReloadToLocation(mc.lastlocation, "reload", mc.lastlocator ,""); }
}


Semi-random locations
I presume that every new town we will make shall have a tavern and a shop. Therefore I included an "inn" and a "tradepost" in the preliminary loactiongenerator. The owners will be generated by the new VC version as well. These locations will appear at random occaisionally "Welcome to my new tavern. I have just opened up in these rooms."
But the player will expect the tavern/shop behind the door under the tavern/shop sign. So we must ensure that whenever a player activates this door the tavern/shop will be used and not another random location.
Which is easy if we tell the location generator which locator in which townmodel shall lead to a tavern/shop. E.g. in the Oxbay townmodel the locator "reload13" leads to the tavern. So we can include a command that tells the generator "if the current model is town_Oxbay AND the locator is reload13 then teleport to tavern".


Point to point marches via random locations
What this system so far can not provide is travelling between two normal, defined locations via randlocs. But with some tricks, which i'll (try to) eplain another day (worn out now) this will be possible too. E.g. we make the island of Cuba with only two defined locations, Santiago and Havanna, and you march from Santiago through some random jungles(with a few surprise settlements or forts) in order to reach Havanna finally and surprise its defences from the landside.
 
This is wonderful, CCC, great job! <img src="http://www.piratesahoy.com/forum/style_emoticons/<#EMO_DIR#>/par-ty.gif" style="vertical-align:middle" emoid=":cheers" border="0" alt="par-ty.gif" />
 
Great stuff!

For a simple hack for point-to-point you could add on the reload locator tree in the orig location, "numrandomlocs" and "endpoint". Then on loading to random loc the first time, pchar.numrandomlocs is set to that, and on each successive load decremented, and if == 0, reload to endpoint.
But that would mean traveling backwards would decrement just the same as forwards.

Maybe we could adopt similar code as the location fantoms, for location models? I.e. on first gen a random loc for a reload locator, save the model type, and set a number of days. When the days expire, create a new interior.
Also, maybe add "size" and "type" params, for semi-random locs, i.e. small house. A more general solution than just for taverns.
Combined, it would mean that a small house would always be a small house, but every once in a while it might get redecorated. <img src="http://www.piratesahoy.com/forum/style_emoticons/<#EMO_DIR#>/happy.gif" style="vertical-align:middle" emoid="^_^" border="0" alt="happy.gif" />

And also maybe even store the character(s) of the house under the locator.randloc.settings tree, so you can even have semipermanent residents for the semipermanent locations.
 
Sort of a similiar idea... no real impact on the game other than a slightly more dynamic, ever-changing look to things, and it would play into townstrength: Maybe most shop, tavern and shipyard interiors could start out as the smallest type (or largest for a rich town), and then move to larger (or smaller) interiors as the town grows richer (or poorer)? That way you'd have more visible evidence of your helping a town grow rich (or stabbing them till they get poor).

Oh and CCC: I'll try this out! I would've sooner, when you sent me the email, but I couldn't get into the FTP.
 
Yes!
We were talking about this on the IIRC Town Economies thread...
Or even having "bare" locations and moving the furnishings in via script.
 
Right, though the bare rooms I pictured as your own... In your ship, your room in a governor's mansion (which would go along with your wifey*, and where you'd always find her instead of randomly walking around**), and maybe a few others in other places, like secret hide-outs among smugglers and pirates.

* I'd still like to see that marryin' mod made a little more interesting...

** and I'd like to be able to marry a pirate chick and take her aboard as an officer, instead of her staying in one place. Rep-up no matter where I go, whoo!
 
I like ALL of those ideas, Alan! <img src="http://www.piratesahoy.com/forum/style_emoticons/<#EMO_DIR#>/me.gif" style="vertical-align:middle" emoid=":onya" border="0" alt="me.gif" /> I was just talking to someone about the marrying mod, and thought the very same thing, it could use a bit of an overhaul. Give the wifey something more to do - nag you about things, ask you to run an errand for ya, that kind of thing... <img src="http://www.piratesahoy.com/forum/style_emoticons/<#EMO_DIR#>/whippa.gif" style="vertical-align:middle" emoid=":whipa" border="0" alt="whippa.gif" /> <img src="http://www.piratesahoy.com/forum/style_emoticons/<#EMO_DIR#>/laugh.gif" style="vertical-align:middle" emoid="xD:" border="0" alt="laugh.gif" />
 
Yes, good ideas Nathan and Alan <img src="http://www.piratesahoy.com/forum/style_emoticons/<#EMO_DIR#>/me.gif" style="vertical-align:middle" emoid=":onya" border="0" alt="me.gif" /> Maybe one can develop diferrent versions out of my rough experiment: one that sends you to comletely random surprise locations, one that stores the way you took and let's you return, one that stores a location as attribute to the reload locator so that it always leads to the same location (would look much more senseible )
 
Few notes:
- EVERY locked entrance now leads to a new location, even entrances that should be properly locked (think of locked town gates (tutorial) or your cabindoor)
- Saving in a random location causes a black screen when loading it again, so don't do that!
- I'd like random locations to be stored, so that the tavern won't suddenly have changed into a governor's mansion in a few seconds. That's a bit weird.
- The random taverns seem to be a bit empty, without any visitors. And defenitly without people sitting at tables. Could be mistaken here though.
I'll post more when I find them.
 
Hee hee hee hee, yeah, you get married and your wifey becomes a quest-generator... "Now Nathaniel dearest my relatives are all coming over for dinner tonight so I'll need you to pick up a few things on your way to the boarding party. Please don't forget some fine French cheese -- oh nevermind the blockade, I need that cheese Nathaniel -- and a few pounds of coconuts -- the PIRATE kind Nathaniel, you know how that other kind upsets my digestion. Oh and while you're out will you remember to find me some new jewels to go with this new dress? I've had my eye on this beaUITiful brooch I saw sitting in the bottom of a chest down in the Redmond dungeon, past all those rats and skeletonpirates. Be a dear and run along now."

"Yes, dear..."
 
<img src="http://www.ganotherapyusa.com/extras/pink.gif" border="0" class="linked-image" /> INDEED! <img src="http://www.piratesahoy.com/forum/style_emoticons/<#EMO_DIR#>/laugh.gif" style="vertical-align:middle" emoid="xD:" border="0" alt="laugh.gif" />
 
<!--QuoteBegin-alan_smithee+Apr 22 2005, 02:57 AM--><div class='quotetop'>QUOTE(alan_smithee @ Apr 22 2005, 02:57 AM)</div><div class='quotemain'><!--QuoteEBegin-->Hee hee hee hee, yeah, you get married and your wifey becomes a quest-generator... "Now Nathaniel dearest my relatives are all coming over for dinner tonight so I'll need you to pick up a few things on your way to the boarding party. Please don't forget some fine French cheese -- oh nevermind the blockade, I need that cheese Nathaniel -- and a few pounds of coconuts -- the PIRATE kind Nathaniel, you know how that other kind upsets my digestion. Oh and while you're out will you remember to find me some new jewels to go with this new dress? I've had my eye on this beaUITiful brooch I saw sitting in the bottom of a chest down in the Redmond dungeon, past all those rats and skeletonpirates. Be a dear and run along now."

"Yes, dear..." <img src="http://www.piratesahoy.com/forum/style_emoticons/<#EMO_DIR#>/huhh.gif" style="vertical-align:middle" emoid=":eek:k" border="0" alt="huhh.gif" />
<div align="right">[snapback]102134[/snapback]</div><!--QuoteEnd--></div><!--QuoteEEnd-->It would be really funny if ths would be implemented! <img src="http://www.piratesahoy.com/forum/style_emoticons/<#EMO_DIR#>/laugh.gif" style="vertical-align:middle" emoid="xD:" border="0" alt="laugh.gif" />
 
Heh, maybe you should learn to do this, Rico, then you could work on it yourself! <img src="http://www.piratesahoy.com/forum/style_emoticons/<#EMO_DIR#>/me.gif" style="vertical-align:middle" emoid=":onya" border="0" alt="me.gif" />
 
I haven't even been PLAYING PotC, actually, so I'll wait for B13 to get started in tinkering with code. <img src="http://www.piratesahoy.com/forum/style_emoticons/<#EMO_DIR#>/wink.gif" style="vertical-align:middle" emoid=";)" border="0" alt="wink.gif" />
 
<!--QuoteBegin-alan_smithee+Apr 22 2005, 01:57 AM--><div class='quotetop'>QUOTE(alan_smithee @ Apr 22 2005, 01:57 AM)</div><div class='quotemain'><!--QuoteEBegin-->Hee hee hee hee, yeah, you get married and your wifey becomes a quest-generator... "Now Nathaniel dearest my relatives are all coming over for dinner tonight so I'll need you to pick up a few things on your way to the boarding party. Please don't forget some fine French cheese -- oh nevermind the blockade, I need that cheese Nathaniel -- and a few pounds of coconuts -- the PIRATE kind Nathaniel, you know how that other kind upsets my digestion. Oh and while you're out will you remember to find me some new jewels to go with this new dress? I've had my eye on this beaUITiful brooch I saw sitting in the bottom of a chest down in the Redmond dungeon, past all those rats and skeletonpirates. Be a dear and run along now."

"Yes, dear..."
<div align="right">[snapback]102134[/snapback]</div><!--QuoteEnd--></div><!--QuoteEEnd-->
Ah, very much like in real life <img src="http://www.piratesahoy.com/forum/style_emoticons/<#EMO_DIR#>/yes.gif" style="vertical-align:middle" emoid=":yes" border="0" alt="yes.gif" /> We are currently renovating garden and carport, so I meet such a questgenerator every day: "Darling, the lawnbales will be deliverd on tuesday. Make sure the well is ready by then." "The rooftiles and pavement stones come on Thursday. Where shall they be stored?" "How about a pergola with white roses spanning over the gravelpath?"
Spring is definetely a bad season for modding! <img src="http://www.piratesahoy.com/forum/style_emoticons/<#EMO_DIR#>/dunno.gif" style="vertical-align:middle" emoid=":shrug" border="0" alt="dunno.gif" />
 
<!--QuoteBegin-Pieter Boelen+Apr 21 2005, 02:11 PM--><div class='quotetop'>QUOTE(Pieter Boelen @ Apr 21 2005, 02:11 PM)</div><div class='quotemain'><!--QuoteEBegin-->Few notes:
- EVERY locked entrance now leads to a new location, even entrances that should be properly locked (think of locked town gates (tutorial) or your cabindoor)
- Saving in a random location causes a black screen when loading it again, so don't do that!
- I'd like random locations to be stored, so that the tavern won't suddenly have changed into a governor's mansion in a few seconds. That's a bit weird.
- The random taverns seem to be a bit empty, without any visitors. And defenitly without people sitting at tables. Could be mistaken here though.
I'll post more when I find them.
<div align="right">[snapback]102080[/snapback]</div><!--QuoteEnd--></div><!--QuoteEEnd-->
You are quite correct with all points, Pieter. There is certainly still some work to be done on this experiment.

The bad safe problem seems to be the same that tailorshops and the shipcabin have. Maybe those locations lack some feature that are necessary to load a saved game. until we find that feature I'll disable saving in random locations.

Storing where a door leads to so that it is always the same room would certainly make more sense, and it will be the next thing that I'll tackle. OTOH for a thief roaming the town for plunder it might be more interesting if the rooms were a surprise. Maybe I can combine both features somehow.
 
well cool, ccc <img src="http://www.piratesahoy.com/forum/style_emoticons/<#EMO_DIR#>/happy.gif" style="vertical-align:middle" emoid="^_^" border="0" alt="happy.gif" />


<!--QuoteBegin-CouchcaptainCharles+Apr 25 2005, 08:13 AM--><div class='quotetop'>QUOTE(CouchcaptainCharles @ Apr 25 2005, 08:13 AM)</div><div class='quotemain'><!--QuoteEBegin-->Storing where a door leads to so that it is always the same room would certainly make more sense, and it will be the next thing that I'll tackle. OTOH for a thief roaming the town for plunder it might be more interesting if the rooms were a surprise. Maybe I can combine both features somehow.
<div align="right">[snapback]102496[/snapback]</div><!--QuoteEnd--></div><!--QuoteEEnd-->

maybe the location models should be stored forever once the location has been visited, but the people and contents could be re-randomised after a certain time? ie. when the player reloads, a check could be done on when the last visit was, which would decide whether to re-load the contents or create new ones.

maybe an exception would be the jungle - nathaniel might get lost in the jungle and go from randloc to randloc (no doubt with all sorts of danger in store) a certain defined number of times...?
 
Oh, and Alan, darling, while you're at it, could you make me a new character? And CCC, dear, now would you find this bug for me ?

I really feel discouraged to ask *anything* of *anyone* lest I be called a "quest generator".

Well, apart from that, ROFL.
 
You had a character in mind Inez...?

Actually this isn't quite the right thread for this but you've just reminded me: The wifey characters are kinda boring. They are plain and vanillia. In addition to all the other changes to them and their function, I'd like to be able to get them new outfits just like my officers. They'd <3 you even more of course if you got them a beautiful ballgown or something, and they'd look hotter in it.

(And if you play as a female character you could get them a nice strapping man's outfit)
 
Back
Top