This commit is contained in:
2022-04-21 16:15:41 +03:00
commit 9d4fc88901
601 changed files with 66252 additions and 0 deletions

View File

@ -0,0 +1,57 @@
// **FORMAT** -- (note no comma after last array entry)
//
// DZE_DEPLOYABLES_CONFIG = [
// [_clickItem,_deployOffset,_packDistance,_damageLimit,_packAny,_cargo,_ammo,_hive,_plot,_simulation,_road,_deployables,_near,_parts,_condition],
// [_clickItem,_deployOffset,_packDistance,_damageLimit,_packAny,_cargo,_ammo,_hive,_plot,_simulation,_road,_deployables,_near,_parts,_condition],
// [...more stuff here...]
// ];
//
// parameter | description | type | example
// --------------|---------------------------------------------------------------------|--------|--------
// _clickItem | class name of the item to click on | string | "ItemToolbox"
// _deployOffset | [_side,_front,_up] array to offset the deployable when buiding | array | [0,2,1]
// _packDistance | how close does the packer need to be to pack the object? | number | 5
// _damageLimit | item can't be repacked if damage is > this. (-1 = no re-packing) | number | 0.1
// _packAny | can anyone repack the deployable? | bool | false
// _cargo | clear the cargo of the deployable? | bool | false
// _ammo | should vehicle ammo be cleared? (does not persist through restart) | bool | true
// _hive | write deployable to database? | bool | false
// _plot | require a plot from the owner to build the deployable? | bool | false
// _simulation | enable simulation (movement/damage) for the object? (true for cars) | bool | true
// _road | enable road building for this object? | bool | true
// _deployables | array of class names that can be deployed with this method | array | ["MMT_Civ"]
// _near | array of items required nearby to build (workshop/fire/fueltank) | array | []
// _parts | array of parts required to build (will be taken from player) | array | ["ItemToolbox"]
// _condition | string of code to evaluate to determine whether action is shown | string | "!(isNull player) && {(getPlayerUID player) in DZE_DEPLOYABLE_ADMINS}"
DZE_DEPLOYABLES_CONFIG = [
// deploy a non-permanent bike from a toolbox right in front of the player that can be re-packed by the owner as long as it's under 10% damage
["ItemToolbox",[0,6,1],5,0.1,false,false,false,false,false,true,true,["MMT_Civ"],[],["ItemToolbox"],"true"],
["ItemToolbox",[0,6,1],5,0.1,false,false,false,false,false,true,true,["CSJ_GyroC"],[],["PartVRotor", "PartEngine", "ItemToolbox"],"true"],
["ItemToolbox",[0,6,1],5,0.1,false,false,false,false,false,true,true,["TT650_Civ"],[],["PartEngine", "ItemToolbox"],"true"]
// deploy fortifications from etool 3 meters in front of player that are permanent until server restart
//["ItemEtool",[0,3,0],5,-1,false,true,false,true,false,false,["Land_fort_rampart","Fort_StoneWall_EP1","Land_fort_bagfence_round"],[],["ItemEtool"],"true"],
// deploy a permanent helicopter from ruby 5 meters in front of player that can be re-packed by anyone as long as it's under 10% damage
//["ItemEtool",[0,8,0],5,-1,false,true,true,true,false,false,["Land_fortified_nest_big"],[],["ItemSandbagExLarge5x","ItemSandbagExLarge5x","ItemSandbagExLarge5x"],"true"],
//["PartWoodPile",[0,2,0],5,1,true,true,true,true,false,false,["Pile_of_wood"],[],["PartWoodPile","PartWoodPile","PartWoodPile","PartWoodPile","PartWoodPile"],"true"],
//["ItemSapphire",[0,2,0],5,1,true,true,true,true,false,false,["DSHKM_CDF","M2StaticMG","SearchLight_CDF"],[],["ItemSapphire"],"true"]
];
// **DZE_DEPLOYABLE_NAME_MAP format
//
// DZE_DEPLOYABLE_NAME_MAP = [
// [_class,_name],
// [_class,_name],
// [... more ...]
// ];
//
// parameter | description | type | example
// --------------|---------------------------------------------------------------------|--------|--------
// _class | class name of the item you want to replace the name of | string | "Notebook"
// _name | new name to display when right clicking | string | "Macbook Pro"
//
DZE_DEPLOYABLE_NAME_MAP = [
["Notebook","Macbook Pro"]
];
DZE_DEPLOYABLE_ADMINS = [];

View File

