From bf87894f8c494c6e09351fd1cb0e4e9cd77c8b0d Mon Sep 17 00:00:00 2001 From: MagicBot Date: Sat, 4 Jun 2022 13:30:35 -0400 Subject: [PATCH] Removed flight job bonus code. --- src/engine/gameManager/MovementManager.java | 94 +-------------------- src/engine/jobs/FlightJob.java | 40 --------- 2 files changed, 4 insertions(+), 130 deletions(-) delete mode 100644 src/engine/jobs/FlightJob.java diff --git a/src/engine/gameManager/MovementManager.java b/src/engine/gameManager/MovementManager.java index 28440b24..eafc4192 100644 --- a/src/engine/gameManager/MovementManager.java +++ b/src/engine/gameManager/MovementManager.java @@ -18,7 +18,6 @@ import engine.exception.MsgSendException; import engine.job.JobContainer; import engine.job.JobScheduler; import engine.jobs.ChangeAltitudeJob; -import engine.jobs.FlightJob; import engine.math.Bounds; import engine.math.Vector3f; import engine.math.Vector3fImmutable; @@ -339,61 +338,7 @@ public enum MovementManager { } - //Update for when the character is in flight - public static void updateFlight(PlayerCharacter pc, ChangeAltitudeMsg msg, int duration) { - if (pc == null) - return; - - // clear flight timer job as we are about to update stuff and submit a new job - pc.clearTimer(flightTimerJobName); - - if (!pc.isActive()) { - pc.setAltitude(0); - pc.setDesiredAltitude(0); - pc.setTakeOffTime(0); - return; - } - - // Check to see if we are mid height change - JobContainer cjc = pc.getTimers().get(changeAltitudeTimerJobName); - if (cjc != null) { - addFlightTimer(pc, msg, MBServerStatics.FLY_FREQUENCY_MS); - return; - } - - // Altitude is zero, do nothing - if (pc.getAltitude() < 1) - return; - //make sure player is still allowed to fly - boolean canFly = false; - PlayerBonuses bonus = pc.getBonuses(); - - if (bonus != null && !bonus.getBool(ModType.NoMod, SourceType.Fly) && bonus.getBool(ModType.Fly, SourceType.None) && pc.isAlive()) - canFly = true; - - // if stam less that 2 - time to force a landing - if (pc.getStamina() < 10f || !canFly) { - PlayerCharacter.GroundPlayer(pc); - // dont call stop movement here as we want to - // preserve endloc - //pc.stopMovement(); - // sync world location - pc.setLoc(pc.getLoc()); - // force a landing - msg.setStartAlt(pc.getAltitude()); - msg.setTargetAlt(0); - msg.setAmountToMove(pc.getAltitude()); - msg.setUp(false); - DispatchMessage.dispatchMsgToInterestArea(pc, msg, DispatchChannel.PRIMARY, MBServerStatics.CHARACTER_LOAD_RANGE, true, false); - MovementManager.addChangeAltitudeTimer(pc, msg.getStartAlt(), msg.getTargetAlt(), (int) (MBServerStatics.HEIGHT_CHANGE_TIMER_MS * pc.getAltitude())); - pc.setAltitude(msg.getStartAlt() - 10); - - } else //Add a new flight timer to check stam / force land - if (pc.getAltitude() > 0) - addFlightTimer(pc, msg, MBServerStatics.FLY_FREQUENCY_MS); - - } public static void finishChangeAltitude(AbstractCharacter ac, float targetAlt) { @@ -529,27 +474,6 @@ public enum MovementManager { member.setEndLoc(destination); } } - - //Getting rid of flgith timer. - - public static void addFlightTimer(PlayerCharacter pc, ChangeAltitudeMsg msg, int duration) { - if (pc == null || pc.getTimers() == null) - return; - if (!pc.getTimers().containsKey(flightTimerJobName)) { - FlightJob ftj = new FlightJob(pc, msg, duration); - JobContainer jc = JobScheduler.getInstance().scheduleJob(ftj, duration); - pc.getTimers().put(flightTimerJobName, jc); - } - } - - public static void addChangeAltitudeTimer(PlayerCharacter pc, float startAlt, float targetAlt, int duration) { - if (pc == null || pc.getTimers() == null) - return; - ChangeAltitudeJob catj = new ChangeAltitudeJob(pc, startAlt, targetAlt); - JobContainer jc = JobScheduler.getInstance().scheduleJob(catj, duration); - pc.getTimers().put(changeAltitudeTimerJobName, jc); - } - public static void translocate(AbstractCharacter teleporter, Vector3fImmutable targetLoc, Regions region) { @@ -557,15 +481,10 @@ public enum MovementManager { if (targetLoc == null) return; - Vector3fImmutable oldLoc = new Vector3fImmutable(teleporter.getLoc()); - - + teleporter.stopMovement(targetLoc); - teleporter.setRegion(region); - - //mobs ignore region sets for now. if (teleporter.getObjectType().equals(GameObjectType.Mob)){ @@ -588,17 +507,11 @@ public enum MovementManager { public static void translocateToObject(AbstractCharacter teleporter, AbstractWorldObject worldObject) { - - Vector3fImmutable targetLoc = teleporter.getLoc(); Vector3fImmutable oldLoc = new Vector3fImmutable(teleporter.getLoc()); - teleporter.stopMovement(teleporter.getLoc()); - - - - + teleporter.stopMovement(teleporter.getLoc()); //mobs ignore region sets for now. if (teleporter.getObjectType().equals(GameObjectType.Mob)){ @@ -609,6 +522,7 @@ public enum MovementManager { DispatchMessage.dispatchMsgToInterestArea(oldLoc, teleporter, msg, DispatchChannel.PRIMARY, MBServerStatics.CHARACTER_LOAD_RANGE, false, false); return; } + boolean collide = false; int maxFloor = -1; int buildingID = 0; @@ -619,6 +533,7 @@ public enum MovementManager { if (collide) break; } + if (!collide) { teleporter.setInBuildingID(0); teleporter.setInBuilding(-1); @@ -633,7 +548,6 @@ public enum MovementManager { } } - TeleportToPointMsg msg = new TeleportToPointMsg(teleporter, targetLoc.getX(), targetLoc.getY(), targetLoc.getZ(), 0, -1, -1); //we shouldnt need to send teleport message to new area, as loadjob should pick it up. // DispatchMessage.dispatchMsgToInterestArea(teleporter, msg, DispatchChannel.PRIMARY, MBServerStatics.CHARACTER_LOAD_RANGE, true, false); diff --git a/src/engine/jobs/FlightJob.java b/src/engine/jobs/FlightJob.java deleted file mode 100644 index 1bd9366c..00000000 --- a/src/engine/jobs/FlightJob.java +++ /dev/null @@ -1,40 +0,0 @@ -// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ . -// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌· -// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀ -// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌ -// ▀▀ █▪▀▀▀ ▀ ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀ ▀ ▀ ▀▀ █▪ ▀▀▀ -// Magicbane Emulator Project © 2013 - 2022 -// www.magicbane.com - - -package engine.jobs; - -import engine.gameManager.MovementManager; -import engine.job.AbstractScheduleJob; -import engine.net.client.msg.ChangeAltitudeMsg; -import engine.objects.PlayerCharacter; - -public class FlightJob extends AbstractScheduleJob { - - private final PlayerCharacter pc; - private final ChangeAltitudeMsg msg; - private final int duration; - - public FlightJob(PlayerCharacter pc, ChangeAltitudeMsg msg, int duration) { - super(); - this.msg = msg; - this.duration = duration; - this.pc = pc; - } - - @Override - protected void doJob() { - if (this.pc != null && this.msg != null) - MovementManager.updateFlight(pc, msg, duration); - } - - @Override - protected void _cancelJob() { - } - -}