Advertisement
Guest User

Untitled

a guest
May 1st, 2017
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 6.31 KB | None | 0 0
  1. #include "globalDefines.hpp"
  2. #define LOOPDELAY_SEC 1         // amount of time to wait per loop iteration
  3. #define SLOWDELAY_SEC 10                // duration of slow update loop
  4. #define SERVER_REPORT_PERIOD 30     // frequency at which server reports stats to logging
  5. #define DEBUG_SVR       publicVariable 
  6. #define DEBUG_ZONES     _ignore=
  7.  
  8. //0bb
  9. "publicTK_Score" addPublicVariableEventHandler
  10. {
  11. _Killer = (_this select 1) select 0;
  12. _Killer addscore -4;
  13. };
  14. //
  15.  
  16.  
  17. float lastTime=0;       // used to create one second intervals for spawn queue processing
  18. int _lmctr=0;
  19. int xmitseq=0;  // transmission sequence no (used for spawn queues and base update messages)
  20. bool debugDoReviveAll=false;    // when set to true, this launches a revive message for everyone in the server
  21. int _debugReviveCounter=0;      // debug revive countdown
  22. onPlayerConnected {};
  23. onPlayerDisconnected {};
  24. code _updateZonePlayerLists   = compileFinal preprocessFile "updateZonePlayerLists.sqf";
  25. code _updateZoneCalculations  = compileFinal preprocessFile "updateZoneCalculations.sqf";
  26. code _updateSpawnQueues       = compileFinal preprocessFile "updateSpawnQueues.sqf";
  27. code _compileGameStatistics   = compileFinal preprocessFile "compileGameStatistics.sqf";
  28. int _slowrep=0;                 // loop timer for infrequent actions
  29. int _slowRepMax=0;              // max value of infrequent action loop timer (note this is set properly just below)
  30. int _srvPrevBase = 0;           // server local record of previous base
  31. int _gameEndHints = [ 115, 110, 105, 100, 95, 90, 85, 80, 75, 70, 65, 60, 55, 50, 45, 40, 35, 30, 25, 20, 17, 15, 13, 10, 7, 5, 3, 1, -100];
  32. int _curEndHint = 0;
  33. while { (_gameEndHints select _curEndHint)*60 > timemax } do
  34.     {
  35.     _curEndHint = _curEndHint + 1;
  36.     };
  37. float _lastReportTime = 0;     // time at which last report of class loadout etc was compiled
  38. _slowRepMax=floor (SLOWDELAY_SEC / LOOPDELAY_SEC);
  39.  
  40. [] execVM "ServerAIThread.sqf";
  41. [] execVM "features\UPSMON\Init_UPSMON.sqf";
  42. if (AAS_Params_AISupportMode != SUPPORT_OFF) then
  43. {
  44. [] execVM "features\UPSMON\Init_UPSMON.sqf";
  45.  
  46. };
  47.  
  48. [60,5*60, 2*60, 10*60, 10*60] execVM "CleanUp.sqf";
  49.  
  50. _hour = AAS_DEFAULT_TIME_HOUR;
  51. if (AAS_Params_HourOfDay > 0) then {_hour = AAS_Params_HourOfDay;};
  52. if (AAS_Params_HourOfDay < 0) then {_hour = floor(random 24);};
  53. _minute = AAS_DEFAULT_TIME_MINUTE;
  54. if (AAS_Params_MinuteOfDay > 0) then {_minute = AAS_Params_MinuteOfDay;};
  55. if (AAS_Params_MinuteOfDay < 0) then {_minute = floor(random 24);};
  56. if (isNil '_hour') then {_hour = "12";};
  57. if (isNil '_minute') then {_minute = "0";};
  58. setDate [(date select 0),(date select 1),(date select 2),_hour,_minute];
  59. switch (AAS_Params_Weather) do
  60. {
  61.     case -1:
  62.     {
  63.         globalOvercast = random floor (101); globalRain= globalOvercast;
  64.     };
  65.     case 0:
  66.     {
  67.         globalOvercast = AAS_DEFAULT_WEATHER; globalRain= AAS_DEFAULT_WEATHER;
  68.     };
  69.    
  70.     case 1:
  71.     {
  72.         globalOvercast = 0; globalRain= 0;
  73.     };
  74.     case 2:
  75.     {
  76.         globalOvercast = 0.5; globalRain= 0.5;
  77.     };
  78.     case 3:
  79.     {
  80.         globalOvercast = 1; globalRain = 1;
  81.     };
  82. };
  83. switch (AAS_Params_Fog) do
  84. {
  85.     case -1:
  86.     {
  87.         globalFog = random floor (101);
  88.     };
  89.    
  90.     case 0:
  91.     {
  92.         globalFog= AAS_DEFAULT_FOG;
  93.     };
  94.    
  95.     case 1:
  96.     {
  97.         globalFog = 0;
  98.     };
  99.     case 2:
  100.     {
  101.         globalFog = 0.4;
  102.     };
  103.     case 3:
  104.     {
  105.         globalFog = 0.6;
  106.     };
  107.     case 4:
  108.     {
  109.         globalFog = 0.8;
  110.     };
  111.     case 5:
  112.     {
  113.         globalFog = 1;
  114.     };
  115. };
  116. call cmdUpdatePlayerLists;
  117.  
  118. 0 setOvercast globalOvercast;
  119. 0 setRain globalRain;
  120. 0 setFog globalFog;
  121.  
  122. forceWeatherChange;
  123.  
  124. while { true } do
  125. {  
  126.     _slowrep=_slowrep + 1;
  127.    
  128.     if (_slowrep > _slowRepMax) then
  129.     {
  130.             publicVariable "timemax";
  131.             centralServerTime=time;
  132.             publicVariable "centralServerTime";
  133.             publicVariable "globalOvercast";
  134.             publicVariable "globalRain";           
  135.             publicVariable "globalFog";
  136.             int _lmctr=0;
  137.         for "_lmctr" from 1 to (count saas_baselist) do
  138.                 {
  139.                 string _lname=BASENAME(_lmctr);
  140.                 _lname setMarkerColor (teamColors select BASEA(_lmctr,TEAM));  
  141.                
  142.                 if( !(_lmctr in curBaseList) ) then
  143.                     {
  144.                     SETSRVBASECACHEA(_lmctr,CAPLEVEL,100);
  145.                     };
  146.                 };
  147.             KRON_UPS_WEST = 0;
  148.             KRON_UPS_EAST = 0;
  149.             int _numRedBases  = { (_x select TEAM) == TEAM_RED  } count saas_baselist;
  150.             int _numBlueBases = { (_x select TEAM) == TEAM_BLUE } count saas_baselist;
  151.             if( time >= timemax and _numBlueBases >  _numRedBases  ) then { goWestWin   = true; publicVariable "goWestWin";   sleep 3; triggerWestWin=true;   };
  152.             if( time >= timemax and _numRedBases  >  _numBlueBases ) then { goEastWin   = true; publicVariable "goEastwin";   sleep 3; triggerEastWin=true;   };
  153.             if( time >= timemax and _numBlueBases == _numRedBases  ) then { goStalemate = true; publicVariable "goStalemate"; sleep 3; triggerStalemate=true; };
  154.             if( (timemax - time) < (_gameEndHints select _curEndHint)*60 ) then
  155.                 {
  156.                 serverHint=format["%1",_gameEndHints select _curEndHint];
  157.                 publicVariable "serverHint";                   
  158.                 _curEndHint = _curEndHint + 1;
  159.                 };
  160.             if( (time-_lastReportTime) > SERVER_REPORT_PERIOD ) then
  161.                 {
  162.                 _lastReportTime=time;
  163.                 call _compileGameStatistics;
  164.                 };
  165.             publicVariable "bonus_trucks_east";
  166.             publicVariable "bonus_trucks_west";
  167.             _slowrep=0;
  168.     };
  169.     if( createEastTruck ) then
  170.         {      
  171.         createEastTruck=false;
  172.         unit _theVehicle = "O_Ifrit_F" createVehicle (getMarkerPos BASENAME(redXrayBaseID));           
  173.         bonus_trucks_east = bonus_trucks_east + [ _theVehicle ];
  174.         };
  175.     if( createWestTruck ) then
  176.         {      
  177.         createWestTruck=false;
  178.         unit _theVehicle = "B_Hunter_F" createVehicle (getMarkerPos BASENAME(blueXrayBaseID));         
  179.         bonus_trucks_west = bonus_trucks_west + [ _theVehicle ];
  180.         };
  181.     if( debugTestRevive ) then
  182.         {
  183.         debugTestRevive=false;
  184.         _debugReviveCounter=61;
  185.         serverHint="Revive all in 30 secs.";
  186.         publicVariable "serverHint";               
  187.         };
  188.     if( _debugReviveCounter > 0 ) then
  189.         {
  190.         _debugReviveCounter = _debugReviveCounter - 1;
  191.        
  192.         if( _debugReviveCounter == 50 ) then
  193.             {
  194.             serverHint="Revive all in 25 secs.";
  195.             publicVariable "serverHint";       
  196.             };
  197.            
  198.         if( _debugReviveCounter == 0 ) then
  199.             {
  200.             debugDoReviveAll=true;
  201.             };
  202.         };
  203.     call cmdUpdatePlayerLists;
  204.     call cmdProcessPlayerAttribs;      
  205.     call _updateZonePlayerLists;    // done by both client and server
  206.     call _updateZoneCalculations;   // percentage calcs done only by server (as stateful)
  207.     call cmdPackStateSAAS;
  208.     publicVariable "v1";   
  209.     call _updateSpawnQueues;
  210.     sleep LOOPDELAY_SEC;
  211. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement