forked from MagicBane/Server
Formation refactored to enum
This commit is contained in:
@@ -13,6 +13,7 @@ import engine.exception.MsgSendException;
|
||||
import engine.math.Bounds;
|
||||
import engine.math.Vector3f;
|
||||
import engine.math.Vector3fImmutable;
|
||||
import engine.mbEnums;
|
||||
import engine.mbEnums.DispatchChannel;
|
||||
import engine.mbEnums.GameObjectType;
|
||||
import engine.mbEnums.ModType;
|
||||
@@ -399,7 +400,7 @@ public enum MovementManager {
|
||||
|
||||
// All checks passed, let's move the player
|
||||
// First get the offset position
|
||||
Vector3f offset = Formation.getOffset(group.getFormation(), pos);
|
||||
Vector3f offset = mbEnums.FormationType.getOffset(group.getFormation(), pos);
|
||||
Vector3fImmutable destination = pc.getEndLoc();
|
||||
// offset forwards or backwards
|
||||
destination = destination.add(faceDir.mult(offset.z));
|
||||
|
||||
@@ -12,6 +12,7 @@ import engine.gameManager.ConfigManager;
|
||||
import engine.gameManager.PowersManager;
|
||||
import engine.gameManager.ZoneManager;
|
||||
import engine.math.Vector2f;
|
||||
import engine.math.Vector3f;
|
||||
import engine.math.Vector3fImmutable;
|
||||
import engine.objects.*;
|
||||
import engine.powers.EffectsBase;
|
||||
@@ -2938,4 +2939,90 @@ public class mbEnums {
|
||||
this.value = value;
|
||||
}
|
||||
}
|
||||
|
||||
public enum FormationType {
|
||||
COLUMN(new Vector3f[]{new Vector3f(0, 0, 0), // Group
|
||||
// Lead
|
||||
new Vector3f(6, 0, 0), // Player 1 offset
|
||||
new Vector3f(0, 0, -6), // Player 2 offset
|
||||
new Vector3f(6, 0, -6), // Player 3 offset
|
||||
new Vector3f(0, 0, -12), // Player 4 offset
|
||||
new Vector3f(6, 0, -12), // Player 5 offset
|
||||
new Vector3f(0, 0, -18), // Player 6 offset
|
||||
new Vector3f(6, 0, -18), // Player 7 offset
|
||||
new Vector3f(0, 0, -24), // Player 8 offset
|
||||
new Vector3f(6, 0, -24)}),
|
||||
LINE(new Vector3f[]{new Vector3f(0, 0, 0),
|
||||
new Vector3f(0, 0, -6), new Vector3f(0, 0, -12),
|
||||
new Vector3f(0, 0, -18), new Vector3f(0, 0, -24),
|
||||
new Vector3f(0, 0, -30), new Vector3f(0, 0, -36),
|
||||
new Vector3f(0, 0, -42), new Vector3f(0, 0, -48),
|
||||
new Vector3f(0, 0, -54)}),
|
||||
BOX(new Vector3f[]{new Vector3f(0, 0, 0),
|
||||
new Vector3f(-6, 0, 0), new Vector3f(6, 0, 0),
|
||||
new Vector3f(-6, 0, -6), new Vector3f(0, 0, -6),
|
||||
new Vector3f(6, 0, -6), new Vector3f(-6, 0, -12),
|
||||
new Vector3f(0, 0, -12), new Vector3f(5, 0, -12),
|
||||
new Vector3f(0, 0, -18)}),
|
||||
TRIANGLE(new Vector3f[]{new Vector3f(0, 0, 0),
|
||||
new Vector3f(-6, 0, -6), new Vector3f(6, 0, -6),
|
||||
new Vector3f(-12, 0, -12), new Vector3f(0, 0, -12),
|
||||
new Vector3f(12, 0, -12), new Vector3f(-18, 0, -18),
|
||||
new Vector3f(-6, 0, -18), new Vector3f(6, 0, -18),
|
||||
new Vector3f(18, 0, -18)}),
|
||||
CIRCLE(new Vector3f[]{new Vector3f(0, 0, 0),
|
||||
new Vector3f(-12, 0, -3), new Vector3f(12, 0, -3),
|
||||
new Vector3f(-18, 0, -12), new Vector3f(18, 0, -12),
|
||||
new Vector3f(-18, 0, -21), new Vector3f(18, 0, -21),
|
||||
new Vector3f(-12, 0, -30), new Vector3f(12, 0, -30),
|
||||
new Vector3f(0, 0, -33)}),
|
||||
RANKS(new Vector3f[]{new Vector3f(0, 0, 0),
|
||||
new Vector3f(0, 0, -6), new Vector3f(-6, 0, 0),
|
||||
new Vector3f(-6, 0, -6), new Vector3f(6, 0, 0),
|
||||
new Vector3f(6, 0, -6), new Vector3f(-12, 0, 0),
|
||||
new Vector3f(-12, 0, -6), new Vector3f(12, 0, 0),
|
||||
new Vector3f(12, 0, -6)}),
|
||||
WEDGE(new Vector3f[]{new Vector3f(0, 0, 0),
|
||||
new Vector3f(6, 0, 0), new Vector3f(-6, 0, -6),
|
||||
new Vector3f(12, 0, -6), new Vector3f(-12, 0, -12),
|
||||
new Vector3f(18, 0, -12), new Vector3f(-18, 0, -18),
|
||||
new Vector3f(24, 0, -18), new Vector3f(-24, 0, -24),
|
||||
new Vector3f(30, 0, -24)}),
|
||||
INVERSEWEDGE(new Vector3f[]{new Vector3f(0, 0, 0),
|
||||
new Vector3f(6, 0, 0), new Vector3f(-6, 0, 6),
|
||||
new Vector3f(12, 0, 6), new Vector3f(-12, 0, 12),
|
||||
new Vector3f(18, 0, 12), new Vector3f(-18, 0, 18),
|
||||
new Vector3f(24, 0, 18), new Vector3f(-24, 0, 24),
|
||||
new Vector3f(30, 0, 24)}),
|
||||
T(new Vector3f[]{new Vector3f(0, 0, 0),
|
||||
new Vector3f(-6, 0, 0), new Vector3f(6, 0, 0),
|
||||
new Vector3f(0, 0, -6), new Vector3f(-12, 0, 0),
|
||||
new Vector3f(12, 0, 0), new Vector3f(0, 0, -12),
|
||||
new Vector3f(-18, 0, 0), new Vector3f(18, 0, 0),
|
||||
new Vector3f(0, 0, -18)});
|
||||
|
||||
public Vector3f[] offsets;
|
||||
|
||||
FormationType(Vector3f[] offsets) {
|
||||
|
||||
this.offsets = offsets;
|
||||
}
|
||||
|
||||
public static Vector3f getOffset(int formation, int position) {
|
||||
|
||||
FormationType formationType;
|
||||
|
||||
if (position > 9 || position < 0)
|
||||
position = 0;
|
||||
|
||||
formationType = FormationType.values()[formation];
|
||||
|
||||
if (formationType == null)
|
||||
formationType = FormationType.BOX;
|
||||
|
||||
return formationType.offsets[position];
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -217,7 +217,7 @@ public class MobAI {
|
||||
|
||||
if (mob.agentType.equals(mbEnums.AIAgentType.GUARDMINION)) {
|
||||
Mob captain = (Mob) mob.guardCaptain;
|
||||
mob.destination = captain.destination.add(Formation.getOffset(2, mob.guardCaptain.minions.indexOf(mob.getObjectUUID()) + 3));
|
||||
mob.destination = captain.destination.add(mbEnums.FormationType.getOffset(2, mob.guardCaptain.minions.indexOf(mob.getObjectUUID()) + 3));
|
||||
mob.lastPatrolPointIndex = captain.lastPatrolPointIndex;
|
||||
} else {
|
||||
mob.destination = mob.patrolPoints.get(mob.lastPatrolPointIndex);
|
||||
@@ -1187,7 +1187,7 @@ public class MobAI {
|
||||
|
||||
if (minion.despawned == false) {
|
||||
if (MovementUtilities.canMove(minion)) {
|
||||
Vector3f minionOffset = Formation.getOffset(2, mob.minions.indexOf(minionUUID) + 3);
|
||||
Vector3f minionOffset = mbEnums.FormationType.getOffset(2, mob.minions.indexOf(minionUUID) + 3);
|
||||
minion.updateLocation();
|
||||
Vector3fImmutable formationPatrolPoint = new Vector3fImmutable(mob.destination.x + minionOffset.x, mob.destination.y, mob.destination.z + minionOffset.z);
|
||||
MovementUtilities.aiMove(minion, formationPatrolPoint, true);
|
||||
|
||||
@@ -1,118 +0,0 @@
|
||||
// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ .
|
||||
// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌·
|
||||
// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀
|
||||
// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌
|
||||
// ▀▀ █▪▀▀▀ ▀ ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀ ▀ ▀ ▀▀ █▪ ▀▀▀
|
||||
// Magicbane Emulator Project © 2013 - 2022
|
||||
// www.magicbane.com
|
||||
|
||||
|
||||
package engine.objects;
|
||||
|
||||
import engine.math.Vector3f;
|
||||
|
||||
public class Formation {
|
||||
|
||||
// Offsets are as follows.
|
||||
// X determines left/right offset
|
||||
// Y not used
|
||||
// Z determines front/back offset
|
||||
|
||||
private static final Vector3f[] COLUMN = {new Vector3f(0, 0, 0), // Group
|
||||
// Lead
|
||||
new Vector3f(6, 0, 0), // Player 1 offset
|
||||
new Vector3f(0, 0, -6), // Player 2 offset
|
||||
new Vector3f(6, 0, -6), // Player 3 offset
|
||||
new Vector3f(0, 0, -12), // Player 4 offset
|
||||
new Vector3f(6, 0, -12), // Player 5 offset
|
||||
new Vector3f(0, 0, -18), // Player 6 offset
|
||||
new Vector3f(6, 0, -18), // Player 7 offset
|
||||
new Vector3f(0, 0, -24), // Player 8 offset
|
||||
new Vector3f(6, 0, -24)}; // Player 9 offset
|
||||
|
||||
private static final Vector3f[] LINE = {new Vector3f(0, 0, 0),
|
||||
new Vector3f(0, 0, -6), new Vector3f(0, 0, -12),
|
||||
new Vector3f(0, 0, -18), new Vector3f(0, 0, -24),
|
||||
new Vector3f(0, 0, -30), new Vector3f(0, 0, -36),
|
||||
new Vector3f(0, 0, -42), new Vector3f(0, 0, -48),
|
||||
new Vector3f(0, 0, -54)};
|
||||
|
||||
private static final Vector3f[] BOX = {new Vector3f(0, 0, 0),
|
||||
new Vector3f(-6, 0, 0), new Vector3f(6, 0, 0),
|
||||
new Vector3f(-6, 0, -6), new Vector3f(0, 0, -6),
|
||||
new Vector3f(6, 0, -6), new Vector3f(-6, 0, -12),
|
||||
new Vector3f(0, 0, -12), new Vector3f(5, 0, -12),
|
||||
new Vector3f(0, 0, -18)};
|
||||
|
||||
private static final Vector3f[] TRIANGLE = {new Vector3f(0, 0, 0),
|
||||
new Vector3f(-6, 0, -6), new Vector3f(6, 0, -6),
|
||||
new Vector3f(-12, 0, -12), new Vector3f(0, 0, -12),
|
||||
new Vector3f(12, 0, -12), new Vector3f(-18, 0, -18),
|
||||
new Vector3f(-6, 0, -18), new Vector3f(6, 0, -18),
|
||||
new Vector3f(18, 0, -18)};
|
||||
|
||||
private static final Vector3f[] CIRCLE = {new Vector3f(0, 0, 0),
|
||||
new Vector3f(-12, 0, -3), new Vector3f(12, 0, -3),
|
||||
new Vector3f(-18, 0, -12), new Vector3f(18, 0, -12),
|
||||
new Vector3f(-18, 0, -21), new Vector3f(18, 0, -21),
|
||||
new Vector3f(-12, 0, -30), new Vector3f(12, 0, -30),
|
||||
new Vector3f(0, 0, -33)};
|
||||
|
||||
private static final Vector3f[] RANKS = {new Vector3f(0, 0, 0),
|
||||
new Vector3f(0, 0, -6), new Vector3f(-6, 0, 0),
|
||||
new Vector3f(-6, 0, -6), new Vector3f(6, 0, 0),
|
||||
new Vector3f(6, 0, -6), new Vector3f(-12, 0, 0),
|
||||
new Vector3f(-12, 0, -6), new Vector3f(12, 0, 0),
|
||||
new Vector3f(12, 0, -6)};
|
||||
|
||||
private static final Vector3f[] WEDGE = {new Vector3f(0, 0, 0),
|
||||
new Vector3f(6, 0, 0), new Vector3f(-6, 0, -6),
|
||||
new Vector3f(12, 0, -6), new Vector3f(-12, 0, -12),
|
||||
new Vector3f(18, 0, -12), new Vector3f(-18, 0, -18),
|
||||
new Vector3f(24, 0, -18), new Vector3f(-24, 0, -24),
|
||||
new Vector3f(30, 0, -24)};
|
||||
|
||||
private static final Vector3f[] INVERSEWEDGE = {new Vector3f(0, 0, 0),
|
||||
new Vector3f(6, 0, 0), new Vector3f(-6, 0, 6),
|
||||
new Vector3f(12, 0, 6), new Vector3f(-12, 0, 12),
|
||||
new Vector3f(18, 0, 12), new Vector3f(-18, 0, 18),
|
||||
new Vector3f(24, 0, 18), new Vector3f(-24, 0, 24),
|
||||
new Vector3f(30, 0, 24)};
|
||||
|
||||
private static final Vector3f[] T = {new Vector3f(0, 0, 0),
|
||||
new Vector3f(-6, 0, 0), new Vector3f(6, 0, 0),
|
||||
new Vector3f(0, 0, -6), new Vector3f(-12, 0, 0),
|
||||
new Vector3f(12, 0, 0), new Vector3f(0, 0, -12),
|
||||
new Vector3f(-18, 0, 0), new Vector3f(18, 0, 0),
|
||||
new Vector3f(0, 0, -18)};
|
||||
|
||||
public static Vector3f getOffset(int formation, int position) {
|
||||
if (position > 9 || position < 0) {
|
||||
// TODO log error here
|
||||
position = 0;
|
||||
}
|
||||
|
||||
switch (formation) {
|
||||
case 0:
|
||||
return Formation.COLUMN[position];
|
||||
case 1:
|
||||
return Formation.LINE[position];
|
||||
case 2:
|
||||
return Formation.BOX[position];
|
||||
case 3:
|
||||
return Formation.TRIANGLE[position];
|
||||
case 4:
|
||||
return Formation.CIRCLE[position];
|
||||
case 5:
|
||||
return Formation.RANKS[position];
|
||||
case 6:
|
||||
return Formation.WEDGE[position];
|
||||
case 7:
|
||||
return Formation.INVERSEWEDGE[position];
|
||||
case 9:
|
||||
return Formation.T[position];
|
||||
default: // default to box
|
||||
return Formation.BOX[position];
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user