Jump to content
mrewok

Trouble WIth EventHandler and model animation.

Recommended Posts

Hello armaverse , i have trouble to script (based on fired near EH) animation on my model ;

My trouble is the following ; i'm doing a boomerang system and i'm able to detect shooter relative position and to exit the EH script if the shooter is the gunner of the vehicle but my problem is it doesn't animate my 3d model as expected...

Here is the script:

/*
Ewk_Boomerang_Eh.sqf
Author(s): MrEwok
Description: This Apply FiredNearEH for Boomerang detection.
Note : None.
FilePath: \EWK_Boomerang_System\Scripts\Ewk_Boomerang_Eh.sqf
*/



										///////////////////////////////////////////For Boomerang System///////////////////////////////////////

										
										
										
										
/*						
	
			this addEventHandler ["FiredNear", {
				params ["_unit", "_firer", "_distance", "_weapon", "_muzzle", "_mode" , "_ammo", "_gunner"];
			}];
*/

DetectMain = false;
publicVariable "DetectMain";
Detect1 = false;
publicVariable "Detect1";
Detect2 = false;
publicVariable "Detect2";
Detect3 = false;
publicVariable "Detect3";
Detect4 = false;
publicVariable "Detect4";
Detect5 = false;
publicVariable "Detect5";
Detect6 = false;
publicVariable "Detect6";
Detect7 = false;
publicVariable "Detect7";
Detect8 = false;
publicVariable "Detect8";
Detect9 = false;
publicVariable "Detect9";
Detect10 = false;
publicVariable "Detect10";
Detect11 = false;
publicVariable "Detect11";
Detect12 = false;
publicVariable "Detect12";

