Skip to content

Commit

Permalink
Frag - Spall simulation rewrite (#10247)
Browse files Browse the repository at this point in the history
Co-authored-by: johnb432 <58661205+johnb432@users.noreply.github.com>
Co-authored-by: Grim <69561145+LinkIsGrim@users.noreply.github.com>
Co-authored-by: PabstMirror <pabstmirror@gmail.com>
  • Loading branch information
4 people authored Sep 21, 2024
1 parent bb058cd commit c0b1a45
Show file tree
Hide file tree
Showing 17 changed files with 646 additions and 207 deletions.
2 changes: 1 addition & 1 deletion addons/frag/CfgAmmo.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class CfgAmmo {
ACE_damageType = "grenade"; // compatibility with medical_damage, shrapnel should produce grenade wounds
timeToLive = 4;
typicalSpeed = 1500;
maxSpeed = 1200;
maxSpeed = 1500;
deflecting = 65;
GVAR(skip) = 1;
};
Expand Down
104 changes: 52 additions & 52 deletions addons/frag/CfgAmmoFragParameters.hpp

Large diffs are not rendered by default.

159 changes: 151 additions & 8 deletions addons/frag/CfgAmmoSpall.hpp
Original file line number Diff line number Diff line change
@@ -1,15 +1,158 @@
class GVAR(spall_small): GVAR(small) {
timeToLive = 0.1;
class GVAR(spallBase): B_65x39_Caseless {
GVAR(skip) = 1;
submunitionAmmo[] = {QGVAR(small), 4, QGVAR(medium), 3, QGVAR(large), 2, QGVAR(huge), 1};
submunitionConeType[] = {"random", 20};
submunitionConeAngle = 40;
submunitionDirectionType = "SubmunitionModelDirection";
triggerTime = 0;
submunitionInitialOffset[] = {0, 0, 0};
submunitionInitSpeed = 0;
triggerSpeedCoef[] = {0.75, 1.25};
deleteParentWhenTriggered = 1;
submunitionParentSpeedCoef = 1;
};

class GVAR(spall_medium): GVAR(medium) {
timeToLive = 0.15;

/*
* ground
*/
class GVAR(ground_spall_tiny): GVAR(spallBase) {
submunitionAmmo[] = {QGVAR(tiny), 9, QGVAR(small), 1};
submunitionConeType[] = {"poissondisccenter", 4};
};

class GVAR(ground_spall_small): GVAR(spallBase) {
submunitionAmmo[] = {QGVAR(small), 4, QGVAR(medium), 1};
submunitionConeType[] = {"poissondisccenter", 6};
};

class GVAR(ground_spall_medium): GVAR(spallBase) {
submunitionAmmo[] = {QGVAR(small), 2, QGVAR(small_HD), 1, QGVAR(medium), 3, QGVAR(medium_HD), 1, QGVAR(large), 2};
submunitionConeType[] = {"poissondisccenter", 15};
};

class GVAR(ground_spall_large): GVAR(spallBase) {
submunitionAmmo[] = {QGVAR(tiny), 3, QGVAR(tiny_HD), 3, QGVAR(small), 4, QGVAR(small_HD), 4, QGVAR(medium_HD), 5, QGVAR(large), 1, QGVAR(large_HD), 2};
submunitionConeType[] = {"poissondisccenter", 15};
};

class GVAR(ground_spall_huge): GVAR(spallBase) {
submunitionAmmo[] = {QGVAR(tiny), 3, QGVAR(tiny_HD), 3, QGVAR(small), 4, QGVAR(small_HD), 4, QGVAR(medium), 5, QGVAR(large), 1, QGVAR(large_HD), 2};
submunitionConeType[] = {"poissondisccenter", 20};
};


/*
* rock
*/
class GVAR(rock_spall_tiny): GVAR(spallBase) {
submunitionAmmo[] = {QGVAR(small), 4, QGVAR(medium_HD), 1};
submunitionConeType[] = {"poissondisccenter", 4};
};

class GVAR(rock_spall_small): GVAR(spallBase) {
submunitionAmmo[] = {QGVAR(small), 4, QGVAR(medium), 1};
submunitionConeType[] = {"poissondisccenter", 5};
};

class GVAR(rock_spall_medium): GVAR(spallBase) {
submunitionAmmo[] = {QGVAR(small), 4, QGVAR(medium), 1, QGVAR(medium_HD), 2, QGVAR(large_HD), 1};
submunitionConeType[] = {"poissondisccenter", 7};
};

class GVAR(rock_spall_large): GVAR(spallBase) {
submunitionAmmo[] = {QGVAR(small), 5, QGVAR(medium), 2, QGVAR(large), 1};
submunitionConeType[] = {"poissondisccenter", 10};
};

class GVAR(rock_spall_huge): GVAR(spallBase) {
submunitionAmmo[] = {QGVAR(small), 5, QGVAR(medium), 2, QGVAR(large), 1, QGVAR(huge_HD), 1};
submunitionConeType[] = {"poissondisccenter", 13};
};


/*
* wood
*/
class GVAR(wood_spall_tiny): GVAR(spallBase) {
submunitionAmmo[] = {QGVAR(tiny), 2, QGVAR(small), 4};
submunitionConeType[] = {"poissondisccenter", 4};
};

class GVAR(wood_spall_small): GVAR(spallBase) {
submunitionAmmo[] = {QGVAR(tiny), 2, QGVAR(small), 4, QGVAR(medium), 1};
submunitionConeType[] = {"poissondisccenter", 6};
};

class GVAR(wood_spall_medium): GVAR(spallBase) {
submunitionAmmo[] = {QGVAR(tiny), 2, QGVAR(small), 2, QGVAR(medium), 2, QGVAR(medium_HD), 1, QGVAR(large_HD), 1};
submunitionConeType[] = {"poissondisccenter", 8};
};

class GVAR(wood_spall_large): GVAR(spallBase) {
submunitionAmmo[] = {QGVAR(tiny), 1, QGVAR(small), 3, QGVAR(medium), 2, QGVAR(large_HD), 2, QGVAR(huge_HD), 1};
submunitionConeType[] = {"poissondisccenter", 10};
};

class GVAR(wood_spall_huge): GVAR(spallBase) {
submunitionAmmo[] = {QGVAR(tiny), 1, QGVAR(small), 3, QGVAR(medium), 2, QGVAR(large_HD), 2, QGVAR(huge_HD), 1};
submunitionConeType[] = {"poissondisccenter", 12};
};


/*
* concrete
*/
class GVAR(concrete_spall_tiny): GVAR(spallBase) {
submunitionAmmo[] = {QGVAR(tiny), 6, QGVAR(tiny_HD), 3, QGVAR(small), 1};
submunitionConeType[] = {"poissondisccenter", 4};
};

class GVAR(concrete_spall_small): GVAR(spallBase) {
submunitionAmmo[] = {QGVAR(tiny), 4, QGVAR(tiny_HD), 2, QGVAR(small), 2, QGVAR(medium), 1};
submunitionConeType[] = {"poissondisccenter", 6};
};

class GVAR(concrete_spall_medium): GVAR(spallBase) {
submunitionAmmo[] = {QGVAR(tiny), 6, QGVAR(tiny_HD), 1, QGVAR(small), 4, QGVAR(medium), 5, QGVAR(large_HD), 1};
submunitionConeType[] = {"poissondisccenter", 9};
};

class GVAR(concrete_spall_large): GVAR(spallBase) {
submunitionAmmo[] = {QGVAR(tiny), 6, QGVAR(small), 4, QGVAR(medium), 3, QGVAR(large), 1, QGVAR(large_HD), 2};
submunitionConeType[] = {"poissondisccenter", 12};
};

class GVAR(concrete_spall_huge): GVAR(spallBase) {
submunitionAmmo[] = {QGVAR(tiny), 8, QGVAR(small), 4, QGVAR(medium), 3, QGVAR(large), 1, QGVAR(large_HD), 1, QGVAR(huge_HD), 1};
submunitionConeType[] = {"poissondisccenter", 18};
};


/*
* metal
*/
class GVAR(metal_spall_tiny): GVAR(spallBase) {
submunitionAmmo[] = {QGVAR(tiny), 9, QGVAR(small), 1};
submunitionConeType[] = {"poissondisccenter", 4};
};

class GVAR(metal_spall_small): GVAR(spallBase) {
submunitionAmmo[] = {QGVAR(tiny), 4, QGVAR(small), 2, QGVAR(medium), 1};
submunitionConeType[] = {"poissondisccenter", 6};
};

class GVAR(metal_spall_medium): GVAR(spallBase) {
submunitionAmmo[] = {QGVAR(tiny), 5, QGVAR(small), 4, QGVAR(medium), 2, QGVAR(large), 1};
submunitionConeType[] = {"poissondisccenter", 8};
};

class GVAR(spall_large): GVAR(large) {
timeToLive = 0.25;
class GVAR(metal_spall_large): GVAR(spallBase) {
submunitionAmmo[] = {QGVAR(tiny), 4, QGVAR(small), 3, QGVAR(medium), 2, QGVAR(large), 1, QGVAR(huge), 1};
submunitionConeType[] = {"poissondisccenter", 12};
};

class GVAR(spall_huge): GVAR(huge) {
timeToLive = 0.3;
class GVAR(metal_spall_huge): GVAR(spallBase) {
submunitionAmmo[] = {QGVAR(tiny), 8, QGVAR(small), 3, QGVAR(medium), 2, QGVAR(large), 3, QGVAR(huge), 1};
submunitionConeType[] = {"poissondisccenter", 18};
};
5 changes: 4 additions & 1 deletion addons/frag/XEH_PREP.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,15 @@ PREP(dev_trackHitBox);
PREP(dev_trackObj);
PREP(doExplosions);
PREP(doReflections);
PREP(doSpall);
PREP(doSpallHitPart);
PREP(doSpallPenetrate);
PREP(findReflections);
PREP(fired);
PREP(frago);
PREP(getFragInfo);
PREP(getMaterialInfo);
PREP(getSpallInfo);
PREP(initMaterialCache);
PREP(setClassBlacklisted);
PREP(shouldFrag);
PREP(shouldSpall);
2 changes: 0 additions & 2 deletions addons/frag/XEH_postInit.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,6 @@
[QGVAR(dev_clearTraces), LINKFUNC(dev_clearTraces)] call CBA_fnc_addEventHandler;

if (!hasInterface) exitWith {};
["ace_firedPlayerVehicleNonLocal", LINKFUNC(dev_fired)] call CBA_fnc_addEventHandler;
["ace_firedPlayerNonLocal", LINKFUNC(dev_fired)] call CBA_fnc_addEventHandler;
GVAR(dev_drawPFEH) = [LINKFUNC(dev_drawTrace), 0] call CBA_fnc_addPerFrameHandler;
["ace_interact_menu_newControllableObject", {
params ["_type"];
Expand Down
2 changes: 2 additions & 0 deletions addons/frag/XEH_preInit.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,10 @@ PREP_RECOMPILE_START;
#include "XEH_PREP.hpp"
PREP_RECOMPILE_END;

GVAR(spallMaterialCache) = uiNamespace getVariable QGVAR(spallMaterialCache);
GVAR(spallInfoCache) = createHashMap;
GVAR(shouldSpallCache) = createHashMap;
GVAR(nextSpallAllowTime) = -1;

GVAR(shouldFragCache) = createHashMap;
GVAR(fragInfoCache) = createHashMap;
Expand Down
1 change: 1 addition & 0 deletions addons/frag/XEH_preStart.sqf
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#include "script_component.hpp"

#include "XEH_PREP.hpp"
call FUNC(initMaterialCache);
8 changes: 4 additions & 4 deletions addons/frag/functions/fnc_addBlacklist.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ if (isNull _projectile || {!isClass (configFile >> "CfgAmmo" >> (typeOf _project
};

_projectile setVariable [QGVAR(blacklisted), true];
_projectile removeEventHandler [
"HitPart",
_projectile getVariable [QGVAR(hitPartEventHandler), -1]
];
(_projectile getVariable [QGVAR(spallEH), [-1, -1]]) params ["_hitPartEH", "_penetratedEH"];
_projectile removeEventHandler ["HitPart", _hitPartEH];
_projectile removeEventHandler ["Penetrated", _penetratedEH];

true
121 changes: 0 additions & 121 deletions addons/frag/functions/fnc_doSpall.sqf

This file was deleted.

Loading

0 comments on commit c0b1a45

Please sign in to comment.