Advertisement
Guest User

player_spawn_2.sqf

a guest
Jan 11th, 2013
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 16.56 KB | None | 0 0
  1.  
  2. private["_refObj","_size","_vel","_speed","_hunger","_thirst","_array","_unsaved","_timeOut","_result","_lastSave"];
  3.  
  4.  
  5. disableSerialization;
  6.  
  7.  
  8. _timeOut = 0;
  9.  
  10.  
  11. _messTimer = 0;
  12.  
  13.  
  14. _lastSave = 0;
  15.  
  16.  
  17. _lastTemp = dayz_temperatur;
  18.  
  19.  
  20. _debug = getMarkerpos "respawn_west";
  21.  
  22.  
  23. _isBandit = false;
  24.  
  25.  
  26. _isHero = false;
  27.  
  28.  
  29.  
  30.  
  31.  
  32. player setVariable ["temperature",dayz_temperatur,true];
  33.  
  34.  
  35.  
  36.  
  37.  
  38. dayz_myLoad = (((count dayz_myBackpackMags) * 0.2) + (count dayz_myBackpackWpns)) + (((count dayz_myMagazines) * 0.1) + (count dayz_myWeapons * 0.5));
  39.  
  40.  
  41.  
  42.  
  43.  
  44. //player addMagazine "Hatchet_swing";
  45.  
  46.  
  47. //player addWeapon "MeleeHatchet";
  48.  
  49.  
  50.  
  51.  
  52.  
  53. while {true} do {
  54.  
  55.  
  56. //Initialize
  57.  
  58.  
  59. _refObj = vehicle player;
  60.  
  61.  
  62. _size = (sizeOf typeOf _refObj) * 0.6;
  63.  
  64.  
  65. _vel = velocity player;
  66.  
  67.  
  68. _speed = round((_vel distance [0,0,0]) * 3.5);
  69.  
  70.  
  71. _saveTime = (playersNumber west * 2) + 10;
  72.  
  73.  
  74.  
  75.  
  76.  
  77. //reset position
  78.  
  79.  
  80. _randomSpot = true;
  81.  
  82.  
  83. _tempPos = getPosATL player;
  84.  
  85.  
  86. _distance = _debug distance _tempPos;
  87.  
  88.  
  89. if (_distance < 2000) then {
  90.  
  91.  
  92. _randomSpot = false;
  93.  
  94.  
  95. };
  96.  
  97.  
  98. _distance = [0,0,0] distance _tempPos;
  99.  
  100.  
  101. if (_distance < 500) then {
  102.  
  103.  
  104. _randomSpot = false;
  105.  
  106.  
  107. };
  108.  
  109.  
  110. _distance = _mylastPos distance _tempPos;
  111.  
  112.  
  113. if (_distance > 400) then {
  114.  
  115.  
  116. _randomSpot = false;
  117.  
  118.  
  119. };
  120.  
  121.  
  122.  
  123.  
  124.  
  125. if (_randomSpot) then {
  126.  
  127.  
  128. _mylastPos = _tempPos;
  129.  
  130.  
  131. };
  132.  
  133.  
  134.  
  135.  
  136.  
  137. dayz_mylastPos = _mylastPos;
  138.  
  139.  
  140. dayz_areaAffect = _size;
  141.  
  142.  
  143.  
  144.  
  145.  
  146. //CheckVehicle
  147.  
  148.  
  149. /*
  150.  
  151.  
  152. if (_refObj != player) then {
  153.  
  154.  
  155. _isSync =_refObj getVariable ["ObjectID",0] > 0;
  156.  
  157.  
  158. if (!_isSync) then {
  159.  
  160.  
  161. _veh allowDamage true;
  162.  
  163.  
  164. _veh setDamage 1;
  165.  
  166.  
  167. player setDamage 1;
  168.  
  169.  
  170. };
  171.  
  172.  
  173. };
  174.  
  175.  
  176. */
  177.  
  178.  
  179.  
  180.  
  181.  
  182. if (_speed > 0.1) then {
  183.  
  184.  
  185. _timeOut = _timeOut + 1;
  186.  
  187.  
  188. };
  189.  
  190.  
  191.  
  192.  
  193.  
  194. _humanity = player getVariable ["humanity",0];
  195.  
  196.  
  197. if (_timeOut > 150) then {
  198.  
  199.  
  200. _timeOut = 0;
  201.  
  202.  
  203. if (_humanity < 2500) then {
  204.  
  205.  
  206. _humanity = _humanity + 150;
  207.  
  208.  
  209. _humanity = _humanity min 2500;
  210.  
  211.  
  212. player setVariable ["humanity",_humanity,true];
  213.  
  214.  
  215. };
  216.  
  217.  
  218. };
  219.  
  220.  
  221.  
  222.  
  223.  
  224. if (_humanity < -2000 and !_isBandit) then {
  225.  
  226.  
  227. _isBandit = true;
  228.  
  229.  
  230. _model = typeOf player;
  231.  
  232.  
  233. if (_model == "Survivor2_DZ") then {
  234.  
  235.  
  236. [dayz_playerUID,dayz_characterID,"Bandit1_DZ"] spawn player_humanityMorph;
  237.  
  238.  
  239. };
  240.  
  241.  
  242. if (_model == "SurvivorW2_DZ") then {
  243.  
  244.  
  245. [dayz_playerUID,dayz_characterID,"BanditW1_DZ"] spawn player_humanityMorph;
  246.  
  247.  
  248. };
  249.  
  250.  
  251. };
  252.  
  253.  
  254.  
  255.  
  256.  
  257. if (_humanity > 0 and _isBandit) then {
  258.  
  259.  
  260. _isBandit = false;
  261.  
  262.  
  263. _model = typeOf player;
  264.  
  265.  
  266. if (_model == "Bandit1_DZ") then {
  267.  
  268.  
  269. [dayz_playerUID,dayz_characterID,"Survivor2_DZ"] spawn player_humanityMorph;
  270.  
  271.  
  272. };
  273.  
  274.  
  275. if (_model == "BanditW1_DZ") then {
  276.  
  277.  
  278. [dayz_playerUID,dayz_characterID,"SurvivorW2_DZ"] spawn player_humanityMorph;
  279.  
  280.  
  281. };
  282.  
  283.  
  284. };
  285.  
  286.  
  287.  
  288.  
  289.  
  290. if (_humanity > 5000 and !_isHero) then {
  291.  
  292.  
  293. _isBandit = false;
  294.  
  295.  
  296. _model = typeOf player;
  297.  
  298.  
  299. if (_model == "Survivor2_DZ") then {
  300.  
  301.  
  302. [dayz_playerUID,dayz_characterID,"Survivor3_DZ"] spawn player_humanityMorph;
  303.  
  304.  
  305. };
  306.  
  307.  
  308. };
  309.  
  310.  
  311.  
  312.  
  313.  
  314. //Has infection?
  315.  
  316.  
  317. if (r_player_infected) then {
  318.  
  319.  
  320. [player,"cough",8,false] call dayz_zombieSpeak;
  321.  
  322.  
  323. };
  324.  
  325.  
  326.  
  327.  
  328.  
  329. //Record Check
  330.  
  331.  
  332. _lastUpdate = time - dayZ_lastPlayerUpdate;
  333.  
  334.  
  335. if (_lastUpdate > 8) then {
  336.  
  337.  
  338. //POSITION?
  339.  
  340.  
  341. _distance = dayz_myPosition distance player;
  342.  
  343.  
  344. if (_distance > 10) then {
  345.  
  346.  
  347. //Player has moved
  348.  
  349.  
  350. dayz_myPosition = getPosATL player;
  351.  
  352.  
  353. player setVariable["posForceUpdate",true,true];
  354.  
  355.  
  356. dayz_unsaved = true;
  357.  
  358.  
  359. dayZ_lastPlayerUpdate = time;
  360.  
  361.  
  362. };
  363.  
  364.  
  365. };
  366.  
  367.  
  368.  
  369.  
  370.  
  371. //Hunger
  372.  
  373.  
  374. _hunger = +((((r_player_bloodTotal - r_player_blood) / r_player_bloodTotal) * 5) + _speed + dayz_myLoad) * 3;
  375.  
  376.  
  377. if (time - dayz_panicCooldown < 120) then {
  378.  
  379.  
  380. _hunger = _hunger * 2;
  381.  
  382.  
  383. };
  384.  
  385.  
  386. dayz_hunger = dayz_hunger + (_hunger / 60);
  387.  
  388.  
  389.  
  390.  
  391.  
  392. //Thirst
  393.  
  394.  
  395. _thirst = 2;
  396.  
  397.  
  398. if (_refObj == player) then {
  399.  
  400.  
  401. _thirst = (_speed + 4) * 3;
  402.  
  403.  
  404. };
  405.  
  406.  
  407. dayz_thirst = dayz_thirst + (_thirst / 60) * (dayz_temperatur / dayz_temperaturnormal); //TeeChange Temperatur effects added Max Effects: -25% and + 16.6% waterloss
  408.  
  409.  
  410.  
  411.  
  412.  
  413. //Temperatur
  414.  
  415.  
  416. 2 call player_temp_calculation; //2 = sleep time of this loop //TeeChange
  417.  
  418.  
  419. if ((_lastTemp - dayz_temperatur) > 0.75 or (_lastTemp - dayz_temperatur) < -0.75 ) then {
  420.  
  421.  
  422. player setVariable ["temperature",dayz_temperatur,true];
  423.  
  424.  
  425. _lastTemp = dayz_temperatur;
  426.  
  427.  
  428. };
  429.  
  430.  
  431.  
  432.  
  433.  
  434. //can get nearby infection
  435.  
  436.  
  437. if (!r_player_infected) then {
  438.  
  439.  
  440. // Infectionriskstart
  441.  
  442.  
  443. if (dayz_temperatur < ((80 / 100) * (dayz_temperaturnormal - dayz_temperaturmin) + dayz_temperaturmin)) then { //TeeChange
  444.  
  445.  
  446. _listTalk = _mylastPos nearEntities ["CAManBase",8];
  447.  
  448.  
  449. {
  450.  
  451.  
  452. if (_x getVariable["USEC_infected",false]) then {
  453.  
  454.  
  455. _rnd = (random 1) * (((dayz_temperaturnormal - dayz_temperatur) * (100 /(dayz_temperaturnormal - dayz_temperaturmin)))/ 50); //TeeChange
  456.  
  457.  
  458. if (_rnd < 0.1) then {
  459.  
  460.  
  461. _rnd = random 1;
  462.  
  463.  
  464. if (_rnd > 0.7) then {
  465.  
  466.  
  467. r_player_infected = true;
  468.  
  469.  
  470. player setVariable["USEC_infected",true];
  471.  
  472.  
  473. };
  474.  
  475.  
  476. };
  477.  
  478.  
  479. };
  480.  
  481.  
  482. } forEach _listTalk;
  483.  
  484.  
  485. if (dayz_temperatur < ((50 / 100) * (dayz_temperaturnormal - dayz_temperaturmin) + dayz_temperaturmin)) then { //TeeChange
  486.  
  487.  
  488. _rnd = (random 1) * (((dayz_temperaturnormal - dayz_temperatur) * (100 /(dayz_temperaturnormal - dayz_temperaturmin)))/ 25); //TeeChange
  489.  
  490.  
  491. if (_rnd < 0.05) then {
  492.  
  493.  
  494. _rnd = random 1;
  495.  
  496.  
  497. if (_rnd > 0.95) then {
  498.  
  499.  
  500. r_player_infected = true;
  501.  
  502.  
  503. player setVariable["USEC_infected",true];
  504.  
  505.  
  506. };
  507.  
  508.  
  509. };
  510.  
  511.  
  512. };
  513.  
  514.  
  515. };
  516.  
  517.  
  518. };
  519.  
  520.  
  521.  
  522.  
  523.  
  524. //If has infection reduce blood
  525.  
  526.  
  527. if (r_player_infected) then {
  528.  
  529.  
  530. if (r_player_blood > 6000) then {
  531.  
  532.  
  533. r_player_blood = r_player_blood - 3;
  534.  
  535.  
  536. };
  537.  
  538.  
  539. };
  540.  
  541.  
  542.  
  543.  
  544.  
  545. //Hunger Effect
  546.  
  547.  
  548. _foodVal = dayz_statusArray select 0;
  549.  
  550.  
  551. _thirstVal = dayz_statusArray select 1;
  552.  
  553.  
  554. if (_thirstVal <= 0) then {
  555.  
  556.  
  557. _result = r_player_blood - 10;
  558.  
  559.  
  560. if (_result < 0) then {
  561.  
  562.  
  563. _id = [player,"dehyd"] spawn player_death;
  564.  
  565.  
  566. } else {
  567.  
  568.  
  569. r_player_blood = _result;
  570.  
  571.  
  572. };
  573.  
  574.  
  575. };
  576.  
  577.  
  578. if (_foodVal <= 0) then {
  579.  
  580.  
  581. _result = r_player_blood - 10;
  582.  
  583.  
  584. if (_result < 0) then {
  585.  
  586.  
  587. _id = [player,"starve"] spawn player_death;
  588.  
  589.  
  590. } else {
  591.  
  592.  
  593. r_player_blood = _result;
  594.  
  595.  
  596. };
  597.  
  598.  
  599. };
  600.  
  601.  
  602.  
  603.  
  604.  
  605. //Record low bloow
  606.  
  607.  
  608. _lowBlood = player getVariable ["USEC_lowBlood", false];
  609.  
  610.  
  611. if ((r_player_blood < r_player_bloodTotal) and !_lowBlood) then {
  612.  
  613.  
  614. player setVariable["USEC_lowBlood",true,true];
  615.  
  616.  
  617. };
  618.  
  619.  
  620.  
  621.  
  622.  
  623. //Broadcast Hunger/Thirst
  624.  
  625.  
  626. _messTimer = _messTimer + 1;
  627.  
  628.  
  629. if (_messTimer > 15) then {
  630.  
  631.  
  632. _messTimer = 0;
  633.  
  634.  
  635. player setVariable ["messing",[dayz_hunger,dayz_thirst],true];
  636.  
  637.  
  638. };
  639.  
  640.  
  641.  
  642.  
  643.  
  644. //check if can disconnect
  645.  
  646.  
  647. if (!dayz_canDisconnect) then {
  648.  
  649.  
  650. if ((time - dayz_damageCounter) > 180) then {
  651.  
  652.  
  653. if (!r_player_unconscious) then {
  654.  
  655.  
  656. dayz_canDisconnect = true;
  657.  
  658.  
  659. dayzDiscoRem = getPlayerUID player;
  660.  
  661.  
  662. publicVariableServer "dayzDiscoRem";
  663.  
  664.  
  665.  
  666.  
  667.  
  668. //Ensure Control is hidden
  669.  
  670.  
  671. _display = uiNamespace getVariable 'DAYZ_GUI_display';
  672.  
  673.  
  674. _control = _display displayCtrl 1204;
  675.  
  676.  
  677. _control ctrlShow false;
  678.  
  679.  
  680. };
  681.  
  682.  
  683. };
  684.  
  685.  
  686. };
  687.  
  688.  
  689.  
  690.  
  691.  
  692. //Save Checker
  693.  
  694.  
  695. if (dayz_unsaved) then {
  696.  
  697.  
  698. if ((time - dayz_lastSave) > _saveTime) then {
  699.  
  700.  
  701. dayzPlayerSave = [player,dayz_Magazines,false];
  702.  
  703.  
  704. publicVariableServer "dayzPlayerSave";
  705.  
  706.  
  707. if (isServer) then {
  708.  
  709.  
  710. dayzPlayerSave call server_playerSync;
  711.  
  712.  
  713. };
  714.  
  715.  
  716. dayz_lastSave = time;
  717.  
  718.  
  719. dayz_Magazines = [];
  720.  
  721.  
  722. };
  723.  
  724.  
  725. _lastSave = _lastSave + 2;
  726.  
  727.  
  728. } else {
  729.  
  730.  
  731. dayz_lastSave = time;
  732.  
  733.  
  734. _lastSave = 0;
  735.  
  736.  
  737. };
  738.  
  739.  
  740.  
  741.  
  742.  
  743. if (!dayz_unsaved) then {
  744.  
  745.  
  746. dayz_lastSave = time;
  747.  
  748.  
  749. };
  750.  
  751.  
  752.  
  753.  
  754.  
  755. //Attach Trigger Current Object
  756.  
  757.  
  758. //dayz_playerTrigger attachTo [_refObj,[0,0,0]];
  759.  
  760.  
  761. //dayz_playerTrigger setTriggerArea [_size,_size,0,false];
  762.  
  763.  
  764.  
  765.  
  766.  
  767. //Debug Info
  768.  
  769.  
  770. _headShots = player getVariable["headShots",0];
  771.  
  772.  
  773. _kills = player getVariable["zombieKills",0];
  774.  
  775.  
  776. _killsH = player getVariable["humanKills",0];
  777.  
  778.  
  779. _killsB = player getVariable["banditKills",0];
  780.  
  781.  
  782. _humanity = player getVariable["humanity",0];
  783.  
  784.  
  785. _zombies = count entities "zZombie_Base";
  786.  
  787.  
  788. _zombiesA = {alive _x} count entities "zZombie_Base";
  789.  
  790.  
  791. //_groups = count allGroups;
  792.  
  793.  
  794. //_dead = count allDead;
  795.  
  796.  
  797. //dayz_zombiesLocal = {local _x} count entities "zZombie_Base";
  798.  
  799.  
  800. //_loot = count allMissionObjects "WeaponHolder";
  801.  
  802.  
  803. //_wrecks = count allMissionObjects "Wreck_Base";
  804.  
  805.  
  806. //_lootL = {local _x} count allMissionObjects "WeaponHolder";
  807.  
  808.  
  809. //_speed = (_vel distance [0,0,0]);
  810.  
  811.  
  812.  
  813.  
  814.  
  815. hintSilent parseText format["<t size='1.25' font='Bitstream' >%14<br /><br /></t><t size='1' font='Bitstream' align='left' >Blood: </t><t size='1' font='Bitstream' align='right' >%4</t><t size='1' font='Bitstream' align='left' ><br />Humanity: </t><t size='1' font='Bitstream' align='right' >%11</t><t size='1' font='Bitstream' align='left' ><br /><br />Headshots: </t><t size='1' font='Bitstream' align='right' >%2</t><t size='1' font='Bitstream' align='left' ><br /><br />Murders: </t><t size='1' font='Bitstream' align='right' >%10</t><t size='1' font='Bitstream' align='left' ><br />Bandits Killed: </t><t size='1' font='Bitstream' align='right' >%12</t><t size='1' font='Bitstream' align='left' ><br />Zombies Killed: </t><t size='1' font='Bitstream' align='right' >%1</t><t size='1' font='Bitstream' align='left' ><br /><br />Zombies (alive/total): <t size='1' font='Bitstream' align='right' >%15/%8</t>",_kills,_headShots,_speed,r_player_blood,round(dayz_temperatur),r_player_infected,dayz_inside,_zombies,_lastSave,_killsH,round(_humanity),_killsB,_freeTarget,dayz_playerName,_zombiesA];
  816.  
  817.  
  818.  
  819.  
  820.  
  821.  
  822.  
  823.  
  824. // If in combat, display counter and restrict logout
  825.  
  826.  
  827. _startcombattimer = player getVariable["startcombattimer",0];
  828.  
  829.  
  830. if (_startcombattimer == 1) then {
  831.  
  832.  
  833. player setVariable["combattimeout", time + 30, true];
  834.  
  835.  
  836. player setVariable["startcombattimer", 0, true];
  837.  
  838.  
  839. dayz_combat = 1;
  840.  
  841.  
  842. };
  843.  
  844.  
  845.  
  846.  
  847.  
  848. _combattimeout = player getVariable["combattimeout",0];
  849.  
  850.  
  851. if (_combattimeout > 0) then {
  852.  
  853.  
  854. _timeleft = _combattimeout - time;
  855.  
  856.  
  857. if (_timeleft > 0) then {
  858.  
  859.  
  860. //hintSilent format["In Combat: %1",round(_timeleft)];
  861.  
  862.  
  863. } else {
  864.  
  865.  
  866. //hintSilent "Not in Combat";
  867.  
  868.  
  869. player setVariable["combattimeout", 0, true];
  870.  
  871.  
  872. dayz_combat = 0;
  873.  
  874.  
  875. _combatdisplay = uiNamespace getVariable 'DAYZ_GUI_display';
  876.  
  877.  
  878. _combatcontrol = _combatdisplay displayCtrl 1307;
  879.  
  880.  
  881. _combatcontrol ctrlShow true;
  882.  
  883.  
  884. };
  885.  
  886.  
  887. } else {
  888.  
  889.  
  890. //hintSilent "Not in Combat";
  891.  
  892.  
  893. dayz_combat = 0;
  894.  
  895.  
  896. _combatdisplay = uiNamespace getVariable 'DAYZ_GUI_display';
  897.  
  898.  
  899. _combatcontrol = _combatdisplay displayCtrl 1307;
  900.  
  901.  
  902. _combatcontrol ctrlShow true;
  903.  
  904.  
  905. };
  906.  
  907.  
  908.  
  909.  
  910.  
  911. /*
  912.  
  913.  
  914. setGroupIconsVisible [false,false];
  915.  
  916.  
  917. clearGroupIcons group player;
  918.  
  919.  
  920. */
  921.  
  922.  
  923. "colorCorrections" ppEffectAdjust [1, 1, 0, [1, 1, 1, 0.0], [1, 1, 1, (r_player_blood/r_player_bloodTotal)], [1, 1, 1, 0.0]];
  924.  
  925.  
  926. "colorCorrections" ppEffectCommit 0;
  927.  
  928.  
  929. sleep 2;
  930.  
  931.  
  932.  
  933.  
  934.  
  935. _myPos = player getVariable["lastPos",[]];
  936.  
  937.  
  938. if (count _myPos > 0) then {
  939.  
  940.  
  941. player setVariable["lastPos",_mylastPos, true];
  942.  
  943.  
  944. player setVariable["lastPos",[]];
  945.  
  946.  
  947. };
  948.  
  949.  
  950.  
  951.  
  952.  
  953. _lastPos = getPosATL player;
  954.  
  955.  
  956. if (player == vehicle player) then {
  957.  
  958.  
  959. if (_mylastPos distance _lastPos > 200) then {
  960.  
  961.  
  962. if (alive player) then {
  963.  
  964.  
  965. player setPosATL _mylastPos;
  966.  
  967.  
  968. };
  969.  
  970.  
  971. };
  972.  
  973.  
  974. } else {
  975.  
  976.  
  977. if (_mylastPos distance _lastPos > 800) then {
  978.  
  979.  
  980. if (alive player) then {
  981.  
  982.  
  983. player setPosATL _mylastPos;
  984.  
  985.  
  986. };
  987.  
  988.  
  989. };
  990.  
  991.  
  992. };
  993.  
  994.  
  995.  
  996.  
  997.  
  998. //Hatchet ammo fix
  999.  
  1000.  
  1001. //"MeleeHatchet" call dayz_meleeMagazineCheck;
  1002.  
  1003.  
  1004.  
  1005.  
  1006.  
  1007. //Crowbar ammo fix
  1008.  
  1009.  
  1010. //"MeleeCrowbar" call dayz_meleeMagazineCheck;
  1011.  
  1012.  
  1013. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement