From 98bfee8bdf22020143483ac08b793788eb0b46ee Mon Sep 17 00:00:00 2001 From: Bruce Date: Fri, 29 Apr 2016 23:02:25 +0200 Subject: [PATCH] added plotManagement by DevZupa --- .../Configs/RscDisplay/plotManagement.hpp | 187 ++++++++++++++++++ .../actions/player_buildingDowngrade.sqf | 25 ++- SQF/dayz_code/actions/player_upgrade.sqf | 27 ++- .../plotManagement/initPlotManagement.sqf | 22 +++ .../actions/plotManagement/maintain_area.sqf | 148 ++++++++++++++ .../plotManagement/maintain_areaSC.sqf | 121 ++++++++++++ .../actions/plotManagement/plotAddFriend.sqf | 24 +++ .../actions/plotManagement/plotGetFriends.sqf | 11 ++ .../plotManagement/plotNearbyHumans.sqf | 13 ++ .../actions/plotManagement/plotObjects.sqf | 18 ++ .../plotManagement/plotRemoveFriend.sqf | 25 +++ .../plotManagement/plotToggleMarkers.sqf | 81 ++++++++ SQF/dayz_code/compile/dze_buildChecks.sqf | 25 ++- SQF/dayz_code/compile/fn_selfActions.sqf | 97 ++++++++- SQF/dayz_code/config.cpp | 5 +- SQF/dayz_code/configVariables.sqf | 8 + SQF/dayz_code/init/variables.sqf | 3 + .../compile/server_updateObject.sqf | 10 +- SQF/dayz_server/system/server_monitor.sqf | 11 +- 19 files changed, 843 insertions(+), 18 deletions(-) create mode 100644 SQF/dayz_code/Configs/RscDisplay/plotManagement.hpp create mode 100644 SQF/dayz_code/actions/plotManagement/initPlotManagement.sqf create mode 100644 SQF/dayz_code/actions/plotManagement/maintain_area.sqf create mode 100644 SQF/dayz_code/actions/plotManagement/maintain_areaSC.sqf create mode 100644 SQF/dayz_code/actions/plotManagement/plotAddFriend.sqf create mode 100644 SQF/dayz_code/actions/plotManagement/plotGetFriends.sqf create mode 100644 SQF/dayz_code/actions/plotManagement/plotNearbyHumans.sqf create mode 100644 SQF/dayz_code/actions/plotManagement/plotObjects.sqf create mode 100644 SQF/dayz_code/actions/plotManagement/plotRemoveFriend.sqf create mode 100644 SQF/dayz_code/actions/plotManagement/plotToggleMarkers.sqf diff --git a/SQF/dayz_code/Configs/RscDisplay/plotManagement.hpp b/SQF/dayz_code/Configs/RscDisplay/plotManagement.hpp new file mode 100644 index 000000000..14fd2c934 --- /dev/null +++ b/SQF/dayz_code/Configs/RscDisplay/plotManagement.hpp @@ -0,0 +1,187 @@ + +class RscTextT +{ + access = 0; + type = 0; + idc = -1; + colorBackground[] = {0,0,0,0}; + colorText[] = {0.8784,0.8471,0.651,1}; + text = ""; + fixedWidth = 0; + x = 0; + y = 0; + h = 0.037; + w = 0.3; + style = 0; + shadow = 2; + font = "Zeppelin32"; + SizeEx = 0.03921; +}; + + +class PlotManagement +{ + idd = 711194; + onLoad = "uiNamespace setVariable ['PlotManagement', _this select 0]"; + class Controls { + class RscText_7000: RscTextT + { + idc = 7000; + x = 0.30 * safezoneW + safezoneX; + y = 0.15 * safezoneH + safezoneY; + w = 0.30 * safezoneW; + h = 0.65 * safezoneH; + colorBackground[] = {0,0,0,0.8}; + }; + + class RscText_7007: RscTextT + { + idc = 7007; + text = "Plot Management"; + x = 0.30 * safezoneW + safezoneX; + y = 0.15 * safezoneH + safezoneY; + w = 0.30 * safezoneW; + h = 0.05 * safezoneH; + colorBackground[] = {0,0,0,0.8}; + colorText[] = {1,1,1,1}; + }; + + class RscShortcutButton_7009: ZSC_RscButtonMenu + { + idc = -1; + text = "Dome"; + x = 0.31 * safezoneW + safezoneX; + y = 0.22 * safezoneH + safezoneY; + w = 0.08 * safezoneW; + onButtonClick = "call PlotPreview;"; + }; + + class RscShortcutButton_7010: ZSC_RscButtonMenu + { + idc = -1; + text = "Refresh"; + x = 0.41 * safezoneW + safezoneX; + y = 0.22 * safezoneH + safezoneY; + w = 0.08 * safezoneW; + onButtonClick = "[""preview""] call MaintainPlot;"; + }; + + class RscShortcutButton_7011: ZSC_RscButtonMenu + { + idc = -1; + text = "Maintain"; + x = 0.51 * safezoneW + safezoneX; + y = 0.22 * safezoneH + safezoneY; + w = 0.08 * safezoneW; + onButtonClick = "[""maintain""] call MaintainPlot;"; + }; + class RscText_7012: RscTextT + { + idc = 7012; + text = ""; + x = 0.31 * safezoneW + safezoneX; + y = 0.30 * safezoneH + safezoneY; + w = 0.30 * safezoneW; + h = 0.05 * safezoneH; + colorText[] = {1,1,1,1}; + + }; + + class RscText_7014: RscStructuredText + { + idc = 7014; + text = ""; + x = 0.30 * safezoneW + safezoneX; + y = 0.15 * safezoneH + safezoneY; + w = 0.30 * safezoneW; + h = 0.03 * safezoneH; + class Attributes { + align = "right"; + }; + }; + + class RscText_7013: RscTextT + { + idc = 7013; + text = ""; + x = 0.31 * safezoneW + safezoneX; + y = 0.33 * safezoneH + safezoneY; + w = 0.30 * safezoneW; + h = 0.03 * safezoneH; + colorText[] = {1,1,1,1}; + }; + + + class RscText_7008: RscTextT + { + idc = -1; + text = "Humans Nearby"; + x = 0.31 * safezoneW + safezoneX; + y = 0.38 * safezoneH + safezoneY; + w = 0.13 * safezoneW; + h = 0.03 * safezoneH; + colorText[] = {1,1,1,1}; + }; + class RscText_7003: RscTextT + { + idc = -1; + text = "PlotFriends"; + x = 0.45 * safezoneW + safezoneX; + y = 0.38 * safezoneH + safezoneY; + w = 0.13 * safezoneW; + h = 0.03 * safezoneH; + colorText[] = {1,1,1,1}; + }; + + + class RscListbox_7001: RscListbox + { + idc = 7001; + x = 0.31* safezoneW + safezoneX; + y = 0.41 * safezoneH + safezoneY; + w = 0.13 * safezoneW; + h = 0.30 * safezoneH; + soundSelect[] = {"",0.1,1}; + colorBackground[] = {0.1,0.1,0.1,0.8}; + }; + class RscListbox_7002: RscListbox + { + idc = 7002; + x = 0.45 * safezoneW + safezoneX; + y = 0.41* safezoneH + safezoneY; + w = 0.13 * safezoneW; + h = 0.30 * safezoneH; + soundSelect[] = {"",0.1,1}; + colorBackground[] = {0.1,0.1,0.1,0.8}; + }; + class RscShortcutButton_7004: ZSC_RscButtonMenu + { + idc = -1; + text = "Add"; + x = 0.33 * safezoneW + safezoneX; + y = 0.70 * safezoneH + safezoneY; + w = 0.08 * safezoneW; + onButtonClick = "[(lbCurSel 7001)] call PlotAddFriend;"; + }; + class RscShortcutButton_7005: ZSC_RscButtonMenu + { + idc = -1; + text = "Delete"; + x = 0.47 * safezoneW + safezoneX; + y = 0.70 * safezoneH + safezoneY; + w = 0.08 * safezoneW; + onButtonClick = "[(lbCurSel 7002)] call PlotRemoveFriend;"; + }; + class RscShortcutButton_7006: ZSC_RscButtonMenu + { + idc = -1; + text = "Close"; + x = 0.40 * safezoneW + safezoneX; + y = 0.74 * safezoneH + safezoneY; + w = 0.08 * safezoneW; + + onButtonClick = "((ctrlParent (_this select 0)) closeDisplay 9000);"; + }; + + }; +}; diff --git a/SQF/dayz_code/actions/player_buildingDowngrade.sqf b/SQF/dayz_code/actions/player_buildingDowngrade.sqf index e47a58e2b..e030755ed 100644 --- a/SQF/dayz_code/actions/player_buildingDowngrade.sqf +++ b/SQF/dayz_code/actions/player_buildingDowngrade.sqf @@ -43,11 +43,28 @@ if(_IsNearPlot == 0) then { if(dayz_characterID == _ownerID) then { _canBuildOnPlot = true; } else { - _friendlies = player getVariable ["friendlyTo",[]]; - // check if friendly to owner - if(_ownerID in _friendlies) then { - _canBuildOnPlot = true; + // plotManagement // + if( DZE_plotManagement ) then { + _friendlies = _nearestPole getVariable ["plotfriends",[]]; + _fuid = []; + { + _friendUID = _x select 0; + _fuid = _fuid + [_friendUID]; + } forEach _friendlies; + // check if friendly to owner + if(dayz_characterID in _fuid) then { + _canBuildOnPlot = true; + }; + } else { + // plotManagement // + _friendlies = player getVariable ["friendlyTo",[]]; + // check if friendly to owner + if(_ownerID in _friendlies) then { + _canBuildOnPlot = true; + }; + // plotManagement // }; + // plotManagement // }; }; diff --git a/SQF/dayz_code/actions/player_upgrade.sqf b/SQF/dayz_code/actions/player_upgrade.sqf index ac813a379..26164cf3a 100644 --- a/SQF/dayz_code/actions/player_upgrade.sqf +++ b/SQF/dayz_code/actions/player_upgrade.sqf @@ -42,13 +42,30 @@ if(_IsNearPlot == 0) then { // check if friendly to owner if(dayz_characterID == _ownerID) then { - _canBuildOnPlot = true; + _canBuildOnPlot = true; } else { - _friendlies = player getVariable ["friendlyTo",[]]; - // check if friendly to owner - if(_ownerID in _friendlies) then { - _canBuildOnPlot = true; + // plotManagement // + if( DZE_plotManagement ) then { + _friendlies = _nearestPole getVariable ["plotfriends",[]]; + _fuid = []; + { + _friendUID = _x select 0; + _fuid = _fuid + [_friendUID]; + } forEach _friendlies; + // check if friendly to owner + if(dayz_characterID in _fuid) then { + _canBuildOnPlot = true; + }; + } else { + // plotManagement // + _friendlies = player getVariable ["friendlyTo",[]]; + // check if friendly to owner + if(_ownerID in _friendlies) then { + _canBuildOnPlot = true; + }; + // plotManagement // }; + // plotManagement // }; }; diff --git a/SQF/dayz_code/actions/plotManagement/initPlotManagement.sqf b/SQF/dayz_code/actions/plotManagement/initPlotManagement.sqf new file mode 100644 index 000000000..0ff1a10ba --- /dev/null +++ b/SQF/dayz_code/actions/plotManagement/initPlotManagement.sqf @@ -0,0 +1,22 @@ +disableSerialization; + +PlotGetFriends = compile preprocessFileLineNumbers "\z\addons\dayz_code\actions\plotManagement\plotGetFriends.sqf"; +PlotNearbyHumans = compile preprocessFileLineNumbers "\z\addons\dayz_code\actions\plotManagement\plotNearbyHumans.sqf"; +PlotAddFriend = compile preprocessFileLineNumbers "\z\addons\dayz_code\actions\plotManagement\plotAddFriend.sqf"; +PlotRemoveFriend = compile preprocessFileLineNumbers "\z\addons\dayz_code\actions\plotManagement\plotRemoveFriend.sqf"; +PlotObjects = compile preprocessFileLineNumbers "\z\addons\dayz_code\actions\plotManagement\plotObjects.sqf"; +PlotPreview = compile preprocessFileLineNumbers "\z\addons\dayz_code\actions\plotManagement\plotToggleMarkers.sqf"; + +// use this for gold +MaintainPlot = compile preprocessFileLineNumbers "\z\addons\dayz_code\actions\plotManagement\maintain_area.sqf"; + +// use this for single currency +//MaintainPlot = compile preprocessFileLineNumbers "\z\addons\dayz_code\actions\plotManagement\maintain_areaSC.sqf"; + + +createdialog "PlotManagement"; +call PlotNearbyHumans; +call PlotGetFriends; +["preview"] call MaintainPlot; +call PlotObjects; + diff --git a/SQF/dayz_code/actions/plotManagement/maintain_area.sqf b/SQF/dayz_code/actions/plotManagement/maintain_area.sqf new file mode 100644 index 000000000..8ab05b37e --- /dev/null +++ b/SQF/dayz_code/actions/plotManagement/maintain_area.sqf @@ -0,0 +1,148 @@ +private ["_missing","_missingQty","_proceed","_itemIn","_countIn","_qty","_num_removed","_uniqueID","_removed","_removed_total","_tobe_removed_total","_obj","_objectID","_objectUID","_classname","_location","_dir","_objectCharacterID","_object","_temp_removed_array","_textMissing","_target","_objectClasses","_range","_objects","_requirements","_count","_cost","_itemText","_option"]; +disableSerialization; + +if (DZE_ActionInProgress) exitWith { cutText [(localize "STR_EPOCH_ACTIONS_2") , "PLAIN DOWN"]; }; +DZE_ActionInProgress = true; + +player removeAction s_player_maintain_area; +s_player_maintain_area = 1; +player removeAction s_player_maintain_area_preview; +s_player_maintain_area_preview = 1; + +_target = cursorTarget; + +_objectClasses = DZE_maintainClasses; +_range = DZE_PlotPole select 0; +_objects = nearestObjects [_target, _objectClasses, _range]; + +_objects_filtered = []; +{ + if (damage _x >= DZE_DamageBeforeMaint) then { + _objects_filtered set [count _objects_filtered, _x]; + }; +} count _objects; +_objects = _objects_filtered; + +_count = count _objects; + +if (_count == 0) exitWith { + _ctrl = ((uiNamespace getVariable "PlotManagement") displayCtrl 7012); + _result = format["Objects to maintain: %1" , _count]; + _ctrl ctrlSetText _result; + _ctrl = ((uiNamespace getVariable "PlotManagement") displayCtrl 7013); + _result = format["No money needed.", " "]; + _ctrl ctrlSetText _result; + DZE_ActionInProgress = false; + s_player_maintain_area = -1; + s_player_maintain_area_preview = -1; +}; + +_requirements = []; +switch true do { + case (_count <= 10): {_requirements = [["ItemGoldBar10oz",1]]}; + case (_count <= 20): {_requirements = [["ItemGoldBar10oz",2]]}; + case (_count <= 35): {_requirements = [["ItemGoldBar10oz",3]]}; + case (_count <= 50): {_requirements = [["ItemGoldBar10oz",4]]}; + case (_count <= 75): {_requirements = [["ItemGoldBar10oz",6]]}; + case (_count <= 100): {_requirements = [["ItemBriefcase100oz",1]]}; + case (_count <= 175): {_requirements = [["ItemBriefcase100oz",2]]}; + case (_count <= 250): {_requirements = [["ItemBriefcase100oz",3]]}; + case (_count <= 325): {_requirements = [["ItemBriefcase100oz",4]]}; + case (_count <= 400): {_requirements = [["ItemBriefcase100oz",5]]}; + case (_count <= 475): {_requirements = [["ItemBriefcase100oz",6]]}; + case (_count <= 550): {_requirements = [["ItemBriefcase100oz",7]]}; + case (_count <= 625): {_requirements = [["ItemBriefcase100oz",8]]}; + case (_count > 625): {_requirements = [["ItemBriefcase100oz",9]]}; +}; + + + +_option = _this select 0; +switch _option do { + case "maintain": { + _missing = ""; + _missingQty = 0; + _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,_range,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; + _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 required items removed from player gear + if (_tobe_removed_total == _removed_total) then { + cutText [format[(localize "STR_EPOCH_ACTIONS_4"), _count], "PLAIN DOWN", 5]; + PVDZE_maintainArea = [player,1,_target]; + publicVariableServer "PVDZE_maintainArea"; + _ctrl = ((uiNamespace getVariable "PlotManagement") displayCtrl 7012); + _result = format["SUCCESS : Objects maintained: %1" , _count]; + _ctrl ctrlSetText _result; + _ctrl = ((uiNamespace getVariable "PlotManagement") displayCtrl 7013); + _result = format["SUCCESS : Price maintained: %1 %2 !" , (_requirements select 0) select 1, (_requirements select 0) select 0]; + _ctrl ctrlSetText _result; + } else { + {player addMagazine _x;} count _temp_removed_array; + cutText [format[(localize "STR_EPOCH_ACTIONS_5"),_removed_total,_tobe_removed_total], "PLAIN DOWN"]; + }; + } else { + _textMissing = getText(configFile >> "CfgMagazines" >> _missing >> "displayName"); + _ctrl = ((uiNamespace getVariable "PlotManagement") displayCtrl 7012); + _result = format["FAILED : Objects maintained: 0" , _count]; + _ctrl ctrlSetText _result; + _ctrl = ((uiNamespace getVariable "PlotManagement") displayCtrl 7013); + _result = format["FAILED : Money needed: %1 %2 !" , (_requirements select 0) select 1, (_requirements select 0) select 0]; + _ctrl ctrlSetText _result; + cutText [format[(localize "STR_EPOCH_ACTIONS_6"), _missingQty, _textMissing], "PLAIN DOWN"]; + }; + }; + case "preview": { + _cost = ""; + { + _itemIn = _x select 0; + _countIn = _x select 1; + _itemText = getText(configFile >> "CfgMagazines" >> _itemIn >> "displayName"); + if (_cost != "") then { + _cost = _cost + " and "; + }; + _cost = _cost + (str(_countIn) + " of " + _itemText); + } count _requirements; + cutText [format[(localize "STR_EPOCH_ACTIONS_7"), _count, _cost], "PLAIN DOWN"]; + _ctrl = ((uiNamespace getVariable "PlotManagement") displayCtrl 7012); + _result = format["Objects to maintain: %1" , _count]; + _ctrl ctrlSetText _result; + _ctrl = ((uiNamespace getVariable "PlotManagement") displayCtrl 7013); + _result = format["Price to maintain: %1 %2" , (_requirements select 0) select 1, (_requirements select 0) select 0]; + _ctrl ctrlSetText _result; + }; +}; + +DZE_ActionInProgress = false; +s_player_maintain_area = -1; +s_player_maintain_area_preview = -1; diff --git a/SQF/dayz_code/actions/plotManagement/maintain_areaSC.sqf b/SQF/dayz_code/actions/plotManagement/maintain_areaSC.sqf new file mode 100644 index 000000000..497358451 --- /dev/null +++ b/SQF/dayz_code/actions/plotManagement/maintain_areaSC.sqf @@ -0,0 +1,121 @@ +private ["_newWealth","_missing","_missingQty","_proceed","_itemIn","_countIn","_target","_objectClasses","_range","_objects","_requirements","_count","_cost","_option"]; +disableSerialization; + +if (DZE_ActionInProgress) exitWith { cutText [(localize "STR_EPOCH_ACTIONS_2") , "PLAIN DOWN"]; }; +DZE_ActionInProgress = true; + +player removeAction s_player_maintain_area; +s_player_maintain_area = 1; +player removeAction s_player_maintain_area_preview; +s_player_maintain_area_preview = 1; + +_target = cursorTarget; + +_objectClasses = DZE_maintainClasses; +_range = DZE_PlotPole select 0; +_objects = nearestObjects [_target, _objectClasses, _range]; + +_objects_filtered = []; +{ + if (damage _x >= DZE_DamageBeforeMaint) then { + _objects_filtered set [count _objects_filtered, _x]; + }; +} count _objects; +_objects = _objects_filtered; + +_count = count _objects; + +if (_count == 0) exitWith { + _ctrl = ((uiNamespace getVariable "PlotManagement") displayCtrl 7012); + _result = format["Objects to maintain: %1" , _count]; + _ctrl ctrlSetText _result; + + _ctrl = ((uiNamespace getVariable "PlotManagement") displayCtrl 7013); + _result = format["Price to maintain: %1 %2" , 0, CurrencyName]; + + _ctrl ctrlSetText _result; + DZE_ActionInProgress = false; + s_player_maintain_area = -1; + s_player_maintain_area_preview = -1; +}; + +_theCost = _count * 1; +_requirements = [[CurrencyName,_theCost]]; + + +_option = _this select 0; +switch _option do { + case "maintain": { + + _wealth = player getVariable["cashMoney",0]; + _missing = ""; + _missingQty = 0; + _proceed = true; + { + _itemIn = _x select 0; + _countIn = _x select 1; + if (_wealth < _countIn) exitWith { _missing = _itemIn; _missingQty = (_countIn - _wealth); _proceed = false; }; + } count _requirements; + + if (_proceed) then { + _newWealth = (_wealth - _countIn); + player playActionNow "Medic"; + [player,_range,true,(getPosATL player)] spawn player_alertZombies; + + player setVariable["cashMoney",_newWealth,true]; + + PVDZ_plr_Save = [player,(magazines player),true,true]; + publicVariableServer "PVDZ_plr_Save"; + + PVDZE_maintainArea = [player,1,_target]; + publicVariableServer "PVDZE_maintainArea"; + + + cutText [format[(localize "STR_EPOCH_ACTIONS_4"), _count], "PLAIN DOWN", 5]; + + _ctrl = ((uiNamespace getVariable "PlotManagement") displayCtrl 7012); + _result = format["SUCCESS : Objects maintained: %1" , _count]; + _ctrl ctrlSetText _result; + + _ctrl = ((uiNamespace getVariable "PlotManagement") displayCtrl 7013); + _result = format["SUCCESS : Price maintained: %1 %2" , _theCost, CurrencyName]; + _ctrl ctrlSetText _result; + + } else { + _ctrl = ((uiNamespace getVariable "PlotManagement") displayCtrl 7012); + _result = format["FAILED: Objects to maintain: %1" , _count]; + _ctrl ctrlSetText _result; + + _ctrl = ((uiNamespace getVariable "PlotManagement") displayCtrl 7013); + _result = format["FAILED: Price to maintain: %1 %2" , _theCost, CurrencyName]; + _ctrl ctrlSetText _result; + + cutText [format[(localize "STR_EPOCH_ACTIONS_6"), _missingQty, CurrencyName], "PLAIN DOWN"]; + }; + }; + case "preview": { + _cost = ""; + { + _itemIn = _x select 0; + _countIn = _x select 1; + if (_cost != "") then { + _cost = _cost + " and "; + }; + _cost = _cost + (str(_countIn) + " " + CurrencyName); + } count _requirements; + + cutText [format[(localize "STR_EPOCH_ACTIONS_7"), _count, _cost], "PLAIN DOWN"]; + + _ctrl = ((uiNamespace getVariable "PlotManagement") displayCtrl 7012); + _result = format["Objects to maintain: %1" , _count]; + _ctrl ctrlSetText _result; + + _ctrl = ((uiNamespace getVariable "PlotManagement") displayCtrl 7013); + _result = format["Price to maintain: %1 %2" , _theCost, CurrencyName]; + _ctrl ctrlSetText _result; + }; +}; + +DZE_ActionInProgress = false; +s_player_maintain_area = -1; +s_player_maintain_area_preview = -1; \ No newline at end of file diff --git a/SQF/dayz_code/actions/plotManagement/plotAddFriend.sqf b/SQF/dayz_code/actions/plotManagement/plotAddFriend.sqf new file mode 100644 index 000000000..7a873c5fc --- /dev/null +++ b/SQF/dayz_code/actions/plotManagement/plotAddFriend.sqf @@ -0,0 +1,24 @@ +private ["_pos","_plots","_thePlot","_inList"]; +_pos = _this select 0; +if (_pos < 0) exitWith {}; +_toAdd = (Humans select _pos); +_plots = nearestObjects [player, ["Plastic_Pole_EP1_DZ"],15]; +_thePlot = _plots select 0; +_friends = _thePlot getVariable ["plotfriends",[]]; +_inList = false; +{ if ((_x select 0) == (_toAdd select 0)) exitWith { _inList = true; }; } forEach _friends; +if (_inList) exitWith { cutText ["Already on the list", "PLAIN DOWN"]; }; +if (count _friends == 6) exitWith { cutText ["Only 6 allowed","PLAIN DOWN"]; }; +_friends = _friends + [_toAdd ]; +_thePlot setVariable ["plotfriends", _friends, true]; + +if (isServer) then { + PVDZ_veh_Save call server_updateObject; +} else { + PVDZ_veh_Save = [_thePlot,"gear"]; + publicVariableServer "PVDZ_veh_Save"; +}; + + +call PlotGetFriends; +call PlotNearbyHumans; \ No newline at end of file diff --git a/SQF/dayz_code/actions/plotManagement/plotGetFriends.sqf b/SQF/dayz_code/actions/plotManagement/plotGetFriends.sqf new file mode 100644 index 000000000..09869aafe --- /dev/null +++ b/SQF/dayz_code/actions/plotManagement/plotGetFriends.sqf @@ -0,0 +1,11 @@ +private ["_plots","_friendlies","_thePlot"]; +lbClear 7002; +_plots = nearestObjects [player, ["Plastic_Pole_EP1_DZ"],15]; +_thePlot = _plots select 0; +_friendlies = _thePlot getVariable ["plotfriends", []]; +{ + lbAdd [7002, (_x select 1)]; +} forEach _friendlies; + + + diff --git a/SQF/dayz_code/actions/plotManagement/plotNearbyHumans.sqf b/SQF/dayz_code/actions/plotManagement/plotNearbyHumans.sqf new file mode 100644 index 000000000..d6ebf3312 --- /dev/null +++ b/SQF/dayz_code/actions/plotManagement/plotNearbyHumans.sqf @@ -0,0 +1,13 @@ +private ["_close"]; +lbClear 7001; +_closePeople = player nearEntities ["CAManBase", 10]; +Humans = []; +{ + if (_x isKindOf "Man" and !(_x isKindOf "zZombie_base")) then { + _friendUID = getPlayerUID _x; + _friendName = name _x; + Humans = Humans + [[_friendUID,_friendName]] ; + lbAdd [7001, _friendName]; + }; +} forEach _closePeople; + diff --git a/SQF/dayz_code/actions/plotManagement/plotObjects.sqf b/SQF/dayz_code/actions/plotManagement/plotObjects.sqf new file mode 100644 index 000000000..4c95d8449 --- /dev/null +++ b/SQF/dayz_code/actions/plotManagement/plotObjects.sqf @@ -0,0 +1,18 @@ +private ["_newWealth","_missing","_missingQty","_proceed","_itemIn","_countIn","_target","_objectClasses","_range","_objects","_requirements","_count","_cost","_option"]; +disableSerialization; + +_range = DZE_PlotPole select 0; +_count = count ((getPosATL player) nearObjects ["All",_range]); + +_colour = "#ffffff"; + +if(_count / DZE_BuildingLimit * 100 < 40)then{ +_colour = "#00ff00"; +}; +if(_count / DZE_BuildingLimit * 100 > 75)then{ +_colour = "#ff0000"; +}; + +_ctrl = ((uiNamespace getVariable "PlotManagement") displayCtrl 7014); +_result = format["%1 / %2" , _count, DZE_BuildingLimit,_colour]; +_ctrl ctrlSetStructuredText parseText _result; diff --git a/SQF/dayz_code/actions/plotManagement/plotRemoveFriend.sqf b/SQF/dayz_code/actions/plotManagement/plotRemoveFriend.sqf new file mode 100644 index 000000000..2783dc285 --- /dev/null +++ b/SQF/dayz_code/actions/plotManagement/plotRemoveFriend.sqf @@ -0,0 +1,25 @@ +private ["_list","_plots","_thePlot","_friends"]; + +_pos = _this select 0; +if (_pos < 0) exitWith {}; +_plots = nearestObjects [player, ["Plastic_Pole_EP1_DZ"],15]; +_thePlot = _plots select 0; +_friends = _thePlot getVariable ["plotfriends", []]; +_toRemove = (_friends select _pos); +_newList = []; +{ + if(_x select 0 != _toRemove select 0)then{ + _newList = _newList + [_x]; + }; +} forEach _friends; +_thePlot setVariable ["plotfriends", _newList, true]; + +if (isServer) then { + PVDZ_veh_Save call server_updateObject; +} else { + PVDZ_veh_Save = [_thePlot,"gear"]; + publicVariableServer "PVDZ_veh_Save"; +}; + +call PlotGetFriends; +call PlotNearbyHumans; \ No newline at end of file diff --git a/SQF/dayz_code/actions/plotManagement/plotToggleMarkers.sqf b/SQF/dayz_code/actions/plotManagement/plotToggleMarkers.sqf new file mode 100644 index 000000000..272ba042d --- /dev/null +++ b/SQF/dayz_code/actions/plotManagement/plotToggleMarkers.sqf @@ -0,0 +1,81 @@ +//Zero Remorse, big thanks to their scripter for this! +private ["_speed","_density","_model","_thePlot","_center","_radius","_angle","_count","_axis","_obj","_idx","_a","_b"]; +//----------------------------------------------------------------------------------------- +_speed = 4; // multiplier for speed of sphere rotation/wobble +_density = 3; // density of markers per ring +_model = "Sign_sphere100cm_EP1"; // marker model to use on rings +// Possible ones to use :: Sign_sphere10cm_EP1 Sign_sphere25cm_EP1 Sign_sphere100cm_EP1 +//----------------------------------------------------------------------------------------- +// +_thePlot = (nearestObjects [player, ["Plastic_Pole_EP1_DZ"],15]) select 0; +_center = getPosASL _thePlot; _radius = DZE_PlotPole select 0; +_obj = false; _tmp = -1; +//----------------------------------------------------------------------------------------- +if (!isNil "PP_Marks") then { + if (((PP_Marks select 0) distance _thePlot) < 10) then { _obj = true; }; + _tmp = (PP_Marks select 0) distance _thePlot; + { deleteVehicle _x; } count PP_Marks; PP_Marks = nil; +}; +//----------------------------------------------------------------------------------------- +if ((isNil "PP_Marks") && (!_obj)) then { + PP_Marks = []; _count = round((2 * pi * _radius) / _density); + //-------------------------------------------------------------------------------- + _obj = "Sign_sphere10cm_EP1" createVehicleLocal [0,0,0]; // PARENT marker on pole + _obj setPosASL [_center select 0, _center select 1, _center select 2]; + _obj setObjectTexture [0, "#(argb,16,16,1)color(0,1,0,0.4)"]; _axis = _obj; + _obj setVectorUp [0, 0, 0]; PP_Marks set [count PP_Marks, _obj]; + //-------------------------------------------------------------------------------- + _angle = 0; + for "_idx" from 0 to _count do { + _a = (_center select 0) + (sin(_angle)*_radius); + _b = (_center select 1) + (cos(_angle)*_radius); + _obj = _model createVehicleLocal [0,0,0]; + _obj setPosASL [_a, _b, _center select 2]; + _obj setObjectTexture [0, "#(argb,16,16,1)color(0,1,0,0.4)"]; + _obj attachTo [_axis]; PP_Marks set [count PP_Marks, _obj]; + //---------------------------------------------------------------------------- + _a = (_center select 0) + (sin(_angle)*_radius); + _b = (_center select 2) + (cos(_angle)*_radius); + _obj = _model createVehicleLocal [0,0,0]; + _obj setPosASL [_a, _center select 1, _b]; + _obj setObjectTexture [0, "#(argb,16,16,1)color(0,1,0,0.4)"]; + _obj attachTo [_axis]; PP_Marks set [count PP_Marks, _obj]; + //---------------------------------------------------------------------------- + _angle = _angle + (360/_count); + }; + //---------------------------------------------------------------------------- + _angle = (360/_count); + for "_idx" from 0 to (_count - 2) do { + //---------------------------------------------------------------------------- + _a = (_center select 1) + (sin(_angle)*_radius); + _b = (_center select 2) + (cos(_angle)*_radius); + _obj = _model createVehicleLocal [0,0,0]; + _obj setPosASL [_center select 0, _a, _b]; + _obj setObjectTexture [0, "#(argb,16,16,1)color(0,1,0,0.4)"]; + _obj attachTo [_axis]; PP_Marks set [count PP_Marks, _obj]; + //---------------------------------------------------------------------------- + _angle = _angle + (360/_count); + }; + _angle = (360/_count); _axis setDir 45; + for "_idx" from 0 to (_count - 2) do { + _a = (_center select 0) + (sin(_angle)*_radius); + _b = (_center select 2) + (cos(_angle)*_radius); + _obj = _model createVehicleLocal [0,0,0]; + _obj setPosASL [_a, _center select 1, _b]; + _obj setObjectTexture [0, "#(argb,16,16,1)color(0,1,0,0.4)"]; + _obj attachTo [_axis]; PP_Marks set [count PP_Marks, _obj]; + //---------------------------------------------------------------------------- + _a = (_center select 1) + (sin(_angle)*_radius); + _b = (_center select 2) + (cos(_angle)*_radius); + _obj = _model createVehicleLocal [0,0,0]; + _obj setPosASL [_center select 0, _a, _b]; + _obj setObjectTexture [0, "#(argb,16,16,1)color(0,1,0,0.4)"]; + _obj attachTo [_axis]; PP_Marks set [count PP_Marks, _obj]; + //---------------------------------------------------------------------------- + _angle = _angle + (360/_count); + }; + //-------------------------------------------------------------------------------- + //-------------------------------------------------------------------------------- +}; +//------------------------------------------------------------------------------------ +//------------------------------------------------------------------------------------ diff --git a/SQF/dayz_code/compile/dze_buildChecks.sqf b/SQF/dayz_code/compile/dze_buildChecks.sqf index 3bb1c62e0..c61f56b21 100644 --- a/SQF/dayz_code/compile/dze_buildChecks.sqf +++ b/SQF/dayz_code/compile/dze_buildChecks.sqf @@ -42,10 +42,29 @@ if(_IsNearPlot == 0) then { }; } else { if(!_isPole) then { - _friendlies = player getVariable ["friendlyTo",[]]; - if(_ownerID in _friendlies) then { - _canBuild = true; + // plotManagement // + if( DZE_plotManagement ) then { + _friendlies = _nearestPole getVariable ["plotfriends",[]]; + _fuid = []; + { + _friendUID = _x select 0; + _fuid = _fuid + [_friendUID]; + } forEach _friendlies; + _builder = getPlayerUID player; + // check if friendly to owner + if(dayz_characterID in _fuid) then { + _canBuild = true; + }; + } else { + // plotManagement // + _friendlies = player getVariable ["friendlyTo",[]]; + // check if friendly to owner + if(_ownerID in _friendlies) then { + _canBuild = true; + }; + // plotManagement // }; + // plotManagement // }; }; }; diff --git a/SQF/dayz_code/compile/fn_selfActions.sqf b/SQF/dayz_code/compile/fn_selfActions.sqf index b3e44f828..7aa38e38e 100644 --- a/SQF/dayz_code/compile/fn_selfActions.sqf +++ b/SQF/dayz_code/compile/fn_selfActions.sqf @@ -412,18 +412,74 @@ if (!isNull _cursorTarget && !_inVehicle && !_isPZombie && (player distance _cur _player_deleteBuild = true; }; }; + + //Allow owners to delete modulars if (_isModular && (dayz_characterID == _ownerID)) then { if (_hasToolbox && "ItemCrowbar" in _itemsPlayer) then { _player_deleteBuild = true; }; }; + // plotManagement // + if(_isModular && DZE_plotManagement) then { + if(_hasToolbox && "ItemCrowbar" in _itemsPlayer) then { + _findNearestPoles = nearestObjects[player, ["Plastic_Pole_EP1_DZ"], DZE_PlotPole select 0]; + _IsNearPlot = count (_findNearestPoles); + _fuid = []; + _allowed = []; + if(_IsNearPlot > 0) then { + _thePlot = _findNearestPoles select 0; + _owner = if(DZE_plotforLife) + then { _thePlot getVariable ["ownerPUID","010"] } + else { _thePlot getVariable ["characterID","0"] }; + _friends = _thePlot getVariable ["plotfriends", []]; + { + _friendUID = _x select 0; + _fuid = _fuid + [_friendUID]; + } forEach _friends; + _allowed = [_owner]; + _allowed = [_owner] + _fuid; + if( (dayz_playerUID in _allowed) || (dayz_characterID in _allowed) ) then { + _player_deleteBuild = true; + }; + }; + }; + }; + // plotManagement // + //Allow owners to delete modular doors without locks if (_isModularDoor && (dayz_characterID == _ownerID)) then { if (_hasToolbox && "ItemCrowbar" in _itemsPlayer) then { _player_deleteBuild = true; }; }; + // plotManagement // + if(_isModularDoor) then { + if(_hasToolbox && "ItemCrowbar" in _itemsPlayer) then { + _findNearestPoles = nearestObjects[player, ["Plastic_Pole_EP1_DZ"], DZE_PlotPole select 0]; + _IsNearPlot = count (_findNearestPoles); + _fuid = []; + _allowed = []; + if(_IsNearPlot > 0)then{ + _thePlot = _findNearestPoles select 0; + _owner = if(DZE_plotforLife) + then { _thePlot getVariable ["ownerPUID","010"] } + else { _thePlot getVariable ["characterID","0"] }; + _friends = _thePlot getVariable ["plotfriends", []]; + { + _friendUID = _x select 0; + _fuid = _fuid + [_friendUID]; + } forEach _friends; + _allowed = [_owner]; + _allowed = [_owner] + _fuid; + if( (dayz_playerUID in _allowed) || (dayz_characterID in _allowed) ) then { + _player_deleteBuild = true; + }; + }; + }; + }; + // plotManagement // + if (_isVehicle) then { if ((_ownerID != "0") && {!_isMan} && {!_isBicycle}) then { _player_lockUnlock_crtl = true; @@ -630,11 +686,40 @@ if (!isNull _cursorTarget && !_inVehicle && !_isPZombie && (player distance _cur }; if ((_cursorTarget isKindOf "Plastic_Pole_EP1_DZ") && {_canDo} && {speed player <= 1}) then { - if (s_player_maintain_area < 0) then { - s_player_maintain_area = player addAction [format["%1",localize "STR_EPOCH_ACTIONS_MAINTAREA"], "\z\addons\dayz_code\actions\maintain_area.sqf", "maintain", 5, false]; - s_player_maintain_area_preview = player addAction [format["%1",localize "STR_EPOCH_ACTIONS_MAINTPREV"], "\z\addons\dayz_code\actions\maintain_area.sqf", "preview", 5, false]; + + // plotManagement // + // add Scroll-Menu to Plotpole + if (DZE_plotManagement && (s_player_plotManagement < 0) ) then { + _adminList = ["0152"]; //TODO: Add admins here if you admins to able to manage all plotpoles + _owner = if(DZE_plotforLife) + then { _cursorTarget getVariable ["ownerPUID","0"] } + else { _cursorTarget getVariable ["characterID","0"] }; + _friends = _cursorTarget getVariable ["plotfriends", []]; + _fuid = []; + { + _friendUID = _x select 0; + _fuid = _fuid + [_friendUID]; + } forEach _friends; + _allowed = [_owner]; + _allowed = [_owner] + _adminList + _fuid; + if( (dayz_playerUID in _allowed) || (dayz_characterID in _allowed) ) then { + s_player_plotManagement = player addAction ["Manage Plot", "\z\addons\dayz_code\actions\plotManagement\initPlotManagement.sqf", [], 5, false]; + }; + }; + // plotManagement // + + if(!DZE_plotManagement) then { + if (s_player_maintain_area < 0) then { + s_player_maintain_area = player addAction [format["%1",localize "STR_EPOCH_ACTIONS_MAINTAREA"], "\z\addons\dayz_code\actions\maintain_area.sqf", "maintain", 5, false]; + s_player_maintain_area_preview = player addAction [format["%1",localize "STR_EPOCH_ACTIONS_MAINTPREV"], "\z\addons\dayz_code\actions\maintain_area.sqf", "preview", 5, false]; + }; }; } else { + // plotManagement // + player removeAction s_player_plotManagement; + s_player_plotManagement = -1; + // plotManagement // + player removeAction s_player_maintain_area; s_player_maintain_area = -1; player removeAction s_player_maintain_area_preview; @@ -1003,6 +1088,12 @@ if (!isNull _cursorTarget && !_inVehicle && !_isPZombie && (player distance _cur }; } else { //Engineering + + // plotManagement // + player removeAction s_player_plotManagement; + s_player_plotManagement = -1; + // plotManagement // + {dayz_myCursorTarget removeAction _x} count s_player_repairActions;s_player_repairActions = []; player removeAction s_player_repair_crtl; s_player_repair_crtl = -1; diff --git a/SQF/dayz_code/config.cpp b/SQF/dayz_code/config.cpp index 6db8bc744..ad9ecb3f1 100644 --- a/SQF/dayz_code/config.cpp +++ b/SQF/dayz_code/config.cpp @@ -112,4 +112,7 @@ class CfgAddons #include "Configs\RscDisplay\tradermenu.hpp" #include "Configs\RscDisplay\deathboards.hpp" #include "Configs\CfgExtra\snappoints.hpp" -#include "external\R3F_Realism\R3F_Weight\R3F_CfgWeight.hpp" \ No newline at end of file +#include "external\R3F_Realism\R3F_Weight\R3F_CfgWeight.hpp" +// plotManagement // +#include "Configs\RscDisplay\plotManagement.hpp" +// plotManagement // diff --git a/SQF/dayz_code/configVariables.sqf b/SQF/dayz_code/configVariables.sqf index f052941f6..e236980f1 100644 --- a/SQF/dayz_code/configVariables.sqf +++ b/SQF/dayz_code/configVariables.sqf @@ -53,6 +53,14 @@ Z_AllowTakingMoneyFromBackpack = true; // When buying items with DEFAULT CURRENC Z_AllowTakingMoneyFromVehicle = true; // When buying items with DEFAULT CURRENCY to any inventory. Do you allow the trader to take money from your vehicle. Z_MoneyVariable = "cashMoney"; // If using a Single currency system, change this to whatever currency you are using. /**********************************************/ + +/////////// plotManagement Variables /////////// +// see also: https://github.com/DevZupa/PlotManagement +DZE_plotManagement = true; +// see also: https://github.com/RimBlock/Epoch/tree/master/A%20Plot%20for%20Life +DZE_plotforLife = false; // NOT IMPLEMENTED. Set always to false - value is used by plotManagement +//////////////////////////////////////////////// + /* Developers: diff --git a/SQF/dayz_code/init/variables.sqf b/SQF/dayz_code/init/variables.sqf index 0cf075809..3a5b2f8fc 100644 --- a/SQF/dayz_code/init/variables.sqf +++ b/SQF/dayz_code/init/variables.sqf @@ -239,6 +239,9 @@ dayz_resetSelfActions = { s_player_toggleSnapSelect = -1; s_player_toggleSnapSelectPoint = []; snapActions = -1; + // plotManagement // + s_player_plotManagement = -1; + // plotManagement // }; call dayz_resetSelfActions; diff --git a/SQF/dayz_server/compile/server_updateObject.sqf b/SQF/dayz_server/compile/server_updateObject.sqf index 20797f9fa..397615173 100644 --- a/SQF/dayz_server/compile/server_updateObject.sqf +++ b/SQF/dayz_server/compile/server_updateObject.sqf @@ -68,7 +68,15 @@ _object_inventory = { if (_object isKindOf "TrapItems") then { _inventory = [["armed",_object getVariable ["armed",false]]]; } else { - _inventory = [getWeaponCargo _object,getMagazineCargo _object,getBackpackCargo _object]; + // plotManagement // + if( DZE_plotManagement && (typeOf (_object) == "Plastic_Pole_EP1_DZ") ) then { + _inventory = _object getVariable ["plotfriends", []]; //We're replacing the inventory with UIDs for this item + } else { + // plotManagement // + _inventory = [getWeaponCargo _object, getMagazineCargo _object, getBackpackCargo _object]; + // plotManagement // + }; + // plotManagement // }; _previous = str(_object getVariable["lastInventory",[]]); diff --git a/SQF/dayz_server/system/server_monitor.sqf b/SQF/dayz_server/system/server_monitor.sqf index 2416a4b7b..4972cc931 100644 --- a/SQF/dayz_server/system/server_monitor.sqf +++ b/SQF/dayz_server/system/server_monitor.sqf @@ -120,6 +120,13 @@ if (_status == "ObjectStreamStart") then { // prevent immediate hive write when vehicle parts are set up _object setVariable ["lastUpdate",diag_ticktime]; _object setVariable ["ObjectID", _idKey, true]; + + // plotManagement // + if( DZE_plotManagement && (typeOf (_object) == "Plastic_Pole_EP1_DZ") ) then { + _object setVariable ["plotfriends", _inventory, true]; + }; + // plotManagement // + dayz_serverIDMonitor set [count dayz_serverIDMonitor,_idKey]; // Fix for leading zero issues on safe codes after restart _lockable = if (isNumber (configFile >> "CfgVehicles" >> _type >> "lockable")) then {getNumber (configFile >> "CfgVehicles" >> _type >> "lockable")} else {0}; @@ -146,7 +153,9 @@ if (_status == "ObjectStreamStart") then { clearWeaponCargoGlobal _object; clearMagazineCargoGlobal _object; clearBackpackCargoGlobal _object; - if (count _inventory > 0) then { + // plotManagement // + if( (count _inventory > 0) && !(typeOf( _object) == "Plastic_Pole_EP1_DZ") ) then { + // plotManagement // if (_type in DZE_LockedStorage) then { _object setVariable ["WeaponCargo",(_inventory select 0),true]; _object setVariable ["MagazineCargo",(_inventory select 1),true];