litter simulation createVehicleLocal /w temporal network sync.

This commit is contained in:
jaynus 2015-04-18 08:31:03 -07:00
parent c952a97de8
commit f31e3c1fd4
5 changed files with 48 additions and 38 deletions

View File

@ -124,4 +124,10 @@ class ACE_Settings {
values[] = {"$STR_ACE_Medical_painEffect_Flash", "$STR_ACE_Medical_painEffect_Chroma"}; values[] = {"$STR_ACE_Medical_painEffect_Flash", "$STR_ACE_Medical_painEffect_Chroma"};
isClientSettable = 1; isClientSettable = 1;
}; };
class GVAR(litterSimulationDetail) {
typeName = "SCALAR";
value = 2;
values[] = {"None", "500", "All"};
};
}; };

View File

@ -265,3 +265,7 @@ if (USE_WOUND_EVENT_SYNC) then {
["playerInventoryChanged", { ["playerInventoryChanged", {
[ACE_player] call FUNC(itemCheck); [ACE_player] call FUNC(itemCheck);
}] call EFUNC(common,addEventHandler); }] call EFUNC(common,addEventHandler);
// Networked litter
[QGVAR(createLitter), FUNC(handleCreateLitter)] call EFUNC(common,addSyncedEventHandler);

View File

@ -21,7 +21,6 @@ PREP(adjustPainLevel);
PREP(canAccessMedicalEquipment); PREP(canAccessMedicalEquipment);
PREP(canTreat); PREP(canTreat);
PREP(canTreatCached); PREP(canTreatCached);
PREP(createLitter);
PREP(determineIfFatal); PREP(determineIfFatal);
PREP(getBloodLoss); PREP(getBloodLoss);
PREP(getBloodPressure); PREP(getBloodPressure);
@ -98,6 +97,10 @@ PREP(moduleTreatmentConfiguration);
PREP(copyDeadBody); PREP(copyDeadBody);
PREP(requestWoundSync); PREP(requestWoundSync);
// Networked litter
PREP(createLitter);
PREP(handleCreateLitter);
GVAR(injuredUnitCollection) = []; GVAR(injuredUnitCollection) = [];
GVAR(IVBags) = []; GVAR(IVBags) = [];

View File

@ -37,21 +37,19 @@ if !(isArray (_config >> "litter")) exitwith {};
_litter = getArray (_config >> "litter"); _litter = getArray (_config >> "litter");
_createLitter = { _createLitter = {
private["_position", "_litterClass", "_direction"];
_position = getPos (_this select 0); _position = getPos (_this select 0);
_litterClass = _this select 1; _litterClass = _this select 1;
_litterObject = createVehicle [_litterClass, _position, [], 0, "NONE"];
if (random(1) >= 0.5) then { if (random(1) >= 0.5) then {
_litterObject setPos [(_position select 0) + random 2, (_position select 1) + random 2, _position select 2]; _position = [(_position select 0) + random 2, (_position select 1) + random 2, _position select 2];
} else { } else {
_litterObject setPos [(_position select 0) - random 2, (_position select 1) - random 2, _position select 2]; _position = [(_position select 0) - random 2, (_position select 1) - random 2, _position select 2];
}; };
_litterObject setDir (random 360); _direction = (random 360);
_litterObject;
}; [QGVAR(createLitter), [_litterClass,_position,_direction], 0] call EFUNC(common,syncedEvent);
if (isnil QGVAR(allCreatedLitter)) then { true
GVAR(allCreatedLitter) = [];
GVAR(litterPFHRunning) = false;
}; };
_createdLitter = []; _createdLitter = [];
@ -75,37 +73,13 @@ _createdLitter = [];
// Loop through through the litter options and place the litter // Loop through through the litter options and place the litter
{ {
if (typeName _x == "ARRAY" && {(count _x > 0)}) then { if (typeName _x == "ARRAY" && {(count _x > 0)}) then {
_createdLitter pushback ([_target, _x select (floor(random(count _x)))] call _createLitter); [_target, _x select (floor(random(count _x)))] call _createLitter;
}; };
if (typeName _x == "STRING") then { if (typeName _x == "STRING") then {
_createdLitter pushback ([_target, _x] call _createLitter); [_target, _x] call _createLitter;
}; };
}foreach _litterOptions; }foreach _litterOptions;
}; };
}; };
}; };
}foreach _litter; }foreach _litter;
if (GVAR(litterCleanUpDelay) >= 0) then {
GVAR(allCreatedLitter) pushback [time, GVAR(litterCleanUpDelay), _createdLitter];
};
if !(GVAR(litterPFHRunning)) then {
GVAR(litterPFHRunning) = true;
[{
{
if (time - (_x select 0) >= (_x select 1)) then {
{
deleteVehicle _x;
}foreach (_this select 2);
GVAR(allCreatedLitter) set[_foreachIndex, objNull];
};
}foreach GVAR(allCreatedLitter);
GVAR(allCreatedLitter) = GVAR(allCreatedLitter) - [objNull];
if (count GVAR(allCreatedLitter) == 0) exitwith {
GVAR(litterPFHRunning) = false;
[_this select 1] call CBA_fnc_removePerFrameHandler;
};
}, 30, []] call CBA_fnc_addPerFrameHandler;
};

View File

@ -0,0 +1,23 @@
#include "script_component.hpp"
PARAMS_3(_litterClass,_position,_direction);
private["_litterObject"];
if (isnil QGVAR(allCreatedLitter)) then {
GVAR(allCreatedLitter) = [];
GVAR(litterPFHRunning) = false;
};
if((count GVAR(allCreatedLitter)) <= GVAR(litterSimulationDetail) )then {
_litterObject = createVehicleLocal [_litterClass, _position, [], 0, "NONE"];
_litterObject setDir _direction;
} else {
// @TODO: We hit max litter items, remove a few of them to work with what we have.
// Basically, we should just start FIFO'ing these
};
GVAR(allCreatedLitter) pushBack _litterObject;
//GVAR(allCreatedLitter) = GVAR(allCreatedLitter) - [objNull];
true