Update vanilla building

Vanilla commits applied:

44f2552ff2

213a333ce5

423d53299d

43bce6554f

f551cdac6e
This commit is contained in:
ebaydayz
2016-09-21 17:14:13 -04:00
parent 33cf7611ed
commit 5e71793c17
2 changed files with 208 additions and 168 deletions

View File

@@ -17,6 +17,8 @@ _keepOnSlope = 0 == (getNumber (configFile >> "CfgVehicles" >> _classname >> "ca
Dayz_constructionContext set [ 4, false ]; // Stop the construction mode, cf. player_build.sqf
//if (count Dayz_constructionContext < 5) then { Dayz_constructionContext set [ 5, false ]; // };
if (_build) then {
_location = getPosATL _ghost;
_direction = getDir _ghost;
@@ -24,6 +26,8 @@ if (_build) then {
_object setDir _direction;
diag_log (Dayz_constructionContext);
if ((Dayz_constructionContext select 5) or (_keepOnSlope)) then {
_object setVectorUp surfaceNormal _location;
_location set [2,0];

View File

@@ -4,7 +4,7 @@ private ["_classType","_item","_action","_missingTools","_missingItem","_emergin
"_o","_offset","_rot","_r","_p","_bn","_bb","_h","_bx","_by","_minElevation","_maxElevation","_insideCheck","_building",
"_unit","_bbb","_ubb","_check","_min","_max","_myX","_myY","_checkBuildingCollision","_objColliding","_inside","_checkOnRoad",
"_roadCollide","_checkBeam2Magnet","_a","_beams","_best","_b","_d","_checkNotBuried","_elevation","_position","_delta","_overElevation",
"_maxplanting","_safeDistance","_dir","_angleRef","_tmp","_actionCancel","_sfx","_actionBuild","_byPassChecks","_keepOnSlope",
"_maxplanting","_safeDistance","_dir","_angleRef","_tmp","_actionCancel","_sfx","_actionBuild","_byPassChecks","_keepOnSlope","_msg",
"_isCollisionBypass","_ok","_missing","_upgradeParts","_ownerID","_posReference"];
/*
Needs a full rewrite to keep up with the demand of everything we plan to add.
@@ -53,7 +53,9 @@ _isWater = {(surfaceIsWater (getPosATL _object)) or dayz_isSwimming};
if (0 != count Dayz_constructionContext) then {
dayz_actionInProgress = false;
localize "str_already_building" call dayz_rollingMessages;
//cutText [localize "str_already_building", "PLAIN DOWN"];
_msg = localize "str_already_building";
_msg call dayz_rollingMessages;
diag_log [ diag_ticktime, __FILE__, 'already building, exiting', Dayz_constructionContext, typeName Dayz_constructionContext];
};
@@ -64,11 +66,17 @@ if (isClass (configFile >> _isClass >> _item)) then {
case (_item isKindOf "Land_A_tent"): {"str_player_31_pitch"};
default {"str_player_31_build"};
};
format[localize "str_player_31",_text,(localize _string)] call dayz_rollingMessages;
//cutText [format [localize "str_player_31",_text,(localize _string)] , "PLAIN DOWN"];
_msg = format [localize "str_player_31",_text,(localize _string)];
_msg call dayz_rollingMessages;
//diag_log(format["player_build: item:%1 require:%2 Player items:%3 magazines:%4", _item, _requiredTools, (items player), (magazines player)]);
};
};
_posReference = [player] call FNC_GetPos;
_canBuild = [_posReference, _item, false] call DZE_BuildChecks;
if !(_canBuild select 0) exitWith {dayz_actionInProgress = false;};
// lets check player has requiredTools for upgrade
_ok = true;
_missing = "";
@@ -82,13 +90,11 @@ _missing = "";
if (!_ok) exitWith {
dayz_actionInProgress = false;
format[localize "str_player_31_missingtools",_text,_missing] call dayz_rollingMessages;
//cutText [format [localize "str_player_31_missingtools",_text,_missing] , "PLAIN DOWN"];
_msg = format [localize "str_player_31_missingtools",_text,_missing];
_msg call dayz_rollingMessages;
};
_posReference = [player] call FNC_GetPos;
_canBuild = [_posReference, _item, false] call DZE_BuildChecks;
if !(_canBuild select 0) exitWith {dayz_actionInProgress = false;};
// lets check player has requiredParts for upgrade
_ok = true;
_upgradeParts = [];
@@ -102,15 +108,18 @@ _upgradeParts = [];
player removeMagazine _x;
};
} count _requiredParts;
call player_forceSave;
if (!_ok) exitWith {
{ player addMagazine _x; } foreach _upgradeParts;
dayz_actionInProgress = false;
format[localize "str_player_31", _missing, localize "str_player_31_build"] call dayz_rollingMessages;
// cutText [format [localize "str_player_31", _missing, localize "str_player_31_build"] , "PLAIN DOWN"];
_msg = format [localize "str_player_31", _missing, localize "str_player_31_build"];
_msg call dayz_rollingMessages;
};
localize "str_player_build_rotate" call dayz_rollingMessages;
_msg = localize "str_player_build_rotate";
_msg call dayz_rollingMessages;
//Get fence beams based on model
_getBeams = {
@@ -164,20 +173,51 @@ _maxElevation = {
_r
};
#define COLLIDABLE_OBJECT_MIN_SIZE 8
//check if building being placed and objects around placement is free to be built on.
//Fence owners must build all the foundations by one player anyone can still upgrade (pending lock build level)
_checkBuildingCollision =
{
scopeName "root";
_objColliding = objNull;
local _count = getNumber (configFile >> "CfgVehicles" >> _ghost >> "buildCollisionPoints");
if (_count == 0) exitWith {};
local _wall = _object isKindOf "DZ_buildables";
//Load object collision points
local _points = [];
_points resize _count;
for "_i" from 0 to _count - 1 do
{ _points set [_i, ATLtoASL (_object modelToWorld (_object selectionPosition format ["buildCollision%1", _i]))]; };
//Trace paths
{
if (!(isNull _x || { _x == player || _x == _object}) && { !(_wall && { _x isKindOf "DZ_buildables" && { _x getVariable ["ownerArray", [""]] select 0 == getPlayerUID player } }) && { [_object, _x] call fn_collisions } }) exitWith
local _p2 = _x select 0; //[0,1,3,2,0,3]
for "_i" from 1 to count _x - 1 do
{
local _p1 = _p2;
_p2 = _x select _i;
{
if (!_wall || { !(_x isKindOf "DZ_buildables" && { _x getVariable ["ownerArray", [""]] select 0 == getPlayerUID player }) }) then
{
local _type = typeof _x;
if (_type != "" && { sizeof _type >= COLLIDABLE_OBJECT_MIN_SIZE }) then
{
_objColliding = _x;
breakTo "root";
};
};
}
foreach nearestObjects [_object, ["AllVehicles", "Building", "DZ_buildables"], 35];
foreach lineIntersectsWith [_points select _p1, _points select _p2, _object, player];
};
} foreach getArray (configFile >> "CfgVehicles" >> _ghost >> "buildCollisionPaths");
};
//Is placement on a road?
@@ -238,7 +278,7 @@ _dir = getDir player;
_object setDir _dir;
Dayz_constructionContext = [_object, round (_dir/5)*5, cameraView, false, true, _keepOnSlope];
// ghost, angle, previous camera, build view on/off, continue on/off, slope on/off
//_posReference = getPosATL player;
_posReference = getPosATL player;
_objColliding = objNull;
_best = [50,[0,0,0],[0,0,0]];
_maxplanting = 10;
@@ -247,7 +287,7 @@ _position = getPosATL _object;
_actionBuildHidden = true;
_actionCancel = player addAction [localize "str_player_build_cancel", "\z\addons\dayz_code\actions\object_build.sqf", [_object, _requiredParts, _classname, _text, false, 0, "none"], 1, true, true, "", "0 != count Dayz_constructionContext"];
while {dayz_actionInProgress && Dayz_constructionContext select 4} do {
while {dayz_actionInProgress and Dayz_constructionContext select 4} do {
// force the angle so that the ghost is showing always the same side
_angleRef=Dayz_constructionContext select 1;
@@ -269,6 +309,7 @@ while {dayz_actionInProgress && Dayz_constructionContext select 4} do {
r_interrupt = false;
_object setDir _angleRef;
_tmp = player modelToWorld [0, _safeDistance,0];
if (Dayz_constructionContext select 5 or _keepOnSlope) then {
_tmp set [2, 0];
_object setVectorUp surfaceNormal _tmp;
@@ -281,14 +322,9 @@ while {dayz_actionInProgress && Dayz_constructionContext select 4} do {
_object setPosATL _position;
};
//Need to add config based bypass checks array.
if (!_isCollisionBypass) then {
// check now that ghost is not colliding
//Check collisions
call _checkBuildingCollision;
//diag_log ("Collision Test");
};
// try to dock a beam from current ghost to another beams nearby
call _checkBeam2Magnet;