Advertisement
Guest User

player_spawn_2.sqf

a guest
Nov 16th, 2012
551
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 10.92 KB | None | 0 0
  1. private["_refObj","_size","_vel","_speed","_hunger","_thirst","_array","_unsaved","_timeOut","_result","_lastSave"];
  2. disableSerialization;
  3. _timeOut =  0;
  4. _messTimer = 0;
  5. _lastSave = 0;
  6. _lastTemp = dayz_temperatur;
  7. _debug = getMarkerpos "respawn_west";
  8. _isBandit = false;
  9. _isHero = false;
  10.  
  11. player setVariable ["temperature",dayz_temperatur,true];
  12.  
  13. dayz_myLoad = (((count dayz_myBackpackMags) * 0.2) + (count dayz_myBackpackWpns)) +  (((count dayz_myMagazines) * 0.1) + (count dayz_myWeapons * 0.5));
  14.  
  15.     //player addMagazine "Hatchet_swing";
  16.     //player addWeapon "MeleeHatchet";
  17.  
  18. while {true} do {
  19.     //Initialize
  20.     _refObj =   vehicle player;
  21.     _size =     (sizeOf typeOf _refObj) * 0.6;
  22.     _vel =      velocity player;
  23.     _speed =    round((_vel distance [0,0,0]) * 3.5);
  24.     _saveTime = (playersNumber west * 2) + 10;
  25.        
  26.     //reset position
  27.     _randomSpot = true;
  28.     _tempPos = getPosATL player;
  29.     _distance = _debug distance _tempPos;
  30.     if (_distance < 2000) then {
  31.         _randomSpot = false;
  32.     }; 
  33.     _distance = [0,0,0] distance _tempPos;
  34.     if (_distance < 500) then {
  35.         _randomSpot = false;
  36.     };
  37.     _distance = _mylastPos distance _tempPos;
  38.     if (_distance > 400) then {
  39.         _randomSpot = false;
  40.     };
  41.    
  42.     if (_randomSpot) then {
  43.         _mylastPos = _tempPos;
  44.     };
  45.    
  46.     dayz_mylastPos = _mylastPos;
  47.     dayz_areaAffect = _size;
  48.    
  49.     //CheckVehicle
  50.     /*
  51.     if (_refObj != player) then {
  52.         _isSync =_refObj getVariable ["ObjectID",0] > 0;
  53.         if (!_isSync) then {
  54.             _veh allowDamage true;
  55.             _veh setDamage 1;
  56.             player setDamage 1;        
  57.         };
  58.     };
  59.     */
  60.    
  61.     if (_speed > 0.1) then {
  62.         _timeOut = _timeOut + 1;
  63.     };
  64.    
  65.     _humanity = player getVariable ["humanity",0];
  66.     if (_timeOut > 150) then {
  67.         _timeOut = 0;
  68.         if (_humanity < 2500) then {
  69.             _humanity = _humanity + 150;
  70.             _humanity = _humanity min 2500;
  71.             player setVariable ["humanity",_humanity,true];
  72.         };
  73.     };
  74.    
  75.     if (_humanity < -2000 and !_isBandit) then {
  76.         _isBandit = true;
  77.         _model = typeOf player;
  78.         if (_model == "Survivor2_DZ") then {
  79.             [dayz_playerUID,dayz_characterID,"Bandit1_DZ"] spawn player_humanityMorph;
  80.         };
  81.         if (_model == "SurvivorW2_DZ") then {
  82.             [dayz_playerUID,dayz_characterID,"BanditW1_DZ"] spawn player_humanityMorph;
  83.         };
  84.     };
  85.    
  86.     if (_humanity > 0 and _isBandit) then {
  87.         _isBandit = false;
  88.         _model = typeOf player;
  89.         if (_model == "Bandit1_DZ") then {
  90.             [dayz_playerUID,dayz_characterID,"Survivor2_DZ"] spawn player_humanityMorph;
  91.         };
  92.         if (_model == "BanditW1_DZ") then {
  93.             [dayz_playerUID,dayz_characterID,"SurvivorW2_DZ"] spawn player_humanityMorph;
  94.         };
  95.     };
  96.    
  97.     if (_humanity > 5000 and !_isHero) then {
  98.         _isBandit = false;
  99.         _model = typeOf player;
  100.         if (_model == "Survivor2_DZ") then {
  101.             [dayz_playerUID,dayz_characterID,"Survivor3_DZ"] spawn player_humanityMorph;
  102.         };
  103.     };
  104.    
  105.     //Has infection?
  106.     if (r_player_infected) then {
  107.         [player,"cough",8,false] call dayz_zombieSpeak;
  108.     };
  109.  
  110.     //Record Check
  111.     _lastUpdate =   time - dayZ_lastPlayerUpdate;
  112.     if (_lastUpdate > 8) then {
  113.         //POSITION?
  114.         _distance = dayz_myPosition distance player;
  115.         if (_distance > 10) then {
  116.             //Player has moved
  117.             dayz_myPosition = getPosATL player;
  118.             player setVariable["posForceUpdate",true,true];
  119.             dayz_unsaved = true;
  120.             dayZ_lastPlayerUpdate = time;
  121.         };
  122.     };
  123.  
  124.     //Hunger
  125.     _hunger = +((((r_player_bloodTotal - r_player_blood) / r_player_bloodTotal) * 5) + _speed + dayz_myLoad) * 3;
  126.     if (time - dayz_panicCooldown < 120) then {
  127.         _hunger = _hunger * 2;
  128.     };
  129.     dayz_hunger = dayz_hunger + (_hunger / 60);
  130.  
  131.     //Thirst
  132.     _thirst = 2;
  133.     if (_refObj == player) then {
  134.         _thirst = (_speed + 4) * 3;
  135.     };
  136.     dayz_thirst = dayz_thirst + (_thirst / 60) * (dayz_temperatur / dayz_temperaturnormal); //TeeChange Temperatur effects added Max Effects: -25% and + 16.6% waterloss
  137.  
  138.     //Temperatur
  139.     2 call player_temp_calculation; //2 = sleep time of this loop       //TeeChange
  140.     if ((_lastTemp - dayz_temperatur) > 0.75 or (_lastTemp - dayz_temperatur) < -0.75 ) then {
  141.         player setVariable ["temperature",dayz_temperatur,true];
  142.         _lastTemp = dayz_temperatur;
  143.     };
  144.    
  145.     //can get nearby infection
  146.     if (!r_player_infected) then {
  147.         //                  Infectionriskstart
  148.         if (dayz_temperatur < ((80 / 100) * (dayz_temperaturnormal - dayz_temperaturmin) + dayz_temperaturmin)) then {  //TeeChange
  149.             _listTalk = _mylastPos nearEntities ["CAManBase",8];
  150.             {
  151.                 if (_x getVariable["USEC_infected",false]) then {
  152.                     _rnd = (random 1) * (((dayz_temperaturnormal - dayz_temperatur) * (100 /(dayz_temperaturnormal - dayz_temperaturmin)))/ 50);    //TeeChange
  153.                     if (_rnd < 0.1) then {
  154.                         _rnd = random 1;
  155.                         if (_rnd > 0.7) then {
  156.                             r_player_infected = true;
  157.                             player setVariable["USEC_infected",true];
  158.                         };
  159.                     };
  160.                 };
  161.             } forEach _listTalk;
  162.             if (dayz_temperatur < ((50 / 100) * (dayz_temperaturnormal - dayz_temperaturmin) + dayz_temperaturmin)) then {  //TeeChange
  163.                 _rnd = (random 1) * (((dayz_temperaturnormal - dayz_temperatur) * (100 /(dayz_temperaturnormal - dayz_temperaturmin)))/ 25);    //TeeChange
  164.                 if (_rnd < 0.05) then {
  165.                     _rnd = random 1;
  166.                     if (_rnd > 0.95) then {
  167.                         r_player_infected = true;
  168.                         player setVariable["USEC_infected",true];
  169.                     };
  170.                 };
  171.             };
  172.         };
  173.     };
  174.    
  175.     //If has infection reduce blood
  176.     if (r_player_infected) then {
  177.         if (r_player_blood > 6000) then {
  178.             r_player_blood = r_player_blood - 3;
  179.         };
  180.     };
  181.    
  182.     //Hunger Effect
  183.     _foodVal =      dayz_statusArray select 0;
  184.     _thirstVal =    dayz_statusArray select 1;
  185.     if (_thirstVal <= 0) then {
  186.         _result = r_player_blood - 10;
  187.         if (_result < 0) then {
  188.             _id = [player,"dehyd"] spawn player_death;
  189.         } else {
  190.             r_player_blood = _result;
  191.         };
  192.     };
  193.     if (_foodVal <= 0) then {
  194.         _result = r_player_blood - 10;
  195.         if (_result < 0) then {
  196.             _id = [player,"starve"] spawn player_death;
  197.         } else {
  198.             r_player_blood = _result;
  199.         };
  200.     };
  201.    
  202.     //Record low bloow
  203.     _lowBlood = player getVariable ["USEC_lowBlood", false];
  204.     if ((r_player_blood < r_player_bloodTotal) and !_lowBlood) then {
  205.         player setVariable["USEC_lowBlood",true,true];
  206.     };
  207.    
  208.     //Broadcast Hunger/Thirst
  209.     _messTimer = _messTimer + 1;
  210.     if (_messTimer > 15) then {
  211.         _messTimer = 0;
  212.         player setVariable ["messing",[dayz_hunger,dayz_thirst],true];
  213.     };
  214.    
  215.     //check if can disconnect
  216.     if (!dayz_canDisconnect) then {
  217.         if ((time - dayz_damageCounter) > 180) then {
  218.             if (!r_player_unconscious) then {
  219.                 dayz_canDisconnect = true;
  220.                 dayzDiscoRem = getPlayerUID player;
  221.                 publicVariableServer "dayzDiscoRem";
  222.                
  223.                 //Ensure Control is hidden
  224.                 _display = uiNamespace getVariable 'DAYZ_GUI_display';
  225.                 _control =  _display displayCtrl 1204;
  226.                 _control ctrlShow false;
  227.             };
  228.         };
  229.     };
  230.  
  231.     //Save Checker
  232.     if (dayz_unsaved) then {
  233.         if ((time - dayz_lastSave) > _saveTime) then {
  234.             dayzPlayerSave = [player,dayz_Magazines,false];
  235.             publicVariableServer "dayzPlayerSave";
  236.             if (isServer) then {
  237.                 dayzPlayerSave call server_playerSync;
  238.             };
  239.             dayz_lastSave = time;
  240.             dayz_Magazines = [];
  241.         };
  242.         _lastSave = _lastSave + 2;
  243.     } else {
  244.         dayz_lastSave = time;
  245.         _lastSave = 0;
  246.     };
  247.  
  248.     if (!dayz_unsaved) then {
  249.         dayz_lastSave = time;
  250.     };
  251.  
  252.     //Attach Trigger Current Object
  253.     //dayz_playerTrigger attachTo [_refObj,[0,0,0]];
  254.     //dayz_playerTrigger setTriggerArea [_size,_size,0,false];
  255.  
  256.     //Debug Info
  257.     _headShots =    player getVariable["headShots",0];
  258.     _kills =        player getVariable["zombieKills",0];
  259.     _killsH =       player getVariable["humanKills",0];
  260.     _killsB =       player getVariable["banditKills",0];
  261.     _humanity =     player getVariable["humanity",0];
  262.     _zombies =      count entities "zZombie_Base";
  263.     _zombiesA =     {alive _x} count entities "zZombie_Base";
  264.     //_groups =     count allGroups;
  265.     //_dead =           count allDead;
  266.     //dayz_zombiesLocal =       {local _x} count entities "zZombie_Base";
  267.     //_loot =       count allMissionObjects "WeaponHolder";
  268.     //_wrecks =         count allMissionObjects "Wreck_Base";
  269.     //_lootL =      {local _x} count allMissionObjects "WeaponHolder";
  270.     //_speed = (_vel distance [0,0,0]);
  271.    
  272.         hintSilent parseText format["<t size='1.25' font='Bitstream' >%14<br /><br /></t>
  273.         <t size='1' font='Bitstream' align='left' >
  274.        
  275.         Blood: </t>
  276.         <t size='1' font='Bitstream' align='right' >%4</t>
  277.         <t size='1' font='Bitstream' align='left' ><br />
  278.         Humanity: </t>
  279.         <t size='1' font='Bitstream' align='right' >%11</t>
  280.         <t size='1' font='Bitstream' align='left' >
  281.         <br /><br />       
  282.  
  283.         Headshots: </t>
  284.         <t size='1' font='Bitstream' align='right' >%2</t>
  285.         <t size='1' font='Bitstream' align='left' >
  286.         <br /><br />
  287.        
  288.         Murders:  </t>
  289.         <t size='1' font='Bitstream' align='right' >%10</t>
  290.         <t size='1' font='Bitstream' align='left' >
  291.         <br />
  292.         Bandits Killed: </t>
  293.         <t size='1' font='Bitstream' align='right' >%12</t>
  294.         <t size='1' font='Bitstream' align='left' >
  295.         <br />
  296.         Zombies Killed: </t>
  297.         <t size='1' font='Bitstream' align='right' >%1</t>
  298.         <t size='1' font='Bitstream' align='left' >
  299.         <br /><br />
  300.        
  301.         Zombies (alive/total):
  302.         <t size='1' font='Bitstream' align='right' >%15/%8</t>"
  303.         ,_kills,_headShots,_speed,r_player_blood,round(dayz_temperatur),r_player_infected,dayz_inside,_zombies,_lastSave,_killsH,round(_humanity),_killsB,_freeTarget,dayz_playerName,_zombiesA];
  304.  
  305.     // If in combat, display counter and restrict logout
  306.     _startcombattimer      = player getVariable["startcombattimer",0];
  307.     if (_startcombattimer == 1) then {
  308.         player setVariable["combattimeout", time + 30, true];
  309.         player setVariable["startcombattimer", 0, true];
  310.         dayz_combat = 1;
  311.     };
  312.  
  313.     _combattimeout = player getVariable["combattimeout",0];
  314.     if (_combattimeout > 0) then {
  315.         _timeleft = _combattimeout - time;
  316.         if (_timeleft <= 0) then {
  317.             //hintSilent "Not in Combat";
  318.             //player setVariable["combattimeout", 0, true];
  319.             dayz_combat = 0;
  320.             //_combatdisplay = uiNamespace getVariable 'DAYZ_GUI_display';
  321.             //_combatcontrol =  _combatdisplay displayCtrl 1307;
  322.             //_combatcontrol ctrlShow true;
  323.         };
  324.     } else {
  325.         //hintSilent "Not in Combat";
  326.         dayz_combat = 0;
  327.         //_combatdisplay = uiNamespace getVariable 'DAYZ_GUI_display';
  328.         //_combatcontrol =  _combatdisplay displayCtrl 1307;
  329.         //_combatcontrol ctrlShow true;
  330.     };
  331.    
  332.     /*
  333.     setGroupIconsVisible [false,false];
  334.     clearGroupIcons group player;
  335.     */
  336.     "colorCorrections" ppEffectAdjust [1, 1, 0, [1, 1, 1, 0.0], [1, 1, 1, (r_player_blood/r_player_bloodTotal)],  [1, 1, 1, 0.0]];
  337.     "colorCorrections" ppEffectCommit 0;
  338.     sleep 2;
  339.    
  340.     _myPos = player getVariable["lastPos",[]];
  341.     if (count _myPos > 0) then {
  342.         player setVariable["lastPos",_mylastPos, true];
  343.         player setVariable["lastPos",[]];
  344.     };
  345.    
  346.     _lastPos = getPosATL player;   
  347.     if (player == vehicle player) then {
  348.         if (_mylastPos distance _lastPos > 200) then {
  349.             if (alive player) then {
  350.                 player setPosATL _mylastPos;
  351.             };
  352.         };
  353.     } else {
  354.         if (_mylastPos distance _lastPos > 800) then {
  355.             if (alive player) then {
  356.                 player setPosATL _mylastPos;
  357.             };
  358.         };
  359.     };
  360.    
  361.     //Hatchet ammo fix 
  362.     //"MeleeHatchet" call dayz_meleeMagazineCheck;
  363.    
  364.     //Crowbar ammo fix 
  365.     //"MeleeCrowbar" call dayz_meleeMagazineCheck;
  366. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement