Jump to content
alleycat

Teamkill check fail (side check fails to detect teamkills)

Recommended Posts

I am trying to detect teamkills from a MPKilled event handler.

	if ((side _unit) != (side _causedBy)) then
	{

		systemchat "kill";
	
	};
	if ((side _unit) == (side _causedBy)) then
	{
		//Suicide
		if (_unit == _causedBy) then
		{

			systemchat "suicide";
		
		}
		//It's a teamkill
		else
		{

			systemchat "teamkill";
		};
	
	};	

_unit is the unit that was killed. _causedBy is the killer.

When I shoot a friendly AI, it always counts as a normal kill. My suspicion is that the moment I kill a friendly the game turns me into a renegade and the side check passes. So I was looking for a way to compare configs of units. For CSAT, all infantry soldiers have "O_Soldier_base_F" as a parent. So I was looking for a way to compare whether shooter and victim share the same parents. I have looked at: https://community.bistudio.com/wiki/inheritsFrombut that does not seem to do what I want.

 

As a last resort I can check for similar uniforms of both units.

  • Like 1

Share this post


Link to post
Share on other sites

A dead unit is side civilian. Check its groups side instead or if its a player you can use playerSide or maybe BIS_fnc_objectSide if you know the unit type is always going to associated with its default config side (e.g its not a Blufor unit grouped into a EAST group)

  • Like 1

Share this post


Link to post
Share on other sites

Thanks for the tip. BIS_fnc_objectSide works, it checks the side the player is before any dynamic change.

  • Like 1

Share this post


Link to post
Share on other sites

Not exactly. "BIS_fnc_objectSide" checks the default side of a unit, as defined in its config.

That won't work if you let a unit switch sides or similar.

 

Using playerSide is probably a better idea.

 

 

 

 

You could also use "HandleDamage" instead. That EH is a bit more complex, but it fires before the actual death occurs, which gives you more options (like logging the recieved damage for later use).

 

You could even use that to reduce damage recieved from friendlies by a certain amount, mirror it, or negate it completely.

Share this post


Link to post
Share on other sites

So I just stumbled across the "HandleScore" eventhandler.

 

This could make your teamkill-check really easy.

 

 

 

The only slightly complex part about it is that you have to re-add this Eventhandler on respawn. Everything else is a breeze. You basically only have to do an "isPlayer" check and test if the score-change is negative.

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

×