Jump to content

Fill aliases with 'dynamic' faction


Monoman1

Recommended Posts

Posted

I want to know if it's possible to:

 

A) Pull a list of faction members for a given faction. I understand there may be many members in the case of bandit factions etc. 

 

B) Fill quest aliases with actors in a 'dynamic' faction. By dynamic I mean that I don't know what that faction will be right now, so it can not be set on the alias conditions because GetInFaction needs a hard coded faction. 

 

I have tried creating a dummy npc that is a member of no factions in a hidden cell. 

When triggered the dummy has all her factions cleared (just in case), then she is added to the faction I want to search for. 

Then a quest is started with aliases with condition 'SameFaction' with target of the dummy npc. 

 

But this just pulls in random Npcs from all over skyrim with no correlation of faction membership what so ever. 

 

Any other ideas?

 

Posted

Formlist with all factions random select out of and the given faction to the dummy is put into another formlist ?

 

 

Posted
3 minutes ago, Tlam99 said:

Formlist with all factions and the given faction to the dummy is put into another formlist ?

 

You'll have to elaborate.

Posted

List 1 faction you search, assign this to npc, write into list2 and use list2 only for quest.

I assume using faction itself out of all npc will be not reliable because hate a faction (-4) like hate bandits

relates again to bandit faction and will bring up this npc.

The relationship part, which interconnects factions.

 

Posted

The main thing I'm trying to do is to get a list (or fill aliases) of actors that are members of the current cell owner faction. So relationship isn't a factor in this case. 

Posted

does this not work ?

 Never tried, but why not.

 

Form FactionReference  = MyFormlist.GetAt(intxx) As Form

Faction MyFaction = FactionReference as Faction

 myNPC.getinfaction(MyFaction)

Posted
14 hours ago, Tlam99 said:

does this not work ?

 Never tried, but why not.

 

Form FactionReference  = MyFormlist.GetAt(intxx) As Form

Faction MyFaction = FactionReference as Faction

 myNPC.getinfaction(MyFaction)

Don't see how this helps. 

 

I need to get a list of actors associated with a faction. I know the faction I want to check:

(Game.GetPlayer()).GetParentCell().GetFactionOwner()

 

What I need is actors in the faction - I don't know 'myNpc'. These actors may or may not be present in the cell at the time because we are talking about breaking into buildings and stealing stuff. So I can't just run a cell scan and loop through all actors in the cell checking to see if they're in the owning faction...

 

It also needs to work for all cells, for all of skyrim + DLCs + every mod ever made. So adding factions to a formlist is impractical anyway. 

Posted

Then my writing is not useful.

For my excuse, at the time I did not know what you are going to do, but only you got tons of random npc.

 

Posted

Well, were it for Fallout 4, you could use actor collection filled using that faction as fill condition, but saddly, Skyrim doesn't have collections.
And even then, it would only give you persistent and nearby actors - any generic bandits and other leveled actors who aren't presently spawned, would not be part of that anyway.

 

How about just fetching N nearby random actors in a loop, checking if they are in the faction, etc.?
Wouldn't that be enough for what you need?

Or maybe try describing what is the ultimate goal of this - and i get it, i hate it when i ask a question and ppl say "and what do you need it for?" instead of answering the simple question, but this question doesn't really have a good answer.

So, i am afraid you will have to rethink what you are doing and lower the bar a little - maybe change the circumstances so you don't need ALL the faction actors, but just a few, or just one, or try to turn things around and do whatever you are trying to do from the other side (whatever that means in your situation).
Sorry, it's hard to give any meaningfull tips, when we don't know what is the purpose of the exercise :)

Posted

It's a long story. 

 

I'm overhauling the vanilla 'Hired thugs' event in Skyrim which when I investigated how it works... well, suffice it to say it only works under fairly narrow circumstances. 

 

I want to cover stealing more comprehensively. The story manager event vanilla uses to capture steal events is inadequate. It works sometimes and doesn't other times with conditions that I do not understand. So I've decided to adapt a hybrid approach:

 

1. Story manager will cover cells with no faction owner - Light/No script load. 

2. OnItemAdded() will handle cells that have a faction owner, but will be off when in dialogue/trade menus or the cell is owned by the player to reduce script load. 

 

Chance of having thugs sent after you will increase based on:

1. The number of items you've stolen from that owner/faction

2. The value of items stolen. 

 

I also want chance to be affected by detection. Detection is handled by aliases that I had wanted to fill with the faction owners of the cell, running a magic effect with LOS and IsDetected magic effect checks. Once detected, detection shuts down and the Npc knows you are in his cell. But if I can not fill the aliases only with the owning faction members then all I can do as a workaround is fill them with all Npcs. Then if detected by a non faction owner then that actor will be removed from it's alias - remove it's ability to detect if not an owner.

 

