Finally got my water arrow script to work properly and I'm starting to think it's slow and inefficient and want to improve it.
What it does is place an activator where an arrow hits, the activator then checks for light sources and light emitting objects(torch, campfire etc) and disables both, then places the off object. Clean up happens after a set amount of time has passed and the player re-enters the cell or the activator doesn't engage with anything. There are a few main parts, I have removed duplicate entries but left the properties to give you an idea of how many there are so far.
Spoiler
Scriptname AceWaterArrowScript extends ObjectReference
Float TimePassed
Actor Property PlayerRef Auto
;replacement object for doused light objects
Static Property TorchOff Auto
Static Property FireOutSmall Auto
Static Property FireOut Auto
Static Property Campfire01Off Auto
Static Property Campfire01LandOffDirt01 Auto
Static Property Campfire01LandOffRiverbedEdge01 Auto
Static Property Campfire01LandOffCoastBeach Auto
Static Property Campfire01LandOffReachDirt Auto
Static Property Campfire01LandOffRocks01 Auto
;lists that have moveable static light objects
Formlist Property LightSourceList Auto
Formlist Property PermTorchList Auto
Formlist Property FireEmberList Auto
Formlist Property FireEmberSpecialList Auto
Formlist Property AceCampfire01BurningList Auto
Formlist Property AceCampfire01LandBurningList Auto
Formlist Property AceCampfire01LandBurningRiverBedEdge01List Auto
Formlist Property AceCampfire01LandBurningCoastalBeach01List Auto
Formlist Property AceCampfire01LandBurningReachDirt01List Auto
Formlist Property AceCampfire01LandBurningRocks01List Auto
;References for pointing to the new object that is inplace of the old light object
ObjectReference PlacedTorch1
ObjectReference PlacedEmber1
ObjectReference PlacedEmber2
ObjectReference PlacedCampFire01
ObjectReference PlacedCampFireLand
ObjectReference PlacedCampFireRiver
ObjectReference PlacedCampFireCoast
ObjectReference PlacedCampFireReach
ObjectReference PlacedCampFireRocks
Event OnInIt()
TimePassed = Utility.GetCurrentGameTime()
;Checks for nearest X and sets them to the object reference
ObjectReference LightSource = Game.FindClosestReferenceOfAnyTypeInListFromRef(LightSourceList, Self, 180)
;The swapping of objects and disabling the lightsource
If TorchObject1 == True
PlacedTorch1 = TorchObject1.PlaceAtMe(TorchOff)
Float TorchScale = TorchObject1.GetScale()
PlacedTorch1.SetScale(TorchScale)
Utility.Wait(0.6)
LightSource.Disable()
TorchObject1.Disable()
EndIf
EndEvent
;Clean up checking
Event OnCellLoad()
Float NewTime = Utility.GetCurrentGameTime()
If NewTime > (TimePassed+0.1)
CleanUp()
EndIf
EndEvent
State Active
Function CleanUp()
;
EndFunction
EndState
Function CleanUp()
;Same as above, checks for the references.
ObjectReference LightSource = Game.FindClosestReferenceOfAnyTypeInListFromRef(LightSourceList, Self, 200)
LightSource.Enable()
;Enables old, disables new and then deletes everything leaving nothing behind.
If TorchObject1 == True
PlacedTorch1.Disable()
TorchObject1.Enable()
PlacedTorch1.Delete()
EndIf
;Final clean up, removes the activator itself last.
Self.Disable()
Self.Delete()
;Debug.Notification("Enabled")
EndFunction
I can't add a script to movable statics to register an OnHit event so this was the only other option I could think of. I still need to add candles and lamps(any others?) which will further slow this down.
Any ideas?