Add fast mouse actions to refuel, add refuel eden attributes (#5418)

* Add fast mouse actions to refuel

* nobody seen that

* Add interaction condition and refuel on ladder

* Add car hit, fix change weapon on uncon

* Replace objNull with nil in setVar, unify var names

* Delete *ConnectNozzle functions

* Delete reset* functions

* Add public function and eden attributes

* Remove static actions from RHS compat

* Remove statusEffect_set on respawn

* Fix dual menu, add deprecating message

* Optimize fnc_takeNozzle

* Cleanup
This commit is contained in:
Dystopian 2017-09-10 21:43:03 +02:00 committed by PabstMirror
parent 635b667a74
commit 559a498e6d
47 changed files with 623 additions and 833 deletions

View File

@ -117,7 +117,7 @@ private _actions = [
// Dummy statement so it's not collapsed when there's no available actions // Dummy statement so it's not collapsed when there's no available actions
true true
}, },
{[ACE_player, _target, ["isNotInside","isNotDragging", "isNotCarrying", "isNotSwimming", "notOnMap", "isNotEscorting", "isNotSurrendering", "isNotSitting", "isNotOnLadder"]] call EFUNC(common,canInteractWith)}, {[ACE_player, _target, ["isNotInside","isNotDragging", "isNotCarrying", "isNotSwimming", "notOnMap", "isNotEscorting", "isNotSurrendering", "isNotSitting", "isNotOnLadder", "isNotRefueling"]] call EFUNC(common,canInteractWith)},
{}, {},
{}, {},
"Spine3", "Spine3",

View File

