Jump to content

Recommended Posts

Hello there i'm having issues with BIS_fnc_relativeDirTo (the purpose is to create a boomerang system that will have a animated led 3d model in my HMMWV's like my crewduke) ,  my problem is that it is spamming some random 90, 180, 270 values... (maybe not random but i don't get why i got those values) 

here is a video (don't mind the generic error i've added a sleep in a unscheduled environment but the detection weirdly seems to work better (Probably just a placebo effect i think^^)) As you can see i have some random values coming in...

 

Video showing my problem

 


For now the script is init by a module (Will add action to add it and activate it later):

/*
sys_boomerang_animate.sqf
Author(s): MrEwok
Description: This Animate (for now) the boomerang system and run Boomerang script collection.
Note : None.
FilePath: \EWK_Boomerang_System\Scripts\sys_boomerang_animate.sqf
*/



_car = _this select 0;

_car animate ["SYS_boomerang", 0];

									////////////////////////////////////////////For Boomerang System///////////////////////////////////////
[_car] execVM "\EWK_Boomerang_System\Scripts\Ewk_Boomerang_Eh.sqf";

waitUntil {!alive _car};

_car animate ["SYS_boomerang", 1];

[_car] execVM "EWK_Boomerang_System\Module\boomerang\sys_boomerang_animate.sqf";

And then it run this 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"];
			}];
*/



	vclBoomerang = _this select 0;										
										
	vclBoomerang addEventHandler ["FiredNear",
	{
	if ((_this select 2) < 100/*Need To Adjust*/) then
	{

	_Shooter = _this select 0;
	_gunner = _this select 7;
	hint str _gunner;
	
	{
	


	
	
	
		
		_relDir = [_Shooter, vclBoomerang] call BIS_fnc_relativeDirTo;
		
		
		if ( _relDir > (_x select 0) && _relDir < (_x select 1) ) then {
			sleep 0.5;  // This is the Generic error in the video...
			systemChat format["Shooter is at %1 from the Vehicle",(_x select 2)];
			systemChat str _relDir;
			
		};
	}forEach [
	
							///////////////////////////////////////////This Was Working but not precise enough///////////////////////////////////////////	
							
							
		/* !!!Basic detection system decrepited!!!
		[45, 135, "to the right of"],
		[135, 225, "behind"],
		[225, 315, "to the left of"],
		[315, 360, "infront"],
		[0, 45, "infront"]
		*/
		
					///////////////////////////////////////////This Was Working END///////////////////////////////////////////
		
		
		[0, 15, "12 oclock"],
		[-0, -15, "12 oclock"],
		//0 = 12 donc 0 a 15
		[15, 45, "1 oclock"],
		[-15, -45, "1 oclock"],
		//30 = 1 donc 15 a 45
		[45, 75, "2 oclock"],
		[-45, -75, "2 oclock"],
		//60 = 2 donc 45 a 75
		[75, 105, "3 oclock"],
		[-75, -105, "3 oclock"],
		//90 = 3 donc 75 a 105
		[105, 135, "4 oclock"],
		[-105, -135, "4 oclock"],
		//120 = 4 donc 105 a 135
		[135, 165, "5 oclock"],
		[-135, -165, "5 oclock"],
		//150 = 5 donc 135 a 165
		[165, 195, "6 oclock"],
		[-165, -195, "6 oclock"],
		//180 = 6 donc 165 a 195
		[195, 225, "7 oclock"],
		[-195, -225, "7 oclock"],
		//210 = 7 donc 195 a 225
		[225, 255, "8 oclock"],
		[-225, -255, "8 oclock"],
		//240 = 8 donc 225 a 255
		[255, 285, "9 oclock"],
		[-255, -285, "9 oclock"],
		//270 = 9 donc 255 a 285
		[285, 315, "10 oclock"],
		[-285, -315, "10 oclock"],
		//300 = 10 donc 285 a 315
		[315, 345, "11 oclock"],
		[-315, -345, "11 oclock"],
		//330 = 11 donc 315 a 345
		[345, 360, "12 oclock"],
		[-345, -360, "12 oclock"]
		//360 = 12 donc 345 a 360
	
	];



};
}];

Please help me!

