Add Vector Building

This commit is contained in:
icomrade
2016-05-12 22:52:04 -04:00
parent 8b0e03545f
commit 6c24aaeb3b
14 changed files with 406 additions and 48 deletions

View File

@@ -170,16 +170,60 @@ server_getDiff2 = {
// 1.8.7 dayz_objectUID2 seems to generate keys that are too long for Epoch hive. Keep old method for now.
dayz_objectUID2 = {
private["_position","_dir","_key"];
private["_position","_dir","_key","_element","_vector","_set","_vecCnt","_usedVec"];
_dir = _this select 0;
_key = "";
_position = _this select 1;
{
_x = _x * 10;
if (_x < 0) then { _x = _x * -10 };
_key = _key + str(round(_x));
} count _position;
_key = _key + str(round(_dir));
if((count _this) == 2) then{
{
_x = _x * 10;
if (_x < 0) then { _x = _x * -10 };
_key = _key + str(round(_x));
} count _position;
_key = _key + str(round(_dir));
} else {
_vector = [];
_usedVec = false;
{
_element = _x;
if(typeName _element == "ARRAY") then{
_vector = _element;
if((count _vector) == 2)then{
if(((count (_vector select 0)) == 3) && ((count (_vector select 1)) == 3))then{
{
_x = _x * 10;
if ( _x < 0 ) then { _x = _x * -10 };
_key = _key + str(round(_x));
} count _position;
_vecCnt = 0;
{
_set = _x;
{
_vecCnt = _vecCnt + (round (_x * 100));
} foreach _set;
} foreach _vector;
if(_vecCnt < 0)then{
_vecCnt = ((_vecCnt * -1) * 3);
};
_key = _key + str(_vecCnt);
_usedVec = true;
};
};
};
} count _this;
if!(_usedVec) then{
{
_x = _x * 10;
if ( _x < 0 ) then { _x = _x * -10 };
_key = _key + str(round(_x));
} count _position;
_key = _key + str(round(_dir));
};
};
// Make sure the generated key is not a duplicate
while {true} do {
if !(_key in currentObjectUIDs) exitWith {currentObjectUIDs set [count currentObjectUIDs,_key];};

View File

@@ -96,7 +96,54 @@ if (_status == "ObjectStreamStart") then {
diag_log ("MOVED OBJ: " + str(_idKey) + " of class " + _type + " to pos: " + str(_pos));
};
//Vector building
_vector = [[0,0,0],[0,0,0]];
_vecExists = false;
_ownerPUID = "0";
if (count _worldspace >= 3) then{
if(count _worldspace == 3) then{
if(typename (_worldspace select 2) == "STRING")then{
_ownerPUID = _worldspace select 2;
}else{
if(typename (_worldspace select 2) == "ARRAY")then{
_vector = _worldspace select 2;
if(count _vector == 2)then{
if(((count (_vector select 0)) == 3) && ((count (_vector select 1)) == 3))then{
_vecExists = true;
};
};
};
};
}else{
//Was not 3 elements, so check if 4 or more
if(count _worldspace == 4) then{
if(typename (_worldspace select 3) == "STRING")then{
_ownerPUID = _worldspace select 3;
}else{
if(typename (_worldspace select 2) == "STRING")then{
_ownerPUID = _worldspace select 2;
};
};
if(typename (_worldspace select 2) == "ARRAY")then{
_vector = _worldspace select 2;
if(count _vector == 2)then{
if(((count (_vector select 0)) == 3) && ((count (_vector select 1)) == 3))then{
_vecExists = true;
};
};
}else{
if(typename (_worldspace select 3) == "ARRAY")then{
_vector = _worldspace select 3;
if(count _vector == 2)then{
if(((count (_vector select 0)) == 3) && ((count (_vector select 1)) == 3))then{
_vecExists = true;
};
};
};
};
};
};
};
/* Plot For Life 2.5 */
// Realign characterID to OwnerPUID - need to force save though.
if (count _worldspace < 3) then {
@@ -153,6 +200,9 @@ if (_status == "ObjectStreamStart") then {
};
_object setVariable ["CharacterID", _ownerID, true];
_object setDir _dir;
if(_vecExists)then{
_object setVectorDirAndUp _vector;
};
_object setDamage _damage;
if (!_wsDone) then {[_object,"position",true] call server_updateObject;};
@@ -220,6 +270,7 @@ if (_status == "ObjectStreamStart") then {
};
_object setPosATL _pos;
if ((_object isKindOf "DZ_buildables") or ((_type in DayZ_SafeObjects) && !(_object isKindOf "TrapItems"))) then {
_object setVariable["memDir",_dir,true];
if (DZE_GodModeBase) then {_object addEventHandler ["HandleDamage",{false}];} else {_object addMPEventHandler ["MPKilled",{_this call vehicle_handleServerKilled;}];};
_object enableSimulation false; // Test disabling simulation server side on buildables only.
_object setVariable ["OEMPos",_pos,true]; // used for inplace upgrades and lock/unlock of safe