Jump to content
Mr H.

Detect whe vehicle animation is changed.

Recommended Posts

I have noticed that the event handlers animChanged, animDone and animStateChanged work very well on humans in game but they do not seem to fire when a vehicle's animation is fired (door opening on an RHS vehicle), is there any other way to test when a vehicle is changing animation? For the moment I'm using stuff like:
 

	waitUntil {((_vehicle animationPhase "hide_tent") == 0) || ((_vehicle animationPhase "hide_tent") == 1)};

But getting the EH to work would be much more satisfying.

Share this post


Link to post
Share on other sites

Perhaps you could try:

inGameUISetEventHandler ["Action","
  params ['_tgt','_caller','_id','_menu'];
  if (_menu == 'Hide tent'') then {
<your stringed code here>
  };
  false
"];

 

If you're not sure how it works, test:

inGameUISetEventHandler ["Action"," hint str _this ;  false"];

 

just be aware, you can have only one inGameUISetEventHandler at the same time. The older will crush the previous one as it's not stackable.

  • Like 1

Share this post


Link to post
Share on other sites

That's what I did but I wasn't aware it wasn't stackable (which might become an issue later) also the strangest thing happened:
I use it to spawn stuff inside the tent of "rhsusf_M1085A1P2_B_D_Medical_fmtv_usarmy" (from RHSUSAF) when it's deployed.
It works very well for me but in MP for my friend the actions where inverted: the items spawned when he closed the tent and I don't know why. Here's the full code: (includes some stuff that's also relevant to my previous question on getting init) :
 

MHQ = [["Land_ClutterCutter_large_F",[0,-5,0],0,false,false,false,false,[]],["Sign_Arrow_Green_F",[-1803.37,-253.378,-0.564929],-335.682,false,false,false,false,[]],["Sign_Arrow_F",[-1803.37,-253.378,-0.564929],-335.682,false,false,false,false,[]],["Sign_Arrow_Yellow_F",[-1803.37,-253.378,-0.564929],-335.682,false,false,false,false,[]],["Land_HelipadEmpty_F",[0.353271,-1.85486,-1.53022],-335.682,true,false,false,false,[]],["Land_Stretcher_01_sand_F",[0.268799,-2.59204,-2.02156],-91.2231,false,false,false,false,[]],["Land_Stretcher_01_sand_F",[0.532959,-1.02863,-2.02274],-91.2226,false,false,false,false,[]],["Land_Stretcher_01_sand_F",[0.928955,-4.19342,-2.02103],-91.2235,false,false,false,false,[]],["MedicalGarbage_01_1x1_v2_F",[-0.236328,-1.82489,-1.76981],-335.682,false,false,false,false,[]],["Land_IntravenStand_01_2bags_F",[1.16663,-1.90289,-2.02262],24.3161,false,false,false,false,[]],["Land_TripodScreen_01_large_F",[2.72949,-6.46667,-2.02085],-80.7826,false,false,true,false,[]],["Land_Laptop_device_F",[-1.38879,-6.58466,-1.15523],-103.901,false,true,false,false,[]],["Land_Portable_generator_F",[-2.32483,-1.73682,-2.02105],24.316,false,false,false,false,[]],["Land_PortableLight_double_F",[-1.81714,-0.993042,-1.79225],-29.3421,false,false,false,false,[]],["acre_oe_303",[7.07385,-9.62292,-2.02203],-335.682,false,false,false,false,[]],["C_supplyCrate_F",[-2.58264,-7.60071,-2.01635],-175.218,false,false,false,true,[10,true,true]],["Land_WoodenTable_large_F",[-0.563721,-6.49072,-2.01851],-269.219,false,false,false,false,[]],["Land_CampingChair_V2_F",[-0.0749512,-7.23315,-2.01839],-193.902,false,false,false,false,[]],["Land_CampingChair_V2_F",[-1.07922,-7.46399,-2.01753],-253.899,false,false,false,false,[]],["Land_CampingChair_V2_F",[-0.0460205,-5.73322,-2.01936],-13.8943,false,false,false,false,[]],["Land_CampingChair_V2_F",[-0.987061,-5.78009,-2.01865],1.0712,false,false,false,false,[]],["Land_PaperBox_open_empty_F",[-5.26428,-5.37286,-2.01583],-155.682,false,false,false,false,[]],["ACE_medicalSupplyCrate_advanced",[3.02014,-2.38989,-2.02367],-82.6879,false,false,false,false,[]]];



inGameUISetEventHandler ["Action", "_this call MRH_fnc_RHS_CPBSACTION"];

MRH_fnc_grabObject = {
params ["_pivot","_objectToGrab"];

_relPos = _pivot worldToModel (getPosATL _objectToGrab);
_dir = getDir _pivot;
_objDir = getDir _objectToGrab;
_relDir = (_objDir - _dir);
_className = typeOf _objectToGrab;
_isAceMedicalFacility =_objectToGrab getVariable ["ace_medical_ismedicalfacility",false];
_isMRHSatelliteConsole = _objectToGrab getVariable ["MRH_Sat_isSatelliteConsole",false];
_isMRHSatelliteScreen = _objectToGrab getVariable ["MRH_Sat_isSatelliteScreen",false];
_AmmoCrateParams = _objectToGrab getVariable ["MRH_AmmoCrateParameters",[]];
_isAmmoBox = false;
_isAceRepairFacility = _objectToGrab getVariable ["ace_isrepairfacility",0];
if !(_AmmoCrateParams isEqualTo[]) then {
	_isAmmoBox = true,
	_AmmoCrateParams deleteAt 0;
	};
_return = [_className,_relPos,_reldir,_isAceMedicalFacility,_isMRHSatelliteConsole,_isMRHSatelliteScreen,_isAmmoBox,_AmmoCrateParams,_isAceRepairFacility];
_return
};

MRH_fnc_createObject = {
params ["_pivot","_className","_relPos","_relDir","_isAceMedicalFacility","_isMRHSatelliteConsole","_isMRHSatelliteScreen","_isAmmoBox","_AmmoCrateParams",["_isAceRepairFacility",0]];
_object = _className createVehicle _relPos;
_object setPosATL (_pivot modelToWorld _relPos);
_object setDir ((getDir _pivot) + _reldir);
_object setVectorUp surfaceNormal position _object;
_object setVariable ["ace_medical_ismedicalfacility",_isAceMedicalFacility,true];
_object setVariable ["ace_isrepairfacility",_isAceRepairFacility,true];
if (_isMRHSatelliteConsole) then {[[_object],MRH_fnc_IsSatelliteConsole] remoteExec ["Call",[0,-2] select isDedicated,true]};
if (_isMRHSatelliteScreen) then {[[_object],MRH_fnc_IsSatMonitor] remoteExec ["Call",[0,-2] select isDedicated,true]};
if (_isAmmoBox) then {
	_AmmoCrateParams params ["_number","_unli","_refresh"];
	[[_object,_number,_unli,_refresh],MRH_fnc_AmmoCrate] remoteExec ["Call",[0,-2] select isDedicated,true];
	};
_object	
};

MRH_fnc_storeComp = {
params ["_pivot","_objectsArray"];
_dataOutPut = [];
{
	private _entry = [_pivot,_x] call MRH_fnc_grabObject;
	_dataOutPut pushBackUnique _entry;
} forEach _objectsArray;
_dataOutPut
};

MRH_fnc_spawnComp = {
	params ["_pivot","_dataInput"];

	_compObjects = [];
	{
		/*
		private _class = _x select 0;
		private _relPos = _x select 1;
		private _relDir = _x select 2;
		private _isAceMedicalFacility = _x select 3;
		private _isMRHSatelliteConsole = _x select 4;
		private _isMRHSatelliteScreen = _x select 5;
		private _isAmmoBox = _x select 6;
		private _AmmoCrateParams = _x select 7;
		private _isAceRepairFacility = _x select 8;
		*/
		_x params ["_class","_relPos","_relDir","_isAceMedicalFacility","_isMRHSatelliteConsole","_isMRHSatelliteScreen","_isAmmoBox","_AmmoCrateParams",["_isAceRepairFacility",0]];
		private _object = [_pivot,_class,_relPos,_relDir,_isAceMedicalFacility,_isMRHSatelliteConsole,_isMRHSatelliteScreen,_isAmmoBox,_AmmoCrateParams,_isAceRepairFacility] call MRH_fnc_createObject;
		_compObjects pushBackUnique _object;
	} forEach _dataInput;
	_compObjects
};


MRH_fnc_createComp ={
	params ["_pivot"];
	_allObjects = [];
	_allMission= allMissionObjects "All";
	{
		if (!(isplayer _x) && (_x != _pivot) && (typeOf _x != "logic") && !(_x isKindOf "Man")) then {_allObjects pushBackUnique _x};
	} forEach _allMission;
	_comp = [_pivot,_allObjects] call MRH_fnc_storeComp;
	copyToClipboard str _comp;
};
MRH_fnc_RHS_CPBSACTION = {

	
	0 = _this spawn {
	_vehicle = _this select 0;
	if ((typeOf _vehicle) != "rhsusf_M1085A1P2_B_D_Medical_fmtv_usarmy") exitWith {};
	if ((_vehicle animationPhase "platform")!= 1) exitWith {};
	_alreadyCalled = _vehicle getVariable ["MRH_MHQ_actionCalled",false];
	if (_alreadyCalled) exitWith {hint "exited"};
	_vehicle setVariable ["MRH_MHQ_actionCalled",true,true];
	//if (((_vehicle animationPhase "hide_tent") != 1) && ((_vehicle animationPhase "hide_tent") != 0)) exitWith { hint "exited"};

	_doDelete = _vehicle getVariable ["MRH_MHQ_Comp",[]];
	if !(_doDelete isEqualTo []) then {{deleteVehicle _x}forEach _doDelete};
	waitUntil {((_vehicle animationPhase "hide_tent") == 0) || ((_vehicle animationPhase "hide_tent") == 1)};
	if ((_vehicle animationPhase "hide_tent") == 0) then {hint "tente repliée"};
	if ((_vehicle animationPhase "hide_tent") == 1) then {
		hint "tente deployée";
		_comp =[_vehicle,mhq] call MRH_fnc_spawnComp;
		_vehicle setVariable ["MRH_MHQ_Comp",_comp,true];

		};
	_vehicle setVariable ["MRH_MHQ_actionCalled",false,true];
	};


};

 

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

×