mirror of
https://github.com/EpochModTeam/DayZ-Epoch.git
synced 2025-12-14 04:02:37 +03:00
Building upgrades from backpack
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
[NEW] Added config variable DZE_HaloSpawnHeight. @ebayShopper
|
[NEW] Added config variable DZE_HaloSpawnHeight. @ebayShopper
|
||||||
[NEW] Added M4SPR_DZE class which spawns with 30Rnd Stanag by default instead of 20Rnd. #1823 @AirwavesMan
|
[NEW] Added M4SPR_DZE class which spawns with 30Rnd Stanag by default instead of 20Rnd. #1823 @AirwavesMan
|
||||||
|
[NEW] Building upgrades now source parts from the player's backpack and main inventory @icomrade
|
||||||
|
|
||||||
[CHANGED] Added NWAF tent camp to Chernarus points of interests and removed trains POI for now.
|
[CHANGED] Added NWAF tent camp to Chernarus points of interests and removed trains POI for now.
|
||||||
[CHANGED] Turbo and HoldBreath keybindings are now allowed again. @icomrade
|
[CHANGED] Turbo and HoldBreath keybindings are now allowed again. @icomrade
|
||||||
|
|||||||
@@ -2,54 +2,52 @@
|
|||||||
DayZ Base Building Upgrades
|
DayZ Base Building Upgrades
|
||||||
Made for DayZ Epoch please ask permission to use/edit/distrubute email vbawol@veteranbastards.com.
|
Made for DayZ Epoch please ask permission to use/edit/distrubute email vbawol@veteranbastards.com.
|
||||||
*/
|
*/
|
||||||
private ["_location","_dir","_classname","_missing","_text","_proceed","_num_removed","_object","_missingQty","_itemIn","_countIn","_qty","_removed","_removed_total","_tobe_removed_total","_objectID","_objectUID","_temp_removed_array","_textMissing","_newclassname","_requirements","_obj","_upgrade","_lockable","_combination_1","_combination_2","_combination_3","_combination","_objectCharacterID","_ownerID"];
|
private ["_location","_dir","_classname","_missing","_text","_proceed","_num_removed","_object","_missingQty","_itemIn","_countIn","_qty","_removed","_removed_total","_tobe_removed_total","_objectID","_objectUID","_temp_removed_array","_textMissing","_newclassname","_requirements","_obj","_upgrade","_lockable","_combination_1","_combination_2","_combination_3","_combination","_objectCharacterID","_ownerID","_qtyBP","_forEachIndex","_bpMags","_countNew","_bp2Remove","_count","_friendsArr","_vector","_temp_BP_removed_array"];
|
||||||
|
|
||||||
if (dayz_actionInProgress) exitWith {localize "str_epoch_player_52" call dayz_rollingMessages;};
|
if (dayz_actionInProgress) exitWith {localize "str_epoch_player_52" call dayz_rollingMessages;};
|
||||||
dayz_actionInProgress = true;
|
dayz_actionInProgress = true;
|
||||||
|
|
||||||
player removeAction s_player_upgrade_build;
|
player removeAction s_player_upgrade_build;
|
||||||
s_player_upgrade_build = 1;
|
s_player_upgrade_build = 1;
|
||||||
|
|
||||||
// get cursortarget from addaction
|
|
||||||
_obj = _this select 3;
|
_obj = _this select 3;
|
||||||
|
|
||||||
// Find objectID
|
|
||||||
_objectID = _obj getVariable ["ObjectID","0"];
|
_objectID = _obj getVariable ["ObjectID","0"];
|
||||||
|
|
||||||
// Find objectUID
|
|
||||||
_objectUID = _obj getVariable ["ObjectUID","0"];
|
_objectUID = _obj getVariable ["ObjectUID","0"];
|
||||||
|
|
||||||
if (_objectID == "0" && _objectUID == "0") exitWith {dayz_actionInProgress = false; s_player_upgrade_build = -1; localize "str_epoch_player_50" call dayz_rollingMessages;};
|
if (_objectID == "0" && _objectUID == "0") exitWith {dayz_actionInProgress = false; s_player_upgrade_build = -1; localize "str_epoch_player_50" call dayz_rollingMessages;};
|
||||||
|
|
||||||
// Get classname
|
|
||||||
_classname = typeOf _obj;
|
_classname = typeOf _obj;
|
||||||
|
|
||||||
// Find display name
|
|
||||||
_text = getText (configFile >> "CfgVehicles" >> _classname >> "displayName");
|
_text = getText (configFile >> "CfgVehicles" >> _classname >> "displayName");
|
||||||
|
|
||||||
// Find next upgrade
|
|
||||||
_upgrade = getArray (configFile >> "CfgVehicles" >> _classname >> "upgradeBuilding");
|
_upgrade = getArray (configFile >> "CfgVehicles" >> _classname >> "upgradeBuilding");
|
||||||
|
|
||||||
if ((count _upgrade) > 0) then {
|
if ((count _upgrade) > 0) then {
|
||||||
|
|
||||||
_newclassname = _upgrade select 0;
|
_newclassname = _upgrade select 0;
|
||||||
|
|
||||||
_lockable = 0;
|
_lockable = 0;
|
||||||
if(isNumber (configFile >> "CfgVehicles" >> _newclassname >> "lockable")) then {
|
if(isNumber (configFile >> "CfgVehicles" >> _newclassname >> "lockable")) then {
|
||||||
_lockable = getNumber(configFile >> "CfgVehicles" >> _newclassname >> "lockable");
|
_lockable = getNumber(configFile >> "CfgVehicles" >> _newclassname >> "lockable");
|
||||||
};
|
};
|
||||||
|
|
||||||
_requirements = _upgrade select 1;
|
_requirements = _upgrade select 1;
|
||||||
|
|
||||||
_missingQty = 0;
|
_missingQty = 0;
|
||||||
_missing = "";
|
_missing = "";
|
||||||
|
_bpMags = [];
|
||||||
|
_bp2Remove = [];
|
||||||
|
_qtyBP = 0;
|
||||||
_proceed = true;
|
_proceed = true;
|
||||||
|
|
||||||
{
|
{
|
||||||
_itemIn = _x select 0;
|
_itemIn = _x select 0;
|
||||||
_countIn = _x select 1;
|
_countIn = _x select 1;
|
||||||
_qty = { (_x == _itemIn) || (configName(inheritsFrom(configFile >> "cfgMagazines" >> _x)) == _itemIn) } count magazines player;
|
_qty = { (_x == _itemIn) || {configName(inheritsFrom(configFile >> "cfgMagazines" >> _x)) == _itemIn} } count magazines player;
|
||||||
if(_qty < _countIn) exitWith { _missing = _itemIn; _missingQty = (_countIn - _qty); _proceed = false; };
|
|
||||||
|
if (!isNull (UnitBackpack Player) && {_qty < _countIn}) then {
|
||||||
|
_bpMags = (getMagazineCargo (unitbackpack player));
|
||||||
|
{
|
||||||
|
if ((_x == _itemIn) || {configName(inheritsFrom(configFile >> "cfgMagazines" >> _x)) == _itemIn}) exitWith {
|
||||||
|
_qtyBP = ((_bpMags select 1) select _forEachIndex);
|
||||||
|
_bp2Remove set [(count _bp2Remove), _x];
|
||||||
|
};
|
||||||
|
} forEach (_bpMags select 0);
|
||||||
|
};
|
||||||
|
|
||||||
|
if ((_qty < _countIn) && {_qtyBP < (_countIn - _qty)}) exitWith { _missing = _itemIn; _missingQty = (_countIn - (_qty + _qtyBP)); _proceed = false; };
|
||||||
} forEach _requirements;
|
} forEach _requirements;
|
||||||
|
|
||||||
if (_proceed) then {
|
if (_proceed) then {
|
||||||
@@ -58,6 +56,7 @@ if ((count _upgrade) > 0) then {
|
|||||||
[player,20,true,(getPosATL player)] spawn player_alertZombies;
|
[player,20,true,(getPosATL player)] spawn player_alertZombies;
|
||||||
|
|
||||||
_temp_removed_array = [];
|
_temp_removed_array = [];
|
||||||
|
_temp_BP_removed_array = [];
|
||||||
_removed_total = 0;
|
_removed_total = 0;
|
||||||
_tobe_removed_total = 0;
|
_tobe_removed_total = 0;
|
||||||
|
|
||||||
@@ -65,7 +64,6 @@ if ((count _upgrade) > 0) then {
|
|||||||
_removed = 0;
|
_removed = 0;
|
||||||
_itemIn = _x select 0;
|
_itemIn = _x select 0;
|
||||||
_countIn = _x select 1;
|
_countIn = _x select 1;
|
||||||
// diag_log format["Recipe Finish: %1 %2", _itemIn,_countIn];
|
|
||||||
_tobe_removed_total = _tobe_removed_total + _countIn;
|
_tobe_removed_total = _tobe_removed_total + _countIn;
|
||||||
|
|
||||||
{
|
{
|
||||||
@@ -77,38 +75,40 @@ if ((count _upgrade) > 0) then {
|
|||||||
_temp_removed_array set [count _temp_removed_array,_x];
|
_temp_removed_array set [count _temp_removed_array,_x];
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
} forEach magazines player;
|
} forEach magazines player;
|
||||||
|
|
||||||
|
if (!isNull (UnitBackpack Player) && {_removed < _countIn}) then {
|
||||||
|
_bpMags = (getMagazineCargo (unitbackpack player));
|
||||||
|
clearMagazineCargoGlobal (unitbackpack player);
|
||||||
|
|
||||||
|
{
|
||||||
|
_count = ((_bpMags select 1) select _forEachIndex);
|
||||||
|
_countNew = _count;
|
||||||
|
if (_x in _bp2Remove && {(_x == _itemIn) || {configName(inheritsFrom(configFile >> "cfgMagazines" >> _x)) == _itemIn}}) then {
|
||||||
|
_countNew = (_count - (_countIn - _removed));
|
||||||
|
_bp2Remove = _bp2Remove - [_x];
|
||||||
|
};
|
||||||
|
if (_countNew > 0) then {
|
||||||
|
(unitbackpack player) addMagazineCargoGlobal [_x, _countNew];
|
||||||
|
};
|
||||||
|
_num_removed = (_count - _countNew);
|
||||||
|
_temp_BP_removed_array set [(count _temp_BP_removed_array), [_x, _num_removed]];
|
||||||
|
_removed_total = _removed_total + _num_removed;
|
||||||
|
} forEach (_bpMags select 0);
|
||||||
|
};
|
||||||
|
|
||||||
} forEach _requirements;
|
} forEach _requirements;
|
||||||
|
|
||||||
// all parts removed proceed
|
|
||||||
if (_tobe_removed_total == _removed_total) then {
|
if (_tobe_removed_total == _removed_total) then {
|
||||||
|
|
||||||
// Get position
|
|
||||||
_location = _obj getVariable["OEMPos",(getposATL _obj)];
|
_location = _obj getVariable["OEMPos",(getposATL _obj)];
|
||||||
|
|
||||||
// Get direction
|
|
||||||
_dir = getDir _obj;
|
_dir = getDir _obj;
|
||||||
// Get vector
|
|
||||||
_vector = [(vectorDir _obj),(vectorUp _obj)];
|
_vector = [(vectorDir _obj),(vectorUp _obj)];
|
||||||
|
|
||||||
// Current charID
|
|
||||||
_objectCharacterID = _obj getVariable ["CharacterID","0"];
|
_objectCharacterID = _obj getVariable ["CharacterID","0"];
|
||||||
|
|
||||||
_classname = _newclassname;
|
_classname = _newclassname;
|
||||||
|
|
||||||
// Create new object
|
|
||||||
_object = createVehicle [_classname, [0,0,0], [], 0, "CAN_COLLIDE"];
|
_object = createVehicle [_classname, [0,0,0], [], 0, "CAN_COLLIDE"];
|
||||||
|
|
||||||
// Set direction
|
|
||||||
_object setDir _dir;
|
_object setDir _dir;
|
||||||
_object setVariable["memDir",_dir,true];
|
_object setVariable["memDir",_dir,true];
|
||||||
|
|
||||||
// Set vector
|
|
||||||
_object setVectorDirAndUp _vector;
|
_object setVectorDirAndUp _vector;
|
||||||
|
|
||||||
// Set location
|
|
||||||
_object setPosATL _location;
|
_object setPosATL _location;
|
||||||
|
|
||||||
if (_lockable == 3) then {
|
if (_lockable == 3) then {
|
||||||
@@ -144,8 +144,10 @@ if ((count _upgrade) > 0) then {
|
|||||||
player reveal _object;
|
player reveal _object;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
{player addMagazine _x;} count _temp_removed_array;
|
{player addMagazine _x;} count _temp_removed_array;
|
||||||
|
if (count _temp_BP_removed_array > 0) then {
|
||||||
|
{(unitbackpack player) addMagazineCargoGlobal _x} count _temp_BP_removed_array;
|
||||||
|
};
|
||||||
format[localize "str_epoch_player_145",_removed_total,_tobe_removed_total] call dayz_rollingMessages;
|
format[localize "str_epoch_player_145",_removed_total,_tobe_removed_total] call dayz_rollingMessages;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user