mirror of
https://github.com/acemod/ACE3.git
synced 2024-08-30 18:23:18 +00:00
reload launcher mag progress bar
This commit is contained in:
parent
ae5fbaef86
commit
f734aeee95
@ -53,6 +53,7 @@ _perFrameFunction = {
|
|||||||
_elapsedTime = time - _startTime;
|
_elapsedTime = time - _startTime;
|
||||||
_errorCode = -1;
|
_errorCode = -1;
|
||||||
|
|
||||||
|
// this does not check: target fell unconscious, target died, target moved inside vehicle / left vehicle, target moved outside of players range, target moves at all.
|
||||||
if (isNull (uiNamespace getVariable [QGVAR(ctrlProgressBar), controlNull])) then {
|
if (isNull (uiNamespace getVariable [QGVAR(ctrlProgressBar), controlNull])) then {
|
||||||
_errorCode = 1;
|
_errorCode = 1;
|
||||||
} else {
|
} else {
|
||||||
|
15
addons/reloadlaunchers/CfgVehicles.hpp
Normal file
15
addons/reloadlaunchers/CfgVehicles.hpp
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
|
||||||
|
class CfgVehicles {
|
||||||
|
class Man;
|
||||||
|
class CAManBase: Man {
|
||||||
|
class ACE_Actions {
|
||||||
|
class GVAR(ReloadLauncher) {
|
||||||
|
displayName = "RELOAD LAUNCHERS";
|
||||||
|
selection = "launcher";
|
||||||
|
distance = 4;
|
||||||
|
condition = "";
|
||||||
|
insertChildren = QUOTE(_this call FUNC(addMissileReloadActions));
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
ADDON = false;
|
ADDON = false;
|
||||||
|
|
||||||
|
PREP(addMissileReloadActions);
|
||||||
PREP(canLoad);
|
PREP(canLoad);
|
||||||
PREP(getLoadableMissiles);
|
PREP(getLoadableMissiles);
|
||||||
PREP(load);
|
PREP(load);
|
||||||
|
@ -5,7 +5,7 @@ class CfgPatches {
|
|||||||
units[] = {};
|
units[] = {};
|
||||||
weapons[] = {};
|
weapons[] = {};
|
||||||
requiredVersion = REQUIRED_VERSION;
|
requiredVersion = REQUIRED_VERSION;
|
||||||
requiredAddons[] = {"ace_common"};
|
requiredAddons[] = {"ace_common","ace_interaction","ace_interact_menu"};
|
||||||
author[] = {""};
|
author[] = {""};
|
||||||
authorUrl = "";
|
authorUrl = "";
|
||||||
VERSION_CONFIG;
|
VERSION_CONFIG;
|
||||||
@ -13,4 +13,6 @@ class CfgPatches {
|
|||||||
};
|
};
|
||||||
|
|
||||||
#include "CfgEventHandlers.hpp"
|
#include "CfgEventHandlers.hpp"
|
||||||
|
|
||||||
|
#include "CfgVehicles.hpp"
|
||||||
#include "CfgWeapons.hpp"
|
#include "CfgWeapons.hpp"
|
||||||
|
@ -0,0 +1,53 @@
|
|||||||
|
/*
|
||||||
|
* Author: commy2
|
||||||
|
* Create one action per reloadable missile
|
||||||
|
*
|
||||||
|
* Argument:
|
||||||
|
* 1: Player (Object)
|
||||||
|
* 0: Target (Object)
|
||||||
|
* 2: Parameters ??? (Array)
|
||||||
|
*
|
||||||
|
* Return value:
|
||||||
|
* Children actions (Array)
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
#include "script_component.hpp"
|
||||||
|
|
||||||
|
private ["_unit", "_target", "_parameters"];
|
||||||
|
|
||||||
|
_unit = _this select 1;
|
||||||
|
_target = _this select 0;
|
||||||
|
_parameters = _this select 2; // ???
|
||||||
|
|
||||||
|
private ["_actions", "_weapon", "_loadableMissiles"];
|
||||||
|
|
||||||
|
_actions = [];
|
||||||
|
|
||||||
|
_weapon = secondaryWeapon _target;
|
||||||
|
_loadableMissiles = [_unit, _weapon] call FUNC(getLoadableMissiles);
|
||||||
|
|
||||||
|
{
|
||||||
|
private ["_name", "_displayName", "_statement", "_condition", "_action"];
|
||||||
|
|
||||||
|
/*
|
||||||
|
getText (configFile >> "CfgWeapons" >> _weapon >> "displayName")
|
||||||
|
getText (configFile >> "CfgMagazines" >> _x >> "displayName")
|
||||||
|
*/
|
||||||
|
|
||||||
|
_name = format [QGVAR(Missile_%1), _x];
|
||||||
|
_displayName = format ["RELOAD %1", _x];
|
||||||
|
|
||||||
|
_statement = {
|
||||||
|
(_this select 2) call DFUNC(load);
|
||||||
|
};
|
||||||
|
|
||||||
|
_condition = {
|
||||||
|
(_this select 2) call DFUNC(canLoad)
|
||||||
|
};
|
||||||
|
|
||||||
|
_action = [_name, _displayName, "", _statement, _condition, {}, [_unit, _target, _weapon, _x], "", 4] call EFUNC(interact_menu,createAction);
|
||||||
|
|
||||||
|
_actions pushBack [_action, [], _unit];
|
||||||
|
} forEach _loadableMissiles;
|
||||||
|
|
||||||
|
_actions
|
@ -6,31 +6,36 @@
|
|||||||
* Argument:
|
* Argument:
|
||||||
* 0: Unit to do the reloading (Object)
|
* 0: Unit to do the reloading (Object)
|
||||||
* 1: Unit eqipped with launcher (Object)
|
* 1: Unit eqipped with launcher (Object)
|
||||||
|
* 2: weapon name (String)
|
||||||
|
* 3: missile name (String)
|
||||||
*
|
*
|
||||||
* Return value:
|
* Return value:
|
||||||
* NONE
|
* NONE
|
||||||
*/
|
*/
|
||||||
#include "script_component.hpp"
|
#include "script_component.hpp"
|
||||||
|
|
||||||
private ["_unit", "_target"];
|
private ["_unit", "_target", "_weapon", "_magazine"];
|
||||||
|
|
||||||
_unit = _this select 0;
|
_unit = _this select 0;
|
||||||
_target = _this select 1;
|
_target = _this select 1;
|
||||||
|
_weapon = _this select 2;
|
||||||
|
_magazine = _this select 3;
|
||||||
|
|
||||||
if (!alive _target) exitWith {false};
|
if (!alive _target) exitWith {false};
|
||||||
|
if (vehicle _target != _target) exitWith {false};
|
||||||
if !([_unit, _target, []] call EFUNC(common,canInteractWith)) exitWith {false};
|
if !([_unit, _target, []] call EFUNC(common,canInteractWith)) exitWith {false};
|
||||||
|
|
||||||
private "_weapon";
|
// target is awake
|
||||||
_weapon = secondaryWeapon _unit;
|
if (_target getVariable ["ACE_isUnconscious", false]) exitWith {false};
|
||||||
|
|
||||||
// has secondary weapon equipped
|
// has secondary weapon equipped
|
||||||
if (_weapon == "" || {currentWeapon _target != _weapon}) exitWith {false};
|
if !(_weapon in weapons _target) exitWith {false};
|
||||||
|
|
||||||
// check if the target really needs to be reloaded
|
// check if the target really needs to be reloaded
|
||||||
if (currentMagazine _target != "") exitWith {false};
|
if (count secondaryWeaponMagazine _target > 0) exitWith {false};
|
||||||
|
|
||||||
// check if the launcher is compatible
|
// check if the launcher is compatible
|
||||||
if (getNumber (configFile >> "CfgWeapons" >> _weapon >> QGVAR(enabled)) == 0) exitWith {false};
|
if (getNumber (configFile >> "CfgWeapons" >> _weapon >> QGVAR(enabled)) == 0) exitWith {false};
|
||||||
|
|
||||||
// check if the reloader has a magazine compatible with targets launcher
|
// check if the magazine compatible with targets launcher
|
||||||
count ([_unit, _weapon] call FUNC(getLoadableMissiles)) > 0
|
_magazine in ([_unit, _weapon] call FUNC(getLoadableMissiles))
|
||||||
|
@ -21,9 +21,28 @@ _target = _this select 1;
|
|||||||
_weapon = _this select 2;
|
_weapon = _this select 2;
|
||||||
_magazine = _this select 3;
|
_magazine = _this select 3;
|
||||||
|
|
||||||
//do stuff
|
private "_reloadTime";
|
||||||
|
_reloadTime = getNumber (configFile >> "CfgWeapons" >> _weapon >> "magazineReloadTime");
|
||||||
|
|
||||||
/**/
|
// do animation
|
||||||
|
[_unit] call EFUNC(common,goKneeling);
|
||||||
|
|
||||||
// reload launcher on remote machine
|
// show progress bar
|
||||||
["reloadLauncher", _target, [_target, _weapon, _magazine]] call EFUNC(common,targetEvent);
|
private ["_onSuccess", "_onFailure", "_condition"];
|
||||||
|
|
||||||
|
_onSuccess = {
|
||||||
|
(_this select 0 select 0) removeMagazine (_this select 0 select 3);
|
||||||
|
["reloadLauncher", _this select 0 select 0, _this select 0] call DEFUNC(common,targetEvent);
|
||||||
|
|
||||||
|
["WEAPON RELOADED"] call DEFUNC(common,displayTextStructured);
|
||||||
|
};
|
||||||
|
|
||||||
|
_onFailure = {
|
||||||
|
["WEAPON NOT RELOADED"] call DEFUNC(common,displayTextStructured);
|
||||||
|
};
|
||||||
|
|
||||||
|
_condition = {
|
||||||
|
(_this select 0) call DFUNC(canLoad) && {(_this select 0 select 0) distance (_this select 0 select 1) < 4}
|
||||||
|
};
|
||||||
|
|
||||||
|
[_reloadTime, [_unit, _target, _weapon, _magazine], _onSuccess, _onFailure, "RELOADING WEAPON", _condition] call EFUNC(common,progressBar);
|
||||||
|
@ -4,9 +4,10 @@
|
|||||||
* Reload a launcher
|
* Reload a launcher
|
||||||
*
|
*
|
||||||
* Argument:
|
* Argument:
|
||||||
* 0: Unit to reload (Object)
|
* 0: Unit to do the reloading (Object)
|
||||||
* 1: weapon name (String)
|
* 1: Target to rload (Object)
|
||||||
* 2: missile name (String)
|
* 2: weapon name (String)
|
||||||
|
* 3: missile name (String)
|
||||||
*
|
*
|
||||||
* Return value:
|
* Return value:
|
||||||
* NONE
|
* NONE
|
||||||
@ -16,13 +17,14 @@
|
|||||||
private ["_unit", "_weapon", "_magazine"];
|
private ["_unit", "_weapon", "_magazine"];
|
||||||
|
|
||||||
_unit = _this select 0;
|
_unit = _this select 0;
|
||||||
_weapon = _this select 1;
|
_target = _this select 1;
|
||||||
_magazine = _this select 2;
|
_weapon = _this select 2;
|
||||||
|
_magazine = _this select 3;
|
||||||
|
|
||||||
_unit selectWeapon _weapon;
|
_target selectWeapon _weapon;
|
||||||
|
|
||||||
if (currentWeapon _unit != _weapon) exitWith {};
|
if (currentWeapon _target != _weapon) exitWith {};
|
||||||
if (currentMagazine _unit != "") exitWith {};
|
if (currentMagazine _target != "") exitWith {};
|
||||||
|
|
||||||
// command is wip, reload time for launchers is not intended.
|
// command is wip, reload time for launchers is not intended.
|
||||||
_unit addWeaponItem [_weapon, _magazine];
|
_target addWeaponItem [_weapon, _magazine];
|
||||||
|
Loading…
Reference in New Issue
Block a user