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" #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; _unit = _this select 0;
_bodyPart = _this select 1; _bodyPart = _this select 1;
_type = _this select 2; _type = _this select 2;
_amount = _this select 3; _amount = _this select 3;
_global = if (count _this > 4) then {_this select 4} else {true};
if (typeName _bodyPart == "STRING") then { if (typeName _bodyPart == "STRING") then {
_bodyPart = [_bodyPart] call FUNC(getBodyPartNumber); _bodyPart = [_bodyPart] call FUNC(getBodyPartNumber);
@ -40,7 +41,7 @@ if (_newAmount < 0) then {
}; };
_selection set [ _type, _newAmount]; _selection set [ _type, _newAmount];
_openWounds set [ _bodyPart , _selection]; _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); [_unit] call FUNC(addToInjuredCollection);
["Medical_onOpenWoundsAdded", [_unit, _bodyPart, _type, _amount]] call ace_common_fnc_localEvent; ["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; _typeOfProjectile = _this select 4;
_returnDamage = _amountOfDamage; _returnDamage = _amountOfDamage;
// do not function on non local units
// From AGM if (!local _unit) exitwith {
// This seems to only show up in MP too, but since it doesn't nil;
// collide with anything, I'll check it in SP as well.
if (_selectionName == "r_femur_hit") then {
_selectionName = "leg_r";
}; };
_bodyPartn = [_selectionName] call FUNC(getBodyPartNumber); _bodyPartn = [_selectionName] call FUNC(getBodyPartNumber);
@ -46,37 +43,15 @@ if (isNull _sourceOfDamage && (_selectionName == "head" || isBurning _unit) && _
0 0
}; // Prefent excessive fire damage }; // Prefent excessive fire damage
if (local _unit && {([_unit] call FUNC(hasMedicalEnabled))}) then { if ([_unit] call FUNC(hasMedicalEnabled)) then {
_returnDamage = 0; _returnDamage = 0;
if (_amountOfDamage < 0) then { if (_amountOfDamage < 0) then {
_amountOfDamage = 0; _amountOfDamage = 0;
}; };
// Ensure damage is being handled correctly. // Ensure damage is being handled correctly.
[_unit, _bodyPartn, _amountOfDamage] call FUNC(setDamageBodyPart);
_newDamage = [_unit, _amountOfDamage, _bodyPartn] call FUNC(getNewDamageBodyPart); _newDamage = [_unit, _amountOfDamage, _bodyPartn] call FUNC(getNewDamageBodyPart);
[_unit] call FUNC(setDamageBodyPart);
// 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.
// figure out the type of damage so we can use that to determine what injures should be given. // figure out the type of damage so we can use that to determine what injures should be given.
_typeOfDamage = [_typeOfProjectile] call FUNC(getTypeOfDamage); _typeOfDamage = [_typeOfProjectile] call FUNC(getTypeOfDamage);

View File

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

View File

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