New follower refuses to follow?

Post » Sat Nov 17, 2012 4:19 am

Hello,

I have a NPC whom I want to join the player character as a follower at the end of a conversation. I'm trying to use a Papyrus fragment at the end of a dialogue, and the code looks as follows:

akSpeaker.AddToFaction(CurrentFollowerFaction)akSpeaker.AddToFaction(PotentialFollowerFaction)akSpeaker.SetFactionRank(CurrentFollowerFaction, 1)akSpeaker.SetFactionRank(PotentialFollowerFaction, 0)akSpeaker.EvaluatePackage()

Both factions are defined, the script compiles without errors. This partially works. The NPC is getting added to the CurrentFollowerFaction with rank of 1, and when I talk with her, I can see the regular follower's dialogue options. She refuses to follow the player, though, and I have no idea why. The relationship is set correctly (ally to Player), there are no AI packages, so it seems the default follower package should be automagically added and enabled when the NPC becomes a member of the CurrentFollowerFaction, but this does not happen.
I have also tried using defining the actual actor instead of akSpeaker and using this actor in the script instead, it didn't work either. What am I missing? Is there a package I have to add manually in order to get it to work?
User avatar
Mrs shelly Sugarplum
 
Posts: 3440
Joined: Thu Jun 15, 2006 2:16 am

Post » Sat Nov 17, 2012 2:39 am

At first, this will appear to be a lot of hassle ... but once you have it setup it will allow you much more flexibility with your follower ... And it's guaranteed to work ...

http://www.gamesas.com/topic/1349193-wip-an-unexpected-companion/

Look at POST No16 and the amendments to that proceedure in POST No19 (with thanks to jediborg and DreamKing, as ever :wink:)


* I should sticky this, or something, I have to go look for the damn thing every time ...
User avatar
Heather Dawson
 
Posts: 3348
Joined: Sun Oct 15, 2006 4:14 pm

Post » Fri Nov 16, 2012 9:43 pm

Hello,

I have a NPC whom I want to join the player character as a follower at the end of a conversation. I'm trying to use a Papyrus fragment at the end of a dialogue, and the code looks as follows:

akSpeaker.AddToFaction(CurrentFollowerFaction)akSpeaker.AddToFaction(PotentialFollowerFaction)akSpeaker.SetFactionRank(CurrentFollowerFaction, 1)akSpeaker.SetFactionRank(PotentialFollowerFaction, 0)akSpeaker.EvaluatePackage()

Both factions are defined, the script compiles without errors. This partially works. The NPC is getting added to the CurrentFollowerFaction with rank of 1, and when I talk with her, I can see the regular follower's dialogue options. She refuses to follow the player, though, and I have no idea why. The relationship is set correctly (ally to Player), there are no AI packages, so it seems the default follower package should be automagically added and enabled when the NPC becomes a member of the CurrentFollowerFaction, but this does not happen.
I have also tried using defining the actual actor instead of akSpeaker and using this actor in the script instead, it didn't work either. What am I missing? Is there a package I have to add manually in order to get it to work?

Factions are only part of the story... and not even the important part for a follower to follow. For that, you need to add the Follower AI Package to the follower, either directly in the Actor dialog or through an alias. (I see you have the EvaluatePackage() call, but I don't see that you've set up a package anywhere?)

A "normal" follower is usually added to the DialogFollower Follower alias with this call to the SetFollower function in DialogueFollowerScript:
Function SetFollower(ObjectReference FollowerRef) actor FollowerActor = FollowerRef as Actor FollowerActor.RemoveFromFaction(pDismissedFollower) If FollowerActor.GetRelationshipRank(Game.GetPlayer()) < 3 && FollowerActor.GetRelationshipRank(Game.GetPlayer()) >= 0  FollowerActor.SetRelationshipRank(Game.GetPlayer(), 3) EndIf FollowerActor.SetPlayerTeammate() ;FollowerActor.SetAV("Morality", 0) pFollowerAlias.ForceRefTo(FollowerActor) pPlayerFollowerCount.SetValue(1) EndFunction

This code adds the follower to the Follwer Alias. If you look at the DialogFollower quest, you can see the Follower alias uses the DefaultFollowerPackage. So if you want your follower to be considered a "normal" follower then I would add your follower using a call to that quest. Otherwise, you just need to add the follower package yourself.
User avatar
CYCO JO-NATE
 
Posts: 3431
Joined: Fri Sep 21, 2007 12:41 pm

Post » Sat Nov 17, 2012 5:04 am

Hello,

I have a NPC whom I want to join the player character as a follower at the end of a conversation. I'm trying to use a Papyrus fragment at the end of a dialogue, and the code looks as follows:

