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

Proposed Change/Addition to IsOfficer()

Generally speaking it’s probably not necessary to know an officer’s number because normally the code will already be looking at the four images, and be able to grab it from there. I just think it’s a potentially-useful technique.

I have to say that I’m not even using the function myself, I’ve looked at it a few times but ultimately never needed it. One thing I was looking at was making officers captive in order to hide them from the passenger list, which I’m no longer doing. While it still wasn’t necessary to know their slot number, at the same time using the“i” would have explicitly prevented the captain from being made captive - since the first slot is zero, it would have returned false (is the captain even a passenger anyway?). That’s the trouble with IsOfficer(), it will regard the captain as an officer, which may not be appropriate in some cases.

As I said, it’s maybe not as useful as I first thought when it comes to this particular function, but the idea is.
 
If you want to improve this function you might want to check the function:
Code:
IsOfficerOf

maybe this one could be used to check if the character is an officer instead.

When an officer is set an attribute is created where the number is stored and the ID of the captain. So this could be used.

you could simplify it to something like this:
Code:
bool IsOfficer(ref _refCharacter)
{
    if(CheckAttribute(_refCharacter, "index"))
    {
        return CheckAttribute(_refCharacter, "OfficerOf.idx");
    }
    return false;
}

But this could have far reaching implications. Because I don't know if everything is coded nice in the game and some function might not like it if IsOfficer will return true for characters which aren't officers of the main character.
 
Last edited:
Do those attributes always get added/removed when they should be?
For the "passenger" one, that certainly was not the case which triggered my less efficient but more reliable rewrite.

I do wonder if I caught and fixed the reason for that being wrong though.
Might have done, but that's difficult to tell....
 
Do those attributes always get added/removed when they should be?
For the "passenger" one, that certainly was not the case which triggered my less efficient but more reliable rewrite.

I do wonder if I caught and fixed the reason for that being wrong though.
Might have done, but that's difficult to tell....
Its set in the function which sets officers. So unless people dont use that it's okay. And if they don't use the function we should change that instead.
 
Back
Top