Browse Source

Handler created for SendSummonsMsg

combat-2
MagicBot 8 months ago
parent
commit
f0ac342b1f
  1. 4
      src/engine/devcmd/cmds/SummonCmd.java
  2. 50
      src/engine/gameManager/PowersManager.java
  3. 5
      src/engine/net/client/ClientMessagePump.java
  4. 4
      src/engine/net/client/Protocol.java
  5. 90
      src/engine/net/client/handlers/SendSummonsMsgHandler.java
  6. 6
      src/engine/net/client/msg/RecvSummonsMsg.java
  7. 6
      src/engine/net/client/msg/SendSummonsMsg.java
  8. 4
      src/engine/powers/poweractions/SummonPowerAction.java

4
src/engine/devcmd/cmds/SummonCmd.java

@ -13,7 +13,7 @@ import engine.devcmd.AbstractDevCmd;
import engine.gameManager.SessionManager; import engine.gameManager.SessionManager;
import engine.gameManager.ZoneManager; import engine.gameManager.ZoneManager;
import engine.math.Vector3fImmutable; import engine.math.Vector3fImmutable;
import engine.net.client.msg.RecvSummonsRequestMsg; import engine.net.client.msg.RecvSummonsMsg;
import engine.objects.AbstractGameObject; import engine.objects.AbstractGameObject;
import engine.objects.PlayerCharacter; import engine.objects.PlayerCharacter;
import engine.objects.Zone; import engine.objects.Zone;
@ -41,7 +41,7 @@ public class SummonCmd extends AbstractDevCmd {
String location = "Somewhere"; String location = "Somewhere";
if (zone != null) if (zone != null)
location = zone.zoneName; location = zone.zoneName;
RecvSummonsRequestMsg rsrm = new RecvSummonsRequestMsg(pc.getObjectType().ordinal(), pc.getObjectUUID(), pc.getFirstName(), RecvSummonsMsg rsrm = new RecvSummonsMsg(pc.getObjectType().ordinal(), pc.getObjectUUID(), pc.getFirstName(),
location, false); location, false);
toSummon.getClientConnection().sendMsg(rsrm); toSummon.getClientConnection().sendMsg(rsrm);

50
src/engine/gameManager/PowersManager.java

@ -1240,53 +1240,7 @@ public enum PowersManager {
return false; return false;
} }
public static void summon(SendSummonsRequestMsg msg, ClientConnection origin) { public static void recvSummon(RecvSummonsMsg msg, ClientConnection origin) {
PlayerCharacter pc = SessionManager.getPlayerCharacter(
origin);
if (pc == null)
return;
PlayerCharacter target = SessionManager
.getPlayerCharacterByLowerCaseName(msg.getTargetName());
if (target == null || target.equals(pc) || target.isCombat()) {
if (target == null) // Player not found. Send not found message
ChatManager.chatInfoError(pc,
"Cannot find that player to summon.");
else if (target.isCombat())
ChatManager.chatInfoError(pc,
"Cannot summon player in combat.");
// else trying to summon self, just fail
// recycle summon
sendRecyclePower(msg.getPowerToken(), origin);
// TODO: client already subtracted 200 mana.. need to correct it
// end cast
PerformActionMsg pam = new PerformActionMsg(msg.getPowerToken(),
msg.getTrains(), msg.getSourceType(), msg.getSourceID(), 0,
0, 0f, 0f, 0f, 1, 0);
sendPowerMsg(pc, 2, pam);
return;
}
if (ConfigManager.MB_RULESET.getValue() == "LORE") {
if (pc.guild.getGuildType().equals(target.guild.getGuildType()) == false) {
ChatManager.chatInfoError(pc,
"Cannot summon player outside your charter.");
return;
}
}
PerformActionMsg pam = new PerformActionMsg(msg.getPowerToken(), msg
.getTrains(), msg.getSourceType(), msg.getSourceID(), target
.getObjectType().ordinal(), target.getObjectUUID(), 0f, 0f, 0f, 1, 0);
// Client removes 200 mana on summon use.. so don't send message to self
target.addSummoner(pc.getObjectUUID(), System.currentTimeMillis() + MBServerStatics.FOURTYFIVE_SECONDS);
usePower(pam, origin, false);
}
public static void recvSummon(RecvSummonsRequestMsg msg, ClientConnection origin) {
PlayerCharacter pc = SessionManager.getPlayerCharacter(origin); PlayerCharacter pc = SessionManager.getPlayerCharacter(origin);
if (pc == null) if (pc == null)
return; return;
@ -1381,7 +1335,7 @@ public enum PowersManager {
} }
} }
private static void sendRecyclePower(int token, ClientConnection origin) { public static void sendRecyclePower(int token, ClientConnection origin) {
RecyclePowerMsg recyclePowerMsg = new RecyclePowerMsg(token); RecyclePowerMsg recyclePowerMsg = new RecyclePowerMsg(token);
Dispatch dispatch = Dispatch.borrow(origin.getPlayerCharacter(), recyclePowerMsg); Dispatch dispatch = Dispatch.borrow(origin.getPlayerCharacter(), recyclePowerMsg);

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

@ -123,11 +123,8 @@ public class ClientMessagePump implements NetMsgHandler {
case ARCREQUESTTRADEBUSY: case ARCREQUESTTRADEBUSY:
TradeManager.invalidTradeRequest((InvalidTradeRequestMsg) msg); TradeManager.invalidTradeRequest((InvalidTradeRequestMsg) msg);
break; break;
case POWERTARGNAME:
PowersManager.summon((SendSummonsRequestMsg) msg, origin);
break;
case ARCSUMMON: case ARCSUMMON:
PowersManager.recvSummon((RecvSummonsRequestMsg) msg, origin); PowersManager.recvSummon((RecvSummonsMsg) msg, origin);
break; break;
case CHANNELMUTE: case CHANNELMUTE:
break; break;

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

@ -44,7 +44,7 @@ public enum Protocol {
ARCREQUESTTRADEBUSY(0xD4BAB4DF, InvalidTradeRequestMsg.class, null), // Attempt trade with someone who is already trading ARCREQUESTTRADEBUSY(0xD4BAB4DF, InvalidTradeRequestMsg.class, null), // Attempt trade with someone who is already trading
ARCSERVERSTATUS(0x87BA4462, null, null), //Update Server Status ARCSERVERSTATUS(0x87BA4462, null, null), //Update Server Status
ARCSIEGESPIRE(0x36A49BC6, ArcSiegeSpireMsg.class, ArcSiegeSpireMsgHandler.class), // Activate/Deactivate Spires ARCSIEGESPIRE(0x36A49BC6, ArcSiegeSpireMsg.class, ArcSiegeSpireMsgHandler.class), // Activate/Deactivate Spires
ARCSUMMON(0xFD816A0A, RecvSummonsRequestMsg.class, null), // Suspect Recv Summons Request ARCSUMMON(0xFD816A0A, RecvSummonsMsg.class, null), // Suspect Recv Summons Request
ARCTRACKINGLIST(0xC89CF08B, TrackWindowMsg.class, TrackWindowMsgHandler.class), //Request/Send Track window ARCTRACKINGLIST(0xC89CF08B, TrackWindowMsg.class, TrackWindowMsgHandler.class), //Request/Send Track window
ARCTRACKOBJECT(0x609B6BA2, TrackArrowMsg.class, null), //Send Track Arrow ARCTRACKOBJECT(0x609B6BA2, TrackArrowMsg.class, null), //Send Track Arrow
ARCUNTRAINABILITY(0x548DBF83, RefineMsg.class, RefineMsgHandler.class), //Refine ARCUNTRAINABILITY(0x548DBF83, RefineMsg.class, RefineMsgHandler.class), //Refine
@ -161,7 +161,7 @@ public enum Protocol {
POWERACTION(0xA0B27EEB, ApplyEffectMsg.class, null), // Apply Effect, add to effects icons POWERACTION(0xA0B27EEB, ApplyEffectMsg.class, null), // Apply Effect, add to effects icons
POWERACTIONDD(0xD43052F8, ModifyHealthMsg.class, null), //Modify Health/Mana/Stamina using power POWERACTIONDD(0xD43052F8, ModifyHealthMsg.class, null), //Modify Health/Mana/Stamina using power
POWERACTIONDDDIE(0xC27D446B, null, null), //Modify Health/Mana/Stamina using power and kill target POWERACTIONDDDIE(0xC27D446B, null, null), //Modify Health/Mana/Stamina using power and kill target
POWERTARGNAME(0x5A807CCE, SendSummonsRequestMsg.class, null), // Send Summons Request POWERTARGNAME(0x5A807CCE, SendSummonsMsg.class, SendSummonsMsgHandler.class), // Send Summons Request
RAISEATTR(0x5EEB65E0, ModifyStatMsg.class, ModifyStatMsgHandler.class), // Modify Stat RAISEATTR(0x5EEB65E0, ModifyStatMsg.class, ModifyStatMsgHandler.class), // Modify Stat
RANDOM(0xAC5D0135, RandomMsg.class, RandomMsgHandler.class), //RequestSend random roll RANDOM(0xAC5D0135, RandomMsg.class, RandomMsgHandler.class), //RequestSend random roll
READYTOENTER(0x490E4FE0, EnterWorldReceivedMsg.class, null), //Client Ack Receive Enter World READYTOENTER(0x490E4FE0, EnterWorldReceivedMsg.class, null), //Client Ack Receive Enter World

90
src/engine/net/client/handlers/SendSummonsMsgHandler.java

@ -0,0 +1,90 @@
// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ .
// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌·
// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀
// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌
// ▀▀ █▪▀▀▀ ▀ ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀ ▀ ▀ ▀▀ █▪ ▀▀▀
// Magicbane Emulator Project © 2013 - 2022
// www.magicbane.com
package engine.net.client.handlers;
import engine.exception.MsgSendException;
import engine.gameManager.ChatManager;
import engine.gameManager.ConfigManager;
import engine.gameManager.SessionManager;
import engine.net.client.ClientConnection;
import engine.net.client.msg.ClientNetMsg;
import engine.net.client.msg.PerformActionMsg;
import engine.net.client.msg.SendSummonsMsg;
import engine.objects.PlayerCharacter;
import engine.server.MBServerStatics;
import static engine.gameManager.PowersManager.*;
public class SendSummonsMsgHandler extends AbstractClientMsgHandler {
public SendSummonsMsgHandler() {
super(SendSummonsMsg.class);
}
@Override
protected boolean _handleNetMsg(ClientNetMsg baseMsg, ClientConnection origin) throws MsgSendException {
PlayerCharacter playerCharacter = origin.getPlayerCharacter();
// Member variable declaration
SendSummonsMsg msg;
// Member variable assignment
msg = (SendSummonsMsg) baseMsg;
if (playerCharacter == null)
return true;
PlayerCharacter target = SessionManager
.getPlayerCharacterByLowerCaseName(msg.getTargetName());
if (target == null || target.equals(playerCharacter) || target.isCombat()) {
if (target == null) // Player not found. Send not found message
ChatManager.chatInfoError(playerCharacter,
"Cannot find that player to summon.");
else if (target.isCombat())
ChatManager.chatInfoError(playerCharacter,
"Cannot summon player in combat.");
// else trying to summon self, just fail
// recycle summon
sendRecyclePower(msg.getPowerToken(), origin);
// TODO: client already subtracted 200 mana.. need to correct it
// end cast
PerformActionMsg pam = new PerformActionMsg(msg.getPowerToken(),
msg.getTrains(), msg.getSourceType(), msg.getSourceID(), 0,
0, 0f, 0f, 0f, 1, 0);
sendPowerMsg(playerCharacter, 2, pam);
return true;
}
if (ConfigManager.MB_RULESET.getValue() == "LORE") {
if (playerCharacter.guild.getGuildType().equals(target.guild.getGuildType()) == false) {
ChatManager.chatInfoError(playerCharacter,
"Cannot summon player outside your charter.");
return true;
}
}
PerformActionMsg pam = new PerformActionMsg(msg.getPowerToken(), msg
.getTrains(), msg.getSourceType(), msg.getSourceID(), target
.getObjectType().ordinal(), target.getObjectUUID(), 0f, 0f, 0f, 1, 0);
// Client removes 200 mana on summon use.. so don't send message to self
target.addSummoner(playerCharacter.getObjectUUID(), System.currentTimeMillis() + MBServerStatics.FOURTYFIVE_SECONDS);
usePower(pam, origin, false);
return true;
}
}

6
src/engine/net/client/msg/RecvSummonsRequestMsg.java → src/engine/net/client/msg/RecvSummonsMsg.java

@ -15,7 +15,7 @@ import engine.net.ByteBufferReader;
import engine.net.ByteBufferWriter; import engine.net.ByteBufferWriter;
import engine.net.client.Protocol; import engine.net.client.Protocol;
public class RecvSummonsRequestMsg extends ClientNetMsg { public class RecvSummonsMsg extends ClientNetMsg {
private int sourceType; private int sourceType;
private int sourceID; private int sourceID;
@ -26,7 +26,7 @@ public class RecvSummonsRequestMsg extends ClientNetMsg {
/** /**
* This is the general purpose constructor. * This is the general purpose constructor.
*/ */
public RecvSummonsRequestMsg(int sourceType, int sourceID, String sourceName, String locationName, boolean accepted) { public RecvSummonsMsg(int sourceType, int sourceID, String sourceName, String locationName, boolean accepted) {
super(Protocol.ARCSUMMON); super(Protocol.ARCSUMMON);
this.sourceType = sourceType; this.sourceType = sourceType;
this.sourceID = sourceID; this.sourceID = sourceID;
@ -41,7 +41,7 @@ public class RecvSummonsRequestMsg extends ClientNetMsg {
* past the limit) then this constructor Throws that Exception to the * past the limit) then this constructor Throws that Exception to the
* caller. * caller.
*/ */
public RecvSummonsRequestMsg(AbstractConnection origin, ByteBufferReader reader) { public RecvSummonsMsg(AbstractConnection origin, ByteBufferReader reader) {
super(Protocol.ARCSUMMON, origin, reader); super(Protocol.ARCSUMMON, origin, reader);
} }

6
src/engine/net/client/msg/SendSummonsRequestMsg.java → src/engine/net/client/msg/SendSummonsMsg.java

@ -15,7 +15,7 @@ import engine.net.ByteBufferReader;
import engine.net.ByteBufferWriter; import engine.net.ByteBufferWriter;
import engine.net.client.Protocol; import engine.net.client.Protocol;
public class SendSummonsRequestMsg extends ClientNetMsg { public class SendSummonsMsg extends ClientNetMsg {
private int powerToken; private int powerToken;
private int sourceType; private int sourceType;
@ -26,7 +26,7 @@ public class SendSummonsRequestMsg extends ClientNetMsg {
/** /**
* This is the general purpose constructor. * This is the general purpose constructor.
*/ */
public SendSummonsRequestMsg() { public SendSummonsMsg() {
super(Protocol.POWERTARGNAME); super(Protocol.POWERTARGNAME);
} }
@ -36,7 +36,7 @@ public class SendSummonsRequestMsg extends ClientNetMsg {
* past the limit) then this constructor Throws that Exception to the * past the limit) then this constructor Throws that Exception to the
* caller. * caller.
*/ */
public SendSummonsRequestMsg(AbstractConnection origin, ByteBufferReader reader) { public SendSummonsMsg(AbstractConnection origin, ByteBufferReader reader) {
super(Protocol.POWERTARGNAME, origin, reader); super(Protocol.POWERTARGNAME, origin, reader);
} }

4
src/engine/powers/poweractions/SummonPowerAction.java

@ -16,7 +16,7 @@ import engine.math.Vector3fImmutable;
import engine.net.Dispatch; import engine.net.Dispatch;
import engine.net.DispatchMessage; import engine.net.DispatchMessage;
import engine.net.client.ClientConnection; import engine.net.client.ClientConnection;
import engine.net.client.msg.RecvSummonsRequestMsg; import engine.net.client.msg.RecvSummonsMsg;
import engine.objects.AbstractCharacter; import engine.objects.AbstractCharacter;
import engine.objects.AbstractWorldObject; import engine.objects.AbstractWorldObject;
import engine.objects.PlayerCharacter; import engine.objects.PlayerCharacter;
@ -57,7 +57,7 @@ public class SummonPowerAction extends AbstractPowerAction {
if (zone != null) if (zone != null)
location = zone.zoneName; location = zone.zoneName;
RecvSummonsRequestMsg rsrm = new RecvSummonsRequestMsg(source.getObjectType().ordinal(), source.getObjectUUID(), source.getFirstName(), RecvSummonsMsg rsrm = new RecvSummonsMsg(source.getObjectType().ordinal(), source.getObjectUUID(), source.getFirstName(),
location, false); location, false);
Dispatch dispatch = Dispatch.borrow(target, rsrm); Dispatch dispatch = Dispatch.borrow(target, rsrm);

Loading…
Cancel
Save