vclBoomerang = _this select 0;	
publicVariable "vclBoomerang";	
while {vclBoomerang animationphase "SYS_boomerang" >= 0.5} do	{
	DetectMain = true;
	if (vclBoomerang animationphase "SYS_boomerang" <= 0.5) exitWith {vclBoomerang execVM "\EWK_Boomerang_System\Scripts\Ewk_Boomerang_Loop.sqf";};
};
	if (DetectMain) then
{
											
vclBoomerang addEventHandler ["FiredNear",
{
    _this spawn 
    {
        params ["_unit", "_firer", "_distance", "_weapon", "_muzzle", "_mode" , "_ammo", "_gunner"];
		
		if (_unit == _firer) exitWith
		{
			hintSilent "";
		};
		hintSilent "";
        if (_distance < 100) then
        {
            {
				
                _relDir = _unit getRelDir _firer;
                if (_relDir > (_x select 0) && _relDir < (_x select 1)) then
                {
				XGvar = _x;
				publicVariable "XGvar";
                    sleep 0.5;
                    //systemChat format["Shooter is at %1 from the Vehicle",(_x select 2)];
					DetectMain = true;
					publicVariable "DetectMain";
					

				

				_case = {};
				if ((_x select 2) isEqualTo "12 oclock") then {_case = 1};
				if ((_x select 2) isEqualTo "1 oclock") then {_case = 2};
				if ((_x select 2) isEqualTo "2 oclock") then {_case = 3};
				if ((_x select 2) isEqualTo "3 oclock") then {_case = 4};
				if ((_x select 2) isEqualTo "4 oclock") then {_case = 5};
				if ((_x select 2) isEqualTo "5 oclock") then {_case = 6};
				if ((_x select 2) isEqualTo "6 oclock") then {_case = 7};
				if ((_x select 2) isEqualTo "7 oclock") then {_case = 8};
				if ((_x select 2) isEqualTo "8 oclock") then {_case = 9};
				if ((_x select 2) isEqualTo "9 oclock") then {_case = 10};
				if ((_x select 2) isEqualTo "10 oclock") then {_case = 11};
				if ((_x select 2) isEqualTo "11 oclock") then {_case = 12};
				
				
				
						/////////////	Those are parsed as they display variable and the value is true wich mean they are changed	/////////////
				switch (_case) do 
				{
				case 1:
				{
				Detect1 = true;
				publicVariable "Detect1";
				//systemChat "Detect1";
				//systemChat str Detect1;
				}; 
				case 2: 	
				{
				Detect2 = true;
				publicVariable "Detect2";
				//systemChat "Detect2";
				//systemChat str Detect2;				
				}; 
				case 3:
				{				
				Detect3 = true;
				publicVariable "Detect3";
				//systemChat "Detect3";
				//systemChat str Detect3;
				}; 
				case 4: 	
				{				
				Detect4 = true;
				publicVariable "Detect4";
				//systemChat "Detect4";
				//systemChat str Detect4;
				}; 
				case 5: 	
				{				
				Detect5 = true;
				publicVariable "Detect5";
				//systemChat "Detect5";
				//systemChat str Detect5;
				}; 
				case 6: 	
				{				
				Detect6 = true;
				publicVariable "Detect6";
				//systemChat "Detect6";
				//systemChat str Detect6;
				};  
				case 7: 	
				{				
				Detect7 = true;
				publicVariable "Detect7";
				//systemChat "Detect7";
				//systemChat str Detect7;
				}; 				
				case 8: 	
				{				
				Detect8 = true;
				publicVariable "Detect8";
				//systemChat "Detect8";
				//systemChat str Detect8;
				};  
				case 9: 	
				{				
				Detect9 = true;
				publicVariable "Detect9";
				//systemChat "Detect9";
				//systemChat str Detect9;
				}; 
				case 10: 	
				{				
				Detect10 = true;
				publicVariable "Detect10";
				//systemChat "Detect10";
				//systemChat str Detect10;
				}; 
				case 11: 	
				{				
				Detect11 = true;
				publicVariable "Detect11";
				//systemChat "Detect11";
				//systemChat str Detect11;
				}; 
				case 12: 	
				{				
				Detect12 = true;
				publicVariable "Detect12";
				//systemChat "Detect12";
				//systemChat str Detect12;
				}; 
			};
					
					/*
					if ((_x select 2) isEqualTo "12 oclock") then {vclBoomerang animate ["Led12_Hide", 1]; Sleep 1; vclBoomerang animate ["Led12_Hide", 0];systemChat str (_x select 2);};
					if ((_x select 2) isEqualTo "1 oclock") then {vclBoomerang animate ["Led1_Hide", 1]; Sleep 1; vclBoomerang animate ["Led1_Hide", 0];systemChat str (_x select 2);};
					if ((_x select 2) isEqualTo "2 oclock") then {vclBoomerang animate ["Led2_Hide", 1]; Sleep 1; vclBoomerang animate ["Led2_Hide", 0];systemChat str (_x select 2);};
					if ((_x select 2) isEqualTo "3 oclock") then {vclBoomerang animate ["Led3_Hide", 1]; Sleep 1; vclBoomerang animate ["Led3_Hide", 0];systemChat str (_x select 2);};
					if ((_x select 2) isEqualTo "4 oclock") then {vclBoomerang animate ["Led4_Hide", 1]; Sleep 1; vclBoomerang animate ["Led4_Hide", 0];systemChat str (_x select 2);};
					if ((_x select 2) isEqualTo "5 oclock") then {vclBoomerang animate ["Led5_Hide", 1]; Sleep 1; vclBoomerang animate ["Led5_Hide", 0];systemChat str (_x select 2);};
					
					if ((_x select 2) isEqualTo "6 oclock") then {vclBoomerang animate ["Led6_Hide", 1]; Sleep 1; vclBoomerang animate ["Led6_Hide", 0];systemChat str (_x select 2);};
					if ((_x select 2) isEqualTo "7 oclock") then {vclBoomerang animate ["Led7_Hide", 1]; Sleep 1; vclBoomerang animate ["Led7_Hide", 0];systemChat str (_x select 2);};
					if ((_x select 2) isEqualTo "8 oclock") then {vclBoomerang animate ["Led8_Hide", 1]; Sleep 1; vclBoomerang animate ["Led8_Hide", 0];systemChat str (_x select 2);};
					if ((_x select 2) isEqualTo "9 oclock") then {vclBoomerang animate ["Led9_Hide", 1]; Sleep 1; vclBoomerang animate ["Led9_Hide", 0];systemChat str (_x select 2);};
					if ((_x select 2) isEqualTo "10 oclock") then {vclBoomerang animate ["Led10_Hide", 1]; Sleep 1; vclBoomerang animate ["Led10_Hide", 0];systemChat str (_x select 2);};
					if ((_x select 2) isEqualTo "11 oclock") then {vclBoomerang animate ["Led11_Hide", 1]; Sleep 1; vclBoomerang animate ["Led11_Hide", 0];systemChat str (_x select 2);};
					*/
					
                    systemChat str _relDir;
					//_Select2 = _x select 2;
					//systemChat str (_x select 2);
                };
            } forEach [
            [0, 15, "12 oclock"],
            [15, 45, "1 oclock"],
            [45, 75, "2 oclock"],
            [75, 105, "3 oclock"],
            [105, 135, "4 oclock"],
            [135, 165, "5 oclock"],
            [165, 195, "6 oclock"],
            [195, 225, "7 oclock"],
            [225, 255, "8 oclock"],
            [255, 285, "9 oclock"],
            [285, 315, "10 oclock"],
            [315, 345, "11 oclock"],
            [345, 360, "12 oclock"]
            ];
        };
    };
}];
};
 //////////////////////////////////////I've Added this to see if it could animate in another loop than the EH one but still doesn't work///////////////////////////////////////////////////
 
												// It detect and display the select2 (wich is the 1 oclock 2 oclock etc....)//
