Advertisement
InnovativeStudios

fn_spawnHostage.sqf

May 15th, 2022
1,970
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
SQF 2.09 KB | None | 0 0
  1. /*
  2.     filename: @fn_spawnHostage.sqf
  3.     Author: J. Schmidt
  4.     Coded for SOG Missions and Campaigns
  5.  
  6. */
  7.  
  8. params ["_hostage", "_shooter", "_time"];
  9.  
  10. private _nearPlayers = [];
  11. private _ld0 = getUnitLoadout _shooter;
  12. private _hgun = _ld0 select 2 select 0;
  13. private _hgunMags = _ld0 select 2 select 4;
  14.  
  15. if (alive _hostage && alive _shooter) then {
  16.     _shooter enableAIFeature ["MOVE", false];
  17.     _hostage enableAIFeature ["MOVE", false];
  18.     _hostage setCaptive true;
  19.  
  20.     _shooter switchMove "acts_executioner_standingloop";
  21.     _hostage switchMove "acts_executionvictim_loop";
  22.  
  23.     while {(_time > 0) && alive _hostage && alive _shooter} do {
  24.         _time = _time - 1;
  25.         sleep 1;
  26.  
  27.         if (!alive _shooter) exitWith {
  28.             waitUntil {
  29.                 sleep 1;
  30.                 _nearPlayers = allPlayers inAreaArray [ASLtoAGL getPosASL _hostage, 2, 2, 0, false, 2];
  31.                 count _nearPlayers > 0;
  32.             };
  33.             _hostage setVariable ["hostageVars", [_nearPlayers select 0, _hgun, _hgunMags, _shooter]];
  34.  
  35.             _hostage addEventHandler ["AnimDone", {
  36.                 params ["_unit", "_anim"];
  37.  
  38.                 if (_anim == "acts_executionvictim_unbow") exitWith {
  39.                     (_unit getVariable "hostageVars") params ["_nearPlayer", "_hgun", "_hgunMags", "_shooter"];
  40.  
  41.                     [_unit] joinSilent (group _nearPlayer);
  42.                    
  43.                     { _shooter removeWeapon _x } forEach weapons _shooter;
  44.                     { _shooter removeMagazine _x } forEach magazines _shooter;
  45.  
  46.                     _unit addWeaponGlobal _hgun;
  47.                     _unit addMagazines _hgunMags;
  48.                     _unit enableAIFeature ["MOVE", true];
  49.                     // _unit setCaptive false;
  50.  
  51.                     _unit removeEventHandler ["AnimDone", 0];
  52.                 };
  53.             }];
  54.  
  55.             _hostage playMove "acts_executionvictim_unbow";
  56.         };
  57.  
  58.         if (!alive _hostage) exitWith {
  59.             _hostage playMove "acts_executionvictim_kill_end";
  60.         };
  61.  
  62.         if (_time <= 0 && alive _hostage && alive _shooter) then {
  63.             _shooter playMove "acts_executioner_kill_end";
  64.  
  65.             sleep 2;
  66.  
  67.             playSound "sn_flare_weapon_fired";
  68.             _shooter playMove "acts_executioner_standingloop";
  69.             _hostage setDamage 0.9;
  70.             _hostage playMove "acts_executionvictim_kill_end";
  71.  
  72.             sleep 2.75;
  73.  
  74.             _hostage setDamage 1;
  75.         };
  76.     };
  77. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement