Jump to content

Method to loop through all NPC in cell to deteremine if PC follower/co


neuroliquidity

Recommended Posts

I'm looking for a method to loop through all NPC references in the current cell as the PC and determine if they are PC followers/companions and are following the PC.

 

I understand the GetCurrentRef (etc) functions, but what I'm trying to determine is what is the most reliable condition to test for, in order to determine of the NPC is a follower and if they are actively following (and not 'waiting').

 

Is testing for FollowerFaction, TeammateFaction, Player Faction a reliable method? What happens if the NPC is a follower, but has been told to wait? would it be better to test for TeammateFaction, and then test what AI package is running on the NPC?

 

I'm also wanting to make sure that this code will also work if the player has other 3rd-party follower mods installed, since I do not want to limit this only the the default-game followers.

 

Any advice from everyone on test conditions, pitfalls to be wary of, etc, would really be appreciated.

 

Thanks, in advance,

Link to comment
Share on other sites

 

These three functions should tell you if an actor is actually following the player at the moment.

 

 

if ((ActorID.GetCurrentAIPackage == 1) && (ActorID.GetCurrentAIProcedure == 11))
if (Actorref.GetPackageTarget == Player)
 ;Yes, following player and not another actor

http://geck.bethsoft.com/index.php/GetCurrentAIPackage

http://geck.bethsoft.com/index.php/GetCurrentAIProcedure

http://geck.bethsoft.com/index.php/GetPackageTarget

 

Then some info on Reference walking: http://www.cipscis.com/fallout/tutorials/loops.aspx

 

Though this test may fail if the companion is in a guard package and it has a quest script that moves the companion with the player. if you use just GetPackageTarget, you can assume that an actor in a guard package is 'following' the player, I guess.

 

 

Link to comment
Share on other sites

Cheers for the info.

 

I'll run some tests. I'm thinking I might be able to combine with GetInFaction, or (better?) GetPlayerTeammate to improve the reliability.

 

I'm wanting to identify any followers (Dogmeat, et al) but I want to also try and include any followers that are added by other mods, so I'm just looking for a method that's near-perfect reliable, as I'm not sure I can get 100% reliable without asking the player to identify their teammates with some convoluted config menus/GetCrosshairReg scripting and storing the references in a list.

 

Again, thanks for the response.

Link to comment
Share on other sites

i did this script to check hostility but it also checks for allies

 

 

SCN SUBdetect

ref creatureREF
int creatureREFcount
float rTimer

BEGIN GAMEMODE
if player.getitemcount SUBaedACT == 0
	stopquest SUBdetectquest
endif
if player.getitemcount AmmoMicroFusionCell < ( SUBskillcostREF.skillcost )
	stopquest SUBdetectquest
	showmessage SUBmfcellsneededMSG
endif

set rTimer to rTimer - GetSecondsPassed
if rTimer <= 0
	set SUBskillcostREF.indicatorREF to 0
	listclear SUBkilllist
ENDIF

set creatureREFcount to GetNumRefs 200 2
set creatureREF to GetFirstRef 200 2
if (creatureREF.GetDistance player < 10000)

	creatureREF.sms NightkinCloakFXShader

	if ( creatureREF.getdead )	 ;dead -> BLACK
	creatureREF.PMS SUBDeadSpotterShader 1 ; DEAD

	elseif ( creatureREF.IsInList SUBkillList )	
	creatureREF.PMS	SUBIndicatedforshotSHADER 1 ;  indicated for shot

	elseif(creatureREF.Getdistance SUBflagREF <= 250 ) ; indicated for shot
	creatureREF.PMS	SUBIndicatedforshotSHADER 1 ;  indicated for shot
	set SUBskillcostREF.indicatorREF to creatureREF
	creatureREF.listaddreference SUBkillList 0
	set rTimer to 3

	elseif(creatureREF.GetCurrentAIProcedure == 8) ;sleeping -> blue
	creatureREF.PMS	SUBsleepSpotterShader 1 ; sleep

	elseif(creatureREF.GetCurrentAIProcedure == 16) ;fleeing -> pink
	creatureREF.PMS SUBfleeSpotterShader 1 ; flee

	elseif (creatureREF.GetCombatTarget == player)	 ;attacks player -> red fast blink
	creatureREF.PMS	SUBSpotterShader 1 ; ATTACKING

	elseif ( creatureREF.GetFactionRelation player == 2)	 ;ally -> green
	creatureREF.PMS SUBFriendSpotterShader 1 ; ally

	elseif (creatureREF.GetFactionRelation player == 1)	 ;enemy with player-> orange fast blink
	creatureREF.PMS SUBEnemySpotterShader 1 ; hostile

	elseif (creatureREF.GetFactionRelation player == 0 && creatureREF.GetAV Aggression >= 2)	 ;neutral but verry aggressive -> orange fast blink
	creatureREF.PMS SUBEnemySpotterShader 1 ; hostile

	else	 ;any actor alife -> grey
	creatureREF.PMS SUBNeutral 1     ; neutral
	endif

