Additional Folders/Files in System

This commit is contained in:
icomrade
2016-02-27 22:34:50 -05:00
parent 3ba3781432
commit c034f43d0b
53 changed files with 22237 additions and 0 deletions

View File

@@ -0,0 +1,126 @@
#include "scheduler.hpp"
sched_achievement_init = {
private ["_timewasterCounter","_buildingList","_buildingCounter"];
//following achievements are monitored in this task
achievement_LitterCount = 0;
achievement_Gut = false;
// following achievements are monitored and saved elsewhere
achievement_Raw = false;
achievement_Fire = false;
achievement_SteadyAim = false;
achievement_Marksman = false;
achievement_Sniper = false;
// variables for the monitoring
_timewasterCounter = diag_ticktime;
_buildingList = [];
_buildingCounter = [0,0,0,0,0,0,0,0,0];
[_timewasterCounter, _buildingList, _buildingCounter]
};
sched_achievement = {
HIDE_FSM_VARS
private ["_timewasterCounter","_buildingList","_buildingCounter","_buildingAchivement","_buildingType","_buildingLimit","_building","_matchType","_count", "_o"];
_timewasterCounter = _this select 0;
_buildingList = _this select 1;
_buildingCounter = _this select 2;
_buildingAchivement = [
[""], // Achievement #2
["Land_A_GeneralStore_01a","Land_A_GeneralStore_01"], // Achievement #3 (5 stores)
["Land_A_GeneralStore_01a","Land_A_GeneralStore_01"], // Achievement #4 (10 stores)
["Land_A_Hospital"], // Achievement #5
["Land_A_Office01"], // Achievement #6
["Land_a_stationhouse"], // Achievement #7
["Land_A_Pub_01"], // Achievement #8
["Land_Mil_ControlTower"], // Achievement #9
["Land_Church_03"] // Achievement #10
];
_buildingLimit = [ 1, 5, 10, 4, 3, 4, 8, 3, 3 ];
// 0 = Time Waster - have been playing for over _timeWasterValue second in a single session
if (dayz_playerAchievements select 0 < 1) then {
if (diag_ticktime - _timewasterCounter >= 3600) then {
_timewasterCounter = -1; // stop checking
dayz_playerAchievements set [0,1];
achievement = [0, player, dayz_characterID];
publicVariableServer "achievement";
};
};
// 1 = High Flyer - find yourself over 500m ATL
if (dayz_playerAchievements select 1 < 1) then {
if (visiblePosition player select 2 > 500) then {
dayz_playerAchievements set [1,1];
achievement = [1, player, dayz_characterID];
publicVariableServer "achievement";
};
};
// 2 = near mass grave
if (dayz_playerAchievements select 2 < 1) then {
_o = (visiblePositionASL player) nearestObject "Mass_grave";
if ((!isNull _o) and {(_o distance player < 3)}) then {
dayz_playerAchievements set [2,1];
achievement = [2, player, dayz_characterID];
publicVariableServer "achievement";
};
};
// 3-10 = Building checker - counts the number of unique buildings (of a certain type) you visit
_building = nearestBuilding visiblePositionASL player; // gives nearest enterable building within 50 meters
if(!isNull _building) then {
if (!(_building in _buildingList)) then {
_buildingType = typeOf _building;
if ((player distance _building < 0.5 * sizeof _buildingType) and {([player,_building] call fnc_isInsideBuilding)}) then {
_matchType = false;
{
if (_buildingType in _x) then {
_matchType = true;
_count = _buildingCounter select _forEachIndex;
_count = _count +1;
_buildingCounter set [_forEachIndex, _count ];
if ((_count >= _buildingLimit select _forEachIndex) and (dayz_playerAchievements select (_forEachIndex + 3) < 1)) then {
dayz_playerAchievements set [ _forEachIndex + 3, 1];
achievement = [_forEachIndex + 3, player, dayz_characterID];
publicVariableServer "achievement";
};
};
} forEach _buildingAchivement;
if (_matchType) then {
_buildingList set [ count _buildingList, _building ];
};
};
};
};
// 11 = LitterCount
if (dayz_playerAchievements select 11 < 1) then {
if (achievement_LitterCount == 5) then {
achievement_LitterCount = -1; //???
dayz_playerAchievements set [11,1];
achievement = [11, player, dayz_characterID];
publicVariableServer "achievement";
};
};
// 12 = ??????
// 13 = Gutting
if (dayz_playerAchievements select 13 < 1) then {
if (achievement_Gut) then {
dayz_playerAchievements set [13,1];
achievement = [13, player, dayz_characterID];
publicVariableServer "achievement";
};
};
[_timewasterCounter, _buildingList, _buildingCounter]
};

View File

