Jump to content

Script Not Adding to Factions


GreatSilentOne

Recommended Posts

I have a script (which I'll paste below) which runs through a FormList of actors and adds them to the factions required to be followers and marriage partners. I know that the script is firing and executing the while loop properly, and yet the NPCs do not have the proper dialogue options. All NPCs have proper voice types (they're all Orcs) and the script sets their relationship rank to 4, so neither of those *should* be the issue.

 

Any help would be much appreciated.

Function setOrcFactions(FormList x, ObjectReference player, Faction potential, Faction current, Faction marriage) global
	; Sets population into marriage and follower factions. Also increases player relationship rank to 4

	int index = x.GetSize()

	while index ; The examples don't put parentheses, so I'm not either, even though it annoys me
		; Navigates location in FormList
		index -= 1

		Debug.MessageBox("In while loop")
		
		; Selects NPC held at the (index) location in the FormList
		Actor currentActor = x.GetAt(index) As Actor

		; Adds to factions
		currentActor.AddToFaction(potential)	; PotenitalFollower
		currentActor.AddToFaction(current)		; CurrentFollower
		currentActor.AddToFaction(marriage)	; PotentialMarriage

		; Current Follower requires rank of -1 until they are recruited
		currentActor.SetFactionRank(current, -1)

		; Make actor like player/player like actor. Rank 3 = will follow, rank 4 = will marry
		currentActor.SetRelationshipRank((player As Actor), 4)
		(player As Actor).SetRelationShipRank(currentActor, 4) ; Not always necessary, just a precaution

	endWhile
endFunction 
Link to comment
Share on other sites

Have you looked at their current faction reaction states? Reading up on AddToFaction noted that in some cases you need to setreaction as well. I haven't done much with the Orcs, so not sure if the orcs on your list are already "friendly" or if they may be in factions that might be opposed to the PlayerFaction.

 

another thought is if you have a relationship defined between the actor and the player in the CK. I am not sure what SetRelationshipRank will do if there is no defined relationship in place.

 

Not sure these are your problems, just a couple of thoughts I have that might help.

Link to comment
Share on other sites

The NPCs being modified are the orcs of the vanilla strongholds. They are not hostile/aggressive towards the player, but I'll give it a shot. As for the SetRelationshipRank, I know that it's possible to make any NPC with a valid voicetype a follower by adding them to the right factions and setting the relationship rank via console command, and the console commands just execute the Papyrus functions we use when we're programming in the CK.

 

Thanks for the suggestions, we'll see what comes of it.

Link to comment
Share on other sites

I've noticed really weird behavior when using SetFactionRank. It seems to fail silently if the faction was originally set in Skyrim.esm or by the ESP of some other mod. I ended up writing something like this to 'fix' the problem:



Function JoinFaction(Actor actorRef, Faction factionRef, int factionRank) global
actorRef.RemoveFromFaction(factionRef)
actorRef.SetFactionRank(factionRef, factionRank)
EndFunction

Link to comment
Share on other sites

Alright, so I think I've narrowed down the problem a bit further. Perhaps this will make it easier to solve.

 

The point of the mod is to allow the player to challenge orc chieftains to a duel, where winning makes the player the new chieftain. Obviously, the chieftain dies and the other orcs don't like this. I attempted a very poor solution (stopping the mourning quest) to see if that would fix it. Even though I removed the chieftain from the orc crime faction, set all of the orcs' relationship with the chief to 0, and placed the player in a "Special Combat" faction (which stops normal aggression from other NPCs), they persist with dialogue such as "Don't you have enough blood on your hands?" whenever I attempt to talk to them. So, this is presumably what's blocking the proper dialogue from appearing/the relationship from being properly set.

 

Any suggestions on this?

Link to comment
Share on other sites

You are probably still hitting some aspect of the crime system. Have you looked at reducing any crime values associated with the Orc CrimeFactions? You may also need to change the player's relationship with that specific crime faction.

 

Writing this, I would focus on one stronghold, look to see what crime faction the NPCs are set with and then have your script make that faction an ally of the Player specifically (not sure if you can do this, may can only adjust faction to faction relationships) and the PlayerFaction itself.

Link to comment
Share on other sites

All Orcs are in the same crime faction, aptly named "CrimeFactionOrcs." Since the script is removing the chieftain from every faction but the "JobOrcChieftain" faction (which I may or may not need him to remain in until after his death), I think the issue is related to another quest which handles NPC response to murder. I haven't found which quest this is to test that theory, however.

Link to comment
Share on other sites

Yes. Here's the Papyrus fragment that handles combat initiation, for reference (pardon the messy code, it's mostly from various debug attempts):

; Activates when player decides to initiate combat

if (Alias_CurrentTargetChief.GetActorReference().IsInFaction(MorKhazgurFac))
     Alias_CurrentTargetChief.GetActorReference().RemoveFromFaction(MorKhazgurFac)
elseif (Alias_CurrentTargetChief.GetActorReference().IsInFaction(DushnikhFac))
     Alias_CurrentTargetChief.GetActorReference().RemoveFromFaction(DushnikhFac)
elseif (Alias_CurrentTargetChief.GetActorReference().IsInFaction(NarzulburFac))
     Alias_CurrentTargetChief.GetActorReference().RemoveFromFaction(NarzulburFac)
elseif (Alias_CurrentTargetChief.GetActorReference().IsInFaction(LargashburFac))
     Alias_CurrentTargetChief.GetActorReference().RemoveFromFaction(LargashburFac)
endIf

Alias_CurrentTargetChief.GetActorReference().RemoveFromFaction(OrcCrimeFac)

FormList x = kmyQuest.determineFormList(Alias_CurrentTargetChief.GetActorReference())
int index = x.GetSize()

while index
     ; Sets all citizens of stronghold to 0 relationship with chieftain
     index -= 1
     (x.GetAt(index) As Actor).SetRelationshipRank(Alias_CurrentTargetChief.GetActorReference(), 0)
endWhile

Alias_Player.GetActorReference().AddToFaction(SpecialFac)
Alias_CurrentTargetChief.GetActorReference().StartCombat(Alias_Player.GetActorReference())

Edited by GreatSilentOne
Link to comment
Share on other sites

  • Recently Browsing   0 members

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