mirror of
https://github.com/acemod/ACE3.git
synced 2024-08-30 18:23:18 +00:00
Added reset
It's now possible to reset a fuel truck by console command: [fuel_truck] call ace_refuel_fnc_reset
This commit is contained in:
parent
113ac0f370
commit
931c6830fc
@ -74,7 +74,7 @@
|
|||||||
class ACE_Actions { \
|
class ACE_Actions { \
|
||||||
class ACE_MainActions { \
|
class ACE_MainActions { \
|
||||||
displayName = CSTRING(Refuel); \
|
displayName = CSTRING(Refuel); \
|
||||||
distance = 3; \
|
distance = REFUEL_ACTION_DISTANCE; \
|
||||||
condition = "true"; \
|
condition = "true"; \
|
||||||
statement = ""; \
|
statement = ""; \
|
||||||
showDisabled = 0; \
|
showDisabled = 0; \
|
||||||
|
@ -22,6 +22,7 @@ PREP(moduleRefuelSettings);
|
|||||||
PREP(readFuelCounter);
|
PREP(readFuelCounter);
|
||||||
PREP(refuel);
|
PREP(refuel);
|
||||||
PREP(reset);
|
PREP(reset);
|
||||||
|
PREP(resetLocal);
|
||||||
PREP(returnNozzle);
|
PREP(returnNozzle);
|
||||||
PREP(setFuel);
|
PREP(setFuel);
|
||||||
PREP(takeNozzle);
|
PREP(takeNozzle);
|
||||||
|
@ -37,7 +37,7 @@ _maxFuel = getNumber (configFile >> "CfgVehicles" >> (typeOf _target) >> QGVAR(f
|
|||||||
_sink setVariable [QGVAR(nozzle), objNull, true];
|
_sink setVariable [QGVAR(nozzle), objNull, true];
|
||||||
[_pfID] call cba_fnc_removePerFrameHandler;
|
[_pfID] call cba_fnc_removePerFrameHandler;
|
||||||
};
|
};
|
||||||
_tooFar = ((_sink modelToWorld _connectToPoint) distance (_source modelToWorld _connectFromPoint)) > 10;
|
_tooFar = ((_sink modelToWorld _connectToPoint) distance (_source modelToWorld _connectFromPoint)) > (REFUEL_HOSE_LENGTH - 2);
|
||||||
if (_tooFar) exitWith {
|
if (_tooFar) exitWith {
|
||||||
[LSTRING(Hint_TooFar), 2, _unit] call EFUNC(common,displayTextStructured);
|
[LSTRING(Hint_TooFar), 2, _unit] call EFUNC(common,displayTextStructured);
|
||||||
|
|
||||||
|
@ -15,17 +15,18 @@
|
|||||||
*/
|
*/
|
||||||
#include "script_component.hpp"
|
#include "script_component.hpp"
|
||||||
|
|
||||||
|
private ["_nozzle", "_nozzleTarget", "_rope"];
|
||||||
params ["_target"];
|
params ["_target"];
|
||||||
|
|
||||||
if !(local _target) then {
|
if (local _target) then {
|
||||||
[[_target, ["HitEngine", _target getVariable [QGVAR(engineHit), 0]]], "{(_this select 0) setHitPointDamage (_this select 1)}", _sink] call EFUNC(common,execRemoteFnc);
|
|
||||||
} else {
|
|
||||||
_target setHitPointDamage ["HitEngine", _target getVariable [QGVAR(engineHit), 0]];
|
_target setHitPointDamage ["HitEngine", _target getVariable [QGVAR(engineHit), 0]];
|
||||||
|
} else {
|
||||||
|
[[_target, ["HitEngine", _target getVariable [QGVAR(engineHit), 0]]], "{(_this select 0) setHitPointDamage (_this select 1)}", _target] call EFUNC(common,execRemoteFnc);
|
||||||
};
|
};
|
||||||
_target setVariable [QGVAR(engineHit), nil, true];
|
_target setVariable [QGVAR(engineHit), nil, true];
|
||||||
_target setVariable [QGVAR(isConnected), false, true];
|
_target setVariable [QGVAR(isConnected), false, true];
|
||||||
|
|
||||||
_nozzle = _target getVariable [QGVAR(nozzle), nil];
|
_nozzle = _target getVariable [QGVAR(ownedNozzle), nil];
|
||||||
if !(isNil "_nozzle") then {
|
if !(isNil "_nozzle") then {
|
||||||
_nozzleTarget = _nozzle getVariable [QGVAR(sink), nil];
|
_nozzleTarget = _nozzle getVariable [QGVAR(sink), nil];
|
||||||
if !(isNil "_nozzleTarget") then {
|
if !(isNil "_nozzleTarget") then {
|
||||||
@ -38,14 +39,12 @@ if !(isNil "_nozzle") then {
|
|||||||
};
|
};
|
||||||
|
|
||||||
{
|
{
|
||||||
// FIXME needs to be done locally
|
if (local _x) then {
|
||||||
_actionID = _x getVariable [QGVAR(ReleaseActionID), -1];
|
[_x, _nozzle] call FUNC(resetLocal);
|
||||||
if (_actionID != -1) then {
|
} else {
|
||||||
_x removeAction _actionID;
|
[[_x, _nozzle], "{_this call FUNC(resetLocal)}", _x] call EFUNC(common,execRemoteFnc);
|
||||||
_x setVariable [QGVAR(isRefueling), false, true];
|
|
||||||
_x setVariable [QGVAR(ReleaseActionID), nil];
|
|
||||||
};
|
};
|
||||||
} count allPlayers;
|
} count allPlayers;
|
||||||
deleteVehicle _nozzle;
|
deleteVehicle _nozzle;
|
||||||
};
|
};
|
||||||
_target getVariable [QGVAR(nozzle), nil, true];
|
_target setVariable [QGVAR(ownedNozzle), nil, true];
|
37
addons/refuel/functions/fnc_resetLocal.sqf
Normal file
37
addons/refuel/functions/fnc_resetLocal.sqf
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
/*
|
||||||
|
* 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", "_nozzle"];
|
||||||
|
|
||||||
|
|
||||||
|
if (isNull _unit ||
|
||||||
|
{isNull _nozzle} ||
|
||||||
|
{!(_unit isKindOf "CAManBase")} ||
|
||||||
|
{!local _unit}) exitWith {};
|
||||||
|
private ["_attachedNozzle", "_actionID"];
|
||||||
|
_attachedNozzle = _unit getVariable [QGVAR(nozzle), nil];
|
||||||
|
if (isNil "_attachedNozzle") exitWith {};
|
||||||
|
|
||||||
|
if (_nozzle != _attachedNozzle) exitWith {};
|
||||||
|
|
||||||
|
_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];
|
||||||
|
};
|
@ -43,7 +43,7 @@ if (isNull _nozzle || {_source != _target}) exitWith {false};
|
|||||||
};
|
};
|
||||||
|
|
||||||
_target setVariable [QGVAR(isConnected), false, true];
|
_target setVariable [QGVAR(isConnected), false, true];
|
||||||
_target setVariable [QGVAR(nozzle), nil, true];
|
_target setVariable [QGVAR(ownedNozzle), nil, true];
|
||||||
ropeDestroy (_nozzle getVariable QGVAR(rope));
|
ropeDestroy (_nozzle getVariable QGVAR(rope));
|
||||||
deleteVehicle _nozzle;
|
deleteVehicle _nozzle;
|
||||||
|
|
||||||
|
@ -57,11 +57,11 @@ if (isNull _nozzle) then { // func is called on fuel truck
|
|||||||
_newNozzle attachTo [_unit, [-0.02,-0.05,0], "righthandmiddle1"]; // TODO replace with right coordinates for real model
|
_newNozzle attachTo [_unit, [-0.02,-0.05,0], "righthandmiddle1"]; // TODO replace with right coordinates for real model
|
||||||
_unit setVariable [QGVAR(nozzle), _newNozzle];
|
_unit setVariable [QGVAR(nozzle), _newNozzle];
|
||||||
|
|
||||||
_rope = ropeCreate [_target, _endPosOffset, _newNozzle, [0, 0, 0], 12];
|
_rope = ropeCreate [_target, _endPosOffset, _newNozzle, [0, 0, 0], REFUEL_HOSE_LENGTH];
|
||||||
_newNozzle setVariable [QGVAR(attachPos), _endPosOffset, true];
|
_newNozzle setVariable [QGVAR(attachPos), _endPosOffset, true];
|
||||||
_newNozzle setVariable [QGVAR(source), _target, true];
|
_newNozzle setVariable [QGVAR(source), _target, true];
|
||||||
_newNozzle setVariable [QGVAR(rope), _rope, true];
|
_newNozzle setVariable [QGVAR(rope), _rope, true];
|
||||||
_target setVariable [QGVAR(nozzle), _newNozzle, true];
|
_target setVariable [QGVAR(ownedNozzle), _newNozzle, true];
|
||||||
|
|
||||||
_unit setVariable [QGVAR(isRefueling), true];
|
_unit setVariable [QGVAR(isRefueling), true];
|
||||||
_actionID = _unit getVariable [QGVAR(ReleaseActionID), -1];
|
_actionID = _unit getVariable [QGVAR(ReleaseActionID), -1];
|
||||||
@ -127,7 +127,7 @@ if (isNull _nozzle) then { // func is called on fuel truck
|
|||||||
params ["_args", "_pfID"];
|
params ["_args", "_pfID"];
|
||||||
_args params ["_unit", "_source", "_endPosOffset"];
|
_args params ["_unit", "_source", "_endPosOffset"];
|
||||||
|
|
||||||
if (_unit distance (_source modelToWorld _endPosOffset) > 10) exitWith {
|
if (_unit distance (_source modelToWorld _endPosOffset) > (REFUEL_HOSE_LENGTH - 2)) exitWith {
|
||||||
_nozzle = _unit getVariable [QGVAR(nozzle), objNull];
|
_nozzle = _unit getVariable [QGVAR(nozzle), objNull];
|
||||||
if !(isNull _nozzle) then {
|
if !(isNull _nozzle) then {
|
||||||
[_unit, _nozzle] call FUNC(dropNozzle);
|
[_unit, _nozzle] call FUNC(dropNozzle);
|
||||||
|
@ -12,7 +12,8 @@
|
|||||||
#include "\z\ace\addons\main\script_macros.hpp"
|
#include "\z\ace\addons\main\script_macros.hpp"
|
||||||
|
|
||||||
#define REFUEL_INFINITE_FUEL -1
|
#define REFUEL_INFINITE_FUEL -1
|
||||||
#define REFUEL_ACTION_DISTANCE 7
|
#define REFUEL_ACTION_DISTANCE 37
|
||||||
|
#define REFUEL_HOSE_LENGTH 12
|
||||||
|
|
||||||
#define REFUEL_HOLSTER_WEAPON \
|
#define REFUEL_HOLSTER_WEAPON \
|
||||||
_unit setVariable [QGVAR(selectedWeaponOnRefuel), currentWeapon _unit]; \
|
_unit setVariable [QGVAR(selectedWeaponOnRefuel), currentWeapon _unit]; \
|
||||||
|
Loading…
Reference in New Issue
Block a user