Jump to content

Question about FollowerState ActorValue


PJMail

Recommended Posts

It 'looks' like it should control your followers as the "FollowPlayer" Package template (used by FollowersCompanionPackage that all companions have) has conditional procedures based on it (FollowerState = 1 means Follow, =3 means Wait, etc).

Also it's value is set by the Script functions Actor.FollowerWait() and FollowerFollow()...

 

Doing a manual "Setav Followerstate 3" does make them wait.

Yet, if I tell a companion to "wait" via the UI (which they do) this ActorValue is still "1" ("Getav Followerstate").

It looks like the Companion command UI works on a different mechanism (that I can't find).

 

What am I missing here?

Link to comment
Share on other sites

Edit: My bad, just noticed you pointed out the functions already.

 

I'll leave this here anyway just in case it sheds a little light on your situation.

 

from the followersscript:

 

 

 

 

;********************************* FOLLOWER COMMANDS ***************************************************

Function FollowerWait(Actor Follower)
    SetFollowerActorValue(Follower, Game.GetCommonProperties().FollowerState, iFollower_Com_Wait)
EndFunction

Function FollowerFollow(Actor Follower)
    SetFollowerActorValue(Follower, Game.GetCommonProperties().FollowerState, iFollower_Com_Follow)
EndFunction

Function FollowerSetDistanceNear(Actor Follower)
    SetFollowerActorValue(Follower, Game.GetCommonProperties().FollowerDistance, iFollower_Dist_Near)
EndFunction

Function FollowerSetDistanceMedium(Actor Follower)
    SetFollowerActorValue(Follower, Game.GetCommonProperties().FollowerDistance, iFollower_Dist_Medium)
EndFunction

Function FollowerSetDistanceFar(Actor Follower)
    SetFollowerActorValue(Follower, Game.GetCommonProperties().FollowerDistance, iFollower_Dist_Far)
EndFunction

Function SetFollowerActorValue(Actor Follower, ActorValue WhichValueToSet, GlobalVariable iFollower_Global)
    Follower.SetValue(WhichValueToSet, iFollower_Global.GetValue())
EndFunction

 

 

Edited by AnishaDawn
Link to comment
Share on other sites

Yes, I understand how it is 'meant' to work, but it looks like Bethesda isn't using their own code when you tell a companion to "Stay".

How (unsurprisingly) inconsistent of them..

 

I want to detect when a companion is "staying" but followerstate is not sufficient it seems...

Link to comment
Share on other sites

Thanks DieFeM, however I do not want to monitor every Companion. I don't care when (or how) they were told to stay - I just want to know if they are not 'following'.

 

When you tell a Companion to "Stay" they are still in the 'currentcompanions' alias in the followers quest, as well as Game.getplayerfollowers(), and their followerstate is set to 'follow'.

However I only want followers who are actually 'following' the player when I run my script...

I am running UCF so maybe it is at fault...

Link to comment
Share on other sites

Looks like I have hit a roadblock..

 

When you 'command' a Companion the Game forces a 'special' package "CommandModeTravel" on their AI stack (this package is not referenced anywhere in the game otherwise).

This package uses a special undocumented condition "GetTypeCommandPerforming" which returns the same values the Event "OnCommandModeGiveCommand" would (that DieFem mentioned). Subject.GetTypeCommandPerforming = 7 means "Stay".

 

Unfortunately there is no corresponding papyrus function to return this so I am stuck.

 

This kludgy system also explains why companions don't 'stay' for very long - almost anything that causes them to refresh their AI stack causes this 'foreign' AI package to drop off it and so they resume their standard 'FollowersCompanionPackage'.

Edited by PJMail
Link to comment
Share on other sites

That's right. The "CommandModeTravel" is used by the interface. It isn't used in quests or Papyrus scripts. The interface (command mode) handles this package through default objects like "CommandModeTravelPackage_DO" and "CommandModeActivatePackage_DO".

 

The FollowersCompanionPackage is only a "FollowPlayer" package. You can see that its "Treat As Player Follower" checkbox is checked. This is what lets the system know that this package is meant for NPCs who recieve commands from you. (The command mode functions like SetCanDoCommand, SetCommandState are in the actor script though).

 

In the "FollowersScript" you can see a lot of unused things... like the "Follower State" actor value. During development, they changed that actor value method.

 

The "GetTypeCommandPerforming = X" is the only way to detect the follower's current command type. Unfortunately, there's no actor script function like: "int commandTypeIndex = myActor.GetTypeCommandPerforming()".

So to detect a follower's command type, you need to use the "OnCommandModeGiveCommand" event. When you recieve this event, you can set a script or a global variable to "store" the follower's current command type. (The event is not always reliable though).

Edited by LarannKiar
Link to comment
Share on other sites

A workaround if there's not a papyrus equivalent condition is to use a spell and add the condition to it in the CK, then use a script with OnEffectStart to set a bool in the script you're checking, or just use OnEffectStart to call another function in your original script. Example:

Scriptname TM_ObjectReferenceScript extends ObjectReference 

Spell Property SpellChecker Auto ;spell has condition GetTypeCommandPerforming == 7
Bool Property IsWaiting Auto

Bool Function IsActorWaiting(Actor akActor) 
    IsWaiting = False 
    SpellChecker.Cast(akActor, akActor) ;akActor casts spell on themself 
    Utility.Wait(0.1) ;wait for spell script to run 
    Return IsWaiting ;is waiting will be true if the spell was successfully cast
EndFunction

Then in the magic effect script:

 

Scriptname TM_MagicEffectScript extends ActiveMagicEffect 
TM_ObjectReferenceScript Property ScriptRef Auto ;access above script

Event OnEffectStart(Actor akTarget, Actor akCaster) ;effect will only start if GetTypeCommandPerforming == 7
    ScriptRef.IsWaiting = True 
EndEvent
Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...