mirror of
https://github.com/acemod/ACE3.git
synced 2024-08-30 18:23:18 +00:00
reload event, some basic functions
This commit is contained in:
parent
0be1959934
commit
40eed0e12f
@ -4,3 +4,9 @@ class Extended_PreInit_EventHandlers {
|
||||
init = QUOTE(call COMPILE_FILE(XEH_preInit));
|
||||
};
|
||||
};
|
||||
|
||||
class Extended_PostInit_EventHandlers {
|
||||
class ADDON {
|
||||
init = QUOTE(call COMPILE_FILE(XEH_postInit));
|
||||
};
|
||||
};
|
||||
|
11
addons/reloadlaunchers/CfgWeapons.hpp
Normal file
11
addons/reloadlaunchers/CfgWeapons.hpp
Normal file
@ -0,0 +1,11 @@
|
||||
|
||||
class CfgWeapons {
|
||||
class Launcher_Base_F;
|
||||
class launch_Titan_base: Launcher_Base_F {
|
||||
GVAR(enabled) = 1;
|
||||
};
|
||||
|
||||
class launch_RPG32_F: Launcher_Base_F {
|
||||
GVAR(enabled) = 1;
|
||||
};
|
||||
};
|
4
addons/reloadlaunchers/XEH_postInit.sqf
Normal file
4
addons/reloadlaunchers/XEH_postInit.sqf
Normal file
@ -0,0 +1,4 @@
|
||||
// by commy2
|
||||
#include "script_component.hpp"
|
||||
|
||||
["reloadLauncher", {_this call DFUNC(reloadLauncher)}] call EFUNC(common,addEventhandler);
|
@ -2,6 +2,8 @@
|
||||
|
||||
ADDON = false;
|
||||
|
||||
PREP(empty);
|
||||
PREP(canLoad);
|
||||
PREP(load);
|
||||
PREP(reloadLauncher);
|
||||
|
||||
ADDON = true;
|
||||
|
@ -13,3 +13,4 @@ class CfgPatches {
|
||||
};
|
||||
|
||||
#include "CfgEventHandlers.hpp"
|
||||
#include "CfgWeapons.hpp"
|
||||
|
56
addons/reloadlaunchers/functions/fnc_canLoad.sqf
Normal file
56
addons/reloadlaunchers/functions/fnc_canLoad.sqf
Normal file
@ -0,0 +1,56 @@
|
||||
/*
|
||||
* Author: commy2
|
||||
*
|
||||
* Check of the unit can reload the launcher of target unit.
|
||||
*
|
||||
* Argument:
|
||||
* 0: Unit to to the reload (Object)
|
||||
* 1: Unit eqipped with launcher (Object)
|
||||
*
|
||||
* Return value:
|
||||
* NONE
|
||||
*/
|
||||
#include "script_component.hpp"
|
||||
|
||||
private ["_unit", "_target"];
|
||||
|
||||
_unit = _this select 0;
|
||||
_target = _this select 1;
|
||||
|
||||
if (!alive _target) exitWith {false};
|
||||
if !([_unit, _target, []] call EFUNC(common,canInteractWith)) exitWith {false};
|
||||
|
||||
private "_weapon";
|
||||
_weapon = secondaryWeapon _unit;
|
||||
|
||||
// has secondary weapon equipped
|
||||
if (_weapon == "" || {currentWeapon _target != _weapon}) exitWith {false};
|
||||
|
||||
// check if the target really needs to be reloaded
|
||||
if (currentMagazine _target != "") exitWith {false};
|
||||
|
||||
// check if the launcher is compatible
|
||||
private "_config";
|
||||
_config = configFile >> "CfgWeapons" >> _weapon;
|
||||
|
||||
if (getNumber (_config >> QGVAR(enabled)) == 0) exitWith {false};
|
||||
|
||||
// get magazine of reloader
|
||||
private "_magazines";
|
||||
_magazines = magazines _unit;
|
||||
|
||||
{
|
||||
_magazines deleteAt (_magazines find _x);
|
||||
} forEach secondaryWeaponMagazine _unit;
|
||||
|
||||
// check if the reloader has a magazine compatible with targets launcher
|
||||
private "_hasMagazine";
|
||||
_hasMagazine = false;
|
||||
|
||||
{
|
||||
if (_x in _magazines) exitWith {
|
||||
_hasMagazine = true;
|
||||
};
|
||||
} forEach getArray (_config >> "magazines");
|
||||
|
||||
_hasMagazine
|
@ -1,3 +0,0 @@
|
||||
#include "script_component.hpp"
|
||||
|
||||
diag_log text format["This is here as an example!!!"];
|
29
addons/reloadlaunchers/functions/fnc_load.sqf
Normal file
29
addons/reloadlaunchers/functions/fnc_load.sqf
Normal file
@ -0,0 +1,29 @@
|
||||
/*
|
||||
* Author: commy2
|
||||
*
|
||||
* Reload a launcher
|
||||
*
|
||||
* Argument:
|
||||
* 0: Unit with magazine (Object)
|
||||
* 1: Unit with launcher (Object)
|
||||
* 2: weapon name (String)
|
||||
* 3: missile name (String)
|
||||
*
|
||||
* Return value:
|
||||
* NONE
|
||||
*/
|
||||
#include "script_component.hpp"
|
||||
|
||||
private ["_unit", "_target", "_weapon", "_magazine"];
|
||||
|
||||
_unit = _this select 0;
|
||||
_target = _this select 1;
|
||||
_weapon = _this select 2;
|
||||
_magazine = _this select 3;
|
||||
|
||||
//do stuff
|
||||
|
||||
/**/
|
||||
|
||||
// reload launcher on remote machine
|
||||
["reloadLauncher", _target, [_target, _weapon, _magazine]] call EFUNC(common,targetEvent);
|
28
addons/reloadlaunchers/functions/fnc_reloadLauncher.sqf
Normal file
28
addons/reloadlaunchers/functions/fnc_reloadLauncher.sqf
Normal file
@ -0,0 +1,28 @@
|
||||
/*
|
||||
* Author: commy2
|
||||
*
|
||||
* Reload a launcher
|
||||
*
|
||||
* Argument:
|
||||
* 0: Unit to reload (Object)
|
||||
* 1: weapon name (String)
|
||||
* 2: missile name (String)
|
||||
*
|
||||
* Return value:
|
||||
* NONE
|
||||
*/
|
||||
#include "script_component.hpp"
|
||||
|
||||
private ["_unit", "_weapon", "_magazine"];
|
||||
|
||||
_unit = _this select 0;
|
||||
_weapon = _this select 1;
|
||||
_magazine = _this select 2;
|
||||
|
||||
_unit selectWeapon _weapon;
|
||||
|
||||
if (currentWeapon _unit != _weapon) exitWith {};
|
||||
if (currentMagazine _unit != "") exitWith {};
|
||||
|
||||
// command is wip, reload time for launchers is not intended.
|
||||
_unit addWeaponItem [_weapon, _magazine];
|
Loading…
Reference in New Issue
Block a user