Skip to content

Commit

Permalink
Merge pull request #1 from kasteelharry/DevBranch
Browse files Browse the repository at this point in the history
Dev branch
  • Loading branch information
kasteelharry authored Oct 30, 2019
2 parents 753df30 + 3438c57 commit 3670ab3
Show file tree
Hide file tree
Showing 4 changed files with 150 additions and 11 deletions.
5 changes: 4 additions & 1 deletion EMP_DEMO_MISSION.Stratis/AL_emp/emp_starter.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,7 @@ if (_viz_eff or _player_viz) then
[_obj_emp,_rang_emp] execvm "AL_emp\config_obj.sqf";
waitUntil {!isNil "special_launchers_emp"};
waitUntil {!isNil "emp_dam"};
[] execvm "AL_emp\emp_effect.sqf";
[] execvm "AL_emp\emp_effect.sqf";

//calls the jamming script, has to be run local to have any effect. Thus run the starting command global.
jamRadiosServer = [[missionNamespace getVariable "Jammers"],missionNamespace getVariable "JammerRadius", missionNamespace getVariable "JammerStrength"] execVM "TFARjamRadios.sqf";
101 changes: 101 additions & 0 deletions EMP_DEMO_MISSION.Stratis/TFARJamRadios.sqf
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
/*
Jam Radios script for TFAR created by Asherion and Rebel, edited by Kasteelharry
Version 0.2.0
Original version available from: https://forums.bistudio.com/forums/topic/203810-release-radio-jamming-script-for-task-force-radio/
This script will jam radios for all players within a given radius of a jamming vehicle
Jamming is stronger nearer to the vehicle, while less strong at the edges of the radius
NOTE: It is recommended to call this script from initPlayerLocal.sqf if you want to run the script from mission start.
Changes made by Kasteelharry:
- Made the interference an exponential function and not a linear function
Parameter(s):
0: ARRAY of object(s) (Required)- Entity(s) that will cause the radios to be jammed.
1: NUMBER (Optional)- Range of the jammer in Meters. Default is 1000.
2: NUMBER (Optional)- Strength of the jammer. Default is 50.
3: BOOL (Optional)- Enable Debug. Default is False.
Example: jamRadios = [[JAMMER],500] execVM "TFARjamRadios.sqf";
*/

if (!hasInterface) exitwith {};
waituntil {!isnull player};

//Define the variables along with their default values.
_jammers = param [0, [objNull], [[objNull]]];
_rad = param [1, 1000, [0]];
_strength = param [2, 50, [0]] - 1; // Minus one so that radio interference never goes below 1 near the edge of the radius (which is the default for TFAR).
_debug = param [3, false, [true]];

//compare distances between jammers and player to find nearest jammer and set it as _jammer
_jammerDist = {
_jammer = objNull;
_closestDist = 1000000;
{
if (_x distance player < _closestdist) then {
_jammer = _x;
_closestDist = _x distance player;
};
} foreach _jammers;
_jammer;
};
_jammer = call _jammerDist;

// While the Jamming Vehicle is not destroyed, loop every 5 seconds
while {alive _jammer} do
{
// Set variables
_dist = player distance _jammer;
_distPercent = _dist / _rad;
_interference = 1;
_sendInterference = 1;

if (_dist < _rad) then {

//Edited by Kasteelharry
_interference = ((_distPercent*100) - _strength)^2 + 1; // Calculat the recieving interference, which has to be above 1 to have any effect.

_sendInterference = 1/_interference; //Calculate the sending interference, which needs to be below 1 to have any effect.
};
// Set the TF receiving and sending distance multipliers
player setVariable ["tf_receivingDistanceMultiplicator", _interference];
player setVariable ["tf_sendingDistanceMultiplicator", _sendInterference];

// Debug chat and marker.
if (_debug) then {
deletemarkerLocal "CIS_DebugMarker";
deletemarkerLocal "CIS_DebugMarker2";
//Area marker
_debugMarker = createmarkerLocal ["CIS_DebugMarker", position _jammer];
_debugMarker setMarkerShapeLocal "ELLIPSE";
_debugMarker setMarkerSizeLocal [_rad, _rad];

//Position Marker
_debugMarker2 = createmarkerLocal ["CIS_DebugMarker2", position _jammer];
_debugMarker2 setMarkerShapeLocal "ICON";
_debugMarker2 setMarkerTypeLocal "mil_dot";
_debugMarker2 setMarkerTextLocal format ["%1", _jammer];

systemChat format ["Distance: %1, Percent: %2, Interference: %3, Send Interference: %4", _dist, 100 * _distPercent, _interference, _sendInterference];
systemChat format ["Active Jammer: %1, Jammers: %2",_jammer, _jammers];

};
// Sleep 5 seconds before running again
sleep 5.0;

//Only run this if there are multiple jammers.
if (count _jammers > 1) then {
//Check if all of the jammers are still alive. If not, remove it from _jammers.
{
if (!alive _x AND count _jammers > 1) then {_jammers = _jammers - [_x]};
} foreach _jammers;

//Check for closest jammer
_jammer = call _jammerDist;
};
};

