changed team spawn selection
This commit is contained in:
parent
e72d612379
commit
0315f61038
@ -193,8 +193,6 @@ public abstract class Game implements Listener
|
||||
public int HungerSet = -1;
|
||||
public int HealthSet = -1;
|
||||
|
||||
public int SpawnDistanceRequirement = 1;
|
||||
|
||||
public boolean PrepareFreeze = true;
|
||||
|
||||
private double _itemMergeRadius = 0;
|
||||
@ -211,6 +209,8 @@ public abstract class Game implements Listener
|
||||
|
||||
public int TickPerTeleport = 1;
|
||||
|
||||
public boolean SpawnNearAllies = false;
|
||||
|
||||
public boolean StrictAntiHack = false;
|
||||
|
||||
public boolean DisableKillCommand = true;
|
||||
@ -475,9 +475,6 @@ public abstract class Game implements Listener
|
||||
//Add
|
||||
GetTeamList().add(team);
|
||||
|
||||
//Set Spawn Data
|
||||
team.SetSpawnRequirement(this.SpawnDistanceRequirement);
|
||||
|
||||
System.out.println("Created Team: " + team.GetName());
|
||||
}
|
||||
|
||||
|
@ -60,13 +60,11 @@ public class GameTeam
|
||||
private HashMap<Player, PlayerState> _players = new HashMap<Player, PlayerState>();
|
||||
|
||||
private ArrayList<Location> _spawns;
|
||||
|
||||
|
||||
private Creature _teamEntity = null;
|
||||
|
||||
private HashSet<Kit> _kitRestrict = new HashSet<Kit>();
|
||||
|
||||
private int _spawnDistance = 0;
|
||||
|
||||
private boolean _visible = true;
|
||||
|
||||
//Records order players go out in
|
||||
@ -99,40 +97,89 @@ public class GameTeam
|
||||
|
||||
public Location GetSpawn()
|
||||
{
|
||||
// ArrayList<Location> valid = new ArrayList<Location>();
|
||||
|
||||
Location best = null;
|
||||
double bestDist = 0;
|
||||
|
||||
for (Location loc : _spawns)
|
||||
//Spawn Allies Together!
|
||||
if (Host.IsLive() && Host.SpawnNearAllies)
|
||||
{
|
||||
double closestPlayer = -1;
|
||||
Location closestLoc = null;
|
||||
double closestDist = 0;
|
||||
|
||||
for (Player player : Host.GetPlayers(true))
|
||||
for (Location loc : _spawns)
|
||||
{
|
||||
double playerDist = UtilMath.offsetSquared(player.getLocation(), loc);
|
||||
|
||||
if (closestPlayer == -1 || playerDist < closestPlayer)
|
||||
closestPlayer = playerDist;
|
||||
//Check if Location is closer!
|
||||
for (Player player : this.GetPlayers(true))
|
||||
{
|
||||
//Different Worlds
|
||||
if (!player.getWorld().equals(loc.getWorld()))
|
||||
continue;
|
||||
|
||||
double dist = UtilMath.offset(player.getLocation(), loc);
|
||||
|
||||
//Dont Spawn Inside Ally
|
||||
if (dist < 0.75)
|
||||
continue;
|
||||
|
||||
//Find Closest Enemy
|
||||
double closestEnemy = -1;
|
||||
|
||||
for (Player enemy : Host.GetPlayers(true))
|
||||
{
|
||||
if (!enemy.getWorld().equals(loc.getWorld()))
|
||||
continue;
|
||||
|
||||
if (this.HasPlayer(enemy))
|
||||
continue;
|
||||
|
||||
double enemyDist = UtilMath.offset(player.getLocation(), loc);
|
||||
|
||||
if (closestEnemy == -1 || enemyDist < closestEnemy)
|
||||
{
|
||||
closestEnemy = enemyDist;
|
||||
}
|
||||
}
|
||||
|
||||
//Dont Spawn Inside Enemy
|
||||
if (closestEnemy != -1 && closestEnemy < 0.75)
|
||||
continue;
|
||||
|
||||
//Good Location!
|
||||
if (closestLoc == null || dist < closestDist)
|
||||
{
|
||||
closestLoc = loc;
|
||||
closestDist = dist;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (best == null || closestPlayer > bestDist)
|
||||
{
|
||||
best = loc;
|
||||
bestDist = closestPlayer;
|
||||
}
|
||||
|
||||
// if (closestPlayer > _spawnDistance * _spawnDistance)
|
||||
// {
|
||||
// valid.add(loc);
|
||||
// }
|
||||
if (closestLoc != null)
|
||||
return closestLoc;
|
||||
}
|
||||
//Spawn Furthest Away!
|
||||
else
|
||||
{
|
||||
Location furthestLoc = null;
|
||||
double furthestDist = 0;
|
||||
|
||||
// if (valid.size() > 0)
|
||||
// valid.get(UtilMath.r(valid.size()));
|
||||
for (Location loc : _spawns)
|
||||
{
|
||||
for (Player player : Host.GetPlayers(true))
|
||||
{
|
||||
//Different Worlds
|
||||
if (!player.getWorld().equals(loc.getWorld()))
|
||||
continue;
|
||||
|
||||
double dist = UtilMath.offsetSquared(player.getLocation(), loc);
|
||||
|
||||
if (best != null)
|
||||
return best;
|
||||
if (furthestLoc == null || dist > furthestDist)
|
||||
{
|
||||
furthestLoc = loc;
|
||||
furthestDist = dist;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (furthestLoc != null)
|
||||
return furthestLoc;
|
||||
}
|
||||
|
||||
return _spawns.get(UtilMath.r(_spawns.size()));
|
||||
}
|
||||
@ -333,11 +380,6 @@ public class GameTeam
|
||||
_spawns = spawns;
|
||||
}
|
||||
|
||||
public void SetSpawnRequirement(int value)
|
||||
{
|
||||
_spawnDistance = value;
|
||||
}
|
||||
|
||||
public void SetVisible(boolean b)
|
||||
{
|
||||
_visible = b;
|
||||
@ -390,6 +432,4 @@ public class GameTeam
|
||||
|
||||
return _places;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -74,8 +74,6 @@ public class Evolution extends SoloGame
|
||||
this.DeathOut = false;
|
||||
|
||||
this.PrepareFreeze = false;
|
||||
|
||||
this.SpawnDistanceRequirement = 16;
|
||||
|
||||
_scoreObj = Scoreboard.GetScoreboard().registerNewObjective("Evolutions", "dummy");
|
||||
_scoreObj.setDisplaySlot(DisplaySlot.BELOW_NAME);
|
||||
|
@ -72,7 +72,6 @@ public class Quiver extends SoloGame
|
||||
this.DamageSelf = false;
|
||||
this.DamageTeamSelf = true;
|
||||
this.PrepareFreeze = false;
|
||||
this.SpawnDistanceRequirement = 16;
|
||||
this.BlockBreakAllow.add(102);
|
||||
this.BlockBreakAllow.add(20);
|
||||
|
||||
|
@ -59,7 +59,6 @@ public class QuiverTeams extends TeamGame
|
||||
this.DamageSelf = false;
|
||||
this.DamageTeamSelf = false;
|
||||
this.PrepareFreeze = false;
|
||||
this.SpawnDistanceRequirement = 24;
|
||||
this.BlockBreakAllow.add(102);
|
||||
this.BlockBreakAllow.add(20);
|
||||
this.BlockBreakAllow.add(18);
|
||||
|
@ -157,7 +157,7 @@ public abstract class Skywars extends Game
|
||||
WorldTimeSet = 0;
|
||||
WorldBoundaryKill = false;
|
||||
|
||||
SpawnDistanceRequirement = 48;
|
||||
SpawnNearAllies = true;
|
||||
|
||||
DamageSelf = true;
|
||||
DamageTeamSelf = true;
|
||||
|
@ -120,7 +120,7 @@ public abstract class SuperSmash extends Game
|
||||
|
||||
this.DeathSpectateSecs = 4;
|
||||
|
||||
this.SpawnDistanceRequirement = 32;
|
||||
SpawnNearAllies = true;
|
||||
|
||||
this.WorldWaterDamage = 1000;
|
||||
|
||||
|
@ -48,7 +48,6 @@ public class SquidShooter extends SoloGame
|
||||
this.DamageSelf = false;
|
||||
this.DamageTeamSelf = true;
|
||||
this.PrepareFreeze = false;
|
||||
this.SpawnDistanceRequirement = 16;
|
||||
this.CompassEnabled = true;
|
||||
this.KitRegisterState = GameState.Prepare;
|
||||
}
|
||||
|
@ -217,7 +217,7 @@ public abstract class SurvivalGames extends Game
|
||||
WorldTimeSet = 0;
|
||||
WorldBoundaryKill = false;
|
||||
|
||||
SpawnDistanceRequirement = 48;
|
||||
SpawnNearAllies = true;
|
||||
|
||||
DamageSelf = true;
|
||||
DamageTeamSelf = true;
|
||||
|
Loading…
Reference in New Issue
Block a user