I don't wan't to release my mod without that feature even if it's a little bit harsh (in fact i could already add the boomerang v2 and say "it's the V2 V3 is better ... but i wan't to add a real V3 and make an alternative version for V2 that's add some kind of randomness if some mission maker want to make it harder ).

I can provide more info if needed (config or basic models with cfg and cpp to reproduce...)...

Share this post


Link to post
Share on other sites

I can't say it will fix the issue, but the Biki states unambiguously:

 

T9W4AF3.png

  • Like 1

Share this post


Link to post
Share on other sites

I've tried i get the same random values... 

I can provide the old code i was using with getRelDir but i was the results where the same or worse and it was almost the same...

basically  instead of:

_relDir = [_Shooter, vclBoomerang] call BIS_fnc_relativeDirTo;

 

I've used:

_relDir = vclBoomerang getRelDir _Shooter;

 

I'm kinda noob in scripting I'm more that 3D/config/model.cfg guy so excuse my poor knowledge 🤣 .

Maybe i can use getRelPos but with object getRelPos [distance, direction] i dunno if i can add it into firedNearEH or i should say i dunno how i can add them ^^

I'm Mounting my P drive and retrying to see if i stiil get thos values with getRelDir and getRelPos (if i can set it up^^) and i get back here.

Edit: i've forgotten to say there's always cba(for some features and for ace) and ace (for crewduke feature and itemcargo in the humvees) launched with my mod .