akSpeaker.AddToFaction(CurrentFollowerFaction)akSpeaker.AddToFaction(PotentialFollowerFaction)akSpeaker.SetFactionRank(CurrentFollowerFaction, 1)akSpeaker.SetFactionRank(PotentialFollowerFaction, 0)akSpeaker.EvaluatePackage()


Just something which i noticed when you create a follower within the ck. It may have nothing to do with your issue. All potential followers have their currentfollowerfaction set to -1 not 1
User avatar
Emily Shackleton
 
Posts: 3535
Joined: Sun Feb 11, 2007 12:36 am

Post » Sat Nov 17, 2012 4:42 am

h4vent and Sollar - thank you so much for your advices, they are the most enlightening. Jediborg and Dreamking's solution does seem to be a lot of hassle, and I would have to tailor it specifically to my needs, however it inspired me to come up with a different solution, which perhaps is not as sophisticated, but it works. Kinda. But it's a good place to start, I guess. I haven't had a chance to look into what Sollar suggested, but I will give it a try once I'm back from work.

I'll be happy to share what I have accomplished so far, but let me provide you with a little background first:

We have a quest, let's call it CustomQuest. The guest is given by a NPC called QuestGiver, an apprentice mage at the College of Winterhold, worried about her missing twin sister (let's call her QuestTarget), who ran away after a violent argument, never to be seen again.

Personae dramatis:
1. QuestGiver - relationship is set to ally with player. No factions. Three AI packages, from the top to the bottom:
- ForceGreetPackage with the following condition: GetStage(CustomQuest) == 70
- PlayerFollowerPackage with the following condition: GetStage(CustomQuest) == 20 AND GetStage(CustomQuest) < 70
- Sandbox package with no conditions, set to Hall of Attainment at Winterhold College.

2. QuestTarget - relationship is set to ally with player. No factions. Two AI packages:
- SitInPrison with the following condition: GetStage(CustomQuest) >10 AND GetStage(CustomQuest) < 70
- Sandbox, exact copy of QuestGiver's package with the following condition: GetIsCompleted(CustomQuest) == 1

Now the quest itself:

Stage 0 - PC meets QuestGiver in the College and is asked for help with finding QuestTarget. If the PC agrees, they are asked to give QuestGiver a little time to get ready and talk to her again, quest progresses to stage 10.
Stage 10 - PC asks QuestGiver where should they start, and is advised to go the Winterhold inn. At this point the quest progresses to stage 20, QuestGiver joins CurrentFollowerFaction with rank of 1 and PotentialFollowerFaction with rank of 0, is forced to evaluate her packages and starts following the player. This part works without a hitch.
Stage 20 - PC and QuestGiver visit Winterhold inn, and are advised to investigate another place. Upon the end of the conversation the quest progressed to stage 30. At this point, for some reason, QuestGiver loses her interest in following the PC around and returns to Hall of Attainment, apparently switching over to her sandbox package.
Stage 30, 35, 40, 45 and 50 are irrelevant here.
Stage 60 - PC and QuestGiver find QuestTarget. Quest progresses to stage 70.
Stage 70 - QuestGiver approaches the PC (via ForceGreet package), thanks them for their help. At this point both QuestGiver and QuestTarget switch their factions and ranks to -1 @ CurrentFollowerFaction, and 0 @ PotentialFollowerFaction. Their packages are evaluated once again, and they start walking towards the setting sun, with PC having two new possible followers. Quest progresses to stage 80.
Stage 80 - Quest is completed, fanfares and such.

At this point I haven't tested stage 70 yet. As I said before, my solution works to some degree for stage 20, but it fails miserably at further stages. Do I have to force QuestGiver to evaluate her AI packages upon completion of every single stage? I'm not sure why the follower package stops working all of a sudden.
User avatar
T. tacks Rims
 
Posts: 3447
Joined: Wed Oct 10, 2007 10:35 am

Post » Sat Nov 17, 2012 5:49 am

@heilghast:
Yes, I noticed that too. Apparently the rank is -1 when the NPC is not following you yet, but it gets changed to 1 when they become your active follower.
User avatar
Ricky Rayner
 
Posts: 3339
Joined: Fri Jul 13, 2007 2:13 am

Post » Fri Nov 16, 2012 2:22 pm

Gah, I can't get it to work. When I try attaching Sollar's script to the QuestGiver's alias I get the following errors from the compiler:

