From b21535665b8de5182f384a7f2c660453452fdca4 Mon Sep 17 00:00:00 2001 From: Cyruz143 Date: Mon, 24 Aug 2020 18:45:56 +0100 Subject: [PATCH] Grenades - Add throwable explosive charges (#7860) * First pass on adding throwable explosives * Moved fnc call to postinit * Disabled gits auto CRLF bs * Changing fnc name and call * Move names to string table * Using vanilla icon and removing explosive depend * More stringtable conversions * Missing semi-colons causing RPT error * Update addons/grenades/stringtable.xml Co-authored-by: PabstMirror * Remove empty strings * Update addons/grenades/stringtable.xml Co-authored-by: Elgin675 * Add compatibility with "realistic names" modules, and add french translation * Fix little mistake * Update addons/grenades/stringtable.xml Co-authored-by: Elgin675 * Add setting * Change setting name, use ace_settingsInitialized Co-authored-by: PabstMirror Co-authored-by: Elgin675 --- addons/grenades/CfgAmmo.hpp | 50 +++++++++++++- addons/grenades/CfgMagazines.hpp | 43 +++++++++++- addons/grenades/CfgWeapons.hpp | 12 +++- addons/grenades/XEH_PREP.hpp | 1 + addons/grenades/XEH_postInit.sqf | 6 ++ addons/grenades/XEH_preInit.sqf | 2 + addons/grenades/config.cpp | 4 +- ...nc_addChangeFuseItemContextMenuOptions.sqf | 68 +++++++++++++++++++ addons/grenades/initSettings.sqf | 9 +++ addons/grenades/stringtable.xml | 50 ++++++++++++++ addons/realisticnames/CfgMagazines.hpp | 8 ++- addons/realisticnames/stringtable.xml | 12 +++- 12 files changed, 257 insertions(+), 8 deletions(-) create mode 100644 addons/grenades/functions/fnc_addChangeFuseItemContextMenuOptions.sqf create mode 100644 addons/grenades/initSettings.sqf diff --git a/addons/grenades/CfgAmmo.hpp b/addons/grenades/CfgAmmo.hpp index e88c2196d9..ae02e89fa1 100644 --- a/addons/grenades/CfgAmmo.hpp +++ b/addons/grenades/CfgAmmo.hpp @@ -119,7 +119,7 @@ class CfgAmmo { effectsSmoke = "ACE_M84FlashbangEffect"; whistleDist = 0; }; - + class ACE_G_CTS9: ACE_G_M84 { GVAR(flashbang) = 1; GVAR(flashbangBangs) = 9; @@ -171,4 +171,52 @@ class CfgAmmo { whistleDist = 0; // no BIS explosion effects whistleOnFire = 0; // no BIS firing effects }; + + class ACE_SatchelCharge_Remote_Ammo_Thrown: Grenade { + model = "\A3\Weapons_F\Explosives\satchel"; + hit = 3000; + indirectHit = 3000; + indirectHitRange = 5; + defaultMagazine = "ACE_SatchelCharge_Remote_Mag_Throwable"; + soundHit1[] = {"A3\Sounds_F\arsenal\explosives\bombs\Explosion_satchel_01", 3.16228, 1, 1500}; + soundHit2[] = {"A3\Sounds_F\arsenal\explosives\bombs\Explosion_satchel_02", 3.16228, 1, 1500}; + multiSoundHit[] = {"soundHit1", 0.5, "soundHit2", 0.5}; + ExplosionEffects = "MineNondirectionalExplosion"; + CraterEffects = "MineNondirectionalCrater"; + whistleDist = 10; + SoundSetExplosion[] = {"ClaymoreMine_Exp_SoundSet", "ClaymoreMine_Tail_SoundSet", "Explosion_Debris_SoundSet"}; + timeToLive = 8; + fuseDistance = 0; + explosionTime = 7; + deflectionSlowDown = 0.1; + explosionType = "bomb"; + ACE_damageType = "explosive"; + EGVAR(frag,skip) = 1; + EGVAR(advanced_throwing,torqueMagnitude) = "(5 + random 20) * selectRandom [1, -1]"; + GVAR(pullPinSound)[] = {"A3\Sounds_F_Orange\arsenal\explosives\Handling\ExplosiveSatchel_TouchOff_01.wss", 2, 1, 50}; + class CamShakeExplode { + power = 20; + duration = 2; + frequency = 20; + distance = 250; + }; + }; + + class ACE_DemoCharge_Remote_Ammo_Thrown: ACE_SatchelCharge_Remote_Ammo_Thrown { + model = "\A3\Weapons_F\explosives\c4_charge_small"; + hit = 500; + indirectHit = 500; + defaultMagazine = "ACE_DemoCharge_Remote_Mag_Throwable"; + soundHit[] = {"A3\Sounds_F\arsenal\explosives\bombs\Explosive_Charge", 3.16228, 1, 1500}; + ExplosionEffects = "MineNondirectionalExplosionSmall"; + CraterEffects = "MineNondirectionalCraterSmall"; + whistleDist = 32; + SoundSetExplosion[] = {"ExplosiveCharge_Exp_SoundSet", "ExplosiveCharge_Tail_SoundSet", "Explosion_Debris_SoundSet"}; + class CamShakeExplode { + power = 10; + duration = 2; + frequency = 20; + distance = 250; + }; + }; }; diff --git a/addons/grenades/CfgMagazines.hpp b/addons/grenades/CfgMagazines.hpp index b5ae52d6ce..ea4641ab7f 100644 --- a/addons/grenades/CfgMagazines.hpp +++ b/addons/grenades/CfgMagazines.hpp @@ -64,7 +64,7 @@ class CfgMagazines { ammo = "ACE_G_M84"; mass = 4; }; - + class ACE_CTS9: HandGrenade { author = ECSTRING(common,ACETeam); displayname = CSTRING(CTS9_Name); @@ -131,4 +131,45 @@ class CfgMagazines { displayName = CSTRING(40mm_flare_ir); descriptionShort = CSTRING(parachute_flare_ir_description); }; + + class CA_Magazine; + class ACE_SatchelCharge_Remote_Mag_Throwable: CA_Magazine { + author = ECSTRING(common,ACETeam); + ammo = "ACE_SatchelCharge_Remote_Ammo_Thrown"; + scope = 1; + picture = "\A3\Weapons_f\data\UI\gear_satchel_CA.paa"; + model = "\A3\Weapons_F\Explosives\satchel_i"; + displayName = CSTRING(SatchelCharge_Remote_Mag_Throwable); + displayNameShort = "$STR_A3_cfgMagazines_PipeBomb0"; + descriptionShort = CSTRING(SatchelCharge_Description); + class Library { + libTextDesc = CSTRING(SatchelCharge_LibText); + }; + type = "2* 256"; + allowedSlots[] = {901}; + value = 5; + mass = 80; + count = 1; + initSpeed = 7.5; + maxLeadSpeed = 0; + nameSound = "satchelcharge"; + nameSoundWeapon = "satchelcharge"; + sound[] = {"A3\sounds_f\dummysound", 0.000316228, 1, 10}; + useAction = 0; + }; + + class ACE_DemoCharge_Remote_Mag_Throwable: ACE_SatchelCharge_Remote_Mag_Throwable { + ammo = "ACE_DemoCharge_Remote_Ammo_Thrown"; + picture = "\A3\Weapons_F\Data\UI\gear_c4_charge_small_CA.paa"; + model = "\A3\Weapons_F\explosives\c4_charge_small_d"; + displayName = CSTRING(DemoCharge_Remote_Mag_Throwable); + displayNameShort = "$STR_A3_cfgMagazines_DemoCharge0"; + descriptionShort = CSTRING(SatchelCharge_Description); + class Library { + libTextDesc = CSTRING(DemoCharge_LibText); + }; + allowedSlots[] = {901, 701}; + mass = 20; + initSpeed = 12.5; + }; }; diff --git a/addons/grenades/CfgWeapons.hpp b/addons/grenades/CfgWeapons.hpp index 6aad205437..842862f7f9 100644 --- a/addons/grenades/CfgWeapons.hpp +++ b/addons/grenades/CfgWeapons.hpp @@ -2,7 +2,7 @@ class CfgWeapons { class GrenadeLauncher; class Throw: GrenadeLauncher { - muzzles[] += {"ACE_HandFlare_WhiteMuzzle","ACE_HandFlare_RedMuzzle","ACE_HandFlare_GreenMuzzle","ACE_HandFlare_YellowMuzzle","ACE_M84Muzzle","ACE_M14Muzzle","ACE_CTS9Muzzle"}; + muzzles[] += {"ACE_HandFlare_WhiteMuzzle","ACE_HandFlare_RedMuzzle","ACE_HandFlare_GreenMuzzle","ACE_HandFlare_YellowMuzzle","ACE_M84Muzzle","ACE_M14Muzzle","ACE_CTS9Muzzle","ACE_SatchelMuzzle","ACE_DemoMuzzle"}; class ThrowMuzzle; class ACE_HandFlare_WhiteMuzzle: ThrowMuzzle { @@ -28,9 +28,17 @@ class CfgWeapons { class ACE_M14Muzzle: ThrowMuzzle { magazines[] = {"ACE_M14"}; }; - + class ACE_CTS9Muzzle: ThrowMuzzle { magazines[] = {"ACE_CTS9"}; }; + + class ACE_SatchelMuzzle: ThrowMuzzle { + magazines[] = {"ACE_SatchelCharge_Remote_Mag_Throwable"}; + }; + + class ACE_DemoMuzzle: ThrowMuzzle { + magazines[] = {"ACE_DemoCharge_Remote_Mag_Throwable"}; + }; }; }; diff --git a/addons/grenades/XEH_PREP.hpp b/addons/grenades/XEH_PREP.hpp index e5e0cb4732..6b5fb57801 100644 --- a/addons/grenades/XEH_PREP.hpp +++ b/addons/grenades/XEH_PREP.hpp @@ -5,3 +5,4 @@ PREP(flashbangThrownFuze); PREP(incendiary); PREP(nextMode); PREP(throwGrenade); +PREP(addChangeFuseItemContextMenuOptions); diff --git a/addons/grenades/XEH_postInit.sqf b/addons/grenades/XEH_postInit.sqf index 6809321d83..b4657f4c9b 100644 --- a/addons/grenades/XEH_postInit.sqf +++ b/addons/grenades/XEH_postInit.sqf @@ -26,3 +26,9 @@ GVAR(flashbangPPEffectCC) ppEffectForceInNVG true; // Statement [] call FUNC(nextMode); }, {false}, [9, [false, false, false]], false] call CBA_fnc_addKeybind; //8 Key + +["ace_settingsInitialized", { + if (GVAR(convertExplosives)) then { + [] call FUNC(addChangeFuseItemContextMenuOptions); + }; +}] call CBA_fnc_addEventHandler; diff --git a/addons/grenades/XEH_preInit.sqf b/addons/grenades/XEH_preInit.sqf index b47cf6628d..9361d05015 100644 --- a/addons/grenades/XEH_preInit.sqf +++ b/addons/grenades/XEH_preInit.sqf @@ -6,4 +6,6 @@ PREP_RECOMPILE_START; #include "XEH_PREP.hpp" PREP_RECOMPILE_END; +#include "initSettings.sqf" + ADDON = true; diff --git a/addons/grenades/config.cpp b/addons/grenades/config.cpp index 945814796a..504b8d5f0e 100644 --- a/addons/grenades/config.cpp +++ b/addons/grenades/config.cpp @@ -11,7 +11,9 @@ class CfgPatches { "ACE_HandFlare_Yellow", "ACE_M84", "ACE_M14", - "ACE_CTS9" + "ACE_CTS9", + "ACE_SatchelCharge_Remote_Mag_Throwable", + "ACE_DemoCharge_Remote_Mag_Throwable" }; requiredVersion = REQUIRED_VERSION; requiredAddons[] = {"ace_common"}; diff --git a/addons/grenades/functions/fnc_addChangeFuseItemContextMenuOptions.sqf b/addons/grenades/functions/fnc_addChangeFuseItemContextMenuOptions.sqf new file mode 100644 index 0000000000..407d029c0e --- /dev/null +++ b/addons/grenades/functions/fnc_addChangeFuseItemContextMenuOptions.sqf @@ -0,0 +1,68 @@ +#include "script_component.hpp" +/* + * Author: Cyruz + * Allows conversion of explosive charges in to throwable versions + * + * Arguments: + * None + * + * Return Value: + * None + * + * Example: + * call ace_grenades_fnc_addChangeFuseItemContextMenuOptions + * + * Public: No + */ + TRACE_1("addChangeFuseItemContextMenuOptions",_this); + +{ + _x params ["_mag", "_throwableMag"]; + + [ + _mag, + "CONTAINER", + LLSTRING(convert_fuse), + nil, + "\a3\ui_f\data\igui\cfg\simpletasks\types\destroy_ca.paa", + [ + {true}, + { + params ["", "", "_item", "", "_magArr"]; + _item isEqualTo (_magArr select 0); + } + ], + { + params ["_unit", "", "", "", "_magArr"]; + _unit addMagazine (_magArr select 1); + false; + }, + true, + [_mag,_throwableMag] + ] call CBA_fnc_addItemContextMenuOption; + + [ + _throwableMag, + "CONTAINER", + LLSTRING(remove_fuse), + nil, + "\a3\ui_f\data\igui\cfg\simpletasks\types\destroy_ca.paa", + [ + {true}, + { + params ["", "", "_item", "", "_magArr"]; + _item isEqualTo (_magArr select 1); + } + ], + { + params ["_unit", "", "", "", "_magArr"]; + _unit addMagazine (_magArr select 0); + false; + }, + true, + [_mag,_throwableMag] + ] call CBA_fnc_addItemContextMenuOption; +} forEach [ + ["SatchelCharge_Remote_Mag", "ACE_SatchelCharge_Remote_Mag_Throwable"], + ["DemoCharge_Remote_Mag", "ACE_DemoCharge_Remote_Mag_Throwable"] +]; diff --git a/addons/grenades/initSettings.sqf b/addons/grenades/initSettings.sqf new file mode 100644 index 0000000000..b6fa36f459 --- /dev/null +++ b/addons/grenades/initSettings.sqf @@ -0,0 +1,9 @@ +[ + QGVAR(convertExplosives), "CHECKBOX", + [LSTRING(convertExplosives_DisplayName), LSTRING(convertExplosives_Description)], + LSTRING(Settings_DisplayName), + true, + true, + {}, + true +] call CBA_fnc_addSetting; diff --git a/addons/grenades/stringtable.xml b/addons/grenades/stringtable.xml index a7ac8557f5..9f623ec832 100644 --- a/addons/grenades/stringtable.xml +++ b/addons/grenades/stringtable.xml @@ -508,5 +508,55 @@ M992 Infračervená světlice M992 Illumination IR Flare + + Explosive Satchel (Throwable) + Charge en sacoche (lançable) + + + Type: Charge<br />Rounds: 1<br />Used on: Things that need to die + Type : Charge<br />Munitions : 1<br />Application : à balancer sur des trucs qui doivent mourir + + + An explosive satchel that is throwable. 7 second fixed fuse + Charge explosive lançable. Détonation après 7 secondes. + + + Explosive Charge (Throwable) + Charge explosive (lançable) + + + An explosive charge that is throwable. 7 second fixed fuse + Bloc explosif lançable. Détonation après 7 secondes. + + + Convert to short fuse + Mèche lente (7 secondes) + + + Remove short fuse + Retirer la mèche lente + + + ACE Grenades + ACE Granaten + ACE Granáty + ACE Granaty + ACE Granate + ACE Granadas + ACE Grenades + ACE Granadas + ACE Гранаты + ACE 手榴弾 + ACE 수류탄 + ACE 手榴弹 + ACE 手榴彈 + ACE Bombalar + + + Allow Explosive Conversion + + + Allow converting explosives to throwables + diff --git a/addons/realisticnames/CfgMagazines.hpp b/addons/realisticnames/CfgMagazines.hpp index bacaed93dc..49a450bbd5 100644 --- a/addons/realisticnames/CfgMagazines.hpp +++ b/addons/realisticnames/CfgMagazines.hpp @@ -390,6 +390,12 @@ class CfgMagazines { class DemoCharge_Remote_Mag: SatchelCharge_Remote_Mag { displayName = CSTRING(DemoCharge_Name); }; + class ACE_SatchelCharge_Remote_Mag_Throwable: SatchelCharge_Remote_Mag { + displayName = CSTRING(SatchelChargeThrowable_Name); + }; + class ACE_DemoCharge_Remote_Mag_Throwable: ACE_SatchelCharge_Remote_Mag_Throwable { + displayName = CSTRING(DemoChargeThrowable_Name); + }; // hand grenades class HandGrenade: CA_Magazine { @@ -474,7 +480,7 @@ class CfgMagazines { }; class PylonRack_7Rnd_Rocket_04_HE_F: 7Rnd_Rocket_04_HE_F { displayName = "Hydra 70 7x HE"; // [vanilla: Shrieker 7x HE - Rocket_04_HE_Plane_CAS_01_F] - }; + }; class PylonRack_7Rnd_Rocket_04_AP_F: 7Rnd_Rocket_04_AP_F { displayName = "Hydra 70 7x AP"; // [vanilla: Shrieker 7x AP - Rocket_04_AP_Plane_CAS_01_F] }; diff --git a/addons/realisticnames/stringtable.xml b/addons/realisticnames/stringtable.xml index a7b10daa84..27ef7ddd99 100644 --- a/addons/realisticnames/stringtable.xml +++ b/addons/realisticnames/stringtable.xml @@ -1312,7 +1312,7 @@ Conjunto de carga de demolición M183 Ładunek burzący M183 Demoliční nálož M183 - M183 Charge de Démolition + M183 Charge de démolition M183 Комплектный подрывной заряд M183 Sacola de Demolição M183 romboló töltet @@ -1323,13 +1323,17 @@ M183炸药包 M183 Demolition Charge Assembly + + M183 Demolition Charge (Throwable) + M183 Charge de démolition (lançable) + M112 Demolition Block M112 Sprengladung Bloque de demolición M112 Ładunek burzący M112 Výbušná nálož M112 - M112 Block de Démolition + M112 Bloc de démolition M112 подрывной заряд M112 Carga de Demolição M112 romboló tömb @@ -1340,6 +1344,10 @@ M112塑性炸药 M112 Demolition Block + + M112 Demolition Charge (Throwable) + M112 Bloc de démolition (lançable) + M67 Fragmentation Grenade M67 Splittergranate