Aller au contenu

Photo

Transferring abilities


  • Veuillez vous connecter pour répondre
11 réponses à ce sujet

#1
Karma

Karma
  • Members
  • 391 messages
I've written a custom function that transfers the approval, equipment, level, attributes, specializations, skills, and talents from one creature to another. Everything transfers just fine. The problem, however, is that the new creature levels up. This gives the new creature the old creature's attributes/specializations/skills/talents as well as more points to spend on attributes/specializations/skills/talent. Is there any way to wipe away those extra spendable points (or better yet, set them to whatever number of spendable points were available to the original creature)?

I've tried setting the creature's property PROPERTY_SIMPLE_ATTRIBUTE/SKILL/TALENT_POINTS to what the original creature had as well as setting it to 0.

Also, is there a way to transfer the tactics over?

#2
jackkel dragon

jackkel dragon
  • Members
  • 2 047 messages
Going through my own module's follower scripts, I'm not seeing why the engine won't let you set the properties to zero (I have to for some creatures and it works). Perhaps before setting the properties you could try something like:



SetLocalInt(oFollower, FOLLOWER_SCALED, 1); //This should prevent the follower being rescaled by player_core or what have you




(This is from one of the wiki scripts, not mine.)



When you do set the properties, it may be a good idea to obtain the properties of the original creature (GetCreatureProperty?) and place them on the new one. The skill points and such from unused level-ups are lost if you just set them to zero.



If I find anything useful, I'll post it.



P.S: It seems like there should be a way to script tactics tranfers, but I can't make any sense of it. One of the wiki's follower scripts has a segment of tactics setup code that may be helpful to take a look at, even if the scripter couldn't tell what it did either.

#3
Karma

Karma
  • Members
  • 391 messages
The tactics from the follower tutorial basically just reads the AIP table and populates the tactics screen with the tactics specified in the table. I do that the easy way - using the tactics functions that already exist. The method may be able to be modified though by having the game get the different integers and then setting them. I'll try it and see what I come up with.


As for the extra points, this is the relevant bit of code I'm using:
[dascript]
int nLevel = GetLevel(GetHero()); //was set to oSource but wouldn't get to the right level
int nStrength = GetCreatureAttribute(oSource, PROPERTY_ATTRIBUTE_STRENGTH, PROPERTY_VALUE_BASE);
int nDexterity = GetCreatureAttribute(oSource, PROPERTY_ATTRIBUTE_DEXTERITY, PROPERTY_VALUE_BASE);
int nWillpower = GetCreatureAttribute(oSource, PROPERTY_ATTRIBUTE_WILLPOWER, PROPERTY_VALUE_BASE);
int nMagic = GetCreatureAttribute(oSource, PROPERTY_ATTRIBUTE_MAGIC, PROPERTY_VALUE_BASE);
int nCunning = GetCreatureAttribute(oSource, PROPERTY_ATTRIBUTE_INTELLIGENCE, PROPERTY_VALUE_BASE);
int nConstitution = GetCreatureAttribute(oSource, PROPERTY_ATTRIBUTE_CONSTITUTION, PROPERTY_VALUE_BASE);
float fAttributePoints = GetCreatureProperty(oSource, PROPERTY_SIMPLE_ATTRIBUTE_POINTS, PROPERTY_VALUE_BASE);
float fSkillPoints = GetCreatureProperty(oSource, PROPERTY_SIMPLE_SKILL_POINTS, PROPERTY_VALUE_BASE);
float fTalentPoints = GetCreatureProperty(oSource, PROPERTY_SIMPLE_TALENT_POINTS, PROPERTY_VALUE_BASE);
float fExperience = GetCreatureProperty(oSource, PROPERTY_SIMPLE_EXPERIENCE, PROPERTY_VALUE_BASE);

//SetCreatureProperty(oTarget, PROPERTY_SIMPLE_EXPERIENCE, fExperience, PROPERTY_VALUE_BASE);
SetCreatureProperty(oTarget, PROPERTY_SIMPLE_LEVEL, IntToFloat(nLevel), PROPERTY_VALUE_BASE);
SetCreatureProperty(oTarget, PROPERTY_ATTRIBUTE_STRENGTH, IntToFloat(nStrength), PROPERTY_VALUE_BASE);
SetCreatureProperty(oTarget, PROPERTY_ATTRIBUTE_DEXTERITY, IntToFloat(nDexterity), PROPERTY_VALUE_BASE);
SetCreatureProperty(oTarget, PROPERTY_ATTRIBUTE_WILLPOWER, IntToFloat(nWillpower), PROPERTY_VALUE_BASE);
SetCreatureProperty(oTarget, PROPERTY_ATTRIBUTE_MAGIC, IntToFloat(nMagic), PROPERTY_VALUE_BASE);
SetCreatureProperty(oTarget, PROPERTY_ATTRIBUTE_INTELLIGENCE, IntToFloat(nCunning), PROPERTY_VALUE_BASE);
SetCreatureProperty(oTarget, PROPERTY_ATTRIBUTE_CONSTITUTION, IntToFloat(nConstitution), PROPERTY_VALUE_BASE);
SetCreatureProperty(oTarget, PROPERTY_SIMPLE_ATTRIBUTE_POINTS, fAttributePoints, PROPERTY_VALUE_BASE);
SetCreatureProperty(oTarget, PROPERTY_SIMPLE_SKILL_POINTS, fSkillPoints, PROPERTY_VALUE_BASE);
SetCreatureProperty(oTarget, PROPERTY_SIMPLE_TALENT_POINTS, fTalentPoints, PROPERTY_VALUE_BASE);
[/dascript]

