From b2629ca10f64006316b493b38d0bc7734bd59917 Mon Sep 17 00:00:00 2001 From: vbawol Date: Sat, 4 Mar 2017 00:52:45 -0600 Subject: [PATCH] allow respawn in base --- Changelogs/0.5.0.0.txt | 3 +- .../sc/BattlEye/remoteexec.txt | 2 +- .../CfgActionMenu/CfgActionMenu_target.hpp | 8 ++ .../epoch_config/Configs/CfgRemoteExec.hpp | 5 ++ .../epoch_player/EPOCH_server_loadPlayer.sqf | 80 +++++++++++-------- .../epoch_player/EPOCH_server_makeSP.sqf | 30 +++++++ .../epoch_player/EPOCH_server_savePlayer.sqf | 4 +- Sources/epoch_server/config.cpp | 1 + 8 files changed, 97 insertions(+), 36 deletions(-) create mode 100644 Sources/epoch_server/compile/epoch_player/EPOCH_server_makeSP.sqf diff --git a/Changelogs/0.5.0.0.txt b/Changelogs/0.5.0.0.txt index 92032072..a819eb06 100644 --- a/Changelogs/0.5.0.0.txt +++ b/Changelogs/0.5.0.0.txt @@ -3,11 +3,12 @@ [Added] Crafting recipe: Mortar (Uses: 12x Rock, 2x dirty water) (Requires: Fire and workbench within 3m). Thanks to @baaljayjay for the suggestion. [Added] Customizability of units spawned by UAV alert via CfgEpochClient > uavAlertUnitSpawnTemplate. (Default: I_Soldier_EPOCH) [Added] Toxic Smoke Grenades can now be found in the world. +[Added] Allow respawn in base at Jammer. Interact with Jammer and choose "Make Spawnpoint" to enable. [Changed] Optimized database SET and SETEX calls in both SQF and C++. [Changed] Optimized database GETRANGE call. [Changed] Optimized NPC Trading and fixed issue if trade failed. Thanks to @Ignatz-HeMan [Changed] Selling to traders with bank debt greater than -50000(default), pays the bank debt back to below the limit instead of the player. Purchasing is unaffected. Thanks to @Ignatz-HeMan -[Changed] Great White Sharks will now spawn if player is deep enough in the ocean. +[Changed] Great White Sharks will now spawn if the player is deep enough in the ocean. [Changed] Objects or Players that have been given "Crypto" variable can be accessed via the dynamic menu (Space Bar) for a "Take Crypto" action. [Changed] Air Drops are now triggered with Epoch Events server side every 45m instead of randomly triggered client side. [Fixed] To prevent issues with ownership only Group Leader can place a Jammer. Thanks to @Ignatz-HeMan diff --git a/Server_Install_Pack/sc/BattlEye/remoteexec.txt b/Server_Install_Pack/sc/BattlEye/remoteexec.txt index 0848e6cc..8ee6daf4 100644 --- a/Server_Install_Pack/sc/BattlEye/remoteexec.txt +++ b/Server_Install_Pack/sc/BattlEye/remoteexec.txt @@ -1 +1 @@ -5 "" !="bis_fnc_execvm \[\[.+\],\"initPlayerServer.sqf\"]" !="bis_fnc_effectkilled(airdestruction|secondaries) \[.+\]" !="epoch_server_checkplayer \[[A-Z]{1} [A-Za-z]{4,10} [0-9]{1,3}-[0-9]{1,3}:[0-9]{1,3}( \(.+\)|) REMOTE\]" !="epoch_server_(save(_vehicles|building)|(lock|pack)Storage|(upgrade|remove|paint|maint)build) \[.+\]" !="epoch_server_((load|respawn|dead|invite|revive|teleport)Player|(upgrade|updateplayer|create|delete)Group) \[.+\]" !="epoch_server_(deadplayerdetonate|triggerantagonist|playersetvariable|missioncomms|makemarker|removemarker) \[.+\]" !="epoch_server_(knockDownTree|mineRocks|lootAnimal|handle_(say3d|switchmove|sapperObjs)) \[.+\]" !="epoch_server_((repair|fill|lock)Vehicle|(loot|fill)Container|(store|take)Crypto|make(NPC|)Trade) \[.+\]" !="epoch_server_(tradeRequest|equippeditem|packJack|create(object|AirDrop)|airDropCrate|destroytrash|unpackBackpack) \[.+\]" !="epoch_(localcleanup|fnc_saveplayer|client_bitePlayer|serverlootobject) \[.+\]" +5 "" !="bis_fnc_execvm \[\[.+\],\"initPlayerServer.sqf\"]" !="bis_fnc_effectkilled(airdestruction|secondaries) \[.+\]" !="epoch_server_checkplayer \[[A-Z]{1} [A-Za-z]{4,10} [0-9]{1,3}-[0-9]{1,3}:[0-9]{1,3}( \(.+\)|) REMOTE\]" !="epoch_server_(save(_vehicles|building)|(lock|pack)Storage|(upgrade|remove|paint|maint)build) \[.+\]" !="epoch_server_((load|respawn|dead|invite|revive|teleport)Player|(upgrade|updateplayer|create|delete)Group) \[.+\]" !="epoch_server_(deadplayerdetonate|triggerantagonist|playersetvariable|missioncomms|make(marker|SP)|removemarker) \[.+\]" !="epoch_server_(knockDownTree|mineRocks|lootAnimal|handle_(say3d|switchmove|sapperObjs)) \[.+\]" !="epoch_server_((repair|fill|lock)Vehicle|(loot|fill)Container|(store|take)Crypto|make(NPC|)Trade) \[.+\]" !="epoch_server_(tradeRequest|equippeditem|packJack|create(object|AirDrop)|airDropCrate|destroytrash|unpackBackpack) \[.+\]" !="epoch_(localcleanup|fnc_saveplayer|client_bitePlayer|serverlootobject) \[.+\]" diff --git a/Sources/epoch_config/Configs/CfgActionMenu/CfgActionMenu_target.hpp b/Sources/epoch_config/Configs/CfgActionMenu/CfgActionMenu_target.hpp index 719d5085..99511a85 100644 --- a/Sources/epoch_config/Configs/CfgActionMenu/CfgActionMenu_target.hpp +++ b/Sources/epoch_config/Configs/CfgActionMenu/CfgActionMenu_target.hpp @@ -107,6 +107,14 @@ class maintain_jammer icon = "x\addons\a3_epoch_code\Data\UI\buttons\build_maintain.paa"; tooltip = "Maintain"; }; +class select_jammer +{ + condition = "dyna_cursorTargetType isEqualTo 'PlotPole_EPOCH' && (damage dyna_cursorTarget < 1)"; + action = "[dyna_cursorTarget,player,Epoch_personalToken] remoteExec [""EPOCH_server_makeSP"",2];"; + icon = "x\addons\a3_epoch_code\Data\UI\buttons\player_inspect.paa"; + tooltip = "Make Spawnpoint"; +}; + //lock unlock class unlock_lockbox { diff --git a/Sources/epoch_config/Configs/CfgRemoteExec.hpp b/Sources/epoch_config/Configs/CfgRemoteExec.hpp index d75a0b55..88af98bf 100644 --- a/Sources/epoch_config/Configs/CfgRemoteExec.hpp +++ b/Sources/epoch_config/Configs/CfgRemoteExec.hpp @@ -286,6 +286,11 @@ class CfgRemoteExec allowedTargets = 2; jip = 0; }; + class EPOCH_server_makeSP + { + allowedTargets = 2; + jip = 0; + }; }; class Commands { diff --git a/Sources/epoch_server/compile/epoch_player/EPOCH_server_loadPlayer.sqf b/Sources/epoch_server/compile/epoch_player/EPOCH_server_loadPlayer.sqf index 6769b08c..517cf774 100644 --- a/Sources/epoch_server/compile/epoch_player/EPOCH_server_loadPlayer.sqf +++ b/Sources/epoch_server/compile/epoch_player/EPOCH_server_loadPlayer.sqf @@ -62,7 +62,7 @@ if (!isNull _player) then { // todo make dynamic if (count _arr < 11) then { // invaild format attempt to override - _arr = [[0, [], _instanceID], [0, 0, 1, 0, []], [_goggles, _headgear, _vest, _backpack, _uniform, _class], [""], call EPOCH_defaultVars_SEPXVar, _weaponsAndItems, _linkedItems, _normalMagazines, _itemsInContainers, _weaponsInContainers, "", true]; + _arr = [[0, [], _instanceID], [0, 0, 1, 0, []], [_goggles, _headgear, _vest, _backpack, _uniform, _class], [], call EPOCH_defaultVars_SEPXVar, _weaponsAndItems, _linkedItems, _normalMagazines, _itemsInContainers, _weaponsInContainers, "", true]; }; _worldspace = _arr select 0; @@ -78,7 +78,30 @@ if (!isNull _player) then { _server_vars = _arr select 3; _vars = _arr select 4; + // Get player group _playerGroup = _arr select 10; + // check players group + if (_playerGroup != "") then { + _found = false; + (["Group", _playerGroup] call EPOCH_fnc_server_hiveGETRANGE) params [ + ["_status", 0, [0] ], + ["_data", [], [[]] ] + ]; + if (_status == 1 && !(_data isEqualTo[])) then { + _data params ["","","","_modArray","_memberArray"]; + _found = _playerGroup == _playerUID; + if (!_found) then { + { + if (_x select 0 == _playerUID) exitWith{_found = true;}; + }forEach (_modArray + _memberArray); + }; + }; + if (!_found) then { + _playerGroup = ""; + }; + diag_log format["DEBUG (Load Player) Set Group: %1", _playerGroup]; + }; + _canBeRevived = _arr select 11; _hitpoints = _vars select 11; @@ -86,10 +109,28 @@ if (!isNull _player) then { _deadPlayer = ["PlayerStats", _playerUID, 0] call EPOCH_fnc_server_hiveGETBIT; _alreadyDead = (_deadPlayer || (_medical select 3 == 1) || (_hitpoints select 2 == 1) || (_hitpoints select 3 == 1) || (_vars select 12 >= 180)); + if (_alreadyDead || _prevInstance != _instanceID || (count _location) < 3 || !(_location isEqualType [])) then { _dir = random 360; - _location = getMarkerPos "respawn_west"; - _location set[2, 0]; + // try to find respawn point by position + _newLocation = _server_vars param [0,[]]; // 0 = RESPAWN POS + if (_newLocation isEqualType [] && {(count _newLocation) == 3}) then { + _jammers = nearestObjects[_newLocation, ["PlotPole_EPOCH"], 1]; + if !(_jammers isEqualTo[]) then { + // get nearby jammer + _jammer = _jammers param [0,objNull]; + // check if jammer is not null and is alive. + if (!isNull _jammer && {alive _jammer}) then { + // check if player is still a member of jammers group. + if ((_jammer getVariable["BUILD_OWNER", "-1"]) in [getPlayerUID player, _playerGroup]) then { + _location = _newLocation; + }; + }; + }; + } else { + _location = getMarkerPos "respawn_west"; + _location set[2, 0]; + }; if (_alreadyDead) then { _vars = call EPOCH_defaultVars_SEPXVar; _canBeRevived = true; @@ -262,36 +303,9 @@ if (!isNull _player) then { _reject = false; _playerGroupArray = []; - if (_playerGroup != "") then { - _response = ["Group", _playerGroup] call EPOCH_fnc_server_hiveGETRANGE; - _found = false; - if ((_response select 0) == 1 && (_response select 1) isEqualType [] && !((_response select 1) isEqualTo[])) then { - _playerGroupArray = _response select 1; - _found = _playerGroup == _playerUID; - if (!_found) then { - { - if (_x select 0 == _playerUID) exitWith{ - _found = true; - }; - }forEach(_playerGroupArray select 4); - }; - if (!_found) then { - { - if (_x select 0 == _playerUID) exitWith{ - _found = true; - }; - }forEach(_playerGroupArray select 3); - }; - if (_found) then { - _newPlyr setVariable["GROUP", _playerGroup]; - }; - }; - if (!_found) then { - _playerGroup = ""; - }; - diag_log format["DEBUG (Load Player) Set Group: %1", _playerGroup]; - }; - + if (_playerGroup != "") then { + _newPlyr setVariable["GROUP", _playerGroup]; + }; _newPlyr setVariable["PUID", _playerUID]; diff --git a/Sources/epoch_server/compile/epoch_player/EPOCH_server_makeSP.sqf b/Sources/epoch_server/compile/epoch_player/EPOCH_server_makeSP.sqf new file mode 100644 index 00000000..d20a38e2 --- /dev/null +++ b/Sources/epoch_server/compile/epoch_player/EPOCH_server_makeSP.sqf @@ -0,0 +1,30 @@ +/* + Author: Aaron Clark - EpochMod.com + + Contributors: + + Description: + Select spawn point + + 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_server/compile/epoch_player/EPOCH_server_selectSpawnpoint.sqf +*/ +params [["_jammer",objNull],["_player",objNull],["_token",""]]; +// check token +if !([_player, _token] call EPOCH_server_getPToken) exitWith{}; +// require object +if (isNull _jammer) exitWith {}; +// reject if player is too far away +if (_player distance _jammer > 20) exitWith{}; +// check if in group with owner +if (alive _jammer) then { + if ((_jammer getVariable["BUILD_OWNER", "-1"]) in [getPlayerUID _player, _player getVariable["GROUP", ""]]) then { + // set position of spawnpoint to players SERVER_VARS + _server_vars = _player getVariable["SERVER_VARS", []]; + _server_vars set [0, getposATL _jammer]; // 0 = RESPAWN POS + _player setVariable ["SERVER_VARS", _server_vars]; + }; +}; diff --git a/Sources/epoch_server/compile/epoch_player/EPOCH_server_savePlayer.sqf b/Sources/epoch_server/compile/epoch_player/EPOCH_server_savePlayer.sqf index 84caaf00..12959c03 100644 --- a/Sources/epoch_server/compile/epoch_player/EPOCH_server_savePlayer.sqf +++ b/Sources/epoch_server/compile/epoch_player/EPOCH_server_savePlayer.sqf @@ -54,7 +54,9 @@ if (_allowSave) then{ }; _player setVariable ["VARS", _vars]; - // Server Only Stats + /* SERVER_VARS INUSE INDEX: + 0 = RESPAWN POS + */ _server_vars = _player getVariable["SERVER_VARS", []]; _group = _player getVariable ["GROUP", ""]; diff --git a/Sources/epoch_server/config.cpp b/Sources/epoch_server/config.cpp index 40dedfc9..47544f7c 100644 --- a/Sources/epoch_server/config.cpp +++ b/Sources/epoch_server/config.cpp @@ -52,6 +52,7 @@ class CfgServerFunctions class fnc_addItemToX {}; class fnc_savePlayer {}; class server_savePlayer {}; + class server_makeSP {}; class server_loadPlayer {}; class server_checkPlayer {}; class server_onPlayerDisconnect {};