Add ACE2 sys_Blood port

This commit is contained in:
Glowbal 2016-09-11 20:46:35 +02:00
parent e3d26c535a
commit e8f55348d8
29 changed files with 375 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,11 @@
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,23 @@
class CfgNonAIVehicles {
class Bird;
class ACE_Bloodsplat_1: Bird {
scope = 1;
vehicleClass = "";
displayName = "";
model = QPATHTOF(splat_1.p3d);
submerged = 0;
submergeSpeed = 0;
timeToLive = 1;
disappearAtContact = 1;
maxSpeed = 7000;
XEH_DISABLED;
weight = 1;
gravityFactor = 1;
airFriction2[] = {0,0,0};
airFriction1[] = {0,0,0};
airFriction0[] = {0,0,0};
};
class ACE_Bloodsplat_2: ACE_Bloodsplat_1 {
model = QPATHTOF(splat_2.p3d);
};
};

View File

@ -0,0 +1,48 @@
class CfgVehicles {
class Static;
class ACE_Blooddrop_1: Static {
htMin = 60;
htMax = 1800;
afMax = 200;
mfMax = 100;
mFact = 0;
tBody = 0;
simulation = "SeaGull";
armor = 0;
timeToLive = 1;
side = -1;
shadow = 0;
scope = 1;
VehicleClass = "";
displayName = "";
model = QPATHTOF(drop_1.p3d);
accuracy = 0;
camouflage = 0;
destrType = "DestructNo";
/* Simulation Seagull Additions */
minHeight = 0;
avgHeight = 0;
maxHeight = 0;
minSpeed = 0;
maxSpeed = 0;
acceleration = 0;
turning = 0;
straightDistance = 0;
flySound[] = { "", 0.0316228, 1, 1 };
singSound[] = { "", 0.0316228, 1, 1 };
canBeShot = 0;
airFriction2[] = { 25, 12, 2.5 };
airFriction1[] = { 1500, 700, 100 };
airFriction0[] = { 40, 20, 60 };
/* Simulation Seagull Additions */
};
class ACE_Blooddrop_2: ACE_Blooddrop_1 {
model = QPATHTOF(drop_2.p3d);
};
class ACE_Blooddrop_3: ACE_Blooddrop_1 {
model = QPATHTOF(drop_3.p3d);
};
class ACE_Blooddrop_4: ACE_Blooddrop_1 {
model = QPATHTOF(drop_4.p3d);
};
};

View File

@ -0,0 +1,40 @@
#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) >= 500) then {
private _deletedBloodDrop = GVAR(bloodDrops) deleteAt 0;
deleteVehicle _deletedBloodDrop;
};
[{
params ["_bloodDrop"];
deleteVehicle _bloodDrop;
}, [_bloodDrop], 900] 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,7 @@
#include "script_component.hpp"
PREP(hit);
PREP(isBleeding);
PREP(onBleeding);
PREP(spawnBlood);
PREP(spurt);

View File

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

View File

@ -0,0 +1,4 @@
renderFlags[] = {"NoZWrite"};
class StageTI {
texture = "z\ace\addons\medical_blood\data\splat_ti_ca.paa";
};

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,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 = getPosATL _unit;
private _causedByPos = getPosATL _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,34 @@
/*
* 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 = getPosATL _unit;
_position = _position apply {if (random 1 >= 0.5) then {_x -(random(0.2))} else {_x + (random(0.2))}};
_position set [2, 0];
private _bloodDrop = ["ACE_Blooddrop_1", "ACE_Blooddrop_2", "ACE_Blooddrop_3", "ACE_Blooddrop_4"] select (floor (_bloodLoss max 3));
[_bloodDrop, _position, getDir _unit] call FUNC(spawnBlood);
};

View File

@ -0,0 +1,37 @@
/*
* Author: Glowbal
* Spawn a blood drop. Available blood drop classes are ACE_Blooddrop_1 through ACE_Blooddrop_4.
*
* Arguments:
* 0: classname of blood drop <OBJECT>
* 1: Position <ARRAY>
*
* Return Value:
* Created blood drop <OBJECT>
*
* Example:
* ["ACE_Blooddrop_2", getPos player] call ace_medical_blood_fnc_spawnBlood
*
* Public: No
*/
#include "script_component.hpp"
params ["_type", "_pos"];
private _p3dFile = getText (configFile >> "CfgVehicles" >> _type >> "model");
if (_p3dFile == "") exitWith {};
// createSimpleObject expects a path without the leading slash
if ((_p3dFile select [0,1]) == "\") then {_p3dFile = _p3dFile select [1];};
private _object = createSimpleObject [_p3dFile, [0,0,0]];
_object setPos _pos;
_object setDir (random 360);
if (!isServer) then {
[QGVAR(bloodDropCreated), [_object]] call CBA_fnc_serverEvent;
} else {
[QGVAR(bloodDropCreated), [_object]] call CBA_fnc_localEvent;
};
_object;

View File

@ -0,0 +1,47 @@
/*
* 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_spawnBlood
*
* 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 _pos = getPosATL _unit;
private _distanceBetweenDrops = DISTANCE_BETWEEN_DROPS * _damage;
private _offSet = OFFSET + _distanceBetweenDrops;
private _sinDir = sin _dir;
private _cosDir = cos _dir;
_pos params ["_x", "_y"];
private _bloodPos = [_x + (_sinDir * _offSet), _y + (_cosDir * _offSet), 0];
["ACE_Blooddrop_2", _bloodPos, _dir] call FUNC(spawnBlood);
if (ceil (MAXIMUM_DROPS * _damage) > 1) then {
private _sin = _sinDir * _distanceBetweenDrops;
private _cos = _cosDir * _distanceBetweenDrops;
for "_i" from 2 to _c do {
_bloodPos params ["_x", "_y"];
_bloodPos = [_x + _sin, _y + _cos, 0];
["ACE_Blooddrop_1", _bloodPos, _dir] call FUNC(spawnBlood);
};
};

View File

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

View File

@ -0,0 +1,18 @@
#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"

Binary file not shown.

Binary file not shown.

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>