diff --git a/addons/medical_blood/README.md b/addons/medical_blood/README.md new file mode 100644 index 0000000000..29632ffd29 --- /dev/null +++ b/addons/medical_blood/README.md @@ -0,0 +1,11 @@ +ace_medical_blood +=============== + +Adds blood visual effect on the ground near a bleeding player. + +## Maintainers + +The people responsible for merging changes to this component or answering potential questions. + +- [Glowbal](https://github.com/Glowbal) +- [commy2](https://github.com/commy2) diff --git a/addons/medical_blood/XEH_postInit.sqf b/addons/medical_blood/XEH_postInit.sqf index ed76b8770c..8d563da1dc 100644 --- a/addons/medical_blood/XEH_postInit.sqf +++ b/addons/medical_blood/XEH_postInit.sqf @@ -25,8 +25,17 @@ if (isServer) then { ["ace_settingsInitialized", { TRACE_1("settingsInitialized", GVAR(enabledFor)); if (GVAR(enabledFor) == 0) exitWith {}; // 0: disabled + if ((GVAR(enabledFor) == 1) && {!hasInterface}) exitWith {}; // 1: enabledFor_OnlyPlayers + + private _listcode = if (GVAR(enabledFor) == 1) then { + {[ACE_player] select {[_x] call FUNC(isBleeding)}} // ace_player is only possible local player + } else { + {allUnits select {(local _x) && {[_x] call FUNC(isBleeding)}}}; // filter all local bleeding units + }; + + private _stateMachine = [_listcode, true] call CBA_statemachine_fnc_create; + [_stateMachine, {call FUNC(onBleeding)}, {}, {}, "Bleeding"] call CBA_statemachine_fnc_addState; - [configFile >> QGVAR(stateMachine)] call CBA_statemachine_fnc_createFromConfig; ["CAManBase", "hit", { params ["_unit"]; diff --git a/addons/medical_blood/config.cpp b/addons/medical_blood/config.cpp index 9d0fe1c985..65b2a69809 100644 --- a/addons/medical_blood/config.cpp +++ b/addons/medical_blood/config.cpp @@ -14,5 +14,5 @@ class CfgPatches { }; }; +#include "ACE_Settings.hpp" #include "CfgEventHandlers.hpp" -#include "state_machine.hpp" diff --git a/addons/medical_blood/functions/fnc_createBlood.sqf b/addons/medical_blood/functions/fnc_createBlood.sqf index 51a937f35d..88d35ca7a6 100644 --- a/addons/medical_blood/functions/fnc_createBlood.sqf +++ b/addons/medical_blood/functions/fnc_createBlood.sqf @@ -19,6 +19,7 @@ #include "script_component.hpp" params ["_type", "_pos"]; +TRACE_2("creating blood",_type,_pos); private _model = GVAR(models) getVariable _type; diff --git a/addons/medical_blood/functions/fnc_hit.sqf b/addons/medical_blood/functions/fnc_hit.sqf index 8a11ba5975..1572b2e5a1 100644 --- a/addons/medical_blood/functions/fnc_hit.sqf +++ b/addons/medical_blood/functions/fnc_hit.sqf @@ -16,14 +16,13 @@ params ["_unit", "_causedBy", "_damage"]; +if (((vehicle _unit) != _unit) && {!((vehicle _unit) isKindOf "StaticWeapon")}) exitWith {}; // Don't bleed on ground if mounted + if (isNull _causedBy) exitWith { // won't be able to calculate the direction properly, so instead we pick something at random [QGVAR(spurt), [_unit, random 360, _damage]] call CBA_fnc_serverEvent; }; // Calculate bulletDirection -private _unitPos = getPosASL _unit; -private _causedByPos = getPosASL _causedBy; - -private _bulletDir = ((_unitPos select 0) - (_causedByPos select 0)) atan2 ((_unitPos select 1) - (_causedByPos select 1)); +private _bulletDir = _unit getDir _causedBy; [QGVAR(spurt), [_unit, _bulletDir, _damage]] call CBA_fnc_serverEvent; diff --git a/addons/medical_blood/functions/fnc_onBleeding.sqf b/addons/medical_blood/functions/fnc_onBleeding.sqf index d4dcdd6de9..204483ce43 100644 --- a/addons/medical_blood/functions/fnc_onBleeding.sqf +++ b/addons/medical_blood/functions/fnc_onBleeding.sqf @@ -17,7 +17,7 @@ params ["_unit"]; -if (GVAR(enabledFor) == 1 && {!isPlayer _unit || {_unit == ACE_player}}) exitWith {}; +if (((vehicle _unit) != _unit) && {!((vehicle _unit) isKindOf "StaticWeapon")}) exitWith {}; // Don't bleed on ground if mounted private _lastTime = _unit getVariable [QGVAR(lastTime), -10]; private _bloodLoss = (if (GVAR(useAceMedical)) then {([_unit] call EFUNC(medical,getBloodLoss)) * 2.5} else {getDammage _unit * 2}) min 6; diff --git a/addons/medical_blood/state_machine.hpp b/addons/medical_blood/state_machine.hpp deleted file mode 100644 index a05beb7c2b..0000000000 --- a/addons/medical_blood/state_machine.hpp +++ /dev/null @@ -1,7 +0,0 @@ -class GVAR(stateMachine) { - list = QUOTE(allUnits select {[_x] call FUNC(isBleeding)}); - skipNull = 1; - class Bleeding { - onState = QUOTE(call FUNC(onBleeding)); - }; -};