Completed game logic & Kit fixes
This commit is contained in:
parent
ee38cb4c39
commit
d30703c570
@ -1,38 +1,51 @@
|
|||||||
package nautilus.game.arcade.game.games.quiver;
|
package nautilus.game.arcade.game.games.quiver;
|
||||||
|
|
||||||
import java.text.DecimalFormat;
|
import java.text.DecimalFormat;
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.Sound;
|
||||||
|
import org.bukkit.entity.Arrow;
|
||||||
import org.bukkit.entity.Minecart;
|
import org.bukkit.entity.Minecart;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.bukkit.event.entity.ProjectileHitEvent;
|
||||||
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
|
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
|
||||||
import org.bukkit.event.player.PlayerDropItemEvent;
|
import org.bukkit.event.player.PlayerDropItemEvent;
|
||||||
|
import org.bukkit.event.player.PlayerPickupItemEvent;
|
||||||
import org.bukkit.event.vehicle.VehicleDamageEvent;
|
import org.bukkit.event.vehicle.VehicleDamageEvent;
|
||||||
import org.bukkit.event.vehicle.VehicleEnterEvent;
|
import org.bukkit.event.vehicle.VehicleEnterEvent;
|
||||||
import org.bukkit.event.vehicle.VehicleEntityCollisionEvent;
|
import org.bukkit.event.vehicle.VehicleEntityCollisionEvent;
|
||||||
import org.bukkit.material.MaterialData;
|
import org.bukkit.material.MaterialData;
|
||||||
|
import org.bukkit.scheduler.BukkitRunnable;
|
||||||
import org.bukkit.util.Vector;
|
import org.bukkit.util.Vector;
|
||||||
|
|
||||||
import mineplex.core.common.util.C;
|
import mineplex.core.common.util.C;
|
||||||
import mineplex.core.common.util.UtilBlock;
|
import mineplex.core.common.util.UtilAlg;
|
||||||
|
import mineplex.core.common.util.UtilMath;
|
||||||
import mineplex.core.common.util.UtilPlayer;
|
import mineplex.core.common.util.UtilPlayer;
|
||||||
|
import mineplex.core.common.util.UtilServer;
|
||||||
import mineplex.core.common.util.UtilTextBottom;
|
import mineplex.core.common.util.UtilTextBottom;
|
||||||
|
import mineplex.core.common.util.UtilTextMiddle;
|
||||||
|
import mineplex.core.common.util.UtilTime;
|
||||||
|
import mineplex.core.common.util.UtilTime.TimeUnit;
|
||||||
import mineplex.core.hologram.Hologram;
|
import mineplex.core.hologram.Hologram;
|
||||||
import mineplex.core.updater.UpdateType;
|
import mineplex.core.updater.UpdateType;
|
||||||
import mineplex.core.updater.event.UpdateEvent;
|
import mineplex.core.updater.event.UpdateEvent;
|
||||||
import mineplex.minecraft.game.core.combat.CombatComponent;
|
import mineplex.minecraft.game.core.combat.CombatComponent;
|
||||||
import mineplex.minecraft.game.core.combat.event.CombatDeathEvent;
|
import mineplex.minecraft.game.core.combat.event.CombatDeathEvent;
|
||||||
|
import mineplex.minecraft.game.core.damage.CustomDamageEvent;
|
||||||
import nautilus.game.arcade.ArcadeManager;
|
import nautilus.game.arcade.ArcadeManager;
|
||||||
import nautilus.game.arcade.GameType;
|
import nautilus.game.arcade.GameType;
|
||||||
import nautilus.game.arcade.events.GameStateChangeEvent;
|
import nautilus.game.arcade.events.GameStateChangeEvent;
|
||||||
import nautilus.game.arcade.game.GameTeam;
|
import nautilus.game.arcade.game.GameTeam;
|
||||||
import nautilus.game.arcade.game.TeamGame;
|
import nautilus.game.arcade.game.TeamGame;
|
||||||
|
import nautilus.game.arcade.game.games.quiver.data.PowerupGenerator;
|
||||||
import nautilus.game.arcade.game.games.quiver.kits.KitBarrage;
|
import nautilus.game.arcade.game.games.quiver.kits.KitBarrage;
|
||||||
import nautilus.game.arcade.game.games.quiver.kits.KitBeserker;
|
import nautilus.game.arcade.game.games.quiver.kits.KitBeserker;
|
||||||
import nautilus.game.arcade.game.games.quiver.kits.KitHeadHunter;
|
import nautilus.game.arcade.game.games.quiver.kits.KitHeadHunter;
|
||||||
@ -46,14 +59,34 @@ import nautilus.game.arcade.kit.Perk;
|
|||||||
public class QuiverPayload extends TeamGame
|
public class QuiverPayload extends TeamGame
|
||||||
{
|
{
|
||||||
|
|
||||||
|
private static final long GAME_TIMEOUT = 600000;
|
||||||
private static final double PAYLOAD_CAPTURE_RANGE = 3;
|
private static final double PAYLOAD_CAPTURE_RANGE = 3;
|
||||||
|
private static final double PAYLOAD_INITIAL_VELOCITY = 0.1;
|
||||||
|
private static final double PAYLOAD_VELOCITY_INCREASE_FACTOR = 1.5;
|
||||||
|
private static final long PAYLOAD_VELOCITY_INCREASE_TIME = 120000;
|
||||||
|
private static final long PAYLOAD_APPROACHING_TIME = 20000;
|
||||||
|
private static final int PAYLOAD_APPROACHING_DISTANCE = 20;
|
||||||
|
private static final int PAYLOAD_MARKER_MAX_DISTANCE = 2;
|
||||||
|
private static final String SUPER_ARROW_DAMAGE_REASON = "Instagib";
|
||||||
|
private static final double SUPER_ARROW_DAMAGE_MOD = 9001;
|
||||||
|
private static final int ULTIMATE_PERCENTAGE_INCREASE_KILL = 5;
|
||||||
|
private static final int ULTIMATE_PERCENTAGE_INCREASE_ASSIST = 2;
|
||||||
|
private static final long POWERUP_SPAWN_DELAY = 20000;
|
||||||
|
|
||||||
private Minecart _minecart;
|
private Minecart _minecart;
|
||||||
private Hologram _hologram;
|
private Hologram _hologram;
|
||||||
private GameTeam _teamDirection;
|
private GameTeam _teamDirection;
|
||||||
private Vector _lastDirection;
|
private Vector _lastDirection;
|
||||||
private boolean _postiveVector;
|
private double _payloadVelocity;
|
||||||
private boolean _oldVector;
|
private long _lastSpeedIncrease;
|
||||||
|
private int _targetIndex;
|
||||||
|
private boolean _recentlyChanged;
|
||||||
|
private boolean _contested;
|
||||||
|
private long _lastAnnoucement;
|
||||||
|
private List<Location> _pathMarkers = new ArrayList<>();
|
||||||
|
private boolean _hasAnnouncedGameEnd;
|
||||||
|
|
||||||
|
private List<PowerupGenerator> _powerupGenerators = new ArrayList<>();
|
||||||
|
|
||||||
private Map<UUID, Double> _ultimatePercentage = new HashMap<UUID, Double>();
|
private Map<UUID, Double> _ultimatePercentage = new HashMap<UUID, Double>();
|
||||||
|
|
||||||
@ -68,7 +101,8 @@ public class QuiverPayload extends TeamGame
|
|||||||
}, new String[] { "Testing Description", });
|
}, new String[] { "Testing Description", });
|
||||||
|
|
||||||
this.DeathOut = false;
|
this.DeathOut = false;
|
||||||
this.DamageTeamSelf = true;
|
this.DamageSelf = false;
|
||||||
|
this.DamageTeamSelf = false;
|
||||||
this.TeamArmorHotbar = true;
|
this.TeamArmorHotbar = true;
|
||||||
this.HungerSet = 20;
|
this.HungerSet = 20;
|
||||||
}
|
}
|
||||||
@ -88,16 +122,38 @@ public class QuiverPayload extends TeamGame
|
|||||||
}
|
}
|
||||||
|
|
||||||
Scoreboard.Reset();
|
Scoreboard.Reset();
|
||||||
|
Scoreboard.WriteBlank();
|
||||||
|
|
||||||
if (_teamDirection != null)
|
Scoreboard.Write(C.cGoldB + "Payload");
|
||||||
|
|
||||||
|
if (_contested)
|
||||||
{
|
{
|
||||||
Scoreboard.Write(_teamDirection.getDisplayName());
|
Scoreboard.Write("Contested");
|
||||||
|
}
|
||||||
|
else if (_teamDirection != null)
|
||||||
|
{
|
||||||
|
String distance = new DecimalFormat("0.0").format(getTrackDistanceToMarker(getDestination(_teamDirection)));
|
||||||
|
Scoreboard.Write(_teamDirection.GetFormattedName() + " (" + _teamDirection.GetColor() + distance + "m)");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Scoreboard.Write("None");
|
Scoreboard.Write("None");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (IsLive())
|
||||||
|
{
|
||||||
|
Scoreboard.WriteBlank();
|
||||||
|
|
||||||
|
Scoreboard.Write(C.cGreenB + "Next Speed Increase");
|
||||||
|
Scoreboard.Write(UtilTime.convertString(PAYLOAD_VELOCITY_INCREASE_TIME - (System.currentTimeMillis() - _lastSpeedIncrease), 0, TimeUnit.FIT));
|
||||||
|
|
||||||
|
Scoreboard.WriteBlank();
|
||||||
|
|
||||||
|
Scoreboard.Write(C.cRedB + "Game End");
|
||||||
|
Scoreboard.Write(UtilTime.convertString(GAME_TIMEOUT - (System.currentTimeMillis() - GetStateTime()), 0, TimeUnit.FIT));
|
||||||
|
}
|
||||||
|
|
||||||
|
Scoreboard.WriteBlank();
|
||||||
Scoreboard.Draw();
|
Scoreboard.Draw();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -109,6 +165,9 @@ public class QuiverPayload extends TeamGame
|
|||||||
Location location = WorldData.GetDataLocs("BLACK").get(0);
|
Location location = WorldData.GetDataLocs("BLACK").get(0);
|
||||||
_minecart = location.getWorld().spawn(location, Minecart.class);
|
_minecart = location.getWorld().spawn(location, Minecart.class);
|
||||||
_hologram = new Hologram(Manager.getHologramManager(), location.add(0, 1, 0), "None");
|
_hologram = new Hologram(Manager.getHologramManager(), location.add(0, 1, 0), "None");
|
||||||
|
_lastSpeedIncrease = System.currentTimeMillis();
|
||||||
|
_lastAnnoucement = System.currentTimeMillis();
|
||||||
|
_payloadVelocity = PAYLOAD_INITIAL_VELOCITY;
|
||||||
|
|
||||||
_minecart.setDisplayBlock(new MaterialData(Material.TNT));
|
_minecart.setDisplayBlock(new MaterialData(Material.TNT));
|
||||||
_hologram.setFollowEntity(_minecart);
|
_hologram.setFollowEntity(_minecart);
|
||||||
@ -118,6 +177,29 @@ public class QuiverPayload extends TeamGame
|
|||||||
{
|
{
|
||||||
player.getInventory().addItem(Quiver.SUPER_ARROW);
|
player.getInventory().addItem(Quiver.SUPER_ARROW);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (Location powerup : WorldData.GetDataLocs("YELLOW"))
|
||||||
|
{
|
||||||
|
_powerupGenerators.add(new PowerupGenerator(this, powerup, POWERUP_SPAWN_DELAY));
|
||||||
|
}
|
||||||
|
|
||||||
|
// Sort path markers
|
||||||
|
|
||||||
|
Location start = UtilAlg.findClosest(GetTeamList().get(0).GetSpawns().get(0), WorldData.GetDataLocs("RED"));
|
||||||
|
Location last = start;
|
||||||
|
ArrayList<Location> dataPoints = new ArrayList<>();
|
||||||
|
|
||||||
|
dataPoints.addAll(WorldData.GetDataLocs("RED"));
|
||||||
|
dataPoints.addAll(WorldData.GetDataLocs("BLUE"));
|
||||||
|
|
||||||
|
while (!dataPoints.isEmpty())
|
||||||
|
{
|
||||||
|
Location dataPoint = UtilAlg.findClosest(last, dataPoints);
|
||||||
|
|
||||||
|
_pathMarkers.add(dataPoint);
|
||||||
|
dataPoints.remove(dataPoint);
|
||||||
|
last = dataPoint;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -132,6 +214,44 @@ public class QuiverPayload extends TeamGame
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (UtilTime.elapsed(GetStateTime(), GAME_TIMEOUT))
|
||||||
|
{
|
||||||
|
GameTeam teamA = GetTeamList().get(0);
|
||||||
|
GameTeam teamB = GetTeamList().get(1);
|
||||||
|
|
||||||
|
if (getTrackDistanceToMarker(getDestination(teamA)) < getTrackDistanceToMarker(getDestination(teamB)))
|
||||||
|
{
|
||||||
|
WinnerTeam = teamA;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
WinnerTeam = teamB;
|
||||||
|
}
|
||||||
|
|
||||||
|
AnnounceEnd(WinnerTeam);
|
||||||
|
SetState(GameState.End);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
else if (UtilTime.elapsed(GetStateTime(), GAME_TIMEOUT - 60000) && !_hasAnnouncedGameEnd)
|
||||||
|
{
|
||||||
|
_hasAnnouncedGameEnd = true;
|
||||||
|
|
||||||
|
String message = C.cRed + "Only 60 second remain!";
|
||||||
|
|
||||||
|
UtilTextMiddle.display("", message, 10, 20, 10);
|
||||||
|
UtilServer.broadcast(message);
|
||||||
|
|
||||||
|
for (Player player : UtilServer.getPlayers())
|
||||||
|
{
|
||||||
|
player.playSound(player.getLocation(), Sound.ENDERDRAGON_GROWL, 1, 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (PowerupGenerator powerupGenerator : _powerupGenerators)
|
||||||
|
{
|
||||||
|
powerupGenerator.update();
|
||||||
|
}
|
||||||
|
|
||||||
_coloredMessage = !_coloredMessage;
|
_coloredMessage = !_coloredMessage;
|
||||||
|
|
||||||
for (Player player : GetPlayers(true))
|
for (Player player : GetPlayers(true))
|
||||||
@ -179,115 +299,208 @@ public class QuiverPayload extends TeamGame
|
|||||||
|
|
||||||
if (event.getType() == UpdateType.FAST && _minecart != null)
|
if (event.getType() == UpdateType.FAST && _minecart != null)
|
||||||
{
|
{
|
||||||
|
if (UtilTime.elapsed(_lastSpeedIncrease, PAYLOAD_VELOCITY_INCREASE_TIME))
|
||||||
Map<GameTeam, Integer> mostPlayers = new HashMap<>();
|
|
||||||
|
|
||||||
for (GameTeam gameTeam : GetTeamList())
|
|
||||||
{
|
{
|
||||||
mostPlayers.put(gameTeam, 0);
|
_lastSpeedIncrease = System.currentTimeMillis();
|
||||||
|
_payloadVelocity *= PAYLOAD_VELOCITY_INCREASE_FACTOR;
|
||||||
|
|
||||||
|
String message = C.cGreen + "The payload\'s speed has been increased!";
|
||||||
|
|
||||||
|
UtilTextMiddle.display("", message, 10, 20, 10);
|
||||||
|
UtilServer.broadcast(message);
|
||||||
|
|
||||||
|
for (Player player : UtilServer.getPlayers())
|
||||||
|
{
|
||||||
|
player.playSound(player.getLocation(), Sound.ENDERDRAGON_GROWL, 1, 0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int teamACount = 0, teamBCount = 0;
|
||||||
|
|
||||||
for (Player player : UtilPlayer.getNearby(_minecart.getLocation(), PAYLOAD_CAPTURE_RANGE))
|
for (Player player : UtilPlayer.getNearby(_minecart.getLocation(), PAYLOAD_CAPTURE_RANGE))
|
||||||
{
|
{
|
||||||
GameTeam gameTeam = GetTeam(player);
|
GameTeam gameTeam = GetTeam(player);
|
||||||
|
|
||||||
Bukkit.broadcastMessage(gameTeam.GetFormattedName() + " " + player.getName());
|
if (GetTeamList().get(0).equals(gameTeam))
|
||||||
|
|
||||||
mostPlayers.put(gameTeam, mostPlayers.get(gameTeam) + 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
int mostPlayersCount = 0;
|
|
||||||
|
|
||||||
for (GameTeam gameTeam : mostPlayers.keySet())
|
|
||||||
{
|
|
||||||
int playerCount = mostPlayers.get(gameTeam);
|
|
||||||
|
|
||||||
if (playerCount > mostPlayersCount)
|
|
||||||
{
|
{
|
||||||
if (_teamDirection == null)
|
teamACount++;
|
||||||
{
|
|
||||||
if (GetTeamList().get(0).equals(gameTeam))
|
|
||||||
{
|
|
||||||
_postiveVector = true;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
_postiveVector = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (_teamDirection.equals(gameTeam))
|
|
||||||
{
|
|
||||||
_postiveVector = true;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
_postiveVector = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
_teamDirection = gameTeam;
|
|
||||||
}
|
|
||||||
else if (playerCount == mostPlayersCount)
|
|
||||||
{
|
|
||||||
_teamDirection = null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO DO NOT HARDCODE
|
|
||||||
|
|
||||||
if (_teamDirection == null)
|
|
||||||
{
|
|
||||||
if (mostPlayersCount == 0)
|
|
||||||
{
|
|
||||||
_hologram.setText("None");
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
teamBCount++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (teamACount > teamBCount && teamBCount == 0)
|
||||||
|
{
|
||||||
|
if (_teamDirection != null)
|
||||||
|
{
|
||||||
|
if (!_teamDirection.equals(GetTeamList().get(0)))
|
||||||
|
{
|
||||||
|
_recentlyChanged = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
_teamDirection = GetTeamList().get(0);
|
||||||
|
}
|
||||||
|
else if (teamACount < teamBCount && teamACount == 0)
|
||||||
|
{
|
||||||
|
if (_teamDirection != null)
|
||||||
|
{
|
||||||
|
if (!_teamDirection.equals(GetTeamList().get(1)))
|
||||||
|
{
|
||||||
|
_recentlyChanged = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
_teamDirection = GetTeamList().get(1);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (teamACount > 0 && teamBCount > 0)
|
||||||
|
{
|
||||||
|
_contested = true;
|
||||||
_hologram.setText("Contested");
|
_hologram.setText("Contested");
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_hologram.setText("None");
|
||||||
|
}
|
||||||
|
|
||||||
_minecart.setVelocity(new Vector(0, 0, 0));
|
_minecart.setVelocity(new Vector(0, 0, 0));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_lastDirection == null)
|
_contested = false;
|
||||||
|
|
||||||
|
if (_teamDirection.equals(GetTeamList().get(0)))
|
||||||
{
|
{
|
||||||
if (_postiveVector)
|
if (_lastDirection == null)
|
||||||
{
|
{
|
||||||
_minecart.setVelocity(new Vector(0.1, 0, 0));
|
_targetIndex = _pathMarkers.size() / PAYLOAD_MARKER_MAX_DISTANCE;
|
||||||
}
|
}
|
||||||
else
|
else if (isMinecartNearMarker(_pathMarkers.get(_targetIndex)) || _recentlyChanged)
|
||||||
{
|
{
|
||||||
_minecart.setVelocity(new Vector(-0.1, 0, 0));
|
_targetIndex++;
|
||||||
|
_recentlyChanged = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (_oldVector == _postiveVector)
|
if (_lastDirection == null)
|
||||||
{
|
{
|
||||||
_minecart.setVelocity(_lastDirection);
|
_targetIndex = _pathMarkers.size() / 2 - 2;
|
||||||
}
|
}
|
||||||
else
|
else if (isMinecartNearMarker(_pathMarkers.get(_targetIndex)) || _recentlyChanged)
|
||||||
{
|
{
|
||||||
_minecart.setVelocity(_lastDirection.multiply(-1));
|
_targetIndex--;
|
||||||
|
_recentlyChanged = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
_oldVector = _postiveVector;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (UtilBlock.solid(_minecart.getVelocity().add(_minecart.getVelocity().normalize()).toLocation(_minecart.getWorld()).getBlock()))
|
if (UtilTime.elapsed(_lastAnnoucement, PAYLOAD_APPROACHING_TIME) && isMinecartNearMarker(getDestination(_teamDirection), PAYLOAD_APPROACHING_DISTANCE))
|
||||||
{
|
{
|
||||||
_minecart.setVelocity(_minecart.getVelocity().normalize().multiply(5));
|
_lastAnnoucement = System.currentTimeMillis();
|
||||||
}
|
|
||||||
else
|
String message = C.cRed + "The payload is approaching its destination!";
|
||||||
{
|
|
||||||
_minecart.setVelocity(_minecart.getVelocity().normalize().multiply(0.1));
|
UtilTextMiddle.display("", message, 10, 20, 10);
|
||||||
|
UtilServer.broadcast(message);
|
||||||
|
|
||||||
|
for (Player player : UtilServer.getPlayers())
|
||||||
|
{
|
||||||
|
player.playSound(player.getLocation(), Sound.NOTE_PLING, 1, 0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_minecart.setVelocity(UtilAlg.getTrajectory(_minecart.getLocation(), _pathMarkers.get(_targetIndex)).normalize().multiply(_payloadVelocity));
|
||||||
_lastDirection = _minecart.getVelocity();
|
_lastDirection = _minecart.getVelocity();
|
||||||
_hologram.setText(_teamDirection.GetFormattedName());
|
_hologram.setText(_teamDirection.GetFormattedName());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void EndCheck()
|
||||||
|
{
|
||||||
|
if (!IsLive())
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
boolean end = false;
|
||||||
|
|
||||||
|
if (isMinecartNearMarker(_pathMarkers.get(_pathMarkers.size() - 1)) && _teamDirection.equals(GetTeamList().get(0)))
|
||||||
|
{
|
||||||
|
WinnerTeam = GetTeamList().get(0);
|
||||||
|
end = true;
|
||||||
|
}
|
||||||
|
else if (isMinecartNearMarker(_pathMarkers.get(0)) && _teamDirection.equals(GetTeamList().get(1)))
|
||||||
|
{
|
||||||
|
WinnerTeam = GetTeamList().get(1);
|
||||||
|
end = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (end)
|
||||||
|
{
|
||||||
|
AnnounceEnd(WinnerTeam);
|
||||||
|
SetState(GameState.End);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean isMinecartNearMarker(Location marker)
|
||||||
|
{
|
||||||
|
return isMinecartNearMarker(marker, PAYLOAD_MARKER_MAX_DISTANCE);
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean isMinecartNearMarker(Location marker, double distance)
|
||||||
|
{
|
||||||
|
return UtilMath.offset(_minecart.getLocation(), marker) < distance;
|
||||||
|
}
|
||||||
|
|
||||||
|
private double getTrackDistanceToMarker(Location marker)
|
||||||
|
{
|
||||||
|
double distance = 0;
|
||||||
|
|
||||||
|
if (_minecart == null)
|
||||||
|
{
|
||||||
|
return distance;
|
||||||
|
}
|
||||||
|
|
||||||
|
distance += UtilMath.offset(_minecart.getLocation(), _pathMarkers.get(_targetIndex));
|
||||||
|
|
||||||
|
if (_teamDirection == null)
|
||||||
|
{
|
||||||
|
return distance;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (_teamDirection.equals(GetTeamList().get(0)))
|
||||||
|
{
|
||||||
|
for (int i = _targetIndex + 1; i < _pathMarkers.size(); i++)
|
||||||
|
{
|
||||||
|
distance += UtilMath.offset(_pathMarkers.get(i - 1), _pathMarkers.get(i));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
for (int i = _targetIndex - 1; i >= 0; i--)
|
||||||
|
{
|
||||||
|
distance += UtilMath.offset(_pathMarkers.get(i + 1), _pathMarkers.get(i));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return distance;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Location getDestination(GameTeam gameTeam)
|
||||||
|
{
|
||||||
|
if (GetTeamList().get(0).equals(gameTeam))
|
||||||
|
{
|
||||||
|
return _pathMarkers.get(_pathMarkers.size() - 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
return _pathMarkers.get(0);
|
||||||
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onVehicleEntityCollision(VehicleEntityCollisionEvent event)
|
public void onVehicleEntityCollision(VehicleEntityCollisionEvent event)
|
||||||
{
|
{
|
||||||
@ -319,6 +532,11 @@ public class QuiverPayload extends TeamGame
|
|||||||
@EventHandler
|
@EventHandler
|
||||||
public void onCombatDeath(CombatDeathEvent event)
|
public void onCombatDeath(CombatDeathEvent event)
|
||||||
{
|
{
|
||||||
|
if (event.GetLog().GetKiller().GetName() == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
Player player = UtilPlayer.searchExact(event.GetLog().GetKiller().GetName());
|
Player player = UtilPlayer.searchExact(event.GetLog().GetKiller().GetName());
|
||||||
|
|
||||||
if (player == null)
|
if (player == null)
|
||||||
@ -326,16 +544,38 @@ public class QuiverPayload extends TeamGame
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
incrementUltimate(player, 5);
|
incrementUltimate(player, ULTIMATE_PERCENTAGE_INCREASE_KILL);
|
||||||
|
|
||||||
for (CombatComponent combatComponent : event.GetLog().GetAttackers())
|
for (CombatComponent combatComponent : event.GetLog().GetAttackers())
|
||||||
{
|
{
|
||||||
|
if (event.GetLog().GetKiller() != null && combatComponent.equals(event.GetLog().GetKiller()))
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
if (combatComponent.IsPlayer())
|
if (combatComponent.IsPlayer())
|
||||||
{
|
{
|
||||||
Player assitedPlayer = UtilPlayer.searchExact(event.GetLog().GetKiller().GetName());
|
Player assitedPlayer = UtilPlayer.searchExact(event.GetLog().GetKiller().GetName());
|
||||||
incrementUltimate(assitedPlayer, 2);
|
|
||||||
|
if (assitedPlayer != null)
|
||||||
|
{
|
||||||
|
incrementUltimate(assitedPlayer, ULTIMATE_PERCENTAGE_INCREASE_ASSIST);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
new BukkitRunnable()
|
||||||
|
{
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void run()
|
||||||
|
{
|
||||||
|
if (!player.getInventory().contains(Quiver.SUPER_ARROW))
|
||||||
|
{
|
||||||
|
player.getInventory().addItem(Quiver.SUPER_ARROW);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}.runTaskLater(Manager.getPlugin(), 10);
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
@ -385,6 +625,38 @@ public class QuiverPayload extends TeamGame
|
|||||||
_ultimatePercentage.put(player.getUniqueId(), _ultimatePercentage.get(player.getUniqueId()) + percentage);
|
_ultimatePercentage.put(player.getUniqueId(), _ultimatePercentage.get(player.getUniqueId()) + percentage);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void onCustomDamage(CustomDamageEvent event)
|
||||||
|
{
|
||||||
|
if (event.GetProjectile() != null)
|
||||||
|
{
|
||||||
|
if (event.GetProjectile() instanceof Arrow && event.GetDamageeEntity() instanceof Player)
|
||||||
|
{
|
||||||
|
event.AddMod("Projectile", SUPER_ARROW_DAMAGE_REASON, SUPER_ARROW_DAMAGE_MOD, false);
|
||||||
|
|
||||||
|
event.SetKnockback(false);
|
||||||
|
event.GetProjectile().remove();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void onProjectileHit(ProjectileHitEvent event)
|
||||||
|
{
|
||||||
|
event.getEntity().remove();
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void onPlayerPickupItem(PlayerPickupItemEvent event)
|
||||||
|
{
|
||||||
|
event.setCancelled(true);
|
||||||
|
|
||||||
|
for (PowerupGenerator powerupGenerator : _powerupGenerators)
|
||||||
|
{
|
||||||
|
powerupGenerator.pickup(event.getPlayer(), event.getItem());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@EventHandler // TODO DEBUG COMMANDS
|
@EventHandler // TODO DEBUG COMMANDS
|
||||||
public void onPlayerCommandPreprocess(PlayerCommandPreprocessEvent event)
|
public void onPlayerCommandPreprocess(PlayerCommandPreprocessEvent event)
|
||||||
{
|
{
|
||||||
|
@ -0,0 +1,119 @@
|
|||||||
|
package nautilus.game.arcade.game.games.quiver.data;
|
||||||
|
|
||||||
|
import org.bukkit.Color;
|
||||||
|
import org.bukkit.FireworkEffect.Type;
|
||||||
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.block.BlockFace;
|
||||||
|
import org.bukkit.entity.Item;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
import org.bukkit.util.Vector;
|
||||||
|
|
||||||
|
import mineplex.core.common.util.C;
|
||||||
|
import mineplex.core.common.util.F;
|
||||||
|
import mineplex.core.common.util.UtilFirework;
|
||||||
|
import mineplex.core.common.util.UtilPlayer;
|
||||||
|
import mineplex.core.common.util.UtilServer;
|
||||||
|
import mineplex.core.common.util.UtilTime;
|
||||||
|
import nautilus.game.arcade.game.Game;
|
||||||
|
import nautilus.game.arcade.game.GameTeam;
|
||||||
|
import nautilus.game.arcade.game.games.quiver.Quiver;
|
||||||
|
|
||||||
|
public class PowerupGenerator
|
||||||
|
{
|
||||||
|
|
||||||
|
private static final int ARROWS_TO_GIVE = 2;
|
||||||
|
|
||||||
|
private Game Host;
|
||||||
|
|
||||||
|
private Location _location;
|
||||||
|
private Item _item;
|
||||||
|
private long _lastPickup;
|
||||||
|
private long _respawnDelay;
|
||||||
|
|
||||||
|
public PowerupGenerator(Game host, Location location, long respawnDelay)
|
||||||
|
{
|
||||||
|
Host = host;
|
||||||
|
_location = location;
|
||||||
|
_lastPickup = System.currentTimeMillis();
|
||||||
|
_respawnDelay = respawnDelay;
|
||||||
|
|
||||||
|
_location.getBlock().getRelative(BlockFace.DOWN).setType(Material.IRON_BLOCK);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void update()
|
||||||
|
{
|
||||||
|
if (_item != null)
|
||||||
|
{
|
||||||
|
if (!_item.isValid())
|
||||||
|
{
|
||||||
|
_item.remove();
|
||||||
|
_item = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (UtilTime.elapsed(_lastPickup, _respawnDelay))
|
||||||
|
{
|
||||||
|
_item = _location.getWorld().dropItem(_location, new ItemStack(Material.ARROW));
|
||||||
|
|
||||||
|
_item.setVelocity(new Vector(0, 1, 0));
|
||||||
|
_item.getLocation().getBlock().getRelative(BlockFace.DOWN).setType(Material.GOLD_BLOCK);
|
||||||
|
|
||||||
|
UtilFirework.playFirework(_location, Type.BALL_LARGE, Color.YELLOW, false, true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void pickup(Player player, Item item)
|
||||||
|
{
|
||||||
|
if (_item == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!_item.equals(item))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!Host.IsAlive(player))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Host.Manager.isSpectator(player))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
GameTeam gameTeam = Host.GetTeam(player);
|
||||||
|
|
||||||
|
if (gameTeam == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
_lastPickup = System.currentTimeMillis();
|
||||||
|
|
||||||
|
_item.remove();
|
||||||
|
_item = null;
|
||||||
|
|
||||||
|
_location.getBlock().getRelative(BlockFace.DOWN).setType(Material.IRON_BLOCK);
|
||||||
|
|
||||||
|
UtilPlayer.message(player, F.main("Game", "You collected the " + C.mItem + "Arrow" + C.cGray + " powerup."));
|
||||||
|
UtilServer.broadcast(C.cYellowB + player.getName() + C.cWhiteB + " collected the " + C.cYellowB + "Arrow" + C.cWhiteB + " Powerup.");
|
||||||
|
|
||||||
|
UtilFirework.playFirework(_location, Type.BALL_LARGE, Color.YELLOW, false, true);
|
||||||
|
|
||||||
|
ItemStack itemStack = Quiver.SUPER_ARROW;
|
||||||
|
itemStack.setAmount(ARROWS_TO_GIVE);
|
||||||
|
|
||||||
|
for (Player other : gameTeam.GetPlayers(true))
|
||||||
|
{
|
||||||
|
other.getInventory().addItem(itemStack);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -26,7 +26,7 @@ public class KitBarrage extends ProgressingKit
|
|||||||
"",
|
"",
|
||||||
C.cGreenB + "ULTIMATE",
|
C.cGreenB + "ULTIMATE",
|
||||||
"When you fire your next arrow you fire will fire an addiational",
|
"When you fire your next arrow you fire will fire an addiational",
|
||||||
C.cGreen + "5" + C.cWhite + " arrows."
|
C.cGreen + "10" + C.cWhite + " arrows."
|
||||||
};
|
};
|
||||||
|
|
||||||
private static final Perk[][] PERKS = {
|
private static final Perk[][] PERKS = {
|
||||||
|
@ -23,7 +23,7 @@ public class KitPyromancer extends ProgressingKit
|
|||||||
private static final String[] DESCRIPTION = {
|
private static final String[] DESCRIPTION = {
|
||||||
"Hot! Hot! Hot!",
|
"Hot! Hot! Hot!",
|
||||||
"",
|
"",
|
||||||
"When your arrows land, players within " + C.cGreen + "1" + C.cWhite + " block are set on",
|
"When your arrows land, players within " + C.cGreen + "2" + C.cWhite + " block are set on",
|
||||||
"fire for " + C.cGreen + "3" + C.cWhite + " seconds.",
|
"fire for " + C.cGreen + "3" + C.cWhite + " seconds.",
|
||||||
"",
|
"",
|
||||||
C.cGreenB + "ULTIMATE",
|
C.cGreenB + "ULTIMATE",
|
||||||
@ -33,27 +33,27 @@ public class KitPyromancer extends ProgressingKit
|
|||||||
|
|
||||||
private static final Perk[][] PERKS = {
|
private static final Perk[][] PERKS = {
|
||||||
{
|
{
|
||||||
new PerkFireArrows(1, 60),
|
new PerkFireArrows(2, 60),
|
||||||
new UltimatePyromancer(3, 10)
|
new UltimatePyromancer(3, 10)
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
new PerkFireArrows(1, 60),
|
new PerkFireArrows(2, 60),
|
||||||
new UltimatePyromancer(3.5, 10)
|
new UltimatePyromancer(3.5, 10)
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
new PerkFireArrows(1, 60),
|
new PerkFireArrows(2, 60),
|
||||||
new UltimatePyromancer(4, 10)
|
new UltimatePyromancer(4, 10)
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
new PerkFireArrows(1, 60),
|
new PerkFireArrows(2, 60),
|
||||||
new UltimatePyromancer(4.5, 10)
|
new UltimatePyromancer(4.5, 10)
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
new PerkFireArrows(1, 60),
|
new PerkFireArrows(2, 60),
|
||||||
new UltimatePyromancer(5, 10)
|
new UltimatePyromancer(5, 10)
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
new PerkFireArrows(1, 60),
|
new PerkFireArrows(2, 60),
|
||||||
new UltimatePyromancer(5.5, 10)
|
new UltimatePyromancer(5.5, 10)
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -34,7 +34,7 @@ public abstract class Ultimate extends Perk
|
|||||||
|
|
||||||
player.getInventory().addItem(Quiver.SUPER_ARROW);
|
player.getInventory().addItem(Quiver.SUPER_ARROW);
|
||||||
player.sendMessage(F.main("Game", "Activated " + F.skill(GetName())));
|
player.sendMessage(F.main("Game", "Activated " + F.skill(GetName())));
|
||||||
UtilServer.broadcast(C.cWhiteB + player.getName() + " activated " + C.cGreenB + GetName());
|
UtilServer.broadcast(C.cGreenB + player.getName() + C.cWhiteB + " activated their " + C.cGreenB + GetName() + C.cWhiteB + ".");
|
||||||
|
|
||||||
for (Player other : UtilServer.getPlayers())
|
for (Player other : UtilServer.getPlayers())
|
||||||
{
|
{
|
||||||
|
@ -7,6 +7,7 @@ import java.util.Set;
|
|||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.entity.Arrow;
|
||||||
import org.bukkit.entity.Creature;
|
import org.bukkit.entity.Creature;
|
||||||
import org.bukkit.entity.LivingEntity;
|
import org.bukkit.entity.LivingEntity;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
@ -18,6 +19,7 @@ import org.bukkit.event.entity.EntityTargetEvent;
|
|||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
import mineplex.core.common.util.UtilPlayer;
|
import mineplex.core.common.util.UtilPlayer;
|
||||||
|
import mineplex.minecraft.game.core.damage.CustomDamageEvent;
|
||||||
|
|
||||||
public class UltimateNecromancer extends Ultimate
|
public class UltimateNecromancer extends Ultimate
|
||||||
{
|
{
|
||||||
@ -83,6 +85,32 @@ public class UltimateNecromancer extends Ultimate
|
|||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void onCustomDamage(CustomDamageEvent event)
|
||||||
|
{
|
||||||
|
if (event.GetProjectile() != null)
|
||||||
|
{
|
||||||
|
if (event.GetProjectile() instanceof Arrow)
|
||||||
|
{
|
||||||
|
LivingEntity livingEntity = event.GetDamagerEntity(true);
|
||||||
|
|
||||||
|
for (UUID uuid : _entities.keySet())
|
||||||
|
{
|
||||||
|
Set<LivingEntity> entities = _entities.get(uuid);
|
||||||
|
Player player = UtilPlayer.searchExact(uuid);
|
||||||
|
|
||||||
|
for (LivingEntity livingEntity2 : entities)
|
||||||
|
{
|
||||||
|
if (livingEntity.equals(livingEntity2))
|
||||||
|
{
|
||||||
|
event.SetDamager(player);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void activate(Player player)
|
public void activate(Player player)
|
||||||
{
|
{
|
||||||
@ -114,6 +142,7 @@ public class UltimateNecromancer extends Ultimate
|
|||||||
|
|
||||||
for (LivingEntity entity : _entities.get(player.getUniqueId()))
|
for (LivingEntity entity : _entities.get(player.getUniqueId()))
|
||||||
{
|
{
|
||||||
|
entity.getEquipment().clear();
|
||||||
entity.remove();
|
entity.remove();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2,8 +2,12 @@ package nautilus.game.arcade.game.games.quiver.ultimates;
|
|||||||
|
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
|
import mineplex.minecraft.game.core.damage.CustomDamageEvent;
|
||||||
|
|
||||||
public class UltimateNinja extends Ultimate
|
public class UltimateNinja extends Ultimate
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -18,6 +22,20 @@ public class UltimateNinja extends Ultimate
|
|||||||
_length = length;
|
_length = length;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void onCustomDamage(CustomDamageEvent event)
|
||||||
|
{
|
||||||
|
if (event.GetCause() != DamageCause.ENTITY_ATTACK)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (getLastUltimate().containsKey(event.GetDamagerPlayer(false).getUniqueId()) && event.GetDamagerPlayer(false).getItemInHand().getType() == Material.DIAMOND_SWORD)
|
||||||
|
{
|
||||||
|
event.AddMod(event.GetDamagerPlayer(false).getName(), "Ninja Strike", 9001, false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void activate(Player player)
|
public void activate(Player player)
|
||||||
{
|
{
|
||||||
|
@ -37,7 +37,7 @@ public class PerkFireArrows extends Perk
|
|||||||
|
|
||||||
for (Player other : UtilPlayer.getNearby(projectile.getLocation(), _distance))
|
for (Player other : UtilPlayer.getNearby(projectile.getLocation(), _distance))
|
||||||
{
|
{
|
||||||
if (!Manager.IsAlive(other) || !player.equals(other))
|
if (!Manager.IsAlive(other) || player.equals(other))
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user