• 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 Guns in treasure chests

Grey Roger

Sea Dog
Staff member
Administrator
Storm Modder
Someone sold me a cheap treasure map which, to my surprise, contained plenty of good stuff, including a load of grapeshot pistols and pepperboxes.

The grapeshot pistol is supposed to become available in the Golden Age of Piracy. The pepperbox is only supposed to exist from Revolutions onward.

I'm playing "Bartolomeu o Portugues". It's the Spanish Main period. Apparently the chest was a time capsule. xD
 
Responsible code from MAXIMUS_functions.c:
Code:
  if( Calc_luck > rand(11) ) // chance you may get robbed, higher luck means lower chances
   {
     Calc_luck = rand(Calc_luck-1)+1;
     //TREASURE
     lcn.treasure_box.money = (Calc_luck*rand(3000));// TIH put here instead
     lcn.treasure_box.items.jewelry1 = (Calc_luck*rand(100));
     if(calc_luck > 3){lcn.treasure_box.items.jewelry2 = (Calc_luck*rand(100));}
     if(calc_luck > 3){lcn.treasure_box.items.jewelry3 = (Calc_luck*rand(100));}
     if(calc_luck > 4){lcn.treasure_box.items.jewelry4 = (Calc_luck*rand(100));}
     lcn.treasure_box.items.jewelry5 = (Calc_luck*rand(100));
     lcn.treasure_box.items.jewelry6 = (Calc_luck*rand(100));
     if(calc_luck > 2){lcn.treasure_box.items.jewelry7 = (Calc_luck*rand(100));}
     lcn.treasure_box.items.jewelry8 = (Calc_luck*rand(100));
     lcn.treasure_box.items.jewelry9 = (Calc_luck*rand(100));
     if(calc_luck > 5){lcn.treasure_box.items.jewelry10 = (Calc_luck*rand(100));}
     if(calc_luck > 1){lcn.treasure_box.items.jewelry11 = (Calc_luck*rand(100));}
     lcn.treasure_box.items.jewelry12 = (Calc_luck*rand(100));
     lcn.treasure_box.items.jewelry13 = (Calc_luck*rand(100));
     if(calc_luck > 2){lcn.treasure_box.items.jewelry14 = (Calc_luck*rand(100));}
     lcn.treasure_box.items.jewelry15 = (Calc_luck*rand(100));
     if(calc_luck > 6){lcn.treasure_box.items.jewelry16 = (Calc_luck*rand(100));}
     if(calc_luck > 9){lcn.treasure_box.items.indian1 = (Calc_luck*rand(100));}
     lcn.treasure_box.items.indian3 = (Calc_luck*rand(50));
     if(calc_luck > 9){lcn.treasure_box.items.indian5 = (Calc_luck*rand(100));}
     if(calc_luck > 8){lcn.treasure_box.items.indian6 = (Calc_luck*rand(100));}
     lcn.treasure_box.items.indian8 = (Calc_luck*rand(10));
     lcn.treasure_box.items.indian9 = (Calc_luck*rand(10));
     if(calc_luck > 9){lcn.treasure_box.items.indian10 = (Calc_luck*rand(100));}
     if(calc_luck > 7){lcn.treasure_box.items.indian12 = (Calc_luck*rand(100));}
     if(calc_luck > 8){lcn.treasure_box.items.indian14 = (Calc_luck*rand(100));}
     //WEAPONS
     if(calc_luck > 6)
     {
       lcn.treasure_box.items.pistol3 = (Calc_luck*rand(5));
       lcn.treasure_box.items.pistol4 = (Calc_luck*rand(5));
       lcn.treasure_box.items.pistol5 = (Calc_luck*rand(5));
     }
     if(calc_luck > 7)
     {
       lcn.treasure_box.items.pistol6 = (Calc_luck*rand(4));
       lcn.treasure_box.items.pistol7 = (Calc_luck*rand(4));
       lcn.treasure_box.items.spyglass3 = 1;
     }
     if(calc_luck > 8)
     {
       lcn.treasure_box.items.pistol8 = (Calc_luck*rand(4));
       lcn.treasure_box.items.pistolmtoon = (Calc_luck*rand(4));
       lcn.treasure_box.items.commonarmor = (Calc_luck*rand(3));
     }
     if(calc_luck > 9)
     {
       lcn.treasure_box.items.pistol9 = (Calc_luck*rand(4));
       lcn.treasure_box.items.pistolmket = (Calc_luck*rand(10));
       lcn.treasure_box.items.goldarmor = rand(10);
       lcn.treasure_box.items.blade24 = rand(10);
       lcn.treasure_box.items.blade27 = rand(10);
       lcn.treasure_box.items.spyglass4 = 1;
     }
   }
 
