Skip to content

Commit

Permalink
-Added error handling for drawing of curator icons
Browse files Browse the repository at this point in the history
-Added check for damage from curator sources such as the howitzer, mortar, or rockets
-Added error handling for drawing of player icons
  • Loading branch information
chessmaster42 committed Nov 18, 2014
1 parent 77a55ac commit cdc5c8a
Show file tree
Hide file tree
Showing 5 changed files with 85 additions and 61 deletions.
Binary file modified src/addons/cws_injury.pbo
Binary file not shown.
Binary file modified src/addons/cws_injury.pbo.chessmaster42.bisign
Binary file not shown.
71 changes: 38 additions & 33 deletions src/addons/cws_injury/functions/common/fn_DrawCuratorIcons.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -11,42 +11,47 @@ cws_ais_debugging = false;
//Iterate through all units in groups
{
{
if(isNil "_x") then {
//Do nothing
} else {
try {
if(isNil "_x") then {
throw "Unit is nil";
};
if(isNull _x) then {
//Do nothing
} else {
if(alive _x) then {
if (_x getVariable ["cws_ais_aisInit", false]) then {
//Build the config for the icon
_unitDamage = [_x] call cws_fnc_GetUnitDamage;
_iconColor = [1, 1 - _unitDamage, 1 - _unitDamage, 0.5 + _unitDamage * 0.5];
_pos = visiblePosition _x;
_pos set [2, (_pos select 2) + 4];
_icon_size = 0.5;
_angle = 0;
_message = "CWS";
_text_size = 0.025;

//Add bleedout time if the unit is in agony
if(_x getVariable ["cws_ais_agony", false]) then {
_life_remaining = _x getVariable ["cws_ais_bleedout_time", 0];
_message = _message + format[" (%1%2)", ceil (_life_remaining * 100), "%"];

//Add healing percentage if the unit is being healed
_healingProgress = _x getVariable ["cws_ais_healing_progress", 0];
if(_healingProgress > 0) then {
_message = _message + format[" (%1%2)", ceil (_healingProgress * 100), "%"];
_iconColor = [0, 1, 0, 1];
};
};

//Draw the icon in 3D space
drawIcon3D["a3\ui_f\data\map\MapControl\hospital_ca.paa", _iconColor, _pos, _icon_size, _icon_size, _angle, _message, 0, _text_size];
};
throw "Unit is null";
};
if(!alive _x) then {
throw "Unit is dead";
};
if (!(_x getVariable ["cws_ais_aisInit", false])) then {
throw "Unit is not running CWS";
};

//Build the config for the icon
_unitDamage = [_x] call cws_fnc_GetUnitDamage;
_iconColor = [1, 1 - _unitDamage, 1 - _unitDamage, 0.5 + _unitDamage * 0.5];
_pos = visiblePosition _x;
_pos set [2, (_pos select 2) + 4];
_icon_size = 0.5;
_angle = 0;
_message = "CWS";
_text_size = 0.025;

//Add bleedout time if the unit is in agony
if(_x getVariable ["cws_ais_agony", false]) then {
_life_remaining = _x getVariable ["cws_ais_bleedout_time", 0];
_message = _message + format[" (%1%2)", ceil (_life_remaining * 100), "%"];

//Add healing percentage if the unit is being healed
_healingProgress = _x getVariable ["cws_ais_healing_progress", 0];
if(_healingProgress > 0) then {
_message = _message + format[" (%1%2)", ceil (_healingProgress * 100), "%"];
_iconColor = [0, 1, 0, 1];
};
};

//Draw the icon in 3D space
drawIcon3D["a3\ui_f\data\map\MapControl\hospital_ca.paa", _iconColor, _pos, _icon_size, _icon_size, _angle, _message, 0, _text_size];
} catch {
//Do nothing
};
} forEach units _x;
} forEach allGroups;
Expand Down
15 changes: 11 additions & 4 deletions src/addons/cws_injury/functions/cws/fn_handleDamage.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,17 @@ if(cws_ais_debugging) then {
_scaled_damage = _damage / (cws_ais_rambofactor max 1);
_agony = false;

//Stop any damage that doesn't have a source defined
//This is a known bug with HandleDamage EVH
//TODO - Check and see if this is still needed
if(isNull _source) exitWith {0};
_curatorMunitions = ["ModuleOrdnanceMortar_F_ammo", "ModuleOrdnanceHowitzer_F_ammo", "ModuleOrdnanceRocket_F_Ammo"];

//Skip null source check if the ammo is from one of the Curator ordnance types
if(_ammo in _curatorMunitions) then {
//Do nothing
} else {
//Stop any damage that doesn't have a source defined
//This is a known bug with HandleDamage EVH
//TODO - Check and see if this is still needed
if(isNull _source) exitWith {0};
};

//Skip over the unit if it's not local
if(!local _unit) exitWith {0};
Expand Down
60 changes: 36 additions & 24 deletions src/addons/cws_injury/functions/loaders/fn_LoadCWS.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -101,32 +101,44 @@ if (cws_ais_show_3d_icons && (_unit == player)) then {
_playerFaction = side player;
{
{
if(isNil "_x") then {
//Do nothing
} else {
try {
if(isNil "_x") then {
throw "Unit is nil";
};
if(isNull _x) then {
//Do nothing
} else {
if(alive _x) then {
if((side _x) == _playerFaction) then {
_distance = ceil (_x distance player);
if (_distance < cws_ais_3d_icon_range && (_x getVariable ["cws_ais_agony", false])) then {
_message = format["%1 (%2m)", name _x, _distance];
_icon_size = 0.5;
_text_size = 0.025;
_iconColor = [1,0,0,1];
_pos = visiblePosition _x;
if(_player_is_medic) then {
_life_remaining = _x getVariable "cws_ais_bleedout_time";
_message = _message + format[" (%1%2)", ceil (_life_remaining * 100), "%"];
_icon_size = 1.0;
_text_size = 0.05;
};
drawIcon3D["a3\ui_f\data\map\MapControl\hospital_ca.paa", _iconColor, _pos, _icon_size, _icon_size, 0, _message, 0, _text_size];
};
};
};
throw "Unit is null";
};
if(!alive _x) then {
throw "Unit is dead";
};
if (!(_x getVariable ["cws_ais_aisInit", false])) then {
throw "Unit is not running CWS";
};
if((side _x) != _playerFaction) then {
throw "Unit not on same side as player";
};
if(!(_x getVariable ["cws_ais_agony", false])) then {
throw "Unit is not in agony";
};
_distance = ceil (_x distance player);
if (_distance >= cws_ais_3d_icon_range) then {
throw "Unit is too far away";
};

_message = format["%1 (%2m)", name _x, _distance];
_icon_size = 0.5;
_text_size = 0.025;
_iconColor = [1,0,0,1];
_pos = visiblePosition _x;
if(_player_is_medic) then {
_life_remaining = _x getVariable "cws_ais_bleedout_time";
_message = _message + format[" (%1%2)", ceil (_life_remaining * 100), "%"];
_icon_size = 1.0;
_text_size = 0.05;
};
drawIcon3D["a3\ui_f\data\map\MapControl\hospital_ca.paa", _iconColor, _pos, _icon_size, _icon_size, 0, _message, 0, _text_size];
} catch {
//Do nothing
};
} forEach units _x;
} forEach allGroups;
Expand Down

0 comments on commit cdc5c8a

Please sign in to comment.