@ -0,0 +1,46 @@
private["_exitWith","_position","_display","_object","_handle","_deployableName"];
_exitWith = "nil";
disableSerialization;
_display = findDisplay 106;
if (!(isNull _display)) then {
_display closeDisplay 0;
};
_deployableName = _this call getDeployableDisplay;
{
if (_x select 0) exitWith {_exitWith = (_x select 1);};
} forEach [
[(dayz_playerUID in DZE_DEPLOYABLE_ADMINS),"admin"],
[!([player,_this] call getHasDeployableParts),format["You need %1 to build %2",str (_this call getDeployableParts),_deployableName]],
[!(call fnc_can_do),format["You can't build a %1 right now.",_deployableName]],
[(player getVariable["inCombat",false]), format["Can't build a %1 while in combat!",(_this call getDeployableDisplay)]],
[DZE_DEPLOYING,"You are already building something!"],
[DZE_PACKING,"You are already packing something!"]
];
if (_exitWith != "nil" && {_exitWith != "admin"}) exitWith {
taskHint [_exitWith, DZE_COLOR_DANGER, "taskFailed"];
};
DZE_DEPLOYING = true;
DZE_DEPLOYING_SUCCESSFUL = false;
_handle = (_this call getDeployableClass) spawn player_deploy;
waitUntil {scriptDone _handle;};
DZE_DEPLOYING = false;
if (!DZE_DEPLOYING_SUCCESSFUL) then {
taskHint ["Deploying Failed!", DZE_COLOR_DANGER, "taskFailed"];
} else {
taskHint [format["You've built a %1!",_deployableName], DZE_COLOR_PRIMARY, "taskDone"];
uiSleep 10;
if (!(_this call getPermanent)) then {
"Warning: Deployed vehicles DO NOT SAVE after server restart!" call dayz_rollingMessages;
} else {
"This vehicle is permanent and will persist through server restarts!" call dayz_rollingMessages;
};
};

View File

@ -0,0 +1,84 @@
// this function checks if play is on ladder/passed out/being drug
fnc_can_do = {
private ["_onLadder"];
_onLadder = (getNumber (configFile >> "CfgMovesMaleSdr" >> "States" >> (animationState player) >> "onLadder")) == 1;
(!r_drag_sqf && !r_player_unconscious && !_onLadder)
};
// this goes through a crafting animation until the loop is interrupted until interrupted by a set of conditions fed to the function
// it then returns the result of what broke the loop, or "nil" -- yes, string of "nil" -- if not broken
fnc_bike_crafting_animation = {
private ["_isLoopDone","_isAnimationStarted","_isAnimationCompleted","_animationState","_isAnimationActive","_exitWith"];
[player,(getPosATL player),30,"repair"] spawn fnc_alertZombies;
player playActionNow "Medic";
r_interrupt = false;
_isLoopDone = false;
_isAnimationStarted = false;
_isAnimationCompleted = false;
_animationState = animationState player;
_isAnimationActive = false;
_exitWith = "nil";
while {!_isLoopDone} do {
_animationState = animationState player;
_isAnimationActive = ["medic",_animationState] call fnc_inString;
if (_isAnimationActive) then {
_isAnimationStarted = true;
};
if (_isAnimationStarted && !_isAnimationActive) then {
_isLoopDone = true;
_isAnimationCompleted = true;
};
{
if (call compile (_x select 0)) exitWith {
_exitWith = _x select 1;
};
} forEach _this;
if (_exitWith != "nil") then {
_isLoopDone = true;
player switchMove "";
player playActionNow "stop";
};
sleep 0.3;
};
_exitWith
};
fnc_set_temp_deployable_id = {
_this setVariable ["DeployedBy",call fnc_temp_deployable_id, true];
};
fnc_set_perm_deployable_id = {
_this setVariable ["CharacterID",call fnc_perm_deployable_id, true];
};
fnc_get_perm_deployable_id = {
private["_return","_parse"];
_return = _this getVariable ["CharacterID","0"];
_parse = parseNumber _return;
if(_parse < 500000) then {
_return = "nil";
};
_return
};
fnc_get_temp_deployable_id = {
_this getVariable ["DeployedBy","nil"]
};
fnc_perm_deployable_id = {
private["_calc","_return"];
_calc = 999999 - (parseNumber dayz_characterID);
if(_calc < 500000) then {
_return = "nil";
} else {
_return = (str _calc);
};
_return
};
fnc_temp_deployable_id = {
getPlayerUID player
};

View File

