Now the officer placement is handled by this function in LAi_deck.c
I sugest officertype get a location attribute assigned to them. And this function only has to scroll trough all passengers and check if their location attribute equals the location. If so they are placed in the location.
Code:
void PlaceOfficersToDeck(string deckType)
{
ref mchr = GetMainCharacter();
ref tmpChr;
int i, _curCharIdx, logined;
aref pRef; makearef(pRef,mchr.Fellows.Passengers);
string PsgAttrName;
ref rShipCaptain = GetCharacter(iShipCaptain); // KK
switch(deckType)
{
case "Deck":
logined = 1;
// KK -->
if (iShipCaptain == GetMainCharacterIndex()) {
for (i = 1; i < GetPassengersQuantity(mchr); i++)
{
PsgAttrName = "id"+(i+1);
_curCharIdx = sti(pRef.(PsgAttrName));
tmpChr = GetCharacter(_curCharIdx);
if(!CheckAttribute(tmpChr,"prisoned") && CheckAttribute(tmpChr,"quest.officertype"))
{
switch(FindCurrentDeck())
{
case "CannonsDeck":
if(tmpChr.quest.officertype==OFFIC_TYPE_CANNONEER)
{
CharacterIntoLocationLocator(_curCharIdx, mchr.location);
LAi_SetCivilianPatrolType(tmpChr);
}
break;
case "Hold":
if(tmpChr.quest.officertype==OFFIC_TYPE_CARPENTER)
{
CharacterIntoLocationLocator(_curCharIdx, mchr.location);
LAi_SetCivilianPatrolType(tmpChr);
}
break;
case "ShipDeck":
if(GetCharacterShipCabin(mchr)=="Cabin_none")
{
CharacterIntoLocationLocator(_curCharIdx, mchr.location);
LAi_SetCivilianPatrolType(tmpChr);
}
else
{
if(tmpChr.quest.officertype==OFFIC_TYPE_ABORDAGE || tmpChr.quest.officertype==OFFIC_TYPE_CANNONEER || tmpChr.quest.officertype==OFFIC_TYPE_CAPNAVY) // KK
{
CharacterIntoLocationLocator(_curCharIdx, mchr.location);
LAi_SetCivilianPatrolType(tmpChr);
}
}
break;
case "Seadogs":
if(tmpChr.quest.officertype==OFFIC_TYPE_BOATSWAIN || tmpChr.quest.officertype==OFFIC_TYPE_DOCTOR || tmpChr.quest.officertype==OFFIC_TYPE_QMASTER || tmpChr.quest.officertype==OFFIC_TYPE_ABORDAGE)
{
CharacterIntoLocationLocator(_curCharIdx, mchr.location);
LAi_SetCivilianPatrolType(tmpChr);
}
break;
}
}
}
} else {
for (i = 1; i < 7; i++)
{
if (i < OFFICER_MAX)
_curCharIdx = GetOfficersIndex(rShipCaptain, i);
else
_curCharIdx = GetOfficersIndex(mchr, i - OFFICER_MAX+1);
if (_curCharIdx < 0) continue;
tmpChr = GetCharacter(_curCharIdx);
if(!CheckAttribute(tmpChr,"prisoned") && CheckAttribute(tmpChr,"quest.officertype"))
{
switch(FindCurrentDeck())
{
case "CannonsDeck":
if(tmpChr.quest.officertype==OFFIC_TYPE_CANNONEER)
{
CharacterIntoLocationLocator(_curCharIdx, mchr.location);
LAi_SetCivilianPatrolType(tmpChr);
}
break;
case "Hold":
if(tmpChr.quest.officertype==OFFIC_TYPE_CARPENTER)
{
CharacterIntoLocationLocator(_curCharIdx, mchr.location);
LAi_SetCivilianPatrolType(tmpChr);
}
break;
case "ShipDeck":
if(GetCharacterShipCabin(rShipCaptain)=="Cabin_none")
{
CharacterIntoLocationLocator(_curCharIdx, mchr.location);
LAi_SetCivilianPatrolType(tmpChr);
}
else
{
if(tmpChr.quest.officertype==OFFIC_TYPE_ABORDAGE || tmpChr.quest.officertype==OFFIC_TYPE_CANNONEER || tmpChr.quest.officertype==OFFIC_TYPE_CAPNAVY) // KK
{
CharacterIntoLocationLocator(_curCharIdx, mchr.location);
LAi_SetCivilianPatrolType(tmpChr);
}
}
break;
case "Seadogs":
if(tmpChr.quest.officertype==OFFIC_TYPE_BOATSWAIN || tmpChr.quest.officertype==OFFIC_TYPE_DOCTOR || tmpChr.quest.officertype==OFFIC_TYPE_QMASTER || tmpChr.quest.officertype==OFFIC_TYPE_ABORDAGE)
{
CharacterIntoLocationLocator(_curCharIdx, mchr.location);
LAi_SetCivilianPatrolType(tmpChr);
}
break;
}
}
}
}
// <-- KK
PostEvent("SetAnotherType", 2500 , "i", mchr);
break;
case "Cabin":
logined = 1;
// KK -->
for (i = 1; i < COMPANION_MAX; i++) {
_curCharIdx = GetCompanionIndex(mchr, i);
if (_curCharIdx < 0) continue;
ChangeCharacterAddressGroup(GetCharacter(_curCharIdx), "None", "", "");
}
bool bPlace = false;
if (iShipCaptain != GetMainCharacterIndex()) {
CharacterIntoLocationLocator(iShipCaptain, mchr.location);
ChangeCharacterAddressGroup(rShipCaptain, mchr.location, "rld", "startloc");
LAi_SetStayTypeNoGroup(rShipCaptain);
logined++;
for (i = 1; i < OFFICER_MAX; i++) {
_curCharIdx = GetOfficersIndex(rShipCaptain, i);
if (_curCharIdx < 0) continue;
tmpChr = GetCharacter(_curCharIdx);
ChangeCharacterAddressGroup(tmpChr, "None", "", "");
CharacterIntoLocationLocator(_curCharIdx, mchr.location);
logined++;
}
}
if (mchr.location == "Cabin_small" && logined > 2) break;
// <-- KK
for(i = 1; i < OFFICER_MAX; i++)
{
_curCharIdx = GetOfficersIndex(mchr, i);
if(_curCharIdx < 0) continue;
tmpChr = GetCharacter(_curCharIdx);
if(CheckAttribute(tmpChr,"quest.officertype"))
{
bPlace = false;
switch(Rand(4))
{
case 0: bPlace = tmpChr.quest.officertype==OFFIC_TYPE_FIRSTMATE; break;
case 1: bPlace = tmpChr.quest.officertype==OFFIC_TYPE_NAVIGATOR; break;
case 2: bPlace = tmpChr.quest.officertype==OFFIC_TYPE_BOATSWAIN; break;
case 3: bPlace = tmpChr.quest.officertype==OFFIC_TYPE_QMASTER; break;
case 4: bPlace = tmpChr.quest.officertype==OFFIC_TYPE_DOCTOR; break;
// Aconcagua: TODO: whatabout the other officertypes???
// PB: They are placed at different deck locations as defined above in this file
}
if(DEBUG_EXPERIENCE>0) TraceAndLog("PlaceOfficersToDeck: Set officer type for " + GetMySimpleName(tmpChr));
// tmpChr.quest.officertype = GetRandomOfficerType(); //Levis let's use a global function so we can easily add types later. - PB: Don't do this here
if(bPlace)
{
ChangeCharacterAddressGroup(tmpChr, "None", "", "");
CharacterIntoLocationLocator(_curCharIdx, mchr.location);
logined++;
}
// KK -->
if (mchr.location == "Cabin_small" && logined > 2) break;
if(!IsOfficer(tmpChr)) continue;
CharacterIntoLocationLocator(_curCharIdx, mchr.location);
// <-- KK
}
}
break;
}
for(i=1; i<GetPassengersQuantity(mchr); i++)
{
PsgAttrName = "id"+(i+1);
_curCharIdx = sti(pRef.(PsgAttrName));
tmpChr = GetCharacter(_curCharIdx);
if(IsOfficer(tmpChr)) continue;
if(!CheckAttribute(tmpChr,"prisoned") && CheckAttribute(tmpChr,"quest.officertype"))
{
LAi_ClearIndexedLocators(mchr.location, tmpChr.location.group);
}
}
}
I sugest officertype get a location attribute assigned to them. And this function only has to scroll trough all passengers and check if their location attribute equals the location. If so they are placed in the location.