@ -21,7 +21,7 @@ if (GVAR(openedMenuType) == _menuType) exitWith {true};
// Conditions: canInteract (these don't apply to zeus) // Conditions: canInteract (these don't apply to zeus)
if ((isNull curatorCamera) && { if ((isNull curatorCamera) && {
!([ACE_player, objNull, ["isNotInside","isNotDragging", "isNotCarrying", "isNotSwimming", "notOnMap", "isNotEscorting", "isNotSurrendering", "isNotSitting", "isNotOnLadder"]] call EFUNC(common,canInteractWith)) !([ACE_player, objNull, ["isNotInside","isNotDragging", "isNotCarrying", "isNotSwimming", "notOnMap", "isNotEscorting", "isNotSurrendering", "isNotSitting", "isNotOnLadder", "isNotRefueling"]] call EFUNC(common,canInteractWith))
}) exitWith {false}; }) exitWith {false};
while {dialog} do { while {dialog} do {

View File

@ -248,7 +248,7 @@ class CfgVehicles {
class ACE_TeamManagement { class ACE_TeamManagement {
displayName = CSTRING(TeamManagement); displayName = CSTRING(TeamManagement);
condition = QUOTE(GVAR(EnableTeamManagement)); condition = QUOTE(GVAR(EnableTeamManagement));
exceptions[] = {"isNotSwimming", "isNotInside", "isNotSitting", "isNotOnLadder"}; exceptions[] = {"isNotSwimming", "isNotInside", "isNotSitting", "isNotOnLadder", "isNotRefueling"};
statement = ""; statement = "";
showDisabled = 1; showDisabled = 1;
priority = 3.2; priority = 3.2;
@ -257,7 +257,7 @@ class CfgVehicles {
class ACE_JoinTeamRed { class ACE_JoinTeamRed {
displayName = CSTRING(JoinTeamRed); displayName = CSTRING(JoinTeamRed);
condition = QUOTE(true); condition = QUOTE(true);
exceptions[] = {"isNotSwimming", "isNotInside", "isNotSitting", "isNotOnLadder"}; exceptions[] = {"isNotSwimming", "isNotInside", "isNotSitting", "isNotOnLadder", "isNotRefueling"};
statement = QUOTE([ARR_2(_player,'RED')] call DFUNC(joinTeam)); statement = QUOTE([ARR_2(_player,'RED')] call DFUNC(joinTeam));
showDisabled = 1; showDisabled = 1;
priority = 2.4; priority = 2.4;
@ -266,7 +266,7 @@ class CfgVehicles {
class ACE_JoinTeamGreen { class ACE_JoinTeamGreen {
displayName = CSTRING(JoinTeamGreen); displayName = CSTRING(JoinTeamGreen);
condition = QUOTE(true); condition = QUOTE(true);
exceptions[] = {"isNotSwimming", "isNotInside", "isNotSitting", "isNotOnLadder"}; exceptions[] = {"isNotSwimming", "isNotInside", "isNotSitting", "isNotOnLadder", "isNotRefueling"};
statement = QUOTE([ARR_2(_player,'GREEN')] call DFUNC(joinTeam)); statement = QUOTE([ARR_2(_player,'GREEN')] call DFUNC(joinTeam));
showDisabled = 1; showDisabled = 1;
priority = 2.3; priority = 2.3;
@ -275,7 +275,7 @@ class CfgVehicles {
class ACE_JoinTeamBlue { class ACE_JoinTeamBlue {
displayName = CSTRING(JoinTeamBlue); displayName = CSTRING(JoinTeamBlue);
condition = QUOTE(true); condition = QUOTE(true);
exceptions[] = {"isNotSwimming", "isNotInside", "isNotSitting", "isNotOnLadder"}; exceptions[] = {"isNotSwimming", "isNotInside", "isNotSitting", "isNotOnLadder", "isNotRefueling"};
statement = QUOTE([ARR_2(_player,'BLUE')] call DFUNC(joinTeam)); statement = QUOTE([ARR_2(_player,'BLUE')] call DFUNC(joinTeam));
showDisabled = 1; showDisabled = 1;
priority = 2.2; priority = 2.2;
@ -284,7 +284,7 @@ class CfgVehicles {
class ACE_JoinTeamYellow { class ACE_JoinTeamYellow {
displayName = CSTRING(JoinTeamYellow); displayName = CSTRING(JoinTeamYellow);
condition = QUOTE(true); condition = QUOTE(true);
exceptions[] = {"isNotSwimming", "isNotInside", "isNotSitting", "isNotOnLadder"}; exceptions[] = {"isNotSwimming", "isNotInside", "isNotSitting", "isNotOnLadder", "isNotRefueling"};
statement = QUOTE([ARR_2(_player,'YELLOW')] call DFUNC(joinTeam)); statement = QUOTE([ARR_2(_player,'YELLOW')] call DFUNC(joinTeam));
showDisabled = 1; showDisabled = 1;
priority = 2.1; priority = 2.1;
@ -293,7 +293,7 @@ class CfgVehicles {
class ACE_LeaveTeam { class ACE_LeaveTeam {
displayName = CSTRING(LeaveTeam); displayName = CSTRING(LeaveTeam);
condition = QUOTE(assignedTeam _player != 'MAIN'); condition = QUOTE(assignedTeam _player != 'MAIN');
exceptions[] = {"isNotSwimming", "isNotInside", "isNotSitting", "isNotOnLadder"}; exceptions[] = {"isNotSwimming", "isNotInside", "isNotSitting", "isNotOnLadder", "isNotRefueling"};
statement = QUOTE([ARR_2(_player,'MAIN')] call DFUNC(joinTeam)); statement = QUOTE([ARR_2(_player,'MAIN')] call DFUNC(joinTeam));
showDisabled = 1; showDisabled = 1;
priority = 2.5; priority = 2.5;
@ -302,7 +302,7 @@ class CfgVehicles {
class ACE_BecomeLeader { class ACE_BecomeLeader {
displayName = CSTRING(BecomeLeader); displayName = CSTRING(BecomeLeader);
condition = QUOTE(_this call DFUNC(canBecomeLeader)); condition = QUOTE(_this call DFUNC(canBecomeLeader));
exceptions[] = {"isNotSwimming", "isNotInside", "isNotSitting", "isNotOnLadder"}; exceptions[] = {"isNotSwimming", "isNotInside", "isNotSitting", "isNotOnLadder", "isNotRefueling"};
statement = QUOTE(_this call DFUNC(doBecomeLeader)); statement = QUOTE(_this call DFUNC(doBecomeLeader));
showDisabled = 1; showDisabled = 1;
priority = 1.0; priority = 1.0;
@ -311,7 +311,7 @@ class CfgVehicles {
class ACE_LeaveGroup { class ACE_LeaveGroup {
displayName = CSTRING(LeaveGroup); displayName = CSTRING(LeaveGroup);
condition = QUOTE(count (units group _player) > 1); condition = QUOTE(count (units group _player) > 1);
exceptions[] = {"isNotSwimming", "isNotInside", "isNotSitting", "isNotOnLadder"}; exceptions[] = {"isNotSwimming", "isNotInside", "isNotSitting", "isNotOnLadder", "isNotRefueling"};
statement = QUOTE(_oldGroup = units group _player; _newGroup = createGroup side _player; [_player] joinSilent _newGroup; {_player reveal _x} forEach _oldGroup;); statement = QUOTE(_oldGroup = units group _player; _newGroup = createGroup side _player; [_player] joinSilent _newGroup; {_player reveal _x} forEach _oldGroup;);
showDisabled = 1; showDisabled = 1;
priority = 1.2; priority = 1.2;

View File

@ -40,7 +40,7 @@ GVAR(ppEffectMuzzleFlash) ppEffectCommit 0;
// Add keybinds // Add keybinds
["ACE3 Equipment", QGVAR(IncreaseNVGBrightness), localize LSTRING(IncreaseNVGBrightness), { ["ACE3 Equipment", QGVAR(IncreaseNVGBrightness), localize LSTRING(IncreaseNVGBrightness), {
// Conditions: canInteract // Conditions: canInteract
if !([ACE_player, objNull, ["isNotEscorting", "isNotInside", "isNotSitting"]] call EFUNC(common,canInteractWith)) exitWith {false}; if !([ACE_player, objNull, ["isNotEscorting", "isNotInside", "isNotSitting", "isNotRefueling"]] call EFUNC(common,canInteractWith)) exitWith {false};
// Conditions: specific // Conditions: specific
if ((currentVisionMode ACE_player != 1)) exitWith {false}; if ((currentVisionMode ACE_player != 1)) exitWith {false};
@ -51,7 +51,7 @@ GVAR(ppEffectMuzzleFlash) ppEffectCommit 0;
["ACE3 Equipment", QGVAR(DecreaseNVGBrightness), localize LSTRING(DecreaseNVGBrightness), { ["ACE3 Equipment", QGVAR(DecreaseNVGBrightness), localize LSTRING(DecreaseNVGBrightness), {
// Conditions: canInteract // Conditions: canInteract
if !([ACE_player, objNull, ["isNotEscorting", "isNotInside", "isNotSitting"]] call EFUNC(common,canInteractWith)) exitWith {false}; if !([ACE_player, objNull, ["isNotEscorting", "isNotInside", "isNotSitting", "isNotRefueling"]] call EFUNC(common,canInteractWith)) exitWith {false};
// Conditions: specific // Conditions: specific
if ((currentVisionMode ACE_player != 1)) exitWith {false}; if ((currentVisionMode ACE_player != 1)) exitWith {false};

36
addons/refuel/Cfg3DEN.hpp Normal file
View File

@ -0,0 +1,36 @@
#define GET_NUMBER(config,default) (if (isNumber (config)) then {getNumber (config)} else {default})
#define GET_1ST_ARRAY(config) (if (isArray (config)) then {getArray (config) select 0} else {[ARR_3(0,0,0)]})
#define DEFAULT_FUELCARGO GET_NUMBER(configFile >> 'CfgVehicles' >> typeOf _this >> QQGVAR(fuelCargo),REFUEL_DISABLED_FUEL)
#define DEFAULT_HOOKS GET_1ST_ARRAY(configFile >> 'CfgVehicles' >> typeOf _this >> QQGVAR(hooks))
class Cfg3DEN {
class Object {
class AttributeCategories {
class ace_attributes {
class Attributes {
class GVAR(fuelCargo) {
displayName = CSTRING(fuelCargo_edenName);
tooltip = CSTRING(fuelCargo_edenDesc);
property = QGVAR(fuelCargo);
control = "EditShort";
expression = QUOTE(if (_value != DEFAULT_FUELCARGO) then {[ARR_2(_this,_value)] call DFUNC(makeSource)});
defaultValue = QUOTE(DEFAULT_FUELCARGO);
validate = "number";
condition = "(1-objectBrain)*(1-objectAgent)";
typeName = "NUMBER";
};
class GVAR(hooks) {
displayName = CSTRING(hooks_edenName);
tooltip = CSTRING(hooks_edenDesc);
property = QGVAR(hooks);
control = "EditXYZ";
expression = QUOTE(if !(_value isEqualTo DEFAULT_HOOKS) then {_this setVariable [ARR_3('%s',[_value],true)]});
defaultValue = QUOTE(DEFAULT_HOOKS);
condition = "(1-objectBrain)*(1-objectAgent)";
};
};
};
};
};
};

View File

@ -19,15 +19,7 @@ class Extended_PostInit_EventHandlers {
class Extended_Respawn_EventHandlers { class Extended_Respawn_EventHandlers {
class CAManBase { class CAManBase {
class ADDON { class ADDON {
respawn = QUOTE(call COMPILE_FILE(XEH_respawn)); respawn = QUOTE(call DFUNC(handleRespawn));
};
};
};
class Extended_Killed_EventHandlers {
class CAManBase {
class ADDON {
killed = QUOTE(_this call FUNC(handleKilled));
}; };
}; };
}; };
@ -35,7 +27,7 @@ class Extended_Killed_EventHandlers {
class Extended_InitPost_EventHandlers { class Extended_InitPost_EventHandlers {
class Land_CanisterFuel_F { class Land_CanisterFuel_F {
class ADDON { class ADDON {
init = QUOTE(_this call DFUNC(makeJerryCan)); init = QUOTE(call DFUNC(makeJerryCan));
}; };
}; };
}; };

View File

@ -1,61 +1,3 @@
#define MACRO_REFUEL_ACTIONS \
class ACE_Actions: ACE_Actions { \
class ACE_MainActions: ACE_MainActions { \
class GVAR(Refuel) { \
displayName = CSTRING(Refuel); \
distance = REFUEL_ACTION_DISTANCE; \
condition = "alive _target"; \
statement = ""; \
showDisabled = 0; \
priority = 2; \
icon = QPATHTOF(ui\icon_refuel_interact.paa); \
class GVAR(TakeNozzle) { \
displayName = CSTRING(TakeNozzle); \
condition = QUOTE([ARR_2(_player,_target)] call FUNC(canTakeNozzle)); \
statement = QUOTE([ARR_3(_player,_target,objNull)] call FUNC(TakeNozzle)); \
exceptions[] = {"isNotInside"}; \
icon = QPATHTOF(ui\icon_refuel_interact.paa); \
}; \
class GVAR(CheckFuelCounter) { \
displayName = CSTRING(CheckFuelCounter); \
condition = "true"; \
statement = QUOTE([ARR_2(_player,_target)] call FUNC(readFuelCounter)); \
exceptions[] = {"isNotInside"}; \
icon = QPATHTOF(ui\icon_refuel_interact.paa); \
}; \
class GVAR(CheckFuel) { \
displayName = CSTRING(CheckFuel); \
condition = QUOTE([ARR_2(_player,_target)] call FUNC(canCheckFuel)); \
statement = QUOTE([ARR_2(_player,_target)] call FUNC(checkFuel)); \
exceptions[] = {"isNotInside"}; \
icon = QPATHTOF(ui\icon_refuel_interact.paa); \
}; \
class GVAR(Return) { \
displayName = CSTRING(Return); \
condition = QUOTE([ARR_2(_player,_target)] call FUNC(canReturnNozzle)); \
statement = QUOTE([ARR_2(_player,_target)] call DFUNC(returnNozzle)); \
exceptions[] = {"isNotInside"}; \
icon = QPATHTOF(ui\icon_refuel_interact.paa); \
}; \
}; \
}; \
};
#define MACRO_CONNECT_ACTIONS \
class ACE_Actions { \
class ACE_MainActions { \
class GVAR(Connect) { \
displayName = CSTRING(Connect); \
distance = REFUEL_ACTION_DISTANCE; \
condition = QUOTE([ARR_2(_player,_target)] call FUNC(canConnectNozzle)); \
statement = QUOTE([ARR_2(_player,_target)] call DFUNC(connectNozzle)); \
icon = QPATHTOF(ui\icon_refuel_interact.paa); \
exceptions[] = {"isNotInside"}; \
}; \
}; \
};
#define MACRO_NOZZLE_ACTIONS \ #define MACRO_NOZZLE_ACTIONS \
class ACE_Actions { \ class ACE_Actions { \
class ACE_MainActions { \ class ACE_MainActions { \
@ -64,35 +6,36 @@
position = "[0,-0.025,0.125]"; \ position = "[0,-0.025,0.125]"; \
condition = "true"; \ condition = "true"; \
statement = ""; \ statement = ""; \
exceptions[] = {INTERACT_EXCEPTIONS}; \
showDisabled = 0; \ showDisabled = 0; \
priority = 2; \ priority = 2; \
icon = QPATHTOF(ui\icon_refuel_interact.paa); \ icon = QPATHTOF(ui\icon_refuel_interact.paa); \
class GVAR(PickUpNozzle) { \ class GVAR(PickUpNozzle) { \
displayName = CSTRING(TakeNozzle); \ displayName = CSTRING(TakeNozzle); \
condition = QUOTE([ARR_2(_player,_target)] call FUNC(canTakeNozzle)); \ condition = QUOTE([ARR_2(_player,_target)] call FUNC(canTakeNozzle)); \
statement = QUOTE([ARR_3(_player,objNull,_target)] call FUNC(takeNozzle)); \ statement = QUOTE([ARR_2(_player,_target)] call FUNC(takeNozzle)); \
exceptions[] = {"isNotInside"}; \ exceptions[] = {"isNotInside", "isNotOnLadder"}; \
icon = QPATHTOF(ui\icon_refuel_interact.paa); \ icon = QPATHTOF(ui\icon_refuel_interact.paa); \
}; \ }; \
class GVAR(TurnOn) { \ class GVAR(TurnOn) { \
displayName = CSTRING(TurnOn); \ displayName = CSTRING(TurnOn); \
condition = QUOTE([ARR_2(_player,_target)] call FUNC(canTurnOn)); \ condition = QUOTE([ARR_2(_player,_target)] call FUNC(canTurnOn)); \
statement = QUOTE([ARR_2(_player,_target)] call DFUNC(turnOn)); \ statement = QUOTE([ARR_2(_player,_target)] call DFUNC(turnOn)); \
exceptions[] = {"isNotInside"}; \ exceptions[] = {INTERACT_EXCEPTIONS}; \
icon = QPATHTOF(ui\icon_refuel_interact.paa); \ icon = QPATHTOF(ui\icon_refuel_interact.paa); \
}; \ }; \
class GVAR(TurnOff) { \ class GVAR(TurnOff) { \
displayName = CSTRING(TurnOff); \ displayName = CSTRING(TurnOff); \
condition = QUOTE([ARR_2(_player,_target)] call FUNC(canTurnOff)); \ condition = QUOTE([ARR_2(_player,_target)] call FUNC(canTurnOff)); \
statement = QUOTE([ARR_2(_player,_target)] call DFUNC(turnOff)); \ statement = QUOTE([ARR_2(_player,_target)] call DFUNC(turnOff)); \
exceptions[] = {"isNotInside"}; \ exceptions[] = {INTERACT_EXCEPTIONS}; \
icon = QPATHTOF(ui\icon_refuel_interact.paa); \ icon = QPATHTOF(ui\icon_refuel_interact.paa); \
}; \ }; \
class GVAR(Disconnect) { \ class GVAR(Disconnect) { \
displayName = CSTRING(Disconnect); \ displayName = CSTRING(Disconnect); \
condition = QUOTE([ARR_2(_player,_target)] call FUNC(canDisconnect)); \ condition = QUOTE([ARR_2(_player,_target)] call FUNC(canDisconnect)); \
statement = QUOTE([ARR_2(_player,_target)] call DFUNC(disconnect)); \ statement = QUOTE([ARR_2(_player,_target)] call DFUNC(disconnect)); \
exceptions[] = {"isNotInside"}; \ exceptions[] = {"isNotInside", "isNotOnLadder"}; \
icon = QPATHTOF(ui\icon_refuel_interact.paa); \ icon = QPATHTOF(ui\icon_refuel_interact.paa); \
}; \ }; \
}; \ }; \
@ -164,31 +107,27 @@ class CfgVehicles {
class Land: AllVehicles {}; class Land: AllVehicles {};
class LandVehicle: Land {}; class LandVehicle: Land {};
class Car: LandVehicle { class Car: LandVehicle {
MACRO_CONNECT_ACTIONS GVAR(canReceive) = 1;
}; };
class Tank: LandVehicle { class Tank: LandVehicle {
MACRO_CONNECT_ACTIONS GVAR(canReceive) = 1;
GVAR(flowRate) = 4; GVAR(flowRate) = 4;
}; };
class StaticWeapon: LandVehicle {
MACRO_CONNECT_ACTIONS
};
class Air: AllVehicles { class Air: AllVehicles {
GVAR(flowRate) = 8; GVAR(flowRate) = 8;
}; };
class Helicopter: Air { class Helicopter: Air {
MACRO_CONNECT_ACTIONS GVAR(canReceive) = 1;
}; };
class Helicopter_Base_F: Helicopter {}; class Helicopter_Base_F: Helicopter {};
class Helicopter_Base_H: Helicopter_Base_F {}; class Helicopter_Base_H: Helicopter_Base_F {};
class Plane: Air { class Plane: Air {
MACRO_CONNECT_ACTIONS GVAR(canReceive) = 1;
GVAR(flowRate) = 16; GVAR(flowRate) = 16;
}; };
@ -197,7 +136,7 @@ class CfgVehicles {
class Ship: AllVehicles {}; class Ship: AllVehicles {};
class Ship_F: Ship { class Ship_F: Ship {
MACRO_CONNECT_ACTIONS GVAR(canReceive) = 1;
GVAR(flowRate) = 4; GVAR(flowRate) = 4;
}; };
@ -217,7 +156,7 @@ class CfgVehicles {
}; };
class SDV_01_base_F: Boat_F { class SDV_01_base_F: Boat_F {
// SDV is using electrical propulsion // SDV is using electrical propulsion
GVAR(fuelCapacity) = 0; GVAR(canReceive) = 0;
}; };
class Car_F: Car { class Car_F: Car {
@ -301,7 +240,6 @@ class CfgVehicles {
}; };
class Van_01_fuel_base_F: Van_01_base_F { class Van_01_fuel_base_F: Van_01_base_F {
MACRO_REFUEL_ACTIONS
GVAR(hooks)[] = {{0.38,-3.17,-.7},{-0.41,-3.17,-.7}}; GVAR(hooks)[] = {{0.38,-3.17,-.7},{-0.41,-3.17,-.7}};
GVAR(fuelCargo) = 2000; GVAR(fuelCargo) = 2000;
}; };
@ -326,7 +264,6 @@ class CfgVehicles {
class B_APC_Tracked_01_CRV_F: B_APC_Tracked_01_base_F { class B_APC_Tracked_01_CRV_F: B_APC_Tracked_01_base_F {
transportFuel = 0; //3k transportFuel = 0; //3k
MACRO_REFUEL_ACTIONS
GVAR(hooks)[] = {{-1.08,-4.81,-.8}}; GVAR(hooks)[] = {{-1.08,-4.81,-.8}};
GVAR(fuelCargo) = 1000; GVAR(fuelCargo) = 1000;
}; };
@ -412,7 +349,7 @@ class CfgVehicles {
class UAV_01_base_F: Helicopter_Base_F { class UAV_01_base_F: Helicopter_Base_F {
// Darter is electrical // Darter is electrical
GVAR(fuelCapacity) = 0; GVAR(canReceive) = 0;
}; };
class UAV: Plane {}; class UAV: Plane {};
@ -430,21 +367,18 @@ class CfgVehicles {
// Vanilla fuel vehicles // Vanilla fuel vehicles
class Truck_02_fuel_base_F: Truck_02_base_F { class Truck_02_fuel_base_F: Truck_02_base_F {
transportFuel = 0; //3k transportFuel = 0; //3k
MACRO_REFUEL_ACTIONS
GVAR(hooks)[] = {{0.99,-3.47,-0.67},{-1.04,-3.47,-0.67}}; GVAR(hooks)[] = {{0.99,-3.47,-0.67},{-1.04,-3.47,-0.67}};
GVAR(fuelCargo) = 10000; GVAR(fuelCargo) = 10000;
}; };
class B_Truck_01_fuel_F: B_Truck_01_mover_F { class B_Truck_01_fuel_F: B_Truck_01_mover_F {
transportFuel = 0; //3k transportFuel = 0; //3k
MACRO_REFUEL_ACTIONS
GVAR(hooks)[] = {{.28,-4.99,-.3},{-.25,-4.99,-.3}}; GVAR(hooks)[] = {{.28,-4.99,-.3},{-.25,-4.99,-.3}};
GVAR(fuelCargo) = 10000; GVAR(fuelCargo) = 10000;
}; };
class O_Truck_03_fuel_F: Truck_03_base_F { class O_Truck_03_fuel_F: Truck_03_base_F {
transportFuel = 0; //3k transportFuel = 0; //3k
MACRO_REFUEL_ACTIONS
GVAR(hooks)[] = {{1.3,-1.59,-.62},{-1.16,-1.59,-.62}}; GVAR(hooks)[] = {{1.3,-1.59,-.62},{-1.16,-1.59,-.62}};
GVAR(fuelCargo) = 10000; GVAR(fuelCargo) = 10000;
}; };
@ -459,7 +393,6 @@ class CfgVehicles {
class Pod_Heli_Transport_04_base_F: Slingload_base_F {}; class Pod_Heli_Transport_04_base_F: Slingload_base_F {};
class Land_Pod_Heli_Transport_04_fuel_F: Pod_Heli_Transport_04_base_F { class Land_Pod_Heli_Transport_04_fuel_F: Pod_Heli_Transport_04_base_F {
transportFuel = 0; //3k transportFuel = 0; //3k
MACRO_REFUEL_ACTIONS
GVAR(hooks)[] = {{-1.49,1.41,-.3}}; GVAR(hooks)[] = {{-1.49,1.41,-.3}};
GVAR(fuelCargo) = 10000; GVAR(fuelCargo) = 10000;
}; };
@ -467,14 +400,12 @@ class CfgVehicles {
class Slingload_01_Base_F: Slingload_base_F {}; class Slingload_01_Base_F: Slingload_base_F {};
class B_Slingload_01_Fuel_F: Slingload_01_Base_F { class B_Slingload_01_Fuel_F: Slingload_01_Base_F {
transportFuel = 0; //3k transportFuel = 0; //3k
MACRO_REFUEL_ACTIONS
GVAR(hooks)[] = {{0.55,3.02,-0.5},{-0.52,3.02,-0.5}}; GVAR(hooks)[] = {{0.55,3.02,-0.5},{-0.52,3.02,-0.5}};
GVAR(fuelCargo) = 10000; GVAR(fuelCargo) = 10000;
}; };
class O_Heli_Transport_04_fuel_F: Heli_Transport_04_base_F { class O_Heli_Transport_04_fuel_F: Heli_Transport_04_base_F {
transportFuel = 0; //3k transportFuel = 0; //3k
MACRO_REFUEL_ACTIONS
GVAR(hooks)[] = {{-1.52,1.14,-1.18}}; GVAR(hooks)[] = {{-1.52,1.14,-1.18}};
GVAR(fuelCargo) = 10000; GVAR(fuelCargo) = 10000;
}; };
@ -496,7 +427,6 @@ class CfgVehicles {
}; };
transportFuel = 0; //60k transportFuel = 0; //60k
MACRO_REFUEL_ACTIONS
GVAR(hooks)[] = {{-3.35,2.45,0.17}}; GVAR(hooks)[] = {{-3.35,2.45,0.17}};
GVAR(fuelCargo) = 60000; GVAR(fuelCargo) = 60000;
}; };
@ -513,7 +443,6 @@ class CfgVehicles {
}; };
class Land_FlexibleTank_01_F: FlexibleTank_base_F { class Land_FlexibleTank_01_F: FlexibleTank_base_F {
transportFuel = 0; //300 transportFuel = 0; //300
MACRO_REFUEL_ACTIONS
GVAR(hooks)[] = {{0, 0, 0.5}}; GVAR(hooks)[] = {{0, 0, 0.5}};
GVAR(fuelCargo) = 300; GVAR(fuelCargo) = 300;
}; };
@ -521,27 +450,23 @@ class CfgVehicles {
// Vanilla buildings // Vanilla buildings
class Land_Fuelstation_Feed_F: House_Small_F { class Land_Fuelstation_Feed_F: House_Small_F {
transportFuel = 0; //50k transportFuel = 0; //50k
MACRO_REFUEL_ACTIONS
GVAR(hooks)[] = {{0,0,-0.5}}; GVAR(hooks)[] = {{0,0,-0.5}};
GVAR(fuelCargo) = REFUEL_INFINITE_FUEL; GVAR(fuelCargo) = REFUEL_INFINITE_FUEL;
}; };
class Land_fs_feed_F: House_Small_F { class Land_fs_feed_F: House_Small_F {
transportFuel = 0; //50k transportFuel = 0; //50k
MACRO_REFUEL_ACTIONS
GVAR(hooks)[] = {{-0.4,0.022,-.23}}; GVAR(hooks)[] = {{-0.4,0.022,-.23}};
GVAR(fuelCargo) = REFUEL_INFINITE_FUEL; GVAR(fuelCargo) = REFUEL_INFINITE_FUEL;
}; };
class Land_FuelStation_01_pump_F: House_F { class Land_FuelStation_01_pump_F: House_F {
transportFuel = 0; //50k transportFuel = 0; //50k
MACRO_REFUEL_ACTIONS
GVAR(hooks)[] = {{0, 0.4, -0.5}, {0, -0.4, -0.5}}; GVAR(hooks)[] = {{0, 0.4, -0.5}, {0, -0.4, -0.5}};
GVAR(fuelCargo) = REFUEL_INFINITE_FUEL; GVAR(fuelCargo) = REFUEL_INFINITE_FUEL;
}; };
class Land_FuelStation_01_pump_malevil_F: House_F { class Land_FuelStation_01_pump_malevil_F: House_F {
transportFuel = 0; //50k transportFuel = 0; //50k
MACRO_REFUEL_ACTIONS
GVAR(hooks)[] = {{0, 0.4, -0.5}, {0, -0.4, -0.5}}; GVAR(hooks)[] = {{0, 0.4, -0.5}, {0, -0.4, -0.5}};
GVAR(fuelCargo) = REFUEL_INFINITE_FUEL; GVAR(fuelCargo) = REFUEL_INFINITE_FUEL;
}; };

View File

@ -1,30 +1,26 @@
PREP(canCheckFuel); PREP(canCheckFuel);
PREP(canConnectNozzle);
PREP(canDisconnect); PREP(canDisconnect);
PREP(canReturnNozzle); PREP(canReturnNozzle);
PREP(canTakeNozzle); PREP(canTakeNozzle);
PREP(canTurnOff); PREP(canTurnOff);
PREP(canTurnOn); PREP(canTurnOn);
PREP(checkFuel); PREP(checkFuel);
PREP(connectNozzle);
PREP(connectNozzleAction); PREP(connectNozzleAction);
PREP(disconnect); PREP(disconnect);
PREP(dropNozzle); PREP(dropNozzle);
PREP(getFuel); PREP(getFuel);
PREP(handleDisconnect); PREP(handleDisconnect);
PREP(handleKilled); PREP(handleRespawn);
PREP(handlePlayerWeaponChanged); PREP(initSource);
PREP(handleUnconscious);
PREP(makeJerryCan); PREP(makeJerryCan);
PREP(maxDistanceDropNozzle); PREP(makeSource);
PREP(moduleRefuelSettings); PREP(moduleRefuelSettings);
PREP(onMouseButtonDown);
PREP(readFuelCounter); PREP(readFuelCounter);
PREP(refuel); PREP(refuel);
PREP(reset);
PREP(resetLocal);
PREP(returnNozzle); PREP(returnNozzle);
PREP(setFuel); PREP(setFuel);
PREP(startNozzleInHandsPFH);
PREP(takeNozzle); PREP(takeNozzle);
PREP(turnOff); PREP(turnOff);
PREP(turnOn); PREP(turnOn);

View File

@ -1,38 +1,110 @@
#include "script_component.hpp" #include "script_component.hpp"
["ace_unconscious", {_this call FUNC(handleUnconscious)}] call CBA_fnc_addEventHandler;
["weapon", FUNC(handlePlayerWeaponChanged)] call CBA_fnc_addPlayerEventHandler;
if (isServer) then { if (isServer) then {
addMissionEventHandler ["HandleDisconnect", {_this call FUNC(handleDisconnect)}]; addMissionEventHandler ["HandleDisconnect", LINKFUNC(handleDisconnect)];
}; };
[QGVAR(resetLocal), { [QGVAR(initSource), LINKFUNC(initSource)] call CBA_fnc_addEventHandler;
_this call FUNC(resetLocal);
}] call CBA_fnc_addEventHandler;
// workaround for static fuel stations if (!hasInterface) exitWith {};
if (hasInterface) then {
["isNotRefueling", {!((_this select 0) getVariable [QGVAR(isRefueling), false])}] call EFUNC(common,addCanInteractWithCondition);
["MouseButtonDown", LINKFUNC(onMouseButtonDown)] call CBA_fnc_addDisplayHandler;
GVAR(mainAction) = [
QGVAR(Refuel),
localize LSTRING(Refuel),
QPATHTOF(ui\icon_refuel_interact.paa),
{},
{ {
if ( alive _target
configName _x isKindOf "Building" && && {[_player, _target, [INTERACT_EXCEPTIONS]] call EFUNC(common,canInteractWith)}
{isClass (_x >> "ACE_Actions" >> "ACE_MainActions" >> QGVAR(Refuel))} && && {REFUEL_DISABLED_FUEL != [_target] call FUNC(getFuel)}
{getNumber (_x >> "scope") == 2} },
) then { {}, [], [0,0,0],
TRACE_1("Compiling menu",configName _x); REFUEL_ACTION_DISTANCE
[configName _x] call EFUNC(interact_menu,compileMenu); ] call EFUNC(interact_menu,createAction);
GVAR(actions) = [
[QGVAR(TakeNozzle),
localize LSTRING(TakeNozzle),
QPATHTOF(ui\icon_refuel_interact.paa),
{[_player, _target] call FUNC(TakeNozzle)},
{[_player, _target] call FUNC(canTakeNozzle)},
{}, [], [0,0,0],
REFUEL_ACTION_DISTANCE
] call EFUNC(interact_menu,createAction),
[QGVAR(CheckFuelCounter),
localize LSTRING(CheckFuelCounter),
QPATHTOF(ui\icon_refuel_interact.paa),
{[_player, _target] call FUNC(readFuelCounter)},
{true},
{}, [], [0,0,0],
REFUEL_ACTION_DISTANCE
] call EFUNC(interact_menu,createAction),
[QGVAR(CheckFuel),
localize LSTRING(CheckFuel),
QPATHTOF(ui\icon_refuel_interact.paa),
{[_player, _target] call FUNC(checkFuel)},
{[_player, _target] call FUNC(canCheckFuel)},
{}, [], [0,0,0],
REFUEL_ACTION_DISTANCE
] call EFUNC(interact_menu,createAction),
[QGVAR(Return),
localize LSTRING(Return),
QPATHTOF(ui\icon_refuel_interact.paa),
{[_player, _target] call FUNC(returnNozzle)},
{[_player, _target] call FUNC(canReturnNozzle)},
{}, [], [0,0,0],
REFUEL_ACTION_DISTANCE
] call EFUNC(interact_menu,createAction)
];
// init menu for config refuel vehicles
private _sourceClasses = [];
{
private _fuelCargo = getNumber (_x >> QGVAR(fuelCargo));
if (_fuelCargo > 0 || {_fuelCargo == REFUEL_INFINITE_FUEL}) then {
private _sourceClass = configName _x;
if (isClass (_x >> "ACE_Actions" >> "ACE_MainActions" >> QGVAR(Refuel))) exitWith {
if (!isClass (inheritsFrom _x >> "ACE_Actions" >> "ACE_MainActions" >> QGVAR(Refuel))) then {
ACE_DEPRECATED(FORMAT_1(QUOTE(GVAR(Refuel) interaction menu in %1),_sourceClass),"3.13.0",QUOTE(GVAR(fuelCargo) config value));
};
}; };
} count ('true' configClasses (configFile >> "CfgVehicles")); // check if we can use actions with inheritance
}; if (
!isText (_x >> "EventHandlers" >> "CBA_Extended_EventHandlers" >> "init") // addActionToClass relies on XEH init
|| {configName _x isKindOf "Static"} // CBA_fnc_addClassEventHandler doesn't support "Static" class
) then {
if (2 == getNumber (_x >> "scope")) then {
[_sourceClass, 0, ["ACE_MainActions"], GVAR(mainAction)] call EFUNC(interact_menu,addActionToClass);
{
[_sourceClass, 0, ["ACE_MainActions", QGVAR(Refuel)], _x] call EFUNC(interact_menu,addActionToClass);
} forEach GVAR(actions);
TRACE_1("add menu to static",_sourceClass);
};
} else {
if (0 == {_sourceClass isKindOf _x} count _sourceClasses) then {
_sourceClasses pushBack _sourceClass;
[_sourceClass, 0, ["ACE_MainActions"], GVAR(mainAction), true] call EFUNC(interact_menu,addActionToClass);
{
[_sourceClass, 0, ["ACE_MainActions", QGVAR(Refuel)], _x, true] call EFUNC(interact_menu,addActionToClass);
} forEach GVAR(actions);
TRACE_1("add menu to dynamic",_sourceClass);
};
};
};
} forEach ('true' configClasses (configFile >> "CfgVehicles"));
#ifdef DRAW_HOOKS_POS #ifdef DRAW_HOOKS_POS
addMissionEventHandler ["Draw3D", { addMissionEventHandler ["Draw3D", {
private _target = cursorObject; private _source = cursorObject;
private _cfgPos = getArray (configFile >> "CfgVehicles" >> typeOf _target >> QGVAR(hooks)); private _cfgPos = getArray (configFile >> "CfgVehicles" >> typeOf _source >> QGVAR(hooks));
private _dynPos = _target getVariable [QGVAR(dev_hooks), []]; private _dynPos = _source getVariable [QGVAR(hooks), []];
{ {
drawIcon3D ["\a3\ui_f\data\gui\cfg\hints\icon_text\group_1_ca.paa", [1,1,1,1], _target modelToWorldVisual _x, 1, 1, 0, format ["Hook %1", _forEachIndex]]; drawIcon3D ["\a3\ui_f\data\gui\cfg\hints\icon_text\group_1_ca.paa", [1,1,1,1], _source modelToWorldVisual _x, 1, 1, 0, format ["Hook %1", _forEachIndex]];
} forEach ([_dynPos, _cfgPos] select (_dynPos isEqualTo [])); } forEach ([_dynPos, _cfgPos] select (_dynPos isEqualTo []));
}]; }];
#endif #endif

View File

@ -1,9 +0,0 @@
#include "script_component.hpp"
params ["_unit"];
if !(local _unit) exitWith {};
[_unit, "forceWalk", "ACE_refuel", false] call EFUNC(common,statusEffect_set);
_unit setVariable [QGVAR(selectedWeaponOnRefuel), nil];
_unit setVariable [QGVAR(isRefueling), false];

View File

@ -15,6 +15,7 @@ class CfgPatches {
}; };
#include "ACE_Settings.hpp" #include "ACE_Settings.hpp"
#include "Cfg3DEN.hpp"
#include "CfgEventHandlers.hpp" #include "CfgEventHandlers.hpp"
#include "CfgVehicles.hpp" #include "CfgVehicles.hpp"

View File

@ -4,7 +4,7 @@
* *
* Arguments: * Arguments:
* 0: Unit <OBJECT> * 0: Unit <OBJECT>
* 1: Fuel Truck/Station <OBJECT> * 1: Fuel Source <OBJECT>
* *
* Return Value: * Return Value:
* Can Check Fuel <BOOL> * Can Check Fuel <BOOL>
@ -16,11 +16,11 @@
*/ */
#include "script_component.hpp" #include "script_component.hpp"
params [["_unit", objNull, [objNull]], ["_target", objNull, [objNull]]]; params [["_unit", objNull, [objNull]], ["_source", objNull, [objNull]]];
!(isNull _unit || !(isNull _unit ||
{!(_unit isKindOf "CAManBase")} || {!(_unit isKindOf "CAManBase")} ||
{!local _unit} || {!local _unit} ||
{!alive _target} || {!alive _source} ||
{([_unit, _target] call EFUNC(interaction,getInteractionDistance)) > REFUEL_ACTION_DISTANCE} || {([_unit, _source] call EFUNC(interaction,getInteractionDistance)) > REFUEL_ACTION_DISTANCE} ||
{(_target call FUNC(getFuel) == REFUEL_INFINITE_FUEL)}) {(_source call FUNC(getFuel) == REFUEL_INFINITE_FUEL)})

View File

@ -1,32 +0,0 @@
/*
* Author: GitHawk
* Check if a unit can connect a fuel nozzle
*
* Arguments:
* 0: Unit <OBJECT>
* 1: Target <OBJECT>
*
* Return Value:
* Can Connect Nozzle <BOOL>
*
* Example:
* [player, tank] call ace_refuel_fnc_canConnectNozzle
*
* Public: No
*/
#include "script_component.hpp"
params [["_unit", objNull, [objNull]], ["_target", objNull, [objNull]]];
private _nozzle = _unit getVariable [QGVAR(nozzle), objNull];
private _engine = false;
if (_target isKindOf "AllVehicles") then {
_engine = isEngineOn _target;
};
!(isNull _nozzle ||
{!alive _target} ||
{_engine} ||
{([_unit, _target] call EFUNC(interaction,getInteractionDistance)) > REFUEL_ACTION_DISTANCE} ||
{!isNull (_target getVariable [QGVAR(nozzle), objNull])})

View File

@ -4,7 +4,7 @@
* *
* Arguments: * Arguments:
* 0: Unit <OBJECT> * 0: Unit <OBJECT>
* 1: Fuel truck <OBJECT> * 1: Fuel Source <OBJECT>
* *
* Return Value: * Return Value:
* Can Return Nozzle <BOOL> * Can Return Nozzle <BOOL>
@ -16,10 +16,10 @@
*/ */
#include "script_component.hpp" #include "script_component.hpp"
params [["_unit", objNull, [objNull]], ["_target", objNull, [objNull]]]; params [["_unit", objNull, [objNull]], ["_source", objNull, [objNull]]];
private _nozzle = _unit getVariable [QGVAR(nozzle), objNull]; private _nozzle = _unit getVariable [QGVAR(nozzle), objNull];
(!isNull _nozzle) && (!isNull _nozzle) &&
{([_unit, _target] call EFUNC(interaction,getInteractionDistance)) < REFUEL_ACTION_DISTANCE} && {([_unit, _source] call EFUNC(interaction,getInteractionDistance)) < REFUEL_ACTION_DISTANCE} &&
{_target == (_nozzle getVariable [QGVAR(source), objNull])} {_source == (_nozzle getVariable [QGVAR(source), objNull])}

View File

@ -4,7 +4,7 @@
* *
* Arguments: * Arguments:
* 0: Unit <OBJECT> * 0: Unit <OBJECT>
* 1: Fuel Station or Nozzle <OBJECT> * 1: Fuel Source or Nozzle <OBJECT>
* *
* Return Value: * Return Value:
* Can connect <BOOL> * Can connect <BOOL>
@ -16,14 +16,14 @@
*/ */
#include "script_component.hpp" #include "script_component.hpp"
params [["_unit", objNull, [objNull]], ["_target", objNull, [objNull]]]; params [["_unit", objNull, [objNull]], ["_object", objNull, [objNull]]];
if (isNull _unit || if (isNull _unit ||
{!(_unit isKindOf "CAManBase")} || {!(_unit isKindOf "CAManBase")} ||
{!local _unit} || {!local _unit} ||
{!alive _target} || {!alive _object} ||
{!isNull (_unit getVariable [QGVAR(nozzle), objNull])} || {!isNull (_unit getVariable [QGVAR(nozzle), objNull])} ||
{typeOf _target == QGVAR(fuelNozzle) && {!isNull (attachedTo _target)}} || // Not carried by someone else {typeOf _object == QGVAR(fuelNozzle) && {!isNull (attachedTo _object)}} || // Not carried by someone else
{([_unit, _target] call EFUNC(interaction,getInteractionDistance)) > REFUEL_ACTION_DISTANCE}) exitWith {false}; {([_unit, _object] call EFUNC(interaction,getInteractionDistance)) > REFUEL_ACTION_DISTANCE}) exitWith {false};
!(_target getVariable [QGVAR(isConnected), false]) && {!(_unit getVariable [QGVAR(isRefueling), false])} !(_object getVariable [QGVAR(isConnected), false]) && {!(_unit getVariable [QGVAR(isRefueling), false])}

View File

@ -4,7 +4,7 @@
* *
* Arguments: * Arguments:
* 0: Unit <OBJECT> * 0: Unit <OBJECT>
* 1: Fuel Truck <OBJECT> * 1: Fuel Source <OBJECT>
* *
* Return Value: * Return Value:
* None * None
@ -16,16 +16,16 @@
*/ */
#include "script_component.hpp" #include "script_component.hpp"
params [["_unit", objNull, [objNull]], ["_target", objNull, [objNull]]]; params [["_unit", objNull, [objNull]], ["_source", objNull, [objNull]]];
private _fuel = [_target] call FUNC(getFuel); private _fuel = [_source] call FUNC(getFuel);
[ [
TIME_PROGRESSBAR(REFUEL_PROGRESS_DURATION * 2), TIME_PROGRESSBAR(REFUEL_PROGRESS_DURATION * 2),
[_unit, _target, _fuel], [_unit, _source, _fuel],
{ {
params ["_args"]; params ["_args"];
_args params [["_unit", objNull, [objNull]], ["_target", objNull, [objNull]], ["_fuel", 0, [0]]]; _args params [["_unit", objNull, [objNull]], ["_source", objNull, [objNull]], ["_fuel", 0, [0]]];
if (_fuel > 0 ) then { if (_fuel > 0 ) then {
[QEGVAR(common,displayTextStructured), [[LSTRING(Hint_RemainingFuel), _fuel], 2, _unit], _unit] call CBA_fnc_targetEvent; [QEGVAR(common,displayTextStructured), [[LSTRING(Hint_RemainingFuel), _fuel], 2, _unit], _unit] call CBA_fnc_targetEvent;
} else { } else {
@ -36,5 +36,5 @@ private _fuel = [_target] call FUNC(getFuel);
{true}, {true},
localize LSTRING(CheckFuelAction), localize LSTRING(CheckFuelAction),
{true}, {true},
["isnotinside"] [INTERACT_EXCEPTIONS]
] call EFUNC(common,progressBar); ] call EFUNC(common,progressBar);

View File

@ -1,62 +0,0 @@
/*
* Author: GitHawk et.al.
* Connect a fuel nozzle.
* With code from ace_attach
*
* Arguments:
* 0: Unit <OBJECT>
* 1: Target <OBJECT>
*
* Return Value:
* None
*
* Example:
* [player, tank] call ace_refuel_fnc_connectNozzle
*
* Public: No
*/
#include "script_component.hpp"
#define PLACE_WAITING -1
#define PLACE_CANCEL 0
#define PLACE_APPROVE 1
params [["_unit", objNull, [objNull]], ["_target", objNull, [objNull]]];
private _nozzle = _unit getVariable [QGVAR(nozzle), objNull];
if (isNull _nozzle) exitWith {};
GVAR(placeAction) = PLACE_WAITING;
[{[localize LSTRING(Connect_Action), ""] call EFUNC(interaction,showMouseHint)}, []] call CBA_fnc_execNextFrame;
_unit setVariable [QGVAR(placeActionEH), [_unit, "DefaultAction", {true}, {GVAR(placeAction) = PLACE_APPROVE;}] call EFUNC(common,AddActionEventHandler)];
private _actionID = _unit addAction [format ["<t color='#FF0000'>%1</t>", localize LSTRING(Cancel)], {GVAR(placeAction) = PLACE_CANCEL;}];
[{
params ["_args","_pfID"];
_args params [["_unit", objNull, [objNull]], ["_target", objNull, [objNull]], ["_nozzle", objNull, [objNull]], ["_actionID", -1, [0]]];
private _virtualPosASL = (eyePos _unit) vectorAdd (positionCameraToWorld [0,0,0.6]) vectorDiff (positionCameraToWorld [0,0,0]);
if (cameraView == "EXTERNAL") then {
_virtualPosASL = _virtualPosASL vectorAdd ((positionCameraToWorld [0.3,0,0]) vectorDiff (positionCameraToWorld [0,0,0]));
};
private _lineInterection = lineIntersects [eyePos ace_player, _virtualPosASL, ace_player];
//Don't allow placing in a bad position:
if (_lineInterection && {GVAR(placeAction) == PLACE_APPROVE}) then {GVAR(placeAction) = PLACE_WAITING;};
if ((GVAR(placeAction) != PLACE_WAITING) ||
{_unit != ace_player} ||
{!([_unit, _target, []] call EFUNC(common,canInteractWith))}) then {
[_pfID] call CBA_fnc_removePerFrameHandler;
[] call EFUNC(interaction,hideMouseHint);
[_unit, "DefaultAction", (_unit getVariable [QGVAR(placeActionEH), -1])] call EFUNC(common,removeActionEventHandler);
_unit removeAction _actionID;
if (GVAR(placeAction) == PLACE_APPROVE) then {
[_unit, _target, _virtualPosASL, _nozzle] call FUNC(ConnectNozzleAction);
};
}; // TODO add model like in attach/functions/fnc_attach
}, 0, [_unit, _target, _nozzle, _actionID] ] call cba_fnc_addPerFrameHandler;

View File

@ -5,7 +5,7 @@
* *
* Arguments: * Arguments:
* 0: Unit <OBJECT> * 0: Unit <OBJECT>
* 1: Target <OBJECT> * 1: Vehicle <OBJECT>
* 2: Visual Position ASL <ARRAY> * 2: Visual Position ASL <ARRAY>
* 3: Nozzle <OBJECT> * 3: Nozzle <OBJECT>
* *
@ -20,14 +20,14 @@
#include "script_component.hpp" #include "script_component.hpp"
private ["_closeInDistance", "_endPosTestOffset"]; private ["_closeInDistance", "_endPosTestOffset"];
params [["_unit", objNull, [objNull]], ["_target", objNull, [objNull]], ["_startingPosASL", [0,0,0], [[]], 3], ["_nozzle", objNull, [objNull]]]; params [["_unit", objNull, [objNull]], ["_sink", objNull, [objNull]], ["_startingPosASL", [0,0,0], [[]], 3], ["_nozzle", objNull, [objNull]]];
private _bestPosASL = []; private _bestPosASL = [];
private _bestPosDistance = 1e99; private _bestPosDistance = 1e99;
private _viewPos = _startingPosASL vectorAdd (((positionCameraToWorld [0,0,0]) vectorFromTo (positionCameraToWorld [0,0,1])) vectorMultiply 3); private _viewPos = _startingPosASL vectorAdd (((positionCameraToWorld [0,0,0]) vectorFromTo (positionCameraToWorld [0,0,1])) vectorMultiply 3);
private _modelVector = _startingPosASL vectorFromTo (AGLtoASL (_target modelToWorld [0,0,0])); private _modelVector = _startingPosASL vectorFromTo (AGLtoASL (_sink modelToWorld [0,0,0]));
private _modelVectorLow = _startingPosASL vectorFromTo (AGLtoASL (_target modelToWorld [0,0,-1])); private _modelVectorLow = _startingPosASL vectorFromTo (AGLtoASL (_sink modelToWorld [0,0,-1]));
{ {
private _endPosASL = _x; private _endPosASL = _x;
@ -35,7 +35,7 @@ private _modelVectorLow = _startingPosASL vectorFromTo (AGLtoASL (_target modelT
private _intersections = lineIntersectsSurfaces [_startingPosASL, _endPosASL, _unit]; private _intersections = lineIntersectsSurfaces [_startingPosASL, _endPosASL, _unit];
{ {
_x params ["_intersectPosASL", "", "_intersectObject"]; _x params ["_intersectPosASL", "", "_intersectObject"];
if (_intersectObject == _target) then { if (_intersectObject == _sink) then {
private _distance = _startingPosASL distance _intersectPosASL; private _distance = _startingPosASL distance _intersectPosASL;
if (_distance < _bestPosDistance) then { if (_distance < _bestPosDistance) then {
_bestPosDistance = _distance; _bestPosDistance = _distance;
@ -51,8 +51,8 @@ private _modelVectorLow = _startingPosASL vectorFromTo (AGLtoASL (_target modelT
_startingPosASL vectorAdd (((positionCameraToWorld [0,0,0]) vectorFromTo (positionCameraToWorld [0,-0.25,1])) vectorMultiply 3), _startingPosASL vectorAdd (((positionCameraToWorld [0,0,0]) vectorFromTo (positionCameraToWorld [0,-0.25,1])) vectorMultiply 3),
_startingPosASL vectorAdd (((positionCameraToWorld [0,0,0]) vectorFromTo (positionCameraToWorld [-0.25,-0.25,1])) vectorMultiply 3), _startingPosASL vectorAdd (((positionCameraToWorld [0,0,0]) vectorFromTo (positionCameraToWorld [-0.25,-0.25,1])) vectorMultiply 3),
_startingPosASL vectorAdd (((positionCameraToWorld [0,0,0]) vectorFromTo (positionCameraToWorld [0.25,-0.25,1])) vectorMultiply 3), _startingPosASL vectorAdd (((positionCameraToWorld [0,0,0]) vectorFromTo (positionCameraToWorld [0.25,-0.25,1])) vectorMultiply 3),
AGLtoASL (_target modelToWorld [0,0,0]), // Try old method of just using model center AGLtoASL (_sink modelToWorld [0,0,0]), // Try old method of just using model center
AGLtoASL (_target modelToWorld [0,0,-0.5]) AGLtoASL (_sink modelToWorld [0,0,-0.5])
]; ];
//Checks (too close to center or can't attach) //Checks (too close to center or can't attach)
@ -64,28 +64,21 @@ if (_bestPosASL isEqualTo []) exitWith {
//Move it out slightly, for visibility sake (better to look a little funny than be embedded//sunk in the hull and be useless) //Move it out slightly, for visibility sake (better to look a little funny than be embedded//sunk in the hull and be useless)
_bestPosASL = _bestPosASL vectorAdd ((_bestPosASL vectorFromTo _startingPosASL) vectorMultiply 0.05); _bestPosASL = _bestPosASL vectorAdd ((_bestPosASL vectorFromTo _startingPosASL) vectorMultiply 0.05);
private _attachPosModel = _target worldToModel (ASLtoAGL _bestPosASL); private _attachPosModel = _sink worldToModel (ASLtoAGL _bestPosASL);
[ [
TIME_PROGRESSBAR(REFUEL_PROGRESS_DURATION), TIME_PROGRESSBAR(REFUEL_PROGRESS_DURATION),
[_unit, _nozzle, _target, _attachPosModel], [_unit, _nozzle, _sink, _attachPosModel],
{ {
params ["_args"]; params ["_args"];
_args params [["_unit", objNull, [objNull]], ["_nozzle", objNull, [objNull]], ["_target", objNull, [objNull]], ["_endPosTestOffset", [0,0,0], [[]], 3]]; _args params [["_unit", objNull, [objNull]], ["_nozzle", objNull, [objNull]], ["_sink", objNull, [objNull]], ["_endPosTestOffset", [0,0,0], [[]], 3]];
_unit setVariable [QGVAR(nozzle), nil, true]; _unit setVariable [QGVAR(nozzle), nil, true];
_unit setVariable [QGVAR(isRefueling), false]; _unit setVariable [QGVAR(isRefueling), false];
[_unit, "forceWalk", "ACE_refuel", false] call EFUNC(common,statusEffect_set);
REFUEL_UNHOLSTER_WEAPON
private _actionID = _unit getVariable [QGVAR(ReleaseActionID), -1];
if (_actionID != -1) then {
_unit removeAction _actionID;
_unit setVariable [QGVAR(ReleaseActionID), nil];
};
detach _nozzle; detach _nozzle;
_nozzle attachTo [_target, _endPosTestOffset]; _nozzle attachTo [_sink, _endPosTestOffset];
_endPosTestOffset params ["_x", "_y"]; _endPosTestOffset params ["_x", "_y"];
private _bb = boundingBoxReal _target; private _bb = boundingBoxReal _sink;
_bb params ["_ll", "_rr"]; _bb params ["_ll", "_rr"];
_ll set [2, 0]; _ll set [2, 0];
_rr set [2, 0]; _rr set [2, 0];
@ -115,9 +108,9 @@ private _attachPosModel = _target worldToModel (ASLtoAGL _bestPosASL);
}; };
}; };
[QEGVAR(common,setVectorDirAndUp), [_nozzle, _dirAndUp], _nozzle] call CBA_fnc_targetEvent; [QEGVAR(common,setVectorDirAndUp), [_nozzle, _dirAndUp], _nozzle] call CBA_fnc_targetEvent;
_nozzle setVariable [QGVAR(sink), _target, true]; _nozzle setVariable [QGVAR(sink), _sink, true];
_nozzle setVariable [QGVAR(isConnected), true, true]; _nozzle setVariable [QGVAR(isConnected), true, true];
_target setVariable [QGVAR(nozzle), _nozzle, true]; _sink setVariable [QGVAR(nozzle), _nozzle, true];
_source = _nozzle getVariable QGVAR(source); _source = _nozzle getVariable QGVAR(source);
private _fuel = [_source] call FUNC(getFuel); private _fuel = [_source] call FUNC(getFuel);
@ -127,10 +120,10 @@ private _attachPosModel = _target worldToModel (ASLtoAGL _bestPosASL);
_source setVariable [QGVAR(fuelCounter), _fuel, true]; _source setVariable [QGVAR(fuelCounter), _fuel, true];
}; };
[_unit, _target, _nozzle, _endPosTestOffset] call FUNC(refuel); [_unit, _sink, _nozzle, _endPosTestOffset] call FUNC(refuel);
}, },
"", "",
localize LSTRING(ConnectAction), localize LSTRING(ConnectAction),
{true}, {true},
["isnotinside"] [INTERACT_EXCEPTIONS]
] call EFUNC(common,progressBar); ] call EFUNC(common,progressBar);

View File

@ -21,9 +21,9 @@ params [["_unit", objNull, [objNull]], ["_nozzle", objNull, [objNull]]];
private _sink = _nozzle getVariable [QGVAR(sink), objNull]; private _sink = _nozzle getVariable [QGVAR(sink), objNull];
if (isNull _sink) exitWith {}; if (isNull _sink) exitWith {};
_sink setVariable [QGVAR(nozzle), objNull, true]; _sink setVariable [QGVAR(nozzle), nil, true];
_nozzle setVariable [QGVAR(sink), objNull, true]; _nozzle setVariable [QGVAR(sink), nil, true];
_nozzle setVariable [QGVAR(isConnected), false, true]; _nozzle setVariable [QGVAR(isConnected), false, true];
[objNull, _nozzle, true] call FUNC(dropNozzle); [objNull, _nozzle, true] call FUNC(dropNozzle);
[_unit, objNull, _nozzle] call FUNC(takeNozzle); [_unit, _nozzle] call FUNC(takeNozzle);

View File

@ -41,5 +41,5 @@ _nozzle setPosASL _groundPosition;
TRACE_1("finalPos",getPosATL _nozzle); TRACE_1("finalPos",getPosATL _nozzle);
if (isNull _unit) exitWith {}; if (isNull _unit) exitWith {};
_unit setVariable [QGVAR(isRefueling), false, true]; _unit setVariable [QGVAR(isRefueling), false];
_unit setVariable [QGVAR(nozzle), objNull, true]; _unit setVariable [QGVAR(nozzle), objNull, true];

View File

@ -3,7 +3,7 @@
* Get the remaining fuel amount. * Get the remaining fuel amount.
* *
* Arguments: * Arguments:
* 0: Target <OBJECT> * 0: Fuel Source <OBJECT>
* *
* Return Value: * Return Value:
* Fuel left (in liters) <NUMBER> * Fuel left (in liters) <NUMBER>
@ -15,15 +15,15 @@
*/ */
#include "script_component.hpp" #include "script_component.hpp"
params [["_target", objNull, [objNull]]]; params [["_source", objNull, [objNull]]];
if (isNull _target) exitWith {0}; if (isNull _source) exitWith {0};
private _fuel = _target getVariable QGVAR(currentFuelCargo); private _fuel = _source getVariable QGVAR(currentFuelCargo);
if (isNil "_fuel") then { if (isNil "_fuel") then {
_fuel = getNumber (configFile >> "CfgVehicles" >> typeOf _target >> QGVAR(fuelCargo)); _fuel = getNumber (configFile >> "CfgVehicles" >> typeOf _source >> QGVAR(fuelCargo));
_target setVariable [QGVAR(currentFuelCargo), _fuel, true]; _source setVariable [QGVAR(currentFuelCargo), _fuel, true];
}; };
_fuel _fuel

View File

@ -1,6 +1,6 @@
/* /*
* Author: GitHawk * Author: GitHawk
* Cleans up refuel * Cleans up refuel on client disconnect.
* *
* Arguments: * Arguments:
* 0: Player <OBJECT> * 0: Player <OBJECT>
@ -15,12 +15,13 @@
*/ */
#include "script_component.hpp" #include "script_component.hpp"
params [["_disconnectedPlayer", objNull, [objNull]]]; params [["_unit", objNull, [objNull]]];
TRACE_1("disconnect",_unit);
if (isNull _disconnectedPlayer) exitWith {}; if (isNull _unit) exitWith {};
private _nozzle = _disconnectedPlayer getVariable [QGVAR(nozzle), objNull];
private _nozzle = _unit getVariable [QGVAR(nozzle), objNull];
if (isNull _nozzle) exitWith {}; if (isNull _nozzle) exitWith {};
[_disconnectedPlayer, _nozzle] call FUNC(dropNozzle); [_unit, _nozzle] call FUNC(dropNozzle);
[_unit, "forceWalk", "ACE_refuel", false] call EFUNC(common,statusEffect_set);

View File

@ -1,26 +0,0 @@
/*
* Author: GitHawk, Jonpas
* Handles medical on set dead event.
*
* Arguments:
* 0: Unit <OBJECT>
*
* Return Value:
* None
*
* Example:
* [player] call ace_refuel_fnc_handleKilled
*
* Public: No
*/
#include "script_component.hpp"
params [["_unit", objNull, [objNull]]];
if (!local _unit) exitWith {};
_unit setVariable [QGVAR(selectedWeaponOnRefuel), nil];
private _nozzle = _unit getVariable [QGVAR(nozzle), objNull];
if !(isNull _nozzle) then {
[_unit, _nozzle] call FUNC(dropNozzle);
};

View File

@ -1,29 +0,0 @@
/*
* Author: Jonpas
* Drops nozzle or jerry can when selecting a weapon.
*
* Arguments:
* 0: Unit <OBJECT>
* 1: Weapon <STRING> (unused)
*
* Return Value:
* None
*
* Example:
* [_unit, "gun"] call ace_refuel_fnc_handlePlayerWeaponChanged;
*
* Public: No
*/
#include "script_component.hpp"
params ["_unit"];
// Drop nozzle/jerry can when selecting a non-primary weapon
if (_unit getVariable [QGVAR(isRefueling), false]) then {
private _nozzle = _unit getVariable [QGVAR(nozzle), objNull];
if !(isNull _nozzle) then {
[_unit, _nozzle] call FUNC(dropNozzle);
_unit setVariable [QGVAR(selectedWeaponOnRefuel), nil];
[_unit, "forceWalk", "ACE_refuel", false] call EFUNC(common,statusEffect_set);
};
};

View File

@ -0,0 +1,26 @@
/*
* Author: Dystopian
* Clean variables on unit respawn.
*
* Arguments:
* 0: Unit <OBJECT>
*
* Return Value:
* None
*
* Example:
* [player] call ace_refuel_fnc_handleRespawn
*
* Public: No
*/
#include "script_component.hpp"
params ["_unit"];
TRACE_1("respawn",_unit);
if (isNull (_unit getVariable [QGVAR(nozzle), objNull])) exitWith {};
_unit setVariable [QGVAR(selectedWeaponOnRefuel), nil];
_unit setVariable [QGVAR(isRefueling), false];
_unit setVariable [QGVAR(nozzle), nil, true];
_unit setVariable [QGVAR(hint), nil];

View File

@ -1,27 +0,0 @@
/*
* Author: GitHawk, Jonpas
* Handles medical on unconscious event.
*
* Arguments:
* 0: Unit <OBJECT>
* 1: Is Unconscious <BOOL>
*
* Return Value:
* None
*
* Example:
* [player, true] call ace_refuel_fnc_handleUnconscious
*
* Public: No
*/
#include "script_component.hpp"
params [["_unit", objNull, [objNull]], ["_isUnconscious", false, [false]]];
if (!local _unit || {!_isUnconscious}) exitWith {};
[_unit, "forceWalk", "ACE_refuel", false] call EFUNC(common,statusEffect_set);
private _nozzle = _unit getVariable [QGVAR(nozzle), objNull];
if !(isNull _nozzle) then {
[_unit, _nozzle] call FUNC(dropNozzle);
};

View File

@ -0,0 +1,26 @@
/*
* Author: Dystopian
* Adds refuel menu to object.
*
* Arguments:
* 0: Source <OBJECT>
*
* Return Value:
* None
*
* Example:
* [cursorObject] call ace_refuel_fnc_initSource
*
* Public: No
*/
#include "script_component.hpp"
if (!hasInterface) exitWith {};
params ["_source"];
TRACE_2("init",_source,typeOf _source);
[_source, 0, ["ACE_MainActions"], GVAR(mainAction)] call EFUNC(interact_menu,addActionToObject);
{
[_source, 0, ["ACE_MainActions", QGVAR(Refuel)], _x] call EFUNC(interact_menu,addActionToObject);
} forEach GVAR(actions);

View File

@ -44,7 +44,7 @@ private _action = [QGVAR(Refuel),
_action = [QGVAR(PickUpNozzle), _action = [QGVAR(PickUpNozzle),
localize LSTRING(TakeNozzle), localize LSTRING(TakeNozzle),
QPATHTOF(ui\icon_refuel_interact.paa), QPATHTOF(ui\icon_refuel_interact.paa),
{[_player, objNull, _target] call FUNC(TakeNozzle)}, {[_player, _target] call FUNC(TakeNozzle)},
{[_player, _target] call FUNC(canTakeNozzle)}, {[_player, _target] call FUNC(canTakeNozzle)},
{}, {},
[], [],

View File

@ -0,0 +1,63 @@
/*
* Author: Dystopian
* Makes an object into a refuel source.
* Run on server only.
*
* Arguments:
* 0: Fuel Source <OBJECT>
* 1: Fuel amount (in liters) <NUMBER> (default: 0)
* 2: Hooks positions <ARRAY> (default: [[0,0,0]])
*
* Return Value:
* None
*
* Example:
* [cursorObject, 100] call ace_refuel_fnc_makeSource
*
* Public: Yes
*/
#include "script_component.hpp"
if (!isServer) exitWith {};
// Only run this after the settings are initialized
if !(EGVAR(common,settingsInitFinished)) exitWith {
EGVAR(common,runAtSettingsInitialized) pushBack [FUNC(makeSource), _this];
};
params [
["_source", objNull, [objNull]],
["_fuelCargo", 0, [0]],
["_hooks", nil, [[]]]
];
TRACE_3("makeSource",_source,_fuelCargo,_hooks);
private _fuelCargoConfig = getNumber (configFile >> "CfgVehicles" >> typeOf _source >> QGVAR(fuelCargo));
if (
isNull _source
|| {_fuelCargo < 0 && {!(_fuelCargo in [REFUEL_INFINITE_FUEL, REFUEL_DISABLED_FUEL])}}
|| {_fuelCargo != 0 && {_fuelCargo == _fuelCargoConfig}}
) exitWith {};
[_source, _fuelCargo] call FUNC(setFuel);
if (_fuelCargo == REFUEL_DISABLED_FUEL) exitWith {};
if (
!isNil "_hooks"
&& {_hooks isEqualTypeAll []}
&& {0 == {!(_x isEqualTypeParams [0,0,0]) || {3 < count _x}} count _hooks}
) then {
_source setVariable [QGVAR(hooks), _hooks, true];
};
// check if menu already exists
if (_fuelCargoConfig != 0 || {!isNil {_source getVariable QGVAR(initSource_jipID)}}) exitWith {};
private _jipID = [QGVAR(initSource), [_source]] call CBA_fnc_globalEventJIP;
_source setVariable [QGVAR(initSource_jipID), _jipID];
_source addEventHandler ["Deleted", {
// delete event from JIP stack to prevent deleted vehicle init
cba_events_eventNamespaceJIP setVariable [(_this select 0) getVariable QGVAR(initSource_jipID), nil, true];
}];

View File

@ -1,64 +0,0 @@
/*
* Author: GitHawk, Jonpas
* Drops the nozzle at maximum hose distance.
*
* Arguments:
* 0: Unit <OBJECT>
* 1: Fuel Truck <OBJECT>
* 2: End Pos Offset <ARRAY>
* 3: Nozzle <OBJECT> (optional)
*
* Return Value:
* None
*
* Example:
* [player, fuelTruck, [0, 0, 0], nozzle] call ace_refuel_fnc_maxDistanceDropNozzle
*
* Public: No
*/
#include "script_component.hpp"
params ["_unit", "_source", "_endPosOffset", "_nozzle"];
// Exit if jerry can (no maximum distance there as it's not connected to anything)
if (_nozzle getVariable [QGVAR(jerryCan), false]) exitWith {};
// Check distance periodically to drop it at maximum hose length
[{
params ["_args", "_pfID"];
_args params [
["_unit", player, [objNull]],
["_source", objNull, [objNull]],
["_endPosOffset", [0, 0, 0], [[]], 3],
["_nozzle", (_args select 0) getVariable [QGVAR(nozzle), objNull], [objNull]]
];
if (!(_unit getVariable [QGVAR(isRefueling), false])) exitWith {
TRACE_1("player not isRefueling",_unit);
[_pfID] call CBA_fnc_removePerFrameHandler;
};
private _hoseLength = _source getVariable [QGVAR(hoseLength), GVAR(hoseLength)];
if (isNull _source || {_unit distance (_source modelToWorld _endPosOffset) > (_hoseLength - 2)} || {!alive _source}) exitWith {
if !(isNull _nozzle) then {
[_unit, _nozzle] call FUNC(dropNozzle);
REFUEL_UNHOLSTER_WEAPON
[_unit, "forceWalk", "ACE_refuel", false] call EFUNC(common,statusEffect_set);
if (isNull _source || {!alive _source}) then {
private _rope = _nozzle getVariable [QGVAR(rope), objNull];
if !(isNull _rope) then {
ropeDestroy _rope;
};
private _helper = _nozzle getVariable [QGVAR(helper), objNull];
if !(isNull _helper) then {
deleteVehicle _helper;
};
deleteVehicle _nozzle;
} else {
[LSTRING(Hint_TooFar), 2, _unit] call EFUNC(common,displayTextStructured);
};
};
[_pfID] call CBA_fnc_removePerFrameHandler;
};
}, 0, [_unit, _target, _endPosOffset, _nozzle]] call CBA_fnc_addPerFrameHandler;

View File

@ -0,0 +1,53 @@
/*
* Author: Dystopian
* Mouse button down event.
*
* Arguments:
* None
*
* Return Value:
* None
*
* Example:
* [] call ace_refuel_fnc_onMouseButtonDown
*
* Public: No
*/
#include "script_component.hpp"
private _button = _this select 1;
private _unit = ACE_player;
private _nozzle = _unit getVariable [QGVAR(nozzle), objNull];
if (_button > 1 || {isNull _nozzle}) exitWith {};
getCursorObjectParams params ["_cursorObject", "", "_distance"];
// RMB
if (_button == 1) exitWith {
if (
!isNull _cursorObject
&& {_distance < REFUEL_NOZZLE_ACTION_DISTANCE}
&& {[_unit, _cursorObject] call FUNC(canReturnNozzle)}
) then {
[_unit, _cursorObject] call FUNC(returnNozzle);
} else {
[_unit, _nozzle] call FUNC(dropNozzle);
};
};
// LMB
// code from attach, don't know what it is
private _virtualPosASL = (eyePos _unit) vectorAdd (positionCameraToWorld [0,0,0.6]) vectorDiff (positionCameraToWorld [0,0,0]);
if (cameraView == "EXTERNAL") then {
_virtualPosASL = _virtualPosASL vectorAdd ((positionCameraToWorld [0.3,0,0]) vectorDiff (positionCameraToWorld [0,0,0]));
};
if (
!isNull _cursorObject
&& {_distance < REFUEL_NOZZLE_ACTION_DISTANCE}
&& {1 == getNumber (configFile >> "CfgVehicles" >> (typeOf _cursorObject) >> QGVAR(canReceive))}
&& {isNull (_cursorObject getVariable [QGVAR(nozzle), objNull])}
&& {!lineIntersects [eyePos _unit, _virtualPosASL, _unit]}
) then {
[_unit, _cursorObject, _virtualPosASL, _nozzle] call FUNC(connectNozzleAction);
};

View File

@ -4,7 +4,7 @@
* *
* Arguments: * Arguments:
* 0: Unit <OBJECT> * 0: Unit <OBJECT>
* 1: Fuel Truck <OBJECT> * 1: Fuel Source <OBJECT>
* *
* Return Value: * Return Value:
* None * None
@ -16,26 +16,26 @@
*/ */
#include "script_component.hpp" #include "script_component.hpp"
params [["_unit", objNull, [objNull]], ["_target", objNull, [objNull]]]; params [["_unit", objNull, [objNull]], ["_source", objNull, [objNull]]];
[ [
TIME_PROGRESSBAR(REFUEL_PROGRESS_DURATION), TIME_PROGRESSBAR(REFUEL_PROGRESS_DURATION),
[_unit, _target], [_unit, _source],
{ {
params ["_args"]; params ["_args"];
_args params [["_unit", objNull, [objNull]], ["_target", objNull, [objNull]]]; _args params [["_unit", objNull, [objNull]], ["_source", objNull, [objNull]]];
private _currentFuel = [_target] call FUNC(getFuel); private _currentFuel = [_source] call FUNC(getFuel);
if (_currentFuel == REFUEL_INFINITE_FUEL) then { if (_currentFuel == REFUEL_INFINITE_FUEL) then {
private _fuelCounter = 0.01 * round (100 * (_target getVariable [QGVAR(fuelCounter), 0])); private _fuelCounter = 0.01 * round (100 * (_source getVariable [QGVAR(fuelCounter), 0]));
[[LSTRING(Hint_FuelCounter), _fuelCounter], 1.5, _unit] call EFUNC(common,displayTextStructured); [[LSTRING(Hint_FuelCounter), _fuelCounter], 1.5, _unit] call EFUNC(common,displayTextStructured);
} else { } else {
private _fuelCounter = 0.01 * round (100 * ((_target getVariable [QGVAR(fuelCounter), _currentFuel]) - _currentFuel)); private _fuelCounter = 0.01 * round (100 * ((_source getVariable [QGVAR(fuelCounter), _currentFuel]) - _currentFuel));
[[LSTRING(Hint_FuelCounter), _fuelCounter], 1.5, _unit] call EFUNC(common,displayTextStructured); [[LSTRING(Hint_FuelCounter), _fuelCounter], 1.5, _unit] call EFUNC(common,displayTextStructured);
}; };
}, },
"", "",
localize LSTRING(CheckFuelCounterAction), localize LSTRING(CheckFuelCounterAction),
{true}, {true},
["isnotinside"] [INTERACT_EXCEPTIONS]
] call EFUNC(common,progressBar); ] call EFUNC(common,progressBar);

View File

@ -4,7 +4,7 @@
* *
* Arguments: * Arguments:
* 0: Unit <OBJECT> * 0: Unit <OBJECT>
* 1: Target <OBJECT> * 1: Vehicle <OBJECT>
* 2: Nozzle <OBJECT> * 2: Nozzle <OBJECT>
* 3: Connection Point <ARRAY> * 3: Connection Point <ARRAY>
* *
@ -19,9 +19,9 @@
#include "script_component.hpp" #include "script_component.hpp"
params [["_unit", objNull, [objNull]], ["_target", objNull, [objNull]], ["_nozzle", objNull, [objNull]], ["_connectToPoint", [0,0,0], [[]], 3]]; params [["_unit", objNull, [objNull]], ["_sink", objNull, [objNull]], ["_nozzle", objNull, [objNull]], ["_connectToPoint", [0,0,0], [[]], 3]];
private _config = configFile >> "CfgVehicles" >> typeOf _target; private _config = configFile >> "CfgVehicles" >> typeOf _sink;
private _rate = getNumber (_config >> QGVAR(flowRate)) * GVAR(rate); private _rate = getNumber (_config >> QGVAR(flowRate)) * GVAR(rate);
private _maxFuel = getNumber (_config >> QGVAR(fuelCapacity)); private _maxFuel = getNumber (_config >> QGVAR(fuelCapacity));
@ -43,8 +43,8 @@ if (_maxFuel == 0) then {
if (!alive _source || {!alive _sink}) exitWith { if (!alive _source || {!alive _sink}) exitWith {
[objNull, _nozzle] call FUNC(dropNozzle); [objNull, _nozzle] call FUNC(dropNozzle);
_nozzle setVariable [QGVAR(isConnected), false, true]; _nozzle setVariable [QGVAR(isConnected), false, true];
_nozzle setVariable [QGVAR(sink), objNull, true]; _nozzle setVariable [QGVAR(sink), nil, true];
_sink setVariable [QGVAR(nozzle), objNull, true]; _sink setVariable [QGVAR(nozzle), nil, true];
[_pfID] call CBA_fnc_removePerFrameHandler; [_pfID] call CBA_fnc_removePerFrameHandler;
}; };
private _hoseLength = _source getVariable [QGVAR(hoseLength), GVAR(hoseLength)]; private _hoseLength = _source getVariable [QGVAR(hoseLength), GVAR(hoseLength)];
@ -54,8 +54,8 @@ if (_maxFuel == 0) then {
[objNull, _nozzle] call FUNC(dropNozzle); [objNull, _nozzle] call FUNC(dropNozzle);
_nozzle setVariable [QGVAR(isConnected), false, true]; _nozzle setVariable [QGVAR(isConnected), false, true];
_nozzle setVariable [QGVAR(sink), objNull, true]; _nozzle setVariable [QGVAR(sink), nil, true];
_sink setVariable [QGVAR(nozzle), objNull, true]; _sink setVariable [QGVAR(nozzle), nil, true];
[_pfID] call CBA_fnc_removePerFrameHandler; [_pfID] call CBA_fnc_removePerFrameHandler;
}; };
@ -108,11 +108,11 @@ if (_maxFuel == 0) then {
}; };
}, 1, [ }, 1, [
_nozzle getVariable QGVAR(source), _nozzle getVariable QGVAR(source),
_target, _sink,
_unit, _unit,
_nozzle, _nozzle,
_rate, _rate,
fuel _target, fuel _sink,
_maxFuel, _maxFuel,
_nozzle getVariable [QGVAR(attachPos), [0,0,0]], _nozzle getVariable [QGVAR(attachPos), [0,0,0]],
_connectToPoint _connectToPoint

View File

@ -1,44 +0,0 @@
/*
* Author: GitHawk
* Resets a fuel vehicle in case is got bugged
*
* Arguments:
* 0: Fuel truck <OBJECT>
*
* Return Value:
* None
*
* Example:
* [truck] call ace_refuel_fnc_reset
*
* Public: Yes
*/
#include "script_component.hpp"
params [["_target", objNull, [objNull]]];
[_target, "blockEngine", "ACE_Refuel", false] call EFUNC(common,statusEffect_set);
_target setVariable [QGVAR(isConnected), false, true];
private _nozzle = _target getVariable [QGVAR(ownedNozzle), nil];
if !(isNil "_nozzle") then {
private _nozzleTarget = _nozzle getVariable [QGVAR(sink), nil];
if !(isNil "_nozzleTarget") then {
_nozzleTarget setVariable [QGVAR(nozzle), nil, true];
};
private _rope = _nozzle getVariable [QGVAR(rope), objNull];
if !(isNull _rope) then {
ropeDestroy _rope;
};
private _helper = _nozzle getVariable [QGVAR(helper), objNull];
if !(isNull _helper) then {
deleteVehicle _helper;
};
{
[QGVAR(resetLocal), [_x, _nozzle], _x] call CBA_fnc_targetEvent;
} count allPlayers;
deleteVehicle _nozzle;
};
_target setVariable [QGVAR(ownedNozzle), nil, true];

View File

@ -1,36 +0,0 @@
/*
* Author: GitHawk
* Resets a player
*
* Arguments:
* 0: Fuel nozzle <OBJECT>
*
* Return Value:
* None
*
* Example:
* [nozzle] call ace_refuel_fnc_resetLocal
*
* Public: No
*/
#include "script_component.hpp"
params [["_unit", objNull, [objNull]], ["_nozzle", objNull, [objNull]]];
if (isNull _unit ||
{isNull _nozzle} ||
{!(_unit isKindOf "CAManBase")} ||
{!local _unit}) exitWith {};
private _attachedNozzle = _unit getVariable [QGVAR(nozzle), nil];
if (isNil "_attachedNozzle") exitWith {};
if (_nozzle != _attachedNozzle) exitWith {};
private _actionID = _unit getVariable [QGVAR(ReleaseActionID), -1];
if (_actionID != -1) then {
_unit removeAction _actionID;
_unit setVariable [QGVAR(isRefueling), false, true];
_unit setVariable [QGVAR(ReleaseActionID), nil];
_unit setVariable [QGVAR(nozzle), nil, true];
};

View File

@ -4,10 +4,10 @@
* *
* Arguments: * Arguments:
* 0: Unit <OBJECT> * 0: Unit <OBJECT>
* 1: Fuel Truck <OBJECT> * 1: Fuel Source <OBJECT>
* *
* Return Value: * Return Value:
* Returned Nozzle <BOOL> * None
* *
* Example: * Example:
* [player, fuelTruck] call ace_refuel_fnc_returnNozzle * [player, fuelTruck] call ace_refuel_fnc_returnNozzle
@ -16,32 +16,24 @@
*/ */
#include "script_component.hpp" #include "script_component.hpp"
params [["_unit", objNull, [objNull]], ["_target", objNull, [objNull]]]; params [["_unit", objNull, [objNull]], ["_source", objNull, [objNull]]];
private _nozzle = _unit getVariable [QGVAR(nozzle), objNull]; private _nozzle = _unit getVariable [QGVAR(nozzle), objNull];
private _source = _nozzle getVariable QGVAR(source);
if (isNull _nozzle || {_source != _target}) exitWith {false}; if (isNull _nozzle || {_source != _nozzle getVariable QGVAR(source)}) exitWith {};
[ [
TIME_PROGRESSBAR(REFUEL_PROGRESS_DURATION), TIME_PROGRESSBAR(REFUEL_PROGRESS_DURATION),
[_unit, _nozzle, _target], [_unit, _nozzle, _source],
{ {
params ["_args"]; params ["_args"];
_args params [["_unit", objNull, [objNull]], ["_nozzle", objNull, [objNull]], ["_target", objNull, [objNull]]]; _args params [["_unit", objNull, [objNull]], ["_nozzle", objNull, [objNull]], ["_source", objNull, [objNull]]];
_unit setVariable [QGVAR(nozzle), nil, true]; _unit setVariable [QGVAR(nozzle), nil, true];
detach _nozzle; detach _nozzle;
[_unit, "forceWalk", "ACE_refuel", false] call EFUNC(common,statusEffect_set);
REFUEL_UNHOLSTER_WEAPON
_unit setVariable [QGVAR(isRefueling), false]; _unit setVariable [QGVAR(isRefueling), false];
private _actionID = _unit getVariable [QGVAR(ReleaseActionID), -1];
if (_actionID != -1) then {
_unit removeAction _actionID;
_unit setVariable [QGVAR(ReleaseActionID), nil];
};
_target setVariable [QGVAR(isConnected), false, true]; _source setVariable [QGVAR(isConnected), false, true];
_target setVariable [QGVAR(ownedNozzle), nil, true]; _source setVariable [QGVAR(ownedNozzle), nil, true];
private _rope = _nozzle getVariable [QGVAR(rope), objNull]; private _rope = _nozzle getVariable [QGVAR(rope), objNull];
if !(isNull _rope) then { if !(isNull _rope) then {
ropeDestroy _rope; ropeDestroy _rope;
@ -52,12 +44,10 @@ if (isNull _nozzle || {_source != _target}) exitWith {false};
}; };
deleteVehicle _nozzle; deleteVehicle _nozzle;
[_target, "blockEngine", "ACE_Refuel", false] call EFUNC(common,statusEffect_set); [_source, "blockEngine", "ACE_Refuel", false] call EFUNC(common,statusEffect_set);
}, },
"", "",
localize LSTRING(ReturnAction), localize LSTRING(ReturnAction),
{true}, {true},
["isnotinside"] [INTERACT_EXCEPTIONS]
] call EFUNC(common,progressBar); ] call EFUNC(common,progressBar);
true

View File

@ -3,7 +3,7 @@
* Set the remaining fuel amount. * Set the remaining fuel amount.
* *
* Arguments: * Arguments:
* 0: Fuel Truck <OBJECT> * 0: Fuel Source <OBJECT>
* 1: Amount (in liters)<NUMBER> * 1: Amount (in liters)<NUMBER>
* *
* Return Value: * Return Value:
@ -16,9 +16,9 @@
*/ */
#include "script_component.hpp" #include "script_component.hpp"
params [["_target", objNull, [objNull]], ["_fuel", nil, [0]]]; params [["_source", objNull, [objNull]], ["_fuel", nil, [0]]];
if (isNull _target || if (isNull _source ||
{isNil "_fuel"}) exitWith {}; {isNil "_fuel"}) exitWith {};
_target setVariable [QGVAR(currentFuelCargo), _fuel, true]; _source setVariable [QGVAR(currentFuelCargo), _fuel, true];

View File

@ -0,0 +1,113 @@
/*
* Author: Dystopian
* PFH while nozzle is in hands.
*
* Arguments:
* 0: Unit <OBJECT>
* 1: Nozzle <OBJECT>
*
* Return Value:
* None
*
* Example:
* [player, nozzle] call ace_refuel_fnc_startNozzleInHandsPFH
*
* Public: No
*/
#include "script_component.hpp"
#define DROP_NOZZLE [_unit, _nozzle] call FUNC(dropNozzle);
#define UNHOLSTER_WEAPON \
_unit selectWeapon (_unit getVariable QGVAR(selectedWeaponOnRefuel)); \
_unit setVariable [QGVAR(selectedWeaponOnRefuel), nil];
#define END_PFH \
_unit setVariable [QGVAR(hint), nil]; \
call EFUNC(interaction,hideMouseHint); \
[_unit, "forceWalk", "ACE_refuel", false] call EFUNC(common,statusEffect_set); \
[_idPFH] call CBA_fnc_removePerFrameHandler;
params ["_unit", "_nozzle"];
TRACE_2("start",_unit,_nozzle);
[{
params ["_args", "_idPFH"];
_args params ["_unit", "_nozzle"];
if !(
alive _unit
&& {"" isEqualTo currentWeapon _unit}
&& {[_unit, objNull, [INTERACT_EXCEPTIONS, "notOnMap"]] call EFUNC(common,canInteractWith)}
&& {!("unconscious" isEqualTo toLower animationState _unit)}
&& {!(_unit getVariable ["ACE_isUnconscious", false])}
) exitWith {
TRACE_3("stop dead/weapon/interact/uncon",_unit,alive _unit,currentWeapon _unit);
DROP_NOZZLE
_unit setVariable [QGVAR(selectedWeaponOnRefuel), nil];
END_PFH
};
// check drop from external events
if (isNull (_unit getVariable [QGVAR(nozzle), objNull])) exitWith {
TRACE_2("stop drop",_unit,_nozzle);
UNHOLSTER_WEAPON
END_PFH
};
private _source = _nozzle getVariable [QGVAR(source), objNull];
if !(alive _source) exitWith {
TRACE_3("stop source",_unit,_nozzle,_source);
DROP_NOZZLE
private _rope = _nozzle getVariable [QGVAR(rope), objNull];
if !(isNull _rope) then {
ropeDestroy _rope;
};
private _helper = _nozzle getVariable [QGVAR(helper), objNull];
if !(isNull _helper) then {
deleteVehicle _helper;
};
deleteVehicle _nozzle;
UNHOLSTER_WEAPON
END_PFH
};
if !(_unit == vehicle _unit && {_unit isEqualTo ACE_player}) exitWith {
TRACE_1("stop vehicle/player",_unit,vehicle _unit);
DROP_NOZZLE
UNHOLSTER_WEAPON
END_PFH
};
// check hoseLength < distance
if (
!(_nozzle getVariable [QGVAR(jerryCan), false])
&& {((_source getVariable [QGVAR(hoseLength), GVAR(hoseLength)]) - 2) < _unit distance (_source modelToWorld (_nozzle getVariable QGVAR(attachPos)))}
) exitWith {
TRACE_1("stop length",_unit);
DROP_NOZZLE
UNHOLSTER_WEAPON
END_PFH
[LSTRING(Hint_TooFar), 2, _unit] call EFUNC(common,displayTextStructured);
};
private _hintLMB = "";
private _hintRMB = localize ELSTRING(dragging,Drop);
getCursorObjectParams params ["_cursorObject", "", "_distance"];
if (!isNull _cursorObject && {_distance < REFUEL_NOZZLE_ACTION_DISTANCE}) then {
if (
1 == getNumber (configFile >> "CfgVehicles" >> (typeOf _cursorObject) >> QGVAR(canReceive))
&& {isNull (_cursorObject getVariable [QGVAR(nozzle), objNull])}
) then {
_hintLMB = localize LSTRING(Connect);
};
if ([_unit, _cursorObject] call FUNC(canReturnNozzle)) then {
_hintRMB = localize LSTRING(Return);
};
};
private _hint = [_hintLMB, _hintRMB];
if !(_hint isEqualTo (_unit getVariable [QGVAR(hint), []])) then {
_unit setVariable [QGVAR(hint), _hint];
_hint call EFUNC(interaction,showMouseHint);
};
}, 0, [_unit, _nozzle]] call cba_fnc_addPerFrameHandler;

View File

@ -4,15 +4,13 @@
* *
* Arguments: * Arguments:
* 0: Unit <OBJECT> * 0: Unit <OBJECT>
* 1: Fuel Truck <OBJECT> * 1: Fuel Source or Nozzle <OBJECT>
* 2: Nozzle <OBJECT> (optional)
* *
* Return Value: * Return Value:
* None * None
* *
* Example: * Example:
* [player, fuelTruck] call ace_refuel_fnc_takeNozzle * [player, cursorObject] call ace_refuel_fnc_takeNozzle
* [player, objNull, nozzle] call ace_refuel_fnc_takeNozzle
* *
* Public: No * Public: No
*/ */
@ -20,133 +18,81 @@
params [ params [
["_unit", objNull, [objNull]], ["_unit", objNull, [objNull]],
["_target", objNull, [objNull]], ["_object", objNull, [objNull]]
["_nozzle", objNull, [objNull]]
]; ];
REFUEL_HOLSTER_WEAPON [
TIME_PROGRESSBAR(REFUEL_PROGRESS_DURATION),
[_unit, _object],
{
params ["_args"];
_args params ["_unit", "_object"];
private _endPosOffset = [0, 0, 0]; if !([_unit, _object] call FUNC(canTakeNozzle)) exitWith {};
if (isNull _nozzle) then { // func is called on fuel truck
_endPosOffset = getArray (configFile >> "CfgVehicles" >> typeOf _target >> QGVAR(hooks));
if (count _endPosOffset == 2) then {
if (_unit distance (_target modelToWorld (_endPosOffset select 0)) < _unit distance (_target modelToWorld (_endPosOffset select 1))) then {
_endPosOffset = _endPosOffset select 0;
} else {
_endPosOffset = _endPosOffset select 1;
};
} else {
_endPosOffset = _endPosOffset select 0;
};
[
TIME_PROGRESSBAR(REFUEL_PROGRESS_DURATION),
[_unit, _target, _endPosOffset],
{
params ["_args"];
_args params [
["_unit", objNull, [objNull]],
["_target", objNull, [objNull]],
["_endPosOffset", [0, 0, 0], [[]], 3]
];
private _newNozzle = QGVAR(fuelNozzle) createVehicle position _unit;
_newNozzle attachTo [_unit, [-0.02,0.05,-0.12], "righthandmiddle1"];
_unit setVariable [QGVAR(nozzle), _newNozzle, true];
private _ropeTarget = _target;
if (!(_target isKindOf "AllVehicles")) then {
private _helper = QGVAR(helper) createVehicle [0,0,0];
[QEGVAR(common,hideObjectGlobal), [_helper, true]] call CBA_fnc_serverEvent;
if ((getText (configFile >> "CfgVehicles" >> typeOf _target >> "simulation")) isEqualTo "thingX") then {
_helper attachTo [_target, [0,0,0]];
} else {
_helper setPosWorld (getPosWorld _target);
_helper setDir (getDir _target);
_helper setVectorUp (vectorUp _target);
};
_newNozzle setVariable [QGVAR(helper), _helper, true];
_ropeTarget = _helper;
};
private _hoseLength = _target getVariable [QGVAR(hoseLength), GVAR(hoseLength)];
private _rope = ropeCreate [_ropeTarget, _endPosOffset, _newNozzle, [0, -0.20, 0.12], _hoseLength];
_newNozzle setVariable [QGVAR(rope), _rope, true];
_newNozzle setVariable [QGVAR(attachPos), _endPosOffset, true];
_newNozzle setVariable [QGVAR(source), _target, true];
[_target, "blockEngine", "ACE_Refuel", true] call EFUNC(common,statusEffect_set);
_target setVariable [QGVAR(isConnected), true, true];
_target setVariable [QGVAR(ownedNozzle), _newNozzle, true];
[_unit, "forceWalk", "ACE_refuel", true] call EFUNC(common,statusEffect_set);
_unit setVariable [QGVAR(isRefueling), true];
private _actionID = _unit getVariable [QGVAR(ReleaseActionID), -1];
if (_actionID != -1) then {
_unit removeAction _actionID;
};
_actionID = _unit addAction [
format ["<t color='#FF0000'>%1</t>", localize ELSTRING(dragging,Drop)],
'_unit = _this select 0; _nozzle = _unit getVariable QGVAR(nozzle); [_unit, _nozzle] call FUNC(dropNozzle); [_unit, "forceWalk", "ACE_refuel", false] call EFUNC(common,statusEffect_set); REFUEL_UNHOLSTER_WEAPON',
nil,
20,
false,
true,
"",
'!isNull (_target getVariable [QGVAR(nozzle), objNull])'
];
_unit setVariable [QGVAR(ReleaseActionID), _actionID];
// Drop nozzle at maximum hose distance
[_unit, _target, _endPosOffset, _nozzle] call FUNC(maxDistanceDropNozzle);
},
"",
localize LSTRING(TakeNozzleAction),
{true},
["isnotinside"]
] call EFUNC(common,progressBar);
} else { // func is called on muzzle either connected or on ground
[
TIME_PROGRESSBAR(REFUEL_PROGRESS_DURATION),
[_unit, _nozzle],
{
params ["_args"];
_args params [
["_unit", objNull, [objNull]],
["_nozzle", objNull, [objNull]]
];
private _source = _object;
private _nozzle = _object;
if (typeOf _object isEqualTo QGVAR(fuelNozzle) || {_object getVariable [QGVAR(jerryCan), false]}) then { // func is called on muzzle either connected or on ground
_source = _nozzle getVariable QGVAR(source);
if (_nozzle getVariable [QGVAR(jerryCan), false]) then { if (_nozzle getVariable [QGVAR(jerryCan), false]) then {
_nozzle attachTo [_unit, [0,1,0], "pelvis"]; _nozzle attachTo [_unit, [0,1,0], "pelvis"];
} else { } else {
_nozzle attachTo [_unit, [-0.02,0.05,-0.12], "righthandmiddle1"]; _nozzle attachTo [_unit, [-0.02,0.05,-0.12], "righthandmiddle1"];
}; };
_unit setVariable [QGVAR(nozzle), _nozzle, true]; } else { // func is called on fuel truck
_nozzle = QGVAR(fuelNozzle) createVehicle [0,0,0];
_nozzle attachTo [_unit, [-0.02,0.05,-0.12], "righthandmiddle1"];
[_unit, "forceWalk", "ACE_refuel", true] call EFUNC(common,statusEffect_set); private _ropeTarget = _source;
_unit setVariable [QGVAR(isRefueling), true]; if !(_source isKindOf "AllVehicles") then {
private _actionID = _unit getVariable [QGVAR(ReleaseActionID), -1]; private _helper = QGVAR(helper) createVehicle [0,0,0];
if (_actionID != -1) then { [QEGVAR(common,hideObjectGlobal), [_helper, true]] call CBA_fnc_serverEvent;
_unit removeAction _actionID; if ((getText (configFile >> "CfgVehicles" >> typeOf _source >> "simulation")) isEqualTo "thingX") then {
_helper attachTo [_source, [0,0,0]];
} else {
_helper setPosWorld (getPosWorld _source);
_helper setDir (getDir _source);
_helper setVectorUp (vectorUp _source);
};
_nozzle setVariable [QGVAR(helper), _helper, true];
_ropeTarget = _helper;
}; };
_actionID = _unit addAction [ private _attachPos = _source getVariable [QGVAR(hooks), getArray (configFile >> "CfgVehicles" >> typeOf _source >> QGVAR(hooks))];
format ["<t color='#FF0000'>%1</t>", localize ELSTRING(dragging,Drop)], if (_attachPos isEqualTo []) then {
'_unit = _this select 0; _nozzle = _unit getVariable QGVAR(nozzle); [_unit, _nozzle] call FUNC(dropNozzle); [_unit, "forceWalk", "ACE_refuel", false] call EFUNC(common,statusEffect_set); REFUEL_UNHOLSTER_WEAPON', _attachPos = [[0,0,0]];
nil, };
20, if (count _attachPos == 1) then {
false, _attachPos = _attachPos select 0;
true, } else {
"", // select closest hook
'!isNull (_target getVariable [QGVAR(nozzle), objNull])' private _hookDistances = _attachPos apply {_unit distance (_source modelToWorld _x)};
]; _attachPos = _attachPos select (_hookDistances find selectMin _hookDistances);
_unit setVariable [QGVAR(ReleaseActionID), _actionID]; };
private _hoseLength = _source getVariable [QGVAR(hoseLength), GVAR(hoseLength)];
private _rope = ropeCreate [_ropeTarget, _attachPos, _nozzle, [0, -0.20, 0.12], _hoseLength];
_nozzle setVariable [QGVAR(rope), _rope, true];
_nozzle setVariable [QGVAR(attachPos), _attachPos, true];
_nozzle setVariable [QGVAR(source), _source, true];
// Drop nozzle at maximum hose distance [_source, "blockEngine", "ACE_Refuel", true] call EFUNC(common,statusEffect_set);
private _target = _nozzle getVariable QGVAR(source); _source setVariable [QGVAR(isConnected), true, true];
private _endPosOffset = _nozzle getVariable QGVAR(attachPos); _source setVariable [QGVAR(ownedNozzle), _nozzle, true];
[_unit, _target, _endPosOffset, _nozzle] call FUNC(maxDistanceDropNozzle); };
},
"", _unit setVariable [QGVAR(nozzle), _nozzle, true];
localize LSTRING(TakeNozzleAction), _unit setVariable [QGVAR(isRefueling), true];
{true},
["isnotinside"] // holster weapon
] call EFUNC(common,progressBar); _unit setVariable [QGVAR(selectedWeaponOnRefuel), currentWeapon _unit];
}; _unit call EFUNC(common,fixLoweredRifleAnimation);
_unit action ["SwitchWeapon", _unit, _unit, 299];
[_unit, "forceWalk", "ACE_refuel", true] call EFUNC(common,statusEffect_set);
[_unit, _nozzle] call FUNC(startNozzleInHandsPFH);
},
{},
localize LSTRING(TakeNozzleAction),
{true},
["isNotInside", "isNotOnLadder"]
] call EFUNC(common,progressBar);

View File

@ -31,5 +31,5 @@ params [["_unit", objNull, [objNull]], ["_nozzle", objNull, [objNull]]];
"", "",
localize LSTRING(TurnOffAction), localize LSTRING(TurnOffAction),
{true}, {true},
["isnotinside"] [INTERACT_EXCEPTIONS]
] call EFUNC(common,progressBar); ] call EFUNC(common,progressBar);

View File

@ -31,5 +31,5 @@ params [["_unit", objNull, [objNull]], ["_nozzle", objNull, [objNull]]];
"", "",
localize LSTRING(TurnOnAction), localize LSTRING(TurnOnAction),
{true}, {true},
["isnotinside"] [INTERACT_EXCEPTIONS]
] call EFUNC(common,progressBar); ] call EFUNC(common,progressBar);

View File

@ -19,21 +19,15 @@
#include "\z\ace\addons\main\script_macros.hpp" #include "\z\ace\addons\main\script_macros.hpp"
#define REFUEL_INFINITE_FUEL -10 #define REFUEL_INFINITE_FUEL -10
#define REFUEL_DISABLED_FUEL -1
#define REFUEL_ACTION_DISTANCE 7 #define REFUEL_ACTION_DISTANCE 7
#define REFUEL_NOZZLE_ACTION_DISTANCE 2
#define REFUEL_PROGRESS_DURATION 2 #define REFUEL_PROGRESS_DURATION 2
#define REFUEL_HOLSTER_WEAPON \
_unit setVariable [QGVAR(selectedWeaponOnRefuel), currentWeapon _unit]; \
_unit call EFUNC(common,fixLoweredRifleAnimation); \
_unit action ["SwitchWeapon", _unit, _unit, 299];
#define REFUEL_UNHOLSTER_WEAPON \
_weaponSelect = _unit getVariable QGVAR(selectedWeaponOnRefuel); \
_unit selectWeapon _weaponSelect; \
_unit setVariable [QGVAR(selectedWeaponOnRefuel), nil];
#ifdef FAST_PROGRESSBARS #ifdef FAST_PROGRESSBARS
#define TIME_PROGRESSBAR(X) ((X) * 0.075) #define TIME_PROGRESSBAR(X) ((X) * 0.075)
#else #else
#define TIME_PROGRESSBAR(X) (X) #define TIME_PROGRESSBAR(X) (X)
#endif #endif
#define INTERACT_EXCEPTIONS "isNotInside", "isNotOnLadder", "isNotRefueling"

View File

@ -476,5 +476,22 @@
<Chinese>加油軟管長度</Chinese> <Chinese>加油軟管長度</Chinese>
<Polish>Długość węża paliwowego</Polish> <Polish>Długość węża paliwowego</Polish>
</Key> </Key>
<Key ID="STR_ACE_Refuel_fuelCargo_edenName">
<English>Fuel Cargo Volume</English>
<Russian>Объем топлива для заправки</Russian>
</Key>
<!-- REFUEL_INFINITE_FUEL, REFUEL_DISABLED_FUEL are used here -->
<Key ID="STR_ACE_Refuel_fuelCargo_edenDesc">
<English>The fuel volume available for refueling (-1 disable, -10 if infinite)</English>
<Russian>Объем топлива, доступный для заправки других машин (-1 отключить, -10 если неограничен)</Russian>
</Key>
<Key ID="STR_ACE_Refuel_hooks_edenName">
<English>Refuel Hose attach coordinates</English>
<Russian>Координаты крепления шланга</Russian>
</Key>
<Key ID="STR_ACE_Refuel_hooks_edenDesc">
<English>Model coordinates used to attach refuel hose</English>
<Russian>Координаты модели, куда крепится заправочный шланг</Russian>
</Key>
</Package> </Package>
</Project> </Project>

View File

@ -62,9 +62,6 @@ While refueling, you can't move the fuel truck. Return the nozzle.
### How do I replenish the fuel supply on a fuel truck? ### How do I replenish the fuel supply on a fuel truck?
Please check the framework description for more details. Please check the framework description for more details.
### Something broke, I can't use the fuel truck / nozzle any longer. What to do?
You can reset the fuel truck and its nozzle by calling `ace_refuel_fnc_reset` with its first parameter being the fuel truck object.
### How do I increase the length of the hose? ### How do I increase the length of the hose?
There is a global setting that will effect all vehicles and static pumps. To only effect a specific vehicle put the following in it's init box: There is a global setting that will effect all vehicles and static pumps. To only effect a specific vehicle put the following in it's init box:
```cpp ```cpp

View File

@ -77,26 +77,7 @@ The jerry can will have the default 20 liters volume.
The jerry can will now have a volume of 200 liters. The jerry can will now have a volume of 200 liters.
### 2.3 Reset a broken fuel truck ### 2.3 Setting the fuel supply
`ace_refuel_fnc_reset`
| Arguments | Type | Optional (default value)
---| --------- | ---- | ------------------------
0 | Fuel Truck | Object | Required
**R** | None | None | Return value
#### 2.3.1 Example
`[truck] call ace_refuel_fnc_reset;`
| Arguments | Explanation
---| --------- | -----------
0 | `truck` | My object
This function will try to reset the fuel truck to a pristine state.
### 2.4 Setting the fuel supply
`ace_refuel_fnc_setFuel` `ace_refuel_fnc_setFuel`
@ -106,7 +87,7 @@ This function will try to reset the fuel truck to a pristine state.
1 | Amount (in liters) | Number | Required 1 | Amount (in liters) | Number | Required
**R** | None | None | Return value **R** | None | None | Return value
#### 2.4.1 Example #### 2.3.1 Example
`[fuelTruck, 428] call ace_refuel_fnc_setFuel;` `[fuelTruck, 428] call ace_refuel_fnc_setFuel;`

View File

@ -1,53 +1,3 @@
#define MACRO_REFUEL_ACTIONS \
class ACE_Actions: ACE_Actions { \
class ACE_MainActions: ACE_MainActions { \
class EGVAR(refuel,Refuel) { \
displayName = ECSTRING(refuel,Refuel); \
distance = 7; \
condition = "alive _target"; \
statement = ""; \
showDisabled = 0; \
priority = 2; \
icon = QPATHTOEF(refuel,ui\icon_refuel_interact.paa); \
class EGVAR(refuel,TakeNozzle) { \
displayName = ECSTRING(refuel,TakeNozzle); \
condition = QUOTE([ARR_2(_player,_target)] call EFUNC(refuel,canTakeNozzle)); \
statement = QUOTE([ARR_3(_player,_target,objNull)] call EFUNC(refuel,TakeNozzle)); \
exceptions[] = {"isNotInside"}; \
icon = QPATHTOEF(refuel,ui\icon_refuel_interact.paa); \
}; \
class EGVAR(refuel,CheckFuelCounter) { \
displayName = ECSTRING(refuel,CheckFuelCounter); \
condition = "true"; \
statement = QUOTE([ARR_2(_player,_target)] call EFUNC(refuel,readFuelCounter)); \
exceptions[] = {"isNotInside"}; \
icon = QPATHTOEF(refuel,ui\icon_refuel_interact.paa); \
}; \
class EGVAR(refuel,CheckFuel) { \
displayName = ECSTRING(refuel,CheckFuel); \
condition = QUOTE([ARR_2(_player,_target)] call EFUNC(refuel,canCheckFuel)); \
statement = QUOTE([ARR_2(_player,_target)] call EFUNC(refuel,checkFuel)); \
exceptions[] = {"isNotInside"}; \
icon = QPATHTOEF(refuel,ui\icon_refuel_interact.paa); \
}; \
class EGVAR(refuel,Connect) { \
displayName = ECSTRING(refuel,Connect); \
condition = QUOTE([ARR_2(_player,_target)] call EFUNC(refuel,canConnectNozzle)); \
statement = QUOTE([ARR_2(_player,_target)] call DEFUNC(refuel,connectNozzle)); \
exceptions[] = {"isNotInside"}; \
icon = QPATHTOEF(refuel,ui\icon_refuel_interact.paa); \
}; \
class EGVAR(refuel,Return) { \
displayName = ECSTRING(refuel,Return); \
condition = QUOTE([ARR_2(_player,_target)] call EFUNC(refuel,canReturnNozzle)); \
statement = QUOTE([ARR_2(_player,_target)] call DEFUNC(refuel,returnNozzle)); \
exceptions[] = {"isNotInside"}; \
icon = QPATHTOEF(refuel,ui\icon_refuel_interact.paa); \
}; \
}; \
}; \
};
class CfgVehicles { class CfgVehicles {
class LandVehicle; class LandVehicle;
class Tank: LandVehicle { class Tank: LandVehicle {
@ -371,7 +321,6 @@ class CfgVehicles {
class RHS_Ural_Support_MSV_Base_01: RHS_Ural_MSV_Base {}; class RHS_Ural_Support_MSV_Base_01: RHS_Ural_MSV_Base {};
class RHS_Ural_Fuel_MSV_01: RHS_Ural_Support_MSV_Base_01 { class RHS_Ural_Fuel_MSV_01: RHS_Ural_Support_MSV_Base_01 {
transportFuel = 0; transportFuel = 0;
MACRO_REFUEL_ACTIONS
EGVAR(refuel,hooks)[] = {{-0.05,-3.6,-0.45}}; EGVAR(refuel,hooks)[] = {{-0.05,-3.6,-0.45}};
EGVAR(refuel,fuelCargo) = 10000; EGVAR(refuel,fuelCargo) = 10000;
}; };

View File

@ -11,56 +11,6 @@
}; \ }; \
} }
#define MACRO_REFUEL_ACTIONS \
class ACE_Actions: ACE_Actions { \
class ACE_MainActions: ACE_MainActions { \
class EGVAR(refuel,Refuel) { \
displayName = ECSTRING(refuel,Refuel); \
distance = 7; \
condition = "alive _target"; \
statement = ""; \
showDisabled = 0; \
priority = 2; \
icon = QPATHTOEF(refuel,ui\icon_refuel_interact.paa); \
class EGVAR(refuel,TakeNozzle) { \
displayName = ECSTRING(refuel,TakeNozzle); \
condition = QUOTE([ARR_2(_player,_target)] call EFUNC(refuel,canTakeNozzle)); \
statement = QUOTE([ARR_3(_player,_target,objNull)] call EFUNC(refuel,TakeNozzle)); \
exceptions[] = {"isNotInside"}; \
icon = QPATHTOEF(refuel,ui\icon_refuel_interact.paa); \
}; \
class EGVAR(refuel,CheckFuelCounter) { \
displayName = ECSTRING(refuel,CheckFuelCounter); \
condition = "true"; \
statement = QUOTE([ARR_2(_player,_target)] call EFUNC(refuel,readFuelCounter)); \
exceptions[] = {"isNotInside"}; \
icon = QPATHTOEF(refuel,ui\icon_refuel_interact.paa); \
}; \
class EGVAR(refuel,CheckFuel) { \
displayName = ECSTRING(refuel,CheckFuel); \
condition = QUOTE([ARR_2(_player,_target)] call EFUNC(refuel,canCheckFuel)); \
statement = QUOTE([ARR_2(_player,_target)] call EFUNC(refuel,checkFuel)); \
exceptions[] = {"isNotInside"}; \
icon = QPATHTOEF(refuel,ui\icon_refuel_interact.paa); \
}; \
class EGVAR(refuel,Connect) { \
displayName = ECSTRING(refuel,Connect); \
condition = QUOTE([ARR_2(_player,_target)] call EFUNC(refuel,canConnectNozzle)); \
statement = QUOTE([ARR_2(_player,_target)] call DEFUNC(refuel,connectNozzle)); \
exceptions[] = {"isNotInside"}; \
icon = QPATHTOEF(refuel,ui\icon_refuel_interact.paa); \
}; \
class EGVAR(refuel,Return) { \
displayName = ECSTRING(refuel,Return); \
condition = QUOTE([ARR_2(_player,_target)] call EFUNC(refuel,canReturnNozzle)); \
statement = QUOTE([ARR_2(_player,_target)] call DEFUNC(refuel,returnNozzle)); \
exceptions[] = {"isNotInside"}; \
icon = QPATHTOEF(refuel,ui\icon_refuel_interact.paa); \
}; \
}; \
}; \
};
class CfgVehicles { class CfgVehicles {
class LandVehicle; class LandVehicle;
class Car: LandVehicle { class Car: LandVehicle {
@ -310,14 +260,12 @@ class CfgVehicles {
class rhsusf_M978A4_usarmy_wd: rhsusf_M977A4_usarmy_wd { class rhsusf_M978A4_usarmy_wd: rhsusf_M977A4_usarmy_wd {
transportFuel = 0; transportFuel = 0;
MACRO_REFUEL_ACTIONS
EGVAR(refuel,hooks)[] = {{-0.44,-4.87,0}, {0.5,-4.87,0}}; EGVAR(refuel,hooks)[] = {{-0.44,-4.87,0}, {0.5,-4.87,0}};
EGVAR(refuel,fuelCargo) = 10000; EGVAR(refuel,fuelCargo) = 10000;
}; };
class rhsusf_M978A4_BKIT_usarmy_wd: rhsusf_M977A4_usarmy_wd { class rhsusf_M978A4_BKIT_usarmy_wd: rhsusf_M977A4_usarmy_wd {
transportFuel = 0; transportFuel = 0;
MACRO_REFUEL_ACTIONS
EGVAR(refuel,hooks)[] = {{-0.44,-4.87,0}, {0.5,-4.87,0}}; EGVAR(refuel,hooks)[] = {{-0.44,-4.87,0}, {0.5,-4.87,0}};
EGVAR(refuel,fuelCargo) = 10000; EGVAR(refuel,fuelCargo) = 10000;
}; };