Script to have npc extinguish torch if sneaking

Post » Thu Jun 21, 2012 12:14 pm

Yeah, ok, then I'm going to make this standalone. I have a brilliant and funny idea for a video...tomorrow...:D
User avatar
Kristina Campbell
 
Posts: 3512
Joined: Sun Oct 15, 2006 7:08 am

Post » Wed Jun 20, 2012 11:21 pm

Figured out why they weren't equipping torches after standing up. Was a lysdexic mishap which wasn't replacing the dummy torches with real ones.

http://www.mediafire.com/?idublkhba380dh6 seems to be working as planned, all with aliases. The vanilla followers shouldn't need the note given to them, but it's still there for up to ten mod added followers.

Spoiler
  • Quest
    ScriptName DisallowTorchQuestScript extends QuestActor rChickenBool bFiltersAppliedFloat fVersion = 1.00FormList Property DisallowTorchFilterFLST AutoLight Property Torch01 AutoMiscObject Property DisallowTorchMISC AutoReferenceAlias[] Property AliasArray AutoEvent OnInit()	If !rChicken		Utility.Wait(3)		rChicken = AliasArray[1].GetActorReference()		rChicken.SetScale(0)		rChicken.EnableAI(False)		rChicken.Enable()		RegisterForUpdate(5)	EndIfEndEventEvent OnUpdate()	If bGetGameLoaded()		If fVersion < 1.00			fVersion = 1.00		EndIf		If !bFiltersApplied			bFiltersApplied = True			Int iIndex = 45			While (iIndex > 0)				iIndex -= 1				AliasArray[iIndex].AddInventoryEventFilter(DisallowTorchFilterFLST)			EndWhile		EndIf		CheckAliases()		DisallowTorchMISC.SetWeight(Torch01.GetWeight())	EndIfEndEventFunction CheckAliases(Int aiIndex = 45)	While (aiIndex > 2)		aiIndex -= 1		(AliasArray[aiIndex] As DisallowTorchActorAliasScript).CheckSelf()	EndWhileEndFunctionBool Function bGetGameLoaded()	If rChicken.GetActorValue("BrainCondition")		rChicken.SetActorValue("BrainCondition", 0)		Return True	Else		Return False	EndIfEndFunction
  • Player Alias
    ScriptName DisallowTorchPlayerAliasScript extends ReferenceAliasDisallowTorchQuestScript Property QuestScript AutoEvent OnLocationChange(Location akOldLoc, Location akNewLoc)	Utility.Wait(5)	QuestScript.CheckAliases()EndEvent
  • Follower Alias
    ScriptName DisallowTorchActorAliasScript extends ReferenceAliasBool bDisallowTorchInt iTorchCountLight Property Torch01 AutoMiscObject Property DisallowTorchMISC AutoReferenceAlias Property TorchContainerAlias AutoDisallowTorchQuestScript Property QuestScript AutoEvent OnObjectEquipped(Form akBaseObject, ObjectReference akReference)	If akBaseObject == Torch01		RegisterForUpdate(1)	EndIfEndEventEvent OnUpdate()	If bDisallowTorch != (GetActorReference().IsSneaking() || GetActorReference().IsDoingFavor())		bDisallowTorch = !bDisallowTorch		If bDisallowTorch			iTorchCount = GetActorReference().GetItemCount(Torch01)			GetActorReference().RemoveItem(Torch01, iTorchCount, True, TorchContainerAlias.GetReference())			GetActorReference().AddItem(DisallowTorchMISC, iTorchCount, True)		Else			GetActorReference().RemoveItem(DisallowTorchMISC, iTorchCount, True)			TorchContainerAlias.GetReference().RemoveItem(Torch01, iTorchCount, True, GetActorReference())			UnregisterForUpdate()		EndIf	EndIfEndEventEvent OnItemAdded(Form akBaseItem, Int aiItemCount, ObjectReference akItemReference, ObjectReference akSourceContainer)	If bDisallowTorch		If akBaseItem == Torch01			GetActorReference().RemoveItem(akBaseItem, aiItemCount, True, TorchContainerAlias.GetReference())			GetActorReference().AddItem(DisallowTorchMISC, aiItemCount, True)			iTorchCount += aiItemCount		EndIf	ElseIf akBaseItem == DisallowTorchMISC		GetActorReference().RemoveItem(akBaseItem, aiItemCount, True)		GetActorReference().AddItem(Torch01, aiItemCount, True)	EndIfEndEventEvent OnItemRemoved(Form akBaseItem, Int aiItemCount, ObjectReference akItemReference, ObjectReference akDestContainer)	If bDisallowTorch		If akBaseItem == DisallowTorchMISC			akDestContainer.RemoveItem(DisallowTorchMISC, aiItemCount, True)			TorchContainerAlias.GetReference().RemoveItem(Torch01, aiItemCount, False, akDestContainer)			iTorchCount -= aiItemCount		EndIf	ElseIf akBaseItem == Torch01		iTorchCount -= aiItemCount	EndIfEndEventFunction CheckSelf()	If !GetActorReference()	ElseIf GetActorReference().GetParentCell() != Game.GetPlayer().GetParentCell() || !GetActorReference().IsPlayerTeammate()		UnregisterForUpdate()	ElseIf GetActorReference().IsSneaking() || GetActorReference().GetEquippedItemType(0) == 11 || GetActorReference().IsDoingFavor()		RegisterForUpdate(1)	EndIfEndFunction
  • Note
    ScriptName DisallowTorchNoteScript extends ObjectReferenceBook Property DisallowTorchBOOK AutoDisallowTorchQuestScript Property QuestScript AutoFormList Property DisallowTorchFilterFLST AutoMiscObject Property DisallowTorchMISC AutoEvent OnContainerChanged(ObjectReference akNewContainer, ObjectReference akOldContainer)	If akNewContainer As Actor 		If (akNewContainer As Actor).IsInFaction(Game.GetForm(0x0005C84D) As Faction)		ElseIf akNewContainer != Game.GetPlayer()			Int iIndex = 45			While (iIndex < 55)				iIndex += 1				ReferenceAlias rAlias = QuestScript.AliasArray[iIndex]				If rAlias.GetActorReference() == akNewContainer As Actor					iIndex = 55				ElseIf !rAlias.GetActorReference()					rAlias.ForceRefTo(akNewContainer)					rAlias.AddInventoryEventFilter(DisallowTorchFilterFLST)					(rAlias As DisallowTorchActorAliasScript).CheckSelf()				EndIf			EndWhile			akNewContainer.RemoveItem(DisallowTorchBOOK, 1, False, akOldContainer)		EndIf	EndIfEndEvent
Oh. Only one container now that's also the GetGameLoaded actor and skipped the FLST with Torch01Shadow as it doesn't seem to be used.
User avatar
Deon Knight
 
Posts: 3363
Joined: Thu Sep 13, 2007 1:44 am

Previous

Return to V - Skyrim