Jump to content
Sign in to follow this  
lawman_actual

Help Determining Weapon Fired

Recommended Posts

I seem to be having a little trouble assessing exactly what type of thing a unit has fired using the fired event handler.

Basically I want to know if the unit is shooting a gun, shooting a launcher or throwing an item.

 

So far I'm working with something like this, coming from the FIRED event handler:

 

_unit = _this select 0;
_weapon = _this select 1;
_muzzle = _this select 2;
_mode = _this select 3;
_ammo = _this select 4;
_magazine = _this select 5;
_projectile = _this select 6;
_vehicle = _this select 7;


_muzzleActual = (_unit weaponAccessories currentMuzzle _unit) select 0;

 

And then:

 

			_typeOfProjectile = (typeOf _projectile);
			if (_typeOfProjectile isKindOf ["Grenade",configFile >> "GrenadeCore"]) then {hint "Grenade Thrown"};

			_typeOfProjectile = (typeOf _projectile);
			if (_typeOfProjectile isKindOf ["BulletBase",configFile >> "BulletCore"]) then {hint "Gun Fired"};

			_typeOfProjectile = (typeOf _projectile);
			if (_typeOfProjectile isKindOf ["MissileBase",configFile >> "MissileCore"]) then {hint "Launcher Fired"};

 

I'm aware i'm probably not using  these right; I was just messing around with using either strings or configFile until it stopped giving me errors.

The grenade one works just fine, but I'm not getting notified if I fire a launcher or shoot a gun.

 

It might be that it's better to assess the weapon or the magazine or whatever, but the furthest I managed to get so far used this approach.

 

Thanks in advance

Law

Share this post


Link to post
Share on other sites

player addEventHandler ["Fired",{

	params ["_firer","_weapon"];

	_type = getNumber (configfile >> "CfgWeapons" >> _weapon >> "type");

	if (_type isEqualTo 0) then {systemchat "Thrown"};
	if (_type isEqualTo 1) then {systemchat "Rifle"};
	if (_type isEqualTo 2) then {systemchat "Pistol"};
	if (_type isEqualTo 3) then {systemchat "No Idea"};
	if (_type isEqualTo 4) then {systemchat "Launcher"};

}];

Cheers

Share this post


Link to post
Share on other sites
19 minutes ago, Grumpy Old Man said:


player addEventHandler ["Fired",{

	params ["_firer","_weapon"];

	_type = getNumber (configfile >> "CfgWeapons" >> _weapon >> "type");

	if (_type isEqualTo 0) then {systemchat "Thrown"};
	if (_type isEqualTo 1) then {systemchat "Rifle"};
	if (_type isEqualTo 2) then {systemchat "Pistol"};
	if (_type isEqualTo 3) then {systemchat "No Idea"};
	if (_type isEqualTo 4) then {systemchat "Launcher"};

}];

Cheers

 

 

I still have much to learn about config files! Had no idea you could do that

Thank you kind sir

  • Like 1

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  

×