diff --git a/Separate NPC disabler.esp b/Separate NPC disabler.esp new file mode 100644 index 00000000..89593220 Binary files /dev/null and b/Separate NPC disabler.esp differ diff --git a/scripts/_00E_MQ12b_NPCControl.pex b/scripts/_00E_MQ12b_NPCControl.pex new file mode 100644 index 00000000..2de173ad Binary files /dev/null and b/scripts/_00E_MQ12b_NPCControl.pex differ diff --git a/scripts/_00e_mq12b_functions.pex b/scripts/_00e_mq12b_functions.pex index 7d8c4c4c..c4516e95 100644 Binary files a/scripts/_00e_mq12b_functions.pex and b/scripts/_00e_mq12b_functions.pex differ diff --git a/scripts/pf_mq12b_sc11_stayputscript_0013390a.pex b/scripts/pf_mq12b_sc11_stayputscript_0013390a.pex index 9923a9ac..76d98836 100644 Binary files a/scripts/pf_mq12b_sc11_stayputscript_0013390a.pex and b/scripts/pf_mq12b_sc11_stayputscript_0013390a.pex differ diff --git a/scripts/pf_mq12b_sc3_genericcitizenf_0011b0c8.pex b/scripts/pf_mq12b_sc3_genericcitizenf_0011b0c8.pex index aeda8ff6..ee3bee09 100644 Binary files a/scripts/pf_mq12b_sc3_genericcitizenf_0011b0c8.pex and b/scripts/pf_mq12b_sc3_genericcitizenf_0011b0c8.pex differ diff --git a/scripts/pf_mq12b_sc3_guardfleepkg_0011b0cc.pex b/scripts/pf_mq12b_sc3_guardfleepkg_0011b0cc.pex index 47766a4c..435878b7 100644 Binary files a/scripts/pf_mq12b_sc3_guardfleepkg_0011b0cc.pex and b/scripts/pf_mq12b_sc3_guardfleepkg_0011b0cc.pex differ diff --git a/scripts/pf_mq12b_sc3_normalcitizench_00046f24.pex b/scripts/pf_mq12b_sc3_normalcitizench_00046f24.pex index 7998550b..ce552be0 100644 Binary files a/scripts/pf_mq12b_sc3_normalcitizench_00046f24.pex and b/scripts/pf_mq12b_sc3_normalcitizench_00046f24.pex differ diff --git a/scripts/pf_mq12b_sc3_normalcitizenfl_0011b0cb.pex b/scripts/pf_mq12b_sc3_normalcitizenfl_0011b0cb.pex index 9f28ed7b..5e99c6be 100644 Binary files a/scripts/pf_mq12b_sc3_normalcitizenfl_0011b0cb.pex and b/scripts/pf_mq12b_sc3_normalcitizenfl_0011b0cb.pex differ diff --git a/scripts/pf_mq12b_sc3_normalcitizenfl_0011b181.pex b/scripts/pf_mq12b_sc3_normalcitizenfl_0011b181.pex index 81b21b9e..f86a65c6 100644 Binary files a/scripts/pf_mq12b_sc3_normalcitizenfl_0011b181.pex and b/scripts/pf_mq12b_sc3_normalcitizenfl_0011b181.pex differ diff --git a/scripts/pf_mq12b_sc4_citizenfleepkgl_0011b182.pex b/scripts/pf_mq12b_sc4_citizenfleepkgl_0011b182.pex index 87763ee7..dcb732f8 100644 Binary files a/scripts/pf_mq12b_sc4_citizenfleepkgl_0011b182.pex and b/scripts/pf_mq12b_sc4_citizenfleepkgl_0011b182.pex differ diff --git a/scripts/pf_mq12b_sc4_guardsandboxmar_0011b180.pex b/scripts/pf_mq12b_sc4_guardsandboxmar_0011b180.pex index e9dbbfef..12a1697f 100644 Binary files a/scripts/pf_mq12b_sc4_guardsandboxmar_0011b180.pex and b/scripts/pf_mq12b_sc4_guardsandboxmar_0011b180.pex differ diff --git a/source/scripts/_00E_MQ12b_NPCControl.psc b/source/scripts/_00E_MQ12b_NPCControl.psc new file mode 100644 index 00000000..427ab6ec --- /dev/null +++ b/source/scripts/_00E_MQ12b_NPCControl.psc @@ -0,0 +1,111 @@ +Scriptname _00E_MQ12b_NPCControl extends Quest Hidden + +; 2.1, Eddoursul: Moved disabling NPCs to a separate quest + +Actor[] RegisteredDisabledNPCs +Int nRegisteredDisabledNPCs +Bool bDisabledNPCsLocked +Actor[] RegisteredGhostedNPCs +Int nRegisteredGhostedNPCs +Bool bGhostedNPCsLocked + +function OnInit() + RegisteredDisabledNPCs = New Actor[128] + nRegisteredDisabledNPCs = 0 + RegisteredGhostedNPCs = New Actor[128] + nRegisteredGhostedNPCs = 0 +endfunction + +; Queue an NPC +Function PrepareNPC(Actor akMoveActor, Bool bOnlyGhost = False) + If MQ12b.bArkUnderAttackPrelude == False + Return + EndIf + + ; Validate akMoveActor, could receive "nullptr form" instead of a valid actor from the packages + If akMoveActor == None || akMoveActor.GetActorBase() == None + Return + EndIf + + If bOnlyGhost == False && RegisteredDisabledNPCs.Find(akMoveActor) < 0 + If akMoveActor.IsDisabled() + Return + EndIf + + if SKSE.GetVersion() + if akMoveActor.GetEnableParent() == None + akMoveActor.DisableNoWait() + _RegisterDisabledNPC(akMoveActor) + return + endif + else + akMoveActor.Disable() + if akMoveActor.IsDisabled() + _RegisterDisabledNPC(akMoveActor) + return + endif + endif + EndIf + + If RegisteredGhostedNPCs.Find(akMoveActor) < 0 && akMoveActor.IsGhost() == False && ! akMoveActor.IsDisabled() + akMoveActor.SetGhost(True) + _RegisterGhostedNPC(akMoveActor) + EndIf +EndFunction + +Function _RegisterDisabledNPC(Actor akMoveActor) + if nRegisteredDisabledNPCs + 1 <= 128 + RegisteredDisabledNPCs[nRegisteredDisabledNPCs] = akMoveActor + nRegisteredDisabledNPCs += 1 + Debug.Trace("Registered disabled " + akMoveActor.GetBaseObject().GetName() + " " + (akMoveActor as String)) + else + ; Added overflow to the ghosted + _RegisterGhostedNPC(akMoveActor) + endif +EndFunction + +Function _RegisterGhostedNPC(Actor akMoveActor) + if nRegisteredGhostedNPCs + 1 <= 128 + RegisteredGhostedNPCs[nRegisteredGhostedNPCs] = akMoveActor + nRegisteredGhostedNPCs += 1 + Debug.Trace("Registered ghosted " + akMoveActor.GetBaseObject().GetName() + " " + (akMoveActor as String)) + else + ; oh well + endif +EndFunction + +Function ReEnableNPCs() + MQ12b.bArkUnderAttackPrelude = false + bool bSKSE = SKSE.GetVersion() as bool + + int Index = RegisteredDisabledNPCs.length + While Index > 0 + Index -= 1 + Actor akActor = RegisteredDisabledNPCs[Index] + if akActor != None && ( ! bSKSE || akActor.GetEnableParent() == None ) + akActor.EnableNoWait() + Debug.Trace("Re-enabled: " + akActor.GetActorBase().GetName()) + RegisteredDisabledNPCs[Index] = None + endif + EndWhile + + RegisteredDisabledNPCs = New Actor[1] + + Index = RegisteredGhostedNPCs.length + While Index > 0 + Index -= 1 + Actor akActor = RegisteredGhostedNPCs[Index] + if akActor != None + if akActor.IsDisabled() && ( ! bSKSE || akActor.GetEnableParent() == None ) + akActor.EnableNoWait() + endif + akActor.SetGhost(False) + Debug.Trace("Unghosted: " + akActor.GetActorBase().GetName()) + RegisteredGhostedNPCs[Index] = None + endif + EndWhile + + RegisteredGhostedNPCs = New Actor[1] +EndFunction + +_00E_MQ12b_Functions Property MQ12b Auto diff --git a/source/scripts/_00e_mq12b_functions.psc b/source/scripts/_00e_mq12b_functions.psc index 1401f498..6ae7a374 100644 --- a/source/scripts/_00e_mq12b_functions.psc +++ b/source/scripts/_00e_mq12b_functions.psc @@ -2,148 +2,17 @@ Scriptname _00E_MQ12b_Functions extends Quest Conditional Import Utility -;===================================================================================== -; GENERAL FUNCTIONS -;===================================================================================== - Int CurScriptVersion = 0 Int Property LATEST_SCRIPT_VERSION = 2 AutoReadOnly -Actor[] RegisteredDisabledNPCs -Int nRegisteredDisabledNPCs -Bool bDisabledNPCsLocked -Actor[] RegisteredGhostedNPCs -Int nRegisteredGhostedNPCs -Bool bGhostedNPCsLocked - -Function PrepareNPC(Actor akMoveActor, Bool bOnlyGhost = False) - If bArkUnderAttackPrelude == False - Return - EndIf - - ; Validate akMoveActor, could receive "nullptr form" instead of a valid actor from the packages - If akMoveActor == None || akMoveActor.GetActorBase() == None - Return - EndIf - - If akMoveActor.IsDisabled() - Return - EndIf - - If bOnlyGhost == False && akMoveActor.GetEnableParent() == None - akMoveActor.Disable() - _RegisterDisabledNPC(akMoveActor) - Return - EndIf - - If akMoveActor.IsGhost() == False - akMoveActor.SetGhost(True) - _RegisterGhostedNPC(akMoveActor) - Return - EndIf -EndFunction - -Function _RegisterDisabledNPC(Actor akMoveActor) - While bDisabledNPCsLocked - Utility.WaitMenuMode(0.1) - EndWhile - - bDisabledNPCsLocked = True - - If RegisteredDisabledNPCs.Length == 0 ; Version update - RegisteredDisabledNPCs = New Actor[128] - nRegisteredDisabledNPCs = 0 - EndIf - If RegisteredDisabledNPCs.Find(akMoveActor) < 0 - If nRegisteredDisabledNPCs >= RegisteredDisabledNPCs.Length - Debug.Notification("MQ12b has problems: reached the limit of stored disabled NPCs") - Else - RegisteredDisabledNPCs[nRegisteredDisabledNPCs] = akMoveActor - nRegisteredDisabledNPCs += 1 - EndIf - EndIf - - bDisabledNPCsLocked = False -EndFunction - -Function _RegisterGhostedNPC(Actor akMoveActor) - While bGhostedNPCsLocked - Utility.WaitMenuMode(0.1) - EndWhile - - bGhostedNPCsLocked = True - - If RegisteredGhostedNPCs.Length == 0 ; Version update - RegisteredGhostedNPCs = New Actor[128] - nRegisteredGhostedNPCs = 0 - EndIf - If RegisteredGhostedNPCs.Find(akMoveActor) < 0 - If nRegisteredGhostedNPCs >= RegisteredGhostedNPCs.Length - Debug.Notification("MQ12b has problems: reached the limit of stored ghosted NPCs") - Else - RegisteredGhostedNPCs[nRegisteredGhostedNPCs] = akMoveActor - nRegisteredGhostedNPCs += 1 - EndIf - EndIf - - bGhostedNPCsLocked = False -EndFunction - -Function ReEnableNPCs() - Int Index - ObjectReference ref - - Index = 0 - While Index < nRegisteredDisabledNPCs - RegisteredDisabledNPCs[Index].EnableNoWait() - RegisteredDisabledNPCs[Index] = None - Index += 1 - EndWhile - - RegisteredDisabledNPCs = New Actor[1] - - Index = 0 - While Index < nRegisteredGhostedNPCs - RegisteredGhostedNPCs[Index].SetGhost(False) - RegisteredGhostedNPCs[Index] = None - Index += 1 - EndWhile - - RegisteredGhostedNPCs = New Actor[1] - - ; Old ways of enabling NPCs, for backward compatibility - OldReenableDisabledNPC() - If CurScriptVersion == 0 - _00E_Func_ReferenceFormList.Enable(MQ12b_SC11_NPCsRef) - - MQ12b_SiegeNPCs.Revert() - - OldRemoveGhostFlag() - EndIf -EndFunction - -Function OldReenableDisabledNPC() ; For version updates with CurScriptVersion < 2 - If CurScriptVersion < 2 - _00E_Func_ReferenceFormList.Enable(MQ12b_AllDisabledNPCs) - EndIf -EndFunction - -Function OldRemoveGhostFlag() ; For version updates with CurScriptVersion == 0 - If CurScriptVersion == 0 && Self.IsCompleted() == 1 - int Index = MQ12b_UnGhostNPCs_OnVersionUpdate1580.GetSize() - While Index > 0 - Index -= 1 - (MQ12b_UnGhostNPCs_OnVersionUpdate1580.GetAt(Index) as Actor).SetGhost(False) - EndWhile - EndIf -EndFunction - ;===================================================================================== ; FUNCTIONS ;===================================================================================== Function SetUp() + CurScriptVersion = LATEST_SCRIPT_VERSION + iCrimeGoldBeforeMQ12bNonViolent = A_CrimeFaction.GetCrimeGoldNonViolent() iCrimeGoldBeforeMQ12bViolent = A_CrimeFaction.GetCrimeGoldViolent() @@ -168,12 +37,6 @@ Function SetUp() Ordenshueter.GetReference().MoveTo(MQ12b_SC1_Orderguard01) Ordenshueterin.GetReference().MoveTo(MQ12b_SC1_Orderguard02) - CurScriptVersion = LATEST_SCRIPT_VERSION - RegisteredDisabledNPCs = New Actor[128] - nRegisteredDisabledNPCs = 0 - RegisteredGhostedNPCs = New Actor[128] - nRegisteredGhostedNPCs = 0 - bArkUnderAttackPrelude = True SkyrimOvercastRain.SetActive(True) @@ -462,6 +325,8 @@ EndFunction Function StartSC07() + bArkUnderAttackPrelude = False ; stop disabling NPCs + _00E_Func_SetNPCAsCompanion.SetNPCAsCompanion(_00E_MC_TealorREF, False) SetObjectiveCompleted(10) @@ -918,7 +783,7 @@ Function CompleteQuestAndStartMQ12c() MQ12b_SC6_NehrimeseGateLinker.Disable() Ark_MyradRef.MoveToMyEditorLocation() MQ12b_DisableThisDudeHeIsAnnoyingREF.Enable() - bArkUnderAttackPrelude = False + bArkUnderAttackPrelude = False ; also disabled earlier in StartSC07() bArkUnderAttack = False bArkUnderAttackFinalScene = False Weather.ReleaseOverride() @@ -935,14 +800,15 @@ Function CompleteQuestAndStartMQ12c() _00E_EPHandler.GiveEP(__Config_RewardEXP) AllowIdleChatter.SetValue(1) Self.CompleteQuest() - ReEnableNPCs() DisablePanicTriggerbox() MQ12c.SetCurrentStageID(5) GoToState("Aftermath") RegisterForSingleUpdateGameTime(24) - + Steam.UnlockAchievement("END_SIEGE_01") - + + SiegeNPCControl.ReEnableNPCs() + EndFunction Function DisablePanicTriggerbox() ;extra function because it gets also called from _00E_PlayerSetUpScript @@ -977,22 +843,23 @@ EndFunction State WaitForNight -Event OnBeginState() + Event OnBeginState() - TimeScale.SetValue(100) - RegisterForSingleUpdate(5) - -EndEvent + TimeScale.SetValue(100) + RegisterForSingleUpdate(5) + + EndEvent -Event OnUpdate() + Event OnUpdate() - If (GameHour.GetValue() <= 4 || GameHour.GetValue() >= 21) - TimeScale.SetValue(0.1) - Else - RegisterForSingleUpdate(5) - EndIf - -EndEvent + If (GameHour.GetValue() <= 4 || GameHour.GetValue() >= 21) + TimeScale.SetValue(0.1) + GoToState("") + Else + RegisterForSingleUpdate(5) + EndIf + + EndEvent EndState @@ -1305,3 +1172,5 @@ EffectShader Property BerserkerFXS Auto _00E_GypsyMinstrelsControlScript Property GypsyMinstrelsControl Auto Perk Property _00E_ArkSiegeLockedGatesPerk Auto + +_00E_MQ12b_NPCControl Property SiegeNPCControl Auto diff --git a/source/scripts/pf_mq12b_sc11_stayputscript_0013390a.psc b/source/scripts/pf_mq12b_sc11_stayputscript_0013390a.psc index 1a468b72..263f6546 100644 --- a/source/scripts/pf_mq12b_sc11_stayputscript_0013390a.psc +++ b/source/scripts/pf_mq12b_sc11_stayputscript_0013390a.psc @@ -5,11 +5,11 @@ Scriptname PF_MQ12b_SC11_StayPutScript_0013390A Extends Package Hidden ;BEGIN FRAGMENT Fragment_0 Function Fragment_0(Actor akActor) ;BEGIN CODE -MQ12b.PrepareNPC(akActor, True) +SiegeNPCControl.PrepareNPC(akActor, True) ;END CODE EndFunction ;END FRAGMENT ;END FRAGMENT CODE - Do not edit anything between this and the begin comment -_00E_MQ12b_Functions Property MQ12b Auto +_00E_MQ12b_NPCControl Property SiegeNPCControl Auto diff --git a/source/scripts/pf_mq12b_sc3_genericcitizenf_0011b0c8.psc b/source/scripts/pf_mq12b_sc3_genericcitizenf_0011b0c8.psc index b568f216..b5d63f36 100644 --- a/source/scripts/pf_mq12b_sc3_genericcitizenf_0011b0c8.psc +++ b/source/scripts/pf_mq12b_sc3_genericcitizenf_0011b0c8.psc @@ -5,12 +5,12 @@ Scriptname PF_MQ12b_SC3_GenericCitizenF_0011B0C8 Extends Package Hidden ;BEGIN FRAGMENT Fragment_0 Function Fragment_0(Actor akActor) ;BEGIN CODE -MQ12b.PrepareNPC(akActor, True) +SiegeNPCControl.PrepareNPC(akActor, True) ;END CODE EndFunction ;END FRAGMENT ;END FRAGMENT CODE - Do not edit anything between this and the begin comment -_00E_MQ12b_Functions Property MQ12b Auto +_00E_MQ12b_NPCControl Property SiegeNPCControl Auto diff --git a/source/scripts/pf_mq12b_sc3_guardfleepkg_0011b0cc.psc b/source/scripts/pf_mq12b_sc3_guardfleepkg_0011b0cc.psc index 4b3cac09..c7a356c3 100644 --- a/source/scripts/pf_mq12b_sc3_guardfleepkg_0011b0cc.psc +++ b/source/scripts/pf_mq12b_sc3_guardfleepkg_0011b0cc.psc @@ -5,11 +5,11 @@ Scriptname PF_MQ12b_SC3_GuardFleePkg_0011B0CC Extends Package Hidden ;BEGIN FRAGMENT Fragment_0 Function Fragment_0(Actor akActor) ;BEGIN CODE -MQ12b.PrepareNPC(akActor, True) +SiegeNPCControl.PrepareNPC(akActor, True) ;END CODE EndFunction ;END FRAGMENT ;END FRAGMENT CODE - Do not edit anything between this and the begin comment -_00E_MQ12b_Functions Property MQ12b Auto +_00E_MQ12b_NPCControl Property SiegeNPCControl Auto diff --git a/source/scripts/pf_mq12b_sc3_normalcitizench_00046f24.psc b/source/scripts/pf_mq12b_sc3_normalcitizench_00046f24.psc index 626a3b40..94e1e81d 100644 --- a/source/scripts/pf_mq12b_sc3_normalcitizench_00046f24.psc +++ b/source/scripts/pf_mq12b_sc3_normalcitizench_00046f24.psc @@ -5,11 +5,11 @@ Scriptname PF_MQ12b_SC3_NormalCitizenCh_00046F24 Extends Package Hidden ;BEGIN FRAGMENT Fragment_0 Function Fragment_0(Actor akActor) ;BEGIN CODE -MQ12b.PrepareNPC(akActor, True) +SiegeNPCControl.PrepareNPC(akActor, True) ;END CODE EndFunction ;END FRAGMENT ;END FRAGMENT CODE - Do not edit anything between this and the begin comment -_00E_MQ12b_Functions Property MQ12b Auto +_00E_MQ12b_NPCControl Property SiegeNPCControl Auto diff --git a/source/scripts/pf_mq12b_sc3_normalcitizenfl_0011b0cb.psc b/source/scripts/pf_mq12b_sc3_normalcitizenfl_0011b0cb.psc index 74a6d670..7a61fe54 100644 --- a/source/scripts/pf_mq12b_sc3_normalcitizenfl_0011b0cb.psc +++ b/source/scripts/pf_mq12b_sc3_normalcitizenfl_0011b0cb.psc @@ -5,11 +5,11 @@ Scriptname PF_MQ12b_SC3_NormalCitizenFl_0011B0CB Extends Package Hidden ;BEGIN FRAGMENT Fragment_0 Function Fragment_0(Actor akActor) ;BEGIN CODE -MQ12b.PrepareNPC(akActor) +SiegeNPCControl.PrepareNPC(akActor) ;END CODE EndFunction ;END FRAGMENT ;END FRAGMENT CODE - Do not edit anything between this and the begin comment -_00E_MQ12b_Functions Property MQ12b Auto +_00E_MQ12b_NPCControl Property SiegeNPCControl Auto diff --git a/source/scripts/pf_mq12b_sc3_normalcitizenfl_0011b181.psc b/source/scripts/pf_mq12b_sc3_normalcitizenfl_0011b181.psc index 930384e9..637994e3 100644 --- a/source/scripts/pf_mq12b_sc3_normalcitizenfl_0011b181.psc +++ b/source/scripts/pf_mq12b_sc3_normalcitizenfl_0011b181.psc @@ -5,11 +5,11 @@ Scriptname PF_MQ12b_SC3_NormalCitizenFl_0011B181 Extends Package Hidden ;BEGIN FRAGMENT Fragment_0 Function Fragment_0(Actor akActor) ;BEGIN CODE -MQ12b.PrepareNPC(akActor) +SiegeNPCControl.PrepareNPC(akActor) ;END CODE EndFunction ;END FRAGMENT ;END FRAGMENT CODE - Do not edit anything between this and the begin comment -_00E_MQ12b_Functions Property MQ12b Auto +_00E_MQ12b_NPCControl Property SiegeNPCControl Auto diff --git a/source/scripts/pf_mq12b_sc4_citizenfleepkgl_0011b182.psc b/source/scripts/pf_mq12b_sc4_citizenfleepkgl_0011b182.psc index bc899a34..72b4facd 100644 --- a/source/scripts/pf_mq12b_sc4_citizenfleepkgl_0011b182.psc +++ b/source/scripts/pf_mq12b_sc4_citizenfleepkgl_0011b182.psc @@ -5,11 +5,11 @@ Scriptname PF_MQ12b_SC4_CitizenFleePkgL_0011B182 Extends Package Hidden ;BEGIN FRAGMENT Fragment_0 Function Fragment_0(Actor akActor) ;BEGIN CODE -MQ12b.PrepareNPC(akActor) +SiegeNPCControl.PrepareNPC(akActor) ;END CODE EndFunction ;END FRAGMENT ;END FRAGMENT CODE - Do not edit anything between this and the begin comment -_00E_MQ12b_Functions Property MQ12b Auto +_00E_MQ12b_NPCControl Property SiegeNPCControl Auto diff --git a/source/scripts/pf_mq12b_sc4_guardsandboxmar_0011b180.psc b/source/scripts/pf_mq12b_sc4_guardsandboxmar_0011b180.psc index d84a7f93..0a19b768 100644 --- a/source/scripts/pf_mq12b_sc4_guardsandboxmar_0011b180.psc +++ b/source/scripts/pf_mq12b_sc4_guardsandboxmar_0011b180.psc @@ -5,11 +5,11 @@ Scriptname PF_MQ12b_SC4_GuardSandboxMar_0011B180 Extends Package Hidden ;BEGIN FRAGMENT Fragment_0 Function Fragment_0(Actor akActor) ;BEGIN CODE -MQ12b.PrepareNPC(akActor, True) +SiegeNPCControl.PrepareNPC(akActor, True) ;END CODE EndFunction ;END FRAGMENT ;END FRAGMENT CODE - Do not edit anything between this and the begin comment -_00E_MQ12b_Functions Property MQ12b Auto +_00E_MQ12b_NPCControl Property SiegeNPCControl Auto