Neither setting it to 0 nor setting it to what the source creature had seems to make a difference. Maybe it's my ordering of the functions.

Modifié par satans_karma, 23 février 2011 - 11:50 .


#4
jackkel dragon

jackkel dragon
  • Members
  • 2 047 messages
It may be order of functions or some other function doing something with the properties. Perhaps instead of setting the level of the new creature through SetCreatureProperty, set it with something like:

int nXp = RW_GetXPNeededForLevel(Max(nLevel, 1));
RewardXP(oTarget, nXp, FALSE, FALSE);


This will likely level-up the creature, but you can undo the level-up with the SetCreatureProperty lines. I'm not sure how this might work with the rest of your script, but when I removed skill points from followers in the initiation script I did this (level-up the creature before resetting properties.)

Edit: Is there a specific value that keeps being added to the creature? Such as the amount of points usually gained by the level-up it had?

Modifié par jackkel dragon, 24 février 2011 - 12:05 .


#5
Karma

Karma
  • Members
  • 391 messages
I tried the RewardXP already with the SetCreatureProperty stuff after it.

It's adding the points that would have normally been gained through all of the leveling up. I'll give the
SetLocalInt(oFollower, FOLLOWER_SCALED, 1); a try (though I'll need to turn it off later I assume).

EDIT: 
SetLocalInt(oFollower, FOLLOWER_SCALED, 1);  does in fact stop the extra points from being given, but it also prevents the creature from later getting XP. 


I tried modifying the tactics section of the follower tutorial to this:
[dascript]
int nMaxTactics = GetNumTactics(oSource);
int nTacticsEntry = 1;
int i;
for (i = 1; nTacticsEntry  <= nMaxTactics; ++i)
{
int bAddEntry = FALSE;
int nTargetType = GetTacticTargetType(oSource, i);
int nCondition = GetTacticCondition(oSource, i);
int nCommandType = GetTacticCommand(oSource, i);
int nCommandParam = GetTacticCommandParam(oSource, i);
int nUseType = GetM2DAInt(TABLE_COMMAND_TYPES, "UseType", nCommandType);

if (nUseType == 0)
{
bAddEntry = TRUE;
}
else
{
bAddEntry = HasAbility(oTarget, nCommandParam);
}

if (bAddEntry)
{
SetTacticEntry(oTarget, nTacticsEntry, TRUE, nTargetType, nCondition, nCommandType, nCommandParam);
++nTacticsEntry;
}
}
[/dascript]

It didn't seem to work.

Modifié par satans_karma, 24 février 2011 - 02:58 .


#6
jackkel dragon

jackkel dragon
  • Members
  • 2 047 messages
It's troubling that the creature can't gain XP. I'm usually able to just keep that variable on without a problem. Though there is a part of my script after setting that variable and the properties that doesn't seem important that may be helping me:


SetCanLevelUp(oFollower,Chargen_HasPointsToSpend(oFollower));


Technically, the autolevel upon recruitment should spend all the points before this. If this function can't get XP working again, I'm really not sure what may be wrong...

Modifié par jackkel dragon, 24 février 2011 - 03:14 .


#7
Karma

Karma
  • Members
  • 391 messages
Basically what I've done is adapted my normal, working hiring script to fit the needs of this companion by removing the autolevel functions and adding in my custom function. There's somewhat of a conundrum: If I send the hiring event to player core, I get the extra points but am able to get tactics and XP, but if I don't send it through player_core, I don't get the points but don't get tactics or XP either. At this point, I'm convinced that it's not my custom function that's at issue but the modifications I've made to the hiring script.

Modified hiring script:
[dascript]
object oHero = GetHero();
object oTamlen = GetObjectByTag("kc_bed100cr_tamlen");
object oTamlenShriek = GetObjectByTag("kc_cam110cr_tamlen");
int nLevel = GetLevel(oHero);

//Chargen_InitializeCharacter(oTamlen, FALSE);
RemoveAbility(oTamlen, 4022);
Chargen_SelectRace(oTamlen, GetCreatureRacialType(oTamlen));
Chargen_SelectCoreclass(oTamlen, class_ROGUE);
//SetLocalInt(oTamlen, FOLLOWER_SCALED, 1);
kcTransferAbilities(oTamlenShriek, oTamlen);
//AL_SpendAttributePoints(oTamlen, nALTable, FALSE);
//AL_SpendSpecializationPoints(oTamlen, nALTable);
//AL_SpendSkillPoints(oTamlen, nALTable, FALSE);
//AL_SpendTalentSpellPoints(oTamlen, nALTable, FALSE);
Chargen_EnableTacticsPresets(oTamlen);
Chargen_SetNumTactics(oTamlen);
ScaleEquippedItems(oTamlen, nLevel);
SetCanLevelUp(oTamlen, Chargen_HasPointsToSpend(oTamlen));
//SetAutoLevelUp(oTamlen, 2);

//UT_HireFollower(oTamlen, FALSE);
SetLocalInt(oTamlen, CREATURE_REWARD_FLAGS, 0);
SetGroupId(oTamlen, GetGroupId(oHero));

int nApprovalDescription = kcGetApprovalDescription(690039);
SetFollowerApprovalEnabled(oTamlen, TRUE);
AdjustFollowerApproval(oTamlen, kcGetApproval(690039));
SetFollowerApprovalDescription(oTamlen, nApprovalDescription);
kcAddFollowerBonusAbility(690034, 0);

SetFollowerState(oTamlen, FOLLOWER_STATE_ACTIVE);
SetFollowerState(oTamlen, FOLLOWER_STATE_AVAILABLE);
//SetEventScript(oTamlen, RESOURCE_SCRIPT_PLAYER_CORE);
//SendPartyMemberHiredEvent(oTamlen, FALSE);

UT_FireFollower(oTamlenShriek, TRUE, TRUE);
DestroyObject(oTamlenShriek);
[/dascript]

I've been turning on and off some of the above functions. The current on/off version basically keeps the scaling variable turned off but doesn't send the hiring to player_core. The result is no extra points, no XP, and no tactics. Basically it has the same effect as SetLocalInt(oFollower, FOLLOWER_SCALED, 1);

Modifié par satans_karma, 24 février 2011 - 03:47 .


#8
jackkel dragon

jackkel dragon
  • Members
  • 2 047 messages
I can't really think of any solution, not yet anyway...



Just a heads-up: UT_HireFollower specifically prevents XP gain, so it's a good idea to leave that commented out.



I'm going to assume you've taken hints from the wiki and not waste your time with links there, but I'm mostly using my copy of the player_core replication there and can't see what's missing here. Have you tried uncommenting the "Chargen_InitializeCharacter"? Since it's before you transfer anything, most of the properties would be overridden anyway.



Also, have you transferred the XP from the old creature? It may not be the same problem, but I once managed to level the PC up to level 9 with only enough XP for level 3, so the XP display was broken until I gained all the XP up to level 8. This is part of why I suggested the RewardXP workaround, if that function works then the creature will have to be able to gain XP (and they'll have enough for future XP gain to be visible on the XP bar.)

#9
Karma

Karma
  • Members
  • 391 messages
I've been using parts of the wiki as needed, but mostly I've been looking at what Bioware did in player_core (the EVENT_TYPE_PARTY_MEMBER_HIRED), chargen_h (all of the different functions that the player_core uses), and utility_h (the UT_HireFollower function).



When I first wrote the custom transfer function, I did have the Rewards thing in there, but I took it out after it didn't work. I then started using the SetCreatureProperty to assign the needed experience, but again, after it didn't work, I commented it out. I can try putting them back in now that I've messed around with the pseudo hiring script. Maybe it'll work now.



I've tried everything I can think of. I really have no explanation. I even tried calling the hiring script and the custom function at different times, but that broke things more. I just don't understand what could be causing the follower not to be able to gain XP and why the tactics are empty - even the presets are missing (except for the "custom" ones). Perhaps I'm misunderstanding what some of these tactics functions actually do (one of them I can't seem to find in any of the chargen files). There's something in player_core that allows XP and tactics. I just need to find it and include it in the proper order.

#10
Karma

Karma
  • Members
  • 391 messages
I rearranged some functions. I ran my custom function first, and now I'm gaining XP. At least that problem is solved.



Also, the tactic preset options ("scrapper", etc.) will show up but only after the follower is added to the active party. I'm still looking for ideas on how to transfer tactics... if anyone has any ideas.

#11
jackkel dragon

jackkel dragon
  • Members
  • 2 047 messages
Sorry that I can't really help with tactics... I just used scripts to set the presets. Glad to hear the XP/bonus points part is settled at least.

#12
Karma

Karma
  • Members
  • 391 messages
Even so, thanks for your help on the rest. Throwing ideas out there and having someone send new ideas back always gets me thinking about other places to look for even more things to try.



The tactics aren't super huge deal anyway. I can always just set up an identical package to the original creature and hope the player hasn't made any significant changes.