@@ -0,0 +1,79 @@
// refactored by facoptere@gmail.com for DayZ mod.
#include "scheduler.hpp"
sched_animals = {
HIDE_FSM_VARS
private ["_min","_count","_global","_obj","_x","_animalssupported","_type","_root","_favouritezones","_angle","_radius","_randrefpoint","_PosList","_Pos","_agent","_pos", "_vehicle", "_speed", "_i"];
_min = diag_fpsmin;
_vehicle = vehicle player;
_count = 0;
_global = 0;
{
_obj = agent _x;
if (_obj isKindOf "CAAnimalBase") then {
if (local _obj) then {
/*if !(_obj setVariable [ "", false ]) then { // animal has been transfered, there is no fsm
private [ "_stance", "_phase", "_dir", "_posagt" ];
_stance = animationState _obj;
_phase = _obj animationPhase _stance;
_dir = direction _obj;
_posagt = visiblePosition _obj;
_obj = createAgent [typeOf _obj, _posagt, [], 0, "CAN_COLLIDE"];
_obj animate [_stance, _phase];
_obj setDir _dir;
_obj setPosATL _posagt;
[_posagt,_obj] execFSM "\z\addons\dayz_code\system\animal_agent.fsm";
_obj setVariable [ "", true ];
};*/
if ((_vehicle distance _obj > dayz_animalDistance*1.33) AND {(0 == {((isplayer _x) AND {(_x != player)}) AND {((alive _x) AND {((vehicle _x) distance _obj < 150)})}} count playableUnits)}) then {
// delete animal
deleteVehicle _obj;
_global = _global - 1;
// diag_log format [ "%2: delete %1", _obj, __FILE__ ];
}
else {
_count = _count + 1;
};
};
_global = _global + 1;
};
} forEach agents;
_speed = velocity _vehicle;
if (_speed distance [0,0,0] > 12) exitWith {objNull};
if ((_vehicle != player) AND {((count crew _vehicle > 1) AND {(driver _vehicle != player)})}) exitWith {objNull};
//diag_log [ dayz_maxGlobalAnimals / (1 max count playableUnits), ceil(1.2*(dayz_maxGlobalAnimals - _global) / (1 max count playableUnits)) min (dayz_maxAnimals - _count), _global,dayz_maxAnimals, _count, dayz_maxGlobalAnimals, _global ];
for "_x" from 0 max (2 min (ceil(1.5*(dayz_maxGlobalAnimals - _global) / (1 max count playableUnits)) min (dayz_maxAnimals - _count))) to 1 step -1 do {
_animalssupported = ["hen","hen","hen","Cow","Sheep","WildBoar","WildBoar","WildBoar","Goat","Rabbit","Rabbit"];
_type = _animalssupported select floor random count _animalssupported;
if (_type == "Cow") then {
_animalssupported = ["Cow01","Cow02","Cow03","Cow04"];
_type = _animalssupported select floor random count _animalssupported;
};
_root = configFile >> "CfgVehicles" >> _type;
_favouritezones = getText ( _root >> "favouritezones");
_angle = (random 120) - 60;
_radius = 0 max ((dayz_animalDistance - 200)/2);
_randrefpoint = (vehicle player) modelToWorld[sin(_angle) * (200 + _radius) , cos(_angle) * (200 + _radius), 0];
_randrefpoint = [ (_randrefpoint select 0) + 5*(_speed select 0), (_randrefpoint select 1) + 5*(_speed select 1), 0];
for "_i" from 1 to 10 do {
_PosList = selectbestplaces [_randrefpoint, _radius, _favouritezones, 10, 5];
if (count _PosList > 0) then {
_Pos = (_PosList select 0) select 0;
if ((!surfaceIsWater _Pos) AND {(0 == {alive _x} count (_Pos nearEntities [ AllPlayers, 200 ]))}) then {
_agent = createAgent [_type, _Pos, [], 0, "FORM"];
[_pos,_agent] execFSM "\z\addons\dayz_code\system\animal_agent.fsm";
_agent setVariable [ "", true ];
_count = _count + 1;
_global = _global + 1;
// diag_log format [ "%4: added %1 at %2, %5m from player (favourite level: %3)", _type, _Pos,
// (_PosList select 0) select 1, __FILE__, round(_Pos distance player) ];
_i = 11;//break
};
};
};
};
// diag_log format [ "%1: update animals. local: %5, global: %6 fps: %2 -> %3%4",__FILE__, _min, diag_fpsmin,if (diag_fpsmin < 10) then {"!! <<<<<<<<<<<<<<<<<<<"} else {""}, _count, _global ];
objNull
};

View File

@@ -0,0 +1,68 @@
/*
Anti-Teleport
Created By Razor
Refactored By Alby
Refactored By facoptere@gmail.com
*/
sched_antiTP_init = {
if (dayz_antihack == 1) then { diag_log [ diag_ticktime, __FILE__, "Anti Teleport inited"]; };
[dayz_antihack == 1, [], 0, 0, objNull]
};
sched_antiTP = {
private ["_lastpos","_lastheight","_lasttime","_lastVehicle","_debug","_curpos","_distance","_curtime","_difftime",
"_curheight","_speed","_topSpeed","_terrainHeight","_safetyVehicle","_curPos"];
_antihack = _this select 0;
_lastpos = _this select 1;
_lastheight = _this select 2;
_lasttime = _this select 3;
_lastVehicle = _this select 4;
if (((_antihack) and {(typeName player == "OBJECT")}) AND {((player in playableUnits) AND {(alive player)})}) then {
if (count _lastpos != 3) then {
_lastpos = getPosATL (vehicle player);
_lastheight = (ATLtoASL _lastpos) select 2;
_lasttime = diag_ticktime;
_lastVehicle = vehicle player;
};
_curpos = getPosATL (vehicle player);
_distance = _lastpos distance _curpos;
_curtime = diag_ticktime;
_difftime = _curtime - _lasttime;
_debug = getMarkerpos "respawn_west";
if ((_distance > 10) OR {(_difftime > 1)}) then {
_curheight = (ATLtoASL _curpos) select 2;
_speed = _distance / _difftime;
_topSpeed = 10;
if (vehicle player != player) then {
_topSpeed = (getNumber (configFile >> "CfgVehicles" >> typeOf (vehicle player) >> "maxSpeed")) min 500;
};
_terrainHeight = getTerrainHeightASL [_curpos select 0, _curpos select 1];
_safetyVehicle = vehicle player;
if (_lastVehicle == vehicle player) then {
if ((_speed > _topSpeed) && (alive player) && ((driver (vehicle player) == player) or (isNull (driver (vehicle player)))) && (_debug distance _lastpos > 3000) && !((vehicle player == player) && (_curheight < _lastheight) && ((_curheight - _terrainHeight) > 1))) then {
(vehicle player) setposATL _lastpos;
PVDZ_sec_atp = format["TELEPORT REVERT for player UID#%1 from %2 to %3, %4 meters, now at %5", getPlayerUID player, _lastpos, _curPos, round(_lastpos distance _curpos), getPosATL player];
publicVariableServer "PVDZ_sec_atp";
} else {
_lastpos = _curpos;
_lastheight = _curheight;
};
_lasttime = _curtime;
};
if (_safetyVehicle == vehicle player) then {
_lastVehicle = vehicle player;
};
};
};
[_antihack, _lastpos, _lastheight, _lasttime, _lastVehicle]
};

View File

