• 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 Shipyard upgrades not factored into sale price

Tingyun

Corsair
Storm Modder
The code for increasing the purchase price of a ship with upgrades seems to work fine, but if the player applies an upgrade to his ship, the sale price he gets does not seem to go up at all. At least, in multiple tests applying and removing upgrades, I did not see any difference. Tested with bronze cannons and stay sails.

Here is the code that is supposed to add to the sale price but doesn't seem to do so:

int idx=0;
for (int i = 0; i < SHIPUPGRADES_QUANTITY; i++) {
idx++;
attributeName = "pic" + idx;
string upgrade = GetShipUpgradeID(i);
if (cn >= 0 && CheckTun(cn, upgrade) == true) {
price += makeint(GetCostTun(cn, upgrade, PRICE_TYPE_SELL)/10); //If an upgrade is applied, you get a percentage of the real price. This can be max of 10%
}
}
 
I thought that worked, dammit! :modding

Is that code getting executed at all? Maybe it doesn't always get called?
 
Not sure Pieter, but I checked and it looks very similar to the code that is applied to increase the sale price of upgraded ships, which does work (they are more expensive when you purchase them, just not when you sell them). Maybe there is some subtle difference between how they are written though.

I tried buying upgraded ships from the shipyard, removing the upgrades, and selling them back. I also tried upgrading them myself, and watching for price changes. Always came back no difference for player sale price, but did make a diference in shipyard purchase price.

I was using rpg shipyards setting, and an owned ship (not privateered), though I don't think either matters.
 
@Tingyun
Could you check if it goes into this statement?

Code:
//Levis negative prices fix
    if(price<(shipprice * 0.05))
    {
        price = makeint(shipprice * 0.05); //5% of shipprice is the minimum you will get.
    }

That might explain why it happens, altough I don't know why it should go in there.
Adding a trace("I go in the if"); statement there (between the if statement) and selling something should add something to the compile.log file.
 
If you do that, you might want to add an 'else' and a another Trace statement in there.
Otherwise it is difficult to tell if it should have been called at all.
 
I'd be happy to check, but could you explain what "goes into" means? I'm afraid my coding ignorance is still fairly substantial, and I'm not sure what that means. Also, when you say put the trace "between the if", does than mean put it inside the {}?

I can probably find some time next week to run whatever tests you need, just want to make sure I know what to do. :)

EDIT: @Pieter Boelen not sure what that means...:p I'll try to figure it out if this bug is still unresolved then.
 
I'd be happy to check, but could you explain what "goes into" means?
Basically it means "check if that code gets executed at all".

Also, when you say put the trace "between the if", does than mean put it inside the {}?
Yes.

@Pieter Boelen not sure what that means...:p I'll try to figure it out if this bug is still unresolved then.
I mean that if you put a Trace only inside the 'if' and it doesn't show in compile.log, either the 'if' did not get called at all OR it returned false.
By putting another Trace before it or by creating an 'else', you're guaranteed to get at least something logged if that code gets executed.
In other words: Then you can tell if it happens. Which is why more often than not, I just put in TraceAndLog("THIS HAPPENS!"); . :rofl
 
Oh, thanks @Pieter Boelen that makes sense

In thst case maybe I can answer @Levis question now, in that I have seen that code for minimum price get executed (a demasted 10% hull ship I sold, but I ran the tests on the upgrade price with fully repaired ships thst were not having thst code executed.

Have to run for now, really enjoyed playing yesterday, can't wait to get back to enjoying this wonderful mod. Hopefully only a few more weeks left. Thanks for everything you are doing to fix the bugs and make it even better! :)
 
Back
Top