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

Solved Fixing the Cannons Interface, including Buy and Sale Prices

Pieter Boelen

Navigation Officer
Administrator
Storm Modder
Hearts of Oak Donator
Okay, now in the process of testing shipyards, currently I'm in Governor's Harbor, ranked American Captain, level 11 with commerce 2+1 (from items), ship is a Dauntless Class first rate.
Found the first exploit to make money... I can sell all but 1 of my 32 pounders for 489097, then reinstall them by using the Repair All function for 428000. Only works this way, Install All in the cannons screen works properly. Maybe that could be fixed by simply making shipyards pay way less for cannons? As it is right now, I'd get nearly 500k for 108 32pounders on my dauntless, while the ship itself would sell for 311k.
Just so you know, I'm currently working on the Cannon Interface and making good progress. I found more than a few things wrong though, but I think I'm almost to the point where it is doing what it was intended to do. :wp
 
Just so you know, I'm currently working on the Cannon Interface and making good progress. I found more than a few things wrong though, but I think I'm almost to the point where it is doing what it was intended to do. :wp

Ah, nice to hear! I can certainly do more testing for you, if needed!
 
In the meantime, that Cannons interface is doing my head in. I'm NOT an interface expert and it is behaving REALLY weird. :facepalm
I think I might have done it! Both for friendly shipyards (regular price) AND hostile ones (double price).
Included in my file here: http://www.piratesahoy.net/threads/...-version-2-available.20513/page-3#post-450747

----> WARNING! The following is a short (really?) explanation of what I have done to the Shipyard Interface; skip over this if you don't care ;)

First, I disabled ALL tradeHigh multiplications, which were spread out over the entire shipyard interface file, then added it instead in a global file similar to how it is handled for the ship repair function.
Then I noticed that a lot of the cannon purchase/sell calculations were using the price straight from the init value, instead of applying the player's commerce skill as intended.
Once that was both rectified, at tradeHigh, cannons would also SELL for double price. Next thing you know, every time you add a cannon, it does so at double price,
but remove a cannon and it is at less than regular price. So just clicking left and right a few times could get you to lose insane amounts of money.
So I had to redo the entire price calculation code there so it would use double price when you're actually BUYING and using single price when SELLING.

And if you might think that should solve the whole thing, turns out that was only the beginning of the troubles.
The code defining whether you can use the various buttons and what explanatory tips show up didn't exactly do what it was supposed to either.
And then there was the WORST part in trying to get the on-screen texts and money values to all match up with what they should be.
Especially after doing a cannon transaction.

----> NOTE: Explanation completed. You can safely continue reading....

Needless to say.... it was an incredible pain to get as far as this. But I've tested it for a bit and it is behaving a lot more sensible now.

If you do your tests properly, you might even end up seeing a couple of help texts that I don't think would ever show up before, indicating the maximum number of cannons you can afford.
This is especially obvious when you get rid of ALL cannons on your ship and don't have enough money for a full new set of cannons.
Also new is that for your own cannon type, it will no longer show your MAXIMUM cannons for "Install All", but only the MISSING number of cannons.
This seems to make more sense to me as that number matches with the amount of gold listed right next to it.

Since cannons now properly take into account your commerce skill and always sell at less than 75% of their purchase value, you should have a REALLY hard time of making money from them!
So here's to hoping you don't manage to break it too badly.... :razz
 
So here's to hoping you don't manage to break it too badly.... :razz
Hum. I already managed to break it a little bit myself. Somehow it is cheaper to NOT use the "Install All" button. No clue why.
When you only have one cannon to install, the prices match up perfectly. But at 2 cannons, they start to diverge.
On your OWN cannon calibre, the "cost by unit" multiplied by the #un to complete the set SHOULD give the cost to complete the set.
While the results aren't hugely off, they're not the same either. WHY does this just not - do - what - it - should??? :modding
 
HA! I think I got that one! Turns out to have been a rounding error because a decimal point calculation was done that included the cannon quantity.
So what I did was to just calculate the price of a single gun as a rounded value first and then multiplied it with the number of cannons.
As far as I can tell, I've now got all the numbers in the Cannons interface matching up completely correctly! :dance

I'm not entirely certain of when you buy or sell a ship with cannons on it though. As far as I can tell, the effect of having cannons is not figured into the ship prices.
So as I understand it, if you have a high commerce skill, you could buy a ship and get the cannons for free, then sell it without cannons and possibly make money that way.
However, selling apparently only assumes you have the smallest cannons installed and cannons sell at less than 75% of their purchase value anyway.

Not sure if this effect is worth fixing. And if we DO fix it, the only way I can think of doing it fairly is by increasing the price of all ships to buy with the value of a full set of cannons.
And then increase the price of selling a ship with the price of selling the number of cannons already installed.

Also, if I understand correctly, the cannon prices get the character commerce skill effects applied twice.
Once when BuyCannons is called and a second time in the GetSellPrice function.

It couldn't all just match up, could it? Fix one thing, find ten more things wrong. :shock
 
HA! I think I got that one! Turns out to have been a rounding error because a decimal point calculation was done that included the cannon quantity.
So what I did was to just calculate the price of a single gun as a rounded value first and then multiplied it with the number of cannons.
As far as I can tell, I've now got all the numbers in the Cannons interface matching up completely correctly! :dance
Extract attached to PROGRAM\CANNONS . Not included in yesterday's full upload thingey because... well, I only just did this, you know? :razz
 

Attachments

  • Cannons.zip
    2.6 KB · Views: 72
Okay, had the time to mess around with the cannons interface and.....
I didn't manage to break anything!!
As far as I can tell, it works just fine. Didn't calculate everything exactly, but if there's something off, it's a matter of a few coins at most. But don't think so.
So, all that work is finally paying off, I think! :treasure:
 
FINALLY! I did calculate everything myself during my tests and it all matched up perfectly with what it should be within the Cannons Interface.
If you use the "Install" button to sell a single cannon, you can see how much one unit sells for. Multiply that by the number of cannons you have,
give you the total sell price. Then add to that the maximum number of cannons with the unit price of a different calibre and it matches up nicely with the "Install All" price listed there.

As I said though, when you get into the prices on the Repair interface, I am not so sure anymore. Actually I AM sure. Sure that it isn't quite right. :facepalm
 
Just paid a visit to Vanderdecken and noticed that while you can't use Cannons/Upgrades/Appearance at first, you CAN after purchasing a ship.
Figured I'd fix that so that now you REALLY can only buy ships from him. And repair at double price, I suppose. :shrug
 
Back
Top