@@ -0,0 +1,40 @@
// (c) facoptere@gmail.com, licensed to DayZMod for the community
sched_bloodStains_init = {
[] // _bloodpool init
};
sched_bloodStains = {
private ["_end","_lastpos","_stain", "_plpos"];
_bloodpool = _this;
_plpos = visiblePosition player; //ATL
if (r_player_injured and {(dayz_bleedingeffect % 2 == 1)}) then {
// add a fresh blood stain
if (((vehicle player == player) and (!dayz_isSwimming)) AND {((_plpos select 2 < 0.3) AND {((getTerrainHeightASL _plpos) > 1.5)})}) then {
_end = count _bloodpool -1;
_lastpos = if (_end >= 0) then { getPosATL (_bloodpool select _end) } else { getMarkerpos "respawn_west" };
if (_plpos distance _lastpos > 3) then { // don't repeat blood stains on the same spot
_stain = createVehicle ["Blood_Trail_DZ", _plpos, [], 0, "CAN_COLLIDE"];
//_stain setDir (direction player);
_bloodpool set [ _end+1, _stain ];
if (_end == 59) then {
// remove the oldest blood stain, to limit total amount to 60 stains
_stain = _bloodpool select 0;
_bloodpool = _bloodpool - [_stain];
deleteVehicle _stain;
};
};
};
}
else {
// remove the oldest blood stain
if (count _bloodpool > 0) then {
_stain = _bloodpool select 0;
_bloodpool = _bloodpool - [_stain];
deleteVehicle _stain;
};
};
_bloodpool
};

View File

@@ -0,0 +1,21 @@
sched_buildingBubble = {
private "_dis";
{
_dis = _x distance player;
if ((player distance _x) > 400) then {
if (_x in dayz_buildingBubbleMonitor) then {
dayz_buildingBubbleMonitor = dayz_buildingBubbleMonitor - [_x];
};
//Clear Loot vars
if (!(isNil {player getVariable "looted"})) then {
_x setVariable ["looted",nil]; //SpawnCheck
};
if (!(isNil {player getVariable "zombieSpawn"})) then {
_x setVariable ["zombieSpawn",nil]; //SpawnCheck
};
};
} count dayz_buildingBubbleMonitor;
objNull
};

View File

@@ -0,0 +1,79 @@
// (c) facoptere@gmail.com, licensed to DayZMod for the community
sched_buriedZeds_init = {
[] // it's _buriedZeds
};
sched_buriedZeds = {
private ["_a","_c","_b","_node","_foot","_head","_z","_x","_pos",
"_config", "_zedPos", "_elevation","_buriedZeds", "_checkInsideBuilding"];
_checkInsideBuilding = {
private ["_building","_this","_point","_inside","_offset","_relPos","_boundingBox","_min","_max","_myX","_myY"];
_building = _this select 0;
_point = _this select 1;
_inside = false;
_offset = 1; // shrink building boundingbox by this length.
_relPos = _building worldToModel _point;
_boundingBox = boundingBox _building;
_min = _boundingBox select 0;
_max = _boundingBox select 1;
_myX = _relPos select 0;
_myY = _relPos select 1;
if ((_myX > (_min select 0)+_offset) and {(_myX < (_max select 0)-_offset)}) then {
if ((_myY > (_min select 1)+_offset) and {(_myY < (_max select 1)-_offset)}) then {
_inside = (1==1);
};
};
_inside
};
_buriedZeds = _this;
_c = count _buriedZeds;
if (_c > 0) then { // give a zombie a little pitch if necessary
_c = _c - 1;
_node = _buriedZeds select _c;
_foot = _node select 0;
_head = _node select 1;
_z = _node select 2;
_elevation = _node select 3;
if (lineIntersects [_head, _foot,_z]) then {
_pos = getPosATL _z;
_pos set [2, _elevation];
_z setPosATL _pos;
_z setVelocity [0,0,0.5];
//diag_log [ __FILE__, "node", _node, "moveto:", _pos ];
};
_buriedZeds resize _c;
}
else { // find potential buried Zeds
{
_z = _x;
_pos = (getPosATL _z);
if ((alive _z) AND {(_pos select 2 < 0.05)}) then {
//_a = _a + 1;
_b = nearestBuilding _z;
if (!isNull _b) then {
_config = configFile >> "CfgLoot" >> "Buildings" >> (typeOf _b) >> "zedPos";
_zedPos = [] + getArray _config;
if ((count _zedPos > 0) and {([_b, _pos] call _checkInsideBuilding)}) then {
_elevation = (_b modelToWorld (_zedPos select 0)) select 2; // ATL
_foot = ATLtoASL _pos;
_foot set [ 2, (_foot select 2) + 0.1 ];
_head = +(_foot);
_head set [ 2, (_foot select 2) + 1.5 ];
if (_elevation < _head select 2) then { // don't handle if lootpos is quite high inside the building.
_buriedZeds set [ count _buriedZeds, [_foot, _head, _z, _elevation] ];
};
};
};
};
} count ((getPosATL player) nearEntities ["zZombie_Base", 30]);
};
//diag_log format [ "alive+ground: %1, inbuilding: %2 plr in:%3 %4", _a, _c, [_b, getPosATL player] call _checkInsideBuilding, _b ];
_buriedZeds
};

View File

@@ -0,0 +1,50 @@
// (c) facoptere@gmail.com, licensed to DayZMod for the community
sched_gravity_init = {
// time, current position, time when freefall starts, position when freefall start, freefall in progress
[ time, VisiblePositionASL player, time, VisiblePositionASL player, false, false]
};
sched_gravity = {
private ["_otime","_opos","_offtime","_offpos","_oid","_idTrickCount","_timeTrickCount","_time","_ppos","_fftime","_ffpos","_pid","_netid","_initDone"];
if ((!(_this select 5) and !isNil 'Dayz_loginCompleted') and {(Dayz_loginCompleted)}) then {
_this = [ time, VisiblePositionASL player, time, VisiblePositionASL player, false, true];
diag_log [ diag_tickTime, __FILE__, "freefall inited" ];
};
_otime = _this select 0;
_opos = _this select 1;
_offtime = _this select 2;
_offpos = _this select 3;
_inprogress = _this select 4;
_initDone = _this select 5;
if (_initDone) then {
// detect and save freefall start
_time = time;
_ppos = VisiblePositionASL player;
_fftime = _time;
_ffpos = +(_ppos);
if ((_opos select 2) - (_ppos select 2) >= if (_inprogress) then {0.1} else {0.39} ) then {
_fftime = _offtime;
_ffpos = +(_offpos);
_inprogress = true;
//diag_log [ diag_tickTime, __FILE__, "global freefall is currently dh:", (_ffpos select 2) - (_ppos select 2), "dt:", _time - _fftime,"gravity:",2*((_ffpos select 2) - (_ppos select 2))/((0.00001 + _time - _fftime)^2) ,"m.s^-2" ];
Dayz_freefall = [ _fftime, 0 max ((_ffpos select 2) - (_ppos select 2)), _time - _fftime ];
}
else {
if (_inprogress) then {
diag_log [ diag_tickTime, __FILE__, "freefall reset, final freefall height is dh:", (_offpos select 2) - (_ppos select 2), "dt:", _time - _offtime, "gravity:",2*((_offpos select 2) - (_ppos select 2))/((_time - _offtime)^2) ,"m.s^-2" ];
Dayz_freefall = [ _fftime, 0 max ((_offpos select 2) - (_ppos select 2)), _time - _offtime ];
}
else {
Dayz_freefall = [ _time, 0, 0.1 ]; // not falling
};
_inprogress = false;
};
[ _time, _ppos, _fftime, _ffpos, _inprogress, _initDone ]
}
else { _this }
};