e:\games\steam\steamapps\common\skyrim\Data\Scripts\Source\temp\CaitlinFollowerScript.psc(7,30): variable pDismissedFollower is undefinede:\games\steam\steamapps\common\skyrim\Data\Scripts\Source\temp\CaitlinFollowerScript.psc(12,1): variable pFollowerAlias is undefinede:\games\steam\steamapps\common\skyrim\Data\Scripts\Source\temp\CaitlinFollowerScript.psc(12,16): none is not a known user-defined typee:\games\steam\steamapps\common\skyrim\Data\Scripts\Source\temp\CaitlinFollowerScript.psc(13,1): variable pPlayerFollowerCount is undefinede:\games\steam\steamapps\common\skyrim\Data\Scripts\Source\temp\CaitlinFollowerScript.psc(13,22): none is not a known user-defined typeNo output generated for CaitlinFollowerScript, compilation failed.
I also tried adding alias_QuestGiver.EvaluatePackage() upon the completion of each stage to check if this makes the follower package stick, but I can't compile it either:

e:\games\steam\steamapps\common\skyrim\Data\Scripts\Source\temp\QF_CustomQuest_04008956.psc(129,17): EvaluatePackage is not a function or does not exist
It recognises the function when added to the Papyrus fragment in dialogue, but it doesn't when it's in the quest stages tab? How come? It's so very confusing.
User avatar
Andrew Perry
 
Posts: 3505
Joined: Sat Jul 07, 2007 5:40 am

Post » Sat Nov 17, 2012 5:39 am

Gah, I can't get it to work. When I try attaching Sollar's script to the QuestGiver's alias I get the following errors from the compiler:

e:\games\steam\steamapps\common\skyrim\Data\Scripts\Source\temp\QF_CustomQuest_04008956.psc(129,17): EvaluatePackage is not a function or does not exist
It recognises the function when added to the Papyrus fragment in dialogue, but it doesn't when it's in the quest stages tab? How come? It's so very confusing.

The code I posted was to show you what DialogueFollower (the vanilla Bethesda follower script shipped with Skyrim) does to add a follower. I wasn't suggestning that YOU run that code directly (cuz it's not going to work :wink:), I suggested that you call the SetFollower function so the DialogueFollower quest can add your follower to the vanilla follower alias. That would set your follower up as a vanilla follower. If you go this route, you need to create a property for the DialogueFollower quest and then call it in your fragment or script.

Otherwise, I suggest you create an "Follower" AI Package and add it to your NPC in the Actor dialog. (I would make some "condition", like based on the factions you already set up, to trigger the package to start with your EvaluatePackage call. (Personally, this is how I implemented my follower but you should be aware of the fact if you go this route, your follower may not be recognized as a follower by the game or other mods, but if the factions are set up correctly it *should* be okay.)
User avatar
Captian Caveman
 
Posts: 3410
Joined: Thu Sep 20, 2007 5:36 am

Post » Fri Nov 16, 2012 5:31 pm

Ah, thank you for the explanation, Sollar. My scripting experience is none, that's why obvious things are not that obvious to me - sorry about that. I am trying to go the latter route, as it seems to be working fine for me (to some extent). I have the follower AI package added to the actor with conditions preventing this package from running outside of the quest, but I can't figure out why this package stops working when the quest progresses to the next stage, and why I can't call EvaluatePackage() from quest stage tab, I would really appreciate some advice here.
User avatar
Brandon Wilson
 
Posts: 3487
Joined: Sat Oct 13, 2007 1:31 am

Post » Fri Nov 16, 2012 11:39 pm

Ah, thank you for the explanation, Sollar. My scripting experience is none, that's why obvious things are not that obvious to me - sorry about that. I am trying to go the latter route, as it seems to be working fine for me (to some extent). I have the follower AI package added to the actor with conditions preventing this package from running outside of the quest, but I can't figure out why this package stops working when the quest progresses to the next stage, and why I can't call EvaluatePackage() from quest stage tab, I would really appreciate some advice here.

No worries... I'll try to be clearer.

FYI - you don't "have" to call EvaluatePackage() to make an AI Package work, it just might take longer till the package starts. But, when you say you can't call it, explain how you can't? Do you get an error? (If so, always post any errors because those mean something, may not to you, but that's why you're posting ;)) My guess is that you are not calling the EvaluatePackage on the actor reference.

This is how I am calling the EvaluatePackage() from my script fragment:
akSpeaker.EvaluatePackage()

But this would not explain why the follower stops following. That would have to be in the AI Package. What condition(s) do you have set up (in the AI Package)? Are you changing that condition at some point? Or likely, do you have a higher priority AI Package that IS becoming true and taking over? Remember, the AI Packages are listed in their order of precedence, so if your follower package is not listed at the top, one of the packages above it can take over. Also, don't forget the "override" packages listed in the Actor Dialogue AND included in the ActorBase! (That last part, the ActorBase, really through me for a loop because I had no AI Packages set up, but my follower still did it's own thing - turned the ActorBase form had AI Packages that were taking over!)
User avatar
chinadoll
 