Detection will be split into: 

1. Once you are detected in the cell the chance of the NPC deciding you're the reason everything went missing goes up. This means that breaking into places at night is a good idea. Not detected = lower chance of thugs. 

2. If you are detected then I want the number of NON faction owner Npcs in a cell at the time to dilute the chances of the owner deciding you're the reason stuff has gone missing - reduce the chance of triggering thugs. This is for busy cells. Like taverns/temples etc. "Was it the player that took my items or one of the other customers?"

 

Here are the problems I have:

1. Not being able to fill aliases only with cell owners as mentioned above. I won't know the cell owner until the player enters a cell. So I can not use the alias condition 'GetInFaction' because it needs a hard coded faction. Possible workaround for that though already implemented. 

2. If the Npc owner is at the tavern and you break into his home while he's away then he won't be present when the cell loads. Therefore, the detection falls apart if he arrives back while you're still inside - He won't be in a detection alias. This could possibly be covered by moving a very large trigger box into the cell on start up and rebooting detection if an actor enters the trigger box. 

3. The vanilla quest adds a note signed by the owner to the thugs. Eg: "Teach her a lesson, signed Belethor". If none of the owner faction members are present on cell load then the owner will be unknown. Of course, the handiest way to get around this is just remove the signed bit. Problem solved. It's a nice touch though, I'd like to keep it. I could possibly do something different like "Teach her not to steal from <Insert cell name> ever again.". Bit clunky though. 

 

I've been around long enough to know fairly well when I've hit a bethesda road block. So I'll have to investigate the alternatives. It just seems really odd to me that getting members of a faction dynamically is impossible... really strange for an rpg. I figured maybe someone knew of some little secret method. If only 'SameFaction' actually worked. 

Posted

If you enter a cell, this cell has a owner. If you steal something, this part has a owner.

Use the owners faction and assign it. Start detection part after this.

 

Posted
On 6/12/2022 at 1:54 AM, Fotogen said:

Example: quest DialogueGeneric, Combat, [Steal] topic. It triggers when you steal something and are detetcted by an NPC.

 

Interesting but I need to capture all (or most anyway) items stolen. Not just the ones you're caught stealing. 

 

It's been an awful mess. 

 

1. Story manager event not firing reliably. I'd say maybe ~50% reliable just from observation. 

2. OnItemAdded() - once object references enter the player inventory GetOwningActor()/GetOwningFaction() no longer work like they do when the object is not in inventory. Should have expected this. 

3. How to cover items that for whatever reason the player drops in owned cells and picks back up again without being flagged as stealing because of #2. 

 

So in the end it looks like I'm going with a ObjRef.GetEditorLocation() == CurrentLocation as a check for stealing object references in the world. 

Objects from containers shouldn't really need any checks... Can't think of any reason the player would put items into an owned container and remove them again unless by accident. 

 

It's not perfect but I think it'll be a decent compromise between accuracy and performance. 

 

Method needs more testing though. 

 

Edit:

Quote

So in the end it looks like I'm going with a ObjRef.GetEditorLocation() == CurrentLocation

Scratch that. GetEditorLocation() is also a steaming pile of shit. Might as well be GetCurrentLocation()

 

Posted

@Monoman1 MAYBE you do not need to track stolen items at all.
I didn't test it, but it seems worth considering.

 

You need some quest script where you store these 4 variables/properties:

  •  score  (int) in range 0-100 inclusive.
    0: nobody saw player at the location.
    1 - 99: somebody saw player at the location and told the owner (this is to be used later as a random chance for the owner deciding whether they believe the witness that player was there - if you want some uncertainty, if not, then you can reduce this variable to a boolean or just 0/1 switch).
    100: the owner himself saw the player at the location.
     
  •  ownerFaction  (faction)
    The faction owning the cell.
     
  •  stolenSeen  (int)
    To store result of  GetStolenItemValueCrime()  function.
     
  •  stolenUnseen  (int)
    To store result of  GetStolenItemValueNoCrime()  function.

 

 

Everytime Player enters/changes location you call a custom function  DidPlayerStoleShit :

Spoiler