while {DetectMain} do 
{
					//animateSource ["Led1_Hide", 1, true];Sleep 0.5; vclBoomerang animateSource ["Led1_Hide", 0];systemChat str (_x select 2);};
	if (Detect1) then {vclBoomerang animateSource ["Led1_Hide", 1, true]; Sleep 0.5; vclBoomerang animateSource ["Led1_Hide", 0, true];systemChat str (XGvar select 2);};
	if (Detect2) then {vclBoomerang animateSource ["Led2_Hide", 1, true]; Sleep 0.5; vclBoomerang animateSource ["Led2_Hide", 0, true];systemChat str (XGvar select 2);};
	if (Detect3) then {vclBoomerang animateSource ["Led3_Hide", 1, true]; Sleep 0.5; vclBoomerang animateSource ["Led3_Hide", 0, true];systemChat str (XGvar select 2);};
	if (Detect4) then {vclBoomerang animateSource ["Led4_Hide", 1, true]; Sleep 0.5; vclBoomerang animateSource ["Led4_Hide", 0, true];systemChat str (XGvar select 2);};
	if (Detect5) then {vclBoomerang animateSource ["Led5_Hide", 1, true]; Sleep 0.5; vclBoomerang animateSource ["Led5_Hide", 0, true];systemChat str (XGvar select 2);};
	if (Detect6) then {vclBoomerang animateSource ["Led6_Hide", 1, true]; Sleep 0.5; vclBoomerang animateSource ["Led6_Hide", 0, true];systemChat str (XGvar select 2);};
	if (Detect7) then {vclBoomerang animateSource ["Led7_Hide", 1, true]; Sleep 0.5; vclBoomerang animateSource ["Led7_Hide", 0, true];systemChat str (XGvar select 2);};
	if (Detect8) then {vclBoomerang animateSource ["Led8_Hide", 1, true]; Sleep 0.5; vclBoomerang animateSource ["Led8_Hide", 0, true];systemChat str (XGvar select 2);};
	if (Detect9) then {vclBoomerang animateSource ["Led9_Hide", 1, true]; Sleep 0.5; vclBoomerang animateSource ["Led9_Hide", 0, true];systemChat str (XGvar select 2);};
	if (Detect10) then {vclBoomerang animateSource ["Led10_Hide", 1, true]; Sleep 0.5; vclBoomerang animateSource ["Led10_Hide", 0, true];systemChat str (XGvar select 2);};
	if (Detect11) then {vclBoomerang animateSource ["Led11_Hide", 1, true]; Sleep 0.5; vclBoomerang animateSource ["Led11_Hide", 0, true];systemChat str (XGvar select 2);};
	if (Detect12) then {vclBoomerang animateSource ["Led12_Hide", 1, true]; Sleep 0.5; vclBoomerang animateSource ["Led12_Hide", 0, true];systemChat str (XGvar select 2);};
};

I can Provide more infos if needed ( config ,model.cfg basic model to animate (to reproduce problem) etc...)

I've tried to reduce animPeriod an tried to use animateSource as Biki says it's can be immediate and i was thinking problem was the speed of the EH/Animation, but doesn't seems to be it. Maybe i could add an ID to the EH but don't really know where to begin and if it can do the trick...

 

Cheers.

MrEwok. 

Share this post


Link to post
Share on other sites

Managed to make it work, it seems it doesn't  animate proxy that is not located in the same pbo as the model... 

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

×