Jump to content

[LE] Captive NPC getting up and walking away?


MesaSolar

Recommended Posts

NPC is in Captive Faction

Using SitTarget AI package linked to a ShackleWallMarker

 

ShackleWallMarker and NPC both linked to an Xmarker

 

But when I get too close to the NPC they just fall out of the shackles and stand up.

 

Need to do 2 things: 1st make them stay in the damn shackles and 2nd free them from the shackles after clicking on them.

 

Thoughts?

Link to comment
Share on other sites

I found this script in FO4 and wonder if it could be adjusted for skyrim?

 

Scriptname DefaultCaptiveActor extends Actor

;This script pops a message box when activating the prisoner
;if player frees, adds captors, himself, and prisoner to factions to make people hate each other
;You should make sure elsewhere that the captors have aggression high enough to attack their enemies
Group MainProperties
bool Property DisableOnUnload = false Auto Const
{after being freed, this actor will disable when unloaded}
bool Property AlsoRemoveFromCaptiveFaction = false Auto Const
{after being freed, this actor will also be removed from the CaptiveFaction
Use this for actors that will be attacked while fleeing}
int Property AggressionAfterFreed = -1 Auto Const
{freed actor will be set with this aggression}
EndGroup
Group SetStageProperties
Quest Property myQuest Auto
{ If this is set, set the stage on this quest if StageToSetWhenFreed is not -1
If myQuest is NOT set, it will try to set the stage on the owning quest}
int Property StageToSetWhenFreed = -1 auto const
{ this stage will be set when the prisoner is freed }
int Property StageToSetOnCleanUp = -1 Auto Const
{ this stage will be set when we try to clean up the actor }
bool Property bSetStageOnlyIfPlayerFreed = true auto const
{ false is always set stage when prisoner is freed }
EndGroup
Group CleanUpProperties
Float Property CleanUpTime = 180.0 Auto
{ Timer is started after freeing this prisoner, then once it has expired, clean up is viable when possible}
EndGroup
Group AutoFillProperties
Keyword Property RESharedDialoguePrisonerSetFree Auto const
Message Property REPrisonerMessageBox Auto const
Faction Property BoundCaptiveFaction Auto const
Faction Property CaptiveFaction Auto Const
RefCollectionAlias Property Captors Auto const
{ Try to get this from quest script REScript }
EndGroup
bool bound = True
int iDoNothing = 0
int iSetFree = 1
int iSetFreeShareItems = 2
int CleanupTimerID = 999
bool ReadyToCleanup = false
Event OnInit()
AddToFaction(BoundCaptiveFaction)
EndEvent
Event OnLoad()
if bound
; TODO when we have it
;playIdle(OffsetBoundStandingStart)
;DL added this for short term use
SetRestrained()
SetFactionRank(BoundCaptiveFaction, 0)
EndIf
RegisterForHitEvent(self, Game.GetPlayer())
EndEvent
Event OnUnload()
if DisableOnUnload && ReadyToCleanup
ClearFactions()
Disable()
DeleteWhenAble()
endif
EndEvent
Event OnTimer(int aiTimerID)
if aiTimerID == CleanupTimerID
ReadyToCleanup = true
endif
EndEvent
Event OnActivate(ObjectReference akActionRef)
if IsDead() || IsinCombat()
debug.trace(self + "OnActivate() IsDead() or IsInCombat() so not showing message box")
Elseif Bound == true
debug.trace(self + "OnActivate() will call show message box")
Actor ActorRef = self
int result = REPrisonerMessageBox.show()
if result == iDoNothing
debug.Notification("DO NOTHING")
elseif result == iSetFree
debug.Notification("SET FREE")
FreePrisoner(ActorRef, OpenPrisonerInventory = False)
elseif result == iSetFreeShareItems
debug.Notification("SET FREE SHARE ITEMS")
FreePrisoner(ActorRef, OpenPrisonerInventory = True)
EndIf
EndIf
EndEvent
Event OnHit(ObjectReference akTarget, ObjectReference akAggressor, Form akSource, Projectile akProjectile, bool abPowerAttack, bool abSneakAttack, bool abBashAttack, bool abHitBlocked, string asMaterialName)
if AkAggressor == game.getPlayer()
;Game.GetPlayer().AddToFaction(REPrisonerFreedCombatPrisonerFaction)
;AddRemoveCaptorFaction(REPrisonerFreedCombatCaptorFaction)
endif
RegisterForHitEvent(self, Game.GetPlayer())
endEvent
Function FreePrisoner(Actor ActorRef, bool playerIsLiberator= true, bool OpenPrisonerInventory = False)
debug.trace(self + "FreePrisoner(" + ActorRef + "," + playerIsLiberator + ", " + OpenPrisonerInventory +")")
ActorRef.SetFactionRank(BoundCaptiveFaction, 1)
if AlsoRemoveFromCaptiveFaction
ActorRef.RemoveFromFaction(CaptiveFaction)
endif
;DL added this for short term use
SetRestrained(false)
ActorRef.EvaluatePackage()
if playerIsLiberator
;Game.GetPlayer().AddToFaction(REPrisonerFreedCombatPrisonerFaction)
EndIf
if OpenPrisonerInventory
ActorRef.openInventory(True)
EndIf
ActorRef.SayCustom(RESharedDialoguePrisonerSetFree)
bound = False
;AddRemoveCaptorFaction(REPrisonerFreedCombatCaptorFaction)
if StageToSetWhenFreed > -1
if playerIsLiberator || bSetStageOnlyIfPlayerFreed == false
if myQuest
myQuest.SetStage(StageToSetWhenFreed)
else
;GetOwningQuest().SetStage(StageToSetWhenFreed)
endif
endif
endif
ActorRef.EvaluatePackage()
;Start The clean up timer, actor will not be clean up till after this
StartTimer(CleanUpTime, CleanupTimerID)
EndFunction
;call when quest shuts down
Function ClearFactions()
;Game.GetPlayer().RemoveFromFaction(REPrisonerFreedCombatPrisonerFaction)
RemoveFromFaction(BoundCaptiveFaction)
;TryToRemoveFromFaction(REPrisonerFreedCombatCaptorFaction)
;AddRemoveCaptorFaction(REPrisonerFreedCombatCaptorFaction, false)
if StageToSetOnCleanUp > -1
if bSetStageOnlyIfPlayerFreed == false
if myQuest
myQuest.SetStage(StageToSetOnCleanUp)
else
;GetOwningQuest().SetStage(StageToSetOnCleanUp)
endif
endif
endif
EndFunction

