diff options
| author | hybrid <hybrid@hybridlabs.pro> | 2026-06-11 19:38:09 +0300 |
|---|---|---|
| committer | hybrid <hybrid@hybridlabs.pro> | 2026-06-11 19:38:09 +0300 |
| commit | a3a91d4f45b22fd487ecbc954ad979be5d03efdd (patch) | |
| tree | a554ab159a347dcd6c00ca1c7c26c1ec3ac0a6bd /Common/Functions/Common_GetRespawnCamps.sqf | |
| download | a2wf_chernarus-main.tar.gz a2wf_chernarus-main.tar.bz2 a2wf_chernarus-main.zip | |
Diffstat (limited to '')
| -rw-r--r-- | Common/Functions/Common_GetRespawnCamps.sqf | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/Common/Functions/Common_GetRespawnCamps.sqf b/Common/Functions/Common_GetRespawnCamps.sqf new file mode 100644 index 0000000..4c8f2ed --- /dev/null +++ b/Common/Functions/Common_GetRespawnCamps.sqf @@ -0,0 +1,14 @@ +Private ['_availableSpawn','_camps','_closestCamp','_deathLoc','_enemySide','_get','_hostiles','_nearestCamps','_respawnCampsMode','_respawnCampsRuleMode','_respawnMinRange','_side','_town','_townSID'],;
_deathLoc = _this select 0;
+_side = _this select 1;
+_availableSpawn = [];
+_respawnCampsMode = 'WFBE_RESPAWNCAMPSMODE' Call GetNamespace;
+_respawnCampsRuleMode = 'WFBE_RESPAWNCAMPSRULEMODE' Call GetNamespace;
+_respawnMinRange = 'WFBE_RESPAWNMINRANGE' Call GetNamespace;
+
+
switch (_respawnCampsMode) do {
case 1: {
/* Classic Respawn */
_town = [_deathLoc] Call GetClosestLocation;
if !(isNull _town) then {
if (_town distance _deathLoc < ('WFBE_RESPAWNRANGE' Call GetNamespace)) then {
_camps = [_town,_side] Call GetFriendlyCamps;
if (count _camps > 0) then {
if (_respawnCampsRuleMode > 0) then {
_closestCamp = ([_deathLoc,_camps] Call SortByDistance) select 0;
_enemySide = if (_side == west) then {[east]} else {[west]};
if (_respawnCampsRuleMode == 2) then {_enemySide = _enemySide + [resistance]};
_hostiles = [_closestCamp,_enemySide,_respawnMinRange] Call GetHostilesInArea;
if (_deathLoc distance _closestCamp < _respawnMinRange && _hostiles > 0) then {_camps = _camps - [_closestCamp]};
};
_availableSpawn = _availableSpawn + _camps;
};
};
+ };
+ };
+
case 2: {
/* Enhanced Respawn - Get the camps around the unit */
_nearestCamps = nearestObjects [_deathLoc, WFCAMP, ('WFBE_RESPAWNRANGE' Call GetNamespace)];
{
_get = _x getVariable 'sideID';
if !(isNil '_get') then {
if ((_side Call GetSideID) == _get) then {
if (_respawnCampsRuleMode > 0) then {
if (_deathLoc distance _x < _respawnMinRange) then {
_enemySide = if (_side == west) then {[east]} else {[west]};
if (_respawnCampsRuleMode == 2) then {_enemySide = _enemySide + [resistance]};
_hostiles = [_x,_enemySide,_respawnMinRange] Call GetHostilesInArea;
if (_hostiles == 0) then {_availableSpawn = _availableSpawn + [_x]};
} else {
_availableSpawn = _availableSpawn + [_x];
};
} else {
_availableSpawn = _availableSpawn + [_x];
};
};
};
} forEach _nearestCamps;
};
case 3: {
/* Defender Only Respawn - Get the camps around the unit only if the town is friendly to the unit. */
_nearestCamps = nearestObjects [_deathLoc, WFCAMP, ('WFBE_RESPAWNRANGE' Call GetNamespace)];
{
_get = _x getVariable 'sideID';
if !(isNil '_get') then {
_town = _x getVariable 'town';
_townSID = _town getVariable 'sideID';
if ((_side Call GetSideID) == _townSID && _get == _townSID) then {
+ if (_respawnCampsRuleMode > 0) then {
if (_deathLoc distance _x < _respawnMinRange) then {
_enemySide = if (_side == west) then {[east]} else {[west]};
if (_respawnCampsRuleMode == 2) then {_enemySide = _enemySide + [resistance]};
_hostiles = [_x,_enemySide,_respawnMinRange] Call GetHostilesInArea;
if (_hostiles == 0) then {_availableSpawn = _availableSpawn + [_x]};
} else {
_availableSpawn = _availableSpawn + [_x];
};
} else {
_availableSpawn = _availableSpawn + [_x];
};
};
};
} forEach _nearestCamps;
};
};
+
+/* Return the available camps */
_availableSpawn
\ No newline at end of file |
