Guest User

Untitled

a guest
Jul 2nd, 2014
267
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.57 KB | None | 0 0
  1. private ["_unitTypes","_lootType","_lootTypeCfg","_loot_count","_index","_weights","_loot","_array","_player","_doLoiter","_agent","_type","_radius","_method","_position","_isAlive","_myDest","_newDest","_rnd","_id"];
  2. _player = _this select 0;
  3.  
  4. _unitTypes = [];
  5. if (DZE_MissionLootTable) then {
  6.     _unitTypes =    []+ getArray (missionConfigFile >> "CfgBuildingLoot" >> "Default" >> "zombieClass");
  7. } else {
  8.     _unitTypes =    []+ getArray (configFile >> "CfgBuildingLoot" >> "Default" >> "zombieClass");
  9. };
  10. _doLoiter =     true;
  11.  
  12. _loot =     "";
  13. _array =    [];
  14. _agent =    objNull;
  15.  
  16. _type = _unitTypes call BIS_fnc_selectRandom;
  17.  
  18. //Create the Group && populate it
  19. //diag_log ("Spawned: " + _type);
  20. _radius = 40;
  21. _method = "NONE";
  22.  
  23. _position = [_player,120,200,10,0,0,0] call BIS_fnc_findSafePos;
  24.  
  25. _agent = createAgent [_type, _position, [], _radius, _method];
  26.  
  27. if (_doLoiter) then {
  28.     //_agent setPosATL _position;
  29.     //_agent setVariable ["doLoiter",true,true];
  30.     _agent setDir round(random 180);
  31. };
  32.  
  33. dayz_spawnZombies = dayz_spawnZombies + 1;
  34.  
  35. if (random 1 > 0.7) then {
  36.     _agent setUnitPos "Middle";
  37. };
  38.  
  39. if (isNull _agent) exitWith {
  40.     dayz_spawnZombies = dayz_spawnZombies - 1;
  41. };
  42.  
  43. _isAlive = alive _agent;
  44.  
  45. _myDest = getPosATL _agent;
  46. _newDest = getPosATL _agent;
  47. _agent setVariable ["myDest",_myDest];
  48. _agent setVariable ["newDest",_newDest];
  49.  
  50. //Add some loot
  51. _rnd = random 1;
  52. if (_rnd > 0.3) then {
  53.     if (DZE_MissionLootTable) then {
  54.         _lootType = getText (missionConfigFile >> "CfgVehicles" >> _type >> "zombieLoot");
  55.     } else {
  56.         _lootType = getText (configFile >> "CfgVehicles" >> _type >> "zombieLoot");
  57.     };
  58.  
  59.     if (DZE_MissionLootTable) then {
  60.         _lootTypeCfg = getArray (missionConfigFile >> "CfgLoot" >> _lootType);
  61.     } else {
  62.         _lootTypeCfg = getArray (configFile >> "CfgLoot" >> _lootType);
  63.     };
  64.     _array = [];
  65.     {
  66.         _array set [count _array, _x select 0]
  67.     } count _lootTypeCfg;
  68.     if (count _array > 0) then {
  69.         _index = dayz_CLBase find _lootType;
  70.         _weights = dayz_CLChances select _index;
  71.         _loot = _array select (_weights select (floor(random (count _weights))));
  72.         if(!isNil "_array") then {
  73.             if (DZE_MissionLootTable) then {
  74.                 _loot_count =   getNumber(missionConfigFile >> "CfgMagazines" >> _loot >> "count");
  75.             } else {
  76.                 _loot_count =   getNumber(configFile >> "CfgMagazines" >> _loot >> "count");
  77.             };
  78.             if(_loot_count>1) then {
  79.                 _agent addMagazine [_loot, ceil(random _loot_count)];
  80.             } else {
  81.                 _agent addMagazine _loot;
  82.             };
  83.         };
  84.     };
  85. };
  86.  
  87. //Start behavior
  88. _id = [_position,_agent] execFSM "\z\AddOns\dayz_code\system\zombie_agent.fsm";
Advertisement
Add Comment
Please, Sign In to add comment