//Set TFR settings back to normal before exiting the script
player setVariable ["tf_receivingDistanceMultiplicator", 1];
player setVariable ["tf_sendingDistanceMultiplicator", 1];
25 changes: 25 additions & 0 deletions EMP_DEMO_MISSION.Stratis/initServer.sqf
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/*
initServer.sqf lines of code
By @kasteelharry
*/

///////////////////////////////////
/// ///
/// EDITABLE VARIABLE ///
/// ///
///////////////////////////////////

_EMPvariables = _jammervariables = EMP; //Needs to contain the variable name of the object spawned in game
_EMP_Range = _jammerRadius = 1000; //Range of the EMP blast and jamming afterwards
_jammerStrength = 100; //Strength of the jammer, max is 100

///////////////////////////////////
/// ///
/// DO NOT EDIT ///
/// ///
///////////////////////////////////
missionNamespace setVariable ["EMP", _EMPvariables, true];
missionNamespace setVariable ["EMP_Range", _EMP_Range, true];
missionNamespace setVariable ["Jammers", _jammerNames, true];
missionNamespace setVariable ["JammerRadius", _jammerRadius, true];
missionNamespace setVariable ["JammerStrength", _JammerStrength, true];
30 changes: 20 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,31 +1,41 @@
# Arma3EMPmultiplayer

A modified version of the Arma 3 EMP script by Aliascartoons on [Armaholic](http://www.armaholic.com/page.php?id=34293). Edited by Kasteelharry for useage in multiplayer and to be used in combination with a TFAR jamming script.
A modified version of the Arma 3 EMP script by Aliascartoons on [Armaholic](http://www.armaholic.com/page.php?id=34293). Edited by Kasteelharry for useage in multiplayer and to be used in combination with the TFAR jamming script by Rebel12340 on [Armaholic](http://www.armaholic.com/page.php?id=32660).

## Installation
## Installation guide

1. Clone or download the repository and place all the files and folders in your mission folder.
2. Copy contents of any already existing files over to the correct files.
3. In the editor give the object that serves as the EMP source the variable name ***EMP***.
- If the object already has a variable name, change it in the initServer.sqf or set the variable "EMP" as shown in usage.
4. Set the range and strength of the EMP and Jammers in the initServer.sqf file.

## Usage

- In your mission place down the object that will function as your EMP/jammer and give it a variable name.
- Run the following line of code:
- Run the following line of code global:

```sqf
[variable,range,true,true] execvm "AL_emp\emp_starter.sqf";
[EMP,EMP_Range,true,true] execvm "AL_emp\emp_starter.sqf";
```

- where variable is the variable name you have given to the object and range is the range of the emp blast.
- where EMP is the variable name you have given to the object in the editor and range is the EMP_Range of the emp blast.
- Changeable in initServer.sqf
- Or with:

- To stop the TFAR Jamming delete the object that was designated as the emp.
```sqf
//Sets the variable from where to run the EMP
missionNamespace setVariable ["EMP", _EMPvariables, true];
//Sets the range of it
missionNamespace setVariable ["EMP_Range", _EMP_Range, true];
```

## Upcoming features
- To stop the TFAR Jamming script delete the object with the EMP variable name.

1) An TFAR jamming script that runs with the same variable as the emp.
2) A way to stop the jamming, etc after finding intel.
## Upcoming features

1) A way to automatically stop the jamming/whitelist players, after, for example, finding intel, walking out the range and back in or rearming at an arsenal.

## Known Bugs

- Toolkits are not removed from the players inventories.
- Toolkits are not removed from the players inventories.

0 comments on commit 3670ab3

Please sign in to comment.