Jump to content

AddScriptPackage breaks companion wheel?


HunterZ

Recommended Posts

In FNV, each of the default followers has a FollowersXXXFollowPlayerDEFAULT (follow closely), FollowersXXXFollowPlayerLONG (follow at a distance) and FollowersXXXFollowPlayerWAIT (wait) script package, where XXX is the name of the follower (Boone, Cass, EDE, etc.).

 

I'm trying to enhance my Follower Cheat Menu MCM mod to allow the player to see which package is currently in use for each companion, and also allow overriding it with a new one. The mod correctly shows which package is in use, and using AddScriptPackage to override it with one of the others also seems to work fine.

 

After overriding the active package for one of the followers, however, I noticed that using the in-game dialogue trees and/or companion wheel to then toggle follow/wait status no longer works! I tried toggling back and forth multiple times, and while the companion wheel appears to reflect the desired state, the AI package never changes to anything but what I set via my mod.

 

Anyone know what the story is here, and whether I can do anything about it? I've tried calling other AI script package related functions before and after AddScriptPackage, but they don't seem to help.

Link to comment
Share on other sites

The wheel uses these variables in the follower's object script to track the state of it's buttons:

 

scn VeronicaSCRIPT


short	CombatStyleRanged
short	CombatStyleMelee
short	IsFollowingDefault
short	IsFollowingShort
short	IsFollowingLong
short FollowerSwitchAggressive			; 0 = Passive (wait for player), 1 = Aggressive (attack when see enemy)
short	Waiting

 

I would imagine that when you substitute a scriptpackage, you should update the appropriate variable in the object script, and also monitor any changes that occur to these variables during dialog with the companion, so you can apply the appropriate scriptpackage if they change.

Link to comment
Share on other sites

Doh, you're probably right. I had already clued into the Waiting flag (since it is used in some of the default game scripts), but didn't think of the fact that the game is probably using similar flags to more easily track the other AI states as well.

 

I'm not sure what the difference would be between IsFollowingDefault and IsFollowingShort, as there are not separate AI packages or UI selections for those two modes as far as I know.

Link to comment
Share on other sites

  • 3 weeks later...

Got it working, but won't be releasing an update to my mod until I figure out what to do about MCM's 10 submenu limit. If only I could do an 8-row by 5-column matrix of checkboxes :P

 

I actually looked up the follower quest that handles changing follower states via dialogue trees and copied some of the logic from there. I discovered that they set flags and run whateverref.evp instead of messing directly with the packages.

Link to comment
Share on other sites

i have question regarding this issue would this break the companion wheel? it's partial of my script

scn ATHSCRIPT

short   ATHREF
short	ATHHired
short	ATHFired
short 	HasBeenHired
short	WeaponOut
short	CombatStyleRanged
short	CombatStyleMelee
short	IsFollowingDefault
short	IsFollowingShort
short	IsFollowingLong
short	Waiting
short	DoOnce
short JFlashlightOn
short ATHHealPercent
short ATHRunSpeed
short ATHHome
short ATHChilledOut

BEGIN GameMode

;_______________________________________________________
;Heals Companion if they drops below 30% and Battle heal is selected
	If ( GetItemCount Stimpak >=2 && GetHealthPercentage <= 0.30 && ATHHealPercent == 1 && ATHHired == 1 )
		Showmessage FollowerMessageHealATH
		PlayIdle 3rdPSpecialIdleStimpak
		ResetHealth
		restoreAV EnduranceCondition 40
		restoreAV PerceptionCondition 40
		restoreAV LeftAttackCondition 40
		restoreAV RightAttackCondition 40
		restoreAV LeftMobilityCondition 40
		restoreAV RightMobilityCondition 40
		removeitem stimpak 2
		PlayIdle 3rdPSpecialIdleStimpak
EndIF

END

Link to comment
Share on other sites

I can't give an authoritative answer, but that looks pretty safe to me. What breaks the wheel is if you mess with the CombatStyleXX/IsFollowingXX/Waiting/etc. variables without properly doing related stuff (or vice versa), and AddScriptPackage appears to be a big no-no.

 

As a style note, you may want your if() statement to check the local variables first and the function call results last. If the scripting engine uses short-circuit evaluation (most languages do these days) then that will be more efficient, which may be important in GameMode code.

Link to comment
Share on other sites

  • Recently Browsing   0 members

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