Added REspawn at base

This commit is contained in:
Zepheris 2018-03-08 22:43:17 -07:00
parent 900b91d386
commit 85738c5805
5 changed files with 170 additions and 184 deletions

View File

@ -64,4 +64,5 @@ ExileClient_object_player_event_onInventoryOpened = "custom\EnigmaRevive\ExileCl
//ExileServer_object_construction_database_load = "custom\fixes\ExileServer_object_construction_database_load.sqf";
//Spawn at Base
ExileClient_gui_selectSpawnLocation_event_onSpawnButtonClick = "custom\respawnAtBase\ExileClient_gui_selectSpawnLocation_event_onSpawnButtonClick.sqf";
ExileClient_gui_selectSpawnLocation_show = "custom\respawnAtBase\ExileClient_gui_selectSpawnLocation_show.sqf";

View File

@ -0,0 +1,66 @@
/**
* ExileServer_object_construction_database_load
*
* Exile Mod
* www.exilemod.com
* © 2015 Exile Mod Team
*
* This work is licensed under the Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International License.
* To view a copy of this license, visit http://creativecommons.org/licenses/by-nc-nd/4.0/.
*/
private["_constructionID","_data","_position","_vectorDirection","_vectorUp","_constructionObject","_damageLevel","_public","_pinCode"];
_constructionID = _this;
_data = format ["loadConstruction:%1", _constructionID] call ExileServer_system_database_query_selectSingle;
_position = [_data select 4, _data select 5, _data select 6];
_vectorDirection = [_data select 7, _data select 8, _data select 9];
_vectorUp = [_data select 10, _data select 11, _data select 12];
_constructionObject = createVehicle [(_data select 1), _position, [], 0, "CAN_COLLIDE"];
_constructionObject setPosATL _position;
_constructionObject setVectorDirAndUp [_vectorDirection, _vectorUp];
_constructionObject setVariable ["ExileDatabaseID", _data select 0];
_constructionObject setVariable ["ExileOwnerUID", (_data select 2)];
_constructionObject setVariable ["ExileIsPersistent", true];
_constructionObject setVariable ["ExileTerritoryID", (_data select 15)];
_damageLevel = (_data select 17);
_public = _damageLevel > 0;
_constructionObject setVariable ["ExileConstructionDamage",_damageLevel,_public];
if(_public)then
{
_constructionObject call ExileServer_util_setDamageTexture;
};
_pinCode = _data select 14;
if !(_pinCode isEqualTo "000000") then
{
_constructionObject setVariable ["ExileAccessCode", _pinCode];
_constructionObject setVariable ["ExileIsLocked", (_data select 13), true];
};
// 2017-03-16 + TEMPORARY WORKAROUND UNTIL EXILE UPDATE
//if (getNumber(configFile >> "CfgVehicles" >> (_data select 1) >> "exileRequiresSimulation") isEqualTo 1) then
//{
// _constructionObject enableSimulationGlobal true;
// _constructionObject call ExileServer_system_simulationMonitor_addVehicle;
//}
//else
//{
// _constructionObject enableSimulationGlobal false;
//};
if (typeOf _constructionObject in ["Exile_Construction_ConcreteDoor_Static", "Exile_Construction_ConcreteGate_Static", "Exile_Construction_WoodGate_Static", "Exile_Construction_WoodDoor_Static", "Exile_Construction_ConcreteWindowHatch_Static", "Exile_Construction_WoodGate_Reinforced_Static", "Exile_Construction_WoodDoor_Reinforced_Static", "Exile_Construction_ConcreteFloorHatch_Static"]) then
{
_constructionObject enableSimulationGlobal true;
_constructionObject call ExileServer_system_simulationMonitor_addVehicle;
}
else
{
_constructionObject enableSimulationGlobal false;
};
// 2017-03-16 - TEMPORARY WORKAROUND UNTIL EXILE UPDATE
_constructionObject setVelocity [0, 0, 0];
_constructionObject setPosATL _position;
_constructionObject setVelocity [0, 0, 0];
_constructionObject setVectorDirAndUp [_vectorDirection, _vectorUp];
_constructionObject setVelocity [0, 0, 0];
_constructionObject

