diff --git a/addons/missileguidance/functions/fnc_attackProfile_LIN.sqf b/addons/missileguidance/functions/fnc_attackProfile_LIN.sqf index e346b16eb6..31ee3983ed 100644 --- a/addons/missileguidance/functions/fnc_attackProfile_LIN.sqf +++ b/addons/missileguidance/functions/fnc_attackProfile_LIN.sqf @@ -21,7 +21,9 @@ params ["_seekerTargetPos", "_args"]; _args params ["_firedEH"]; _firedEH params ["_shooter","","","","","","_projectile"]; -if (_seekerTargetPos isEqualTo [0,0,0]) exitWith {_seekerTargetPos}; +if (_seekerTargetPos isEqualTo [0,0,0]) exitWith { + _projectilePos vectorAdd (_projectile vectorModelToWorld [0, 50, 0]) +}; private _shooterPos = getPosASL _shooter; private _projectilePos = getPosASL _projectile; diff --git a/addons/pike/$PBOPREFIX$ b/addons/pike/$PBOPREFIX$ new file mode 100644 index 0000000000..abc9bbeaae --- /dev/null +++ b/addons/pike/$PBOPREFIX$ @@ -0,0 +1 @@ +z\ace\addons\pike diff --git a/addons/pike/CfgAmmo.hpp b/addons/pike/CfgAmmo.hpp new file mode 100644 index 0000000000..224f820fad --- /dev/null +++ b/addons/pike/CfgAmmo.hpp @@ -0,0 +1,83 @@ +class CfgAmmo { + class SubmunitionBase; + class GVAR(ammo_gl): SubmunitionBase { + model = QPATHTOF(models\ace_pike_ammo.p3d); + submunitionAmmo = QGVAR(ammo_rocket); + submunitionCount = 1; + submunitionConeAngle = 0; + EGVAR(frag,skip) = 1; // don't frag because this is a scripted ammo + class Eventhandlers { + fired = QUOTE(call FUNC(ammoFired)); + }; + }; + + class MissileBase; + class GVAR(ammo_rocket): MissileBase { + irLock = 0; + laserLock = 0; + airLock = 0; + manualControl = 0; + timeToLive = 22; + + model = QPATHTOF(models\ace_pike_ammo.p3d); + maxSpeed = 150; // ~2km in 15sec + thrust = 19; + thrustTime = 14; + initTime = 0; + airFriction = 0.1; + + hit = 120; + indirectHit = 10; + indirectHitRange = 10; + warheadName = "HE"; + + EGVAR(frag,enabled) = 1; + EGVAR(frag,force) = 1; + EGVAR(frag,classes)[] = {QEGVAR(frag,tiny_HD)}; + EGVAR(frag,metal) = 200; + EGVAR(frag,charge) = 270; // ~8x a normal 40mm + EGVAR(frag,gurney_c) = 2700; + EGVAR(frag,gurney_k) = "1/2"; + + CraterEffects="ExploAmmoCrater"; + explosionEffects="ExploAmmoExplosion"; + effectsMissileInit = "RocketBackEffectsRPG"; + effectsMissile = "missile3"; + + SoundSetExplosion[] = {"GrenadeHe_Exp_SoundSet", "GrenadeHe_Tail_SoundSet", "Explosion_Debris_SoundSet"}; + soundHit1[] = { "A3\Sounds_F\arsenal\explosives\Grenades\Explosion_gng_grenades_01", 3.1622777, 1, 1500}; + soundHit2[] = { "A3\Sounds_F\arsenal\explosives\Grenades\Explosion_gng_grenades_02", 3.1622777, 1, 1500}; + soundHit3[] = { "A3\Sounds_F\arsenal\explosives\Grenades\Explosion_gng_grenades_03", 3.1622777, 1, 1500}; + soundHit4[] = { "A3\Sounds_F\arsenal\explosives\Grenades\Explosion_gng_grenades_04", 3.1622777, 1, 1500}; + multiSoundHit[] = {"soundHit1", 0.25, "soundHit2", 0.25, "soundHit3", 0.25, "soundHit4", 0.25}; + whistleDist=16; + + // Begin ACE guidance Configs + class ace_missileguidance { + enabled = 2; + + minDeflection = 0.0005; // Minium flap deflection for guidance + maxDeflection = 0.0025; // Maximum flap deflection for guidance + incDeflection = 0.0005; // The incrmeent in which deflection adjusts. + + canVanillaLock = 0; // Can this default vanilla lock? Only applicable to non-cadet mode + + // Guidance type for munitions + defaultSeekerType = "SALH"; + seekerTypes[] = {"SALH"}; + + defaultSeekerLockMode = "LOAL"; + seekerLockModes[] = {"LOAL"}; + + seekerAngle = 90; // Angle in front of the missile which can be searched + seekerAccuracy = 1; // seeker accuracy multiplier + + seekerMinRange = 1; + seekerMaxRange = 3000; // Range from the missile which the seeker can visually search + + // Attack profile type selection + defaultAttackProfile = "LIN"; + attackProfiles[] = {"LIN"}; + }; + }; +}; diff --git a/addons/pike/CfgEventhandlers.hpp b/addons/pike/CfgEventhandlers.hpp new file mode 100644 index 0000000000..f72363981a --- /dev/null +++ b/addons/pike/CfgEventhandlers.hpp @@ -0,0 +1,10 @@ +class Extended_PreStart_EventHandlers { + class ADDON { + init = QUOTE(call COMPILE_SCRIPT(XEH_preStart)); + }; +}; +class Extended_PreInit_EventHandlers { + class ADDON { + init = QUOTE(call COMPILE_SCRIPT(XEH_preInit)); + }; +}; diff --git a/addons/pike/CfgMagazineWells.hpp b/addons/pike/CfgMagazineWells.hpp new file mode 100644 index 0000000000..e5ccc8b074 --- /dev/null +++ b/addons/pike/CfgMagazineWells.hpp @@ -0,0 +1,5 @@ +class CfgMagazineWells { + class CBA_40mm_EGLM { // for longer grenades that can only fit side breech-loading + ADDON[] = {"ACE_40mm_Pike"}; + }; +}; diff --git a/addons/pike/CfgMagazines.hpp b/addons/pike/CfgMagazines.hpp new file mode 100644 index 0000000000..4258127db6 --- /dev/null +++ b/addons/pike/CfgMagazines.hpp @@ -0,0 +1,15 @@ +class CfgMagazines { + class 1Rnd_HE_Grenade_shell; + class ACE_40mm_Pike: 1Rnd_HE_Grenade_shell { + displayName = CSTRING(magazine_displayName); + displayNameShort = CSTRING(magazine_displayNameShort); + descriptionShort = CSTRING(magazine_descriptionShort); + picture = QPATHTOF(ui\gear_pike_ca.paa); + ammo = QGVAR(ammo_gl); + count = 1; + // model = QPATHTOF(models\ace_pike_ammo.p3d); // kinda ugly, just use pouch thing + initSpeed = 50; + mass = 17; // ~1.7 Pounds + author = ECSTRING(common,ACETeam); + }; +}; diff --git a/addons/pike/README.md b/addons/pike/README.md new file mode 100644 index 0000000000..a90c3570db --- /dev/null +++ b/addons/pike/README.md @@ -0,0 +1,4 @@ +ace_pike +=========== + +Adds 40mm Pike semi-active laser seeking rocket, firable from the M320 or EGLM grenade launcher. diff --git a/addons/pike/XEH_PREP.hpp b/addons/pike/XEH_PREP.hpp new file mode 100644 index 0000000000..a82521a9ae --- /dev/null +++ b/addons/pike/XEH_PREP.hpp @@ -0,0 +1,2 @@ +LOG("prep"); +PREP(ammoFired); diff --git a/addons/pike/XEH_preInit.sqf b/addons/pike/XEH_preInit.sqf new file mode 100644 index 0000000000..a7feade1c3 --- /dev/null +++ b/addons/pike/XEH_preInit.sqf @@ -0,0 +1,7 @@ +#include "script_component.hpp" + +ADDON = false; + +#include "XEH_PREP.hpp" + +ADDON = true; diff --git a/addons/pike/XEH_preStart.sqf b/addons/pike/XEH_preStart.sqf new file mode 100644 index 0000000000..022888575e --- /dev/null +++ b/addons/pike/XEH_preStart.sqf @@ -0,0 +1,3 @@ +#include "script_component.hpp" + +#include "XEH_PREP.hpp" diff --git a/addons/pike/config.cpp b/addons/pike/config.cpp new file mode 100644 index 0000000000..f676a6143b --- /dev/null +++ b/addons/pike/config.cpp @@ -0,0 +1,20 @@ +#include "script_component.hpp" + +class CfgPatches { + class ADDON { + name = COMPONENT_NAME; + units[] = {}; + weapons[] = {}; + requiredVersion = REQUIRED_VERSION; + requiredAddons[] = {"ace_missileguidance"}; + author = ECSTRING(common,ACETeam); + authors[] = {"PabstMirror"}; + url = ECSTRING(main,URL); + VERSION_CONFIG; + }; +}; + +#include "CfgAmmo.hpp" +#include "CfgEventhandlers.hpp" +#include "CfgMagazines.hpp" +#include "CfgMagazineWells.hpp" diff --git a/addons/pike/functions/fnc_ammoFired.sqf b/addons/pike/functions/fnc_ammoFired.sqf new file mode 100644 index 0000000000..dd99c5f60f --- /dev/null +++ b/addons/pike/functions/fnc_ammoFired.sqf @@ -0,0 +1,63 @@ +#include "..\script_component.hpp" +/* + * Author: PabstMirror + * Handles firing the 40mm pike grenade (shell) + * + * Arguments: + * FiredEH + * + * Return Value: + * Nothing + * + * Example: + * [] call ace_pike_fnc_ammoFired + * + * Public: No + */ + +params ["_unit", "", "", "", "_ammo", "", "_projectile", "_gunner"]; +TRACE_4("ammoFired",_unit,_ammo,_projectile,_gunner); + +if (!local _gunner) exitWith {}; +if (isNull _projectile) exitWith {}; + +// Get MissileGuidance args now +private _firedEH = +_this; +// Inject the submunition ammo into guidance args +_firedEH set [4, getText (configFile >> "CfgAmmo" >> _ammo >> "submunitionAmmo")]; +private _guidanceArgs = _firedEH call EFUNC(missileguidance,onFiredDeferred); +_projectile setVariable [QGVAR(guidanceArgs), _guidanceArgs]; + +// On missile deploy start guidance +_projectile addEventHandler ["SubmunitionCreated", { + params ["_projectile", "_submunitionProjectile"]; + TRACE_2("SubmunitionCreated",_projectile,_submunitionProjectile); + + private _guidanceArgs = _projectile getVariable [QGVAR(guidanceArgs), []]; + if (_guidanceArgs isEqualTo []) exitWith { ERROR_1("bad args %1",_projectile); }; + // Inject the submunition projectile and time into guidance args + _guidanceArgs params ["_firedEH", "", "", "", "_stateParams"]; + _firedEH set [6, _submunitionProjectile]; // _firedEH params ["","","","","","","_projectile"]; + _stateParams set [0, diag_tickTime]; // _stateParams params ["_lastRunTime"] + + [EFUNC(missileguidance,guidancePFH), 0, _guidanceArgs] call CBA_fnc_addPerFrameHandler; + if (!isNil QEFUNC(frag,addPfhRound)) then { + [_firedEH # 0, _firedEH # 4, _submunitionProjectile] call EFUNC(frag,addPfhRound); + }; + + #ifdef DEBUG_MODE_FULL + [{ + params ["_time", "_projectile"]; + if (isNull _projectile) exitWith {true}; + systemChat format ["%1 - %2", CBA_missionTime - _time, vectorMagnitude velocity _projectile]; + false + }, {}, [CBA_missionTime, _submunitionProjectile]] call CBA_fnc_waitUntilAndExecute; + #endif +}]; + +// Trigger motor after ~4 meter delay (could also use config `triggerTime`) +[{ + params ["_projectile"]; + if (isNull _projectile) exitWith { WARNING_1("null %1",_projectile); }; + triggerAmmo _projectile; +}, [_projectile], 0.1] call CBA_fnc_waitAndExecute; diff --git a/addons/pike/models/ace_pike_ammo.p3d b/addons/pike/models/ace_pike_ammo.p3d new file mode 100644 index 0000000000..9a60996295 Binary files /dev/null and b/addons/pike/models/ace_pike_ammo.p3d differ diff --git a/addons/pike/script_component.hpp b/addons/pike/script_component.hpp new file mode 100644 index 0000000000..b7bd9b4d93 --- /dev/null +++ b/addons/pike/script_component.hpp @@ -0,0 +1,17 @@ +#define COMPONENT pike +#define COMPONENT_BEAUTIFIED Pike +#include "\z\ace\addons\main\script_mod.hpp" + +// #define DEBUG_MODE_FULL +// #define DISABLE_COMPILE_CACHE +// #define ENABLE_PERFORMANCE_COUNTERS + +#ifdef DEBUG_ENABLED_PIKE + #define DEBUG_MODE_FULL +#endif + +#ifdef DEBUG_SETTINGS_PIKE + #define DEBUG_SETTINGS DEBUG_SETTINGS_PIKE +#endif + +#include "\z\ace\addons\main\script_macros.hpp" diff --git a/addons/pike/stringtable.xml b/addons/pike/stringtable.xml new file mode 100644 index 0000000000..2fdc40161b --- /dev/null +++ b/addons/pike/stringtable.xml @@ -0,0 +1,14 @@ + + + + + 40mm Pike + + + Pike SALH + + + Semi-Active Laser Guided 40mm Grenade + + + diff --git a/addons/pike/ui/gear_pike_ca.paa b/addons/pike/ui/gear_pike_ca.paa new file mode 100644 index 0000000000..1b0ecb3807 Binary files /dev/null and b/addons/pike/ui/gear_pike_ca.paa differ