-
Notifications
You must be signed in to change notification settings - Fork 739
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 Blood - Settings improvements and cleanup #7069
Merged
Merged
Changes from 3 commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,3 @@ | ||
|
||
class Extended_PreStart_EventHandlers { | ||
class ADDON { | ||
init = QUOTE(call COMPILE_FILE(XEH_preStart)); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
|
||
PREP(cleanupLoop); | ||
PREP(createBlood); | ||
PREP(handleWoundReceived); | ||
PREP(init); | ||
PREP(isBleeding); | ||
PREP(onBleeding); | ||
PREP(createBlood); | ||
PREP(serverCleanupBlood); | ||
PREP(spurt); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 8 additions & 5 deletions
13
...lood/functions/fnc_serverCleanupBlood.sqf → ...dical_blood/functions/fnc_cleanupLoop.sqf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,26 @@ | ||
#include "script_component.hpp" | ||
/* | ||
* Author: PabstMirror | ||
* Loop that cleans up blood | ||
* Handles cleaning up blood objects that have reached the end of their lifetime. | ||
* | ||
* Arguments: | ||
* None | ||
* | ||
* ReturnValue: | ||
* Return Value: | ||
* None | ||
* | ||
* Example: | ||
* [] call ace_medical_blood_fnc_cleanupLoop | ||
* | ||
* Public: No | ||
*/ | ||
|
||
(GVAR(bloodDrops) deleteAt 0) params ["", "_deletedBloodDrop"]; | ||
deleteVehicle _deletedBloodDrop; | ||
|
||
// If we cleaned out the array, exit loop | ||
// Exit the loop if we have cleaned out the array | ||
if (GVAR(bloodDrops) isEqualTo []) exitWith {}; | ||
|
||
// Wait until the next blood drop in the queue will expire | ||
(GVAR(bloodDrops) select 0) params ["_expireTime"]; | ||
[FUNC(serverCleanupBlood), [], (_expireTime - CBA_missionTime)] call CBA_fnc_waitAndExecute; | ||
[FUNC(cleanupLoop), [], _expireTime - CBA_missionTime] call CBA_fnc_waitAndExecute; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,31 @@ | ||
#include "script_component.hpp" | ||
/* | ||
* Author: Glowbal | ||
* Spawn a blood drop. | ||
* Creates a blood object and handles its cleanup. | ||
* Available blood drop classes are blooddrop_1 through blooddrop_4. | ||
* | ||
* Arguments: | ||
* 0: classname of blood drop <OBJECT> | ||
* 0: Blood Drop Type <STRING> | ||
* 1: Position <ARRAY> | ||
* | ||
* Return Value: | ||
* Created blood drop <OBJECT> | ||
* Blood Drop <OBJECT> | ||
* | ||
* Example: | ||
* ["blooddrop_2", getPos player] call ace_medical_blood_fnc_createBlood | ||
* | ||
* Public: No | ||
*/ | ||
|
||
params ["_type", "_pos"]; | ||
TRACE_2("creating blood",_type,_pos); | ||
params ["_type", "_position"]; | ||
TRACE_2("Creating blood",_type,_position); | ||
|
||
private _model = GVAR(models) getVariable _type; | ||
|
||
private _object = createSimpleObject [_model, [0,0,0]]; | ||
_object setDir random 360; | ||
_object setPos _pos; | ||
private _bloodDrop = createSimpleObject [_model, [0, 0, 0]]; | ||
_bloodDrop setDir random 360; | ||
_bloodDrop setPos _position; | ||
|
||
[QGVAR(bloodDropCreated), [_object]] call CBA_fnc_serverEvent; | ||
[QGVAR(bloodDropCreated), _bloodDrop] call CBA_fnc_serverEvent; | ||
|
||
_object | ||
_bloodDrop |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
#include "script_component.hpp" | ||
/* | ||
* Author: mharis001 | ||
* Initializes the medical blood system based on the given mode. | ||
* Should only be called from the CBA setting changed script. | ||
* | ||
* Arguments: | ||
* 0: Mode <NUMBER> | ||
* | ||
* Return Value: | ||
* None | ||
* | ||
* Example: | ||
* [2] call ace_medical_blood_fnc_init | ||
* | ||
* Public: No | ||
*/ | ||
|
||
params ["_mode"]; | ||
|
||
// Exit if setting is refreshed to the same value | ||
if (!isNil QGVAR(currentSetup) && {_mode == GVAR(currentSetup)}) exitWith { | ||
TRACE_2("Setting refreshed to current setup",GVAR(currentSetup),_mode); | ||
}; | ||
|
||
// Track this new configuration that will be set up | ||
GVAR(currentSetup) = _mode; | ||
|
||
// Delete current state machine if it exists | ||
if (!isNil QGVAR(stateMachine)) then { | ||
GVAR(stateMachine) call CBA_statemachine_fnc_delete; | ||
GVAR(stateMachine) = nil; | ||
}; | ||
|
||
// Remove wound received if it was previously added | ||
if (!isNil QGVAR(woundReceivedEH)) then { | ||
[QEGVAR(medical,woundReceived), GVAR(woundReceivedEH)] call CBA_fnc_removeEventHandler; | ||
GVAR(woundReceivedEH) = nil; | ||
}; | ||
|
||
// Don't need to set up anything if blood is disabled or players only on a non-player machine | ||
if (_mode == BLOOD_DISABLED || {_mode == BLOOD_ONLY_PLAYERS && {!hasInterface}}) exitWith { | ||
TRACE_1("Mode does not require any setup",_mode); | ||
}; | ||
|
||
private _listCode = if (_mode == BLOOD_ONLY_PLAYERS) then { | ||
// ACE_player is the only possible local player | ||
{ | ||
if (alive ACE_player) then { | ||
[ACE_player] | ||
} else { | ||
[] | ||
}; | ||
} | ||
} else { | ||
// Filter all local units | ||
EFUNC(common,getLocalUnits) | ||
}; | ||
|
||
GVAR(stateMachine) = [_listCode, true] call CBA_statemachine_fnc_create; | ||
[GVAR(stateMachine), LINKFUNC(onBleeding), {}, {}, "Bleeding"] call CBA_statemachine_fnc_addState; | ||
|
||
GVAR(woundReceivedEH) = [QEGVAR(medical,woundReceived), FUNC(handleWoundReceived)] call CBA_fnc_addEventHandler; | ||
|
||
TRACE_3("Set up state machine and wounds event",_mode,GVAR(stateMachine),GVAR(woundReceivedEH)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Do we need a seperate setPos? It creates a additonal network message as blooddrops are global.
Speaking of which, couldn't we make blooddrops local only with the new createSimpleObject local syntax?
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 think we want them to be global, but agree about whether
setPos
is necessaryThere 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.
Surprising results (unless I made a mistake)
edit: we knew that createVehicle at [0,0,0] is faster because it normally scans for a "free" position, but I didn't think it did that for createSimpleObject (objects are in a row clipping though things)
createVehicle
@ [0,0,0] - 492 mscreateVehicle
@ pos - 4798 ms (and non-precise placement)createSimpleObject
@ [0,0,0] - 263 mscreateSimpleObject
@ pos - 2641 msThere 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.
network traffic vs sqf speed
(unless the game can serialize the create and setPos together?)
we can continue to think about this after merge