Posts: 3401
Joined: Tue Aug 22, 2006 5:09 am

Post » Sat Nov 17, 2012 5:18 am

Hmm, do I need to call EvaluatePackage on the actor reference? I tried calling it on the alias:

alias_QuestGiver.EvaluatePackage()

Which returns this error during compilation:


e:\games\steam\steamapps\common\skyrim\Data\Scripts\Source\temp\QF_CustomQuest_04008956.psc(129,17): EvaluatePackage is not a function or does not exist


Calling EvaluatePackage() from the dialogue Papyrus Fragment works fine, however there are other NPCs that trigger progression to further stages of the quest, so akSpeaker simply won't work here, and I have to call it on either the actor or alias reference, I thought doing it in scripts running at the end of each stage would be the best idea, but apparently CK thinks otherwise.

As for the AI Packages, I have the following assigned to the actor, going from the top to the bottom:

- ForceGreetPackage with the following condition: GetStage(CustomQuest) == 70
- PlayerFollowerPackage with the following condition: GetStage(CustomQuest) == 20 AND GetStage(CustomQuest) < 70
- Sandbox package with no conditions, set to Hall of Attainment at Winterhold College.

As per my post above, the actor is supposed to become the active follower at stage 20, and switch back to potential follower at stage 70. These conditions remain unchanged for the duration of the quest. How do I check the ActorBase packages? I will try removing the sandbox package and check if the follower package sticks then.
User avatar
phillip crookes
 
Posts: 3420
Joined: Wed Jun 27, 2007 1:39 pm

Post » Fri Nov 16, 2012 5:36 pm

Doh! So stupid of me! If the condition is set to ==20 AND <70, advancing to stage 30 will obviously break it and cause the NPC to switch to another package. I'm going to change it to >=20 AND <70 and test again tomorrow, it's already late. Thanks for all your help, Sollar!
User avatar
[Bounty][Ben]
 
Posts: 3352
Joined: Mon Jul 30, 2007 2:11 pm

Post » Fri Nov 16, 2012 3:00 pm

Doh! So stupid of me! If the condition is set to ==20 AND <70, advancing to stage 30 will obviously break it and cause the NPC to switch to another package. I'm going to change it to >=20 AND <70 and test again tomorrow, it's already late. Thanks for all your help, Sollar!
Correct answer ;)

Good luck :)
User avatar
Danial Zachery
 
Posts: 3451
Joined: Fri Aug 24, 2007 5:41 am

Post » Fri Nov 16, 2012 11:10 pm

>How do I check the ActorBase packages?
Buttom left of the Actor dialog shows the ActorBase (or None). Click the edit button to see the Actor dialog for the ActorBase.

> and switch back to potential follower at stage 70
Realize, the followr package is not going to take affect above stage 70, so you'll need to change the conditions. I would look at changing what criteria you use and instead use the faction information. I would change it to this:
Function Name: GetIsInFaction
Function Info: CurrentFollowerFaction
Comp: ==
Value: 1 (this means "true", not the actual rank value)

This way, you would change the CurrentFollowerFaction data in the quest stages and keep all the quest related functionality in one place. This will also keep the AI Package conditions simpler and you won't have to "remember" to go back to the AI Package every time you make changes in your quest, which could be very easy to forget a few months down the road if you make changes to your quest. (This is the concept of encapsulation - everything kept in it's own little capsule or compartment. Makes maintaining and updating code MUCH easier.)

This is how I would set it up anyway.
User avatar
Stacy Hope
 
Posts: 3391
Joined: Thu Jun 22, 2006 6:23 am

Post » Fri Nov 16, 2012 8:58 pm

Just to let you know, everything works like a charm now. Sollar, there is a reason I'm trying to stick to quest stages instead of faction membership to trigger the follower package: I use UFO as a follower mod. I noticed that with the follower package forced by the script, the follower cannot be dismissed via dialogue anymore, which is exactly what I'm looking for, QuestGiver is supposed to travel together with the PC until the quest is completed. Upon the completion of the quest, (stage 70), both QuestGiver and QuestTarget change their faction memberships and the follower package is dropped in the favour of sandbox. Now when the PC approaches either QuestGiver or QuestTarget, he gets 'follow me, I need your help' option, which makes both actors follow the PC just fine using the default follower package. If I set the condition to the faction membership, I'd probably have problems dismissing QuestGiver after the quest has been completed. I would have to test it, though, but at this point I am a little reluctant of attempting to fix things that already work perfectly fine.

Once again, thank you so much for all your help, everyone, I appreciate it.
User avatar
Laura Shipley
 
Posts: 3564
Joined: Thu Oct 26, 2006 4:47 am


Return to V - Skyrim