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
Medical rewrite bug fixes #6523
Changes from all commits
e51ba84
4ac3b95
017b0e5
2541b65
fa05b02
d8ff004
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 |
---|---|---|
|
@@ -19,6 +19,7 @@ class Extended_PostInit_EventHandlers { | |
class Extended_Init_EventHandlers { | ||
class CAManBase { | ||
class ADDON { | ||
onRespawn = 1; | ||
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. 👍 I overlooked that this wasn't a respawn XEH in my comment on #6518 |
||
init = QUOTE(call FUNC(initUnit)); | ||
}; | ||
}; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,6 +17,8 @@ | |
|
||
params ["_unit"]; | ||
|
||
if (!local _unit) exitWith {}; | ||
|
||
if (damage _unit > 0) then { | ||
_unit setDamage 0; | ||
}; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -46,6 +46,7 @@ private _heartRate = GET_HEART_RATE(_unit); | |
|
||
if !IN_CRDC_ARRST(_unit) then { | ||
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. Isn't this preventing the unit from entering when in cardiac arrest?
Regarding the XEH for the respawn issue: 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. That is only resetting the statemachine though and not resetting the variables such as openWounds right? My worry is that if the new unit does not override the variables from the old unit on respawn it will have a reference to the actual arrays meaning they will receive any updates to the old arrays (and therefor receive wounds when shooting the old corpse). 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. The check indeed prevents the unit when entering when in cardiac arrest, but that doesn't matter too much as the updateUnitVitals and therefore updateHeartRate is not being called when in cardiac arrest. Problem is that the first time when the unit leaves cardiac arrest state, updateUnitVitals will run updateHeartRate with a _deltaT of 10 as updateUnitVitals hasn't been run in a while. Even if that would be fixed by running updateUnitVitals when in cardiac arrest, I don't believe that it is intentional to ever report a new HR after adjustment beyond the targetHR. |
||
private _hrChange = 0; | ||
private _targetHR = 0; | ||
private _bloodVolume = GET_BLOOD_VOLUME(_unit); | ||
if (_bloodVolume > BLOOD_VOLUME_CLASS_4_HEMORRHAGE) then { | ||
GET_BLOOD_PRESSURE(_unit) params ["_bloodPressureL", "_bloodPressureH"]; | ||
|
@@ -57,23 +58,26 @@ if !IN_CRDC_ARRST(_unit) then { | |
_targetBP = _targetBP * (_bloodVolume / DEFAULT_BLOOD_VOLUME); | ||
}; | ||
|
||
private _targetHR = DEFAULT_HEART_RATE; | ||
_targetHR = DEFAULT_HEART_RATE; | ||
if (_bloodVolume < BLOOD_VOLUME_CLASS_2_HEMORRHAGE) then { | ||
_targetHR = _heartRate * (_targetBP / (45 max _meanBP)); | ||
}; | ||
if (_painLevel > 0.2) then { | ||
_targetHR = _targetHR max (80 + 50 * _painLevel); | ||
}; | ||
_targetHR = _targetHR + _hrTargetAdjustment; | ||
_targetHR = (_targetHR + _hrTargetAdjustment) max 0; | ||
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. Isn't 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. The hrTargetAdjustment can be a rather large negative value depending on current medication I believe. I don't know if it could ever go below 0 because of that but I'd think its worth ensuring it won't. Will remove it if that's really wanted but it seems like taking a bit of a gamble just to save 6 characters. 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. This is good, we're just moving the |
||
|
||
_hrChange = round(_targetHR - _heartRate) / 2; | ||
} else { | ||
_hrChange = -round(_heartRate / 10); | ||
}; | ||
_heartRate = (_heartRate + _deltaT * _hrChange) max 0; | ||
if (_hrChange < 0) then { | ||
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. You can put the whole new If statement directly under the _hrChange calculation and spare it since it is redundant:
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. I'm sorry, I don't think I understand what you are suggesting. The heart rate is currently doing a min or max with _targetHR depending on if we are increasing or decreasing our heart rate. Wouldn't the change you are suggesting here cause any gradual change lowering the HR to happen immediately instead? 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. After going through the code more closely these lines look good to me 👍 This doesn't fix the issue of incorrectly large For the exiting cardiac arrest |
||
_heartRate = (_heartRate + _deltaT * _hrChange) max _targetHR; | ||
} else { | ||
_heartRate = (_heartRate + _deltaT * _hrChange) min _targetHR; | ||
}; | ||
}; | ||
|
||
_unit setVariable [VAR_HEART_RATE, _heartRate, _syncValue]; | ||
|
||
_heartRate | ||
|
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 should be done in the medical vitals component through an eventhandler I think.
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.
Well spotted, I would agree that an EH is better here
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.
Would we also want to change leftStateCardiacArrest then?
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.
We probably also want to do it for that function, yes. That may require introducing some new events though. Does not have to be done in this PR, imo. But we should create an issue for it if we do not. I will leave that to your discretion @redbery.
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.
I don't think I'll have the time to do that today as it is somewhat involved which would mean it would need to wait until next weekend. Think it is better to create a new issue for it if you don't mind.