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

Fixed No maps for sale

Grey Roger

Sea Dog
Staff member
Administrator
Storm Modder
Sometimes a storekeeper has no maps for sale.

Fair enough, items are random, so he may genuinely have no maps for sale. But in the storyline on which I'm working, it's important that the player gets one particular map, so I arrange for the storekeeper in Santiago to have one. But occasionally he still won't sell it and the "Maps" section of the item buy/sell interface is blank. He certainly has the map - I inserted a bit of code to allow fighting in the store, mugged him, and the map in question was among his equipment.

My thought was that if the storekeeper has no maps originally then the "Maps" section is blank even if he's subsequently acquired a map; he still isn't prepared to sell maps, so it doesn't show up. But apparently there's been a general shortage of maps for sale and this may be linked, which is why I'm reporting it here.
 
@Grey Roger: Thanks for the report.
I forgot to ask: Do you have a savegame that is affected by the "no maps" issue?
That might make it easier for me to test; otherwise I may end up searching for such an instance, only to find maps everywhere when I don't want to. :facepalm
 
I confirmed this problem and am now investigating the cause.

Simple solution is to add this attribute to the player character:
Code:
PChar.alwaysshowitems.mapcuba = true;
Then use this afterwards:
Code:
DeleteAttribute(PChar,"alwaysshowitems.mapcuba");

But that doesn't do anything about the root cause:
The game considers a "minlevel 1" item of "quality 3" (??? Why not -1???) to be TOO GOOD for a "Quality 10" item trader.
Therefore all maps are marked as "buy only" and you can only SELL them to the trader, but he won't sell them to you even if he has them.

Ideally the item trading system requires some careful thought because at the moment I don't think it 100% works like we would want it to.
 
It seems I managed something interesting here. Extract attached to PROGRAM\ITEMS to try, then press F11 in your savegame!

With this code, setting "itm.quality = -2" results in the "quality" attribute being removed.
Then those items remain available throughout the entire game, regardless of player/trader levels.

At the moment, I applied this trick exclusively to the Maps.
Additionally, I set itm.rare = 0.01; which is a VERY low value, but even at the start of the game, there are several available.
Checking that "Level 10" trader from the Save posted above, he has nearly ALL of them regardless of that low rarity value.

On a savegame, it may take a while for this change to become apparent,
because item traders need to be "reset" individually before they start making use of this changed situation.
That eventually happens over time, so there should be no manual action required.
It will immediately be correct at the start of a new game, of course.

@Grey Roger: To correct your savegame, you should:
1. Load the file
2. Press F11 to Reinitialize
3. Execute this code through console to "remind" the item trader that he DOES sell maps now:
Code:
   ch = CharacterFromID("Jose Zugarro");
   SetTraderItemStats(ch, IT_RECALC_ALL);
4. You can also execute this line afterwards (OPTIONAL):
Code:
GiveNewItemsToTrader(ch);
GiveItem2Character(ch,"mapCuba");
That will give brand new items to the trader and he should have PLENTY maps afterwards.
Because that first command erases his previous items, you need to re-give the Cuba Map afterwards.

Long story short:
- If you start a new game on Ardent, he should now ALWAYS have that map, because you manually add it to him
- With the new initItems.c file, he should now also always SELL it

So I think that solves the problem. The stealing of the map should now be superfluous, but of course that is a fun thing to keep anyway.

I hope this helps you. And even moreso: I hope this finally solves the problem of "maps stopping to appear" as the game progresses!
 

Attachments

  • initItems.zip
    51.1 KB · Views: 152
Is this for the latest version (Beta 4)? I ask because i've noticed this issue in Beta 3.1, but when i was able to playtest Beta 4 i was pleased to see Maps for sale in most of the merchants, iirc Beta 3.4 also seemed to have them.

Anyway is this potential fix suitable for 3.1? I would prefer to have a chance of maps, rather than none or all maps, can that work? I'm sure we did get this working for various items at some point in the past.....
 
Is this for the latest version (Beta 4)?
For certain. :yes

I ask because i've noticed this issue in Beta 3.1, but when i was able to playtest Beta 4 i was pleased to see Maps for sale in most of the merchants, iirc Beta 3.4 also seemed to have them.
As far as I can tell, it has been a long-standing issue. But it never made it onto the Bug Tracker properly and we never did investigate.
So it isn't much of a surprise that you would notice it in older game versions too.

Anyway is this potential fix suitable for 3.1? I would prefer to have a chance of maps, rather than none or all maps, can that work? I'm sure we did get this working for various items at some point in the past.....
You might be able to work into into earlier game versions.
Find:
Code:
  if(sti(itm.quality) == -1)  // means we auto-assign
  {
  price = stf(itm.price);
  if(!CheckAttribute(itm,"groupID"))
  {
  // All items have groupID now so this code is never used
  qual = pow2(price, IT_QUAL_AI_POW) * IT_QUAL_AI_SCL;  // price^0.5 * 0.165, 150=2, 925=5, 3700=10
//  Trace("Item without GroupID = " + itm.id);  // never gets executed
  }
  else
  {
  price /= IT_WEAP_PRICE_SCL;  // price / 0.25
  qual = pow2(price, IT_QUAL_AW_POW) * IT_QUAL_AW_SCL; // (price*4)^0.33333 * 0.22, 200=2, 3000=5, 5000=6, 23500=10
  }
  itm.quality = iclamp(IT_QUAL_MIN, IT_QUAL_MAX, round(qual));  // 1..10
  }
  if(CheckAttribute(itm,"groupID"))
