Jump to content

Detecting if settlement is owned by player


Recommended Posts

Hi,

 

In my script, I'm using the below lines to detect if the player is currently in a settlement, and it's working fine:

 

Location Here = PlayerREF.GetCurrentLocation()
If Here.HasKeyword(LocTypeWorkshopSettlement)
...
Else
...
EndIf
Now I need to know if this current settlement is owned by the player in my script. I have difficulty finding the info.
What would be the best way to do this ?
thks
Link to comment
Share on other sites

Bool Function IsLocalWorkshopOwned(Location thisLocation)

Bool bIsowned = False

If (thisLocation == None)
   thisLocation = Game.GetPlayer().GetCurrentLocation()
EndIf

Quest  WorkshopParent = Game.GetFormFromFile(0x0002058e, "Fallout4.esm") as Quest
WorkshopScript thisWorkshop = (WorkshopParent as WorkshopParentScript).GetWorkshopFromLocation(thisLocation)
If (thisWorkshop != None) 
   bIsOwned = thisWorkshop.OwnedByPlayer
EndIf

Return bIsOwned

EndFunction

If you know how to do script proprties turn pWorkshopParent and Game.GetPlayer into them for neatness.

 

Note1 this only detects Workshops that are registered with WorkshopParent as full settlements. Standalone/Isolated/PlayerHome workshops will not be found, that takes a bit more work.

 

Note2 GetWorkshopFromLocation is EZ but the #1 victim of crappy mod added workshops, users removing registered workshop mods from their load order and workshop location overwrites. Learn more here.

Link to comment
Share on other sites

  • Recently Browsing   0 members

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