mirror of
https://github.com/EpochModTeam/DayZ-Epoch.git
synced 2025-12-14 04:02:37 +03:00
New vehicle upgrade system
Need test with datsun vehicle to ensure it works fine
This commit is contained in:
@@ -7,6 +7,9 @@ private ["_proceed","_itemIn","_countIn","_missing","_missingQty","_qty","_remov
|
||||
if(DZE_ActionInProgress) exitWith { cutText [(localize "STR_EPOCH_PLAYER_52") , "PLAIN DOWN"]; };
|
||||
DZE_ActionInProgress = true;
|
||||
|
||||
// This is used to find correct upgrade based what upgrades was called allows multiple upgrades per vehicle.
|
||||
_upgrade = _this select 0;
|
||||
|
||||
if (vehicle player != player) exitWith {DZE_ActionInProgress = false; cutText [(localize "STR_EPOCH_ACTIONS_18"), "PLAIN DOWN"]};
|
||||
|
||||
// look for nearest empty vehicle
|
||||
@@ -24,72 +27,87 @@ if (_IsNearVehicle >= 1) then {
|
||||
_vehicle = _findNearestVehicle select 0;
|
||||
|
||||
_notNearestPlayer = _vehicle call dze_isnearest_player;
|
||||
|
||||
|
||||
if (!isNull _vehicle and local _vehicle and !_notNearestPlayer) then {
|
||||
|
||||
_classname = typeOf _vehicle;
|
||||
|
||||
// lookup vehicle and find if any upgrades are available
|
||||
_upgrade = getArray (configFile >> "CfgVehicles" >> _classname >> "upgradeVehicle");
|
||||
_upgrade = getArray (configFile >> "CfgVehicles" >> _classname >> "Upgrades" >> _upgrade);
|
||||
|
||||
if ((count _upgrade) > 0) then {
|
||||
if (!isNil "_upgrade" && (count _upgrade) > 0) then {
|
||||
|
||||
_newclassname = _upgrade select 0;
|
||||
_requirements = _upgrade select 1;
|
||||
|
||||
_requirementsWeapon = _upgrade select 1;
|
||||
_requirementsMagazine = _upgrade select 2;
|
||||
|
||||
_missingQty = 0;
|
||||
_missing = "";
|
||||
|
||||
|
||||
_proceed = true;
|
||||
{
|
||||
_itemIn = _x select 0;
|
||||
_countIn = _x select 1;
|
||||
_qty = { (_x == _itemIn) || (configName(inheritsFrom(configFile >> "cfgMagazines" >> _x)) == _itemIn) } count magazines player;
|
||||
if(_qty < _countIn) exitWith { _missing = _itemIn; _missingQty = (_countIn - _qty); _proceed = false; };
|
||||
} forEach _requirements;
|
||||
|
||||
} forEach _requirementsMagazine;
|
||||
{
|
||||
_itemIn = _x select 0;
|
||||
_countIn = _x select 1;
|
||||
_qty = { (_x == _itemIn) || (configName(inheritsFrom(configFile >> "cfgWeapons" >> _x)) == _itemIn) } count weapons player;
|
||||
if(_qty < _countIn) exitWith { _missing = _itemIn; _missingQty = (_countIn - _qty); _proceed = false; };
|
||||
} forEach _requirementsWeapon;
|
||||
|
||||
if (_proceed) then {
|
||||
|
||||
player playActionNow "Medic";
|
||||
[player,20,true,(getPosATL player)] spawn player_alertZombies;
|
||||
|
||||
_temp_removed_array = [];
|
||||
|
||||
_temp_removed_array_mag = [];
|
||||
_temp_removed_array_wep = [];
|
||||
_removed_total = 0;
|
||||
_tobe_removed_total = 0;
|
||||
|
||||
|
||||
{
|
||||
_removed = 0;
|
||||
_itemIn = _x select 0;
|
||||
_countIn = _x select 1;
|
||||
// diag_log format["Recipe Finish: %1 %2", _itemIn,_countIn];
|
||||
diag_log format["Recipe Finish: %1 %2", _itemIn,_countIn];
|
||||
_tobe_removed_total = _tobe_removed_total + _countIn;
|
||||
|
||||
{
|
||||
{
|
||||
if( (_removed < _countIn) && ((_x == _itemIn) || configName(inheritsFrom(configFile >> "cfgMagazines" >> _x)) == _itemIn)) then {
|
||||
_num_removed = ([player,_x] call BIS_fnc_invRemove);
|
||||
_removed = _removed + _num_removed;
|
||||
_removed_total = _removed_total + _num_removed;
|
||||
if(_num_removed >= 1) then {
|
||||
_temp_removed_array set [count _temp_removed_array,_x];
|
||||
_temp_removed_array_mag set [count _temp_removed_array_mag,_x];
|
||||
};
|
||||
};
|
||||
|
||||
} forEach magazines player;
|
||||
{
|
||||
if( (_removed < _countIn) && ((_x == _itemIn) || configName(inheritsFrom(configFile >> "cfgWeapons" >> _x)) == _itemIn)) then {
|
||||
_num_removed = ([player,_x] call BIS_fnc_invRemove);
|
||||
_removed = _removed + _num_removed;
|
||||
_removed_total = _removed_total + _num_removed;
|
||||
if(_num_removed >= 1) then {
|
||||
_temp_removed_array_wep set [count _temp_removed_array_wep,_x];
|
||||
};
|
||||
};
|
||||
} forEach weapons player;
|
||||
|
||||
} forEach _requirements;
|
||||
|
||||
// all parts removed proceed
|
||||
if (_tobe_removed_total == _removed_total) then {
|
||||
|
||||
|
||||
_objectID = _vehicle getVariable ["ObjectID","0"];
|
||||
_objectUID = _vehicle getVariable ["ObjectUID","0"];
|
||||
|
||||
if(_objectID == "0" && _objectUID == "0") then {
|
||||
|
||||
cutText [(localize "str_epoch_player_50"), "PLAIN DOWN"];
|
||||
|
||||
} else {
|
||||
|
||||
}
|
||||
else {
|
||||
// Get position
|
||||
_location = getposATL _vehicle;
|
||||
|
||||
@@ -98,31 +116,34 @@ if (_IsNearVehicle >= 1) then {
|
||||
|
||||
// Current charID
|
||||
_objectCharacterID = _vehicle getVariable ["CharacterID","0"];
|
||||
|
||||
|
||||
PVDZE_veh_Upgrade = [_vehicle,[_dir,_location],_newclassname,true,_objectCharacterID,player];
|
||||
publicVariableServer "PVDZE_veh_Upgrade";
|
||||
publicVariableServer "PVDZE_veh_Upgrade";
|
||||
|
||||
cutText [(localize "STR_EPOCH_VEHUP_SUCCESS"), "PLAIN DOWN"];
|
||||
};
|
||||
|
||||
} else {
|
||||
|
||||
{player addMagazine _x;} forEach _temp_removed_array;
|
||||
}
|
||||
else {
|
||||
{player addMagazine _x;} forEach _temp_removed_array_mag;
|
||||
{player addWeapon _x;} forEach _temp_removed_array_wep;
|
||||
cutText [format[(localize "str_epoch_player_145"),_removed_total,_tobe_removed_total], "PLAIN DOWN"];
|
||||
|
||||
};
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
_textMissing = getText(configFile >> "CfgMagazines" >> _missing >> "displayName");
|
||||
cutText [format[(localize "str_epoch_player_146"),_missingQty, _textMissing], "PLAIN DOWN"];
|
||||
};
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
cutText [(localize "str_epoch_player_82"), "PLAIN DOWN"];
|
||||
};
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
cutText [(localize "str_epoch_player_245"), "PLAIN DOWN"];
|
||||
};
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
cutText [(localize "STR_EPOCH_PLAYER_27"), "PLAIN DOWN"];
|
||||
};
|
||||
|
||||
DZE_ActionInProgress = false;
|
||||
DZE_ActionInProgress = false;
|
||||
Reference in New Issue
Block a user