mirror of
https://github.com/acemod/ACE3.git
synced 2024-08-30 18:23:18 +00:00
commit
dadec15948
@ -116,3 +116,4 @@ voiper
|
||||
VyMajoris(W-Cephei)<vycanismajoriscsa@gmail.com>
|
||||
Winter <simon@agius-muscat.net>
|
||||
zGuba
|
||||
Grey-Soldierman <gungamer101@hotmail.com>
|
||||
|
BIN
addons/apl/ace_entrchtool.p3d
Normal file
BIN
addons/apl/ace_entrchtool.p3d
Normal file
Binary file not shown.
BIN
addons/apl/ace_envelope_big.p3d
Normal file
BIN
addons/apl/ace_envelope_big.p3d
Normal file
Binary file not shown.
BIN
addons/apl/ace_envelope_big4.p3d
Normal file
BIN
addons/apl/ace_envelope_big4.p3d
Normal file
Binary file not shown.
BIN
addons/apl/ace_envelope_big4_nogeo.p3d
Normal file
BIN
addons/apl/ace_envelope_big4_nogeo.p3d
Normal file
Binary file not shown.
BIN
addons/apl/ace_envelope_small.p3d
Normal file
BIN
addons/apl/ace_envelope_small.p3d
Normal file
Binary file not shown.
BIN
addons/apl/ace_envelope_small4.p3d
Normal file
BIN
addons/apl/ace_envelope_small4.p3d
Normal file
Binary file not shown.
BIN
addons/apl/ace_envelope_small4_nogeo.p3d
Normal file
BIN
addons/apl/ace_envelope_small4_nogeo.p3d
Normal file
Binary file not shown.
75
addons/apl/data/entrchtool.rvmat
Normal file
75
addons/apl/data/entrchtool.rvmat
Normal file
@ -0,0 +1,75 @@
|
||||
ambient[]={1,1,1,1};
|
||||
diffuse[]={2,2,2,0};
|
||||
forcedDiffuse[]={0,0,0,0};
|
||||
emmisive[]={0,0,0,1};
|
||||
specular[]={0.054000214,0.054000214,0.058000047,0};
|
||||
specularPower=50.700001;
|
||||
PixelShaderID="Super";
|
||||
VertexShaderID="Super";
|
||||
class Stage1
|
||||
{
|
||||
texture="z\ace\addons\apl\data\entrchtool_nohq.paa";
|
||||
uvSource="tex";
|
||||
class uvTransform
|
||||
{
|
||||
aside[]={1,0,0};
|
||||
up[]={0,1,0};
|
||||
dir[]={0,0,0};
|
||||
pos[]={0,0,0};
|
||||
};
|
||||
};
|
||||
class Stage2
|
||||
{
|
||||
texture="#(argb,8,8,3)color(0.5,0.5,0.5,1,DT)";
|
||||
uvSource="tex";
|
||||
class uvTransform
|
||||
{
|
||||
aside[]={4,0,0};
|
||||
up[]={0,6,0};
|
||||
dir[]={0,0,2};
|
||||
pos[]={0,0,0};
|
||||
};
|
||||
Filter="Anizotropic";
|
||||
};
|
||||
class Stage3
|
||||
{
|
||||
texture="#(argb,8,8,3)color(0,0,0,0,MC)";
|
||||
uvSource="tex";
|
||||
class uvTransform
|
||||
{
|
||||
aside[]={1,0,0};
|
||||
up[]={0,1,0};
|
||||
dir[]={0,0,0};
|
||||
pos[]={0,0,0};
|
||||
};
|
||||
Filter="Anizotropic";
|
||||
};
|
||||
class Stage4
|
||||
{
|
||||
texture="z\ace\addons\apl\data\entrchtool_as.paa";
|
||||
uvSource="tex";
|
||||
class uvTransform
|
||||
{
|
||||
aside[]={1,0,0};
|
||||
up[]={0,1,0};
|
||||
dir[]={0,0,0};
|
||||
pos[]={0,0,0};
|
||||
};
|
||||
};
|
||||
class Stage5
|
||||
{
|
||||
texture="z\ace\addons\apl\data\entrchtool_smdi.paa";
|
||||
uvSource="tex";
|
||||
class uvTransform
|
||||
{
|
||||
aside[]={1,0,0};
|
||||
up[]={0,1,0};
|
||||
dir[]={0,0,0};
|
||||
pos[]={0,0,0};
|
||||
};
|
||||
};
|
||||
class Stage6
|
||||
{
|
||||
texture="a3\data_f\env_co.paa";
|
||||
uvSource="none";
|
||||
};
|
BIN
addons/apl/data/entrchtool_as.paa
Normal file
BIN
addons/apl/data/entrchtool_as.paa
Normal file
Binary file not shown.
BIN
addons/apl/data/entrchtool_co.paa
Normal file
BIN
addons/apl/data/entrchtool_co.paa
Normal file
Binary file not shown.
BIN
addons/apl/data/entrchtool_nohq.paa
Normal file
BIN
addons/apl/data/entrchtool_nohq.paa
Normal file
Binary file not shown.
BIN
addons/apl/data/entrchtool_smdi.paa
Normal file
BIN
addons/apl/data/entrchtool_smdi.paa
Normal file
Binary file not shown.
BIN
addons/apl/data/zr_plevel_co.paa
Normal file
BIN
addons/apl/data/zr_plevel_co.paa
Normal file
Binary file not shown.
1
addons/trenches/$PBOPREFIX$
Normal file
1
addons/trenches/$PBOPREFIX$
Normal file
@ -0,0 +1 @@
|
||||
z\ace\addons\trenches
|
20
addons/trenches/CfgEventHandlers.hpp
Normal file
20
addons/trenches/CfgEventHandlers.hpp
Normal file
@ -0,0 +1,20 @@
|
||||
|
||||
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));
|
||||
};
|
||||
};
|
||||
|
||||
class Extended_Killed_EventHandlers {
|
||||
class CAManBase {
|
||||
class ADDON {
|
||||
killed = QUOTE(_this call FUNC(handleKilled));
|
||||
};
|
||||
};
|
||||
};
|
64
addons/trenches/CfgVehicles.hpp
Normal file
64
addons/trenches/CfgVehicles.hpp
Normal file
@ -0,0 +1,64 @@
|
||||
class CfgVehicles {
|
||||
class Man;
|
||||
class CAManBase: Man {
|
||||
class ACE_SelfActions {
|
||||
class ACE_Equipment {
|
||||
class GVAR(digEnvelopeSmall) {
|
||||
displayName = CSTRING(DigEnvelopeSmall);
|
||||
condition = QUOTE([ARR_2(_this select 0,'ace_trenches_trenchSmall')] call FUNC(canDigTrench));
|
||||
//wait a frame to handle "Do When releasing action menu key" option
|
||||
statement = QUOTE([ARR_2({_this call FUNC(placeTrench)},[ARR_2(_this select 0,'ace_trenches_trenchSmall')])] call EFUNC(common,execNextFrame));
|
||||
exceptions[] = {};
|
||||
showDisabled = 0;
|
||||
priority = 4;
|
||||
//icon = PATHTOF(UI\icon_sandbag_ca.paa);
|
||||
};
|
||||
class GVAR(digEnvelopeBig) {
|
||||
displayName = CSTRING(DigEnvelopeBig);
|
||||
condition = QUOTE([ARR_2(_this select 0,'ace_trenches_trenchBig')] call FUNC(canDigTrench));
|
||||
//wait a frame to handle "Do When releasing action menu key" option
|
||||
statement = QUOTE([ARR_2({_this call FUNC(placeTrench)},[ARR_2(_this select 0,'ace_trenches_trenchBig')])] call EFUNC(common,execNextFrame));
|
||||
exceptions[] = {};
|
||||
showDisabled = 0;
|
||||
priority = 4;
|
||||
//icon = PATHTOF(UI\icon_sandbag_ca.paa);
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
class BagFence_base_F;
|
||||
class ACE_envelope_small: BagFence_base_F {
|
||||
author = ECSTRING(common,ACETeam);
|
||||
displayName = CSTRING(EnvelopeSmallName);
|
||||
descriptionShort = CSTRING(EnevlopeSmallDescription);
|
||||
model = QUOTE(PATHTOEF(apl,ace_envelope_small4.p3d));
|
||||
scope = 2;
|
||||
};
|
||||
class ACE_envelope_big: BagFence_base_F {
|
||||
author = ECSTRING(common,ACETeam);
|
||||
displayName = CSTRING(EnvelopeBigName);
|
||||
descriptionShort = CSTRING(EnevlopeBigDescription);
|
||||
model = QUOTE(PATHTOEF(apl,ace_envelope_big4.p3d));
|
||||
scope = 2;
|
||||
};
|
||||
|
||||
|
||||
class ACE_envelope_small_NoGeo: ACE_envelope_small {
|
||||
scope = 1;
|
||||
//@todo: replace by a no geo model
|
||||
model = QUOTE(PATHTOEF(apl,ace_envelope_small4_nogeo.p3d));
|
||||
};
|
||||
class ACE_envelope_big_NoGeo: ACE_envelope_big {
|
||||
scope = 1;
|
||||
//@todo: replace by a no geo model
|
||||
model = QUOTE(PATHTOEF(apl,ace_envelope_big4_nogeo.p3d));
|
||||
};
|
||||
|
||||
class Box_NATO_Support_F;
|
||||
class ACE_Box_Misc: Box_NATO_Support_F {
|
||||
class TransportItems {
|
||||
MACRO_ADDITEM(ACE_EntrenchingTool,50);
|
||||
};
|
||||
};
|
||||
};
|
16
addons/trenches/CfgWeapons.hpp
Normal file
16
addons/trenches/CfgWeapons.hpp
Normal file
@ -0,0 +1,16 @@
|
||||
class CfgWeapons {
|
||||
class InventoryItem_Base_F;
|
||||
class ACE_ItemCore;
|
||||
|
||||
class ACE_EntrenchingTool: ACE_ItemCore {
|
||||
author = ECSTRING(common,ACETeam);
|
||||
displayName = CSTRING(EntrenchingToolName);
|
||||
descriptionShort = CSTRING(EntrenchingToolDescription);
|
||||
model = QUOTE(PATHTOEF(apl,ace_entrchtool.p3d));
|
||||
picture = QUOTE(PATHTOF(ui\w_entrchtool_ca.paa));
|
||||
scope = 2;
|
||||
class ItemInfo: InventoryItem_Base_F {
|
||||
mass = 10;
|
||||
};
|
||||
};
|
||||
};
|
12
addons/trenches/README.md
Normal file
12
addons/trenches/README.md
Normal file
@ -0,0 +1,12 @@
|
||||
ace_trenches
|
||||
=================
|
||||
|
||||
Adds item 'ACE_entrenchingtool'
|
||||
Adds 2 trenches; Envelope - Small & Envelop - Big
|
||||
|
||||
|
||||
## Maintainers
|
||||
|
||||
The people responsible for merging changes to this component or answering potential questions.
|
||||
|
||||
- [Grey](https://github.com/Grey-Soldierman)
|
BIN
addons/trenches/UI/w_entrchtool_ca.paa
Normal file
BIN
addons/trenches/UI/w_entrchtool_ca.paa
Normal file
Binary file not shown.
28
addons/trenches/XEH_postInit.sqf
Normal file
28
addons/trenches/XEH_postInit.sqf
Normal file
@ -0,0 +1,28 @@
|
||||
#include "script_component.hpp"
|
||||
|
||||
if (isServer) then {
|
||||
// Cancel dig on hard disconnection. Function is identical to killed
|
||||
addMissionEventHandler ["HandleDisconnect", {_this call FUNC(handleKilled)}];
|
||||
};
|
||||
|
||||
if (!hasInterface) exitWith {};
|
||||
|
||||
GVAR(trenchId) = 0;
|
||||
GVAR(trench) = objNull;
|
||||
GVAR(digPFH) = -1;
|
||||
GVAR(digDirection) = 0;
|
||||
|
||||
[{_this call FUNC(handleScrollWheel)}] call EFUNC(common,addScrollWheelEventHandler);
|
||||
|
||||
// Cancel dig sandbag if interact menu opened
|
||||
["interactMenuOpened", {[ACE_player] call FUNC(handleInteractMenuOpened)}] call EFUNC(common,addEventHandler);
|
||||
|
||||
// Cancel dig on player change. This does work when returning to lobby, but not when hard disconnecting.
|
||||
["playerChanged", {_this call FUNC(handlePlayerChanged)}] call EFUNC(common,addEventhandler);
|
||||
["playerInventoryChanged", {_this call FUNC(handlePlayerInventoryChanged)}] call EFUNC(common,addEventhandler);
|
||||
["playerVehicleChanged", {[ACE_player, objNull] call FUNC(handlePlayerChanged)}] call EFUNC(common,addEventhandler);
|
||||
|
||||
// handle waking up dragged unit and falling unconscious while dragging
|
||||
["medical_onUnconscious", {_this call FUNC(handleUnconscious)}] call EFUNC(common,addEventhandler);
|
||||
|
||||
//@todo Captivity?
|
22
addons/trenches/XEH_preInit.sqf
Normal file
22
addons/trenches/XEH_preInit.sqf
Normal file
@ -0,0 +1,22 @@
|
||||
#include "script_component.hpp"
|
||||
|
||||
ADDON = false;
|
||||
|
||||
PREP(canDigTrench);
|
||||
PREP(handleInteractMenuOpened);
|
||||
PREP(handleKilled);
|
||||
PREP(handlePlayerChanged);
|
||||
PREP(handlePlayerInventoryChanged);
|
||||
PREP(handleScrollWheel);
|
||||
PREP(handleUnconscious);
|
||||
PREP(placeCancel);
|
||||
PREP(placeConfirm);
|
||||
PREP(placeTrench);
|
||||
|
||||
// Trench types
|
||||
// Name of the object, name of th dummy no geo object, dx, dy
|
||||
GVAR(trenchSmall) = ["ACE_envelope_small", "ACE_envelope_small_NoGeo", 2, 3, 0.35];
|
||||
GVAR(trenchBig) = ["ACE_envelope_big", "ACE_envelope_big_NoGeo", 6, 1.1, 0.20];
|
||||
GVAR(trenchType) = GVAR(trenchSmall);
|
||||
|
||||
ADDON = true;
|
16
addons/trenches/config.cpp
Normal file
16
addons/trenches/config.cpp
Normal file
@ -0,0 +1,16 @@
|
||||
#include "script_component.hpp"
|
||||
|
||||
class CfgPatches {
|
||||
class ADDON {
|
||||
units[] = {"ACE_envelope_small","ACE_envelope_big"};
|
||||
weapons[] = {"ACE_EntrenchingTool"};
|
||||
requiredVersion = REQUIRED_VERSION;
|
||||
requiredAddons[] = {"ace_interaction"};
|
||||
author[] = {"Grey", "esteldunedain"};
|
||||
authorUrl = "";
|
||||
VERSION_CONFIG;
|
||||
};
|
||||
};
|
||||
#include "CfgEventHandlers.hpp"
|
||||
#include "CfgVehicles.hpp"
|
||||
#include "CfgWeapons.hpp"
|
34
addons/trenches/functions/fnc_canDigTrench.sqf
Normal file
34
addons/trenches/functions/fnc_canDigTrench.sqf
Normal file
@ -0,0 +1,34 @@
|
||||
/*
|
||||
* Author: Ruthberg, commy2, esteldunedain
|
||||
* Checks if a unit can dig a trench
|
||||
*
|
||||
* Arguments:
|
||||
* 0: Unit <OBJECT>
|
||||
* 1: Trench type <STRING>
|
||||
*
|
||||
* Return Value:
|
||||
* Can dig <BOOL>
|
||||
*
|
||||
* Example:
|
||||
* [ACE_player] call ace_trenches_fnc_canDigTrench
|
||||
*
|
||||
* Public: No
|
||||
*/
|
||||
#include "script_component.hpp"
|
||||
|
||||
#define SURFACE_BLACKLIST ["water", "concrete", "tarmac", "wood", "metal", "roof_tin", "roof_tiles", "wood_int", "concrete_int", "tiles_int", "metal_int", "stony", "rock", "int_concrete", "int_tiles", "int_wood", "tiling", "wavymetal", "int_metal"]
|
||||
|
||||
params ["_unit","_trenchTypeName"];
|
||||
|
||||
if !("ACE_EntrenchingTool" in items _unit) exitWith {false};
|
||||
|
||||
// Can't dig trench if above ground level
|
||||
if ((getPosATL _unit) select 2 > 0.05) exitWith {false};
|
||||
|
||||
private ["_surfaceClass", "_surfaceType"];
|
||||
|
||||
_surfaceClass = (surfaceType getPosASL _unit) select [1];
|
||||
_surfaceType = getText (configFile >> "CfgSurfaces" >> _surfaceClass >> "soundEnviron");
|
||||
TRACE_1("",_surfaceType);
|
||||
|
||||
!(_surfaceType in SURFACE_BLACKLIST)
|
19
addons/trenches/functions/fnc_handleInteractMenuOpened.sqf
Normal file
19
addons/trenches/functions/fnc_handleInteractMenuOpened.sqf
Normal file
@ -0,0 +1,19 @@
|
||||
/*
|
||||
* Author: commy2
|
||||
* Handle opening of interaction menu.
|
||||
*
|
||||
* Arguments:
|
||||
* 0: Unit <OBJECT>
|
||||
*
|
||||
* Return Value:
|
||||
* None
|
||||
*
|
||||
* Public: No
|
||||
*/
|
||||
#include "script_component.hpp"
|
||||
|
||||
params ["_unit"];
|
||||
|
||||
if (_unit getVariable [QGVAR(isPlacing), false]) then {
|
||||
[_unit] call FUNC(placeCancel);
|
||||
};
|
19
addons/trenches/functions/fnc_handleKilled.sqf
Normal file
19
addons/trenches/functions/fnc_handleKilled.sqf
Normal file
@ -0,0 +1,19 @@
|
||||
/*
|
||||
* Author: commy2
|
||||
* Handle death.
|
||||
*
|
||||
* Arguments:
|
||||
* 0: Unit <OBJECT>
|
||||
*
|
||||
* Return Value:
|
||||
* None
|
||||
*
|
||||
* Public: No
|
||||
*/
|
||||
#include "script_component.hpp"
|
||||
|
||||
params ["_unit"];
|
||||
|
||||
if (_unit getVariable [QGVAR(isPlacing), false]) then {
|
||||
[_unit] call FUNC(placeCancel);
|
||||
};
|
24
addons/trenches/functions/fnc_handlePlayerChanged.sqf
Normal file
24
addons/trenches/functions/fnc_handlePlayerChanged.sqf
Normal file
@ -0,0 +1,24 @@
|
||||
/*
|
||||
* Author: commy2
|
||||
* Handle player changes.
|
||||
*
|
||||
* Arguments:
|
||||
* 0: New Player Unit <OBJECT>
|
||||
* 1: Old Player Unit <OBJECT>
|
||||
*
|
||||
* Return Value:
|
||||
* None
|
||||
*
|
||||
* Public: No
|
||||
*/
|
||||
#include "script_component.hpp"
|
||||
|
||||
params ["_newPlayer", "_oldPlayer"];
|
||||
|
||||
if (_newPlayer getVariable [QGVAR(isPlacing), false]) then {
|
||||
[_newPlayer] call FUNC(placeCancel);
|
||||
};
|
||||
|
||||
if (_oldPlayer getVariable [QGVAR(isPlacing), false]) then {
|
||||
[_oldPlayer] call FUNC(placeCancel);
|
||||
};
|
@ -0,0 +1,22 @@
|
||||
/*
|
||||
* Author: commy2
|
||||
* Handle the InventoryChanged event.
|
||||
*
|
||||
* Arguments:
|
||||
* 0: Unit <OBJECT>
|
||||
* 1: Weapon <STRING>
|
||||
*
|
||||
* Return Value:
|
||||
* None
|
||||
*
|
||||
* Public: No
|
||||
*/
|
||||
#include "script_component.hpp"
|
||||
|
||||
params ["_unit"];
|
||||
|
||||
if (_unit getVariable [QGVAR(isPlacing), false]) then {
|
||||
if !("ACE_EntrenchingTool" in items _unit) then {
|
||||
[_unit] call FUNC(placeCancel);
|
||||
};
|
||||
};
|
24
addons/trenches/functions/fnc_handleScrollWheel.sqf
Normal file
24
addons/trenches/functions/fnc_handleScrollWheel.sqf
Normal file
@ -0,0 +1,24 @@
|
||||
/*
|
||||
* Author: Garth 'L-H' de Wet, Ruthberg
|
||||
* Handles sandbag rotation
|
||||
*
|
||||
* Arguments:
|
||||
* 0: scroll amount <NUMBER>
|
||||
*
|
||||
* Return Value:
|
||||
* handled <BOOL>
|
||||
*
|
||||
* Example:
|
||||
* [1.2] call ace_sandbag_fnc_handleScrollWheel
|
||||
*
|
||||
* Public: No
|
||||
*/
|
||||
#include "script_component.hpp"
|
||||
|
||||
params ["_scroll"];
|
||||
|
||||
if (GETMVAR(ACE_Modifier,0) == 0 || GVAR(digPFH) == -1) exitWith { false };
|
||||
|
||||
GVAR(digDirection) = GVAR(digDirection) + (_scroll * 5);
|
||||
|
||||
true
|
19
addons/trenches/functions/fnc_handleUnconscious.sqf
Normal file
19
addons/trenches/functions/fnc_handleUnconscious.sqf
Normal file
@ -0,0 +1,19 @@
|
||||
/*
|
||||
* Author: commy2
|
||||
* Handle unconsciousness.
|
||||
*
|
||||
* Arguments:
|
||||
* 0: Unit <OBJECT>
|
||||
*
|
||||
* Return Value:
|
||||
* None
|
||||
*
|
||||
* Public: No
|
||||
*/
|
||||
#include "script_component.hpp"
|
||||
|
||||
params ["_unit"];
|
||||
|
||||
if (_unit getVariable [QGVAR(isPlacing), false]) then {
|
||||
[_unit] call FUNC(placeCancel);
|
||||
};
|
36
addons/trenches/functions/fnc_placeCancel.sqf
Normal file
36
addons/trenches/functions/fnc_placeCancel.sqf
Normal file
@ -0,0 +1,36 @@
|
||||
/*
|
||||
* Author: Garth 'L-H' de Wet, Ruthberg, edited by commy2 for better MP and eventual AI support
|
||||
* Cancels trench dig
|
||||
*
|
||||
* Arguments:
|
||||
* 0: unit <OBJECT>
|
||||
*
|
||||
* Return Value:
|
||||
* None
|
||||
*
|
||||
* Example:
|
||||
* [ACE_player] call ace_sandbag_fnc_placeCancel
|
||||
*
|
||||
* Public: No
|
||||
*/
|
||||
#include "script_component.hpp"
|
||||
|
||||
params ["_unit"];
|
||||
|
||||
// enable running again
|
||||
[_unit, "forceWalk", "ACE_Trenches", false] call EFUNC(common,statusEffect_set);
|
||||
|
||||
// delete placement dummy
|
||||
deleteVehicle GVAR(trench);
|
||||
|
||||
// remove digment pfh
|
||||
[GVAR(digPFH)] call CBA_fnc_removePerFrameHandler;
|
||||
GVAR(digPFH) = -1;
|
||||
|
||||
// remove mouse button actions
|
||||
call EFUNC(interaction,hideMouseHint);
|
||||
|
||||
[_unit, "DefaultAction", _unit getVariable [QGVAR(Dig), -1]] call EFUNC(common,removeActionEventHandler);
|
||||
[_unit, "zoomtemp", _unit getVariable [QGVAR(Cancel), -1]] call EFUNC(common,removeActionEventHandler);
|
||||
|
||||
_unit setVariable [QGVAR(isPlacing), false, true];
|
115
addons/trenches/functions/fnc_placeConfirm.sqf
Normal file
115
addons/trenches/functions/fnc_placeConfirm.sqf
Normal file
@ -0,0 +1,115 @@
|
||||
/*
|
||||
* Author: Garth 'L-H' de Wet, Ruthberg, edited by commy2 for better MP and eventual AI support and esteldunedain
|
||||
* Confirms trench dig
|
||||
*
|
||||
* Arguments:
|
||||
* 0: unit <OBJECT>
|
||||
*
|
||||
* Return Value:
|
||||
* None
|
||||
*
|
||||
* Example:
|
||||
* [ACE_player] call ace_trenches_fnc_placeConfirm
|
||||
*
|
||||
* Public: No
|
||||
*/
|
||||
#include "script_component.hpp"
|
||||
|
||||
params ["_unit"];
|
||||
|
||||
// enable running again
|
||||
[_unit, "forceWalk", "ACE_Trenches", false] call EFUNC(common,statusEffect_set);
|
||||
|
||||
// remove dig pfh
|
||||
[GVAR(digPFH)] call CBA_fnc_removePerFrameHandler;
|
||||
GVAR(digPFH) = -1;
|
||||
|
||||
// remove mouse button actions
|
||||
call EFUNC(interaction,hideMouseHint);
|
||||
|
||||
[_unit, "DefaultAction", _unit getVariable [QGVAR(Dig), -1]] call EFUNC(common,removeActionEventHandler);
|
||||
[_unit, "zoomtemp", _unit getVariable [QGVAR(Cancel), -1]] call EFUNC(common,removeActionEventHandler);
|
||||
|
||||
_unit setVariable [QGVAR(isPlacing), false, true];
|
||||
|
||||
// Delete placement dummy and create real trench
|
||||
params ["_unit"];
|
||||
if (isNull GVAR(trench)) exitWith {};
|
||||
|
||||
deleteVehicle GVAR(trench);
|
||||
private _trench = createVehicle [GVAR(trenchType) select 0, [0, 0, 0], [], 0, "NONE"];
|
||||
|
||||
GVAR(trenchType) params ["", "", "_dx", "_dy", "_offset"];
|
||||
private _basePos = GVAR(trenchPos);
|
||||
private _angle = (GVAR(digDirection) + getDir _unit);
|
||||
|
||||
// _v1 forward from the player, _v2 to the right, _v3 points away from the ground
|
||||
private _v3 = surfaceNormal _basePos;
|
||||
private _v2 = [sin _angle, +cos _angle, 0] vectorCrossProduct _v3;
|
||||
private _v1 = _v3 vectorCrossProduct _v2;
|
||||
|
||||
// Stick the trench to the ground
|
||||
_basePos set [2, getTerrainHeightASL _basePos];
|
||||
private _minzoffset = 0;
|
||||
private ["_ix","_iy"];
|
||||
for [{_ix = -_dx/2},{_ix <= _dx/2},{_ix = _ix + _dx/3}] do {
|
||||
for [{_iy = -_dy/2},{_iy <= _dy/2},{_iy = _iy + _dy/3}] do {
|
||||
private _pos = _basePos vectorAdd (_v2 vectorMultiply _ix)
|
||||
vectorAdd (_v1 vectorMultiply _iy);
|
||||
_minzoffset = _minzoffset min ((getTerrainHeightASL _pos) - (_pos select 2));
|
||||
#ifdef DEBUG_MODE_FULL
|
||||
_pos set [2, getTerrainHeightASL _pos];
|
||||
_pos2 = +_pos;
|
||||
_pos2 set [2, getTerrainHeightASL _pos + 1];
|
||||
drawLine3D [ASLtoAGL _pos, ASLtoAGL _pos2, [1,1,0,1]];
|
||||
#endif
|
||||
};
|
||||
};
|
||||
_basePos set [2, (_basePos select 2) + _minzoffset + _offset];
|
||||
private _vecDirAndUp = [_v1, _v3];
|
||||
|
||||
GVAR(trench) = objNull;
|
||||
|
||||
// Mark the unit as digging
|
||||
private _trenchId = GVAR(trenchId);
|
||||
_unit setVariable [QGVAR(isDiggingId), _trenchId, true];
|
||||
GVAR(trenchId) = GVAR(trenchId) + 1;
|
||||
|
||||
// Create progress bar
|
||||
private _fnc_onFinish = {
|
||||
(_this select 0) params ["_unit"];
|
||||
_unit setVariable [QGVAR(isDiggingId), -1, true];
|
||||
};
|
||||
private _fnc_onFailure = {
|
||||
(_this select 0) params ["_unit"];
|
||||
_unit setVariable [QGVAR(isDiggingId), -1, true];
|
||||
};
|
||||
[12.5, [_unit], _fnc_onFinish, _fnc_onFailure, localize LSTRING(DiggingTrench)] call EFUNC(common,progressBar);
|
||||
|
||||
// Schedule progressive raising of the trench
|
||||
private _fnc_setPlacing = {
|
||||
params ["_unit", "_trench", "_trenchId", "_pos", "_vecDirAndUp"];
|
||||
|
||||
// If the progress bar was cancelled, cancel elevation
|
||||
// We use an uid to avoid any chance of an older trench being raised when a new one is built
|
||||
if (_unit getVariable [QGVAR(isDiggingId), -1] != _trenchId) exitWith {};
|
||||
|
||||
_trench setPosASL _pos;
|
||||
_trench setVectorDirAndUp _vecDirAndUp;
|
||||
};
|
||||
|
||||
// For loops are for wimps
|
||||
[_unit, _trench, _trenchId, _basePos vectorDiff [0, 0, 1.0], _vecDirAndUp] call _fnc_setPlacing;
|
||||
[_fnc_setPlacing, [_unit, _trench, _trenchId, _basePos vectorDiff [0, 0, 0.9], _vecDirAndUp], 3.0] call EFUNC(common,waitAndExecute);
|
||||
[_fnc_setPlacing, [_unit, _trench, _trenchId, _basePos vectorDiff [0, 0, 0.8], _vecDirAndUp], 4.0] call EFUNC(common,waitAndExecute);
|
||||
[_fnc_setPlacing, [_unit, _trench, _trenchId, _basePos vectorDiff [0, 0, 0.7], _vecDirAndUp], 5.0] call EFUNC(common,waitAndExecute);
|
||||
[_fnc_setPlacing, [_unit, _trench, _trenchId, _basePos vectorDiff [0, 0, 0.6], _vecDirAndUp], 6.0] call EFUNC(common,waitAndExecute);
|
||||
[_fnc_setPlacing, [_unit, _trench, _trenchId, _basePos vectorDiff [0, 0, 0.5], _vecDirAndUp], 7.0] call EFUNC(common,waitAndExecute);
|
||||
[_fnc_setPlacing, [_unit, _trench, _trenchId, _basePos vectorDiff [0, 0, 0.4], _vecDirAndUp], 8.0] call EFUNC(common,waitAndExecute);
|
||||
[_fnc_setPlacing, [_unit, _trench, _trenchId, _basePos vectorDiff [0, 0, 0.3], _vecDirAndUp], 9.0] call EFUNC(common,waitAndExecute);
|
||||
[_fnc_setPlacing, [_unit, _trench, _trenchId, _basePos vectorDiff [0, 0, 0.2], _vecDirAndUp],10.0] call EFUNC(common,waitAndExecute);
|
||||
[_fnc_setPlacing, [_unit, _trench, _trenchId, _basePos vectorDiff [0, 0, 0.1], _vecDirAndUp],11.0] call EFUNC(common,waitAndExecute);
|
||||
[_fnc_setPlacing, [_unit, _trench, _trenchId, _basePos vectorDiff [0, 0, 0.0], _vecDirAndUp],12.0] call EFUNC(common,waitAndExecute);
|
||||
|
||||
// Play animation
|
||||
[_unit, "AinvPknlMstpSnonWnonDnon_medic4"] call EFUNC(common,doAnimation);
|
104
addons/trenches/functions/fnc_placeTrench.sqf
Normal file
104
addons/trenches/functions/fnc_placeTrench.sqf
Normal file
@ -0,0 +1,104 @@
|
||||
/*
|
||||
* Author: Garth 'L-H' de Wet, Ruthberg, edited by commy2 for better MP and eventual AI support, esteldunedain
|
||||
* Starts the place process for trench.
|
||||
*
|
||||
* Arguments:
|
||||
* 0: unit <OBJECT>
|
||||
* 1: Trench type <STRING>
|
||||
*
|
||||
* Return Value:
|
||||
* None
|
||||
*
|
||||
* Example:
|
||||
* [ACE_player] call ace_trenches_fnc_placeTrench
|
||||
*
|
||||
* Public: No
|
||||
*/
|
||||
#include "script_component.hpp"
|
||||
|
||||
params ["_unit","_trenchTypeName"];
|
||||
|
||||
GVAR(trenchType) = missionNamespace getVariable _trenchTypeName;
|
||||
|
||||
TRACE_2("",_trenchTypeName,GVAR(trenchType));
|
||||
// prevent the placing unit from running
|
||||
[_unit, "forceWalk", "ACE_Trenches", true] call EFUNC(common,statusEffect_set);
|
||||
|
||||
// create the trench
|
||||
private "_trench";
|
||||
_trench = createVehicle [GVAR(trenchType) select 1, [0, 0, 0], [], 0, "NONE"];
|
||||
|
||||
GVAR(trench) = _trench;
|
||||
|
||||
// prevent collisions with trench
|
||||
["enableSimulationGlobal", [_trench, false]] call EFUNC(common,serverEvent);
|
||||
|
||||
GVAR(digDirection) = 0;
|
||||
|
||||
// pfh that runs while the dig is in progress
|
||||
GVAR(digPFH) = [{
|
||||
(_this select 0) params ["_unit", "_trench"];
|
||||
GVAR(trenchType) params ["", "", "_dx", "_dy", "_offset"];
|
||||
|
||||
// Cancel if the helper object is gone
|
||||
if (isNull _trench) exitWith {
|
||||
[_unit] call FUNC(placeCancel);
|
||||
};
|
||||
|
||||
// Cancel if the place is no longer suitable
|
||||
if !([_unit, GVAR(trenchType)] call FUNC(canDigTrench)) exitWith {
|
||||
[_unit] call FUNC(placeCancel);
|
||||
};
|
||||
|
||||
// Update trench position
|
||||
GVAR(trenchType) params ["", "", "_dx", "_dy", "_offset"];
|
||||
private _basePos = eyePos _unit vectorAdd ([sin getDir _unit, +cos getDir _unit, 0] vectorMultiply 1.0);
|
||||
|
||||
private _angle = (GVAR(digDirection) + getDir _unit);
|
||||
|
||||
// _v1 forward from the player, _v2 to the right, _v3 points away from the ground
|
||||
private _v3 = surfaceNormal _basePos;
|
||||
private _v2 = [sin _angle, +cos _angle, 0] vectorCrossProduct _v3;
|
||||
private _v1 = _v3 vectorCrossProduct _v2;
|
||||
|
||||
// Stick the trench to the ground
|
||||
_basePos set [2, getTerrainHeightASL _basePos];
|
||||
private _minzoffset = 0;
|
||||
private ["_ix","_iy"];
|
||||
for [{_ix = -_dx/2},{_ix <= _dx/2},{_ix = _ix + _dx/3}] do {
|
||||
for [{_iy = -_dy/2},{_iy <= _dy/2},{_iy = _iy + _dy/3}] do {
|
||||
private _pos = _basePos vectorAdd (_v2 vectorMultiply _ix)
|
||||
vectorAdd (_v1 vectorMultiply _iy);
|
||||
_minzoffset = _minzoffset min ((getTerrainHeightASL _pos) - (_pos select 2));
|
||||
#ifdef DEBUG_MODE_FULL
|
||||
_pos set [2, getTerrainHeightASL _pos];
|
||||
_pos2 = +_pos;
|
||||
_pos2 set [2, getTerrainHeightASL _pos + 1];
|
||||
drawLine3D [ASLtoAGL _pos, ASLtoAGL _pos2, [1,1,0,1]];
|
||||
#endif
|
||||
};
|
||||
};
|
||||
_basePos set [2, (_basePos select 2) + _minzoffset + _offset];
|
||||
TRACE_2("",_minzoffset,_offset);
|
||||
_trench setPosASL _basePos;
|
||||
_trench setVectorDirAndUp [_v1, _v3];
|
||||
GVAR(trenchPos) = _basePos;
|
||||
|
||||
}, 0, [_unit, _trench]] call CBA_fnc_addPerFrameHandler;
|
||||
|
||||
// add mouse button action and hint
|
||||
[localize LSTRING(ConfirmDig), localize LSTRING(CancelDig), localize LSTRING(ScrollAction)] call EFUNC(interaction,showMouseHint);
|
||||
|
||||
_unit setVariable [QGVAR(Dig), [
|
||||
_unit, "DefaultAction",
|
||||
{GVAR(digPFH) != -1},
|
||||
{[_this select 0] call FUNC(placeConfirm)}
|
||||
] call EFUNC(common,addActionEventHandler)];
|
||||
|
||||
_unit setVariable [QGVAR(Cancel), [
|
||||
_unit, "zoomtemp",
|
||||
{GVAR(digPFH) != -1},
|
||||
{[_this select 0] call FUNC(placeCancel)}
|
||||
] call EFUNC(common,addActionEventHandler)];
|
||||
|
||||
_unit setVariable [QGVAR(isPlacing), true, true];
|
1
addons/trenches/functions/script_component.hpp
Normal file
1
addons/trenches/functions/script_component.hpp
Normal file
@ -0,0 +1 @@
|
||||
#include "\z\ace\addons\trenches\script_component.hpp"
|
12
addons/trenches/script_component.hpp
Normal file
12
addons/trenches/script_component.hpp
Normal file
@ -0,0 +1,12 @@
|
||||
#define COMPONENT trenches
|
||||
#include "\z\ace\addons\main\script_mod.hpp"
|
||||
|
||||
#ifdef DEBUG_ENABLED_TRENCHES
|
||||
#define DEBUG_MODE_FULL
|
||||
#endif
|
||||
|
||||
#ifdef DEBUG_SETTINGS_TRENCHES
|
||||
#define DEBUG_SETTINGS DEBUG_SETTINGS_TRENCHES
|
||||
#endif
|
||||
|
||||
#include "\z\ace\addons\main\script_macros.hpp"
|
43
addons/trenches/stringtable.xml
Normal file
43
addons/trenches/stringtable.xml
Normal file
@ -0,0 +1,43 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project name="ACE">
|
||||
<Package name="trenches">
|
||||
<Key ID="STR_ACE_Trenches_EntrenchingToolName">
|
||||
<English>Entrenching Tool</English>
|
||||
<Polish>Saperka</Polish>
|
||||
</Key>
|
||||
<Key ID="STR_ACE_Trenches_EntrenchingToolDescription">
|
||||
<English>Entrenching Tool</English>
|
||||
<Polish>Saperka, używana do budowy okopów</Polish>
|
||||
</Key>
|
||||
<Key ID="STR_ACE_Trenches_EnvelopeSmallName">
|
||||
<English>Envelope - Small</English>
|
||||
</Key>
|
||||
<Key ID="STR_ACE_Trenches_EnevlopeSmallDescription">
|
||||
<English>Small Personal Trench</English>
|
||||
</Key>
|
||||
<Key ID="STR_ACE_Trenches_DigEnvelopeSmall">
|
||||
<English>Dig Small Trench</English>
|
||||
</Key>
|
||||
<Key ID="STR_ACE_Trenches_EnvelopeBigName">
|
||||
<English>Envelope - Big</English>
|
||||
</Key>
|
||||
<Key ID="STR_ACE_Trenches_EnevlopeBigDescription">
|
||||
<English>Large Personal Trench</English>
|
||||
</Key>
|
||||
<Key ID="STR_ACE_Trenches_DigEnvelopeBig">
|
||||
<English>Dig Big Trench</English>
|
||||
</Key>
|
||||
<Key ID="STR_ACE_Trenches_ConfirmDig">
|
||||
<English>Confirm Dig</English>
|
||||
</Key>
|
||||
<Key ID="STR_ACE_Trenches_CancelDig">
|
||||
<English>Cancel Dig</English>
|
||||
</Key>
|
||||
<Key ID="STR_ACE_Trenches_ScrollAction">
|
||||
<English>+Ctrl rotate</English>
|
||||
</Key>
|
||||
<Key ID="STR_ACE_Trenches_DiggingTrench">
|
||||
<English>Digging Trench</English>
|
||||
</Key>
|
||||
</Package>
|
||||
</Project>
|
Loading…
Reference in New Issue
Block a user