@Grey Roger: Might this be considered a satisfactory solution?
Code:
    //WEAPONS
     int period = GetCurrentPeriod();
     if(calc_luck > 6)
     {
       if (period >= PERIOD_GOLDEN_AGE_OF_PIRACY)   lcn.treasure_box.items.pistol3     = (Calc_luck*rand(5));  // Grapeshot Pistol
       if (period >= PERIOD_REVOLUTIONS)       lcn.treasure_box.items.pistol4     = (Calc_luck*rand(5));  // Quad-Barrel Pistol
       if (period >= PERIOD_GOLDEN_AGE_OF_PIRACY)   lcn.treasure_box.items.pistol5     = (Calc_luck*rand(5));  // Horse Pistol (was Scrapper Pistol)
     }
     if(calc_luck > 7)
     {
       if (period >= PERIOD_GOLDEN_AGE_OF_PIRACY)   lcn.treasure_box.items.pistol6     = (Calc_luck*rand(4));  // Double-Shot Pistol
       if (period >= PERIOD_EARLY_EXPLORERS)     lcn.treasure_box.items.pistol7     = (Calc_luck*rand(4));  // Brace of Small Pistols
       lcn.treasure_box.items.spyglass3 = 1;
     }
     if(calc_luck > 8)
     {
       if (period >= PERIOD_EARLY_EXPLORERS)     lcn.treasure_box.items.pistol8     = (Calc_luck*rand(4));  // Brace of Flintlock Pistols
       if (period >= PERIOD_GOLDEN_AGE_OF_PIRACY)   lcn.treasure_box.items.pistolmtoon   = (Calc_luck*rand(4));  // Musketoon
       lcn.treasure_box.items.commonarmor = (Calc_luck*rand(3));
     }
     if(calc_luck > 9)
     {
       if (period >= PERIOD_GOLDEN_AGE_OF_PIRACY)   lcn.treasure_box.items.pistol9     = (Calc_luck*rand(4));  // Brace of Horse Pistols
       if (period >= PERIOD_GOLDEN_AGE_OF_PIRACY)   lcn.treasure_box.items.pistolmket   = (Calc_luck*rand(10)); // Musket
       if (period >= PERIOD_COLONIAL_POWERS)     lcn.treasure_box.items.blade24     = rand(10);  // English Officer's Sabre
       if (period >= PERIOD_GOLDEN_AGE_OF_PIRACY)   lcn.treasure_box.items.blade27     = rand(10);  // Bosun's Choice
       lcn.treasure_box.items.goldarmor = rand(10);
       lcn.treasure_box.items.spyglass4 = 1;
     }
 
Perhaps have some alternative weapons for earlier periods?

Isn't "if (period >= PERIOD_EARLY_EXPLORERS)" redundant? When would that condition fail?

Another piece of weirdness, not limited to treasure chests: if I read "initItems.c" and "ItemsDescribe.txt" correctly, "PiratesPistol" is a single flintlock pistol, "pistol8" is a brace of flintlock pistols. "PiratesPistol" is available from "Spanish Main" onwards, while "pistol8" is available in "Early Explorers". Which means you can't get a single flintlock pistol in "Early Explorers", you can only get it in packs of 3. xD
 
Perhaps have some alternative weapons for earlier periods?
Feel free to set that up. :doff

Isn't "if (period >= PERIOD_EARLY_EXPLORERS)" redundant? When would that condition fail?
Never. :cheeky
Only reason I did add that is so the code doesn't look too messy.

Ideally I should make that code actually read the period appearance from initItems.c instead of hardcoding it there.
That isn't actually very good practice, but it is SO much simpler to set up of course.... :wp

Other question: Do we NEED weapons in treasure chests? If not, we can just remove them altogether.
What isn't there cannot be wrong. ;)

Another piece of weirdness, not limited to treasure chests: if I read "initItems.c" and "ItemsDescribe.txt" correctly, "PiratesPistol" is a single flintlock pistol, "pistol8" is a brace of flintlock pistols. "PiratesPistol" is available from "Spanish Main" onwards, while "pistol8" is available in "Early Explorers". Which means you can't get a single flintlock pistol in "Early Explorers", you can only get it in packs of 3. xD
What abou tthe former "Scrapper Pistol"? I thought that the brace of pistols was a brace of that one and not of the "PiratesPistol". :confused:
 
