From af6318940b97d8dee0aca2e66d7c350e3523967b Mon Sep 17 00:00:00 2001 From: He-Man Date: Sat, 7 Apr 2018 00:11:12 +0200 Subject: [PATCH] More precise Vehicle saving / loading This change will save / load Vehicles much more accurate (especially on Ramps / slopy terrain. Background: If use VectorDir / VectorUp, the Vehicle will be tilted around the model Center and PosWorld also use the Modelcenter, while PosATL / PosASL use the lowest level of the Vehicle. --- .../compile/epoch_vehicle/EPOCH_load_vehicles.sqf | 14 ++++++++------ .../epoch_vehicle/EPOCH_load_vehicles_old.sqf | 13 +++++++++---- .../epoch_vehicle/EPOCH_server_save_vehicle.sqf | 2 +- 3 files changed, 18 insertions(+), 11 deletions(-) diff --git a/Sources/epoch_server/compile/epoch_vehicle/EPOCH_load_vehicles.sqf b/Sources/epoch_server/compile/epoch_vehicle/EPOCH_load_vehicles.sqf index 51b5c860..33a4061a 100644 --- a/Sources/epoch_server/compile/epoch_vehicle/EPOCH_load_vehicles.sqf +++ b/Sources/epoch_server/compile/epoch_vehicle/EPOCH_load_vehicles.sqf @@ -68,10 +68,8 @@ for "_i" from 1 to _maxVehicleLimit do { if (_class != "" && _damage < 1) then { // remove location from worldspace and set to new var - _location = _worldspace deleteAt 0; - + _worldspace params [["_location",[]],["_VectorDir",[0,0,0]],["_VectorUp",[0,0,1]],["_useposworld",false]]; if !(_location isEqualTo []) then { - // increased position precision if (count _location == 2) then{ _location = (_location select 0) vectorAdd (_location select 1); @@ -117,9 +115,13 @@ for "_i" from 1 to _maxVehicleLimit do { _vehicle call EPOCH_server_setVToken; _vehicle call EPOCH_server_vehicleInit; // set final direction and postion of vehicle - _vehicle setVectorDirAndUp _worldspace; - _vehicle setposATL _location; - + _vehicle setVectorDirAndUp [_VectorDir,_VectorUp]; + if (_useposworld) then { + _vehicle setposWorld _location; + } + else { + _vehicle setposATL _location; + }; // set fuel level _vehicle setFuel _fuel; // apply persistent textures diff --git a/Sources/epoch_server/compile/epoch_vehicle/EPOCH_load_vehicles_old.sqf b/Sources/epoch_server/compile/epoch_vehicle/EPOCH_load_vehicles_old.sqf index 3bfd7e75..984eaacf 100644 --- a/Sources/epoch_server/compile/epoch_vehicle/EPOCH_load_vehicles_old.sqf +++ b/Sources/epoch_server/compile/epoch_vehicle/EPOCH_load_vehicles_old.sqf @@ -51,7 +51,7 @@ for "_i" from 1 to _maxVehicleLimit do { _damage = _arr select 2; if (_class != "" && _damage < 1) then { - _location = _worldspace deleteAt 0; + _worldspace params [["_location",[]],["_VectorDir",[0,0,0]],["_VectorUp",[0,0,1]],["_useposworld",false]]; if !(_location isEqualTo []) then { @@ -68,11 +68,16 @@ for "_i" from 1 to _maxVehicleLimit do { _class = ["O_Heli_Transport_04_EPOCH","O_Heli_Transport_04_bench_EPOCH","O_Heli_Transport_04_box_EPOCH","O_Heli_Transport_04_covered_EPOCH","B_Heli_Transport_03_unarmed_EPOCH","O_Truck_03_covered_EPOCH"] select _found; }; - _vehicle = createVehicle [_class, _location, [], 0, "CAN_COLLIDE"]; + _vehicle = createVehicle [_class, [random 500, random 500,500], [], 0, "CAN_COLLIDE"]; _allVehicles pushBack _vehicle; _vehicle call EPOCH_server_setVToken; - _vehicle setposATL _location; - _vehicle setVectorDirAndUp _worldspace; + if (_useposworld) then { + _vehicle setposWorld _location; + } + else { + _vehicle setposATL _location; + }; + _vehicle setVectorDirAndUp [_VectorDir,_VectorUp]; _vehicle setDamage _damage; _allHitpoints = getAllHitPointsDamage _vehicle; diff --git a/Sources/epoch_server/compile/epoch_vehicle/EPOCH_server_save_vehicle.sqf b/Sources/epoch_server/compile/epoch_vehicle/EPOCH_server_save_vehicle.sqf index 9f00da39..9d93c869 100644 --- a/Sources/epoch_server/compile/epoch_vehicle/EPOCH_server_save_vehicle.sqf +++ b/Sources/epoch_server/compile/epoch_vehicle/EPOCH_server_save_vehicle.sqf @@ -31,7 +31,7 @@ if (!isNull _vehicle) then { _colorSlot = _vehicle getVariable ["VEHICLE_TEXTURE",0]; _baseType = _vehicle getVariable ["VEHICLE_BASECLASS",""]; - _VAL = [typeOf _vehicle,[(getposATL _vehicle call EPOCH_precisionPos),vectordir _vehicle,vectorup _vehicle],damage _vehicle,_hitpoints,fuel _vehicle,_inventory,[true,magazinesAllTurrets _vehicle],_colorSlot,_baseType]; + _VAL = [typeOf _vehicle,[getposworld _vehicle,vectordir _vehicle,vectorup _vehicle,true],damage _vehicle,_hitpoints,fuel _vehicle,_inventory,[true,magazinesAllTurrets _vehicle],_colorSlot,_baseType]; ["Vehicle", _vehHiveKey, EPOCH_expiresVehicle, _VAL] call EPOCH_fnc_server_hiveSETEX; }; };