Skip to content

Commit

Permalink
Added explosive testing function
Browse files Browse the repository at this point in the history
  • Loading branch information
pterolatypus committed Jun 18, 2021
1 parent 32df51c commit 15086f5
Show file tree
Hide file tree
Showing 4 changed files with 67 additions and 2 deletions.
1 change: 1 addition & 0 deletions addons/medical_damage/XEH_PREP.hpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
PREP(debug_explosiveTest);
PREP(determineIfFatal);
PREP(getTypeOfDamage);
PREP(handleIncapacitation);
Expand Down
63 changes: 63 additions & 0 deletions addons/medical_damage/functions/fnc_debug_explosiveTest.sqf
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
#include "script_component.hpp"
/*
* Author: Pterolatypus
* Testing function that spawns AI units in a spiral around the given point and optionally spawns a projectile at the center
* Used for observing the effects of explosive munitions
*
* Arguments:
* 0: Center position, format PositionAGL <ARRAY>
* 1: Distance to spawn units <ARRAY>
* 0: Min (default: 1)
* 1: Max (default: 10)
* 2: Step (default: 1)
* 2: Unit class to spawn <STRING> (default: "B_Soldier_F")
* 3: Ammo class to spawn, "" or nil to skip <STRING> (default: "")
* 4: Delay between unit placement and ammo spawning in seconds <NUMBER> (default: 1)
* 5: Function to run on each unit that is spawned (optional) <CODE> params [_unit, _center, _ammoClass]
*
* ReturnValue:
* Nothing
*
* Example:
* [position player, [20, 80, 5]] call ace_medical_damage_fnc_debug_explosiveTest
*
* Public: No
*/
params [
"_center",
["_distances", []],
["_unitClass", "B_Soldier_F"],
["_ammoClass", ""],
["_delay", 1],
"_initCode"
];

_distances params [["_min", 1], ["_max", 10], ["_step", 1]];

if (isNil "_center") exitwith {};

_max = _max max _min;
private _nSteps = 0 max ceil ((_max - _min) / _step);
private _angleStep = 360 / (_nSteps + 1);

for "_distance" from _min to _max step _step do {
private _i = (_distance - _min) / _step;
private _angle = _i * _angleStep;
private _offset = [_distance * sin _angle, _distance * cos _angle, 0];
private _position = _center vectorAdd _offset;
private _unit = (createGroup west) createUnit [_unitClass, _position, [], 0, "CAN_COLLIDE"];
if !(isNil "_initCode") then {
[_unit, _center, _ammoClass] call _initCode;
};
};

// spawn the ammo above the ground falling. necessary for shells, doesn't cause problems for grenades etc.
if (_ammoClass != "") then {
[{
params ["_ammoClass", "_center"];
private _position = _center vectorAdd [0, 0, 5];
private _obj = _ammoClass createVehicle _position;
_object setVectorDirAndUp [[0, 0, -1], [0, 1, 0]];
_obj setVelocity [0, 0, -20];
}, [_ammoClass, _center], _delay] call CBA_fnc_waitAndExecute;
};
3 changes: 2 additions & 1 deletion addons/medical_damage/functions/fnc_handleIncapacitation.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,14 @@ private _bodyPartDamage = _unit getVariable [QEGVAR(medical,bodyPartDamage), [0,
_bodyPartDamage params ["_headDamage", "_bodyDamage", "_leftArmDamage", "_rightArmDamage", "_leftLegDamage", "_rightLegDamage"];

// Exclude non penetrating body damage
/*
{
_x params ["", "_bodyPartN", "_amountOf", "", "_damage"];
if (_bodyPartN == 1 && {_damage < PENETRATION_THRESHOLD}) then {
_bodyDamage = _bodyDamage - (_amountOf * _damage);
};
} forEach GET_OPEN_WOUNDS(_unit);

*/
private _damageThreshold = GET_DAMAGE_THRESHOLD(_unit);

if ((_headDamage > _damageThreshold / 2) || {_bodyDamage > _damageThreshold} || {(_painLevel >= PAIN_UNCONSCIOUS) && {random 1 < EGVAR(medical,painUnconsciousChance)}}) then {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ params ["_unit", "_allDamages", "_typeOfDamage"];
private _newDamage = _storedDamage + _damage;

// schedule a task to convert stored damage to wounds after 1s
// because the task resets stored damage to zero, if it isn't currently zero that means there is a task already waiting
// the task resets stored damage to zero, so if it isn't currently zero that means there is a task already waiting
if (_storedDamage == 0 && _newDamage > 0) then {
[{
params ["_unit", "_bodyPart", "_typeOfDamage"];
Expand Down

0 comments on commit 15086f5

Please sign in to comment.