@ -0,0 +1,101 @@
call compile preprocessFileLineNumbers "scripts\deployAnything\config.sqf";
call compile preprocessFileLineNumbers "scripts\deployAnything\wrapper.sqf";
call compile preprocessFileLineNumbers "scripts\deployAnything\functions.sqf";
_DZE_DEPLOYABLE_VERSION = "3.0.1";
diag_log format["Deploy Anything: loading version %1 ...",_DZE_DEPLOYABLE_VERSION];
player_deploy = compile preprocessFileLineNumbers "scripts\deployAnything\player_deploy.sqf";
DZE_DEPLOYABLES = [];
{
private["_class","_distance","_deployables","_packDist","_packOthers","_clearCargo","_clearAmmo","_permanent","_damage","_needNear","_parts","_requirePlot","_enableSim","_road","_condition"];
_class = _x select 0;
_distance = _x select 1;
_packDist = _x select 2;
_damage = _x select 3;
_packOthers = _x select 4;
_clearCargo = _x select 5;
_clearAmmo = _x select 6;
_permanent = _x select 7;
_requirePlot = _x select 8;
_enableSim = _x select 9;
_road = _x select 10;
_deployables = _x select 11;
_needNear = _x select 12;
_parts = _x select 13;
_condition = _x select 14;
{
DZE_DEPLOYABLES set [count DZE_DEPLOYABLES,[_class,_distance,_packDist,_damage,_packOthers,_clearCargo,_clearAmmo,_permanent,_requirePlot,_enableSim,_road,_x,_needNear,_parts,_condition]];
} forEach _deployables;
} forEach DZE_DEPLOYABLES_CONFIG;
if (isServer) exitWith {
diag_log "Deploy Anything: adding deployables to safe vehicle list...";
{
local _classname = _forEachIndex call getDeployableClass;
DZE_safeVehicle = DZE_safeVehicle + [_classname];
if (_forEachIndex call getPermanent && (!(_classname isKindof "AllVehicles") || (_classname isKindOf "StaticWeapon"))) then {
DayZ_SafeObjects set [count DayZ_SafeObjects,_classname];
};
} forEach DZE_DEPLOYABLES;
};
[] spawn {
if (!isDedicated && {isNil "DZE_CLICK_ACTIONS"}) exitWith {
diag_log "Deploy Anything: ERROR -- Click Actions Handler missing!";
};
{
DZE_CLICK_ACTIONS = DZE_CLICK_ACTIONS + [[(_forEachIndex call getDeployableKitClass),format["Deploy %1",(_forEachIndex call getDeployableDisplay)],format["%1 execVM 'scripts\deployAnything\deploy.sqf';",_forEachIndex],(_forEachIndex call getDeployableCondition)]];
} forEach DZE_DEPLOYABLES;
DZE_DEPLOYING = false;
DZE_PACKING = false;
DZE_COLOR_PRIMARY = [(51/255),(181/255),(229/255),1];
DZE_COLOR_SUCCESS = [(153/255),(204/255),0,1];
DZE_COLOR_DANGER = [1,(68/255),(68/255),1];
diag_log "Deploy Anything: waiting for login...";
waitUntil{!isNil "Dayz_loginCompleted"};
[] spawn {
waitUntil {sm_done;};
{
if (parseNumber(_x getVariable["CharacterID","0"]) > 500000) then {
[_x,false] call local_lockUnlock;
};
} forEach vehicles;
};
while {true} do {
if (!isNull player) then {
{
private ["_cursorTarget"];
_cursorTarget = cursorTarget;
if (!(isNull _cursorTarget)
&& {_forEachIndex call getDeployablePackAny}
&& {typeOf _cursorTarget == (_forEachIndex call getDeployableClass)}
&& {call fnc_can_do}
&& {(((_cursorTarget call fnc_get_temp_deployable_id) != "nil") || ((_cursorTarget call fnc_get_perm_deployable_id) != "nil"))}
&& {(
((_cursorTarget call fnc_get_perm_deployable_id) == (call fnc_perm_deployable_id))
|| ((_cursorTarget call fnc_get_temp_deployable_id) == (call fnc_temp_deployable_id))
|| (_forEachIndex call getDeployablePackOthers)
|| ((getPlayerUID player) in DZE_DEPLOYABLE_ADMINS)
)}
&& {(player distance _cursorTarget) < (_forEachIndex call getDeployablePackDistance)}) then {
if ((_forEachIndex call getActionId) < 0) then {
[_forEachIndex,player addaction["<t color='#33b5e5'>" + format["Pack %1",(_forEachIndex call getDeployableDisplay)] + "</t>","scripts\deployAnything\pack.sqf",[_forEachIndex,_cursorTarget],0,false,true]] call setActionId;
};
} else {
player removeAction (_forEachIndex call getActionId);
[_forEachIndex,-1] call setActionId;
};
} forEach DZE_DEPLOYABLES;
};
uiSleep 2.5;
};
};

View File

