Merge pull request #1602 from acemod/medicalFallingFix2

[Adv. Medical] Improved falling damage
This commit is contained in:
Glowbal 2015-06-13 13:39:22 +02:00
commit e0bb3c0a4e
2 changed files with 22 additions and 13 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,21 +46,29 @@ 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];
_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 * abs(_unit getVariable [QGVAR(impactVelocity), _impactVelocity]) / 50;
} else {
_newDamage = _newDamage * 0.5;
};
} else {
if (_selectionName == "") then {
_selectionName = ["leg_l", "leg_r"] select (floor(random 2));
_this set [1, _selectionName];
};
_newDamage = _newDamage * 0.7;
};
_projectile = "falling";
_this set [4, "falling"];
};
if (_unit getVariable [QGVAR(isFalling), false] && {!(_selectionName in ["", "leg_l", "leg_r"])}) exitWith {0};
if (_unit getVariable [QGVAR(isFalling), false]) then {
if (_selectionName == "") then {
_selectionName = ["leg_l", "leg_r"] select (floor(random 2));
};
_this set [1, _selectionName];
_newDamage = _newDamage * 0.7;
};
// Finished with the current frame, reset variables
// Note: sometimes handleDamage spans over 2 or even 3 frames.
@ -95,7 +103,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);