Merge branch 'master' into Medical_Dragging

This commit is contained in:
Glowbal 2015-03-22 21:07:26 +01:00
commit 1aa2425c1e
21 changed files with 329 additions and 6 deletions

View File

@ -53,6 +53,7 @@ _perFrameFunction = {
_elapsedTime = time - _startTime;
_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 {
_errorCode = 1;
} else {

View File

@ -13,8 +13,10 @@ if (_unit getVariable [QGVAR(isDragging), false]) then {
private "_draggedObject";
_draggedObject = _unit getVariable [QGVAR(draggedObject), objNull];
if (!isNull _draggedObject) then {
[_unit, _draggedObject] call FUNC(dropObject);
};
};
};
@ -25,7 +27,9 @@ if (_unit getVariable [QGVAR(isCarrying), false]) then {
private "_carriedObject";
_carriedObject = _unit getVariable [QGVAR(carriedObject), objNull];
if (!isNull _carriedObject) then {
[_unit, _carriedObject] call FUNC(dropObject_carry);
};
};
};

View File

@ -48,8 +48,8 @@ if (_type in _initializedClasses) exitWith {};
_initializedClasses pushBack _type;
GVAR(initializedClasses_carry) = _initializedClasses;
_carryAction = [QGVAR(drag), localize "STR_ACE_Dragging_Carry", "", {[_player, _target] call FUNC(carryObject)}, {[_player, _target] call FUNC(canCarry)}] call EFUNC(interact_menu,createAction);
_dropAction = [QGVAR(drop), localize "STR_ACE_Dragging_Drop", "", {[_player, _target] call FUNC(dropObject_carry)}, {[_player, _target] call FUNC(canDrop_carry)}] call EFUNC(interact_menu,createAction);
_carryAction = [QGVAR(carry), localize "STR_ACE_Dragging_Carry", "", {[_player, _target] call FUNC(carryObject)}, {[_player, _target] call FUNC(canCarry)}] call EFUNC(interact_menu,createAction);
_dropAction = [QGVAR(drop_carry), localize "STR_ACE_Dragging_Drop", "", {[_player, _target] call FUNC(dropObject_carry)}, {[_player, _target] call FUNC(canDrop_carry)}] call EFUNC(interact_menu,createAction);
[_type, 0, ["ACE_MainActions"], _carryAction] call EFUNC(interact_menu,addActionToClass);
[_type, 0, ["ACE_MainActions"], _dropAction] call EFUNC(interact_menu,addActionToClass);
[_type, 0, [], _dropAction] call EFUNC(interact_menu,addActionToClass);

View File

