diff --git a/SQF/dayz_code/Configs/CfgMagazines.hpp b/SQF/dayz_code/Configs/CfgMagazines.hpp index 50518e158..6caf3a1c9 100644 --- a/SQF/dayz_code/Configs/CfgMagazines.hpp +++ b/SQF/dayz_code/Configs/CfgMagazines.hpp @@ -171,6 +171,95 @@ class CfgMagazines { }; }; + + class ItemORP: CA_Magazine + { + scope = 2; + count = 1; + type = 256; + displayName = "HowTo: Offroad Performance"; // TODO: localize + model = "\z\addons\dayz_epoch\models\doc_generic.p3d"; + picture = "\z\addons\dayz_epoch\pictures\equip_doc_generic_ca.paa"; + descriptionShort = "Offroad performace manual."; // TODO: localize + weight = 0.1; + sfx = "document"; + class ItemActions + { + class Upgrades + { + text = "Upgrade Vehicle"; // TODO: localize + script = "spawn player_upgradeVehicle;"; + }; + }; + + }; + + class ItemAVE: CA_Magazine + { + scope = 2; + count = 1; + type = 256; + displayName = "HowTo: Vehicle Maintenance"; // TODO: localize + model = "\z\addons\dayz_epoch\models\doc_generic.p3d"; + picture = "\z\addons\dayz_epoch\pictures\equip_doc_generic_ca.paa"; + descriptionShort = "Vehicle maintenance and engineering manual."; // TODO: localize + weight = 0.1; + sfx = "document"; + class ItemActions + { + class Upgrades + { + text = "Upgrade Vehicle"; // TODO: localize + script = "spawn player_upgradeVehicle;"; + }; + }; + + }; + + class ItemLRK: CA_Magazine + { + scope = 2; + count = 1; + type = 256; + displayName = "HowTo: Luggage Rack"; // TODO: localize + model = "\z\addons\dayz_epoch\models\doc_generic.p3d"; + picture = "\z\addons\dayz_epoch\pictures\equip_doc_generic_ca.paa"; + descriptionShort = "Luggage Rack install guide."; // TODO: localize + weight = 0.1; + sfx = "document"; + class ItemActions + { + class Upgrades + { + text = "Upgrade Vehicle"; // TODO: localize + script = "spawn player_upgradeVehicle;"; + }; + }; + + }; + + class ItemTNK: CA_Magazine + { + scope = 2; + count = 1; + type = 256; + displayName = "HowTo: Fuel Tank"; // TODO: localize + model = "\z\addons\dayz_epoch\models\doc_generic.p3d"; + picture = "\z\addons\dayz_epoch\pictures\equip_doc_generic_ca.paa"; + descriptionShort = "Fuel Tank install guide."; // TODO: localize + weight = 0.1; + sfx = "document"; + class ItemActions + { + class Upgrades + { + text = "Upgrade Vehicle"; // TODO: localize + script = "spawn player_upgradeVehicle;"; + }; + }; + + }; + class ItemLetter: CA_Magazine { scope = 2; diff --git a/SQF/dayz_code/Configs/CfgVehicles/LAND/Volha.hpp b/SQF/dayz_code/Configs/CfgVehicles/LAND/Volha.hpp index 58231104a..139f21102 100644 --- a/SQF/dayz_code/Configs/CfgVehicles/LAND/Volha.hpp +++ b/SQF/dayz_code/Configs/CfgVehicles/LAND/Volha.hpp @@ -265,6 +265,7 @@ class Volha_1_TK_CIV_EP1: Volha_TK_CIV_Base_EP1 scope = 2; accuracy = 1000; displayname = "GAZ (blue)"; + upgradeVehicle = {"Volha_1_TK_CIV_EP1_DZE1",{{"ItemORP",1},{"PartEngine",2}}}; }; class Volha_2_TK_CIV_EP1: Volha_TK_CIV_Base_EP1 { @@ -273,6 +274,7 @@ class Volha_2_TK_CIV_EP1: Volha_TK_CIV_Base_EP1 displayname = "GAZ (grey)"; hiddenSelections[] = {"Camo1"}; hiddenSelectionsTextures[] = {"ca\wheeled_E\Volha\Data\Volha_Gray_ECIV_CO"}; + upgradeVehicle = {"Volha_2_TK_CIV_EP1_DZE1",{{"ItemORP",1},{"PartEngine",2}}}; }; class VolhaLimo_TK_CIV_EP1: Volha_TK_CIV_Base_EP1 { @@ -281,6 +283,7 @@ class VolhaLimo_TK_CIV_EP1: Volha_TK_CIV_Base_EP1 displayname = "GAZ Limo"; hiddenSelections[] = {"Camo1"}; hiddenSelectionsTextures[] = {"ca\wheeled_E\Volha\Data\Volha_Black_ECIV_CO"}; + upgradeVehicle = {"VolhaLimo_TK_CIV_EP1_DZE1",{{"ItemORP",1},{"PartEngine",2}}}; }; // Performance 1 @@ -288,22 +291,25 @@ class VolhaLimo_TK_CIV_EP1_DZE1: VolhaLimo_TK_CIV_EP1 { maxspeed = 150; // max engine limit 125-130 terrainCoef = 2.5; + upgradeVehicle = {"VolhaLimo_TK_CIV_EP1_DZE2",{{"ItemAVE",1},{"PartGeneric",1},{"ItemTankTrap",1}}}; }; class Volha_1_TK_CIV_EP1_DZE1: Volha_1_TK_CIV_EP1 { maxspeed = 150; // car 100 terrainCoef = 2.5; + upgradeVehicle = {"Volha_1_TK_CIV_EP1_DZE2",{{"ItemAVE",1},{"PartGeneric",1},{"ItemTankTrap",1}}}; }; class Volha_2_TK_CIV_EP1_DZE1: Volha_2_TK_CIV_EP1 { maxspeed = 150; // car 100 terrainCoef = 2.5; + upgradeVehicle = {"Volha_2_TK_CIV_EP1_DZE2",{{"ItemAVE",1},{"PartGeneric",1},{"ItemTankTrap",1}}}; }; -// Armmor 2 +// Armor 2 class VolhaLimo_TK_CIV_EP1_DZE2: VolhaLimo_TK_CIV_EP1_DZE1 { armor = 50; // car 20 - + upgradeVehicle = {"VolhaLimo_TK_CIV_EP1_DZE3",{{"ItemLRK",1},{"ItemTent",1}}}; class HitPoints: HitPoints { class HitLFWheel: HitLFWheel @@ -359,7 +365,7 @@ class VolhaLimo_TK_CIV_EP1_DZE2: VolhaLimo_TK_CIV_EP1_DZE1 class Volha_1_TK_CIV_EP1_DZE2: Volha_1_TK_CIV_EP1_DZE1 { armor = 50; // car 20 - + upgradeVehicle = {"Volha_1_TK_CIV_EP1_DZE3",{{"ItemLRK",1},{"ItemTent",1}}}; class HitPoints: HitPoints { class HitLFWheel: HitLFWheel @@ -415,7 +421,7 @@ class Volha_1_TK_CIV_EP1_DZE2: Volha_1_TK_CIV_EP1_DZE1 class Volha_2_TK_CIV_EP1_DZE2: Volha_2_TK_CIV_EP1_DZE1 { armor = 50; // car 20 - + upgradeVehicle = {"Volha_2_TK_CIV_EP1_DZE3",{{"ItemLRK",1},{"ItemTent",1}}}; class HitPoints: HitPoints { class HitLFWheel: HitLFWheel @@ -474,18 +480,21 @@ class VolhaLimo_TK_CIV_EP1_DZE3: VolhaLimo_TK_CIV_EP1_DZE2 transportMaxWeapons = 20; // car 10 transportMaxMagazines = 100; // car 50 transportmaxbackpacks = 4; // car 2 + upgradeVehicle = {"VolhaLimo_TK_CIV_EP1_DZE4",{{"ItemTNK",1},{"PartFueltank",2}}}; }; class Volha_1_TK_CIV_EP1_DZE3: Volha_1_TK_CIV_EP1_DZE2 { transportMaxWeapons = 20; // car 10 transportMaxMagazines = 100; // car 50 transportmaxbackpacks = 4; // car 2 + upgradeVehicle = {"Volha_1_TK_CIV_EP1_DZE4",{{"ItemTNK",1},{"PartFueltank",2}}}; }; class Volha_2_TK_CIV_EP1_DZE3: Volha_2_TK_CIV_EP1_DZE2 { transportMaxWeapons = 20; // car 10 transportMaxMagazines = 100; // car 50 transportmaxbackpacks = 4; // car 2 + upgradeVehicle = {"Volha_2_TK_CIV_EP1_DZE4",{{"ItemTNK",1},{"PartFueltank",2}}}; }; // Fuel 4 class VolhaLimo_TK_CIV_EP1_DZE4: VolhaLimo_TK_CIV_EP1_DZE3 diff --git a/SQF/dayz_code/compile/player_upgradeVehicle.sqf b/SQF/dayz_code/compile/player_upgradeVehicle.sqf new file mode 100644 index 000000000..d2337be31 --- /dev/null +++ b/SQF/dayz_code/compile/player_upgradeVehicle.sqf @@ -0,0 +1,167 @@ +/* + DayZ Epoch Vehicle Upgrades + Made for DayZ Unleashed by [VB]AWOL please ask permission to use/edit/distrubute email vbawol@veteranbastards.com. +*/ +private ["_proceed","_itemIn","_countIn","_missing","_missingQty","_qty","_removed","_tobe_removed_total","_textMissing","_num_removed","_removed_total","_temp_removed_array","_countr","_objectID","_objectUID","_location","_dir","_objectCharacterID","_weapons","_magazines","_backpacks","_classname","_object","_holder","_objWpnTypes","_objWpnQty","_newclassname","_requirements","_upgrade","_vehicle","_findNearestVehicles","_findNearestVehicle","_IsNearVehicle"]; + +if(TradeInprogress) exitWith { cutText [(localize "STR_EPOCH_PLAYER_52") , "PLAIN DOWN"]; }; +TradeInprogress = true; + +// look for nearest vehicle +_findNearestVehicles = nearestObjects [player, ["LandVehicle"], 10]; +_findNearestVehicle = []; +{ + if (alive _x) exitWith { + _findNearestVehicle set [(count _findNearestVehicle),_x]; + }; +} foreach _findNearestVehicles; + +_IsNearVehicle = count (_findNearestVehicle); +if (_IsNearVehicle >= 1) then { + + _vehicle = _findNearestVehicle select 0; + + if (!isNull _vehicle and local _vehicle) then { + + _classname = typeOf _vehicle; + + // lookup vehicle and find if any upgrades are available + _upgrade = getArray (configFile >> "CfgVehicles" >> _classname >> "upgradeVehicle"); + + if ((count _upgrade) > 0) then { + + _newclassname = _upgrade select 0; + _requirements = _upgrade select 1; + + _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; + + if (_proceed) then { + + player playActionNow "Medic"; + [player,20,true,(getPosATL player)] spawn player_alertZombies; + + _temp_removed_array = []; + _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]; + _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]; + }; + }; + + } forEach magazines player; + + } forEach _requirements; + + // all parts removed proceed + if (_tobe_removed_total == _removed_total) then { + + _objectID = _vehicle getVariable ["ObjectID","0"]; + _objectUID = _vehicle getVariable ["ObjectUID","0"]; + + PVDZE_obj_Delete = [_objectID,_objectUID,player]; + publicVariableServer "PVDZE_obj_Delete"; + + // Get position + _location = getposATL _vehicle; + + // Get direction + _dir = getDir _vehicle; + + // Current charID + _objectCharacterID = _vehicle getVariable ["CharacterID","0"]; + + _weapons = getWeaponCargo _vehicle; + _magazines = getMagazineCargo _vehicle; + _backpacks = getBackpackCargo _vehicle; + + // remove old vehicle + deleteVehicle _vehicle; + + _classname = _newclassname; + + // Create new object + _object = createVehicle [_classname, [0,0,0], [], 0, "CAN_COLLIDE"]; + + // Set direction + _object setDir _dir; + + // Set location + _object setPosATL _location; + + PVDZE_veh_Publish2 = [_object,[_dir,_location],_classname,true,_objectCharacterID,player]; + publicVariableServer "PVDZE_veh_Publish2"; + + _holder = _object; + + //Add weapons + _objWpnTypes = _weapons select 0; + _objWpnQty = _weapons select 1; + _countr = 0; + { + _holder addweaponcargoGlobal [_x,(_objWpnQty select _countr)]; + _countr = _countr + 1; + } forEach _objWpnTypes; + + //Add Magazines + _objWpnTypes = _magazines select 0; + _objWpnQty = _magazines select 1; + _countr = 0; + { + _holder addmagazinecargoGlobal [_x,(_objWpnQty select _countr)]; + _countr = _countr + 1; + } forEach _objWpnTypes; + + //Add Backpacks + _objWpnTypes = _backpacks select 0; + _objWpnQty = _backpacks select 1; + _countr = 0; + { + _holder addbackpackcargoGlobal [_x,(_objWpnQty select _countr)]; + _countr = _countr + 1; + } forEach _objWpnTypes; + + player reveal _object; + + } else { + + {player addMagazine _x;} forEach _temp_removed_array; + cutText [format[(localize "str_epoch_player_145"),_removed_total,_tobe_removed_total], "PLAIN DOWN"]; + + }; + } else { + _textMissing = getText(configFile >> "CfgMagazines" >> _missing >> "displayName"); + cutText [format[(localize "str_epoch_player_146"),_missingQty, _textMissing], "PLAIN DOWN"]; + }; + + } else { + cutText [(localize "str_epoch_player_82"), "PLAIN DOWN"]; + }; + + } else { + cutText [(localize "str_epoch_player_245"), "PLAIN DOWN"]; + }; +}; + +TradeInprogress = false; \ No newline at end of file diff --git a/SQF/dayz_code/init/compiles.sqf b/SQF/dayz_code/init/compiles.sqf index c4cde8373..51610af3b 100644 --- a/SQF/dayz_code/init/compiles.sqf +++ b/SQF/dayz_code/init/compiles.sqf @@ -106,6 +106,8 @@ if (!isDedicated) then { player_sleep = compile preprocessFileLineNumbers "\z\addons\dayz_code\actions\player_sleep.sqf"; //player_mineOre = compile preprocessFileLineNumbers "\z\addons\dayz_code\actions\player_mineOre.sqf"; player_antiWall = compile preprocessFileLineNumbers "\z\addons\dayz_code\compile\player_antiWall.sqf"; + + player_upgradeVehicle = compile preprocessFileLineNumbers "\z\addons\dayz_code\compile\player_upgradeVehicle.sqf"; //ui player_selectSlot = compile preprocessFileLineNumbers "\z\addons\dayz_code\compile\ui_selectSlot.sqf";