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

Cannot Confirm Losing reputation when firing at a surrendered ship

Grey Roger

Sea Dog
Staff member
Administrator
Storm Modder
Being a pirate, and having found a nice fat Portuguese merchant ship, I attacked it. After it had surrendered, I hit it with several grapeshots, each one dropping my reputation, so that at the end of the broadside I'd dropped from "Matey" to "Horror of the High Seas".

But here's the problem. I fired when the ship was still hostile, and it surrendered while the broadside was in progress. So although the act of firing the broadside, and the first shot or two, happened before the ship surrendered, part of the broadside went off and then hit the ship after the surrender.
 
Being a pirate, and having found a nice fat Portuguese merchant ship, I attacked it. After it had surrendered, I hit it with several grapeshots, each one dropping my reputation, so that at the end of the broadside I'd dropped from "Matey" to "Horror of the High Seas".

But here's the problem. I fired when the ship was still hostile, and it surrendered while the broadside was in progress. So although the act of firing the broadside, and the first shot or two, happened before the ship surrendered, part of the broadside went off and then hit the ship after the surrender.
That's really quite odd; I know for certain there is code in place to prevent exactly that.

The relevant file is in PROGRAM\SEA_AI, probably AIShip.c (but might be sea.c) .
Can you search through that file for "reputation" and post the related sections?

I know I substantially simplified that a while back, because you convinced me to remove a lot of those reputation hits you used to get from accidentally hitting other ships.
 
Probably this in "AIShip.c":
Code:
void Ship_FireAction()
{
   // LDH restored 23Jan09
   aref rCharacter = GetEventData();         // we attack this character
   aref rMainGroupCharacter = GetEventData();     // commander character for rCharacter - PB: This isn't actually used anymore
   ref rMainCharacter = GetMainCharacter();
   int iRelation = GetEventData();

// KK -->
   if (!TestRef(rCharacter) || !TestRef(rMainGroupCharacter)) return;
   int iCharacterIndex = sti(rCharacter.index);
   if (iCharacterIndex < 0) return;
   int iMainGroupCharacterIndex = sti(rMainGroupCharacter.index);
   if (iMainGroupCharacterIndex < 0) return;
// <-- KK

   if (iRelation != RELATION_ENEMY)
   {
     if (IsCompanion(rCharacter) && GetAttribute(rCharacter, "CompanionEnemyEnable") == true)   // If companion that can turn hostile
     {
       ChangeCharacterReputation(rMainCharacter, -20);                       // Double rep loss compared to ShipMutiny() as you did not give them fair warning with a hostile flag
       SeaAI_SetCompanionEnemy(rCharacter);                           // Disconnect companion from our group and set it enemy to us
     }
     else                                             // If other ship
     {
       if(CheckAttribute(rCharacter,"surrendered"))                       // NK: surrendered ships 05-04-20
       {
         if (sti(rCharacter.surrendered.seatime) + 20 < GetSeaTime())             // 20 second grace period
         {
           ChangeCharacterReputation(rMainCharacter, -15);                   // NK: Large rep loss for firing on surrendered ships
         }
       }
       else
       {
         ChangeCharacterReputation(rMainCharacter, -15);                     // NK: Large rep loss for firing on friendly ships
         SetGroupHostile(rCharacter, true);                           // Have them turn hostile; as you fired first, this is a betrayal
         RefreshBattleInterface(true);                             // Update relations and battle interface
       }
     }
   }
}
 
