Here's currently what I have based on reading the follower hire code executed in player_core and the tutorials above:
case VIRGIL_JOINS:
{
object oOldFollower = GetObjectByTag("virgil");
object oFollower = CreateObject(OBJECT_TYPE_CREATURE, R"virgil.utc", GetLocation(oPC));
int nClass = CLASS_WIZARD;
int nRace = RACE_HUMAN;
int nGender = GENDER_MALE;
//update plot flag
WR_SetPlotFlag(PLT_PARTY_STATUS, VIRGIL_IN_PARTY, TRUE);
//remove old follower
SetObjectActive(oOldFollower, FALSE);
Safe_Destroy_Object(oOldFollower);
//reset character to defaults
InitFollower_Thirst(oFollower);
//init character
//Chargen_InitializeCharacter(oFollower);
Chargen_SelectRace(oFollower, nRace);
CharGen_ClearAbilityList(oFollower, 1);
Chargen_SelectCoreClass(oFollower, nClass);
Chargen_SetNumTactics(oFollower);
Chargen_EnableTacticsPresets(oFollower);
//Set player rank
SetCreatureRank(oFollower, CREATURE_RANK_PLAYER);
if(IsPartyPerceivingHostiles(oFollower) & GetCombatState(oFollower) == FALSE)
{
SetCombatState(oFollower, TRUE);
}
//remove stationary flag, allow level up
SetLocalInt(oFollower, FOLLOWER_SCALED, 1);
SetLocalInt(oFollower, AI_FLAG_STATIONARY, 0);
SetLocalInt(oFollower, CREATURE_REWARD_FLAGS, 0);
SetLocalInt(oFollower, AMBIENT_SYSTEM_STATE, 0);
//level scaling (DO NOT SPEND POINTS)
int nPackage = GetPackage(oFollower);
int nTargetLevel;
int nPlayerLevel = GetLevel(oPC);
if(nPlayerLevel >= 13 || nPlayerLevel == 1 )
{
nTargetLevel = nPlayerLevel;
}
else
{
nTargetLevel = nPlayerLevel + 1;
}
int nMinLevel = GetM2DAInt(TABLE_PACKAGES, "MinLevel", nPackage);
if(nMinLevel > 0 && nMinLevel > nTargetLevel)
{
nTargetLevel = nMinLevel;
}
//xp until hero level
int nXp = RW_GetXPNeededForLevel(Max(nTargetLevel, 1));
RewardXP(oFollower, nXp, TRUE, FALSE);
//add specialization
float count=1.0;
if(GetLevel(GetHero())>=7)
{
SetCreatureProperty(oFollower, 38, count); // 38 is the spec point ID
count=count+1.;
}
if(GetLevel(GetHero())>=14)
{
SetCreatureProperty(oFollower, 38, count); // 38 is the spec point ID
}
//clear any unwanted conditions on the follower
SetImmortal(oFollower, FALSE);
SetPlot(oFollower, FALSE);
SetObjectInteractive(oFollower, TRUE);
SetObjectActive(oFollower, TRUE);
SetTeamId(oFollower, -1);
//init follower settings
InitHeartbeat(oFollower, CONFIG_CONSTANT_HEARTBEAT_RATE);
SetEventScript(oFollower, RESOURCE_SCRIPT_PLAYER_CORE);
SendPartyMemberHiredEvent(oFollower, FALSE);
SetFollowerApprovalEnabled(oFollower, TRUE);
//RW_CatchUpToPlayer(oFollower);
SetFollowerState(oFollower, FOLLOWER_STATE_LOCKEDACTIVE);
break;
}
}
Unfortunately this results in a follower who, while having class, race and gender selected correctly, has 1 HP, 0 mana/stamina and no available points to spend, no selected abilities or spells, etc. Although, the follower DOES receive one talent, possibly the default one when the class is selected. Replacing the player_core "XP calculation script" with RW_CatchUpToPlayer doesn't help.
Any thoughts?
EDIT: Upon further testing I notice the following:
- The follower actually has all the "default" points to level up, same as what you get on character creation
- The follower does NOT get any racial/class benefits, so starting attributes are very low (i.e. 9 magic for a mage)
I feel like I'm quite close now, but the auto-leveling still isn't working for some reason.
EDIT 2: Success! I had to run the extra level-up stuff
after the follower is added to the party, not before. With all that done they are receiving class/race benefits properly and also get their level-up added correctly. Awesome. Thanks for all the help guys!
Modifié par sea-, 24 juin 2013 - 05:08 .