mirror of
https://github.com/EpochModTeam/DayZ-Epoch.git
synced 2025-12-13 19:52:38 +03:00
Move build checks to separate files
For better organization
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
// If parameters were passed redirect to vanilla player_build (Epoch items don't pass anything)
|
||||
// If an array was passed redirect to vanilla player_build (Epoch items pass a string)
|
||||
if (!isNil "_this" && {typeName _this == "ARRAY"} && {count _this > 0}) exitWith {_this spawn player_buildVanilla;};
|
||||
private ["_classname","_classnametmp","_require","_text","_ghost","_lockable","_requireplot","_isAllowedUnderGround","_offset","_isPole","_isLandFireDZ","_hasRequired","_hasrequireditem","_reason","_buildObject","_location1","_object","_objectHelper","_position","_controls","_cancel","_dir","_cnt","_pos","_distance","_buildables","_onLadder","_vehicle","_inVehicle","_abort","_needNear","_isNear","_needText","_findNearestPoles","_findNearestPole","_IsNearPlot","_canBuildOnPlot","_nearestPole","_ownerID","_friendlies","_missing","_checkMag","_enableGhost","_helperColor","_canDo","_objHDiff","_isOk","_zheightchanged","_zheightdirection","_rotate","_location2","_lastDir","_objectHelperDir","_objectHelperPos","_tmpbuilt","_limit","_proceed","_counter","_dis","_sfx","_started","_finished","_animState","_isMedic","_num_removed","_combinationDisplay","_combination_1","_combination_2","_combination_3","_combination_4","_combination","_combination_1_Display"];
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// If parameters were passed redirect to vanilla player_build (Epoch items don't pass anything)
|
||||
// If an array was passed redirect to vanilla player_build (Epoch items pass a string)
|
||||
if (!isNil "_this" && {typeName _this == "ARRAY"} && {count _this > 0}) exitWith {_this spawn player_buildVanilla;};
|
||||
/*
|
||||
DayZ Base Building
|
||||
|
||||
69
SQF/dayz_code/compile/dze_buildChecks.sqf
Normal file
69
SQF/dayz_code/compile/dze_buildChecks.sqf
Normal file
@@ -0,0 +1,69 @@
|
||||
//Checks if item is near a plot, if the player is plot owner or friendly, if there are too many items, and if the player has required tools
|
||||
private ["_requireplot","_distance","_canBuild","_friendlies","_nearestPole","_ownerID","_pos","_item","_classname","_isPole","_isLandFireDZ","_needText","_findNearestPoles","_findNearestPole","_IsNearPlot","_buildables","_center"];
|
||||
|
||||
_pos = _this select 0;
|
||||
_item = _this select 1;
|
||||
_toolCheck = _this select 2;
|
||||
_classname = getText (configFile >> "CfgMagazines" >> _item >> "ItemActions" >> "Build" >> "create");
|
||||
_requireplot = DZE_requireplot;
|
||||
if(isNumber (configFile >> "CfgVehicles" >> _classname >> "requireplot")) then {
|
||||
_requireplot = getNumber(configFile >> "CfgVehicles" >> _classname >> "requireplot");
|
||||
};
|
||||
_isPole = (_classname == "Plastic_Pole_EP1_DZ");
|
||||
_isLandFireDZ = (_classname == "Land_Fire_DZ");
|
||||
_needText = localize "str_epoch_player_246";
|
||||
|
||||
_distance = DZE_PlotPole select 0;
|
||||
_canBuild = false;
|
||||
_nearestPole = objNull;
|
||||
_ownerID = 0;
|
||||
_friendlies = [];
|
||||
if(_isPole) then {
|
||||
_distance = DZE_PlotPole select 1;
|
||||
};
|
||||
|
||||
_findNearestPoles = nearestObjects [_pos, ["Plastic_Pole_EP1_DZ"], _distance];
|
||||
_findNearestPole = [];
|
||||
{
|
||||
if (alive _x) then {
|
||||
_findNearestPole set [(count _findNearestPole),_x];
|
||||
};
|
||||
} count _findNearestPoles;
|
||||
|
||||
_IsNearPlot = count (_findNearestPole);
|
||||
if(_isPole && {_IsNearPlot > 0}) exitWith {DZE_ActionInProgress = false; format[localize "str_epoch_player_44",_distance] call dayz_rollingMessages; [_canBuild, _isPole];};
|
||||
if(_IsNearPlot == 0) then {
|
||||
if (_requireplot == 0 || _isLandFireDZ) then {
|
||||
_canBuild = true;
|
||||
};
|
||||
} else {
|
||||
_nearestPole = _findNearestPole select 0;
|
||||
_ownerID = _nearestPole getVariable ["CharacterID","0"];
|
||||
if(dayz_characterID == _ownerID) then {
|
||||
if (!_isPole) then {
|
||||
_canBuild = true;
|
||||
};
|
||||
} else {
|
||||
if(!_isPole) then {
|
||||
_friendlies = player getVariable ["friendlyTo",[]];
|
||||
if(_ownerID in _friendlies) then {
|
||||
_canBuild = true;
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
if(!_canBuild) exitWith { DZE_ActionInProgress = false; format[localize "STR_EPOCH_PLAYER_135",_needText,_distance] call dayz_rollingMessages; [_canBuild, _isPole];};
|
||||
|
||||
_buildables = DZE_maintainClasses + DZE_LockableStorage + ["DZ_buildables"];
|
||||
_buildables set [count _buildables,"TentStorage"];
|
||||
_center = if (isNull _nearestPole) then {_pos} else {_nearestPole};
|
||||
if ((count (nearestObjects [_center,_buildables,_distance])) >= DZE_BuildingLimit) exitWith {DZE_ActionInProgress = false; format[localize "str_epoch_player_41",_distance] call dayz_rollingMessages; [false, _isPole];};
|
||||
|
||||
if (_toolCheck) then {
|
||||
_require = getArray (configFile >> "cfgMagazines" >> _item >> "ItemActions" >> "Build" >> "require");
|
||||
_classname = getText (configFile >> "CfgMagazines" >> _item >> "ItemActions" >> "Build" >> "create");
|
||||
_canBuild = [_item, _require, _classname] call dze_requiredItemsCheck;
|
||||
};
|
||||
|
||||
//When calling this function in another script use a silent exitWith, unless you have something special to say. i.e. if (!(_canBuild select 0)) exitWith{};
|
||||
[_canBuild, _isPole];
|
||||
37
SQF/dayz_code/compile/dze_requiredItemsCheck.sqf
Normal file
37
SQF/dayz_code/compile/dze_requiredItemsCheck.sqf
Normal file
@@ -0,0 +1,37 @@
|
||||
private ["_missingText","_hasrequireditem","_hastoolweapon","_item","_require","_missing","_text","_classname","_hasbuilditem"];
|
||||
|
||||
_item = _this select 0;
|
||||
_require = _this select 1;
|
||||
_classname = _this select 2;
|
||||
_missing = [];
|
||||
_missingText = "";
|
||||
_hasrequireditem = true;
|
||||
_text = getText (configFile >> "CfgVehicles" >> _classname >> "displayName");
|
||||
{
|
||||
_hastoolweapon = _x in weapons player;
|
||||
if (!_hastoolweapon) then {
|
||||
_missingText = getText (configFile >> "cfgWeapons" >> _x >> "displayName");
|
||||
_missing set [count _missing, _missingText];
|
||||
_hasrequireditem = false;
|
||||
};
|
||||
} forEach _require;
|
||||
_missingText = "";
|
||||
|
||||
{
|
||||
if (_forEachIndex == 0) then {
|
||||
_missingText = _x;
|
||||
} else {
|
||||
if (_forEachIndex == ((count _missing) - 1)) then {
|
||||
_missingText = _missingText + " and " + _x;
|
||||
} else {
|
||||
_missingText = _missingText + ", " + _x;
|
||||
};
|
||||
};
|
||||
} forEach _missing;
|
||||
|
||||
_hasbuilditem = _item in magazines player;
|
||||
if (!_hasbuilditem) exitWith {DZE_ActionInProgress = false; format[localize "str_player_31",_text,"build"] call dayz_rollingMessages; false;};
|
||||
if (!_hasrequireditem) exitWith {DZE_ActionInProgress = false; format[localize "str_epoch_player_137",_missingText] call dayz_rollingMessages; false;};
|
||||
|
||||
//When calling this function in another script use a silent exitWith, unless you have something special to say. i.e. if (!_hasrequireditem) exitWith{};
|
||||
_hasrequireditem;
|
||||
@@ -144,7 +144,9 @@ if (!isDedicated) then {
|
||||
// EPOCH ADDITIONS
|
||||
autoRunOff = {autoRunActive = false; terminate autoRunThread; player playActionNow "Stop";};
|
||||
dog_findTargetAgent = compile preprocessFileLineNumbers "\z\addons\dayz_code\compile\dog_findTargetAgent.sqf";
|
||||
dze_isnearest_player = compile preprocessFileLineNumbers "\z\addons\dayz_code\compile\dze_isNearestPlayer.sqf";
|
||||
dze_isnearest_player = compile preprocessFileLineNumbers "\z\addons\dayz_code\compile\dze_isNearestPlayer.sqf";
|
||||
dze_buildChecks = compile preprocessFileLineNumbers "\z\addons\dayz_code\compile\dze_buildChecks.sqf";
|
||||
dze_requiredItemsCheck = compile preprocessFileLineNumbers "\z\addons\dayz_code\compile\dze_requiredItemsCheck.sqf";
|
||||
dze_surrender_off = {player setVariable ["DZE_Surrendered",false,true]; DZE_Surrender = false;};
|
||||
epoch_tempKeys = compile preprocessFileLineNumbers "\z\addons\dayz_code\compile\epoch_tempKeys.sqf";
|
||||
epoch_totalCurrency = compile preprocessFileLineNumbers "\z\addons\dayz_code\compile\epoch_totalCurrency.sqf";
|
||||
@@ -173,115 +175,6 @@ if (!isDedicated) then {
|
||||
player_upgradeVehicle = compile preprocessFileLineNumbers "\z\addons\dayz_code\compile\player_upgradeVehicle.sqf";
|
||||
player_vaultPitch = compile preprocessFileLineNumbers "\z\addons\dayz_code\actions\vault_pitch.sqf";
|
||||
|
||||
DZE_RequiredItemsCheck = {
|
||||
private ["_missingText","_hasrequireditem","_hastoolweapon","_item","_require","_missing","_missingCount","_text","_classname","_hasbuilditem"];
|
||||
_item = _this select 0;
|
||||
_require = _this select 1;
|
||||
_classname = _this select 2;
|
||||
_missing = [];
|
||||
_missingText = "";
|
||||
_hasrequireditem = true;
|
||||
_text = getText (configFile >> "CfgVehicles" >> _classname >> "displayName");
|
||||
{
|
||||
_hastoolweapon = _x in weapons player;
|
||||
if (!_hastoolweapon) then {
|
||||
_missingText = getText (configFile >> "cfgWeapons" >> _x >> "displayName");
|
||||
_missing set [count _missing, _missingText];
|
||||
_hasrequireditem = false;
|
||||
};
|
||||
} forEach _require;
|
||||
_missingText = "";
|
||||
|
||||
{
|
||||
if (_forEachIndex == 0) then {
|
||||
_missingText = _x;
|
||||
} else {
|
||||
if (_forEachIndex == ((count _missing) - 1)) then {
|
||||
_missingText = _missingText + " and " + _x;
|
||||
} else {
|
||||
_missingText = _missingText + ", " + _x;
|
||||
};
|
||||
};
|
||||
} forEach _missing;
|
||||
|
||||
_hasbuilditem = _item in magazines player;
|
||||
if (!_hasbuilditem) exitWith {DZE_ActionInProgress = false; format[localize "str_player_31",_text,"build"] call dayz_rollingMessages; false;};
|
||||
if (!_hasrequireditem) exitWith {DZE_ActionInProgress = false; format[localize "str_epoch_player_137",_missingText] call dayz_rollingMessages; false;};
|
||||
|
||||
//When calling this function in another script use a silent exitWith, unless you have something special to say. i.e. if (!_hasrequireditem) exitWith{};
|
||||
_hasrequireditem;
|
||||
};
|
||||
|
||||
DZE_BuildChecks = { //Checks if item is near a plot, if the player is plot owner or friendly, if there are too many items, and if the player has required tools
|
||||
private ["_requireplot","_distance","_canBuild","_friendlies","_nearestPole","_ownerID","_pos","_item","_classname","_isPole","_isLandFireDZ","_needText","_findNearestPoles","_findNearestPole","_IsNearPlot","_buildables","_center"];
|
||||
_pos = _This select 0;
|
||||
_item = _this select 1;
|
||||
_toolCheck = _this select 2;
|
||||
_classname = getText (configFile >> "CfgMagazines" >> _item >> "ItemActions" >> "Build" >> "create");
|
||||
_requireplot = DZE_requireplot;
|
||||
if(isNumber (configFile >> "CfgVehicles" >> _classname >> "requireplot")) then {
|
||||
_requireplot = getNumber(configFile >> "CfgVehicles" >> _classname >> "requireplot");
|
||||
};
|
||||
_isPole = (_classname == "Plastic_Pole_EP1_DZ");
|
||||
_isLandFireDZ = (_classname == "Land_Fire_DZ");
|
||||
_needText = localize "str_epoch_player_246";
|
||||
|
||||
_distance = DZE_PlotPole select 0;
|
||||
_canBuild = false;
|
||||
_nearestPole = objNull;
|
||||
_ownerID = 0;
|
||||
_friendlies = [];
|
||||
if(_isPole) then {
|
||||
_distance = DZE_PlotPole select 1;
|
||||
};
|
||||
|
||||
_findNearestPoles = nearestObjects [_pos, ["Plastic_Pole_EP1_DZ"], _distance];
|
||||
_findNearestPole = [];
|
||||
{
|
||||
if (alive _x) then {
|
||||
_findNearestPole set [(count _findNearestPole),_x];
|
||||
};
|
||||
} count _findNearestPoles;
|
||||
|
||||
_IsNearPlot = count (_findNearestPole);
|
||||
if(_isPole && {_IsNearPlot > 0}) exitWith {DZE_ActionInProgress = false; format[localize "str_epoch_player_44",_distance] call dayz_rollingMessages; [_canBuild, _isPole];};
|
||||
if(_IsNearPlot == 0) then {
|
||||
if (_requireplot == 0 || _isLandFireDZ) then {
|
||||
_canBuild = true;
|
||||
};
|
||||
} else {
|
||||
_nearestPole = _findNearestPole select 0;
|
||||
_ownerID = _nearestPole getVariable ["CharacterID","0"];
|
||||
if(dayz_characterID == _ownerID) then {
|
||||
if (!_isPole) then {
|
||||
_canBuild = true;
|
||||
};
|
||||
} else {
|
||||
if(!_isPole) then {
|
||||
_friendlies = player getVariable ["friendlyTo",[]];
|
||||
if(_ownerID in _friendlies) then {
|
||||
_canBuild = true;
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
if(!_canBuild) exitWith { DZE_ActionInProgress = false; format[localize "STR_EPOCH_PLAYER_135",_needText,_distance] call dayz_rollingMessages; [_canBuild, _isPole];};
|
||||
|
||||
_buildables = DZE_maintainClasses + DZE_LockableStorage + ["DZ_buildables"];
|
||||
_buildables set [count _buildables,"TentStorage"];
|
||||
_center = if (isNull _nearestPole) then {_pos} else {_nearestPole};
|
||||
if ((count (nearestObjects [_center,_buildables,_distance])) >= DZE_BuildingLimit) exitWith {DZE_ActionInProgress = false; format[localize "str_epoch_player_41",_distance] call dayz_rollingMessages; [false, _isPole];};
|
||||
|
||||
if (_toolCheck) then {
|
||||
_require = getArray (configFile >> "cfgMagazines" >> _item >> "ItemActions" >> "Build" >> "require");
|
||||
_classname = getText (configFile >> "CfgMagazines" >> _item >> "ItemActions" >> "Build" >> "create");
|
||||
_canBuild = [_item, _require, _classname] call DZE_RequiredItemsCheck;
|
||||
};
|
||||
|
||||
//When calling this function in another script use a silent exitWith, unless you have something special to say. i.e. if (!(_canBuild select 0)) exitWith{};
|
||||
[_canBuild, _isPole];
|
||||
};
|
||||
|
||||
dayz_losChance = {
|
||||
private["_agent","_maxDis","_dis","_val","_maxExp","_myExp"];
|
||||
_agent = _this select 0;
|
||||
|
||||
Reference in New Issue
Block a user