Skip to content

Instantly share code, notes, and snippets.

@fireundubh
Created July 5, 2017 01:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fireundubh/0e78a7050c3c4ec79753adbef4a36f94 to your computer and use it in GitHub Desktop.
Save fireundubh/0e78a7050c3c4ec79753adbef4a36f94 to your computer and use it in GitHub Desktop.
ScriptName dubhTrueNeutralWhiterunGuards Extends Quest
Formlist dubhWhiterunGuards Auto
Faction CWImperialFaction Auto
Faction CWImperialFactionNPC Auto
Faction CrimeFactionImperial Auto
Quest CWSiegeObj Auto
Bool Function CheckWhiterunBattle()
If CWSiegeObj.IsRunning()
If CWSiegeObj.GetStage() <= 1
Return True
EndIf
EndIf
If CWSiegeObj.GetStageDone() >= 8999
Return False
EndIf
If CWSiegeObj.IsCompleted()
Return False
EndIf
EndFunction
Bool Function ClearFaction(Actor akActor, Faction akFaction)
If akActor.IsInFaction(akFaction) == True
akActor.RemoveFromFaction(akFaction)
EndIf
Return akActor.IsInFaction(akFaction)
EndFunction
Function ResetGuards()
Int i = 0
While i < dubhWhiterunGuards.GetSize()
Actor currentGuard = dubhWhiterunGuards.GetAt(i)
ClearFaction(currentGuard, CWImperialFaction)
ClearFaction(currentGuard, CWImperialFactionNPC)
ClearFaction(currentGuard, CrimeFactionImperial)
i += 1
EndWhile
EndFunction
Bool Function ResetFaction(Actor akActor, Faction akFaction)
If akActor.IsInFaction(akFaction) == False
akActor.AddToFaction(akFaction)
EndIf
Return akActor.IsInFaction(akFaction)
EndFunction
Function MakeGuardsNeutral()
Int i = 0
While i < dubhWhiterunGuards.GetSize()
Actor currentGuard = dubhWhiterunGuards.GetAt(i)
ResetFaction(currentGuard, CWImperialFaction)
ResetFaction(currentGuard, CWImperialFactionNPC)
ResetFaction(currentGuard, CrimeFactionImperial)
i += 1
EndWhile
EndFunction
Event OnInit()
GoToState("Active")
EndEvent
Event OnPlayerLoadGame()
GoToState("Active")
EndEvent
State Active
Event OnBeginState()
RegisterForSingleUpdate(1.0)
EndEvent
Event OnUpdate()
If CheckWhiterunBattle()
MakeGuardsNeutral()
Else
ResetGuards()
EndIf
RegisterForSingleUpdate(1.0)
EndEvent
EndState
State Dead
EndState
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment