mirror of
https://github.com/ravmustang/PTWS.git
synced 2024-08-30 17:22:14 +00:00
Weather Update
This commit is contained in:
parent
a042207ae4
commit
448da7a005
@ -0,0 +1,190 @@
|
||||
/**
|
||||
* ExileClient_object_player_stats_updateTemperature
|
||||
*
|
||||
* Exile Mod
|
||||
* www.exilemod.com
|
||||
* © 2015 Exile Mod Team
|
||||
*
|
||||
* This work is licensed under the Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International License.
|
||||
* To view a copy of this license, visit http://creativecommons.org/licenses/by-nc-nd/4.0/.
|
||||
*/
|
||||
|
||||
private["_timeElapsed","_forcedBodyTemperatureChangePerMinute","_wetnessChangePerMinute","_altitude","_isSwimming","_bodyTemperature","_bodyWetness","_temperatureConfig","_fromDayTimeTemperature","_toDayTimeTemperature","_environmentTemperature","_playerIsInVehicle","_playerVehicle","_isFireNearby","_startPosition","_endPosition","_intersections","_isBelowRoof","_clothingColdProtection","_movementInfluence","_regulation","_environmentInfluence"];
|
||||
/*
|
||||
// PTWS Season Temperature Control
|
||||
*/
|
||||
|
||||
_month = date select 1;
|
||||
_season = "";
|
||||
|
||||
_WinterEnd = 1;
|
||||
_SpringEnd = 4;
|
||||
_SummerEnd = 7;
|
||||
_FallEnd = 10;
|
||||
|
||||
if ((_month > _WinterEnd) && (_month <= _SpringEnd)) then // The season will be the month after _PreviousSeasonEnd and the months upto and including _ThisSeasonEnd ex. Spring starts on Feb and ends in Apr.
|
||||
{
|
||||
_season = "Spring";
|
||||
};
|
||||
|
||||
if ((_month > _SpringEnd) && (_month <= _SummerEnd)) then
|
||||
{
|
||||
_season = "Summer";
|
||||
};
|
||||
|
||||
if ((_month > _SummerEnd) && (_month <= _FallEnd)) then
|
||||
{
|
||||
_season = "Fall";
|
||||
};
|
||||
|
||||
if (_month == 11 || _month == 12 || _month == 1) then
|
||||
{
|
||||
_season = "Winter";
|
||||
};
|
||||
|
||||
//diag_log format["PTWS - Current Season:%1",_season];
|
||||
|
||||
_seasonDaytimeTemperature = [];
|
||||
|
||||
//Switches the daytimeTemperature array based on the season, this replace the values in the mission config.
|
||||
switch (_season) do {
|
||||
case "Winter": { _seasonDaytimeTemperature = [-6.93,-5.89,-4.42,-3.40,-2.68,-1.10,1.48,2.63,3.40,4.66,5.32,6.80,6.80,5.32,4.66,3.40,2.63,1.48,-1.10,-2.68,-3.40,-4.42,-5.89,-6.93,-7.93]; };
|
||||
case "Spring": { _seasonDaytimeTemperature = [9,11,14,17,20,24,26,27,28,28,28,27,26,28,28,28,27,26,24,20,17,14,11,9,8]; };
|
||||
case "Summer": { _seasonDaytimeTemperature = [15.93,16.89,18.42,20.40,22.68,25.10,27.48,29.63,31.40,32.66,33.32,33.80,33.80,33.32,32.66,31.40,29.63,27.48,25.10,22.68,20.40,18.42,16.89,15.93,15.93]; };
|
||||
case "Fall": { _seasonDaytimeTemperature = [-2.00,-1.77,-1.12,-0.10,1.24,2.78,4.40,6.00,7.46,8.65,9.50,9.90,9.90,9.50,8.65,7.46,6.00,4.40,2.78,1.24,-0.10,-1.12,-1.77,-2.00,-2.00]; };
|
||||
};
|
||||
|
||||
//diag_log format["PTWS - Current Temperature Array:%1",_seasonDaytimeTemperature];
|
||||
|
||||
/*
|
||||
// PTWS Season Temperature Control
|
||||
*/
|
||||
_timeElapsed = _this;
|
||||
_forcedBodyTemperatureChangePerMinute = 0;
|
||||
_wetnessChangePerMinute = -0.1;
|
||||
_altitude = ((getPosASL player) select 2) max 0;
|
||||
_isSwimming = (_altitude < 0.1) || (underwater player);
|
||||
_bodyTemperature = ExileClientPlayerAttributes select 5;
|
||||
_bodyWetness = ExileClientPlayerAttributes select 6;
|
||||
_temperatureConfig = missionConfigFile >> "CfgExileEnvironment" >> worldName >> "Temperature";
|
||||
//_fromDayTimeTemperature = (getArray (_temperatureConfig >> "daytimeTemperature")) select (date select 3);
|
||||
//_toDayTimeTemperature = (getArray (_temperatureConfig >> "daytimeTemperature")) select ((date select 3) + 1);
|
||||
_fromDayTimeTemperature = _seasonDaytimeTemperature select (date select 3);
|
||||
_toDayTimeTemperature = _seasonDaytimeTemperature select ((date select 3) + 1);
|
||||
_environmentTemperature = [_fromDayTimeTemperature, _toDayTimeTemperature, (date select 4) / 60] call ExileClient_util_math_lerp;
|
||||
_environmentTemperature = _environmentTemperature + overcast * (getNumber (_temperatureConfig >> "overcast"));
|
||||
_environmentTemperature = _environmentTemperature + rain * (getNumber (_temperatureConfig >> "rain"));
|
||||
_environmentTemperature = _environmentTemperature + windStr * (getNumber (_temperatureConfig >> "wind"));
|
||||
_environmentTemperature = _environmentTemperature + _altitude / 100 * (getNumber (_temperatureConfig >> "altitude"));
|
||||
if (_isSwimming) then
|
||||
{
|
||||
_environmentTemperature = _environmentTemperature + (getNumber (_temperatureConfig >> "water"));
|
||||
};
|
||||
ExileClientEnvironmentTemperature = _environmentTemperature;
|
||||
_playerIsInVehicle = false;
|
||||
_playerVehicle = vehicle player;
|
||||
if !(_playerVehicle isEqualTo player) then
|
||||
{
|
||||
try
|
||||
{
|
||||
if (_playerVehicle isKindOf "Exile_Bike_QuadBike_Abstract") throw false;
|
||||
if (_playerVehicle isKindOf "Exile_Bike_OldBike") throw false;
|
||||
if (_playerVehicle isKindOf "Exile_Bike_MountainBike") throw false;
|
||||
throw true;
|
||||
}
|
||||
catch
|
||||
{
|
||||
_playerIsInVehicle = _exception;
|
||||
};
|
||||
};
|
||||
if (_playerIsInVehicle) then
|
||||
{
|
||||
if (isEngineOn _playerVehicle) then
|
||||
{
|
||||
_forcedBodyTemperatureChangePerMinute = 0.05;
|
||||
_wetnessChangePerMinute = -0.5;
|
||||
}
|
||||
else
|
||||
{
|
||||
_forcedBodyTemperatureChangePerMinute = 0.01;
|
||||
_wetnessChangePerMinute = -0.2;
|
||||
};
|
||||
}
|
||||
else
|
||||
{
|
||||
if (_isSwimming) then
|
||||
{
|
||||
_wetnessChangePerMinute = 99999;
|
||||
}
|
||||
else
|
||||
{
|
||||
_isFireNearby = [ASLtoAGL (getPosASL player), 5] call ExileClient_util_world_isFireInRange;
|
||||
if (_isFireNearby) then
|
||||
{
|
||||
_forcedBodyTemperatureChangePerMinute = 1;
|
||||
_wetnessChangePerMinute = -0.5;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (rain > 0.1) then
|
||||
{
|
||||
_startPosition = getPosASL player;
|
||||
_endPosition = [_startPosition select 0, _startPosition select 1, (_startPosition select 2 ) + 10];
|
||||
_intersections = lineIntersectsSurfaces [_startPosition, _endPosition, player, objNull, false, 1, "GEOM", "VIEW"];
|
||||
_isBelowRoof = !(_intersections isEqualTo []);
|
||||
if !(_isBelowRoof) then
|
||||
{
|
||||
_wetnessChangePerMinute = rain;
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
_bodyWetness = ((_bodyWetness + _wetnessChangePerMinute / 60 * _timeElapsed) max 0) min 1;
|
||||
if (ExileClientEnvironmentTemperature > 25) then
|
||||
{
|
||||
_forcedBodyTemperatureChangePerMinute = 0.5;
|
||||
};
|
||||
if (_forcedBodyTemperatureChangePerMinute > 0) then
|
||||
{
|
||||
_bodyTemperature = _bodyTemperature + _forcedBodyTemperatureChangePerMinute / 60 *_timeElapsed;
|
||||
}
|
||||
else
|
||||
{
|
||||
_clothingColdProtection = 0;
|
||||
if !((uniform player) isEqualTo "") then
|
||||
{
|
||||
_clothingColdProtection = _clothingColdProtection + 0.25;
|
||||
};
|
||||
if !((headgear player) isEqualTo "") then
|
||||
{
|
||||
_clothingColdProtection = _clothingColdProtection + 0.05;
|
||||
};
|
||||
if !((vest player) isEqualTo "") then
|
||||
{
|
||||
_clothingColdProtection = _clothingColdProtection + 0.10;
|
||||
};
|
||||
_clothingColdProtection = ((_clothingColdProtection * (1 - (_bodyWetness * 0.5))) max 0) min 1;
|
||||
_movementInfluence = 0;
|
||||
if ((getPos player) select 2 < 0.1) then
|
||||
{
|
||||
_movementInfluence = (37 - _bodyTemperature) * (1 - (_bodyWetness * 0.5)) * 0.075 * (vectorMagnitude (velocity player))/6.4;
|
||||
};
|
||||
if (_bodyTemperature < 37) then
|
||||
{
|
||||
_regulation = 0.1;
|
||||
}
|
||||
else
|
||||
{
|
||||
_regulation = -0.1;
|
||||
};
|
||||
_environmentInfluence = (1 - _clothingColdProtection) * (-0.2 + 0.008 * ExileClientEnvironmentTemperature);
|
||||
_bodyTemperature = _bodyTemperature + (_regulation + _movementInfluence + _environmentInfluence) / 60 *_timeElapsed;
|
||||
};
|
||||
_bodyTemperature = _bodyTemperature min 37;
|
||||
if (_bodyTemperature < 35) then
|
||||
{
|
||||
player setDamage ((damage player) + 0.1/60*_timeElapsed);
|
||||
};
|
||||
ExileClientPlayerAttributes set [6, _bodyWetness];
|
||||
ExileClientPlayerAttributes set [5, _bodyTemperature];
|
@ -0,0 +1,68 @@
|
||||
/**
|
||||
* ExileClient_system_snow_thread_update
|
||||
*
|
||||
* Exile Mod
|
||||
* www.exilemod.com
|
||||
* © 2015 Exile Mod Team
|
||||
*
|
||||
* This work is licensed under the Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International License.
|
||||
* To view a copy of this license, visit http://creativecommons.org/licenses/by-nc-nd/4.0/.
|
||||
*/
|
||||
|
||||
private["_enableSnow","_surfaceTypes","_posASL"];
|
||||
_enableSnow = false;
|
||||
_posASL = (getPosASL player select 2);
|
||||
/*
|
||||
if (rain < 0.01) then
|
||||
{
|
||||
_surfaceTypes = getArray (missionConfigFile >> "CfgExileEnvironment" >> worldName >> "Snow" >> "surfaces");
|
||||
if ((surfaceType (getPos player)) in _surfaceTypes) then
|
||||
{
|
||||
_enableSnow = true;
|
||||
ExileSnowClose attachTo [vehicle player, [0, 4, 1]];
|
||||
ExileSnowNear attachTo [vehicle player, [0, 4, 1.5]];
|
||||
ExileSnowFar attachTo [vehicle player, [0, 4, 2]];
|
||||
};
|
||||
};
|
||||
if (_enableSnow) then
|
||||
{
|
||||
ExileSnowClose attachTo [vehicle player, [0, 4, 1]];
|
||||
ExileSnowNear attachTo [vehicle player, [0, 4, 1.5]];
|
||||
ExileSnowFar attachTo [vehicle player, [0, 4, 2]];
|
||||
ExileSnowClose setDropInterval 0.01;
|
||||
ExileSnowNear setDropInterval 0.01;
|
||||
ExileSnowFar setDropInterval 0.01;
|
||||
}
|
||||
else
|
||||
{
|
||||
ExileSnowClose setDropInterval 0;
|
||||
ExileSnowNear setDropInterval 0;
|
||||
ExileSnowFar setDropInterval 0;
|
||||
};
|
||||
*/
|
||||
_environmentTemperatureValue = format ["%1", [ExileClientEnvironmentTemperature, 1] call ExileClient_util_math_round];
|
||||
_environmentTemperature = parseNumber _environmentTemperatureValue;
|
||||
//diag_log format["PTWS - Current Temperature:%1",_environmentTemperature];
|
||||
if ((0 >= _environmentTemperature) && (overcast >= 0.3)) then
|
||||
{
|
||||
_enableSnow = true;
|
||||
ExileSnowClose attachTo [vehicle player, [0, 4, 1]];
|
||||
ExileSnowNear attachTo [vehicle player, [0, 4, 1.5]];
|
||||
ExileSnowFar attachTo [vehicle player, [0, 4, 2]];
|
||||
};
|
||||
|
||||
if (_enableSnow) then
|
||||
{
|
||||
ExileSnowClose attachTo [vehicle player, [0, 4, 1]];
|
||||
ExileSnowNear attachTo [vehicle player, [0, 4, 1.5]];
|
||||
ExileSnowFar attachTo [vehicle player, [0, 4, 2]];
|
||||
ExileSnowClose setDropInterval 0.01;
|
||||
ExileSnowNear setDropInterval 0.01;
|
||||
ExileSnowFar setDropInterval 0.01;
|
||||
}
|
||||
else
|
||||
{
|
||||
ExileSnowClose setDropInterval 0;
|
||||
ExileSnowNear setDropInterval 0;
|
||||
ExileSnowFar setDropInterval 0;
|
||||
};
|
@ -10,24 +10,22 @@
|
||||
*/
|
||||
|
||||
private["_useRealTime","_useStaticTime","_staticTime","_changetime"];
|
||||
call ExileServer_system_weather_thread_weatherSimulation;
|
||||
//call ExileServer_system_weather_thread_weatherSimulation;
|
||||
_useRealTime = getNumber (configFile >> "CfgSettings" >> "Time" >> "useRealTime");
|
||||
_useStaticTime = getNumber (configFile >> "CfgSettings" >> "Time" >> "useStaticTime");
|
||||
_staticTime = getArray (configFile >> "CfgSettings" >> "Time" >> "staticTime");
|
||||
/*
|
||||
if(_useStaticTime isEqualTo 1)then
|
||||
{
|
||||
setDate _staticTime;
|
||||
//setDate _staticTime;
|
||||
}
|
||||
else
|
||||
{
|
||||
if(_useRealTime isEqualTo 1)then
|
||||
{
|
||||
setDate ExileServerStartTime;
|
||||
//setDate ExileServerStartTime;
|
||||
};
|
||||
};
|
||||
*/
|
||||
forceWeatherChange;
|
||||
_changetime = round(getNumber (configFile >> "CfgSettings" >> "Weather" >> "interval") * 60);
|
||||
[_changetime, ExileServer_system_weather_thread_weatherSimulation, [], true] call ExileServer_system_thread_addTask;
|
||||
//[_changetime, ExileServer_system_weather_thread_weatherSimulation, [], true] call ExileServer_system_thread_addTask;
|
||||
true
|
11
PTWS.ini
11
PTWS.ini
@ -13,7 +13,18 @@ Number of Inputs = 1
|
||||
SQL1_INPUTS = 1
|
||||
OUTPUT = 1
|
||||
|
||||
[getWeather]
|
||||
SQL1_1 = SELECT weather FROM ptws WHERE DateID = ?
|
||||
Number of Inputs = 1
|
||||
SQL1_INPUTS = 1
|
||||
OUTPUT = 1
|
||||
|
||||
[setDate]
|
||||
SQL1_1= UPDATE ptws SET date = ? WHERE DateID = ?
|
||||
Number of Inputs = 2
|
||||
SQL1_INPUTS = 1,2
|
||||
|
||||
[setWeather]
|
||||
SQL1_1= UPDATE ptws SET weather = ? WHERE DateID = ?
|
||||
Number of Inputs = 2
|
||||
SQL1_INPUTS = 1,2
|
||||
|
15
README.md
15
README.md
@ -1,15 +1,20 @@
|
||||
# PTWS
|
||||
####Persistent Time and Weather System
|
||||
|
||||
PTWS is a script made for Exile that allows time (and hopefully weather soon) to persist through server restarts. This is far from done but I think in its current state it is still useful for RP, or for people who want to run their servers on smaller time multipliers and still have their players experience a full day/night cycle.
|
||||
PTWS is a script made for Exile that allows time and weather to persist through server restarts. It also has seasons defined by months that will change the temperature.
|
||||
|
||||
#### Features
|
||||
* Persistent time (year, month, day, hour, minute)
|
||||
* Persistent weather
|
||||
* Dynamic weather (thanks to code34's Real weather)
|
||||
* Seasons that change the temperature
|
||||
* Snow based on temperature and current overcast
|
||||
* Time accleration
|
||||
|
||||
#### To-do List
|
||||
* Add Persistent weather
|
||||
* Configure seasons based on months
|
||||
* ~Add Persistent weather~
|
||||
* ~Configure seasons based on months~
|
||||
* Make the seasons affect more than the temperature
|
||||
* ????
|
||||
|
||||
## Installation
|
||||
@ -27,7 +32,9 @@ PTWS is a script made for Exile that allows time (and hopefully weather soon) to
|
||||
##### Mission
|
||||
1) Copy `PTWS` from `Mission Files\mpmissions\Exile.Yourmap` into the root of your Exile.Yourmap folder.
|
||||
|
||||
2) Open your `config.cpp` in your mission folder and edit your `CfgExileCustomCode` and add a new line inside like this:
|
||||
2) Open your `config.cpp` in your mission folder and edit your `CfgExileCustomCode` and add a two new lines inside like this:
|
||||
`ExileServer_system_weather_initialize = "PTWS\ExileServer_system_weather_initialize.sqf"`
|
||||
`ExileClient_object_player_stats_updateTemperature = "PTWS\ExileClient_object_player_stats_updateTemperature.sqf"`
|
||||
`ExileClient_system_snow_thread_update = "PTWS\ExileClient_system_snow_thread_update.sqf"`
|
||||
|
||||
#### You are done!
|
||||
|
Binary file not shown.
@ -4,7 +4,7 @@ class CfgPatches
|
||||
units[] = {};
|
||||
weapons[] = {};
|
||||
requiredVersion = 0.1;
|
||||
requiredAddons[] = {};
|
||||
requiredAddons[] = {"exile_server"};
|
||||
author[]= {"MajorXAcE"};
|
||||
};
|
||||
};
|
||||
@ -18,13 +18,15 @@ class CfgFunctions {
|
||||
file = "\PTWS\initServer.sqf";
|
||||
};
|
||||
};
|
||||
/*
|
||||
|
||||
class compiles
|
||||
{
|
||||
file = "\PTWS\scripts";
|
||||
class saveDate {};
|
||||
class saveWeather {};
|
||||
class controlWeather {};
|
||||
class timeAcc {};
|
||||
};
|
||||
*/
|
||||
|
||||
};
|
||||
};
|
@ -1,5 +1,6 @@
|
||||
PTWS_ID = "PTWS"; // The name of the id that will be in database, if changed the system will create a new entry and start over.
|
||||
PTWS_StartingDate = [2016,8,22,12,0]; // The date that the server will start on NOTE: Must be in this format [year, month, day, hour, minute] see https://community.bistudio.com/wiki/date
|
||||
PTWS_StartingWeather = [0,0,[0,0,0],[0,0,false],0,0,0,0,0]; //The weather parameters that the server will start with. NOTE: Must be in this format [overcast,rain,[fogValue, fogDecay, fogBase],[windx, windy, forced],gusts,lightnings,waves]
|
||||
|
||||
PTWS_timeAcc = true; // Enables/Disables the time multipliers for day and night.
|
||||
PTWS_timeAccNightStart = 18; // The 24hr time that the night multiplier starts. Default: 18 = 6:00PM
|
||||
@ -7,4 +8,8 @@ PTWS_timeAccDayStart = 6; // The 24hr time that the day multiplier starts. D
|
||||
PTWS_timeAccMultiplierNight = 6; //The multiplier for night time acceleration. Default: 6x = 2 hour nights
|
||||
PTWS_timeAccMultiplierDay = 4; //The multiplier for day time acceleration. Default: 4x = 3 hour days
|
||||
|
||||
PTWS_weatherChangeFast = false; //If set to true, the weather will change every PTWS_weatherChangeMin seconds, if false it will change sometime between PTWS_weatherChangeMax and PTWS_weatherChangeMin.
|
||||
PTWS_weatherChangeMax = 5400;
|
||||
PTWS_weatherChangeMin = 900;
|
||||
|
||||
PTWS_CompiledOkay = true;
|
||||
|
@ -8,7 +8,7 @@
|
||||
//Borrowed from second_coming's occupation mod.
|
||||
if(isNil "PTWS_CompiledOkay") exitWith { diag_log "PTWS - Failed to read config.sqf, check for typos."; };
|
||||
|
||||
diag_log "PTWS - Initialised";
|
||||
diag_log "PTWS - Initialized";
|
||||
|
||||
// Start PTWS
|
||||
[]execVM "\PTWS\scripts\insertPTWS.sqf";
|
||||
|
@ -0,0 +1,63 @@
|
||||
/*
|
||||
Author: code34 nicolas_boiteux@yahoo.fr
|
||||
Copyright (C) 2013-2015 Nicolas BOITEUX
|
||||
|
||||
Real weather for MP GAMES v 1.3 adapted for PTWS
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
private ["_lastrain","_rain","_overcast","_fogValue","_fogDecay","_fogHeight"];
|
||||
_lastrain = 0;
|
||||
_rain = 0;
|
||||
_overcast = 0;
|
||||
_fogValue = 0;
|
||||
_fogDecay = 0;
|
||||
_fogHeight =0;
|
||||
|
||||
_overcast = random 1;
|
||||
if(_overcast > 0.5) then {
|
||||
_rain = random 0.5;
|
||||
} else {
|
||||
_rain = 0;
|
||||
};
|
||||
|
||||
if((date select 3 > 5) and (date select 3 <10)) then {
|
||||
_fogValue = 0.2 + (random 0.8);
|
||||
_fogDecay = 0.2;
|
||||
_fogHeight = random 20;
|
||||
} else {
|
||||
if((_lastrain > 0.6) and (_rain < 0.2)) then {
|
||||
_fogValue = random 0.4;
|
||||
_fogDecay = 0;
|
||||
_fogHeight = 0;
|
||||
} else {
|
||||
_fogValue = 0;
|
||||
_fogDecay = 0;
|
||||
_fogHeight = 0;
|
||||
};
|
||||
};
|
||||
|
||||
if(random 1 > 0.5) then { "wind case 1";
|
||||
_wind = [random 7, random 7, false];
|
||||
} else {
|
||||
_wind = [random 3, random 3, false];
|
||||
};
|
||||
_lastrain = _rain;
|
||||
|
||||
wcweather = [_rain, [_fogValue,_fogDecay,_fogHeight], _overcast, _wind, date];
|
||||
60 setRain (wcweather select 0);
|
||||
60 setfog (wcweather select 1);
|
||||
60 setOvercast (wcweather select 2);
|
||||
setwind (wcweather select 3);
|
@ -0,0 +1,9 @@
|
||||
private["_currentdate","_data","_extDB2Message"];
|
||||
_currentdate = date;
|
||||
_data =
|
||||
[
|
||||
_currentdate,
|
||||
PTWS_ID
|
||||
];
|
||||
_extDB2Message = ["setDate", _data] call ExileServer_util_extDB2_createMessage;
|
||||
_extDB2Message call ExileServer_system_database_query_fireAndForget;
|
@ -0,0 +1,10 @@
|
||||
private["_currentWeather","_data","_extDB2Message"];
|
||||
_windDB = [wind select 0, wind select 1, false];
|
||||
_currentWeather = [overcast,rain,fogParams,_windDB,gusts,lightnings,waves];
|
||||
_data =
|
||||
[
|
||||
_currentWeather,
|
||||
PTWS_ID
|
||||
];
|
||||
_extDB2Message = ["setWeather", _data] call ExileServer_util_extDB2_createMessage;
|
||||
_extDB2Message call ExileServer_system_database_query_fireAndForget;
|
@ -1,13 +1,12 @@
|
||||
//Can't be called by ExileServer_system_thread_addTask for some reason.
|
||||
//Borrowed the the template from second_coming's occupation mod.
|
||||
private["_timeMultiplier"];
|
||||
if (daytime > PTWS_timeAccNightStart || daytime < PTWS_timeAccDayStart) then
|
||||
{
|
||||
_timeMultiplier = PTWS_timeAccMultiplierNight;
|
||||
}
|
||||
else
|
||||
{
|
||||
_timeMultiplier = PTWS_timeAccMultiplierDay;
|
||||
};
|
||||
|
||||
if(timeMultiplier != _timeMultiplier) then { setTimeMultiplier _timeMultiplier; };
|
||||
//Borrowed the the template from second_coming's occupation mod.
|
||||
private["_timeMultiplier"];
|
||||
if (daytime > PTWS_timeAccNightStart || daytime < PTWS_timeAccDayStart) then
|
||||
{
|
||||
_timeMultiplier = PTWS_timeAccMultiplierNight;
|
||||
}
|
||||
else
|
||||
{
|
||||
_timeMultiplier = PTWS_timeAccMultiplierDay;
|
||||
};
|
||||
|
||||
if(timeMultiplier != _timeMultiplier) then { setTimeMultiplier _timeMultiplier; };
|
@ -1,12 +1,5 @@
|
||||
private["_dateID"];
|
||||
private ["_insertDatabaseID"];
|
||||
if (!isServer) exitWith {};
|
||||
|
||||
missionNamespace setVariable ["PTWS",PTWS_ID];
|
||||
PTWS_DB_ID = missionNamespace getVariable "ExileDatabaseID";
|
||||
|
||||
if (isNil "PTWS_DB_ID") then
|
||||
{
|
||||
_dateID = format["createDate:%1", missionNamespace getVariable "PTWS"] call ExileServer_system_database_query_insertSingle;
|
||||
missionNamespace setVariable ["ExileDatabaseID", _dateID];
|
||||
_dateID;
|
||||
};
|
||||
//None of my checks work for the database entry work :/
|
||||
_insertDatabaseID = format["createDate:%1", PTWS_ID] call ExileServer_system_database_query_insertSingle;
|
||||
_insertDatabaseID;
|
@ -1,11 +1,8 @@
|
||||
private["_dateID","_date","_saveddate","_currentdate","_data","_extDB2Message","_timeMultiplier"];
|
||||
private["_saveddate","_savedWeather","_overcast","_rain","_fog","_wind","_gusts","_lightnings","_waves","_timeforecast","_timeforecastMinutes"];
|
||||
if (!isServer) exitWith {};
|
||||
|
||||
missionNamespace setVariable ["PTWS",PTWS_ID];
|
||||
|
||||
_dateID = missionNamespace getVariable "PTWS";
|
||||
_date = format ["getDate:%1", _dateID] call ExileServer_system_database_query_selectFull;
|
||||
_saveddate = (_date select 0) select 0;
|
||||
_saveddate = format ["getDate:%1", PTWS_ID] call ExileServer_system_database_query_selectSingleField;
|
||||
_savedWeather = format ["getWeather:%1", PTWS_ID] call ExileServer_system_database_query_selectSingleField;
|
||||
|
||||
if (typeName _saveddate isEqualTo "ARRAY") then
|
||||
{
|
||||
@ -18,42 +15,69 @@ else
|
||||
diag_log format["PTWS - No saved date found, loading PTWS_StartingDate:%1",PTWS_StartingDate];
|
||||
};
|
||||
|
||||
if (true) then
|
||||
if (typeName _savedWeather isEqualTo "ARRAY") then
|
||||
{
|
||||
diag_log "PTWS - SaveDate Initialised";
|
||||
//[60, PTWS_fnc_saveDate, [], true] call ExileServer_system_thread_addTask; //This doesn't work for some reason :/
|
||||
while {true} do
|
||||
{
|
||||
_dateID = missionNamespace getVariable "PTWS";
|
||||
_currentdate = date;
|
||||
_data =
|
||||
[
|
||||
_currentdate,
|
||||
_dateID
|
||||
];
|
||||
_extDB2Message = ["setDate", _data] call ExileServer_util_extDB2_createMessage;
|
||||
_extDB2Message call ExileServer_system_database_query_fireAndForget;
|
||||
//Borrowed the template from second_coming's occupation mod.
|
||||
if (PTWS_timeAcc) then
|
||||
{
|
||||
if (daytime > PTWS_timeAccNightStart || daytime < PTWS_timeAccDayStart) then
|
||||
{
|
||||
_timeMultiplier = PTWS_timeAccMultiplierNight;
|
||||
}
|
||||
else
|
||||
{
|
||||
_timeMultiplier = PTWS_timeAccMultiplierDay;
|
||||
};
|
||||
|
||||
if(timeMultiplier != _timeMultiplier) then { setTimeMultiplier _timeMultiplier; };
|
||||
};
|
||||
uiSleep 60;
|
||||
};
|
||||
diag_log format["PTWS - Loading last saved weather : %1", _savedWeather];
|
||||
_overcast = _savedWeather select 0;
|
||||
_rain = _savedWeather select 1;
|
||||
_fog = _savedWeather select 2;
|
||||
_wind = _savedWeather select 3;
|
||||
_gusts = _savedWeather select 4;
|
||||
_lightnings = _savedWeather select 5;
|
||||
_waves = _savedWeather select 6;
|
||||
|
||||
0 setovercast _overcast;
|
||||
0 setrain _rain;
|
||||
0 setfog _fog;
|
||||
setwind _wind;
|
||||
0 setgusts _gusts;
|
||||
0 setlightnings _lightnings;
|
||||
0 setwaves _waves;
|
||||
forceWeatherChange;
|
||||
}
|
||||
else
|
||||
{
|
||||
diag_log format["PTWS - No saved weather found, loading PTWS_StartingWeather:%1",PTWS_StartingWeather];
|
||||
_overcast = PTWS_StartingWeather select 0;
|
||||
_rain = PTWS_StartingWeather select 1;
|
||||
_fog = PTWS_StartingWeather select 2;
|
||||
_wind = PTWS_StartingWeather select 3;
|
||||
_gusts = PTWS_StartingWeather select 4;
|
||||
_lightnings = PTWS_StartingWeather select 5;
|
||||
_waves = PTWS_StartingWeather select 6;
|
||||
|
||||
0 setovercast _overcast;
|
||||
0 setrain _rain;
|
||||
0 setfog _fog;
|
||||
setwind _wind;
|
||||
0 setgusts _gusts;
|
||||
0 setlightnings _lightnings;
|
||||
0 setwaves _waves;
|
||||
forceWeatherChange;
|
||||
};
|
||||
/*
|
||||
|
||||
diag_log "PTWS - SaveDate Initialized";
|
||||
//Thanks WolfkillArcadia!
|
||||
[60, PTWS_fnc_saveDate, [], true] call ExileServer_system_thread_addTask;
|
||||
|
||||
diag_log "PTWS - SaveWeather Initialized";
|
||||
[60, PTWS_fnc_saveWeather, [], true] call ExileServer_system_thread_addTask;
|
||||
|
||||
if(PTWS_weatherChangeMin > PTWS_weatherChangeMax) exitwith {hint format["PTWS - Max time: %1 must to be higher than Min time: %2", PTWS_weatherChangeMax, PTWS_weatherChangeMin];};
|
||||
_timeforecast = PTWS_weatherChangeMin;
|
||||
|
||||
if !(PTWS_weatherChangeFast) then {
|
||||
_timeforecast = PTWS_weatherChangeMin + (random (PTWS_weatherChangeMax - PTWS_weatherChangeMin));
|
||||
};
|
||||
|
||||
diag_log "PTWS - ControlWeather Initialized";
|
||||
_timeforecastMinutes = [_timeforecast,"HH:MM:SS"] call BIS_fnc_secondsToString;
|
||||
diag_log format ["PTWS - Time until next forecast:%1",_timeforecastMinutes];
|
||||
[_timeforecast, PTWS_fnc_controlWeather, [], true] call ExileServer_system_thread_addTask;
|
||||
|
||||
if (PTWS_timeAcc) then
|
||||
{
|
||||
diag_log "PTWS - TimeAcc Initialised";
|
||||
//[60, PTWS_fnc_timeAcc, [], true] call ExileServer_system_thread_addTask; //Help please?
|
||||
diag_log "PTWS - TimeAcc Initialized";
|
||||
[60, PTWS_fnc_timeAcc, [], true] call ExileServer_system_thread_addTask;
|
||||
};
|
||||
*/
|
||||
|
||||
|
@ -1,30 +0,0 @@
|
||||
class CfgPatches
|
||||
{
|
||||
class PTWS {
|
||||
units[] = {};
|
||||
weapons[] = {};
|
||||
requiredVersion = 0.1;
|
||||
requiredAddons[] = {};
|
||||
author[]= {"MajorXAcE"};
|
||||
};
|
||||
};
|
||||
|
||||
class CfgFunctions {
|
||||
class PTWS {
|
||||
class main {
|
||||
class postInit
|
||||
{
|
||||
postInit = 1;
|
||||
file = "\PTWS\initServer.sqf";
|
||||
};
|
||||
};
|
||||
/*
|
||||
class compiles
|
||||
{
|
||||
file = "\PTWS\scripts";
|
||||
class saveDate {};
|
||||
class timeAcc {};
|
||||
};
|
||||
*/
|
||||
};
|
||||
};
|
@ -1,13 +0,0 @@
|
||||
//Can't be called by ExileServer_system_thread_addTask for some reason.
|
||||
private["_dateID","_currentdate","_data","_extDB2Message"];
|
||||
missionNamespace setVariable ["PTWS",PTWS_ID];
|
||||
|
||||
_dateID = missionNamespace getVariable "PTWS";
|
||||
_currentdate = date;
|
||||
_data =
|
||||
[
|
||||
_currentdate,
|
||||
_dateID
|
||||
];
|
||||
_extDB2Message = ["setDate", _data] call ExileServer_util_extDB2_createMessage;
|
||||
_extDB2Message call ExileServer_system_database_query_fireAndForget;
|
@ -1,17 +0,0 @@
|
||||
[] spawn
|
||||
{
|
||||
waitUntil {time > 0};
|
||||
diag_log "PTWS - Loading Config";
|
||||
|
||||
// Get the config for PTWS
|
||||
call compile preprocessFileLineNumbers "\PTWS\config.sqf";
|
||||
|
||||
if(isNil "PTWS_CompiledOkay") exitWith { diag_log "PTWS - Failed to read config.sqf, check for typos."; };
|
||||
|
||||
diag_log "PTWS - Initialised";
|
||||
|
||||
// Start PTWS
|
||||
[]execVM "\PTWS\scripts\insertPTWS.sqf";
|
||||
sleep 1;
|
||||
[]execVM "\PTWS\scripts\startPTWS.sqf";
|
||||
};
|
Loading…
Reference in New Issue
Block a user