View File

@@ -0,0 +1,34 @@
#include "scheduler.hpp"
sched_gui_init = { [false] };
sched_gui = {
HIDE_FSM_VARS
private [ "_array", "_initDone" ];
_initDone = _this select 0;
if ((!_initDone and !isNil 'Dayz_loginCompleted') and {(Dayz_loginCompleted)}) then {
3 cutRsc ['playerStatusGUI', 'PLAIN',3]; // show the whole HUD
_initDone = true;
};
//else {
// diag_log [ diag_Ticktime, __FILE__, "waiting", _initDone,Dayz_loginCompleted];
//};
if (_initDone) then {
_array = player call world_surfaceNoise;
dayz_surfaceNoise = _array select 1;
dayz_surfaceType = _array select 0;
call player_checkStealth;
dayz_statusArray = call player_updateGui;
};
// move this elsewhere, it deals with the menu
if (!isNull cursorTarget and !dayz_heartBeat) then {
if (alive cursorTarget) then {
cursorTarget spawn dayz_lowHumanity;
};
};
[_initDone]
};

View File

@@ -0,0 +1,51 @@
// (c) facoptere@gmail.com, licensed to DayZMod for the community
_base="z\addons\dayz_code\system\scheduler\";
call compile preprocessFileLineNumbers (_base+"sched_oneachframe.sqf");
call compile preprocessFileLineNumbers (_base+"sched_towngenerator.sqf");
call compile preprocessFileLineNumbers (_base+"sched_throwable.sqf");
call compile preprocessFileLineNumbers (_base+"sched_planthint.sqf");
call compile preprocessFileLineNumbers (_base+"sched_bloodstains.sqf");
call compile preprocessFileLineNumbers (_base+"sched_animals.sqf");
call compile preprocessFileLineNumbers (_base+"sched_buriedZeds.sqf");
call compile preprocessFileLineNumbers (_base+"sched_gravity.sqf");
call compile preprocessFileLineNumbers (_base+"sched_security.sqf");
call compile preprocessFileLineNumbers (_base+"sched_antiTeleport.sqf");
call compile preprocessFileLineNumbers (_base+"sched_newDay.sqf");
call compile preprocessFileLineNumbers (_base+"sched_spawnCheck.sqf");
call compile preprocessFileLineNumbers (_base+"sched_playerActions.sqf");
call compile preprocessFileLineNumbers (_base+"sched_medical.sqf");
call compile preprocessFileLineNumbers (_base+"sched_achievement.sqf");
call compile preprocessFileLineNumbers (_base+"sched_gui.sqf");
call compile preprocessFileLineNumbers (_base+"sched_buildingBubble.sqf");
_list = [];
if (!isNil "_this") then { call _this; }; // patch the code before starting the scheduler (the task contents can't be modified after the FSM has started)
if (count _list == 0) then {
_list = [
// period offset loop code <-> ctx, init code ->ctx
[ 0, 0, sched_onEachFrame, sched_onEachFrame_init ], // SPECIAL: nul period -> code returns boolean requesting to skip other tasks
[ 0.2, 20, sched_gravity, sched_gravity_init ],
[ 0.2, 0.15, sched_security, sched_security_init ],
[ 0.2, 0.05, sched_antiTP, sched_antiTP_init ],
[ 0.1, 0.01, sched_playerActions ],
[ 0.2, 0.07, sched_townGenerator, sched_townGenerator_init ],
[ 0.2, 0.12, sched_gui, sched_gui_init ],
[ 2, 0.13, sched_medical_effects, sched_medical_effects_init ],
[ 10, 15.13, sched_medical_effectsSlow ],
[ 6, 24.18, sched_spawnCheck, sched_spawnCheck_init ],
[ 1, 0.63, sched_throwable, sched_throwable_init ],
[ 1, 0.33, sched_medical, sched_medical_init ],
[ 10, 0.26, sched_plantHint ],
[ 3, 2.70, sched_achievement, sched_achievement_init ],
[ 4, 2.38, sched_bloodStains, sched_bloodStains_init ],
[ 60, 10.44, sched_animals ],
[ 10, 5.44, sched_medical_slow ],
[ 15, 35.44, sched_buildingBubble ],
[ 60, 20.44, sched_newDay ],
[ 1, 0.51, sched_buriedZeds, sched_buriedZeds_init ]
];
};
_list execFSM (_base+"scheduler.fsm");
diag_log [ diag_tickTime, __FILE__, "Scheduler started"];

View File

