Code Cleanup Grenades, fix dedicated server AI thrown flasbangs do nothing

This commit is contained in:
commy2 2015-09-26 22:39:12 +02:00
parent f77242fce3
commit 6cc920dc34
7 changed files with 41 additions and 27 deletions

View File

@ -1,3 +1,4 @@
class CfgAmmo { class CfgAmmo {
class FlareCore; class FlareCore;
class FlareBase: FlareCore { class FlareBase: FlareCore {

View File

@ -1,19 +1,20 @@
class Extended_PreInit_EventHandlers { class Extended_PreInit_EventHandlers {
class ADDON { class ADDON {
init = QUOTE( call COMPILE_FILE(XEH_preInit) ); init = QUOTE(call COMPILE_FILE(XEH_preInit));
}; };
}; };
class Extended_PostInit_EventHandlers { class Extended_PostInit_EventHandlers {
class ADDON { class ADDON {
init = QUOTE( call COMPILE_FILE(XEH_postInit) ); init = QUOTE(call COMPILE_FILE(XEH_postInit));
}; };
}; };
class Extended_FiredBIS_EventHandlers { class Extended_FiredBIS_EventHandlers {
class CAManBase { class CAManBase {
class ADDON { class ADDON {
clientFiredBIS = QUOTE( _this call FUNC(throwGrenade) ); firedBIS = QUOTE(_this call FUNC(throwGrenade));
}; };
}; };
}; };

View File

@ -1,9 +1,6 @@
class CfgVehicles { class CfgVehicles {
class NATO_Box_Base; class NATO_Box_Base;
class EAST_Box_Base;
class IND_Box_Base;
class Box_NATO_Support_F;
class Box_NATO_Grenades_F: NATO_Box_Base { class Box_NATO_Grenades_F: NATO_Box_Base {
class TransportItems { class TransportItems {
MACRO_ADDITEM(ACE_HandFlare_White,12); MACRO_ADDITEM(ACE_HandFlare_White,12);
@ -12,6 +9,7 @@ class CfgVehicles {
}; };
}; };
class EAST_Box_Base;
class Box_East_Grenades_F: EAST_Box_Base { class Box_East_Grenades_F: EAST_Box_Base {
class TransportItems { class TransportItems {
MACRO_ADDITEM(ACE_HandFlare_Yellow,12); MACRO_ADDITEM(ACE_HandFlare_Yellow,12);
@ -20,6 +18,7 @@ class CfgVehicles {
}; };
}; };
class IND_Box_Base;
class Box_IND_Grenades_F: IND_Box_Base { class Box_IND_Grenades_F: IND_Box_Base {
class TransportItems { class TransportItems {
MACRO_ADDITEM(ACE_HandFlare_Yellow,12); MACRO_ADDITEM(ACE_HandFlare_Yellow,12);
@ -28,6 +27,7 @@ class CfgVehicles {
}; };
}; };
class Box_NATO_Support_F;
class ACE_Box_Misc: Box_NATO_Support_F { class ACE_Box_Misc: Box_NATO_Support_F {
class TransportItems { class TransportItems {
MACRO_ADDITEM(ACE_HandFlare_White,12); MACRO_ADDITEM(ACE_HandFlare_White,12);

View File

@ -1,21 +1,26 @@
class CfgWeapons { class CfgWeapons {
class GrenadeLauncher; class GrenadeLauncher;
class Throw: GrenadeLauncher { class Throw: GrenadeLauncher {
muzzles[] += {"ACE_HandFlare_WhiteMuzzle", "ACE_HandFlare_RedMuzzle", "ACE_HandFlare_GreenMuzzle", "ACE_HandFlare_YellowMuzzle", "ACE_M84Muzzle"}; muzzles[] += {"ACE_HandFlare_WhiteMuzzle","ACE_HandFlare_RedMuzzle","ACE_HandFlare_GreenMuzzle","ACE_HandFlare_YellowMuzzle","ACE_M84Muzzle"};
class ThrowMuzzle; class ThrowMuzzle;
class ACE_HandFlare_WhiteMuzzle: ThrowMuzzle { class ACE_HandFlare_WhiteMuzzle: ThrowMuzzle {
magazines[] = {"ACE_HandFlare_White"}; magazines[] = {"ACE_HandFlare_White"};
}; };
class ACE_HandFlare_RedMuzzle: ThrowMuzzle { class ACE_HandFlare_RedMuzzle: ThrowMuzzle {
magazines[] = {"ACE_HandFlare_Red"}; magazines[] = {"ACE_HandFlare_Red"};
}; };
class ACE_HandFlare_GreenMuzzle: ThrowMuzzle { class ACE_HandFlare_GreenMuzzle: ThrowMuzzle {
magazines[] = {"ACE_HandFlare_Green"}; magazines[] = {"ACE_HandFlare_Green"};
}; };
class ACE_HandFlare_YellowMuzzle: ThrowMuzzle { class ACE_HandFlare_YellowMuzzle: ThrowMuzzle {
magazines[] = {"ACE_HandFlare_Yellow"}; magazines[] = {"ACE_HandFlare_Yellow"};
}; };
class ACE_M84Muzzle: ThrowMuzzle { class ACE_M84Muzzle: ThrowMuzzle {
magazines[] = {"ACE_M84"}; magazines[] = {"ACE_M84"};
}; };

View File

@ -2,7 +2,7 @@
#include "script_component.hpp" #include "script_component.hpp"
["flashbangExplosion", DFUNC(flashbangExplosionEH)] call EFUNC(common,addEventHandler); ["flashbangExplosion", {_this call FUNC(flashbangExplosionEH)}] call EFUNC(common,addEventHandler);
if (!hasInterface) exitWith {}; if (!hasInterface) exitWith {};
@ -21,4 +21,4 @@ GVAR(flashbangPPEffectCC) ppEffectForceInNVG true;
[] call FUNC(nextMode); [] call FUNC(nextMode);
}, },
{false}, {false},
[9, [false, false, false]], false] call cba_fnc_addKeybind; //8 Key [9, [false, false, false]], false] call CBA_fnc_addKeybind; //8 Key

View File

@ -15,13 +15,14 @@
*/ */
#include "script_component.hpp" #include "script_component.hpp"
private ["_affected", "_strength", "_posGrenade", "_angleDiff", "_light", "_losCount", "_dirToUnitVector", "_eyeDir", "_eyePos"];
params ["_grenade"]; params ["_grenade"];
private ["_affected", "_strength", "_posGrenade", "_eyePos", "_losCount", "_eyeDir", "_dirToUnitVector", "_angleDiff", "_light"];
_affected = _grenade nearEntities ["CAManBase", 20]; _affected = _grenade nearEntities ["CAManBase", 20];
{ {
if ((local _x) && {alive _x}) then { if (local _x && {alive _x}) then {
_strength = 1 - ((_x distance _grenade) min 15) / 15; _strength = 1 - ((_x distance _grenade) min 15) / 15;
@ -30,14 +31,17 @@ _affected = _grenade nearEntities ["CAManBase", 20];
if (_x != ACE_player) then { if (_x != ACE_player) then {
//must be AI //must be AI
[_x, true] call EFUNC(common,disableAI); [_x, true] call EFUNC(common,disableAI);
_x setSkill ((skill _x) / 50);
_x setSkill (skill _x / 50);
[{ [{
params ["_unit"]; params ["_unit"];
//Make sure we don't enable AI for unconscious units //Make sure we don't enable AI for unconscious units
if (!(_unit getVariable ["ace_isunconscious", false])) then { if (!(_unit getVariable ["ace_isUnconscious", false])) then {
[_unit, false] call EFUNC(common,disableAI); [_unit, false] call EFUNC(common,disableAI);
}; };
_unit setSkill (skill _unit * 50); _unit setSkill (skill _unit * 50);
}, [_x], (7 * _strength)] call EFUNC(common,waitAndExecute); }, [_x], (7 * _strength)] call EFUNC(common,waitAndExecute);
} else { } else {
@ -49,7 +53,7 @@ _affected = _grenade nearEntities ["CAManBase", 20];
//Check for line of sight (check 4 points in case grenade is stuck in an object or underground) //Check for line of sight (check 4 points in case grenade is stuck in an object or underground)
_losCount = { _losCount = {
(!lineIntersects [(_posGrenade vectorAdd _x), _eyePos, _grenade, ACE_player]) !lineIntersects [_posGrenade vectorAdd _x, _eyePos, _grenade, ACE_player]
} count [[0,0,0], [0,0,0.2], [0.1, 0.1, 0.1], [-0.1, -0.1, 0.1]]; } count [[0,0,0], [0,0,0.2], [0.1, 0.1, 0.1], [-0.1, -0.1, 0.1]];
TRACE_1("Line of sight count (out of 4)",_losCount); TRACE_1("Line of sight count (out of 4)",_losCount);
@ -57,9 +61,9 @@ _affected = _grenade nearEntities ["CAManBase", 20];
_strength = _strength / 10; _strength = _strength / 10;
}; };
//Add ace_hearing ear ringing sound effect // add ace_hearing ear ringing sound effect
if ((isClass (configFile >> "CfgPatches" >> "ACE_Hearing")) && {_strength > 0}) then { if (isClass (configFile >> "CfgPatches" >> "ACE_Hearing") && {_strength > 0}) then {
[_x, (20 * _strength)] call EFUNC(hearing,earRinging); [_x, 20 * _strength] call EFUNC(hearing,earRinging);
}; };
// account for people looking away by slightly // account for people looking away by slightly
@ -68,16 +72,16 @@ _affected = _grenade nearEntities ["CAManBase", 20];
_dirToUnitVector = _eyePos vectorFromTo _posGrenade; _dirToUnitVector = _eyePos vectorFromTo _posGrenade;
_angleDiff = acos (_eyeDir vectorDotProduct _dirToUnitVector); _angleDiff = acos (_eyeDir vectorDotProduct _dirToUnitVector);
//From 0-45deg, full effect // from 0-45deg, full effect
if (_angleDiff > 45) then { if (_angleDiff > 45) then {
_strength = _strength - _strength * ((_angleDiff - 45) / 120); _strength = _strength - _strength * ((_angleDiff - 45) / 120);
}; };
TRACE_1("Final strength for player",_strength); TRACE_1("Final strength for player",_strength);
//Add ace_medical pain effect: // add ace_medical pain effect:
if ((isClass (configFile >> "CfgPatches" >> "ACE_Medical")) && {_strength > 0.1}) then { if (isClass (configFile >> "CfgPatches" >> "ACE_Medical") && {_strength > 0.1}) then {
[ACE_player, (_strength / 2)] call EFUNC(medical,adjustPainLevel); [ACE_player, _strength / 2] call EFUNC(medical,adjustPainLevel);
}; };
// create flash to illuminate environment // create flash to illuminate environment
@ -87,14 +91,14 @@ _affected = _grenade nearEntities ["CAManBase", 20];
_light setLightColor [1,1,1]; _light setLightColor [1,1,1];
_light setLightDayLight true; _light setLightDayLight true;
//Delete the light after 0.1 seconds // delete the light after 0.1 seconds
[{ [{
params ["_light"]; params ["_light"];
deleteVehicle _light; deleteVehicle _light;
}, [_light], 0.1] call EFUNC(common,waitAndExecute); }, [_light], 0.1] call EFUNC(common,waitAndExecute);
// blind player // blind player
if (_strength > 0.1 && hasInterface) then { if (hasInterface && {_strength > 0.1}) then {
GVAR(flashbangPPEffectCC) ppEffectEnable true; GVAR(flashbangPPEffectCC) ppEffectEnable true;
GVAR(flashbangPPEffectCC) ppEffectAdjust [1,1,(0.8 + _strength) min 1,[1,1,1,0],[0,0,0,1],[0,0,0,0]]; 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; GVAR(flashbangPPEffectCC) ppEffectCommit 0.01;
@ -102,14 +106,15 @@ _affected = _grenade nearEntities ["CAManBase", 20];
//PARTIALRECOVERY - start decreasing effect over ACE_time //PARTIALRECOVERY - start decreasing effect over ACE_time
[{ [{
params ["_strength"]; params ["_strength"];
GVAR(flashbangPPEffectCC) ppEffectAdjust [1,1,0,[1,1,1,0],[0,0,0,1],[0,0,0,0]]; GVAR(flashbangPPEffectCC) ppEffectAdjust [1,1,0,[1,1,1,0],[0,0,0,1],[0,0,0,0]];
GVAR(flashbangPPEffectCC) ppEffectCommit (10 * _strength); GVAR(flashbangPPEffectCC) ppEffectCommit (10 * _strength);
}, [_strength], (7 * _strength), 0] call EFUNC(common,waitAndExecute); }, [_strength], 7 * _strength] call EFUNC(common,waitAndExecute);
//FULLRECOVERY - end effect //FULLRECOVERY - end effect
[{ [{
GVAR(flashbangPPEffectCC) ppEffectEnable false; GVAR(flashbangPPEffectCC) ppEffectEnable false;
}, [], (17 * _strength)] call EFUNC(common,waitAndExecute); }, [], 17 * _strength] call EFUNC(common,waitAndExecute);
}; };
}; };
}; };

View File

@ -14,6 +14,7 @@
* Public: No * Public: No
*/ */
#include "script_component.hpp" #include "script_component.hpp"
params ["_projectile"]; params ["_projectile"];
if (alive _projectile) then { if (alive _projectile) then {
@ -21,5 +22,6 @@ if (alive _projectile) then {
private "_affected"; private "_affected";
_affected = _projectile nearEntities ["CAManBase", 50]; _affected = _projectile nearEntities ["CAManBase", 50];
["flashbangExplosion", _affected, [_projectile]] call EFUNC(common,targetEvent); ["flashbangExplosion", _affected, [_projectile]] call EFUNC(common,targetEvent);
}; };