Dieser Commit ist enthalten in:
Ursprung
ab08f5c131
Commit
7b26b7bf91
@ -23,6 +23,7 @@ import com.comphenix.tinyprotocol.TinyProtocol;
|
|||||||
import de.steamwar.core.Core;
|
import de.steamwar.core.Core;
|
||||||
import de.steamwar.fightsystem.ai.LixfelAI;
|
import de.steamwar.fightsystem.ai.LixfelAI;
|
||||||
import de.steamwar.fightsystem.ai.navmesh.NavMesh;
|
import de.steamwar.fightsystem.ai.navmesh.NavMesh;
|
||||||
|
import de.steamwar.fightsystem.ai.chaos.ChaosAI;
|
||||||
import de.steamwar.fightsystem.commands.*;
|
import de.steamwar.fightsystem.commands.*;
|
||||||
import de.steamwar.fightsystem.countdown.*;
|
import de.steamwar.fightsystem.countdown.*;
|
||||||
import de.steamwar.fightsystem.event.HellsBells;
|
import de.steamwar.fightsystem.event.HellsBells;
|
||||||
@ -171,11 +172,10 @@ public class FightSystem extends JavaPlugin {
|
|||||||
}
|
}
|
||||||
|
|
||||||
FightStatistics.unrank();
|
FightStatistics.unrank();
|
||||||
FightWorld.forceLoad();
|
|
||||||
|
|
||||||
Bukkit.getScheduler().runTask(getPlugin(), () -> {
|
Bukkit.getScheduler().runTask(getPlugin(), () -> {
|
||||||
new LixfelAI(Fight.getBlueTeam(), "Lixfel.AI");
|
new ChaosAI(Fight.getBlueTeam());
|
||||||
new LixfelAI(Fight.getRedTeam(), "YoyoNow.AI");
|
new LixfelAI(Fight.getRedTeam(), SteamwarUser.get(-1));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -23,7 +23,6 @@ import de.steamwar.entity.REntityServer;
|
|||||||
import de.steamwar.fightsystem.Config;
|
import de.steamwar.fightsystem.Config;
|
||||||
import de.steamwar.fightsystem.ai.navmesh.NavMesh;
|
import de.steamwar.fightsystem.ai.navmesh.NavMesh;
|
||||||
import de.steamwar.fightsystem.fight.FightTeam;
|
import de.steamwar.fightsystem.fight.FightTeam;
|
||||||
import de.steamwar.fightsystem.states.FightState;
|
|
||||||
import de.steamwar.sql.SchematicNode;
|
import de.steamwar.sql.SchematicNode;
|
||||||
import de.steamwar.sql.SteamwarUser;
|
import de.steamwar.sql.SteamwarUser;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
@ -31,7 +30,6 @@ import org.bukkit.entity.Player;
|
|||||||
import org.bukkit.util.Vector;
|
import org.bukkit.util.Vector;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.function.Function;
|
|
||||||
|
|
||||||
public class LixfelAI extends AI {
|
public class LixfelAI extends AI {
|
||||||
|
|
||||||
@ -40,8 +38,8 @@ public class LixfelAI extends AI {
|
|||||||
private final FightTeam team;
|
private final FightTeam team;
|
||||||
private final NavMesh navMesh;
|
private final NavMesh navMesh;
|
||||||
|
|
||||||
public LixfelAI(FightTeam team, String user) {
|
public LixfelAI(FightTeam team, SteamwarUser user) {
|
||||||
super(team, SteamwarUser.get(user));
|
super(team, user);
|
||||||
this.team = team;
|
this.team = team;
|
||||||
navMesh = new NavMesh(team, entityServer);
|
navMesh = new NavMesh(team, entityServer);
|
||||||
}
|
}
|
||||||
@ -69,14 +67,6 @@ public class LixfelAI extends AI {
|
|||||||
private Vector destination = null;
|
private Vector destination = null;
|
||||||
private int index = 0;
|
private int index = 0;
|
||||||
|
|
||||||
LixfelPathplanner getPathplanner() {
|
|
||||||
return pathplanner;
|
|
||||||
}
|
|
||||||
|
|
||||||
void setAction(Action action) {
|
|
||||||
this.action = action;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void plan() {
|
protected void plan() {
|
||||||
setReady();
|
setReady();
|
||||||
|
@ -1,31 +0,0 @@
|
|||||||
/*
|
|
||||||
* This file is a part of the SteamWar software.
|
|
||||||
*
|
|
||||||
* Copyright (C) 2023 SteamWar.de-Serverteam
|
|
||||||
*
|
|
||||||
* This program is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU Affero General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU Affero General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU Affero General Public License
|
|
||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package de.steamwar.fightsystem.ai.chaos;
|
|
||||||
|
|
||||||
import org.bukkit.util.Vector;
|
|
||||||
|
|
||||||
public class Bridge {
|
|
||||||
private Bridge() {
|
|
||||||
}
|
|
||||||
|
|
||||||
public static final Vector BRIDGE_POS = new Vector(25, 14, 24);
|
|
||||||
public static final Vector BRIDGE_SHIELDS = new Vector(25, 15, 25);
|
|
||||||
public static final Vector BRIDGE_MG = new Vector(21, 15, 24);
|
|
||||||
}
|
|
@ -28,7 +28,7 @@ public class Cannon {
|
|||||||
public final Vector escape;
|
public final Vector escape;
|
||||||
public final String name;
|
public final String name;
|
||||||
|
|
||||||
private Cannon(String name, Vector[] tnt, Vector button, Vector load, Vector escape) {
|
public Cannon(String name, Vector[] tnt, Vector button, Vector load, Vector escape) {
|
||||||
this.tnt = tnt;
|
this.tnt = tnt;
|
||||||
this.button = button;
|
this.button = button;
|
||||||
this.load = load;
|
this.load = load;
|
||||||
@ -36,137 +36,23 @@ public class Cannon {
|
|||||||
this.name = name;
|
this.name = name;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static final Vector[] DS_LEFT_TNT = new Vector[] {
|
public Vector[] getTnt() {
|
||||||
new Vector(40, 24, 12),
|
return tnt;
|
||||||
new Vector(39, 24, 12),
|
}
|
||||||
new Vector(38, 23, 12),
|
|
||||||
new Vector(38, 24, 12),
|
|
||||||
new Vector(40, 23, 15),
|
|
||||||
new Vector(40, 23, 14),
|
|
||||||
new Vector(40, 24, 15),
|
|
||||||
new Vector(40, 24, 14),
|
|
||||||
new Vector(38, 23, 15),
|
|
||||||
new Vector(38, 23, 14),
|
|
||||||
new Vector(38, 24, 15),
|
|
||||||
new Vector(38, 24, 14),
|
|
||||||
new Vector(40, 23, 12),
|
|
||||||
};
|
|
||||||
public static final Vector DS_LEFT_BUTTON = new Vector(39, 25, 11);
|
|
||||||
public static final Vector DS_LEFT_LOAD = new Vector(39, 25, 13);
|
|
||||||
public static final Vector DS_LEFT_ESCAPE = new Vector(31, 26, 13);
|
|
||||||
public static final Cannon DS_LEFT = new Cannon("Downstäb Links", DS_LEFT_TNT, DS_LEFT_BUTTON, DS_LEFT_LOAD, DS_LEFT_ESCAPE);
|
|
||||||
|
|
||||||
public static final Vector[] DS_RIGHT_TNT = new Vector[] {
|
public Vector getButton() {
|
||||||
new Vector(12, 24, 12),
|
return button;
|
||||||
new Vector(11, 24, 12),
|
}
|
||||||
new Vector(10, 23, 12),
|
|
||||||
new Vector(10, 24, 12),
|
|
||||||
new Vector(10, 23, 15),
|
|
||||||
new Vector(10, 23, 14),
|
|
||||||
new Vector(10, 24, 15),
|
|
||||||
new Vector(10, 24, 14),
|
|
||||||
new Vector(12, 23, 14),
|
|
||||||
new Vector(12, 24, 14),
|
|
||||||
new Vector(12, 23, 15),
|
|
||||||
new Vector(12, 24, 15),
|
|
||||||
new Vector(12, 23, 12),
|
|
||||||
};
|
|
||||||
public static final Vector DS_RIGHT_BUTTON = new Vector(11, 25, 11);
|
|
||||||
public static final Vector DS_RIGHT_LOAD = new Vector(11, 25, 13);
|
|
||||||
public static final Vector DS_RIGHT_ESCAPE = new Vector(19, 26, 13);
|
|
||||||
public static final Cannon DS_RIGHT = new Cannon("Downstäb Rechts", DS_RIGHT_TNT, DS_RIGHT_BUTTON, DS_RIGHT_LOAD, DS_RIGHT_ESCAPE);
|
|
||||||
|
|
||||||
public static final Vector[] STATIC_LEFT_TNT = new Vector[] {
|
public Vector getLoad() {
|
||||||
new Vector(37, 17, 15),
|
return load;
|
||||||
new Vector(37, 17, 14),
|
}
|
||||||
new Vector(37, 18, 16),
|
|
||||||
new Vector(37, 18, 15),
|
|
||||||
new Vector(37, 18, 14),
|
|
||||||
new Vector(36, 17, 16),
|
|
||||||
new Vector(36, 17, 15),
|
|
||||||
new Vector(36, 17, 14),
|
|
||||||
new Vector(36, 18, 16),
|
|
||||||
new Vector(36, 18, 15),
|
|
||||||
new Vector(36, 18, 14),
|
|
||||||
new Vector(37, 17, 16),
|
|
||||||
};
|
|
||||||
public static final Vector STATIC_LEFT_BUTTON = new Vector(38, 18, 11);
|
|
||||||
public static final Vector STATIC_LEFT_LOAD = new Vector(37, 17, 12);
|
|
||||||
public static final Vector STATIC_LEFT_ESCAPE = new Vector(30, 13, 9);
|
|
||||||
public static final Cannon STATIC_LEFT = new Cannon("Lupf Links", STATIC_LEFT_TNT, STATIC_LEFT_BUTTON, STATIC_LEFT_LOAD, STATIC_LEFT_ESCAPE);
|
|
||||||
|
|
||||||
public static final Vector[] STATIC_RIGHT_TNT = new Vector[] {
|
public Vector getEscape() {
|
||||||
new Vector(14, 17, 15),
|
return escape;
|
||||||
new Vector(14, 18, 16),
|
}
|
||||||
new Vector(14, 18, 15),
|
|
||||||
new Vector(14, 17, 14),
|
|
||||||
new Vector(14, 18, 14),
|
|
||||||
new Vector(13, 17, 16),
|
|
||||||
new Vector(13, 17, 15),
|
|
||||||
new Vector(13, 17, 14),
|
|
||||||
new Vector(13, 18, 16),
|
|
||||||
new Vector(13, 18, 15),
|
|
||||||
new Vector(13, 18, 14),
|
|
||||||
new Vector(14, 17, 16),
|
|
||||||
};
|
|
||||||
public static final Vector STATIC_RIGHT_BUTTON = new Vector(12, 18, 11);
|
|
||||||
public static final Vector STATIC_RIGHT_LOAD = new Vector(13, 17, 12);
|
|
||||||
public static final Vector STATIC_RIGHT_ESCAPE = new Vector(20, 13, 9);
|
|
||||||
public static final Cannon STATIC_RIGHT = new Cannon("Lupf Rechts", STATIC_RIGHT_TNT, STATIC_RIGHT_BUTTON, STATIC_RIGHT_LOAD, STATIC_RIGHT_ESCAPE);
|
|
||||||
|
|
||||||
public static final Vector[] AK_TNT = new Vector[] {
|
public String getName() {
|
||||||
new Vector(10, 7, 17),
|
return name;
|
||||||
new Vector(10, 11, 17),
|
}
|
||||||
new Vector(10, 10, 17),
|
|
||||||
new Vector(10, 8, 17),
|
|
||||||
new Vector(10, 9, 17),
|
|
||||||
new Vector(10, 7, 15),
|
|
||||||
new Vector(11, 7, 15),
|
|
||||||
new Vector(12, 7, 15),
|
|
||||||
new Vector(10, 10, 15),
|
|
||||||
new Vector(11, 10, 15),
|
|
||||||
new Vector(12, 10, 15),
|
|
||||||
new Vector(12, 8, 15),
|
|
||||||
new Vector(12, 9, 15),
|
|
||||||
new Vector(11, 8, 15),
|
|
||||||
new Vector(11, 9, 15),
|
|
||||||
new Vector(10, 8, 15),
|
|
||||||
new Vector(10, 9, 15),
|
|
||||||
new Vector(10, 7, 19),
|
|
||||||
new Vector(11, 7, 19),
|
|
||||||
new Vector(12, 7, 19),
|
|
||||||
new Vector(12, 8, 19),
|
|
||||||
new Vector(11, 8, 19),
|
|
||||||
new Vector(10, 8, 19),
|
|
||||||
new Vector(10, 10, 19),
|
|
||||||
new Vector(11, 10, 19),
|
|
||||||
new Vector(12, 10, 19),
|
|
||||||
new Vector(12, 9, 19),
|
|
||||||
new Vector(11, 9, 19),
|
|
||||||
new Vector(10, 9, 19),
|
|
||||||
new Vector(10, 6, 17),
|
|
||||||
};
|
|
||||||
public static final Vector AK_BUTTON = new Vector(9, 9, 16);
|
|
||||||
public static final Vector AK_LOAD = new Vector(11, 8, 17);
|
|
||||||
public static final Cannon AK = new Cannon("Arschkratzer", AK_TNT, AK_BUTTON, AK_LOAD, null);
|
|
||||||
|
|
||||||
public static final Vector[] HA_RIGHT_TNT = new Vector[] {
|
|
||||||
new Vector(23, 5, 9),
|
|
||||||
new Vector(23, 6, 9),
|
|
||||||
new Vector(23, 7, 9),
|
|
||||||
new Vector(23, 8, 9),
|
|
||||||
};
|
|
||||||
|
|
||||||
public static final Vector[] HA_LEFT_TNT = new Vector[] {
|
|
||||||
new Vector(27, 5, 9),
|
|
||||||
new Vector(27, 6, 9),
|
|
||||||
new Vector(27, 7, 9),
|
|
||||||
new Vector(27, 8, 9),
|
|
||||||
};
|
|
||||||
|
|
||||||
public static final Vector HA_RIGHT_LOAD = new Vector(23, 8, 8);
|
|
||||||
public static final Vector HA_LEFT_LOAD = new Vector(27, 8, 8);
|
|
||||||
|
|
||||||
public static final Cannon HA_LEFT = new Cannon("Halbautomatik Links", HA_LEFT_TNT, null, HA_LEFT_LOAD, null);
|
|
||||||
public static final Cannon HA_RIGHT = new Cannon("Halbautomatik Rechts", HA_RIGHT_TNT, null, HA_RIGHT_LOAD, null);
|
|
||||||
}
|
}
|
||||||
|
@ -19,39 +19,44 @@
|
|||||||
|
|
||||||
package de.steamwar.fightsystem.ai.chaos;
|
package de.steamwar.fightsystem.ai.chaos;
|
||||||
|
|
||||||
|
import de.steamwar.entity.REntityServer;
|
||||||
import de.steamwar.fightsystem.FightSystem;
|
import de.steamwar.fightsystem.FightSystem;
|
||||||
import de.steamwar.fightsystem.ai.AI;
|
import de.steamwar.fightsystem.ai.AI;
|
||||||
import de.steamwar.fightsystem.ai.LixfelPathplanner;
|
import de.steamwar.fightsystem.ai.chaos.gears.Gear;
|
||||||
|
import de.steamwar.fightsystem.ai.chaos.gears.TheUnderground;
|
||||||
|
import de.steamwar.fightsystem.ai.navmesh.NavMesh;
|
||||||
import de.steamwar.fightsystem.fight.FightTeam;
|
import de.steamwar.fightsystem.fight.FightTeam;
|
||||||
import de.steamwar.fightsystem.states.FightState;
|
import de.steamwar.fightsystem.states.FightState;
|
||||||
import de.steamwar.sql.SchematicNode;
|
import de.steamwar.sql.SchematicNode;
|
||||||
import de.steamwar.sql.SteamwarUser;
|
import de.steamwar.sql.SteamwarUser;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.Material;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.player.PlayerTeleportEvent;
|
||||||
import org.bukkit.util.Vector;
|
import org.bukkit.util.Vector;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
public class ChaosAI extends AI {
|
public class ChaosAI extends AI {
|
||||||
private final LixfelPathplanner pathplanner = new LixfelPathplanner(chooseSchematic());
|
|
||||||
private State state = State.PRE_PREPARE;
|
private State state = State.PRE_PREPARE;
|
||||||
private static final Cannon[] cannons = new Cannon[] {
|
private static final Gear gear = TheUnderground.THE_UNDERGROUND;
|
||||||
Cannon.DS_LEFT,
|
|
||||||
Cannon.DS_RIGHT,
|
|
||||||
Cannon.STATIC_LEFT,
|
|
||||||
Cannon.STATIC_RIGHT,
|
|
||||||
Cannon.HA_LEFT,
|
|
||||||
Cannon.HA_RIGHT,
|
|
||||||
//Cannon.AK,
|
|
||||||
};
|
|
||||||
private Cannon currentCannon;
|
private Cannon currentCannon;
|
||||||
private boolean igniteMg = false;
|
private boolean igniteMg = false;
|
||||||
private static final Random random = new Random();
|
private static final Random random = new Random();
|
||||||
public static Map<FightTeam, Boolean> onePrepares = new HashMap<>();
|
public static Map<FightTeam, Boolean> onePrepares = new HashMap<>();
|
||||||
private boolean prepares = false;
|
private boolean prepares = false;
|
||||||
private static final Map<FightTeam, Set<Cannon>> cannonsShot = new HashMap<>();
|
private static final Map<FightTeam, Set<Cannon>> cannonsShot = new HashMap<>();
|
||||||
|
private final NavMesh navMesh;
|
||||||
|
private final REntityServer entityServer = new REntityServer();
|
||||||
|
|
||||||
|
|
||||||
|
private Vector source = null;
|
||||||
|
private Vector destination = null;
|
||||||
|
private int index = 0;
|
||||||
|
private State nextState = null;
|
||||||
|
|
||||||
public ChaosAI(FightTeam team) {
|
public ChaosAI(FightTeam team) {
|
||||||
this(team, SteamwarUser.get(14533));
|
this(team, SteamwarUser.get(14533));
|
||||||
}
|
}
|
||||||
@ -59,6 +64,7 @@ public class ChaosAI extends AI {
|
|||||||
|
|
||||||
public ChaosAI(FightTeam team, SteamwarUser user) {
|
public ChaosAI(FightTeam team, SteamwarUser user) {
|
||||||
super(team, user);
|
super(team, user);
|
||||||
|
this.navMesh = new NavMesh(team, entityServer);
|
||||||
if (Boolean.FALSE.equals(onePrepares.getOrDefault(team, false))) {
|
if (Boolean.FALSE.equals(onePrepares.getOrDefault(team, false))) {
|
||||||
prepares = true;
|
prepares = true;
|
||||||
onePrepares.put(team, true);
|
onePrepares.put(team, true);
|
||||||
@ -67,7 +73,7 @@ public class ChaosAI extends AI {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public SchematicNode chooseSchematic() {
|
public SchematicNode chooseSchematic() {
|
||||||
return SchematicNode.getSchematicNode(111476);
|
return SchematicNode.getSchematicNode(gear.getSchematicId());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -77,16 +83,17 @@ public class ChaosAI extends AI {
|
|||||||
Bukkit.getScheduler().runTaskLater(FightSystem.getPlugin(), () -> {
|
Bukkit.getScheduler().runTaskLater(FightSystem.getPlugin(), () -> {
|
||||||
state = State.PREPARE;
|
state = State.PREPARE;
|
||||||
}, 20 * 15);
|
}, 20 * 15);
|
||||||
state = State.PREPARING_PREPARE;
|
state = State.WAIT;
|
||||||
break;
|
|
||||||
case WAIT_TILL_IGNITE:
|
|
||||||
case PREPARING_PREPARE:
|
|
||||||
break;
|
break;
|
||||||
case PREPARE:
|
case PREPARE:
|
||||||
prepare();
|
prepare();
|
||||||
state = State.PREPARE_READY;
|
|
||||||
break;
|
break;
|
||||||
case PREPARE_READY:
|
case PREPARE_READY:
|
||||||
|
if (prepares) {
|
||||||
|
for (Vector prepareButton : gear.getPrepareButtons()) {
|
||||||
|
interact(prepareButton);
|
||||||
|
}
|
||||||
|
}
|
||||||
setReady();
|
setReady();
|
||||||
state = State.WAIT_TILL_START;
|
state = State.WAIT_TILL_START;
|
||||||
break;
|
break;
|
||||||
@ -99,10 +106,10 @@ public class ChaosAI extends AI {
|
|||||||
case IGNITE_MG:
|
case IGNITE_MG:
|
||||||
if(igniteMg) {
|
if(igniteMg) {
|
||||||
if (prepares) {
|
if (prepares) {
|
||||||
interact(Bridge.BRIDGE_MG);
|
interact(gear.getMgButton());
|
||||||
chat("Die MG ist angezündet!");
|
chat("Die MG ist angezündet!");
|
||||||
}
|
}
|
||||||
state = State.WAIT_TILL_IGNITE;
|
state = State.WAIT;
|
||||||
currentCannon = randomCannon();
|
currentCannon = randomCannon();
|
||||||
Bukkit.getScheduler().runTaskLater(FightSystem.getPlugin(), () -> state = State.FIGHT, 20 * 9);
|
Bukkit.getScheduler().runTaskLater(FightSystem.getPlugin(), () -> state = State.FIGHT, 20 * 9);
|
||||||
}
|
}
|
||||||
@ -110,20 +117,69 @@ public class ChaosAI extends AI {
|
|||||||
case FIGHT:
|
case FIGHT:
|
||||||
fireCannon(currentCannon);
|
fireCannon(currentCannon);
|
||||||
break;
|
break;
|
||||||
|
case LOAD_CANNON:
|
||||||
|
loadCannon(currentCannon);
|
||||||
|
break;
|
||||||
case ESCAPE:
|
case ESCAPE:
|
||||||
chat("Ich flüchte!");
|
|
||||||
if (currentCannon.escape != null) {
|
|
||||||
pathplanner.planToAnywhere(getPosition(), currentCannon.escape.add(new Vector(0.5, 0, 0.5))).forEach(this::move);
|
|
||||||
}
|
|
||||||
|
|
||||||
cannonsShot.computeIfAbsent(team, fightTeam -> new HashSet<>()).remove(currentCannon);
|
cannonsShot.computeIfAbsent(team, fightTeam -> new HashSet<>()).remove(currentCannon);
|
||||||
currentCannon = randomCannon();
|
currentCannon = randomCannon();
|
||||||
|
|
||||||
state = State.FIGHT;
|
state = State.WAIT;
|
||||||
|
Bukkit.getScheduler().runTaskLater(FightSystem.getPlugin(), () -> state = State.FIGHT, 20 * 4);
|
||||||
|
break;
|
||||||
|
case WAIT:
|
||||||
|
break;
|
||||||
|
case WALK:
|
||||||
|
if (!getEntity().isOnGround() && getEntity().getLocation().getBlock().getType() != Material.LADDER) return;
|
||||||
|
|
||||||
|
List<Vector> oldRoute = navMesh.path(source, destination);
|
||||||
|
navMesh.update(getEntity().getLocation().toVector());
|
||||||
|
List<Vector> path = navMesh.path(source, destination);
|
||||||
|
|
||||||
|
if (path.isEmpty()) {
|
||||||
|
source = null;
|
||||||
|
destination = null;
|
||||||
|
state = nextState;
|
||||||
|
chat("no route");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (!oldRoute.equals(path)) {
|
||||||
|
source = getEntity().getLocation().toVector();
|
||||||
|
index = 0;
|
||||||
|
chat("new route");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (index == 0) {
|
||||||
|
chat(source + " -> " + destination + " = " + path.size());
|
||||||
|
}
|
||||||
|
|
||||||
|
Vector loc = path.get(index++);
|
||||||
|
move(toAIPosition(loc));
|
||||||
|
|
||||||
|
if (index == path.size()) {
|
||||||
|
source = null;
|
||||||
|
destination = null;
|
||||||
|
state = nextState;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void moveTo(Vector vec, State nextState) {
|
||||||
|
source = getEntity().getLocation().toVector();
|
||||||
|
Vector currentBest = null;
|
||||||
|
for (Vector vector : navMesh.getWalkableBlocks(source)) {
|
||||||
|
if (currentBest == null || vector.distanceSquared(vec) < currentBest.distanceSquared(vec)) {
|
||||||
|
currentBest = vector;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
destination = currentBest;
|
||||||
|
index = 0;
|
||||||
|
state = State.WALK;
|
||||||
|
this.nextState = nextState;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void stop() {
|
public void stop() {
|
||||||
chat("gege wp eZ win 4nus");
|
chat("gege wp eZ win 4nus");
|
||||||
@ -135,19 +191,25 @@ public class ChaosAI extends AI {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean acceptJoinRequest(Player player, FightTeam team) {
|
public boolean acceptJoinRequest(Player player, FightTeam team) {
|
||||||
|
if (team == this.team) {
|
||||||
|
entityServer.addPlayer(player);
|
||||||
|
}
|
||||||
return team == this.team;
|
return team == this.team;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void fireCannon(Cannon cannon) {
|
public void fireCannon(Cannon cannon) {
|
||||||
chat("Ich feuere " + cannon.name + " an!");
|
chat("Ich feuere " + cannon.name + " an!");
|
||||||
pathplanner.planToAnywhere(getPosition(), cannon.load.add(new Vector(0.5, 0, 0.5))).forEach(this::move);
|
moveTo(cannon.load.clone().add(new Vector(0.5, 0, 0.5)), State.LOAD_CANNON);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void loadCannon(Cannon cannon) {
|
||||||
if (cannon.button == null) {
|
if (cannon.button == null) {
|
||||||
for (int i = 0; i < 20; i++) {
|
for (int i = 0; i < 20; i++) {
|
||||||
for (Vector vector : cannon.tnt) {
|
for (Vector vector : cannon.tnt) {
|
||||||
setTNT(vector);
|
setTNT(vector);
|
||||||
}
|
}
|
||||||
for (int j = 0; j < 30; j++) {
|
for (int j = 0; j < 30; j++) {
|
||||||
getBlock(Bridge.BRIDGE_MG);
|
getBlock(gear.getMgButton());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -157,13 +219,15 @@ public class ChaosAI extends AI {
|
|||||||
interact(cannon.button);
|
interact(cannon.button);
|
||||||
}
|
}
|
||||||
|
|
||||||
state = State.ESCAPE;
|
if (currentCannon.escape != null) {
|
||||||
|
moveTo(cannon.getEscape().clone().add(new Vector(0.5, 0, 0.5)), State.ESCAPE);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private Cannon randomCannon() {
|
private Cannon randomCannon() {
|
||||||
Cannon nextCannon = cannons[random.nextInt(cannons.length)];
|
Cannon nextCannon = gear.getCannons()[random.nextInt(gear.getCannons().length)];
|
||||||
while (cannonsShot.computeIfAbsent(team, fightTeam -> new HashSet<>()).contains(nextCannon)) {
|
while (cannonsShot.computeIfAbsent(team, fightTeam -> new HashSet<>()).contains(nextCannon)) {
|
||||||
nextCannon = cannons[random.nextInt(cannons.length)];
|
nextCannon = gear.getCannons()[random.nextInt(gear.getCannons().length)];
|
||||||
}
|
}
|
||||||
|
|
||||||
cannonsShot.computeIfAbsent(team, fightTeam -> new HashSet<>()).add(nextCannon);
|
cannonsShot.computeIfAbsent(team, fightTeam -> new HashSet<>()).add(nextCannon);
|
||||||
@ -178,28 +242,26 @@ public class ChaosAI extends AI {
|
|||||||
}
|
}
|
||||||
Bukkit.getScheduler().runTaskLater(FightSystem.getPlugin(), () -> {
|
Bukkit.getScheduler().runTaskLater(FightSystem.getPlugin(), () -> {
|
||||||
igniteMg = true;
|
igniteMg = true;
|
||||||
}, 20 * 21);
|
}, 20L * gear.getMgTime());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void prepare() {
|
public void prepare() {
|
||||||
chat("Prepare your fkin 4nus");
|
chat("Prepare your fkin 4nus");
|
||||||
if (prepares) {
|
if (prepares) {
|
||||||
pathplanner.planToAnywhere(getPosition(), Bridge.BRIDGE_POS.add(new Vector(0.5, 0, 0.5))).forEach(this::move);
|
moveTo(gear.getBridge().clone().add(new Vector(0.5, 0, 0.5)), State.PREPARE_READY);
|
||||||
interact(Bridge.BRIDGE_SHIELDS);
|
|
||||||
pathplanner.planToAnywhere(getPosition(), Bridge.BRIDGE_POS.add(new Vector(0.5, 0, 0.5)).subtract(new Vector(2, 0, 0))).forEach(this::move);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private enum State {
|
private enum State {
|
||||||
PRE_PREPARE,
|
PRE_PREPARE,
|
||||||
PREPARING_PREPARE,
|
|
||||||
PREPARE,
|
PREPARE,
|
||||||
PREPARE_READY,
|
PREPARE_READY,
|
||||||
WAIT_TILL_START,
|
WAIT_TILL_START,
|
||||||
IGNITE_MG,
|
IGNITE_MG,
|
||||||
WAIT_TILL_IGNITE,
|
|
||||||
FIGHT,
|
FIGHT,
|
||||||
|
LOAD_CANNON,
|
||||||
ESCAPE,
|
ESCAPE,
|
||||||
|
WAIT,
|
||||||
|
WALK,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,66 @@
|
|||||||
|
/*
|
||||||
|
* This file is a part of the SteamWar software.
|
||||||
|
*
|
||||||
|
* Copyright (C) 2023 SteamWar.de-Serverteam
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Affero General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Affero General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package de.steamwar.fightsystem.ai.chaos.gears;
|
||||||
|
|
||||||
|
import de.steamwar.fightsystem.ai.chaos.Cannon;
|
||||||
|
import org.bukkit.util.Vector;
|
||||||
|
|
||||||
|
public class Gear {
|
||||||
|
|
||||||
|
private final Cannon[] cannons;
|
||||||
|
private final Vector bridge;
|
||||||
|
private final Vector[] prepareButtons;
|
||||||
|
private final Vector mgButton;
|
||||||
|
private final int mgTime;
|
||||||
|
private final int schematicId;
|
||||||
|
|
||||||
|
protected Gear(Cannon[] cannons, Vector bridge, Vector[] prepareButtons, Vector mgButton, int mgTime, int schematicId) {
|
||||||
|
this.cannons = cannons;
|
||||||
|
this.bridge = bridge;
|
||||||
|
this.prepareButtons = prepareButtons;
|
||||||
|
this.mgButton = mgButton;
|
||||||
|
this.mgTime = mgTime;
|
||||||
|
this.schematicId = schematicId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Cannon[] getCannons() {
|
||||||
|
return cannons;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Vector getBridge() {
|
||||||
|
return bridge;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Vector[] getPrepareButtons() {
|
||||||
|
return prepareButtons;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Vector getMgButton() {
|
||||||
|
return mgButton;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getMgTime() {
|
||||||
|
return mgTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getSchematicId() {
|
||||||
|
return schematicId;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,184 @@
|
|||||||
|
/*
|
||||||
|
* This file is a part of the SteamWar software.
|
||||||
|
*
|
||||||
|
* Copyright (C) 2023 SteamWar.de-Serverteam
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Affero General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Affero General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package de.steamwar.fightsystem.ai.chaos.gears;
|
||||||
|
|
||||||
|
import de.steamwar.fightsystem.ai.chaos.Cannon;
|
||||||
|
import org.bukkit.util.Vector;
|
||||||
|
|
||||||
|
public class TheUnderground {
|
||||||
|
|
||||||
|
public static final Vector[] DS_LEFT_TNT = new Vector[] {
|
||||||
|
new Vector(40, 24, 12),
|
||||||
|
new Vector(39, 24, 12),
|
||||||
|
new Vector(38, 23, 12),
|
||||||
|
new Vector(38, 24, 12),
|
||||||
|
new Vector(40, 23, 15),
|
||||||
|
new Vector(40, 23, 14),
|
||||||
|
new Vector(40, 24, 15),
|
||||||
|
new Vector(40, 24, 14),
|
||||||
|
new Vector(38, 23, 15),
|
||||||
|
new Vector(38, 23, 14),
|
||||||
|
new Vector(38, 24, 15),
|
||||||
|
new Vector(38, 24, 14),
|
||||||
|
new Vector(40, 23, 12),
|
||||||
|
};
|
||||||
|
public static final Vector DS_LEFT_BUTTON = new Vector(39, 25, 11);
|
||||||
|
public static final Vector DS_LEFT_LOAD = new Vector(39, 25, 13);
|
||||||
|
public static final Vector DS_LEFT_ESCAPE = new Vector(31, 26, 13);
|
||||||
|
public static final Cannon DS_LEFT = new Cannon("Downstäb Links", DS_LEFT_TNT, DS_LEFT_BUTTON, DS_LEFT_LOAD, DS_LEFT_ESCAPE);
|
||||||
|
|
||||||
|
public static final Vector[] DS_RIGHT_TNT = new Vector[] {
|
||||||
|
new Vector(12, 24, 12),
|
||||||
|
new Vector(11, 24, 12),
|
||||||
|
new Vector(10, 23, 12),
|
||||||
|
new Vector(10, 24, 12),
|
||||||
|
new Vector(10, 23, 15),
|
||||||
|
new Vector(10, 23, 14),
|
||||||
|
new Vector(10, 24, 15),
|
||||||
|
new Vector(10, 24, 14),
|
||||||
|
new Vector(12, 23, 14),
|
||||||
|
new Vector(12, 24, 14),
|
||||||
|
new Vector(12, 23, 15),
|
||||||
|
new Vector(12, 24, 15),
|
||||||
|
new Vector(12, 23, 12),
|
||||||
|
};
|
||||||
|
public static final Vector DS_RIGHT_BUTTON = new Vector(11, 25, 11);
|
||||||
|
public static final Vector DS_RIGHT_LOAD = new Vector(11, 25, 13);
|
||||||
|
public static final Vector DS_RIGHT_ESCAPE = new Vector(19, 26, 13);
|
||||||
|
public static final Cannon DS_RIGHT = new Cannon("Downstäb Rechts", DS_RIGHT_TNT, DS_RIGHT_BUTTON, DS_RIGHT_LOAD, DS_RIGHT_ESCAPE);
|
||||||
|
|
||||||
|
public static final Vector[] STATIC_LEFT_TNT = new Vector[] {
|
||||||
|
new Vector(37, 17, 15),
|
||||||
|
new Vector(37, 17, 14),
|
||||||
|
new Vector(37, 18, 16),
|
||||||
|
new Vector(37, 18, 15),
|
||||||
|
new Vector(37, 18, 14),
|
||||||
|
new Vector(36, 17, 16),
|
||||||
|
new Vector(36, 17, 15),
|
||||||
|
new Vector(36, 17, 14),
|
||||||
|
new Vector(36, 18, 16),
|
||||||
|
new Vector(36, 18, 15),
|
||||||
|
new Vector(36, 18, 14),
|
||||||
|
new Vector(37, 17, 16),
|
||||||
|
};
|
||||||
|
public static final Vector STATIC_LEFT_BUTTON = new Vector(38, 18, 11);
|
||||||
|
public static final Vector STATIC_LEFT_LOAD = new Vector(37, 17, 12);
|
||||||
|
public static final Vector STATIC_LEFT_ESCAPE = new Vector(30, 13, 9);
|
||||||
|
public static final Cannon STATIC_LEFT = new Cannon("Lupf Links", STATIC_LEFT_TNT, STATIC_LEFT_BUTTON, STATIC_LEFT_LOAD, STATIC_LEFT_ESCAPE);
|
||||||
|
|
||||||
|
public static final Vector[] STATIC_RIGHT_TNT = new Vector[] {
|
||||||
|
new Vector(14, 17, 15),
|
||||||
|
new Vector(14, 18, 16),
|
||||||
|
new Vector(14, 18, 15),
|
||||||
|
new Vector(14, 17, 14),
|
||||||
|
new Vector(14, 18, 14),
|
||||||
|
new Vector(13, 17, 16),
|
||||||
|
new Vector(13, 17, 15),
|
||||||
|
new Vector(13, 17, 14),
|
||||||
|
new Vector(13, 18, 16),
|
||||||
|
new Vector(13, 18, 15),
|
||||||
|
new Vector(13, 18, 14),
|
||||||
|
new Vector(14, 17, 16),
|
||||||
|
};
|
||||||
|
public static final Vector STATIC_RIGHT_BUTTON = new Vector(12, 18, 11);
|
||||||
|
public static final Vector STATIC_RIGHT_LOAD = new Vector(13, 17, 12);
|
||||||
|
public static final Vector STATIC_RIGHT_ESCAPE = new Vector(20, 13, 9);
|
||||||
|
public static final Cannon STATIC_RIGHT = new Cannon("Lupf Rechts", STATIC_RIGHT_TNT, STATIC_RIGHT_BUTTON, STATIC_RIGHT_LOAD, STATIC_RIGHT_ESCAPE);
|
||||||
|
|
||||||
|
public static final Vector[] AK_TNT = new Vector[] {
|
||||||
|
new Vector(10, 7, 17),
|
||||||
|
new Vector(10, 11, 17),
|
||||||
|
new Vector(10, 10, 17),
|
||||||
|
new Vector(10, 8, 17),
|
||||||
|
new Vector(10, 9, 17),
|
||||||
|
new Vector(10, 7, 15),
|
||||||
|
new Vector(11, 7, 15),
|
||||||
|
new Vector(12, 7, 15),
|
||||||
|
new Vector(10, 10, 15),
|
||||||
|
new Vector(11, 10, 15),
|
||||||
|
new Vector(12, 10, 15),
|
||||||
|
new Vector(12, 8, 15),
|
||||||
|
new Vector(12, 9, 15),
|
||||||
|
new Vector(11, 8, 15),
|
||||||
|
new Vector(11, 9, 15),
|
||||||
|
new Vector(10, 8, 15),
|
||||||
|
new Vector(10, 9, 15),
|
||||||
|
new Vector(10, 7, 19),
|
||||||
|
new Vector(11, 7, 19),
|
||||||
|
new Vector(12, 7, 19),
|
||||||
|
new Vector(12, 8, 19),
|
||||||
|
new Vector(11, 8, 19),
|
||||||
|
new Vector(10, 8, 19),
|
||||||
|
new Vector(10, 10, 19),
|
||||||
|
new Vector(11, 10, 19),
|
||||||
|
new Vector(12, 10, 19),
|
||||||
|
new Vector(12, 9, 19),
|
||||||
|
new Vector(11, 9, 19),
|
||||||
|
new Vector(10, 9, 19),
|
||||||
|
new Vector(10, 6, 17),
|
||||||
|
};
|
||||||
|
public static final Vector AK_BUTTON = new Vector(9, 9, 16);
|
||||||
|
public static final Vector AK_LOAD = new Vector(11, 8, 17);
|
||||||
|
public static final Cannon AK = new Cannon("Arschkratzer", AK_TNT, AK_BUTTON, AK_LOAD, null);
|
||||||
|
|
||||||
|
public static final Vector[] HA_RIGHT_TNT = new Vector[] {
|
||||||
|
new Vector(23, 5, 9),
|
||||||
|
new Vector(23, 6, 9),
|
||||||
|
new Vector(23, 7, 9),
|
||||||
|
new Vector(23, 8, 9),
|
||||||
|
};
|
||||||
|
|
||||||
|
public static final Vector[] HA_LEFT_TNT = new Vector[] {
|
||||||
|
new Vector(27, 5, 9),
|
||||||
|
new Vector(27, 6, 9),
|
||||||
|
new Vector(27, 7, 9),
|
||||||
|
new Vector(27, 8, 9),
|
||||||
|
};
|
||||||
|
|
||||||
|
public static final Vector HA_RIGHT_LOAD = new Vector(23, 8, 8);
|
||||||
|
public static final Vector HA_LEFT_LOAD = new Vector(27, 8, 8);
|
||||||
|
|
||||||
|
public static final Cannon HA_LEFT = new Cannon("Halbautomatik Links", HA_LEFT_TNT, null, HA_LEFT_LOAD, null);
|
||||||
|
public static final Cannon HA_RIGHT = new Cannon("Halbautomatik Rechts", HA_RIGHT_TNT, null, HA_RIGHT_LOAD, null);
|
||||||
|
|
||||||
|
public static final Vector BRIDGE_POS = new Vector(25, 14, 24);
|
||||||
|
public static final Vector BRIDGE_SHIELDS = new Vector(25, 15, 25);
|
||||||
|
public static final Vector BRIDGE_MG = new Vector(21, 15, 24);
|
||||||
|
|
||||||
|
public static final Gear THE_UNDERGROUND = new Gear(
|
||||||
|
new Cannon[] {
|
||||||
|
DS_LEFT,
|
||||||
|
DS_RIGHT,
|
||||||
|
STATIC_LEFT,
|
||||||
|
STATIC_RIGHT,
|
||||||
|
AK,
|
||||||
|
HA_LEFT,
|
||||||
|
HA_RIGHT,
|
||||||
|
//Cannon.AK,
|
||||||
|
},
|
||||||
|
BRIDGE_POS,
|
||||||
|
new Vector[] {
|
||||||
|
BRIDGE_SHIELDS
|
||||||
|
},
|
||||||
|
BRIDGE_MG,
|
||||||
|
21,
|
||||||
|
124667
|
||||||
|
);
|
||||||
|
}
|
@ -78,14 +78,12 @@ public class NavMesh implements Listener {
|
|||||||
});
|
});
|
||||||
floorBlock.forEach(this::checkNeighbouring);
|
floorBlock.forEach(this::checkNeighbouring);
|
||||||
System.out.println(System.currentTimeMillis() - time + " ms");
|
System.out.println(System.currentTimeMillis() - time + " ms");
|
||||||
/*
|
|
||||||
iterateWalkableBlocks((vector, ceilingOffset) -> {
|
iterateWalkableBlocks((vector, ceilingOffset) -> {
|
||||||
RArmorStand armorStand = new RArmorStand(entityServer, vector.toLocation(WORLD), RArmorStand.Size.MARKER);
|
RArmorStand armorStand = new RArmorStand(entityServer, vector.toLocation(WORLD), RArmorStand.Size.MARKER);
|
||||||
armorStand.setNoGravity(true);
|
armorStand.setNoGravity(true);
|
||||||
armorStand.setInvisible(true);
|
armorStand.setInvisible(true);
|
||||||
armorStand.setDisplayName("+" + (ceilingOffset == null ? "∞" : ceilingOffset));
|
armorStand.setDisplayName("+" + (ceilingOffset == null ? "∞" : ceilingOffset));
|
||||||
});
|
});
|
||||||
*/
|
|
||||||
}, 20);
|
}, 20);
|
||||||
});
|
});
|
||||||
new OneShotStateDependent(ArenaMode.All, FightState.Spectate, () -> {
|
new OneShotStateDependent(ArenaMode.All, FightState.Spectate, () -> {
|
||||||
|
0
gradlew
vendored
Ausführbare Datei → Normale Datei
0
gradlew
vendored
Ausführbare Datei → Normale Datei
In neuem Issue referenzieren
Einen Benutzer sperren