Jump to content
LSValmont

vSuppress Multiplayer Script [v1.1 - released 05/06/2019]

Recommended Posts

vSuppress Script by Valmont and George Floros is the first script based Audio-Visual Suppression effects for Arma 3.

 

vSuppress Main Features:

 

- Easily add Suppression effects to your missions. These audio visual effects will trigger on players when Ai Units' bullets land or pass near them simulating the "Fear Effect" of being shot, the anxiety caused by being pinned down or just general combat stress.

- Fully Multiplayer Compatible!

- Extremely lightweight. The script was conceived with performance in mind and on testings with 60+ Ai units shooting at a single player resulted in a meagerly 2 FPS negative impact. 

- The Suppression effects are purely cosmetic and will not cause any other effects on players such as decreased stamina, stats etc.

- The sounds and the visual effects can be easily tweaked and disabled inside the script.

- Players cannot suppress other players, only Ai Units who have the script/EH running will be able to suppress players.

- The suppression effects are quite minimalist and fast in nature to keep Arma 3's gameplay unchanged while adding an additional layer of immersion to the game.

 

Requirements:

Spoiler

 

- Basic Mission Editing knowledge. (For adding the commands to the unit's init etc).

- Nothing else 😉.

 

 

Usage:

Spoiler

 

There are two versions of the script: 

- vSuppressAll.sqf that runs from your missions' init.sqf and sets the variables and eventhandlers for all enemy Ai units present at the start of the mission.

vSuppressUnit.sqf that can be used to add the script to a single specific Ai Unit or for adding the suppression effects to units that spawn via script or after mission start.

 

 

vSuppress version 1.1 DEMO MISSION DOWNLOAD LINK: https://drive.google.com/open?id=1NLZx5lH_G5p6ubcK73xvwwgYVqCWpdvL

 

Notes:

Spoiler

 

- vSuppress was born out of the need of an "out of the box" thinking regarding projectile impact tracking in Arma 3 that is both performance friendly, accurate enough and does not create dependency on additional mods/addons. (Since native solutions such as a ProjectileImpactEH currently does not exist in Arma 3).

 

Most if not all current mods dealing with Suppression rely on loops that track the position of the bullet projectiles almost in realtime and until they loose velocity or cease to exist, checking its positions and velocity all the way up to that point. This approach was accurate but fairly impractical in terms of resources used and also in terms of multiplayer environments where Arma 3 calculations can often go wrong under low FPS/Latency scenarios. In fact in our MP testing scenarios the solutions using the projectile tracking loop could result in a loss of up to 10+ FPSs during heavy combat situations versus the 2 FPS loss of vSuppress.

 

- To work under MP environments and without a noticeable performance impact vSuppress took a unique approach on the matter by using a cleaver solution conceived by George Floros that consisted in using the assignedTarget command and complemented by Valmont's weaponDirection currentWeapon vectorAdd vectorMultiply to actually predict the potential future location of the projectile instead of actually tracking the real projectile (expensive).

 

 

  • Like 2
  • Thanks 1

Share this post


Link to post
Share on other sites

Try changing _projectile call bulletCheck; to _projectile spawn bulletcheck;

 

I didn't think while {} do {} could be called, as the engine halts for the code to execute first.

 

Further down the line, I'd add some way to not have the function be called every time an AI fires. It will cause death and chaos due to FPS drain otherwise.

 

  • Like 1

Share this post


Link to post
Share on other sites
1 hour ago, genesis92x said:

Try changing _projectile call bulletCheck; to _projectile spawn bulletcheck;

 

I didn't think while {} do {} could be called, as the engine halts for the code to execute first.

 

Further down the line, I'd add some way to not have the function be called every time an AI fires. It will cause death and chaos due to FPS drain otherwise.

 

 

Thanks, will try your suggestions and will report back!

Share this post


Link to post
Share on other sites
2 hours ago, genesis92x said:

Try changing _projectile call bulletCheck; to _projectile spawn bulletcheck;

 

I didn't think while {} do {} could be called, as the engine halts for the code to execute first.

 

Further down the line, I'd add some way to not have the function be called every time an AI fires. It will cause death and chaos due to FPS drain otherwise.

 

 

Ok so I tried with spawn and it still did not work for some reason. It is weird because it should work...

Share this post


Link to post
Share on other sites
4 hours ago, LSValmont said:

Ok so I tried with spawn and it still did not work for some reason.

 

I think that you should just change , your think on how to use this.

Since it's a script that affects players, then you need to run this code in the initPlayerlocal and not on every enemy.

Then check the EH again for "FiredNear" because you want a certain distance as i see.

I don't think that you need to remoteexec anything.

You don't need either a while true for the pp effects.

  • Like 1

Share this post


Link to post
Share on other sites
6 hours ago, GEORGE FLOROS GR said:

 

I think that you should just change , your think on how to use this.

Since it's a script that affects players, then you need to run this code in the initPlayerlocal and not on every enemy.

Then check the EH again for "FiredNear" because you want a certain distance as i see.

I don't think that you need to remoteexec anything.

You don't need either a while true for the pp effects.

 

The problem is that  "FiredNear" only detects if the shooter was close, not the actual bullet, so if you get fire from an AI unit who is far from your playerUnit you won't get the suppression effects... 

 

The problem with Arma 3 is that it is very complicated, as far as I know, to detect where a bullet hits.

 

In every single suppression script/mod I check they use the "Fired" EH.

 

The problem is that all those mods and scripts are more complex and use more FPS that what I want with this script.

Share this post


Link to post
Share on other sites

Looping to track bullet pos feels expensive to me.  You could reduce that by checking angle of shooter to player first to see if within a 5 degree tolerance first.  Could save some FPS. 

BIS_fnc_inAngleSector

You could also check line of sight from shooter player.  If both line of sight and inAngleSector good, then that might be enough data for you to consider the bullet near the player without ever checking the bullet.

  • Thanks 1

Share this post


Link to post
Share on other sites
1 hour ago, johnnyboy said:

Looping to track bullet pos feels expensive to me.  You could reduce that by checking angle of shooter to player first to see if within a 5 degree tolerance first.  Could save some FPS. 

BIS_fnc_inAngleSector

You could also check line of sight from shooter player.  If both line of sight and inAngleSector good, then that might be enough data for you to consider the bullet near the player without ever checking the bullet.

 

Thank you Johnny. So far I get no errors and everything seems to work when I run the commands individually but as a whole I cannot get the suppression effect to show for players.

 

I think I am way over my head now so I've requested help from the master...

https://forums.bohemia.net/forums/topic/215280-i-saw-a-video-of-a-ballistic-tracer-script-that-showed-the-projectile-with-a-dot-where-can-i-find-that-script/?do=findComment&comment=3353475

I hope we can make this work. So far the only good suppression effects come from mods and quite expensive in terms of network/processing. I want this script/EH to be as light as a feather 😃

Share this post


Link to post
Share on other sites
5 minutes ago, LSValmont said:

I hope we can make this work.

 

What you want is a little bit of this , right ?

 

  • Like 2

Share this post


Link to post
Share on other sites
2 minutes ago, GEORGE FLOROS GR said:

 

What you want is a little bit of this , right ?

 

 

Yes sir, something similar to that but:

 

- In script format. 

- Without any config options that could make players just deactivate or reduce the effects.

- Not as invasive. The effects are quite minimal yet enough to feel the "danger" of the situation.

- And finally the code has to be leaner than that of the mod.

 

I have checked laxemann's code a lot and it writes a lot of variables for its cumulative suppression, it is good but quite redundant for the needs of this SUPER SIMPLE SUPPRESSION SCRIPT. What I am trying to do is a lot simpler and should be a lot faster too.

  • Like 1

Share this post


Link to post
Share on other sites

I 'll try to check it and add if it's possible a solution about it.

  • Thanks 1

Share this post


Link to post
Share on other sites
1 hour ago, GEORGE FLOROS GR said:

I 'll try to check it and add if it's possible a solution about it.

 

Thank you so much George! You are always there backing all our backs! 😍

 

PS: If we figure this out I wouldn't mind you releasing this as: "GF Suppression Effects Script" (or something). 😉

  • Thanks 1

Share this post


Link to post
Share on other sites

see one simple ex:

 

in the initplayerlocal.sqf

player addEventHandler ["FiredNear", {
	params ["_unit", "_firer", "_distance", "_weapon", "_muzzle", "_mode", "_ammo", "_gunner"];
	
	if (_distance > 0)then{
	
		_Blur = {
			"dynamicBlur" ppEffectEnable true;
			"dynamicBlur" ppEffectAdjust [2];
			"dynamicBlur" ppEffectCommit 0;
			"dynamicBlur" ppEffectAdjust [0];
			"dynamicBlur" ppEffectCommit 0.2;
		};
		
		_unit spawn _Blur;

		
		systemchat "taking fire";
	};
}];

 

  • Thanks 1

Share this post


Link to post
Share on other sites
14 minutes ago, GEORGE FLOROS GR said:

see one simple ex:

 

in the initplayerlocal.sqf

 

Ok will try it now. 

 

Last time I used that EH it only fired if the enemy was really close... Will spawn some enemies over 200mtrs to see if the effects are still there.

PS: This will also fire if you shoot or if an ally shoots so more conditions will be needed.

  • Like 1

Share this post


Link to post
Share on other sites

 

check :

player addEventHandler ["FiredNear", {
	params ["_unit", "_firer", "_distance", "_weapon", "_muzzle", "_mode", "_ammo", "_gunner"];
	
	if (_distance > 0)then{
	
		_Blur = {
			"dynamicBlur" ppEffectEnable true;
			"dynamicBlur" ppEffectAdjust [2];
			"dynamicBlur" ppEffectCommit 0;
			"dynamicBlur" ppEffectAdjust [0];
			"dynamicBlur" ppEffectCommit 0.2;
		};
				
		_ChromAberration = {
		
			_pp = ppEffectCreate ["ChromAberration",200];
			_pp ppEffectEnable true;
			_pp ppEffectAdjust [0.02, 0.02, true];
			_pp ppEffectCommit 2;
			uisleep 1;
			ppeffectdestroy _pp;
		};
		
		_ppGrain = {
			_pp = ppEffectCreate ["filmGrain", 2012];
			_pp ppEffectEnable true;
			_pp ppEffectAdjust [random 0.2, 1, 1, 0, 1];
			_pp ppEffectCommit 0;
			uisleep 0.2;
			ppeffectdestroy _pp;
		};
		
		_unit spawn _Blur;
		_unit spawn _ChromAberration;
		_unit spawn _ppGrain;
		
		systemchat "taking fire";
	};
}];

 

Share this post


Link to post
Share on other sites
1 minute ago, GEORGE FLOROS GR said:

check :

FiredNear won't work George.

 

Just tested it.

 

Your unit needs to be very close to the unit that is firing for the EH to execute.

 

So I placed a barricade, my player and then a enemy 200mtrs away on the VR map.

 

The enemy would start to shoot and I will get no blur effect nor the systemchat until I get lets say 20 meters from that unit and then it fires.

 

It would be great to have a "HitNear" or "BulletNear" eventHandler but we don't. 😓

  • Like 1

Share this post


Link to post
Share on other sites
1 minute ago, GEORGE FLOROS GR said:

...and i was sure that is going to work !

 

It would if we could increase the range from the unit firing to the player that the FiredNear checks... but I don't think that is possible.

 

There was an approach of having a loop on the player checking for nearby bullet impact effects but that could be performance intensive I think.

 

Our best bet is perhaps checking the trajectory of the bullet and if the trajectory ends up close to a player then the effects fire. johnnyBoy suggested https://community.bistudio.com/wiki/BIS_fnc_inAngleSector but I have no idea on how to use it. Nor could I find a script using it.

Share this post


Link to post
Share on other sites
40 minutes ago, GEORGE FLOROS GR said:

...and i was sure that is going to work !

 

I got the Fired EH to work.

 

Will release the full script after testing 😉

  • Like 1

Share this post


Link to post
Share on other sites
20 hours ago, LSValmont said:

I got the Fired EH to work.

 

I'm very curious to see how you made it !

I tried this yesterday with no luck !

Share this post


Link to post
Share on other sites
3 hours ago, GEORGE FLOROS GR said:

 

I'm very curious to see how you made it !

I tried this yesterday with no luck !

 

I am adding sounds to the script now, but I can give you a preview version:

 

Just place this on your Init.sqf and place a enemy named badguy and your playableUnit.

I suggest a VR map and add something you can use as cover.

 

Spoiler

 


// used as: _unit addEventHandler ["Fired", aiSuppressEH];

aiSuppressEH = 
{
    params["_unit","_weapon","_muzzle","_mode","_ammo","_magazine","_projectile","_vehicle"];
	_random = random 2;
	if (_random > 1) exitWith {};
	if (_unit isEqualTo player) exitWith {};
	if (toLower(_weapon) isEqualTo "put") exitWith {};
	
	if (isNull _projectile) then {
		 _projectile = nearestObject [_unit, _ammo];
	};
	
    _getProjPos = [_unit,_projectile] spawn {
    	params ["_unit","_projectile"];
    	waitUntil {
		if (vectorMagnitude velocity _projectile <= 0.01) then {_bulletPos = getPosATL _projectile; [_unit,_bulletPos] call bulletImpactCheck; true};
		};
    };
};

bulletImpactCheck =
{
_aiWhoFired = _this select 0;
_bulletPos = _this select 1;
_nearHumans = [];
_targetHumans = [];
_closestEnemy = objNull;
_nearHumans = nearestObjects [_bulletPos, ["man"], 15];

	{
		if ((side _aiWhoFired) getFriend (side _x) < 0.6 && alive _x && !isNull _x && isPlayer _x) then {_targetHumans = _targetHumans + [_x];}
	}forEach _nearHumans;
	_targetsAmount = count _targetHumans;
	if (_targetsAmount > 0) then
	{
		{
		_null = [_x] remoteExecCall ["suppressionEffect",_x];
		} forEach _targetHumans;
	};
};

suppressionEffect =
{
	hint "taking fire";
	0 = ["ChromAberration", 200, [0.02, 0.02, true]] spawn { 
	 params ["_name", "_priority", "_effect", "_handle"]; 
	 while {
	  _handle = ppEffectCreate [_name, _priority]; 
	  _handle < 0 
	 } do { 
	  _priority = _priority + 1; 
	 }; 
	 _handle ppEffectEnable true; 
	 _handle ppEffectAdjust _effect; 
	 _handle ppEffectCommit 0.2; 
	 waitUntil {ppEffectCommitted _handle};
	 uiSleep 0.4; 
	 _handle ppEffectEnable false; 
	 ppEffectDestroy _handle; 
	};
};


badguy addEventHandler ["Fired", aiSuppressEH];

 

 

 

 

  • Like 1

Share this post


Link to post
Share on other sites
3 hours ago, LSValmont said:

Just

 

check also this approach :

maybe it's more simple and as i notice it's working fine.

- i don't know if i need to change the getposASL to just pos though.

{
_x addEventHandler ["Fired", {
   params ["_unit", "_weapon", "_muzzle", "_mode", "_ammo", "_magazine", "_projectile", "_vehicle"];
   

	if (
	(!isnull cursortarget)
	&& (alive cursorTarget)
	&& (cursorTarget isKindOf "Man")
	//&& (isPlayer cursorTarget)
	
	)then{
	
	_pos = getposASL cursortarget;
	_shot = nearestObject [_pos,_ammo];
		
		if(_pos distance _shot < 5)then{
			systemchat "_shot < 5";
		};
	
	};
		
	systemchat "Fired";
    
}];
}forEach allunits;

 

Share this post


Link to post
Share on other sites
4 minutes ago, GEORGE FLOROS GR said:

 

check also this approach :

maybe it's more simple and as i notice it's working fine.

- i don't know if i need to change the getposASL to just pos though.


{
_x addEventHandler ["Fired", {
   params ["_unit", "_weapon", "_muzzle", "_mode", "_ammo", "_magazine", "_projectile", "_vehicle"];
   

	if (
	(!isnull cursortarget)
	&& (alive cursorTarget)
	&& (cursorTarget isKindOf "Man")
	//&& (isPlayer cursorTarget)
	
	)then{
	
	_pos = getposASL cursortarget;
	_shot = nearestObject [_pos,_ammo];
		
		if(_pos distance _shot < 5)then{
			systemchat "_shot < 5";
		};
	
	};
		
	systemchat "Fired";
    
}];
}forEach allunits;

 

 

Doesn't cursortarget only work for players? It also works for Ai? Never though it would since Ai Units have no "cursors" 😃

 

But if you tested this and the Ai bullets are causing the systemchat to fire then I guess it works.

 

If it didn't I would suggest https://community.bistudio.com/wiki/lineIntersectsWith instead of Cursor Object.

  • Like 1

Share this post


Link to post
Share on other sites

This is the code with the PP effects from above :

Spoiler

GF_ppEffects = {


	_Blur = {
		"dynamicBlur" ppEffectEnable true;
		"dynamicBlur" ppEffectAdjust [2];
		"dynamicBlur" ppEffectCommit 0;
		"dynamicBlur" ppEffectAdjust [0];
		"dynamicBlur" ppEffectCommit 0.2;
	};

	_ChromAberration = {
	
		_pp = ppEffectCreate ["ChromAberration",200];
		_pp ppEffectEnable true;
		_pp ppEffectAdjust [0.02, 0.02, true];
		_pp ppEffectCommit 2;
		uisleep 1;
		ppeffectdestroy _pp;
	};
	
	_ppGrain = {
		_pp = ppEffectCreate ["filmGrain", 2012];
		_pp ppEffectEnable true;
		_pp ppEffectAdjust [random 0.2, 1, 1, 0, 1];
		_pp ppEffectCommit 0;
		uisleep 0.2;
		ppeffectdestroy _pp;
	};
	
	_this spawn _Blur;
	_this spawn _ChromAberration;
	_this spawn _ppGrain;
	
	//	systemchat "GF_ppEffects";
};


{
	if!(isplayer _x)then{
		_x addEventHandler ["Fired", {
		   params ["_unit", "_weapon", "_muzzle", "_mode", "_ammo", "_magazine", "_projectile", "_vehicle"];
		   

			if (
			(!isnull cursortarget)
			&& (alive cursorTarget)
			&& (cursorTarget isKindOf "Man")
			
			)then{

			_Target = cursorTarget;
			_pos = getpos cursortarget;
			_shot = nearestObject [_pos,_ammo];
				
				if(_pos distance _shot < 5)then{
					systemchat "_shot < 5";
					[_Target] call GF_ppEffects;
				};
			
			};
				
				systemchat "Fired";
			
		}];
	};
}forEach allunits;

 

 

Share this post


Link to post
Share on other sites
11 minutes ago, GEORGE FLOROS GR said:

This is the code with the PP effects from above :

  Reveal hidden contents


GF_ppEffects = {


	_Blur = {
		"dynamicBlur" ppEffectEnable true;
		"dynamicBlur" ppEffectAdjust [2];
		"dynamicBlur" ppEffectCommit 0;
		"dynamicBlur" ppEffectAdjust [0];
		"dynamicBlur" ppEffectCommit 0.2;
	};

	_ChromAberration = {
	
		_pp = ppEffectCreate ["ChromAberration",200];
		_pp ppEffectEnable true;
		_pp ppEffectAdjust [0.02, 0.02, true];
		_pp ppEffectCommit 2;
		uisleep 1;
		ppeffectdestroy _pp;
	};
	
	_ppGrain = {
		_pp = ppEffectCreate ["filmGrain", 2012];
		_pp ppEffectEnable true;
		_pp ppEffectAdjust [random 0.2, 1, 1, 0, 1];
		_pp ppEffectCommit 0;
		uisleep 0.2;
		ppeffectdestroy _pp;
	};
	
	_this spawn _Blur;
	_this spawn _ChromAberration;
	_this spawn _ppGrain;
	
	//	systemchat "GF_ppEffects";
};


{
	if!(isplayer _x)then{
		_x addEventHandler ["Fired", {
		   params ["_unit", "_weapon", "_muzzle", "_mode", "_ammo", "_magazine", "_projectile", "_vehicle"];
		   

			if (
			(!isnull cursortarget)
			&& (alive cursorTarget)
			&& (cursorTarget isKindOf "Man")
			
			)then{

			_Target = cursorTarget;
			_pos = getpos cursortarget;
			_shot = nearestObject [_pos,_ammo];
				
				if(_pos distance _shot < 5)then{
					systemchat "_shot < 5";
					[_Target] call GF_ppEffects;
				};
			
			};
				
				systemchat "Fired";
			
		}];
	};
}forEach allunits;

 

 

 

Ok I got your approach to work...

 

Seems to be a good alternative! Do you know if it will work in MP?

 

Since mine uses remoteExec it surely works.

 

Also the other advantage of my approach is that it can suppress more than one player if the bullet landed near them.

Also another advantage of my approach is that it fires even if  you are hidden from the Ai.

 

But yours is probably a lot less resource intensive. (Any Idea how we can test the fastest one?)

  • 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

×