mirror of
https://github.com/acemod/ACE3.git
synced 2024-08-30 18:23:18 +00:00
added impact angle calculation handle to minimize spawning spall inside walls
This commit is contained in:
parent
210a876c0c
commit
acb7249039
@ -17,26 +17,26 @@
|
|||||||
*/
|
*/
|
||||||
TRACE_1("",_this);
|
TRACE_1("",_this);
|
||||||
params [
|
params [
|
||||||
"_projectile",
|
"_projectile",
|
||||||
["_hitObj", objNull],
|
["_hitObj", objNull],
|
||||||
// "",
|
// "",
|
||||||
["_lPosASL", [0, 0, 0]],
|
["_lPosASL", [0, 0, 0]],
|
||||||
["_lVel", [0, 0, 0]],
|
["_lVel", [0, 0, 0]],
|
||||||
|
["_sNorm", [0, 0, 0]],
|
||||||
// "",
|
// "",
|
||||||
// "",
|
// "",
|
||||||
// "",
|
["_surfaceType", ""],
|
||||||
["_surfaceType", ""],
|
["_ammo", "", [""]],
|
||||||
["_ammo", "", [""]],
|
["_shotParents", [objNull, objNull], [[]]],
|
||||||
["_shotParents", [objNull, objNull], [[]]],
|
["_vUp", [0,0,1]]
|
||||||
["_vUp", [0,0,1]]
|
|
||||||
];
|
];
|
||||||
|
|
||||||
if (CBA_missionTime - GVAR(lastSpallTime) < ACE_FRAG_SPALL_HOLDOFF) exitWith {
|
if (CBA_missionTime - GVAR(lastSpallTime) < ACE_FRAG_SPALL_HOLDOFF) exitWith {
|
||||||
TRACE_2("timeExit",CBA_missionTime,GVAR(lastSpallTime));
|
TRACE_2("timeExit",CBA_missionTime,GVAR(lastSpallTime));
|
||||||
};
|
};
|
||||||
|
|
||||||
if (isNull _hitObj || {_hitObj isKindOf "man"}) exitWith {
|
if (isNull _hitObj || {_hitObj isKindOf "man"}) exitWith {
|
||||||
TRACE_1("invalidHit",_hitObj);
|
TRACE_1("invalidHit",_hitObj);
|
||||||
};
|
};
|
||||||
|
|
||||||
if (_lPosASL isEqualTo [0,0,0]) exitWith {
|
if (_lPosASL isEqualTo [0,0,0]) exitWith {
|
||||||
@ -48,7 +48,6 @@ private _vel = if (alive _projectile) then {
|
|||||||
} else {
|
} else {
|
||||||
[0, 0, 0]
|
[0, 0, 0]
|
||||||
};
|
};
|
||||||
private _lVelUnit = vectorNormalized _lVel;
|
|
||||||
|
|
||||||
|
|
||||||
// Find spall speed / fragment
|
// Find spall speed / fragment
|
||||||
@ -67,32 +66,38 @@ private _material = [_surfaceType] call FUNC(getMaterialInfo);
|
|||||||
TRACE_1("materialCacheRetrieved",_material);
|
TRACE_1("materialCacheRetrieved",_material);
|
||||||
|
|
||||||
//** start calculating where the spalling should come !*! could be better **//
|
//** start calculating where the spalling should come !*! could be better **//
|
||||||
|
private _lVelUnit = vectorNormalized _lVel;
|
||||||
private _unitStep = _lVelUnit vectorMultiply 0.05;
|
private _unitStep = _lVelUnit vectorMultiply 0.05;
|
||||||
private _spallPos = +_lPosASL;
|
private _spallPos = +_lPosASL;
|
||||||
|
|
||||||
|
|
||||||
|
if (120 > acos ((vectorNormalized _lVelUnit) vectorDotProduct _sNorm)) then {
|
||||||
|
_spallPos = _spallPos vectorAdd (_unitStep vectorMultiply 5);
|
||||||
|
};
|
||||||
|
|
||||||
if (terrainIntersectASL [_lPosASL vectorAdd _unitStep, _lPosASL]) exitWith {
|
if (terrainIntersectASL [_lPosASL vectorAdd _unitStep, _lPosASL]) exitWith {
|
||||||
TRACE_3("terrainIntersect",_lPosASL,_unitStep,_lPosASL);
|
TRACE_3("terrainIntersect",_lPosASL,_unitStep,_lPosASL);
|
||||||
};
|
};
|
||||||
// step through
|
// step through
|
||||||
for "_i" from 1 to 20 do
|
for "_i" from 1 to 20 do
|
||||||
{
|
{
|
||||||
private _nPos = _spallPos vectorAdd _unitStep;
|
private _nPos = _spallPos vectorAdd _unitStep;
|
||||||
if (!lineIntersects [_spallPos, _nPos]) then {
|
if (!lineIntersects [_spallPos, _nPos]) then {
|
||||||
_spallPos = _nPos vectorAdd _unitStep;
|
_spallPos = _nPos vectorAdd _unitStep;
|
||||||
break
|
break
|
||||||
};
|
};
|
||||||
_spallPos = _nPos;
|
_spallPos = _nPos;
|
||||||
};
|
};
|
||||||
|
|
||||||
#ifdef DEBUG_MODE_FULL
|
#ifdef DEBUG_MODE_FULL
|
||||||
if GVAR(dbgSphere) then {
|
if GVAR(dbgSphere) then {
|
||||||
[_spallPos, "green"] call FUNC(dev_sphereDraw);
|
[_spallPos, "green"] call FUNC(dev_sphereDraw);
|
||||||
[_lPosASL vectorAdd _lVelUnit, "orange"] call FUNC(dev_sphereDraw);
|
[_lPosASL vectorAdd _lVelUnit, "orange"] call FUNC(dev_sphereDraw);
|
||||||
[_lPosASL, "orange"] call FUNC(dev_sphereDraw);
|
[_lPosASL, "orange"] call FUNC(dev_sphereDraw);
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
//***** Passed all other exit withs, performance o'clock */
|
//***** Passed all exit withs *****//
|
||||||
GVAR(lastSpallTime) = CBA_missionTime;
|
GVAR(lastSpallTime) = CBA_missionTime;
|
||||||
|
|
||||||
//***** Select spalled fragment spawner **//
|
//***** Select spalled fragment spawner **//
|
||||||
|
@ -58,7 +58,7 @@ if (GVAR(spallEnabled) && {_shouldSpall}) then
|
|||||||
"HitPart",
|
"HitPart",
|
||||||
{
|
{
|
||||||
params ["_proj", "_hitObj", "",
|
params ["_proj", "_hitObj", "",
|
||||||
"_posASL", "_vel", "", "",
|
"_posASL", "_vel", "_sNorm", "",
|
||||||
"", "_surfType"
|
"", "_surfType"
|
||||||
];
|
];
|
||||||
private _shotPrnt = getShotParents _proj;
|
private _shotPrnt = getShotParents _proj;
|
||||||
@ -67,12 +67,12 @@ if (GVAR(spallEnabled) && {_shouldSpall}) then
|
|||||||
if (isServer) then {
|
if (isServer) then {
|
||||||
[
|
[
|
||||||
LINKFUNC(doSpallMomentum),
|
LINKFUNC(doSpallMomentum),
|
||||||
[_proj, _hitObj, _posASL, _vel, _surfType, _shotPrnt, _ammo, _vUp]
|
[_proj, _hitObj, _posASL, _vel, _sNorm, _surfType, _ammo, _shotPrnt, _vUp]
|
||||||
] call CBA_fnc_execNextFrame;
|
] call CBA_fnc_execNextFrame;
|
||||||
} else {
|
} else {
|
||||||
[
|
[
|
||||||
QGVAR(spall_eh),
|
QGVAR(spall_eh),
|
||||||
[_proj, _hitObj, _posASL, _vel, _surfType, _shotPrnt, _ammo, _vUp]
|
[_proj, _hitObj, _posASL, _vel, _sNorm, _surfType, _ammo, _shotPrnt, _vUp]
|
||||||
] call CBA_fnc_serverEvent;
|
] call CBA_fnc_serverEvent;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user