@@ -0,0 +1,152 @@
// (c) facoptere@gmail.com, licensed to DayZMod for the community
#include "scheduler.hpp"
sched_medical_slow = { // 10 seconds
if (abs (r_player_blood - (player getVariable["USEC_BloodQty", 12000])) > 120) then {
//Do not global send
player setVariable["USEC_BloodQty", r_player_blood, false];
player setVariable["medForceUpdate", true, false];
//Send only to server
PVDZ_serverStoreVar = [player, "USEC_BloodQty", r_player_blood];
publicVariableServer "PVDZ_serverStoreVar";
};
objNull
};
sched_medical_init = { [ []spawn{} ] };
sched_medical = { // 1 second
HIDE_FSM_VARS
private "_unconHdlr";
_unconHdlr = _this select 0;
if (r_player_blood == 12000) then {
r_player_foodstack = 0;
};
//r_player_unconscious = getVariable ["NORRN_unconscious", true];
if (r_player_blood <= 0) then {
[dayz_sourceBleeding, "bled"] spawn player_death;
};
if (!canStand player) then { // be consistant with player_updateGui.sqf
if ((player getVariable ["hit_legs", 0] < 1) OR !r_fracture_legs) then {
player setVariable ["hit_legs",1,true];
r_fracture_legs = true;
};
};
if ((r_player_blood <= 3000) and !r_player_unconscious) then {
if (random 100 > 99) then {
[player, ((random 0.1) + 0.2)] call fnc_usec_damageUnconscious;
};
};
//Handle Unconscious player
if ((r_player_unconscious) and (!r_player_unconsciousInProgress) and (scriptDone _unconHdlr)) then {
//localize "CLIENT: Start Unconscious Function";
_unconHdlr = [] spawn fnc_usec_unconscious;
};
if (r_player_injured) then {
if (!r_player_handler) then {
r_player_handler = true;
[] spawn fnc_usec_playerHandleBlood;
};
} else {
[] spawn fnc_usec_playerHandleBlood;
};
[_unconHdlr]
};
sched_medical_effects_init = {
private ["_hndCC", "_hndDB", "_hndRB"];
_hndCC = ppEffectCreate ["colorCorrections", 3];
_hndCC ppEffectEnable true;
_hndDB = ppEffectCreate ["dynamicBlur", 2];
_hndDB ppEffectEnable true;
_hndRB = ppEffectCreate ["radialBlur", 1];
_hndRB ppEffectEnable true;
_hndRB ppEffectAdjust [0, 0, 0.5, 0.5];
_hndRB ppEffectCommit 0;
[ _hndCC, _hndDB, _hndRB ]
};
sched_medical_effects = {
// every 2 seconds:
// change saturation, blur and vignetting according to blood level
// Shivering if character temperature is near the minimum
private ["_hndCC", "_hndDB", "_tmp1", "_tmp2", "_tmp3"];
_hndCC = _this select 0;
_hndDB = _this select 1;
_hndRB = _this select 2;
if (r_player_infected) then {
_tmp1 = 0.4 + 0.06 * cos(diag_tickTime * 360 / 12);
_tmp2 = 0.05 + 0.03 * cos(diag_tickTime * 360 / 4);
_tmp3 = 0.05 + 0.03 * sin(diag_tickTime * 360 / 4);
_hndRB ppEffectAdjust [_tmp2, _tmp3, _tmp1, _tmp1];
}
else {
_hndRB ppEffectAdjust [0, 0, 0.5, 0.5];
};
if (r_player_unconscious) then {
// TODO: 0 fadeSound 0.05;
_hndCC ppEffectAdjust [1, 0.2, 0, [1, 1, 1, 0], [1, 1, 1, 0], [1, 1, 1, 0]];
_hndDB ppEffectAdjust [20];
}
else {
_tmp1 = r_player_blood/r_player_bloodTotal;
_tmp1 = (1 + random 7) * _tmp1;
_tmp1 = 1 min _tmp1;
_tmp2 = if (_tmp1 > 0.5) then {1} else {0.3};
_hndCC ppEffectAdjust [1, 1, 0, [1, 1, 1, 0], [_tmp2, _tmp2, _tmp2, _tmp1], [1, 1, 1, 0]];
_hndDB ppEffectAdjust [0];
};
[_hndCC, _hndDB, _hndRB] ppEffectCommit 1.5;
//Add Shivering
if (dayz_temperatur <= (0.125 * (dayz_temperaturmax - dayz_temperaturmin) + dayz_temperaturmin) and ((vehicle player == player and speed player < 5) or (vehicle player != player))) then {
addCamShake [0.6 * (dayz_temperaturmin / dayz_temperatur), 2, 30];
};
[ _hndCC, _hndDB, _hndRB ]
};
sched_medical_effectsSlow = {
// every 10 seconds: diziness using slow shakecam, to handle pain and lack of water
HIDE_FSM_VARS
r_player_inpain = true;
if ((r_player_inpain or dayz_thirst >= SleepWater) and !r_player_unconscious and (1 > random 9) and (0 == player getVariable["startcombattimer",0])) then {
_blurTask = [] spawn {
_strength = 0.5 + (random 1);
_duration = 8 + (random 10);
enableCamShake true;
//[posCoef, vertCoef, horzCoef, bankCoef, interpolation]
setCamShakeParams [0.02, 0.05, 0.1, 0.3, true];
addCamShake [_strength, _duration, 0.4];
playSound "breath_1";
//Lets make sure the spawn ends 1 sec after the _duration timer this should provide a smooth transtion rather then a snap to focus.
sleep _duration + 1;
};
};
if (r_player_infected and !r_player_unconscious and 1 > random 2 and ((vehicle player == player and speed player < 5) or (vehicle player != player))) then {
[player,"cough",1,false] call dayz_zombieSpeak;
addCamShake [2, 1, 25];
};
objNull
};

View File

@@ -0,0 +1,13 @@
#include "scheduler.hpp"
sched_newDay = {
HIDE_FSM_VARS
private "_day";
_day = round(360 * (dateToNumber date));
if(dayz_currentDay != _day) then {
dayz_sunRise = call world_sunRise;
dayz_currentDay = _day;
};
objNull
};

View File

@@ -0,0 +1,33 @@
// (c) facoptere@gmail.com, licensed to DayZMod for the community
// detect low FPS
// in case of player "lag" (fps_min very low), all other scheduler tasks are suspended during 50 frames
sched_onEachFrame_init = {
sched_ef_lowFPSctr=0;
objNull
};
sched_onEachFrame = {
private ["_ret"];
_ret = (1==0);
if (diag_fpsmin < 10) then {
sched_ef_lowFPSctr = sched_ef_lowFPSctr +1;
if (sched_ef_lowFPSctr < 50) then {
_ret = (1==1);
}
}
else {
if (sched_ef_lowFPSctr == 1) then { hintSilent ""; };
sched_ef_lowFPSctr = 0 max (sched_ef_lowFPSctr -1);
};
if (sched_ef_lowFPSctr >= 100) then {
sched_ef_lowFPSctr = 2;
hintSilent localize "str_player_lowPFS";
diag_log format [ "h1nt: LOW FPS (%1)", diag_fpsmin ];
};
_ret
};

