Jump to content

How to check faction of player?


azzendix

Recommended Posts

I create Readable Shadowmarks mod and I want to add thieves guild member as a requirement to it.

 

Which method should I use to check that player is a member of thieves guild?

Choice 1: Check faction status - PlayerRef.IsInFaction(ThievesguildFaction)

Is it work for player or just NPC?

 

Choice 2: Check quest stage - (I don't know much about it.)

Edited by azzendix
Link to comment
Share on other sites

Thanks, PeterMartyr!

 

"GetStageDone" is what I am looking for.

Not sure about this but IsInFaction is not working with a player for me(?). I use this command with my thief character and it returns zero.

So I decide to use GetStageDone only.

Edited by azzendix
Link to comment
Share on other sites

 

"GetStageDone" is what I am looking for.

 

No it is not. If you are looking to verify someone is a member of the Thieves Guild you would use - PlayerRef.IsInFaction(ThievesguildFaction).

 

Like PeteMartyr told you.

 

If you are getting a return of false, when the player is a Member, you are doing something wrong or you have not progressed far enough into the quest line.

 

Post the script you are using.

Edited by Masterofnet
Link to comment
Share on other sites

It is my mistake. I should make it clear.

 

I don't have IsInFaction script to show you because I didn't actually use IsInFaction. Wiki says GetinFaction is the alternative command for console.(IsInFaction for papyrus in CK)

So I just test with GetInFaction in console only - player.GetInFaction 10A794 (10A794 is FactionID)

It returns 0 for my thief character(?) and returns 1 for other thieves guild NPC.

 

About quest progression, I just finished Scoundrel's Folly quest.(5th of 12 main quests). Maybe It is not far enough like you said.

 

--------------------------------------------------------------------------------------------------------------------------------------------

 

I updated my mod already but I want to know your opinion. So I can fix it If I do something wrong.

 

I learn from 2 mods. First, I look at the script from Shadowmarks by Arthmoor.

Arthmoor uses GetStageDone to check if the player is a member of the Thieves Guild AND the city has been brought under the influence of the Guild. - If ( TGTQ02.GetStageDone(200) == 1 )

So I think it should be a good idea to use GetStageDone for my mod too. I found the "welcome to the guild " stage in Loud and Clear quest. - If ( TG02.GetStageDone(20) == 1 )

 

Second, I look at the perk from No Furniture Activation When Sneaking by CDCooley because his mod can block activation.

CDCooley attaches perk to playeralias to block furniture activation if player is sneaking. (Screenshot below)

http://i.imgur.com/aUryiUB.png

 

http://i.imgur.com/DhHtbQx.png

 

--------------------------------------------------------------------------------------------------------------------------------------------

 

Finally, I combine the GetStageDone and perk idea. Here is the perk for my mod.

7wQ27Id.png

 

0Rsy0oo.png

 

It is working as intended. A Player can't activate shadowmarks if a player is not a member of the thieves guild.

http://i.imgur.com/wwodAEdm.jpg

http://i.imgur.com/bEBdwovm.jpg

Edited by azzendix
Link to comment
Share on other sites

I am not sure how your Perk is preventing someone who is not in the thieves guild from activating a Shadowmark. Your condition says quest stage 20 of tg02 is not done.

 

However. The player is added to the thieves guild faction when stage 10 of tg02 is set so that is what you would use. Also if the player kills a member they may be kicked out until they pay a fine. You don't want them using the marks during that time, so you need to use - get in faction.

 

Also keep in mind the big man used that perk to prevent the player from activating any activator when sneaking. In this case I would just use a block activation script on your shadow mark activator.

 

Bool Blocked

 

Event OnActivate(ObjectReference akActionRef)
If (akActionRef as actor).IsInFaction(thievesguildfaction)
If Blocked == True
Self.BlockActivation(False)
EndIf
;Display the message
else
If Blocked == False
Self.BlockActivation()
Blocked = True
EndIf
EndIf
EndEvent
Edited by Masterofnet
Link to comment
Share on other sites

It is my mistake. I should make it clear.

I updated my mod already but I want to know your opinion. So I can fix it If I do something wrong.

That all looks reasonable to me. And if it's working there's no reason to change it now. (Making changes to a mod people are already using can be tricky.)

 

Personally I would have done it without the perk by having the script on the activators enable them in the OnCellLoad event (assuming the original marks are still there too). I would also just use one single script for all of the activators (but that means manually filling the property which can be a pain). Just for future reference the script would look something like this:

ScriptName ShadowMarkForThievesOnlyScript extends ObjectReference

Message Property ShadowMark_Msg Auto  
Quest Property TG02 Auto

Event OnActivate(ObjectReference akActionRef)
    if Game.GetPlayer() == akActionRef()
        ShadowMark_Msg.Show()
    endif
EndEvent

Event OnCellLoad()
    if TG02.GetStageDone(20)
        Enable()
        GoToState("Ready")
    endif
EndEvent

State Ready
    Event OnCellLoad()
    EndEvent
EndState

Alternately I would have used a simpler version without the activation block by simply giving the activators a more descriptive name like "Loot Shadowmark" so I didn't even need to implement those message boxes.

 

 

 

Also if the player kills a member they may be kicked out until they pay a fine. You don't want them using the marks during that time, so you need to use - get in faction.

I don't see why getting kicked out of the guild would make you forget how to recognize the marks.

Link to comment
Share on other sites

 

I don't see why getting kicked out of the guild would make you forget how to recognize the marks.

 

 

He said being a member was a requirement. If they were kicked out they would no longer be a member. They kicked the person out and changed the meaning of the marks so only current members can read them.

 

I see no reason to use block activation either and I like the idea of disabling them unless the player is in the guild.

 

Also if you were going to use get stage done on tg02 it would be stage 10.

ScriptName ShadowMarkScript extends ObjectReference

Message Property ShadowMark Auto  
Faction Property Thievesguildfaction Auto
Actor Property PlayerRef Auto

Event OnActivate(ObjectReference akActionRef)
If PlayerRef == AkActionRef 
        ShadowMark.Show() ;Give information about valuable items.
EndIf
EndEvent

Event OnCellAttach()
If PlayerRef.IsInFaction(thievesguildfaction)
  If IsDisabled()
    Enable()
  EndIf
Else
  If IsDisabled()
  Else
    Disable()
  EndIf
EndIF
EndEvent



Edited by Masterofnet
Link to comment
Share on other sites

Wow... I wish I read all comments from both of you before I update my mod. That's so much better.

 

@cdcooley

I would also just use one single script for all of the activators (but that means manually filling the property which can be a pain).

 

I think about one script for all activator before but I decided to use 9 separate scripts because filling the property like that is not fun.(like you said)

At that moment, I don't even know I can finish this mod or not. I almost give up many times. So I go with the simpler method that can get things done.

 

 

@Masterofnet

Also if you were going to use get stage done on tg02 it would be stage 10.

 

I got your point. The game put a player in the Thieves guild faction after stage 10 but I refer to actual dialogues from Mercer and Brynjolf.

These dialogues are the reason I decided to use tg02 stage 20 as a condition.

Mercer Frey: Since Brynjolf assures me you'll be nothing but a benefit to us, then you're in. Welcome to the Thieves Guild. -- Mercer says this line before the end of stage 20.

Brynjolf: Welcome to the family, lad. I'm expecting you to make us a lot of coin, so don't disappoint me. -- Brynjolf says this line in the beginning of stage 30.

 

 

------------------------------------------------------------------------------

 

Edited: Move questions into the spoiler below.

Anyway, I don't have the plan to update mod anymore since you said it is not a good idea to do it.

Thank you PeterMartyr, Masterofnet, cdcooley.

 

 

 

I have some questions:

 

1. About updating mod, How do I know what is safe or not safe for updating my mod? Any guideline?

 

2. About scripting, Is there any way to check the name or ID of activator that scripts attach to?

EDIT: This is not the actual script. It is just a quick example for this question.

;This is just a quick example.

---ScriptName--- 

---Property--- 
Activator Property ShadowMarkCache auto
Activator Property ShadowMarkLoot auto
Activator Property ShadowMarkDanger auto
Activator Property ShadowMarkGuildMember auto

Event OnActivate
     If(AkActivator == ShadowMarkCache) then ShadowMarkCache_Msg.Show()
     If(AkActivator == ShadowMarkLoot) then ShadowMarkLoot_Msg.Show()
     If(AkActivator == ShadowMarkDanger) then ShadowMarkDanger_Msg.Show()
     If(AkActivator == ShadowMarkGuildMember) then ShadowMarkGuildMember_Msg.Show()
EndEvert

3. Does 9 separate scripts affects performance? (compare to one script for all activator.)

 

 

Edited by azzendix
Link to comment
Share on other sites

When updating you don't want to delete any objects or change script properties (although you can add properties to a script).

 

You could write a single script with all those properties and lots of conditions, but it would be inefficient for the game to run. The separate script you have now are better. The problem isn't really performance but memory. Multiple unused properties or multiple different scripts all take up extra memory. And every script name and property name gets stored in the game's string cache which means the fewer names the better. Although your mod only uses about a dozen so it's really not that important.

Link to comment
Share on other sites

  • Recently Browsing   0 members

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