Halvhjearne

DZMSAIKilled.sqf

Feb 28th, 2014
209
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.23 KB | None | 0 0
  1. /*
  2.     DZMSAIKilled.sqf by Vampire
  3.     This function is called when an AI Unit is killed.
  4.     It handles the humanity allocation and body cleanup.
  5. */
  6.  
  7. private ["_unit","_player","_humanity","_banditkills"];
  8. _unit = _this select 0;
  9. _player = _this select 1;
  10.  
  11. //If the killer is a player, lets handle the humanity
  12.  
  13. if (isPlayer _player) then {
  14.     private ["_banditkills","_humanity"];
  15.    
  16.     //diag_log text format ["[DZMS]: Debug: Unit killed by %1 at %2", _player, mapGridPosition _unit];
  17.    
  18.     //Lets grab some info
  19.     _humanity = _player getVariable ["humanity",0];
  20.     _banditkills = _player getVariable ["banditKills",0];
  21.    
  22.     //If the player gets humanity per config, lets give it
  23.     if (DZMSMissHumanity) then {
  24.         _player setVariable ["humanity",(_humanity + DZMSCntHumanity),true];
  25.     };
  26.    
  27.     //If this counts as a bandit kill, lets give it
  28.     if (DZMSCntBanditKls) then {
  29.         _player setVariable ["banditKills",(_banditkills + 1),true];
  30.     };
  31.    
  32.     //Lets inform the nearby AI of roughly the players position
  33.     //This makes the AI turn and react instead of laying around
  34.     {
  35.         if (((position _x) distance (position _unit)) <= 300) then {
  36.             _x reveal [_player, 4.0];
  37.         }
  38.     } forEach allUnits;
  39.    
  40. } else {
  41.  
  42.     //diag_log text format ["[DZMS]: Debug: Unit killed by %1 at %2", _player, mapGridPosition _unit];
  43.  
  44.     if (DZMSRunGear) then {
  45.         //Since a player ran them over, or they died from unknown causes
  46.         //Lets strip their gear
  47.         removeBackpack _unit;
  48.         removeAllWeapons _unit;
  49.         {
  50.             _unit removeMagazine _x
  51.         } forEach magazines _unit;
  52.     };
  53.    
  54. };
  55.  
  56. if (DZMSCleanDeath) then {
  57.     _unit call DZMSPurgeObject;
  58.     if (DZMSCleanDeath) exitWith {};
  59. };
  60. //better check if hasweapon
  61. if (DZMSUseNVG and (_unit hasweapon "NVGoggles")) then {
  62.     _unit removeWeapon "NVGoggles";
  63. };
  64.  
  65. //if (DZMSUseRPG AND ("RPG7V" in (weapons _unit))) then {
  66. //better check if hasweapon and just making sure to remove forEach magazine type for rpg
  67. if (DZMSUseRPG and (_unit hasweapon "RPG7V")) then {
  68.     _unit removeWeapon "RPG7V";
  69.     //untested, but should work like this
  70.     _ammo = [] + getArray (configFile >> "cfgWeapons" >> "RPG7V" >> "magazines");
  71.     {_unit removeMagazine _x}forEach _ammo;
  72. };
  73.  
  74. //Dead body timer and cleanup
  75. [DZMSBodyTime,10] call DZMSSleep;
  76. _unit call DZMSPurgeObject;
Advertisement
Add Comment
Please, Sign In to add comment