Jump to content
Sign in to follow this  
JFisher

Hostages like in the Firing from Vehicles Scenario

Recommended Posts

SPOILERS INCOMING FOR THE FIRING FROM VEHICLES SCENARIO!!!

 

Is there an easy way to add hostages to your mission in the same way as the firing from vehicles hostages? Where they had the nice animation and you had to use the BIS_fnc_holdActionAdd action to release them?

 

If not, how do I tie the animations together so nicely like they did there? Currently struggling with getting the animations nice n smooth.

 

Thanks!

Share this post


Link to post
Share on other sites

Alright, I found the anwser. First off let's start by saying that I mixed this up with another mission. The showcase actually doesn't use the `BIS_fnc_holdActionAdd `. Anyway, I added it to my mission. I actually found the anwser by reverse engineering the showcase and man o man, I learned a lot from this. I got the entire hostage thing working with the following scripts:

 

Init.sqf

Spoiler

waitUntil {time > 0};
//===================================================================
// POST-INIT
//===================================================================

// Set Captive Status
{
	private ["_unit"];
	_unit = _x;
	{_unit disableAI _x} forEach ["AUTOTARGET", "MOVE", "TARGET"];
	_unit setCaptive true;

	 
	[ 
		_unit,
		"Release",
		"\a3\ui_f\data\IGUI\Cfg\holdactions\holdAction_unbind_ca.paa",
		"\a3\ui_f\data\IGUI\Cfg\holdactions\holdAction_unbind_ca.paa",
		"_this distance _target < 3",
		"_caller distance _target < 3",
		{},
		{},
		{ FISH_capStatus = 1; },
		{},
		[],
		12,
		0,
		true,
		false
	] remoteExec ["BIS_fnc_holdActionAdd", 0, _unit];
} forEach FISH_capUnits;

[] spawn {
	scriptName "init.sqf: set captive status";
	
	waitUntil {!(isNil "FISH_capStatus")};
	
	private ["_inAnim"];
	_inAnim = false;
	
	if (FISH_capStatus == 0) then {
		// Move into animations
		_inAnim = true;
		{_x switchMove "Acts_AidlPsitMstpSsurWnonDnon_loop"; sleep 1} forEach FISH_capUnits;
	};
	
	waitUntil {FISH_capStatus == 1};
	
	if (!(_inAnim)) then {
		// Enable movement
		{
			private ["_unit"];
			_unit = _x;
			{_unit enableAI _x} forEach ["AUTOTARGET", "MOVE", "TARGET"];
		} forEach FISH_capUnits;
	} else {
		if (isServer) then {
			{
				// Play animation
				_x playMove "Acts_AidlPsitMstpSsurWnonDnon_out";
				
				// Track when animation finishes
				private ["_animEH"];
				_animEH = _x addEventHandler [
					"AnimDone",
					{
						private ["_unit", "_anim"];
						_unit = _this select 0;
						_anim = _this select 1;
						
						if (_anim == "Acts_AidlPsitMstpSsurWnonDnon_out") then {
							// Remove eventhandler
							_unit removeEventHandler ["AnimDone", _unit getVariable "BIS_animEH"];
							
							// Enable movement
							{_unit enableAI _x} forEach ["AUTOTARGET", "MOVE", "TARGET"];
							[[[_unit], {{(_this select 0) enableAI _x} forEach ["AUTOTARGET", "MOVE", "TARGET"]}], "BIS_fnc_spawn"] call BIS_fnc_MP;
						};
					}
				];
				
				_x setVariable ["BIS_animEH", _animEH];
				
				sleep 2;
			} forEach FISH_capUnits;
		};
	};
};

 

 

InitServer.sqf

Spoiler

//===================================================================
// PRE-INIT
//===================================================================
// Global arrays
// Used by the server and clients for either flow conditions or events
FISH_capUnits = [cap1, cap2, cap3]; // Ingame Unit Var Names

// Statuses
// Broadcasted due to local functionality
FISH_capStatus = 0;	// 0: captive, 1: rescued

 

 

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×