2024-01-11 20:01:50 +00:00
|
|
|
#include "..\script_component.hpp"
|
2024-01-09 20:00:43 +00:00
|
|
|
/*
|
|
|
|
* Author: Lambda.Tiger
|
2024-02-16 03:03:12 +00:00
|
|
|
* This function returns a classification of material type based on the surface hit.
|
2024-01-13 06:35:22 +00:00
|
|
|
*
|
2024-01-09 20:00:43 +00:00
|
|
|
* Arguments:
|
2024-02-16 03:03:12 +00:00
|
|
|
* 0: Surface type given as either a CfgSurfaces path or .bisurf filepath, same format as "HitPart" projectile parameter <STRING>
|
2024-01-13 06:35:22 +00:00
|
|
|
*
|
2024-01-09 20:00:43 +00:00
|
|
|
* Return Value:
|
2024-02-16 03:03:12 +00:00
|
|
|
* Material categories as expanded on in line 44 below <STRING>
|
2024-01-09 20:00:43 +00:00
|
|
|
*
|
|
|
|
* Example:
|
2024-03-29 00:33:56 +00:00
|
|
|
* "a3\data_f\penetration\concrete.bisurf" call ace_frag_fnc_getMaterialInfo
|
2024-01-09 20:00:43 +00:00
|
|
|
*
|
|
|
|
* Public: No
|
|
|
|
*/
|
2024-03-01 18:51:21 +00:00
|
|
|
|
2024-02-16 03:03:12 +00:00
|
|
|
#define ACE_FRAG_SOUNDENVIRON_STR_LEN 12
|
2024-03-03 04:28:41 +00:00
|
|
|
#define ACE_FRAG_SOUNDHIT_STR_LEN 8
|
2024-02-16 03:03:12 +00:00
|
|
|
#define ACE_FRAG_MATERIAL_SEARCH_LEN 10
|
2024-01-09 20:00:43 +00:00
|
|
|
|
|
|
|
params ["_surfType"];
|
|
|
|
|
2024-01-11 20:01:50 +00:00
|
|
|
private _material = GVAR(spallMaterialCache) get _surfType;
|
2024-01-09 20:00:43 +00:00
|
|
|
|
2024-01-09 23:25:09 +00:00
|
|
|
TRACE_2("materialCache",_surfType,_material);
|
2024-03-03 04:28:41 +00:00
|
|
|
if (!isNil "_material") exitWith {_material};
|
2024-01-13 06:35:22 +00:00
|
|
|
// Use 'soundEnviron' or 'soundHit' to extract approx material
|
2024-01-16 00:47:06 +00:00
|
|
|
private _surfaceConfig = configFile >> "CfgSurfaces" >> _surfType;
|
|
|
|
if (isClass _surfaceConfig) then {
|
|
|
|
_material = getText (_surfaceConfig >> "soundEnviron");
|
2024-02-14 22:50:09 +00:00
|
|
|
if (_material == "" || {_material == "empty"}) then {
|
2024-01-16 00:47:06 +00:00
|
|
|
_material = getText (_surfaceConfig >> "soundhit");
|
2024-01-13 06:35:22 +00:00
|
|
|
};
|
2024-01-18 02:48:27 +00:00
|
|
|
} else { // Messy way when a surface isn't added to CfgSurfaces
|
2024-01-15 19:55:15 +00:00
|
|
|
private _surfFileText = toLowerANSI preprocessFile _surfType;
|
2024-01-11 00:51:38 +00:00
|
|
|
_surfFileText = _surfFileText regexReplace ["[^a-z0-9]", ""];
|
2024-01-15 22:10:01 +00:00
|
|
|
private _idx = ACE_FRAG_SOUNDENVIRON_STR_LEN + (_surfFileText find "soundenviron");
|
2024-01-11 00:51:38 +00:00
|
|
|
if (_surfFileText select [_idx, 5] isEqualTo "empty") then {
|
2024-03-03 04:28:41 +00:00
|
|
|
_idx = ACE_FRAG_SOUNDHIT_STR_LEN + (_surfFileText find "soundhit");
|
2024-01-11 00:51:38 +00:00
|
|
|
};
|
2024-01-15 21:18:42 +00:00
|
|
|
_material = _surfFileText select [_idx, ACE_FRAG_MATERIAL_SEARCH_LEN];
|
2024-01-09 23:25:09 +00:00
|
|
|
};
|
2024-01-10 06:17:56 +00:00
|
|
|
TRACE_1("materialSubString",_material);
|
2024-01-09 20:00:43 +00:00
|
|
|
|
2024-01-09 23:25:09 +00:00
|
|
|
_material = switch (true) do {
|
|
|
|
case ("dirt" in _material);
|
|
|
|
case ("grass" in _material): { "ground" };
|
|
|
|
case ("gravel" in _material);
|
|
|
|
case ("rock" in _material): { "rock" };
|
|
|
|
case ("wood" in _material): { "wood" };
|
|
|
|
case ("lino" in _material);
|
2024-01-11 00:51:38 +00:00
|
|
|
case ("building" in _material);
|
2024-01-09 23:25:09 +00:00
|
|
|
case ("concrete" in _material): { "concrete" };
|
|
|
|
case ("metal" in _material): { "metal" };
|
|
|
|
default { "ground" };
|
|
|
|
};
|
|
|
|
|
2024-01-11 20:01:50 +00:00
|
|
|
GVAR(spallMaterialCache) set [_surfType, _material];
|
2024-01-09 23:25:09 +00:00
|
|
|
TRACE_2("materialCacheSet",_surfType,_material);
|
2024-01-09 20:00:43 +00:00
|
|
|
|
2024-01-15 19:39:19 +00:00
|
|
|
_material
|