From 3fc29673bb5816a0bd4da23ab8a3136b211ece69 Mon Sep 17 00:00:00 2001 From: Glowbal Date: Tue, 3 Mar 2015 23:26:54 +0100 Subject: [PATCH] More fixes and improvements for wounds --- addons/medical/functions/fnc_handleDamage_wounds.sqf | 9 +++++---- addons/medical/functions/fnc_parseConfigForInjuries.sqf | 8 ++++---- .../functions/fnc_treatmentAdvanced_bandageLocal.sqf | 8 +++++--- 3 files changed, 14 insertions(+), 11 deletions(-) diff --git a/addons/medical/functions/fnc_handleDamage_wounds.sqf b/addons/medical/functions/fnc_handleDamage_wounds.sqf index a156a284a5..c2cc549828 100644 --- a/addons/medical/functions/fnc_handleDamage_wounds.sqf +++ b/addons/medical/functions/fnc_handleDamage_wounds.sqf @@ -82,15 +82,16 @@ _woundsCreated = []; for "_i" from 0 to (1+ floor(random(_x select 1)-1)) /* step +1 */ do { // Find the injury we are going to add. Format [ classID, allowdSelections, bloodloss, painOfInjury, minimalDamage] - _toAddInjury = _allPossibleInjuries select (floor(random (count _allPossibleInjuries))); + _toAddInjury = if (random(1) >= 0.5) then {_allPossibleInjuries select _highestPossibleSpot} else {_allPossibleInjuries select (floor(random (count _allPossibleInjuries)));}; _toAddClassID = _toAddInjury select 0; _foundIndex = -1; + _bodyPartNToAdd = if (_injuryTypeInfo select 1) then {_bodyPartn} else {floor(random(6))}; // If the injury type is selection part specific, we will check if one of those injury types already exists and find the spot for it.. if ((_injuryTypeInfo select 1)) then { { // Check if we have an id of the given class on the given bodypart already - if (_x select 0 == _toAddClassID && {_x select 2 == _bodyPartn}) exitwith { + if (_x select 1 == _toAddClassID && {_x select 2 == _bodyPartNToAdd}) exitwith { _foundIndex = _foreachIndex; }; }foreach _openWounds; @@ -99,7 +100,7 @@ _woundsCreated = []; _injury = []; if (_foundIndex < 0) then { // Create a new injury. Format [ID, classID, bodypart, percentage treated, bloodloss rate] - _injury = [_woundID, _toAddInjury select 0, if (_injuryTypeInfo select 1) then {_bodyPartn} else {floor(random(6))}, 1, _toAddInjury select 2]; + _injury = [_woundID, _toAddInjury select 0, _bodyPartNToAdd, 1, _toAddInjury select 2]; // Since it is a new injury, we will have to add it to the open wounds array to store it _openWounds pushback _injury; @@ -108,7 +109,7 @@ _woundsCreated = []; _woundID = _woundID + 1; } else { // We already have one of these, so we are just going to increase the number that we have of it with a new one. - _injury = _openWounds select _foreachIndex; + _injury = _openWounds select _foundIndex; _injury set [3, (_injury select 3) + 1]; }; // Store the injury so we can process it later correctly. diff --git a/addons/medical/functions/fnc_parseConfigForInjuries.sqf b/addons/medical/functions/fnc_parseConfigForInjuries.sqf index 8fac99f8a1..c00a85b700 100644 --- a/addons/medical/functions/fnc_parseConfigForInjuries.sqf +++ b/addons/medical/functions/fnc_parseConfigForInjuries.sqf @@ -29,7 +29,7 @@ for "_i" from 0 to (count _configDamageTypes -1) /* step +1 */ do { GVAR(allAvailableDamageTypes) = _allFoundDamageTypes; // Creating a hash map to map wound IDs to classnames -GVAR(woundClassNameIDHash) = HASHCREATE; +GVAR(woundClassNames) = []; // function for parsing a sublcass of an injury _parseForSubClassWounds = { @@ -42,9 +42,9 @@ _parseForSubClassWounds = { _subClasspain = if (isNumber(_subClassConfig >> "pain")) then { getNumber(_subClassConfig >> "pain");} else { _pain }; _subClassminDamage = if (isNumber(_subClassConfig >> "minDamage")) then { getNumber(_subClassConfig >> "minDamage");} else { _minDamage }; _subClasscauses = if (isArray(_subClassConfig >> "causes")) then { getArray(_subClassConfig >> "causes");} else { _causes }; - _subClassDisplayName = if (isText(_entry >> "name")) then { getText(_entry >> "name");} else {_classDisplayName + " " + _subClass}; + _subClassDisplayName = if (isText(_subClassConfig >> "name")) then { getText(_subClassConfig >> "name");} else {_classDisplayName + " " + _subClass}; if (count _selections > 0 && {count _causes > 0}) then { - HASH_SET(GVAR(woundClassNameIDHash), _classID, _subClasstype); + GVAR(woundClassNames) pushback _subClasstype; _allWoundClasses pushback [_classID, _subClassselections, _subClassbloodLoss, _subClasspain, _subClassminDamage, _subClasscauses, _subClassDisplayName]; _classID = _classID + 1; }; @@ -75,7 +75,7 @@ if (isClass _woundsConfig) then { // There were no subclasses, so we will add this one instead. if (count _selections > 0 && count _causes > 0) then { - HASH_SET(GVAR(woundClassNameIDHash), _classID, _classType); + GVAR(woundClassNames) pushback _classType; _allWoundClasses pushback [_classID, _selections, _bloodLoss, _pain, _minDamage, _causes, _classDisplayName]; _classID = _classID + 1; }; diff --git a/addons/medical/functions/fnc_treatmentAdvanced_bandageLocal.sqf b/addons/medical/functions/fnc_treatmentAdvanced_bandageLocal.sqf index ac7b81cdf3..ee68878de8 100644 --- a/addons/medical/functions/fnc_treatmentAdvanced_bandageLocal.sqf +++ b/addons/medical/functions/fnc_treatmentAdvanced_bandageLocal.sqf @@ -44,11 +44,13 @@ _mostEffectiveInjury = _openWounds select 0; if (_x select 2 == _part) then { _woundEffectivenss = _effectiveness; _classID = (_x select 1); - // Check if this wound type has attributes specified for the used bandage - if (HASH_HASKEY(GVAR(woundClassNameIDHash), _classID)) then { + // Select the classname from the wound classname storage + _className = GVAR(woundClassNames) select _classID; + // Check if this wound type has attributes specified for the used bandage + if (isClass (_config >> _className)) then { // Collect the effectiveness from the used bandage for this wound type - _woundTreatmentConfig = (_config >> (HASH_GET(GVAR(woundClassNameIDHash), _classID))); + _woundTreatmentConfig = (_config >> _className); if (isNumber (_woundTreatmentConfig >> "effectiveness")) then { _woundEffectivenss = getNumber (_woundTreatmentConfig >> "effectiveness"); };