View File

@@ -0,0 +1,19 @@
// (c) facoptere@gmail.com, licensed to DayZMod for the community
// grasshopper sound near gatherable plants
sched_plantHint = {
{
(getPosATL _x) spawn {
sleep random 10;
_sound=format["Sound_Crickets%1",1+floor random 3];
//diag_log [ _sound ];
_x = createSoundSource [_sound, _this, [], 0];
sleep 2;
deleteVehicle _x;
};
false
} count (nearestObjects [getPosATL player, ["Plant_Base"], 15]);
objNull
};

View File

@@ -0,0 +1,10 @@
#include "scheduler.hpp"
sched_playerActions = {
HIDE_FSM_VARS
call fnc_usec_selfActions;
call fnc_usec_damageActions;
call fnc_usec_upgradeActions;
objNull
};

View File

@@ -0,0 +1,75 @@
// (c) facoptere@gmail.com, licensed to DayZMod for the community
sched_security_init = {
if (dayz_antihack == 1) then { diag_log [ diag_ticktime, __FILE__, "Some security routines inited"]; };
if (dayz_antihack == 1) then { [ "", time, 0, 0, grpNull ] } else { [] }
};
sched_security = {
private ["_netid","_timeTrickCount","_idTrickCount","_time","_otime","_pid", "_quit", "_list"];
if (count _this != 5) exitWith { [] };
_netid = _this select 0;
_otime = _this select 1;
_idTrickCount = _this select 2;
_timeTrickCount = _this select 3;
_grp = _this select 4;
_time = time;
if (typeName player != "OBJECT") then {
PVDZ_sec_atp = format["WARNING typename error for player UID#%1", getPlayerUID player];
publicVariableServer "PVDZ_sec_atp";
endMission "LOSER";
};
switch (true) do {
case (1==0) : {
PVDZ_sec_atp = format["WARNING true error for player UID#%1", getPlayerUID player];
publicVariableServer "PVDZ_sec_atp";
endMission "LOSER";
};
};
_timeTrickCount = _timeTrickCount * 0.8;
if (_time - _otime > 1 or _time < _otime) then {
_timeTrickCount = _timeTrickCount +1;
if (_timeTrickCount > 2) then {
PVDZ_sec_atp = format["WARNING unusual time shift for UID#%1", getPlayerUID player];
publicVariableServer "PVDZ_sec_atp";
};
};
_pid = netid player;
_idTrickCount = _idTrickCount * 0.8;
if (_pid != _netid) then {
_idTrickCount = _idTrickCount +1;
if (_idTrickCount > 2) then {
PVDZ_sec_atp = format["WARNING unusual outfit swap for UID#%1", getPlayerUID player];
publicVariableServer "PVDZ_sec_atp";
};
};
if (isNull _grp) then { _grp = group ((allmissionobjects 'FunctionsManager') select 0); };
if (!isNull _grp) then {
_list = units _grp;
if (count _list > 1) then {
_quit = false;
for "_i" from 2 to (count _list)-1 do {
_u = (_list select _i);
if (!isNull _u) then {
_pos = getPosATL _u;
PVDZ_sec_atp = format [ "From play3r UID#%1: illegal gr0up m3mber %2 at %3,%4... Server may be compromised!", getPlayerUID player, typeOf _u, _pos select 0, _pos select 1];
publicVariableServer "PVDZ_sec_atp";
deleteVehicle _u;
_quit = true;
};
};
if (_quit) then {
endMission "LOSER";
};
};
};
[ _pid, _time, _idTrickCount, _timeTrickCount, _grp ]
};

View File

@@ -0,0 +1,10 @@
#include "scheduler.hpp"
sched_spawnCheck_init = { []spawn{} };
sched_spawnCheck = {
HIDE_FSM_VARS
if (scriptDone _this) then {
_this = [] execVM '\z\addons\dayz_code\compile\player_spawnCheck.sqf'; // stuffed with "sleep" commands, can't put it in scheduler
};
_this;
};

View File

@@ -0,0 +1,46 @@
// (c) facoptere@gmail.com, licensed to DayZMod for the community
// automatically select primary weapon after inactivity on throwable weapon
// (The problem in ArmA is that when a player select a throwable, he still holds the primary weapon in hand,
// the throwable appears in his hand only when the player clicks on fire button)
sched_throwable_init = {
sched_throwable_prevmuzz="";
sched_throwable_time=0;
objNull
};
sched_throwable = {
private ["_stance","_cur_muzz","_type", "_x"];
if ((!isNil "player") and {(!isNull player)}) then {
_cur_muzz = currentMuzzle player;
if (((!isNil "_cur_muzz") and {(_cur_muzz != "")}) AND {(0 == getNumber(configFile >> "CfgWeapons" >> _cur_muzz >> "type"))}) then {
if (sched_throwable_prevmuzz != _cur_muzz) then {
sched_throwable_prevmuzz = currentMuzzle player;
sched_throwable_time = diag_tickTime+11;
};
if (((player getVariable["combattimeout", diag_tickTime])-diag_tickTime)>27) then {
sched_throwable_time = diag_tickTime+21;
};
};
if (abs(sched_throwable_time-diag_tickTime)<2) then {
_stance = toArray (animationState player);
_stance = if ((!isNil "_stance") and {(count _stance>17)}) then {toString [_stance select 17]} else {""};
_type = 4096;
switch _stance do {
case "p": { _type = 2; };
case "r": { _type = 1; };
};
{
if (_type == getNumber(configFile >> "CfgWeapons" >> _x >> "type")) exitWith {
player selectWeapon _x;
};
} count (weapons player);
sched_throwable_time = 0;
};
};
objNull
};

View File

