Cleanup Frag Component (#4581)

* Cleanup frag component

* Optimize fnc_addTrack

* Add additional cleanup

* Please work?

* Add more cleanup

* Fix script errors

* Fix/optimize spalling

* Add missing changes
This commit is contained in:
Ozan Eğitmen 2016-10-27 01:16:31 +03:00 committed by Glowbal
parent a13441fa85
commit 49b5a0ea86
32 changed files with 441 additions and 504 deletions

View File

@ -34,7 +34,6 @@ class ACE_Settings {
typeName = "SCALAR"; typeName = "SCALAR";
value = 50; value = 50;
}; };
class GVAR(enableDebugTrace) { class GVAR(enableDebugTrace) {
category = CSTRING(Module_DisplayName); category = CSTRING(Module_DisplayName);
displayName = CSTRING(EnableDebugTrace); displayName = CSTRING(EnableDebugTrace);

View File

@ -1,6 +1,6 @@
#define BASE_DRAG -0.01 #define BASE_DRAG -0.01
#define HD_MULT 5 #define HD_MULT 5
#define BASE_DRAG_HD (BASE_DRAG*HD_MULT) #define BASE_DRAG_HD (BASE_DRAG * HD_MULT)
class CfgAmmo { class CfgAmmo {
//class ace_arty_105mm_m1_m782_time; //class ace_arty_105mm_m1_m782_time;
@ -104,10 +104,8 @@ class CfgAmmo {
GVAR(gurney_k) = 1/2; GVAR(gurney_k) = 1/2;
}; };
class ACE_G_40mm_HEDP: G_40mm_HEDP { class ACE_G_40mm_HEDP: G_40mm_HEDP {};
}; class ACE_G_40mm_HE: G_40mm_HE {};
class ACE_G_40mm_HE: G_40mm_HE {
};
class ACE_G_40mm_Practice: ACE_G_40mm_HE { class ACE_G_40mm_Practice: ACE_G_40mm_HE {
GVAR(skip) = 1; GVAR(skip) = 1;
GVAR(force) = 0; GVAR(force) = 0;
@ -438,8 +436,6 @@ class CfgAmmo {
indirectHitRange = 0.25; indirectHitRange = 0.25;
airFriction = BASE_DRAG_HD*0.65; airFriction = BASE_DRAG_HD*0.65;
caliber = 2; caliber = 2;
}; };
class GVAR(huge): GVAR(large) { class GVAR(huge): GVAR(large) {

View File

@ -1,5 +1,3 @@
//CfgAmmoReflections.hpp
#define ACE_EXPLOSION_REFLECTION(range, hit)\ #define ACE_EXPLOSION_REFLECTION(range, hit)\
class ace_explosion_reflection_##range##_##hit : ace_explosion_reflection_base {\ class ace_explosion_reflection_##range##_##hit : ace_explosion_reflection_base {\
indirectHitRange = range;\ indirectHitRange = range;\

View File

@ -1,4 +1,3 @@
class Extended_PreStart_EventHandlers { class Extended_PreStart_EventHandlers {
class ADDON { class ADDON {
init = QUOTE(call COMPILE_FILE(XEH_preStart)); init = QUOTE(call COMPILE_FILE(XEH_preStart));

View File

@ -22,7 +22,6 @@ PREP(addPfhRound);
PREP(removePfhRound); // THIS SHOULD ABE USED SPARINGLY PREP(removePfhRound); // THIS SHOULD ABE USED SPARINGLY
// Explosive Reflection // Explosive Reflection
GVAR(replacedBisArtyWrapper) = true;
PREP(findReflections); PREP(findReflections);
PREP(doExplosions); PREP(doExplosions);
PREP(doReflections); PREP(doReflections);

View File

@ -1,16 +1,15 @@
#include "script_component.hpp" #include "script_component.hpp"
if(GVAR(EnableDebugTrace) && !isMultiplayer) then { if (GVAR(EnableDebugTrace) && {!isMultiplayer}) then {
GVAR(traceFrags) = true; GVAR(traceFrags) = true;
GVAR(autoTrace) = true; GVAR(autoTrace) = true;
}; };
if(isServer) then { if (isServer) then {
[QGVAR(frag_eh), { _this call FUNC(frago); }] call CBA_fnc_addEventHandler; [QGVAR(frag_eh), {_this call FUNC(frago);}] call CBA_fnc_addEventHandler;
}; };
["ace_settingsInitialized", { ["ace_settingsInitialized", {
//If not enabled, exit
if (!GVAR(enabled)) exitWith {}; if (!GVAR(enabled)) exitWith {};
// Register fire event handler // Register fire event handler
@ -20,9 +19,8 @@ if(isServer) then {
["ace_firedNonPlayerVehicle", DFUNC(fired)] call CBA_fnc_addEventHandler; ["ace_firedNonPlayerVehicle", DFUNC(fired)] call CBA_fnc_addEventHandler;
[FUNC(masterPFH), 0, []] call CBA_fnc_addPerFrameHandler; [FUNC(masterPFH), 0, []] call CBA_fnc_addPerFrameHandler;
}] call CBA_fnc_addEventHandler; }] call CBA_fnc_addEventHandler;
//Cache for ammo type configs // Cache for ammo type configs
GVAR(cacheRoundsTypesToTrack) = createLocation ["ACE_HashLocation", [-10000,-10000,-10000], 0, 0]; GVAR(cacheRoundsTypesToTrack) = createLocation ["ACE_HashLocation", [-10000, -10000, -10000], 0, 0];
GVAR(cacheRoundsTypesToTrack) setText QGVAR(cacheRoundsTypesToTrack); GVAR(cacheRoundsTypesToTrack) setText QGVAR(cacheRoundsTypesToTrack);

View File

@ -4,10 +4,11 @@ ADDON = false;
#include "XEH_PREP.hpp" #include "XEH_PREP.hpp"
GVAR(replacedBisArtyWrapper) = true;
GVAR(blackList) = []; GVAR(blackList) = [];
GVAR(traceFrags) = false; GVAR(traceFrags) = false;
GVAR(TOTALFRAGS) = 0; GVAR(totalFrags) = 0;
GVAR(spallHPData) = []; GVAR(spallHPData) = [];
GVAR(spallIsTrackingCount) = 0; GVAR(spallIsTrackingCount) = 0;

View File

@ -1,4 +1,5 @@
#include "script_component.hpp" #include "script_component.hpp"
class CfgPatches { class CfgPatches {
class ADDON { class ADDON {
name = COMPONENT_NAME; name = COMPONENT_NAME;

View File

@ -1,3 +1,5 @@
#include "script_component.hpp" #include "script_component.hpp"
params ["_round"]; params ["_round"];
GVAR(blackList) set [(count GVAR(blackList)), _round];
GVAR(blackList) pushBack _round;

View File

@ -1,73 +1,67 @@
//#define DEBUG_MODE_FULL //#define DEBUG_MODE_FULL
#include "script_component.hpp" #include "script_component.hpp"
private ["_enabled", "_doSpall", "_spallTrack", "_spallTrackID"]; params ["_gun", "_type", "_round", ["_doFragTrack", false]];
PARAMS_3(_gun,_type,_round);
DEFAULT_PARAM(3,_doFragTrack,false);
if (!GVAR(enabled)) exitWith {}; if (!GVAR(enabled)) exitWith {};
//_enabled = getNumber (configFile >> "CfgAmmo" >> _type >> QGVAR(enabled)); //_enabled = getNumber (configFile >> "CfgAmmo" >> _type >> QGVAR(enabled));
//if(_enabled < 1) exitWith {}; //if (_enabled < 1) exitWith {};
if(_round in GVAR(blackList)) exitWith { if (_round in GVAR(blackList)) exitWith {
GVAR(blackList) = GVAR(blackList) - [_round]; REM(GVAR(blackList),_round);
}; };
// Exit on max track // Exit on max track
if( (count GVAR(objects)) > GVAR(MaxTrack)) exitWith { }; if ((count GVAR(objects)) > GVAR(MaxTrack)) exitWith {};
if(_gun == ACE_player) then { if (
_gun == ACE_player ||
{(gunner _gun) == ACE_player} ||
{local _gun && {!(isPlayer (gunner _gun))} && {!(isPlayer _gun)}}
) then {
_doFragTrack = true; _doFragTrack = true;
} else {
if((gunner _gun) == ACE_player) then {
_doFragTrack = true;
} else {
if(local _gun && {!(isPlayer (gunner _gun))} && {!(isPlayer _gun)}) then {
_doFragTrack = true;
};
};
}; };
_doSpall = false; private _doSpall = false;
if(GVAR(SpallEnabled)) then { if (GVAR(SpallEnabled)) then {
if(GVAR(spallIsTrackingCount) <= 0) then { if (GVAR(spallIsTrackingCount) <= 0) then {
GVAR(spallHPData) = []; GVAR(spallHPData) = [];
}; };
if(GVAR(spallIsTrackingCount) > 5) then { if (GVAR(spallIsTrackingCount) > 5) then {
// ACE_player sideChat "LIMT!"; // ACE_player sideChat "LIMT!";
} else { } else {
_doSpall = true; _doSpall = true;
GVAR(spallIsTrackingCount) = GVAR(spallIsTrackingCount) + 1; INC(GVAR(spallIsTrackingCount));
}; };
}; };
// ACE_player sideChat format["c: %1", GVAR(spallIsTrackingCount)]; // ACE_player sideChat format ["c: %1", GVAR(spallIsTrackingCount)];
if(GVAR(autoTrace)) then { if (GVAR(autoTrace)) then {
[ACE_player, _round, [1,0,0,1]] call FUNC(addTrack); [ACE_player, _round, [1, 0, 0, 1]] call FUNC(addTrack);
}; };
// We only do the single track object check here. // We only do the single track object check here.
// We should do an {!(_round in GVAR(objects))} // We should do an {!(_round in GVAR(objects))}
// But we leave that out here for optimization. So this cannot be a framework function // But we leave that out here for optimization. So this cannot be a framework function
// Otherwise, it should only be added once and from the FiredEH // Otherwise, it should only be added once and from the FiredEH
if(_doFragTrack && {alive _round}) then { if (_doFragTrack && {alive _round}) then {
_spallTrack = []; private _spallTrack = [];
_spallTrackID = []; private _spallTrackID = [];
private ["_args"]; private _args = [
_args = [_round, (getPosASL _round), (velocity _round), _type, diag_frameno, _gun, _doSpall, _spallTrack, _spallTrackID, _round, getPosASL _round, velocity _round, _type, diag_frameno, _gun, _doSpall, _spallTrack, _spallTrackID,
(getNumber (configFile >> "CfgAmmo" >> _type >> QGVAR(skip))), getNumber (configFile >> "CfgAmmo" >> _type >> QGVAR(skip)),
(getNumber (configFile >> "CfgAmmo" >> _type >> "explosive")), getNumber (configFile >> "CfgAmmo" >> _type >> "explosive"),
(getNumber (configFile >> "CfgAmmo" >> _type >> "indirectHitRange")), getNumber (configFile >> "CfgAmmo" >> _type >> "indirectHitRange"),
(getNumber (configFile >> "CfgAmmo" >> _type >> QGVAR(force))), getNumber (configFile >> "CfgAmmo" >> _type >> QGVAR(force)),
(getNumber(configFile >> "CfgAmmo" >> _type >> "indirecthit")*(sqrt((getNumber (configFile >> "CfgAmmo" >> _type >> "indirectHitRange"))))) getNumber (configFile >> "CfgAmmo" >> _type >> "indirecthit") * (sqrt (getNumber (configFile >> "CfgAmmo" >> _type >> "indirectHitRange")))
]; ];
TRACE_1("Initializing track", _round); TRACE_1("Initializing track", _round);
GVAR(objects) pushBack _round; GVAR(objects) pushBack _round;
GVAR(arguments) pushBack _args; GVAR(arguments) pushBack _args;
if(_doSpall) then { if (_doSpall) then {
[_round, 1, _spallTrack, _spallTrackID] call FUNC(spallTrack); [_round, 1, _spallTrack, _spallTrackID] call FUNC(spallTrack);
}; };
// ACE_player sideChat "WTF2"; // ACE_player sideChat "WTF2";

View File

@ -5,16 +5,12 @@ if (GVAR(autoTrace)) then {
}; };
// setAccTime 0.05; // setAccTime 0.05;
private _index = count GVAR(traces); params ["_origin", "_obj", ["_color", [1, 0, 0, 1]]];
params ["_origin", "_obj"];
private _color = [1,0,0,1];
if((count _this) > 2) then {
_color = _this select 2;
};
private _positions = []; private _positions = [];
private _objSpd = vectorMagnitude (velocity _obj); private _objSpd = vectorMagnitude (velocity _obj);
_positions set[(count _positions), [(getPos _obj), _objSpd]]; _positions pushBack [getPos _obj, _objSpd];
private _data = [_origin, typeOf _origin, typeOf _obj, _objSpd, _positions, _color]; private _data = [_origin, typeOf _origin, typeOf _obj, _objSpd, _positions, _color];
GVAR(traces) set[_index, _data]; private _index = GVAR(traces) pushBack _data;
[DFUNC(trackTrace), 0, [_obj, _index, CBA_missionTime]] call CBA_fnc_addPerFrameHandler; [DFUNC(trackTrace), 0, [_obj, _index, CBA_missionTime]] call CBA_fnc_addPerFrameHandler;

View File

@ -1,7 +1,11 @@
#define DEBUG_MODE_FULL #define DEBUG_MODE_FULL
#include "script_component.hpp" #include "script_component.hpp"
params [["_debugMissing", true, [false]], ["_debugForce", false, [false]], ["_debugNonFrag", false, [false]]]; params [
["_debugMissing", true, [false]],
["_debugForce", false, [false]],
["_debugNonFrag", false, [false]]
];
diag_log text format ["~~~~~~~~~~~~~Start [%1]~~~~~~~~~~~~~", _this]; diag_log text format ["~~~~~~~~~~~~~Start [%1]~~~~~~~~~~~~~", _this];
@ -10,7 +14,7 @@ private _processedCfgAmmos = [];
{ {
private _ammo = toLower getText (_x >> "ammo"); private _ammo = toLower getText (_x >> "ammo");
if ((_ammo != "") && {!(_ammo in _processedCfgAmmos)}) then { if (_ammo != "" && {!(_ammo in _processedCfgAmmos)}) then {
_processedCfgAmmos pushBack _ammo; _processedCfgAmmos pushBack _ammo;
//Ignore mines/bombs //Ignore mines/bombs
@ -23,37 +27,37 @@ private _processedCfgAmmos = [];
private _explosive = getNumber (_ammoConfig >> "explosive"); private _explosive = getNumber (_ammoConfig >> "explosive");
private _indirectRange = getNumber (_ammoConfig >> "indirectHitRange"); private _indirectRange = getNumber (_ammoConfig >> "indirectHitRange");
private _force = getNumber (_ammoConfig >> QGVAR(force)); private _force = getNumber (_ammoConfig >> QGVAR(force));
private _fragPower = getNumber(_ammoConfig >> "indirecthit")*(sqrt((getNumber (_ammoConfig >> "indirectHitRange")))); private _fragPower = getNumber (_ammoConfig >> "indirecthit") * (sqrt ((getNumber (_ammoConfig >> "indirectHitRange"))));
private _shouldAdd = (_skip == 0) && {(_force == 1) || {_explosive > 0.5 && {_indirectRange >= 4.5} && {_fragPower >= 35}}}; private _shouldAdd = (_skip == 0) && {(_force == 1) || {_explosive > 0.5 && {_indirectRange >= 4.5} && {_fragPower >= 35}}};
if (_shouldAdd) then { if (_shouldAdd) then {
if (_debugForce && {((getNumber(_ammoConfig >> "hit")) < 5) || {_fragPower < 10}}) then { if (_debugForce && {((getNumber(_ammoConfig >> "hit")) < 5) || {_fragPower < 10}}) then {
diag_log text format ["Ammo [%1] from Mag [%2] - Weak but will still frag!",_ammo,configName _x]; diag_log text format ["Ammo [%1] from Mag [%2] - Weak but will still frag!", _ammo, configName _x];
diag_log text format [" - _force=%1,_fragPower=%2",_force,_fragPower]; diag_log text format [" - _force=%1,_fragPower=%2", _force, _fragPower];
}; };
_warn = false; private _warn = false;
_fragTypes = getArray (_ammoConfig >> QGVAR(CLASSES)); _fragTypes = getArray (_ammoConfig >> QGVAR(CLASSES));
if(_fragTypes isEqualTo []) then {_warn = true;}; if (_fragTypes isEqualTo []) then {_warn = true;};
_c = getNumber(_ammoConfig >> QGVAR(CHARGE)); _c = getNumber(_ammoConfig >> QGVAR(CHARGE));
if(_c == 0) then {_warn = true;}; if (_c == 0) then {_warn = true;};
_m = getNumber(_ammoConfig >> QGVAR(METAL)); _m = getNumber(_ammoConfig >> QGVAR(METAL));
if(_m == 0) then {_warn = true;}; if (_m == 0) then {_warn = true;};
_k = getNumber(_ammoConfig >> QGVAR(GURNEY_K)); _k = getNumber(_ammoConfig >> QGVAR(GURNEY_K));
if(_k == 0) then {_warn = true;}; if (_k == 0) then {_warn = true;};
_gC = getNumber(_ammoConfig >> QGVAR(GURNEY_C)); _gC = getNumber(_ammoConfig >> QGVAR(GURNEY_C));
if(_gC == 0) then { _warn = true;}; if (_gC == 0) then {_warn = true;};
if(_debugMissing && _warn) then { if (_debugMissing && {_warn}) then {
diag_log text format ["Ammo [%1] from Mag [%2] MISSING frag configs:",_ammo,configName _x]; diag_log text format ["Ammo [%1] from Mag [%2] MISSING frag configs:", _ammo, configName _x];
diag_log text format [" - _c=%1,_m=%2,_k=%3,_gC=%4,_fragTypes=%5",_c,_m,_k,_gC,_fragTypes]; diag_log text format [" - _c=%1,_m=%2,_k=%3,_gC=%4,_fragTypes=%5", _c, _m, _k, _gC, _fragTypes];
}; };
} else { } else {
if (_debugNonFrag && {isArray (_ammoConfig >> QGVAR(CLASSES))}) then { if (_debugNonFrag && {isArray (_ammoConfig >> QGVAR(CLASSES))}) then {
diag_log text format ["Ammo [%1] from Mag [%2] has frag configs but will NOT frag:",_ammo,configName _x]; diag_log text format ["Ammo [%1] from Mag [%2] has frag configs but will NOT frag:", _ammo, configName _x];
diag_log text format ["- skip=%1,explosive=%2,indirectHitRange=%3,force=%4,fragPower=%5",_skip,_explosive,_indirectRange,_force,_fragPower]; diag_log text format ["- skip=%1,explosive=%2,indirectHitRange=%3,force=%4,fragPower=%5", _skip, _explosive, _indirectRange, _force, _fragPower];
}; };
}; };
}; };

View File

@ -1,20 +1,22 @@
//fnc_doExplosions.sqf //fnc_doExplosions.sqf
#include "script_component.hpp" #include "script_component.hpp"
params ["_args"]; params ["_args", "_pfhID"];
_args params ["_explosions", "_index"]; _args params ["_explosions", "_index"];
for "_i" from _index to ((_index+2) min (count _explosions)) do { for "_i" from _index to ((_index + 2) min (count _explosions)) do {
private _exp = _explosions select _i; private _exp = _explosions select _i;
_exp params ["_refExp", "_bpos", "_hit", "_distance", "_indirectHitRange", "_depth"]; _exp params ["_refExp", "_bpos", "_hit", "_distance", "_indirectHitRange", "_depth"];
_refExp createVehicle (ASLtoATL _bpos); _refExp createVehicle (ASLtoATL _bpos);
// if(_hit >= 150 && _distance > _indirectHitRange) then { // if (_hit >= 150 && _distance > _indirectHitRange) then {
// [_bpos, _refExp, _depth] call FUNC(doReflections); // [_bpos, _refExp, _depth] call FUNC(doReflections);
// }; // };
}; };
_index = _index + 2;
if(_index >= (count _explosions)) then { ADD(_index,2);
[(_this select 1)] call CBA_fnc_removePerFrameHandler;
if (_index >= count _explosions) then {
[_pfhID] call CBA_fnc_removePerFrameHandler;
} else { } else {
_params set[1, _index]; _args set [1, _index];
}; };

View File

@ -1,14 +1,10 @@
//fnc_doReflections.sqf //fnc_doReflections.sqf
#include "script_component.hpp" #include "script_component.hpp"
params ["_pos", "_ammo"]; params ["_pos", "_ammo", ["_depth", 1]];
private _depth = 1; // TEST_ICONS pushBack [_pos, format ["EXP!", _hit, _range, _hitFactor]];
if(count _this > 2) then { if (_depth <= 2) then {
_depth = _this select 2;
};
// TEST_ICONS pushBack [_pos, format["EXP!", _hit, _range, _hitFactor]];
if(_depth <= 2) then {
private _indirectHitRange = getNumber(configFile >> "CfgAmmo" >> _ammo >> "indirectHitRange"); private _indirectHitRange = getNumber(configFile >> "CfgAmmo" >> _ammo >> "indirectHitRange");
private _indirectHit = getNumber(configFile >> "CfgAmmo" >> _ammo >> "indirectHit"); private _indirectHit = getNumber(configFile >> "CfgAmmo" >> _ammo >> "indirectHit");
private _testParams = [_pos, [_indirectHitRange, _indirectHit], [], [], -4, _depth, 0]; private _testParams = [_pos, [_indirectHitRange, _indirectHit], [], [], -4, _depth, 0];

View File

@ -2,145 +2,126 @@
#include "script_component.hpp" #include "script_component.hpp"
// ACE_player sideChat "WAAAAAAAAAAAAAAAAAAAAA"; // ACE_player sideChat "WAAAAAAAAAAAAAAAAAAAAA";
params ["_hitData"]; params ["_hitData", "_hitPartDataIndex"];
private _initialData = GVAR(spallHPData) select (_hitData select 0); private _initialData = GVAR(spallHPData) select (_hitData select 0);
private _hpData = (_hitData select 1) select (_this select 1); _initialData params ["_hpId", "_object", "_roundType", "_round", "_curPos", "_velocity"];
_hpData params ["_object"]; private _hpData = (_hitData select 1) select _hitPartDataIndex;
_object removeEventHandler ["hitPart", _initialData select 0]; (_hpData select 0) removeEventHandler ["hitPart", _hpId];
private _foundObjects = _initialData select 7;
private _index = _foundObjects find _object;
if(_index != -1) then {
_foundObjects set[_index, nil];
};
_initialData params ["", "_object", "_roundType", "_round"]; private _caliber = getNumber (configFile >> "CfgAmmo" >> _roundType >> "caliber");
private _explosive = getNumber (configFile >> "CfgAmmo" >> _roundType >> "explosive");
private _idh = getNumber (configFile >> "CfgAmmo" >> _roundType >> "indirectHitRange");
private _caliber = getNumber(configFile >> "CfgAmmo" >> _roundType >> "caliber"); if !(_caliber >= 2.5 || {(_explosive > 0 && {_idh >= 1})}) exitWith {};
private _explosive = getNumber(configFile >> "CfgAmmo" >> _roundType >> "explosive"); // ACE_player sideChat format ["BBBB"];
private _idh = getNumber(configFile >> "CfgAmmo" >> _roundType >> "indirectHitRange"); private _exit = false;
private _vm = 1;
private _alive = true; private _oldVelocity = vectorMagnitude _velocity;
if(!alive _round && (_initialData select 6) isEqualTo 1) then { private _curVelocity = vectorMagnitude (velocity _round);
_alive = false;
};
if(_alive || {_caliber >= 2.5} || {(_explosive > 0 && {_idh >= 1})}) then { if (alive _round) then {
// ACE_player sideChat format["BBBB"]; private _diff = _velocity vectorDiff (velocity _round);
private _exit = false; private _polar = _diff call CBA_fnc_vect2polar;
private _vm = 1; // ACE_player sideChat format ["polar: %1", _polar];
private _velocity = _initialData select 5; if (abs (_polar select 1) > 45 || {abs (_polar select 2) > 45}) then {
if (_caliber < 2.5) then {
private _oldVelocity = vectorMagnitude _velocity; // ACE_player sideChat format ["exit!"];
private _curVelocity = vectorMagnitude (velocity _round); _exit = true;
} else {
if(alive _round) then { SUB(_vm,_curVelocity / _oldVelocity);
private _diff = _velocity vectorDiff (velocity _round);
private _polar = _diff call CBA_fnc_vect2polar;
// ACE_player sideChat format["polar: %1", _polar];
if((abs(_polar select 1) > 45 || abs(_polar select 2) > 45)) then {
if(_caliber < 2.5) then {
// ACE_player sideChat format["exit!"];
_exit = true;
} else {
_vm = 1-(_curVelocity/_oldVelocity);
};
};
};
if(!_exit) then {
private _unitDir = vectorNormalized _velocity;
private _pos = _hpData select 3;
private _spallPos = nil;
for "_i" from 0 to 100 do {
private _pos1 = _pos vectorAdd (_unitDir vectorMultiply (0.01 * _i));
private _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];
// _data = [nil, nil, nil, 1, [[ASLtoATL _pos1, 1], [ASLtoATL _pos2, 1]]];
// NOU_TRACES set[(count NOU_TRACES), _data];
if(!lineIntersects [_pos1, _pos2]) exitWith {
// ACE_player sideChat format["FOUND!"];
_spallPos = _pos2;
};
};
if(!isNil "_spallPos") then {
private _spallPolar = _velocity call CBA_fnc_vect2polar;
if(_explosive > 0) then {
// ACE_player sideChat format["EXPLOSIVE!"];
private _warn = false;
private _c = getNumber(configFile >> "CfgAmmo" >> _roundType >> QGVAR(CHARGE));
if(_c == 0) then { _c = 1; _warn = true;};
private _m = getNumber(configFile >> "CfgAmmo" >> _roundType >> QGVAR(METAL));
if(_m == 0) then { _m = 2; _warn = true;};
private _k = getNumber(configFile >> "CfgAmmo" >> _roundType >> QGVAR(GURNEY_K));
if(_k == 0) then { _k = 1/2; _warn = true;};
private _gC = getNumber(configFile >> "CfgAmmo" >> _roundType >> QGVAR(GURNEY_C));
if(_gC == 0) then { _gC = 2440; _warn = true;};
if(_warn) then {
WARNING_1("Ammo class %1 lacks proper explosive properties definitions for frag!",_roundType); //TODO: turn this off when we get closer to release
};
private _fragPower = (((_m/_c)+_k)^-(1/2))*_gC;
_spallPolar set[0, _fragPower*0.66];
};
private _fragTypes = [
QGVAR(spall_small), QGVAR(spall_small), QGVAR(spall_small),
QGVAR(spall_small),QGVAR(spall_medium),QGVAR(spall_medium),QGVAR(spall_medium),
QGVAR(spall_medium), QGVAR(spall_large), QGVAR(spall_large), QGVAR(spall_huge),
QGVAR(spall_huge)
];
// diag_log text format["SPALL POWER: %1", _spallPolar select 0];
private _spread = 15+(random 25);
private _spallCount = 5+(random 10);
for "_i" from 1 to _spallCount do {
private _elev = ((_spallPolar select 2)-_spread)+(random (_spread*2));
private _dir = ((_spallPolar select 1)-_spread)+(random (_spread*2));
if(abs _elev > 90) then {
_dir = _dir + 180;
};
_dir = _dir % 360;
private _vel = (_spallPolar select 0)*0.33*_vm;
_vel = (_vel-(_vel*0.25))+(random (_vel*0.5));
private _spallFragVect = [_vel, _dir, _elev] call CBA_fnc_polar2vect;
private _fragType = round (random ((count _fragTypes)-1));
private _fragment = (_fragTypes select _fragType) createVehicleLocal [0,0,10000];
_fragment setPosASL _spallPos;
_fragment setVelocity _spallFragVect;
if(GVAR(traceFrags)) then {
[ACE_player, _fragment, [1,0.5,0,1]] call FUNC(addTrack);
};
};
_spread = 5+(random 5);
_spallCount = 3+(random 5);
for "_i" from 1 to _spallCount do {
private _elev = ((_spallPolar select 2)-_spread)+(random (_spread*2));
private _dir = ((_spallPolar select 1)-_spread)+(random (_spread*2));
if(abs _elev > 90) then {
_dir = _dir + 180;
};
_dir = _dir % 360;
private _vel = (_spallPolar select 0)*0.55*_vm;
_vel = (_vel-(_vel*0.25))+(random (_vel*0.5));
private _spallFragVect = [_vel, _dir, _elev] call CBA_fnc_polar2vect;
private _fragType = round (random ((count _fragTypes)-1));
private _fragment = (_fragTypes select _fragType) createVehicleLocal [0,0,10000];
_fragment setPosASL _spallPos;
_fragment setVelocity _spallFragVect;
if(GVAR(traceFrags)) then {
[ACE_player, _fragment, [1,0,0,1]] call FUNC(addTrack);
};
};
}; };
}; };
}; };
if (_exit) exitWith {};
private _unitDir = vectorNormalized _velocity;
private _pos = _hpData select 3;
private _spallPos = [];
for "_i" from 0 to 100 do {
private _pos1 = _pos vectorAdd (_unitDir vectorMultiply (0.01 * _i));
private _pos2 = _pos vectorAdd (_unitDir vectorMultiply (0.01 * (_i + 1)));
// _data = [nil, nil, nil, 1, [[ASLtoATL _pos1, 1], [ASLtoATL _pos2, 1]]];
// NOU_TRACES pushBack _data;
if (!lineIntersects [_pos1, _pos2]) exitWith {
// ACE_player sideChat format ["FOUND!"];
_spallPos = _pos2;
};
};
if (_spallPos isEqualTo []) exitWith {};
private _spallPolar = _velocity call CBA_fnc_vect2polar;
if (_explosive > 0) then {
// ACE_player sideChat format ["EXPLOSIVE!"];
private _warn = false;
private _c = getNumber (configFile >> "CfgAmmo" >> _roundType >> QGVAR(CHARGE));
if (_c == 0) then {_c = 1; _warn = true;};
private _m = getNumber (configFile >> "CfgAmmo" >> _roundType >> QGVAR(METAL));
if (_m == 0) then {_m = 2; _warn = true;};
private _k = getNumber (configFile >> "CfgAmmo" >> _roundType >> QGVAR(GURNEY_K));
if (_k == 0) then {_k = 1 / 2; _warn = true;};
private _gC = getNumber (configFile >> "CfgAmmo" >> _roundType >> QGVAR(GURNEY_C));
if (_gC == 0) then {_gC = 2440; _warn = true;};
if (_warn) then {
WARNING_1("Ammo class %1 lacks proper explosive properties definitions for frag!",_roundType); //TODO: turn this off when we get closer to release
};
private _fragPower = (((_m / _c) + _k) ^ - (1 / 2)) * _gC;
_spallPolar set [0, _fragPower * 0.66];
};
private _fragTypes = [
QGVAR(spall_small), QGVAR(spall_small), QGVAR(spall_small),
QGVAR(spall_small),QGVAR(spall_medium),QGVAR(spall_medium),QGVAR(spall_medium),
QGVAR(spall_medium), QGVAR(spall_large), QGVAR(spall_large), QGVAR(spall_huge),
QGVAR(spall_huge)
];
// diag_log text format ["SPALL POWER: %1", _spallPolar select 0];
private _spread = 15 + (random 25);
private _spallCount = 5 + (random 10);
for "_i" from 1 to _spallCount do {
private _elev = ((_spallPolar select 2) - _spread) + (random (_spread * 2));
private _dir = ((_spallPolar select 1) - _spread) + (random (_spread * 2));
if (abs _elev > 90) then {
ADD(_dir,180);
};
_dir = _dir % 360;
private _vel = (_spallPolar select 0) * 0.33 * _vm;
_vel = (_vel - (_vel * 0.25)) + (random (_vel * 0.5));
private _spallFragVect = [_vel, _dir, _elev] call CBA_fnc_polar2vect;
private _fragType = round (random ((count _fragTypes) - 1));
private _fragment = (_fragTypes select _fragType) createVehicleLocal [0,0,10000];
_fragment setPosASL _spallPos;
_fragment setVelocity _spallFragVect;
if (GVAR(traceFrags)) then {
[ACE_player, _fragment, [1, 0.5, 0, 1]] call FUNC(addTrack);
};
};
_spread = 5 + (random 5);
_spallCount = 3 + (random 5);
for "_i" from 1 to _spallCount do {
private _elev = ((_spallPolar select 2) - _spread) + (random (_spread * 2));
private _dir = ((_spallPolar select 1) - _spread) + (random (_spread * 2));
if (abs _elev > 90) then {
ADD(_dir,180);
};
_dir = _dir % 360;
private _vel = (_spallPolar select 0) * 0.55 * _vm;
_vel = (_vel - (_vel * 0.25)) + (random (_vel * 0.5));
private _spallFragVect = [_vel, _dir, _elev] call CBA_fnc_polar2vect;
private _fragType = round (random ((count _fragTypes) - 1));
private _fragment = (_fragTypes select _fragType) createVehicleLocal [0, 0, 10000];
_fragment setPosASL _spallPos;
_fragment setVelocity _spallFragVect;
if (GVAR(traceFrags)) then {
[ACE_player, _fragment, [1, 0, 0, 1]] call FUNC(addTrack);
};
};

View File

@ -1,31 +1,23 @@
#include "script_component.hpp" #include "script_component.hpp"
private ["_color", "_index", "_lastPos", "_lastSpd", "_max", "_positions", "_startSpeed"];
{ {
_positions = _x select 4; private _positions = _x select 4;
_color = _x select 5; private _color = _x select 5;
_index = 0; private _index = 0;
_max = count _positions; private _max = count _positions;
_startSpeed = 0.01 max ((_positions select 0) select 1); private _lastSpd = [];
_lastSpd = []; private _lastPos = [];
_lastPos = [];
while {_index < _max} do { while {_index < _max} do {
_data1 = _positions select _index; _data1 = _positions select _index;
_data2 = nil; _data2 = _positions select ([_index + ACE_TRACE_DRAW_INC, _max - 1] select (_index + ACE_TRACE_DRAW_INC >= _max));
if(_index + ACE_TRACE_DRAW_INC >= _max) then {
_data2 = _positions select (_max - 1);
} else {
_data2 = _positions select (_index + ACE_TRACE_DRAW_INC);
};
_pos1 = _data1 select 0; _pos1 = _data1 select 0;
_pos2 = _data2 select 0; _pos2 = _data2 select 0;
_index = _index + ACE_TRACE_DRAW_INC; ADD(_index,ACE_TRACE_DRAW_INC);
drawLine3D [_pos1, _pos2, _color]; drawLine3D [_pos1, _pos2, _color];
_lastPos = _pos2; _lastPos = _pos2;
_lastSpd = _data1 select 1; _lastSpd = _data1 select 1;
}; };
// drawIcon3D ["", [1,0,0,1], _lastPos, 0, 0, 0, format["%1m/s", _lastSpd], 1, 0.05, "RobotoCondensed"]; // drawIcon3D ["", [1,0,0,1], _lastPos, 0, 0, 0, format ["%1m/s", _lastSpd], 1, 0.05, "RobotoCondensed"];
} forEach GVAR(traces); } forEach GVAR(traces);

View File

@ -1,61 +1,58 @@
//fnc_findReflections.sqf //fnc_findReflections.sqf
#include "script_component.hpp" #include "script_component.hpp"
private ["_lastPos", "_test", "_vec", "_testPos", "_buckets", "_excludes", "_bucketIndex", "_bucketPos", "_bucketList", "_c", "_index", "_blist", "_avgX", "_avgY", "_avgZ", "_bpos", "_distance", "_hitFactor", "_hit", "_range", "_refExp", "_i", "_x", "_res", "_forEachIndex", "_explosions", "_can", "_dirvec", "_zAng"];
BEGIN_COUNTER(fnc_findReflections); BEGIN_COUNTER(fnc_findReflections);
params ["_args"]; params ["_args", "_pfhID"];
_args params ["_pos", "_explosiveInfo", "_los", "_nlos", "_zIndex", "_depth", "_rand"]; _args params ["_pos", "_explosiveInfo", "_los", "_nlos", "_zIndex", "_depth", "_rand"];
private _split = 15; private _split = 15;
private _radi = (360/_split*_depth); private _radi = 360 / _split * _depth;
// player sideChat format["p: %1", _explosiveInfo]; // player sideChat format ["p: %1", _explosiveInfo];
_explosiveInfo params ["_indirectHitRange", "_indirectHit"]; _explosiveInfo params ["_indirectHitRange", "_indirectHit"];
private _distanceCount = (floor _indirectHitRange*4) min 100; private _distanceCount = (floor _indirectHitRange * 4) min 100;
if(_zIndex < 5) then { if (_zIndex < 5) then {
_lastPos = _pos; private _lastPos = _pos;
_zAng = _zIndex*20+2; private _zAng = _zIndex * 20 + 2;
if(_zAng > 80) then { if (_zAng > 80) then {
_radi = 1; _radi = 1;
_zAng = 90; _zAng = 90;
}; };
for "_i" from 0 to _radi do { for "_i" from 0 to _radi do {
_test = true; private _test = true;
_vec = [1, ((_i*_split)+_rand) mod 360, _zAng] call CBA_fnc_polar2vect; private _vec = [1, ((_i * _split) + _rand) % 360, _zAng] call CBA_fnc_polar2vect;
for "_x" from 1 to _distanceCount do { for "_x" from 1 to _distanceCount do {
_testPos = _pos vectorAdd (_vec vectorMultiply _x); private _testPos = _pos vectorAdd (_vec vectorMultiply _x);
// drop ["\a3\data_f\Cl_basic","","Billboard",1,15,ASLtoATL _testPos,[0,0,0],1,1.275,1.0,0.0,[1],[[1,0,0,1]],[0],0.0,2.0,"","",""]; // drop ["\a3\data_f\Cl_basic","","Billboard",1,15,ASLtoATL _testPos,[0,0,0],1,1.275,1.0,0.0,[1],[[1,0,0,1]],[0],0.0,2.0,"","",""];
_res = lineIntersectsWith [_pos, _testPos]; private _res = lineIntersectsWith [_pos, _testPos];
if(count _res > 0) exitWith { if (count _res > 0) exitWith {
_test = false; _test = false;
_nlos pushBack _lastPos; _nlos pushBack _lastPos;
// { // {
// _x addEventHandler ["HandleDamage", { diag_log text format["this: %1", _this]; }]; // _x addEventHandler ["HandleDamage", { diag_log text format ["this: %1", _this]; }];
// } forEach _res; // } forEach _res;
// drop ["\a3\data_f\Cl_basic","","Billboard",1,15,ASLtoATL _testPos,[0,0,0],1,1.275,1.0,0.0,[1],[[1,0,0,1]],[0],0.0,2.0,"","",""]; // drop ["\a3\data_f\Cl_basic","","Billboard",1,15,ASLtoATL _testPos,[0,0,0],1,1.275,1.0,0.0,[1],[[1,0,0,1]],[0],0.0,2.0,"","",""];
// TEST_PAIRS pushBack [_pos, _lastPos, [1,0,0,1]]; // TEST_PAIRS pushBack [_pos, _lastPos, [1,0,0,1]];
}; };
// if(terrainIntersectASL [_pos, _testPos]) exitWith {}; // if (terrainIntersectASL [_pos, _testPos]) exitWith {};
_lastPos = _testPos; _lastPos = _testPos;
}; };
}; };
_args set[4, _zIndex+1]; _args set [4, _zIndex + 1];
} else { } else {
_depth = _depth + 1; INC(_depth);
_buckets = []; private _buckets = [];
_excludes = []; private _excludes = [];
_bucketIndex = 0; private _bucketPos = nil;
_bucketPos = nil; private _bucketList = nil;
_bucketList = nil; private _c = 0;
_c = 0; while {count _nlos != count _excludes && {_c < (count _nlos)}} do {
while { count(_nlos) != count(_excludes) && _c < (count _nlos) } do {
scopeName "mainSearch"; scopeName "mainSearch";
{ {
if(!(_forEachIndex in _excludes)) then { if (!(_forEachIndex in _excludes)) then {
_index = _buckets pushBack [_x, [_x]]; private _index = _buckets pushBack [_x, [_x]];
_excludes pushBack _forEachIndex; _excludes pushBack _forEachIndex;
_bucketPos = _x; _bucketPos = _x;
_bucketList = (_buckets select _index) select 1; _bucketList = (_buckets select _index) select 1;
@ -63,59 +60,58 @@ if(_zIndex < 5) then {
}; };
} forEach _nlos; } forEach _nlos;
{ {
if(!(_forEachIndex in _excludes)) then { if (!(_forEachIndex in _excludes)) then {
_testPos = _x; _testPos = _x;
if(_testPos vectorDistanceSqr _bucketPos <= 30) then { if (_testPos vectorDistanceSqr _bucketPos <= 30) then {
_bucketList pushBack _x; _bucketList pushBack _x;
_excludes pushBack _forEachIndex; _excludes pushBack _forEachIndex;
}; };
}; };
} forEach _nlos; } forEach _nlos;
_c = _c + 1; INC(_c);
}; };
// player sideChat format["c: %1", count _buckets]; // player sideChat format ["c: %1", count _buckets];
_explosions = []; private _explosions = [];
{ {
_blist = _x select 1; private _blist = _x select 1;
_avgX = 0; private _avgX = 0;
_avgY = 0; private _avgY = 0;
_avgZ = 0; private _avgZ = 0;
{ {
_avgX = _avgX + (_x select 0); ADD(_avgX,_x select 0);
_avgY = _avgY + (_x select 1); ADD(_avgY,_x select 1);
_avgZ = _avgZ + (_x select 2); ADD(_avgZ,_x select 2);
} forEach _blist; } forEach _blist;
_c = count _blist; _c = count _blist;
_bpos = [_avgX/_c, _avgY/_c, _avgZ/_c]; private _bpos = [_avgX / _c, _avgY / _c, _avgZ / _c];
_distance = _pos vectorDistance _bpos; private _distance = _pos vectorDistance _bpos;
_hitFactor = 1-(((_distance/(_indirectHitRange*4)) min 1) max 0); private _hitFactor = 1 - (((_distance / (_indirectHitRange * 4)) min 1) max 0);
// _hitFactor = 1/(_distance^2); // _hitFactor = 1 / (_distance ^ 2);
_hit = _indirectHit*_hitFactor; private _hit = _indirectHit * _hitFactor;
_hit = (floor (_hit/4)) min 500; _hit = (floor (_hit / 4)) min 500;
_hit = _hit - (_hit%10); SUB(_hit,_hit % 10);
_range = (floor (_indirectHitRange-(_distance/4))) min 100; private _range = (floor (_indirectHitRange - (_distance / 4))) min 100;
_range = _range - (_range%2); SUB(_range,_range % 2);
if(_hit >= 10 && _range > 0) then { if (_hit >= 10 && {_range > 0}) then {
// TEST_ICONS pushBack [_bpos, format["h: %1, r: %2, hf: %3 d: %4 ihr: %5", _hit, _range, _hitFactor, _distance, _indirectHitRange*4]]; // TEST_ICONS pushBack [_bpos, format ["h: %1, r: %2, hf: %3 d: %4 ihr: %5", _hit, _range, _hitFactor, _distance, _indirectHitRange*4]];
// TEST_PAIRS pushBack [_pos, _bpos, [1,0,0,1]]; // TEST_PAIRS pushBack [_pos, _bpos, [1,0,0,1]];
_refExp = format["ace_explosion_reflection_%1_%2", _range, _hit]; private _refExp = format ["ace_explosion_reflection_%1_%2", _range, _hit];
// _refExp createVehicle (ASLtoATL _bpos); // _refExp createVehicle (ASLtoATL _bpos);
// drop ["\a3\data_f\Cl_basic","","Billboard",1,15,ASLtoATL _bpos,[0,0,0],1,1.275,1.0,0.0,[1],[[1,0,0,1]],[0],0.0,2.0,"","",""]; // drop ["\a3\data_f\Cl_basic","","Billboard",1,15,ASLtoATL _bpos,[0,0,0],1,1.275,1.0,0.0,[1],[[1,0,0,1]],[0],0.0,2.0,"","",""];
_explosions pushBack [_refExp, _bpos, _hit, _distance, _indirectHitRange/4, _depth]; _explosions pushBack [_refExp, _bpos, _hit, _distance, _indirectHitRange / 4, _depth];
}; };
if(count _explosions > (_radi*2)/_depth) exitWith {}; if (count _explosions > (_radi * 2) / _depth) exitWith {};
} forEach _buckets; } forEach _buckets;
// _can = "Land_Bricks_V4_F" createVehicle (ASLtoATL _pos); // _can = "Land_Bricks_V4_F" createVehicle (ASLtoATL _pos);
// _dirvec = _pos vectorFromTo ((ATLtoASL (player modelToWorldVisual (player selectionPosition "Spine3")))); // _dirvec = _pos vectorFromTo ((ATLtoASL (player modelToWorldVisual (player selectionPosition "Spine3"))));
// _dirvec = _dirvec vectorMultiply 100; // _dirvec = _dirvec vectorMultiply 100;
// _can setVelocity _dirvec; // _can setVelocity _dirvec;
[DFUNC(doExplosions), 0, [_explosions, 0]] call CBA_fnc_addPerFrameHandler; [DFUNC(doExplosions), 0, [_explosions, 0]] call CBA_fnc_addPerFrameHandler;
[(_this select 1)] call CBA_fnc_removePerFrameHandler; [_pfhID] call CBA_fnc_removePerFrameHandler;
}; };
END_COUNTER(fnc_findReflections); END_COUNTER(fnc_findReflections);

View File

@ -42,7 +42,7 @@ if (isNil "_shouldAdd") then {
private _explosive = getNumber (configFile >> "CfgAmmo" >> _ammo >> "explosive"); private _explosive = getNumber (configFile >> "CfgAmmo" >> _ammo >> "explosive");
private _indirectRange = getNumber (configFile >> "CfgAmmo" >> _ammo >> "indirectHitRange"); private _indirectRange = getNumber (configFile >> "CfgAmmo" >> _ammo >> "indirectHitRange");
private _force = getNumber (configFile >> "CfgAmmo" >> _ammo >> QGVAR(force)); private _force = getNumber (configFile >> "CfgAmmo" >> _ammo >> QGVAR(force));
private _fragPower = getNumber(configFile >> "CfgAmmo" >> _ammo >> "indirecthit")*(sqrt((getNumber (configFile >> "CfgAmmo" >> _ammo >> "indirectHitRange")))); private _fragPower = getNumber (configFile >> "CfgAmmo" >> _ammo >> "indirecthit") * (sqrt (getNumber (configFile >> "CfgAmmo" >> _ammo >> "indirectHitRange")));
_shouldAdd = (_skip == 0) && {(_force == 1) || {_explosive > 0.5 && {_indirectRange >= 4.5} && {_fragPower >= 35}}}; _shouldAdd = (_skip == 0) && {(_force == 1) || {_explosive > 0.5 && {_indirectRange >= 4.5} && {_fragPower >= 35}}};
TRACE_6("SettingCache[willFrag?]",_skip,_explosive,_indirectRange,_force,_fragPower,_shouldAdd); TRACE_6("SettingCache[willFrag?]",_skip,_explosive,_indirectRange,_force,_fragPower,_shouldAdd);

View File

@ -6,44 +6,36 @@
#define MAX_FRAG_COUNT 50 #define MAX_FRAG_COUNT 50
if(!isServer) exitWith { }; if (!isServer) exitWith {};
BEGIN_COUNTER(frago); BEGIN_COUNTER(frago);
// _startTime = diag_tickTime; // _startTime = diag_tickTime;
private ["_fuseDist", "_indirectHitRange", "_fragRange", "_c", "_m", "_k", "_gC", "_fragPower", "_fragPowerRandom", "_manObjects", "_objects", "_crew", "_fragCount", "_fragArcs", "_doRandom", "_boundingBox", "_targetPos", "_distance", "_add", "_bbX", "_bbY", "_bbZ", "_cubic", "_targetVel", "_baseVec", "_dir", "_currentCount", "_count", "_vecVar", "_vec", "_fp", "_vel", "_fragType", "_fragObj", "_randomCount", "_sectorSize", "_sectorOffset", "_i", "_randomDir", "_endTime", "_target"]; params ["_round", "_lastPos", "_lastVel", "_shellType", "_firedFrame", "_gun"];
params ["_round", "_lastPos", "_lastVel", "_shellType"];
private _gun = nil;
if((count _this) > 5) then {
_gun = _this select 5;
};
private _fragTypes = [ private _fragTypes = [
QGVAR(tiny), QGVAR(tiny), QGVAR(tiny), QGVAR(tiny), QGVAR(tiny), QGVAR(tiny),
QGVAR(tiny_HD), QGVAR(tiny_HD), QGVAR(tiny_HD), QGVAR(tiny_HD), QGVAR(tiny_HD), QGVAR(tiny_HD),
QGVAR(small),QGVAR(small),QGVAR(small),QGVAR(small), QGVAR(small), QGVAR(small), QGVAR(small), QGVAR(small),
QGVAR(small_HD),QGVAR(small_HD),QGVAR(small_HD),QGVAR(small_HD), QGVAR(small_HD), QGVAR(small_HD), QGVAR(small_HD), QGVAR(small_HD),
QGVAR(medium_HD), QGVAR(medium_HD), QGVAR(medium_HD), QGVAR(medium_HD), QGVAR(medium_HD) QGVAR(medium_HD), QGVAR(medium_HD), QGVAR(medium_HD), QGVAR(medium_HD), QGVAR(medium_HD)
]; ];
private _warn = false; private _warn = false;
if(isArray (configFile >> "CfgAmmo" >> _shellType >> QGVAR(CLASSES))) then { if (isArray (configFile >> "CfgAmmo" >> _shellType >> QGVAR(CLASSES))) then {
_fragTypes = getArray (configFile >> "CfgAmmo" >> _shellType >> QGVAR(CLASSES)); _fragTypes = getArray (configFile >> "CfgAmmo" >> _shellType >> QGVAR(CLASSES));
} else { } else {
_warn = true; _warn = true;
}; };
private _atlPos = ASLtoATL _lastPos;
private _isArmed = true; private _isArmed = true;
if(!isNil "_gun") then { if (!isNil "_gun") then {
_fuseDist = getNumber(configFile >> "CfgAmmo" >> _shellType >> "fuseDistance"); private _fuseDist = getNumber(configFile >> "CfgAmmo" >> _shellType >> "fuseDistance");
_isArmed = ((getPosASL _gun) distance _lastPos > _fuseDist); _isArmed = ((getPosASL _gun) distance _lastPos > _fuseDist);
}; };
_indirectHitRange = getNumber(configFile >> "CfgAmmo" >> _shellType >> "indirecthitrange"); private _indirectHitRange = getNumber(configFile >> "CfgAmmo" >> _shellType >> "indirecthitrange");
_fragRange = 20 * _indirectHitRange * 4; private _fragRange = 20 * _indirectHitRange * 4;
// _c = 185; // grams of comp-b // _c = 185; // grams of comp-b
// _m = 210; // grams of fragmentating metal // _m = 210; // grams of fragmentating metal
// _k = 3/5; // spherical K factor // _k = 3/5; // spherical K factor
@ -54,26 +46,27 @@ _fragRange = 20 * _indirectHitRange * 4;
// _k = 1/2; // spherical K factor // _k = 1/2; // spherical K factor
// _gC = 2320; // Gurney constant of tritonal in /ms // _gC = 2320; // Gurney constant of tritonal in /ms
private _c = getNumber (configFile >> "CfgAmmo" >> _shellType >> QGVAR(CHARGE));
if (_c == 0) then {_c = 1; _warn = true;};
private _m = getNumber (configFile >> "CfgAmmo" >> _shellType >> QGVAR(METAL));
if (_m == 0) then {_m = 2; _warn = true;};
private _k = getNumber (configFile >> "CfgAmmo" >> _shellType >> QGVAR(GURNEY_K));
if (_k == 0) then {_k = 0.5; _warn = true;};
private _gC = getNumber (configFile >> "CfgAmmo" >> _shellType >> QGVAR(GURNEY_C));
if (_gC == 0) then {_gC = 2440; _warn = true;};
_c = getNumber(configFile >> "CfgAmmo" >> _shellType >> QGVAR(CHARGE)); if (_warn) then {
if(_c == 0) then { _c = 1; _warn = true;};
_m = getNumber(configFile >> "CfgAmmo" >> _shellType >> QGVAR(METAL));
if(_m == 0) then { _m = 2; _warn = true;};
_k = getNumber(configFile >> "CfgAmmo" >> _shellType >> QGVAR(GURNEY_K));
if(_k == 0) then { _k = 1/2; _warn = true;};
_gC = getNumber(configFile >> "CfgAmmo" >> _shellType >> QGVAR(GURNEY_C));
if(_gC == 0) then { _gC = 2440; _warn = true;};
if(_warn) then {
WARNING_1("Ammo class %1 lacks proper explosive properties definitions for frag!",_shellType); //TODO: turn this off when we get closer to release WARNING_1("Ammo class %1 lacks proper explosive properties definitions for frag!",_shellType); //TODO: turn this off when we get closer to release
}; };
_fragPower = (((_m/_c)+_k)^-(1/2))*_gC; private _fragPower = (((_m / _c) + _k) ^ - (1 / 2)) * _gC;
_fragPower = _fragPower * 0.8; // Gunery equation is for a non-fragmenting metal, imperical value of 80% represents fragmentation _fragPower = _fragPower * 0.8; // Gunery equation is for a non-fragmenting metal, imperical value of 80% represents fragmentation
_fragPowerRandom = _fragPower * 0.5; private _atlPos = ASLtoATL _lastPos;
if((_atlPos select 2) < 0.5) then {
_lastPos set[2, (_lastPos select 2)+0.5]; private _fragPowerRandom = _fragPower * 0.5;
if ((_atlPos select 2) < 0.5) then {
_lastPos set [2, (_lastPos select 2) + 0.5];
}; };
// _manObjects = _atlPos nearEntities ["CaManBase", _fragRange]; // _manObjects = _atlPos nearEntities ["CaManBase", _fragRange];
@ -81,134 +74,130 @@ if((_atlPos select 2) < 0.5) then {
// setAccTime 0.01; // setAccTime 0.01;
//_objects = nearestObjects [_atlPos, ["AllVehicles"], _fragRange]; // Not sure if tracking "ReammoBox" is required, if so revert this change for _objects //_objects = nearestObjects [_atlPos, ["AllVehicles"], _fragRange]; // Not sure if tracking "ReammoBox" is required, if so revert this change for _objects
_objects = _atlPos nearEntities [["Car", "Motorcycle", "Tank", "StaticWeapon", "CAManBase", "Air", "Ship"], _fragRange]; private _objects = _atlPos nearEntities [["Car", "Motorcycle", "Tank", "StaticWeapon", "CAManBase", "Air", "Ship"], _fragRange];
// _objects = _manObjects; // _objects = _manObjects;
// Target also people inside vehicles or manning weapons // Add unique crews in faster way
_crew = [];
{ {
{ {
_crew set [count _crew,_x] _objects pushBackUnique _x;
} forEach (crew _x); } forEach (crew _x);
} forEach _objects; } forEach _objects;
_objects = _objects - _crew; private _fragCount = 0;
_objects = _objects + _crew;
_fragCount = 0; private _fragArcs = [];
_fragArcs set [360, 0];
_fragArcs = [];
_fragArcs set[360, 0];
#ifdef DEBUG_MODE_FULL #ifdef DEBUG_MODE_FULL
ACE_player sideChat format["_fragRange: %1", _fragRange]; ACE_player sideChat format ["_fragRange: %1", _fragRange];
ACE_player sideChat format["_objects: %1", _objects]; ACE_player sideChat format ["_objects: %1", _objects];
#endif #endif
_doRandom = true;
if(_isArmed && (count _objects) > 0) then { private _doRandom = true;
if (_isArmed && {!(_objects isEqualTo [])}) then {
if (GVAR(ReflectionsEnabled)) then { if (GVAR(ReflectionsEnabled)) then {
[_lastPos, _shellType] call FUNC(doReflections); [_lastPos, _shellType] call FUNC(doReflections);
}; };
{ {
//if(random(1) > 0.5) then { //if (random(1) > 0.5) then {
_target = _x; private _target = _x;
if(alive _target) then { if (alive _target) then {
_boundingBox = boundingBox _target; private _boundingBox = boundingBox _target;
_targetPos = (getPosASL _target); private _targetPos = getPosASL _target;
_distance = _targetPos distance _lastPos; private _distance = _targetPos distance _lastPos;
_add = (((_boundingBox select 1) select 2)/2)+((((_distance-(_fragpower/8)) max 0)/_fragPower)*10); private _add = (((_boundingBox select 1) select 2) / 2) + ((((_distance - (_fragpower / 8)) max 0) / _fragPower) * 10);
_bbX = (abs((_boundingBox select 0) select 0))+((_boundingBox select 1) select 0); private _bbX = (abs ((_boundingBox select 0) select 0)) + ((_boundingBox select 1) select 0);
_bbY = (abs((_boundingBox select 0) select 1))+((_boundingBox select 1) select 1); private _bbY = (abs ((_boundingBox select 0) select 1)) + ((_boundingBox select 1) select 1);
_bbZ = (abs((_boundingBox select 0) select 2))+((_boundingBox select 1) select 2); private _bbZ = (abs ((_boundingBox select 0) select 2)) + ((_boundingBox select 1) select 2);
_cubic = _bbX * _bbY * _bbZ; private _cubic = _bbX * _bbY * _bbZ;
if(_cubic > 1) then { if (_cubic > 1) then {
_doRandom = true; _doRandom = true;
_targetVel = (velocity _target); private _targetVel = velocity _target;
_targetPos = _targetPos vectorAdd [
(_targetVel select 0) * (_distance / _fragPower),
(_targetVel select 1) * (_distance / _fragPower),
_add
];
_targetPos set[0, (_targetPos select 0)+((_targetVel select 0)*(_distance/_fragPower))]; private _baseVec = _lastPos vectorFromTo _targetPos;
_targetPos set[1, (_targetPos select 1)+((_targetVel select 1)*(_distance/_fragPower))];
_targetPos set[2, (_targetPos select 2)+_add];
_baseVec = _lastPos vectorFromTo _targetPos; private _dir = floor (_baseVec call CBA_fnc_vectDir);
private _currentCount = _fragArcs select _dir;
_dir = floor(_baseVec call CBA_fnc_vectDir); ISNILS(_currentCount,0);
_currentCount = _fragArcs select _dir; if (_currentCount < 20) then {
if(isNil "_currentCount") then { private _count = ceil (random (sqrt (_m / 1000)));
_currentCount = 0; private _vecVar = FRAG_VEC_VAR;
}; if (!(_target isKindOf "Man")) then {
if(_currentCount < 20) then { _vecVar = ((sqrt _cubic) / 2000) + FRAG_VEC_VAR;
_count = ceil(random(sqrt(_m/1000))); if ((crew _target) isEqualTo [] && {_count > 0}) then {
_vecVar = FRAG_VEC_VAR; _count = 0 max (_count / 2);
if(!(_target isKindOf "Man")) then {
_vecVar = ((sqrt _cubic)/2000)+FRAG_VEC_VAR;
if((count (crew _target)) == 0 && _count > 0) then {
_count = 0 max (_count/2);
}; };
}; };
for "_i" from 1 to _count do { for "_i" from 1 to _count do {
_vec = +_baseVec; private _vec = _baseVec vectorDiff [
(_vecVar / 2) + (random _vecVar),
(_vecVar / 2) + (random _vecVar),
(_vecVar / 2) + (random _vecVar)
];
_vec set[0, (_vec select 0)-(_vecVar/2)+(random _vecVar)]; private _fp = _fragPower - (random (_fragPowerRandom));
_vec set[1, (_vec select 1)-(_vecVar/2)+(random _vecVar)]; private _vel = _vec vectorMultiply _fp;
_vec set[2, (_vec select 2)-(_vecVar/2)+(random _vecVar)];
_fp = (_fragPower-(random (_fragPowerRandom))); private _fragType = round (random ((count _fragTypes) - 1));
_vel = _vec vectorMultiply _fp; private _fragObj = (_fragTypes select _fragType) createVehicleLocal [0,0,10000];
// diag_log text format ["fp: %1 %2", _fp, typeOf _fragObj];
_fragType = round (random ((count _fragTypes)-1));
_fragObj = (_fragTypes select _fragType) createVehicleLocal [0,0,10000];
// diag_log text format["fp: %1 %2", _fp, typeOf _fragObj];
_fragObj setPosASL _lastPos; _fragObj setPosASL _lastPos;
_fragObj setVectorDir _vec; _fragObj setVectorDir _vec;
_fragObj setVelocity _vel; _fragObj setVelocity _vel;
if(GVAR(traceFrags)) then { if (GVAR(traceFrags)) then {
GVAR(TOTALFRAGS) = GVAR(TOTALFRAGS) + 1; INC(GVAR(totalFrags));
[ACE_player, _fragObj, [1,0,0,1]] call FUNC(addTrack); [ACE_player, _fragObj, [1,0,0,1]] call FUNC(addTrack);
}; };
_fragCount = _fragCount + 1; INC(_fragCount);
_currentCount = _currentCount + 1; INC(_currentCount);
}; };
_fragArcs set[_dir, _currentCount]; _fragArcs set [_dir, _currentCount];
}; };
}; };
}; };
//}; //};
if(_fragCount > MAX_FRAG_COUNT) exitWith {}; if (_fragCount > MAX_FRAG_COUNT) exitWith {};
} forEach _objects; } forEach _objects;
if(_fragCount > MAX_FRAG_COUNT) exitWith {}; if (_fragCount > MAX_FRAG_COUNT) exitWith {};
_randomCount = ((ceil((MAX_FRAG_COUNT - _fragCount)*0.1)) max 0)+20; private _randomCount = ((ceil ((MAX_FRAG_COUNT - _fragCount) * 0.1)) max 0) + 20;
_sectorSize = 360 / (_randomCount max 1); private _sectorSize = 360 / (_randomCount max 1);
// _doRandom = false; // _doRandom = false;
if(_doRandom) then { if (_doRandom) then {
for "_i" from 1 to _randomCount do { for "_i" from 1 to _randomCount do {
// Distribute evenly // Distribute evenly
_sectorOffset = 360 * (_i - 1) / (_randomCount max 1); private _sectorOffset = 360 * (_i - 1) / (_randomCount max 1);
_randomDir = random(_sectorSize); private _randomDir = random (_sectorSize);
_vec = [cos(_sectorOffset + _randomDir), sin(_sectorOffset + _randomDir), sin(30 - (random 45))]; _vec = [cos (_sectorOffset + _randomDir), sin (_sectorOffset + _randomDir), sin (30 - (random 45))];
_fp = (_fragPower-(random (_fragPowerRandom))); _fp = (_fragPower - (random (_fragPowerRandom)));
_vel = _vec vectorMultiply _fp; _vel = _vec vectorMultiply _fp;
_fragType = round (random ((count _fragTypes)-1)); _fragType = round (random ((count _fragTypes) - 1));
_fragObj = (_fragTypes select _fragType) createVehicleLocal [0,0,10000]; _fragObj = (_fragTypes select _fragType) createVehicleLocal [0, 0, 10000];
_fragObj setPosASL _lastPos; _fragObj setPosASL _lastPos;
_fragObj setVectorDir _vec; _fragObj setVectorDir _vec;
_fragObj setVelocity _vel; _fragObj setVelocity _vel;
if(GVAR(traceFrags)) then { if (GVAR(traceFrags)) then {
GVAR(TOTALFRAGS) = GVAR(TOTALFRAGS) + 1; INC(GVAR(totalFrags));
[ACE_player, _fragObj, [1,0.5,0,1]] call FUNC(addTrack); [ACE_player, _fragObj, [1,0.5,0,1]] call FUNC(addTrack);
}; };
_fragCount = _fragCount + 1; INC(_fragCount);
}; };
}; };
}; };
// #ifdef DEBUG_MODE_FULL // #ifdef DEBUG_MODE_FULL
// ACE_player sideChat format["total frags: %1", GVAR(TOTALFRAGS)]; // ACE_player sideChat format["total frags: %1", GVAR(totalFrags)];
// ACE_player sideChat format["tracks: %1", (count GVAR(trackedObjects))]; // ACE_player sideChat format["tracks: %1", (count GVAR(trackedObjects))];
// #endif // #endif
// _endTime = diag_tickTime; // _endTime = diag_tickTime;

View File

@ -15,36 +15,35 @@
if (!GVAR(enabled)) exitWith {}; if (!GVAR(enabled)) exitWith {};
private ["_gcIndex", "_iter"]; private _gcIndex = [];
_gcIndex = [];
_iter = 0; private _iter = 0;
while { (count GVAR(objects)) > 0 && { _iter < (GVAR(MaxTrackPerFrame) min (count GVAR(objects))) } } do { private _objectCount = count GVAR(objects);
private ["_object", "_args"]; while {_objectCount > 0 && {_iter < (GVAR(MaxTrackPerFrame) min _objectCount)}} do {
if(GVAR(lastIterationIndex) >= (count GVAR(objects))) then {
if (GVAR(lastIterationIndex) >= _objectCount) then {
GVAR(lastIterationIndex) = 0; GVAR(lastIterationIndex) = 0;
}; };
_object = GVAR(objects) select GVAR(lastIterationIndex); private _object = GVAR(objects) select GVAR(lastIterationIndex);
if(!isNil "_object") then { if (!isNil "_object") then {
_args = GVAR(arguments) select GVAR(lastIterationIndex); private _args = GVAR(arguments) select GVAR(lastIterationIndex);
if(!(_args call FUNC(pfhRound))) then { if (!(_args call FUNC(pfhRound))) then {
_gcIndex pushBack GVAR(lastIterationIndex); // Add it to the GC if it returns false _gcIndex pushBack GVAR(lastIterationIndex); // Add it to the GC if it returns false
}; };
}; };
_iter = _iter + 1; INC(_iter);
GVAR(lastIterationIndex) = GVAR(lastIterationIndex) + 1; INC(GVAR(lastIterationIndex));
}; };
// clean up dead object references // Clean up dead object references
private ["_deletionCount", "_deleteIndex"]; private _deletionCount = 0;
_deletionCount = 0;
{ {
TRACE_1("GC Projectile", _x); TRACE_1("GC Projectile", _x);
_deleteIndex = _x - _deletionCount; private _deleteIndex = _x - _deletionCount;
GVAR(objects) deleteAt _deleteIndex; GVAR(objects) deleteAt _deleteIndex;
GVAR(arguments) deleteAt _deleteIndex; GVAR(arguments) deleteAt _deleteIndex;
_deletionCount = _deletionCount + 1; INC(_deletionCount);
} forEach _gcIndex; } forEach _gcIndex;

View File

@ -1,26 +1,26 @@
#include "script_component.hpp" #include "script_component.hpp"
params ["_round", "_lastPos", "_lastVel", "_type", "_firedFrame", "", "_doSpall", "_spallTrack", "_foundObjectHPIds", "_skip", "_explosive", "_indirectRange", "_force", "_fragPower"]; params ["_round", "_lastPos", "_lastVel", "_type", "_firedFrame", "_gun", "_doSpall", "_spallTrack", "_foundObjectHPIds", "_skip", "_explosive", "_indirectRange", "_force", "_fragPower"];
if(_round in GVAR(blackList)) exitWith { if (_round in GVAR(blackList)) exitWith {
false false
}; };
if (!alive _round) exitWith { if (!alive _round) exitWith {
if((diag_frameno - _firedFrame) > 1) then { //skip if deleted within a single frame if ((diag_frameno - _firedFrame) > 1) then { //skip if deleted within a single frame
if(_skip == 0) then { if (_skip == 0) then {
if((_explosive > 0.5 && {_indirectRange >= 4.5} && {_fragPower >= 35}) || {_force == 1} ) then { if ((_explosive > 0.5 && {_indirectRange >= 4.5} && {_fragPower >= 35}) || {_force == 1}) then {
// shotbullet, shotShell don't seem to explode when touching water, so don't create frags // shotbullet, shotShell don't seem to explode when touching water, so don't create frags
if (((_lastPos select 2) < 0) && {(toLower getText (configFile >> "CfgAmmo" >> _type >> "simulation")) in ["shotbullet", "shotshell"]}) exitWith {}; if (((_lastPos select 2) < 0) && {(toLower getText (configFile >> "CfgAmmo" >> _type >> "simulation")) in ["shotbullet", "shotshell"]}) exitWith {};
[QGVAR(frag_eh), _this] call CBA_fnc_serverEvent; [QGVAR(frag_eh), _this] call CBA_fnc_serverEvent;
}; };
}; };
}; };
if(_doSpall) then { if (_doSpall) then {
GVAR(spallIsTrackingCount) = GVAR(spallIsTrackingCount) - 1; DEC(GVAR(spallIsTrackingCount));
// diag_log text format["F: %1", _foundObjectHPIds]; // diag_log text format ["F: %1", _foundObjectHPIds];
{ {
if(!isNil "_x") then { if (!isNil "_x") then {
_x removeEventHandler ["hitPart", _foundObjectHPIds select _forEachIndex]; _x removeEventHandler ["hitPart", _foundObjectHPIds select _forEachIndex];
}; };
} forEach _spallTrack; } forEach _spallTrack;
@ -28,12 +28,12 @@ if (!alive _round) exitWith {
false false
}; };
_this set[1, (getPosASL _round)]; _this set [1, getPosASL _round];
_this set[2, (velocity _round)]; _this set [2, velocity _round];
if(_doSpall) then { if (_doSpall) then {
private ["_scale"]; private ["_scale"];
_scale = ( (count GVAR(objects)) / GVAR(MaxTrackPerFrame) ) max 0.1; _scale = ((count GVAR(objects)) / GVAR(MaxTrackPerFrame)) max 0.1;
[_round, _scale, _spallTrack, _foundObjectHPIds] call FUNC(spallTrack); [_round, _scale, _spallTrack, _foundObjectHPIds] call FUNC(spallTrack);
}; };

View File

@ -4,8 +4,8 @@
PARAMS_1(_round); PARAMS_1(_round);
if(_round in GVAR(blackList)) then { if (_round in GVAR(blackList)) then {
GVAR(blackList) = GVAR(blackList) - [_round]; REM(GVAR(blackList),_round);
}; };
GVAR(objects) = GVAR(objects) - [_round]; REM(GVAR(objects),_round);

View File

@ -1,12 +1,11 @@
#include "script_component.hpp" #include "script_component.hpp"
private ["_ret"]; private _ret = true;
_ret = true; if (IS_ARRAY(_this select 0)) then {
if(IS_ARRAY((_this select 0))) then {
_ret = false; _ret = false;
} else { } else {
if((_this select 0) in GVAR(trackedObjects)) then { if ((_this select 0) in GVAR(trackedObjects)) then {
GVAR(trackedObjects) = GVAR(trackedObjects) - [(_this select 0)]; REM(GVAR(trackedObjects),_this select 0);
} else { } else {
_ret = false; _ret = false;
}; };

View File

@ -1,29 +1,27 @@
#include "script_component.hpp" #include "script_component.hpp"
private ["_initialData", "_hpData", "_round", "_hpRound", "_hpDirect"]; //player sideChat format ["f: %1 c: %2", (_this select 0), (count GVAR(spallHPData))];
//player sideChat format["f: %1 c: %2", (_this select 0), (count GVAR(spallHPData))];
if ((_this select 0) <= (count GVAR(spallHPData))) then { params ["_index", "_hitPartData"];
_initialData = GVAR(spallHPData) select (_this select 0);
if (!isNil "_initialData") then { private _initialData = GVAR(spallHPData) param [_index, []];
_hpRound = ((_this select 1) select 0) select 2; if (_initialData isEqualTo []) exitWith {};
_round = _initialData select 3;
_hpDirect = ((_this select 1) select 0) select 10; private _hpRound = (_hitPartData select 0) select 2;
if (_hpDirect && {_round == _hpRound}) then { private _round = _initialData select 3;
{ private _hpDirect = (_hitPartData select 0) select 10;
_hpData = _x;
_round = _initialData select 3; if (_hpDirect && {_round == _hpRound}) then {
// diag_log text format["HPDUMP-------------------------------------"]; {
// { // diag_log text format ["HPDUMP-------------------------------------"];
// _hp = _x; // {
// diag_log text format["%1 --", _forEachIndex]; // _hp = _x;
// { // diag_log text format ["%1 --", _forEachIndex];
// diag_log text format["%1: %2", _forEachIndex, _x]; // {
// } forEach _hp; // diag_log text format ["%1: %2", _forEachIndex, _x];
// } forEach (_this select 1); // } forEach _hp;
[DFUNC(doSpall), [_this, _forEachIndex]] call CBA_fnc_execNextFrame; // } forEach (_this select 1);
// player sideChat "WEEE"; [DFUNC(doSpall), [_this, _forEachIndex]] call CBA_fnc_execNextFrame;
} forEach (_this select 1); // player sideChat "WEEE";
}; } forEach _hitPartData;
};
}; };

View File

@ -3,7 +3,7 @@
params ["_round", "_multiplier", "_foundObjects", "_foundObjectHPIds"]; params ["_round", "_multiplier", "_foundObjects", "_foundObjectHPIds"];
private _delta = (1/diag_fps) * _multiplier; private _delta = (1 / diag_fps) * _multiplier;
private _curPos = getPosASL _round; private _curPos = getPosASL _round;
private _velocity = velocity _round; private _velocity = velocity _round;
@ -12,17 +12,15 @@ private _forwardPos = _curPos vectorAdd _velocityStep;
private _intersectsWith = lineIntersectsWith [_curPos, _forwardPos]; private _intersectsWith = lineIntersectsWith [_curPos, _forwardPos];
if (count _intersectsWith > 0) then { if (_intersectsWith isEqualTo []) exitWith {};
// player sideChat format["inter: %1", _intersectsWith];
{ // player sideChat format ["inter: %1", _intersectsWith];
if(!(_x in _foundObjects)) then { {
// diag_log text format["Adding HP: %1", _x]; // diag_log text format ["Adding HP: %1", _x];
private _index = count GVAR(spallHPData); private _index = count GVAR(spallHPData);
private _hpId = _x addEventHandler ["hitPart", compile format["[%1, _this] call " + QFUNC(spallHP), _index]]; private _hpId = _x addEventHandler ["hitPart", compile format ["[%1, _this] call " + QFUNC(spallHP), _index]];
_foundObjects set[(count _foundObjects), _x]; _foundObjects pushBack _x;
_foundObjectHPIds set[(count _foundObjectHPIds), _hpId]; _foundObjectHPIds pushBack _hpId;
private _data = [_hpId, _x, typeOf _round, _round, _curPos, _velocity, 0, _foundObjects, _foundObjectHPIds]; private _data = [_hpId, _x, typeOf _round, _round, _curPos, _velocity, 0, _foundObjects, _foundObjectHPIds];
GVAR(spallHPData) set[_index, _data]; GVAR(spallHPData) pushBack _data;
}; } forEach (_intersectsWith select {!(_x in _foundObjects)});
} forEach _intersectsWith;
};

View File

@ -1,5 +1,5 @@
#include "script_component.hpp" #include "script_component.hpp"
if(!GVAR(tracesStarted)) then {
GVAR(tracesStarted) = true; if (GVAR(tracesStarted)) exitWith {};
GVAR(traceID) = [FUNC(drawTraces), 0, []] call CBA_fnc_addPerFrameHandler; GVAR(tracesStarted) = true;
}; GVAR(traceID) = [FUNC(drawTraces)] call CBA_fnc_addPerFrameHandler;

View File

@ -1,5 +1,5 @@
#include "script_component.hpp" #include "script_component.hpp"
if(GVAR(tracesStarted)) then {
GVAR(tracesStarted) = false; if (!GVAR(tracesStarted)) exitWith {};
[GVAR(traceID)] call CBA_fnc_removePerFrameHandler; GVAR(tracesStarted) = false;
}; [GVAR(traceID)] call CBA_fnc_removePerFrameHandler;

View File

@ -1,12 +1,12 @@
#include "script_component.hpp" #include "script_component.hpp"
params ["_args"]; params ["_args", "_pfhID"];
_args params ["_tracerObj", "_index"]; _args params ["_tracerObj", "_index"];
if (alive _tracerObj && (count GVAR(traces)) > 0) then { if (alive _tracerObj && {!(GVAR(traces) isEqualTo [])}) then {
private _data = GVAR(traces) select _index; private _data = GVAR(traces) select _index;
private _positions = _data select 4; private _positions = _data select 4;
_positions pushBack [(getPos _tracerObj), vectorMagnitude (velocity _tracerObj)]; _positions pushBack [getPos _tracerObj, vectorMagnitude (velocity _tracerObj)];
} else { } else {
[(_this select 1)] call CBA_fnc_removePerFrameHandler; [_pfhID] call CBA_fnc_removePerFrameHandler;
}; };

View File

@ -17,4 +17,4 @@
#include "\z\ace\addons\main\script_macros.hpp" #include "\z\ace\addons\main\script_macros.hpp"
#define ACE_TRACE_DRAW_INC 1 #define ACE_TRACE_DRAW_INC 1