Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion addons/medical/XEH_PREP.hpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
PREP(addDamageToUnit);
PREP(addWound);
PREP(adjustPainLevel);
PREP(deserializeState);
PREP(fullHeal);
Expand All @@ -7,7 +8,7 @@ PREP(getBloodLoss);
PREP(getIVs);
PREP(getOpenWounds);
PREP(getStitchedWounds);
PREP(isInjured);
PREP(isInStableCondition);
PREP(isInjured);
PREP(serializeState);
PREP(setUnconscious);
73 changes: 73 additions & 0 deletions addons/medical/functions/fnc_addWound.sqf
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
#include "..\script_component.hpp"
/*
* Author: Cplhardcore
* Adds an entry to the specified medical log of the unit.
*
* Arguments:
* 0: Unit <OBJECT>
* 1: Bodypart <STRING>
* 2: Wound to add <ARRAY>
* 2.0: Wound Type <STRING>
* 2.1: Amount <NUMBER>
* 2.2: Size (0 - 2) <NUMBER>
* 2.3: Wound Damage <NUMBER>
Comment on lines +10 to +13
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This some new styling choice? I haven't seen any other ace function do this. They're always:

/*
 * 0: Whatever <ARRAY>
 *   0: Foo <...>
 *   1: Bar <...>

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

its a subset of a param, so it made sense to make it still contain the number of the param

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Dart's example is what's usually used in ACE, please follow it.

*
* Return Value:
* None
*
* Example:
* [player, "body", ["Avulsion", 1, 2, 1]] call ace_medical_fnc_addWound
*
* Public: Yes
*/

params ["_unit", "_bodyPart", "_woundParams"];
_woundParams params ["_woundType", "_amountOf", "_size", "_woundDamage"];
TRACE_1("_woundParams",_woundParams);
private _bodyPartNToAdd = ALL_BODY_PARTS find _bodyPart;
if (_bodyPartNToAdd < 0) exitWith {
ERROR_1("invalid body part %1",_bodyPart);
};
private _createdWounds = false;
private _painLevel = 0;
private _bodyPartVisParams = [_unit, false, false, false, false];
private _openWounds = GET_OPEN_WOUNDS(_unit);
private _existingWounds = _openWounds getOrDefault [_bodyPart, [], true];
private _bodyPartDamage = GET_BODYPART_DAMAGE(_unit);
EGVAR(medical_damage,woundDetails) get _woundType params ["","_injuryBleedingRate","_injuryPain"];
TRACE_1("_injuryBleedingRate",_injuryBleedingRate);
private _woundClassIDToAdd = EGVAR(medical_damage,woundClassNames) find _woundType;
TRACE_1("_woundClassIDToAdd",_woundClassIDToAdd);
private _pain = _size * _injuryPain;
_painLevel = _painLevel + _pain;
private _bleeding = _size * _injuryBleedingRate;
private _classComplex = 10 * _woundClassIDToAdd + _size;
private _injury = [_classComplex, _amountOf, _bleeding, 1];
private _createNewWound = true;
{
_x params ["_classID", "_oldAmountOf", "_oldBleeding", "_oldDamage"];
if (_classComplex == _classID) exitWith {
TRACE_2("merging with existing wound",_injury,_x);
private _newAmountOf = _oldAmountOf + 1;
_x set [1, _newAmountOf];
private _newBleeding = (_oldAmountOf * _oldBleeding + _bleeding) / _newAmountOf;
_x set [2, _newBleeding];
private _newDamage = (_oldAmountOf * _oldDamage + _woundDamage) / _newAmountOf;
_x set [3, _newDamage];
_createNewWound = false;
};
} forEach _existingWounds;
if (_createNewWound) then {
TRACE_1("adding new wound",_injury);
_existingWounds pushBack _injury;
};
_createdWounds = true;
_bodyPartVisParams set [[1,2,3,3,4,4] select _bodyPartNToAdd, true];
if (_createdWounds) then {
_unit setVariable [VAR_OPEN_WOUNDS, _openWounds, true];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't we always want to sync this, even if just merging into an existing wound?
If we don't sync then the bleeding local players sees is different from what remote players see for them?

I know this is based on https://github.com/acemod/ACE3/blob/master/addons/medical_damage/functions/fnc_woundsHandlerBase.sqf#L199 so I'm worried it effects that as well

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If its being merged with an old one, there will already be bloody clothing, so there's no need to update it

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It should probably still be updated to avoid cases where remote players see different bleeding than the local player. The network cost to avoid it is negligible IMO.

_bodyPartDamage set [_bodyPartNToAdd, (_bodyPartDamage select _bodyPartNToAdd) + _woundDamage];
_unit setVariable [VAR_BODYPART_DAMAGE, _bodyPartDamage, true];
_bodyPartVisParams call EFUNC(medical_engine,updateBodyPartVisuals);
[QEGVAR(medical,injured), [_unit, _painLevel]] call CBA_fnc_localEvent;
};
_unit call EFUNC(medical_status,updateWoundBloodLoss);