How about this:
Code:
//WEAPONS
int period = GetCurrentPeriod();
if(calc_luck > 6)
{
if (period >= PERIOD_GOLDEN_AGE_OF_PIRACY) lcn.treasure_box.items.pistol3 = (Calc_luck*rand(5)); // Grapeshot Pistol
else lcn.treasure_box.items.pistol2 = (Calc_luck*rand(5)); // Duelling Pistol
}
if(calc_luck > 7)
{
if (period >= PERIOD_GOLDEN_AGE_OF_PIRACY) lcn.treasure_box.items.pistol6 = (Calc_luck*rand(4)); // Double-Shot Pistol
else lcn.treasure_box.items.pistol7 = (Calc_luck*rand(5)); // Brace of Small Pistols
lcn.treasure_box.items.spyglass3 = 1;
}
if(calc_luck > 8)
{
if (period >= PERIOD_GOLDEN_AGE_OF_PIRACY) lcn.treasure_box.items.pistolmtoon = (Calc_luck*rand(4)); // Musketoon
else lcn.treasure_box.items.pistol8 = (Calc_luck*rand(4)); // Brace of Flintlock Pistols
lcn.treasure_box.items.commonarmor = (Calc_luck*rand(3));
}
if(calc_luck > 9)
{
if (period >= PERIOD_GOLDEN_AGE_OF_PIRACY) lcn.treasure_box.items.pistol9 = (Calc_luck*rand(4)); // Brace of Horse Pistols
if (period >= PERIOD_GOLDEN_AGE_OF_PIRACY) lcn.treasure_box.items.pistolmket = (Calc_luck*rand(10)); // Musket
else lcn.treasure_box.items.pistolbbuss = (Calc_luck*rand(10)); // Blunderbuss
if (period >= PERIOD_GOLDEN_AGE_OF_PIRACY) lcn.treasure_box.items.blade27 = rand(10); // Bosun's Choice
else lcn.treasure_box.items.blade22 = rand(10); // Corsair's Pride
lcn.treasure_box.items.goldarmor = rand(10);
lcn.treasure_box.items.spyglass4 = 1;
}
What about the former "Scrapper Pistol"? I thought that the brace of pistols was a brace of that one and not of the "PiratesPistol". :confused:
The Scrapper Pistol is now the Horse Pistol. I've removed it from the lowest luck result (calc_luck>7) as it's rather powerful, though it could easily be put back in place of the Grapeshot Pistol or the Double-Shot Pistol. If you're lucky (calc_luck>9) you can still get a brace of them in the relevant period. (If you're feeling lucky, there's one place where you can get a quad-pack of them. ;))

From "ItemsDescribe.txt":
itmname_pistol8 {Brace of Flintlock Pistols}
itmdescr_pistol8
{
Three flintlock pistols on a band for rapid access. They are said to be the work of a one-armed, one-eyed Spanish gunsmith. 'Gunman' ability needed.
}
...
itmname_PiratesPistol {Flintlock Pistol}
itmdescr_PiratesPistol
{
A common flintlock pistol.
}
 
How about this:
Why not? :doff

The Scrapper Pistol is now the Horse Pistol.
[...]
From "ItemsDescribe.txt":
Can you use GM Viewer to check that the pistol8 actually matches the PiratesPistol model?

If you're lucky (calc_luck>9) you can still get a brace of them in the relevant period. (If you're feeling lucky, there's one place where you can get a quad-pack of them. ;))
On Realistic Game Mode, yes. :cheeky
 
I can't use GM Viewer for anything, I've never managed to get it working on my Windows 7 PC. But I've definitely seen single Flintlock Pistols, and looking through "ItemsDescribe.txt", they can't have come from anywhere else. The only other mentions of the word "Flintlock" in there are for the Brace of Flintlock Pistols (which I've also seen) and "Jack's Lucky Flintlock", alias "pistol3_14", which I haven't seen, probably because "initItems.c" indicates it to be a quest item to do with Jack Sparrow and I haven't played any quest involving Jack Sparrow. ;)
 
I can't use GM Viewer for anything, I've never managed to get it working on my Windows 7 PC.
Works for me on Windows 7. Only textures for characters don't work, but pistols are fine. Ships and locations too.

But I've definitely seen single Flintlock Pistols, and looking through "ItemsDescribe.txt", they can't have come from anywhere else. The only other mentions of the word "Flintlock" in there are for the Brace of Flintlock Pistols (which I've also seen) and "Jack's Lucky Flintlock", alias "pistol3_14", which I haven't seen, probably because "initItems.c" indicates it to be a quest item to do with Jack Sparrow and I haven't played any quest involving Jack Sparrow. ;)
I was just thinking that the descriptions have been changed a gazillion times since the items were added, so they may not be 100% accurate.
But anyway, not important enough to go too deeply into this one. Feel free to make the change. :doff
 
Its suppost to give you all (from the period) when luck is 9?
It does now at least.
 
Its suppost to give you all (from the period) when luck is 9?
It does now at least.
Any of the rand statements could return 0 so there wouldn't be any guns of that type.
But it does potentially look like overkill.

As this code is at risk of becoming quite convoluted, I am inclined to VASTLY reduce this or completely remove it.
After all, proper treasure is gold and diamonds. Pistols aren't that expensive and you can get them quite easily if you want to.
Perhaps for variety we can have 1 good pistol per period that may or may not appear in the chest?
 
I think the chest should have mostly coins, diamond, ruby's and incan statues etc.
Leave it for now, I will look into this soon. I think I'm going to tie this into a quest where you need to collect some incan artifacs for the indian trader to get .... (you know what ;) ). So then I will look at this code and make it more "nice".
I think the chest should mostly contain ruby, diamonds, gold etc and some statues.
And maybe only really fancy swords and pistols. but not the crappy ones.
 
I think the chest should mostly contain ruby, diamonds, gold etc and some statues.
And maybe only really fancy swords and pistols. but not the crappy ones.
Agreed. Mostly actual treasure! :cheeky
 
Closed this cause it fixed. Will work on it later tough
 
Back
Top