Merge remote-tracking branch 'origin/flight-fix-cleanup' into release-1.3
This commit is contained in:
@@ -18,7 +18,6 @@ import engine.exception.MsgSendException;
|
|||||||
import engine.job.JobContainer;
|
import engine.job.JobContainer;
|
||||||
import engine.job.JobScheduler;
|
import engine.job.JobScheduler;
|
||||||
import engine.jobs.ChangeAltitudeJob;
|
import engine.jobs.ChangeAltitudeJob;
|
||||||
import engine.jobs.FlightJob;
|
|
||||||
import engine.math.Bounds;
|
import engine.math.Bounds;
|
||||||
import engine.math.Vector3f;
|
import engine.math.Vector3f;
|
||||||
import engine.math.Vector3fImmutable;
|
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) {
|
|
||||||
|
|
||||||
// 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) {
|
public static void finishChangeAltitude(AbstractCharacter ac, float targetAlt) {
|
||||||
|
|
||||||
@@ -530,43 +475,17 @@ public enum MovementManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//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) {
|
public static void translocate(AbstractCharacter teleporter, Vector3fImmutable targetLoc, Regions region) {
|
||||||
|
|
||||||
|
|
||||||
if (targetLoc == null)
|
if (targetLoc == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
|
||||||
Vector3fImmutable oldLoc = new Vector3fImmutable(teleporter.getLoc());
|
Vector3fImmutable oldLoc = new Vector3fImmutable(teleporter.getLoc());
|
||||||
|
|
||||||
|
|
||||||
teleporter.stopMovement(targetLoc);
|
teleporter.stopMovement(targetLoc);
|
||||||
|
|
||||||
teleporter.setRegion(region);
|
teleporter.setRegion(region);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//mobs ignore region sets for now.
|
//mobs ignore region sets for now.
|
||||||
if (teleporter.getObjectType().equals(GameObjectType.Mob)){
|
if (teleporter.getObjectType().equals(GameObjectType.Mob)){
|
||||||
teleporter.setInBuildingID(0);
|
teleporter.setInBuildingID(0);
|
||||||
@@ -588,17 +507,11 @@ public enum MovementManager {
|
|||||||
|
|
||||||
public static void translocateToObject(AbstractCharacter teleporter, AbstractWorldObject worldObject) {
|
public static void translocateToObject(AbstractCharacter teleporter, AbstractWorldObject worldObject) {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Vector3fImmutable targetLoc = teleporter.getLoc();
|
Vector3fImmutable targetLoc = teleporter.getLoc();
|
||||||
|
|
||||||
Vector3fImmutable oldLoc = new Vector3fImmutable(teleporter.getLoc());
|
Vector3fImmutable oldLoc = new Vector3fImmutable(teleporter.getLoc());
|
||||||
|
|
||||||
teleporter.stopMovement(teleporter.getLoc());
|
teleporter.stopMovement(teleporter.getLoc());
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//mobs ignore region sets for now.
|
//mobs ignore region sets for now.
|
||||||
if (teleporter.getObjectType().equals(GameObjectType.Mob)){
|
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);
|
DispatchMessage.dispatchMsgToInterestArea(oldLoc, teleporter, msg, DispatchChannel.PRIMARY, MBServerStatics.CHARACTER_LOAD_RANGE, false, false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean collide = false;
|
boolean collide = false;
|
||||||
int maxFloor = -1;
|
int maxFloor = -1;
|
||||||
int buildingID = 0;
|
int buildingID = 0;
|
||||||
@@ -619,6 +533,7 @@ public enum MovementManager {
|
|||||||
if (collide)
|
if (collide)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!collide) {
|
if (!collide) {
|
||||||
teleporter.setInBuildingID(0);
|
teleporter.setInBuildingID(0);
|
||||||
teleporter.setInBuilding(-1);
|
teleporter.setInBuilding(-1);
|
||||||
@@ -633,7 +548,6 @@ public enum MovementManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
TeleportToPointMsg msg = new TeleportToPointMsg(teleporter, targetLoc.getX(), targetLoc.getY(), targetLoc.getZ(), 0, -1, -1);
|
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.
|
//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);
|
// DispatchMessage.dispatchMsgToInterestArea(teleporter, msg, DispatchChannel.PRIMARY, MBServerStatics.CHARACTER_LOAD_RANGE, true, false);
|
||||||
|
|||||||
@@ -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() {
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -4781,8 +4781,11 @@ public void dismissNecroPets() {
|
|||||||
}finally{
|
}finally{
|
||||||
this.updateLock.writeLock().unlock();
|
this.updateLock.writeLock().unlock();
|
||||||
}
|
}
|
||||||
}
|
//temp removal
|
||||||
|
if(AbstractCharacter.CanFly(this) == false && this.altitude > 0)
|
||||||
|
GroundPlayer(this);
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@Override
|
@Override
|
||||||
public void updateFlight() {
|
public void updateFlight() {
|
||||||
|
|||||||
@@ -76,75 +76,108 @@ public abstract class AbstractPowerAction {
|
|||||||
int token = DbManager.hasher.SBStringHash(IDString);
|
int token = DbManager.hasher.SBStringHash(IDString);
|
||||||
//cache token, used for applying effects.
|
//cache token, used for applying effects.
|
||||||
PowersManager.ActionTokenByIDString.put(IDString, token);
|
PowersManager.ActionTokenByIDString.put(IDString, token);
|
||||||
if (type.equals("ApplyEffect"))
|
apa = null;
|
||||||
apa = new ApplyEffectPowerAction(rs, effects);
|
switch (type)
|
||||||
else if (type.equals("ApplyEffects"))
|
{
|
||||||
apa = new ApplyEffectsPowerAction(rs, effects);
|
default:
|
||||||
else if (type.equals("DeferredPower"))
|
Logger.error("valid type not found for poweraction of ID" + rs.getInt("ID"));
|
||||||
apa = new DeferredPowerPowerAction(rs, effects);
|
break;
|
||||||
else if (type.equals("DamageOverTime"))
|
case "ApplyEffect":
|
||||||
apa = new DamageOverTimePowerAction(rs, effects);
|
apa = new ApplyEffectPowerAction(rs, effects);
|
||||||
else if (type.equals("Peek"))
|
break;
|
||||||
apa = new PeekPowerAction(rs);
|
case "ApplyEffects":
|
||||||
else if (type.equals("Charm"))
|
apa = new ApplyEffectsPowerAction(rs, effects);
|
||||||
apa = new CharmPowerAction(rs);
|
break;
|
||||||
else if (type.equals("Fear"))
|
case "DeferredPower":
|
||||||
apa = new FearPowerAction(rs);
|
apa = new DeferredPowerPowerAction(rs, effects);
|
||||||
else if (type.equals("Confusion"))
|
break;
|
||||||
apa = new ConfusionPowerAction(rs);
|
case "DamageOverTime":
|
||||||
else if (type.equals("RemoveEffect"))
|
apa = new DamageOverTimePowerAction(rs, effects);
|
||||||
apa = new RemoveEffectPowerAction(rs);
|
break;
|
||||||
else if (type.equals("Track"))
|
case "Peek":
|
||||||
apa = new TrackPowerAction(rs, effects);
|
apa = new PeekPowerAction(rs);
|
||||||
else if (type.equals("DirectDamage"))
|
break;
|
||||||
apa = new DirectDamagePowerAction(rs, effects);
|
case "Charm":
|
||||||
else if (type.equals("Transform"))
|
apa = new CharmPowerAction(rs);
|
||||||
apa = new TransformPowerAction(rs, effects);
|
break;
|
||||||
else if (type.equals("CreateMob"))
|
case "Fear":
|
||||||
apa = new CreateMobPowerAction(rs);
|
apa = new FearPowerAction(rs);
|
||||||
else if (type.equals("Invis"))
|
break;
|
||||||
apa = new InvisPowerAction(rs, effects);
|
case "Confusion":
|
||||||
else if (type.equals("ClearNearbyAggro"))
|
apa = new ConfusionPowerAction(rs);
|
||||||
apa = new ClearNearbyAggroPowerAction(rs);
|
break;
|
||||||
else if (type.equals("MobRecall"))
|
case "RemoveEffect":
|
||||||
apa = new MobRecallPowerAction(rs);
|
apa = new RemoveEffectPowerAction(rs);
|
||||||
else if (type.equals("SetItemFlag"))
|
break;
|
||||||
apa = new SetItemFlagPowerAction(rs);
|
case "Track":
|
||||||
else if (type.equals("SimpleDamage"))
|
apa = new TrackPowerAction(rs, effects);
|
||||||
apa = new SimpleDamagePowerAction(rs);
|
break;
|
||||||
else if (type.equals("TransferStatOT"))
|
case "DirectDamage":
|
||||||
apa = new TransferStatOTPowerAction(rs, effects);
|
apa = new DirectDamagePowerAction(rs, effects);
|
||||||
else if (type.equals("TransferStat"))
|
break;
|
||||||
apa = new TransferStatPowerAction(rs, effects);
|
case "Transform":
|
||||||
else if (type.equals("Teleport"))
|
apa = new TransformPowerAction(rs, effects);
|
||||||
apa = new TeleportPowerAction(rs);
|
break;
|
||||||
else if (type.equals("TreeChoke"))
|
case "CreateMob":
|
||||||
apa = new TreeChokePowerAction(rs);
|
apa = new CreateMobPowerAction(rs);
|
||||||
else if (type.equals("Block"))
|
break;
|
||||||
apa = new BlockPowerAction(rs);
|
case "Invis":
|
||||||
else if (type.equals("Resurrect"))
|
apa = new InvisPowerAction(rs, effects);
|
||||||
apa = new ResurrectPowerAction(rs);
|
break;
|
||||||
else if (type.equals("ClearAggro"))
|
case "ClearNearbyAggro":
|
||||||
apa = new ClearAggroPowerAction(rs);
|
apa = new ClearNearbyAggroPowerAction(rs);
|
||||||
else if (type.equals("ClaimMine"))
|
break;
|
||||||
apa = new ClaimMinePowerAction(rs);
|
case "MobRecall":
|
||||||
else if (type.equals("Recall"))
|
apa = new MobRecallPowerAction(rs);
|
||||||
apa = new RecallPowerAction(rs);
|
break;
|
||||||
else if (type.equals("SpireDisable"))
|
case "SetItemFlag":
|
||||||
apa = new SpireDisablePowerAction(rs);
|
apa = new SetItemFlagPowerAction(rs);
|
||||||
else if (type.equals("Steal"))
|
break;
|
||||||
apa = new StealPowerAction(rs);
|
case "SimpleDamage":
|
||||||
else if (type.equals("Summon"))
|
apa = new SimpleDamagePowerAction(rs);
|
||||||
apa = new SummonPowerAction(rs);
|
break;
|
||||||
else if (type.equals("RunegateTeleport"))
|
case "TransferStatOT":
|
||||||
apa = new RunegateTeleportPowerAction(rs);
|
apa = new TransferStatOTPowerAction(rs, effects);
|
||||||
else if (type.equals("RunegateTeleport"))
|
break;
|
||||||
apa = new RunegateTeleportPowerAction(rs);
|
case "TransferStat":
|
||||||
else if (type.equals("OpenGate"))
|
apa = new TransferStatPowerAction(rs, effects);
|
||||||
apa = new OpenGatePowerAction(rs);
|
break;
|
||||||
else {
|
case "Teleport":
|
||||||
Logger.error("valid type not found for poweraction of ID" + rs.getInt("ID"));
|
apa = new TeleportPowerAction(rs);
|
||||||
continue;
|
break;
|
||||||
|
case "TreeChoke":
|
||||||
|
apa = new TreeChokePowerAction(rs);
|
||||||
|
break;
|
||||||
|
case "Block":
|
||||||
|
apa = new BlockPowerAction(rs);
|
||||||
|
break;
|
||||||
|
case "Resurrect":
|
||||||
|
apa = new ResurrectPowerAction(rs);
|
||||||
|
break;
|
||||||
|
case "ClearAggro":
|
||||||
|
apa = new ClearAggroPowerAction(rs);
|
||||||
|
break;
|
||||||
|
case "ClaimMine":
|
||||||
|
apa = new ClaimMinePowerAction(rs);
|
||||||
|
break;
|
||||||
|
case "Recall":
|
||||||
|
apa = new RecallPowerAction(rs);
|
||||||
|
break;
|
||||||
|
case "SpireDisable":
|
||||||
|
apa = new SpireDisablePowerAction(rs);
|
||||||
|
break;
|
||||||
|
case "Steal":
|
||||||
|
apa = new StealPowerAction(rs);
|
||||||
|
break;
|
||||||
|
case "Summon":
|
||||||
|
apa = new SummonPowerAction(rs);
|
||||||
|
break;
|
||||||
|
case "RunegateTeleport":
|
||||||
|
apa = new RunegateTeleportPowerAction(rs);
|
||||||
|
break;
|
||||||
|
case "OpenGate":
|
||||||
|
apa = new OpenGatePowerAction(rs);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
powerActions.put(IDString, apa);
|
powerActions.put(IDString, apa);
|
||||||
powerActionsByID.put(apa.UUID, apa);
|
powerActionsByID.put(apa.UUID, apa);
|
||||||
|
|||||||
Reference in New Issue
Block a user