Jump to content

Adding packages to actors using scripts


Recommended Posts

I have a wonderfully buggy Diamond City settlement mod that keeps throwing up problem after problem. The latest (hopefully final problem) is that the workshop-specific packages on my Diamond City settlers aren't working properly – most obviously the WorkshopSleep0x8 package (i.e. my settlers are all congregating at a seemingly random spot rather than looking for a bed). I can't figure out why that is, but I assume it's something to do with their WorkshopLinkHome references. I assume. I also appreciate that it's going to be difficult for anyone else to diagnose the problem from afar, but I'm open to thoughts from anyone who may have experienced similar issues!

The workshop packages are added to actors through the WorkshopParent script, with:

function ApplyWorkshopAliasData(actor theActor)
    WorkshopActorApply.ApplyToRef(theActor)
endFunction

where 'WorkshopActorApply' is a reference alias that bundles all the necessary packages together. Arguably the worst part is, I wanted to turn the existing generic NPCs in Diamond City into workshop settlers, but in doing so, that script has replaced all their default packages with the broken workshop ones! I tried creating a script to revert them, using aliases that bundle their old packages and constant references to the associated NPCs. So something like this:

DiamondCityPackages.ApplyToRef(DiamondCityNPC)

But… that doesn't work ('ApplyToRef is not a function or does not exist'). What should I be doing instead? I realise an alternative would be to add Diamond City-specific packages directly to the Workshop Parent quest, but that's obviously going to limit compatibility with other mods.

Link to comment
Share on other sites

ApplyToRef is a ReferenceAlias script function, in ReferenceAlias.psc. It should work, make sure "DiamondCityPackages" is casted as a ReferenceAlias and "DiamondCityNPC" is an ObjectReference or Actor.

ReferenceAlias Property DiamondCityPackages Auto Const
Actor Property DiamondCityNPC Auto Const

Function ApplyAliasPackageData()
	DiamondCityPackages.ApplyToRef(DiamondCityNPC)
EndFunction

 

Link to comment
Share on other sites

I'm dumb – I was casting as an Alias rather than a ReferenceAlias. Thanks for helping me clear that up! Now I just need to figure out how I want to apply the packages to settlers who are relocated to Diamond City from other settlements… Any ideas?

Link to comment
Share on other sites

If you'd like to stick with ApplyToRef, you can use the ObjectReference event OnWorkshopNPCTransfer for those settler. One of this event's parameters is an "action keyword". It points to WorkshopAssignHome when a settler is sent to a settlement in the WorkshopAssignment menu.

I'd rather make a handler quest with a ReferenceCollectionAlias (RefColl) search instead of ApplyToRef though. You create a quest that let's say the Story Manager (SM) starts Location Loaded (i.e. when the area around the settlement loads, take a look at some of the MinRadiant quests for examples). Then you add a few conditions for the location with condition GetEventData, so that the SM doesn't try to start the quest on any location load event.

Add a RefColl to the quest with fill conditions to filter the references the quest tries to pick and alias (e.g. HasVMScript "WorkshopNPCScript" == 1, IsActor == 1, ( GetIsReference "DiamondCityWorkshopRef" == 1, Run on: GetLinkedRef "WorkshopItemKeyword"), GetDead == 0, GetDisabled == 0, etc.).

As long the NPCs are in the RefColl, Alias Data >> AI Packages are on their "AI stack" as well. If the quest with the AI package has higher Priority (Quest Data tab) than the WorkshopParent quest, ideally, this AI package is active on NPCs held in its quest alias instead of the vanilla workshop package ("ideally" due to the hardly predictable mod conflicts).

Finally, handle quest shutdown in a quest script.

  • Thanks 1
Link to comment
Share on other sites

  • Recently Browsing   0 members

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