@ -0,0 +1,60 @@
private["_isPackingLocked","_lastPackTime","_exitWith","_deployable","_cursorTarget","_deployableName"];
_exitWith = "nil";
_deployable = (_this select 3) select 0;
_cursorTarget = (_this select 3) select 1;
_lastPackTime = _cursorTarget getVariable["lastPackTime",diag_tickTime - 11];
_isPackingLocked = diag_tickTime - _lastPackTime < 10;
_deployableName = _deployable call getDeployableDisplay;
{
if (_x select 0) exitWith {_exitWith = (_x select 1);};
} forEach [
[(dayz_playerUID in DZE_DEPLOYABLE_ADMINS),"admin"],
[!(call fnc_can_do),format["You can't pack your %1 right now.",_deployableName]],
[(player getVariable["inCombat",false]),format["Can't pack a %1 while in combat!",_deployableName]],
[(damage cursorTarget > (_deployable call getDamageLimit)),format["The %1 must be under %2 percent damaged to pack!",_deployableName,(_deployable call getDamageLimit) * 100]],
[_isPackingLocked,format["Someone just tried to pack that %1! Try again in a few seconds.",_deployableName]],
[DZE_PACKING,"You are already packing something!"],
[DZE_DEPLOYING,"You are already building something!"]
];
if (_exitWith != "nil" && {_exitWith != "admin"}) exitWith {
taskHint [_exitWith, DZE_COLOR_DANGER, "taskFailed"];
};
_cursorTarget setVariable["lastPackTime",diag_tickTime,true];
DZE_PACKING = true;
_exitWith = [
["dayz_playerUID in DZE_DEPLOYABLE_ADMINS","admin"],
["r_interrupt",format["Packing %1 interrupted!",_deployableName]],
["(player getVariable['inCombat',false])",format["You can't pack your %1 while in combat!",_deployableName]]
] call fnc_bike_crafting_animation;
if (_exitWith != "nil" && {_exitWith != "admin"}) exitWith {
DZE_PACKING = false;
taskHint [_exitWith, DZE_COLOR_DANGER, "taskFailed"];
};
{
if (isClass(configFile >> "CfgWeapons" >> _x)) then {
player addWeapon _x;
};
if (isClass(configFile >> "CfgMagazines" >> _x)) then {
player addMagazine _x;
};
} forEach (_deployable call getDeployableParts);
if (_deployable call getPermanent) then {
PVDZ_obj_Destroy = [_cursorTarget getVariable["ObjectID","0"],_cursorTarget getVariable["ObjectUID","0"],player,_cursorTarget,dayz_authKey];
publicVariableServer "PVDZ_obj_Destroy";
} else {
deleteVehicle _cursorTarget;
};
player removeAction (_deployable call getActionId);
[_deployable,-1] call setActionId;
DZE_PACKING = false;
taskHint [format["You have packed your %1 back into your %2.",_deployableName,(_deployable call getDeployableKitDisplay)], DZE_COLOR_PRIMARY, "taskDone"];

View File

