Jump to content

Need help to pinpoint Curie when she's around the player


Hoamaii

Recommended Posts

Hi Guys,

I need a second set of neurons here - as I'm having a hard time pinpointing Curie when she's around the player.

Here's what I'm trying to do:

1. Give a ring to actors in script A. When that ring's equipped, I add the actor to a Faction and to a FormList.

2. Later on, script B runs on a placed furniture to try and find out which, among all actors in FormList, is closest to the Player.

This works fine for every actor, EXCEPT (of course) Curie, whether she in Robot form or Synth.

Script A:

Event OnEquipped(Actor akActor)
	If akActor != Game.GetPlayer()
		aRingBearer = akActor
		aRingBearer.AddToFaction(_HST_SleepMateFaction)
	;	ActorBase MySleepmate = aRingBearer.GetBaseObject() as ActorBase
		ActorBase MySleepmate = aRingBearer.GetLeveledActorBase() as ActorBase
		If !_HST_CurrentSleepMateList.HasForm(MySleepmate)
			_HST_CurrentSleepmateList.AddForm(MySleepmate)
		EndIf
	EndIf
EndEvent

Note: GetBaseObject() works just as fine as GetLaveledActorBase() for nearly all companions but Curie.

Script B:

Actor Function GetNearbyRingBearer()
	Actor NearbyRingBearer
	If _HST_CurrentSleepmateList.GetSize() > 0
		NearbySleepmateRef = Game.FindClosestReferenceOfAnyTypeInList(_HST_CurrentSleepmateList, PlayerRef.GetPositionX(), PlayerRef.GetPositionY(), PlayerRef.GetPositionZ(), 1200.0)
		If NearbySleepmateRef
			NearbyRingBearer = NearbySleepmateRef as Actor
			Return NearbyRingBearer
		EndIf
	Else
		Debug.Notification("CurrentSleepmateList EMPTY")
		Return None
	EndIf
EndFunction

Note: I've also tried "FindClosestActor", but it's a real pain because it always returns the player first.

SCRIPT A: Debug shows me that Curie's editor form "CompanionCurie" gets successfully added to the list.

SCRIPT B: yet Actor function GetNearbyRingBearer() always returns None for Curie (whereas it works perfectly for all other actors).

When I click on Curie in Game with console, I do get her proper RefID (00102249) which is the placed ref's ID in Vault 81 from CompanionCurie's base form.
I just don't understand why FindClosestReferenceOfAnyTypeInList(...) can't ever find her even when she's the only form in the formlist.

Any idea what I could try next?

 

Many thanks in advance guys!

Link to comment
Share on other sites

Try using ObjectReferences rather than ActorBase, more reliable and faster on the find.

 

You can add ObjectReferences to your form either in the CK (use the edit/find function on REFID to tell you which cell they are in), or at the start of your script from ReferenceAlias fills,or just xEdit copy the form SKK_UCCompanionREF out of SKKUnlockCompanions.esp

Link to comment
Share on other sites

You mean adding actors as objectReferences to the FormList rather than their actorBase?..

 

Silly question I didn't think of asking you yesterday, but how do you add a Ref to a FormList through script - I always assumed you can only add Forms to FormLists?

Link to comment
Share on other sites

You can use all of the normal FormList functions with ObjectReferences no problem, example adding all player owned workshop map markers to the survival fast travel formlist;

WorkshopScript[] WorkshopREFs = pWorkshopParentScript.Workshops
Int iIndex = 0 
While iIndex < WorkshopREFs.Length 
   If (WorkshopREFs[iIndex].OwnedByPlayer == TRUE)
      pHC_FastTravelAllowedList.Addform(WorkshopREFs[iIndex].myMapMarker)
   EndIf
   iIndex += 1
EndWhile 

Just remember to cast when you pull them out:

ObjectReference ThisREF = (pMyFormList.GetAt(iIndex) as ObjectReference)
Link to comment
Share on other sites

Oh heck, I never would have thought of trying that, thanks!

 

Is that specific to Fallout 4? If I remember correctly, you could only add BaseObjects to FormLists in Skyrim.

 

