diff --git a/Sources/epoch_code/compile/functions/EPOCH_fnc_SetFinalDir.sqf b/Sources/epoch_code/compile/functions/EPOCH_fnc_SetFinalDir.sqf new file mode 100644 index 00000000..01ec5edc --- /dev/null +++ b/Sources/epoch_code/compile/functions/EPOCH_fnc_SetFinalDir.sqf @@ -0,0 +1,33 @@ +/* + + Author: He-Man - EpochMod.com + + Contributors: + + Description: + Workaround for delayed positioning for Server side placed items + + Licence: + Arma Public License Share Alike (APL-SA) - https://www.bistudio.com/community/licenses/arma-public-license-share-alike + + Github: + https://github.com/EpochModTeam/Epoch/tree/release/Sources/epoch_code/compile/functions/EPOCH_fnc_SetFinalDir.sqf + + usage: + _array = []; + { + _array pushback [_x,[vectordir _x, VectorUp _x]]; + } foreach _objs; + _array remoteExec ["EPOCH_fnc_SetFinalDir",_player]; +*/ + +uisleep 1; // Give some time for init Server Side +{ + _x params ["_obj","_dir"]; + if (_dir isEqualType []) then { + _obj setVectorDirAndUp _dir; + } + else { + _obj setdir _dir; + }; +} foreach _this; diff --git a/Sources/epoch_config/Configs/CfgClientFunctions.hpp b/Sources/epoch_config/Configs/CfgClientFunctions.hpp index 94a34f8f..c7fb794d 100644 --- a/Sources/epoch_config/Configs/CfgClientFunctions.hpp +++ b/Sources/epoch_config/Configs/CfgClientFunctions.hpp @@ -175,6 +175,7 @@ class CfgClientFunctions class fnc_createLocalMarkerSet {}; class fnc_deleteLocalMarkerSet {}; class fnc_AnimateScheduled {}; + class fnc_SetFinalDir {}; }; class environment { diff --git a/Sources/epoch_server/compile/epoch_bases/EPOCH_server_saveBuilding.sqf b/Sources/epoch_server/compile/epoch_bases/EPOCH_server_saveBuilding.sqf index c8d92ccd..7cc27a91 100644 --- a/Sources/epoch_server/compile/epoch_bases/EPOCH_server_saveBuilding.sqf +++ b/Sources/epoch_server/compile/epoch_bases/EPOCH_server_saveBuilding.sqf @@ -70,6 +70,7 @@ if (isText _staticClassConfig) then { }; [_player,"BuildingsSet",1,true] call EPOCH_server_updatePlayerStats; diag_log format["Epoch: STORAGE: %1 created storage %2 at %3 with slot %4", _playerUID, _staticClass, _vehiclePos, _slot]; + [[_storageObj,[vectordir _storageObj, vectorup _storageObj]]] remoteexec ['Epoch_fnc_SetFinalDir',_player]; }; } else { @@ -113,6 +114,7 @@ if (isText _staticClassConfig) then { }; _newVehicle call EPOCH_saveBuilding; [_player,"BuildingsSet",1,true] call EPOCH_server_updatePlayerStats; + [[_newVehicle,[vectordir _newVehicle, vectorup _newVehicle]]] remoteexec ['Epoch_fnc_SetFinalDir',_player]; }; } else { diff --git a/Sources/epoch_server/compile/epoch_bases/EPOCH_swapBuilding.sqf b/Sources/epoch_server/compile/epoch_bases/EPOCH_swapBuilding.sqf index 4907d521..4ea8a62c 100644 --- a/Sources/epoch_server/compile/epoch_bases/EPOCH_swapBuilding.sqf +++ b/Sources/epoch_server/compile/epoch_bases/EPOCH_swapBuilding.sqf @@ -2,7 +2,7 @@ //[[[cog import generate_private_arrays ]]] private ["_newObj","_objectPos","_owner","_UpdatePlots"]; //[[[end]]] -params [["_class",""],["_object",objNull],["_method",2]]; +params [["_class",""],["_object",objNull],["_method",0]]; _newObj = objNull; if (!isNull _object && !(_class isEqualTo "")) then { _objectPos = getPosWorld _object; diff --git a/Sources/epoch_server/compile/epoch_looting/EPOCH_server_spawnLoot.sqf b/Sources/epoch_server/compile/epoch_looting/EPOCH_server_spawnLoot.sqf index 0a25c589..50df4100 100644 --- a/Sources/epoch_server/compile/epoch_looting/EPOCH_server_spawnLoot.sqf +++ b/Sources/epoch_server/compile/epoch_looting/EPOCH_server_spawnLoot.sqf @@ -14,13 +14,13 @@ */ private [ "_masterConfig","_building","_buildingLoot","_selectedConfig","_config","_EpochLootChance","_cfgBaseBuilding","_loots","_lootLimit","_possibleLoots","_posName","_positions","_possibleCount","_randomIndex","_selectedLoot", - "_pos","_dir","_item","_color","_GroundSpawnChance","_MinGroundContainers","_MaxGroundContainers","_lootType" + "_pos","_dir","_item","_color","_GroundSpawnChance","_MinGroundContainers","_MaxGroundContainers","_lootType","_privateDir" ]; params [["_player",objNull,[objNull]],["_token","",[""]],["_LootsArray",[]]]; if !([_player, _token] call EPOCH_server_getPToken) exitWith{}; - +_privateDir = []; _masterConfig = getmissionconfig "CfgBuildingLootPos"; { _x params [["_Building",objnull],["_LootType",""],["_buildingLootArray",[]]]; @@ -38,6 +38,8 @@ _masterConfig = getmissionconfig "CfgBuildingLootPos"; _item setvariable ["Epoch_ParentBuilding",_building]; _buildingLoot pushback _item; _item setDir _dir; + _item setowner (owner _player); // switch owner for better simulations on looting + _privateDir pushback [_item,_dir]; if (surfaceIsWater _pos) then { _item setPosASL _pos; } @@ -72,4 +74,7 @@ _masterConfig = getmissionconfig "CfgBuildingLootPos"; }; }; }; -} foreach _LootsArray; \ No newline at end of file +} foreach _LootsArray; +if !(_privateDir isEqualTo []) then { + _privateDir remoteexec ['Epoch_fnc_SetFinalDir',_player]; +}; \ No newline at end of file