function DidPlayerStoleShit()
 

    ; If faction is set and score is greater than 0, somebody detected player in previous location,
    ; so proceed to handle the possibility that player stole something in that previous location.
    if ownerFaction != none && score > 0
        ; score of 100: owner saw player (100 % chance that owner will act)
        ; score of 0-99: somebody saw player and told owner (value represents the chance owner believes the witness and will act)
        if Utility.RandomInt() <= score
            int newStolenSeen = ownerFaction.GetStolenItemValueCrime()
            int newStolenUnseen = ownerFaction.GetStolenItemValueNoCrime()
            ; if the stolen value has increased, it means player stole shit from the faction
            if stolenSeen > newStolenSeen || stolenUnseen > newStolenUnseen
                ; Decide player's punishment...
                ; You can select the type/difficulty of punishment depending on the stolen value.
                ; Maybe send the thugs, or "tell the guards" => add bounty, or just modify the NPC affinity, ...
            endIf
        endIf
    endIf

    ; (re)set the variable values, so they reflect the current cell player just entered
    score = 0
    ownerFaction = Game.GetPlayer().GetParentCell().GetFactionOwner()
    stolenSeen = ownerFaction.GetStolenItemValueCrime()
    stolenUnseen = ownerFaction.GetStolenItemValueNoCrime()


    ; Enable or give player the detection cloak.
    ; You can of course give the cloak to player via an alias and use some global or conditional quest property used in that ability condition to toggle it ON/OFF,
    ; but whatever you chose, at this point we must make sure the cloak gets activated.
    ;Game.GetPlayer().AddSpell(TheDetectionCloakAbibility)

endFunction

 

 

 

When somebody detects player (via the player given cloak spell effect), you check if the detecting actor is the cell owner.

Give the magic effect a  GetDetected  condition for the Subject detecting Player, so the effect gets applied only to actors that detected the player.
Then in the magic effect script of that applied effect, you do the owner check and set the "score" value as follows:

 

  • If cell owner
    Set  score  to 100, and remove/disable the cloak spell from player (not needed anymore since owner knows 100% player was there)
     
  • If not cell owner
    Set the  score  to a random value in range 0-50 (or 25-75, or whatever), and keep the cloak running in case the owner may yet to detect the player too.
    Example:
    ; everytime a non-owner detects the player again, it results in a little chance of increasing the score to
    ; simulate multiple witnesses telling the owner about player, increasing chance the owner will believe them
    int newScore = Utility.RandomInt(25, 75) ; adjust range as desired
    if score < newScore

        score = newScore
    endIf

 

Posted

@Monoman1 Oh, do not forget to give that cloak effect some additonal condition(s) to exclude creatures, so you don't end up having chickens or whatnot "telling" the owner about player's presence :)

 

EDIT: also, give the cloak ability a condition to make it run on player only if in a cell that has an owner (there is no point otherwise, so we can save some little resources by not running the cloak in unowned wilderness cells etc.).

Posted

@Roggvir

GetStolenItemValue is an interesting approach thanks. I'll have to see if it fits (and that that the functions actually work!)

 

Was currently testing an alias set up where all  inventory objects in the world are scanned to an alias and given OnActivate but its my last resort. Works well enough though it seems. Heavier but I could track each individual item stolen. Not sure thats important though. 

 

I still would like to be able to run detection on faction owner npcs that aren't present when the cell loads but I suppose I can just go with my work around trigger box. 

 

19 minutes ago, Roggvir said:

@Monoman1 Oh, do not forget to give that cloak effect some additonal condition(s) to exclude creatures, so you don't end up having chickens or whatnot "telling" the owner about player's presence :)

 

EDIT: also, give the cloak ability a condition to make it run on player only if in a cell that has an owner (there is no point otherwise, so we can save some little resources by not running the cloak in unowned wilderness cells etc.).

Detection is already in place and working well enough.

Shuts down automatically when detected and doesnt start in cells with no faction owner or the faction owner is the player.

Posted
9 minutes ago, Monoman1 said:

Was currently testing an alias set up where all  inventory objects in the world are scanned to an alias and given OnActivate but its my last resort. Works well enough though it seems. Heavier but I could track each individual item stolen. Not sure thats important though.

By "inventory objects" you mean containers, right?

If those GetStolenItemValue functions work, it would be probably the least expensive and simplest solution - IF you do not need to know the exact items that gets stolen.

Posted
18 minutes ago, Roggvir said:

inventory objects" you mean containers, right

Nope. I mean stuff sitting in the world. Like the weapons/armor sitting around warmaidens.

 

If they're not in an alias when picked up then GetFactionOwner() will return None - this is a problem determining if the object originally belonged to the player. (Dropped item)

 

If they're in a container I can assume the object belonged to the cell faction owner. Cant think of any reason the player would put items in a faction owned container and take them back unless by mistake (shouldn't happen too often)

Posted

Well. It was a nice idea...

 

image.jpeg

 

That's after stealing several items. Witnessed and unwitnessed. 

Would love to know enough to investigate these functions to see what they're actually doing. Half of them must be blank/commented out functions. 

 

It may be that the value is not added on to the cell owner faction but some other faction... somehow. But if it doesn't work for the cell owner faction then it's of little use unfortunately.

 

Looks like it's back to aliases. 

Archived

This topic is now archived and is closed to further replies.

  • Recently Browsing   0 members

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