Probably this in "AIShip.c":
Code:
void Ship_FireAction()
{
   // LDH restored 23Jan09
   aref rCharacter = GetEventData();         // we attack this character
   aref rMainGroupCharacter = GetEventData();     // commander character for rCharacter - PB: This isn't actually used anymore
   ref rMainCharacter = GetMainCharacter();
   int iRelation = GetEventData();

// KK -->
   if (!TestRef(rCharacter) || !TestRef(rMainGroupCharacter)) return;
   int iCharacterIndex = sti(rCharacter.index);
   if (iCharacterIndex < 0) return;
   int iMainGroupCharacterIndex = sti(rMainGroupCharacter.index);
   if (iMainGroupCharacterIndex < 0) return;
// <-- KK

   if (iRelation != RELATION_ENEMY)
   {
     if (IsCompanion(rCharacter) && GetAttribute(rCharacter, "CompanionEnemyEnable") == true)   // If companion that can turn hostile
     {
       ChangeCharacterReputation(rMainCharacter, -20);                       // Double rep loss compared to ShipMutiny() as you did not give them fair warning with a hostile flag
       SeaAI_SetCompanionEnemy(rCharacter);                           // Disconnect companion from our group and set it enemy to us
     }
     else                                             // If other ship
     {
       if(CheckAttribute(rCharacter,"surrendered"))                       // NK: surrendered ships 05-04-20
       {
         if (sti(rCharacter.surrendered.seatime) + 20 < GetSeaTime())             // 20 second grace period
         {
           ChangeCharacterReputation(rMainCharacter, -15);                   // NK: Large rep loss for firing on surrendered ships
         }
       }
       else
       {
         ChangeCharacterReputation(rMainCharacter, -15);                     // NK: Large rep loss for firing on friendly ships
         SetGroupHostile(rCharacter, true);                           // Have them turn hostile; as you fired first, this is a betrayal
         RefreshBattleInterface(true);                             // Update relations and battle interface
       }
     }
   }
}
Yep, that's it! :onya

This is the line I was referring to:
Code:
if (sti(rCharacter.surrendered.seatime) + 20 < GetSeaTime())  // 20 second grace period
"GetSeaTime()" gets written to the "surrendered.seatime" attribute at the time when the ship surrenders.
That code there checks if more than 20 seconds have passed since then and applies the reputation hit only AFTER those 20 seconds.

So the only way what you describe should happen is if your broadside lasted MORE than 20 seconds.
You could put some Trace and/or LogIt lines in there to check that it indeed does do what it should.
 
Can't you check if the "fire" button was pressed after the ship surrendered and apply a penalty for the act of initiating the broadside, rather than apply a penalty for each shot?
 
Can't you check if the "fire" button was pressed after the ship surrendered and apply a penalty for the act of initiating the broadside, rather than apply a penalty for each shot?
If I recall, Ship_FireAction() gets executed ONLY if you manually aim and fire your cannons, so what you request should already be the case.
I'm pretty sure I got rid of that "reputation change for each shot" months ago at your request.

Please add some debugging lines to double-check though.
Be sure to use Trace because LogIt won't clearly tell you if the same stuff gets executed multiple times.
 
If I ever again attack a ship which then surrenders part way through a broadside, I'll let you know. For that matter, if I find a ship which has surrendered, and if I remember, I'll try shooting at it and see if I get penalised once or for each shot, then let you know. ;)
 
If I ever again attack a ship which then surrenders part way through a broadside, I'll let you know. For that matter, if I find a ship which has surrendered, and if I remember, I'll try shooting at it and see if I get penalised once or for each shot, then let you know. ;)
Cheers! When you do the testing, I recommend putting in those Trace lines; otherwise it will probably very difficult to figure out what happens.
 
@Grey Roger: Have you got any clue about this one? As far as I can tell from the code, this should not be an actual problem.
So if it is, I'd rather like to know....
 
It didn't seem to be a problem last time. I managed to force a ship to surrender, fired a broadside of grape into it anyway, and didn't get a whole string of messages about losing reputation on this occasion. I don't know why it happened the previous time.
 
It didn't seem to be a problem last time. I managed to force a ship to surrender, fired a broadside of grape into it anyway, and didn't get a whole string of messages about losing reputation on this occasion. I don't know why it happened the previous time.
In that case, I suspect it is a VERY unlikely scenario.
Possibly the "20 second grace time" isn't quite enough to 100% cover all cases.
If it happens again, we can try to up it to "30". In the meantime, I'll archive this as "Cannot Confirm".
 
Back
Top