Merge pull request #874 from acemod/fragCleanup

Frag cleanup
This commit is contained in:
ulteq 2015-04-30 10:35:25 +02:00
commit d2aa28715d
24 changed files with 92 additions and 184 deletions

View File

@ -0,0 +1,8 @@
class ACE_Settings {
class GVAR(enabled) {
displayName = "Frag System";
description = "Enables the shrapnel system for explosives";
typeName = "BOOL";
value = 1;
};
};

View File

@ -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;
@ -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;

View File

@ -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));
};
};

View File

@ -0,0 +1,5 @@
#include "script_component.hpp"
if(isServer) then {
[QGVAR(frag_eh), { _this call FUNC(frago); }] call ace_common_fnc_addEventHandler;
};

View File

@ -1,18 +0,0 @@
#include "script_component.hpp"
if(isServer) then {
[QGVAR(frag_eh), { _this call FUNC(frago); }] call ace_common_fnc_addEventHandler;
};
/*
GVAR(replacedBisArtyWrapper) = false;
[] spawn {
waitUntil {
if(!(isNil "BIS_ARTY_F_ShellFlight")) then {
ACE_WRAPPER_BIS_ARTY_F_ShellFlight = BIS_ARTY_F_ShellFlight;
BIS_ARTY_F_ShellFlight = FUNC(BIS_ARTY_WRAPPER);
GVAR(replacedBisArtyWrapper) = true;
};
sleep 4;
GVAR(replacedBisArtyWrapper)
};
};
*/

View File

@ -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;

View File

@ -10,7 +10,6 @@ class CfgPatches {
};
};
//PRELOAD_ADDONS;
#include "CfgEventhandlers.hpp"
#include "CfgAmmo.hpp"
#include "ACE_Settings.hpp"

View File

@ -1,13 +0,0 @@
#include "script_component.hpp"
_ret = [(_this select 6)] call FUNC(removeTrack);
if(!_ret) then {
[(_this select 6)] call FUNC(addBlackList);
};
_this call ACE_WRAPPER_BIS_ARTY_F_ShellFlight;
_catEntry = BIS_ARTY_SHELLCAT select ((count BIS_ARTY_SHELLCAT) - 1);
_shell = _catEntry select 0;
_ARTY_DeployOnImpact = getText (configFile >> "CfgAmmo" >> "ARTY_DeployOnImpact");
if(_ARTY_DeployOnImpact == "") then {
_this set[6, _shell];
_this call FUNC(fired);
};

View File

@ -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];

View File

@ -1,7 +0,0 @@
#include "script_component.hpp"
private ["_round"];
_round = _this select 0;
if(alive _round) then {
GVAR(trackedObjects) set[(count GVAR(trackedObjects)), _round];
[DFUNC(trackFragRound), 0, [_round, (getPosASL _round), (velocity _round), (typeOf _round), time, objNull, false, 0, 0]] call cba_fnc_addPerFrameHandler;
};

View File

@ -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);
};
@ -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;

View File

@ -1,2 +0,0 @@
#include "script_component.hpp"
GVAR(traces) = [];

View File

@ -1,7 +0,0 @@
#include "script_component.hpp"
private ["_ret"];
_ret = [(_this select 0)] call FUNC(removeTrack);
if(!_ret) then {
[(_this select 0)] call FUNC(addBlackList);
};

View File

@ -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;
@ -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);
@ -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];

View File

@ -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 {
@ -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);

View File

@ -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;

View File

@ -1,10 +0,0 @@
#include "script_component.hpp"
private ["_params", "_shell"];
_params = _this select 0;
_shell = _params select 0;
if(alive _shell) then {
drop ["\Ca\Data\Cl_basic","","Billboard",1,30,(getPos _shell),[0,0,0],1,1.275,1.0,0.0,[0.5],[[0,1,0,1]],[0],0.0,2.0,"","",""];
} else {
[_this select 1] call cba_fnc_removePerFrameHandler;
};

View File

@ -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;
@ -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];
@ -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];

View File