The only change I could see to make would be from this: RESharedDialoguePrisonerSetFree to

THIS: WESharedDialogue where WESharedDialogue is the dialogue used by freed captives. So I tried making that small adjustment and creating a new script but I go the following error message:

 

Starting 1 compile threads for 1 files...
Compiling "APWDefaultCaptiveActorScript"...
G:\Steam\steamapps\common\Skyrim Special Edition\Data\Source\Scripts\temp\APWDefaultCaptiveActorScript.psc(10,6): Unknown user flag Const
G:\Steam\steamapps\common\Skyrim Special Edition\Data\Source\Scripts\temp\APWDefaultCaptiveActorScript.psc(12,6): Unknown user flag Const
G:\Steam\steamapps\common\Skyrim Special Edition\Data\Source\Scripts\temp\APWDefaultCaptiveActorScript.psc(15,5): Unknown user flag Const
G:\Steam\steamapps\common\Skyrim Special Edition\Data\Source\Scripts\temp\APWDefaultCaptiveActorScript.psc(17,8): no viable alternative at input '\\r\\n'
G:\Steam\steamapps\common\Skyrim Special Edition\Data\Source\Scripts\temp\APWDefaultCaptiveActorScript.psc(23,5): Unknown user flag const
G:\Steam\steamapps\common\Skyrim Special Edition\Data\Source\Scripts\temp\APWDefaultCaptiveActorScript.psc(25,5): Unknown user flag Const
G:\Steam\steamapps\common\Skyrim Special Edition\Data\Source\Scripts\temp\APWDefaultCaptiveActorScript.psc(27,6): Unknown user flag const
G:\Steam\steamapps\common\Skyrim Special Edition\Data\Source\Scripts\temp\APWDefaultCaptiveActorScript.psc(30,8): no viable alternative at input '\\r\\n'
G:\Steam\steamapps\common\Skyrim Special Edition\Data\Source\Scripts\temp\APWDefaultCaptiveActorScript.psc(35,8): no viable alternative at input '\\r\\n'
G:\Steam\steamapps\common\Skyrim Special Edition\Data\Source\Scripts\temp\APWDefaultCaptiveActorScript.psc(38,9): Unknown user flag const
G:\Steam\steamapps\common\Skyrim Special Edition\Data\Source\Scripts\temp\APWDefaultCaptiveActorScript.psc(40,9): Unknown user flag const
G:\Steam\steamapps\common\Skyrim Special Edition\Data\Source\Scripts\temp\APWDefaultCaptiveActorScript.psc(41,9): Unknown user flag Const
G:\Steam\steamapps\common\Skyrim Special Edition\Data\Source\Scripts\temp\APWDefaultCaptiveActorScript.psc(43,20): Unknown user flag const
G:\Steam\steamapps\common\Skyrim Special Edition\Data\Source\Scripts\temp\APWDefaultCaptiveActorScript.psc(45,8): no viable alternative at input '\\r\\n'
G:\Steam\steamapps\common\Skyrim Special Edition\Data\Source\Scripts\temp\APWDefaultCaptiveActorScript.psc(115,0): mismatched input 'Function' expecting ENDEVENT
No output generated for APWDefaultCaptiveActorScript, compilation failed.
Batch compile of 1 files finished. 0 succeeded, 1 failed.
Failed on APWDefaultCaptiveActorScript
Link to comment
Share on other sites

