Skip to content

Commit

Permalink
Merge pull request #874 from acemod/fragCleanup
Browse files Browse the repository at this point in the history
Frag cleanup
  • Loading branch information
ulteq committed Apr 30, 2015
2 parents e77ddcf + 2068eae commit d2aa287
Show file tree
Hide file tree
Showing 24 changed files with 92 additions and 184 deletions.
8 changes: 8 additions & 0 deletions addons/frag/ACE_Settings.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
class ACE_Settings {
class GVAR(enabled) {
displayName = "Frag System";
description = "Enables the shrapnel system for explosives";
typeName = "BOOL";
value = 1;
};
};
25 changes: 13 additions & 12 deletions addons/frag/CfgAmmo.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class CfgAmmo {
// GVAR(skip) = 1;
//};
class Bo_GBU12_LGB;
class Nou_GBU12 : Bo_GBU12_LGB {
class ACE_GBU12 : Bo_GBU12_LGB {
GVAR(classes)[] = {"ACE_frag_large", "ACE_frag_large", "ACE_frag_large_HD", "ACE_frag_large", "ACE_frag_huge", "ACE_frag_huge_HD", "ACE_frag_huge"};
GVAR(metal) = 140000;
GVAR(charge) = 87000;
Expand Down Expand Up @@ -72,26 +72,27 @@ class CfgAmmo {
GVAR(gurney_c) = 2320;
GVAR(gurney_k) = 1/2;
};


class G_40mm_HE: GrenadeBase {
GVAR(skip) = 0;
GVAR(force) = 1;
};

class ACE_G_40mm_HEDP: G_40mm_HE {

class G_40mm_HEDP: GrenadeBase {
// Source: http://www.inetres.com/gp/military/infantry/grenade/40mm_ammo.html#M433
GVAR(classes)[] = {"ACE_frag_tiny_HD"};
GVAR(metal) = 200;
GVAR(charge) = 45;
GVAR(gurney_c) = 2830;
GVAR(gurney_k) = 3/5;
GVAR(gurney_k) = 1/2;
};
class ACE_G_40mm_HE: ACE_G_40mm_HEDP {
class G_40mm_HE: GrenadeBase {
// Source: http://www.inetres.com/gp/military/infantry/grenade/40mm_ammo.html#M441
GVAR(classes)[] = {"ACE_frag_tiny_HD"};
GVAR(metal) = 200;
GVAR(charge) = 32;
GVAR(gurney_c) = 2700;
GVAR(gurney_k) = 3/5;
GVAR(gurney_k) = 1/2;
};

class ACE_G_40mm_HEDP: G_40mm_HEDP {
};
class ACE_G_40mm_HE: G_40mm_HE {
};
class ACE_G_40mm_Practice: ACE_G_40mm_HE {
GVAR(skip) = 1;
Expand Down
6 changes: 3 additions & 3 deletions addons/frag/CfgEventhandlers.hpp
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
class Extended_PreInit_EventHandlers {
class ADDON {
init = QUOTE(call COMPILE_FILE(XEH_pre_init));
init = QUOTE(call COMPILE_FILE(XEH_preInit));
};
};

class Extended_PostInit_EventHandlers {
class ADDON {
init = QUOTE(call COMPILE_FILE(XEH_post_init));
class ADDON {
init = QUOTE(call COMPILE_FILE(XEH_postInit));
};
};

Expand Down
Empty file removed addons/frag/CfgVehicles.hpp
Empty file.
5 changes: 5 additions & 0 deletions addons/frag/XEH_postInit.sqf
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#include "script_component.hpp"

if(isServer) then {
[QGVAR(frag_eh), { _this call FUNC(frago); }] call ace_common_fnc_addEventHandler;
};
18 changes: 0 additions & 18 deletions addons/frag/XEH_post_init.sqf

This file was deleted.

33 changes: 10 additions & 23 deletions addons/frag/XEH_pre_Init.sqf → addons/frag/XEH_preInit.sqf
Original file line number Diff line number Diff line change
@@ -1,48 +1,35 @@
#include "script_component.hpp"


ADDON = false;

PREP(doSpall);
PREP(fired);
PREP(frago);
PREP(trackFragRound);
PREP(spallTrack);
PREP(doSpall);
PREP(vectorDiffFast);
PREP(trackFragRound);

GVAR(trackedObjects) = [];
GVAR(blackList) = [];
GVAR(traceFrags) = false;

GVAR(replacedBisArtyWrapper) = true;
GVAR(trackedObjects) = [];

GVAR(TOTALFRAGS) = 0;

GVAR(spallIsTrackingCount) = 0;
GVAR(spallHPData) = [];
GVAR(spallIsTrackingCount) = 0;

GVAR(autoTrace) = true;
GVAR(traceID) = -1;
GVAR(traces) = [];
GVAR(tracesStarted) = false;
GVAR(traceID) = -1;
GVAR(autoTrace) = true;

// TODO setting
GVAR(enabled) = true;


// * Other Shit */
PREP(frag_trace);
PREP(denyFrag);
PREP(BIS_ARTY_WRAPPER);
PREP(startTracing);
PREP(stopTracing);
PREP(clearTraces);
PREP(trackTrace);
PREP(addBlackList);
PREP(addTrack);
PREP(drawTraces);
PREP(removeTrack);
PREP(spallHP);
PREP(addBlackList);
PREP(addManualTrack);
PREP(startTracing);
PREP(stopTracing);
PREP(trackTrace);

ADDON = true;
3 changes: 1 addition & 2 deletions addons/frag/config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ class CfgPatches {
};
};

//PRELOAD_ADDONS;

#include "CfgEventhandlers.hpp"
#include "CfgAmmo.hpp"
#include "ACE_Settings.hpp"
13 changes: 0 additions & 13 deletions addons/frag/functions/fnc_BIS_ARTY_WRAPPER.sqf

This file was deleted.

6 changes: 3 additions & 3 deletions addons/frag/functions/fnc_addBlackList.sqf
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include "script_component.hpp"
private ["_round"];
_round = _this select 0;
#include "script_component.hpp"
private ["_round"];
_round = _this select 0;
GVAR(blackList) set[(count GVAR(blackList)), _round];
7 changes: 0 additions & 7 deletions addons/frag/functions/fnc_addManualTrack.sqf

This file was deleted.

15 changes: 9 additions & 6 deletions addons/frag/functions/fnc_addTrack.sqf
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
#include "script_component.hpp"
if(GVAR(autoTrace)) then {

private ["_color", "_data", "_index", "_obj", "_objSpd", "_origin", "_positions"];

if (GVAR(autoTrace)) then {
[] call FUNC(startTracing);
};

Expand All @@ -12,9 +15,9 @@ if((count _this) > 2) then {
_color = _this select 2;
};
_positions = [];
_objVel = velocity _obj;
_objTVel = sqrt((_objVel select 0)^2 + (_objVel select 1)^2 + (_objVel select 2)^2);
_positions set[(count _positions), [(getPos _obj), _objTVel]];
_data = [_origin, typeOf _origin, typeOf _obj, _objTVel, _positions, _color];
_objSpd = vectorMagnitude (velocity _obj);
_positions set[(count _positions), [(getPos _obj), _objSpd]];
_data = [_origin, typeOf _origin, typeOf _obj, _objSpd, _positions, _color];

GVAR(traces) set[_index, _data];
[DFUNC(trackTrace), 0, [_obj, _index, time]] call cba_fnc_addPerFrameHandler;
[DFUNC(trackTrace), 0, [_obj, _index, time]] call cba_fnc_addPerFrameHandler;
2 changes: 0 additions & 2 deletions addons/frag/functions/fnc_clearTraces.sqf

This file was deleted.

7 changes: 0 additions & 7 deletions addons/frag/functions/fnc_denyFrag.sqf

This file was deleted.

21 changes: 6 additions & 15 deletions addons/frag/functions/fnc_doSpall.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,12 @@
#ifdef DEBUG_MODE_FULL
GVAR(traceFrags) = true;
#endif
// ACE_player sideChat "WAAAAAAAAAAAAAAAAAAAAA";
// ACE_player sideChat "WAAAAAAAAAAAAAAAAAAAAA";
private ["_params", "_initialData", "_hpData", "_roundType", "_round", "_object", "_caliber", "_explosive",
"_idh", "_alive", "_exit", "_vm", "_velocity", "_unitDir", "_oldVelocity", "_curVelocity", "_diff", "_polar",
"_pos", "_spallPos", "_i", "_pos1", "_pos2", "_blah", "_data", "_spallPolar", "_c", "_warn", "_m", "_k",
"_gC", "_shellType", "_fragPower", "_spread", "_spallCount", "_elev", "_dir", "_vel", "_spallFragVect",
"_fragment"];

"_fragment", "_index", "_hitData", "_fragTypes", "_fragType", "_foundObjects"];

_params = _this select 0;
[(_this select 1)] call cba_fnc_removePerFrameHandler;
Expand Down Expand Up @@ -45,8 +44,8 @@ if(_alive || {_caliber >= 2.5} || {(_explosive > 0 && {_idh >= 1})}) then {
_vm = 1;
_velocity = _initialData select 5;

_oldVelocity = _velocity call BIS_fnc_magnitude;
_curVelocity = (velocity _round) call BIS_fnc_magnitude;
_oldVelocity = vectorMagnitude _velocity;
_curVelocity = vectorMagnitude (velocity _round);

if(alive _round) then {
_diff = _velocity vectorDiff (velocity _round);
Expand All @@ -66,16 +65,8 @@ if(_alive || {_caliber >= 2.5} || {(_explosive > 0 && {_idh >= 1})}) then {
_pos = _hpData select 3;
_spallPos = nil;
for "_i" from 0 to 100 do {
_pos1 = [
(_pos select 0) + (((_unitDir select 0)*0.01)*_i),
(_pos select 1) + (((_unitDir select 1)*0.01)*_i),
(_pos select 2) + (((_unitDir select 2)*0.01)*_i)
];
_pos2 = [
(_pos select 0) + (((_unitDir select 0)*0.01)*(_i+1)),
(_pos select 1) + (((_unitDir select 1)*0.01)*(_i+1)),
(_pos select 2) + (((_unitDir select 2)*0.01)*(_i+1))
];
_pos1 = _pos vectorAdd (_unitDir vectorMultiply (0.01 * _i));
_pos2 = _pos vectorAdd (_unitDir vectorMultiply (0.01 * (_i + 1)));
// _blah = [_object, "FIRE"] intersect [_object worldToModel (ASLtoATL _pos1), _object worldToModel (ASLtoATL _pos2)];
// diag_log text format["b: %1", _blah];

Expand Down
10 changes: 5 additions & 5 deletions addons/frag/functions/fnc_drawTraces.sqf
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
#include "script_component.hpp"

private ["_color", "_index", "_lastPos", "_lastSpd", "_max", "_positions", "_startSpeed"];

{
_positions = _x select 4;
_color = _x select 5;
_index = 0;
_max = count _positions;
_startSpeed = (_positions select 0) select 1;
if(_startSpeed <= 0) then {
_startSpeed = 0.01;
};
_startSpeed = 0.01 max ((_positions select 0) select 1);
_lastSpd = [];
_lastPos = [];
while {_index < _max} do {
Expand All @@ -29,4 +29,4 @@
_lastSpd = _data1 select 1;
};
// drawIcon3D ["", [1,0,0,1], _lastPos, 0, 0, 0, format["%1m/s", _lastSpd], 1, 0.05, "PuristaMedium"];
} forEach GVAR(traces);
} forEach GVAR(traces);
6 changes: 4 additions & 2 deletions addons/frag/functions/fnc_fired.sqf
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#include "script_component.hpp"
private ["_gun", "_type", "_round", "_doFragTrack", "_doSpall"];
if !(!isNil QGVAR(enabled) && {GVAR(enabled)}) exitWith {};

private ["_gun", "_type", "_round", "_doFragTrack", "_doSpall", "_spallTrack", "_spallTrackID"];

if (!GVAR(enabled)) exitWith {};

_gun = _this select 0;
_type = _this select 4;
Expand Down
10 changes: 0 additions & 10 deletions addons/frag/functions/fnc_frag_trace.sqf

This file was deleted.

18 changes: 5 additions & 13 deletions addons/frag/functions/fnc_frago.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ private ["_round", "_lastPos", "_lastVel", "_shellType", "_gun", "_fragTypes", "
"_manObjects", "_objects", "_crew", "_fragCount", "_fragArcs", "_doRandom", "_target", "_boundingBox",
"_targetPos", "_distance", "_add", "_bbX", "_bbY", "_bbZ", "_cubic", "_targetVel", "_baseVec", "_dir",
"_currentCount", "_count", "_vecVar", "_i", "_vec", "_fp", "_vel", "_fragType", "_fragObj", "_randomCount",
"_sectorSize", "_sectorOffset", "_randomDir"];
"_sectorSize", "_sectorOffset", "_randomDir", "_endTime"];


_round = _this select 0;
Expand Down Expand Up @@ -159,11 +159,7 @@ if(_isArmed && (count _objects) > 0) then {
_vec set[2, (_vec select 2)-(_vecVar/2)+(random _vecVar)];

_fp = (_fragPower-(random (_fragPowerRandom)));
_vel = [
(_vec select 0)*_fp,
(_vec select 1)*_fp,
(_vec select 2)*_fp
];
_vel = _vec vectorMultiply _fp;

_fragType = round (random ((count _fragTypes)-1));
_fragObj = (_fragTypes select _fragType) createVehicleLocal [0,0,10000];
Expand Down Expand Up @@ -198,14 +194,10 @@ if(_isArmed && (count _objects) > 0) then {
_sectorOffset = 360 * (_i - 1) / (_randomCount max 1);
_randomDir = random(_sectorSize);
_vec = [cos(_sectorOffset + _randomDir), sin(_sectorOffset + _randomDir), sin(30 - (random 45))];

_fp = (_fragPower-(random (_fragPowerRandom)));

_vel = [
(_vec select 0)*_fp,
(_vec select 1)*_fp,
(_vec select 2)*_fp
];

_vel = _vec vectorMultiply _fp;

_fragType = round (random ((count _fragTypes)-1));
_fragObj = (_fragTypes select _fragType) createVehicleLocal [0,0,10000];
Expand Down
Loading

0 comments on commit d2aa287

Please sign in to comment.