2024-02-21 16:00:29 +00:00
|
|
|
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
|
|
|
|
|
2024-02-21 16:41:16 +00:00
|
|
|
If bOnlyGhost == False
|
|
|
|
If RegisteredDisabledNPCs.Find(akMoveActor) >= 0 || akMoveActor.IsDisabled()
|
2024-02-21 16:00:29 +00:00
|
|
|
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)
|
2024-02-21 16:41:16 +00:00
|
|
|
int iSlot = nRegisteredDisabledNPCs
|
|
|
|
if iSlot + 1 <= 128
|
2024-02-21 16:00:29 +00:00
|
|
|
nRegisteredDisabledNPCs += 1
|
2024-02-21 16:41:16 +00:00
|
|
|
RegisteredDisabledNPCs[iSlot] = akMoveActor
|
2024-02-21 16:00:29 +00:00
|
|
|
Debug.Trace("Registered disabled " + akMoveActor.GetBaseObject().GetName() + " " + (akMoveActor as String))
|
|
|
|
else
|
|
|
|
; Added overflow to the ghosted
|
|
|
|
_RegisterGhostedNPC(akMoveActor)
|
|
|
|
endif
|
|
|
|
EndFunction
|
|
|
|
|
|
|
|
Function _RegisterGhostedNPC(Actor akMoveActor)
|
2024-02-21 16:41:16 +00:00
|
|
|
int iSlot = nRegisteredGhostedNPCs
|
|
|
|
if iSlot + 1 <= 128
|
2024-02-21 16:00:29 +00:00
|
|
|
nRegisteredGhostedNPCs += 1
|
2024-02-21 16:41:16 +00:00
|
|
|
RegisteredGhostedNPCs[iSlot] = akMoveActor
|
2024-02-21 16:00:29 +00:00
|
|
|
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
|