• 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 Ship_FireAction Not Working

From "globals.c":
Code:
#define PRIVATEER_NATION 8
#define NEUTRAL_NATION  9
#define UNKNOWN_NATION  10
#define ANY_NATION  11

#define PERSONAL_NATION  -1
I'm not sure what "NEUTRAL_NATION", "UNKNOWN_NATION" and "ANY_NATION" are used for, but it seems to me that "No served nation" ought to be an option with one or other of them. ;)
I don't know what they're used for anyway and I'd prefer avoiding them if I can for simplicity's sake.

Otherwise perhaps you could set served nation to "Personal", provided that doing so doesn't involve automatically hoisting the "Personal" flag.
Served nation should go to Pirate because you just did the worst single act of piracy possible. Worse even than attacking ships of a friendly nation under a hostile flag without provocation.
The only difference between served nation Personal and Pirate is that with Pirate, you can be recognized in non-pirate ports for being a traitor.
Which especially in this case seems very appropriate to me.

The automatic hoisting idea is a thing of the past anyway. Not that forts can be included in the process in a similar way to ships, I have done away with that concept.

In any case, you're right that attacking under a friendly flag is a particularly dishonourable way of betraying a nation and should get at least the same effect. But I still think that to get Pirate as served nation, you ought to need to go and join them; doing something naughty just opens the door for you.
The way it works at the moment is that you CAN get served nation Pirate once an "act of piracy" brings you nation points with them up to "0" (=Friendly). That is as far as you can get it without joining them.
Once you join them, you can gain ranks with the pirates as if you had a normal LoM.

If you MUST join the pirates before Served Nation goes to PIRATE, then no act of piracy would ever be enough to get you marked as a traitor.
As far as I'm concerned, if you act like a pirate, then you ARE a pirate. If you join the pirates, that just means you joined a particular group (the Brotherhood) and aren't on your own anymore.
 
If getting your relations with Pirates up to 0 automatically sets your served nation to Pirate, what about a corsair who starts off with some negative score but not hostile, and then works his way up to 0 by sinking lots of enemy ships while serving the nation of his LoM? Francis Drake goes on the rampage and plunders a whole load of Spanish ships, so his relations with England go up and he earns some ranks, but his relations with Pirates also go up to 0 - does he suddenly find that his served nation has become Pirate?
 
If getting your relations with Pirates up to 0 automatically sets your served nation to Pirate, what about a corsair who starts off with some negative score but not hostile, and then works his way up to 0 by sinking lots of enemy ships while serving the nation of his LoM?
For Francis Drake with an English LoM, sinking ships hostile to England while under an English flag is not an act of piracy.
Therefore he would gain points with England for that, but would NOT also gain points with the Pirates.
So your relation with them would remain Wary or Neutral and as long as you don't perform any true acts of piracy, your served nation will not become Pirate.
That is the way it is intended to work in any case, so if something different happens on the next update, that is a bug that should be fixed.
 
I am finally beginning to properly get to grips with this whole thing.

It turns out that Ship_FireAction is executed EXCLUSIVELY when you use manual aim and the cross-hairs are GREEN.
That means that when this is executed, the player must have deliberately fired fired on a friendly ship.

When I removed all the "turning hostile" code from that function and other ships still turned hostile to me when I fired on them,
that was also NOT some mystery functionality from the engine. Rather, it was a deliberate part of Ship_HullHitEvent .
This means that we now have PROPER CONTROL over this and we can absolutely prevent ships from turning hostile despite our cannonballs hitting them.

So now that we have the ability to make this behave exactly how we want it to, the main question is WHAT do we want it to do?

I'd imagine something along the lines of:
- When hitting a friendly ship (Ship_HullHitEvent), remove some reputation points (maybe only 1?) but do NOT turn them nor their nation hostile (it might have been some stray cannonballs)
- When this is a companion ship that can turn hostile, DO turn the ship hostile
- When deliberately firing on a friendly ship (Ship_FireAction), remove MORE reputation points (10-15?) AND turn them hostile (but not their nation)
- Turning a nation hostile will be limited to actually SINKING or CAPTURING a ship
- Add extra reputation loss/served nation to PIRATE if you do that sinking or capturing while still under a flag friendly to the ship you attacked
- NEVER turn already surrendered ships back to hostile

Does that sound about right?

-------------------------------------------

For the time being, I have changed the behaviour so that in both instances, the ships become hostile, but the nations do not.
 
- When hitting a friendly ship (Ship_HullHitEvent), remove some reputation points (maybe only 1?) but do NOT turn them nor their nation hostile (it might have been some stray cannonballs)
- When this is a companion ship that can turn hostile, DO turn the ship hostile
- When deliberately firing on a friendly ship (Ship_FireAction), remove MORE reputation points (10-15?) AND turn them hostile (but not their nation)
- NEVER turn already surrendered ships back to hostile
I have now created one general function to be used in both instances of firing on friendly ships:
Code:
void AttackFriendlyShip(ref rCharacter, int iRelation, bool bDeliberate)
{
   ref rMainCharacter = GetMainCharacter();

   if (IsCompanion(rCharacter))                         // If companion
   {
     if (GetAttribute(rCharacter, "CompanionEnemyEnable") == true)
     {
       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
     {
       ChangeCharacterReputation(rMainCharacter, -1);             // Small rep loss for firing on your own companions
     }
   }
   else                                     // If other ship
   {
     if (bDeliberate)                             // Deliberately firing on friendly ship using manual aim
     {
       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
         if (iRelation != RELATION_ENEMY)
         {
           SetGroupHostile(rCharacter);                 // Have them turn hostile
           RefreshBattleInterface(true);                 // Update relations and battle interface
         }
       }
     }
     else                                   // Possibly a stray cannonball has hit the ship
     {
       ChangeCharacterReputation(rMainCharacter, -1);             // Small rep loss for accidentally hitting other ships
     }
   }
}
"bDeliberate" is if you use manual aim and that gives you a large reputation loss AND turns the ship and the rest of its fleet hostile.
Interesting to note that this happens at the moment you manually fire with the cross-hairs are green.
This does NOT mean you actually hit them, as you might not have aimed very well or your cannons may not have been fully loaded at the time.

When your cannonballs hit a friendly ship by accident, you just get a small reputation loss.

The behaviour for companions is the same in both cases: Small reputation loss and companions that can turn hostile will do so.

Only thing left to do is to add flag-dependent acts of piracy. I'll continue that later in this thread:
http://www.piratesahoy.net/threads/change-in-nation-relations-from-player-actions.25514/

--------------------------------------------------

As far as I'm concerned, the main issue from this thread is now Fixed.
The functionality works again, there is common behaviour between both methods and nations don't turn hostile based on a single shot.
 
Back
Top