sortitus Posted March 3, 2010 Share Posted March 3, 2010 So, I've been running a personal modification of Arwen's ShadesFX that enabled the sunglasses effect on power armor helmets, but last night I decided to expand the script/effect and make a new mod just for the helmets. So, the very basic structure of this script is Arwen's, though hers is simpler. scn AdaptiveImageEnhancementScript short IsDayTime short EnableAIEIndoor short EnableAIEDay short EnableAIENight short DisableAIEIndoor short DisableAIEDay short DisableAIENight short aieEnabledIndoor short aieEnabledDay short aieEnabledNight begin GameMode if GameHour >5 && GameHour <20 set IsDayTime endif set EnableAIEIndoor imod AdaptIndoorSFX set aieEnabledIndoor set EnableAIEDay imod AdaptDaySFX set aieEnabledDay set EnableAIENight imod AdaptNightSFX set aieEnabledNight set DisableAIEIndoor rimod AdaptIndoorSFX set aieEnabledIndoor to 0 set DisableAIEDay rimod AdaptDaySFX set aieEnabledDay to 0 set DisableAIENight rimod AdaptNightSFX set aieEnabledNight to 0 end begin OnEquip(+effect that runs on cell changes) if IsInInterior !=1 DisableAIEIndoor if IsDayTime EnableAIEDay else EnableAIENight endif else if aieEnabledDay DisableAIEDay elseif aieEnabledNight DisableAIENight endif EnableAIEIndoor endif (need to do timing to this next bit) if IsInInterior !=1 && if aieEnabledIndoor DisableAIEIndoor else EnableAIEIndoor endif if IsDayTime && aieEnabledNight DisableAIENight EnableAIEDay elseif IsDayTime && DisableAIEDay EnableAIENight endif end begin OnUnequip player if aieEnabledIndoor DisableAIEIndoor elseif aieEnabledDay DisableAIEDay elseif aieEnabledNight DisableAIENight endif end begin OnDrop player if aieEnabledIndoor DisableAIEIndoor elseif aieEnabledDay DisableAIEDay elseif aieEnabledNight DisableAIENight endif end So, obviously the script doesn't work as is. How do I get this to make EnableAIEIndoor (and the other similar pieces) run imod ... set ... when it's referenced? I can remove those functions and manually imod and set each time they're referenced if the GECK and FOSE don't allow them. Are there blocktypes that run on cell change? I'm aware of OnLoad, but I don't know if that does what I want, and quickly cycling between cells will bypass it (though I think my script is smart enough to at least change at the next timed update if that happens). I'm under the impression that when using "if (x)" and it ==1, the ==1 is not needed. Is that correct? *headasplode* EDIT: I got a working version, but I can't get the timer to work inside the OnEquip block. Is it possible?Operational Code:scn AdaptiveImageEnhancementScript short IsDayTime short aieEnabledIndoor short aieEnabledDay short aieEnabledNight float TimedUpdate short StartTimer begin GameMode if (GameHour - 5) <15 set IsDayTime to 1 endif end begin OnEquip if StartTimer if TimedUpdate >0 set TimedUpdate to TimedUpdate - GetSecondsPassed else if IsInInterior if aieEnabledIndoor else if aieEnabledDay rimod AdaptDaySFX set aieEnabledDay to 0 elseif aieEnabledNight rimod AdaptNightSFX set aieEnabledNight to 0 endif imod AdaptIndoorSFX set aieEnabledIndoor to 1 endif else if aieEnabledIndoor rimod AdaptIndoorSFX set aieEnabledIndoor to 0 endif if IsDayTime if aieEnabledDay else if aieEnabledNight rimod AdaptNightSFX set aieEnabledNight to 0 endif imod AdaptDaySFX set aieEnabledDay to 1 endif else if aieEnabledNight else if aieEnabledDay rimod AdaptDaySFX set aieEnabledDay to 0 endif imod AdaptNightSFX set aieEnabledNight to 1 endif endif endif endif else set TimedUpdate to 2 set StartTimer to 1 endif end begin OnUnequip player rimod AdaptIndoorSFX rimod AdaptDaySFX rimod AdaptNightSFX set aieEnabledIndoor to 0 set aieEnabledDay to 0 set aieEnabledNight to 0 end begin OnDrop player rimod AdaptIndoorSFX rimod AdaptDaySFX rimod AdaptNightSFX set aieEnabledIndoor to 0 set aieEnabledDay to 0 set aieEnabledNight to 0 end Link to comment Share on other sites More sharing options...
Khet Posted March 5, 2010 Share Posted March 5, 2010 OnEquip only runs when the object is equipped, and then it isn't run again until the next equip action. A better choice for timers and if the item is equipped would be this: Player.getEquipped ITEMID Run it in a GameMode block. It'll constantly check if the ITEMID is equipped to the player, and thus update any timers. Link to comment Share on other sites More sharing options...
sortitus Posted March 6, 2010 Author Share Posted March 6, 2010 Ok, I ran getEquipped inside a GameMode, but it added the effect on every frame. if IsDay if aieEnabledDay else rimod AdaptIndoorSFX rimod AdaptNightSFX set aieEnabledIndoor to 0 set aieEnabledNight to 0 imod AdaptDaySFX set aieEnabledDay to 1 if aieEnabled else set aieEnabled to 1 endif endif endif I was testing during the day, and I think this is the only place the problem could be, but here's the complete new code just in case.scn AdaptiveImageEnhancementScript short IsNight short IsTwilight short IsDay short aieEnabled short aieEnabledIndoor short aieEnabledDay short aieEnabledNight begin GameMode if player.GetEquipped AdaptiveImageEnhancementList if GameHour >=20 if GameHour <=4.5 set IsNight to 1 endif elseif GameHour <=6 if GameHour >=18.5 set IsDay to 1 endif else set IsTwilight to 1 endif if IsInInterior if aieEnabledIndoor else rimod AdaptDaySFX rimod AdaptNightSFX set aieEnabledDay to 0 set aieEnabledNight to 0 imod AdaptIndoorSFX set aieEnabledIndoor to 1 if aieEnabled else set aieEnabled to 1 endif endif else if IsDay if aieEnabledDay else rimod AdaptIndoorSFX rimod AdaptNightSFX set aieEnabledIndoor to 0 set aieEnabledNight to 0 imod AdaptDaySFX set aieEnabledDay to 1 if aieEnabled else set aieEnabled to 1 endif endif elseif IsTwilight if aieEnabledIndoor else rimod AdaptDaySFX rimod AdaptNightSFX set aieEnabledDay to 0 set aieEnabledNight to 0 imod AdaptIndoorSFX set aieEnabledIndoor to 1 if aieEnabled else set aieEnabled to 1 endif endif else if aieEnabledNight else rimod AdaptDaySFX rimod AdaptIndoorSFX set aieEnabledDay to 0 set aieEnabledIndoor to 0 imod AdaptNightSFX set aieEnabledNight to 1 if aieEnabled else set aieEnabled to 1 endif endif endif endif elseif aieEnabled rimod AdaptIndoorSFX rimod AdaptDaySFX rimod AdaptNightSFX set aieEnabledIndoor to 0 set aieEnabledDay to 0 set aieEnabledNight to 0 set aieEnabled to 0 endif endThanks for the help so far! Link to comment Share on other sites More sharing options...
Dyadya_Fedor Posted March 6, 2010 Share Posted March 6, 2010 This one should workscn AdaptiveImageEnhancementScript short IsNight short IsTwilight short IsDay short aieEnabled short aieEnabledIndoor short aieEnabledDay short aieEnabledNight begin GameMode if player.GetEquipped AdaptiveImageEnhancementList if GameHour >= 20 || GameHour <= 4.5 set IsNight to 1 set IsDay to 0 set IsTwilight to 0 elseif GameHour >= 6 && GameHour <= 18.5 set IsNight to 0 set IsDay to 1 set IsTwilight to 0 else set IsNight to 0 set IsDay to 0 set IsTwilight to 1 endif if Player.IsInInterior if aieEnabledIndoor else rimod AdaptDaySFX rimod AdaptNightSFX imod AdaptIndoorSFX set aieEnabledDay to 0 set aieEnabledNight to 0 set aieEnabledIndoor to 1 set aieEnabled to 1 endif else if IsDay if aieEnabledDay else rimod AdaptIndoorSFX rimod AdaptNightSFX imod AdaptDaySFX set aieEnabledIndoor to 0 set aieEnabledNight to 0 set aieEnabledDay to 1 set aieEnabled to 1 endif elseif IsTwilight if aieEnabledIndoor else rimod AdaptDaySFX rimod AdaptNightSFX imod AdaptIndoorSFX set aieEnabledDay to 0 set aieEnabledNight to 0 set aieEnabledIndoor to 1 set aieEnabled to 1 endif else if aieEnabledNight else rimod AdaptDaySFX rimod AdaptIndoorSFX imod AdaptNightSFX set aieEnabledDay to 0 set aieEnabledIndoor to 0 set aieEnabledNight to 1 set aieEnabled to 1 endif endif endif elseif aieEnabled rimod AdaptIndoorSFX rimod AdaptDaySFX rimod AdaptNightSFX set aieEnabledIndoor to 0 set aieEnabledDay to 0 set aieEnabledNight to 0 set aieEnabled to 0 endif end And "optimized" onescn AdaptiveImageEnhancementScript short Period short aieEnabled begin GameMode if player.GetEquipped AdaptiveImageEnhancementList if GameHour >= 20 || GameHour <= 4.5 set Period to 1 ;Night elseif GameHour >= 6 && GameHour <= 18.5 set Period to 2 ;Day else set Period to 3 ;Twilight endif if Player.IsInInterior if aieEnabled != 4 rimod AdaptDaySFX rimod AdaptNightSFX imod AdaptIndoorSFX set aieEnabled to 4 endif else if Period == 2 && aieEnabled != 1 rimod AdaptIndoorSFX rimod AdaptNightSFX imod AdaptDaySFX set aieEnabled to 1 elseif Period == 3 && aieEnabled != 2 rimod AdaptDaySFX rimod AdaptNightSFX imod AdaptIndoorSFX set aieEnabled to 2 elseif Period == 1 && aieEnabled != 3 rimod AdaptDaySFX rimod AdaptIndoorSFX imod AdaptNightSFX set aieEnabled to 3 endif endif elseif aieEnabled rimod AdaptIndoorSFX rimod AdaptDaySFX rimod AdaptNightSFX set aieEnabled to 0 endif end Link to comment Share on other sites More sharing options...
sortitus Posted March 6, 2010 Author Share Posted March 6, 2010 Hmm... the first one applies the effect on every frame just like my version, but the second one has that problem sometimes on waiting and time of day changes. I even got a crash on the second one, though I'm not sure how related it was. I see that I had my times reversed and had an and instead of an or for the daytime. :P I'm attaching the ESP in case you'd like to test it yourself. The imods are set to be more obvious for troubleshooting in this version, and I'm using the optimized script. Also, Tortoiseshell Glasses are in the power armor helmet list since none of my current saves have training. Man, my first script has not turned out so well. :verymad: Maybe I should have tried something a little easier first. I do have a question about the structure of the script. Would it be better to put the Period check inside the else block after IsInterior? I don't think that this would change how it works at all, but would make it a little lighter weight when not outside? Eg. if Player.IsInInterior... else [i][b]if GameHour >= 20 || GameHour <= 4.5 set Period to 1 ;Night elseif GameHour >= 6 && GameHour <= 18.5 set Period to 2 ;Day else set Period to 3 ;Twilight endif[/b][/i] if (whattime)... endif endif Link to comment Share on other sites More sharing options...
Dyadya_Fedor Posted March 6, 2010 Share Posted March 6, 2010 I don't think that this would change how it works at all, but would make it a little lighter weight when not outside?AFAIK, in this case perfomance impact imperceptible, but yes, a little. I forgotted, what there are many helmets around, thereby many instances of script is running. There is several solutions1) You can attach this script to all helmetsscn AdaptiveImageEnhancementScript short Period short aieEnabled short Equipped begin OnEquip Player set Equipped to 1 end begin OnUnequip Player set Equipped to 0 end begin GameMode if Equipped if Player.IsInInterior if aieEnabled != 4 rimod AdaptDaySFX rimod AdaptNightSFX imod AdaptIndoorSFX set aieEnabled to 4 endif else if GameHour >= 20 || GameHour <= 4.5 set Period to 1 ;Night elseif GameHour >= 6 && GameHour <= 18.5 set Period to 2 ;Day else set Period to 3 ;Twilight endif if Period == 2 && aieEnabled != 1 rimod AdaptIndoorSFX rimod AdaptNightSFX imod AdaptDaySFX set aieEnabled to 1 elseif Period == 3 && aieEnabled != 2 rimod AdaptDaySFX rimod AdaptNightSFX imod AdaptIndoorSFX set aieEnabled to 2 elseif Period == 1 && aieEnabled != 3 rimod AdaptDaySFX rimod AdaptIndoorSFX imod AdaptNightSFX set aieEnabled to 3 endif endif elseif aieEnabled rimod AdaptIndoorSFX rimod AdaptDaySFX rimod AdaptNightSFX set aieEnabled to 0 endif endor2) You can create empty armor with Playable flag unchecked with this scriptscn AdaptiveImageEnhancementScript short Period short aieEnabled begin GameMode if player.GetEquipped AdaptiveImageEnhancementList if Player.IsInInterior if aieEnabled != 4 rimod AdaptDaySFX rimod AdaptNightSFX imod AdaptIndoorSFX set aieEnabled to 4 endif else if GameHour >= 20 || GameHour <= 4.5 set Period to 1 ;Night elseif GameHour >= 6 && GameHour <= 18.5 set Period to 2 ;Day else set Period to 3 ;Twilight endif if Period == 2 && aieEnabled != 1 rimod AdaptIndoorSFX rimod AdaptNightSFX imod AdaptDaySFX set aieEnabled to 1 elseif Period == 3 && aieEnabled != 2 rimod AdaptDaySFX rimod AdaptNightSFX imod AdaptIndoorSFX set aieEnabled to 2 elseif Period == 1 && aieEnabled != 3 rimod AdaptDaySFX rimod AdaptIndoorSFX imod AdaptNightSFX set aieEnabled to 3 endif endif elseif aieEnabled rimod AdaptIndoorSFX rimod AdaptDaySFX rimod AdaptNightSFX set aieEnabled to 0 endif endand add it to player (or create quest with this script). No need to modify original helmets (as long as they in AdaptiveImageEnhancementList) Link to comment Share on other sites More sharing options...
sortitus Posted March 7, 2010 Author Share Posted March 7, 2010 The first one works perfectly! Big Kudos! I had been mixing some stuff into your suggestions, but nothing worked, so I was ready to go back to my old version that required an unequip/equip to change imods. You'll get full credits on the mod when I release it, which should be some time in the next 72 hours. Thanks lots and lots and lots! :D Link to comment Share on other sites More sharing options...
Recommended Posts