Jump to content

Recommended Posts

Posted

Seasons greetings,

 

I'm working on a mod to create an array of actors that are potential followers - the goal is to then manipulate all the mod added followers to make their recruitment more interersting. I've got most of what i wanted working using SkyPal, however i've run into a problem in excluding some vanilla followers from my list to edit. I've created a form list in the CK with the specific actors to exclude, and created a function to check that each of my potential actors isn't in the list using the HasForm fucntion. However i still see these actors in my array when I test - the code for the function is below but the line that doesn't seem to work correctly is:

 

DTFollowersToExcludeList.HasForm(ref_to_check) == false

 

with DTFollowersToExcludeList being the formlist. The first 2 conditions in the statement work correctly as I only get actors in the PotentialFollowerFaction - any thoughts would be welcome,

 

Thanks

function Get_NPC_Array()
	int [] Base_Form_Types = new int[1]
   	Base_Form_Types[0] = NPC_Form_Type
	ObjectReference[] NPC_Array = SkyPal_References.All()
	Debug.MessageBox(NPC_Array.Length+"NPCs Found")
	NPC_Array = SkyPal_References.Filter_Form_Types(NPC_Array, Base_Form_Types)
	Debug.MessageBox(NPC_Array.Length+"Characters Found")
	int Index = 0
	actor ref_to_check
	int Array_Length = NPC_Array.Length
	Adventurer_Array = new Actor[128]
	while index < Array_Length
		ref_to_check = NPC_Array[index] as actor
		if ref_to_check.IsInFaction(PotentialFollowerFaction) && ref_to_check.IsInFaction(DTPotentialFollower) == false && DTFollowersToExcludeList.HasForm(ref_to_check) == false
			ArrayAddRef(Adventurer_Array, ref_to_check)
			index +=1
			ref_to_check.RemoveFromFaction(PotentialFollowerFaction)
			ref_to_check.AddToFaction(DTPotentialFollower)
			ref_to_check.SetRelationshipRank(Game.GetPlayer(), 0)
			ref_to_check.SetFactionRank(DTPotentialFollower,Utility.RandomInt(0, 100))
			;debug.Notification("Added to Array called")
		else
			index +=1
			;debug.Notification("Added to array not called")
		endif
	endWhile
	Debug.MessageBox(Adventurer_Array.Length+"Adventurers Found")
endFunction
Posted (edited)

You wrote: "any thoughts would be welcome"

I think you should split your function in subfunctions to get a better overview. In my opinion the "Adventurer_Array" is wrong initialized!

 

maybe next code is useful to you

  Reveal hidden contents

 

Edited by ReDragon2013
Posted

NPC_Array is an ObjectReference array. You are casting those values into Actor and assigning it to ref_to_check. Then you are checking to see if these actors are in the DTFollowersToExcludeList form list.

 

The question then is this: What did you assign to the DTFollowersToExcludeList? The base actor or the pre-placed object reference?

 

If the base actor, you probably need to use: ref_to_check.GetActorBase()

If the pre-placed object reference, you probably need to use: NPC_Array[index]

 

It may be a good idea to temporarily trace out the contents (actual ID numbers not names) of the array and the form list to ensure that you are trying to compare the correct things.

Posted

Thanks for the quick feedback - I think you are both on to it with the actorbase, I populated the list in the CK from the actors pane so assume that's what i should be checking - i'll give that a try and see if it works.

 

@ReDragon2013 thanks for the code tips, i'll take a look!

  • Recently Browsing   0 members

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