Done with this script. Posting it here in case it can help someone.
The script only runs at at night, from 8pm to 4am. The script will play 11 different spooky sounds at tandom times once player enters the area with the activator. And it will spawn a random number of undead with a slight chance of spawning a Dremora.
Scriptname TombsHaunted extends ObjectReference
import sound
import game
import utility
GlobalVariable property GameHour auto
Float Property NoEarlierThan = 20.0 Auto
Float Property NoLaterThan = 4.0 Auto
int random
int random1
int random2
int random3
int random4
int random5
int random6
int myNum
int myLoop
int timer
int instanceID00
ObjectReference property mySoundOrigin auto
ObjectReference Property dhLoc Auto
ObjectReference Property dhLo2 Auto
bool function IsTimeValid()
Float TT = GameHour.GetValue()
if TT > 13
if TT >= NoEarlierThan
return TRUE
endif
elseif TT <= NoLaterThan
return TRUE
endif
Return FALSE
endFunction
Event OnTrigger(ObjectReference akActionRef)
if (akActionRef == Game.GetPlayer())
if IsTimeValid()
random3 = Utility.RandomInt(1, 300)
random6 = Utility.RandomInt(2, 10)
if random3 < 2
random4 = Utility.RandomInt(1, 10)
if random4 > 5
dhLoc.PlaceAtMe (LivingDead , random6)
Debug.Notification("Ambush!")
instanceID00 = Zombie6TT.Play(Self)
Else
dhLo2.PlaceAtMe (LivingDead , random6)
Debug.Notification("Undead!!")
instanceID00 = Zombie6TT.Play(Self)
endif
random5 = Utility.RandomInt(1, 10)
if random5 > 7
dhLoc.PlaceAtMe (Warlock, 1)
endif
endif
if timer < 1
timer = Utility.RandomInt(5, 25)
random = Utility.RandomInt(1, 100)
if random < 21
random1 = Utility.RandomInt(1, 100)
if random1 < 8 && random1 > 0
instanceID00 = Zombie1TT.Play(Self)
elseif random1 < 15 && random1 > 8
instanceID00 = Zombie2TT.Play(Self)
elseif random1 < 20 && random1 > 15
instanceID00 = Zombie3TT.Play(Self)
elseif random1 < 30 && random1 > 20
instanceID00 = Zombie4TT.Play(Self)
elseif random1 < 40 && random1 > 30
instanceID00 = Zombie5TT.Play(Self)
elseif random1 < 50 && random1 > 40
instanceID00 = Zombie6TT.Play(Self)
elseif random1 < 60 && random1 > 50
instanceID00 = Zombie7TT.Play(Self)
elseif random1 < 70 && random1 > 60
instanceID00 = Zombie8TT.Play(Self)
elseif random1 < 80 && random1 > 70
instanceID00 = Zombie9TT.Play(Self)
elseif random1 < 90 && random1 > 80
instanceID00 = Zombie10TT.Play(Self)
elseif random1 <101 && random1 > 90
instanceID00 = Zombie11TT.Play(Self)
endif
endif
endif
endif
if timer >0
timer = timer - 1
endif
endif
EndEvent
Sound Property Zombie1TT Auto
Sound Property Zombie2TT Auto
Sound Property Zombie3TT Auto
Sound Property Zombie4TT Auto
Sound Property Zombie5TT Auto
Sound Property Zombie6TT Auto
Sound Property Zombie7TT Auto
Sound Property Zombie8TT Auto
Sound Property Zombie9TT Auto
Sound Property Zombie10TT Auto
Sound Property Zombie11TT Auto
ActorBase Property LivingDead Auto
Int Property random4 Auto
ActorBase Property Warlock Auto