mirror of
https://github.com/2006-Scape/apollo.git
synced 2026-07-07 16:49:12 +00:00
Format and cleanup.
This commit is contained in:
+3
-3
@@ -4,10 +4,10 @@
|
|||||||
<chain />
|
<chain />
|
||||||
</event>
|
</event>
|
||||||
<event>
|
<event>
|
||||||
<type>org.apollo.game.event.impl.CharacterDesignEvent</type>
|
<type>org.apollo.game.event.impl.PlayerDesignEvent</type>
|
||||||
<chain>
|
<chain>
|
||||||
<handler>org.apollo.game.event.handler.impl.CharacterDesignVerificationHandler</handler>
|
<handler>org.apollo.game.event.handler.impl.PlayerDesignVerificationHandler</handler>
|
||||||
<handler>org.apollo.game.event.handler.impl.CharacterDesignEventHandler</handler>
|
<handler>org.apollo.game.event.handler.impl.PlayerDesignEventHandler</handler>
|
||||||
</chain>
|
</chain>
|
||||||
</event>
|
</event>
|
||||||
<event>
|
<event>
|
||||||
|
|||||||
@@ -91,7 +91,7 @@ public final class IndexedFileSystem implements Closeable {
|
|||||||
} else if (newEngineData.exists() && !oldEngineData.isDirectory()) {
|
} else if (newEngineData.exists() && !oldEngineData.isDirectory()) {
|
||||||
data = new RandomAccessFile(newEngineData, readOnly ? "r" : "rw");
|
data = new RandomAccessFile(newEngineData, readOnly ? "r" : "rw");
|
||||||
} else {
|
} else {
|
||||||
throw new FileNotFoundException("No data file present");
|
throw new FileNotFoundException("no data file present");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -123,27 +123,27 @@ public final class IndexedFileSystem implements Closeable {
|
|||||||
for (int i = 1; i < crcs.length; i++) {
|
for (int i = 1; i < crcs.length; i++) {
|
||||||
crc32.reset();
|
crc32.reset();
|
||||||
|
|
||||||
ByteBuffer bb = getFile(0, i);
|
ByteBuffer buffer = getFile(0, i);
|
||||||
byte[] bytes = new byte[bb.remaining()];
|
byte[] bytes = new byte[buffer.remaining()];
|
||||||
bb.get(bytes, 0, bytes.length);
|
buffer.get(bytes, 0, bytes.length);
|
||||||
crc32.update(bytes, 0, bytes.length);
|
crc32.update(bytes, 0, bytes.length);
|
||||||
|
|
||||||
crcs[i] = (int) crc32.getValue();
|
crcs[i] = (int) crc32.getValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
// hash the CRCs and place them in the buffer
|
// hash the CRCs and place them in the buffer
|
||||||
ByteBuffer buf = ByteBuffer.allocate(crcs.length * 4 + 4);
|
ByteBuffer buffer = ByteBuffer.allocate(crcs.length * 4 + 4);
|
||||||
for (int crc : crcs) {
|
for (int crc : crcs) {
|
||||||
hash = (hash << 1) + crc;
|
hash = (hash << 1) + crc;
|
||||||
buf.putInt(crc);
|
buffer.putInt(crc);
|
||||||
}
|
}
|
||||||
|
|
||||||
// place the hash into the buffer
|
// place the hash into the buffer
|
||||||
buf.putInt(hash);
|
buffer.putInt(hash);
|
||||||
buf.flip();
|
buffer.flip();
|
||||||
|
|
||||||
synchronized (this) {
|
synchronized (this) {
|
||||||
crcTable = buf.asReadOnlyBuffer();
|
crcTable = buffer.asReadOnlyBuffer();
|
||||||
return crcTable.duplicate();
|
return crcTable.duplicate();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -153,16 +153,16 @@ public final class IndexedFileSystem implements Closeable {
|
|||||||
/**
|
/**
|
||||||
* Gets a file.
|
* Gets a file.
|
||||||
*
|
*
|
||||||
* @param fd The {@link FileDescriptor} which points to the file.
|
* @param descriptor The {@link FileDescriptor} which points to the file.
|
||||||
* @return A {@link ByteBuffer} which contains the contents of the file.
|
* @return A {@link ByteBuffer} which contains the contents of the file.
|
||||||
* @throws IOException If an I/O error occurs.
|
* @throws IOException If an I/O error occurs.
|
||||||
*/
|
*/
|
||||||
public ByteBuffer getFile(FileDescriptor fd) throws IOException {
|
public ByteBuffer getFile(FileDescriptor descriptor) throws IOException {
|
||||||
Index index = getIndex(fd);
|
Index index = getIndex(descriptor);
|
||||||
ByteBuffer buffer = ByteBuffer.allocate(index.getSize());
|
ByteBuffer buffer = ByteBuffer.allocate(index.getSize());
|
||||||
|
|
||||||
// calculate some initial values
|
// calculate some initial values
|
||||||
long ptr = (long) index.getBlock() * (long) FileSystemConstants.BLOCK_SIZE;
|
long ptr = index.getBlock() * FileSystemConstants.BLOCK_SIZE;
|
||||||
int read = 0;
|
int read = 0;
|
||||||
int size = index.getSize();
|
int size = index.getSize();
|
||||||
int blocks = size / FileSystemConstants.CHUNK_SIZE;
|
int blocks = size / FileSystemConstants.CHUNK_SIZE;
|
||||||
@@ -171,7 +171,6 @@ public final class IndexedFileSystem implements Closeable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0; i < blocks; i++) {
|
for (int i = 0; i < blocks; i++) {
|
||||||
|
|
||||||
// read header
|
// read header
|
||||||
byte[] header = new byte[FileSystemConstants.HEADER_SIZE];
|
byte[] header = new byte[FileSystemConstants.HEADER_SIZE];
|
||||||
synchronized (data) {
|
synchronized (data) {
|
||||||
@@ -211,15 +210,14 @@ public final class IndexedFileSystem implements Closeable {
|
|||||||
read += chunkSize;
|
read += chunkSize;
|
||||||
ptr = (long) nextBlock * (long) FileSystemConstants.BLOCK_SIZE;
|
ptr = (long) nextBlock * (long) FileSystemConstants.BLOCK_SIZE;
|
||||||
|
|
||||||
// if we still have more data to read, check the validity of the
|
// if we still have more data to read, check the validity of the header
|
||||||
// header
|
|
||||||
if (size > read) {
|
if (size > read) {
|
||||||
if (nextType != fd.getType() + 1) {
|
if (nextType != descriptor.getType() + 1) {
|
||||||
throw new IOException("File type mismatch.");
|
throw new IOException("file type mismatch.");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (nextFile != fd.getFile()) {
|
if (nextFile != descriptor.getFile()) {
|
||||||
throw new IOException("File id mismatch.");
|
throw new IOException("file id mismatch.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -261,12 +259,12 @@ public final class IndexedFileSystem implements Closeable {
|
|||||||
/**
|
/**
|
||||||
* Gets the index of a file.
|
* Gets the index of a file.
|
||||||
*
|
*
|
||||||
* @param fd The {@link FileDescriptor} which points to the file.
|
* @param descriptor The {@link FileDescriptor} which points to the file.
|
||||||
* @return The {@link Index}.
|
* @return The {@link Index}.
|
||||||
* @throws IOException If an I/O error occurs.
|
* @throws IOException If an I/O error occurs.
|
||||||
*/
|
*/
|
||||||
private Index getIndex(FileDescriptor fd) throws IOException {
|
private Index getIndex(FileDescriptor descriptor) throws IOException {
|
||||||
int index = fd.getType();
|
int index = descriptor.getType();
|
||||||
if (index < 0 || index >= indices.length) {
|
if (index < 0 || index >= indices.length) {
|
||||||
throw new IndexOutOfBoundsException("file descriptor type out of bounds");
|
throw new IndexOutOfBoundsException("file descriptor type out of bounds");
|
||||||
}
|
}
|
||||||
@@ -274,7 +272,7 @@ public final class IndexedFileSystem implements Closeable {
|
|||||||
byte[] buffer = new byte[FileSystemConstants.INDEX_SIZE];
|
byte[] buffer = new byte[FileSystemConstants.INDEX_SIZE];
|
||||||
RandomAccessFile indexFile = indices[index];
|
RandomAccessFile indexFile = indices[index];
|
||||||
synchronized (indexFile) {
|
synchronized (indexFile) {
|
||||||
long ptr = (long) fd.getFile() * (long) FileSystemConstants.INDEX_SIZE;
|
long ptr = descriptor.getFile() * FileSystemConstants.INDEX_SIZE;
|
||||||
if (ptr >= 0 && indexFile.length() >= ptr + FileSystemConstants.INDEX_SIZE) {
|
if (ptr >= 0 && indexFile.length() >= ptr + FileSystemConstants.INDEX_SIZE) {
|
||||||
indexFile.seek(ptr);
|
indexFile.seek(ptr);
|
||||||
indexFile.readFully(buffer);
|
indexFile.readFully(buffer);
|
||||||
|
|||||||
@@ -2,4 +2,3 @@
|
|||||||
* Contains classes which deal with archives.
|
* Contains classes which deal with archives.
|
||||||
*/
|
*/
|
||||||
package org.apollo.fs.archive;
|
package org.apollo.fs.archive;
|
||||||
|
|
||||||
|
|||||||
@@ -2,4 +2,3 @@
|
|||||||
* Contains classes which parse files within the game's cache.
|
* Contains classes which parse files within the game's cache.
|
||||||
*/
|
*/
|
||||||
package org.apollo.fs.decoder;
|
package org.apollo.fs.decoder;
|
||||||
|
|
||||||
|
|||||||
@@ -3,4 +3,3 @@
|
|||||||
* store game data files.
|
* store game data files.
|
||||||
*/
|
*/
|
||||||
package org.apollo.fs;
|
package org.apollo.fs;
|
||||||
|
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import org.apollo.game.model.Mob;
|
|||||||
import org.apollo.game.scheduling.ScheduledTask;
|
import org.apollo.game.scheduling.ScheduledTask;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An action is a specialised {@link ScheduledTask} which is specific to a character.
|
* An action is a specialised {@link ScheduledTask} which is specific to a mob.
|
||||||
* <p>
|
* <p>
|
||||||
* <strong>ALL</strong> actions <strong>MUST</strong> implement the {@link #equals(Object)} method. This is to check if
|
* <strong>ALL</strong> actions <strong>MUST</strong> implement the {@link #equals(Object)} method. This is to check if
|
||||||
* two actions are identical: if they are, then the new action does not replace the old one (so spam/accidental clicking
|
* two actions are identical: if they are, then the new action does not replace the old one (so spam/accidental clicking
|
||||||
@@ -15,9 +15,9 @@ import org.apollo.game.scheduling.ScheduledTask;
|
|||||||
public abstract class Action<T extends Mob> extends ScheduledTask {
|
public abstract class Action<T extends Mob> extends ScheduledTask {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The character performing the action.
|
* The mob performing the action.
|
||||||
*/
|
*/
|
||||||
private final T character;
|
protected final T mob;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A flag indicating if this action is stopping.
|
* A flag indicating if this action is stopping.
|
||||||
@@ -29,20 +29,20 @@ public abstract class Action<T extends Mob> extends ScheduledTask {
|
|||||||
*
|
*
|
||||||
* @param delay The delay in pulses.
|
* @param delay The delay in pulses.
|
||||||
* @param immediate A flag indicating if the action should happen immediately.
|
* @param immediate A flag indicating if the action should happen immediately.
|
||||||
* @param character The character performing the action.
|
* @param mob The mob performing the action.
|
||||||
*/
|
*/
|
||||||
public Action(int delay, boolean immediate, T character) {
|
public Action(int delay, boolean immediate, T mob) {
|
||||||
super(delay, immediate);
|
super(delay, immediate);
|
||||||
this.character = character;
|
this.mob = mob;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the character which performed the action.
|
* Gets the mob which performed the action.
|
||||||
*
|
*
|
||||||
* @return The character.
|
* @return The mob.
|
||||||
*/
|
*/
|
||||||
public T getCharacter() {
|
public T getMob() {
|
||||||
return character;
|
return mob;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -50,7 +50,7 @@ public abstract class Action<T extends Mob> extends ScheduledTask {
|
|||||||
super.stop();
|
super.stop();
|
||||||
if (!stopping) {
|
if (!stopping) {
|
||||||
stopping = true;
|
stopping = true;
|
||||||
character.stopAction();
|
mob.stopAction();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -41,12 +41,12 @@ public abstract class DistancedAction<T extends Mob> extends Action<T> {
|
|||||||
*
|
*
|
||||||
* @param delay The delay between executions once the distance threshold is reached.
|
* @param delay The delay between executions once the distance threshold is reached.
|
||||||
* @param immediate Whether or not this action fires immediately after the distance threshold is reached.
|
* @param immediate Whether or not this action fires immediately after the distance threshold is reached.
|
||||||
* @param character The character.
|
* @param mob The mob.
|
||||||
* @param position The position.
|
* @param position The position.
|
||||||
* @param distance The distance.
|
* @param distance The distance.
|
||||||
*/
|
*/
|
||||||
public DistancedAction(int delay, boolean immediate, T character, Position position, int distance) {
|
public DistancedAction(int delay, boolean immediate, T mob, Position position, int distance) {
|
||||||
super(0, true, character);
|
super(0, true, mob);
|
||||||
this.position = position;
|
this.position = position;
|
||||||
this.distance = distance;
|
this.distance = distance;
|
||||||
this.delay = delay;
|
this.delay = delay;
|
||||||
@@ -59,7 +59,7 @@ public abstract class DistancedAction<T extends Mob> extends Action<T> {
|
|||||||
// some actions (e.g. agility) will cause the player to move away again
|
// some actions (e.g. agility) will cause the player to move away again
|
||||||
// so we don't check once the player got close enough once
|
// so we don't check once the player got close enough once
|
||||||
executeAction();
|
executeAction();
|
||||||
} else if (getCharacter().getPosition().getDistance(position) <= distance) {
|
} else if (mob.getPosition().getDistance(position) <= distance) {
|
||||||
reached = true;
|
reached = true;
|
||||||
setDelay(delay);
|
setDelay(delay);
|
||||||
if (immediate) { // TODO: required?
|
if (immediate) { // TODO: required?
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
/**
|
/**
|
||||||
* Contains classes related to actions, specialised scheduled tasks which
|
* Contains classes related to actions, specialised scheduled tasks which
|
||||||
* characters perform.
|
* mobs perform.
|
||||||
*/
|
*/
|
||||||
package org.apollo.game.action;
|
package org.apollo.game.action;
|
||||||
|
|
||||||
|
|||||||
@@ -2,4 +2,3 @@
|
|||||||
* Contains classes related to in-game commands.
|
* Contains classes related to in-game commands.
|
||||||
*/
|
*/
|
||||||
package org.apollo.game.command;
|
package org.apollo.game.command;
|
||||||
|
|
||||||
|
|||||||
@@ -2,4 +2,3 @@
|
|||||||
* Contains classes related to the chaining of event handlers.
|
* Contains classes related to the chaining of event handlers.
|
||||||
*/
|
*/
|
||||||
package org.apollo.game.event.handler.chain;
|
package org.apollo.game.event.handler.chain;
|
||||||
|
|
||||||
|
|||||||
@@ -23,7 +23,6 @@ public final class CommandEventHandler extends EventHandler<CommandEvent> {
|
|||||||
String[] arguments = new String[components.length - 1];
|
String[] arguments = new String[components.length - 1];
|
||||||
|
|
||||||
System.arraycopy(components, 1, arguments, 0, arguments.length);
|
System.arraycopy(components, 1, arguments, 0, arguments.length);
|
||||||
|
|
||||||
Command command = new Command(name, arguments);
|
Command command = new Command(name, arguments);
|
||||||
|
|
||||||
World.getWorld().getCommandDispatcher().dispatch(player, command);
|
World.getWorld().getCommandDispatcher().dispatch(player, command);
|
||||||
|
|||||||
@@ -27,7 +27,6 @@ public final class ItemOnItemVerificationHandler extends EventHandler<ItemOnItem
|
|||||||
Item item = inventory.get(slot);
|
Item item = inventory.get(slot);
|
||||||
if (item == null || item.getId() != event.getTargetId()) {
|
if (item == null || item.getId() != event.getTargetId()) {
|
||||||
ctx.breakHandlerChain();
|
ctx.breakHandlerChain();
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+5
-5
@@ -2,21 +2,21 @@ package org.apollo.game.event.handler.impl;
|
|||||||
|
|
||||||
import org.apollo.game.event.handler.EventHandler;
|
import org.apollo.game.event.handler.EventHandler;
|
||||||
import org.apollo.game.event.handler.EventHandlerContext;
|
import org.apollo.game.event.handler.EventHandlerContext;
|
||||||
import org.apollo.game.event.impl.CharacterDesignEvent;
|
import org.apollo.game.event.impl.PlayerDesignEvent;
|
||||||
import org.apollo.game.event.impl.CloseInterfaceEvent;
|
import org.apollo.game.event.impl.CloseInterfaceEvent;
|
||||||
import org.apollo.game.model.Player;
|
import org.apollo.game.model.Player;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A handler which handles {@link CharacterDesignEvent}s.
|
* A handler which handles {@link PlayerDesignEvent}s.
|
||||||
*
|
*
|
||||||
* @author Graham
|
* @author Graham
|
||||||
*/
|
*/
|
||||||
public final class CharacterDesignEventHandler extends EventHandler<CharacterDesignEvent> {
|
public final class PlayerDesignEventHandler extends EventHandler<PlayerDesignEvent> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void handle(EventHandlerContext ctx, Player player, CharacterDesignEvent event) {
|
public void handle(EventHandlerContext ctx, Player player, PlayerDesignEvent event) {
|
||||||
player.setAppearance(event.getAppearance());
|
player.setAppearance(event.getAppearance());
|
||||||
player.setDesignedCharacter(true);
|
player.setDesigned(true);
|
||||||
player.send(new CloseInterfaceEvent());
|
player.send(new CloseInterfaceEvent());
|
||||||
}
|
}
|
||||||
|
|
||||||
+6
-6
@@ -2,21 +2,21 @@ package org.apollo.game.event.handler.impl;
|
|||||||
|
|
||||||
import org.apollo.game.event.handler.EventHandler;
|
import org.apollo.game.event.handler.EventHandler;
|
||||||
import org.apollo.game.event.handler.EventHandlerContext;
|
import org.apollo.game.event.handler.EventHandlerContext;
|
||||||
import org.apollo.game.event.impl.CharacterDesignEvent;
|
import org.apollo.game.event.impl.PlayerDesignEvent;
|
||||||
import org.apollo.game.model.Appearance;
|
import org.apollo.game.model.Appearance;
|
||||||
import org.apollo.game.model.Gender;
|
import org.apollo.game.model.Gender;
|
||||||
import org.apollo.game.model.Player;
|
import org.apollo.game.model.Player;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A handler which verifies {@link CharacterDesignEvent}s.
|
* A handler which verifies {@link PlayerDesignEvent}s.
|
||||||
*
|
*
|
||||||
* @author Graham
|
* @author Graham
|
||||||
*/
|
*/
|
||||||
public final class CharacterDesignVerificationHandler extends EventHandler<CharacterDesignEvent> {
|
public final class PlayerDesignVerificationHandler extends EventHandler<PlayerDesignEvent> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void handle(EventHandlerContext ctx, Player player, CharacterDesignEvent event) {
|
public void handle(EventHandlerContext ctx, Player player, PlayerDesignEvent event) {
|
||||||
if (!valid(event.getAppearance()) || player.hasDesignedCharacter()) {
|
if (!valid(event.getAppearance()) || player.hasDesignedAvatar()) {
|
||||||
ctx.breakHandlerChain();
|
ctx.breakHandlerChain();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -42,7 +42,7 @@ public final class CharacterDesignVerificationHandler extends EventHandler<Chara
|
|||||||
} else if (gender == Gender.FEMALE) {
|
} else if (gender == Gender.FEMALE) {
|
||||||
return validFemaleStyle(appearance);
|
return validFemaleStyle(appearance);
|
||||||
} else {
|
} else {
|
||||||
return false; // maybe null?
|
throw new IllegalArgumentException("player can only be either male or female");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -21,7 +21,6 @@ public final class SwitchItemEventHandler extends EventHandler<SwitchItemEvent>
|
|||||||
Inventory inventory;
|
Inventory inventory;
|
||||||
boolean insertPermitted = false;
|
boolean insertPermitted = false;
|
||||||
|
|
||||||
// TODO is there a better way of doing this??
|
|
||||||
switch (event.getInterfaceId()) {
|
switch (event.getInterfaceId()) {
|
||||||
case SynchronizationInventoryListener.INVENTORY_ID:
|
case SynchronizationInventoryListener.INVENTORY_ID:
|
||||||
case BankConstants.SIDEBAR_INVENTORY_ID:
|
case BankConstants.SIDEBAR_INVENTORY_ID:
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ public final class WalkEventHandler extends EventHandler<WalkEvent> {
|
|||||||
Position step = steps[i];
|
Position step = steps[i];
|
||||||
if (i == 0) {
|
if (i == 0) {
|
||||||
if (!queue.addFirstStep(step)) {
|
if (!queue.addFirstStep(step)) {
|
||||||
return; /* ignore packet */
|
return; // ignore packet
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
queue.addStep(step);
|
queue.addStep(step);
|
||||||
|
|||||||
@@ -2,4 +2,3 @@
|
|||||||
* Contains event handler implementations.
|
* Contains event handler implementations.
|
||||||
*/
|
*/
|
||||||
package org.apollo.game.event.handler.impl;
|
package org.apollo.game.event.handler.impl;
|
||||||
|
|
||||||
|
|||||||
@@ -2,4 +2,3 @@
|
|||||||
* Contains classes which define abstract event handlers.
|
* Contains classes which define abstract event handlers.
|
||||||
*/
|
*/
|
||||||
package org.apollo.game.event.handler;
|
package org.apollo.game.event.handler;
|
||||||
|
|
||||||
|
|||||||
@@ -1,12 +0,0 @@
|
|||||||
package org.apollo.game.event.impl;
|
|
||||||
|
|
||||||
import org.apollo.game.event.Event;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* An outgoing event sent to reset the animations of every character.
|
|
||||||
*
|
|
||||||
* @author Major
|
|
||||||
*/
|
|
||||||
public class CharacterAnimationResetEvent extends Event {
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
package org.apollo.game.event.impl;
|
||||||
|
|
||||||
|
import org.apollo.game.event.Event;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* An outgoing event sent to reset the animations of every mob.
|
||||||
|
*
|
||||||
|
* @author Major
|
||||||
|
*/
|
||||||
|
public class MobAnimationResetEvent extends Event {
|
||||||
|
|
||||||
|
}
|
||||||
+4
-4
@@ -4,11 +4,11 @@ import org.apollo.game.event.Event;
|
|||||||
import org.apollo.game.model.Appearance;
|
import org.apollo.game.model.Appearance;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An event sent by the client when the player modifies their character's design.
|
* An event sent by the client when the player modifies their design.
|
||||||
*
|
*
|
||||||
* @author Graham
|
* @author Graham
|
||||||
*/
|
*/
|
||||||
public final class CharacterDesignEvent extends Event {
|
public final class PlayerDesignEvent extends Event {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The appearance.
|
* The appearance.
|
||||||
@@ -16,11 +16,11 @@ public final class CharacterDesignEvent extends Event {
|
|||||||
private final Appearance appearance;
|
private final Appearance appearance;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates the character design event.
|
* Creates the player design event.
|
||||||
*
|
*
|
||||||
* @param appearance The appearance.
|
* @param appearance The appearance.
|
||||||
*/
|
*/
|
||||||
public CharacterDesignEvent(Appearance appearance) {
|
public PlayerDesignEvent(Appearance appearance) {
|
||||||
this.appearance = appearance;
|
this.appearance = appearance;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3,14 +3,14 @@ package org.apollo.game.event.impl;
|
|||||||
import org.apollo.game.event.Event;
|
import org.apollo.game.event.Event;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An event which is sent to the client to make a character model on an interface play a certain animation.
|
* An event which is sent to the client to make a mob model on an interface play a certain animation.
|
||||||
*
|
*
|
||||||
* @author Chris Fletcher
|
* @author Chris Fletcher
|
||||||
*/
|
*/
|
||||||
public final class SetWidgetModelAnimationEvent extends Event {
|
public final class SetWidgetModelAnimationEvent extends Event {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The model's mood id.
|
* The model's animation id.
|
||||||
*/
|
*/
|
||||||
private final int animation;
|
private final int animation;
|
||||||
|
|
||||||
|
|||||||
@@ -31,17 +31,5 @@ public class SpamPacketEvent extends Event {
|
|||||||
public byte[] getData() {
|
public byte[] getData() {
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
// 0
|
|
||||||
// random * 256
|
|
||||||
// 101
|
|
||||||
// 233
|
|
||||||
// 45092 (short)
|
|
||||||
// 35784 if random * 2= 0
|
|
||||||
// random * 256
|
|
||||||
// 64
|
|
||||||
// 38
|
|
||||||
// Math.random() * 65536
|
|
||||||
// Math.random() * 65536
|
|
||||||
// offset - start offset (exc. the first 0 sent) - size byte.
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -2,4 +2,3 @@
|
|||||||
* Contains event implementations.
|
* Contains event implementations.
|
||||||
*/
|
*/
|
||||||
package org.apollo.game.event.impl;
|
package org.apollo.game.event.impl;
|
||||||
|
|
||||||
|
|||||||
@@ -2,4 +2,3 @@
|
|||||||
* Contains classes related to the event management in the game.
|
* Contains classes related to the event management in the game.
|
||||||
*/
|
*/
|
||||||
package org.apollo.game.event;
|
package org.apollo.game.event;
|
||||||
|
|
||||||
|
|||||||
@@ -7,16 +7,16 @@ package org.apollo.game.model;
|
|||||||
*/
|
*/
|
||||||
public enum Direction {
|
public enum Direction {
|
||||||
|
|
||||||
/**
|
|
||||||
* East movement.
|
|
||||||
*/
|
|
||||||
EAST(4),
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* No movement.
|
* No movement.
|
||||||
*/
|
*/
|
||||||
NONE(-1),
|
NONE(-1),
|
||||||
|
|
||||||
|
/**
|
||||||
|
* North west movement.
|
||||||
|
*/
|
||||||
|
NORTH_WEST(0),
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* North movement.
|
* North movement.
|
||||||
*/
|
*/
|
||||||
@@ -28,9 +28,19 @@ public enum Direction {
|
|||||||
NORTH_EAST(2),
|
NORTH_EAST(2),
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* North west movement.
|
* West movement.
|
||||||
*/
|
*/
|
||||||
NORTH_WEST(0),
|
WEST(3),
|
||||||
|
|
||||||
|
/**
|
||||||
|
* East movement.
|
||||||
|
*/
|
||||||
|
EAST(4),
|
||||||
|
|
||||||
|
/**
|
||||||
|
* South west movement.
|
||||||
|
*/
|
||||||
|
SOUTH_WEST(5),
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* South movement.
|
* South movement.
|
||||||
@@ -40,17 +50,7 @@ public enum Direction {
|
|||||||
/**
|
/**
|
||||||
* South east movement.
|
* South east movement.
|
||||||
*/
|
*/
|
||||||
SOUTH_EAST(7),
|
SOUTH_EAST(7);
|
||||||
|
|
||||||
/**
|
|
||||||
* South west movement.
|
|
||||||
*/
|
|
||||||
SOUTH_WEST(5),
|
|
||||||
|
|
||||||
/**
|
|
||||||
* West movement.
|
|
||||||
*/
|
|
||||||
WEST(3);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An empty direction array.
|
* An empty direction array.
|
||||||
|
|||||||
@@ -1,14 +1,14 @@
|
|||||||
package org.apollo.game.model;
|
package org.apollo.game.model;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents an in-game entity, such as a character, object, projectile etc.
|
* Represents an in-game entity, such as a mob, object, projectile etc.
|
||||||
*
|
*
|
||||||
* @author Major
|
* @author Major
|
||||||
*/
|
*/
|
||||||
public abstract class Entity {
|
public abstract class Entity {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The position of the entity.
|
* The position of this entity.
|
||||||
*/
|
*/
|
||||||
protected Position position;
|
protected Position position;
|
||||||
|
|
||||||
@@ -20,7 +20,7 @@ public abstract class Entity {
|
|||||||
public abstract EntityType getEntityType();
|
public abstract EntityType getEntityType();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the position of this entity.
|
* Gets the {@link Position} of this entity.
|
||||||
*
|
*
|
||||||
* @return The position.
|
* @return The position.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ public enum EntityType {
|
|||||||
PROJECTILE,
|
PROJECTILE,
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A permanent object appearing on the map.
|
* A permanent object appearing on the map, loaded from the cache.
|
||||||
*/
|
*/
|
||||||
STATIC_OBJECT;
|
STATIC_OBJECT;
|
||||||
|
|
||||||
|
|||||||
@@ -8,59 +8,59 @@ package org.apollo.game.model;
|
|||||||
public final class EquipmentConstants {
|
public final class EquipmentConstants {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The amulet slot.
|
* The hat slot.
|
||||||
*/
|
*/
|
||||||
public static final int AMULET = 2;
|
public static final int HAT = 0;
|
||||||
|
|
||||||
/**
|
|
||||||
* The arrows slot.
|
|
||||||
*/
|
|
||||||
public static final int ARROWS = 13;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The cape slot.
|
* The cape slot.
|
||||||
*/
|
*/
|
||||||
public static final int CAPE = 1;
|
public static final int CAPE = 1;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The amulet slot.
|
||||||
|
*/
|
||||||
|
public static final int AMULET = 2;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The weapon slot.
|
||||||
|
*/
|
||||||
|
public static final int WEAPON = 3;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The chest slot.
|
* The chest slot.
|
||||||
*/
|
*/
|
||||||
public static final int CHEST = 4;
|
public static final int CHEST = 4;
|
||||||
|
|
||||||
/**
|
|
||||||
* The feet slot.
|
|
||||||
*/
|
|
||||||
public static final int FEET = 10;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The hands slot.
|
|
||||||
*/
|
|
||||||
public static final int HANDS = 9;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The hat slot.
|
|
||||||
*/
|
|
||||||
public static final int HAT = 0;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The legs slot.
|
|
||||||
*/
|
|
||||||
public static final int LEGS = 7;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The ring slot.
|
|
||||||
*/
|
|
||||||
public static final int RING = 12;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The shield slot.
|
* The shield slot.
|
||||||
*/
|
*/
|
||||||
public static final int SHIELD = 5;
|
public static final int SHIELD = 5;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The weapon slot.
|
* The legs slot.
|
||||||
*/
|
*/
|
||||||
public static final int WEAPON = 3;
|
public static final int LEGS = 7;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The hands slot.
|
||||||
|
*/
|
||||||
|
public static final int HANDS = 9;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The feet slot.
|
||||||
|
*/
|
||||||
|
public static final int FEET = 10;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The ring slot.
|
||||||
|
*/
|
||||||
|
public static final int RING = 12;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The arrows slot.
|
||||||
|
*/
|
||||||
|
public static final int ARROWS = 13;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Default private constructor to prevent instantiation;
|
* Default private constructor to prevent instantiation;
|
||||||
|
|||||||
@@ -7,15 +7,15 @@ package org.apollo.game.model;
|
|||||||
*/
|
*/
|
||||||
public enum Gender {
|
public enum Gender {
|
||||||
|
|
||||||
/**
|
|
||||||
* The female gender.
|
|
||||||
*/
|
|
||||||
FEMALE(1),
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The male gender.
|
* The male gender.
|
||||||
*/
|
*/
|
||||||
MALE(0);
|
MALE(0),
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The female gender.
|
||||||
|
*/
|
||||||
|
FEMALE(1);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An integer representation used by the client.
|
* An integer representation used by the client.
|
||||||
|
|||||||
@@ -73,7 +73,6 @@ public final class Inventory implements Cloneable {
|
|||||||
* Creates an inventory.
|
* Creates an inventory.
|
||||||
*
|
*
|
||||||
* @param capacity The capacity.
|
* @param capacity The capacity.
|
||||||
* @throws IllegalArgumentException If the capacity is negative.
|
|
||||||
*/
|
*/
|
||||||
public Inventory(int capacity) {
|
public Inventory(int capacity) {
|
||||||
this(capacity, StackMode.STACK_STACKABLE_ITEMS);
|
this(capacity, StackMode.STACK_STACKABLE_ITEMS);
|
||||||
@@ -83,7 +82,7 @@ public final class Inventory implements Cloneable {
|
|||||||
* Creates an inventory.
|
* Creates an inventory.
|
||||||
*
|
*
|
||||||
* @param capacity The capacity.
|
* @param capacity The capacity.
|
||||||
* @param mode The stacking mode.
|
* @param mode The {@link StackMode}.
|
||||||
* @throws IllegalArgumentException If the capacity is negative.
|
* @throws IllegalArgumentException If the capacity is negative.
|
||||||
* @throws NullPointerException If the mode is {@code null}.
|
* @throws NullPointerException If the mode is {@code null}.
|
||||||
*/
|
*/
|
||||||
@@ -92,7 +91,7 @@ public final class Inventory implements Cloneable {
|
|||||||
throw new IllegalArgumentException("capacity cannot be negative");
|
throw new IllegalArgumentException("capacity cannot be negative");
|
||||||
}
|
}
|
||||||
if (mode == null) {
|
if (mode == null) {
|
||||||
throw new NullPointerException("mode");
|
throw new NullPointerException("stacking mode cannot be null");
|
||||||
}
|
}
|
||||||
this.capacity = capacity;
|
this.capacity = capacity;
|
||||||
items = new Item[capacity];
|
items = new Item[capacity];
|
||||||
@@ -195,9 +194,9 @@ public final class Inventory implements Cloneable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds a listener.
|
* Adds an {@link InventoryListener}.
|
||||||
*
|
*
|
||||||
* @param listener The listener to add.
|
* @param listener The listener.
|
||||||
*/
|
*/
|
||||||
public void addListener(InventoryListener listener) {
|
public void addListener(InventoryListener listener) {
|
||||||
listeners.add(listener);
|
listeners.add(listener);
|
||||||
@@ -298,7 +297,6 @@ public final class Inventory implements Cloneable {
|
|||||||
*
|
*
|
||||||
* @param slot The slot.
|
* @param slot The slot.
|
||||||
* @return The item, or {@code null} if the slot is empty.
|
* @return The item, or {@code null} if the slot is empty.
|
||||||
* @throws IndexOutOfBoundsException If the slot is out of bounds.
|
|
||||||
*/
|
*/
|
||||||
public Item get(int slot) {
|
public Item get(int slot) {
|
||||||
checkBounds(slot);
|
checkBounds(slot);
|
||||||
@@ -447,7 +445,6 @@ public final class Inventory implements Cloneable {
|
|||||||
*
|
*
|
||||||
* @param slot
|
* @param slot
|
||||||
* @return The item that was in the slot.
|
* @return The item that was in the slot.
|
||||||
* @throws IndexOutOfBoundsException If the slot is out of bounds.
|
|
||||||
*/
|
*/
|
||||||
public Item reset(int slot) {
|
public Item reset(int slot) {
|
||||||
checkBounds(slot);
|
checkBounds(slot);
|
||||||
@@ -467,7 +464,6 @@ public final class Inventory implements Cloneable {
|
|||||||
* @param slot The slot.
|
* @param slot The slot.
|
||||||
* @param item The item, or {@code null} to remove the item that is in the slot.
|
* @param item The item, or {@code null} to remove the item that is in the slot.
|
||||||
* @return The item that was in the slot.
|
* @return The item that was in the slot.
|
||||||
* @throws IndexOutOfBoundsException If the slot is out of bounds.
|
|
||||||
*/
|
*/
|
||||||
public Item set(int slot, Item item) {
|
public Item set(int slot, Item item) {
|
||||||
if (item == null) {
|
if (item == null) {
|
||||||
@@ -529,7 +525,6 @@ public final class Inventory implements Cloneable {
|
|||||||
* @param insert If the swap should be done in insertion mode.
|
* @param insert If the swap should be done in insertion mode.
|
||||||
* @param oldSlot The old slot.
|
* @param oldSlot The old slot.
|
||||||
* @param newSlot The new slot.
|
* @param newSlot The new slot.
|
||||||
* @throws IndexOutOfBoundsException If the slot is out of bounds.
|
|
||||||
*/
|
*/
|
||||||
public void swap(boolean insert, int oldSlot, int newSlot) {
|
public void swap(boolean insert, int oldSlot, int newSlot) {
|
||||||
checkBounds(oldSlot);
|
checkBounds(oldSlot);
|
||||||
@@ -543,13 +538,14 @@ public final class Inventory implements Cloneable {
|
|||||||
for (int slot = oldSlot; slot > newSlot; slot--) {
|
for (int slot = oldSlot; slot > newSlot; slot--) {
|
||||||
swap(slot, slot - 1);
|
swap(slot, slot - 1);
|
||||||
}
|
}
|
||||||
} // else no change is required - aren't we lucky?
|
}
|
||||||
forceRefresh();
|
forceRefresh();
|
||||||
} else {
|
} else {
|
||||||
Item temp = items[oldSlot];
|
Item tmp = items[oldSlot];
|
||||||
items[oldSlot] = items[newSlot];
|
items[oldSlot] = items[newSlot];
|
||||||
items[newSlot] = temp;
|
items[newSlot] = tmp;
|
||||||
notifyItemsUpdated(); // TODO can we just fire for the two slots?
|
notifyItemUpdated(oldSlot);
|
||||||
|
notifyItemUpdated(newSlot);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -558,7 +554,6 @@ public final class Inventory implements Cloneable {
|
|||||||
*
|
*
|
||||||
* @param oldSlot The old slot.
|
* @param oldSlot The old slot.
|
||||||
* @param newSlot The new slot.
|
* @param newSlot The new slot.
|
||||||
* @throws IndexOutOufBoundsException If the slot is out of bounds.
|
|
||||||
*/
|
*/
|
||||||
public void swap(int oldSlot, int newSlot) {
|
public void swap(int oldSlot, int newSlot) {
|
||||||
swap(false, oldSlot, newSlot);
|
swap(false, oldSlot, newSlot);
|
||||||
|
|||||||
@@ -4,13 +4,12 @@ import java.util.ArrayList;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.apollo.game.action.Action;
|
import org.apollo.game.action.Action;
|
||||||
import org.apollo.game.event.Event;
|
|
||||||
import org.apollo.game.model.Inventory.StackMode;
|
import org.apollo.game.model.Inventory.StackMode;
|
||||||
import org.apollo.game.model.def.NpcDefinition;
|
import org.apollo.game.model.def.NpcDefinition;
|
||||||
import org.apollo.game.scheduling.impl.SkillNormalizationTask;
|
import org.apollo.game.scheduling.impl.SkillNormalizationTask;
|
||||||
import org.apollo.game.sync.block.SynchronizationBlock;
|
import org.apollo.game.sync.block.SynchronizationBlock;
|
||||||
import org.apollo.game.sync.block.SynchronizationBlockSet;
|
import org.apollo.game.sync.block.SynchronizationBlockSet;
|
||||||
import org.apollo.util.CharacterRepository;
|
import org.apollo.util.MobRepository;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A {@link Mob} is a living entity in the world, such as a player or NPC.
|
* A {@link Mob} is a living entity in the world, such as a player or NPC.
|
||||||
@@ -20,95 +19,80 @@ import org.apollo.util.CharacterRepository;
|
|||||||
public abstract class Mob extends Entity {
|
public abstract class Mob extends Entity {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The character's current action.
|
* This mob's current action.
|
||||||
*/
|
*/
|
||||||
private Action<?> action;
|
private Action<?> action;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The character's bank.
|
* This mob's set of {@link SynchronizationBlock}s.
|
||||||
*/
|
*/
|
||||||
private final Inventory bank = new Inventory(InventoryConstants.BANK_CAPACITY, StackMode.STACK_ALWAYS);
|
protected SynchronizationBlockSet blockSet = new SynchronizationBlockSet();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A set of {@link SynchronizationBlock}s.
|
* This mob's {@link NpcDefinition). A {@link Player} only uses this if they are appearing as an npc in-game.
|
||||||
*/
|
*/
|
||||||
private SynchronizationBlockSet blockSet = new SynchronizationBlockSet();
|
protected NpcDefinition definition;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The character's {@link NpcDefinition). This is only used by an instance of the {@link Player} class if they are
|
* This mob's equipment.
|
||||||
* appearing as an npc in-game.
|
|
||||||
*/
|
|
||||||
private NpcDefinition definition;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The character's equipment.
|
|
||||||
*/
|
*/
|
||||||
private final Inventory equipment = new Inventory(InventoryConstants.EQUIPMENT_CAPACITY, StackMode.STACK_ALWAYS);
|
private final Inventory equipment = new Inventory(InventoryConstants.EQUIPMENT_CAPACITY, StackMode.STACK_ALWAYS);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The first direction.
|
* This mob's first movement {@link Direction}.
|
||||||
*/
|
*/
|
||||||
private Direction firstDirection = Direction.NONE;
|
private Direction firstDirection = Direction.NONE;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The index of this character in the {@link CharacterRepository} it belongs to.
|
* The index of this mob in the {@link MobRepository} it belongs to.
|
||||||
*/
|
*/
|
||||||
private int index = -1;
|
private int index = -1;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The character's inventory.
|
* This mob's inventory.
|
||||||
*/
|
*/
|
||||||
private final Inventory inventory = new Inventory(InventoryConstants.INVENTORY_CAPACITY);
|
private final Inventory inventory = new Inventory(InventoryConstants.INVENTORY_CAPACITY);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The list of local npcs.
|
* This mob's {@link List} of local npcs.
|
||||||
*/
|
*/
|
||||||
private final List<Npc> localNpcs = new ArrayList<Npc>();
|
private final List<Npc> localNpcs = new ArrayList<Npc>();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A list of local players.
|
* This mob's {@link List} of local players.
|
||||||
*/
|
*/
|
||||||
private final List<Player> localPlayers = new ArrayList<Player>();
|
private final List<Player> localPlayers = new ArrayList<Player>();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The second direction.
|
* This mob's second movement direction.
|
||||||
*/
|
*/
|
||||||
private Direction secondDirection = Direction.NONE;
|
private Direction secondDirection = Direction.NONE;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The character's skill set.
|
* This mob's skill set.
|
||||||
*/
|
*/
|
||||||
private final SkillSet skillSet = new SkillSet();
|
private final SkillSet skillSet = new SkillSet();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Teleportation flag.
|
* Indicates whether this mob is currently teleporting or not.
|
||||||
*/
|
*/
|
||||||
private boolean teleporting = false;
|
private boolean teleporting = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The walking queue.
|
* This mob's walking queue.
|
||||||
*/
|
*/
|
||||||
private final WalkingQueue walkingQueue = new WalkingQueue(this);
|
private final WalkingQueue walkingQueue = new WalkingQueue(this);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a new character with the specified initial position.
|
* Creates a new mob with the specified initial {@link Position}.
|
||||||
*
|
*
|
||||||
* @param position The initial position of this character.
|
* @param position The initial position.
|
||||||
*/
|
*/
|
||||||
public Mob(Position position) {
|
public Mob(Position position) {
|
||||||
this.position = position;
|
this.position = position;
|
||||||
init();
|
init();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the character's bank.
|
|
||||||
*
|
|
||||||
* @return The character's bank.
|
|
||||||
*/
|
|
||||||
public Inventory getBank() {
|
|
||||||
return bank;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the {@link SynchronizationBlockSet}.
|
* Gets the {@link SynchronizationBlockSet}.
|
||||||
*
|
*
|
||||||
@@ -118,6 +102,19 @@ public abstract class Mob extends Entity {
|
|||||||
return blockSet;
|
return blockSet;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Deals damage to this mob.
|
||||||
|
*
|
||||||
|
* @param damage The damage dealt.
|
||||||
|
* @param type The type of damage.
|
||||||
|
* @param secondary Whether this should be dealt as a secondary hit or not.
|
||||||
|
*/
|
||||||
|
public void damage(int damage, int type, boolean secondary) {
|
||||||
|
Skill hitpoints = skillSet.getSkill(Skill.HITPOINTS);
|
||||||
|
blockSet.add(SynchronizationBlock.createHitUpdateBlock(damage, type, hitpoints.getCurrentLevel(),
|
||||||
|
hitpoints.getMaximumLevel(), secondary));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the directions as an array.
|
* Gets the directions as an array.
|
||||||
*
|
*
|
||||||
@@ -132,27 +129,27 @@ public abstract class Mob extends Entity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the character's equipment.
|
* Gets the mob's equipment.
|
||||||
*
|
*
|
||||||
* @return The character's equipment.
|
* @return The mob's equipment.
|
||||||
*/
|
*/
|
||||||
public Inventory getEquipment() {
|
public Inventory getEquipment() {
|
||||||
return equipment;
|
return equipment;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the first direction.
|
* Gets the first {@link Direction}.
|
||||||
*
|
*
|
||||||
* @return The first direction.
|
* @return The direction.
|
||||||
*/
|
*/
|
||||||
public Direction getFirstDirection() {
|
public Direction getFirstDirection() {
|
||||||
return firstDirection;
|
return firstDirection;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the index of this character.
|
* Gets the index of this mob.
|
||||||
*
|
*
|
||||||
* @return The index of this character.
|
* @return The index.
|
||||||
*/
|
*/
|
||||||
public int getIndex() {
|
public int getIndex() {
|
||||||
synchronized (this) {
|
synchronized (this) {
|
||||||
@@ -161,34 +158,34 @@ public abstract class Mob extends Entity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the character's inventory.
|
* Gets the mob's inventory.
|
||||||
*
|
*
|
||||||
* @return The character's inventory.
|
* @return The inventory.
|
||||||
*/
|
*/
|
||||||
public Inventory getInventory() {
|
public Inventory getInventory() {
|
||||||
return inventory;
|
return inventory;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the local npc list.
|
* Gets the local npc {@link List}.
|
||||||
*
|
*
|
||||||
* @return The local npc list.
|
* @return The list.
|
||||||
*/
|
*/
|
||||||
public List<Npc> getLocalNpcList() {
|
public List<Npc> getLocalNpcList() {
|
||||||
return localNpcs;
|
return localNpcs;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the local player list.
|
* Gets the local player {@link List}.
|
||||||
*
|
*
|
||||||
* @return The local player list.
|
* @return The list.
|
||||||
*/
|
*/
|
||||||
public List<Player> getLocalPlayerList() {
|
public List<Player> getLocalPlayerList() {
|
||||||
return localPlayers;
|
return localPlayers;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets this character's {@link NpcDefinition}.
|
* Gets this mob's {@link NpcDefinition}.
|
||||||
*
|
*
|
||||||
* @param definition The definition.
|
* @param definition The definition.
|
||||||
*/
|
*/
|
||||||
@@ -196,31 +193,26 @@ public abstract class Mob extends Entity {
|
|||||||
return definition;
|
return definition;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public Position getPosition() {
|
|
||||||
return position;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the second direction.
|
* Gets the second {@link Direction}.
|
||||||
*
|
*
|
||||||
* @return The second direction.
|
* @return The direction.
|
||||||
*/
|
*/
|
||||||
public Direction getSecondDirection() {
|
public Direction getSecondDirection() {
|
||||||
return secondDirection;
|
return secondDirection;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the character's skill set.
|
* Gets this mob's {@link SkillSet}.
|
||||||
*
|
*
|
||||||
* @return The character's skill set.
|
* @return The skill set.
|
||||||
*/
|
*/
|
||||||
public SkillSet getSkillSet() {
|
public SkillSet getSkillSet() {
|
||||||
return skillSet;
|
return skillSet;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the walking queue.
|
* Gets the {@link WalkingQueue}.
|
||||||
*
|
*
|
||||||
* @return The walking queue.
|
* @return The walking queue.
|
||||||
*/
|
*/
|
||||||
@@ -229,14 +221,14 @@ public abstract class Mob extends Entity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initialises this character.
|
* Initialises this mob.
|
||||||
*/
|
*/
|
||||||
private void init() {
|
private void init() {
|
||||||
World.getWorld().schedule(new SkillNormalizationTask(this));
|
World.getWorld().schedule(new SkillNormalizationTask(this));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks if this character is active.
|
* Checks if this mob is active.
|
||||||
*
|
*
|
||||||
* @return {@code true} if so, {@code false} if not.
|
* @return {@code true} if so, {@code false} if not.
|
||||||
*/
|
*/
|
||||||
@@ -245,7 +237,7 @@ public abstract class Mob extends Entity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks if this player is currently teleporting.
|
* Checks if this mob is currently teleporting.
|
||||||
*
|
*
|
||||||
* @return {@code true} if so, {@code false} if not.
|
* @return {@code true} if so, {@code false} if not.
|
||||||
*/
|
*/
|
||||||
@@ -254,7 +246,7 @@ public abstract class Mob extends Entity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Plays the specified animation.
|
* Plays the specified {@link Animation}.
|
||||||
*
|
*
|
||||||
* @param animation The animation.
|
* @param animation The animation.
|
||||||
*/
|
*/
|
||||||
@@ -263,7 +255,7 @@ public abstract class Mob extends Entity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Plays the specified graphic.
|
* Plays the specified {@link Graphic}.
|
||||||
*
|
*
|
||||||
* @param graphic The graphic.
|
* @param graphic The graphic.
|
||||||
*/
|
*/
|
||||||
@@ -279,18 +271,7 @@ public abstract class Mob extends Entity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sends an {@link Event} to either:
|
* Sets this mob's {@link NpcDefinition}.
|
||||||
* <ul>
|
|
||||||
* <li>The client if this {@link Mob} is a {@link Player}.</li>
|
|
||||||
* <li>The AI routines if this {@link Mob} is an NPC</li>
|
|
||||||
* </ul>
|
|
||||||
*
|
|
||||||
* @param event The event.
|
|
||||||
*/
|
|
||||||
public abstract void send(Event event);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets this character's {@link NpcDefinition}.
|
|
||||||
*
|
*
|
||||||
* @param definition The definition.
|
* @param definition The definition.
|
||||||
*/
|
*/
|
||||||
@@ -299,7 +280,7 @@ public abstract class Mob extends Entity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the next directions for this character.
|
* Sets the next directions for this mob.
|
||||||
*
|
*
|
||||||
* @param first The first direction.
|
* @param first The first direction.
|
||||||
* @param second The second direction.
|
* @param second The second direction.
|
||||||
@@ -310,9 +291,9 @@ public abstract class Mob extends Entity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the index of this character.
|
* Sets the index of this mob.
|
||||||
*
|
*
|
||||||
* @param index The index of this character.
|
* @param index The index.
|
||||||
*/
|
*/
|
||||||
public void setIndex(int index) {
|
public void setIndex(int index) {
|
||||||
synchronized (this) {
|
synchronized (this) {
|
||||||
@@ -321,18 +302,29 @@ public abstract class Mob extends Entity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the position of this character.
|
* Sets the position of this mob.
|
||||||
*
|
*
|
||||||
* @param position The position of this character.
|
* @param position The position.
|
||||||
*/
|
*/
|
||||||
public void setPosition(Position position) {
|
public void setPosition(Position position) {
|
||||||
this.position = position;
|
this.position = position;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the teleporting flag.
|
* Forces this mob to shout a message. Note that messages can only be shown in the chat box if they are said by a
|
||||||
|
* player.
|
||||||
*
|
*
|
||||||
* @param teleporting {@code true} if the player is teleporting, {@code false} if not.
|
* @param message The message.
|
||||||
|
* @param chatBox If the message should be shown in the player's chat box.
|
||||||
|
*/
|
||||||
|
public void shout(String message, boolean chatBox) {
|
||||||
|
blockSet.add(SynchronizationBlock.createForceChatBlock(message));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets whether this mob is teleporting or not.
|
||||||
|
*
|
||||||
|
* @param teleporting {@code true} if the mob is teleporting, {@code false} if not.
|
||||||
*/
|
*/
|
||||||
public void setTeleporting(boolean teleporting) {
|
public void setTeleporting(boolean teleporting) {
|
||||||
this.teleporting = teleporting;
|
this.teleporting = teleporting;
|
||||||
@@ -366,21 +358,22 @@ public abstract class Mob extends Entity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Stops the current animation.
|
* Stops the current {@link Animation}.
|
||||||
*/
|
*/
|
||||||
public void stopAnimation() {
|
public void stopAnimation() {
|
||||||
playAnimation(Animation.STOP_ANIMATION);
|
playAnimation(Animation.STOP_ANIMATION);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Stops the current graphic.
|
* Stops the current {@link Graphic}.
|
||||||
*/
|
*/
|
||||||
public void stopGraphic() {
|
public void stopGraphic() {
|
||||||
playGraphic(Graphic.STOP_GRAPHIC);
|
playGraphic(Graphic.STOP_GRAPHIC);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Teleports this character to the specified position, setting the appropriate flags and clearing the walking queue.
|
* Teleports this mob to the specified {@link Position}, setting the appropriate flags and clearing the walking
|
||||||
|
* queue.
|
||||||
*
|
*
|
||||||
* @param position The position.
|
* @param position The position.
|
||||||
*/
|
*/
|
||||||
@@ -388,11 +381,11 @@ public abstract class Mob extends Entity {
|
|||||||
teleporting = true;
|
teleporting = true;
|
||||||
this.position = position;
|
this.position = position;
|
||||||
walkingQueue.clear();
|
walkingQueue.clear();
|
||||||
stopAction(); // TODO do it on any movement is a must.. walking queue perhaps?
|
stopAction(); // TODO do it on any movement is a must... walking queue perhaps?
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Turns the character to face the specified position.
|
* Turns the mob to face the specified {@link Position}.
|
||||||
*
|
*
|
||||||
* @param position The position to face.
|
* @param position The position to face.
|
||||||
*/
|
*/
|
||||||
@@ -401,12 +394,12 @@ public abstract class Mob extends Entity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Updates the character's interacting character.
|
* Updates this mob's interacting mob.
|
||||||
*
|
*
|
||||||
* @param index The index of the interacting character.
|
* @param index The index of the interacting mob.
|
||||||
*/
|
*/
|
||||||
public void updateInteractingCharacter(int index) {
|
public void updateInteractingMob(int index) {
|
||||||
blockSet.add(SynchronizationBlock.createInteractingCharacterBlock(index));
|
blockSet.add(SynchronizationBlock.createInteractingMobBlock(index));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -1,19 +1,14 @@
|
|||||||
package org.apollo.game.model;
|
package org.apollo.game.model;
|
||||||
|
|
||||||
import org.apollo.game.event.Event;
|
|
||||||
import org.apollo.game.model.def.NpcDefinition;
|
import org.apollo.game.model.def.NpcDefinition;
|
||||||
|
import org.apollo.game.sync.block.SynchronizationBlock;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An {@link Npc} is a {@link Mob} that is not being controlled by a player.
|
* An {@link Npc} is a {@link Mob} that is not being controlled by a player.
|
||||||
*
|
*
|
||||||
* @author Major
|
* @author Major
|
||||||
*/
|
*/
|
||||||
public class Npc extends Mob {
|
public final class Npc extends Mob {
|
||||||
|
|
||||||
/**
|
|
||||||
* This npc's definition.
|
|
||||||
*/
|
|
||||||
private final NpcDefinition definition;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a new npc with the specified id and {@link Position}.
|
* Creates a new npc with the specified id and {@link Position}.
|
||||||
@@ -36,23 +31,31 @@ public class Npc extends Mob {
|
|||||||
this.definition = definition;
|
this.definition = definition;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the id of this npc. Shorthand for {@link #getDefinition().getId()}.
|
||||||
|
*
|
||||||
|
* @return The id.
|
||||||
|
*/
|
||||||
|
public int getId() {
|
||||||
|
return definition.getId();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Transforms this npc into the npc with the specified id.
|
||||||
|
*
|
||||||
|
* @param id The id.
|
||||||
|
*/
|
||||||
|
public void transform(int id) {
|
||||||
|
if (id < 0 || id > NpcDefinition.count()) {
|
||||||
|
throw new IllegalArgumentException("id to transform to is out of bounds");
|
||||||
|
}
|
||||||
|
definition = NpcDefinition.lookup(id);
|
||||||
|
blockSet.add(SynchronizationBlock.createTransformBlock(id));
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public EntityType getEntityType() {
|
public EntityType getEntityType() {
|
||||||
return EntityType.NPC;
|
return EntityType.NPC;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets this npc's {@link NpcDefinition}
|
|
||||||
*
|
|
||||||
* @return The definition.
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public NpcDefinition getNpcDefinition() {
|
|
||||||
return definition;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void send(Event event) {
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -12,6 +12,7 @@ import org.apollo.game.event.impl.ServerMessageEvent;
|
|||||||
import org.apollo.game.event.impl.SetWidgetTextEvent;
|
import org.apollo.game.event.impl.SetWidgetTextEvent;
|
||||||
import org.apollo.game.event.impl.SwitchTabInterfaceEvent;
|
import org.apollo.game.event.impl.SwitchTabInterfaceEvent;
|
||||||
import org.apollo.game.event.impl.UpdateRunEnergyEvent;
|
import org.apollo.game.event.impl.UpdateRunEnergyEvent;
|
||||||
|
import org.apollo.game.model.Inventory.StackMode;
|
||||||
import org.apollo.game.model.inter.InterfaceConstants;
|
import org.apollo.game.model.inter.InterfaceConstants;
|
||||||
import org.apollo.game.model.inter.InterfaceSet;
|
import org.apollo.game.model.inter.InterfaceSet;
|
||||||
import org.apollo.game.model.inter.bank.BankConstants;
|
import org.apollo.game.model.inter.bank.BankConstants;
|
||||||
@@ -102,20 +103,25 @@ public final class Player extends Mob {
|
|||||||
*/
|
*/
|
||||||
private Appearance appearance = Appearance.DEFAULT_APPEARANCE;
|
private Appearance appearance = Appearance.DEFAULT_APPEARANCE;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This player's bank.
|
||||||
|
*/
|
||||||
|
private final Inventory bank = new Inventory(InventoryConstants.BANK_CAPACITY, StackMode.STACK_ALWAYS);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A {@link List} of this player's mouse clicks.
|
* A {@link List} of this player's mouse clicks.
|
||||||
*/
|
*/
|
||||||
private Deque<Point> clicks = new ArrayDeque<Point>();
|
private Deque<Point> clicks = new ArrayDeque<Point>();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The player's credentials.
|
* This player's credentials.
|
||||||
*/
|
*/
|
||||||
private PlayerCredentials credentials;
|
private PlayerCredentials credentials;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A flag indicating if the player has designed their character.
|
* A flag indicating if the player has designed their avatar.
|
||||||
*/
|
*/
|
||||||
private boolean designedCharacter = false;
|
private boolean designedAvatar = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A flag which indicates there are npcs that couldn't be added.
|
* A flag which indicates there are npcs that couldn't be added.
|
||||||
@@ -150,7 +156,7 @@ public final class Player extends Mob {
|
|||||||
/**
|
/**
|
||||||
* This player's prayer icon.
|
* This player's prayer icon.
|
||||||
*/
|
*/
|
||||||
private int prayerIcon = -1;
|
private int prayerIcon = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The privilege level.
|
* The privilege level.
|
||||||
@@ -246,6 +252,15 @@ public final class Player extends Mob {
|
|||||||
return appearance;
|
return appearance;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the mob's bank.
|
||||||
|
*
|
||||||
|
* @return The bank.
|
||||||
|
*/
|
||||||
|
public Inventory getBank() {
|
||||||
|
return bank;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the {@link Deque} of clicks.
|
* Gets the {@link Deque} of clicks.
|
||||||
*
|
*
|
||||||
@@ -369,12 +384,12 @@ public final class Player extends Mob {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks if the player has designed their character.
|
* Checks if the player has designed their avatar.
|
||||||
*
|
*
|
||||||
* @return A flag indicating if the player has designed their character.
|
* @return A flag indicating if the player has designed their avatar.
|
||||||
*/
|
*/
|
||||||
public boolean hasDesignedCharacter() {
|
public boolean hasDesignedAvatar() {
|
||||||
return designedCharacter;
|
return designedAvatar;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -424,8 +439,6 @@ public final class Player extends Mob {
|
|||||||
InventoryListener fullInventoryListener = new FullInventoryListener(this,
|
InventoryListener fullInventoryListener = new FullInventoryListener(this,
|
||||||
FullInventoryListener.FULL_INVENTORY_MESSAGE);
|
FullInventoryListener.FULL_INVENTORY_MESSAGE);
|
||||||
InventoryListener fullBankListener = new FullInventoryListener(this, FullInventoryListener.FULL_BANK_MESSAGE);
|
InventoryListener fullBankListener = new FullInventoryListener(this, FullInventoryListener.FULL_BANK_MESSAGE);
|
||||||
InventoryListener fullEquipmentListener = new FullInventoryListener(this,
|
|
||||||
FullInventoryListener.FULL_EQUIPMENT_MESSAGE);
|
|
||||||
|
|
||||||
// equipment appearance listener
|
// equipment appearance listener
|
||||||
InventoryListener appearanceListener = new AppearanceInventoryListener(this);
|
InventoryListener appearanceListener = new AppearanceInventoryListener(this);
|
||||||
@@ -444,7 +457,6 @@ public final class Player extends Mob {
|
|||||||
bank.addListener(fullBankListener);
|
bank.addListener(fullBankListener);
|
||||||
equipment.addListener(syncEquipmentListener);
|
equipment.addListener(syncEquipmentListener);
|
||||||
equipment.addListener(appearanceListener);
|
equipment.addListener(appearanceListener);
|
||||||
equipment.addListener(fullEquipmentListener);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -530,7 +542,11 @@ public final class Player extends Mob {
|
|||||||
viewingDistance = 1;
|
viewingDistance = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
/**
|
||||||
|
* Sends an {@link Event} to this player.
|
||||||
|
*
|
||||||
|
* @param event The event.
|
||||||
|
*/
|
||||||
public void send(Event event) {
|
public void send(Event event) {
|
||||||
if (isActive()) {
|
if (isActive()) {
|
||||||
if (!queuedEvents.isEmpty()) {
|
if (!queuedEvents.isEmpty()) {
|
||||||
@@ -552,8 +568,8 @@ public final class Player extends Mob {
|
|||||||
send(new IdAssignmentEvent(getIndex(), members)); // TODO should this be sent when we reconnect?
|
send(new IdAssignmentEvent(getIndex(), members)); // TODO should this be sent when we reconnect?
|
||||||
sendMessage("Welcome to RuneScape.");
|
sendMessage("Welcome to RuneScape.");
|
||||||
|
|
||||||
if (!designedCharacter) {
|
if (!designedAvatar) {
|
||||||
interfaceSet.openWindow(InterfaceConstants.CHARACTER_DESIGN);
|
interfaceSet.openWindow(InterfaceConstants.AVATAR_DESIGN);
|
||||||
}
|
}
|
||||||
|
|
||||||
int[] tabs = InterfaceConstants.DEFAULT_INVENTORY_TABS;
|
int[] tabs = InterfaceConstants.DEFAULT_INVENTORY_TABS;
|
||||||
@@ -569,7 +585,7 @@ public final class Player extends Mob {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sends a message to the character.
|
* Sends a message to the player.
|
||||||
*
|
*
|
||||||
* @param message The message.
|
* @param message The message.
|
||||||
*/
|
*/
|
||||||
@@ -605,12 +621,12 @@ public final class Player extends Mob {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the character design flag.
|
* Sets the design flag.
|
||||||
*
|
*
|
||||||
* @param designedCharacter A flag indicating if the character has been designed.
|
* @param designed A flag indicating if the player has been designed.
|
||||||
*/
|
*/
|
||||||
public void setDesignedCharacter(boolean designedCharacter) {
|
public void setDesigned(boolean designed) {
|
||||||
this.designedCharacter = designedCharacter;
|
this.designedAvatar = designed;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -700,9 +716,14 @@ public final class Player extends Mob {
|
|||||||
this.withdrawingNotes = withdrawingNotes;
|
this.withdrawingNotes = withdrawingNotes;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void shout(String message, boolean chatBox) {
|
||||||
|
blockSet.add(SynchronizationBlock.createForceChatBlock(chatBox ? '~' + message : message));
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void teleport(Position position) {
|
public void teleport(Position position) {
|
||||||
super.teleport(position); // TODO put this in the same place as Character#teleport and WalkEventHandler!!
|
super.teleport(position);
|
||||||
if (interfaceSet.size() > 0) {
|
if (interfaceSet.size() > 0) {
|
||||||
interfaceSet.close();
|
interfaceSet.close();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -48,8 +48,8 @@ public final class SkillSet {
|
|||||||
* @return The minimum level.
|
* @return The minimum level.
|
||||||
*/
|
*/
|
||||||
public static int getLevelForExperience(double experience) {
|
public static int getLevelForExperience(double experience) {
|
||||||
int points = 0;
|
int points = 0, output = 0;
|
||||||
int output = 0;
|
|
||||||
for (int lvl = 1; lvl <= 99; lvl++) {
|
for (int lvl = 1; lvl <= 99; lvl++) {
|
||||||
points += Math.floor(lvl + 300.0 * Math.pow(2.0, lvl / 7.0));
|
points += Math.floor(lvl + 300.0 * Math.pow(2.0, lvl / 7.0));
|
||||||
output = (int) Math.floor(points / 4);
|
output = (int) Math.floor(points / 4);
|
||||||
@@ -110,22 +110,21 @@ public final class SkillSet {
|
|||||||
setSkill(id, new Skill(newExperience, newCurrentLevel, newMaximumLevel));
|
setSkill(id, new Skill(newExperience, newCurrentLevel, newMaximumLevel));
|
||||||
|
|
||||||
if (delta > 0) {
|
if (delta > 0) {
|
||||||
// here so it notifies using the updated skill
|
notifyLevelledUp(id); // here so it notifies using the updated skill
|
||||||
notifyLevelledUp(id);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds a listener.
|
* Adds a {@link SkillListener} to this set.
|
||||||
*
|
*
|
||||||
* @param listener The listener to add.
|
* @param listener The listener.
|
||||||
*/
|
*/
|
||||||
public boolean addListener(SkillListener listener) {
|
public boolean addListener(SkillListener listener) {
|
||||||
return listeners.add(listener);
|
return listeners.add(listener);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the combat level for this skill set.
|
* Calculates the combat level for this skill set.
|
||||||
*
|
*
|
||||||
* @return The combat level.
|
* @return The combat level.
|
||||||
*/
|
*/
|
||||||
@@ -138,15 +137,12 @@ public final class SkillSet {
|
|||||||
int ranged = skills[Skill.RANGED].getMaximumLevel();
|
int ranged = skills[Skill.RANGED].getMaximumLevel();
|
||||||
int magic = skills[Skill.MAGIC].getMaximumLevel();
|
int magic = skills[Skill.MAGIC].getMaximumLevel();
|
||||||
|
|
||||||
double combatLevel = (defence + hitpoints + Math.floor(prayer / 2)) * 0.25;
|
double base = (defence + hitpoints + Math.floor(prayer / 2)) * 0.25;
|
||||||
|
|
||||||
double melee = (attack + strength) * 0.325;
|
double melee = (attack + strength) * 0.325;
|
||||||
|
|
||||||
double range = ranged * 0.4875;
|
double range = ranged * 0.4875;
|
||||||
|
|
||||||
double mage = magic * 0.4875;
|
double mage = magic * 0.4875;
|
||||||
|
|
||||||
this.combatLevel = (int) (combatLevel + Math.max(melee, Math.max(range, mage)));
|
this.combatLevel = (int) (base + Math.max(melee, Math.max(range, mage)));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -169,7 +165,7 @@ public final class SkillSet {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the combat level for this skill set.
|
* Gets the combat level of this skill set.
|
||||||
*
|
*
|
||||||
* @return The combat level.
|
* @return The combat level.
|
||||||
*/
|
*/
|
||||||
@@ -218,13 +214,10 @@ public final class SkillSet {
|
|||||||
int cur = skills[id].getCurrentLevel();
|
int cur = skills[id].getCurrentLevel();
|
||||||
int max = skills[id].getMaximumLevel();
|
int max = skills[id].getMaximumLevel();
|
||||||
|
|
||||||
if (cur > max) {
|
if (cur == max) {
|
||||||
cur--;
|
|
||||||
} else if (max > cur) {
|
|
||||||
cur++;
|
|
||||||
} else {
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
cur += cur < max ? 1 : -1;
|
||||||
|
|
||||||
setSkill(id, new Skill(skills[id].getExperience(), cur, max));
|
setSkill(id, new Skill(skills[id].getExperience(), cur, max));
|
||||||
}
|
}
|
||||||
@@ -270,14 +263,14 @@ public final class SkillSet {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Removes all the listeners.
|
* Removes all the {@link SkillListener}s.
|
||||||
*/
|
*/
|
||||||
public void removeAllListeners() {
|
public void removeAllListeners() {
|
||||||
listeners.clear();
|
listeners.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Removes a listener.
|
* Removes a {@link SkillListener}.
|
||||||
*
|
*
|
||||||
* @param listener The listener to remove.
|
* @param listener The listener to remove.
|
||||||
*/
|
*/
|
||||||
@@ -286,7 +279,7 @@ public final class SkillSet {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets a skill.
|
* Sets a {@link Skill}.
|
||||||
*
|
*
|
||||||
* @param id The id.
|
* @param id The id.
|
||||||
* @param skill The skill.
|
* @param skill The skill.
|
||||||
@@ -298,7 +291,7 @@ public final class SkillSet {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the number of skills.
|
* Gets the number of {@link Skill}s in this set.
|
||||||
*
|
*
|
||||||
* @return The number of skills.
|
* @return The number of skills.
|
||||||
*/
|
*/
|
||||||
@@ -307,7 +300,7 @@ public final class SkillSet {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Re-enables the firing of events.
|
* Starts the firing of events.
|
||||||
*/
|
*/
|
||||||
public void startFiringEvents() {
|
public void startFiringEvents() {
|
||||||
firingEvents = true;
|
firingEvents = true;
|
||||||
|
|||||||
@@ -51,9 +51,9 @@ public final class WalkingQueue {
|
|||||||
private static final int MAXIMUM_SIZE = 128;
|
private static final int MAXIMUM_SIZE = 128;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The character whose walking queue this is.
|
* The mob whose walking queue this is.
|
||||||
*/
|
*/
|
||||||
private final Mob character;
|
private final Mob mob;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The old queue of directions.
|
* The old queue of directions.
|
||||||
@@ -71,32 +71,32 @@ public final class WalkingQueue {
|
|||||||
private boolean runningQueue;
|
private boolean runningQueue;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a walking queue for the specified character.
|
* Creates a walking queue for the specified mob.
|
||||||
*
|
*
|
||||||
* @param character The character.
|
* @param mob The mob.
|
||||||
*/
|
*/
|
||||||
public WalkingQueue(Mob character) {
|
public WalkingQueue(Mob mob) {
|
||||||
this.character = character;
|
this.mob = mob;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds the first step to the queue, attempting to connect the server and client position by looking at the previous
|
* Adds the first step to the queue, attempting to connect the server and client position by looking at the previous
|
||||||
* queue.
|
* queue.
|
||||||
*
|
*
|
||||||
* @param clientConnectionPosition The first step.
|
* @param clientPosition The first step.
|
||||||
* @return {@code true} if the queues could be connected correctly, {@code false} if not.
|
* @return {@code true} if the queues could be connected correctly, {@code false} if not.
|
||||||
*/
|
*/
|
||||||
public boolean addFirstStep(Position clientConnectionPosition) {
|
public boolean addFirstStep(Position clientPosition) {
|
||||||
Position serverPosition = character.getPosition();
|
Position serverPosition = mob.getPosition();
|
||||||
|
|
||||||
int deltaX = clientConnectionPosition.getX() - serverPosition.getX();
|
int deltaX = clientPosition.getX() - serverPosition.getX();
|
||||||
int deltaY = clientConnectionPosition.getY() - serverPosition.getY();
|
int deltaY = clientPosition.getY() - serverPosition.getY();
|
||||||
|
|
||||||
if (Direction.isConnectable(deltaX, deltaY)) {
|
if (Direction.isConnectable(deltaX, deltaY)) {
|
||||||
points.clear();
|
points.clear();
|
||||||
oldPoints.clear();
|
oldPoints.clear();
|
||||||
|
|
||||||
addStep(clientConnectionPosition);
|
addStep(clientPosition);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -119,7 +119,7 @@ public final class WalkingQueue {
|
|||||||
addStep(travelBackPosition);
|
addStep(travelBackPosition);
|
||||||
}
|
}
|
||||||
|
|
||||||
addStep(clientConnectionPosition);
|
addStep(clientPosition);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -147,7 +147,7 @@ public final class WalkingQueue {
|
|||||||
Direction direction = Direction.fromDeltas(deltaX, deltaY);
|
Direction direction = Direction.fromDeltas(deltaX, deltaY);
|
||||||
|
|
||||||
if (direction != Direction.NONE) {
|
if (direction != Direction.NONE) {
|
||||||
Point p = new Point(new Position(x, y, character.getPosition().getHeight()), direction);
|
Point p = new Point(new Position(x, y, mob.getPosition().getHeight()), direction);
|
||||||
points.add(p);
|
points.add(p);
|
||||||
oldPoints.add(p);
|
oldPoints.add(p);
|
||||||
}
|
}
|
||||||
@@ -202,7 +202,7 @@ public final class WalkingQueue {
|
|||||||
private Point getLast() {
|
private Point getLast() {
|
||||||
Point last = points.peekLast();
|
Point last = points.peekLast();
|
||||||
if (last == null) {
|
if (last == null) {
|
||||||
return new Point(character.getPosition(), Direction.NONE);
|
return new Point(mob.getPosition(), Direction.NONE);
|
||||||
}
|
}
|
||||||
return last;
|
return last;
|
||||||
}
|
}
|
||||||
@@ -211,17 +211,18 @@ public final class WalkingQueue {
|
|||||||
* Called every pulse, updates the queue.
|
* Called every pulse, updates the queue.
|
||||||
*/
|
*/
|
||||||
public void pulse() {
|
public void pulse() {
|
||||||
Position position = character.getPosition();
|
Position position = mob.getPosition();
|
||||||
|
|
||||||
Direction first = Direction.NONE;
|
Direction first = Direction.NONE;
|
||||||
Direction second = Direction.NONE;
|
Direction second = Direction.NONE;
|
||||||
|
|
||||||
Point next = points.poll();
|
Point next = points.poll();
|
||||||
if (next != null) {
|
if (next != null) {
|
||||||
|
mob.stopAction();
|
||||||
first = next.direction;
|
first = next.direction;
|
||||||
position = next.position;
|
position = next.position;
|
||||||
|
|
||||||
if (runningQueue /* or run toggled AND enough energy */) {
|
if (runningQueue /* and enough energy */) {
|
||||||
next = points.poll();
|
next = points.poll();
|
||||||
if (next != null) {
|
if (next != null) {
|
||||||
second = next.direction;
|
second = next.direction;
|
||||||
@@ -230,8 +231,8 @@ public final class WalkingQueue {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
character.setDirections(first, second);
|
mob.setDirections(first, second);
|
||||||
character.setPosition(position);
|
mob.setPosition(position);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -26,13 +26,13 @@ import org.apollo.game.model.sector.SectorRepository;
|
|||||||
import org.apollo.game.scheduling.ScheduledTask;
|
import org.apollo.game.scheduling.ScheduledTask;
|
||||||
import org.apollo.game.scheduling.Scheduler;
|
import org.apollo.game.scheduling.Scheduler;
|
||||||
import org.apollo.io.EquipmentDefinitionParser;
|
import org.apollo.io.EquipmentDefinitionParser;
|
||||||
import org.apollo.util.CharacterRepository;
|
import org.apollo.util.MobRepository;
|
||||||
import org.apollo.util.plugin.PluginManager;
|
import org.apollo.util.plugin.PluginManager;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The world class is a singleton which contains objects like the {@link CharacterRepository} for players and NPCs. It
|
* The world class is a singleton which contains objects like the {@link MobRepository} for players and NPCs. It should
|
||||||
* should only contain things relevant to the in-game world and not classes which deal with I/O and such (these may be
|
* only contain things relevant to the in-game world and not classes which deal with I/O and such (these may be better
|
||||||
* better off inside some custom {@link Service} or other code, however, the circumstances are rare).
|
* off inside some custom {@link Service} or other code, however, the circumstances are rare).
|
||||||
*
|
*
|
||||||
* @author Graham
|
* @author Graham
|
||||||
*/
|
*/
|
||||||
@@ -86,20 +86,14 @@ public final class World {
|
|||||||
private final CommandDispatcher dispatcher = new CommandDispatcher();
|
private final CommandDispatcher dispatcher = new CommandDispatcher();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The {@link CharacterRepository} of {@link Npc}s.
|
* The {@link MobRepository} of {@link Npc}s.
|
||||||
*/
|
*/
|
||||||
private final CharacterRepository<Npc> npcRepository = new CharacterRepository<Npc>(WorldConstants.MAXIMUM_NPCS);
|
private final MobRepository<Npc> npcRepository = new MobRepository<Npc>(WorldConstants.MAXIMUM_NPCS);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The {@link CharacterRepository} of {@link Player}s.
|
* The {@link MobRepository} of {@link Player}s.
|
||||||
*/
|
*/
|
||||||
private final CharacterRepository<Player> playerRepository = new CharacterRepository<Player>(
|
private final MobRepository<Player> playerRepository = new MobRepository<Player>(WorldConstants.MAXIMUM_PLAYERS);
|
||||||
WorldConstants.MAXIMUM_PLAYERS);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The release number (i.e. version) of this world.
|
|
||||||
*/
|
|
||||||
private int releaseNumber;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A {@link Map} of player usernames and the player objects.
|
* A {@link Map} of player usernames and the player objects.
|
||||||
@@ -111,6 +105,11 @@ public final class World {
|
|||||||
*/
|
*/
|
||||||
private PluginManager pluginManager;
|
private PluginManager pluginManager;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The release number (i.e. version) of this world.
|
||||||
|
*/
|
||||||
|
private int releaseNumber;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This world's {@link SectorRepository}.
|
* This world's {@link SectorRepository}.
|
||||||
*/
|
*/
|
||||||
@@ -128,7 +127,7 @@ public final class World {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the command dispatcher. TODO should this be here?
|
* Gets the command dispatcher.
|
||||||
*
|
*
|
||||||
* @return The command dispatcher.
|
* @return The command dispatcher.
|
||||||
*/
|
*/
|
||||||
@@ -141,7 +140,7 @@ public final class World {
|
|||||||
*
|
*
|
||||||
* @return The npc repository.
|
* @return The npc repository.
|
||||||
*/
|
*/
|
||||||
public CharacterRepository<Npc> getNpcRepository() {
|
public MobRepository<Npc> getNpcRepository() {
|
||||||
return npcRepository;
|
return npcRepository;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -156,14 +155,14 @@ public final class World {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the character repository.
|
* Gets the player repository.
|
||||||
* <p>
|
* <p>
|
||||||
* Note: players should be registered and unregistered using {@link World#register(Player)} and
|
* Note: players should be registered and unregistered using {@link World#register(Player)} and
|
||||||
* {@link World#unregister(Player)} respectively, not by adding to or removing from this repository directly.
|
* {@link World#unregister(Player)} respectively, not by adding to or removing from this repository directly.
|
||||||
*
|
*
|
||||||
* @return The character repository.
|
* @return The player repository.
|
||||||
*/
|
*/
|
||||||
public CharacterRepository<Player> getPlayerRepository() {
|
public MobRepository<Player> getPlayerRepository() {
|
||||||
return playerRepository;
|
return playerRepository;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -176,6 +175,15 @@ public final class World {
|
|||||||
return pluginManager;
|
return pluginManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the release number of this world.
|
||||||
|
*
|
||||||
|
* @return The release number.
|
||||||
|
*/
|
||||||
|
public int getReleaseNumber() {
|
||||||
|
return releaseNumber;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initialises the world by loading definitions from the specified file system.
|
* Initialises the world by loading definitions from the specified file system.
|
||||||
*
|
*
|
||||||
@@ -288,15 +296,6 @@ public final class World {
|
|||||||
return RegistrationStatus.WORLD_FULL;
|
return RegistrationStatus.WORLD_FULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the release number of this world.
|
|
||||||
*
|
|
||||||
* @return The release number.
|
|
||||||
*/
|
|
||||||
public int getReleaseNumber() {
|
|
||||||
return releaseNumber;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Schedules a new task.
|
* Schedules a new task.
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -3,4 +3,3 @@
|
|||||||
* NPCs, etc.
|
* NPCs, etc.
|
||||||
*/
|
*/
|
||||||
package org.apollo.game.model.def;
|
package org.apollo.game.model.def;
|
||||||
|
|
||||||
|
|||||||
@@ -8,9 +8,9 @@ package org.apollo.game.model.inter;
|
|||||||
public class InterfaceConstants {
|
public class InterfaceConstants {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The character design interface id.
|
* The avatar design interface id.
|
||||||
*/
|
*/
|
||||||
public static final int CHARACTER_DESIGN = 3559;
|
public static final int AVATAR_DESIGN = 3559;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The default inventory tab ids.
|
* The default inventory tab ids.
|
||||||
|
|||||||
@@ -63,7 +63,6 @@ public final class InterfaceSet {
|
|||||||
*/
|
*/
|
||||||
public void close() {
|
public void close() {
|
||||||
closeAndNotify();
|
closeAndNotify();
|
||||||
|
|
||||||
player.send(new CloseInterfaceEvent());
|
player.send(new CloseInterfaceEvent());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -33,7 +33,6 @@ public final class BankUtils {
|
|||||||
Inventory bank = player.getBank();
|
Inventory bank = player.getBank();
|
||||||
|
|
||||||
Item item = inventory.get(slot);
|
Item item = inventory.get(slot);
|
||||||
|
|
||||||
int newId = ItemDefinition.noteToItem(item.getId());
|
int newId = ItemDefinition.noteToItem(item.getId());
|
||||||
|
|
||||||
if (bank.freeSlots() == 0 && !bank.contains(item.getId())) {
|
if (bank.freeSlots() == 0 && !bank.contains(item.getId())) {
|
||||||
@@ -126,7 +125,7 @@ public final class BankUtils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Default private constructor to prevent insantiation.
|
* Default private constructor to prevent instantiation.
|
||||||
*/
|
*/
|
||||||
private BankUtils() {
|
private BankUtils() {
|
||||||
|
|
||||||
|
|||||||
@@ -2,4 +2,3 @@
|
|||||||
* Contains bank-related classes.
|
* Contains bank-related classes.
|
||||||
*/
|
*/
|
||||||
package org.apollo.game.model.inter.bank;
|
package org.apollo.game.model.inter.bank;
|
||||||
|
|
||||||
|
|||||||
@@ -2,4 +2,3 @@
|
|||||||
* Contains interface-related classes.
|
* Contains interface-related classes.
|
||||||
*/
|
*/
|
||||||
package org.apollo.game.model.inter;
|
package org.apollo.game.model.inter;
|
||||||
|
|
||||||
|
|||||||
@@ -17,11 +17,6 @@ public final class FullInventoryListener extends InventoryAdapter {
|
|||||||
*/
|
*/
|
||||||
public static final String FULL_BANK_MESSAGE = "Not enough bank space.";
|
public static final String FULL_BANK_MESSAGE = "Not enough bank space.";
|
||||||
|
|
||||||
/**
|
|
||||||
* The equipment full message.
|
|
||||||
*/
|
|
||||||
public static final String FULL_EQUIPMENT_MESSAGE = "Not enough equipment space."; // TODO confirm if possible
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The inventory full message.
|
* The inventory full message.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -12,17 +12,17 @@ public abstract class InventoryAdapter implements InventoryListener {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void capacityExceeded(Inventory inventory) {
|
public void capacityExceeded(Inventory inventory) {
|
||||||
/* empty */
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void itemsUpdated(Inventory inventory) {
|
public void itemsUpdated(Inventory inventory) {
|
||||||
/* empty */
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void itemUpdated(Inventory inventory, int slot, Item item) {
|
public void itemUpdated(Inventory inventory, int slot, Item item) {
|
||||||
/* empty */
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -2,4 +2,3 @@
|
|||||||
* Contains inventory listeners.
|
* Contains inventory listeners.
|
||||||
*/
|
*/
|
||||||
package org.apollo.game.model.inv;
|
package org.apollo.game.model.inv;
|
||||||
|
|
||||||
|
|||||||
@@ -2,4 +2,3 @@
|
|||||||
* Contains models related to in-game objects.
|
* Contains models related to in-game objects.
|
||||||
*/
|
*/
|
||||||
package org.apollo.game.model.obj;
|
package org.apollo.game.model.obj;
|
||||||
|
|
||||||
|
|||||||
@@ -3,4 +3,3 @@
|
|||||||
* players and NPCs.
|
* players and NPCs.
|
||||||
*/
|
*/
|
||||||
package org.apollo.game.model;
|
package org.apollo.game.model;
|
||||||
|
|
||||||
|
|||||||
@@ -12,17 +12,17 @@ public abstract class SkillAdapter implements SkillListener {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void levelledUp(SkillSet set, int id, Skill skill) {
|
public void levelledUp(SkillSet set, int id, Skill skill) {
|
||||||
/* empty */
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void skillsUpdated(SkillSet set) {
|
public void skillsUpdated(SkillSet set) {
|
||||||
/* empty */
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void skillUpdated(SkillSet set, int id, Skill skill) {
|
public void skillUpdated(SkillSet set, int id, Skill skill) {
|
||||||
/* empty */
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -11,25 +11,25 @@ import org.apollo.game.model.SkillSet;
|
|||||||
public interface SkillListener {
|
public interface SkillListener {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called when a skill is levelled up.
|
* Called when a {@link Skill} is levelled up.
|
||||||
*
|
*
|
||||||
* @param set The skill set.
|
* @param set The {@link SkillSet}.
|
||||||
* @param id The skill's id.
|
* @param id The skill's id.
|
||||||
* @param skill The skill.
|
* @param skill The skill.
|
||||||
*/
|
*/
|
||||||
public void levelledUp(SkillSet set, int id, Skill skill);
|
public void levelledUp(SkillSet set, int id, Skill skill);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called when all the skills are updated.
|
* Called when all {@link Skill}s are updated.
|
||||||
*
|
*
|
||||||
* @param set The skill set.
|
* @param set The {@link SkillSet}.
|
||||||
*/
|
*/
|
||||||
public void skillsUpdated(SkillSet set);
|
public void skillsUpdated(SkillSet set);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called when a single skill is updated.
|
* Called when a single {@link Skill} is updated.
|
||||||
*
|
*
|
||||||
* @param set The skill set.
|
* @param set The {@link SkillSet}.
|
||||||
* @param id The skill's id.
|
* @param id The skill's id.
|
||||||
* @param skill The skill.
|
* @param skill The skill.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -2,4 +2,3 @@
|
|||||||
* Contains skill listeners.
|
* Contains skill listeners.
|
||||||
*/
|
*/
|
||||||
package org.apollo.game.model.skill;
|
package org.apollo.game.model.skill;
|
||||||
|
|
||||||
|
|||||||
@@ -2,4 +2,3 @@
|
|||||||
* Contains classes related to the game server.
|
* Contains classes related to the game server.
|
||||||
*/
|
*/
|
||||||
package org.apollo.game;
|
package org.apollo.game;
|
||||||
|
|
||||||
|
|||||||
@@ -12,26 +12,26 @@ import org.apollo.game.scheduling.ScheduledTask;
|
|||||||
public final class SkillNormalizationTask extends ScheduledTask {
|
public final class SkillNormalizationTask extends ScheduledTask {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The character.
|
* The mob.
|
||||||
*/
|
*/
|
||||||
private final Mob character;
|
private final Mob mob;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates the skill normalization task.
|
* Creates the skill normalization task.
|
||||||
*
|
*
|
||||||
* @param character The character.
|
* @param mob The mob.
|
||||||
*/
|
*/
|
||||||
public SkillNormalizationTask(Mob character) {
|
public SkillNormalizationTask(Mob mob) {
|
||||||
super(100, false);
|
super(100, false);
|
||||||
this.character = character;
|
this.mob = mob;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void execute() {
|
public void execute() {
|
||||||
if (!character.isActive()) { // TODO is this check okay for this? an NPC could be temporarily removed from list
|
if (!mob.isActive()) {
|
||||||
stop();
|
stop();
|
||||||
} else {
|
} else {
|
||||||
character.getSkillSet().normalize();
|
mob.getSkillSet().normalize();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2,4 +2,3 @@
|
|||||||
* Contains scheduled task implementations.
|
* Contains scheduled task implementations.
|
||||||
*/
|
*/
|
||||||
package org.apollo.game.scheduling.impl;
|
package org.apollo.game.scheduling.impl;
|
||||||
|
|
||||||
|
|||||||
@@ -3,4 +3,3 @@
|
|||||||
* future pulses periodically.
|
* future pulses periodically.
|
||||||
*/
|
*/
|
||||||
package org.apollo.game.scheduling;
|
package org.apollo.game.scheduling;
|
||||||
|
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ import org.apollo.game.sync.task.PostPlayerSynchronizationTask;
|
|||||||
import org.apollo.game.sync.task.PreNpcSynchronizationTask;
|
import org.apollo.game.sync.task.PreNpcSynchronizationTask;
|
||||||
import org.apollo.game.sync.task.PrePlayerSynchronizationTask;
|
import org.apollo.game.sync.task.PrePlayerSynchronizationTask;
|
||||||
import org.apollo.game.sync.task.SynchronizationTask;
|
import org.apollo.game.sync.task.SynchronizationTask;
|
||||||
import org.apollo.util.CharacterRepository;
|
import org.apollo.util.MobRepository;
|
||||||
import org.apollo.util.NamedThreadFactory;
|
import org.apollo.util.NamedThreadFactory;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -54,8 +54,8 @@ public final class ParallelClientSynchronizer extends ClientSynchronizer {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void synchronize() {
|
public void synchronize() {
|
||||||
CharacterRepository<Player> players = World.getWorld().getPlayerRepository();
|
MobRepository<Player> players = World.getWorld().getPlayerRepository();
|
||||||
CharacterRepository<Npc> npcs = World.getWorld().getNpcRepository();
|
MobRepository<Npc> npcs = World.getWorld().getNpcRepository();
|
||||||
int playerCount = players.size();
|
int playerCount = players.size();
|
||||||
int npcCount = npcs.size();
|
int npcCount = npcs.size();
|
||||||
|
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ import org.apollo.game.sync.task.PostPlayerSynchronizationTask;
|
|||||||
import org.apollo.game.sync.task.PreNpcSynchronizationTask;
|
import org.apollo.game.sync.task.PreNpcSynchronizationTask;
|
||||||
import org.apollo.game.sync.task.PrePlayerSynchronizationTask;
|
import org.apollo.game.sync.task.PrePlayerSynchronizationTask;
|
||||||
import org.apollo.game.sync.task.SynchronizationTask;
|
import org.apollo.game.sync.task.SynchronizationTask;
|
||||||
import org.apollo.util.CharacterRepository;
|
import org.apollo.util.MobRepository;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An implementation of {@link ClientSynchronizer} which runs in a single thread (the {@link GameService} thread from
|
* An implementation of {@link ClientSynchronizer} which runs in a single thread (the {@link GameService} thread from
|
||||||
@@ -26,8 +26,8 @@ public final class SequentialClientSynchronizer extends ClientSynchronizer {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void synchronize() {
|
public void synchronize() {
|
||||||
CharacterRepository<Player> players = World.getWorld().getPlayerRepository();
|
MobRepository<Player> players = World.getWorld().getPlayerRepository();
|
||||||
CharacterRepository<Npc> npcs = World.getWorld().getNpcRepository();
|
MobRepository<Npc> npcs = World.getWorld().getNpcRepository();
|
||||||
|
|
||||||
for (Player player : players) {
|
for (Player player : players) {
|
||||||
SynchronizationTask task = new PrePlayerSynchronizationTask(player);
|
SynchronizationTask task = new PrePlayerSynchronizationTask(player);
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ import org.apollo.game.model.Animation;
|
|||||||
public final class AnimationBlock extends SynchronizationBlock {
|
public final class AnimationBlock extends SynchronizationBlock {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The animation.
|
* The {@link Animation}.
|
||||||
*/
|
*/
|
||||||
private final Animation animation;
|
private final Animation animation;
|
||||||
|
|
||||||
@@ -24,7 +24,7 @@ public final class AnimationBlock extends SynchronizationBlock {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the animation.
|
* Gets the {@link Animation}.
|
||||||
*
|
*
|
||||||
* @return The animation.
|
* @return The animation.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -53,11 +53,12 @@ public final class AppearanceBlock extends SynchronizationBlock {
|
|||||||
/**
|
/**
|
||||||
* Creates the appearance block.
|
* Creates the appearance block.
|
||||||
*
|
*
|
||||||
* @param name The player's name.
|
* @param name The player's username.
|
||||||
* @param appearance The appearance.
|
* @param appearance The appearance.
|
||||||
* @param combat The player's combat.
|
* @param combat The player's combat.
|
||||||
* @param skill The player's skill, or 0 if showing the combat level.
|
* @param skill The player's skill, or 0 if showing the combat level.
|
||||||
* @param equipment The player's equipment.
|
* @param equipment The player's equipment.
|
||||||
|
* @param npcId The npc id of the player, if they are appearing as an npc (otherwise {@code -1}).
|
||||||
*/
|
*/
|
||||||
AppearanceBlock(long name, Appearance appearance, int combat, int skill, Inventory equipment, int prayerIcon,
|
AppearanceBlock(long name, Appearance appearance, int combat, int skill, Inventory equipment, int prayerIcon,
|
||||||
int headIcon, int npcId) {
|
int headIcon, int npcId) {
|
||||||
|
|||||||
@@ -11,12 +11,12 @@ import org.apollo.game.model.Player.PrivilegeLevel;
|
|||||||
public final class ChatBlock extends SynchronizationBlock {
|
public final class ChatBlock extends SynchronizationBlock {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The chat event.
|
* The {@link ChatEvent}.
|
||||||
*/
|
*/
|
||||||
private final ChatEvent chatEvent;
|
private final ChatEvent chatEvent;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The privilege level.
|
* The {@link PrivilegeLevel}.
|
||||||
*/
|
*/
|
||||||
private final PrivilegeLevel privilegeLevel;
|
private final PrivilegeLevel privilegeLevel;
|
||||||
|
|
||||||
|
|||||||
@@ -2,8 +2,8 @@ package org.apollo.game.sync.block;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* The Force Chat {@link SynchronizationBlock}. This is a block that can be implemented in both player and npc
|
* The Force Chat {@link SynchronizationBlock}. This is a block that can be implemented in both player and npc
|
||||||
* synchronization tasks, and will cause the character to shout the specified text. It is not possible to add colour or
|
* synchronization tasks, and will cause the mob to shout the specified text. It is not possible to add colour or effect
|
||||||
* effect (e.g. wave or scroll) to this block.
|
* (e.g. wave or scroll) to this block.
|
||||||
*
|
*
|
||||||
* @author Major
|
* @author Major
|
||||||
*/
|
*/
|
||||||
@@ -17,7 +17,7 @@ public class ForceChatBlock extends SynchronizationBlock {
|
|||||||
/**
|
/**
|
||||||
* Creates a new force chat [@link SynchronizationBlock}.
|
* Creates a new force chat [@link SynchronizationBlock}.
|
||||||
*
|
*
|
||||||
* @param message The message the character will say.
|
* @param message The message the mob will say.
|
||||||
*/
|
*/
|
||||||
public ForceChatBlock(String message) {
|
public ForceChatBlock(String message) {
|
||||||
this.message = message;
|
this.message = message;
|
||||||
|
|||||||
@@ -48,8 +48,8 @@ public class ForceMovementBlock extends SynchronizationBlock {
|
|||||||
* @param travelDurationY The length of time (in game pulses) the player's movement along the Y axis will last.
|
* @param travelDurationY The length of time (in game pulses) the player's movement along the Y axis will last.
|
||||||
* @param direction The direction the player should move.
|
* @param direction The direction the player should move.
|
||||||
*/
|
*/
|
||||||
public ForceMovementBlock(Position initialPosition, Position finalPosition, int travelDurationX,
|
ForceMovementBlock(Position initialPosition, Position finalPosition, int travelDurationX, int travelDurationY,
|
||||||
int travelDurationY, Direction direction) {
|
Direction direction) {
|
||||||
this.initialPosition = initialPosition;
|
this.initialPosition = initialPosition;
|
||||||
this.finalPosition = finalPosition;
|
this.finalPosition = finalPosition;
|
||||||
this.travelDurationX = travelDurationX;
|
this.travelDurationX = travelDurationX;
|
||||||
|
|||||||
@@ -1,15 +1,14 @@
|
|||||||
package org.apollo.game.sync.block;
|
package org.apollo.game.sync.block;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The Hit Update {@link SynchronizationBlock}. This is a simple implementation designed so that you can integrate it
|
* The hit update {@link SynchronizationBlock}. Both npcs and players can implement this block.
|
||||||
* easily with your combat system. Both npcs and players can implement this block.
|
|
||||||
*
|
*
|
||||||
* @author Major
|
* @author Major
|
||||||
*/
|
*/
|
||||||
public class HitUpdateBlock extends SynchronizationBlock {
|
public class HitUpdateBlock extends SynchronizationBlock {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The {@link org.apollo.game.model.Mob}'s current health.
|
* The mob's current health.
|
||||||
*/
|
*/
|
||||||
private final int currentHealth;
|
private final int currentHealth;
|
||||||
|
|
||||||
@@ -19,7 +18,7 @@ public class HitUpdateBlock extends SynchronizationBlock {
|
|||||||
private final int damage;
|
private final int damage;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The {@link org.apollo.game.model.Mob}'s maximum health.
|
* The mob's maximum health.
|
||||||
*/
|
*/
|
||||||
private final int maximumHealth;
|
private final int maximumHealth;
|
||||||
|
|
||||||
@@ -31,20 +30,20 @@ public class HitUpdateBlock extends SynchronizationBlock {
|
|||||||
/**
|
/**
|
||||||
* Creates a new Hit Update block.
|
* Creates a new Hit Update block.
|
||||||
*
|
*
|
||||||
* @param hitDamage The damage dealt by the hit.
|
* @param damage The damage dealt by the hit.
|
||||||
* @param hitType The type of hit.
|
* @param type The type of hit.
|
||||||
* @param currentHealth The current health of the {@link org.apollo.game.model.Mob}.
|
* @param currentHealth The current health of the mob.
|
||||||
* @param maximumHealth The maximum health of the {@link org.apollo.game.model.Mob}.
|
* @param maximumHealth The maximum health of the mob.
|
||||||
*/
|
*/
|
||||||
public HitUpdateBlock(int hitDamage, int hitType, int currentHealth, int maximumHealth) {
|
HitUpdateBlock(int damage, int type, int currentHealth, int maximumHealth) {
|
||||||
damage = hitDamage;
|
this.damage = damage;
|
||||||
type = hitType;
|
this.type = type;
|
||||||
this.currentHealth = currentHealth;
|
this.currentHealth = currentHealth;
|
||||||
this.maximumHealth = maximumHealth;
|
this.maximumHealth = maximumHealth;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the current health of the {@link org.apollo.game.model.Mob}.
|
* Gets the current health of the mob.
|
||||||
*
|
*
|
||||||
* @return The current health;
|
* @return The current health;
|
||||||
*/
|
*/
|
||||||
@@ -62,7 +61,7 @@ public class HitUpdateBlock extends SynchronizationBlock {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the maximum health of the {@link org.apollo.game.model.Mob}.
|
* Gets the maximum health of the mob.
|
||||||
*
|
*
|
||||||
* @return The maximum health.
|
* @return The maximum health.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -1,36 +0,0 @@
|
|||||||
package org.apollo.game.sync.block;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The InteractingCharacterBlock {@link SynchronizationBlock}.
|
|
||||||
*
|
|
||||||
* @note As all Apollo events should be immutable to avoid concurency issues, this uses the index of the character
|
|
||||||
* rather than the actual character. This should not be changed.
|
|
||||||
*
|
|
||||||
* @author Major
|
|
||||||
*/
|
|
||||||
public class InteractingCharacterBlock extends SynchronizationBlock {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The index of the character.
|
|
||||||
*/
|
|
||||||
private final int characterIndex;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Creates the interacting character block.
|
|
||||||
*
|
|
||||||
* @param characterIndex The index of the current interacting character.
|
|
||||||
*/
|
|
||||||
public InteractingCharacterBlock(int characterIndex) {
|
|
||||||
this.characterIndex = characterIndex;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the interacting character's current index.
|
|
||||||
*
|
|
||||||
* @return The index of the character.
|
|
||||||
*/
|
|
||||||
public int getInteractingCharacterIndex() {
|
|
||||||
return characterIndex;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,36 @@
|
|||||||
|
package org.apollo.game.sync.block;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The interacting mob {@link SynchronizationBlock}.
|
||||||
|
* <p>
|
||||||
|
* Note: As all Apollo events should be immutable to avoid concurrency issues, this uses the index of the mob rather
|
||||||
|
* than the actual mob. This should not be changed.
|
||||||
|
*
|
||||||
|
* @author Major
|
||||||
|
*/
|
||||||
|
public class InteractingMobBlock extends SynchronizationBlock {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The index of the mob.
|
||||||
|
*/
|
||||||
|
private final int mobIndex;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates the interacting mob block.
|
||||||
|
*
|
||||||
|
* @param mobIndex The index of the current interacting mob.
|
||||||
|
*/
|
||||||
|
public InteractingMobBlock(int mobIndex) {
|
||||||
|
this.mobIndex = mobIndex;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the interacting mob's index.
|
||||||
|
*
|
||||||
|
* @return The index.
|
||||||
|
*/
|
||||||
|
public int getInteractingMobIndex() {
|
||||||
|
return mobIndex;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
+15
-15
@@ -1,16 +1,16 @@
|
|||||||
package org.apollo.game.sync.block;
|
package org.apollo.game.sync.block;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The Second Hit Update {@link SynchronizationBlock}. This is believed to be used for when multiple attacks happen at
|
* The secondary hit update {@link SynchronizationBlock}. This is used for when multiple attacks happen at once (for
|
||||||
* once (for example, the dragon-dagger special attack). This block can be implemented by both players and npcs.
|
* example, the dragon-dagger special attack). This block can be implemented by both players and npcs.
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
* @author Major
|
* @author Major
|
||||||
*/
|
*/
|
||||||
public class SecondHitUpdateBlock extends SynchronizationBlock {
|
public class SecondaryHitUpdateBlock extends SynchronizationBlock {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The character's current health.
|
* The mob's current health.
|
||||||
*/
|
*/
|
||||||
private final int currentHealth;
|
private final int currentHealth;
|
||||||
|
|
||||||
@@ -20,7 +20,7 @@ public class SecondHitUpdateBlock extends SynchronizationBlock {
|
|||||||
private final int damage;
|
private final int damage;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The character's maximum health.
|
* The mob's maximum health.
|
||||||
*/
|
*/
|
||||||
private final int maximumHealth;
|
private final int maximumHealth;
|
||||||
|
|
||||||
@@ -30,22 +30,22 @@ public class SecondHitUpdateBlock extends SynchronizationBlock {
|
|||||||
private final int type;
|
private final int type;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a new Second Hit Update block.
|
* Creates a new secondary hit update block.
|
||||||
*
|
*
|
||||||
* @param hitDamage The damage dealt by the hit.
|
* @param damage The damage dealt by the hit.
|
||||||
* @param hitType The type of hit.
|
* @param type The type of hit.
|
||||||
* @param currentHealth The current health of the character.
|
* @param currentHealth The current health of the mob.
|
||||||
* @param maximumHealth The maximum health of the character.
|
* @param maximumHealth The maximum health of the mob.
|
||||||
*/
|
*/
|
||||||
public SecondHitUpdateBlock(int hitDamage, int hitType, int currentHealth, int maximumHealth) {
|
SecondaryHitUpdateBlock(int damage, int type, int currentHealth, int maximumHealth) {
|
||||||
damage = hitDamage;
|
this.damage = damage;
|
||||||
type = hitType;
|
this.type = type;
|
||||||
this.currentHealth = currentHealth;
|
this.currentHealth = currentHealth;
|
||||||
this.maximumHealth = maximumHealth;
|
this.maximumHealth = maximumHealth;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the current health of the character.
|
* Gets the current health of the mob.
|
||||||
*
|
*
|
||||||
* @return The current health;
|
* @return The current health;
|
||||||
*/
|
*/
|
||||||
@@ -63,7 +63,7 @@ public class SecondHitUpdateBlock extends SynchronizationBlock {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the maximum health of the character.
|
* Gets the maximum health of the mob.
|
||||||
*
|
*
|
||||||
* @return The maximum health.
|
* @return The maximum health.
|
||||||
*/
|
*/
|
||||||
@@ -63,11 +63,11 @@ public abstract class SynchronizationBlock {
|
|||||||
/**
|
/**
|
||||||
* Creates a new force movement block with the specified parameters.
|
* Creates a new force movement block with the specified parameters.
|
||||||
*
|
*
|
||||||
* @param initialPosition The initial position of the player.
|
* @param initialPosition The initial {@link Position} of the player.
|
||||||
* @param finalPosition The final position of the player.
|
* @param finalPosition The final {@link Position} of the player
|
||||||
* @param travelDurationX The duration motion along the X axis will occur.
|
* @param travelDurationX The length of time (in game pulses) the player's movement along the X axis will last.
|
||||||
* @param travelDurationY The duration motion along the Y axis will occur.
|
* @param travelDurationY The length of time (in game pulses) the player's movement along the Y axis will last.
|
||||||
* @param direction The direction the player will face.
|
* @param direction The direction the player should move.
|
||||||
* @return The force movement block.
|
* @return The force movement block.
|
||||||
*/
|
*/
|
||||||
public static SynchronizationBlock createForceMovementBlock(Position initialPosition, Position finalPosition,
|
public static SynchronizationBlock createForceMovementBlock(Position initialPosition, Position finalPosition,
|
||||||
@@ -86,13 +86,39 @@ public abstract class SynchronizationBlock {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates an interacting character block with the specified character index.
|
* Creates a new hit or secondary hit update block
|
||||||
*
|
*
|
||||||
* @param index The index of the interacting character.
|
* @param damage The damage dealt by the hit.
|
||||||
* @return The interacting character block.
|
* @param type The type of hit.
|
||||||
|
* @param currentHealth The current health of the mob.
|
||||||
|
* @param maximumHealth The maximum health of the mob.
|
||||||
|
* @param secondary If the block is a secondary hit or not.
|
||||||
|
* @return The hit update block.
|
||||||
*/
|
*/
|
||||||
public static SynchronizationBlock createInteractingCharacterBlock(int index) {
|
public static SynchronizationBlock createHitUpdateBlock(int damage, int type, int currentHealth, int maximumHealth,
|
||||||
return new InteractingCharacterBlock(index);
|
boolean secondary) {
|
||||||
|
return secondary ? new SecondaryHitUpdateBlock(damage, type, currentHealth, maximumHealth)
|
||||||
|
: new HitUpdateBlock(damage, type, currentHealth, maximumHealth);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates an interacting mob block with the specified index.
|
||||||
|
*
|
||||||
|
* @param index The index of the mob being interacted with.
|
||||||
|
* @return The interacting mob block.
|
||||||
|
*/
|
||||||
|
public static SynchronizationBlock createInteractingMobBlock(int index) {
|
||||||
|
return new InteractingMobBlock(index);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a transform block with the specified id.
|
||||||
|
*
|
||||||
|
* @param id The id.
|
||||||
|
* @return The transform block.
|
||||||
|
*/
|
||||||
|
public static SynchronizationBlock createTransformBlock(int id) {
|
||||||
|
return new TransformBlock(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -11,9 +11,9 @@ import java.util.Map;
|
|||||||
public final class SynchronizationBlockSet implements Cloneable {
|
public final class SynchronizationBlockSet implements Cloneable {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The blocks.
|
* A {@link Map} of {@link SynchronizationBlock}s.
|
||||||
*/
|
*/
|
||||||
private final Map<Class<? extends SynchronizationBlock>, SynchronizationBlock> blocks = new HashMap<Class<? extends SynchronizationBlock>, SynchronizationBlock>();
|
private final Map<Class<? extends SynchronizationBlock>, SynchronizationBlock> blocks = new HashMap<>();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds a {@link SynchronizationBlock}.
|
* Adds a {@link SynchronizationBlock}.
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ public final class TransformBlock extends SynchronizationBlock {
|
|||||||
*
|
*
|
||||||
* @param id The id.
|
* @param id The id.
|
||||||
*/
|
*/
|
||||||
public TransformBlock(int id) {
|
TransformBlock(int id) {
|
||||||
this.id = id;
|
this.id = id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2,4 +2,3 @@
|
|||||||
* Contains classes related to synchronization 'blocks'.
|
* Contains classes related to synchronization 'blocks'.
|
||||||
*/
|
*/
|
||||||
package org.apollo.game.sync.block;
|
package org.apollo.game.sync.block;
|
||||||
|
|
||||||
|
|||||||
@@ -3,4 +3,3 @@
|
|||||||
* client's state is updated by the server so it matches the server's state.
|
* client's state is updated by the server so it matches the server's state.
|
||||||
*/
|
*/
|
||||||
package org.apollo.game.sync;
|
package org.apollo.game.sync;
|
||||||
|
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ public final class AddNpcSegment extends SynchronizationSegment {
|
|||||||
* Creates the add npc segment.
|
* Creates the add npc segment.
|
||||||
*
|
*
|
||||||
* @param blockSet The block set.
|
* @param blockSet The block set.
|
||||||
* @param index The characters's index.
|
* @param index The npcs's index.
|
||||||
* @param position The position.
|
* @param position The position.
|
||||||
* @param npcId The id of the npc.
|
* @param npcId The id of the npc.
|
||||||
*/
|
*/
|
||||||
@@ -41,7 +41,7 @@ public final class AddNpcSegment extends SynchronizationSegment {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the character's index.
|
* Gets the npc's index.
|
||||||
*
|
*
|
||||||
* @return The index.
|
* @return The index.
|
||||||
*/
|
*/
|
||||||
@@ -69,7 +69,7 @@ public final class AddNpcSegment extends SynchronizationSegment {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public SegmentType getType() {
|
public SegmentType getType() {
|
||||||
return SegmentType.ADD_CHARACTER;
|
return SegmentType.ADD_MOB;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -4,7 +4,7 @@ import org.apollo.game.model.Position;
|
|||||||
import org.apollo.game.sync.block.SynchronizationBlockSet;
|
import org.apollo.game.sync.block.SynchronizationBlockSet;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A {@link SynchronizationSegment} which adds a character.
|
* A {@link SynchronizationSegment} which adds a player.
|
||||||
*
|
*
|
||||||
* @author Graham
|
* @author Graham
|
||||||
*/
|
*/
|
||||||
@@ -21,10 +21,10 @@ public final class AddPlayerSegment extends SynchronizationSegment {
|
|||||||
private final Position position;
|
private final Position position;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates the add character segment.
|
* Creates the add player segment.
|
||||||
*
|
*
|
||||||
* @param blockSet The block set.
|
* @param blockSet The block set.
|
||||||
* @param index The characters's index.
|
* @param index The player's index.
|
||||||
* @param position The position.
|
* @param position The position.
|
||||||
*/
|
*/
|
||||||
public AddPlayerSegment(SynchronizationBlockSet blockSet, int index, Position position) {
|
public AddPlayerSegment(SynchronizationBlockSet blockSet, int index, Position position) {
|
||||||
@@ -34,7 +34,7 @@ public final class AddPlayerSegment extends SynchronizationSegment {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the character's index.
|
* Gets the player's index.
|
||||||
*
|
*
|
||||||
* @return The index.
|
* @return The index.
|
||||||
*/
|
*/
|
||||||
@@ -53,7 +53,7 @@ public final class AddPlayerSegment extends SynchronizationSegment {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public SegmentType getType() {
|
public SegmentType getType() {
|
||||||
return SegmentType.ADD_CHARACTER;
|
return SegmentType.ADD_MOB;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -4,7 +4,7 @@ import org.apollo.game.model.Direction;
|
|||||||
import org.apollo.game.sync.block.SynchronizationBlockSet;
|
import org.apollo.game.sync.block.SynchronizationBlockSet;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A {@link SynchronizationSegment} where the character is moved (or doesn't move!).
|
* A {@link SynchronizationSegment} where the mob is moved (or doesn't move!).
|
||||||
*
|
*
|
||||||
* @author Graham
|
* @author Graham
|
||||||
*/
|
*/
|
||||||
|
|||||||
+5
-5
@@ -3,11 +3,11 @@ package org.apollo.game.sync.seg;
|
|||||||
import org.apollo.game.sync.block.SynchronizationBlockSet;
|
import org.apollo.game.sync.block.SynchronizationBlockSet;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A {@link SynchronizationSegment} which removes a character.
|
* A {@link SynchronizationSegment} which removes a mob.
|
||||||
*
|
*
|
||||||
* @author Graham
|
* @author Graham
|
||||||
*/
|
*/
|
||||||
public final class RemoveCharacterSegment extends SynchronizationSegment {
|
public final class RemoveMobSegment extends SynchronizationSegment {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An empty {@link SynchronizationBlockSet}.
|
* An empty {@link SynchronizationBlockSet}.
|
||||||
@@ -15,15 +15,15 @@ public final class RemoveCharacterSegment extends SynchronizationSegment {
|
|||||||
private static final SynchronizationBlockSet EMPTY_BLOCK_SET = new SynchronizationBlockSet();
|
private static final SynchronizationBlockSet EMPTY_BLOCK_SET = new SynchronizationBlockSet();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates the remove character segment.
|
* Creates the remove mob segment.
|
||||||
*/
|
*/
|
||||||
public RemoveCharacterSegment() {
|
public RemoveMobSegment() {
|
||||||
super(EMPTY_BLOCK_SET);
|
super(EMPTY_BLOCK_SET);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public SegmentType getType() {
|
public SegmentType getType() {
|
||||||
return SegmentType.REMOVE_CHARACTER;
|
return SegmentType.REMOVE_MOB;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -8,9 +8,9 @@ package org.apollo.game.sync.seg;
|
|||||||
public enum SegmentType {
|
public enum SegmentType {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A segment where the character is added.
|
* A segment where the mob is added.
|
||||||
*/
|
*/
|
||||||
ADD_CHARACTER,
|
ADD_MOB,
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A segment without any movement.
|
* A segment without any movement.
|
||||||
@@ -18,9 +18,9 @@ public enum SegmentType {
|
|||||||
NO_MOVEMENT,
|
NO_MOVEMENT,
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A segment where the character is removed.
|
* A segment where the mob is removed.
|
||||||
*/
|
*/
|
||||||
REMOVE_CHARACTER,
|
REMOVE_MOB,
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A segment with movement in two directions.
|
* A segment with movement in two directions.
|
||||||
@@ -28,7 +28,7 @@ public enum SegmentType {
|
|||||||
RUN,
|
RUN,
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A segment where the character is teleported.
|
* A segment where the mob is teleported.
|
||||||
*/
|
*/
|
||||||
TELEPORT,
|
TELEPORT,
|
||||||
|
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import org.apollo.game.model.Position;
|
|||||||
import org.apollo.game.sync.block.SynchronizationBlockSet;
|
import org.apollo.game.sync.block.SynchronizationBlockSet;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A {@link SynchronizationSegment} where the character is teleported to a new location.
|
* A {@link SynchronizationSegment} where the mob is teleported to a new location.
|
||||||
*
|
*
|
||||||
* @author Graham
|
* @author Graham
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
/**
|
/**
|
||||||
* Contains classes related to synchronization segments. Each segment contains
|
* Contains classes related to synchronization segments. Each segment contains
|
||||||
* multiple blocks and can be used to add, remove, teleport or move a
|
* multiple blocks and can be used to add, remove, teleport or move a
|
||||||
* character.
|
* mob.
|
||||||
*/
|
*/
|
||||||
package org.apollo.game.sync.seg;
|
package org.apollo.game.sync.seg;
|
||||||
|
|
||||||
|
|||||||
@@ -11,9 +11,9 @@ import org.apollo.game.model.World;
|
|||||||
import org.apollo.game.sync.block.SynchronizationBlockSet;
|
import org.apollo.game.sync.block.SynchronizationBlockSet;
|
||||||
import org.apollo.game.sync.seg.AddNpcSegment;
|
import org.apollo.game.sync.seg.AddNpcSegment;
|
||||||
import org.apollo.game.sync.seg.MovementSegment;
|
import org.apollo.game.sync.seg.MovementSegment;
|
||||||
import org.apollo.game.sync.seg.RemoveCharacterSegment;
|
import org.apollo.game.sync.seg.RemoveMobSegment;
|
||||||
import org.apollo.game.sync.seg.SynchronizationSegment;
|
import org.apollo.game.sync.seg.SynchronizationSegment;
|
||||||
import org.apollo.util.CharacterRepository;
|
import org.apollo.util.MobRepository;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A {@link SynchronizationTask} which synchronizes npcs with the specified {@link Player}.
|
* A {@link SynchronizationTask} which synchronizes npcs with the specified {@link Player}.
|
||||||
@@ -46,15 +46,14 @@ public final class NpcSynchronizationTask extends SynchronizationTask {
|
|||||||
public void run() {
|
public void run() {
|
||||||
SynchronizationBlockSet blockSet = player.getBlockSet();
|
SynchronizationBlockSet blockSet = player.getBlockSet();
|
||||||
List<Npc> localNpcs = player.getLocalNpcList();
|
List<Npc> localNpcs = player.getLocalNpcList();
|
||||||
int oldLocalNpcs = localNpcs.size();
|
|
||||||
List<SynchronizationSegment> segments = new ArrayList<SynchronizationSegment>();
|
List<SynchronizationSegment> segments = new ArrayList<SynchronizationSegment>();
|
||||||
|
Iterator<Npc> it = localNpcs.iterator();
|
||||||
|
|
||||||
for (Iterator<Npc> it = localNpcs.iterator(); it.hasNext();) {
|
for (Npc npc = null; it.hasNext(); npc = it.next()) {
|
||||||
Npc npc = it.next();
|
|
||||||
if (!npc.isActive() || npc.isTeleporting()
|
if (!npc.isActive() || npc.isTeleporting()
|
||||||
|| npc.getPosition().getLongestDelta(player.getPosition()) > player.getViewingDistance()) {
|
|| npc.getPosition().getLongestDelta(player.getPosition()) > player.getViewingDistance()) {
|
||||||
it.remove();
|
it.remove();
|
||||||
segments.add(new RemoveCharacterSegment());
|
segments.add(new RemoveMobSegment());
|
||||||
} else {
|
} else {
|
||||||
segments.add(new MovementSegment(npc.getBlockSet(), npc.getDirections()));
|
segments.add(new MovementSegment(npc.getBlockSet(), npc.getDirections()));
|
||||||
}
|
}
|
||||||
@@ -62,26 +61,24 @@ public final class NpcSynchronizationTask extends SynchronizationTask {
|
|||||||
|
|
||||||
int added = 0;
|
int added = 0;
|
||||||
|
|
||||||
CharacterRepository<Npc> repository = World.getWorld().getNpcRepository();
|
MobRepository<Npc> repository = World.getWorld().getNpcRepository();
|
||||||
for (Npc npc : repository) {
|
for (Npc npc : repository) {
|
||||||
if (localNpcs.size() >= 255) {
|
if (localNpcs.size() >= 255) {
|
||||||
player.flagExcessiveNpcs();
|
player.flagExcessiveNpcs();
|
||||||
break;
|
} else if (added < NEW_NPCS_PER_CYCLE) {
|
||||||
} else if (added >= NEW_NPCS_PER_CYCLE) {
|
if (!localNpcs.contains(npc)
|
||||||
break;
|
&& npc.getPosition().isWithinDistance(player.getPosition(), player.getViewingDistance())) {
|
||||||
}
|
localNpcs.add(npc);
|
||||||
|
added++;
|
||||||
if (npc.getPosition().isWithinDistance(player.getPosition(), player.getViewingDistance())
|
blockSet = npc.getBlockSet();
|
||||||
&& !localNpcs.contains(npc)) {
|
segments.add(new AddNpcSegment(blockSet, npc.getIndex(), npc.getPosition(), npc.getId()));
|
||||||
localNpcs.add(npc);
|
}
|
||||||
added++;
|
continue;
|
||||||
blockSet = npc.getBlockSet();
|
|
||||||
segments.add(new AddNpcSegment(blockSet, npc.getIndex(), npc.getPosition(), npc.getNpcDefinition()
|
|
||||||
.getId()));
|
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
}
|
}
|
||||||
NpcSynchronizationEvent event = new NpcSynchronizationEvent(player.getPosition(), segments, oldLocalNpcs);
|
NpcSynchronizationEvent event = new NpcSynchronizationEvent(player.getPosition(), segments, localNpcs.size());
|
||||||
player.send(event);
|
player.send(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -14,10 +14,10 @@ import org.apollo.game.sync.block.SynchronizationBlock;
|
|||||||
import org.apollo.game.sync.block.SynchronizationBlockSet;
|
import org.apollo.game.sync.block.SynchronizationBlockSet;
|
||||||
import org.apollo.game.sync.seg.AddPlayerSegment;
|
import org.apollo.game.sync.seg.AddPlayerSegment;
|
||||||
import org.apollo.game.sync.seg.MovementSegment;
|
import org.apollo.game.sync.seg.MovementSegment;
|
||||||
import org.apollo.game.sync.seg.RemoveCharacterSegment;
|
import org.apollo.game.sync.seg.RemoveMobSegment;
|
||||||
import org.apollo.game.sync.seg.SynchronizationSegment;
|
import org.apollo.game.sync.seg.SynchronizationSegment;
|
||||||
import org.apollo.game.sync.seg.TeleportSegment;
|
import org.apollo.game.sync.seg.TeleportSegment;
|
||||||
import org.apollo.util.CharacterRepository;
|
import org.apollo.util.MobRepository;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A {@link SynchronizationTask} which synchronizes the specified {@link Player} .
|
* A {@link SynchronizationTask} which synchronizes the specified {@link Player} .
|
||||||
@@ -67,44 +67,45 @@ public final class PlayerSynchronizationTask extends SynchronizationTask {
|
|||||||
List<Player> localPlayers = player.getLocalPlayerList();
|
List<Player> localPlayers = player.getLocalPlayerList();
|
||||||
int oldLocalPlayers = localPlayers.size();
|
int oldLocalPlayers = localPlayers.size();
|
||||||
List<SynchronizationSegment> segments = new ArrayList<SynchronizationSegment>();
|
List<SynchronizationSegment> segments = new ArrayList<SynchronizationSegment>();
|
||||||
|
Iterator<Player> it = localPlayers.iterator();
|
||||||
|
|
||||||
for (Iterator<Player> it = localPlayers.iterator(); it.hasNext();) {
|
for (Player local = null; it.hasNext(); local = it.next()) {
|
||||||
Player p = it.next();
|
if (!local.isActive() || local.isTeleporting()
|
||||||
if (!p.isActive() || p.isTeleporting()
|
|| local.getPosition().getLongestDelta(player.getPosition()) > player.getViewingDistance()) {
|
||||||
|| p.getPosition().getLongestDelta(player.getPosition()) > player.getViewingDistance()) {
|
|
||||||
it.remove();
|
it.remove();
|
||||||
segments.add(new RemoveCharacterSegment());
|
segments.add(new RemoveMobSegment());
|
||||||
} else {
|
} else {
|
||||||
segments.add(new MovementSegment(p.getBlockSet(), p.getDirections()));
|
segments.add(new MovementSegment(local.getBlockSet(), local.getDirections()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int added = 0;
|
int added = 0;
|
||||||
|
|
||||||
CharacterRepository<Player> repository = World.getWorld().getPlayerRepository();
|
MobRepository<Player> repository = World.getWorld().getPlayerRepository();
|
||||||
for (Player p : repository) {
|
for (Player global : repository) {
|
||||||
if (localPlayers.size() >= 255) {
|
if (localPlayers.size() >= 255) {
|
||||||
player.flagExcessivePlayers();
|
player.flagExcessivePlayers();
|
||||||
break;
|
} else if (added < NEW_PLAYERS_PER_CYCLE) {
|
||||||
} else if (added >= NEW_PLAYERS_PER_CYCLE) {
|
// we do not check p.isActive() here, since if they are active they
|
||||||
break;
|
// must be in the repository
|
||||||
}
|
if (global != player
|
||||||
// we do not check p.isActive() here, since if they are active they
|
&& global.getPosition().isWithinDistance(player.getPosition(), player.getViewingDistance())
|
||||||
// must be in the repository
|
&& !localPlayers.contains(global)) {
|
||||||
if (p != player && p.getPosition().isWithinDistance(player.getPosition(), player.getViewingDistance())
|
localPlayers.add(global);
|
||||||
&& !localPlayers.contains(p)) {
|
added++;
|
||||||
localPlayers.add(p);
|
|
||||||
added++;
|
|
||||||
|
|
||||||
blockSet = p.getBlockSet();
|
blockSet = global.getBlockSet();
|
||||||
if (!blockSet.contains(AppearanceBlock.class)) {
|
if (!blockSet.contains(AppearanceBlock.class)) {
|
||||||
// TODO check if client has cached appearance
|
// TODO check if client has cached appearance
|
||||||
blockSet = blockSet.clone();
|
blockSet = blockSet.clone();
|
||||||
blockSet.add(SynchronizationBlock.createAppearanceBlock(p));
|
blockSet.add(SynchronizationBlock.createAppearanceBlock(global));
|
||||||
|
}
|
||||||
|
|
||||||
|
segments.add(new AddPlayerSegment(blockSet, global.getIndex(), global.getPosition()));
|
||||||
}
|
}
|
||||||
|
continue;
|
||||||
segments.add(new AddPlayerSegment(blockSet, p.getIndex(), p.getPosition()));
|
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
PlayerSynchronizationEvent event = new PlayerSynchronizationEvent(lastKnownRegion, player.getPosition(),
|
PlayerSynchronizationEvent event = new PlayerSynchronizationEvent(lastKnownRegion, player.getPosition(),
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ public final class EquipmentDefinitionParser {
|
|||||||
DataInputStream dis = new DataInputStream(is);
|
DataInputStream dis = new DataInputStream(is);
|
||||||
|
|
||||||
int count = dis.readShort() & 0xFFFF;
|
int count = dis.readShort() & 0xFFFF;
|
||||||
EquipmentDefinition[] defs = new EquipmentDefinition[count];
|
EquipmentDefinition[] definitions = new EquipmentDefinition[count];
|
||||||
|
|
||||||
for (int id = 0; id < count; id++) {
|
for (int id = 0; id < count; id++) {
|
||||||
int slot = dis.readByte() & 0xFF;
|
int slot = dis.readByte() & 0xFF;
|
||||||
@@ -53,16 +53,16 @@ public final class EquipmentDefinitionParser {
|
|||||||
int ranged = dis.readByte() & 0xFF;
|
int ranged = dis.readByte() & 0xFF;
|
||||||
int magic = dis.readByte() & 0xFF;
|
int magic = dis.readByte() & 0xFF;
|
||||||
|
|
||||||
EquipmentDefinition def = new EquipmentDefinition(id);
|
EquipmentDefinition definition = new EquipmentDefinition(id);
|
||||||
def.setLevels(attack, strength, defence, ranged, magic);
|
definition.setLevels(attack, strength, defence, ranged, magic);
|
||||||
def.setSlot(slot);
|
definition.setSlot(slot);
|
||||||
def.setFlags(twoHanded, fullBody, fullHat, fullMask);
|
definition.setFlags(twoHanded, fullBody, fullHat, fullMask);
|
||||||
|
|
||||||
defs[id] = def;
|
definitions[id] = definition;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return defs;
|
return definitions;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -2,4 +2,3 @@
|
|||||||
* Contains classes which deal with input/output.
|
* Contains classes which deal with input/output.
|
||||||
*/
|
*/
|
||||||
package org.apollo.io;
|
package org.apollo.io;
|
||||||
|
|
||||||
|
|||||||
@@ -59,7 +59,7 @@ public final class BinaryPlayerLoader implements PlayerLoader {
|
|||||||
int height = in.readUnsignedByte();
|
int height = in.readUnsignedByte();
|
||||||
|
|
||||||
// read appearance
|
// read appearance
|
||||||
boolean designedCharacter = in.readBoolean();
|
boolean designed = in.readBoolean();
|
||||||
|
|
||||||
int genderIntValue = in.readUnsignedByte();
|
int genderIntValue = in.readUnsignedByte();
|
||||||
Gender gender = genderIntValue == Gender.MALE.toInteger() ? Gender.MALE : Gender.FEMALE;
|
Gender gender = genderIntValue == Gender.MALE.toInteger() ? Gender.MALE : Gender.FEMALE;
|
||||||
@@ -72,20 +72,20 @@ public final class BinaryPlayerLoader implements PlayerLoader {
|
|||||||
colors[i] = in.readUnsignedByte();
|
colors[i] = in.readUnsignedByte();
|
||||||
}
|
}
|
||||||
|
|
||||||
Player p = new Player(credentials, new Position(x, y, height));
|
Player player = new Player(credentials, new Position(x, y, height));
|
||||||
p.setPrivilegeLevel(privilegeLevel);
|
player.setPrivilegeLevel(privilegeLevel);
|
||||||
p.setMembers(members);
|
player.setMembers(members);
|
||||||
p.setDesignedCharacter(designedCharacter);
|
player.setDesigned(designed);
|
||||||
p.setAppearance(new Appearance(gender, style, colors));
|
player.setAppearance(new Appearance(gender, style, colors));
|
||||||
|
|
||||||
// read inventories
|
// read inventories
|
||||||
readInventory(in, p.getInventory());
|
readInventory(in, player.getInventory());
|
||||||
readInventory(in, p.getEquipment());
|
readInventory(in, player.getEquipment());
|
||||||
readInventory(in, p.getBank());
|
readInventory(in, player.getBank());
|
||||||
|
|
||||||
// read skills
|
// read skills
|
||||||
int size = in.readUnsignedByte();
|
int size = in.readUnsignedByte();
|
||||||
SkillSet skills = p.getSkillSet();
|
SkillSet skills = player.getSkillSet();
|
||||||
skills.stopFiringEvents();
|
skills.stopFiringEvents();
|
||||||
try {
|
try {
|
||||||
for (int i = 0; i < size; i++) {
|
for (int i = 0; i < size; i++) {
|
||||||
@@ -94,10 +94,11 @@ public final class BinaryPlayerLoader implements PlayerLoader {
|
|||||||
skills.setSkill(i, new Skill(experience, level, SkillSet.getLevelForExperience(experience)));
|
skills.setSkill(i, new Skill(experience, level, SkillSet.getLevelForExperience(experience)));
|
||||||
}
|
}
|
||||||
} finally {
|
} finally {
|
||||||
|
skills.calculateCombatLevel();
|
||||||
skills.startFiringEvents();
|
skills.startFiringEvents();
|
||||||
}
|
}
|
||||||
|
|
||||||
return new PlayerLoaderResponse(LoginConstants.STATUS_OK, p);
|
return new PlayerLoaderResponse(LoginConstants.STATUS_OK, player);
|
||||||
} finally {
|
} finally {
|
||||||
in.close();
|
in.close();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ public final class BinaryPlayerSaver implements PlayerSaver {
|
|||||||
out.writeByte(position.getHeight());
|
out.writeByte(position.getHeight());
|
||||||
|
|
||||||
// write appearance
|
// write appearance
|
||||||
out.writeBoolean(player.hasDesignedCharacter());
|
out.writeBoolean(player.hasDesignedAvatar());
|
||||||
Appearance appearance = player.getAppearance();
|
Appearance appearance = player.getAppearance();
|
||||||
out.writeByte(appearance.getGender().toInteger());
|
out.writeByte(appearance.getGender().toInteger());
|
||||||
int[] style = appearance.getStyle();
|
int[] style = appearance.getStyle();
|
||||||
|
|||||||
@@ -26,21 +26,20 @@ public final class BinaryPlayerUtil {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the file for the specified player.
|
* Gets the save {@link File} for the specified player.
|
||||||
*
|
*
|
||||||
* @param name The name of the player.
|
* @param username The username of the player.
|
||||||
* @return The file.
|
* @return The file.
|
||||||
*/
|
*/
|
||||||
public static File getFile(String name) {
|
public static File getFile(String username) {
|
||||||
name = NameUtil.decodeBase37(NameUtil.encodeBase37(name));
|
username = NameUtil.decodeBase37(NameUtil.encodeBase37(username));
|
||||||
return new File(SAVED_GAMES_DIRECTORY, name + ".dat");
|
return new File(SAVED_GAMES_DIRECTORY, username + ".dat");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Default private constructor to prevent instantiation.
|
* Default private constructor to prevent instantiation.
|
||||||
*/
|
*/
|
||||||
private BinaryPlayerUtil() {
|
private BinaryPlayerUtil() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -2,4 +2,3 @@
|
|||||||
* Contains various player loader/saver implementations.
|
* Contains various player loader/saver implementations.
|
||||||
*/
|
*/
|
||||||
package org.apollo.io.player.impl;
|
package org.apollo.io.player.impl;
|
||||||
|
|
||||||
|
|||||||
@@ -2,4 +2,3 @@
|
|||||||
* Contains classes which deal with loading and saving player files.
|
* Contains classes which deal with loading and saving player files.
|
||||||
*/
|
*/
|
||||||
package org.apollo.io.player;
|
package org.apollo.io.player;
|
||||||
|
|
||||||
|
|||||||
@@ -2,4 +2,3 @@
|
|||||||
* Contains classes related to the login service.
|
* Contains classes related to the login service.
|
||||||
*/
|
*/
|
||||||
package org.apollo.login;
|
package org.apollo.login;
|
||||||
|
|
||||||
|
|||||||
@@ -2,4 +2,3 @@
|
|||||||
* Contains codecs for the game protocol.
|
* Contains codecs for the game protocol.
|
||||||
*/
|
*/
|
||||||
package org.apollo.net.codec.game;
|
package org.apollo.net.codec.game;
|
||||||
|
|
||||||
|
|||||||
@@ -2,4 +2,3 @@
|
|||||||
* Contains codecs for the handshake protocol.
|
* Contains codecs for the handshake protocol.
|
||||||
*/
|
*/
|
||||||
package org.apollo.net.codec.handshake;
|
package org.apollo.net.codec.handshake;
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ package org.apollo.net.codec.jaggrab;
|
|||||||
import org.jboss.netty.buffer.ChannelBuffer;
|
import org.jboss.netty.buffer.ChannelBuffer;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents a single JAGGRAB reponse.
|
* Represents a single JAGGRAB response.
|
||||||
*
|
*
|
||||||
* @author Graham
|
* @author Graham
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -2,4 +2,3 @@
|
|||||||
* Contains codecs for the JAGGRAB protocol.
|
* Contains codecs for the JAGGRAB protocol.
|
||||||
*/
|
*/
|
||||||
package org.apollo.net.codec.jaggrab;
|
package org.apollo.net.codec.jaggrab;
|
||||||
|
|
||||||
|
|||||||
@@ -2,4 +2,3 @@
|
|||||||
* Contains codecs for the login protocol.
|
* Contains codecs for the login protocol.
|
||||||
*/
|
*/
|
||||||
package org.apollo.net.codec.login;
|
package org.apollo.net.codec.login;
|
||||||
|
|
||||||
|
|||||||
@@ -107,9 +107,8 @@ public final class OnDemandRequest implements Comparable<OnDemandRequest> {
|
|||||||
return 1;
|
return 1;
|
||||||
} else if (thisPriority == otherPriority) {
|
} else if (thisPriority == otherPriority) {
|
||||||
return 0;
|
return 0;
|
||||||
} else {
|
|
||||||
return -1;
|
|
||||||
}
|
}
|
||||||
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -17,21 +17,21 @@ public final class UpdateEncoder extends OneToOneEncoder {
|
|||||||
@Override
|
@Override
|
||||||
protected Object encode(ChannelHandlerContext ctx, Channel c, Object msg) {
|
protected Object encode(ChannelHandlerContext ctx, Channel c, Object msg) {
|
||||||
if (msg instanceof OnDemandResponse) {
|
if (msg instanceof OnDemandResponse) {
|
||||||
OnDemandResponse resp = (OnDemandResponse) msg;
|
OnDemandResponse response = (OnDemandResponse) msg;
|
||||||
|
|
||||||
FileDescriptor fileDescriptor = resp.getFileDescriptor();
|
FileDescriptor descriptor = response.getFileDescriptor();
|
||||||
int fileSize = resp.getFileSize();
|
int fileSize = response.getFileSize();
|
||||||
int chunkId = resp.getChunkId();
|
int chunkId = response.getChunkId();
|
||||||
ChannelBuffer chunkData = resp.getChunkData();
|
ChannelBuffer chunkData = response.getChunkData();
|
||||||
|
|
||||||
ChannelBuffer buf = ChannelBuffers.buffer(6 + chunkData.readableBytes());
|
ChannelBuffer buffer = ChannelBuffers.buffer(6 + chunkData.readableBytes());
|
||||||
buf.writeByte(fileDescriptor.getType() - 1);
|
buffer.writeByte(descriptor.getType() - 1);
|
||||||
buf.writeShort(fileDescriptor.getFile());
|
buffer.writeShort(descriptor.getFile());
|
||||||
buf.writeShort(fileSize);
|
buffer.writeShort(fileSize);
|
||||||
buf.writeByte(chunkId);
|
buffer.writeByte(chunkId);
|
||||||
buf.writeBytes(chunkData);
|
buffer.writeBytes(chunkData);
|
||||||
|
|
||||||
return buf;
|
return buffer;
|
||||||
}
|
}
|
||||||
return msg;
|
return msg;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,4 +2,3 @@
|
|||||||
* Contains codecs for the ondemand (update) protocol.
|
* Contains codecs for the ondemand (update) protocol.
|
||||||
*/
|
*/
|
||||||
package org.apollo.net.codec.update;
|
package org.apollo.net.codec.update;
|
||||||
|
|
||||||
|
|||||||
@@ -2,4 +2,3 @@
|
|||||||
* Contains classes which contain meta data about the protocol/various packets.
|
* Contains classes which contain meta data about the protocol/various packets.
|
||||||
*/
|
*/
|
||||||
package org.apollo.net.meta;
|
package org.apollo.net.meta;
|
||||||
|
|
||||||
|
|||||||
@@ -3,4 +3,3 @@
|
|||||||
* classes - such as the pipeline factory, handler and codecs.
|
* classes - such as the pipeline factory, handler and codecs.
|
||||||
*/
|
*/
|
||||||
package org.apollo.net;
|
package org.apollo.net;
|
||||||
|
|
||||||
|
|||||||
@@ -3,4 +3,3 @@
|
|||||||
* allowing for portability between various protocol and client releases.
|
* allowing for portability between various protocol and client releases.
|
||||||
*/
|
*/
|
||||||
package org.apollo.net.release;
|
package org.apollo.net.release;
|
||||||
|
|
||||||
|
|||||||
@@ -1,20 +0,0 @@
|
|||||||
package org.apollo.net.release.r317;
|
|
||||||
|
|
||||||
import org.apollo.game.event.impl.CharacterAnimationResetEvent;
|
|
||||||
import org.apollo.net.codec.game.GamePacket;
|
|
||||||
import org.apollo.net.codec.game.GamePacketBuilder;
|
|
||||||
import org.apollo.net.release.EventEncoder;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* An {@link EventEncoder} for the {@link CharacterAnimationResetEvent}.
|
|
||||||
*
|
|
||||||
* @author Major
|
|
||||||
*/
|
|
||||||
public class CharacterAnimationResetEventEncoder extends EventEncoder<CharacterAnimationResetEvent> {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public GamePacket encode(CharacterAnimationResetEvent event) {
|
|
||||||
return new GamePacketBuilder(1).toGamePacket();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user