View File

@ -0,0 +1,23 @@
/**
* ExileClient_gui_selectSpawnLocation_event_onSpawnButtonClick
*
* Exile Mod
* www.exilemod.com
* © 2015 Exile Mod Team
*
* This work is licensed under the Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International License.
* To view a copy of this license, visit http://creativecommons.org/licenses/by-nc-nd/4.0/.
*
* Modifications for eXpoch Base Spawn 4 Exile
* by DirtySanchez
* and DonkeyPunch Community Gaming
* Please read the readme for all information pertaining to this work and its use
*/
if(ExileClientSelectedSpawnLocationMarkerName in eXpochClientPlayerBases)then
{
eXpochClientPlayerLastBaseSpawn = diag_tickTime;
};
ExileClientSpawnLocationSelectionDone = true;
closeDialog 1;
true

View File

@ -1,184 +1,73 @@
private["_display","_spawnButton","_listBox","_listItemIndex","_numberOfSpawnPoints","_randNum","_randData","_randomSpawnIndex"];
if(isNil "spawnRegistry") then
{
spawnRegistry = [];
};
fn_checkRespawnDelay = {
_markerName = _this select 0;
if(isNil "_markerName") exitWith { diag_log "checkRespawn: invalid parameter 1"; true; };
diag_log format["checkRespawn: Checking flag %1...", _markerName];
_counter = 0;
{
_name = _x select 0;
_time = _x select 1;
if(isNil "_name") exitWith { true; };
if(isNil "_time") exitWith { true; };
diag_log format["checkRespawn: checking flag %1, with reg %2", _markerName, _name];
if(_name isEqualTo _markerName) then
{
if(_time > time-300) then
{
_counter = _counter + 1;
};
};
} forEach spawnRegistry;
diag_log format["checkRespawn: counter for flag %1 = %2",_markerName, _counter];
if(_counter >= 1) exitWith
{
diag_log format["checkRespawn: returned false"];
false;
};
diag_log format["checkRespawn: returned true"];
true;
};
/**
* ExileClient_gui_selectSpawnLocation_show
*
* Exile Mod
* www.exilemod.com
* © 2015 Exile Mod Team
*
* This work is licensed under the Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International License.
* To view a copy of this license, visit http://creativecommons.org/licenses/by-nc-nd/4.0/.
*
* Modifications for eXpoch Base Spawn 4 Exile
* by DirtySanchez
* and DonkeyPunch Community Gaming
* Please read the readme for all information pertaining to this work and its use
*/
private["_display","_spawnButton","_listBox","_listItemIndex","_numberOfSpawnPoints","_randNum","_randData","_randomSpawnIndex","_territoryPos"];
disableSerialization;
diag_log "Selecting spawn location...";
ExileClientSpawnLocationSelectionDone = false;
ExileClientSelectedSpawnLocationMarkerName = "";
eXpochClientPlayerBases = [];
createDialog "RscExileSelectSpawnLocationDialog";
waitUntil {_display = findDisplay 24002;!isNull _display};
waitUntil
{
_display = findDisplay 24002;
!isNull _display
};
_spawnButton = _display displayCtrl 24003;
_spawnButton ctrlEnable false;
_display displayAddEventHandler ["KeyDown", "_this call ExileClient_gui_loadingScreen_event_onKeyDown"];
_listBox = _display displayCtrl 24002;
lbClear _listBox;
{
if (getMarkerType _x == "ExileSpawnZone") then
{
_name = markerText _x;
if(! ( [_name] call fn_checkRespawnDelay) ) exitWith { diag_log format["checkRespawn returned false for spawn zone: %1, respawn disabled",_name]; };
diag_log format["Adding spawn zone: %1",markerText _x];
_listItemIndex = _listBox lbAdd (markerText _x);
_listBox lbSetData [_listItemIndex, _x];
};
} forEach allMapMarkers;
// _numberOfSpawnPoints = {getMarkerType _x == "ExileSpawnZone"} count allMapMarkers;
// if(_numberOfSpawnPoints > 0)then
// {
// _randNum = floor(random _numberOfSpawnPoints);
// _randData = lbData [24002,_randNum];
// _randomSpawnIndex = _listBox lbAdd "Random";
// _listBox lbSetData [_randomSpawnIndex, _randData];
// };
defaultLBsize = lbSize _listBox;
myUID = getPlayerUID player;
myFlags = [];
{
_flag = _x;
_owner = _flag getVariable ["ExileOwnerUID", ""];
_arrBuildRights = _x getVariable["ExileTerritoryBuildRights",[]]; // by Nerexis
if(myUID isEqualTo _owner OR ( !(isNil "_arrBuildRights") AND (count _arrBuildRights>0) AND (myUID in _arrBuildRights) ) )then
{
_name = _flag getVariable ["ExileTerritoryName", ""];
if(! ( [_name] call fn_checkRespawnDelay) ) exitWith { diag_log format["checkRespawn returned false for flag: %1, respawn disabled",_name]; };
_lbid = _listBox lbAdd (_flag getVariable ["ExileTerritoryName", ""]);
_listBox lbSetColor [_lbid, [0,0.68,1,1]];
_listBox lbSetData [_lbid,str(count myFlags)];
myFlags pushBack _flag;
// localmarkerName = format['LOCALFLAG_%1',myUID];
// deleteMarkerLocal localmarkerName;
// _marker = createMarkerLocal [localmarkerName,getPosATL _flag];
// _marker setMarkerShapeLocal "ICON";
// _marker setMarkerTypeLocal "loc_Bunker";
// _marker setMarkerColorLocal "ColorGreen";
// _marker setMarkerSize [3, 3];
// _marker setMarkerTextLocal (_flag getVariable ["ExileTerritoryName", ""]);
};
} forEach (allMissionObjects "Exile_Construction_Flag_Static");
fnc_LBSelChanged_24002 = {
disableSerialization;
_ctrl = _this select 0;
_curSel = lbCurSel _ctrl;
if(_curSel < defaultLBsize)then
{
_this call ExileClient_gui_selectSpawnLocation_event_onListBoxSelectionChanged;
}
else
forEach allMapMarkers;
//eXpoch base spawn
if(eXpochClientPlayerLastBaseSpawn < (diag_tickTime - eXpochBaseRespawnTimeLimit))then
{
_data = _ctrl lbData _curSel;
_num = parseNumber _data;
_flag = myFlags select _num;
markerName = format['FLAG_%1',myUID];
deleteMarker markerName;
createMarker [markerName,getPosATL _flag];
ExileClientSelectedSpawnLocationMarkerName = markerName;
// localmarkerName = format['LOCALFLAG_%1',myUID];
// deleteMarkerLocal localmarkerName;
// _marker = createMarkerLocal [localmarkerName,getPosATL _flag];
// _marker setMarkerShapeLocal "ICON";
// _marker setMarkerTypeLocal "loc_Bunker";
// _marker setMarkerColorLocal "ColorGreen";
// _marker setMarkerSize [3, 3];
// _marker setMarkerTextLocal (_flag getVariable ["ExileTerritoryName", ""]);
_mapControl = (findDisplay 24002) displayCtrl 24001;
_mapControl ctrlMapAnimAdd [1, 0.1, getMarkerPos ExileClientSelectedSpawnLocationMarkerName];
ctrlMapAnimCommit _mapControl;
_mapCenter = [worldSize/2,worldSize/2,0];
_allTerritoryFlags = (nearestObjects [_mapCenter, ["Exile_Construction_Flag_Static"], ceil(worldSize/1.75 + 3000)]);
{
_playerUID = getPlayerUID player;
_buildRights = _x getVariable [eXpochBaseSpawnAllowedType, []];
if (_playerUID in _buildRights) then
{
_territoryLevelConfig = _x getVariable ["ExileTerritoryLevel", 0];
_territoryPos = getPosATL _x;
if((_territoryLevelConfig >= eXpochBaseSpawnLevelRequired) && !((getPos ExileClientLastDeathMarker) distance _territoryPos < eXpochBaseSpawnDeadBodyDistLimit)) then{
_baseName = _x getVariable ["ExileTerritoryName", ""];
eXpochClientPlayerBases pushBack _baseName;
createMarker [_baseName,_territoryPos];
_listItemIndex = _listBox lbAdd _baseName;
_listBox lbSetData [_listItemIndex, _baseName];
};
};
_listBox ctrlRemoveAllEventHandlers "LBSelChanged";
_listBox ctrlAddEventHandler ["LBSelChanged", "_this call fnc_LBSelChanged_24002;"];
fnc_ButtonClick_24003 = {
disableSerialization;
_display = nil;
waitUntil {_display = findDisplay 24002;!isNull _display};
_lB = _display displayCtrl 24002;
_curSel = lbCurSel _lB;
_data = _lB lbData _curSel;
_num = parseNumber _data;
_flag = myFlags select _num;
_name = lbText [24002, _curSel]; //_flag getVariable ["ExileTerritoryName", ""];
//spawnRegistry pushBack [_name, time];
spawnRegistry pushBack [_name, time];
//diag_log format["Plr selected spawn %1", lbText [24002, _curSel]];
diag_log format["Plr respawning at flag %1 - time: %2",_name, _time];
[] call ExileClient_gui_selectSpawnLocation_event_onSpawnButtonClick;
// if(!isNil 'markerName')then
// {
// [] spawn {
// waitUntil {!isNil 'ExileClientLoadedIn'};
// uiSleep 3;
// deleteMarker markerName;
// deleteMarkerLocal localmarkerName;
// };
// };
}forEach _allTerritoryFlags;
};
_spawnButton = _display displayCtrl 24003;
_spawnButton ctrlRemoveAllEventHandlers "ButtonClick";
_spawnButton ctrlSetEventHandler["ButtonClick","call fnc_ButtonClick_24003"];
_spawnButton ctrlSetText "Spawn!";
_spawnButton ctrlEnable true;
_spawnButton ctrlCommit 0;
_numberOfSpawnPoints = {getMarkerType _x == "ExileSpawnZone"} count allMapMarkers;
if (_numberOfSpawnPoints > 0) then
{
_randNum = floor(random _numberOfSpawnPoints);
_randData = lbData [24002,_randNum];
_randomSpawnIndex = _listBox lbAdd "Random";
_listBox lbSetData [_randomSpawnIndex, _randData];
};
true

View File

@ -520,3 +520,10 @@ execVM "addons\modChecker\init\modCheckerInit.sqf";
//Advanced Repair
Bones_fnc_salvageAndRepairMenuHelo = compileFinal preprocessFileLineNumbers "Custom\advancedRepair\Bones_fnc_salvageAndRepairMenuHelo.sqf";
Bones_fnc_salvageAndRepairMenuCar = compileFinal preprocessFileLineNumbers "Custom\advancedRepair\Bones_fnc_salvageAndRepairMenuCar.sqf";
//Respawn at Base
eXpochClientPlayerLastBaseSpawn = diag_tickTime; // Do not change this
eXpochBaseRespawnTimeLimit = 900; // How long before the players can respawn at their base since the last death or joining server - default: 900
eXpochBaseSpawnLevelRequired = 1; // Required Level of Base for Allowing Spawn - default: 4
eXpochBaseSpawnAllowedType = "ExileTerritoryBuildRights"; // If only owners can spawn change this to "ExileOwnerUID" - default: "ExileTerritoryBuildRights"
eXpochBaseSpawnDeadBodyDistLimit = 500; // If the players dead body is within 500m of their own base, they will not get the option to spawn there