Various Changes

This commit is contained in:
PabstMirror 2015-03-20 20:17:49 -05:00
parent f8e758e136
commit 38745f4871
13 changed files with 122 additions and 72 deletions

View File

@ -6,9 +6,9 @@ class CfgVehicles {
class ACE_DisarmInventory {
displayName = "$STR_ACE_Disarming_OpenInventory";
distance = 4;
condition = QUOTE([_target] call FUNC(canDisarm));
condition = QUOTE([ARR_2(_player,_target)] call FUNC(canPlayerDisarmUnit));
statement = QUOTE([ARR_2(_player,_target)] call FUNC(openDisarmDialog));
icon = "\a3\Modules_F_Curator\Data\portraitRespawnInventory_ca.paa"; //todo
icon = "\a3\Modules_F_Curator\Data\portraitRespawnInventory_ca.paa";
selection = "spine3";
exceptions[] = {};
};

View File

@ -2,7 +2,8 @@
ADDON = false;
PREP(canDisarm);
PREP(canBeDisarmed);
PREP(canPlayerDisarmUnit);
PREP(disarmDropItems);
PREP(eventCallerFinish);
PREP(eventTargetFinish);

View File

@ -6,10 +6,10 @@
* 0: Target <OBJECT>
*
* Return Value:
* The return value <BOOL>
* Can Be Disarmed <BOOL>
*
* Example:
* [cursorTarget] call ace_disarming_fnc_canDisarm
* [cursorTarget] call ace_disarming_fnc_canBeDisarmed
*
* Public: No
*/
@ -17,7 +17,9 @@
PARAMS_1(_target);
//Check animationState for putDown anim:
//Check animationState for putDown anim
//This ensures the unit doesn't have to actualy do any animation to drop something
//This should always be true for the 3 possible status effects that allow disarming
_animationStateCfgMoves = getText (configFile >> "CfgMovesMaleSdr" >> "States" >> (animationState _target) >> "actions");
if (_animationStateCfgMoves == "") exitWith {false};
_putDownAnim = getText (configFile >> "CfgMovesBasic" >> "Actions" >> _animationStateCfgMoves >> "PutDown");

View File

@ -0,0 +1,22 @@
/*
* Author: PabstMirror
* Checks the conditions for being able to disarm a unit
*
* Arguments:
* 0: Player <OBJECT>
* 1: Target <OBJECT>
*
* Return Value:
* Can Be Disarm Target <BOOL>
*
* Example:
* [player, cursorTarget] call ace_disarming_fnc_canPlayerDisarmUnit
*
* Public: No
*/
#include "script_component.hpp"
PARAMS_2(_player,_target);
([_target] call FUNC(canBeDisarmed)) &&
{([_player, _target, []] call EFUNC(common,canInteractWith))}

View File

@ -1,6 +1,6 @@
/*
* Author: PabstMirror
* Makes a unit drop items:
* Makes a unit drop items
*
* Arguments:
* 0: caller (player) <OBJECT>
@ -30,7 +30,7 @@ _fncSumArray = {
};
//Sanity Checks
if (!([_target] call FUNC(canDisarm))) exitWith {
if (!([_target] call FUNC(canBeDisarmed))) exitWith {
[_caller, _target, "Debug: Cannot disarm target"] call FUNC(eventTargetFinish);
};
if (_doNotDropAmmo && {({_x in _listOfItemsToRemove} count (magazines _target)) > 0}) exitWith {
@ -38,20 +38,23 @@ if (_doNotDropAmmo && {({_x in _listOfItemsToRemove} count (magazines _target))
};
_holder = objNull;
//If not dropping ammo, don't use an existing container
if (!_doNotDropAmmo) then {
//Try to use the same container, if one exists
{
if ((_x getVariable [QGVAR(disarmUnit), objNull]) == _target) exitWith {
_holder = _x;
};
} forEach ((getpos _target) nearObjects ["GroundWeaponHolder", 3]);
} forEach ((getpos _target) nearObjects [DISARM_CONTAINER, 3]);
};
if (isNull _holder) then {
_dropPos = _target modelToWorld [-0.75, 0.75, 0];
_dropPos set [2, 0];
_dropPos = _target modelToWorld [0, 0.75, 0];
_dropPos set [2, ((getPosASL _target) select 2)];
// _holder = createVehicle ["WeaponHolderSimulated", _dropPos, [], 0, "CAN_COLLIDE"];
_holder = createVehicle ["GroundWeaponHolder", _dropPos, [], 0, "CAN_COLLIDE"];
_holder = createVehicle [DISARM_CONTAINER, _dropPos, [], 0, "CAN_COLLIDE"];
_holder setPosASL _dropPos;
_holder setVariable [QGVAR(holderInUse), false];
_holder setVariable [QGVAR(disarmUnit), _target, true];
};
@ -59,12 +62,12 @@ if (isNull _holder) then {
if (isNull _holder) exitWith {
[_caller, _target, "Debug: Null Holder"] call FUNC(eventTargetFinish);
};
//Make sure only one drop operation at a time...
//Make sure only one drop operation at a time (using PFEH system as a queue)
if (_holder getVariable [QGVAR(holderInUse), false]) exitWith {
systemChat format ["Debug: %1 - Ground Container In Use, waiting until free", time];
[{
_this call FUNC(disarmDropItems);
}, _this, 0.05, 0.05] call EFUNC(common,waitAndExecute);
}, _this, 0, 0] call EFUNC(common,waitAndExecute);
};
_holder setVariable [QGVAR(holderInUse), true];
@ -164,7 +167,7 @@ systemChat format ["PFEh start %1", time];
_needToRemoveVest = ((vest _target) != "") && {(vest _target) in _listOfItemsToRemove};
_needToRemoveUniform = ((uniform _target) != "") && {(uniform _target) in _listOfItemsToRemove};
if ((time < _maxWaitTime) && {[_target] call FUNC(canDisarm)} && {_needToRemoveWeapon || _needToRemoveMagazines || _needToRemoveBackpack}) then {
if ((time < _maxWaitTime) && {[_target] call FUNC(canBeDisarmed)} && {_needToRemoveWeapon || _needToRemoveMagazines || _needToRemoveBackpack}) then {
//action drop weapons (keeps loaded magazine and attachements)
{
if (_x in _listOfItemsToRemove) then {
@ -222,18 +225,16 @@ systemChat format ["PFEh start %1", time];
systemChat "Debug: Deleting Dummy";
clearItemCargoGlobal _holder;
};
//Verify we didn't timeout waiting on drop action
if (time >= _maxWaitTime) exitWith {
_holder setVariable [QGVAR(holderInUse), false];
[_caller, _target, "Debug: Drop Actions Timeout"] call FUNC(eventTargetFinish);
};
//If target lost disarm status:
if (!([_target] call FUNC(canDisarm))) exitWith {
if (!([_target] call FUNC(canBeDisarmed))) exitWith {
_holder setVariable [QGVAR(holderInUse), false];
[_caller, _target, "Debug: Target cannot be disarmed"] call FUNC(eventTargetFinish);
};
if (_needToRemoveVest && {!((vestItems _target) isEqualTo [])}) exitWith {
_holder setVariable [QGVAR(holderInUse), false];
[_caller, _target, "Debug: Vest Not Empty"] call FUNC(eventTargetFinish);

View File

@ -1,6 +1,6 @@
/*
* Author: PabstMirror
* Starts the disarming process from the caller
* Recieves a possible error code from FUNC(eventTargetFinish)
*
* Arguments:
* 0: caller (player) <OBJECT>
@ -11,7 +11,7 @@
* None
*
* Example:
* TODO
* [player1, player2, "Someting fucked up"] call ace_disarming_fnc_eventCallerFinish
*
* Public: No
*/
@ -22,4 +22,4 @@ PARAMS_3(_caller,_target,_errorMsg);
if (_caller != ACE_player) exitWith {};
systemChat format ["Debug-Caller: Disarm finished from [%1] with code [%2]", _target, _errorMsg];
[format ["Problem Removing Item<br/>%1", _errorMsg]] call EFUNC(common,displayTextStructured);
diag_log text format ["[ACE_Disarming] %1 - eventCallerFinish: %2", time, _this];

View File

@ -1,6 +1,7 @@
/*
* Author: PabstMirror
* TODO
* After FUNC(disarmDropItems) has completed, passing a possible error code.
* Passes that error back to orginal caller.
*
* Arguments:
* 0: caller <OBJECT>
@ -11,7 +12,7 @@
* Nothing
*
* Example:
* eventTargetFinish
* [player1, player2, "Someting fucked up"] call ace_disarming_fnc_eventTargetFinish
*
* Public: No
*/
@ -21,6 +22,6 @@ PARAMS_3(_caller,_target,_errorMsg);
if (_errorMsg != "") then {
systemChat _errorMsg;
diag_log text format ["[ACE_Disarming] %1 - eventTargetFinish: %2", time, _this];
["DisarmDebugCallback", [_caller], [_caller, _target, _errorMsg]] call EFUNC(common,targetEvent);
};

View File

@ -1,6 +1,7 @@
/*
* Author: PabstMirror
* TODO
* Disarm Event Handler, Starting func, called on the target.
* If target has to remove uniform/vest, this will add all uniform/vest items to the drop list.
*
* Arguments:
* 0: caller (player) <OBJECT>

View File

@ -16,18 +16,28 @@
*/
#include "script_component.hpp"
#define TEXTURES_RANKS [ \
"", \
"\A3\Ui_f\data\GUI\Cfg\Ranks\private_gs.paa", \
"\A3\Ui_f\data\GUI\Cfg\Ranks\corporal_gs.paa", \
"\A3\Ui_f\data\GUI\Cfg\Ranks\sergeant_gs.paa", \
"\A3\Ui_f\data\GUI\Cfg\Ranks\lieutenant_gs.paa", \
"\A3\Ui_f\data\GUI\Cfg\Ranks\captain_gs.paa", \
"\A3\Ui_f\data\GUI\Cfg\Ranks\major_gs.paa", \
"\A3\Ui_f\data\GUI\Cfg\Ranks\colonel_gs.paa" \
]
PARAMS_2(_caller,_target);
//Sanity Checks
if (_caller != ACE_player) exitwith {ERROR("Player isn't caller?");};
if (!([_target] call FUNC(canDisarm))) exitWith {ERROR("Unit Cannot Be Disarmed");};
if (!([] call EGVAR(common,canInteract))) exitWith {ERROR("Player cannot Interact");};
if (dialog) then {closeDialog 0;};
createDialog QGVAR(remoteInventory);
if (!([_player, _target] call FUNC(canPlayerDisarmUnit))) exitWith {ERROR("Can't Disarm Unit");};
if (dialog) then {ERROR("Dialog open when trying to open disarm dialog"); closeDialog 0;};
disableSerialization;
createDialog QGVAR(remoteInventory);
_display = uiNamespace getVariable ["ACE_remoteInventory", displayNull];
if (isNull _display) exitWith {ERROR("Display is Null");};
@ -53,11 +63,12 @@ GVAR(disarmTarget) = _target;
EXPLODE_2_PVT(_this,_args,_pfID);
EXPLODE_3_PVT(_args,_player,_target,_display);
if ((!([_target] call FUNC(canDisarm))) ||
if ((!([_player, _target] call FUNC(canPlayerDisarmUnit))) ||
{isNull _display} ||
{_player != ACE_player} ||
{!([_player, _target, []] call EFUNC(common,canInteractWith))}) then {
{_player != ACE_player}) then {
systemChat "Debug: closeing dialog";
[_pfID] call CBA_fnc_removePerFrameHandler;
GVAR(disarmTarget) = objNull;
if (!isNull _display) then {closeDialog 0;}; //close dialog if still open
@ -67,9 +78,12 @@ GVAR(disarmTarget) = _target;
_playerName = _display displayCtrl 111;
_rankPicture = _display displayCtrl 1203;
_rankPicture ctrlSetText "\A3\Ui_f\data\GUI\Cfg\Ranks\corporal_gs.paa";
//Show rank and name (just like BIS's inventory)
_rankIndex = ["PRIVATE", "CORPORAL", "SERGEANT", "LIEUTENANT", "CAPTAIN", "MAJOR", "COLONEL"] find (rank _target);
_rankPicture ctrlSetText (TEXTURES_RANKS select _rankIndex);
_playerName ctrlSetText ([GVAR(disarmTarget)] call EFUNC(common,getName));
//Clear both inventory lists:
lbClear _groundContainer;
lbClear _targetContainer;
@ -77,17 +91,18 @@ GVAR(disarmTarget) = _target;
_targetUniqueItems = [GVAR(disarmTarget)] call FUNC(getAllGearUnit);
[_targetContainer, _targetUniqueItems] call FUNC(showItemsInListbox);
//Try to find a holder that the target is using to drop items into:
_holder = objNull;
{
if ((_x getVariable [QGVAR(disarmUnit), objNull]) == _target) exitWith {
_holder = _x;
};
} forEach ((getpos _target) nearObjects ["GroundWeaponHolder", 3]);
} forEach ((getpos _target) nearObjects [DISARM_CONTAINER, 3]);
//If a holder exists, show it's inventory
if (!isNull _holder) then {
_holderUniqueItems = [_holder] call FUNC(getAllGearContainer);
[_groundContainer, _holderUniqueItems] call FUNC(showItemsInListbox);
};
};
}, 0.05, [_caller, _target, _display]] call CBA_fnc_addPerFrameHandler;
}, 0, [_caller, _target, _display]] call CBA_fnc_addPerFrameHandler;

