simplify blood splatter by using woundReceived event

This commit is contained in:
commy2 2016-10-02 18:35:40 +02:00
parent 5875f58604
commit 6082020056
5 changed files with 40 additions and 41 deletions

View File

@ -3,16 +3,16 @@
GVAR(useAceMedical) = ["ace_medical"] call EFUNC(common,isModLoaded);
// To support public API regardless of component settings
[QGVAR(spurt), {
_this call FUNC(spurt);
}] call CBA_fnc_addEventHandler;
[QGVAR(spurt), FUNC(spurt)] call CBA_fnc_addEventHandler;
if (isServer) then {
GVAR(bloodDrops) = [];
[QGVAR(bloodDropCreated), {
params ["_bloodDrop"];
GVAR(bloodDrops) pushBack _bloodDrop;
if (count GVAR(bloodDrops) >= MAX_BLOOD_OBJECTS) then {
private _deletedBloodDrop = GVAR(bloodDrops) deleteAt 0;
deleteVehicle _deletedBloodDrop;
@ -25,7 +25,7 @@ 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
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
@ -36,11 +36,5 @@ if (isServer) then {
private _stateMachine = [_listcode, true] call CBA_statemachine_fnc_create;
[_stateMachine, {call FUNC(onBleeding)}, {}, {}, "Bleeding"] call CBA_statemachine_fnc_addState;
["CAManBase", "hit", {
params ["_unit"];
if (GVAR(enabledFor) == 1 && {!isPlayer _unit || {_unit == ACE_player}}) exitWith {};
_this call FUNC(hit);
}] call CBA_fnc_addClassEventHandler;
[QEGVAR(medical_engine,woundReceived), FUNC(woundReceived)] call CBA_fnc_addEventHandler;
}] call CBA_fnc_addEventHandler;

View File

@ -1,28 +0,0 @@
/*
* Author: Glowbal
* Handle unit hit eventhandler
*
* Arguments:
* 0: unit <OBJECT>
* 1: caused by <OBJECT>
* 2: damage <NUMBER>
*
* Return Value:
* None
*
* Public: No
*/
#include "script_component.hpp"
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 _bulletDir = _unit getDir _causedBy;
[QGVAR(spurt), [_unit, _bulletDir, _damage]] call CBA_fnc_serverEvent;

View File

@ -15,7 +15,6 @@
*
* Public: No
*/
#include "script_component.hpp"
#define MAXIMUM_DROPS 4
@ -27,9 +26,12 @@ params ["_unit", "_dir", "_damage"];
private _distanceBetweenDrops = DISTANCE_BETWEEN_DROPS * _damage;
private _offset = OFFSET + _distanceBetweenDrops;
private _pos = _unit getPos [_offset, _dir];
["blooddrop_2", _pos, _dir] call FUNC(createBlood);
private _dropAmount = ceil (MAXIMUM_DROPS * _damage);
TRACE_2("spurt blood",_dropAmount,_damage);
if (_dropAmount > 1) then {
for "_i" from 2 to _dropAmount do {
_pos = _pos getPos [_distanceBetweenDrops, _dir];

View File

@ -0,0 +1,31 @@
/*
* Author: Glowbal, commy2
* Handle wounds received event.
*
* Arguments:
* 0: unit <OBJECT>
* 1: caused by <OBJECT>
* 2: damage <NUMBER>
*
* Return Value:
* None
*
* Public: No
*/
#include "script_component.hpp"
params ["_unit", "", "_damage", "_shooter"];
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
_damage = _damage min 1;
if (isNull _shooter) 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 _bulletDir = _shooter getDir _unit;
[QGVAR(spurt), [_unit, _bulletDir, _damage]] call CBA_fnc_serverEvent;

View File

@ -2,7 +2,7 @@
#define COMPONENT_BEAUTIFIED Medical Blood
#include "\z\ace\addons\main\script_mod.hpp"
// #define DEBUG_ENABLED_MEDICAL_BLOOD
#define DEBUG_ENABLED_MEDICAL_BLOOD
#define DISABLE_COMPILE_CACHE
// #define ENABLE_PERFORMANCE_COUNTERS