diff --git a/framework/CfgFunctions.hpp b/framework/CfgFunctions.hpp index 3aeabc1..c2d1ac8 100644 --- a/framework/CfgFunctions.hpp +++ b/framework/CfgFunctions.hpp @@ -31,7 +31,7 @@ class DOUBLES(PREFIX,client) { class bindVehicleActions {}; class addGetNearMenPFH {}; class addDraw3DPFH {}; - class addPFHCode {}; + class registerPFHCode {}; class clearPFHCode {}; }; }; @@ -40,15 +40,16 @@ class DOUBLES(PREFIX,common) { class functions { file = "framework\common\functions"; class addCBASettings { preInit = 1; }; - class logMissionInfo {}; class addPlayerInfoToArray {}; + class checkPlayerInventory {}; class createOrUpdateDiaryRecord {}; + class draw3DIconStatus {}; class getApprovedAssetsCfg {}; class getBattalionCfg {}; class getNameOfBase {}; class getNearestBase {}; class log {}; - class checkPlayerInventory {}; + class logMissionInfo {}; class logSettingChanged {}; class padString {}; class recurseSubclasses {}; diff --git a/framework/client/functions/fn_bindEventHandlers.sqf b/framework/client/functions/fn_bindEventHandlers.sqf index 61948d2..72faae7 100644 --- a/framework/client/functions/fn_bindEventHandlers.sqf +++ b/framework/client/functions/fn_bindEventHandlers.sqf @@ -7,20 +7,19 @@ player addEventHandler["Respawn", params ["_unit", "_corpse"]; private _killer = _corpse getVariable ["ace_medical_causeOfDeath", "#scripted"]; if (_killer == "respawn_button") then { - private _timeWentUnconscious = _unit getVariable [QGVARMAIN(lastTimeKnockedOut), -1]; - private _durationSpentUnconscious = diag_tickTime - _timeWentUnconscious; + private _timeWentUnconscious = _corpse getVariable [QGVARMAIN(lastTimeKnockedOut), -1]; + private _durationSpentUnconscious = -1; + if (_timeWentUnconscious > -1) then { + _durationSpentUnconscious = diag_tickTime - _timeWentUnconscious; + }; + [ LEVEL_INFO, QUOTE(COMPONENT), "RESPAWNED WHILE UNCONSCIOUS", - [_unit, [[ - "durationSpentUnconscious", - (if (_timeWentUnconscious > - 1) then { - _durationSpentUnconscious - } else { - -1 - }) - ]]] call EFUNC(common,addPlayerInfoToArray) + [_unit, [ + ["durationSpentUnconscious", _durationSpentUnconscious] + ]] call EFUNC(common,addPlayerInfoToArray) ] remoteExec [QEFUNC(common,log), 2]; // format["%1 was unconscious then clicked the respawn button", name _unit] remoteExec["systemChat", 0]; }; diff --git a/framework/client/functions/fn_addPFHCode.sqf b/framework/client/functions/fn_registerPFHCode.sqf similarity index 100% rename from framework/client/functions/fn_addPFHCode.sqf rename to framework/client/functions/fn_registerPFHCode.sqf diff --git a/framework/common/functions/fn_draw3DIconStatus.sqf b/framework/common/functions/fn_draw3DIconStatus.sqf new file mode 100644 index 0000000..a697632 --- /dev/null +++ b/framework/common/functions/fn_draw3DIconStatus.sqf @@ -0,0 +1,54 @@ +#include "..\script_component.hpp" + +if (!hasInterface) exitWith {}; + +params [ + ["_drawTargets", [], [[]]], + ["_icon", "", [""]], + ["_text", "", [""]], + ["_color", [], [[]]] +]; + +if (count _drawTargets isEqualTo 0) exitWith {}; + +_cameraPos = positionCameraToWorld [0,0,0]; +_cameraPosASL = AGLToASL _cameraPos; + +{ + _target = _x; + _visible = [objNull, "VIEW"] checkVisibility [_cameraPosASL, eyePos _target]; + + if ( _visible isEqualTo 0 ) exitWith {}; + + _objectPos = (_target modelToWorldVisual (_target selectionPosition "pilot")); + _distance = (visiblePosition _target) vectorDiff _cameraPos; + + _scale = 0; + _heightOffset = 0; + _heightScaling = 0.012; + + if ( _icon isNotEqualTo "") then { + _heightOffset = 0.065; + _scale = 1; + _heightScaling = 0.075; + }; + + _drawPos = _objectPos vectorAdd [0, 0, (0.18 + _heightOffset) + (vectorMagnitude _distance * _heightScaling)]; + + drawIcon3D [ + _icon, + _color, + _drawPos, + _scale, + _scale, + 0, + _text, + 2, + 0.025 + ]; + + true; +} count _drawTargets; + +nil + diff --git a/framework/init/functions/fn_addRespawnChatHandler.sqf b/framework/init/functions/fn_addRespawnChatHandler.sqf index ad7dd7c..cfb06d3 100644 --- a/framework/init/functions/fn_addRespawnChatHandler.sqf +++ b/framework/init/functions/fn_addRespawnChatHandler.sqf @@ -9,21 +9,19 @@ if (!hasInterface) exitWith {}; player setDamage 1; private _timeWentUnconscious = player getVariable [QGVARMAIN(lastTimeKnockedOut), -1]; - private _durationSpentUnconscious = diag_tickTime - _timeWentUnconscious; + private _durationSpentUnconscious = -1; + if (_timeWentUnconscious > - 1) then { + _durationSpentUnconscious = diag_tickTime - _timeWentUnconscious; + }; // log to server RPT [ LEVEL_INFO, QUOTE(COMPONENT), "CHAT COMMAND RESPAWN", - [player, [[ - "durationSpentUnconscious", - (if (_timeWentUnconscious > - 1) then { - _durationSpentUnconscious - } else { - -1 - }) - ]]] call EFUNC(common,addPlayerInfoToArray) + [player, [ + ["durationSpentUnconscious", _durationSpentUnconscious] + ]] call EFUNC(common,addPlayerInfoToArray) ] remoteExec [QEFUNC(common,log), 2]; // systemChat to all remote machines diff --git a/framework/triageIcons/functions/fn_draw3D.sqf b/framework/triageIcons/functions/fn_draw3D.sqf index c4cb8d5..21c9738 100644 --- a/framework/triageIcons/functions/fn_draw3D.sqf +++ b/framework/triageIcons/functions/fn_draw3D.sqf @@ -47,6 +47,7 @@ private _code = { true // outline // further params optional, omitted ]; + true; } count ( (localNamespace getVariable [QEGVAR(client,nearMen), []]) select { @@ -59,4 +60,4 @@ private _code = { }; // add codeblock to common array -[_code] call EFUNC(client,addPFHCode); \ No newline at end of file +[_code] call EFUNC(client,registerPFHCode); \ No newline at end of file diff --git a/framework/vehicleFlags/functions/fn_draw3D.sqf b/framework/vehicleFlags/functions/fn_draw3D.sqf index c654220..3b971a3 100644 --- a/framework/vehicleFlags/functions/fn_draw3D.sqf +++ b/framework/vehicleFlags/functions/fn_draw3D.sqf @@ -4,37 +4,21 @@ // adds codeblock to common array to be processed per frame private _code = { - { - private _unit = _x; - - // color based on triage level - private _color = [0.9, 0.9, 0.9, 1]; // default color - // draw position, slightly above the prone unit - private _drawPos = (visiblePosition _unit) vectorAdd [0, 0, 0.5]; - // draw icon - drawIcon3D [ - "", // icon texture - _color, // color - _drawPos, // position AGL - 1, // width - 1, // height - 0, // angle - "Setting vehicle flag...", // text - true // outline - // further params optional, omitted - ]; - true; - } count ( - (localNamespace getVariable [QEGVAR(client,nearMen), []]) select { - (_x getVariable [QGVAR(inFlagMenu), false]) && { - // distance within X meters - player distance _x <= 10 || - // check unit not in a vehicle - isNull (objectParent _x) - } + private _unitsToDraw = (localNamespace getVariable [QEGVAR(client,nearMen), []]) select { + (_x getVariable [QGVAR(inFlagMenu), false]) && { + // distance within X meters + player distance _x <= 15 || + // check unit not in a vehicle + isNull (objectParent _x) } - ); + }; + [ + _unitsToDraw, + "", + "Setting vehicle flag...", + [0.9, 0.9, 0.9, 1] + ] call EFUNC(common,draw3dIconStatus); }; // add codeblock to common array -[_code] call EFUNC(client,addPFHCode); \ No newline at end of file +[_code] call EFUNC(client,registerPFHCode); \ No newline at end of file