@ -52,4 +52,4 @@ _dragAction = [QGVAR(drag), localize "STR_ACE_Dragging_Drag", "", {[_player, _ta
_dropAction = [QGVAR(drop), localize "STR_ACE_Dragging_Drop", "", {[_player, _target] call FUNC(dropObject)}, {[_player, _target] call FUNC(canDrop)}] call EFUNC(interact_menu,createAction);
[_type, 0, ["ACE_MainActions"], _dragAction] call EFUNC(interact_menu,addActionToClass);
[_type, 0, ["ACE_MainActions"], _dropAction] call EFUNC(interact_menu,addActionToClass);
[_type, 0, [], _dropAction] call EFUNC(interact_menu,addActionToClass);

View File

@ -40,4 +40,7 @@ _unit selectWeapon primaryWeapon _unit;
// can't play action that depends on weapon if it was added the same frame
[{_this playActionNow "grabDrag";}, _unit] call EFUNC(common,execNextFrame);
// prevents draging and carrying at the same time
_unit setVariable [QGVAR(isDragging), true, true];
[FUNC(startDragPFH), 0.2, [_unit, _target, time + 5]] call CBA_fnc_addPerFrameHandler;

View File

@ -10,6 +10,17 @@ _timeOut = _this select 0 select 2;
// timeout. Do nothing. Quit. time, because anim length is linked to ingame time.
if (time > _timeOut) exitWith {
[_this select 1] call CBA_fnc_removePerFrameHandler;
// drop if in timeout
private "_draggedObject";
_draggedObject = _unit getVariable [QGVAR(draggedObject), objNull];
if (!isNull _draggedObject) exitWith {
[_unit, _draggedObject] call FUNC(dropObject);
};
// re-enable everything
_unit setVariable [QGVAR(isDragging), false, true];
};
// unit is ready to start dragging

View File

@ -0,0 +1 @@
z\ace\addons\reloadlaunchers

View File

@ -0,0 +1,12 @@
class Extended_PreInit_EventHandlers {
class ADDON {
init = QUOTE(call COMPILE_FILE(XEH_preInit));
};
};
class Extended_PostInit_EventHandlers {
class ADDON {
init = QUOTE(call COMPILE_FILE(XEH_postInit));
};
};

View File

@ -0,0 +1,15 @@
class CfgVehicles {
class Man;
class CAManBase: Man {
class ACE_Actions {
class GVAR(ReloadLauncher) {
displayName = "$STR_ACE_ReloadLaunchers_LoadLauncher";
selection = "launcher";
distance = 4;
condition = "";
insertChildren = QUOTE(_this call FUNC(addMissileReloadActions));
};
};
};
};

View 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;
};
};

View File

@ -0,0 +1,4 @@
// by commy2
#include "script_component.hpp"
["reloadLauncher", {_this call DFUNC(reloadLauncher)}] call EFUNC(common,addEventhandler);

View File

@ -0,0 +1,11 @@
#include "script_component.hpp"
ADDON = false;
PREP(addMissileReloadActions);
PREP(canLoad);
PREP(getLoadableMissiles);
PREP(load);
PREP(reloadLauncher);
ADDON = true;

View File

@ -0,0 +1,18 @@
#include "script_component.hpp"
class CfgPatches {
class ADDON {
units[] = {};
weapons[] = {};
requiredVersion = REQUIRED_VERSION;
requiredAddons[] = {"ace_common","ace_interaction","ace_interact_menu"};
author[] = {""};
authorUrl = "";
VERSION_CONFIG;
};
};
#include "CfgEventHandlers.hpp"
#include "CfgVehicles.hpp"
#include "CfgWeapons.hpp"

View File

@ -0,0 +1,48 @@
/*
* 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"];
_name = format [QGVAR(Missile_%1), _x];
_displayName = format [localize "STR_ACE_ReloadLaunchers_LoadMagazine", getText (configFile >> "CfgMagazines" >> _x >> "displayName")];
_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

View File

@ -0,0 +1,41 @@
/*
* Author: commy2
*
* Check of the unit can reload the launcher of target unit.
*
* Argument:
* 0: Unit to do the reloading (Object)
* 1: Unit eqipped 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;
if (!alive _target) exitWith {false};
if (vehicle _target != _target) exitWith {false};
if !([_unit, _target, []] call EFUNC(common,canInteractWith)) exitWith {false};
// target is awake
if (_target getVariable ["ACE_isUnconscious", false]) exitWith {false};
// has secondary weapon equipped
if !(_weapon in weapons _target) exitWith {false};
// check if the target really needs to be reloaded
if (count secondaryWeaponMagazine _target > 0) exitWith {false};
// check if the launcher is compatible
if (getNumber (configFile >> "CfgWeapons" >> _weapon >> QGVAR(enabled)) == 0) exitWith {false};
// check if the magazine compatible with targets launcher
_magazine in ([_unit, _weapon] call FUNC(getLoadableMissiles))

View File

@ -0,0 +1,28 @@
/*
* Author: commy2
*
* Return all magazine types from reloaders inventory that are compatible with given weapon.
*
* Argument:
* 0: Unit to to the reload (Object)
* 1: A launcher (String)
*
* Return value:
* Reloable magazines (Array)
*/
#include "script_component.hpp"
private ["_unit", "_weapon"];
_unit = _this select 0;
_weapon = _this select 1;
// get available magazines of reloader, Note: "magazines" does not include currently loaded magazines
private "_magazines";
_magazines = magazines _unit;
// case sensitvity
_magazines = [_magazines, {toLower _this}] call EFUNC(common,map);
// get reloaders magazine types compatible with targets launcher. No duplicates.
[getArray (configFile >> "CfgWeapons" >> _weapon >> "magazines"), {toLower _this in _magazines}] call EFUNC(common,filter)

View File

@ -0,0 +1,48 @@
/*
* 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;
private "_reloadTime";
_reloadTime = getNumber (configFile >> "CfgWeapons" >> _weapon >> "magazineReloadTime");
// do animation
[_unit] call EFUNC(common,goKneeling);
// show progress bar
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);
[localize "STR_ACE_ReloadLaunchers_LauncherLoaded"] call DEFUNC(common,displayTextStructured);
};
_onFailure = {
[localize "STR_ACE_Common_ActionAborted"] 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, localize "STR_ACE_ReloadLaunchers_LoadingLauncher", _condition] call EFUNC(common,progressBar);

View File

@ -0,0 +1,30 @@
/*
* Author: commy2
*
* Reload a launcher
*
* Argument:
* 0: Unit to do the reloading (Object)
* 1: Target to rload (Object)
* 2: weapon name (String)
* 3: missile name (String)
*
* Return value:
* NONE
*/
#include "script_component.hpp"
private ["_unit", "_weapon", "_magazine"];
_unit = _this select 0;
_target = _this select 1;
_weapon = _this select 2;
_magazine = _this select 3;
_target selectWeapon _weapon;
if (currentWeapon _target != _weapon) exitWith {};
if (currentMagazine _target != "") exitWith {};
// command is wip, reload time for launchers is not intended.
_target addWeaponItem [_weapon, _magazine];

View File

@ -0,0 +1 @@
#include "\z\ace\addons\reloadlaunchers\script_component.hpp"

View File

@ -0,0 +1,12 @@
#define COMPONENT reloadlaunchers
#include "\z\ace\addons\main\script_mod.hpp"
#ifdef DEBUG_ENABLED_RELOADLAUNCHERS
#define DEBUG_MODE_FULL
#endif
#ifdef DEBUG_ENABLED_RELOADLAUNCHERS
#define DEBUG_SETTINGS DEBUG_ENABLED_RELOADLAUNCHERS
#endif
#include "\z\ace\addons\main\script_macros.hpp"

View File

@ -0,0 +1,24 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Edited with tabler - 2014-12-16 -->
<Project name="ACE">
<Package name="ReloadLaunchers">
<Key ID="STR_ACE_ReloadLaunchers_LoadLauncher">
<English>Load launcher</English>
<German>Panzerabwehr laden</German>
</Key>
<Key ID="STR_ACE_ReloadLaunchers_LoadingLauncher">
<English>Loading launcher ...</English>
<German>Panzerabwehr wird geladen ...</German>
</Key>
<Key ID="STR_ACE_ReloadLaunchers_LauncherLoaded">
<English>Launcher loaded</English>
<German>Panzerabwehr geladen</German>
</Key>
<Key ID="STR_ACE_ReloadLaunchers_LoadMagazine">
<English>Load %1</English>
<German>Lade %1</German>
</Key>
</Package>
</Project>