mirror of
https://github.com/acemod/ACE3.git
synced 2024-08-30 18:23:18 +00:00
Grenades Cleanup
Shouldn't be any change to functionality Headers Formating simplifying (waitAndExecute) exceptions/canInteract for keybind
This commit is contained in:
parent
fb3a610649
commit
1a61148053
@ -6,7 +6,7 @@ class Extended_PreInit_EventHandlers {
|
||||
|
||||
class Extended_PostInit_EventHandlers {
|
||||
class ADDON {
|
||||
clientInit = QUOTE( call COMPILE_FILE(XEH_postInitClient) );
|
||||
init = QUOTE( call COMPILE_FILE(XEH_postInit) );
|
||||
};
|
||||
};
|
||||
|
||||
|
28
addons/grenades/XEH_postInit.sqf
Normal file
28
addons/grenades/XEH_postInit.sqf
Normal file
@ -0,0 +1,28 @@
|
||||
// by commy2
|
||||
|
||||
#include "script_component.hpp"
|
||||
|
||||
["flashbangExplosion", {_this call FUNC(flashbangExplosionEH)}] call EFUNC(common,addEventHandler);
|
||||
|
||||
if !(hasInterface) exitWith {};
|
||||
|
||||
GVAR(flashbangPPEffectCC) = ppEffectCreate ["ColorCorrections", 4265];
|
||||
GVAR(flashbangPPEffectCC) ppEffectForceInNVG true;
|
||||
|
||||
// Add keybinds
|
||||
["ACE3",
|
||||
localize "STR_ACE_Grenades_SwitchGrenadeMode",
|
||||
{
|
||||
// Conditions: canInteract
|
||||
_exceptions = [QEGVAR(captives,isNotEscorting)];
|
||||
if !(_exceptions call EGVAR(common,canInteract)) exitWith {false};
|
||||
// Conditions: specific
|
||||
if (!([ACE_player] call EFUNC(common,canUseWeapon))) exitWith {false};
|
||||
|
||||
// Statement
|
||||
[] call FUNC(nextMode);
|
||||
},
|
||||
[9, [false, false, false]], //8 key
|
||||
false,
|
||||
"keydown"
|
||||
] call cba_fnc_registerKeybind;
|
@ -1,13 +0,0 @@
|
||||
// by commy2
|
||||
|
||||
#include "script_component.hpp"
|
||||
|
||||
GVAR(flashbangPPEffectCC) = ppEffectCreate ["ColorCorrections", 4265];
|
||||
GVAR(flashbangPPEffectCC) ppEffectForceInNVG true;
|
||||
|
||||
["ACE3",
|
||||
localize "STR_ACE_Grenades_SwitchGrenadeMode",
|
||||
{_this call FUNC(nextMode)},
|
||||
[9, [false, false, false]], //8 key
|
||||
false,
|
||||
"keydown"] call cba_fnc_registerKeybind;
|
@ -2,12 +2,9 @@
|
||||
|
||||
ADDON = false;
|
||||
|
||||
PREP(flashbangEffectStages);
|
||||
PREP(flashbangExplosionEH);
|
||||
PREP(flashbangThrownFuze);
|
||||
PREP(nextMode);
|
||||
PREP(throwGrenade);
|
||||
|
||||
["flashbangExplosion", { _this call DFUNC(flashbangExplosionEH) }] call EFUNC(common,addEventHandler);
|
||||
|
||||
ADDON = true;
|
||||
|
@ -1,57 +0,0 @@
|
||||
/*
|
||||
* Author: KoffeinFlummi, Pabst Mirror
|
||||
*
|
||||
* Handles the different stages of the flash bang effect recovery
|
||||
*
|
||||
* Arguments:
|
||||
* ARRAY[
|
||||
* 0-ARRAY - PARAMS:
|
||||
* 0: NUMBER - Stage, controls a case statement
|
||||
* 1: NUMBER - Time To Wait Until
|
||||
* 2: VARIES - Stage's Variable
|
||||
* 1-NUMBER perFrame handle
|
||||
* Return Value:
|
||||
* None
|
||||
*/
|
||||
|
||||
#include "script_component.hpp"
|
||||
|
||||
private ["_stage", "_waitUntilTime"];
|
||||
|
||||
_stage = (_this select 0) select 0;
|
||||
_waitUntilTime = (_this select 0) select 1;
|
||||
|
||||
if (_waitUntilTime > time) exitWith {};
|
||||
|
||||
//remove frameEH
|
||||
[(_this select 1)] call cba_fnc_removePerFrameHandler;
|
||||
|
||||
switch (_stage) do {
|
||||
case(EFFECT_STAGE_RESETAI): {
|
||||
private "_unit";
|
||||
_unit = (_this select 0) select 2;
|
||||
_unit enableAI "MOVE";
|
||||
_unit enableAI "ANIM";
|
||||
_unit enableAI "AUTOTARGET";
|
||||
_unit enableAI "TARGET";
|
||||
_unit enableAI "FSM";
|
||||
_unit setSkill (skill _unit * 50);
|
||||
};
|
||||
case(EFFECT_STAGE_DELETELIGHT): {
|
||||
private "_light";
|
||||
_light = (_this select 0) select 2;
|
||||
deleteVehicle _light;
|
||||
};
|
||||
case(EFFECT_STAGE_PARTIALRECOVERY): {
|
||||
private "_strength";
|
||||
_strength = (_this select 0) select 2;
|
||||
GVAR(flashbangPPEffectCC) ppEffectAdjust [1,1,0,[1,1,1,0],[0,0,0,1],[0,0,0,0]];
|
||||
GVAR(flashbangPPEffectCC) ppEffectCommit (10 * _strength);
|
||||
};
|
||||
case(EFFECT_STAGE_FULLRECOVERY): {
|
||||
GVAR(flashbangPPEffectCC) ppEffectEnable false;
|
||||
};
|
||||
default {
|
||||
TRACE_1("EffectStage Bad Stage", _stage);
|
||||
};
|
||||
};
|
@ -1,20 +1,23 @@
|
||||
/*
|
||||
* Author: KoffeinFlummi
|
||||
*
|
||||
* Creates the flashbang effect and knock out AI units.
|
||||
*
|
||||
* Arguments:
|
||||
* 0: The grenade (Object)
|
||||
* 0: The grenade <OBJECT>
|
||||
*
|
||||
* Return Value:
|
||||
* None
|
||||
* Nothing
|
||||
*
|
||||
* Example:
|
||||
* [theGrenade] call ace_grenades_fnc_flashbangExplosionEH
|
||||
*
|
||||
* Public: No
|
||||
*/
|
||||
|
||||
#include "script_component.hpp"
|
||||
|
||||
private ["_grenade", "_affected", "_strength", "_posGrenade", "_posUnit", "_angleGrenade", "_angleView", "_angleDiff", "_light"];
|
||||
private ["_affected", "_strength", "_posGrenade", "_posUnit", "_angleGrenade", "_angleView", "_angleDiff", "_light"];
|
||||
|
||||
_grenade = _this select 0;
|
||||
PARAMS_1(_grenade);
|
||||
|
||||
_affected = _grenade nearEntities ["CAManBase", 50];
|
||||
|
||||
@ -32,7 +35,15 @@ _affected = _grenade nearEntities ["CAManBase", 50];
|
||||
_x disableAI "FSM";
|
||||
_x setSkill ((skill _x) / 50);
|
||||
|
||||
[FUNC(flashbangEffectStages), 0, [EFFECT_STAGE_RESETAI, (time + (7 * _strength)), _x]] call CBA_fnc_addPerFrameHandler;
|
||||
[{
|
||||
PARAMS_1(_unit);
|
||||
_unit enableAI "MOVE";
|
||||
_unit enableAI "ANIM";
|
||||
_unit enableAI "AUTOTARGET";
|
||||
_unit enableAI "TARGET";
|
||||
_unit enableAI "FSM";
|
||||
_unit setSkill (skill _unit * 50);
|
||||
}, [_x], (7 * _strength), 0.1] call EFUNC(common,waitAndExecute); //0.1 precision is fine for AI
|
||||
} else {
|
||||
//Do effects for player
|
||||
// is there line of sight to the grenade?
|
||||
@ -54,7 +65,7 @@ _affected = _grenade nearEntities ["CAManBase", 50];
|
||||
_angleGrenade = ((_posGrenade select 0) - (_posUnit select 0)) atan2 ((_posGrenade select 1) - (_posUnit select 1));
|
||||
_angleGrenade = (_angleGrenade + 360) % 360;
|
||||
|
||||
_angleView = (eyeDirection player select 0) atan2 (eyeDirection player select 1);
|
||||
_angleView = (eyeDirection ACE_player select 0) atan2 (eyeDirection ACE_player select 1);
|
||||
_angleView = (_angleView + 360) % 360;
|
||||
|
||||
_angleDiff = 180 - abs (abs (_angleGrenade - _angleView) - 180);
|
||||
@ -63,13 +74,17 @@ _affected = _grenade nearEntities ["CAManBase", 50];
|
||||
_strength = _strength - _strength * (_angleDiff / 135);
|
||||
|
||||
// create flash to illuminate environment
|
||||
_light = "#lightpoint" createVehicleLocal getPos _grenade;
|
||||
_light = "#lightpoint" createVehicleLocal (getPos _grenade);
|
||||
_light setLightBrightness 200;
|
||||
_light setLightAmbient [1,1,1];
|
||||
_light setLightColor [1,1,1];
|
||||
_light setLightDayLight true;
|
||||
|
||||
[FUNC(flashbangEffectStages), 0, [EFFECT_STAGE_DELETELIGHT, (time + (0.1)), _light]] call CBA_fnc_addPerFrameHandler;
|
||||
//Delete the light after 0.1 seconds
|
||||
[{
|
||||
PARAMS_1(_light);
|
||||
deleteVehicle _light;
|
||||
}, [_light], 0.1, 0] call EFUNC(common,waitAndExecute);
|
||||
|
||||
// blind player
|
||||
if (_strength > 0.1) then {
|
||||
@ -77,8 +92,17 @@ _affected = _grenade nearEntities ["CAManBase", 50];
|
||||
GVAR(flashbangPPEffectCC) ppEffectAdjust [1,1,(0.8 + _strength) min 1,[1,1,1,0],[0,0,0,1],[0,0,0,0]];
|
||||
GVAR(flashbangPPEffectCC) ppEffectCommit 0.01;
|
||||
|
||||
[FUNC(flashbangEffectStages), 0, [EFFECT_STAGE_PARTIALRECOVERY, (time + (7 * _strength)), _strength]] call CBA_fnc_addPerFrameHandler;
|
||||
[FUNC(flashbangEffectStages), 0, [ EFFECT_STAGE_FULLRECOVERY, (time + (17 * _strength))]] call CBA_fnc_addPerFrameHandler;
|
||||
//PARTIALRECOVERY - start decreasing effect over time
|
||||
[{
|
||||
PARAMS_1(_strength);
|
||||
GVAR(flashbangPPEffectCC) ppEffectAdjust [1,1,0,[1,1,1,0],[0,0,0,1],[0,0,0,0]];
|
||||
GVAR(flashbangPPEffectCC) ppEffectCommit (10 * _strength);
|
||||
}, [_strength], (7 * _strength), 0] call EFUNC(common,waitAndExecute);
|
||||
|
||||
//FULLRECOVERY - end effect
|
||||
[{
|
||||
GVAR(flashbangPPEffectCC) ppEffectEnable false;
|
||||
}, [], (17 * _strength), 0] call EFUNC(common,waitAndExecute);
|
||||
};
|
||||
};
|
||||
};
|
||||
|
@ -1,14 +1,21 @@
|
||||
//Waits for the grenade fuze to trigger and 'explode'
|
||||
|
||||
/*
|
||||
* Author: commy2
|
||||
* Waits for the flashbang grenade fuze to trigger and 'explode'
|
||||
*
|
||||
* Arguments:
|
||||
* 0: projectile - Flashbang Grenade <OBJECT>
|
||||
*
|
||||
* Return Value:
|
||||
* Nothing
|
||||
*
|
||||
* Example:
|
||||
* [theFlashbang] call ace_grenades_fnc_flashbangThrownFuze
|
||||
*
|
||||
* Public: No
|
||||
*/
|
||||
#include "script_component.hpp"
|
||||
|
||||
_projectile = (_this select 0) select 0;
|
||||
_waitUntilTime = (_this select 0) select 1;
|
||||
|
||||
if (_waitUntilTime > time) exitWith {};
|
||||
|
||||
//remove frameEH
|
||||
[(_this select 1)] call cba_fnc_removePerFrameHandler;
|
||||
PARAMS_1(_projectile);
|
||||
|
||||
if (alive _projectile) then {
|
||||
playSound3D ["A3\Sounds_F\weapons\Explosion\explosion_mine_1.wss", _projectile, false, getPosASL _projectile, 5, 1.2, 400];
|
||||
|
@ -1,21 +1,22 @@
|
||||
/*
|
||||
* Author: commy2
|
||||
*
|
||||
* Select the next throwing mode and display message.
|
||||
*
|
||||
* Argument:
|
||||
* Arguments:
|
||||
* Nothing
|
||||
*
|
||||
* Return value:
|
||||
* Nothing
|
||||
* Return Value:
|
||||
* Handeled <BOOL>
|
||||
*
|
||||
* Example:
|
||||
* [] call ace_grenades_fnc_nextMode
|
||||
*
|
||||
* Public: No
|
||||
*/
|
||||
|
||||
#include "script_component.hpp"
|
||||
|
||||
private ["_mode", "_hint"];
|
||||
|
||||
if (!([ACE_player] call EFUNC(common,canUseWeapon))) exitWith {false};
|
||||
|
||||
_mode = missionNamespace getVariable [QGVAR(currentThrowMode), 0];
|
||||
|
||||
if (_mode == 4) then {
|
||||
|
@ -1,15 +1,24 @@
|
||||
/*
|
||||
* Author: commy2
|
||||
*
|
||||
* Adjust the grenades throwing direction and speed to the selected throwing mode.
|
||||
*
|
||||
* Argument:
|
||||
* input from "Fired" eventhandler
|
||||
* Arguments:
|
||||
* 0: unit - Object the event handler is assigned to <OBJECT>
|
||||
* 1: weapon - Fired weapon <STRING>
|
||||
* 2: muzzle - Muzzle that was used <STRING>
|
||||
* 3: mode - Current mode of the fired weapon <STRING>
|
||||
* 4: ammo - Ammo used <STRING>
|
||||
* 5: magazine - magazine name which was used <STRING>
|
||||
* 6: projectile - Object of the projectile that was shot <OBJECT>
|
||||
*
|
||||
* Return value:
|
||||
* Return Value:
|
||||
* Nothing
|
||||
*
|
||||
* Example:
|
||||
* [clientFiredBIS-XEH] call ace_grenades_fnc_throwGrenade
|
||||
*
|
||||
* Public: No
|
||||
*/
|
||||
|
||||
#include "script_component.hpp"
|
||||
|
||||
private ["_unit", "_weapon", "_projectile", "_mode", "_fuzeTime"];
|
||||
@ -57,5 +66,5 @@ if (_mode != 0) then {
|
||||
if (typeOf _projectile == "ACE_G_M84") then {
|
||||
_fuzeTime = getNumber (configFile >> "CfgAmmo" >> typeOf _projectile >> "fuseDistance");
|
||||
// _fuzeTime = getNumber (configFile >> "CfgAmmo" >> typeOf _projectile >> "explosionTime"); //@toDo pretty sure this should be explosionTime not fuseDistance
|
||||
[FUNC(flashbangThrownFuze), 0, [_projectile, (time + _fuzeTime)]] call CBA_fnc_addPerFrameHandler;
|
||||
[FUNC(flashbangThrownFuze), [_projectile], _fuzeTime, 0] call EFUNC(common,waitAndExecute);
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user