Jump to content

Function to detect if Player is in a playerOwned Settlement?


Recommended Posts

Just off the top of my head, try it out in Somerville Place. There are several locations throughout the settlement that have issues. There shouldn't be any script lag involved in finding an entry in a ~37 entry array. I used this implementation in a mod of mine a while ago and remember getting a few complaints about this. This is one of the smaller settlements. Considering I don't experience any script lag in the larger settlements, there shouldn't be an issue. I could be wrong, though. Either way, it doesn't work for anyone I've contacted about this.

 

I had taken a picture of a couple locations, but I'm apparently unable to link to image sharing sites in this section of the forum (at least, using the image hosting sites that I tried). Brilliant.

Then I guess people should use it carefully. I had 2 backup functions that fired in case the first one failed.

 

 

Wow, you're fast replying , thanks!.. Just went out to run some errand and I get a lot more answers already!.. :smile:

 

Actually, what I'm trying to do is indeed a condition check for a spell, checking:

 

A. whether the player is inside the boundaries of a settlement he owns,

B. whether or not this specific location's settlement has settlers.

 

The tricky thing is I'd want it to work for custom or modded settlements if I can.

 

Running a condition check on my spell would do the trick if that works.

 

Edit: maybe running the condition check through the WorkshopItemKeyword would work too because that spell can only be casted to the player if he is in SitState.

If you need a condition function then the one suggested by KernallsEgg is a good one (LocationHasPlayerOwnedWorkshop). Not sure about custom workshops. Another way could use LocationHasKeyword . There are some specific keywords related to workshop settlements. But I don`t know how to check if they are owned by player with condition functions. Maybe you can make it work so the condition functions check for workshop and the the script checks the ownership and settlers.

 

To get settlers there is another WorkshopParent function ObjectReference[] workshopNPCs = WorkshopParent.GetWorkshopActors(WorkshopRef as WorkshopScript) ; requires the function to get WorkshopRef that was mentioned before.

Edited by kitcat81
Link to comment
Share on other sites

OK, the condition check LocationHasPlayerOwnedWorkshop on MagicEffect works just as I need in the dozen Settlements (owned and not owned) that I tested - I just realized (I'm a bit slow tonight) that I need to attach 2 scripted effects on my spell though, one which checks positive and the other negative... Forgot to tell you I want that spell to fire inside and outside settlements, but attach different functions whether I'm in a settlement or not.

 

Hmm... I'll try the other ways you guys suggested, using the WorkshopParent script, and try to check for settlers as well...

Link to comment
Share on other sites

Couldn't you just set the LocationHasPlayerOwnedWorkshop value to 1 for inside the settlement and 0 for outside the settlement? A bit lost here.

 

Also, please keep in mind that this method will not recognise Home Plate, or any other non-settlement workshops as workshops.

 

Edit: After a quick look (it's almost 5 AM here, heading to bed in a minute), it looks like you can use the WorkshopParent GetWorkshopActors function to get the number of settlers (and their references if need be).

 

 

 

ObjectReference[] Function GetWorkshopActors(WorkshopScript workshopRef)
	return workshopRef.GetWorkshopResourceObjects(WorkshopRatings[WorkshopRatingPopulation].resourceValue)
endFunction 

 

 

Edited by KernalsEgg
Link to comment
Share on other sites

@ KernalEgg:

 

Yeah, that's what I did, set it to 1 in one case, and to 0 in the other. And It's ok if it does not recognize HomePlate, it never has any settler anyway.

 

Thanks for the settlers script you posted - I'll try that, you might just have saved me quite some time looking for the appropriate Function! :)

 

Good night to you from France (wow, yeah, it is late in your part of the world!..) and kudos for your kind help!

Link to comment
Share on other sites

Apologies, I'm not reading things right tonight. I thought that you were insinuating that you needed another method to determine when you're not in a player owned workshop. I've been tending to skim over messages, take away some key points only to assume the wrong thing. That's when I go back and edit my message after I read the message properly. Night :smile:

Link to comment
Share on other sites

Haha :tongue: I was coincidentally reading an old thread of yours from the start of last year about an issue I was having in SSE (just as you made this post), and you said the same thing. I wouldn't have guessed that English wasn't your first language if you hadn't said anything.

 

If you're wondering - I spent a good hour trying to fix an alias issue that I just needed to untick the Run Once box to resolve. I'd recreated the same couple quests several times over in new .ESP files (as I've been testing a few things out, and so I've started fresh a couple times) and just forgotten to untick it this time... While I'm at it whoever decided that Shouts don't register OnHit events on objects can have an unpleasant day for all I care.

Link to comment
Share on other sites

Old thread of mine of last year?.. Oooh wow, when I get stuck, I tend to dump my puzzles in the forums and hope that some kind soul will play brain cells ping-pong with me... :confused:

 

Forget to tick or untick a box you've used a hundred times before, oh yeah, that's happened to me a LOT too!.. My personal "bad-habit" is I tend to be over-zealous with clean-up functions, and sometimes will use them like 2 or 3 times in the same 1500 lines script, or in several scripts that'll run together, which of course generates logs errors, and 3 weeks later I'll bang my head against the wall to figure out why!.. :pinch:

 

Shouldn't you be in bed by now?

 

PS. Incidentally, I just found a function in the WorshopParent script, "bool Function IsFriendlyLocation(ObjectReference TargetRef)" which might in fact achieve both my goals in one shot...

Link to comment
Share on other sites

This may help, I use this to make sure the player is in a "wild" cell or at least not in his owned cells before I dynamically place an "easter egg" for my scavenger mod:

 

If (Playerref.GetParentCell().GetActorOwner() != Playerref.getactorbase())
Link to comment
Share on other sites

  • Recently Browsing   0 members

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