mirror of
https://github.com/darksaid98/AlathranWars.git
synced 2026-12-03 22:15:24 +00:00
Raid ending rework
This commit is contained in:
1 parent
ab1ce3d70f
commit
c1f5b5cbe5
1 file changed
+136
-93
@@ -222,12 +222,10 @@ public class Raid {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* End of raid
|
* End of raid
|
||||||
*/
|
*/
|
||||||
public void stop() {
|
public void stop() {
|
||||||
this.phase = RaidPhase.END;
|
|
||||||
Bukkit.getScheduler().cancelTask(this.bukkitId[0]);
|
Bukkit.getScheduler().cancelTask(this.bukkitId[0]);
|
||||||
RaidData.removeRaid(this);
|
RaidData.removeRaid(this);
|
||||||
}
|
}
|
||||||
@@ -745,9 +743,23 @@ public class Raid {
|
|||||||
Raid.this.raiderPlayers = Raid.this.war.getSide2Players();
|
Raid.this.raiderPlayers = Raid.this.war.getSide2Players();
|
||||||
Raid.this.defenderPlayers = Raid.this.war.getSide1Players();
|
Raid.this.defenderPlayers = Raid.this.war.getSide1Players();
|
||||||
}
|
}
|
||||||
if (Raid.this.raidTicks >= RaidPhase.END.startTick) {
|
raidTicks += incremental;
|
||||||
Bukkit.getServer().getScheduler().cancelTask(Raid.this.bukkitId[0]);
|
|
||||||
|
if (Raid.this.raidTicks >= RaidPhase.END.startTick && Raid.this.phase == RaidPhase.COMBAT) {
|
||||||
Raid.this.phase = RaidPhase.END;
|
Raid.this.phase = RaidPhase.END;
|
||||||
|
}
|
||||||
|
|
||||||
|
//check and start travel phase
|
||||||
|
if (Raid.this.raidTicks >= RaidPhase.TRAVEL.startTick && Raid.this.phase == RaidPhase.GATHER) {
|
||||||
|
startTravel();
|
||||||
|
}
|
||||||
|
|
||||||
|
//check and start combat phase
|
||||||
|
if (Raid.this.raidTicks >= RaidPhase.COMBAT.startTick && Raid.this.phase == RaidPhase.TRAVEL) {
|
||||||
|
startCombat();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Raid.this.phase == RaidPhase.END) {
|
||||||
//TODO: fix raid scoring
|
//TODO: fix raid scoring
|
||||||
//for raiders to win, they need a significant up from the defenders
|
//for raiders to win, they need a significant up from the defenders
|
||||||
if (Raid.this.raidScore > 800) {
|
if (Raid.this.raidScore > 800) {
|
||||||
@@ -755,114 +767,109 @@ public class Raid {
|
|||||||
} else {
|
} else {
|
||||||
Raid.this.defendersWin(Raid.this.raidScore);
|
Raid.this.defendersWin(Raid.this.raidScore);
|
||||||
}
|
}
|
||||||
} else {
|
}
|
||||||
raidTicks += incremental;
|
|
||||||
|
|
||||||
//check and start travel phase
|
//Raid gather phase behavior
|
||||||
if (Raid.this.raidTicks >= RaidPhase.TRAVEL.startTick && Raid.this.phase == RaidPhase.GATHER) {
|
if (Raid.this.phase == RaidPhase.GATHER) {
|
||||||
startTravel();
|
//Broadcast
|
||||||
|
if (raidTicks % 6000 == 0) {
|
||||||
|
Bukkit.broadcastMessage(String.valueOf(Helper.Chatlabel()) + "The raid of "
|
||||||
|
+ Raid.this.getRaidedTown().getName() + " will begin in " + (int) (RaidPhase.TRAVEL.startTick / 20 / 60) + " minutes!");
|
||||||
|
Bukkit.broadcastMessage(
|
||||||
|
"The Raiders are gathering at " + getGatherTown().getName() + " before making the journey over!");
|
||||||
}
|
}
|
||||||
|
|
||||||
//check and start combat phase
|
|
||||||
if (Raid.this.raidTicks >= RaidPhase.COMBAT.startTick && Raid.this.phase == RaidPhase.TRAVEL) {
|
|
||||||
startCombat();
|
|
||||||
}
|
|
||||||
|
|
||||||
//Raid gather phase behavior
|
//Prevent players from leaving gather town prematurely, if player is raid owner, dont do that
|
||||||
if (Raid.this.phase == RaidPhase.GATHER) {
|
for (String playerName : getActiveRaiders()) {
|
||||||
//Broadcast
|
try {
|
||||||
if (raidTicks % 6000 == 0) {
|
Player p = Bukkit.getPlayer(playerName);
|
||||||
Bukkit.broadcastMessage(String.valueOf(Helper.Chatlabel()) + "The raid of "
|
ArrayList<WorldCoord> cluster = Helper.getCluster(Raid.this.getGatherTown().getHomeBlock().getWorldCoord());
|
||||||
+ Raid.this.getRaidedTown().getName() + " will begin in " + (int) (RaidPhase.TRAVEL.startTick / 20 / 60) + " minutes!");
|
if (!cluster.contains(WorldCoord.parseWorldCoord(p))) {
|
||||||
Bukkit.broadcastMessage(
|
if (p.equals(owner)) {
|
||||||
"The Raiders are gathering at " + getGatherTown().getName() + " before making the journey over!");
|
p.teleport(gatherTown.getSpawn());
|
||||||
}
|
p.sendMessage(String.valueOf(Helper.Chatlabel()) + "You cannot leave the gather town. As raid party leader, you have remained in the party. To stop the raid type /raid abandon");
|
||||||
|
p.sendMessage(String.valueOf(Helper.Chatlabel()) + "You have been teleported to the gather town's spawn.");
|
||||||
|
} else {
|
||||||
//Prevent players from leaving gather town prematurely
|
|
||||||
for (String playerName : getActiveRaiders()) {
|
|
||||||
try {
|
|
||||||
Player p = Bukkit.getPlayer(playerName);
|
|
||||||
ArrayList<WorldCoord> cluster = Helper.getCluster(Raid.this.getGatherTown().getHomeBlock().getWorldCoord());
|
|
||||||
if (!cluster.contains(WorldCoord.parseWorldCoord(p))) {
|
|
||||||
Raid.this.removeActiveRaider(p.getName());
|
Raid.this.removeActiveRaider(p.getName());
|
||||||
p.sendMessage(String.valueOf(Helper.Chatlabel()) + "By leaving the gathering town you have left the raid on " + Raid.this.getRaidedTown().getName() + "!");
|
p.sendMessage(String.valueOf(Helper.Chatlabel()) + "By leaving the gathering town you have left the raid on " + Raid.this.getRaidedTown().getName() + "!");
|
||||||
p.sendMessage(String.valueOf(Helper.Chatlabel()) + "To rejoin, do /raid join [war] [town]");
|
p.sendMessage(String.valueOf(Helper.Chatlabel()) + "To rejoin, do /raid join [war] [town]");
|
||||||
}
|
}
|
||||||
} catch (NullPointerException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
} catch (NotRegisteredException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
} catch (TownyException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
}
|
||||||
|
} catch (NullPointerException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
} catch (NotRegisteredException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
} catch (TownyException e) {
|
||||||
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//Raid Travel phase behavior
|
//Raid Travel phase behavior
|
||||||
else if (Raid.this.phase == RaidPhase.TRAVEL) {
|
else if (Raid.this.phase == RaidPhase.TRAVEL) {
|
||||||
|
|
||||||
//Report
|
//Report
|
||||||
if (raidTicks % 2400 == 0) {
|
if (raidTicks % 2400 == 0) {
|
||||||
Bukkit.broadcastMessage(String.valueOf(Helper.Chatlabel()) + "The Raiders of "
|
Bukkit.broadcastMessage(String.valueOf(Helper.Chatlabel()) + "The Raiders of "
|
||||||
+ (side1AreRaiders ? Raid.this.war.getSide1() : Raid.this.war.getSide2())
|
+ (side1AreRaiders ? Raid.this.war.getSide1() : Raid.this.war.getSide2())
|
||||||
+ " are on their way to raid "
|
+ " are on their way to raid "
|
||||||
+ Raid.this.getRaidedTown().getName() + "!");
|
+ Raid.this.getRaidedTown().getName() + "!");
|
||||||
}
|
|
||||||
|
|
||||||
//Check if a player has arrived at the town (in it, or within 200 blocks) and if so start combat
|
|
||||||
for (String player : activeRaiders) {
|
|
||||||
try {
|
|
||||||
boolean playerCloseToHomeBlockRaid = false;
|
|
||||||
final int homeBlockXCoordRaided = Raid.this.getRaidedTown().getHomeBlock().getCoord().getX() * 16;
|
|
||||||
final int homeBlockZCoordRaided = Raid.this.getRaidedTown().getHomeBlock().getCoord().getZ() * 16;
|
|
||||||
Player p = Bukkit.getPlayer(player);
|
|
||||||
//Carryover from sieges
|
|
||||||
if (Math.abs(p.getLocation().getBlockX() - homeBlockXCoordRaided) <= 200 && Math.abs(p.getLocation().getBlockZ() - homeBlockZCoordRaided) <= 200) {
|
|
||||||
playerCloseToHomeBlockRaid = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
WorldCoord playercoord = WorldCoord.parseWorldCoord(Bukkit.getPlayer(player));
|
|
||||||
if (Raid.this.getRaidedTown().hasTownBlock(playercoord) || playerCloseToHomeBlockRaid) {
|
|
||||||
startCombat();
|
|
||||||
}
|
|
||||||
} catch (TownyException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//Raid combat phase behavior
|
//Check if a player has arrived at the town (in it, or within 200 blocks) and if so start combat
|
||||||
else if (Raid.this.phase == RaidPhase.COMBAT) {
|
for (String player : activeRaiders) {
|
||||||
|
try {
|
||||||
|
boolean playerCloseToHomeBlockRaid = false;
|
||||||
|
final int homeBlockXCoordRaided = Raid.this.getRaidedTown().getHomeBlock().getCoord().getX() * 16;
|
||||||
|
final int homeBlockZCoordRaided = Raid.this.getRaidedTown().getHomeBlock().getCoord().getZ() * 16;
|
||||||
|
Player p = Bukkit.getPlayer(player);
|
||||||
|
//Carryover from sieges
|
||||||
|
if (Math.abs(p.getLocation().getBlockX() - homeBlockXCoordRaided) <= 200 && Math.abs(p.getLocation().getBlockZ() - homeBlockZCoordRaided) <= 200) {
|
||||||
|
playerCloseToHomeBlockRaid = true;
|
||||||
|
}
|
||||||
|
|
||||||
//Report
|
WorldCoord playercoord = WorldCoord.parseWorldCoord(Bukkit.getPlayer(player));
|
||||||
if (Raid.this.raidTicks % 6000 == 0) {
|
if (Raid.this.getRaidedTown().hasTownBlock(playercoord) || playerCloseToHomeBlockRaid) {
|
||||||
Bukkit.broadcastMessage(String.valueOf(Helper.Chatlabel()) + "Report on the raid of "
|
startCombat();
|
||||||
+ Raid.this.getRaidedTown().getName() + ":");
|
}
|
||||||
Bukkit.broadcastMessage(
|
} catch (TownyException e) {
|
||||||
"Raid Score - " + String.valueOf(Raid.this.raidScore));
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//Looting chunks
|
//Raid combat phase behavior
|
||||||
for (String name : Raid.this.getActiveRaiders()) {
|
else if (Raid.this.phase == RaidPhase.COMBAT) {
|
||||||
Player p = Bukkit.getPlayer(name);
|
|
||||||
WorldCoord wc = WorldCoord.parseWorldCoord(p);
|
//Report
|
||||||
if (p.isSneaking()) {
|
if (Raid.this.raidTicks % 6000 == 0) {
|
||||||
//check if our chunk is looted, if so skip this player
|
Bukkit.broadcastMessage(String.valueOf(Helper.Chatlabel()) + "Report on the raid of "
|
||||||
//Idk if thisll work but if it do then ye
|
+ Raid.this.getRaidedTown().getName() + ":");
|
||||||
if (Raid.this.lootedChunks.containsKey(wc)) {
|
Bukkit.broadcastMessage(
|
||||||
if (Raid.this.lootedChunks.get(wc).finished) {
|
"Raid Score - " + String.valueOf(Raid.this.raidScore));
|
||||||
p.sendMessage(Helper.Chatlabel() + "This chunk is already looted, try another.");
|
}
|
||||||
} else {
|
|
||||||
doLootAt(p, wc);
|
//Looting chunks
|
||||||
}
|
for (String name : Raid.this.getActiveRaiders()) {
|
||||||
|
Player p = Bukkit.getPlayer(name);
|
||||||
|
WorldCoord wc = WorldCoord.parseWorldCoord(p);
|
||||||
|
if (p.isSneaking()) {
|
||||||
|
//check if our chunk is looted, if so skip this player
|
||||||
|
//Idk if thisll work but if it do then ye
|
||||||
|
if (Raid.this.lootedChunks.containsKey(wc)) {
|
||||||
|
if (Raid.this.lootedChunks.get(wc).finished) {
|
||||||
|
p.sendMessage(Helper.Chatlabel() + "This chunk is already looted, try another.");
|
||||||
} else {
|
} else {
|
||||||
if (Raid.this.getRaidedTown().hasTownBlock(wc)) {
|
doLootAt(p, wc);
|
||||||
doLootAt(p, wc);
|
|
||||||
} else {
|
|
||||||
p.sendMessage(Helper.Chatlabel() + "This space is not part of the raided town, you cannot loot this area.");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
if (Raid.this.getRaidedTown().hasTownBlock(wc)) {
|
||||||
|
doLootAt(p, wc);
|
||||||
|
} else {
|
||||||
|
p.sendMessage(Helper.Chatlabel() + "This space is not part of the raided town, you cannot loot this area.");
|
||||||
|
}
|
||||||
|
}
|
||||||
// for (LootBlock c : Raid.this.lootedChunks.values()) {
|
// for (LootBlock c : Raid.this.lootedChunks.values()) {
|
||||||
// if (c.worldCoord.equals(wc)) {
|
// if (c.worldCoord.equals(wc)) {
|
||||||
// looted = true;
|
// looted = true;
|
||||||
@@ -871,14 +878,50 @@ public class Raid {
|
|||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public TownBlock getHomeBlockRaided() {
|
||||||
|
return homeBlockRaided;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setHomeBlockRaided(TownBlock homeBlockRaided) {
|
||||||
|
this.homeBlockRaided = homeBlockRaided;
|
||||||
|
}
|
||||||
|
|
||||||
|
public TownBlock getHomeBlockGather() {
|
||||||
|
return homeBlockGather;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setHomeBlockGather(TownBlock homeBlockGather) {
|
||||||
|
this.homeBlockGather = homeBlockGather;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPhase(RaidPhase phase) {
|
||||||
|
this.phase = phase;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Location getTownSpawnRaided() {
|
||||||
|
return townSpawnRaided;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTownSpawnRaided(Location townSpawnRaided) {
|
||||||
|
this.townSpawnRaided = townSpawnRaided;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Location getTownSpawnGather() {
|
||||||
|
return townSpawnGather;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTownSpawnGather(Location townSpawnGather) {
|
||||||
|
this.townSpawnGather = townSpawnGather;
|
||||||
|
}
|
||||||
|
|
||||||
public static class LootBlock {
|
public static class LootBlock {
|
||||||
|
|
||||||
public WorldCoord worldCoord;
|
public WorldCoord worldCoord;
|
||||||
|
|||||||
Reference in new issue
Block a user