@ -0,0 +1,463 @@
/*
DayZ Base Building
Made for DayZ Epoch please ask permission to use/edit/distrubute email vbawol@veteranbastards.com.
*/
private ["_vector","_IsNearPlot","_abort","_animState","_buildables","_buildcheck","_canBuild","_cancel","_classname","_classnametmp","_counter","_dir","_distance","_exitWith","_finished","_friendlies","_hasbuilditem","_hasrequireditem","_hastoolweapon","_index","_inVehicle","_isAllowedUnderGround","_isMedic","_isNear","_isOk","_isfriendly","_isowner","_limit","_location","_location1","_location2","_message","_missing","_nearestPole","_needNear","_needText","_objHDiff","_object","_offset","_onLadder","_ownerID","_plotcheck","_position","_proceed","_reason","_requireplot","_rotate","_started","_text","_tmpbuilt","_vehicle","_zheightchanged","_zheightdirection","_havePad","_heliPad","_charID"];
if (dayz_actionInProgress) exitWith {localize "str_epoch_player_40" call dayz_rollingMessages;};
dayz_actionInProgress = true;
_onLadder = (getNumber (configFile >> "CfgMovesMaleSdr" >> "States" >> (animationState player) >> "onLadder")) == 1;
_cancel = false;
_reason = "";
_vehicle = vehicle player;
_inVehicle = (_vehicle != player);
DZE_Q = false;
DZE_Z = false;
DZE_Q_alt = false;
DZE_Z_alt = false;
DZE_Q_ctrl = false;
DZE_Z_ctrl = false;
DZE_5 = false;
DZE_4 = false;
DZE_6 = false;
DZE_cancelBuilding = false;
call gear_ui_init;
closeDialog 1;
if (dayz_isSwimming) exitWith {dayz_actionInProgress = false; localize "str_player_26" call dayz_rollingMessages;};
if (_inVehicle) exitWith {dayz_actionInProgress = false; localize "str_epoch_player_42" call dayz_rollingMessages;};
if (_onLadder) exitWith {dayz_actionInProgress = false; localize "str_player_21" call dayz_rollingMessages;};
if (player getVariable["combattimeout",0] >= diag_tickTime) exitWith {dayz_actionInProgress = false; localize "str_epoch_player_43" call dayz_rollingMessages;};
_abort = false;
_reason = "";
_index = _this call getDeployableIndex;
_needNear = _index call getDeployableNeedNearBy;
{
switch (_x) do {
case "fire": {
_distance = 3;
_isNear = {inflamed _x} count (getPosATL player nearObjects _distance);
if (_isNear == 0) then {
_abort = true;
_reason = localize "STR_EPOCH_FIRE";
};
};
case "workshop": {
_distance = 3;
_isNear = count (nearestObjects [player, ["Wooden_shed_DZ","WoodShack_DZ","WorkBench_DZ"], _distance]);
if (_isNear == 0) then {
_abort = true;
_reason = localize "STR_BLD_name_ItemWorkshop";
};
};
case "fueltank": {
_distance = 30;
_isNear = count (nearestObjects [player, dayz_fuelsources, _distance]);
if (_isNear == 0) then {
_abort = true;
_reason = localize "STR_EPOCH_VEHUP_TNK";
};
};
};
} forEach _needNear;
if (_abort) exitWith {
dayz_actionInProgress = false;
format[localize "str_epoch_player_135",_reason,_distance] call dayz_rollingMessages;
};
_classname = _index call getDeployableClass;
_classnametmp = _classname;
_text = _index call getDeployableDisplay;
if (_index call getDeployableRequirePlot) then {_requireplot = 1;} else {_requireplot = 0;};
_isAllowedUnderGround = 1;
if (isNumber (configFile >> "CfgVehicles" >> _classname >> "nounderground")) then {
_isAllowedUnderGround = getNumber(configFile >> "CfgVehicles" >> _classname >> "nounderground");
};
_offset = _index call getDeployableDistanceOffset;
_distance = DZE_PlotPole select 0;
_needText = localize "str_epoch_player_246";
_canBuild = false;
_nearestPole = objNull;
_ownerID = 0;
_friendlies = [];
_plotcheck = [player, false] call FNC_find_plots;
_distance = DZE_PlotPole select 0;
_IsNearPlot = _plotcheck select 1;
_nearestPole = _plotcheck select 2;
if (_IsNearPlot == 0) then {
if (_requireplot == 0) then {
_canBuild = true;
} else {
_exitWith = localize "STR_EPOCH_PLAYER_135";
};
} else {
if (_requireplot == 0) then {
_canBuild = true;
} else {
_ownerID = _nearestPole getVariable["CharacterID","0"];
if (dayz_characterID == _ownerID) then {
_canBuild = true;
} else {
if (DZE_permanentPlot) then {
_buildcheck = [player, _nearestPole] call FNC_check_access;
_isowner = _buildcheck select 0;
_isfriendly = ((_buildcheck select 1) or (_buildcheck select 3));
if (_isowner || _isfriendly) then {
_canBuild = true;
} else {
_exitWith = localize "STR_EPOCH_PLAYER_134";
};
} else {
_friendlies = player getVariable ["friendlyTo",[]];
if (_ownerID in _friendlies) then {
_canBuild = true;
} else {
_exitWith = localize "STR_EPOCH_PLAYER_134";
};
};
};
};
};
if (!_canBuild) exitWith {dayz_actionInProgress = false; format[_exitWith,_needText,_distance] call dayz_rollingMessages;};
_havePad = false;
if !(isNil "vg_list") then {
if (_className in vg_heliPads) then {
_heliPad = nearestObjects [player,vg_heliPads,vg_distance];
if (count _heliPad > 0) then {
_havePad = true;
};
};
};
if (_havePad) exitWith {
dayz_actionInProgress = false;
systemChat "You already have a heli pad!";
};
_missing = "";
_hasrequireditem = true;
_hastoolweapon = (_index call getDeployableKitClass) in ((weapons player) + (magazines player));
if (!_hastoolweapon) then { _hasrequireditem = false; _missing = (_index call getDeployableKitDisplay); };
_hasbuilditem = [player,_index] call getHasDeployableParts;
if (!_hasbuilditem) exitWith {dayz_actionInProgress = false; format[localize "str_player_31",str (_index call getDeployableParts),"build"] call dayz_rollingMessages; };
if (!_hasrequireditem) exitWith {dayz_actionInProgress = false; format[localize "str_epoch_player_137",_missing] call dayz_rollingMessages; };
if (_hasrequireditem) then {
_dir = getdir player;
_location = getPos player;
_location = [(_location select 0)+8*sin(_dir),(_location select 1)+8*cos(_dir),0];
_isOk = true;
_location1 = getPosATL player;
_object = createVehicle [_classname, _location, [], 0, "CAN_COLLIDE"];
_object setVehicleLock "LOCKED";
_object setVariable["ObjectUID","1",true];
_object attachTo [player,_offset];
_object setDir _dir;
_position = getPosATL _object;
[localize "str_epoch_player_45",1] call dayz_rollingMessages;
_objHDiff = 0;
while {_isOk} do {
_zheightchanged = false;
_zheightdirection = "";
_rotate = false;
if (DZE_Q) then {
DZE_Q = false;
_zheightdirection = "up";
_zheightchanged = true;
};
if (DZE_Z) then {
DZE_Z = false;
_zheightdirection = "down";
_zheightchanged = true;
};
if (DZE_Q_alt) then {
DZE_Q_alt = false;
_zheightdirection = "up_alt";
_zheightchanged = true;
};
if (DZE_Z_alt) then {
DZE_Z_alt = false;
_zheightdirection = "down_alt";
_zheightchanged = true;
};
if (DZE_Q_ctrl) then {
DZE_Q_ctrl = false;
_zheightdirection = "up_ctrl";
_zheightchanged = true;
};
if (DZE_Z_ctrl) then {
DZE_Z_ctrl = false;
_zheightdirection = "down_ctrl";
_zheightchanged = true;
};
if (DZE_4) then {
_rotate = true;
DZE_4 = false;
_dir = _dir + 30;
};
if (DZE_6) then {
_rotate = true;
DZE_6 = false;
_dir = _dir - 30;
};
if (_rotate) then {
_object setDir _dir;
_object setPosATL _position;
};
if (_zheightchanged) then {
detach _object;
_position = getPosATL _object;
if (_zheightdirection == "up") then {
_position set [2,((_position select 2)+0.1)];
_objHDiff = _objHDiff + 0.1;
};
if (_zheightdirection == "down") then {
_position set [2,((_position select 2)-0.1)];
_objHDiff = _objHDiff - 0.1;
};
if (_zheightdirection == "up_alt") then {
_position set [2,((_position select 2)+1)];
_objHDiff = _objHDiff + 1;
};
if (_zheightdirection == "down_alt") then {
_position set [2,((_position select 2)-1)];
_objHDiff = _objHDiff - 1;
};
if (_zheightdirection == "up_ctrl") then {
_position set [2,((_position select 2)+0.01)];
_objHDiff = _objHDiff + 0.01;
};
if (_zheightdirection == "down_ctrl") then {
_position set [2,((_position select 2)-0.01)];
_objHDiff = _objHDiff - 0.01;
};
if ((_isAllowedUnderGround == 0) && ((_position select 2) < 0)) then {
_position set [2,0];
};
_object setPosATL _position;
_object attachTo [player];
_object setDir _dir;
};
uiSleep 0.5;
_location2 = getPosATL player;
if (DZE_5) exitWith {
_isOk = false;
_position = [_object] call FNC_GetPos;
detach _object;
_dir = getDir _object;
_vector = [(vectorDir _object),(vectorUp _object)];
deleteVehicle _object;
};
if (_location1 distance _location2 > DZE_buildMaxMoveDistance) exitWith {
_isOk = false;
_cancel = true;
_reason = format [localize "STR_EPOCH_BUILD_FAIL_MOVED",DZE_buildMaxMoveDistance];
detach _object;
deleteVehicle _object;
};
if (abs(_objHDiff) > DZE_buildMaxHeightDistance) exitWith {
_isOk = false;
_cancel = true;
_reason = format [localize "STR_EPOCH_BUILD_FAIL_HEIGHT",DZE_buildMaxHeightDistance];
detach _object;
deleteVehicle _object;
};
if (DZE_cancelBuilding) exitWith {
_isOk = false;
_cancel = true;
_reason = localize "STR_EPOCH_PLAYER_46";
detach _object;
deleteVehicle _object;
};
};
if (!(_index call getDeployableBuildOnRoad)) then {if (isOnRoad [_position select 0, _position select 1, 0]) then { _cancel = true; _reason = localize "STR_EPOCH_BUILD_FAIL_ROAD";};};
if (_classname isKindOf "MotorCycle") then {
if (count (nearestObjects [_position, ["Building","DZE_Housebase"], 5]) > 0) then {
_cancel = true;
_reason = format ["%1 can not be built near a wall/door",_text];
};
};
if (!_cancel) then {
_classname = _classnametmp;
_tmpbuilt = createVehicle [_classname, _location, [], 0, "CAN_COLLIDE"];
_tmpbuilt setVehicleLock "LOCKED";
if (!(_index call getDeployableSimulation)) then {
_tmpbuilt enableSimulation false;
};
_tmpbuilt setVariable ["ObjectUID", "1", true];
if (_index call getPermanent) then {
_tmpbuilt setVectorDirAndUp _vector;
} else {
_tmpbuilt setdir _dir; // setdir is incompatible with setVectorDirAndUp and should not be used together on the same object https://community.bistudio.com/wiki/setVectorDirAndUp
};
_location = _position;
if ((_isAllowedUnderGround == 0) && ((_location select 2) < 0)) then {
_location set [2,0];
};
_tmpbuilt setPosATL _location;
format[localize "str_epoch_player_138",_text] call dayz_rollingMessages;
_limit = 3;
if (DZE_StaticConstructionCount > 0) then {
_limit = DZE_StaticConstructionCount;
} else {
if (isNumber (configFile >> "CfgVehicles" >> _classname >> "constructioncount")) then {
_limit = getNumber(configFile >> "CfgVehicles" >> _classname >> "constructioncount");
};
};
_isOk = true;
_proceed = false;
_counter = 0;
while {_isOk} do {
["Working",0,[100,15,10,0]] call dayz_NutritionSystem;
if !((getPlayerUID player) in DZE_DEPLOYABLE_ADMINS) then {
player playActionNow "Medic";
[player,"repair",0,false,20] call dayz_zombieSpeak;
[player,20,true,(getPosATL player)] spawn player_alertZombies;
r_interrupt = false;
r_doLoop = true;
_started = false;
_finished = false;
while {r_doLoop} do {
_animState = animationState player;
_isMedic = ["medic",_animState] call fnc_inString;
if (_isMedic) then {
_started = true;
};
if (_started && !_isMedic) then {
r_doLoop = false;
_finished = true;
};
if (r_interrupt) then {
r_doLoop = false;
};
if (DZE_cancelBuilding) exitWith {
r_doLoop = false;
};
uiSleep 0.1;
};
r_doLoop = false;
} else {
_finished = true;
};
if (!_finished) exitWith {
_isOk = false;
_proceed = false;
};
if (_finished) then {
_counter = _counter + 1;
};
format[localize "str_epoch_player_139",_text, _counter,_limit] call dayz_rollingMessages;
if (_counter == _limit) exitWith {
_isOk = false;
_proceed = true;
};
};
if (_proceed) then {
if ([player,_index] call getHasDeployableParts) then {
[player,_index] call removeDeployableParts;
[format[localize "str_build_01",_text],1] call dayz_rollingMessages;
_tmpbuilt setVariable ["OEMPos",_location,true];
if (_index call getPermanent) then {
_charID = dayz_characterID;
_tmpbuilt setVariable ["CharacterID",_charID,true];
PVDZ_obj_Publish = [_charID,_tmpbuilt,[_dir,_position,dayz_playerUID,_vector],[],player,dayz_authKey];
publicVariableServer "PVDZ_obj_Publish";
};
if (_index call getClearCargo) then {
clearWeaponCargoGlobal _tmpbuilt;
clearMagazineCargoGlobal _tmpbuilt;
};
if (_index call getDeployableClearAmmo) then {
_tmpbuilt setVehicleAmmo 0;
};
_tmpbuilt call fnc_set_temp_deployable_id;
player reveal _tmpbuilt;
_tmpbuilt call fnc_veh_ResetEH;
// for non JIP users this should make sure everyone has eventhandlers for vehicles.
PVDZE_veh_Init = _tmpbuilt;
publicVariable "PVDZE_veh_Init";
_tmpbuilt setVehicleLock "UNLOCKED";
DZE_DEPLOYING_SUCCESSFUL = true;
} else {
deleteVehicle _tmpbuilt;
localize "str_epoch_player_46" call dayz_rollingMessages;
};
} else {
r_interrupt = false;
if (vehicle player == player) then {
[objNull, player, rSwitchMove,""] call RE;
player playActionNow "stop";
};
deleteVehicle _tmpbuilt;
localize "str_epoch_player_46" call dayz_rollingMessages;
};
} else {
format[localize "str_epoch_player_47",_text,_reason] call dayz_rollingMessages;
};
};
dayz_actionInProgress = false;