View File

@ -4,7 +4,7 @@
*
* Arguments:
* 0: RscListBox <CONTROL>
* 1: ItemArray [["items"],[counts]] <ARRAY>
* 1: ItemArray [["itemClassnames"],[counts]] <ARRAY>
*
* Return Value:
* Nothing
@ -19,32 +19,39 @@
disableSerialization;
PARAMS_2(_listBoxCtrl,_itemsCountArray);
private "_classname";
{
_displayName = "";
_picture = "";
_classname = _x;
_count = (_itemsCountArray select 1) select _forEachIndex;
switch (true) do {
case (isClass (configFile >> "CfgWeapons" >> _x)): {
_displayName = getText (configFile >> "CfgWeapons" >> _x >> "displayName");
_picture = getText (configFile >> "CfgWeapons" >> _x >> "picture");
if (_classname != DUMMY_ITEM) then { //Don't show the dummy potato
switch (true) do {
case (isClass (configFile >> "CfgWeapons" >> _classname)): {
_displayName = getText (configFile >> "CfgWeapons" >> _classname >> "displayName");
_picture = getText (configFile >> "CfgWeapons" >> _classname >> "picture");
};
case (isClass (configFile >> "CfgMagazines" >> _classname)): {
_displayName = getText (configFile >> "CfgMagazines" >> _classname >> "displayName");
_picture = getText (configFile >> "CfgMagazines" >> _classname >> "picture");
};
case (isClass (configFile >> "CfgVehicles" >> _classname)): {
_displayName = getText (configFile >> "CfgVehicles" >> _classname >> "displayName");
_picture = getText (configFile >> "CfgVehicles" >> _classname >> "picture");
};
case (isClass (configFile >> "CfgGlasses" >> _classname)): {
_displayName = getText (configFile >> "CfgGlasses" >> _classname >> "displayName");
_picture = getText (configFile >> "CfgGlasses" >> _classname >> "picture");
};
};
case (isClass (configFile >> "CfgMagazines" >> _x)): {
_displayName = getText (configFile >> "CfgMagazines" >> _x >> "displayName");
_picture = getText (configFile >> "CfgMagazines" >> _x >> "picture");
};
case (isClass (configFile >> "CfgVehicles" >> _x)): {
_displayName = getText (configFile >> "CfgVehicles" >> _x >> "displayName");
_picture = getText (configFile >> "CfgVehicles" >> _x >> "picture");
};
case (isClass (configFile >> "CfgGlasses" >> _x)): {
_displayName = getText (configFile >> "CfgGlasses" >> _x >> "displayName");
_picture = getText (configFile >> "CfgGlasses" >> _x >> "picture");
};
};
_listBoxCtrl lbAdd format ["%1", _displayName];
_listBoxCtrl lbSetData [_forEachIndex, _x];
_listBoxCtrl lbSetPicture [_forEachIndex, _picture];
_listBoxCtrl lbSetTextRight [_forEachIndex, str _count];
_listBoxCtrl lbAdd format ["%1", _displayName];
_listBoxCtrl lbSetData [_forEachIndex, _classname];
_listBoxCtrl lbSetPicture [_forEachIndex, _picture];
_listBoxCtrl lbSetTextRight [_forEachIndex, str _count];
};
} forEach (_itemsCountArray select 0);

View File

@ -14,7 +14,7 @@
* Verified Good <BOOL>
*
* Example:
* [] call ace_disarming_fnc_verifyMagazinesMoved
* [stuff] call ace_disarming_fnc_verifyMagazinesMoved
*
* Public: No
*/
@ -26,7 +26,6 @@ PARAMS_4(_startA,_endA,_startB,_endB);
//Quick Lazy Count Check
if (((count _startA) + (count _startB)) != ((count _endA) + (count _endB))) exitWith {
systemChat format ["%1 - %2", ((count _startA) + (count _startB)), ((count _endA) + (count _endB))];
false
};
@ -39,6 +38,4 @@ _problem = false;
_beginingArray deleteAt _index;
} forEach (_endA + _endB);
systemChat format ["%1 - %2", _problem, _beginingArray];
(!_problem) && {_beginingArray isEqualTo []}

