Browse Source

Handler created for RecvSummonsMsg

combat-2
MagicBot 8 months ago
parent
commit
093bc5e97e
  1. 100
      src/engine/gameManager/PowersManager.java
  2. 4
      src/engine/net/client/ClientMessagePump.java
  3. 2
      src/engine/net/client/Protocol.java
  4. 135
      src/engine/net/client/handlers/RecvSummonsMsgHandler.java

100
src/engine/gameManager/PowersManager.java

@ -18,7 +18,10 @@ import engine.job.AbstractJob; @@ -18,7 +18,10 @@ import engine.job.AbstractJob;
import engine.job.AbstractScheduleJob;
import engine.job.JobContainer;
import engine.job.JobScheduler;
import engine.jobs.*;
import engine.jobs.AbstractEffectJob;
import engine.jobs.FinishRecycleTimeJob;
import engine.jobs.UseItemJob;
import engine.jobs.UsePowerJob;
import engine.math.Vector3fImmutable;
import engine.net.ByteBufferWriter;
import engine.net.Dispatch;
@ -1240,101 +1243,6 @@ public enum PowersManager { @@ -1240,101 +1243,6 @@ public enum PowersManager {
return false;
}
public static void recvSummon(RecvSummonsMsg msg, ClientConnection origin) {
PlayerCharacter pc = SessionManager.getPlayerCharacter(origin);
if (pc == null)
return;
PlayerCharacter source = PlayerCharacter.getFromCache(msg.getSourceID());
if (source == null)
return;
long tooLate = pc.getSummoner(source.getObjectUUID());
if (tooLate < System.currentTimeMillis()) {
ChatManager.chatInfoError(pc, "You waited too long to " + (msg.accepted() ? "accept" : "decline") + " the summons.");
pc.removeSummoner(source.getObjectUUID());
return;
}
if (pc.getBonuses() != null && pc.getBonuses().getBool(ModType.BlockedPowerType, SourceType.SUMMON)) {
ErrorPopupMsg.sendErrorMsg(pc, "You have been blocked from receiving summons!");
ErrorPopupMsg.sendErrorMsg(source, "Target is blocked from receiving summons!");
pc.removeSummoner(source.getObjectUUID());
return;
}
pc.removeSummoner(source.getObjectUUID());
// Handle Accepting or Denying a summons.
// set timer based on summon type.
boolean wentThrough = false;
if (msg.accepted())
// summons accepted, let's move the player if within time
if (source.isAlive()) {
// //make sure summons handled in time
ConcurrentHashMap<String, JobContainer> timers = source.getTimers();
// if (timers == null || !timers.containsKey("SummonSend")) {
// ChatManager.chatInfoError(pc, "You waited too long to " + (msg.accepted() ? "accept" : "decline") + " the summons.");
// return;
// }
// // clear last summons accept timer
// timers.get("SummonSend").cancelJob();
//timers.remove("SummonSend");
// cancel any other summons waiting
timers = pc.getTimers();
if (timers != null && timers.containsKey("Summon"))
timers.get("Summon").cancelJob();
// get time to wait before summons goes through
BaseClass base = source.baseClass;
PromotionClass promo = source.getPromotionClass();
int duration;
//determine if in combat with another player
//comment out this block to disable combat timer
// if (lastAttacked < 60000) {
// if (pc.inSafeZone()) //player in safe zone, no need for combat timer
// combat = false;
// else if (source.inSafeZone()) //summoner in safe zone, apply combat timer
// combat = true;
// else if ((source.getLoc().distance2D(pc.getLoc())) > 6144f)
// combat = true; //more than 1.5x width of zone, not tactical summons
// }
if (promo != null && promo.getObjectUUID() == 2519)
duration = 10000; // Priest summons, 10 seconds
else if (base != null && base.getObjectUUID() == 2501)
duration = 15000; // Healer Summons, 15 seconds
else
duration = 45000; // Belgosh Summons, 45 seconds
// Teleport to summoners location
FinishSummonsJob fsj = new FinishSummonsJob(source, pc);
JobContainer jc = JobScheduler.getInstance().scheduleJob(fsj,
duration);
if (timers != null)
timers.put("Summon", jc);
wentThrough = true;
}
// Summons failed
if (!wentThrough)
// summons refused. Let's be nice and reset recycle timer
if (source != null) {
// Send summons refused Message
ErrorPopupMsg.sendErrorPopup(source, 29);
// recycle summons power
//finishRecycleTime(428523680, source, true);
}
}
public static void sendRecyclePower(int token, ClientConnection origin) {
RecyclePowerMsg recyclePowerMsg = new RecyclePowerMsg(token);

4
src/engine/net/client/ClientMessagePump.java

@ -10,7 +10,6 @@ @@ -10,7 +10,6 @@
package engine.net.client;
import engine.gameManager.ChatManager;
import engine.gameManager.PowersManager;
import engine.gameManager.SessionManager;
import engine.gameManager.TradeManager;
import engine.net.NetMsgHandler;
@ -123,9 +122,6 @@ public class ClientMessagePump implements NetMsgHandler { @@ -123,9 +122,6 @@ public class ClientMessagePump implements NetMsgHandler {
case ARCREQUESTTRADEBUSY:
TradeManager.invalidTradeRequest((InvalidTradeRequestMsg) msg);
break;
case ARCSUMMON:
PowersManager.recvSummon((RecvSummonsMsg) msg, origin);
break;
case CHANNELMUTE:
break;
case KEEPALIVESERVERCLIENT:

2
src/engine/net/client/Protocol.java

@ -44,7 +44,7 @@ public enum Protocol { @@ -44,7 +44,7 @@ public enum Protocol {
ARCREQUESTTRADEBUSY(0xD4BAB4DF, InvalidTradeRequestMsg.class, null), // Attempt trade with someone who is already trading
ARCSERVERSTATUS(0x87BA4462, null, null), //Update Server Status
ARCSIEGESPIRE(0x36A49BC6, ArcSiegeSpireMsg.class, ArcSiegeSpireMsgHandler.class), // Activate/Deactivate Spires
ARCSUMMON(0xFD816A0A, RecvSummonsMsg.class, null), // Suspect Recv Summons Request
ARCSUMMON(0xFD816A0A, RecvSummonsMsg.class, RecvSummonsMsgHandler.class), // Suspect Recv Summons Request
ARCTRACKINGLIST(0xC89CF08B, TrackWindowMsg.class, TrackWindowMsgHandler.class), //Request/Send Track window
ARCTRACKOBJECT(0x609B6BA2, TrackArrowMsg.class, null), //Send Track Arrow
ARCUNTRAINABILITY(0x548DBF83, RefineMsg.class, RefineMsgHandler.class), //Refine

135
src/engine/net/client/handlers/RecvSummonsMsgHandler.java

@ -0,0 +1,135 @@ @@ -0,0 +1,135 @@
// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ .
// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌·
// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀
// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌
// ▀▀ █▪▀▀▀ ▀ ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀ ▀ ▀ ▀▀ █▪ ▀▀▀
// Magicbane Emulator Project © 2013 - 2022
// www.magicbane.com
package engine.net.client.handlers;
import engine.Enum;
import engine.exception.MsgSendException;
import engine.gameManager.ChatManager;
import engine.job.JobContainer;
import engine.job.JobScheduler;
import engine.jobs.FinishSummonsJob;
import engine.net.client.ClientConnection;
import engine.net.client.msg.ClientNetMsg;
import engine.net.client.msg.ErrorPopupMsg;
import engine.net.client.msg.RecvSummonsMsg;
import engine.objects.BaseClass;
import engine.objects.PlayerCharacter;
import engine.objects.PromotionClass;
import java.util.concurrent.ConcurrentHashMap;
public class RecvSummonsMsgHandler extends AbstractClientMsgHandler {
public RecvSummonsMsgHandler() {
super(RecvSummonsMsg.class);
}
@Override
protected boolean _handleNetMsg(ClientNetMsg baseMsg, ClientConnection origin) throws MsgSendException {
PlayerCharacter playerCharacter = origin.getPlayerCharacter();
// Member variable declaration
RecvSummonsMsg msg;
// Member variable assignment
msg = (RecvSummonsMsg) baseMsg;
if (playerCharacter == null)
return true;
PlayerCharacter source = PlayerCharacter.getFromCache(msg.getSourceID());
if (source == null)
return true;
long tooLate = playerCharacter.getSummoner(source.getObjectUUID());
if (tooLate < System.currentTimeMillis()) {
ChatManager.chatInfoError(playerCharacter, "You waited too long to " + (msg.accepted() ? "accept" : "decline") + " the summons.");
playerCharacter.removeSummoner(source.getObjectUUID());
return true;
}
if (playerCharacter.getBonuses() != null && playerCharacter.getBonuses().getBool(Enum.ModType.BlockedPowerType, Enum.SourceType.SUMMON)) {
ErrorPopupMsg.sendErrorMsg(playerCharacter, "You have been blocked from receiving summons!");
ErrorPopupMsg.sendErrorMsg(source, "Target is blocked from receiving summons!");
playerCharacter.removeSummoner(source.getObjectUUID());
return true;
}
playerCharacter.removeSummoner(source.getObjectUUID());
// Handle Accepting or Denying a summons.
// set timer based on summon type.
boolean wentThrough = false;
if (msg.accepted()) // summons accepted, let's move the player if within time
if (source.isAlive()) {
//make sure summons handled in time
ConcurrentHashMap<String, JobContainer> timers;
timers = playerCharacter.getTimers();
if (timers != null && timers.containsKey("Summon"))
timers.get("Summon").cancelJob();
// get time to wait before summons goes through
BaseClass base = source.baseClass;
PromotionClass promo = source.getPromotionClass();
int duration;
//determine if in combat with another player
//comment out this block to disable combat timer
// if (lastAttacked < 60000) {
// if (pc.inSafeZone()) //player in safe zone, no need for combat timer
// combat = false;
// else if (source.inSafeZone()) //summoner in safe zone, apply combat timer
// combat = true;
// else if ((source.getLoc().distance2D(pc.getLoc())) > 6144f)
// combat = true; //more than 1.5x width of zone, not tactical summons
// }
if (promo != null && promo.getObjectUUID() == 2519)
duration = 10000; // Priest summons, 10 seconds
else if (base != null && base.getObjectUUID() == 2501)
duration = 15000; // Healer Summons, 15 seconds
else
duration = 45000; // Belgosh Summons, 45 seconds
// Teleport to summoners location
FinishSummonsJob fsj = new FinishSummonsJob(source, playerCharacter);
JobContainer jc = JobScheduler.getInstance().scheduleJob(fsj,
duration);
if (timers != null)
timers.put("Summon", jc);
wentThrough = true;
}
// Summons failed
if (!wentThrough) // summons refused. Let's be nice and reset recycle timer
{
// Send summons refused Message
ErrorPopupMsg.sendErrorPopup(source, 29);
// recycle summons power
//finishRecycleTime(428523680, source, true);
}
return true;
}
}
Loading…
Cancel
Save