Zorkaz Posted December 1, 2020 Share Posted December 1, 2020 I'm currently creating a frozen wasteland, therefore I'm creating a simple cold/warm system. Now some weather would be extra cold, like a blizzard. But how would you approach a system that regularily checks if the weather's good or bad? I mean obviously a while() script would work, but maybe there's something more elegant and efficient Link to comment Share on other sites More sharing options...
DieFeM Posted December 1, 2020 Share Posted December 1, 2020 (edited) I guess you could use some combination of magic effects and/or spells with cloaks and conditions, but it looks like a nightmare to setup. So if you end up going by the script route I would suggest using a recursive timer instead of a while loop. Event SomeEvent() StartTimer(5) EndEvent Event OnTimer(Int aiTimerID) // Do Weather Checks here // and call a new timer (recurrency) StartTimer(5) EndEvent Edited December 1, 2020 by DieFeM Link to comment Share on other sites More sharing options...
NoCashNoExp Posted December 1, 2020 Share Posted December 1, 2020 (edited) This really ties in what determines the current weather's temperature. Location, date or time of the day or maybe all of those combined? There's no way to do it without timers as your script has to be constantly checking for weather changes. You could get away with running your check code when the player enters a new cell but then the player might stay at the same cell for some time and invalidate those checks (ex: it's colder at night than at day time). You should probably take into account timescale. Each 20 minutes in FO4 = 1 minute in real life. The more your script waits between checks, the less computing it has to perform and this in turn should net better performance. Edited December 1, 2020 by NoCashNoExp Link to comment Share on other sites More sharing options...
SKKmods Posted December 1, 2020 Share Posted December 1, 2020 Long runing while loops are cancer for real time systems and your own scripts. Use events, if there are no real time event triggers to hook create timer events. Work with the principle that every script function takes one frame to execute (not 100% accurate but focusses attention) and consoles run at 30 fps. From that you can work out when to crossover from a while loop + bailout counter (you do use bailout counters, right ?) to a timer and a sensible timer frequency. Test question: it takes 13 seconds for an actor to recover from bleedout. Is it more effective to (a) While IsBleedingOut() == True Wait (3.0), or (b) If IsBleedingOut() == True Self.StartTimer(3.0) ? Bonus mark: is 3.0 seconds the best compromise between UX response and system resource load. Link to comment Share on other sites More sharing options...
Zorkaz Posted December 1, 2020 Author Share Posted December 1, 2020 No question about using Events per se. I just don't find any about changed weather conditions. But: Every weather type can cast a spell occasionally as it seems (OnLightningStrike), so maybe that's the answers for cold weather spells @NoCashNoExpI haven't started but conditioning but I suppose that part might be easy. All I need is one or two spells with different magic effects that have conditions set up, so no complicated time scripts. Of course this doesn't take into account clothing, ect.. but you can turn the system off so people can make Frost patches Link to comment Share on other sites More sharing options...
octodecoy Posted December 2, 2020 Share Posted December 2, 2020 You could use a single magic effect on an ability with condition GetCurrentWeatherPercent < 1.0 to make a sort of pseudo event for when the weather is changing. Maybe also condition it to see if player is in your custom worldspace and is outdoors. Then you can do whatever checking you need in script. If the magic effect is constant OnEffectFinish would happen when the weather is fully transitioned in, or you could use OnEffectStart and check with script what weather is currently transitioning in. I haven't actually done this extensively, only a little bit in the past to see if it would work.....so I'm unsure if there are any huge flaws with it that I'm not thinking of. Link to comment Share on other sites More sharing options...
Recommended Posts