The original IsOfficer() function serves only to query the player’s own officers. The problem with the original code is the use of GetMainCharacter(), which obviously targets the self-player and means it is useless for checking companions. Original...
This is my own function which I have applied in a single case...
Instead of simply referencing the player, often MainChar or myCh, this permits the reference ship and the officer. As such, if enemyCh is the first input then that is where it will look. I use refShip1 and refShip2 in this respect because it’s easier to read it that way.
As to what is done with the original function, I guess there are two choices: remove it completely because it is obsolete in my view, or leave it in place because a lot of code will be referencing it and it’d be quite a pain to go through it all. Then there’s the case for including this function.
Code:
bool IsOfficer(ref _refCharacter)
{
if(CheckAttribute(_refCharacter, "index"))
{
int findIdx = sti(_refCharacter.index);
if(findIdx >= 0)
{
for(int i=0; i<4; i++)
{
if(GetOfficersIndex(GetMainCharacter(),i) == findIdx)
return true;
}
}
}
return false;
}
Code:
bool IsAnOfficer(ref _refShip, ref _refChar)
{
if (CheckAttribute(_refChar,"index")) {
int findIdx = sti(_refChar.index)
if (findIdx > 0) {
for (int i=0; i<OFFICER_MAX; i++) {
if (GetOfficersIndex(_refShip,i) == findIdx) {
return i // this effectively returns the officer's slot number
}
}
}
}
return false
}
As to what is done with the original function, I guess there are two choices: remove it completely because it is obsolete in my view, or leave it in place because a lot of code will be referencing it and it’d be quite a pain to go through it all. Then there’s the case for including this function.
Last edited: