1
0
mirror of https://github.com/Rogiel/l2jserver2 synced 2025-12-10 09:22:49 +00:00

Open map implemented

Signed-off-by: Rogiel <rogiel@rogiel.com>
This commit is contained in:
2011-05-22 13:21:08 -03:00
parent 87ce7bb987
commit 0661b41cfd
31 changed files with 649 additions and 111 deletions

View File

@@ -37,6 +37,7 @@ import com.l2jserver.game.net.packet.client.CharacterRequestActionUse;
import com.l2jserver.game.net.packet.client.CharacterRequestBypass;
import com.l2jserver.game.net.packet.client.CharacterRequestInventoryPacket;
import com.l2jserver.game.net.packet.client.CharacterRequestMovePacket;
import com.l2jserver.game.net.packet.client.CharacterRequestOpenMap;
import com.l2jserver.game.net.packet.client.CharacterSelectPacket;
import com.l2jserver.game.net.packet.client.CharacterValidatePositionPacket;
import com.l2jserver.game.net.packet.client.EnterWorld;
@@ -178,6 +179,8 @@ public class Lineage2PacketReader extends OneToOneDecoder {
return CharacterAppearingPacket.class;
case CharacterRequestActionUse.OPCODE:
return CharacterRequestActionUse.class;
case CharacterRequestOpenMap.OPCODE:
return CharacterRequestOpenMap.class;
default:
logger.warn("Unknown opcode: 0x{}", Integer.toHexString(opcode));
break;

View File

@@ -29,6 +29,7 @@ import com.l2jserver.model.id.object.ActorID;
import com.l2jserver.model.id.object.provider.ObjectIDResolver;
import com.l2jserver.model.world.L2Character;
import com.l2jserver.model.world.capability.Actor;
import com.l2jserver.service.game.character.ActorIsNotAttackableServiceException;
import com.l2jserver.service.game.character.CannotSetTargetServiceException;
import com.l2jserver.service.game.character.CharacterService;
import com.l2jserver.util.dimensional.Coordinate;
@@ -129,6 +130,8 @@ public class CharacterAttackRequestPacket extends AbstractClientPacket {
charService.attack(character, actor);
} catch (CannotSetTargetServiceException e) {
conn.sendActionFailed();
} catch (ActorIsNotAttackableServiceException e) {
conn.sendActionFailed();
}
}
}

View File

@@ -23,6 +23,8 @@ import com.l2jserver.game.net.Lineage2Connection;
import com.l2jserver.game.net.packet.AbstractClientPacket;
import com.l2jserver.model.world.L2Character;
import com.l2jserver.model.world.L2Character.CharacterMoveType;
import com.l2jserver.service.game.character.CharacterAlreadyRunningServiceException;
import com.l2jserver.service.game.character.CharacterAlreadyWalkingServiceException;
import com.l2jserver.service.game.character.CharacterService;
/**
@@ -101,10 +103,16 @@ public class CharacterRequestActionUse extends AbstractClientPacket {
// TODO
break;
case WALK_RUN:
if (character.getMoveType() == CharacterMoveType.WALK) {
charService.run(character);
} else {
charService.walk(character);
try {
if (character.getMoveType() == CharacterMoveType.WALK) {
charService.run(character);
} else {
charService.walk(character);
}
} catch (CharacterAlreadyWalkingServiceException e) {
conn.sendActionFailed();
} catch (CharacterAlreadyRunningServiceException e) {
conn.sendActionFailed();
}
break;
}

View File

@@ -49,7 +49,26 @@ public class CharacterRequestMovePacket extends AbstractClientPacket {
// packet
private Coordinate target;
private Coordinate origin;
private int moveMovement;
@SuppressWarnings("unused")
private MovementType type;
public enum MovementType {
MOUSE(0x01), KEYBOARD(0x00);
public final int id;
MovementType(int id) {
this.id = id;
}
public static MovementType fromID(int id) {
for (final MovementType type : values()) {
if (type.id == id)
return type;
}
return null;
}
}
@Inject
public CharacterRequestMovePacket(CharacterService charService) {
@@ -65,7 +84,7 @@ public class CharacterRequestMovePacket extends AbstractClientPacket {
// seems that L2Walker does not send this
if (buffer.readableBytes() >= 4) {
// 0 keyboard, 1 mouse
this.moveMovement = buffer.readInt();
this.type = MovementType.fromID(buffer.readInt());
}
}

View File

@@ -0,0 +1,44 @@
/*
* This file is part of l2jserver <l2jserver.com>.
*
* l2jserver is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* l2jserver is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with l2jserver. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jserver.game.net.packet.client;
import org.jboss.netty.buffer.ChannelBuffer;
import com.l2jserver.game.net.Lineage2Connection;
import com.l2jserver.game.net.packet.AbstractClientPacket;
import com.l2jserver.game.net.packet.server.CharacterOpenMap;
/**
* Executes an bypass command
*
* @author <a href="http://www.rogiel.com">Rogiel</a>
*/
public class CharacterRequestOpenMap extends AbstractClientPacket {
/**
* The packet OPCODE
*/
public static final int OPCODE = 0x6c;
@Override
public void read(Lineage2Connection conn, ChannelBuffer buffer) {
}
@Override
public void process(final Lineage2Connection conn) {
conn.write(new CharacterOpenMap(1665));
}
}

View File

@@ -22,6 +22,7 @@ import com.l2jserver.game.net.Lineage2Connection;
import com.l2jserver.game.net.packet.AbstractServerPacket;
import com.l2jserver.game.net.packet.server.CharacterCreateFailPacket.Reason;
import com.l2jserver.model.world.L2Character;
import com.l2jserver.model.world.capability.Actor;
import com.l2jserver.service.game.chat.ChatMessageDestination;
import com.l2jserver.util.BufferUtils;
@@ -39,27 +40,51 @@ public class ActorChatMessagePacket extends AbstractServerPacket {
public static final int OPCODE = 0x4a;
/**
* The selected character
* The sending actor
*/
private final Actor actor;
/**
* The message destination
*/
private final L2Character character;
private ChatMessageDestination destination;
/**
* The message
*/
private String message = null;
/**
* The message ID
*/
private int messageID = 0;
public ActorChatMessagePacket(L2Character character,
public ActorChatMessagePacket(Actor character,
ChatMessageDestination destination, String message) {
super(OPCODE);
this.character = character;
this.actor = character;
this.destination = destination;
this.message = message;
}
public ActorChatMessagePacket(Actor actor,
ChatMessageDestination destination, int messageID) {
super(OPCODE);
this.actor = actor;
this.destination = destination;
this.messageID = messageID;
}
@Override
public void write(Lineage2Connection conn, ChannelBuffer buffer) {
buffer.writeInt(character.getID().getID());
buffer.writeInt(actor.getID().getID());
buffer.writeInt(destination.id);
BufferUtils.writeString(buffer, character.getName()); // TODO can be
// char id!
BufferUtils.writeString(buffer, message); // TODO can be msg id
if (actor instanceof L2Character) {
BufferUtils.writeString(buffer, ((L2Character) actor).getName());
} else {
buffer.writeInt(actor.getID().getID());
}
if (message != null) {
BufferUtils.writeString(buffer, message);
} else {
buffer.writeInt(messageID);
}
}
}

View File

@@ -0,0 +1,50 @@
/*
* This file is part of l2jserver <l2jserver.com>.
*
* l2jserver is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* l2jserver is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with l2jserver. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jserver.game.net.packet.server;
import org.jboss.netty.buffer.ChannelBuffer;
import com.l2jserver.game.net.Lineage2Connection;
import com.l2jserver.game.net.packet.AbstractServerPacket;
/**
* An packet informing that the character was created with success.
*
* @author <a href="http://www.rogiel.com">Rogiel</a>
*/
public class CharacterOpenMap extends AbstractServerPacket {
/**
* The packet OPCODE
*/
public static final int OPCODE = 0xa3;
/**
* The map ID
*/
private final int mapID;
public CharacterOpenMap(int mapID) {
super(OPCODE);
this.mapID = mapID;
}
@Override
public void write(Lineage2Connection conn, ChannelBuffer buffer) {
buffer.writeInt(mapID);
buffer.writeByte(0x00); // seven signs period
}
}