So i will check if ace change basic EH on their chat now (i've just think about it how dumb i am ^^).

 

Share this post


Link to post
Share on other sites

Well, I just tried this and it seems to work just fine (calling from vehicle init):

 

//[this] execVM "ok_boomer.sqf";

_vclBoomerang = _this select 0;														
_vclBoomerang addEventHandler ["FiredNear",
{
    _this spawn 
    {
        params ["_unit", "_firer", "_distance", "_weapon", "_muzzle", "_mode" , "_ammo", "_gunner"];
        if (_distance < 100) then
        {
            {
                _relDir = _unit getRelDir _firer;
                if (_relDir > (_x select 0) && _relDir < (_x select 1)) then
                {
                    sleep 0.5;
                    systemChat format["Shooter is at %1 from the Vehicle",(_x select 2)];
                    systemChat str _relDir;
                };
            } 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 removed the checks for negative values as they will never evaluate true (both getRelDir and the BIS function return only positive values between 0 and 360).

 

I added a spawn so the sleep could run.

 

Running your code as-is, I saw the pure values, but backtracking from my "fixes" I was unable to get them. Not sure where the problem is, I'll keep looking.

 

One thing to remember with the FiredNearEH is that it will also trigger when the unit the EH is attached to fires - it will detect the .50 in your HMMWV turret.

  • Thanks 1

Share this post


Link to post
Share on other sites

I will try that i think it'll work as it spawn so it's sheduled and i think problem was the fact firednear is scheduled an systemchat is not... i can be wrong trought... 

Also double check with negative values is because of this 

//ensure return is between 0-360.

if (_dir < 0) then {_dir = _dir + 360};

if (_dir > 360) then {_dir = _dir - 360};

And i wasn't sure this:

if ( _relDir > (_x select 0) && _relDir < (_x select 1) ) then { MYCODE.....

  was the same

Share this post


Link to post
Share on other sites

OK, I started with your code then gradually applied my "fixes" until the issue disappeared. Sticking with declaring the EH's params and using those variables was the fix.

 

I think it is best practice to declare an EH's full set of params, even if you aren't going to use them all.

Share this post


Link to post
Share on other sites

It's work like a charm thanks Harzach !!!

If you want me to provide the script just ask , i will Update it for my purpose trought so basic detection will change...

@Harzach yeah i'm learning as i can but as i said i'm more that 3d / config guy , i was that guy in EODS and i will stay that guy i think^^, i'm trying to maintain and update my hmmwv mod as i can after six years of non modding ^^

  • Like 1

Share this post


Link to post
Share on other sites

Great! I don't actually play much anymore, but I enjoy solving problems. I always thought a Boomerang system would be a nice option to have alongside the CREW Duke and whatnot. Have fun!

  • Like 1

Share this post


Link to post
Share on other sites

I don't play that much too (at least in MP) but i have some spare time with that covid shit so i thought i could at least update my mod and it degenerated so i'm adding few features^^ so crew duke is functional but need polishing and boomerang is comming thanks to you. Will try those finctionality's in MP to ensure it's fully working.

  • Like 1

Share this post


Link to post
Share on other sites
23 minutes ago, mrewok said:

And i wasn't sure this:

if ( _relDir > (_x select 0) && _relDir < (_x select 1) ) then { MYCODE.....

  was the same

 

I mean, I don't know how a negative value could slip in there as neither the command nor the function are capable of returning one, but if you're fine with the extra code, go for it! 

 

My test included driving around inside a ring of 36 riflemen, while filling an array with every unique _relDir value. Thousands of values, no negatives.

Share this post


Link to post
Share on other sites

Yep i've never had negative but always used that code that always return positive (i and the eods team where using it a lot when it was way before v2.0 of arma (i'm an old decrepited modder ^^) and as i don't really understand scriptig and as i haven't found anything on it i was, (like a dumbass) assuming that was still reliable... (but honestly since 2016 a lot of things have change^^) .But from what i've quickly tested it fully work and if i can detect it i can animate a model and play sounds so i wiil work on that thing ^^.

  • Like 1

Share this post


Link to post
Share on other sites

Hello there i'm coming back because i have trouble with the animations following that EH script.

I'll explain more,

The detection is with the EH as Said before but it seems it's too fast to animate model even with animateSource and global variables...

I may create another thread as it's not really related to the GetRelDir thing...

Here is the scipt:

/*
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";													
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
                {
                    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);};
	while {Detect1} do {vclBoomerang animateSource ["Led1_Hide", 1, true]; Sleep 0.5; vclBoomerang animateSource ["Led1_Hide", 0, true];systemChat str (_x select 2);};
	while {Detect2} do {vclBoomerang animateSource ["Led2_Hide", 2, true]; Sleep 0.5; vclBoomerang animateSource ["Led2_Hide", 0, true];systemChat str (_x select 2);};
	while {Detect3} do {vclBoomerang animateSource ["Led3_Hide", 3, true]; Sleep 0.5; vclBoomerang animateSource ["Led3_Hide", 0, true];systemChat str (_x select 2);};
	while {Detect4} do {vclBoomerang animateSource ["Led4_Hide", 4, true]; Sleep 0.5; vclBoomerang animateSource ["Led4_Hide", 0, true];systemChat str (_x select 2);};
	while {Detect5} do {vclBoomerang animateSource ["Led5_Hide", 5, true]; Sleep 0.5; vclBoomerang animateSource ["Led5_Hide", 0, true];systemChat str (_x select 2);};
	while {Detect6} do {vclBoomerang animateSource ["Led6_Hide", 6, true]; Sleep 0.5; vclBoomerang animateSource ["Led6_Hide", 0, true];systemChat str (_x select 2);};
	while {Detect7} do {vclBoomerang animateSource ["Led7_Hide", 7, true]; Sleep 0.5; vclBoomerang animateSource ["Led7_Hide", 0, true];systemChat str (_x select 2);};
	while {Detect8} do {vclBoomerang animateSource ["Led8_Hide", 8, true]; Sleep 0.5; vclBoomerang animateSource ["Led8_Hide", 0, true];systemChat str (_x select 2);};
	while {Detect9} do {vclBoomerang animateSource ["Led9_Hide", 9, true]; Sleep 0.5; vclBoomerang animateSource ["Led9_Hide", 0, true];systemChat str (_x select 2);};
	while {Detect10} do {vclBoomerang animateSource ["Led10_Hide", 10, true]; Sleep 0.5; vclBoomerang animateSource ["Led10_Hide", 0, true];systemChat str (_x select 2);};
	while {Detect11} do {vclBoomerang animateSource ["Led11_Hide", 11, true]; Sleep 0.5; vclBoomerang animateSource ["Led11_Hide", 0, true];systemChat str (_x select 2);};
	while {Detect12} do {vclBoomerang animateSource ["Led12_Hide", 12, true]; Sleep 0.5; vclBoomerang animateSource ["Led12_Hide", 0, true];systemChat str (_x select 2);};
};

Thanks!

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

×