<img src="style_emoticons/<#EMO_DIR#>/hi.gif" style="vertical-align:middle" emoid=":gday" border="0" alt="hi.gif" /> , fellow PotC modders,
As you might know, I have been doing some experiments on changing the officer system.
Here is an overview on what I've done.
My first goal was to answer this question : is it possible, in PotC, to change the officer system so that it looks/works similar to Seadogs or AOP system?
This would requires several changes :
- twart the limitation of the three-officers-at-the-time system.
- make so that officers contribute only to certain skills & perks, depending on their speciality.
I've packed up my experimental code into something you guys can look at ; it's on the FTP, in my folder. (new_officer_system.rar)
<img src="style_emoticons/<#EMO_DIR#>/readon.gif" style="vertical-align:middle" emoid=":mm" border="0" alt="readon.gif" /> First thing to notice : I've created a new file, officers.c, that contains the most important part of the code.
* InitOfficersType() function, that creates all kind of officer you can have on your ship
* functions to assign/remove a character to those different positions in your ship
* two rewritten functions that deal with party skills/perks
Here's a typical part of InitOfficersType :
<!--c1--><div class='codetop'>CODE</div><div class='codemain'><!--ec1--> //Carpenter
makeref(officer, Officer_type[n]);
officer.name = "Carpenter";
officer.skill.Leadership = 0;
officer.skill.Fencing = 0;
officer.skill.Sailing = 0;
officer.skill.Accuracy = 0;
officer.skill.Cannons = 0;
officer.skill.Grappling = 0;
officer.skill.Repair = 1;
officer.skill.Defence = 0;
officer.skill.Commerce = 0;
officer.skill.Sneak = 0;
officer.perk.LightRepair = 1;
officer.perk.InstantRepair = 1;
n++;<!--c2--></div><!--ec2-->
This one will contribute only to repair skill, LightRepair, and InstantRepair perks.
Please note that I've added an officer called 'captain' who deals with all skills, and all perks.
The functions that assign/remove an officer are not very elaborated : it just stores the index number of that character as a .Ship.Officers.[officer_type name] attribute of the character that haves the ship.
The two rewritten functions are GetSummonSkillFromName from PROGRAM\Characters\CharacterUtilite.c, and GetOfficersPerkUsing from PROGRAM\INTERFACE\Perks\perks.c.
I'll quickly show you how they looked like :
<!--c1--><div class='codetop'>CODE</div><div class='codemain'><!--ec1-->int GetSummonSkillFromName(ref _refCharacter, string skillName)
{
int sumSkill = GetCharacterSkill(_refCharacter,skillName);
int i,cn,curSkill;
for(i=1;i<4;i++)
{
cn = GetOfficersIndex(&_refCharacter,i);
if(cn!=-1)
{
curSkill = GetCharacterSkill(GetCharacter(cn),skillName);
if(sumSkill<curSkill)
{
sumSkill = curSkill;
}
}
}
return sumSkill;
}<!--c2--></div><!--ec2-->
<!--c1--><div class='codetop'>CODE</div><div class='codemain'><!--ec1-->bool GetOfficersPerkUsing(ref chref, string perkName)
{
for(int i=0; i<4; i++)
{
int cn = GetOfficersIndex(chref,i);
if(cn<0) {continue;}
if( GetCharacterPerkUsing(&Characters[cn], perkName) ) {return true;}
}
return false;
}<!--c2--></div><!--ec2-->
And here is how I changed them : in stead of checking you plus the three other guys in the three available slots, now it checks if some officers are supposed to help you with this skill/perks, than gets the index of this officer if you got one, than checks if his skill is higher or if he has the perk.
<!--c1--><div class='codetop'>CODE</div><div class='codemain'><!--ec1--> int GetSummonSkillFromName(ref _refCharacter, string skillName)
{
int sumSkill = GetCharacterSkill(_refCharacter,skillName);
int i,cn,curSkill,n;
for (n = 0; n < MAX_OFFICER_TYPES; n++)
{
ref officer;
makeref(officer, Officer_type[n]);
if(CheckAttribute(officer, "skill." + (skillName)) && sti(officer.skill.(skillName)) > 0)
{
string _post = officer.name;
cn = Get_ship_OfficersIndex(&_refCharacter, _post);
if(cn!=-1)
{
curSkill = GetCharacterSkill(GetCharacter(cn), skillName);
if(sumSkill<curSkill) sumSkill = curSkill;
}
}
}
return sumSkill;
}
bool GetOfficersPerkUsing(ref chref, string perkName)
{
for (int n = 0; n < MAX_OFFICER_TYPES; n++)
{
ref officer;
makeref(officer, Officer_type[n]);
if(CheckAttribute(officer, "perk." + (perkName)))
{
string _post = officer.name;
int cn = Get_ship_OfficersIndex(&chref, _post);
if(cn<0) {continue;}
if( GetCharacterPerkUsing(&Characters[cn], perkName) ) {return true;}
}
}
return false;
}<!--c2--></div><!--ec2-->
My conclusion is that it is pretty much fesable to change the current system into this kind. It would requires other things I haven't done yet : function that removes the stored id of the character if he dies, an of course a proper interface in which you could assign/remove them.
Some more care should be put to InitOfficersType, to chose carefully which officer helps with which skill/perk.
Now for some extra notes - for example, while playing with GetSummonSkillFromName and GetOfficersPerkUsing with some LogIt()s, I noticed a bunch of weird things.
- when I hit some character, it runs GetSummonSkillFromName without giving a skill name..
- two perks that don't exist are checked all the time, 'charisma' and 'witcharm'.
- perk 'sharedexperience' represent 90% of all asked perks. I think we'd have to look at this one more carefully.
- Instantrepair perk code is repetitive.
- your old saves will not be compatible with my changes : you'll be able to load them, but not to save again (CTD). So while you're testing this code, it's better to start a new game.
Any comments are welcomed. Be sure to use winmerge if you want to try the .rar file, as I haven't got the latest alpha version.
To set an officer to a given position, you must use dialog links ('changing' his role aboard).
As you might know, I have been doing some experiments on changing the officer system.
Here is an overview on what I've done.
My first goal was to answer this question : is it possible, in PotC, to change the officer system so that it looks/works similar to Seadogs or AOP system?
This would requires several changes :
- twart the limitation of the three-officers-at-the-time system.
- make so that officers contribute only to certain skills & perks, depending on their speciality.
I've packed up my experimental code into something you guys can look at ; it's on the FTP, in my folder. (new_officer_system.rar)
<img src="style_emoticons/<#EMO_DIR#>/readon.gif" style="vertical-align:middle" emoid=":mm" border="0" alt="readon.gif" /> First thing to notice : I've created a new file, officers.c, that contains the most important part of the code.
* InitOfficersType() function, that creates all kind of officer you can have on your ship
* functions to assign/remove a character to those different positions in your ship
* two rewritten functions that deal with party skills/perks
Here's a typical part of InitOfficersType :
<!--c1--><div class='codetop'>CODE</div><div class='codemain'><!--ec1--> //Carpenter
makeref(officer, Officer_type[n]);
officer.name = "Carpenter";
officer.skill.Leadership = 0;
officer.skill.Fencing = 0;
officer.skill.Sailing = 0;
officer.skill.Accuracy = 0;
officer.skill.Cannons = 0;
officer.skill.Grappling = 0;
officer.skill.Repair = 1;
officer.skill.Defence = 0;
officer.skill.Commerce = 0;
officer.skill.Sneak = 0;
officer.perk.LightRepair = 1;
officer.perk.InstantRepair = 1;
n++;<!--c2--></div><!--ec2-->
This one will contribute only to repair skill, LightRepair, and InstantRepair perks.
Please note that I've added an officer called 'captain' who deals with all skills, and all perks.
The functions that assign/remove an officer are not very elaborated : it just stores the index number of that character as a .Ship.Officers.[officer_type name] attribute of the character that haves the ship.
The two rewritten functions are GetSummonSkillFromName from PROGRAM\Characters\CharacterUtilite.c, and GetOfficersPerkUsing from PROGRAM\INTERFACE\Perks\perks.c.
I'll quickly show you how they looked like :
<!--c1--><div class='codetop'>CODE</div><div class='codemain'><!--ec1-->int GetSummonSkillFromName(ref _refCharacter, string skillName)
{
int sumSkill = GetCharacterSkill(_refCharacter,skillName);
int i,cn,curSkill;
for(i=1;i<4;i++)
{
cn = GetOfficersIndex(&_refCharacter,i);
if(cn!=-1)
{
curSkill = GetCharacterSkill(GetCharacter(cn),skillName);
if(sumSkill<curSkill)
{
sumSkill = curSkill;
}
}
}
return sumSkill;
}<!--c2--></div><!--ec2-->
<!--c1--><div class='codetop'>CODE</div><div class='codemain'><!--ec1-->bool GetOfficersPerkUsing(ref chref, string perkName)
{
for(int i=0; i<4; i++)
{
int cn = GetOfficersIndex(chref,i);
if(cn<0) {continue;}
if( GetCharacterPerkUsing(&Characters[cn], perkName) ) {return true;}
}
return false;
}<!--c2--></div><!--ec2-->
And here is how I changed them : in stead of checking you plus the three other guys in the three available slots, now it checks if some officers are supposed to help you with this skill/perks, than gets the index of this officer if you got one, than checks if his skill is higher or if he has the perk.
<!--c1--><div class='codetop'>CODE</div><div class='codemain'><!--ec1--> int GetSummonSkillFromName(ref _refCharacter, string skillName)
{
int sumSkill = GetCharacterSkill(_refCharacter,skillName);
int i,cn,curSkill,n;
for (n = 0; n < MAX_OFFICER_TYPES; n++)
{
ref officer;
makeref(officer, Officer_type[n]);
if(CheckAttribute(officer, "skill." + (skillName)) && sti(officer.skill.(skillName)) > 0)
{
string _post = officer.name;
cn = Get_ship_OfficersIndex(&_refCharacter, _post);
if(cn!=-1)
{
curSkill = GetCharacterSkill(GetCharacter(cn), skillName);
if(sumSkill<curSkill) sumSkill = curSkill;
}
}
}
return sumSkill;
}
bool GetOfficersPerkUsing(ref chref, string perkName)
{
for (int n = 0; n < MAX_OFFICER_TYPES; n++)
{
ref officer;
makeref(officer, Officer_type[n]);
if(CheckAttribute(officer, "perk." + (perkName)))
{
string _post = officer.name;
int cn = Get_ship_OfficersIndex(&chref, _post);
if(cn<0) {continue;}
if( GetCharacterPerkUsing(&Characters[cn], perkName) ) {return true;}
}
}
return false;
}<!--c2--></div><!--ec2-->
My conclusion is that it is pretty much fesable to change the current system into this kind. It would requires other things I haven't done yet : function that removes the stored id of the character if he dies, an of course a proper interface in which you could assign/remove them.
Some more care should be put to InitOfficersType, to chose carefully which officer helps with which skill/perk.
Now for some extra notes - for example, while playing with GetSummonSkillFromName and GetOfficersPerkUsing with some LogIt()s, I noticed a bunch of weird things.
- when I hit some character, it runs GetSummonSkillFromName without giving a skill name..
- two perks that don't exist are checked all the time, 'charisma' and 'witcharm'.
- perk 'sharedexperience' represent 90% of all asked perks. I think we'd have to look at this one more carefully.
- Instantrepair perk code is repetitive.
- your old saves will not be compatible with my changes : you'll be able to load them, but not to save again (CTD). So while you're testing this code, it's better to start a new game.
Any comments are welcomed. Be sure to use winmerge if you want to try the .rar file, as I haven't got the latest alpha version.
To set an officer to a given position, you must use dialog links ('changing' his role aboard).