@@ -0,0 +1,226 @@
// (c) facoptere@gmail.com, licensed to DayZMod for the community
#include "scheduler.hpp"
// look for cells around this radius
#define NEARBYSIZE 380
// how many objects to create per frame
#define CHUNKSIZE 10
// do nothing if player position is close from previous position, distance in meter.
#define TRESHOLD 50
sched_townGenerator_init = {
private ["_maxX","_maxY","_townarray","_objectarray","_i","_object","_j","_position","_y","_type","_dir",
"_onFire","_index","_cell", "_x","_farFromCenter"];
sched_tg_state = -1;
sched_tg_follow = {player}; //use some code here, could be useful for GCAM to change the character to follow
sched_tg_newActive = [];
sched_tg_currentActive = [];
sched_tg_var1 = 0;
sched_tg_var2 = 0;
sched_tg_grid = [];
sched_tg_grid resize 4096;
sched_tg_minX=50000;
sched_tg_minY=50000;
sched_tg_ready=false;
sched_tg_pos=getMarkerpos "respawn_west";
_maxX=-50000;
_maxY=-50000;
_townarray = configFile >> "CfgTownGeneratorChernarus";
// Compute the area size
for "_i" from (count _townarray)-1 to 0 step -1 do {
_objectarray = (_townarray select _i);
for "_j" from ((count _objectarray) - 1) to 0 step -1 do {
_object = _objectarray select _j;
if (isClass(_object)) then {
_position = [] + getArray (_object >> "position");
_x = _position select 0;
_y = _position select 1;
sched_tg_minX = sched_tg_minX min _x;
sched_tg_minY = sched_tg_minY min _y;
_maxX = _maxX max _x;
_maxY = _maxY max _y;
};
};
};
sched_tg_minX = floor sched_tg_minX;
sched_tg_minY = floor sched_tg_minY;
sched_tg_cellX = ceil((_maxX - sched_tg_minX) / 64);
sched_tg_cellY = ceil((_maxY - sched_tg_minY) / 64);
// Building the 4096 matrix...
for "_i" from (count _townarray)-1 to 0 step -1 do {
_objectarray = (_townarray select _i);
for "_j" from (count _objectarray) - 1 to 0 step -1 do {
_object = _objectarray select _j;
if (isClass(_object)) then {
_position = [] + getArray (_object >> "position");
_type = getText (_object >> "type");
_dir = getNumber (_object >> "direction");
//_onFire = getNumber (_object >> "onFire");
_x = _position select 0;
_y = _position select 1;
_index = floor((_x - sched_tg_minX) / sched_tg_cellX) + floor((_y - sched_tg_minY) / sched_tg_cellY) * 64;
_farFromCenter = [0.5,0.5,0] distance [((_x - sched_tg_minX) / sched_tg_cellX) % 1, ((_y - sched_tg_minY) / sched_tg_cellY) % 1, 0];
_cell = sched_tg_grid select _index;
if (isNil "_cell") then { _cell = []; sched_tg_grid set [ _index, _cell]; };
if (_farFromCenter > 0.6) then { // put objects far from cell center at the beginning of the array of object
_cell = [[ objNull, _type, _position, _dir/*, _onFire*/ ]] + _cell;
}
else {
_cell set [ count _cell, [ objNull, _type, _position, _dir/*, _onFire*/ ] ];
}
};
};
};
objNull
};
sched_townGenerator_ready = {
HIDE_FSM_VARS
private "_character";
_character = if (serverCommandAvailable "#kick") then { call sched_tg_follow } else { player };
((!isNil "sched_tg_state") AND {(sched_tg_state == 2)}) AND ({sched_tg_pos distance visiblePositionASL _character <= TRESHOLD})
};
sched_townGenerator = {
HIDE_FSM_VARS
private ["_character","_position","_y","_velocity","_iy","_i","_j","_jx",
"_index","_cell","_imax","_object","_onFire", "_x"];
switch true do {
case (sched_tg_state == 0): { // look for new cells to show and old cells to hide
_character = if (serverCommandAvailable "#kick") then { call sched_tg_follow } else { player };
_position = visiblePositionASL _character;
if ((_position distance sched_tg_pos > TRESHOLD) /*AND {(_position select 0 > -NEARBYSIZE)}*/) then {
sched_tg_pos = _position;
_x = _position select 0;
_y = _position select 1;
// shift position to 1 second in the future:
_velocity = velocity vehicle _character;
_x = _x + (_velocity select 0);
_y = _y + (_velocity select 1);
sched_tg_newActive resize 0;
for "_i" from (_y+NEARBYSIZE) to (_y-NEARBYSIZE) step -sched_tg_cellY do {
_iy = floor((_i - sched_tg_minY) / sched_tg_cellY);
if ((_iy >= 0) AND {(_iy < 64)}) then {
for "_j" from (_x-NEARBYSIZE) to (_x+NEARBYSIZE) step sched_tg_cellX do {
//diag_log format [ "%1: x y _i _j %1 %2 %3 %4", __FILE__, _x, _y, _i, _j ];
_jx = floor((_j - sched_tg_minX) / sched_tg_cellX);
if ((_jx >= 0) AND {(_jx < 64)}) then {
if (abs((_j-_x)*(_i-_y)) < NEARBYSIZE * NEARBYSIZE) then {
_index = _jx + _iy * 64;
//diag_log format [ "%1: -> index=%2", __FILE__, _index ];
_cell = sched_tg_grid select _index;
if ((!isNil "_cell") AND {!(_index IN sched_tg_newActive)}) then {
sched_tg_newActive set [ count sched_tg_newActive, _index ];
};
};
};
};
};
};
sched_tg_state = 1;
sched_tg_ready = false;
sched_tg_var1 = 0;
//sched_tg_var2 = 0;
//sched_tg_fps = diag_fpsmin;
//sched_tg_newSpawned = 0;
//sched_tg_newTextureSpawned = 0;
};
};
case (sched_tg_state == 1): { // show new cells, per shunk of CHUNKSIZE objects
if (sched_tg_var1 >= count sched_tg_newActive) then {
sched_tg_state = 2;
sched_tg_ready = true;
sched_tg_var1 = 0;
sched_tg_var2 = 0;
sched_tg_deleted = 0;
}
else {
_index = -1;
// don't wait to next frame to find a new cell to show
while {sched_tg_var1 < count sched_tg_newActive} do {
_index = sched_tg_newActive select sched_tg_var1;
if !(_index IN sched_tg_currentActive) exitWith {};
sched_tg_var1 = sched_tg_var1 +1;
_index = -1;
//sched_tg_var2 = 0;
};
if (_index >= 0) then {
// create objects from cell index _index
_cell = sched_tg_grid select _index;
_imax = (count _cell) min (sched_tg_var2 + CHUNKSIZE);
//diag_log format ["%1: spawn cell #%2, %4 objects from #%3", __FILE__, _index, sched_tg_var2, _imax-sched_tg_var2 ];
for "_i" from sched_tg_var2 to _imax-1 do {
_x = _cell select _i;
//sched_tg_newSpawned = sched_tg_newSpawned + 1;
if ("" != (_x select 1)) then {
_object = (_x select 1) createVehicleLocal [0,0,0];
_position = _x select 2;
_object setDir (_x select 3);
_object setPos [_position select 0,_position select 1,0];
_object setPosATL _position;
_object allowDamage false;
//_onFire ...
_object setVariable ["", true]; // SV used by player_spawnCheck, exists if object is local
_x set [ 0, _object ]; // object reference for faster delete
};
};
sched_tg_var2 = _imax;
if (_imax == count _cell) then {
sched_tg_var1 = sched_tg_var1 +1;
sched_tg_var2 = 0;
};
};
};
};
case (sched_tg_state == 2): { // hide whole cells
if (sched_tg_var1 >= count sched_tg_currentActive) then {
sched_tg_currentActive = +(sched_tg_newActive);
sched_tg_state = 0;
sched_tg_var1 = 0;
// if ((sched_tg_newSpawned > 0) or (diag_fpsmin < 10)) then {
// diag_log format [ "%1: spawned:%2 newTexture:%3 deleted:%4 fps: %5 -> %6%7", __FILE__,
// sched_tg_newSpawned, sched_tg_newTextureSpawned, sched_tg_deleted, sched_tg_fps, diag_fpsmin, if (diag_fpsmin < 10) then {"!! <<<<<<<<<<<<<<<<<<<"} else {""} ];
// };
}
else {
_index = -1;
// don't wait to next frame to find a new cell to hide
while {sched_tg_var1 < count sched_tg_currentActive} do {
_index = sched_tg_currentActive select sched_tg_var1;
if !(_index IN sched_tg_newActive) exitWith {};
sched_tg_var1 = sched_tg_var1 +1;
_index = -1;
//sched_tg_var2 = 0;
};
if (_index >= 0) then {
//diag_log format ["%1: despawn cell #%2", __FILE__, _index ];
// delete objects from cell index _x
{
deleteVehicle (_x select 0);
_x set [ 0, objNull ];
sched_tg_deleted = sched_tg_deleted +1;
} count (sched_tg_grid select _index);
//sched_tg_currentActive = sched_tg_currentActive - [_x];
};
sched_tg_var1 = sched_tg_var1 +1;
};
};
default { // -1
//diag_log [ diag_tickTime, __FILE__, "waiting for plantSpawner" ];
if ((!isNil "dayz_plantSpawner_done") and {(dayz_plantSpawner_done == 2)}) then {
sched_tg_state = 0; // ready to start the loop
};
};
}; // switch
//diag_log format ["%1: state:%2 cellWidth:%3 cellHeight:%4 var1:%5 var2:%6 currentActive:%7 newActive:%8", __FILE__,
// sched_tg_state, sched_tg_cellX, sched_tg_cellY, sched_tg_var1, sched_tg_var2, sched_tg_currentActive, sched_tg_newActive ];
objNull
};