View File

@ -0,0 +1,180 @@
/* this sqf file is used to manipulate the deployable array to work more like a class than an array */
/* this gets the item that makes the deployable */
getDeployableKitClass = {
(DZE_DEPLOYABLES select _this) select 0
};
/* this gets the distance of the deployable */
getDeployableDistanceOffset = {
(DZE_DEPLOYABLES select _this) select 1
};
/* this gets the distance a player must be to pack the deployable back up */
getDeployablePackDistance = {
(DZE_DEPLOYABLES select _this) select 2
};
/* if the damage is higher than this, it can't be packed again */
getDamageLimit = {
(DZE_DEPLOYABLES select _this) select 3
};
/* should players be allowed to pack deployables placed by others? */
getDeployablePackOthers = {
(DZE_DEPLOYABLES select _this) select 4
};
/* checks if cargo should be cleared for this item */
getClearCargo = {
(DZE_DEPLOYABLES select _this) select 5
};
/* should vehicle ammo be cleared when spawned? */
getDeployableClearAmmo = {
(DZE_DEPLOYABLES select _this) select 6
};
/* should the vehicle be saved permanently to the database */
getPermanent = {
(DZE_DEPLOYABLES select _this) select 7
};
/* does the deployable require a plot to build ? */
getDeployableRequirePlot = {
(DZE_DEPLOYABLES select _this) select 8
};
/* does the object have simulation enabled? */
getDeployableSimulation = {
(DZE_DEPLOYABLES select _this) select 9
};
/* can the object be built on a road? */
getDeployableBuildOnRoad = {
(DZE_DEPLOYABLES select _this) select 10
};
/* this gets the class of the deployable */
getDeployableClass = {
(DZE_DEPLOYABLES select _this) select 11
};
getDeployableNeedNearBy = {
(DZE_DEPLOYABLES select _this) select 12
};
/* the parts required to make this item */
getDeployableParts = {
(DZE_DEPLOYABLES select _this) select 13
};
/* what condition is used to determine whether or not the player sees the option? */
getDeployableCondition = {
(DZE_DEPLOYABLES select _this) select 14
};
/* should players be allowed to pack deployables at all? */
getDeployablePackAny = {
((_this call getDamageLimit) >= 0) || (!(isNull player) && {dayz_playerUID in DZE_DEPLOYABLE_ADMINS});
};
/* this gets what type of item the kit is*/
getDeployableKitType = {
private["_return"];
if(isClass(configFile >> "CfgWeapons" >> (_this call getDeployableKitClass))) then {
_return = "CfgWeapons";
} else {
_return = "CfgMagazines";
};
_return
};
/* this is a wrapper function for getting the value of the scroll action */
getActionId = {
call compile format["
if (isNil 'DZE_ACTION_DEPLOYABLE_PACK_%1') then {
DZE_ACTION_DEPLOYABLE_PACK_%1 = -1;
};
DZE_ACTION_DEPLOYABLE_PACK_%1
",_this];
};
/* this is a wrapper function for setting the value of the scroll action */
setActionId = {
call compile format["DZE_ACTION_DEPLOYABLE_PACK_%1 = %2;",_this select 0,_this select 1];
};
/* this gets the display name of the kit or falls back to class name if unsuccessful */
getDeployableKitDisplay = {
private["_display"];
_display = getText (configFile >> (_this call getDeployableKitType) >> (_this call getDeployableKitClass) >> "displayName");
if((isNil "_display")||_display == "") then {
_display = (_this call getDeployableKitClass);
};
_display
};
/* this gets the display name of the deployable or falls back to class name if unsuccessful */
getDeployableDisplay = {
private["_display","_class"];
_class = (_this call getDeployableClass);
_display = getText (configFile >> "CfgVehicles" >> _class >> "displayName");
if((isNil "_display")||_display == "") then {
_display = _class;
};
{
if(_class == (_x select 0)) then {
_display = (_x select 1);
};
} forEach DZE_DEPLOYABLE_NAME_MAP;
_display
};
/* looks up the index of a deployable based on the class */
getDeployableIndex = {
private["_return"];
_return = -1;
{
if(_this == (_forEachIndex call getDeployableClass)) then {
_return = _forEachIndex;
}
} forEach DZE_DEPLOYABLES;
_return
};
/* check if player has required parts to build the item */
/* [player,_partIndex] call getHasDeployableParts; */
getHasDeployableParts = {
private["_player","_weapons","_parts","_item","_params","_index","_part","_return","_inventory"];
_params = _this;
_player = _params select 0;
_index = _params select 1;
_parts = _index call getDeployableParts;
_inventory = (weapons _player) + (magazines _player);
_return = true;
{
_part = _x;
if(!(_part in _inventory)) exitWith {_return = false;};
{
_item = _x;
if(_item == _part) exitWith {_inventory set [_forEachIndex,"nil"];};
} forEach _inventory;
} forEach _parts;
_return
};
/* remove this item's parts from the players inventory */
/* [player,_partIndex] call removeDeployableParts; */
removeDeployableParts = {
private["_player","_params","_index","_parts","_part"];
_params = _this;
_player = _params select 0;
_index = _params select 1;
_parts = _index call getDeployableParts;
{
_part = _x;
_player removeWeapon _part;
_player removeMagazine _part;
} forEach _parts;
};