Kolmain 6 Posted February 9, 2011 Is there anyway that I can alternate between the day and night movie effects modules depending on the time? Share this post Link to post Share on other sites
twirly 11 Posted February 9, 2011 Can't help with the Movie Modules but here's a brilliant way to find out if it's dark...was just looking this up yesterday myself. Thanks to Carl Gustaffa. http://forums.bistudio.com/showthread.php?t=107476&highlight=detect+night Hope it helps. Share this post Link to post Share on other sites
Clayman 20 Posted February 10, 2011 You can change the ppEffects any time during the mission. Movie Day: "colorCorrections" ppEffectAdjust [1, 1.02, -0.005, [0.0, 0.0, 0.0, 0.0], [1, 0.8, 0.6, 0.65], [0.199, 0.587, 0.114, 0.0]]; "colorCorrections" ppEffectCommit 0; "colorCorrections" ppEffectEnable true; Movie Night: "colorCorrections" ppEffectAdjust [1, 1.15, 0, [0.0, 0.0, 0.0, 0.0], [0.5, 0.8, 1, 0.5], [0.199, 0.587, 0.114, 0.0]]; "colorCorrections" ppEffectCommit 0; "colorCorrections" ppEffectEnable true; Share this post Link to post Share on other sites
Kolmain 6 Posted February 10, 2011 so heres the code X_fnc_SunElev = { /* Author: CarlGustaffa Description: Returns the suns altitude for current day and hour of the year on any island (whos latitude may differ). Parameters: None needed. Returns: Suns altitude in degrees, positive values after sunrise, negative values before sunrise. */ private ["_lat", "_day", "_hour", "_angle", "_isday"]; _lat = -1 * getNumber(configFile >> "CfgWorlds" >> worldName >> "latitude"); _day = 360 * (dateToNumber date); _hour = (daytime / 24) * 360; _angle = ((12 * cos(_day) - 78) * cos(_lat) * cos(_hour)) - (24 * sin(_lat) * cos(_day)); _angle }; but im nto sure how to implement it? how do i get the return? Share this post Link to post Share on other sites
twirly 11 Posted February 10, 2011 (edited) You include it as a function in a script like this.... X_fnc_SunElev = { /* Author: CarlGustaffa Description: Returns the suns altitude for current day and hour of the year on any island (whos latitude may differ). Parameters: None needed. Returns: Suns altitude in degrees, positive values after sunrise, negative values before sunrise. */ private ["_lat", "_day", "_hour", "_angle", "_isday"]; _lat = -1 * getNumber(configFile >> "CfgWorlds" >> worldName >> "latitude"); _day = 360 * (dateToNumber date); _hour = (daytime / 24) * 360; _angle = ((12 * cos(_day) - 78) * cos(_lat) * cos(_hour)) - (24 * sin(_lat) * cos(_day)); _angle }; [color="Red"]_sunangle = [] call X_fnc_SunElev[/color]; hint format ["Angle of the sun is %1",_sunangle]; ..or you can make a separate ".sqf" for it and also call it as a function. In which case you would preprocess the function by including this line in your "init.sqf" in your mission folder. init.sqf:- X_fnc_SunElev = compile preProcessFile "X_fnc_SunElev.sqf"; Now the function itself.... X_fnc_SunElev.sqf:- /* Author: CarlGustaffa Description: Returns the suns altitude for current day and hour of the year on any island (whos latitude may differ). Parameters: None needed. Returns: Suns altitude in degrees, positive values after sunrise, negative values before sunrise. */ private ["_lat", "_day", "_hour", "_angle", "_isday"]; _lat = -1 * getNumber(configFile >> "CfgWorlds" >> worldName >> "latitude"); _day = 360 * (dateToNumber date); _hour = (daytime / 24) * 360; _angle = ((12 * cos(_day) - 78) * cos(_lat) * cos(_hour)) - (24 * sin(_lat) * cos(_day)); _angle }; Then call the function the same way as above :- _sunangle = [] call X_fnc_SunElev; hint format ["Angle of the sun is %1",_sunangle]; Hope that helps in some way. Edited February 10, 2011 by twirly Clarity Share this post Link to post Share on other sites
Kolmain 6 Posted February 10, 2011 (edited) so using this _sunangle = [] call X_fnc_SunElev; will return _sunangle as the angle, pos day negative night? so jsut check if and then? EDIT: Goona try this X_fnc_SunElev = { [size=2][color=#ff0000][size=2][color=#ff0000]private[/color][/size][/color][/size][size=2] ["_lat", "_day", "_hour", "_angle", "_isday"]; [/size][size=2][color=#808080][size=2][color=#808080]_lat[/color][/size][/color][/size][size=2] = -1 * getNumber([/size][size=2][color=#ff0000][size=2][color=#ff0000]configFile[/color][/size][/color][/size][size=2] >> "CfgWorlds" >> [/size][size=2][color=#ff0000][size=2][color=#ff0000]worldName[/color][/size][/color][/size][size=2] >> "latitude"); [/size][size=2][color=#808080][size=2][color=#808080]_day[/color][/size][/color][/size][size=2] = 360 * ([/size][size=2][color=#ff0000][size=2][color=#ff0000]dateToNumber[/color][/size][/color][/size][size=2] [/size][size=2][color=#ff0000][size=2][color=#ff0000]date[/color][/size][/color][/size][size=2]); [/size][size=2][color=#808080][size=2][color=#808080]_hour[/color][/size][/color][/size][size=2] = ([/size][size=2][color=#ff0000][size=2][color=#ff0000]daytime[/color][/size][/color][/size][size=2] / 24) * 360; [/size][size=2][color=#808080][size=2][color=#808080]_angle[/color][/size][/color][/size][size=2] = ((12 * [/size][size=2][color=#ff0000][size=2][color=#ff0000]cos[/color][/size][/color][/size][size=2]([/size][size=2][color=#808080][size=2][color=#808080]_day[/color][/size][/color][/size][size=2]) - 78) * [/size][size=2][color=#ff0000][size=2][color=#ff0000]cos[/color][/size][/color][/size][size=2]([/size][size=2][color=#808080][size=2][color=#808080]_lat[/color][/size][/color][/size][size=2]) * [/size][size=2][color=#ff0000][size=2][color=#ff0000]cos[/color][/size][/color][/size][size=2]([/size][size=2][color=#808080][size=2][color=#808080]_hour[/color][/size][/color][/size][size=2])) - (24 * [/size][size=2][color=#ff0000][size=2][color=#ff0000]sin[/color][/size][/color][/size][size=2]([/size][size=2][color=#808080][size=2][color=#808080]_lat[/color][/size][/color][/size][size=2]) * [/size][size=2][color=#ff0000][size=2][color=#ff0000]cos[/color][/size][/color][/size][size=2]([/size][size=2][color=#808080][size=2][color=#808080]_day[/color][/size][/color][/size][size=2])); [/size][size=2][color=#808080][size=2][color=#808080]_angle [/color][/size][/color][/size][size=2]}; [/size][size=2][color=#808080][size=2][color=#808080]_sunangle[/color][/size][/color][/size][size=2] = [] [/size][size=2][color=#ff0000][size=2][color=#ff0000]call[/color][/size][/color][/size][size=2] X_fnc_SunElev;     [/size][size=2][color=#0000ff][size=2][color=#0000ff]if[/color][/size][/color][/size][size=2] {[/size][size=2][color=#808080][size=2][color=#808080]_sunangle[/color][/size][/color][/size][size=2] > 0} [/size][size=2][color=#0000ff][size=2][color=#0000ff]then[/color][/size][/color][/size][size=2] { "colorCorrections" [/size][size=2][color=#ff0000][size=2][color=#ff0000]ppEffectAdjust[/color][/size][/color][/size][size=2] [1, 1.02, -0.005, [0.0, 0.0, 0.0, 0.0], [1, 0.8, 0.6, 0.65], [0.199, 0.587, 0.114, 0.0]]; "colorCorrections" [/size][size=2][color=#ff0000][size=2][color=#ff0000]ppEffectCommit[/color][/size][/color][/size][size=2] 0; "colorCorrections" [/size][size=2][color=#ff0000][size=2][color=#ff0000]ppEffectEnable[/color][/size][/color][/size][size=2] [/size][size=2][color=#0000ff][size=2][color=#0000ff]true[/color][/size][/color][/size][size=2]; } [/size][size=2][color=#0000ff][size=2][color=#0000ff]else[/color][/size][/color][/size][size=2] { "colorCorrections" [/size][size=2][color=#ff0000][size=2][color=#ff0000]ppEffectAdjust[/color][/size][/color][/size][size=2] [1, 1.15, 0, [0.0, 0.0, 0.0, 0.0], [0.5, 0.8, 1, 0.5], [0.199, 0.587, 0.114, 0.0]]; "colorCorrections" [/size][size=2][color=#ff0000][size=2][color=#ff0000]ppEffectCommit[/color][/size][/color][/size][size=2] 0; "colorCorrections" [/size][size=2][color=#ff0000][size=2][color=#ff0000]ppEffectEnable[/color][/size][/color][/size][size=2] [/size][size=2][color=#0000ff][size=2][color=#0000ff]true[/color][/size][/color][/size][size=2]; }; [/size] Edited February 10, 2011 by Kolmain Share this post Link to post Share on other sites
twirly 11 Posted February 10, 2011 so using this_sunangle = [] call X_fnc_SunElev; will return _sunangle as the angle, pos day negative night? so jsut check if and then? Roger on that! Share this post Link to post Share on other sites
demonized 20 Posted February 11, 2011 (edited) this will give different values dependig on time of year, in dec i get darkness ca at -3,75. in june i get darkness at ca -10. Now the script itself only determines sun elevation and not darkness so script works as intended ofc, but there is always light quite awhile after sundown, as in RL. But i want to be able to determine darkness. Accurate determination of darkness is not easily acessible, but can ofc be tested and set to whatever value wich coresponds with your missions date. so for december i choose -4 as elevation value to determine darkness. Anyone got a solution to this so it can be used all year without predefining value for current date? ---------- Post added at 05:46 PM ---------- Previous post was at 05:35 PM ---------- Also its higly dependant on day of month and weather. so values are very fluid. Was thinking of maybe just hardcode the 365 days values into my scripts, but that seems like an never ending task now with at least 1000+ different values. Edited February 11, 2011 by Demonized Share this post Link to post Share on other sites