Replace with:
Code:
  if(sti(itm.quality) == -1)  // means we auto-assign
  {
  price = stf(itm.price);
  if(!CheckAttribute(itm,"groupID"))
  {
  // All items have groupID now so this code is never used
  qual = pow2(price, IT_QUAL_AI_POW) * IT_QUAL_AI_SCL;  // price^0.5 * 0.165, 150=2, 925=5, 3700=10
//  Trace("Item without GroupID = " + itm.id);  // never gets executed
  }
  else
  {
  price /= IT_WEAP_PRICE_SCL;  // price / 0.25
  qual = pow2(price, IT_QUAL_AW_POW) * IT_QUAL_AW_SCL; // (price*4)^0.33333 * 0.22, 200=2, 3000=5, 5000=6, 23500=10
  }
  itm.quality = iclamp(IT_QUAL_MIN, IT_QUAL_MAX, round(qual));  // 1..10
  }
    if(sti(itm.quality) == -2)   DeleteAttribute(itm, "quality"); // PB: Remove attribute for items that should remain available throughout the game
  if(CheckAttribute(itm,"groupID"))
Eg. add the line marked "PB" near the bottom.

Then find:
Code:
int InitMap(int n, ref map)
{
   ref refMap;

   if (!CheckAttribute(map, "id")) return n;
   if (!FindFile("RESOURCE\Textures\INTERFACES\Maps", "*.tga.tx", map.id + ".tga.tx")) return n;

   makeref(refMap, Items[n]);
   DeleteAttribute(refMap, "");
   CopyAttributes(refMap, map);
   refMap.index = n;
   //refMap.picTexture = "items_maps";   //JRH
   refMap.numrand = 0;
   refMap.quality = -1;
And replace with:
Code:
int InitMap(int n, ref map)
{
   ref refMap;

   if (!CheckAttribute(map, "id")) return n;
   if (!FindFile("RESOURCE\Textures\INTERFACES\Maps", "*.tga.tx", map.id + ".tga.tx")) return n;

   makeref(refMap, Items[n]);
   DeleteAttribute(refMap, "");
   CopyAttributes(refMap, map);
   refMap.index = n;
   //refMap.picTexture = "items_maps";   //JRH
   refMap.numrand = 0;
   refMap.quality = -2;  // PB: If -2, attribute is removed and item should be ALWAYS available
   refMap.rare  = 0.01; // PB: Low value so each trader has only VERY few of them
It is just those final two lines that are new/changed.

I'd definitely be interested to hear from you if that helps and maps then no longer disappear from the game at higher levels.
Or would be missing from certain traders.
 
It seems I managed something interesting here. Extract attached to PROGRAM\ITEMS to try, then press F11 in your savegame!
Thanks! :onya Is this included in the 6th February update or should it be installed in addition to that?

I won't need to correct a savegame because developing the storyline requires that I routinely start a new game anyway. Additions or changes to the character definition files, for a start, require a new game to take effect. And any existing savegame will already have the map due to the burglary option if the map wasn't properly for sale. I'll keep the burglary code in place but if the map is always for sale then the chances are nobody will find out about it. Oh well, since burglary is promised in the story description, I'll have to figure out how to do it somewhere else... :D
 
Thanks! :onya Is this included in the 6th February update or should it be installed in addition to that?
It is in addition, because I made the installer first and then continued modding (just in case I'd break anything).

I won't need to correct a savegame because developing the storyline requires that I routinely start a new game anyway. Additions or changes to the character definition files, for a start, require a new game to take effect.
Very true. I just mentioned it for testing purposes so you can observe the difference on your original save. :doff

I'll keep the burglary code in place but if the map is always for sale then the chances are nobody will find out about it. Oh well, since burglary is promised in the story description, I'll have to figure out how to do it somewhere else... :D
Sounds good! :cheers
 
I'll give that code change a go and report back :sail

I also just started a 3.4 and 4 game and it is true, at game start/low char level no one seems to have any maps (which is the same in 3.1 too), so yeah thinking back on it it might have been once i had reached Jamaica (was about level 8 after that trip, 5 gained on route!) that i saw maps in the Stores.
 
I also just started a 3.4 and 4 game and it is true, at game start/low char level no one seems to have any maps (which is the same in 3.1 too), so yeah thinking back on it it might have been once i had reached Jamaica (was about level 8 after that trip, 5 gained on route!) that i saw maps in the Stores.
That sounds like the opposite problem that I noticed. In your case, it sounds like the game figured that the map items were "too good" for the player.
In my case, on player level 4 and a merchant with quality 10(!), the maps didn't show because the game considered either the player or the merchant to be "too good" for the items.
Either way, it doesn't help. Hopefully my change will make this behave more sensibly. It does help when you are able to get maps if you want them. :facepalm
 
ok well that did do something :) At game start in v 3.1 i do now get some maps (between 3-4 it seems) at the trade store, with none at the outside trade tents, with a level 1 or 2 game starting char. Before there were none anywhere, so this is good.
 
At game start in v 3.1 i do now get some maps (between 3-4 it seems) at the trade store, with none at the outside trade tents, with a level 1 or 2 game starting char.
None at all at the trade tents? I started a new game on Assassin and got 4-5 maps at both of the traders in port.
Please keep an eye on it; occasionally none for item traders is OK; but not always.
 
Lol, ok now i found some in the trade tents (4th game run), so there is some variability in when and whom will have some. Also the number of maps can vary, i had just 2 in the trade tent this time, and just 3 in the trade store. Seems pretty nice, more or less fixed no? Good job.
 
Lol, ok now i found some in the trade tents (4th game run), so there is some variability in when and whom will have some. Also the number of maps can vary, i had just 2 in the trade tent this time, and just 3 in the trade store. Seems pretty nice, more or less fixed no? Good job.
Sounds about right to me! Indeed I made the "rare" value VERY low, so there would be as few maps available as possible.
But they still appear consistently, which is fine by me. :doff
 
It seems I managed something interesting here. Extract attached to PROGRAM\ITEMS to try, then press F11 in your savegame!

With this code, setting "itm.quality = -2" results in the "quality" attribute being removed.
Then those items remain available throughout the entire game, regardless of player/trader levels.

At the moment, I applied this trick exclusively to the Maps.
Additionally, I set itm.rare = 0.01; which is a VERY low value, but even at the start of the game, there are several available.
Checking that "Level 10" trader from the Save posted above, he has nearly ALL of them regardless of that low rarity value.

On a savegame, it may take a while for this change to become apparent,
because item traders need to be "reset" individually before they start making use of this changed situation.
That eventually happens over time, so there should be no manual action required.
It will immediately be correct at the start of a new game, of course.

@Grey Roger: To correct your savegame, you should:
1. Load the file
2. Press F11 to Reinitialize
3. Execute this code through console to "remind" the item trader that he DOES sell maps now:
Code:
   ch = CharacterFromID("Jose Zugarro");
   SetTraderItemStats(ch, IT_RECALC_ALL);
4. You can also execute this line afterwards (OPTIONAL):
Code:
GiveNewItemsToTrader(ch);
GiveItem2Character(ch,"mapCuba");
That will give brand new items to the trader and he should have PLENTY maps afterwards.
Because that first command erases his previous items, you need to re-give the Cuba Map afterwards.

Long story short:
- If you start a new game on Ardent, he should now ALWAYS have that map, because you manually add it to him
- With the new initItems.c file, he should now also always SELL it

So I think that solves the problem. The stealing of the map should now be superfluous, but of course that is a fun thing to keep anyway.

I hope this helps you. And even moreso: I hope this finally solves the problem of "maps stopping to appear" as the game progresses!
Anyone tried this on Beta 4 yet? What's the verdict?
 
The one in Santiago to whom I give a map in my storyline code hasn't failed to sell it to me since installing your fix. But he's also always had other maps as well, whereas previously he'd refuse to sell the Cuba map if he didn't already have any of his own. Does your fix ensure that store-keepers always have at least one map in stock? If not, I've yet to see this one sell just the Cuba map given to him by the storyline code, so it may not be conclusive.
 
Does your fix ensure that store-keepers always have at least one map in stock?
It doesn't actively ensure that there is always a map. When I did my testing, I did run into a trader without any at all.
But if the fix works as intended, the chance of that happening is really quite small.

Basically what happened is that depending on player/trader level, map items could be considered either "too good" or "not good enough" and therefore stop being sold.
The tweak I made ensures that this entire mechanism is completely skipped for map items.
So player and/or trader level should no longer have anything to do with their appearance in the game.

Instead I just set an arbitrary low "rare" value to try to avoid having too many maps available from the same trader.
As far as I could tell in my tests, higher level traders do still get more different maps AND more of each map.
Of course having multiple maps of the same one makes very little sense; but there is no harm in it either, so I didn't bother trying to rectify that.

So if he virtually always DOES have maps on sale, then it sounds like this works as I hoped.


Would you want him to sell exclusively the Cuba map at that point of the quest? That might be tricky to arrange....
You'd have to take all other map items from him before you check his inventory.
But if it is the first time you talk to him, his inventory is generated at the time that you check it.
So you would end up taking away his map items (that he doesn't have), then giving him one, then he gets a whole bunch of other ones added after that. :facepalm
 
Back
Top