Further improved the handling of falling damage:

* Makes sure _projectile is always "falling"
* Enables the creation of wounds in multiple body parts at once
* Caches the initial impact velocity for later damage calculation
* Adjusts the maxDamage value of Large Abrasions
This commit is contained in:
ulteq 2015-06-13 11:53:30 +02:00
parent 234b62b409
commit 84d20f9794
2 changed files with 10 additions and 8 deletions

View File

@ -328,6 +328,7 @@ class ACE_Medical_Advanced {
class Large {
name = CSTRING(Wounds_Abrasion_Large);
minDamage = 0.3;
maxDamage = 0.5;
bleedingRate = 0.0002;
};
};

View File

@ -18,7 +18,7 @@
#include "script_component.hpp"
private ["_unit", "_selectionName","_damage", "_source","_projectile","_hitSelections","_hitPoints","_newDamage","_cache_hitpoints","_cache_projectiles","_cache_params","_cache_damages"];
private ["_unit", "_selectionName", "_damage", "_source", "_projectile", "_hitSelections", "_hitPoints", "_impactVelocity", "_newDamage", "_cache_hitpoints", "_cache_projectiles", "_cache_params", "_cache_damages"];
_unit = _this select 0;
_selectionName = _this select 1;
_damage = _this select 2;
@ -46,17 +46,16 @@ if (vehicle _unit != _unit && {!(vehicle _unit isKindOf "StaticWeapon")} && {isN
};
};
// From AGM medical:
// Exclude falling damage to everything other than legs; reduce structural damage.
if (((velocity _unit) select 2 < -5) && {(vehicle _unit == _unit)}) then {
// Handle falling damage
_impactVelocity = (velocity _unit) select 2;
if (_impactVelocity < -5 && {vehicle _unit == _unit}) then {
_unit setVariable [QGVAR(isFalling), true];
_projectile = "falling";
_this set [4, "falling"];
_unit setVariable [QGVAR(impactVelocity), _impactVelocity];
};
if (_unit getVariable [QGVAR(isFalling), false]) then {
if !(_selectionName in ["", "leg_l", "leg_r"]) then {
if (_selectionName == "body") then {
_newDamage = _newDamage * 0.1;
_newDamage = _newDamage * abs(_unit getVariable [QGVAR(impactVelocity), _impactVelocity]) / 50;
} else {
_newDamage = _newDamage * 0.5;
};
@ -67,6 +66,8 @@ if (_unit getVariable [QGVAR(isFalling), false]) then {
};
_newDamage = _newDamage * 0.7;
};
_projectile = "falling";
_this set [4, "falling"];
};
diag_log format["[handleDamage_caching] Projectile: %1; Velocity: %2 m/s; SelectionName: %3; newDamage: %4", _projectile, (velocity _unit) select 2, _selectionName, _newDamage];
@ -103,7 +104,7 @@ if (_selectionName != "") then {
private ["_index","_otherDamage"];
_index = _cache_projectiles find _projectile;
// Check if the current projectile has already been handled once
if (_index >= 0) exitwith {
if (_index >= 0 && {_projectile != "falling"}) exitwith {
_cache_damages = _unit getVariable QGVAR(cachedDamages);
// Find the previous damage this projectile has done
_otherDamage = (_cache_damages select _index);