Jump to content
HazJ

[SOLVED] Grenade owner/side/group (Grenade Indicators)

Recommended Posts

Hi all,

I made grenade indicators two years ago and came around to move/update code, etc and I just don't like the way I did it but I can't seem to think of any other way. Each client has FiredNear EH which checks if grenade and then adds it to appropriate array.

if (isNil "groupIndex") then
{
	groupIndex = 1;
} else
{
	groupIndex = groupIndex + 1;
};

bluforGrenades = [];
opforGrenades = [];
groupGrenades = [];
call compile format ["group%1Grenades = [];", groupIndex];

The reason for call compile + groupIndex is Independent isn't one side. It is a solo team with groups system so friendly grenades would show for separate group. Grenades doesn't appear to have side, I have tried owner and a few other things as well but had no luck.  Surely there must be a better way of doing this? I just can't think what. Any help would be great!

Below is a video, you may want to mute your volume as I had Smooth radio running in background lol. Not my daily bus route music but I find it relaxing when coding in ArmA, lol. We all need to be relaxed when coding in ArmA, or even sometimes playing it. As we all know lol... "ArmA'd"

 

The last AI was determined to get away from being fragged with the grenade, but I was more determined! As you can see in the video, lol.

  • Like 2

Share this post


Link to post
Share on other sites

Bump. Anyone? Still looking for a better way of doing this. @Larrow ? (:

Share this post


Link to post
Share on other sites

One last try, bump. I would really like to know a better way of doing this.

  • Like 1

Share this post


Link to post
Share on other sites

I am sorry, what exactly are you trying to achieve ? get side of person who throw the grenade ?

Share this post


Link to post
Share on other sites

@M1ke_SK

Not the side of unit. The side of the grenade or something similar. At the moment, I use FiredNear EH and add to appropriate array.

bluforGrenades = [];
opforGrenades = [];
groupGrenades = [];
call compile format ["group%1Grenades = [];", groupIndex];

I use onEachFrame with BIS_fnc_addStackedEventHandler to show and update the grenade icon. I would like to somehow remove EH and the use of all those arrays and just get the grenade thrower or something.

_friendlyGrenades = player nearObjects ["GrenadeHand", GRENADE_SEARCH_RADIUS];

I need to filter them for blufor, opfor and Independent solo players/groups.

Share this post


Link to post
Share on other sites

Why not pre-define array of allowed grenades. `bluforGrenades = ["class1", "class2", ...];` and then filter by using class of grenade and use command `in`.

if (typeOf _grenade in blueforGrenades) then 
{
	// ... do stuff
}

 

Share this post


Link to post
Share on other sites

@M1ke_SK

Because one side can use same grenade types from other sides. I have it working with arrays + Fired EH just fine but I feel like there could be a better way of doing it, without the hacky work-around.

Share this post


Link to post
Share on other sites

Not sure if it will work, but in the fired eventhandler you could use setShotParents and then, while using nearObjects, filter the indicators according to the side of the group and using the array returned by getShotParents.

  • Like 1

Share this post


Link to post
Share on other sites

Thanks, I will give that a try. At least I can ditch all the arrays and just have one + use getShotParents command (hopefully).

Share this post


Link to post
Share on other sites
4 minutes ago, HazJ said:

Thanks, I will give that a try. At least I can ditch all the arrays and just have one + use getShotParents command (hopefully).

Just whipped this together quickly to demonstrate my point:

player addEventHandler ["Fired", {
	(_this select 6) setShotParents [vehicle (_this select 0), (_this select 0)]
}];

addMissionEventhandler ["Draw3D", {
	_friendlyGrenades = (player nearObjects ["GrenadeHand", 10]) select {
		(getShotParents _x) params ["_vehicle", "_unit"];
		
		side group _unit isEqualTo side group player
	};
	
	if (count _friendlyGrenades > 0) then {
		{
			drawIcon3D ["", [1,0,0,1], visiblePosition _x, 0, 0, 0, "Target", 1, 0.05, "PuristaMedium"];
			nil;
		} count _friendlyGrenades;
	};
}];

 

  • Like 2

Share this post


Link to post
Share on other sites

@HallyG - Even better. Thank you! Much appreciated. I added filter so icon only shows for X grenade types:

if (str _x find "handgrenade" >= 0) then
{

All working now. Thanks again Hally! Can't wait for next patch, nice command:

https://community.bistudio.com/wiki/findIf

  • Like 2

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

×