• 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!

Fix in Progress No items for sale when moored at a beach

Grey Roger

Sea Dog
Staff member
Administrator
Storm Modder
This is me in Pointe a Pitre on Guadeloupe, about to talk to one of the street traders and then buying items from him:
item_trader.jpg items_for_sale.jpg

Nothing unusual about that - except that my ship is currently at Anse Casse-Bois. Until now, if you moor at a beach and then walk into town, neither the store nor street traders have items for sale, and the street traders don't have any money which means you can't sell items either.

After some serious digging involving adding loads of 'trace' commands into both "items_utilite.c" and "Towntable.c", I think I've finally fixed it. This part of function "TownUpdate" seems to be the problem:
Code:
        TownID = GetTownIDFromLocID(Characters[GetMainCharacterIndex()].location.from_sea);
        if(TownID == ctown.id)
        {
            flt = true;
            ctown.fleetsinport.pchar = true;
        }
        // LDH 29Mar09
        if (TownID == "")
        {
            ref pchar = GetMainCharacter();
            string island = "";
            if (pchar.location.from_sea != "")
                island = FindIslandByLocation(pchar.location.from_sea);
            if (island != "")
                TownID = GetAttribute(FindIsland(island),"towns.1"); // PB: For islands with no towns
        }
First, 'if (TownID == "")' will always fail because if you're at a beach, TownID isn't "", it's "-1". So, change the condition to 'if (TownID == "" || TownID == "-1")'

Second, 'GetAttribute(FindIsland(island),"towns.1")' isn't going to work because 'FindIsland' returns an integer (the island's index). That should probably be 'GetAttribute(GetIslandByID(island),"towns.1")'.

Testing so far looks good - I've landed at beaches on Guadeloupe, Puerto Rico and Barbados, walked into town and been able to trade with street vendors. If you want to test this, download this version of "PROGRAM\Towns\Towntable.c".
 

Attachments

  • Towntable.c
    64.8 KB · Views: 52
Second, 'GetAttribute(FindIsland(island),"towns.1")' isn't going to work because 'FindIsland' returns an integer (the island's index). That should probably be 'GetAttribute(GetIslandByID(island),"towns.1")'.
Which bloody idiot wrote that??
Did that bugger even test it at all?!?
:walkplank
 
That seems to have fixed the problem if I land at a beach normally, but not if a quest teleports me there, e.g. during "Strange Things Going On in the Caribbean", when I'm delivering the first letter to Padre Domingues and am sent to Puerto Rico's beach to be ambushed by Satanists. If I then continue into town, there are still no items for sale.

Traces in 'TownUpdate' show that 'UpdateAllTowns' is called each day, and also when I moor at a port or beach. So I added this into "PROGRAM\QUESTS\quests.c", funtion 'DoReloadFromSeaToLocation':
Code:
if(HasSubstr(idLocation, "port") || HasSubstr(idLocation, "shore")) UpdateAllTowns(false);
'DoReloadFromSeaToLocation' can also be used to teleport you to a cabin or deck, so only do the update if it is in fact about to send you to a port or beach. And now, after I've finished off the Satanists as well as the thugs along the path, I can continue into town and trade items before handing the letter to Padre Domingues.
 

Attachments

  • quests.c
    58.4 KB · Views: 53
Back
Top