Mostly for my self but others are free to give suggestions.
Just checking IsOfficer should probably be enough, but needs testing.
I sugest to change this:
into this:
result should be the same but should skip some steps if not needed.
To prevent crashed due to to much event calls and to keep the performance up this line:
can be changed to always call the function. At the moment the whole post init system is disabled anyways.
Suggest to change this line:
into this:
it will prevent some checks to be done when not nessecary
Suggest to change this:
into this:
it will reduce the amount of checks done again.
In this piece of code:
I believe the we can just use the modval. because maybe the charmod is a temporary buff which will be removed later, so XP should be going to the skill untill it really is at level 10 and not at a boosted level 10.
Code:
if (skillmult < 0.5 && bAllies(chref) && IsOfficer(chr)) skillmult = 0.5; // Character is in the player shore party
I sugest to change this:
Code:
skillmult = 0.0;
if (cn == sti(chref.index)) skillmult = 1.0; // The character who gained the XP gets 100%
if (expName == "") skillmult = 1.0; // All characters join in "general XP"
if (expName == SKILL_FENCING) // Fencing is a personal skill and should be handled differently
{
if (skillmult < 0.5 && bAllies(chref) && IsOfficer(chr)) skillmult = 0.5; // Character is in the player shore party
}
else // For any non-personal skills
{
tempmult = GetOfficerSkillFactor(chr, expName); // This means some officers can get 200% XP!
if (skillmult < tempmult) skillMult = tempmult; // The officer who gains the XP will ALWAYS get it
}
if (IsMainCharacter(chr)) // Special case for the player, because you cannot focus on all skills at the same time
{
skillmult = 0.5; // Only 50% of all skills
if (expName == SKILL_LEADERSHIP) skillmult = 1.0; // But a captain MUST know how to lead a crew
if (expName == SKILL_SAILING) skillmult = 1.0; // And navigate a ship
}
if (skillmult < 0.5 && SharedXP) skillmult = 0.5; // Sharing XP, so everybody gets at least 50%
Code:
skillmult = 0.0;
if (cn == sti(chref.index))
{
skillmult = 1.0; // The character who gained the XP gets 100%
}
else
{
if (expName == "")
{
skillmult = 1.0; // All characters join in "general XP"
}
else
{
if (IsMainCharacter(chr)) // Special case for the player, because you cannot focus on all skills at the same time
{
skillmult = 0.5; // Only 50% of all skills
if (expName == SKILL_LEADERSHIP) skillmult = 1.0; // But a captain MUST know how to lead a crew
if (expName == SKILL_SAILING) skillmult = 1.0; // And navigate a ship
}
else
{
if (expName == SKILL_FENCING) // Fencing is a personal skill and should be handled differently
{
if (skillmult < 0.5 && bAllies(chref) && IsOfficer(chr)) skillmult = 0.5; // Character is in the player shore party
}
else // For any non-personal skills
{
tempmult = GetOfficerSkillFactor(chr, expName); // This means some officers can get 200% XP!
if (skillmult < tempmult) skillMult = tempmult; // The officer who gains the XP will ALWAYS get it
}
}
}
}
if (skillmult < 0.5 && SharedXP) skillmult = 0.5; // Sharing XP, so everybody gets at least 50%
To prevent crashed due to to much event calls and to keep the performance up this line:
Code:
if(AUTO_SKILL_SYSTEM)
{
if (CheckAttribute(chref, "skipPostInit")) AddXPtoSkillsMain(chref, expName, realExp); // PB: Allow overriding the PostInit process if necessary
else PostEvent("procAddXPtoSkillsMain",0,"lsls",sti(chref.index),expName,realExp,chref.location);
}
Suggest to change this line:
Code:
if(CheckAttribute(chref,"completeinit") && curExp >= nextExp && !CheckAttribute(chref,"quest.NoRaise"))
{
//We need to check the officerprice before the level is increased. Since the last update maybe the assignment or skill levels have been changed.
//We only check if we are going levelup
officerprice = GetBaseOfficerPrice(chref);
if(DEBUG_OFFICERPRICE > 1) trace("OFFICERPRICE check previous price: "+officerprice+" for "+GetMySimpleName(chref));
}
Code:
if(CheckAttribute(chref,"completeinit"))
{
if(curExp >= nextExp && !CheckAttribute(chref,"quest.NoRaise"))
{
//We need to check the officerprice before the level is increased. Since the last update maybe the assignment or skill levels have been changed.
//We only check if we are going levelup
officerprice = GetBaseOfficerPrice(chref);
if(DEBUG_OFFICERPRICE > 1) trace("OFFICERPRICE check previous price: "+officerprice+" for "+GetMySimpleName(chref));
}
}
Suggest to change this:
Code:
if(CheckAttribute(chref,"completeinit")) ResetMaxHP(chref);
//Now we check how much the officer price would have increased and we add this to the already existing officerprice
if(CheckAttribute(chref,"completeinit") && !CheckAttribute(chref,"quest.NoRaise"))
{
officerprice = GetBaseOfficerPrice(chref) - officerprice;
if(DEBUG_OFFICERPRICE > 1) trace("OFFICERPRICE substracted price is: "+officerprice+" for "+GetMySimpleName(chref));
if(officerprice > 0) //We'll never lower the officerprice
{
chref.quest.OfficerPrice = sti(chref.quest.OfficerPrice) + officerprice;
//If there is an old officerprice, we raise this too in case it is put back
if(CheckAttribute(chref,"quest.officerprice.old")) chref.quest.officerprice.old = sti(chref.quest.officerprice.old) + officerprice;
if(DEBUG_OFFICERPRICE > 1) trace("OFFICERPRICE set to: "+chref.quest.OfficerPrice+" for "+GetMySimpleName(chref));
}
}
Code:
//Now we check how much the officer price would have increased and we add this to the already existing officerprice
if(CheckAttribute(chref,"completeinit"))
{
ResetMaxHP(chref);
if(!CheckAttribute(chref,"quest.NoRaise"))
{
officerprice = GetBaseOfficerPrice(chref) - officerprice;
if(DEBUG_OFFICERPRICE > 1) trace("OFFICERPRICE substracted price is: "+officerprice+" for "+GetMySimpleName(chref));
if(officerprice > 0) //We'll never lower the officerprice
{
chref.quest.OfficerPrice = sti(chref.quest.OfficerPrice) + officerprice;
//If there is an old officerprice, we raise this too in case it is put back
if(CheckAttribute(chref,"quest.officerprice.old")) chref.quest.officerprice.old = sti(chref.quest.officerprice.old) + officerprice;
if(DEBUG_OFFICERPRICE > 1) trace("OFFICERPRICE set to: "+chref.quest.OfficerPrice+" for "+GetMySimpleName(chref));
}
}
}
In this piece of code:
Code:
int modval = GetCharacterBaseSkill(chref, expName);
if(modval == 0) return LevelUp;
[...]
while (curSkill >= nextSkill)
{
LevelUp = true;
//Substract the xp needed to level up.
curSkill = curSkill-nextSkill;
//Add the level
if(GetCharacterSkill(chref, expName) >= MAX_CHARACTER_SKILL)
{
[...]
}
else
{
IncreaseBaseSkill(chref, expName, 1);
if(CheckAttribute(chref,"completeinit") && GetCharacterSkill(chref, expName)>0)
{
[...]
}
}
[...]
int GetCharacterSkill(ref character, string skillName)
{
int skillPoints = GetCharacterBaseSkill(character, skillName);
//Levis add a character based modifier also
skillPoints += GetCharacterCharMod(character, skillName);
skillPoints = iclamp(0, MAX_CHARACTER_SKILL, skillPoints);
return skillPoints;
}