mirror of
https://github.com/acemod/ACE3.git
synced 2024-08-30 18:23:18 +00:00
Convert Finger to CBA/ACE format
This commit is contained in:
parent
ebc55ca6cd
commit
9d914d655a
@ -1,23 +1,24 @@
|
||||
#include "code\addon.hpp"
|
||||
|
||||
#define LOC(x) $__LOCALIZE_PREFIX__##x
|
||||
|
||||
|
||||
class ACE_Settings {
|
||||
class GVAR(FP_indicator_for_self) {
|
||||
displayName = LOC(indicator_for_self);
|
||||
description = LOC(indicator_for_self__desc);
|
||||
isClientSettable = 1;
|
||||
typeName = "BOOL";
|
||||
value = 1;
|
||||
};
|
||||
class GVAR(FP_indicator_color)
|
||||
{
|
||||
value[] = {0.83, 0.68, 0.21, 0.75};
|
||||
typeName = "COLOR";
|
||||
isClientSettable = 1;
|
||||
displayName = LOC(color);
|
||||
description = LOC(color__desc);
|
||||
};
|
||||
|
||||
class GVAR(canFingerEachOther) {
|
||||
typeName = "BOOL";
|
||||
value = 1;
|
||||
};
|
||||
class GVAR(maxRange) {
|
||||
typeName = "SCALAR";
|
||||
value = 4;
|
||||
};
|
||||
class GVAR(indicatorForSelf) {
|
||||
displayName = CSTRING(indicatorForSelf_name);
|
||||
description = CSTRING(indicatorForSelf_description);
|
||||
isClientSettable = 1;
|
||||
typeName = "BOOL";
|
||||
value = 1;
|
||||
};
|
||||
class GVAR(indicatorColor) {
|
||||
value[] = {0.83, 0.68, 0.21, 0.75};
|
||||
typeName = "COLOR";
|
||||
isClientSettable = 1;
|
||||
displayName = CSTRING(indicatorColor_name);
|
||||
description = CSTRING(indicatorColor_description);
|
||||
};
|
||||
};
|
||||
|
10
addons/finger/CfgEventHandlers.hpp
Normal file
10
addons/finger/CfgEventHandlers.hpp
Normal file
@ -0,0 +1,10 @@
|
||||
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));
|
||||
};
|
||||
};
|
23
addons/finger/XEH_postInit.sqf
Normal file
23
addons/finger/XEH_postInit.sqf
Normal file
@ -0,0 +1,23 @@
|
||||
#include "script_component.hpp"
|
||||
|
||||
[QGVAR(fingered), {_this call FUNC(incomingFinger)}] call EFUNC(common,addEventHandler);
|
||||
|
||||
if (!hasInterface) exitWith {};
|
||||
|
||||
GVAR(lastFPTime) = -1;
|
||||
GVAR(fingersHash) = HASH_CREATE;
|
||||
GVAR(pfeh_id) = -1;
|
||||
|
||||
["SettingsInitialized", {
|
||||
//If not enabled, dont't bother adding keybind
|
||||
if (!GVAR(canFingerEachOther)) exitWith {};
|
||||
|
||||
["ACE3 Common",
|
||||
QGVAR(finger),
|
||||
[(localize LSTRING(keyComb)), (localize LSTRING(keyComb_description))],
|
||||
{
|
||||
_this call FUNC(keyPress);
|
||||
},
|
||||
{false},
|
||||
[41, true, false, false], true] call cba_fnc_addKeybind; // Shift + Tilda (hold)
|
||||
}] call EFUNC(common,addEventHandler);
|
9
addons/finger/XEH_preInit.sqf
Normal file
9
addons/finger/XEH_preInit.sqf
Normal file
@ -0,0 +1,9 @@
|
||||
#include "script_component.hpp"
|
||||
|
||||
ADDON = false;
|
||||
|
||||
PREP(incomingFinger);
|
||||
PREP(keyPress);
|
||||
PREP(perFrameEH);
|
||||
|
||||
ADDON = true;
|
@ -1,26 +0,0 @@
|
||||
#ifndef __ADDON_HPP_
|
||||
#define __ADDON_HPP_
|
||||
|
||||
|
||||
#define __ADDON_NAME__ ace_finger
|
||||
#define __BASENAME__ __ADDON_NAME__##_var
|
||||
#define __PREFIX__ "\z\ace\addons\finger"
|
||||
#define __PREFIXC__ "\z\ace\addons\finger\code\"
|
||||
|
||||
#define FUNC(x) __BASENAME__##_fnc_##x
|
||||
#define CFUNC(x) __ADDON_NAME__##_fnc_##x
|
||||
|
||||
#define GVAR(x) __BASENAME__##_##x
|
||||
|
||||
#define __LOCALIZE_PREFIX__ STR_Addons_ACE__dfinger__
|
||||
#define LOCALIZE(x) (localize ('__LOCALIZE_PREFIX__##x'))
|
||||
|
||||
|
||||
|
||||
|
||||
#define PV(x) private ['x']; x
|
||||
|
||||
|
||||
|
||||
|
||||
#endif
|
@ -1,24 +0,0 @@
|
||||
#include "addon.hpp"
|
||||
#include "main.hpp"
|
||||
|
||||
#define BASE_SIZE 44
|
||||
|
||||
|
||||
PV(_pos) = [0,0,0];
|
||||
PV(_name) = "";
|
||||
|
||||
|
||||
PV(_fov_corr) = ((worldToScreen (positionCameraToWorld [1000, 0, 10000])) select 0) - 0.5;
|
||||
PV(_sz) = BASE_SIZE * _fov_corr;
|
||||
|
||||
{
|
||||
_pos = _x select 0;
|
||||
_name = _x select 1;
|
||||
|
||||
drawIcon3D [FP_ICON, [
|
||||
GVAR(FP_indicator_color) select 0,
|
||||
GVAR(FP_indicator_color) select 1,
|
||||
GVAR(FP_indicator_color) select 2,
|
||||
(GVAR(FP_indicator_color) select 3) max MIN_OPAQUE
|
||||
], _pos, _sz, _sz, 0, _name, 1, 0.03, "PuristaMedium"];
|
||||
} forEach MAP_VALUES(GVAR(cur_fps));
|
@ -1,94 +0,0 @@
|
||||
#include "addon.hpp"
|
||||
#include "main.hpp"
|
||||
|
||||
// finger-pointing array format:
|
||||
// 1: source player
|
||||
// 2: position of finger-pointing
|
||||
// 3: players to broadcast the finger-pointing to
|
||||
|
||||
// server-side event-handlers
|
||||
|
||||
if (isServer) then
|
||||
{
|
||||
// receives finger-pointing array and broadcasts it to provided players
|
||||
|
||||
GVAR(fnc_pv_fpToServer) =
|
||||
{
|
||||
LOGV(_this);
|
||||
|
||||
PV(_val) = _this select 1;
|
||||
|
||||
PV(_sp) = _val select 0;
|
||||
PV(_pfp) = _val select 1;
|
||||
PV(_dps) = _val select 2;
|
||||
|
||||
GVAR(pv_fpToClient) = [_sp, _pfp];
|
||||
PV(_owner) = 0;
|
||||
{
|
||||
_owner = owner _x;
|
||||
|
||||
LOGV(_x);
|
||||
LOGV(_owner);
|
||||
|
||||
if (_owner > 0 && {isPlayer _x}) then
|
||||
{
|
||||
if (player == _x) then
|
||||
{
|
||||
[0, GVAR(pv_fpToClient)] call GVAR(fnc_pv_fpToClient);
|
||||
}
|
||||
else
|
||||
{
|
||||
_owner publicVariableClient 'GVAR(pv_fpToClient)';
|
||||
};
|
||||
};
|
||||
} forEach _dps;
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
'GVAR(pv_fpToServer)' addPublicVariableEventHandler GVAR(fnc_pv_fpToServer);
|
||||
|
||||
};
|
||||
|
||||
|
||||
if (hasInterface) then
|
||||
{
|
||||
// currently shown finger-pointings map
|
||||
// key: source player
|
||||
// value: [position, source player name, last update time]
|
||||
//
|
||||
|
||||
|
||||
GVAR(cur_fps) = CREATE_MAP();
|
||||
|
||||
GVAR(fp_handler_running) = false;
|
||||
|
||||
|
||||
// receives pointing-object and starts drawing process in format
|
||||
// 1: source player
|
||||
// 2: position of finger-pointing
|
||||
//
|
||||
|
||||
GVAR(fnc_pv_fpToClient) = {
|
||||
LOGV(_this);
|
||||
|
||||
PV(_val) = _this select 1;
|
||||
PV(_sp) = _val select 0;
|
||||
PV(_pfp) = _val select 1;
|
||||
|
||||
PV(_newval) = [_pfp, name _sp, diag_tickTime];
|
||||
MAP_SET(GVAR(cur_fps), _sp, _newval);
|
||||
|
||||
if (!GVAR(fp_handler_running)) then
|
||||
{
|
||||
GVAR(fp_handler_running) = true;
|
||||
|
||||
[] spawn CFUNC(_fp_handler);
|
||||
};
|
||||
};
|
||||
|
||||
'GVAR(pv_fpToClient)' addPublicVariableEventHandler GVAR(fnc_pv_fpToClient);
|
||||
|
||||
|
||||
};
|
@ -1,44 +0,0 @@
|
||||
#include "addon.hpp"
|
||||
#include "main.hpp"
|
||||
|
||||
['GVAR(_OEF_renderer)', "onEachFrame", CFUNC(_OEF_renderer)]
|
||||
call BIS_fnc_addStackedEventHandler;
|
||||
|
||||
|
||||
// deleting figner-pointings which last more than FP_TIMEOUT
|
||||
|
||||
while {MAP_LEN(GVAR(cur_fps)) > 0} do
|
||||
{
|
||||
if (!(
|
||||
alive player &&
|
||||
{player == vehicle player ||
|
||||
(vehicle player) isKindOf "StaticWeapon"}
|
||||
)) exitWith
|
||||
{
|
||||
GVAR(cur_fps) = CREATE_MAP();
|
||||
};
|
||||
|
||||
|
||||
_ct = diag_tickTime;
|
||||
|
||||
_i = 0;
|
||||
while {_i < MAP_LEN(GVAR(cur_fps))} do
|
||||
{
|
||||
_e = MAP_VALUES(GVAR(cur_fps)) select _i;
|
||||
if (_ct > (_e select 2) + FP_TIMEOUT) then
|
||||
{
|
||||
MAP_IDEL(GVAR(cur_fps), _i);
|
||||
}
|
||||
else
|
||||
{
|
||||
_i = _i + 1;
|
||||
};
|
||||
};
|
||||
|
||||
sleep 0.1;
|
||||
};
|
||||
|
||||
|
||||
['GVAR(_OEF_renderer)', "onEachFrame"] call BIS_fnc_addStackedEventHandler;
|
||||
|
||||
GVAR(fp_handler_running) = false;
|
@ -1,18 +0,0 @@
|
||||
#include "addon.hpp"
|
||||
#include "main.hpp"
|
||||
|
||||
[] spawn
|
||||
{
|
||||
[] call CFUNC(_comm);
|
||||
};
|
||||
|
||||
|
||||
if (hasInterface) then
|
||||
{
|
||||
[] spawn
|
||||
{
|
||||
[] call CFUNC(_mainLoop);
|
||||
};
|
||||
};
|
||||
|
||||
|
@ -1,90 +0,0 @@
|
||||
#include "addon.hpp"
|
||||
#include "main.hpp"
|
||||
|
||||
LOG("Starting");
|
||||
|
||||
//while {isNull (findDisplay 46)} do {sleep 1;};
|
||||
|
||||
|
||||
GVAR(FP_keyComb) = FP_DEFAULT_KEYBIND;
|
||||
|
||||
GVAR(lastFPTime) = -FP_ACTION_TIMEOUT;
|
||||
|
||||
|
||||
["ACE3 Common",
|
||||
"point_finger_at",
|
||||
[LOCALIZE(keyComb), LOCALIZE(keyComb)],
|
||||
{
|
||||
|
||||
PV(_rv) = false;
|
||||
if (alive player) then
|
||||
{
|
||||
if (!(
|
||||
(player == vehicle player ||
|
||||
(vehicle player) isKindOf "StaticWeapon") &&
|
||||
cameraView in ["INTERNAL", "EXTERNAL"]
|
||||
)) exitWith {};
|
||||
|
||||
_rv = true;
|
||||
|
||||
if (diag_tickTime < GVAR(lastFPTime) + FP_ACTION_TIMEOUT)
|
||||
exitWith {};
|
||||
|
||||
|
||||
PV(_pos_prec) = positionCameraToWorld [0, 0, FP_DISTANCE];
|
||||
PV(_pos) = positionCameraToWorld [
|
||||
random (2*FP_RANDOMIZATION_X) - FP_RANDOMIZATION_X,
|
||||
random (2*FP_RANDOMIZATION_Y) - FP_RANDOMIZATION_Y,
|
||||
FP_DISTANCE
|
||||
];
|
||||
|
||||
|
||||
PV(_dest_players) = [];
|
||||
|
||||
PV(_pep) = eyePos player;
|
||||
{
|
||||
if (isPlayer _x && _x != player && alive _x &&
|
||||
{(_x == vehicle _x || (vehicle _x) isKindOf "StaticWeapon") && {
|
||||
((eyePos _x) vectorDistance _pep) < MAX_DIST_TO_OTHER_PLAYERS
|
||||
}}) then
|
||||
{
|
||||
_dest_players pushBack _x;
|
||||
};
|
||||
} forEach playableUnits;
|
||||
|
||||
GVAR(pv_fpToServer) = [player, _pos, _dest_players];
|
||||
|
||||
LOGV(GVAR(pv_fpToServer));
|
||||
|
||||
if (isServer) then
|
||||
{
|
||||
[0, GVAR(pv_fpToServer)] call GVAR(fnc_pv_fpToServer);
|
||||
}
|
||||
else
|
||||
{
|
||||
publicVariableServer 'GVAR(pv_fpToServer)';
|
||||
};
|
||||
|
||||
|
||||
if (GVAR(FP_indicator_for_self)) then
|
||||
{
|
||||
[0, [player, _pos_prec]] call GVAR(fnc_pv_fpToClient);
|
||||
};
|
||||
|
||||
player playActionNow "GestureGo";
|
||||
GVAR(lastFPTime) = diag_tickTime;
|
||||
|
||||
_rv = true;
|
||||
};
|
||||
|
||||
_rv;
|
||||
},
|
||||
"",
|
||||
[GVAR(FP_keyComb) select 0,
|
||||
[GVAR(FP_keyComb) select 1, GVAR(FP_keyComb) select 2, GVAR(FP_keyComb) select 3]]
|
||||
] call cba_fnc_addKeybind;
|
||||
|
||||
|
||||
|
||||
|
||||
LOG("Done");
|
@ -1,54 +0,0 @@
|
||||
#define XOR(x,y) (((x)||(y)) && !((x)&&(y)))
|
||||
#define SQR(x) ((x)*(x))
|
||||
|
||||
|
||||
// debug
|
||||
|
||||
|
||||
#ifdef DEBUG
|
||||
#define LOG(msg) (diag_log text format["%1:%2> %3", __FILE__, __LINE__, (msg)])
|
||||
#define LOGV(msg) (diag_log text format["%1:%2> %3 = %4", __FILE__, __LINE__, (#msg), (msg)])
|
||||
#else
|
||||
#define LOG(msg)
|
||||
#define LOGV(msg)
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// map macros
|
||||
|
||||
#define CREATE_MAP() [[],[]]
|
||||
|
||||
#define MAP_KEYS(m) ((m) select 0)
|
||||
#define MAP_VALUES(m) ((m) select 1)
|
||||
|
||||
#define MAP_SET(m, k, v) if (true) then {_____map_t = MAP_KEYS(m) find (k);\
|
||||
if (_____map_t >= 0) exitWith {MAP_VALUES(m) set [_____map_t, (v)]};\
|
||||
_____map_t = count MAP_KEYS(m);\
|
||||
MAP_KEYS(m) set [_____map_t, (k)];\
|
||||
MAP_VALUES(m) set [_____map_t, (v)];\
|
||||
}
|
||||
|
||||
#define MAP_GET(m, k) if (true) then {_____map_t = MAP_KEYS(m) find (k);\
|
||||
if (_____map_t >= 0) exitWith {MAP_VALUES(m) select _____map_t};\
|
||||
nil\
|
||||
}
|
||||
|
||||
#define MAP_DEL(m, k) if (true) then {_____map_t = MAP_KEYS(m) find (k);\
|
||||
if (_____map_t >= 0) exitWith {\
|
||||
MAP_KEYS(m) deleteAt _____map_t;\
|
||||
MAP_VALUES(m) deleteAt _____map_t;\
|
||||
};\
|
||||
}
|
||||
|
||||
#define MAP_LEN(m) (count MAP_KEYS(m))
|
||||
|
||||
#define MAP_IKEY(m, k) (MAP_KEYS(m) find (k))
|
||||
#define MAP_IGET(m, i) (MAP_VALUES(m) select (i))
|
||||
#define MAP_ISET(m, i, v) (MAP_VALUES(m) set [(i), (v)])
|
||||
#define MAP_IDEL(m, i) if (true) then {\
|
||||
MAP_KEYS(m) deleteAt (i);\
|
||||
MAP_VALUES(m) deleteAt (i);\
|
||||
}
|
@ -1,12 +0,0 @@
|
||||
#ifndef __MAIN_HPP_
|
||||
#define __MAIN_HPP_
|
||||
|
||||
#include "addon.hpp"
|
||||
|
||||
#include "settings.hpp"
|
||||
|
||||
#include "structures.hpp"
|
||||
#include "macros.hpp"
|
||||
|
||||
|
||||
#endif
|
@ -1,25 +0,0 @@
|
||||
#ifndef __STRUCTURES_H__
|
||||
#define __STRUCTURES_H__
|
||||
|
||||
// #define DEBUG
|
||||
|
||||
|
||||
#define FP_ICON "\z\ace\addons\finger\img\fp_icon.paa"
|
||||
|
||||
#define FP_DEFAULT_KEYBIND [41, true, false, false] // Shift + Tilda
|
||||
|
||||
|
||||
#define FP_TIMEOUT 2
|
||||
#define FP_ACTION_TIMEOUT 1
|
||||
|
||||
#define FP_DISTANCE 10000
|
||||
#define FP_RANDOMIZATION_X 350
|
||||
#define FP_RANDOMIZATION_Y 100
|
||||
|
||||
#define MAX_DIST_TO_OTHER_PLAYERS 4
|
||||
|
||||
|
||||
#define MIN_OPAQUE 0.1
|
||||
|
||||
|
||||
#endif
|
@ -1,10 +0,0 @@
|
||||
#ifndef __STRUCTURES_H__
|
||||
#define __STRUCTURES_H__
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#endif
|
@ -2,51 +2,17 @@
|
||||
|
||||
#define RECOMPILE 0
|
||||
|
||||
class CfgPatches
|
||||
{
|
||||
class ace_finger
|
||||
{
|
||||
units[]={};
|
||||
weapons[]={};
|
||||
|
||||
requiredVersion = REQUIRED_VERSION;
|
||||
requiredAddons[] = {"ace_common"};
|
||||
|
||||
author[]=
|
||||
{
|
||||
"Drill"
|
||||
};
|
||||
authorUrl = "https://github.com/TheDrill/";
|
||||
|
||||
addon_version=6;
|
||||
|
||||
VERSION_CONFIG;
|
||||
};
|
||||
class CfgPatches {
|
||||
class ace_finger {
|
||||
units[]={};
|
||||
weapons[]={};
|
||||
requiredVersion = REQUIRED_VERSION;
|
||||
requiredAddons[] = {"ace_common"};
|
||||
author[]= {"Drill"};
|
||||
authorUrl = "https://github.com/TheDrill/";
|
||||
VERSION_CONFIG;
|
||||
};
|
||||
};
|
||||
|
||||
class CfgFunctions
|
||||
{
|
||||
class ace_finger
|
||||
{
|
||||
class Main
|
||||
{
|
||||
file="\z\ace\addons\finger\code";
|
||||
class _init
|
||||
{
|
||||
preInit=0;
|
||||
postInit=1;
|
||||
recompile=RECOMPILE;
|
||||
};
|
||||
|
||||
class _mainLoop {recompile=RECOMPILE;};
|
||||
class _comm {recompile=RECOMPILE;};
|
||||
class _fp_handler {recompile=RECOMPILE;};
|
||||
class _OEF_renderer {recompile=RECOMPILE;};
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
|
||||
#include "ACE_Settings.hpp"
|
||||
|
||||
#include "CfgEventHandlers.hpp"
|
||||
|
35
addons/finger/functions/fnc_incomingFinger.sqf
Normal file
35
addons/finger/functions/fnc_incomingFinger.sqf
Normal file
@ -0,0 +1,35 @@
|
||||
/*
|
||||
* Author: TheDrill, PabstMirror
|
||||
* Recieve an finger event, adds to the array (or updates if already present) and starts PFEH if not already running
|
||||
*
|
||||
* Arguments:
|
||||
* 0: Source Unit (can be self) <OBJECT>
|
||||
* 1: Position being pointed at (from positionCameraToWorld) <ARRAY>
|
||||
*
|
||||
* Return Value:
|
||||
* None
|
||||
*
|
||||
* Example:
|
||||
* [bob, [1,2,3]] call ace_finger_fnc_incomingFinger;
|
||||
*
|
||||
* Public: No
|
||||
*/
|
||||
#include "script_component.hpp"
|
||||
|
||||
PARAMS_2(_sourceUnit,_fingerPosPrecise);
|
||||
|
||||
private ["_data", "_fingerPos"];
|
||||
|
||||
//add some random float to location if it's not our own finger:
|
||||
_fingerPos = if (_sourceUnit == ACE_player) then {
|
||||
_fingerPosPrecise
|
||||
} else {
|
||||
_fingerPosPrecise vectorAdd [random (2*FP_RANDOMIZATION_X) - FP_RANDOMIZATION_X, random (2*FP_RANDOMIZATION_X) - FP_RANDOMIZATION_X, random (2*FP_RANDOMIZATION_Y) - FP_RANDOMIZATION_Y]
|
||||
};
|
||||
|
||||
_data = [ACE_diagTime, _fingerPos, ([_sourceUnit] call EFUNC(common,getName))];
|
||||
HASH_SET(GVAR(fingersHash), _sourceUnit, _data);
|
||||
|
||||
if (GVAR(pfeh_id) == -1) then {
|
||||
GVAR(pfeh_id) = [DFUNC(perFrameEH), 0, []] call CBA_fnc_addPerFrameHandler;
|
||||
};
|
55
addons/finger/functions/fnc_keyPress.sqf
Normal file
55
addons/finger/functions/fnc_keyPress.sqf
Normal file
@ -0,0 +1,55 @@
|
||||
/*
|
||||
* Author: TheDrill
|
||||
* On keypress, point and send position to nearby players
|
||||
*
|
||||
* Arguments:
|
||||
* None
|
||||
*
|
||||
* Return Value:
|
||||
* Key Handeled <BOOL>
|
||||
*
|
||||
* Example:
|
||||
* [] call ace_finger_fnc_keyPress;
|
||||
*
|
||||
* Public: No
|
||||
*/
|
||||
#include "script_component.hpp"
|
||||
|
||||
private["_fingerPosPrecise", "_playerEyePos", "_sendFingerToPlayers"];
|
||||
|
||||
if (!alive ACE_player) exitWith {false};
|
||||
// Conditions: canInteract
|
||||
if !([ACE_player, ACE_player, ["isNotInside"]] call EFUNC(common,canInteractWith)) exitWith {false};
|
||||
//make sure player is dismounted or in a static weapon:
|
||||
if ((ACE_player != vehicle ACE_player) && {!((vehicle ACE_player) isKindOf "StaticWeapon")}) exitWith {false};
|
||||
//Check camera view (not in GUNNER)
|
||||
if !(cameraView in ["INTERNAL", "EXTERNAL"]) exitWith {false};
|
||||
//Exit if run recently (run every 1 seconds)
|
||||
if (ACE_diagTime < (GVAR(lastFPTime) + FP_ACTION_TIMEOUT)) exitWith {false};
|
||||
|
||||
GVAR(lastFPTime) = ACE_diagTime;
|
||||
|
||||
_fingerPosPrecise = positionCameraToWorld [0, 0, FP_DISTANCE];
|
||||
_playerEyePos = eyePos ACE_player;
|
||||
|
||||
_sendFingerToPlayers = [];
|
||||
|
||||
{
|
||||
if ((((eyePos _x) vectorDistance _playerEyePos) < GVAR(maxRange)) &&
|
||||
{alive _x} &&
|
||||
{(_x == (vehicle _x)) || {(vehicle _x) isKindOf "StaticWeapon"}} &&
|
||||
{GVAR(indicatorForSelf) || {_x != ACE_player}} &&
|
||||
{!(lineIntersects [(eyePos _x), _playerEyePos, ACE_player, _x])} &&
|
||||
{[_x] call EFUNC(common,isPlayer)}) then {
|
||||
|
||||
_sendFingerToPlayers pushBack _x;
|
||||
};
|
||||
} forEach allUnits;
|
||||
|
||||
TRACE_1("sending finger to",_sendFingerToPlayers);
|
||||
|
||||
[QGVAR(fingered), _sendFingerToPlayers, [ACE_player, _fingerPosPrecise]] call EFUNC(common,targetEvent);
|
||||
|
||||
ACE_player playActionNow "GestureGo";
|
||||
|
||||
true
|
50
addons/finger/functions/fnc_perFrameEH.sqf
Normal file
50
addons/finger/functions/fnc_perFrameEH.sqf
Normal file
@ -0,0 +1,50 @@
|
||||
/*
|
||||
* Author: TheDrill, PabstMirror
|
||||
* The perFrameEventHandler to draw the icons
|
||||
*
|
||||
* Arguments:
|
||||
* None
|
||||
*
|
||||
* Return Value:
|
||||
* None
|
||||
*
|
||||
* Example:
|
||||
* [fromCBA] call ace_finger_fnc_perFrameEH;
|
||||
*
|
||||
* Public: No
|
||||
*/
|
||||
#include "script_component.hpp"
|
||||
|
||||
private["_drawColor", "_fovCorrection", "_iconSize", "_sourceUnit", "_timeLeftToShow"];
|
||||
|
||||
if (!alive ACE_player) then {GVAR(fingersHash) = HASH_CREATE;};
|
||||
// Conditions: canInteract
|
||||
if !([ACE_player, ACE_player, ["isNotInside"]] call EFUNC(common,canInteractWith)) then {GVAR(fingersHash) = HASH_CREATE;};
|
||||
//make sure player is dismounted or in a static weapon:
|
||||
if ((ACE_player != vehicle ACE_player) && {!((vehicle ACE_player) isKindOf "StaticWeapon")}) then {GVAR(fingersHash) = HASH_CREATE;};
|
||||
|
||||
_fovCorrection = ((worldToScreen (positionCameraToWorld [1000, 0, 10000])) select 0) - 0.5;
|
||||
_iconSize = BASE_SIZE * _fovCorrection;
|
||||
|
||||
{
|
||||
_sourceUnit = _x;
|
||||
_data = HASH_GET(GVAR(fingersHash), _x);
|
||||
EXPLODE_3_PVT(_data,_lastTime,_pos,_name);
|
||||
_timeLeftToShow = _lastTime + FP_TIMEOUT - ACE_diagTime;
|
||||
if (_timeLeftToShow <= 0) then {
|
||||
HASH_REM(GVAR(fingersHash), _x);
|
||||
} else {
|
||||
_drawColor = + GVAR(indicatorColor);
|
||||
//Fade out:
|
||||
if (_timeLeftToShow < 0.5) then {
|
||||
_drawColor set [3, ((_drawColor select 3) * (_timeLeftToShow / 0.5))];
|
||||
};
|
||||
|
||||
drawIcon3D [FP_ICON, _drawColor, _pos, _iconSize, _iconSize, 0, _name, 1, 0.03, "PuristaMedium"];
|
||||
};
|
||||
} forEach (GVAR(fingersHash) select 0);
|
||||
|
||||
if ((count (GVAR(fingersHash) select 0)) == 0) then {
|
||||
[GVAR(pfeh_id)] call CBA_fnc_removePerFrameHandler;
|
||||
GVAR(pfeh_id) = -1;
|
||||
};
|
1
addons/finger/functions/script_component.hpp
Normal file
1
addons/finger/functions/script_component.hpp
Normal file
@ -0,0 +1 @@
|
||||
#include "\z\ace\addons\finger\script_component.hpp"
|
@ -10,3 +10,13 @@
|
||||
#endif
|
||||
|
||||
#include "\z\ace\Addons\main\script_macros.hpp"
|
||||
|
||||
#define BASE_SIZE 44
|
||||
#define FP_ICON "\z\ace\addons\finger\img\fp_icon.paa"
|
||||
|
||||
#define FP_TIMEOUT 2
|
||||
#define FP_ACTION_TIMEOUT 1
|
||||
|
||||
#define FP_DISTANCE 10000
|
||||
#define FP_RANDOMIZATION_X 350
|
||||
#define FP_RANDOMIZATION_Y 100
|
||||
|
@ -1,34 +1,28 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Project name="ace_dfinger">
|
||||
<Package name="strings">
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<Key ID="STR_Addons_ACE__dfinger__indicator_for_self">
|
||||
<Original>Show finger indicator to self</Original>
|
||||
<Russian>Отображать пальце-индикатор для показывающего игрока</Russian>
|
||||
</Key>
|
||||
<Key ID="STR_Addons_ACE__dfinger__indicator_for_self__desc">
|
||||
<Original>Render the indicator for the pointing player. This option doesn't affect whether the other players would see the indicator</Original>
|
||||
<Russian>Отображать индикатор для показывающего игрока. Эта настройка не влияет на то, будутт ли другие игроки видеть индикатор</Russian>
|
||||
</Key>
|
||||
|
||||
<Key ID="STR_Addons_ACE__dfinger__color">
|
||||
<Original>Finger indicator</Original>
|
||||
<Russian>Пальце-индикатор</Russian>
|
||||
</Key>
|
||||
<Key ID="STR_Addons_ACE__dfinger__color__desc">
|
||||
<Original>Color of the finger-pointing indicator circle</Original>
|
||||
<Russian>Цвет индикатора пальце-указания</Russian>
|
||||
</Key>
|
||||
|
||||
<Key ID="STR_Addons_ACE__dfinger__keyComb">
|
||||
<Original>Action "point a finger at"</Original>
|
||||
<Russian>Действие "показать пальцем на"</Russian>
|
||||
</Key>
|
||||
|
||||
</Package>
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project name="ACE">
|
||||
<Package name="finger">
|
||||
<Key ID="STR_ACE_finger_indicatorForSelf_name">
|
||||
<English>Show finger indicator to self</English>
|
||||
<Russian>Отображать пальце-индикатор для показывающего игрока</Russian>
|
||||
</Key>
|
||||
<Key ID="STR_ACE_finger_indicatorForSelf_description">
|
||||
<English>Render the indicator for the pointing player. This option doesn't affect whether the other players would see the indicator</English>
|
||||
<Russian>Отображать индикатор для показывающего игрока. Эта настройка не влияет на то, будутт ли другие игроки видеть индикатор</Russian>
|
||||
</Key>
|
||||
<Key ID="STR_ACE_finger_indicatorColor_name">
|
||||
<English>Finger indicator</English>
|
||||
<Russian>Пальце-индикатор</Russian>
|
||||
</Key>
|
||||
<Key ID="STR_ACE_finger_indicatorColor_description">
|
||||
<English>Color of the finger-pointing indicator circle</English>
|
||||
<Russian>Цвет индикатора пальце-указания</Russian>
|
||||
</Key>
|
||||
<Key ID="STR_ACE_finger_keyComb">
|
||||
<English>Action "point a finger at"</English>
|
||||
<Russian>Действие "показать пальцем на"</Russian>
|
||||
</Key>
|
||||
<Key ID="STR_ACE_finger_keyComb_description">
|
||||
<English>Shows a virtual marker of where you are pointing to nearby units.</English>
|
||||
</Key>
|
||||
</Package>
|
||||
</Project>
|
||||
|
Loading…
Reference in New Issue
Block a user