add some more functions to engine component

This commit is contained in:
commy2 2016-09-30 11:23:07 +02:00
parent 1196cbb210
commit 77f21e9441
5 changed files with 72 additions and 4 deletions

View File

@ -2,4 +2,6 @@
PREP(handleDamage);
PREP(playInjuredSound);
PREP(damageBodyPart);
PREP(setLimping);
PREP(updatePainSway);
PREP(setStructuralDamage);

View File

@ -5,7 +5,7 @@
* Arguments:
* 0: Unit <OBJECT>
* 1: Selection, can be "Head", "Body", "Arms" or "Legs" <STRING>
* 2: Damage (optional, default: 1) <BOOLEAN>
* 2: Damage (optional, default: true) <BOOLEAN>
*
* Return Value:
* None
@ -29,7 +29,7 @@ if (!local _unit) exitWith {
ACE_LOGERROR("Unit not local or null");
};
_damage = [0, 0.99] select _damage;
_damage = [0, 0.495] select _damage;
switch (toLower _selection) do {
case ("head"): {
@ -39,9 +39,9 @@ switch (toLower _selection) do {
_unit setHitPointDamage ["HitBody", _damage];
};
case ("arms"): {
_unit setHitPointDamage ["HitHands", _damage];
_unit setHitPointDamage ["HitHands", _damage + (_unit getVariable [QGVAR(painSway), 0])];
};
case ("legs"): {
_unit setHitPointDamage ["HitLegs", _damage];
_unit setHitPointDamage ["HitLegs", _damage + ([0, LIMPING_MIN_DAMAGE] select (_unit getVariable [QGVAR(isLimping), false]))];
};
};

View File

@ -0,0 +1,29 @@
/*
* Author: commy2
* Forces a unit to limp or not.
*
* Arguments:
* 0: Unit <OBJECT>
* 1: Limping (optional, default: true) <BOOLEAN>
*
* Return Value:
* None
*
* Example:
* [player, true] call ace_medical_engine_fnc_setLimping
*
* Public: No
*/
#include "script_component.hpp"
params [["_unit", objNull, [objNull]], ["_isLimping", true, [false]]];
if (!local _unit) exitWith {
ACE_LOGERROR("Unit not local or null");
};
private _damage = [0, LIMPING_MIN_DAMAGE] select _isLimping;
_unit setHitPointDamage ["HitLegs", _damage];
_unit setVariable [QGVAR(isLimping), _isLimping, true];

View File

@ -0,0 +1,32 @@
/*
* Author: commy2
* Updates weapon sway caused by pain.
*
* Arguments:
* 0: Unit <OBJECT>
*
* Return Value:
* None
*
* Example:
* player call ace_medical_engine_fnc_updatePainSway
*
* Public: No
*/
#include "script_component.hpp"
params [["_unit", objNull, [objNull]]];
if (!local _unit) exitWith {
ACE_LOGERROR("Unit not local or null");
};
private _damage = PAIN_MAX_DAMAGE * ((_unit getVariable [QEGVAR(medical,pain), 0]) min 1);
_unit setVariable [QGVAR(painSway), _damage];
if (_unit getHitPointDamage "HitHands" > DAMAGED_MIN_THRESHOLD) then {
_damage = _damage + DAMAGED_MIN_THRESHOLD;
};
_unit setHitPointDamage ["HitHands", _damage];

View File

@ -42,3 +42,8 @@
#define PRIORITY_RIGHT_ARM (1 + random 1)
#define PRIORITY_LEFT_LEG (1 + random 1)
#define PRIORITY_RIGHT_LEG (1 + random 1)
// don't change, these reflect hard coded engine behaviour
#define DAMAGED_MIN_THRESHOLD 0.495
#define PAIN_MAX_DAMAGE 0.345
#define LIMPING_MIN_DAMAGE 0.5