Advertisement
Guest User

Untitled

a guest
Apr 16th, 2014
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.92 KB | None | 0 0
  1. /* //
  2. DZMSAISpawn.sqf by Vampire
  3. Usage: [position,unitcount,skillLevel] execVM "dir\DZMSAISpawn.sqf";
  4. Position is the coordinates to spawn at [X,Y,Z]
  5. UnitCount is the number of units to spawn
  6. SkillLevel is the skill number defined in DZMSAIConfig.sqf
  7. */ //
  8. private ["_rndNum","_rndNum2","_light1","_position","_unitcount","_skill","_wpRadius","_xpos","_ypos","_unitGroup","_aiskin","_unit","_weapon","_magazine","_wppos1","_wppos2","_wppos3","_wppos4","_wp1","_wp2","_wp3","_wp4","_wpfin","_unitArrayName","_unitMissionCount","_barOpen"];
  9. _position = _this select 0;
  10. _unitcount = _this select 1;
  11. _skill = _this select 2;
  12. _unitArrayName = _this select 3;
  13.  
  14. //diag_log text format ["[DZMS]: AI Pos:%1 / AI UnitNum: %2 / AI SkillLev:%3",_position,_unitcount,_skill];
  15.  
  16. _wpRadius = 20;
  17.  
  18. _xpos = _position select 0;
  19. _ypos = _position select 1;
  20.  
  21. //Create the unit group. We use east by default.
  22. _unitGroup = createGroup east;
  23.  
  24. //Probably unnecessary, but prevents client AI stacking
  25. if (!isServer) exitWith {};
  26.  
  27. for "_x" from 1 to _unitcount do {
  28.  
  29. //Lets pick a skin from the array
  30. _aiskin = ["Hooker1","Hooker2","Hooker3","Hooker4"] call BIS_fnc_selectRandom;
  31.  
  32. //Lets spawn the unit
  33. _unit = _unitGroup createUnit [_aiskin, [(_position select 0),(_position select 1),(_position select 2)], [], 10, "PRIVATE"];
  34.  
  35. //Make him join the correct team
  36. [_unit] joinSilent _unitGroup;
  37.  
  38. //Add the behaviour
  39. _unit enableAI "TARGET";
  40. _unit enableAI "AUTOTARGET";
  41. _unit enableAI "MOVE";
  42. _unit enableAI "ANIM";
  43. _unit enableAI "FSM";
  44. _unit allowDammage false;
  45. _unit addEventHandler ["handleDamage", {false}];
  46. _unit setBehaviour "CARELESS";
  47.  
  48. //Remove the items he spawns with by default
  49. removeAllWeapons _unit;
  50. removeAllItems _unit;
  51.  
  52. [_unit] spawn {
  53. _unit = _this select 0;
  54. _barOpen = 0;
  55.  
  56. while {(_barOpen < 50)} do {
  57. _rndNum = floor(random 20);
  58. _rndNum2 = floor(random 20);
  59.  
  60. crueDanceLight1C = [1,0,0];
  61.  
  62. _light1 = "#lightpoint" createVehicleLocal _unitpos;
  63. _light1 setLightBrightness 0.1;
  64. crueDanceLight1 setLightColor crueDanceLight1C;
  65. crueDanceLight1 setLightAmbient crueDanceLight1C;
  66.  
  67. sleep _rndNum;
  68. _unit playMove "ActsPercMstpSnonWnonDnon_DancingStefan";
  69. sleep _rndNum2;
  70.  
  71. deleteVehicle crueDanceLight1;
  72. _barOpen = _barOpen + 1;
  73. };
  74. };
  75.  
  76. //Lets prepare the unit for cleanup
  77. _unit addEventHandler ["Killed",{ [(_this select 0), (_this select 1)] ExecVM DZMSAIKilled; }];
  78. _unit setVariable ["DZMSAI", true];
  79. };
  80.  
  81. //diag_log text format ["[DZMS]: Spawned %1 Hooker at %2",_unitcount,_position];
  82.  
  83. // load the unit groups into a passed array name so they can be cleaned up later
  84. call compile format["
  85. %1 = %1 + (units _unitGroup);
  86. _unitMissionCount = count %1;
  87. ",_unitArrayName];
  88.  
  89. diag_log text format["[DZMS]: (%3) %1 Hooker Spawned, %2 units in mission.",count (units _unitGroup),_unitMissionCount,_unitArrayName];
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement