Fix medical blood locality / bleeding in vehicles (#4469)

* Fix medical blood locality / bleeding in vehicles

- Fix ace_setting
- Don't run on headless if enabledFor = 1
- Don't create blood for non-local units
- Don't create blood when mounted (except static weapons)

* Add readme
This commit is contained in:
PabstMirror 2016-09-29 10:42:56 -05:00 committed by GitHub
parent 85c4a1f021
commit 3c7ac5a3e4
7 changed files with 27 additions and 14 deletions

View File

@ -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)

View File

@ -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"];

View File

@ -14,5 +14,5 @@ class CfgPatches {
};
};
#include "ACE_Settings.hpp"
#include "CfgEventHandlers.hpp"
#include "state_machine.hpp"

View File

@ -19,6 +19,7 @@
#include "script_component.hpp"
params ["_type", "_pos"];
TRACE_2("creating blood",_type,_pos);
private _model = GVAR(models) getVariable _type;

View File

@ -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;

View File

@ -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;

View File

@ -1,7 +0,0 @@
class GVAR(stateMachine) {
list = QUOTE(allUnits select {[_x] call FUNC(isBleeding)});
skipNull = 1;
class Bleeding {
onState = QUOTE(call FUNC(onBleeding));
};
};