View File

@ -1,3 +1,6 @@
//The disarming dialog
//Meant to mimic the real BIS inventory (so people understand how to use it)
class RscText;
class RscPicture;
class RscActiveText;
@ -13,8 +16,7 @@ class GVAR(remoteInventory) {
fadein = 0;
fadeout = 0;
class Colors
{
class Colors {
dragValidBgr[] = {"(profilenamespace getvariable ['IGUI_TEXT_RGB_R',0])","(profilenamespace getvariable ['IGUI_TEXT_RGB_G',1])","(profilenamespace getvariable ['IGUI_TEXT_RGB_B',1])",0.5};
dragInvalidBgr[] = {"(profilenamespace getvariable ['IGUI_ERROR_RGB_R',0.8])","(profilenamespace getvariable ['IGUI_ERROR_RGB_G',0.0])","(profilenamespace getvariable ['IGUI_ERROR_RGB_B',0.0])",0.5};
dragValidBar[] = {"(profilenamespace getvariable ['IGUI_WARNING_RGB_R',0.8])","(profilenamespace getvariable ['IGUI_WARNING_RGB_G',0.5])","(profilenamespace getvariable ['IGUI_WARNING_RGB_B',0.0])",0.5};
@ -86,7 +88,7 @@ class GVAR(remoteInventory) {
h = "1 * ((safeZoneH / 1.2) / 25)";
colorText[] = {1,1,1,0.7};
colorActive[] = {1,1,1,1};
tooltip = "Close";
tooltip = "$str_disp_close";
};
class ExternalContainerBackground: RscPicture {
colorText[] = {1,1,1,0.1};
@ -121,16 +123,16 @@ class GVAR(remoteInventory) {
};
class GroundContainer: RscListBox {
idc = 632;
sizeEx = "0.8 * ( ( ((safezoneW / safezoneH) min 1.2) / 1.2) / 25)";
sizeEx2 = "0.8 * ( ( ((safezoneW / safezoneH) min 1.2) / 1.2) / 25)";
rowHeight = "1.75 * ( ( ((safezoneW / safezoneH) min 1.2) / 1.2) / 25)";
sizeEx = "0.8 * ((((safezoneW / safezoneH) min 1.2) / 1.2) / 25)";
sizeEx2 = "0.8 * ((((safezoneW / safezoneH) min 1.2) / 1.2) / 25)";
rowHeight = "1.75 * ((((safezoneW / safezoneH) min 1.2) / 1.2) / 25)";
canDrag = 0;
colorText[] = {1,1,1,1};
colorBackground[] = {0,0,0,0};
itemBackground[] = {1,1,1,0.2};
itemSpacing = 0.001;
x = "1.5 * (safeZoneH / 40) + (safezoneX + (safezoneW - safeZoneH)/2)";
y = "2.5 * ((safeZoneH / 1.2) / 25) + (safezoneY + (safezoneH - (safeZoneH / 1.2))/2)";
x = "1.5 * (safeZoneH / 40) + (safezoneX + (safezoneW - safeZoneH)/2)";
y = "2.5 * ((safeZoneH / 1.2) / 25) + (safezoneY + (safezoneH - (safeZoneH / 1.2))/2)";
w = "11 * (safeZoneH / 40)";
h = "21.5 * ((safeZoneH / 1.2) / 25)";
};

View File

@ -11,5 +11,6 @@
#include "\z\ace\addons\main\script_macros.hpp"
#define DISARM_CONTAINER "GroundWeaponHolder"
#define DUMMY_ITEM "ACE_DebugPotato"
#define UNIQUE_MAGAZINES ["ACE_key_customKeyMagazine"]