Merge pull request #4377 from acemod/sys-blood-port

Add ace2 sys blood port
This commit is contained in:
commy2 2016-09-19 17:35:32 +02:00 committed by GitHub
commit 3d422021ef
29 changed files with 444 additions and 0 deletions

View File

@ -1,5 +1,6 @@
class ACE_Settings {
class GVAR(enabledFor) {
category = ECSTRING(medical,Category_Medical);
value = 2;
typeName = "SCALAR";
values[] = {ECSTRING(Common,Disabled), CSTRING(enabledFor_OnlyServerAndHC), ECSTRING(Common,Enabled)};

View File

@ -0,0 +1 @@
x\ace\addons\medical_blood

View File

@ -0,0 +1,10 @@
class ACE_Settings {
class GVAR(enabledFor) {
category = ECSTRING(medical,Category_Medical);
displayName = CSTRING(MedicalBloodSettings_enabledFor_DisplayName);
description = CSTRING(MedicalBloodSettings_enabledFor_Description);
value = 2;
typeName = "SCALAR";
values[] = {ECSTRING(Common,Disabled), CSTRING(enabledFor_OnlyPlayers), ECSTRING(Common,Enabled)};
};
};

View File

@ -0,0 +1,18 @@
class Extended_PreStart_EventHandlers {
class ADDON {
init = QUOTE(call COMPILE_FILE(XEH_preStart));
};
};
class Extended_PreInit_EventHandlers {
class ADDON {
init = QUOTE(call COMPILE_FILE(XEH_preInit));
};
};
class Extended_PostInit_EventHandlers {
class ADDON {
init = QUOTE(call COMPILE_FILE(XEH_postInit));
};
};

View File

@ -0,0 +1,6 @@
PREP(hit);
PREP(isBleeding);
PREP(onBleeding);
PREP(createBlood);
PREP(spurt);

View File

@ -0,0 +1,37 @@
#include "script_component.hpp"
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;
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;
};
[{deleteVehicle _this}, _bloodDrop, BLOOD_OBJECT_LIFETIME] call CBA_fnc_waitAndExecute;
}] call CBA_fnc_addEventHandler;
};
["ace_settingsInitialized", {
TRACE_1("settingsInitialized", GVAR(enabledFor));
if (GVAR(enabledFor) == 0) exitWith {}; // 0: disabled
[configFile >> QGVAR(stateMachine)] call CBA_statemachine_fnc_createFromConfig;
["CAManBase", "hit", {
params ["_unit"];
if (GVAR(enabledFor) == 1 && {!isPlayer _unit || {_unit == ACE_player}}) exitWith {};
_this call FUNC(hit);
}] call CBA_fnc_addClassEventHandler;
}] call CBA_fnc_addEventHandler;

View File

@ -0,0 +1,27 @@
#include "script_component.hpp"
ADDON = false;
#include "XEH_PREP.hpp"
// blood object model namespace
GVAR(models) = [] call CBA_fnc_createNamespace;
{
_x params ["_name", "_model"];
// createSimpleObject expects a path without the leading slash
if ((_model select [0,1]) isEqualTo "\") then {
_model = _model select [1];
};
GVAR(models) setVariable [_name, _model];
} forEach [
// higher number means bigger model
["blooddrop_1", QPATHTOF(data\drop_1.p3d)],
["blooddrop_2", QPATHTOF(data\drop_2.p3d)],
["blooddrop_3", QPATHTOF(data\drop_3.p3d)],
["blooddrop_4", QPATHTOF(data\drop_4.p3d)]
];
ADDON = true;

View File

@ -0,0 +1,3 @@
#include "script_component.hpp"
#include "XEH_PREP.hpp"

View File

@ -0,0 +1,18 @@
#include "script_component.hpp"
class CfgPatches {
class ADDON {
name = COMPONENT_NAME;
units[] = {};
weapons[] = {};
requiredVersion = REQUIRED_VERSION;
requiredAddons[] = {"ace_main"};
author = ECSTRING(common,ACETeam);
authors[] = {"Glowbal","Sickboy","commy2"};
url = ECSTRING(main,URL);
VERSION_CONFIG;
};
};
#include "CfgEventHandlers.hpp"
#include "state_machine.hpp"

View File

