#include “ginc_object”
#include “ginc_cutscene”
//56178
int GetXPForClass(object oOriginal,int nClassPosition,int BaseLevel){
int iLevel = GetLevelByPosition(nClassPosition,oOriginal);
int iLevelSum = iLevel + BaseLevel ;
if( iLevel > 0){
string s2DA = "exptable";
string sXP = Get2DAString(s2DA,"XP",iLevelSum);
SendMessageToPC(GetFirstPC(FALSE),"sXP = " + sXP);
return StringToInt(sXP);
}
else {
return 0;
}
}
//-------------------------------------------------------------------------------------------------------
int GetLevelUpPackageSOAR(object oOriginal,int nClassPosition){
int iPackage = 255;
if(GetClassByPosition(nClassPosition,oOriginal) == CLASS_TYPE_WIZARD){
//SendMessageToPC(GetFirstPC(FALSE),"nClassPosition = " + IntToString(nClassPosition));
int iSpellSchool = 0 ;// GetCasterClassSpellSchool(oOriginal,nClassPosition);
if(GetStringLowerCase(GetTag(oOriginal))== "edwin"){
iSpellSchool = 2;
}
else {
//SendMessageToPC(GetFirstPC(FALSE),"Trying to retrieve iSpellSchool");
//iSpellSchool = GetCasterClassSpellSchool(oOriginal,2); Doesn' t work, can' t get the caster school
}
//SendMessageToPC(GetFirstPC(FALSE),"iSpellSchool = " + IntToString(iSpellSchool));
switch (iSpellSchool){
case 1 :
iPackage = PACKAGE_WIZARD_ABJURATION;
break;
case 2 :
iPackage = PACKAGE_WIZARD_CONJURATION;
break;
case 3 :
iPackage = PACKAGE_WIZARD_DIVINATION;
break;
case 4 :
iPackage = PACKAGE_WIZARD_ENCHANTMENT;
break;
case 5 :
iPackage = PACKAGE_WIZARD_EVOCATION;
break;
case 0 :
iPackage = PACKAGE_WIZARDGENERALIST;
break;
case 6 :
iPackage = PACKAGE_WIZARD_ILLUSION;
break;
case 7 :
iPackage = PACKAGE_WIZARD_NECROMANCY;
break;
case 8 :
iPackage = PACKAGE_WIZARD_TRANSMUTATION;
break;
}
return iPackage;
}
return iPackage;
}
//-------------------------------------------------------------------------------------------------------
object LevelUpClass(object oNewCompanion,int iClass,int iLevel,int iPackage){
//SendMessageToPC(GetFirstPC(FALSE),"iClass = " + IntToString(iClass) );
//SendMessageToPC(GetFirstPC(FALSE),"iLevel = " + IntToString(iLevel) );
int i;
for(i= 1; i <= iLevel;i++){
LevelUpHenchman(oNewCompanion,iClass,FALSE,iPackage);
}
return oNewCompanion;
}
//-------------------------------------------------------------------------------------------------------
object SetClasses(object oOriginal,object oNewCompanion){
int iLevelClass1 = GetLevelByPosition(1,oOriginal);
int iLevelClass2 = GetLevelByPosition(2,oOriginal);
int iLevelClass3 = GetLevelByPosition(3,oOriginal);
int iLevelClass4 = GetLevelByPosition(4,oOriginal);
int ECL = 0;
if(GetSubRace(oOriginal) == RACIAL_SUBTYPE_DROW){
ECL =2;
}
int iLevel1 = iLevelClass1 + ECL;
int iLevel2 = iLevel1 + iLevelClass2 ;
int iLevel3 = iLevel3 + iLevelClass3 ;
int iLevel4 = iLevel4 + iLevelClass4 ;
int XPLevelUp =0;
ResetCreatureLevelForXP(oNewCompanion,0,FALSE);
if( iLevelClass1 > 0) {
LevelUpClass(oNewCompanion,GetClassByPosition(1,oOriginal),iLevelClass1-1,GetLevelUpPackageSOAR(oOriginal,1));
}
if( iLevelClass2 > 0) {
LevelUpClass(oNewCompanion,GetClassByPosition(2,oOriginal),iLevelClass2,GetLevelUpPackageSOAR(oOriginal,2));
//XPLevelUp = GetXPForClass(oOriginal,2,ECL);
}
if( iLevelClass3 > 0) {
LevelUpClass(oNewCompanion,GetClassByPosition(3,oOriginal),iLevelClass3,GetLevelUpPackageSOAR(oOriginal,3));
}
if( iLevelClass4 > 0) {
LevelUpClass(oNewCompanion,GetClassByPosition(4,oOriginal),iLevelClass4,GetLevelUpPackageSOAR(oOriginal,4));
}
return oNewCompanion;
}
//------------------------------------------------------------------------------------------------------
object CopySpell(object oOriginal, object oNewCompanion){
int iNumberOfSpells = GetNum2DARows("spells");
int i;
for (i=0; i <= iNumberOfSpells; i++){
if(!GetSpellKnown(oOriginal,i)){
SetSpellKnown(oNewCompanion,0,TRUE,TRUE);
}
}
return oNewCompanion;
}
//------------------------------------------------------------------------------------------------------
object newCompanion(object oOriginal,object oNewCompanion){
oNewCompanion = SetClasses(oOriginal,oNewCompanion);
SetXP(oNewCompanion,GetXP(oOriginal));
int iNumberOfFeats = GetNum2DARows("feat");
int i;
for(i=0 ; i <6;i++){
SetBaseAbilityScore(oNewCompanion,i,GetAbilityScore(oOriginal,i,TRUE));
}
int iNumberOfSkills = GetNum2DARows("skills");
for (i=0; i <= iNumberOfSkills; i++){
SetBaseSkillRank(oNewCompanion,i,GetSkillRank(i,oOriginal,TRUE),FALSE);
}
for (i=0; i <= iNumberOfFeats; i++){
/*
FeatRemove(oNewCompanion,i);
if(GetHasFeat(i,oOriginal)){
FeatAdd(oNewCompanion,i,FALSE,FALSE,FALSE);
}*/
if(GetHasFeat(i,oOriginal) && !GetHasFeat(i,oNewCompanion)){
FeatAdd(oNewCompanion,i,FALSE,FALSE,FALSE);
}
else if(!GetHasFeat(i,oOriginal) && GetHasFeat(i,oNewCompanion)){
FeatRemove(oNewCompanion,i);
}
}
SetFortitudeSavingThrow(oNewCompanion,GetFortitudeSavingThrow(oOriginal));
SetReflexSavingThrow(oNewCompanion,GetReflexSavingThrow(oOriginal));
SetWillSavingThrow(oNewCompanion,GetWillSavingThrow(oOriginal));
return oNewCompanion;
}