-
Notifications
You must be signed in to change notification settings - Fork 749
Medical - Add API to directly add wounds to units #11211
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
68a04cb
5055cf0
10cb855
5b3c066
e98a219
fb89914
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| 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> | ||
| * | ||
| * 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]; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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? 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
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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); | ||
There was a problem hiding this comment.
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:
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.