Advertisement
Guest User

Untitled

a guest
Apr 15th, 2014
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.85 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. _barOpen = 0;
  53. _rndNum = floor(random 20);
  54. _rndNum2 = floor(random 20);
  55. while {(_barOpen < 50)} do {
  56.  
  57. crueDanceLight1C = [1,0,0];
  58.  
  59. _light1 = "#lightpoint" createVehicleLocal _unitpos;
  60. _light1 setLightBrightness 0.1;
  61. crueDanceLight1 setLightColor crueDanceLight1C;
  62. crueDanceLight1 setLightAmbient crueDanceLight1C;
  63.  
  64. sleep _rndNum;
  65. _aiunit playMove "ActsPercMstpSnonWnonDnon_DancingStefan";
  66. sleep _rndNum2;
  67.  
  68. deleteVehicle crueDanceLight1;
  69. _barOpen = _barOpen + 1;
  70. };
  71.  
  72. //Lets prepare the unit for cleanup
  73. _unit addEventHandler ["Killed",{ [(_this select 0), (_this select 1)] ExecVM DZMSAIKilled; }];
  74. _unit setVariable ["DZMSAI", true];
  75. };
  76.  
  77. //diag_log text format ["[DZMS]: Spawned %1 Hooker at %2",_unitcount,_position];
  78.  
  79. // load the unit groups into a passed array name so they can be cleaned up later
  80. call compile format["
  81. %1 = %1 + (units _unitGroup);
  82. _unitMissionCount = count %1;
  83. ",_unitArrayName];
  84.  
  85. 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