add emp functionality

This commit is contained in:
2024-02-08 19:43:55 -08:00
parent 2c733f77df
commit e0e06eff5e
15 changed files with 249 additions and 0 deletions

View File

@@ -50,6 +50,21 @@ class CfgFunctions {
}; };
}; };
class DOUBLES(PREFIX,emp) {
class functions {
file = "framework\emp\functions";
// class addCBASettings {preInit=1;};
class initClient {};
class addACEActions {};
class getObjectsToAffect {};
class applyLocalUnitEffects {};
class applyLocalGroupEffects {};
class deploy {};
class playZapServer {};
class flickerLights {};
};
};
class DOUBLES(PREFIX,fbcb2_assets) { class DOUBLES(PREFIX,fbcb2_assets) {
class functions { class functions {
file = "framework\fbcb2_assets\functions"; file = "framework\fbcb2_assets\functions";

View File

@@ -0,0 +1,12 @@
params [["_obj", objNull],["_rad", 500]];
private _action = [
"KE_bomb_aceActionStart", "Activate EMP bomb", "",
{(_this select 2) call KE_EB_fnc_loading;},{true}, {}, [_obj,_rad], [0,0,0.4], 5] call ace_interact_menu_fnc_createAction;
[_obj, 0, ["ACE_MainActions"], _action] call ace_interact_menu_fnc_addActionToObject;
//for debug
private _action = [
"KE_bomb_aceActionStart_Self", "Activate EMP bomb remote", "",
{(_this select 2) call KE_EB_fnc_loading;},{true}, {}, [d1,_rad], [0,0,0.4], 5] call ace_interact_menu_fnc_createAction;
[player, 1, ["ACE_SelfActions"], _action] call ace_interact_menu_fnc_addActionToObject;

View File

@@ -0,0 +1,11 @@
#include "..\script_component.hpp"
params [["_group", grpNull, [grpNull]]];
if (isNull _group) exitWith {};
if !(local _group) exitWith {};
//set gunlight status
_group enableGunLights "forceOff";
_group enableIRLasers true;
true;

View File

@@ -0,0 +1,45 @@
#include "..\script_component.hpp"
params [["_obj", objNull, [objNull]]];
if (isNull _obj) exitWith {};
if !(local _obj) exitWith {};
//handle lights for 'special' objects
{
params ["_lightClassName", "_hitIndexes"];
if ((typeOf _object) isEqualTo _lightClassName) then {
{
_object setHitIndex [_hitIndex, GVAR(lightHitPointDamageToApply)];
} forEach _hitIndexes;
};
} forEach GVAR(specialLightTypes);
//set veh light status
_obj engineOn false;
_obj setCollisionLight false;
_obj setPilotLight false;
//set damage on engines (motor and instruments)
_obj setHitPointDamage ["hitEngine", 0.9];
_obj setHitPointDamage ["HitAvionics", 0.9];
//for player units
if (isPlayer _obj) then {
_obj action ["IRLaserOff", _obj];
_obj action ["nvGogglesOff", _obj];
_nvgs = hmd _obj;
_obj unassignItem _nvgs;
_obj removeItem _nvgs;
_radio = _obj getSlotItemName 611;
_gps = _obj getSlotItemName 612;
_obj unassignItem _radio;
_obj removeItem _radio;
_obj unassignItem _gps;
_obj removeItem _gps;
_obj unassignItem "ACE_microDAGR";
_obj removeItem "ACE_microDAGR";
_obj unassignItem "MineDetector";
_obj removeItem "MineDetector";
};
true;

View File

@@ -0,0 +1,39 @@
// this script is used in a trigger and run on all machines.
// it is used to simulate the effects of an EMP bomb on all objects within a certain radius of the trigger
// safeguards have been put in place so that "Local Argument" commands are only processed on the machine that owns the object
// this is important because the results of these commands are not reliable if the object is not local
// the playSound3D command has been modified to only play the sound on this local machine for every non-man object. This way, the many machines running this function are not propagating duplicate sound instances to each other all at once.
#include "..\script_component.hpp"
if (!isServer) exitWith {};
//get center and radius
params [["_center",objNull],["_rad",200]];
private _objectsToAffect = [_center, _rad] call FUNC(getAffectedObjects);
{
// sleep to add aesthetic
sleep GVAR(timeBetweenEntities);
[{
params ["_obj"];
// local flicker light effect
[_obj] remoteExecCall [QFUNC(flickerLights), 0];
// playSound3D from server (running this code) to all clients
[_obj] call FUNC(playZapServer);
// process these if our machine owns the object, since many of the commands require local arguments
// the results of these commands are not reliable if the object is not local
[_obj] remoteExecCall [QFUNC(applyLocalUnitEffects), _obj];
// these are group-related commands that should be run where group is local
[group _obj] remoteExecCall [QFUNC(applyLocalGroupEffects), group _obj];
}, [_x]] call CBA_fnc_directCall;
} forEach _objectsToAffect;

View File

@@ -0,0 +1,40 @@
/*
Function: fn_flickerLights
Description:
Handle the flickering of lights on an object.
Author: IndigoFox
*/
#include "..\script_component.hpp"
params ["_object"];
//set light status
[_object] spawn {
params ["_object"];
// if has interface, do fancy flickering
if (hasInterface) then {
// if player is within object view distance of the object, flicker the lights
if (_object distance player < (getObjectViewDistance#0)) then {
for "_i" from 1 to 3 do {
_object switchLight "OFF";
sleep (random 0.5);
_object switchLight "ON";
sleep (random 0.5);
};
};
};
// always finish by shutting off
_object switchLight "OFF";
// always, if object local, damage lights
if (local _object) then {
sleep 0.7;
{
_object setHit [_x, GVAR(lightHitPointDamageToApply), false];
} forEach GVAR(standardLightHitPoints);
};
};

View File

@@ -0,0 +1,16 @@
#include "..\script_component.hpp"
params [["_center",objNull],["_rad",200]];
//create array for special objects
private _sA = [];
{
_sA pushBack (_x select 0);
} forEach GVAR(specialLightTypes);
//search for and return objects
nearestObjects [
_center,
["man","car","tank","air"] + GVAR(streetAndLampClasses) + _sA,
_rad
];

View File

@@ -0,0 +1,39 @@
#include "..\script_component.hpp"
//define vars
GVAR(timeBetweenEntities) = 0.01;
GVAR(chanceToPlayZap) = 5;
GVAR(zapAudibleDistance) = 100;
GVAR(lightHitPointDamageToApply) = 0.97;
GVAR(standardLightHitPoints) = [
"light_1_hitpoint",
"light_2_hitpoint",
"light_3_hitpoint",
"light_4_hitpoint"
];
GVAR(streetAndLampClasses) = [
"Lamps_base_F",
"PowerLines_base_F",
"PowerLines_Small_base_F",
"Land_fs_roof_F",
"Land_NavigLight",
"PowerLines_Wires_base_F",
"Land_PowerPoleWooden_L_F",
"Land_Runway_PAPI",
"Land_fs_sign_F",
"Land_FuelStation_01_roof_malevil_F", "Land_FuelStation_01_roof_F",
"Streetlamp"
];
//light special: ["CLASSNAME",[HITINDEX OF THE LAMPS]]
GVAR(specialLightTypes) = [
["Land_PowLines_WoodL",[0,1]],
["Land_A_GeneralStore_01", [42,43,44,45]],
["Land_A_GeneralStore_01a", [42,43,44,45]],
["Land_Mil_Guardhouse", [8]],
["Land_NAV_Lighthouse", [0]],
["Land_Mil_House", [40,41,42,43,44,45,46,47]],
["Land_LightHouse_F", [0,1,2,3,4]]
];

View File

@@ -0,0 +1,28 @@
#include "..\script_component.hpp"
params [["_object", objNull, [objNull]]];
if (isNull _object) exitWith {};
if (_object isKindOf "CAManBase") exitWith {};
// we're broadcasting a playSound3D command to all clients,
// so this only be run on the server
if (!isServer) exitWith {};
private _playSound = selectRandomWeighted [true,GVAR(chanceToPlayZap),false,(100-GVAR(chanceToPlayZap))];
if (_playSound) then {
private _sound = selectRandom ["zap1","zap2","zap3","zap4"];
playSound3D [
format [
"%1.wss",
getMissionPath ("framework\emp\sounds\" + _sound)
],
_object,
false,
getPosASL _object,
1, // volume
1, // pitch
GVAR(zapAudibleDistance), // max distance heard
0, // time offset sec
false // NOT local, send to all clients
];
};

View File

@@ -0,0 +1,3 @@
#define COMPONENT emp
#define COMPONENT_BEAUTIFIED EMP
#include "../script_mod.hpp"

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@@ -23,6 +23,7 @@ EGVAR(common,diaryRecords) = createHashMap;
// initialize other modules // initialize other modules
call EFUNC(emp,initClient);
call EFUNC(mapcopy,initClient); call EFUNC(mapcopy,initClient);
call EFUNC(reinsert,initClient); call EFUNC(reinsert,initClient);
call EFUNC(resupply,initClient); call EFUNC(resupply,initClient);