Hi guys,
Yeh the models tricked me out for a bit. So the current script is still very much proof of concept and only works against 1 sconce at a time. Eventually I'll either make this a point and shoot target script for a spell called "LightSap" or I'll make it loop through a "for loop" multiple times to try and get all the surrounding torches in a small area. There really aren't ever that many Torch Sconces around your character at a single time. Here are the two scripts. One is a modifification of a beth script, and one is the Light Sap spell itself.
Scriptname mm_BeluaLightSapScript extends activemagiceffect Import DebugFormList Property mm_BeluaTorchList AutoEvent OnEffectStart(Actor akTarget, Actor akCaster);ObjectReference Function FindRandomReferenceOfAnyTypeInListFromRef(FormList arBaseObjectsA, ObjectReference arCenter, \ float afRadius) globalObjectReference torch = Game.FindRandomReferenceOfAnyTypeInListFromRef(mm_BeluaTorchList, akCaster, 200)Trace("Torch is " + torch)if torch != None Trace("Disabling torch") torch.DamageObject(1000.0) torch.DisableLinkChain() (torch as RemovableTorchSconce01SCRIPT).ExtinguishTorch()EndIfEndEventEvent OnEffectFinish(Actor akTarget, Actor akCaster)EndEventHere's the spell. I'm using a formlist to search for RemovableTorchSconces.
Here's the modified Beth script:
Scriptname RemovableTorchSconce01SCRIPT extends ObjectReference Hiddenimport debugLight Property Torch01 Auto{The Torch01 we look for in the players inventory}Activator Property RemovableTorch01 Auto{Base object for torch activator that gets placed}Light Property TorchOff AutoBool Property StartsEmpty Auto{If this is TRUE the sconce will start empty. Default = FALSE}Bool Property TorchInSconce = TRUE Auto Hidden{TRUE when there is a torch in the sonce, FALSE when there isn't. Default = TRUE}ObjectReference Property PlacedTorch Auto Hidden{A way to refer to the torch after it's been placed at the sconce}ObjectReference Property UnlitTorch Auto HiddenSound Property ITMGenericUp AutoSound Property ITMGenericDown AutoEVENT OnCellLoad();Trace("DARYL - " + self + "Cell Loaded")UnlitTorch.Disable()UnlitTorch.Delete()if (StartsEmpty == FALSE && !IsDisabled()) ;Trace("DARYL - " + self + "Should start with a torch in it") ; If this sconce is marked to start with a torch then place one in it if (PlacedTorch) ;Trace("DARYL - " + self + "A torch has been placed here before, lets simply enable it") PlacedTorch.Enable() else PlacedTorch = Self.PlaceAtMe(RemovableTorch01) ;Trace("DARYL - " + self + "A torch has never been placed here, lets place one as " + PlacedTorch) endif EnableLinkChain() GoToState("HasTorch")elseif (StartsEmpty == FALSE && IsDisabled()) ;STEVE - Special Case - Add a torch when this gets enabled and activated. ;Remove the old torch (if we had one) PlacedTorch.Disable() DisableLinkChain() ;Trace("STEVE - " + self + "Sconce is starting disabled, going to Awaiting Activation.") goToState("AwaitingActivation")else DisableLinkChain() ;Trace("DARYL - " + self + "Sconce is starting empty, going to NoTorch State") GoToState("NoTorch")endifEndEVENTFunction RemoveTorch()PlacedTorch.Disable()DisableLinkChain()GoToState("NoTorch")EndFunctionFunction ExtinguishTorch()if self.GetState() == "HasTorch" PlacedTorch.Disable() DisableLinkChain() Self.PlaceAtMe(TorchOff) GoToState("TorchExtinguished")EndIfEndFunctionState TorchExtinguishedEVENT onActivate(ObjectReference TriggerRef) GoToState("Busy") ;;Trace("DARYL - " + self + "Player has activated this sconce in the HasTorch State") PlacedTorch.Disable() DisableLinkChain() UnlitTorch = TriggerRef.AddItem(Torch01) int TorchTaken = ITMGenericUp.Play(self) ;;Trace("DARYL - " + self + "Disabling the torch, giving one to the player, and going into the Busy State") GoToState("NoTorch")EndEVENTEndStateSTATE HasTorchEVENT onActivate(ObjectReference TriggerRef) GoToState("Busy") ;;Trace("DARYL - " + self + "Player has activated this sconce in the HasTorch State") PlacedTorch.Disable() DisableLinkChain() TriggerRef.AddItem(Torch01) int TorchTaken = ITMGenericUp.Play(self) ;;Trace("DARYL - " + self + "Disabling the torch, giving one to the player, and going into the Busy State") GoToState("NoTorch")EndEVENTEndStateSTATE NoTorchEVENT onActivate(ObjectReference TriggerRef) ;;Trace("DARYL - " + self + "Player has activated the sconce in the NoTorch State") if TriggerRef.GetItemCount(Torch01) > 0 GoToState("Busy") ;;Trace("DARYL - " + self + "The player has " + (Game.GetPlayer()).GetItemCount(Torch01) + " torches, so lets place one") if (PlacedTorch) ;;Trace("DARYL - " + self + "A torch has been placed here before, lets simply enable it") PlacedTorch.Enable() else PlacedTorch = Self.PlaceAtMe(RemovableTorch01) ;;Trace("DARYL - " + self + "A torch has never been placed here, lets place one as " + PlacedTorch) endif TriggerRef.RemoveItem(Torch01) EnableLinkChain() int TorchPlaced = ITMGenericDown.Play(self) ;;Trace("DARYL - " + self + "The player now has" + (Game.GetPlayer()).GetItemCount(Torch01) + " torches after removing one") GoToState("HasTorch") endif EndEVENTEndStateSTATE Busy;Do NothingEndStateSTATE AwaitingActivationEvent OnActivate(ObjectReference obj) Self.Enable() OnCellLoad()EndEventEndStateTorchOff currently references a modified Light object, mm_BeluaTorch01. This object is a copy of Torch01 but the NIF points to Weapons\Torch\torch.nif and it's set to "Off by default". It's the only way I could get the off torch look with no light.
Hope that clarifies things a bit. I think you're right http://www.gamesas.com/user/764276-sluckyd/. I think I likely need to figure out the correct angle and rotation of the new torch dependent on the sconce's rotation. Ugh...maths.
-MM