I'll see if that works for my purposes here, thanks a lot for your help :smile:

Link to comment
Share on other sites

Without capturing ObjectReferences in FormLists, the Fallout 4-76 dynamic OpenWorld would not be possible as that opens the world using hundreds of ObjectReferences in FormLists to drive Enable() Disable() SetOpen() Unlock() & etc loops on the world objects. As opposed to simply hacking all them base game assets in xEdit.

 

No idea about Skyrim, never touched that.

Link to comment
Share on other sites

I just downloaded your "Unlock All Companions" mod as you suggested and I'm reading your script right now - very clever approach!.. I'll load it in the CK, see if I can read your mind ;)

 

Yes, many F04 systems are significantly different from Skyrim, which means I need to shed a lot of old habits when in F04 CK - while in the same time I need to keep these old habits alive when modding Skyrim :pinch:

 

Thanks again, man!

Link to comment
Share on other sites

Argh!.. Curie is a freaking nightmare!!!!...

- GetLeveledBaseActor() returns absolutely nothing that can be found in the editor (form, actor or leveled actor), nor even anything that seems remotely related to her various forms. GetBaseObject() or GetBaseActor() don't help either.

- checking in game with console, her ref ID is 00102249, which is the Ref ID of her Vault 81 placed ref in the world, so far so good. Checking with script, her actor ref in game is recognized as that ref just the same.

- YET "Game.FindClosestReferenceOfAnyTypeInList(...)" systematically returns none, whether it's looking for an ObjectReference or an Actor, even after I manually added all her possible refs and forms to my Formlist, hoping at least one would come out and be recognized.

I tried your suggestions, SKK50, it doesn't works either. My issue obviously isn't with the Formlist, it's more with the function "FindClosestReferenceOfAnyTypeInList" which seems completely unable to relate what's in the formlist with Curie's type in the world, even when she's standing on the furniture which runs the script!.. It's like Curie's completely ignored altogether.

 

She's recognized as an actor or an objectReference by other functions but obviously not by this one. Yet "FindClosestReferenceOfAnyTypeInList" works flawlessly with all other actors!..

 

I'm not ultra familiar with leveled actors, especially those which can have two different forms (robot or synth in this case), but it really feels like I'm hitting a wall there.

 

I'll probably be able to find some scripted crazy workaround but if any of you guys have better experience with Curie, I sure could do with some advices!..

 

 

What I'm (still) trying to do:

 

1. add Curie to a formlist via a scripted piece of armor "OnEquipped()". Several other actors may have been added to that list in the same fashion already.

 

2. use that formlist to determine which actor is closer to the player, via another script attached to a placed object. That's where I need "FindClosestReferenceOfAnyTypeInList(...)" - Curie may be the closest among 10 others, or not... At the moment, since Curie seems to be completely ignored by that function, it always returns any other actor but Curie.

 

Many thanks in advance for any suggestion! :)

Link to comment
Share on other sites

A workaround would be to force a keyword on the actors and use a keyword based find on them which should bypass body double issues and prove if curie is a findable entity.
Link to comment
Share on other sites

Hey, thanks for the suggestion - I thought of trying that in combination with "FindAllReferencesWithKeyword(..)" but that would have been my last resort I guess as that would have meant changing the mod's basic mechanics when it's already been out for nearly a year now without any real bugs to fix. In the end, I thought it safer to eventually add functions to a couple of existing scripts rather than change them...

 

I did find a workaround by adding a custom function specific for Curie - unfortunately having to add her specific Ref as a property to the script - then I just compare distances between my closest actor found in the list and Curie's with "GetDistance". It does the job, seems reliable and hopefuly should not slow the script too much. Not very elegant but hey, some days modding is all about finding workarounds, right? :rolleyes:

 

It still baffles me that "FindClosestReferenceOfAnyTypeInList(...)" will only work with forms obviously when, as I've learnt thanks to you, Fallout 4 now lets us add ObjRefs to Formlists. Not the first contradiction I've found in the CKs anyway... :no:

 

Have you found your way around animations by the way?

 

Thanks again for your help!

Link to comment
Share on other sites

  • Recently Browsing   0 members

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