@ -0,0 +1,91 @@
class StageTI {
texture = "z\ace\addons\medical_blood\data\blood_ti_ca.paa";
};
ambient[] = {1.0,1.0,1.0,1.0};
diffuse[] = {1.0,1.0,1.0,1.0};
forcedDiffuse[] = {0.0,0.0,0.0,0.0};
emmisive[] = {0.0,0.0,0.0,1.0};
specular[] = {0.0,0.0,0.0,1.0};
specularPower = 1.0;
PixelShaderID = "Super";
VertexShaderID = "Super";
renderFlags[] = {"NoZWrite"};
class Stage1 {
texture = "z\ace\addons\medical_blood\data\blood_nohq.paa";
uvSource = "tex";
class uvTransform {
aside[] = {1.0,0.0,0.0};
up[] = {0.0,1.0,0.0};
dir[] = {0.0,0.0,0.0};
pos[] = {0.0,0.0,0.0};
};
};
class Stage2 {
texture = "#(argb,8,8,3)color(0.5,0.5,0.5,0.5,DT)";
uvSource = "tex";
class uvTransform {
aside[] = {1.0,0.0,0.0};
up[] = {0.0,1.0,0.0};
dir[] = {0.0,0.0,0.0};
pos[] = {0.0,0.0,0.0};
};
};
class Stage3 {
texture = "#(argb,8,8,3)color(0.0,0.0,0.0,0.0,MC)";
uvSource = "tex";
class uvTransform {
aside[] = {1.0,0.0,0.0};
up[] = {0.0,1.0,0.0};
dir[] = {0.0,0.0,0.0};
pos[] = {0.0,0.0,0.0};
};
};
class Stage4 {
texture = "#(argb,8,8,3)color(1.0,1.0,1.0,1.0,AS)";
uvSource = "tex";
class uvTransform {
aside[] = {1.0,0.0,0.0};
up[] = {0.0,1.0,0.0};
dir[] = {0.0,0.0,0.0};
pos[] = {0.0,0.0,0.0};
};
};
class Stage5 {
texture = "z\ace\addons\medical_blood\data\blood_smdi.paa";
uvSource = "tex";
class uvTransform {
aside[] = {1.0,0.0,0.0};
up[] = {0.0,1.0,0.0};
dir[] = {0.0,0.0,0.0};
pos[] = {0.0,0.0,0.0};
};
};
class Stage6 {
texture = "#(ai,64,64,1)fresnel(0.7,0.001)";
uvSource = "tex";
class uvTransform {
aside[] = {1.0,0.0,0.0};
up[] = {0.0,1.0,0.0};
dir[] = {0.0,0.0,0.0};
pos[] = {0.0,0.0,0.0};
};
};
class Stage7 {
texture = "a3\data_f\env_land_co.paa";
useWorldEnvMap = "false";
uvSource = "tex";
class uvTransform {
aside[] = {1.0,0.0,0.0};
up[] = {0.0,1.0,0.0};
dir[] = {0.0,0.0,0.0};
pos[] = {0.0,0.0,0.0};
};
};

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -0,0 +1,31 @@
/*
* Author: Glowbal
* Spawn a blood drop.
* Available blood drop classes are blooddrop_1 through blooddrop_4.
*
* Arguments:
* 0: classname of blood drop <OBJECT>
* 1: Position <ARRAY>
*
* Return Value:
* Created blood drop <OBJECT>
*
* Example:
* ["blooddrop_2", getPos player] call ace_medical_blood_fnc_createBlood
*
* Public: No
*/
#include "script_component.hpp"
params ["_type", "_pos"];
private _model = GVAR(models) getVariable _type;
private _object = createSimpleObject [_model, [0,0,0]];
_object setDir random 360;
_object setPos _pos;
[QGVAR(bloodDropCreated), [_object]] call CBA_fnc_serverEvent;
_object

View File

@ -0,0 +1,29 @@
/*
* 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 (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));
[QGVAR(spurt), [_unit, _bulletDir, _damage]] call CBA_fnc_serverEvent;

View File

@ -0,0 +1,23 @@
/*
* Author: Glowbal
* Check if is bleeding
*
* Arguments:
* 0: unit <TYPE>
*
* Return Value:
* is Bleeding <BOOL>
*
* Example:
* [UNIT] call ace_medical_blood_fnc_isBleeding
*
* Public: No
*/
#include "script_component.hpp"
params ["_unit"];
if (GVAR(useAceMedical)) exitWith {
_unit getVariable [QEGVAR(medical,isBleeding), false];
};
alive _unit && {getDammage _unit > 0.3};

View File