SetRestrained() is the key here.

 

They need to be linked to the shackles and have SetRestrained() called so they stay put. To release them, SetRestrained(false) needs to be set in the OnActivate() event.

Do you mean to add that to the above script? Or make an entirely new one with just those two parameters?

Link to comment
Share on other sites

I managed to find WEPrisonerAliasScript and attached it to my NPC's alias. Autofilled the properties. This appears to be similar to what I found in FO4. But even with this attached nothing happens when I click on the NPC. Sometimes they even just fall out of the shackles after killing their "captor" So not sure what the problem is:

 

 

 

Scriptname WEPrisonerAliasScript extends ReferenceAlias
;This script pops a message box when activating the prisoner
;if player frees, adds captors, himself, and prisoner to factions to make people hate each other
;You should make sure elsewhere that the captors have aggression high enough to attack their enemies
Topic Property WESharedDialoguePrisonerSetFree Auto
idle Property OffsetBoundStandingStart Auto
idle Property OffsetStop Auto
Message Property WEPrisonerMessageBox Auto
Faction Property WEPrisonerFreedFaction Auto
Faction Property WEPrisonerFreedCombatCaptorFaction Auto
Faction Property WEPrisonerFreedCombatPrisonerFaction Auto
ReferenceAlias Property Captor1 Auto
ReferenceAlias Property Captor2 Auto
ReferenceAlias Property Captor3 Auto
ReferenceAlias Property Captor4 Auto
ReferenceAlias Property Captor5 Auto
bool bound = True
int iDoNothing = 0
int iSetFree = 1
int iSetFreeShareItems = 2
Event OnLoad()
if bound
GetActorReference().playIdle(OffsetBoundStandingStart)
EndIf
EndEvent
Event OnActivate(ObjectReference akActionRef)
if GetActorReference().IsDead() || GetActorReference().IsinCombat()
; debug.trace(self + "OnActivate() IsDead() or IsInCombat() so not showing message box")
Elseif Bound == true
; debug.trace(self + "OnActivate() will call show message box")
Actor ActorRef = GetActorReference()
int result = WEPrisonerMessageBox.show()
if result == iDoNothing
;debug.Notification("DO NOTHING")
elseif result == iSetFree
;debug.Notification("SET FREE")
FreePrisoner(ActorRef, OpenInventory = False)
elseif result == iSetFreeShareItems
;debug.Notification("SET FREE SHARE ITEMS")
FreePrisoner(ActorRef, OpenInventory = True)
EndIf
EndIf
EndEvent
Event OnHit(objectReference akAggressor, Form akSource, Projectile akProjectile, bool abPowerAttack, bool abSneakAttack, bool abBashAttack, bool abHitBlocked)
if AkAggressor == game.getPlayer()
Game.GetPlayer().AddToFaction(WEPrisonerFreedCombatPrisonerFaction)
Captor1.TryToAddToFaction(WEPrisonerFreedCombatCaptorFaction)
Captor2.TryToAddToFaction(WEPrisonerFreedCombatCaptorFaction)
Captor3.TryToAddToFaction(WEPrisonerFreedCombatCaptorFaction)
Captor4.TryToAddToFaction(WEPrisonerFreedCombatCaptorFaction)
Captor5.TryToAddToFaction(WEPrisonerFreedCombatCaptorFaction)
endif
endEvent
Function FreePrisoner(Actor ActorRef, bool playerIsLiberator= true, bool OpenInventory = False)
; debug.trace(self + "FreePrisoner(" + ActorRef + "," + playerIsLiberator + ", " + OpenInventory +")")
ActorRef.AddToFaction(WEPrisonerFreedFaction)
ActorRef.AddToFaction(WEPrisonerFreedCombatPrisonerFaction)
ActorRef.EvaluatePackage()
if playerIsLiberator
Game.GetPlayer().AddToFaction(WEPrisonerFreedCombatPrisonerFaction)
EndIf
if OpenInventory
ActorRef.openInventory(True)
EndIf
ActorRef.Say(WESharedDialoguePrisonerSetFree)
bound = False
Captor1.TryToAddToFaction(WEPrisonerFreedCombatCaptorFaction)
Captor2.TryToAddToFaction(WEPrisonerFreedCombatCaptorFaction)
Captor3.TryToAddToFaction(WEPrisonerFreedCombatCaptorFaction)
Captor4.TryToAddToFaction(WEPrisonerFreedCombatCaptorFaction)
Captor5.TryToAddToFaction(WEPrisonerFreedCombatCaptorFaction)
ActorRef.EvaluatePackage()
EndFunction
Function ClearFactions()
;call when quest shuts down
; debug.trace(self + "FreePrisoner")
Game.GetPlayer().RemoveFromFaction(WEPrisonerFreedCombatPrisonerFaction)
TryToRemoveFromFaction(WEPrisonerFreedCombatCaptorFaction)
Captor1.TryToRemoveFromFaction(WEPrisonerFreedCombatCaptorFaction)
Captor2.TryToRemoveFromFaction(WEPrisonerFreedCombatCaptorFaction)
Captor3.TryToRemoveFromFaction(WEPrisonerFreedCombatCaptorFaction)
Captor4.TryToRemoveFromFaction(WEPrisonerFreedCombatCaptorFaction)
Captor5.TryToRemoveFromFaction(WEPrisonerFreedCombatCaptorFaction)
EndFunction
Link to comment
Share on other sites

You keep mentioning "they just fall out of the shackles". Leads me to believe there is something set wrong with the havok in the placement..

So I checked "don't havok settle" and they stay in the shackles after killing their captor. Now the only thing I need to fix is getting the message box to pop up to free them from the shackles and get them to return to the quest giver.

Link to comment
Share on other sites

I seem to remember a quest involving the Thalmor. Maybe you are already aware of it. I forget the name. It was one where you had to go to a dinner party as a "spy". You end up freeing a NPC in the basement. It has pretty much everything you are looking to do in it.

Link to comment
Share on other sites

I seem to remember a quest involving the Thalmor. Maybe you are already aware of it. I forget the name. It was one where you had to go to a dinner party as a "spy". You end up freeing a NPC in the basement. It has pretty much everything you are looking to do in it.

Thank you so much! That finally fixed it!

Link to comment
Share on other sites

  • Recently Browsing   0 members

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