mikey74 186 Posted November 28 (edited) ok sense the new US military rifle coming in replacing the m4 is all suppressed. I wrote a script to make sure everyone of them is suppressed. This script version requires the new Expeditionary Forces: If you are creating a mission simple paste in your init.sqf. You can replace the _supressor "ef_snds_mxar" and the other classnames with what ever you like. Enjoy! 🙂 Spoiler { private _entity = _x; // Get the player's primary weapon private _weapon = primaryWeapon _entity; // Define the suppressor item (for example, a suppressor for a 5.56mm weapon) //_muzzles = [PrimaryWeapon _entity,"muzzle"] call BIS_fnc_compatibleItems; <<<<<--- this works BTW ---> //_muzzles params [["_suppressor",""]];// "ef_snds_mxar_coy" if (tolower _weapon find "_mx" >= 0) then { _suppressor = switch (true) do { case (tolower _weapon find "_black" >= 0): { "ef_snds_mxar"; // Black suppressor }; case (tolower _weapon find "_khk" >= 0): { "ef_snds_mxar_khk"; // Khaki suppressor }; case (tolower _weapon find "_snd" >= 0): { "ef_snds_mxar_sand"; // Sand suppressor for tan variants }; case (tolower _weapon find "coy" >= 0): { "ef_snds_mxar_coy"; // Sand suppressor for tan variants }; default { "ef_snds_mxar_sand"; // Default to black if no match }; }; // Get the current muzzle attachment _currentMuzzle = ((primaryWeaponItems _entity) select 0);//currentMuzzle _entity; // Check if a suppressor is already attached if (_currentMuzzle == "") then { // If no suppressor is attached, add the suppressor to the weapon _entity addPrimaryWeaponItem _suppressor; }; }; } forEach allunits;//units blufor; addMissionEventHandler ["EntityCreated", { params ["_entity"]; if !((vehicle _entity) isKindOf "CaManBase") exitWith { }; // Get the player's primary weapon private _weapon = primaryWeapon _entity; // Define the suppressor item (for example, a suppressor for a 5.56mm weapon) //_muzzles = [PrimaryWeapon _entity,"muzzle"] call BIS_fnc_compatibleItems; <<<<<--- this works BTW ---> //_muzzles params [["_suppressor",""]];// "ef_snds_mxar_coy" if (tolower _weapon find "_mx" >= 0) then { _suppressor = switch (true) do { case (tolower _weapon find "_black" >= 0): { "ef_snds_mxar"; // Black suppressor }; case (tolower _weapon find "_khk" >= 0): { "ef_snds_mxar_khk"; // Khaki suppressor }; case (tolower _weapon find "_snd" >= 0): { "ef_snds_mxar_sand"; // Sand suppressor for tan variants }; case (tolower _weapon find "coy" >= 0): { "ef_snds_mxar_coy"; // Sand suppressor for tan variants }; default { "ef_snds_mxar_sand"; // Default to black if no match }; }; // Get the current muzzle attachment _currentMuzzle = ((primaryWeaponItems _entity) select 0);//currentMuzzle _entity; // Check if a suppressor is already attached if (_currentMuzzle == "") then { // If no suppressor is attached, add the suppressor to the weapon _entity addPrimaryWeaponItem _suppressor; }; }; }]; Edited Friday at 03:03 AM by mikey74 Updated script 2 Share this post Link to post Share on other sites
pierremgi 4879 Posted Thursday at 10:47 AM This reminds me that I created a module "adapt silencers" for stealth/combat simulation, so AIs automatically mount or dismount the silencer on weapon, depending on the combat status. Just checked, that works with new Expeditionary Forces DLC. 1 Share this post Link to post Share on other sites
mikey74 186 Posted Thursday at 10:59 AM (edited) Yeh I've started pulling up my old scripts and updating them. I'm still not great at coding in arma but much better than I was 10 years ago even with me being a bit rusty. lol Speeking of. I need to update this script. Assuming anyone is really interested in it. I'll keep it updated. Maybe even create a pbo for it if I can remember how. lol Oh the EntityCreated Event Handler is because I use a lot of re-spawning in my self made played missions. I figure I may not be the only one doing this. Edited Thursday at 11:02 AM by mikey74 clarifying Event handler Share this post Link to post Share on other sites
pierremgi 4879 Posted Thursday at 02:23 PM 3 hours ago, mikey74 said: Oh the EntityCreated Event Handler is because I use a lot of re-spawning in my self made played missions. I figure I may not be the only one doing this. EntityCreated EH fires for multiple useless "entities" like rabbit or flies, but also foot prints and so on. So, a decent use of it implies to start by something like: if (_entity isKindOf "CaManBase") then {.... your code }; If you script such code for players only: in initPlayerLocal.sqf: your_fnc_holySilencer = {... }; player call your_fnc_holySilencer; addMissionEventHandler ["entityRespawned", {(_this #0) call your_fnc_holySilencer}]; 1 Share this post Link to post Share on other sites
mikey74 186 Posted Friday at 02:50 AM (edited) 12 hours ago, pierremgi said: EntityCreated EH fires for multiple useless "entities" like rabbit or flies, but also foot prints and so on. So, a decent use of it implies to start by something like: if (_entity isKindOf "CaManBase") then {.... your code }; If you script such code for players only: in initPlayerLocal.sqf: your_fnc_holySilencer = {... }; player call your_fnc_holySilencer; addMissionEventHandler ["entityRespawned", {(_this #0) call your_fnc_holySilencer}]; The missions I use respawns are mostly not multiplayer. I play more single player type missions. I wrote respawning scripts for aI and player because in single player you just cant. Thanks though. Doubt that would work on what I have wrote. hmmm or would it!?!? May have to test this. Thanks 🙂 Just tested. Nope not on a single-player mission it doesn't work. Thanks for the idea thought! 🙂 Edited Friday at 03:02 AM by mikey74 on second thought. Test results Share this post Link to post Share on other sites
pierremgi 4879 Posted Friday at 05:38 AM 1 hour ago, mikey74 said: The missions I use respawns are mostly not multiplayer. I play more single player type missions. I wrote respawning scripts for aI and player because in single player you just cant. Thanks though. Doubt that would work on what I have wrote. hmmm or would it!?!? May have to test this. Thanks 🙂 Just tested. Nope not on a single-player mission it doesn't work. Thanks for the idea thought! 🙂 In SP, there is no respawn. I duno what you wrote for that. Mine (SP Simple Respawn module) makes the player fall unconscious, then aware (+ some options). So, your unit remains unchanged and you don't need anything to re-run. For AIs, I wrote some other modules in this case, and yes, I re-create same unit as the one who died. I manage this "SP respawn" system (MP also) with options same loadout as at start / same loadout as in death. I'm using get/setUnitLoadout commands for that. You just have to get the loadout once the silence is added, for example. Anyway, your script is working..., even for Vanilla BLUFOR equipped with any MX rifle. Share this post Link to post Share on other sites
mikey74 186 Posted Friday at 05:53 AM (edited) Spoiler // function to handle unit info and classes for respawning of AI Mikeys_fnc_handleplayer_info params ["_unit"]; private _group = group _unit; // Collect unit data _unitData = [ (_unit isEqualTo leader _group), // (_unitData select 0) isLeader (face _unit), // (_unitData select 1) players face (typeOf _unit), // (_unitData select 2) class and loadout (getUnitLoadout [_unit, true]), // (_unitData select 3) loadout (leader _group), // (_unitData select 4) who is Leader (name _unit), // (_unitData select 5) players Name (nameSound _unit), // (_unitData select 6) players namesound (speaker _unit), // (_unitData select 7) players sound (pitch _unit), // (_unitData select 8) players pitch (rank _unit), // (_unitData select 9) Rank player (rankId _unit), // (_unitData select 10) RankID player _group, // (_unitData select 11) players group ([(leader _group),4000] call Mikeys_fnc_no_findDir) // (_unitData select 12) battle field direction for side ]; _unit setVariable ["UnitData", _unitData]; // All Data collected Spoiler // Function to handle unit deaths and respawning AI Mikeys_fnc_handleplayerDeath params ["_unit", "_killer", "_group", "_side"]; private _unitData = (_unit getVariable "UnitData"); private _isLeader = (_unitData select 0); private _face = (_unitData select 1); private _type_unit = (_unitData select 2); private _loadout = (_unitData select 3); private _Leader = (_unitData select 4); private _Name = (_unitData select 5); private _namesound = (_unitData select 6); private _speaker = (_unitData select 7); private _pitch = (_unitData select 8); private _Rank = (_unitData select 9); private _rankId = (_unitData select 10); private _group = (_unitData select 11); private _Perm_Direction = (_unitData select 12); [_unit] joinSilent grpNull; // Determine unit type to spawn _max_deaths = (_group getVariable "Max_units"); if (_max_deaths <= 0) exitWith { enableEndDialog; failMission "KILLED"; forceEnd; }; // Update KIA count and calculate remaining units private _kiaCount = (_group getVariable "KIA_count") + 1; _group setVariable ["KIA_count", _kiaCount, true]; _max_deaths = _max_deaths - 1; _group setVariable ["Max_units",_max_deaths]; hint format ["Group %1: KIA: %2 | Units Left: %3", _group, _kiaCount, _max_deaths]; //_typeOfU = typeOf _unit; private _spawnPos = _unit getPos [100,(_Perm_Direction + random (selectRandom [15,-15]))]; private _position = if (surfaceIsWater _spawnPos) then { // Define a function to check water depth _depth_checker = { params ["_pos"]; private _testPos = +_pos; _testPos set [2, getTerrainHeightASL _testPos]; ASLtoAGL _testPos select 2 }; // Adjust position to avoid water _position = _spawnPos; _distance = 1; _debth = -100; While {_debth < -0.5} do { _pos = _spawnPos getPos [_distance,(_spawnPos getDir _corpse)]; _distance = _distance + 1; _debth = [_pos] call _depth_checker; _position = _pos; }; _position } else { // Find suitable position ( or is it in) trees and forests private _treeplaces = selectBestPlaces [_spawnPos, 50, "(1 - forest) * (3 + trees) * (1 - sea) * (1 - meadow)", 1, 30]; private _forestplaces = selectBestPlaces [_spawnPos, 50, "(1 + forest) * (3 + trees) * (1 - sea) * (1 - meadow)", 1, 30]; private _trees = [_spawnPos]; { _select = _x; _pos = _x#0; if ({_x distance _pos > 7} count _trees > 0) then {_trees pushBack _pos}; } forEach (_treeplaces + _forestplaces); selectRandom _trees };//_spawnPos findEmptyPosition [0, 15]; // Ensure spawning position is not too far from the original position if (_position distance (leader (_group)) > 300) then {_position = ((leader (_group)) getPos [(50 + (random 50)),_Perm_Direction]);}; // Ensure spawning position is valid if (str _position isEqualTo "[0,0,0]" || (_position distance [0,0,0] <= 50)) then {_position = (_corpse getPos [(25 + (random 50)),_Perm_Direction]);}; _Newunit = _group createUnit [_type_unit, [0,0,0], [], 0, "NONE"]; [_Newunit, _face, _speaker, _pitch, _Name] call BIS_fnc_setIdentity; player setUnitRank _Rank; if (player isEqualTo _unit) then {addSwitchableUnit _unit}; _Newunit setVariable ["UnitData", _unitData]; _Newunit addEventHandler ["Killed", { params ["_unit", "_killer", "_instigator", "_useEffects"]; [_unit, _killer, (group _unit), side (group _unit)] call Mikeys_fnc_handleplayerDeath; }]; _Newunit setUnitLoadout [_loadout, true]; _Newunit setUnitPos "DOWN"; _Newunit hideObject true; _Newunit setPos _position; //player setPos _position; [_Newunit,_unit,_rallyPiont] spawn { params ["_Newunit","_unit","_rallyPiont"]; //sleep 2; // switch to new unit //selectPlayer _Newunit; // Set up camera for player's unit private _camera = "camera" camCreate (_unit modelToWorld [0,0,1]); showCinemaBorder false; _camera camSetFocus [-1, -1]; _camera camSetTarget _unit; _camera camSetRelPos [0,0,0]; _camera cameraEffect ["internal", "BACK"]; _camera camSetPos (_unit modelToWorld [0,-0.5,5]); _camera camCommit 1; // switch to new unit selectPlayer _Newunit; _Newunit playActionNow "PlayerProne"; Uisleep 1;//waitUntil { camCommitted _camera; }; // Adjust and clear death blur effect BIS_DeathBlur ppEffectAdjust [0.0]; BIS_DeathBlur ppEffectCommit 0.0; ppEffectDestroy BIS_DeathBlur; private _leader = if (!isNull (leader (group _Newunit))) then {(leader (group _Newunit))} else {_unit}; _Newunit setdir (_Newunit getDir _leader); _camera camSetTarget _leader;//_corpse; _camera camSetRelPos [0,0,0.7]; _camera camSetPos (_unit modelToWorld [0,0.25,30]); _camera camCommit 1; Uisleep 1;//waitUntil { camCommitted _camera; }; _camera camSetTarget _leader;//_unit; _camera camSetRelPos [0,0,7]; _camera camSetPos (_unit modelToWorld [0,0.5,15]); _camera camCommit 1; Uisleep 1;//waitUntil { camCommitted _camera; }; _camera camSetRelPos [0, 0, 0.3]; _camera camSetPos (_Newunit modelToWorld [0,0,1.5]); _sleepcommit = ((10 min (_unit distance _Newunit)*0.1)*0.35); _camera camCommit _sleepcommit; Uisleep _sleepcommit;//waitUntil { camCommitted _camera; }; _camera cameraEffect ["terminate","back"]; camDestroy _camera; BIS_DeathBlur ppEffectAdjust [0.0]; BIS_DeathBlur ppEffectCommit 0.0; //player setPos _rallyPiont; //hint format ["%1\n%2", _Newunit,_rallyPiont]; // Debugging _Newunit hideObject false; _Newunit setUnitPos "AUTO"; [] call Mikeys_fnc_aimFocus; sleep 3; //deleteVehicle _unit; }; //_typeOfU createUnit [_spawnPos, group _unit, "myUnit = this"]; // Additional logic for West side (e.g., respawn, move, etc.) Works real well. Just like MP. Except how and where they spawn. I'd have to re open dropbox and send ya a sample mission to explain most of it. lol Edited Friday at 05:57 AM by mikey74 to sloppy needed spoilers. 1 Share this post Link to post Share on other sites
pierremgi 4879 Posted Friday at 06:15 AM So, perhaps, you just have to call your silencer script just before : _unit setVariable ["UnitData", _unitData]; and that's all. Share this post Link to post Share on other sites
mikey74 186 Posted Friday at 06:25 AM (edited) bump Edited Monday at 10:09 AM by mikey74 tmi. may add revised code later on Share this post Link to post Share on other sites