@ -0,0 +1,38 @@
/*
* Author: Glowbal
* handle bleeding state (state machine)
*
* Arguments:
* 0: unit <TYPE>
*
* Return Value:
* is Bleeding <BOOL>
*
* Example:
* [UNIT] call ace_medical_blood_fnc_onBleeding
*
* Public: No
*/
#include "script_component.hpp"
params ["_unit"];
if (GVAR(enabledFor) == 1 && {!isPlayer _unit || {_unit == ACE_player}}) exitWith {};
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;
if ((CBA_missionTime - _lastTime) + _bloodLoss >= 8 + random 2) then {
_unit setVariable [QGVAR(lastTime), CBA_missionTime];
private _position = getPosASL _unit;
_position = _position vectorAdd [
random 0.4 - 0.2,
random 0.4 - 0.2,
0
];
_position set [2, 0];
private _bloodDrop = ["blooddrop_1", "blooddrop_2", "blooddrop_3", "blooddrop_4"] select floor (_bloodLoss max 3);
[_bloodDrop, _position, getDir _unit] call FUNC(createBlood);
};

View File

@ -0,0 +1,38 @@
/*
* Author: Sickboy
* Spurt blood on the ground
*
* Arguments:
* 0: unit <OBJECT>
* 1: direction <NUMBER>
* 2: damage <NUMBER>
*
* Return Value:
* None
*
* Example:
* [UNIT, random 360, 1] call ace_medical_blood_fnc_spurt
*
* Public: No
*/
#include "script_component.hpp"
#define MAXIMUM_DROPS 4
#define DISTANCE_BETWEEN_DROPS 0.20
#define OFFSET 0.25
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);
if (_dropAmount > 1) then {
for "_i" from 2 to _dropAmount do {
_pos = _pos getPos [_distanceBetweenDrops, _dir];
["blooddrop_1", _pos, _dir] call FUNC(createBlood);
};
};

View File

@ -0,0 +1 @@
#include "\z\ace\addons\medical_blood\script_component.hpp"

View File

@ -0,0 +1,21 @@
#define COMPONENT medical_blood
#define COMPONENT_BEAUTIFIED Medical Blood
#include "\z\ace\addons\main\script_mod.hpp"
// #define DEBUG_ENABLED_MEDICAL_BLOOD
// #define DISABLE_COMPILE_CACHE
// #define CBA_DEBUG_SYNCHRONOUS
// #define ENABLE_PERFORMANCE_COUNTERS
#ifdef DEBUG_ENABLED_MEDICAL_BLOOD
#define DEBUG_MODE_FULL
#endif
#ifdef DEBUG_SETTINGS_MEDICAL_BLOOD
#define DEBUG_SETTINGS DEBUG_SETTINGS_MEDICAL_BLOOD
#endif
#include "\z\ace\addons\main\script_macros.hpp"
#define MAX_BLOOD_OBJECTS 500
#define BLOOD_OBJECT_LIFETIME 900

View File

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

View File

@ -0,0 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<Project name="ACE">
<Package name="medical_blood">
<Key ID="STR_ACE_medical_blood_enabledFor_OnlyPlayers">
<English>Only Players</English>
</Key>
<Key ID="STR_ACE_medical_blood_MedicalBloodSettings_enabledFor_DisplayName">
<English>Enable Blood Drops</English>
</Key>
<Key ID="STR_ACE_medical_blood_MedicalBloodSettings_enabledFor_Description">
<English>Enable or disable Blood Drops created on bleeding and taking damage</English>
</Key>
</Package>
</Project>

Binary file not shown.

After

Width:  |  Height:  |  Size: 110 KiB

View File

@ -0,0 +1,30 @@
---
layout: wiki
title: Medical Blood
description: Spawn blood drops for bleeding units.
group: feature
category: realism
parent: wiki
mod: ace
version:
major: 3
minor: 8
patch: 0
---
<div class="panel callout">
<h5>Note:</h5>
<p>This component supports both ACE medical as well as the vanilla medical systems.</p>
</div>
## 1. Overview
When any unit is bleeding, this component will spawn blood drops on the ground. The same happens for units that are taking damage. It can be configured to run only for players, for all units (AI and Players) or disabled through the ACE Settings framework.
## 2. In game
<img src="{{ site.baseurl }}/img/wiki/feature/ace_blood_screen.jpg" width="500" height="160" alt="ACE Blood in game" />
## 3. Dependencies
{% include dependencies_list.md component="medical_blood" %}