I am trying to implement a mod where it provides lightning during storm weather and have hooked into the game using a quest (which auto starts) and then check if it is raining. The problem I have is that a light rain doesn't really justify a lightning strike and I am not sure how to check the level of the rain. I know from playing the game for over 700 hours! (I know I am sad, but I love this game) that the weather does play in what seems different stages (light rain, heavy rain, etc) but how to detect this within my quest is unknown to me at the moment?
Can anyone give me some pointers as to detecting the rain stage? Maybe explain the transition stuff as I presume the 1.0 means we are moving to another weather type?
I would also appreciate if someone can check my usage of RegisterForSingleUpdate rather than using RegisterForUpdate as this concerns me due to the comments on the Wiki regarding save game bloat!? I certainly do not want to corrupt any save games etc!?
The quest I have setup is as follows:-
Spoiler
Scriptname MintyQuestScript extends Quest{Place holder to hook into weather system}import debugimport gameimport weather; External propertiesSpell Property ForkLightningSpell AutoSpell Property SheetLightningSpell Auto; Variablesbool initalised = falseEvent OnInit()if (!initalised) ; seems OnInit can be called twice! RegisterForSingleUpdate(1) initalised = trueendifEndEventEvent OnUpdate()if (IsOutsideWithFullSky() && IsWeatherRaining() && !IsWeatherTransitioning()) if (Utility.RandomInt(0, 10) > 5) ForkLightningSpell.Cast(getPlayer(), None) else SheetLightningSpell.Cast(getPlayer(), None) endifendifRegisterForSingleUpdate(20)endEventbool Function IsOutsideWithFullSky() Globalreturn (GetSkyMode() == 3) ; int SKYMODE_FULL = 3EndFunctionbool Function IsWeatherRaining() Globalreturn (GetCurrentWeather().GetClassification() == 2) ; int WEATHER_RAINING = 2EndFunctionbool Function IsWeatherTransitioning() Globalreturn !(Weather.GetCurrentWeatherTransition() == 1.0)EndFunctionAnother issue I am having is how to place actors within the worldspace, basically what I am trying to achieve is sheet lightning and as such am trying to place two invisible actors (source and target) to allow me to cast a visual lightning effect within the sky (but not hitting the ground). I guessed this would be simply placing two actors, moving them, and then scripting the RemoteCast between the two but either I don't see the effect or the lightning hits the ground. Is it possible to have spells cast this way?
The script behind the lightning strike is as follows (taken mostly from the VoiceStormCall script)
Spoiler
Scriptname MintySheetLightningScript extends activemagiceffectimport weatherimport utilityimport gameimport debug;======================================================================================;; PROPERTIES /;=============/Float Property fStartDelayRand = 0.0 auto{Random Value added to the fDelay (Default = 0.0)}Float Property fHeight = 1000.0 auto{From how high in the sky should the spell be cast? (Default = 3584.0)}Float Property fXYBaseRandom = 1500.0 auto{Moves the casting point a random amount up to this value before first cast. Also is the size of the area we aim for on "Miss" shots. (Default = 1500.0)}Float Property fPOSRandom = 512.0 auto{We move the casting point by up to this amount each time we fire (Default = 512.0)}Float Property fDelay = 2.0 auto{Base Delay at start of spell (Default = 2.0)}Float Property fRecast = 1.0 auto{How long before we recast the spell? (Default = 1.0)}Float Property fRecastRand = 0.0 auto{Add Some random time to the recast! (Default = 0.0)}activator property PlacedActivator auto{The name of the placed Activator that the spell will come from. (REQUIRED!)}activator property PlacedTargetActivator auto{The name of the placed Activator we aiming at for missing (REQUIRED! if missing)}Spell property SpellRef auto{The name of the Spell the Sky will cast. (REQUIRED!)}GlobalVariable Property MAGProjectileStormVar auto;======================================================================================;; VARIABLES /;=============/objectReference ActivatorRefobjectReference ActivatorTargetRefbool KeepUpdating = TrueActor CasterActorActor TargetActorFloat PosXFloat PosYFloat PosZFloat TPosXFloat TPosYFloat TPosZFloat fTDistanceobjectReference CastFromHereRefbool bHasSound = Falsebool bHasImod = Falsebool bCasterIsPlayer = falseActor player;======================================================================================;; EVENTS /;=============/Event OnInit() player = GetPlayer()EndEventEvent OnEffectStart(Actor Target, Actor Caster) Notification("Casting Sheet Lightning") ; Add the recast and randomizer to build the random range. fRecastRand = fRecastRand + fRecast MAGProjectileStormVar.setValue(1.0) ;We need this global for the Clear Skys shout to stop all Projectile Storms. TargetActor = Target CasterActor = Caster CastFromHereRef = TargetActor ActivatorRef = CastFromHereRef.placeAtMe(PlacedActivator) PosX = CastFromHereRef.GetPositionX() + RandomFloat(-fXYBaseRandom,fXYBaseRandom) PosY = CastFromHereRef.GetPositionY() + RandomFloat(-fXYBaseRandom,fXYBaseRandom) PosZ = CastFromHereRef.GetPositionZ() ActivatorTargetRef = Target.placeAtMe(PlacedTargetActivator) ; Miss onPurpose PosZ = (PosZ + fHeight) ActivatorRef.SetPosition(PosX,PosY,PosZ) RegisterForSingleUpdate(fDelay + RandomFloat(0.0,fStartDelayRand))EndEventEvent OnUpdate()if MAGProjectileStormVar.GetValue() == 1.0 if (TargetActor.GetParentCell() != none) if (ActivatorRef.GetParentCell() != none) if SpellRef != none if true TPosX = player.GetPositionX() + RandomFloat(-fXYBaseRandom,fXYBaseRandom) TPosY = player.GetPositionY() + RandomFloat(-fXYBaseRandom,fXYBaseRandom) TPosZ = (player.GetPositionZ() + fHeight) else TPosX = TargetActor.GetPositionX() + RandomFloat(-fXYBaseRandom,fXYBaseRandom) TPosY = TargetActor.GetPositionY() + RandomFloat(-fXYBaseRandom,fXYBaseRandom) TPosZ = TargetActor.GetPositionZ() endif ActivatorTargetRef.SetPosition(TPosX,TPosY,PosZ) ActivatorRef.SetPosition(PosX,PosY,PosZ) SpellRef.RemoteCast(ActivatorRef,CasterActor,ActivatorTargetRef) if KeepUpdating == True RegisterForSingleUpdate(RandomFloat(fRecast,fRecastRand)) endif Endif Endif else KeepUpdating = false if (ActivatorRef != none) ActivatorRef.disable() ActivatorRef.delete() endif if (ActivatorTargetRef != none) ActivatorTargetRef.disable() ActivatorTargetRef.delete() endif EndIfendifendEventEvent OnEffectFinish(Actor Target, Actor Caster);Notification("Ending Sheet Lightning")KeepUpdating = falseif (ActivatorRef != none) ActivatorRef.disable() ActivatorRef.delete()endifif (ActivatorTargetRef != none) ActivatorTargetRef.disable() ActivatorTargetRef.delete()endifEndEventAny pointers to parts of the Wiki / tutorials / or in game scripts are much appreciated.
Thanks for your time ;o)
P.S. Sorry for the indenting but I did try to follow the post for help guidelines and tried [xml]. [code], etc and this was the best I could get with posting from notepad++