View File

@@ -0,0 +1,77 @@
// (c) facoptere@gmail.com, licensed to DayZMod for the community
class FSM {
fsmName = "server_cleanup";
initState = "init";
finalStates[] = {"end"};
class States {
class init {
name="init";
init= "" \n
//"diag_log[""Scheduler init""];" \n
"__sc_taskArray = [];" \n
"__sc_time = diag_tickTime;" \n
"{" \n
" private [ ""__sc_period"", ""__sc_offset"", ""__sc_code"", ""__sc_init"", ""__sc_ctx"" ];" \n
" __sc_period = _x select 0;" \n
" __sc_offset = _x select 1;" \n
" __sc_code = _x select 2;" \n
" __sc_init = _x select 3;" \n
" __sc_ctx = if (!isNil ""__sc_init"") then { call __sc_init } else { objNull };" \n
" __sc_taskArray set [ count __sc_taskArray, [ __sc_code, __sc_ctx, __sc_period, __sc_time + __sc_offset - __sc_period ]];" \n
// " diag_log [ __sc_period, __sc_time - __sc_offset + __sc_period, __sc_ctx, __sc_code ];" \n
"} count _this;" \n
"_this=nil;";
class Links {
class L0 {
priority=0;
to="loop";
condition="1==1";
action="";
};
};
};
class end {
name="end";
init= "diag_log[""Scheduler terminated""]";
class Links {};
};
class loop {
name="loop";
init= "" \n
// "diag_log[""Scheduler loop action""];" \n
"__sc_lootT0 = diag_tickTime;" \n
"{" \n
" private [ ""__sc_task"", ""__sc_period"", ""__sc_offset"", ""__sc_code"", ""__sc_next"", ""__sc_ctx"" ];" \n
" __sc_task = _x;" \n
" __sc_code = __sc_task select 0;" \n
" __sc_ctx = __sc_task select 1;" \n
" __sc_period = __sc_task select 2;" \n
" __sc_next = __sc_task select 3;" \n
" if (diag_tickTime >= __sc_next) then {" \n
// " if (__sc_period>=0.2) then {diag_log['scheduler idx/period/previous/time/next', _forEachIndex, __sc_period, __sc_task select 3, diag_tickTime, __sc_next ];};" \n
" __sc_ctx = __sc_ctx call __sc_code;" \n
" if (__sc_period > 0) then { __sc_next = __sc_next + __sc_period * (1 + floor((diag_tickTime - __sc_next) / __sc_period)); };" \n
" __sc_task set [1, __sc_ctx];" \n
" __sc_task set [3, __sc_next];" \n
" };" \n
" if ((__sc_period == 0) AND {(__sc_ctx)}) exitWith {};" \n
" if (diag_tickTime - __sc_lootT0 > 0.02) exitWith {};" \n // hopefully should not happen frequently
"} count __sc_taskArray;";
class Links {
class L0 {
priority=1;
to="end";
condition="(!isServer) and {(deathHandled)}";
action="";
};
class L1 {
priority=0;
to="loop";
condition="1==1";
action= "";
};
};
};
};
};

View File

@@ -0,0 +1 @@
#define HIDE_FSM_VARS private ["__sc_task","__sc_code","__sc_period","__sc_next","__sc_taskArray", "__sc_lootT0"];