Minor code clean up

This commit is contained in:
Thomas Kooi 2015-01-22 22:00:37 +01:00
parent 68ab7b5143
commit 8137080bbc
4 changed files with 55 additions and 32 deletions

View File

@ -21,14 +21,14 @@ class Extended_Killed_Eventhandlers {
class Extended_Local_Eventhandlers {
class CaManBase {
class ADDON {
class ADDON {
Local = QUOTE(_this call FUNC(eh_local));
};
};
};
class Extended_Init_Eventhandlers {
class CaManBase {
class ADDON {
class ADDON {
init = QUOTE(_this call FUNC(onInitForUnit););
};
};

View File

@ -22,7 +22,7 @@ _selectionName = _this select 0;
1
};
case "hands": {
if (random(1)>0.499) then {
if (random(1)>=0.5) then {
2
} else {
3
@ -35,7 +35,7 @@ _selectionName = _this select 0;
3
};
case "legs": {
if (random(1)>0.499) then {
if (random(1)>=0.5) then {
4
} else {
5

View File

@ -10,7 +10,7 @@
#include "script_component.hpp"
private ["_unit", "_caller", "_selectionName", "_removeItem", "_prevAnim"];
private ["_unit", "_caller", "_selectionName", "_removeItem", "_prevAnim", "_value"];
_caller = _this select 0;
_target = _this select 1;
_selectionName = _this select 2;
@ -38,12 +38,7 @@ if (count _attributes > 1) then {
_value = _value + (_attributes select 1);
[_target,(_attributes select 0),_value] call EFUNC(common,setDefinedVariable);
_patient = "patient";
if (_target == _caller) then {
_patient = "himself";
};
// TODO localization
[_target,"treatment",format["%1 has given %4 a %2(%3ml)",[_caller] call cse_fnc_getName,_attributes select 2,_attributes select 1,_target]] call FUNC(addActivityToLog);
[_target,_removeItem] call FUNC(addToTriageList);
};
};

View File

@ -1,25 +1,53 @@
/**
* fnc_setDamageBodyPart.sqf
* @Descr: N/A
* @Author: Glowbal
*
* @Arguments: []
* @Return:
* @PublicAPI: false
*/
#include "script_component.hpp"
private ["_unit", "_bodyPart", "_amountOfDamage"];
private ["_unit", "_bodyStatus", "_headDamage", "_torsoDamage", "_handsDamage", "_legsDamage"];
_unit = _this select 0;
_bodyPart = _this select 1;
_amountOfDamage = _this select 2;
if (alive _unit) then {
_hitPointName = switch (_bodyPart) do {
case 0: {"hitHead"};
case 1: {"hitBody"};
case 2: {"hitHands"};
case 3: {"hitHands"};
case 4: {"hitLegs"};
case 5: {"hitLegs"};
default {"hitLegs"};
};
if (_amountOfDamage < 0.95) then {
_unit setHitPointDamage [_hitPointName, _amountOfDamage];
_unit setHit [_selectionName, _amountOfDamage];
} else {
_unit setHitPointDamage [_hitPointName, 0.95];
_unit setHit [_selectionName, 0.95];
};
};
if (!local _unit) exitwith {
// execute only local
};
_bodyStatus = [_unit,QGVAR(bodyPartStatus),[0,0,0,0,0,0]] call EFUNC(common,getDefinedVariable);
// ["head", "body", "hand_l", "hand_r", "leg_l", "leg_r"]
_headDamage = _bodyStatus select 0;
if (_headDamage > 0.95) then {
_unit setHitPointDamage ["hitHead", 0.95];
} else {
_unit setHitPointDamage ["hitHead", _headDamage];
};
_torsoDamage = _bodyStatus select 1;
if (_torsoDamage > 0.95) then {
_unit setHitPointDamage ["hitBody", 0.95];
} else {
_unit setHitPointDamage ["hitBody", _torsoDamage];
};
_handsDamage = (_bodyStatus select 2) + (_bodyStatus select 3);
if (_handsDamage > 0.95) then {
_unit setHitPointDamage ["hitHands", 0.95];
} else {
_unit setHitPointDamage ["hitHands", _handsDamage];
};
_legsDamage = (_bodyStatus select 4) + (_bodyStatus select 5);
if (_legsDamage > 0.95) then {
_unit setHitPointDamage ["hitLegs", 0.95];
} else {
_unit setHitPointDamage ["hitLegs", _legsDamage];
};
if ({_x > 0} count _bodyStatus == 0) then {
_unit setDamage 0;
};