• 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 Problems with ship in Havana in "Ardent"

Just tested the different situations.
By using this file everything seems to go well.
Place in:
..\PROGRAM\CANNONS
 

Attachments

  • Cannons.c
    12.3 KB · Views: 197
Are you including my suggestions from post #20 too? Just checking. :)
That was the fix. I've only added the carge type to be set to default also in the reset function (which sounds good to me. if the canons need to be reset it will take the default charge also).
 
I was able to test this. It does indeed work - thanks! :onya The unarmed not-war tartane is now genuinely unarmed and the food doesn't disappear.

And my surgeon also sends his thanks, now he's been reinstated to his proper post.
 
@Levis can you confirm the reason for your fix being
Code:
void SetNoneCannonsOnShip(ref ch)
{
    //if (!CheckAttribute(ch,"ship.cannons.borts")) return;
    aref arship; makearef(arship, ch.Ship);
    ch.Ship.Cannons.Borts.cannonf.qty = 0;
    ch.Ship.Cannons.Borts.cannonb.qty = 0;
    ch.Ship.Cannons.Borts.cannonl.qty = 0;
    ch.Ship.Cannons.Borts.cannonr.qty = 0;
    ch.Ship.Cannons.Type = CANNON_TYPE_NONECANNON;
    ch.ship.cannons.charge.type = DEFAULT_CHARGE;
without me having to trawl through cannon loading sequnces (ie what does this attribute setting actually mean)- rather than @Pieter Boelen 's
Code:
void SetNoneCannonsOnShip(ref ch)
{
    //if (!CheckAttribute(ch,"ship.cannons.borts")) return;
    aref arship; makearef(arship, ch.Ship);
    ch.Ship.Cannons.Borts.cannonf.qty = 0;
    ch.Ship.Cannons.Borts.cannonb.qty = 0;
    ch.Ship.Cannons.Borts.cannonl.qty = 0;
    ch.Ship.Cannons.Borts.cannonr.qty = 0;
    ch.Ship.Cannons.Type = CANNON_TYPE_NONECANNON;
    ch.Ship.stats.CannonsQuantity = 0;
I am looking at the setting (and over-riding) of CANNON_TYPE_NONECANNON (for cannon transfer outcomes) and note in ships.init that ships/items intended for cannons have a non zero value set for CanonsQuantity but those that aren't (unarmed ships and several specialist items) get zero. However other bits of code (such as re-supply) look at Cannons Quantity so if that is left unaffected it may have/be having unexpected results? :shrug

However conversely if the clearing of CannonsQuantity was done and was put in SetNoneCannonsOnShip that wipes the value for checking the maximum cannon quantity if cannons are ever restored by setting a valid cannon type (if I am getting this at all). That would mean I couldn't use it as a simple clearing function if you remove all cannons from a ship.:pirateraft

[I am speculating here how to fix the none sticking CANNON_TYPE_NONECANNON in the July version (and earlier) -understanding it doesn't now happen in latest version] So for this specific case (GiveShip2Character) where @Grey Roger wants to set a none armed status on a normally armed vessel (thus where ships_init gives a value to Cannons Quantity) perhaps the wiping of Cannons Quantity could be placed in GiveShip2Character straight after the call to SetNoneCannonsOnShip and not within that call. This would presume the plot line means this ship is never eventually wanted /able to be armed.

I'm looking at this because I was/am working on the July version of cannon transfer interface and this seems to have been both broken and fixed since then but I wonder if it has fixed or just masked any problems arising from a combination of CANNON_TYPE_NONECANNON with a non zero CannonsQuantity. BUT I also need to understand what @Levis fix would do if I include it in the function but then call that from elsewhere.

I feel a headache coming on.:modding
 
I do think it makes a lot of sense to have zero cannons if the type is NONE.
Without that, it probably all becomes even more complex. :facepalm
 
So for this specific case (GiveShip2Character) where @Grey Roger wants to set a none armed status on a normally armed vessel (thus where ships_init gives a value to Cannons Quantity) perhaps the wiping of Cannons Quantity could be placed in GiveShip2Character straight after the call to SetNoneCannonsOnShip and not within that call. This would presume the plot line means this ship is never eventually wanted /able to be armed.
Yes, the intention is indeed for that ship never to be armed - in fact, if the player follows the plot, he should not have that ship for very long because he'll soon be getting something much better. The unarmed ship is just to get you from one end of Cuba to the other.

If it's of any significance, the quest code currently includes this:
Code:
       GiveShip2Character(PChar,"TartaneWar","Esme",CANNON_TYPE_NONECANNON,SPAIN,false,false);
       makearef(arShip, PChar.ship.stats);
       arship.CannonsQuantity = 0;
I don't know what the "Cannons.Borts" attributes do, but the quest itself zeroes the basic "CannonsQuantity" attribute. So this story ought to work regardless of where, or even if, the attribute is zeroed anywhere else.
 
I do think it makes a lot of sense to have zero cannons if the type is NONE.
Without that, it probably all becomes even more complex. :facepalm

I agree entirely -- so what I think I will need is how to use the target player/companion ship to get its type to create an aref/ref to get at the CannonQuantity from the appropriate entry in ships.init table for any given ship to be reset for correct cannon (max) numbers on gaining cannons regardless as to whether its local CannonsQuantity has been set to zero when NONE was set or not.
I really don't get references still - so I'm blindly copying/adjusting code here - which I suspect will only give me circular references back to the player/companion ship in question and not the underlying model stats. Any hints on the syntax I need anyone?

Similarly I am testing against MaxCaliber to prevent the exploit of overlarge cannons - but since the local MaxCaliber (up to now) has no need to be wiped down, the local one is still there to test.

Yes, the intention is indeed for that ship never to be armed - in fact, if the player follows the plot, he should not have that ship for very long because he'll soon be getting something much better. The unarmed ship is just to get you from one end of Cuba to the other.

If it's of any significance, the quest code currently includes this:
Code:
       GiveShip2Character(PChar,"TartaneWar","Esme",CANNON_TYPE_NONECANNON,SPAIN,false,false);
       makearef(arShip, PChar.ship.stats);
       arship.CannonsQuantity = 0;
I don't know what the "Cannons.Borts" attributes do, but the quest itself zeroes the basic "CannonsQuantity" attribute. So this story ought to work regardless of where, or even if, the attribute is zeroed anywhere else.

Indeed I think it is significant. I presume you had that in place as well as the new cannons.c when reporting it fixed in post #25? If the earlier problem of CANNON_TYPE_NONECANNON not quite doing the job arose because CannonsQuantity was not zero this would (and apparently does) fix that for this case :thumbs1. That gives me further hope that sorting this in the general case may remove some weirdness in cannon transfer too
 
I agree entirely -- so what I think I will need is how to use the target player/companion ship to get its type to create an aref/ref to get at the CannonQuantity from the appropriate entry in ships.init table for any given ship to be reset for correct cannon (max) numbers on gaining cannons regardless as to whether its local CannonsQuantity has been set to zero when NONE was set or not.
I really don't get references still - so I'm blindly copying/adjusting code here - which I suspect will only give me circular references back to the player/companion ship in question and not the underlying model stats. Any hints on the syntax I need anyone?

Similarly I am testing against MaxCaliber to prevent the exploit of overlarge cannons - but since the local MaxCaliber (up to now) has no need to be wiped down, the local one is still there to test.
Maybe something like:
Code:
  ref rship = GetShipByType(GetCharacterShipType(ch)); // This should give you a reference to the ships_init.c entry
  ch.Ship.Cannons.Type = rship.Cannons.Type; // Check the syntax with the actual ships_init.c file; writing from memory here....

Indeed I think it is significant. I presume you had that in place as well as the new cannons.c when reporting it fixed in post #25? If the earlier problem of CANNON_TYPE_NONECANNON not quite doing the job arose because CannonsQuantity was not zero this would (and apparently does) fix that for this case :thumbs1. That gives me further hope that sorting this in the general case may remove some weirdness in cannon transfer too
Sounds like adding 'CannonsQuantity = 0;' in the general function is a good idea.
In fact, I thought @Levis already did that because I think he said he added my proposed fix as well? :confused:
 
Maybe something like:
Code:
  ref rship = GetShipByType(GetCharacterShipType(ch)); // This should give you a reference to the ships_init.c entry
  ch.Ship.Cannons.Type = rship.Cannons.Type; // Check the syntax with the actual ships_init.c file; writing from memory here....
Looking at "ships_init.c", in which a random ship somewhere down the list has 'refShip.Cannon = CANNON_TYPE_LONG_LBS24;', perhaps:
Code:
ref rship = GetShipByType(GetCharacterShipType(ch));
ch.Ship.Cannon = rship.Cannon;
Sounds like adding 'CannonsQuantity = 0;' in the general function is a good idea.
In fact, I thought @Levis already did that because I think he said he added my proposed fix as well? :confused:
No, looking at the contents of "Levis-Fixes_7-10b.zip", the version of "Cannons.c" in there is the same as the first one in post #26, i.e. without the line 'ch.Ship.stats.CannonsQuantity = 0;' and with the line 'ch.ship.cannons.charge.type = DEFAULT_CHARGE;'.
 
Looking at "ships_init.c", in which a random ship somewhere down the list has 'refShip.Cannon = CANNON_TYPE_LONG_LBS24;', perhaps:
Thanks for checking my syntax! Looks like you're absolutely correct. :onya

No, looking at the contents of "Levis-Fixes_7-10b.zip", the version of "Cannons.c" in there is the same as the first one in post #26, i.e. without the line 'ch.Ship.stats.CannonsQuantity = 0;' and with the line 'ch.ship.cannons.charge.type = DEFAULT_CHARGE;'.
Disappointing. In that case, I'll definitely recommend @pedrwyth to add that again!
If you have cannons of no type, then obviously you have zero of them. ;)

I'm also not sure what's the point in changing the charge type; that is just whether you've loaded with Balls/Grapes but that shouldn't matter one way or another. :confused:
 
Possibly because something is going to get upset if there isn't a charge type defined. Recall that what prompted me to start this thread wasn't the minor annoyance of the ship starting out with CANNON_TYPE_NONE and ending up with CANNON_TYPE_something_else; it was the fact that from 23rd September onwards, the ship forgot that it had any food, framerate was very slow, and there were a lot of errors to do with cannons. There was still weirdness even when I changed my line to give the ship 4lb cannons. It does all work now, even if the net effect is that the ship has no cannons, it has 0 of them, and they would be loaded with cannonballs if I were carrying any. xD
 
Thanks guys (@Pieter Boelen & @Grey Roger ):bow

near enough, what I actually need from ships.init is probably (also a random pick)
Code:
refShip.CannonsQuantity     = 32;
it's the quantity I need to reset so you don't get to have more than the previous full cannon set(the type will come from the swapping ship IF the calibre does not exceed the MaxCaliber allowed - otherwise I might need the type call too) so I will have
Code:
ref rship = GetShipByType(GetCharacterShipType(ch));
ch.Ship.CannonsQuantity = rship.CannonsQuantity;

Conceptually to transfer to a NONE ship I may well need to get cannonf.qty and cannonb.qty too (since they get zeroed) AND re-run the allocation of the remainder to port and starboard - this gets real messy real quick - I think I need to go away and re-appraise what currently happens on trying to transfer with a ship where I have sold all the cannons v one where (as per this example) the NONE is force set, and CannonQuantity is cleared and a new case where on selling the last cannon I set the NONE attribute (just in case). I might be some time!

Possibly because something is going to get upset if there isn't a charge type defined. Recall that what prompted me to start this thread wasn't the minor annoyance of the ship starting out with CANNON_TYPE_NONE and ending up with CANNON_TYPE_something_else; it was the fact that from 23rd September onwards, the ship forgot that it had any food, framerate was very slow, and there were a lot of errors to do with cannons. There was still weirdness even when I changed my line to give the ship 4lb cannons. It does all work now, even if the net effect is that the ship has no cannons, it has 0 of them, and they would be loaded with cannonballs if I were carrying any. xD
That's how I read it from the sequence of posts too :readsomehow in the process the failure to properly charge the cannons was interfering with food allocation etc :duel:and the recharge at least cleared that -which is why I was wondering what changing that recharge attribute effectively did.
 
I think basically any ship with 0 cannons MUST have CANNON_TYPE_NONE set.
Likewise, any ship that has CANNON_TYPE_NONE should really have 0 cannons.
They're technically two independent variables, but they should be completely linked.

Since cannons are placed in arcs, indeed using the "cannonf"and "cannonb" values will be necessary too. :onya
 
Conceptually to transfer to a NONE ship I may well need to get cannonf.qty and cannonb.qty too (since they get zeroed) AND re-run the allocation of the remainder to port and starboard - this gets real messy real quick - I think I need to go away and re-appraise what currently happens on trying to transfer with a ship where I have sold all the cannons v one where (as per this example) the NONE is force set, and CannonQuantity is cleared and a new case where on selling the last cannon I set the NONE attribute (just in case). I might be some time!
For my story, I don't care if the player is stupid enough to buy cannons for this ship rather than just sail to Santiago and steal the snow brig I've provided for him. xD

In general, though, if you're trying to transfer new cannons to a ship which has CANNON_TYPE_NONECANNON, aren't you going to run into the limitation that you're not allowed to increase a ship's calibre by transferring bigger guns to it? If you have 4lb guns and you've just captured something with 6lb guns, you can't upgrade your ship's guns to 6lb by transferring them. So if you have CANNON_TYPE_NONECANNON, you won't be able to transfer guns to your ship. You should, however, be able to add guns at the shipyard.

On the other hand, if you have no cannons because you either sold them all or they were all knocked out in battle, you should be able to transfer cannons up to the size you last had. You have 4lb guns, or at least you did until they were all destroyed while you were closing to board that ship with 6lb guns. You can't upgrade to 6lb guns but you can transfer guns to your ship - they'll just turn into 4lb guns when you do.

And that's why 0 cannons does not necessarily mean CANNON_TYPE_NONECANNON. ;)
 
In general, though, if you're trying to transfer new cannons to a ship which has CANNON_TYPE_NONECANNON, aren't you going to run into the limitation that you're not allowed to increase a ship's calibre by transferring bigger guns to it? If you have 4lb guns and you've just captured something with 6lb guns, you can't upgrade your ship's guns to 6lb by transferring them. So if you have CANNON_TYPE_NONECANNON, you won't be able to transfer guns to your ship. You should, however, be able to add guns at the shipyard.
If one ship has no cannons at all, then I suppose it makes sense to directly transfer the calibre from the other ship.
Or alternatively, take the "default calibre" for that ship type and assume you cannot upgrade above that.

On the other hand, if you have no cannons because you either sold them all or they were all knocked out in battle, you should be able to transfer cannons up to the size you last had. You have 4lb guns, or at least you did until they were all destroyed while you were closing to board that ship with 6lb guns. You can't upgrade to 6lb guns but you can transfer guns to your ship - they'll just turn into 4lb guns when you do.

And that's why 0 cannons does not necessarily mean CANNON_TYPE_NONECANNON. ;)
I don't think that is feasible, because that gets really complicated really fast as @pedrwyth also noticed.

So I do recommend to consider 0 cannons = CANNON_TYPE_NONECANNON .
And for upgrading, as soon as 1 cannon is installed on a ship with no cannons, assume that ship to get the "default calibre".
 
I have a revised transfer_cannons ready for testing in which I think:-

I have fixed where you got a dead captain or unassigned together with a ransack interface header where you were using two companions in the transfer. I suspect if applied elsewhere this would also fix the same issue where it occurs in the other transfer interfaces.

I have changed the left to right transfers to match those use for the right to left originally. These allow cannons to be moved from different arcs if the receiving ship needs them in different arcs. Originally left to right only allowed moves in the same arc meaning you had to swap slots (or even ships sometimes) to achieve the same end.

I have removed (commented out) the block on moving cannons you previously met on your ship if the caliber was too large (right to left) and now you get the cannons you move downgraded to fit your pre-existing if they are smaller than those you are moving. If the pre-existing are smaller you still downgrade to their caliber (as before in some cases) if you choose to proceed. Whilst not realistic I think this does retain the extra gameplay rather than only allowing a matching swap (which would be more realistic

Transferring onto an empty ship gives revised appropriate dialogues and larger than maximum caliber is cut down to the maximum allowed for the receiving vessel (long gun type forced). Smaller or equal maximum gives whatever caliber you are transferring (can't remember if it maintains type but maybe not).

I have introduced a CANNON_TYPE_NONECANNON type if you get down to zero cannons during a transfer but haven't checked what happens in the (presumably rare) event you lose your last cannon in battle. EDIT I think you do get it set in the shipyard ENDEDIT

The coding structure is overly complex since I just kept throwing stuff at it but I'm sure @Pieter Boelen can simplify it somewhat.

I haven't addressed keeping larger calibers you might have got from Vanderdecken.

I did see a dinghy for sale at the shipyard with 0 number 4lb cannons but haven't chased that up (none armed vessels getting an incorrect cannon type at the shipyard).

So here is a revised transfer_cannons.c and a RESOURCE\INI\TEXTS\ENGLISH\interface_strings.txt. As far as I know they should work in both july and sept(with oct 10b required). I think the
ch.Ship.stats.CannonsQuantity = 0; addition to CANNON_TYPE_NONECANNON would be a good thing too.

EDIT file revised 28/10/2016 to correct usage of sti() for getting maximum caliber - coding simplified ENDEDIT
 

Attachments

  • interface_strings.txt
    99.4 KB · Views: 164
  • transfer_cannons.7z
    6.7 KB · Views: 142
Last edited:
Just tested the different situations.
By using this file everything seems to go well.
Place in:
..\PROGRAM\CANNONS
This is going to be resurrected in the next post-7th January update zip. I want my unarmed ship back! :D
 
Back
Top