endif

label 5
if creatureREFcount > 0
	set creatureREF to GetNextRef
	if (creatureREF.GetDistance player < 10000)

		creatureREF.sms NightkinCloakFXShader

		if ( creatureREF.getdead )	 ;dead -> BLACK
		creatureREF.PMS SUBDeadSpotterShader 1 ; DEAD

		elseif ( creatureREF.IsInList SUBkillList )	
		creatureREF.PMS	SUBIndicatedforshotSHADER 1 ; indicated for shot

		elseif(creatureREF.Getdistance SUBflagREF <= 250 ) ; indicated for shot
		creatureREF.PMS	SUBIndicatedforshotSHADER 1 ; indicated for shot
		set SUBskillcostREF.indicatorREF to creatureREF
		creatureREF.listaddreference SUBkillList 0
		set rTimer to 3

		elseif(creatureREF.GetCurrentAIProcedure == 8) ;sleeping -> blue
		creatureREF.PMS	SUBsleepSpotterShader 1 ; sleep

		elseif(creatureREF.GetCurrentAIProcedure == 16) ;fleeing -> pink
		creatureREF.PMS SUBfleeSpotterShader 1 ; flee

		elseif (creatureREF.GetCombatTarget == player)	 ;attacks player -> red fast blink
		creatureREF.PMS	SUBSpotterShader 1 ; ATTACKING

		elseif ( creatureREF.GetFactionRelation player == 2)	 ;ally -> green
		creatureREF.PMS SUBFriendSpotterShader 1 ; ALLY

		elseif (creatureREF.GetFactionRelation player == 1)	 ;enemy with player-> orange fast blink
		creatureREF.PMS SUBEnemySpotterShader 1 ; hostile

		elseif (creatureREF.GetFactionRelation player == 0 && creatureREF.GetAV Aggression >= 2)	 ;neutral but verry aggressive -> orange fast blink
		creatureREF.PMS SUBEnemySpotterShader 1 ; hostile

		else	 ;any actor alife -> grey
		creatureREF.PMS SUBNeutral 1     ; neutral
		endif

	endif
	set creatureREFcount to creatureREFcount - 1
	goto 5
endif

set creatureREFcount to GetNumRefs 201 1
set creatureREF to GetFirstRef 201 1
if (creatureREF.GetDistance player < 5000)
	creatureREF.PMS SUBItemSpotterShader 1
endif
label 6
if creatureREFcount > 0
	set creatureREF to GetNextRef
	if (creatureREF.GetDistance player < 5000)
		creatureREF.PMS SUBItemSpotterShader 1
	endif
	set creatureREFcount to creatureREFcount - 1
	goto 6
endif
if SUBskillcostREF.indicatorREF
	showmessage SUBtestmessageMSG
endif
END

 

 

you should be able to deduse what you need for what your doing

 

(sounds like your trying to find a solution to the moveto problem that excludes companions that adapts to mod companions as well... only reason i think that is because i was thinking about doing it myself for my teleporter.

 

but refwalking is awesome!! i use it all the time to find and highlight enemies (the script attached) or to lock on enemies for weapon tracking also partially the code found in this script.

 

there are tons of uses!

 

OOOH 1 more VERY important thing

refwalking for me is notoriously buggy when not used in a quest script and controlled with startquest and stopquest

 

 

oh yeah your probabbly also gonna need to use creatureREF.getcurrentAIpackage == 1 to check if they are in a follow package curently.

Edited by angelwraith
Link to comment
Share on other sites

  • Recently Browsing   0 members

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