mirror of
https://github.com/EpochModTeam/DayZ-Epoch.git
synced 2025-12-13 19:52:38 +03:00
Updated Vanilla Buildables collision Checks.
Vanilla development commit:
8e2953ab67
This commit is contained in:
@@ -157,70 +157,56 @@ _maxElevation = {
|
|||||||
_r
|
_r
|
||||||
};
|
};
|
||||||
|
|
||||||
//Is the placed object inside another object
|
//Collision system replaced.
|
||||||
_insideCheck = {
|
/*
|
||||||
private ["_bbb","_building","_ubb","_unit","_check","_min","_max","_myX","_p","_myY"];
|
//Is the placed object inside another object
|
||||||
|
_insideCheck = {
|
||||||
|
private ["_bbb","_building","_ubb","_unit","_check","_min","_max","_myX","_p","_myY"];
|
||||||
|
|
||||||
_building = _this select 0;
|
_building = _this select 0;
|
||||||
_unit = _this select 1;
|
_unit = _this select 1;
|
||||||
|
|
||||||
if ((typeOf _building != "") and {((sizeOf (typeOf _building) < 8) or {(_unit distance _building > (sizeOf (typeOf _building) + sizeOf (typeOf _unit))/2)})}) exitwith {false};
|
|
||||||
|
|
||||||
_bbb = boundingBox _building;
|
|
||||||
_ubb = boundingBox _unit;
|
|
||||||
|
|
||||||
_check = {
|
|
||||||
_min = _bbb select 0;
|
|
||||||
_max = _bbb select 1;
|
|
||||||
_myX = _p select 0;
|
|
||||||
_myY = _p select 1;
|
|
||||||
|
|
||||||
(((_myX > (_min select 0)) and {(_myX < (_max select 0))}) and {((_myY > (_min select 1)) and {(_myY < (_max select 1))})})
|
if ((typeOf _building != "") and {((sizeOf (typeOf _building) < 8) or {(_unit distance _building > (sizeOf (typeOf _building) + sizeOf (typeOf _unit))/2)})}) exitwith {false};
|
||||||
};
|
|
||||||
|
_bbb = boundingBox _building;
|
||||||
|
_ubb = boundingBox _unit;
|
||||||
|
|
||||||
|
_check = {
|
||||||
|
_min = _bbb select 0;
|
||||||
|
_max = _bbb select 1;
|
||||||
|
_myX = _p select 0;
|
||||||
|
_myY = _p select 1;
|
||||||
|
|
||||||
|
(((_myX > (_min select 0)) and {(_myX < (_max select 0))}) and {((_myY > (_min select 1)) and {(_myY < (_max select 1))})})
|
||||||
|
};
|
||||||
|
|
||||||
_p = _building worldToModel (_unit modelToWorld [ (_ubb select 0) select 0, (_ubb select 0) select 1, 0]);
|
_p = _building worldToModel (_unit modelToWorld [ (_ubb select 0) select 0, (_ubb select 0) select 1, 0]);
|
||||||
if (call _check) exitWith {true};
|
if (call _check) exitWith {true};
|
||||||
_p = _building worldToModel (_unit modelToWorld [ (_ubb select 0) select 0, (_ubb select 1) select 1, 0]);
|
_p = _building worldToModel (_unit modelToWorld [ (_ubb select 0) select 0, (_ubb select 1) select 1, 0]);
|
||||||
if (call _check) exitWith {true};
|
if (call _check) exitWith {true};
|
||||||
_p = _building worldToModel (_unit modelToWorld [ (_ubb select 1) select 0, (_ubb select 1) select 1, 0]);
|
_p = _building worldToModel (_unit modelToWorld [ (_ubb select 1) select 0, (_ubb select 1) select 1, 0]);
|
||||||
if (call _check) exitWith {true};
|
if (call _check) exitWith {true};
|
||||||
_p = _building worldToModel (_unit modelToWorld [ (_ubb select 1) select 0, (_ubb select 0) select 1, 0]);
|
_p = _building worldToModel (_unit modelToWorld [ (_ubb select 1) select 0, (_ubb select 0) select 1, 0]);
|
||||||
if (call _check) exitWith {true};
|
if (call _check) exitWith {true};
|
||||||
|
|
||||||
false
|
false
|
||||||
};
|
};
|
||||||
|
*/
|
||||||
|
|
||||||
//check if building being placed and objects around placement is free to be built on.
|
//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)
|
//Fence owners must build all the foundations by one player anyone can still upgrade (pending lock build level)
|
||||||
_checkBuildingCollision = {
|
_checkBuildingCollision =
|
||||||
|
{
|
||||||
_objColliding = objNull;
|
_objColliding = objNull;
|
||||||
{
|
local _wall = _object isKindOf "DZ_buildables";
|
||||||
_inside = false;
|
|
||||||
_ownerID = _x getVariable ["ownerArray",[]];
|
|
||||||
|
|
||||||
if (count _ownerID > 0) then { _ownerID = _ownerID select 0; } else { _ownerID = (getPlayerUID player); };
|
|
||||||
|
|
||||||
if (_object in ["WoodenFence_ghost","MetalFence_ghost","WoodenGate_ghost","MetalGate_ghost"]) then {};
|
|
||||||
|
|
||||||
if(_ownerID != (getPlayerUID player)) then {
|
|
||||||
if ((!isNull _x) and (!(_x == player)) and (!(_x == _object)) ) then {
|
|
||||||
if ((_x isKindOf "Building") or (_x isKindOf "AllVehicles")) then {
|
|
||||||
//_inside = [_object, _x] call _insideCheck;
|
|
||||||
_inside = [_object, _x] call fn_collisions;
|
|
||||||
|
|
||||||
if (!_inside) then {
|
|
||||||
//_inside = [_x, _object] call _insideCheck;
|
|
||||||
_inside = [_x, _object] call fn_collisions;
|
|
||||||
};
|
|
||||||
};
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
if (_inside) exitWith { _objColliding = _x; };
|
|
||||||
} forEach (nearestObjects [_object, ["Building", "Air", "LandVehicle", "Ship", "DZ_buildables"], 35]);
|
|
||||||
|
|
||||||
(!isNull _objColliding)
|
{
|
||||||
// _objColliding contains the building that collides with the ghost object
|
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
|
||||||
|
{
|
||||||
|
_objColliding = _x;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
foreach nearestObjects [_object, ["AllVehicles", "Building", "DZ_buildables"], 35];
|
||||||
};
|
};
|
||||||
|
|
||||||
//Is placement on a road?
|
//Is placement on a road?
|
||||||
@@ -325,6 +311,8 @@ while {r_action_count != 0 and Dayz_constructionContext select 4} do {
|
|||||||
|
|
||||||
// check now that ghost is not colliding
|
// check now that ghost is not colliding
|
||||||
call _checkBuildingCollision;
|
call _checkBuildingCollision;
|
||||||
|
|
||||||
|
diag_log format ["_objColliding: %1", _objColliding];
|
||||||
};
|
};
|
||||||
|
|
||||||
// try to dock a beam from current ghost to another beams nearby
|
// try to dock a beam from current ghost to another beams nearby
|
||||||
|
|||||||
Reference in New Issue
Block a user