Skip to content

Commit 73946d8

Browse files
authored
Improve positioning of Teleport Players module (#693)
1 parent 9199403 commit 73946d8

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

addons/modules/functions/fnc_moduleTeleportPlayers.sqf

+16-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#include "script_component.hpp"
22
/*
3-
* Author: mharis001
3+
* Author: mharis001, Kex
44
* Zeus module function to teleport players.
55
*
66
* Arguments:
@@ -34,7 +34,22 @@ params ["_logic"];
3434
_players = _players arrayIntersect _players;
3535
};
3636

37+
// Ensure proper spacing among units
38+
private _gridSize = TELEPORT_SPACING + 0.5 * selectMax (_players apply {sizeOf typeOf _x});
39+
private _nGrid = ceil sqrt count _players;
40+
private _offset = _gridSize * floor (_nGrid / 2);
41+
private _startPos = _position vectorDiff [_offset, _offset, 0];
42+
private _positions = [];
43+
44+
for "_i" from 0 to (_nGrid - 1) do {
45+
for "_j" from 0 to (_nGrid - 1) do {
46+
_positions pushBack (_startPos vectorAdd [_i * _gridSize, _j * _gridSize, 0]);
47+
};
48+
};
49+
3750
{
51+
private _position = _positions select _forEachIndex;
52+
3853
// Special handling for aircraft that are flying
3954
// Without "FLY" they will be teleported to the ground and explode
4055
// Manually set their velocity to prevent them from falling out of the sky

addons/modules/script_component.hpp

+2
Original file line numberDiff line numberDiff line change
@@ -177,3 +177,5 @@
177177

178178
#define OBJECT_SCALE_MIN 0.0001
179179
#define OBJECT_SCALE_MAX 65504
180+
181+
#define TELEPORT_SPACING 5 // Meters

0 commit comments

Comments
 (0)