mirror of
https://github.com/acemod/ACE3.git
synced 2024-08-30 18:23:18 +00:00
possilbe "magic number" cleanup and formatting
This commit is contained in:
parent
ff462333cb
commit
54c4f45cf9
@ -1,5 +1,5 @@
|
||||
#include "..\script_component.hpp"
|
||||
#define HITBOX_DRAW_PATH [[3 , 2 , 1 , 5 , 6 , 7 , 3 , 0 , 4 , 5], [0, 1], [2, 6], [7, 4]]
|
||||
#define HITBOX_DRAW_PATH [[3, 2, 1, 5, 6, 7, 3, 0, 4, 5], [0, 1], [2, 6], [7, 4]]
|
||||
/*
|
||||
* Author: Lambda.Tiger
|
||||
* Per frame function to draw all dev traces
|
||||
|
@ -37,12 +37,12 @@ if (_aID > -1 && {_lastUnit isNotEqualTo objNull}) then {
|
||||
_aID = _currentUnit addAction [
|
||||
"Reset Lines",
|
||||
FUNC(dev_clearTraces),
|
||||
nil, // arguments
|
||||
1.5, // priority
|
||||
true, // showWindow
|
||||
false, // hideOnUse
|
||||
"", // shortcut
|
||||
"true", // condition
|
||||
nil,
|
||||
1.5,
|
||||
true,
|
||||
false,
|
||||
"",
|
||||
"true",
|
||||
8
|
||||
];
|
||||
|
||||
|
@ -36,34 +36,34 @@ if (_shotParentVic getVariable [QGVAR(nextFragTime), -1] > CBA_missionTime) exit
|
||||
_shotParentVic setVariable [QGVAR(nextFragTime), CBA_missionTime + ACE_FRAG_HOLDOFF_VEHICLE];
|
||||
|
||||
// Check normal round timeout and adjust _max frags
|
||||
private _timeSince = CBA_missionTime - GVAR(lastFragTime);
|
||||
if (_ammo isEqualTo "" || {_posASL isEqualTo [0, 0, 0] || _timeSince < ACE_FRAG_HOLDOFF}) exitWith {
|
||||
TRACE_3("timeExit",_timeSince,CBA_missionTime,GVAR(lastFragTime));
|
||||
private _timeSinceLastFrag = CBA_missionTime - GVAR(lastFragTime);
|
||||
if (_ammo isEqualTo "" || {_posASL isEqualTo [0, 0, 0] || _timeSinceLastFrag < ACE_FRAG_HOLDOFF}) exitWith {
|
||||
TRACE_3("timeExit",_timeSinceLastFrag,CBA_missionTime,GVAR(lastFragTime));
|
||||
};
|
||||
private _maxFrags = round linearConversion [0.1, 1.5, _timeSince, ACE_FRAG_COUNT_MIN, ACE_FRAG_COUNT_MAX, true];
|
||||
TRACE_3("willFrag",_timeSince,CBA_missionTime,_maxFrags);
|
||||
private _maxFragCount = round linearConversion [0.1, 1.5, _timeSinceLastFrag, ACE_FRAG_COUNT_MIN, ACE_FRAG_COUNT_MAX, true];
|
||||
TRACE_3("willFrag",_timeSinceLastFrag,CBA_missionTime,_maxFragCount);
|
||||
|
||||
|
||||
private _ammoArr = [_ammo] call FUNC(getFragInfo);
|
||||
_ammoArr params ["_fragRange", "_fragVel", "_fragTypes", "_modFragCount"];
|
||||
// For low frag rounds limit the # of frags
|
||||
// For low frag rounds limit the # of frags created
|
||||
if (_modFragCount < 10) then {
|
||||
_maxFrags = _modFragCount*4;
|
||||
GVAR(lastFragTime) = CBA_missionTime - 0.1;
|
||||
_maxFragCount = _modFragCount * ACE_FRAG_LOW_FRAG_COEFF;
|
||||
GVAR(lastFragTime) = CBA_missionTime - ACE_FRAG_LOW_FRAG_HOLDOFF_REDUCTION;
|
||||
} else {
|
||||
GVAR(lastFragTime) = CBA_missionTime;
|
||||
};
|
||||
// Offset for ground clearance
|
||||
private _heightAGL = (ASLToAGL _posASL)#2;
|
||||
if (_heightAGL < 0.25) then {
|
||||
_posASL = _posASL vectorAdd [0, 0, 0.25];
|
||||
private _heightATL = (ASLToATL _posASL)#2;
|
||||
if (_heightATL < ACE_FRAG_MIN_GROUND_OFFSET) then {
|
||||
_posASL = _posASL vectorAdd [0, 0, ACE_FRAG_MIN_GROUND_OFFSET];
|
||||
};
|
||||
|
||||
TRACE_3("fnc_doFragTargeted IF", _fragRange, _timeSince, GVAR(fragSimComplexity));
|
||||
if (_fragRange > 3 && _timeSince > ACE_FRAG_HOLDOFF*1.5 && GVAR(fragSimComplexity) != 1) then {
|
||||
_maxFrags = _maxFrags - ([_posASL, _fragVel, _fragRange, _maxFrags, _fragTypes, _modFragCount, _shotParents] call FUNC(doFragTargeted));
|
||||
TRACE_3("fnc_doFragTargeted IF", _fragRange, _timeSinceLastFrag, GVAR(fragSimComplexity));
|
||||
if (GVAR(fragSimComplexity) != 1 && _fragRange > 3) then {
|
||||
_maxFragCount = _maxFragCount - ([_posASL, _fragVel, _fragRange, _maxFragCount, _fragTypes, _modFragCount, _shotParents] call FUNC(doFragTargeted));
|
||||
};
|
||||
|
||||
if (_timeSince > 0.2 && {GVAR(fragSimComplexity) > 0}) then {
|
||||
[_posASL, _velocity, _heightAGL, _fragTypes, _maxFrags, _shotParents] call FUNC(doFragRandom);
|
||||
if (GVAR(fragSimComplexity) > 0) then {
|
||||
[_posASL, _velocity, _heightATL, _fragTypes, _maxFragCount, _shotParents] call FUNC(doFragRandom);
|
||||
};
|
||||
|
@ -25,10 +25,10 @@ params [
|
||||
["_fragVelocity", [0,0,0]],
|
||||
["_heightAGL", 2, [123]],
|
||||
["_fragType", [], [[]]],
|
||||
["_fragCnt", 10, [123]],
|
||||
["_maxFragCount", 10, [123]],
|
||||
["_shotParents", [objNull, objNull], [[]], [2]]
|
||||
];
|
||||
TRACE_5("fnc_doFragRandom", _posASL, _fragVelocity, _heightAGL, _fragType, _fragCnt);
|
||||
TRACE_6("doFragRandom",_posASL,_fragVelocity,_heightAGL,_fragType,_maxFragCount,_shotParents);
|
||||
|
||||
// See cfgAmmoFragSpawner for different frag types
|
||||
private _hMode = switch (true) do {
|
||||
@ -44,14 +44,14 @@ private _type = if (count _fragType > 0 &&
|
||||
QGVAR(def_small_)
|
||||
};
|
||||
|
||||
_fragCnt = switch (true) do {
|
||||
case (_fragCnt <= 5): {"5"};
|
||||
case (_fragCnt <= 10): {"10"};
|
||||
_maxFragCount = switch (true) do {
|
||||
case (_maxFragCount <= 5): {"5"};
|
||||
case (_maxFragCount <= 10): {"10"};
|
||||
default {"15"};
|
||||
};
|
||||
|
||||
// Spawn the fragment spawner
|
||||
private _fragSpawner = createVehicle [_type + _fragCnt + _hMode, ASLToATL _posASL, [], 0, "CAN_COLLIDE"];
|
||||
private _fragSpawner = createVehicle [_type + _maxFragCount + _hMode, ASLToATL _posASL, [], 0, "CAN_COLLIDE"];
|
||||
_fragSpawner setVectorDirandUp [[0,0,1], [1,0,0]];
|
||||
_fragSpawner setVelocity _fragVelocity;
|
||||
_fragSpawner setShotParents _shotParents;
|
||||
|
@ -1,4 +1,7 @@
|
||||
#include "..\script_component.hpp"
|
||||
#define ACE_FRAG_SOUNDENVIRON_STR_LEN 12
|
||||
#define ACE_FRAG_SOUNDGIT_STR_LEN 8
|
||||
#define ACE_FRAG_MATERIAL_SEARCH_LEN 10
|
||||
/*
|
||||
* Author: Lambda.Tiger
|
||||
* This function returns a classification of material type based
|
||||
@ -33,11 +36,11 @@ if (isClass (configFile >> "CfgSurfaces" >> _surfType)) then {
|
||||
} else { // Messy way when a surface isn't added to cfgSurfaces
|
||||
private _surfFileText = toLowerANSI preprocessFile _surfType;
|
||||
_surfFileText = _surfFileText regexReplace ["[^a-z0-9]", ""];
|
||||
private _idx = 12 + (_surfFileText find "soundenviron");
|
||||
private _idx = ACE_FRAG_SOUNDENVIRON_STR_LEN + (_surfFileText find "soundenviron");
|
||||
if (_surfFileText select [_idx, 5] isEqualTo "empty") then {
|
||||
_idx = 8 + (_surfFileText find "soundhit");
|
||||
_idx = ACE_FRAG_SOUNDGIT_STR_LEN + (_surfFileText find "soundhit");
|
||||
};
|
||||
_material = _surfFileText select [_idx, 10];
|
||||
_material = _surfFileText select [_idx, ACE_FRAG_MATERIAL_SEARCH_LEN];
|
||||
};
|
||||
TRACE_1("materialSubString",_material);
|
||||
|
||||
|
@ -47,8 +47,7 @@ if (_shouldFrag && GVAR(enabled)) then {
|
||||
|
||||
|
||||
private _shouldSpall = _ammo call FUNC(shouldSpall);
|
||||
if (GVAR(spallEnabled) && {_shouldSpall}) then
|
||||
{
|
||||
if (GVAR(spallEnabled) && {_shouldSpall}) then {
|
||||
_projectile addEventHandler [
|
||||
"HitPart",
|
||||
{
|
||||
|
@ -31,4 +31,7 @@
|
||||
#define ACE_FRAG_HALF_GRAVITY_APPROX 4.905
|
||||
// stop searching at 0.5% chance to hit
|
||||
#define ACE_FRAG_MIN_FRAG_HIT_CHANCE 0.005
|
||||
#define ACE_FRAG_MIN_GROUND_OFFSET 0.25
|
||||
#define ACE_FRAG_LOW_FRAG_COEFF 4
|
||||
#define ACE_FRAG_LOW_FRAG_HOLDOFF_REDUCTION 4
|
||||
#define ACE_FRAG_SPALL_VELOCITY_INHERIT_COEFF 2
|
||||
|
Loading…
Reference in New Issue
Block a user