mirror of
https://github.com/acemod/ACE3.git
synced 2024-08-30 18:23:18 +00:00
Working Demo
This commit is contained in:
parent
7b88280988
commit
6130b5b373
30
addons/explosives/GUI_VirtualAmmo.hpp
Normal file
30
addons/explosives/GUI_VirtualAmmo.hpp
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
class RscTitles {
|
||||||
|
class GVAR(virtualAmmo) {
|
||||||
|
idd = -1;
|
||||||
|
movingEnable = 1;
|
||||||
|
duration = 9999999;
|
||||||
|
fadein = 0;
|
||||||
|
fadeout = 0;
|
||||||
|
onLoad = "uiNamespace setVariable ['ACE_explosives_virtualAmmoDisplay', (_this select 0)];";
|
||||||
|
class controls {};
|
||||||
|
class objects {
|
||||||
|
class TheObject {
|
||||||
|
idc = 800851;
|
||||||
|
type = 82;
|
||||||
|
model = "\a3\weapons_f\Ammo\Handgrenade.p3d"; //dummy value, cannot be "" !!!
|
||||||
|
scale = 1;
|
||||||
|
direction[] = {0, 0, 1};
|
||||||
|
up[] = {0, 1, 0};
|
||||||
|
x = 0.5;
|
||||||
|
y = 0.5;
|
||||||
|
z = 1;
|
||||||
|
xBack = 0.5;
|
||||||
|
yBack = 0.5;
|
||||||
|
zBack = 0.5;
|
||||||
|
inBack = 0;
|
||||||
|
enableZoom = 0;
|
||||||
|
zoomDuration = 1;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
@ -12,6 +12,8 @@ class CfgPatches {
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#include "ACE_Settings.hpp"
|
||||||
|
|
||||||
#include "CfgEventHandlers.hpp"
|
#include "CfgEventHandlers.hpp"
|
||||||
|
|
||||||
#include "CfgAmmo.hpp"
|
#include "CfgAmmo.hpp"
|
||||||
@ -21,6 +23,7 @@ class CfgPatches {
|
|||||||
|
|
||||||
#include "ACE_Triggers.hpp"
|
#include "ACE_Triggers.hpp"
|
||||||
#include "ExplosivesUI.hpp"
|
#include "ExplosivesUI.hpp"
|
||||||
|
#include "GUI_VirtualAmmo.hpp"
|
||||||
|
|
||||||
class CfgActions {
|
class CfgActions {
|
||||||
class None;
|
class None;
|
||||||
@ -39,5 +42,3 @@ class CfgMineTriggers {
|
|||||||
mineTriggerRange = 1;
|
mineTriggerRange = 1;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
#include "ACE_Settings.hpp"
|
|
||||||
|
@ -43,10 +43,10 @@ _children = [];
|
|||||||
format ["Explosive_%1", _forEachIndex],
|
format ["Explosive_%1", _forEachIndex],
|
||||||
format [_name + " (%1)", _itemCount select _foreachIndex],
|
format [_name + " (%1)", _itemCount select _foreachIndex],
|
||||||
getText(_x >> "picture"),
|
getText(_x >> "picture"),
|
||||||
{(_this select 2) call FUNC(setupExplosive);},
|
{_this call FUNC(setupExplosive);},
|
||||||
{true},
|
{true},
|
||||||
{},
|
{},
|
||||||
[_unit, configName _x]
|
(configName _x)
|
||||||
] call EFUNC(interact_menu,createAction),
|
] call EFUNC(interact_menu,createAction),
|
||||||
[],
|
[],
|
||||||
_unit
|
_unit
|
||||||
|
@ -14,9 +14,9 @@
|
|||||||
* Public: No
|
* Public: No
|
||||||
*/
|
*/
|
||||||
#include "script_component.hpp"
|
#include "script_component.hpp"
|
||||||
if (isNull(GVAR(Setup)) || {ACE_Modifier == 0} || !GVAR(pfeh_running)) exitWith {false};
|
|
||||||
_this = _this * 5;
|
if ((!GVAR(pfeh_running)) || {ACE_Modifier == 0}) exitWith {false};
|
||||||
GVAR(Setup) setDir ((getDir GVAR(Setup)) + _this);
|
|
||||||
GVAR(TweakedAngle) = GVAR(TweakedAngle) + _this;
|
GVAR(TweakedAngle) = ((GVAR(TweakedAngle) + 5 * _this) + 360) % 360;
|
||||||
|
|
||||||
true
|
true
|
||||||
|
@ -3,8 +3,9 @@
|
|||||||
* Starts the setup process for the passed explosive. Player only.
|
* Starts the setup process for the passed explosive. Player only.
|
||||||
*
|
*
|
||||||
* Arguments:
|
* Arguments:
|
||||||
* 0: Unit <OBJECT>
|
* 0: Vehicle <OBJECT>
|
||||||
* 1: Classname of explosive to place. (CfgMagazine class) <STRING>
|
* 1: Player Unit <OBJECT>
|
||||||
|
* 2: Classname of explosive to place. (CfgMagazine class) <STRING>
|
||||||
*
|
*
|
||||||
* Return Value:
|
* Return Value:
|
||||||
* None
|
* None
|
||||||
@ -15,6 +16,120 @@
|
|||||||
* Public: Yes
|
* Public: Yes
|
||||||
*/
|
*/
|
||||||
#include "script_component.hpp"
|
#include "script_component.hpp"
|
||||||
|
|
||||||
|
PARAMS_3(_vehicle,_player,_magClassname);
|
||||||
|
|
||||||
|
[_player, "ACE_Explosives", true] call EFUNC(common,setForceWalkStatus);
|
||||||
|
GVAR(TweakedAngle) = 0;
|
||||||
|
|
||||||
|
//Get setup object vehicle and model:
|
||||||
|
_setupObjectClass = getText(ConfigFile >> "CfgMagazines" >> _magClassname >> "ACE_SetupObject");
|
||||||
|
if (!isClass (configFile >> "CfgVehicles" >> _setupObjectClass)) exitWith {ERROR("Bad Vehicle");};
|
||||||
|
_p3dModel = getText (configFile >> "CfgVehicles" >> _setupObjectClass >> "model");
|
||||||
|
if (_p3dModel == "") exitWith {ERROR("No Model");}; //"" - will crash game!
|
||||||
|
|
||||||
|
[localize LSTRING(PlaceAction), localize LSTRING(CancelAction), localize LSTRING(ScrollAction)] call EFUNC(interaction,showMouseHint);
|
||||||
|
_player setVariable [QGVAR(placeActionEH), [_player, "DefaultAction", {true}, {GVAR(placeAction) = PLACE_APPROVE;}] call EFUNC(common,AddActionEventHandler)];
|
||||||
|
_player setVariable [QGVAR(cancelActionEH), [_player, "zoomtemp", {true}, {GVAR(placeAction) = PLACE_CANCEL;}] call EFUNC(common,AddActionEventHandler)];
|
||||||
|
|
||||||
|
|
||||||
|
//Display to show virtual object:
|
||||||
|
(QGVAR(virtualAmmo) call BIS_fnc_rscLayer) cutRsc [QGVAR(virtualAmmo), "PLAIN", 0, false];
|
||||||
|
((uiNamespace getVariable [QGVAR(virtualAmmoDisplay), displayNull]) displayCtrl 800851) ctrlSetModel _p3dModel;
|
||||||
|
|
||||||
|
GVAR(pfeh_running) = true;
|
||||||
|
GVAR(placeAction) = PLACE_WAITING;
|
||||||
|
|
||||||
|
|
||||||
|
[{
|
||||||
|
private["_angle", "_dir", "_screenPos", "_realDistance", "_up", "_virtualPos", "_virtualPosASL", "_badPosition"];
|
||||||
|
|
||||||
|
PARAMS_2(_args,_pfID);
|
||||||
|
EXPLODE_3_PVT(_args,_unit,_magClassname,_setupObjectClass);
|
||||||
|
|
||||||
|
_virtualPosASL = (eyePos _unit) vectorAdd (positionCameraToWorld [0,0,1]) vectorDiff (positionCameraToWorld [0,0,0]);
|
||||||
|
if (cameraView == "EXTERNAL") then {
|
||||||
|
_virtualPosASL = _virtualPosASL vectorAdd ((positionCameraToWorld [0.3,0,0]) vectorDiff (positionCameraToWorld [0,0,0]));
|
||||||
|
};
|
||||||
|
_virtualPos = _virtualPosASL call EFUNC(common,ASLToPosition);
|
||||||
|
_intersectsWith = lineIntersectsWith [eyePos ACE_player, _virtualPosASL, ACE_player];
|
||||||
|
|
||||||
|
hintSilent format ["IntersectsWith %1", _intersectsWith];
|
||||||
|
|
||||||
|
_badPosition = (count _intersectsWith) > 0;
|
||||||
|
|
||||||
|
//Don't allow placing in a bad position:
|
||||||
|
if (_badPosition && {GVAR(placeAction) == PLACE_APPROVE}) then {GVAR(placeAction) = PLACE_WAITING;};
|
||||||
|
|
||||||
|
//Cancel on RMB, For some reason this works (when held) but AddActionEventHandler doesn't
|
||||||
|
if ((inputAction "zoomTemp") > 0) then {GVAR(placeAction) = PLACE_CANCEL;};
|
||||||
|
|
||||||
|
if ((GVAR(placeAction) != PLACE_WAITING) ||
|
||||||
|
{_unit != ACE_player} ||
|
||||||
|
{(inputAction "optics") > 0}) then {
|
||||||
|
|
||||||
|
[_pfID] call CBA_fnc_removePerFrameHandler;
|
||||||
|
GVAR(pfeh_running) = false;
|
||||||
|
|
||||||
|
[_unit, "ACE_Explosives", false] call EFUNC(common,setForceWalkStatus);
|
||||||
|
[] call EFUNC(interaction,hideMouseHint);
|
||||||
|
[_unit, "DefaultAction", (_unit getVariable [QGVAR(placeActionEH), -1])] call EFUNC(common,removeActionEventHandler);
|
||||||
|
[_unit, "zoomtemp", (_unit getVariable [QGVAR(cancelActionEH), -1])] call EFUNC(common,removeActionEventHandler);
|
||||||
|
|
||||||
|
(QGVAR(virtualAmmo) call BIS_fnc_rscLayer) cutText ["", "PLAIN"];
|
||||||
|
|
||||||
|
if (GVAR(placeAction) == PLACE_APPROVE) then {
|
||||||
|
systemChat "place";
|
||||||
|
_dir = (positionCameraToWorld [0,0,0]) vectorFromTo (positionCameraToWorld [0,0,1]);
|
||||||
|
_angle = ((_dir select 0) atan2 (_dir select 1)) - GVAR(TweakedAngle) - 180;
|
||||||
|
|
||||||
|
systemChat format ["Pos %1, Cam %2, Ang %3", _virtualPosASL, ((_dir select 0) atan2 (_dir select 1)), _angle];
|
||||||
|
|
||||||
|
_realObject = _setupObjectClass createVehicle _virtualPos;
|
||||||
|
_realObject setPosAsl _virtualPosASL;
|
||||||
|
_realObject setDir _angle;
|
||||||
|
// [_unit, _attachToVehicle, _itemClassname, _itemVehClass, _onAtachText, _virtualPos] call FUNC(placeApprove);
|
||||||
|
};
|
||||||
|
} else {
|
||||||
|
// systemChat format ["A Running %1 - %2", time, _badPosition];
|
||||||
|
//Show the virtual object:
|
||||||
|
if (_badPosition) then {
|
||||||
|
((uiNamespace getVariable [QGVAR(virtualAmmoDisplay), displayNull]) displayCtrl 800851) ctrlShow false;
|
||||||
|
} else {
|
||||||
|
((uiNamespace getVariable [QGVAR(virtualAmmoDisplay), displayNull]) displayCtrl 800851) ctrlShow true;
|
||||||
|
_screenPos = worldToScreen _virtualPos;
|
||||||
|
if (_screenPos isEqualTo []) exitWith {
|
||||||
|
((uiNamespace getVariable [QGVAR(virtualAmmoDisplay), displayNull]) displayCtrl 800851) ctrlShow false;
|
||||||
|
};
|
||||||
|
_realDistance = (_virtualPos distance (positionCameraToWorld [0,0,0])) / ((call CBA_fnc_getFov) select 1);
|
||||||
|
_screenPos = [(_screenPos select 0), _realDistance, (_screenPos select 1)];
|
||||||
|
((uiNamespace getVariable [QGVAR(virtualAmmoDisplay), displayNull]) displayCtrl 800851) ctrlSetPosition _screenPos;
|
||||||
|
_dir = (positionCameraToWorld [0,0,1]) vectorFromTo (positionCameraToWorld [0,0,0]);
|
||||||
|
_angle = asin (_dir select 2) + 90;
|
||||||
|
|
||||||
|
_modelUp = [0, (cos _angle), (sin _angle)];
|
||||||
|
_modelDir = [cos GVAR(TweakedAngle), sin GVAR(TweakedAngle), 0] vectorCrossProduct _modelUp;
|
||||||
|
|
||||||
|
// systemChat format ["Running %1", [_modelDir, _modelUp]];
|
||||||
|
((uiNamespace getVariable [QGVAR(virtualAmmoDisplay), displayNull]) displayCtrl 800851) ctrlSetModelDirAndUp [_modelDir, _modelUp];
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}, 0, [_player, _magClassname, _setupObjectClass]] call CBA_fnc_addPerFrameHandler;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
|
||||||
|
|
||||||
closeDialog 0;
|
closeDialog 0;
|
||||||
EXPLODE_2_PVT(_this,_unit,_class);
|
EXPLODE_2_PVT(_this,_unit,_class);
|
||||||
GVAR(placer) = _unit;
|
GVAR(placer) = _unit;
|
||||||
@ -24,8 +139,8 @@ GVAR(Setup) = createVehicle [getText(ConfigFile >> "CfgMagazines" >> _class >> "
|
|||||||
GVAR(Setup) enableSimulationGlobal false;
|
GVAR(Setup) enableSimulationGlobal false;
|
||||||
GVAR(Setup) setVariable [QGVAR(class), _class, true];
|
GVAR(Setup) setVariable [QGVAR(class), _class, true];
|
||||||
|
|
||||||
[_unit, "ACE_Explosives", true] call EFUNC(common,setForceWalkStatus);
|
|
||||||
GVAR(TweakedAngle) = 180;
|
|
||||||
|
|
||||||
[QGVAR(Placement),"OnEachFrame", {
|
[QGVAR(Placement),"OnEachFrame", {
|
||||||
private ["_player", "_pos"];
|
private ["_player", "_pos"];
|
||||||
@ -41,9 +156,4 @@ GVAR(TweakedAngle) = 180;
|
|||||||
};
|
};
|
||||||
}] call CALLSTACK(BIS_fnc_addStackedEventHandler);
|
}] call CALLSTACK(BIS_fnc_addStackedEventHandler);
|
||||||
|
|
||||||
[localize LSTRING(PlaceAction), localize LSTRING(CancelAction),
|
*/
|
||||||
localize LSTRING(ScrollAction)] call EFUNC(interaction,showMouseHint);
|
|
||||||
_unit setVariable [QGVAR(Place), [_unit, "DefaultAction",
|
|
||||||
{GVAR(pfeh_running) AND !isNull (GVAR(Setup))}, {call FUNC(place_Approve);}] call EFUNC(common,AddActionEventHandler)];
|
|
||||||
_unit setVariable [QGVAR(Cancel), [_unit, "zoomtemp",
|
|
||||||
{GVAR(pfeh_running) AND !isNull (GVAR(Setup))}, {call FUNC(place_Cancel);}] call EFUNC(common,AddActionEventHandler)];
|
|
||||||
|
@ -12,3 +12,7 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "\z\ace\addons\main\script_macros.hpp"
|
#include "\z\ace\addons\main\script_macros.hpp"
|
||||||
|
|
||||||
|
#define PLACE_WAITING -1
|
||||||
|
#define PLACE_CANCEL 0
|
||||||
|
#define PLACE_APPROVE 1
|
Loading…
Reference in New Issue
Block a user