Respawn in captured territories

Respawn in captured territories

« posted: Aug 13, 2018, 05:57 PM »
I'm trying to replace the town respawn with the ability to respawn in any of your sides 'owned' territories. I figured out the file and bit of code I think I need to edit. Not getting any code errors, but it's still not working. I think I'm getting close, but figure it out.

In loadRespawnDialog.sqf I replaced;

Code: [Select]
_towns = [];
{
_town = _x select 0;
_town call _setPlayersInfo;
_towns pushBack _town;
} forEach (call cityList);

with

Code: [Select]
_currentTerritoryOwner =[];
_playerTeam = [];
_towns = [];

{
// private "_friendlyPlayers";
// _town = _x select 0;
_territory = _x select 0;
// _town call _setPlayersInfo;

if (_currentTerritoryOwner isEqualTo _playerTeam) then
{
// _towns pushBack _town;
_towns pushBack _territory;
};
// } forEach (call cityList);
} forEach (["config_territory_markers", []] call getPublicVar);

I only know enough to modify scripts, not to just code outright, so I'm sure there's probably some unneeded or redundant pieces pasted in there. I'm also probably way off in how I'm going about accomplishing this.

Re: Respawn in captured territories

« Reply #1 posted: Feb 28, 2022, 06:00 PM »
Tried to add this option to Seforu Ramal but failed totally.
Searched the forums and also www, but havn't found any solutions.

  • Offline LeonZ
  • github.com/LeonZ2019/Lucky-s-Wasteland-Server
  • First Blood
  • ***
  • Posts: 78

Re: Respawn in captured territories

« Reply #2 posted: Feb 28, 2022, 07:06 PM »
Improved the speed of code by change the forEach to findIf, it should be work, not tested
spawnInTown.sqf
Code: [Select]
_citiesTerritories = call cityList;
_citiesTerritories append (call compile preprocessFileLineNumbers "mapConfig\territories.sqf");
_index = _citiesTerritories findIf { _x select 0 == _marker };
if (["TERRITORY_", _location] call fn_startsWith) then
{
_rad = selectMax (markerSize _marker);
_townName = _citiesTerritories select _index select 1;
} else
{
_rad = _citiesTerritories select _index select 1;
_townName = _citiesTerritories select _index select 2;
};

_pos = getMarkerPos _marker;
_notInArea = false;
while { _notInArea } do
{
_playerPos = [_pos,5,_rad,1,0,0,0] call findSafePos;
if (_playerPos inArea _marker) then
{
_notInArea = true;
};
};
if (_preload) then { waitUntil {sleep 0.1; preloadCamera _playerPos} };
waitUntil {!isNil "bis_fnc_init" && {bis_fnc_init}};
player setPos _playerPos;

loadRespawnDialog.sqf
Code: [Select]
_setPlayersInfo =
{
private ["_location", "_townEntry"];

_location = _this; // spawn beacon object or town marker name
_isBeacon = (typeName _location == "OBJECT");
_friendlyUnits = [];
_friendlyPlayers = 0;
_friendlyNPCs = 0;
_enemyPlayers = 0;
_enemyNPCs = 0;

{
if (alive _x && {_x isKindOf "CAManBase" && {!(_x call A3W_fnc_isUnconscious) && _x inArea _location}}) then
Code: [Select]
_citiesTerritories = call cityList;
_citiesTerritories append (call compile preprocessFileLineNumbers "mapConfig\territories.sqf");
_towns = [];
{
private "_friendlyPlayers";
_town = _x select 0;
_town call _setPlayersInfo;

if (_friendlyPlayers > 0) then
{
_towns pushBack _town;
};
} forEach _citiesTerritories;
Code: [Select]
_data = "objectFromNetId " + str netId _location;
}
else
{
_index = _citiesTerritories findIf { _x select 0 == _location };
if (["TERRITORY_", _location] call fn_startsWith) then
{
_text = _citiesTerritories select _index select 1;
} else
{
_text = _citiesTerritories select _index select 2;
}
_data = str _location;
};
LeonZ#1848 on Discord