-
Notifications
You must be signed in to change notification settings - Fork 745
Medical Statemachine - Optimize medical handling for uninjured AI units #11101
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?
Conversation
| if (!IS_MEDICAL_ACTIVITY(_unit)) then { | ||
| TRACE_2("activating medical for unit",_unit,typeOf _unit); | ||
| _unit setVariable [VAR_MEDICAL_ACTIVITY, true, true]; | ||
| }; |
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.
vitals will go from never being run so the deltaT will max out at 10 seconds
so for example an AI would bleed 10seconds worth the first time they are hit
could fix with
| }; | |
| if (_unit isNil QEGVAR(medical_vitals,lastTimeUpdated)) then { | |
| _unit setVariable [QEGVAR(medical_vitals,lastTimeUpdated), CBA_missionTime - 1]; | |
| }; | |
| }; |
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.
Can you toggle QEGVAR(medical,medicalActivity)? As in, what is the impact if you do?
If it's meant to be toggled, you might want to add more checks regarding the update time.
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 added a note that it should not be changed mid-mission
Co-authored-by: Jouni Järvinen <[email protected]>
|
How well does this handle medical API functions? I imagine |
| }, _this] call CBA_fnc_addEventHandlerArgs; | ||
| }; | ||
|
|
||
| if (!IS_MEDICAL_ACTIVITY(_unit)) then { [QGVAR(activateMedical), _unit] call CBA_fnc_localEvent; }; |
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.
Maybe medical activity could only be enabled if state if the serialized state also had activity (check when serializing and output some magic value maybe)?
Thinking about a persistent mission with spawned but untouched AI in some far-off corner of the map, if they get serialized indiscriminately, this'd make them active after a restart
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.
fixed by adding ace_medical_engine_fnc_checkForMedicalActivity
this also handles manually scripted medical changes
like mission maker doing this setVariable ["ace_medical_bloodVolume", 4] to make a medical training dummy
|
|
| TRACE_1("checkForMedicalActivity",_unit); | ||
|
|
||
| if (!alive _unit || {!local _unit}) exitWith {}; | ||
| if (_unit getVariable [QEGVAR(medical,medicalActivity), false]) exitWith {}; |
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.
Shouldn't it use EGVAR(medical,const_medicalActivity) as a default?
| if (!IS_MEDICAL_ACTIVITY(_unit)) then { | ||
| TRACE_2("activating medical for unit",_unit,typeOf _unit); | ||
| _unit setVariable [VAR_MEDICAL_ACTIVITY, true, true]; | ||
| }; |
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.
Can you toggle QEGVAR(medical,medicalActivity)? As in, what is the impact if you do?
If it's meant to be toggled, you might want to add more checks regarding the update time.
| ```sqf | ||
| // always run all vitals calculations on all AI (this should not be changed mid-mission) | ||
| ace_medical_const_medicalActivity = true; | ||
| // specific AI | ||
| unit setVariable ["ace_medical_medicalActivity", true] | ||
| ``` |
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'd like to make it even clearer:
| ```sqf | |
| // always run all vitals calculations on all AI (this should not be changed mid-mission) | |
| ace_medical_const_medicalActivity = true; | |
| // specific AI | |
| unit setVariable ["ace_medical_medicalActivity", true] | |
| ``` | |
| ```sqf | |
| // always run all vitals calculations on all AI | |
| ace_medical_const_medicalActivity = true; | |
| // specific AI | |
| unit setVariable ["ace_medical_medicalActivity", true] | |
| ``` | |
| Once medical activity has been enabled, you can't disable it. In other words: if you execute `unit setVariable ["ace_medical_medicalActivity", true]`, you can't disable medical activity for that specific AI anymore. If you run `ace_medical_const_medicalActivity = true;`, you can no longer set it to `false` and all AI will have their medical activity enabled. |
Is this correct?
Skip running unit vital calculations and network activity for
AI units that have not been wounded or treated
The default values for things like heart rate are very close to the value they reach over time,
so I think this should not even be noticeable in most cases.
Possible edge case would be something like a AI unit with scripted reduce blood volume, HR/Pressure wouldn't update
But it's very easy to add a setVar to force the vital to always run