[Tutorial] Snow added to Dynamic Weather

Discussion in 'Tutorials' started by Vampire, Nov 19, 2013.

  1. ShootingBlanks

    ShootingBlanks OpenDayZ Guru!

    Joined:
    Mar 31, 2013
    Messages:
    2,422
    Likes Received:
    336
    look at your first post with the error.
    your file name,is,wrong ..

    weather/dynamicweather.sqf
     
  2. Bazlat

    Bazlat New Member

    Joined:
    Jun 1, 2015
    Messages:
    14
    Likes Received:
    0
    Okay so just like it says in the tutorial? This is how i did it but For some reason it always says it cant find script weather\dynamicweathereffects.sqf when it is loading the game.
     
  3. ShootingBlanks

    ShootingBlanks OpenDayZ Guru!

    Joined:
    Mar 31, 2013
    Messages:
    2,422
    Likes Received:
    336
    are you sure you have the correct filename? the first post had wrong filename.

    post the actual rpt to pastebin, and,post your init.sqf file and a screenshot of the mission showing the folder and file.
     
  4. Bazlat

    Bazlat New Member

    Joined:
    Jun 1, 2015
    Messages:
    14
    Likes Received:
    0
    I will double check when i am home i downloaded the file from the link he provided so it should be the correct one. I appreciate all your help will post again tonight when i am able to try again.
     
  5. Bazlat

    Bazlat New Member

    Joined:
    Jun 1, 2015
    Messages:
    14
    Likes Received:
    0
    okay so I got the dynamic weather to work (I think) the game loads with no errors and it looks like I have overcast when it first starts not sure if the snow should happen right off the bat, anyway my next question is how would I get the temperature to effect the chars when it is snowing/raining so that they would have to build a fire or find warmer cloths to keep warm. I want the water to effect it as well so if they step in the water while snowing they would freeze to death fairly quick unless they built a fire. Is any of this possible if so how would I go about getting it to work? I would need a small step by step I know it has something to do with the fn_temperature.sqf but I don't know from there.
     
  6. ShootingBlanks

    ShootingBlanks OpenDayZ Guru!

    Joined:
    Mar 31, 2013
    Messages:
    2,422
    Likes Received:
    336
    BTW, you know there is a Winter Chernarus map someone posted about here a few months ago .. supposedly snow on the ground and all .. wintery ..



    https://community.bistudio.com/wiki/surfaceIsWater
    and then if thats true then you start affecting the body temperature. That bit of code is already in the fn_temperatur.sqf file. At the end of the file it takes the variable _difference and adjusts the body temp, positive effects are added, negative effects are subtracted and they appear to be cumulative. So if you are in water and its raining you have -10.5
    [​IMG]

    I dont think you want to add any new functionality, just increase the current effects. So all you would have to do is adjust the negative affects.

    So just copy that file into your mission and edit the compiles.sqf to point to the new location
    Code:
      player_temp_calculation = compile preprocessFileLineNumbers "fixes\fn_temperatur.sqf";        //Temperatur System //TeeChange
     
  7. Bazlat

    Bazlat New Member

    Joined:
    Jun 1, 2015
    Messages:
    14
    Likes Received:
    0
    No i didnt know that thank i will see if i can find it. Also where do i put theplayer_temp_calculation = compile preprocessFileLineNumbers "fixes\fn_temperatur.sqf"; //Temperatur System //TeeChange

    In the compiles folder does it need to go someplace soecial or just at the bottom?
     
  8. ShootingBlanks

    ShootingBlanks OpenDayZ Guru!

    Joined:
    Mar 31, 2013
    Messages:
    2,422
    Likes Received:
    336
    your compiles.sqf lists all the files to be used and their location. there is already a line that says exactly what i pasted except the location is /z/addons/dayz_code/ ... etc...etc and i changed it to your mission. and i put the file in a folder called fixes in your mission.
    so just search the compiles for fn_temp

    you do already have the compiles.sqf in your mission right? if not that is another tutorial.
     
  9. Bazlat

    Bazlat New Member

    Joined:
    Jun 1, 2015
    Messages:
    14
    Likes Received:
    0
    Does the dynamic weather still give sunny days or is it just rain and snow? I ask because i wonder if the sun is out does that count as a warming factot?
     
  10. Bazlat

    Bazlat New Member

    Joined:
    Jun 1, 2015
    Messages:
    14
    Likes Received:
    0
    I have changed the fn_temperatur.sqf and it doesn't seem to effect my char at all, below is how I have my files.

    In my custom folder I have my custom compiles.sqf which at the bottom I have
    player_temp_calculation = compile preprocessFileLineNumbers "weather\fn_temperatur.sqf"; //Temperatur System //TeeChange

    in my weather folder I have my fn_temperatur.sqf and I changed my variables for the effects but nothing happens I change the negative so they are like this on the list.
    15
    8
    2.5
    2.5
    5

    but it doesn't seem to change anything on my character. not when it snows or when it rains.
     
  11. ShootingBlanks

    ShootingBlanks OpenDayZ Guru!

    Joined:
    Mar 31, 2013
    Messages:
    2,422
    Likes Received:
    336
    what is the base temperature and what percentage of a change is 15 .. maybe you really need to crank it up. What you want to do is add a line to that file that outputs the temperature and adjustments to the log so you can track it

    they are actually already in the file, just commented out. So remove the // at the start of the relevent comments.
    The first one will give you what its changing when in water, the bottom one will give you the actual player body temperature and the cumulative _difference taking into account water, rain, sun, standing, etc etc
    line 122
    //diag_log format["water - %1",_difference];
    line 176
    //diag_log format["%1 - %2",dayz_temperatur,_difference];
     
  12. Bazlat

    Bazlat New Member

    Joined:
    Jun 1, 2015
    Messages:
    14
    Likes Received:
    0
    How would i make the snow effect the temperature of the players or would it treat it like rain?
     
  13. ShootingBlanks

    ShootingBlanks OpenDayZ Guru!

    Joined:
    Mar 31, 2013
    Messages:
    2,422
    Likes Received:
    336
    i expect the snow is actually rain with some wind blown ash that is supposed to look like snow. it may not even be rain, it might just be the ash ... look up the "eagle wing" effects .. probably same as tbis script without the yellow sky
     
  14. Bazlat

    Bazlat New Member

    Joined:
    Jun 1, 2015
    Messages:
    14
    Likes Received:
    0
    Thank you for all your help it is working now just need to tweak the values a bit. I was apparently putting the values as positive numbers i forgot to put the - sign in.
     
  15. Stuff and Junk

    Stuff and Junk Well-Known Member

    Joined:
    Nov 4, 2013
    Messages:
    266
    Likes Received:
    21
    If you do it like this you can control the initial weather without having to open the weather.sqf:
    Code:
    //fog, overcast, rain, snow, wind, debug
    [0, 0, 0, 0, [0,0], false] execVM "fixes\system\DynamicWeatherEffects.sqf";
    
    Notice my weather custom is in the fixes\system\ folder, only because that is what folder I chose to use.

    EDIT: If you want to have snow affect players temperature then you need to over ride the fn_temperatur.sqf file and add in the required code to make snow factor in temp changes just like rain.

    Code:
    /*
    Author: TeeTime
    
    Does: Manages the body temperature of a Player
    
    Possible Problems:
        =>  Balancing
    
    Missing:
        Save Functions
    
        Should Effects Sum Up?
    
        Math Functions for Water
    
        Player Update GUI Colours need to be checked
    
        Shivering Function need improvements
    */
    private ["_warm_clothes","_cold_clothes","_snow_factor","_snowfall","_playerIsWarm","_playerIsCold","_difference","_isinvehicle","_isinbuilding","_daytime","_height_mod","_temp","_looptime","_vehicle_factor","_moving_factor","_fire_factor","_building_factor","_sun_factor","_water_factor","_rain_factor","_night_factor","_wind_factor","_raining","_sunrise","_fireplaces","_building"];
    _looptime = _this;
    
    //Factors are equal to win/loss of factor*basic value
    //All Values can be seen as x of 100: 100 / x = minutes from min temperature to max temperature (without other effects)
    /*
    Warm Weather Variables Start
    _vehicle_factor = 5;
    _moving_factor = 4;
    _fire_factor = 20;    //Should be always:  _rain_factor + _night_factor + _wind_factor OR higher !
    _building_factor = 7;
    _sun_factor = 3;    //max sun factor linear over the day. highest value in the middle of the day
    
    _water_factor = -12;
    _rain_factor = -12; //6
    _night_factor = -6; //4
    _wind_factor = -6;
    _stand_factor = -6; //4
    
    _difference = 0;
    //_hasfireffect = false;
    _isinbuilding = false;
    _isinvehicle = false;
    
    _raining = if(rain > 0) then {true} else {false};
    _sunrise = call world_sunRise;
    Warm Weather Variables End
    */
    /*
    Cold Weather Start */
    _vehicle_factor     = 4;
    _moving_factor         = 3;
    _fire_factor         = 34;    //Should be always:  _snow_factor + _rain_factor + _night_factor + _wind_factor OR higher !
    _building_factor     = 6;
    _sun_factor         = 2;    //max sun factor linear over the day. highest value in the middle of the day
    
    _warm_clothes        = 24;
    _luke_clothes         = 12;
    _cold_clothes        = 0;
    
    _water_factor         = -40;
    _rain_factor         = -16; //6
    _snow_factor        = -18;
    _night_factor         = -7; //4
    _wind_factor         = -7;
    _stand_factor         = -7; //4
    
    _difference = 0;
    //_hasfireffect = false;
    _isinbuilding = false;
    _isinvehicle = false;
    
    if(isNil ("snow")) then {snow = 0};
    _snowfall = if(snow > 0) then {true} else {false};
    _raining = if(rain > 0) then {true} else {false};
    _sunrise = call world_sunRise;
    /*
    Cold Weather End */
    
    //POSITIV EFFECTS
    //vehicle
    if((vehicle player) != player) then {
        _difference = _difference + _vehicle_factor;
        _isinvehicle = true;
    } else {
        //speed factor
        private["_vel","_speed"];
        _vel = velocity player;
        _speed = round((_vel distance [0,0,0]) * 3.6);
        _difference = (_moving_factor * (_speed / 20)) min 7;
    };
    
    //fire
    _fireplaces = nearestObjects [player, ["flamable_DZ","Land_Fire","Land_Campfire"], 8];
    if(({inflamed _x} count _fireplaces) > 0 && !_isinvehicle ) then {
        //Math: factor * 1 / (0.5*(distance max 1)^2) 0.5 = 12.5% of the factor effect in a distance o 4 meters
        _difference = _difference + (_fire_factor /(0.5*((player distance (_fireplaces select 0)) max 1)^2));
        //_hasfireffect = true;
    };
    
    //building
    _building = nearestObject [player, "HouseBase"];
    if(!isNull _building) then {
        if([player,_building] call fnc_isInsideBuilding) then {
            //Make sure thate Fire and Building Effect can only appear single Not used at the moment
            //if(!_hasfireffect && _fire_factor > _building_factor) then {
                _difference = _difference + _building_factor;
            //};
            _isinbuilding = true;
            dayz_inside = true;
        } else {
            dayz_inside = false;
        };
    } else {
        dayz_inside = false;
    };
    
    //sun
    if(daytime > _sunrise && daytime < (24 - _sunrise) && !_raining && overcast <= 0.6 && !_isinbuilding) then {
        /*Mathematic Basic
    
        t = temperature effect
    
        a = calcfactor
        f = sunfactor
        s = sunrise
        d = daytime
    
        I:    a = f / (12 - s)
        II:    t = -a * (d - 12) + f
    
        I + II =>
    
        t = -(f / (12 - s)) * (d - 12) + f
    
        Parabel with highest Point( greatest Effect == _sun_factor) always at 12.00
        Zero Points are always at sunrise and sunset -> Only Positiv Values Possible
        */
    
        _difference = _difference + (-((_sun_factor / (12 - _sunrise)^2)) * ((daytime - 12)^2) + _sun_factor);
    };
    
    _playerIsWarm = (typeOf player) in ["Sniper1_DZ","BanditW1_DZ","Bandit1_DZ","Survivor3_DZ","CZ_Soldier_DES_EP1","Ins_Soldier_Sniper"];
    _playerIsLuke = (typeOf player) in ["Camo1_DZ","Soldier1_DZ","Rocket_DZ"];
    _playerIsCold = (typeOf player) in [];
    
    if (_playerIsWarm) then {
        _difference = _difference + _warm_clothes;
    };
    if (_playerIsCold) then {
        _difference = _difference + _cold_clothes;
    };
    if (_playerIsLuke) then {
        _difference = _difference + _luke_clothes;
    };
    
    
    //NEGATIVE EFFECTS
    
    //water
    if(surfaceIsWater getPosATL player || dayz_isSwimming) then {
        _difference = _difference + _water_factor;
    };
    
    //rain
    if(_raining && !_isinvehicle && !_isinbuilding) then {
        _difference = _difference + (rain * _rain_factor);
    };
    
    if(_snowfall && !_isinvehicle && !_isinbuilding) then {
        _difference = _difference + (snow * _snow_factor);
    };
    
    //night
    if((daytime < _sunrise || daytime > (24 - _sunrise)) && !_isinvehicle) then {
        _daytime = if(daytime < 12) then {daytime + 24} else {daytime};
        if(_isinbuilding) then {
            _difference = _difference + ((((_night_factor * -1) / (_sunrise^2)) * ((_daytime - 24)^2) + _night_factor)) / 2;
        } else {
            _difference = _difference + (((_night_factor * -1) / (_sunrise^2)) * ((_daytime - 24)^2) + _night_factor);
        };
    };
    
    //wind
    if(((wind select 0) > 4 || (wind select 1) > 4) && !_isinvehicle && !_isinbuilding ) then {
        _difference = _difference + _wind_factor;
    };
    
    /*
    //height
    if (!_isinvehicle && overcast >= 0.6) then {
        _height_mod = ((getPosASL player select 2) / 100) / 2;
        _difference = _difference - _height_mod;
    };
    */
    //height
    if(!_isinvehicle && overcast >= 0.6) then {
        _height_mod = ((getPosASL player select 2) / 100) * 4;
        _difference = _difference - _height_mod;
    };
    
    //Standing cooldown.
    if (!_isinvehicle && !_isinvehicle && !_isinbuilding) then {
        _difference = _difference - _stand_factor;
    };
    
    //Calculate Change Value Basic Factor Looptime Correction Adjust Value to current used temperatur scala
    _difference = _difference * SleepTemperatur / (60 / _looptime) * ((dayz_temperaturmax - dayz_temperaturmin) / 100);
    
    //Change Temperatur Should be moved in a own Function to allow adding of Items which increase the Temp like "hot tea"
    dayz_temperatur = (((dayz_temperatur + _difference) max dayz_temperaturmin) min dayz_temperaturmax);
     
    Last edited: Jun 7, 2015

Share This Page