@ -1,15 +1,15 @@
#include "script_component.hpp"
private ["_initialData", "_currentCount", "_hpData", "_round", "_hpRound"];
private ["_initialData", "_hpData", "_round", "_hpRound", "_hpDirect"];
//player sideChat format["f: %1 c: %2", (_this select 0), (count GVAR(spallHPData))];
if((_this select 0) <= (count GVAR(spallHPData))) then {
if ((_this select 0) <= (count GVAR(spallHPData))) then {
_initialData = GVAR(spallHPData) select (_this select 0);
if(!isNil "_initialData") then {
if (!isNil "_initialData") then {
_hpRound = ((_this select 1) select 0) select 2;
_round = _initialData select 3;
_hpDirect = ((_this select 1) select 0) select 10;
if(_hpDirect && {_round == _hpRound}) then {
if (_hpDirect && {_round == _hpRound}) then {
{
_hpData = _x;
_round = _initialData select 3;
@ -26,4 +26,4 @@ if((_this select 0) <= (count GVAR(spallHPData))) then {
} forEach (_this select 1);
};
};
};
};

View File

@ -1,30 +1,22 @@
//fnc_spallTrack.sqf
#include "script_component.hpp"
private ["_params", "_round", "_multiplier", "_delta", "_curPos", "_velocity", "_velocityStep", "_forwardPos", "_intersectsWith", "_index", "_i", "_test", "_hpId", "_data"];
// setAccTime 0;
private ["_round", "_multiplier", "_foundObjects", "_foundObjectHPIds", "_delta", "_curPos", "_velocity", "_velocityStep", "_forwardPos", "_intersectsWith", "_index", "_hpId", "_data"];
_round = _this select 0;
_multiplier = _this select 1;
_foundObjects = _this select 2;
_foundObjectHPIds = _this select 3;
_delta = (1/diag_fps)*_multiplier;
_delta = (1/diag_fps) * _multiplier;
_curPos = getPosASL _round;
_velocity = velocity _round;
_velocityStep = [
(_velocity select 0)*_delta,
(_velocity select 1)*_delta,
(_velocity select 2)*_delta
];
_forwardPos = [
(_curPos select 0) + (_velocityStep select 0),
(_curPos select 1) + (_velocityStep select 1),
(_curPos select 2) + (_velocityStep select 2)
];
_velocityStep = _velocity vectorMultiply _delta;
_forwardPos = _curPos vectorAdd _velocityStep;
_intersectsWith = lineIntersectsWith [_curPos, _forwardPos];
if(count _intersectsWith > 0) then {
if (count _intersectsWith > 0) then {
// player sideChat format["inter: %1", _intersectsWith];
{
if(!(_x in _foundObjects)) then {
@ -37,4 +29,4 @@ if(count _intersectsWith > 0) then {
GVAR(spallHPData) set[_index, _data];
};
} forEach _intersectsWith;
};
};

View File

@ -1,6 +1,6 @@
//fnc_trackFragRound.sqf
#include "script_component.hpp"
private ["_params", "_round", "_lastPos", "_lastVel", "_type", "_time", "_doSpall", "_skip", "_explosive", "_indirectRange", "_force", "_fragPower"];
private ["_params", "_round", "_lastPos", "_lastVel", "_type", "_time", "_doSpall", "_spallTrack", "_foundObjectHPIds", "_skip", "_explosive", "_indirectRange", "_force", "_fragPower"];
_params = _this select 0;
_round = _params select 0;
_lastPos = _params select 1;

View File

@ -1,14 +1,14 @@
#include "script_component.hpp"
private ["_params", "_tracerObj", "_index", "_positions"];
_params = _this select 0;
_tracerObj = _params select 0;
_index = _params select 1;
if(alive _tracerObj && (count GVAR(traces)) > 0) then {
if (alive _tracerObj && (count GVAR(traces)) > 0) then {
_data = GVAR(traces) select _index;
_positions = _data select 4;
_objVel = velocity _tracerObj;
_objTVel = sqrt((_objVel select 0)^2 + (_objVel select 1)^2 + (_objVel select 2)^2);
_positions set[(count _positions), [(getPos _tracerObj), _objTVel]];
_positions set[(count _positions), [(getPos _tracerObj), vectorMagnitude (velocity _tracerObj)]];
} else {
[(_this select 1)] call cba_fnc_removePerFrameHandler;
};
};

View File

@ -1,15 +0,0 @@
#include "script_component.hpp"
private["_p1","_p2","_return"];
_p1 = _this select 0;
_p2 = _this select 1;
if ((count _p1) != (count _p2)) then {textLogFormat ["BIS_FNC Error: vectors not of same size"]};
_return = [];
{
_return set[_forEachIndex, (_p2 select _forEachIndex) - _x];
} forEach _p1;
_return