Added broadcast flag to addOpenWounds, so we can stack call it followed by a broadcast.

Improvements made to assignOpenWounds, now better results for single hits.
This commit is contained in:
Thomas Kooi 2015-01-22 22:28:04 +01:00
parent b173b21c51
commit dc1098233e
4 changed files with 43 additions and 74 deletions

View File

@ -10,11 +10,12 @@
#include "script_component.hpp"
private ["_unit", "_bodyPart", "_type", "_openWounds", "_selection", "_amount", "_newAmount"];
private ["_unit", "_bodyPart", "_type", "_openWounds", "_selection", "_amount", "_newAmount", "_global"];
_unit = _this select 0;
_bodyPart = _this select 1;
_type = _this select 2;
_amount = _this select 3;
_global = if (count _this > 4) then {_this select 4} else {true};
if (typeName _bodyPart == "STRING") then {
_bodyPart = [_bodyPart] call FUNC(getBodyPartNumber);
@ -40,7 +41,7 @@ if (_newAmount < 0) then {
};
_selection set [ _type, _newAmount];
_openWounds set [ _bodyPart , _selection];
[_unit, QGVAR(openWounds),_openWounds] call EFUNC(common,setDefinedVariable);
[_unit, QGVAR(openWounds),_openWounds, _global] call EFUNC(common,setDefinedVariable);
[_unit] call FUNC(addToInjuredCollection);
["Medical_onOpenWoundsAdded", [_unit, _bodyPart, _type, _amount]] call ace_common_fnc_localEvent;

View File

@ -20,12 +20,9 @@ _sourceOfDamage = _this select 3;
_typeOfProjectile = _this select 4;
_returnDamage = _amountOfDamage;
// From AGM
// This seems to only show up in MP too, but since it doesn't
// collide with anything, I'll check it in SP as well.
if (_selectionName == "r_femur_hit") then {
_selectionName = "leg_r";
// do not function on non local units
if (!local _unit) exitwith {
nil;
};
_bodyPartn = [_selectionName] call FUNC(getBodyPartNumber);
@ -46,37 +43,15 @@ if (isNull _sourceOfDamage && (_selectionName == "head" || isBurning _unit) && _
0
}; // Prefent excessive fire damage
if (local _unit && {([_unit] call FUNC(hasMedicalEnabled))}) then {
if ([_unit] call FUNC(hasMedicalEnabled)) then {
_returnDamage = 0;
if (_amountOfDamage < 0) then {
_amountOfDamage = 0;
};
// Ensure damage is being handled correctly.
[_unit, _bodyPartn, _amountOfDamage] call FUNC(setDamageBodyPart);
_newDamage = [_unit, _amountOfDamage, _bodyPartn] call FUNC(getNewDamageBodyPart);
// From AGM medical:
// Exclude falling damage to everything other than legs; reduce structural damage.
if (((velocity _unit) select 2 < -5) && (vehicle _unit == _unit)) then {
_unit setVariable [QGVAR(isFalling), True];
};
if (_unit getVariable [QGVAR(isFalling), false] && !(_selectionName in ["", "leg_l", "leg_r"])) exitWith {};
if (_unit getVariable [QGVAR(isFalling), false]) then {
_newDamage = _newDamage * 0.7;
};
// Increase damage for kinetic penetrators for people inside vehicles
// to simulate hot spikey things flying around (generally unpleasant).
if ((["ACE_Armour"] call EFUNC(common,isModLoaded_f)) && _projectile != "" && vehicle _unit != _unit) then {
_hit = getNumber (configFile >> "CfgAmmo" >> _projectile >> "hit");
if (_hit >= 100) then {
_hit = linearConversion [100, 1000, _hit, 0, ARMOURCOEF, True];
_newDamage = _newDamage * (1 + _hit);
};
};
// TODO collect everything for 3 frames, then execute the handling for the damage.
[_unit] call FUNC(setDamageBodyPart);
// figure out the type of damage so we can use that to determine what injures should be given.
_typeOfDamage = [_typeOfProjectile] call FUNC(getTypeOfDamage);

View File

@ -10,62 +10,57 @@
#include "script_component.hpp"
private ["_unit", "_amountOfDamage", "_typeOfInjury", "_bodyPartn","_sizeOfWound","_amountOfNewWounds", "_return"];
private ["_unit", "_amountOfDamage", "_typeOfInjury", "_bodyPartn"];
_unit = _this select 0;
_amountOfDamage = _this select 1;
_typeOfInjury = _this select 2;
_bodyPartn = _this select 3;
_sizeOfWound = 0;
_amountOfNewWounds = 0;
_return = false;
if (_amountOfDamage > 0.05) then {
switch (_typeOfInjury) do {
case "Bullet": {
_amountOfNewWounds = 1;
_sizeOfWound = round(random(2));
if (_amountOfDamage > 0.05) exitwith {
switch (toLower _typeOfInjury) do {
case "bullet": {
[_unit, _bodyPartn, round(random(2)), 1, false] call FUNC(addOpenWounds);
};
case "Grenade": {
_amountOfNewWounds = 1;
_sizeOfWound = round(random(2));
if (_sizeOfWound < 1) then {
_sizeOfWound = 1;
case "grenade": {
[_unit, _bodyPartn, round(random(2)), 1] call FUNC(addOpenWounds);
for "_i" from 0 to round(random(3)) /* step +1 */ do {
[_unit, round(random(6)), round(random(2)), 1, false] call FUNC(addOpenWounds);
};
};
case "Explosive": {
_amountOfNewWounds = 1;
_sizeOfWound = round(random(2));
if (_sizeOfWound < 1) then {
_sizeOfWound = 1;
case "explosive": {
[_unit, _bodyPartn, round(random(2)), 1] call FUNC(addOpenWounds);
for "_i" from 0 to round(random(4)) /* step +1 */ do {
[_unit, round(random(6)), round(random(2)), 1, false] call FUNC(addOpenWounds);
};
};
case "Shell": {
_amountOfNewWounds = 1;
_sizeOfWound = round(random(2));
if (_sizeOfWound < 1) then {
_sizeOfWound = 1;
case "shell": {
[_unit, _bodyPartn, round(random(2)), 1] call FUNC(addOpenWounds);
for "_i" from 0 to round(random(5)) /* step +1 */ do {
[_unit, round(random(6)), round(random(2)), 1, false] call FUNC(addOpenWounds);
};
};
case "Unknown": {
_amountOfNewWounds = 1;
_sizeOfWound = round(random(1));
case "backblast": {
if (random(1)>=0.5) then{
[_unit, _bodyPartn, round(random(1)), 1, false] call FUNC(addOpenWounds);
};
};
case "VehicleCrash": {
_amountOfNewWounds = if (random(1)>=0.5) then{0}else{1};
_sizeOfWound = round(random(1));
case "unknown": {
[_unit, _bodyPartn, round(random(1)), 1, false] call FUNC(addOpenWounds);
};
case "vehiclecrash": {
if (random(1)>=0.5) then{
[_unit, _bodyPartn, round(random(1)), 1, false] call FUNC(addOpenWounds);
};
};
default {
_amountOfNewWounds = 1;
_sizeOfWound = round(random(1));
[_unit, _bodyPartn, round(random(1)), 1, false] call FUNC(addOpenWounds);
};
};
if (_sizeOfWound > 2) then {
_sizeOfWound = 3;
};
if (_amountOfNewWounds>0) then {
[_unit, _bodyPartn, _sizeOfWound, _amountOfNewWounds] call FUNC(addOpenWounds);
_return = true;
};
// one more call to broadcast the new injuries
[_unit, _bodyPartn, 0, 0, true] call FUNC(addOpenWounds);
true;
};
_return;
false;

View File

@ -53,5 +53,3 @@
[QGVAR(addedToUnitLoop),false,false, QUOTE(ADDON)] call EFUNC(common,defineVariable);
GVAR(VarDefinesCompleted) = true;
diag_log "finished variable defines";