mirror of
https://github.com/Rogiel/l2jserver2
synced 2025-12-09 08:52:51 +00:00
Template classes for all NPC instances
Signed-off-by: Rogiel <rogiel@rogiel.com>
This commit is contained in:
@@ -23,7 +23,7 @@ import org.jboss.netty.buffer.ChannelBuffer;
|
||||
import com.google.inject.Inject;
|
||||
import com.l2jserver.game.net.Lineage2Connection;
|
||||
import com.l2jserver.game.net.packet.AbstractClientPacket;
|
||||
import com.l2jserver.service.admin.AdministratorService;
|
||||
import com.l2jserver.service.game.spawn.CharacterAlreadyTeleportingServiceException;
|
||||
import com.l2jserver.service.game.spawn.NotSpawnedServiceException;
|
||||
import com.l2jserver.service.game.spawn.SpawnService;
|
||||
import com.l2jserver.util.BufferUtils;
|
||||
@@ -43,7 +43,7 @@ public class AdminCommandPacket extends AbstractClientPacket {
|
||||
/**
|
||||
* The admin service
|
||||
*/
|
||||
private final AdministratorService adminService;
|
||||
// private final AdministratorService adminService;
|
||||
private final SpawnService spawnService;
|
||||
|
||||
/**
|
||||
@@ -52,9 +52,9 @@ public class AdminCommandPacket extends AbstractClientPacket {
|
||||
private String command;
|
||||
|
||||
@Inject
|
||||
public AdminCommandPacket(AdministratorService adminService,
|
||||
SpawnService spawnService) {
|
||||
this.adminService = adminService;
|
||||
public AdminCommandPacket(/* AdministratorService adminService, */
|
||||
SpawnService spawnService) {
|
||||
// this.adminService = adminService;
|
||||
this.spawnService = spawnService;
|
||||
}
|
||||
|
||||
@@ -75,8 +75,9 @@ public class AdminCommandPacket extends AbstractClientPacket {
|
||||
try {
|
||||
spawnService.teleport(conn.getCharacter(), coord);
|
||||
} catch (NotSpawnedServiceException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
conn.sendActionFailed();
|
||||
} catch (CharacterAlreadyTeleportingServiceException e) {
|
||||
conn.sendActionFailed();
|
||||
}
|
||||
}
|
||||
// TODO implement admin commands
|
||||
|
||||
@@ -21,7 +21,8 @@ import org.jboss.netty.buffer.ChannelBuffer;
|
||||
import com.google.inject.Inject;
|
||||
import com.l2jserver.game.net.Lineage2Connection;
|
||||
import com.l2jserver.game.net.packet.AbstractClientPacket;
|
||||
import com.l2jserver.service.game.character.CharacterService;
|
||||
import com.l2jserver.service.game.spawn.CharacterNotTeleportingServiceException;
|
||||
import com.l2jserver.service.game.spawn.SpawnService;
|
||||
|
||||
/**
|
||||
* Completes the creation of an character. Creates the object, inserts into the
|
||||
@@ -36,13 +37,13 @@ public class CharacterAppearingPacket extends AbstractClientPacket {
|
||||
public static final int OPCODE = 0x3a;
|
||||
|
||||
/**
|
||||
* The {@link CharacterService}
|
||||
* The {@link SpawnService}
|
||||
*/
|
||||
private final CharacterService charService;
|
||||
private final SpawnService spawnService;
|
||||
|
||||
@Inject
|
||||
public CharacterAppearingPacket(CharacterService charService) {
|
||||
this.charService = charService;
|
||||
public CharacterAppearingPacket(SpawnService spawnService) {
|
||||
this.spawnService = spawnService;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -51,6 +52,10 @@ public class CharacterAppearingPacket extends AbstractClientPacket {
|
||||
|
||||
@Override
|
||||
public void process(final Lineage2Connection conn) {
|
||||
charService.appearing(conn.getCharacter());
|
||||
try {
|
||||
spawnService.finishTeleport(conn.getCharacter());
|
||||
} catch (CharacterNotTeleportingServiceException e) {
|
||||
conn.sendActionFailed();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,8 +31,8 @@ import com.l2jserver.model.id.object.provider.CharacterIDProvider;
|
||||
import com.l2jserver.model.id.template.CharacterTemplateID;
|
||||
import com.l2jserver.model.id.template.provider.CharacterTemplateIDProvider;
|
||||
import com.l2jserver.model.template.CharacterTemplate;
|
||||
import com.l2jserver.model.world.Actor.Race;
|
||||
import com.l2jserver.model.world.Actor.Sex;
|
||||
import com.l2jserver.model.world.Actor.ActorRace;
|
||||
import com.l2jserver.model.world.Actor.ActorSex;
|
||||
import com.l2jserver.model.world.L2Character;
|
||||
import com.l2jserver.model.world.character.CharacterAppearance.CharacterFace;
|
||||
import com.l2jserver.model.world.character.CharacterAppearance.CharacterHairColor;
|
||||
@@ -80,11 +80,11 @@ public class CharacterCreatePacket extends AbstractClientPacket {
|
||||
/**
|
||||
* The race of the new character
|
||||
*/
|
||||
private Race race;
|
||||
private ActorRace race;
|
||||
/**
|
||||
* The sex of the new character
|
||||
*/
|
||||
private Sex sex;
|
||||
private ActorSex sex;
|
||||
/**
|
||||
* The class of the new character
|
||||
*/
|
||||
@@ -146,8 +146,8 @@ public class CharacterCreatePacket extends AbstractClientPacket {
|
||||
@Override
|
||||
public void read(Lineage2Connection conn, ChannelBuffer buffer) {
|
||||
name = BufferUtils.readString(buffer);
|
||||
race = Race.fromOption(buffer.readInt());
|
||||
sex = Sex.fromOption(buffer.readInt());
|
||||
race = ActorRace.fromOption(buffer.readInt());
|
||||
sex = ActorSex.fromOption(buffer.readInt());
|
||||
characterClass = CharacterClass.fromID(buffer.readInt());
|
||||
|
||||
intelligence = buffer.readInt();
|
||||
@@ -252,7 +252,7 @@ public class CharacterCreatePacket extends AbstractClientPacket {
|
||||
/**
|
||||
* @return the race
|
||||
*/
|
||||
public Race getRace() {
|
||||
public ActorRace getRace() {
|
||||
return race;
|
||||
}
|
||||
|
||||
@@ -260,14 +260,14 @@ public class CharacterCreatePacket extends AbstractClientPacket {
|
||||
* @param race
|
||||
* the race to set
|
||||
*/
|
||||
public void setRace(Race race) {
|
||||
public void setRace(ActorRace race) {
|
||||
this.race = race;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the sex
|
||||
*/
|
||||
public Sex getSex() {
|
||||
public ActorSex getSex() {
|
||||
return sex;
|
||||
}
|
||||
|
||||
@@ -275,7 +275,7 @@ public class CharacterCreatePacket extends AbstractClientPacket {
|
||||
* @param sex
|
||||
* the sex to set
|
||||
*/
|
||||
public void setSex(Sex sex) {
|
||||
public void setSex(ActorSex sex) {
|
||||
this.sex = sex;
|
||||
}
|
||||
|
||||
|
||||
@@ -41,7 +41,7 @@ import org.jboss.netty.buffer.ChannelBuffer;
|
||||
|
||||
import com.l2jserver.game.net.Lineage2Connection;
|
||||
import com.l2jserver.game.net.packet.AbstractServerPacket;
|
||||
import com.l2jserver.model.world.Actor.Sex;
|
||||
import com.l2jserver.model.world.Actor.ActorSex;
|
||||
import com.l2jserver.model.world.Item;
|
||||
import com.l2jserver.model.world.L2Character;
|
||||
import com.l2jserver.model.world.L2Character.CharacterMoveType;
|
||||
@@ -145,19 +145,19 @@ public class CharacterInformationBroadcastPacket extends AbstractServerPacket {
|
||||
|
||||
buffer.writeInt(0x00); // unk
|
||||
|
||||
buffer.writeInt((int) character.getAttributes().getMoveSpeed());
|
||||
buffer.writeInt((int) character.getAttributes().getMoveSpeed());
|
||||
buffer.writeInt((int) character.getAttributes().getMoveSpeed());
|
||||
buffer.writeInt((int) character.getAttributes().getMoveSpeed());
|
||||
buffer.writeInt((int) character.getAttributes().getMoveSpeed());
|
||||
buffer.writeInt((int) character.getAttributes().getMoveSpeed());
|
||||
buffer.writeInt((int) character.getAttributes().getMoveSpeed());
|
||||
buffer.writeInt((int) character.getAttributes().getMoveSpeed());
|
||||
buffer.writeInt((int) character.getAttributes().getRunSpeed());
|
||||
buffer.writeInt((int) character.getAttributes().getRunSpeed());
|
||||
buffer.writeInt((int) character.getAttributes().getRunSpeed());
|
||||
buffer.writeInt((int) character.getAttributes().getRunSpeed());
|
||||
buffer.writeInt((int) character.getAttributes().getRunSpeed());
|
||||
buffer.writeInt((int) character.getAttributes().getRunSpeed());
|
||||
buffer.writeInt((int) character.getAttributes().getRunSpeed());
|
||||
buffer.writeInt((int) character.getAttributes().getRunSpeed());
|
||||
|
||||
buffer.writeDouble(0x01); // move speed multiplier
|
||||
buffer.writeDouble(0x01); // attack speed multiplier
|
||||
|
||||
if (character.getSex() == Sex.MALE) {
|
||||
if (character.getSex() == ActorSex.MALE) {
|
||||
buffer.writeDouble(character.getTemplate().getMaleCollisionRadius());
|
||||
buffer.writeDouble(character.getTemplate().getMaleCollisionHeight());
|
||||
} else {
|
||||
|
||||
@@ -48,7 +48,7 @@ import com.l2jserver.game.net.Lineage2Connection;
|
||||
import com.l2jserver.game.net.packet.AbstractServerPacket;
|
||||
import com.l2jserver.model.world.Item;
|
||||
import com.l2jserver.model.world.L2Character;
|
||||
import com.l2jserver.model.world.Actor.Sex;
|
||||
import com.l2jserver.model.world.Actor.ActorSex;
|
||||
import com.l2jserver.model.world.actor.ActorExperience;
|
||||
import com.l2jserver.model.world.character.CharacterInventory.InventoryPaperdoll;
|
||||
import com.l2jserver.util.BufferUtils;
|
||||
@@ -189,32 +189,26 @@ public class CharacterInformationPacket extends AbstractServerPacket {
|
||||
|
||||
buffer.writeInt(0x00); // (max?) talismans count
|
||||
buffer.writeInt(0x00); // cloak sratus
|
||||
buffer.writeInt(character.getAttributes().getPhysicalAttack());
|
||||
buffer.writeInt((int) character.getAttributes().getPhysicalAttack());
|
||||
buffer.writeInt(character.getAttributes().getAttackSpeed());
|
||||
buffer.writeInt(character.getAttributes().getPhysicalDefense());
|
||||
buffer.writeInt((int) character.getAttributes().getPhysicalDefense());
|
||||
|
||||
buffer.writeInt(character.getAttributes().getEvasionChance()); // evasion
|
||||
buffer.writeInt(character.getAttributes().getAccuracy());
|
||||
buffer.writeInt(character.getAttributes().getCriticalChance());
|
||||
|
||||
buffer.writeInt(character.getAttributes().getMagicalAttack());
|
||||
buffer.writeInt((int) character.getAttributes().getMagicalAttack());
|
||||
buffer.writeInt(character.getAttributes().getCastSpeed());
|
||||
buffer.writeInt(character.getAttributes().getAttackSpeed());
|
||||
buffer.writeInt(character.getAttributes().getMagicalDefense());
|
||||
buffer.writeInt((int) character.getAttributes().getMagicalDefense());
|
||||
|
||||
buffer.writeInt(0x00); // 0-non-pvp 1-pvp = violett name
|
||||
buffer.writeInt(0x00); // karma
|
||||
|
||||
buffer.writeInt((int) character.getAttributes().getMoveSpeed()); // run
|
||||
// speed
|
||||
buffer.writeInt((int) character.getAttributes().getMoveSpeed()); // walk
|
||||
// speed
|
||||
buffer.writeInt((int) character.getAttributes().getMoveSpeed()); // swim
|
||||
// run
|
||||
// speed
|
||||
buffer.writeInt((int) character.getAttributes().getMoveSpeed()); // swim
|
||||
// walk
|
||||
// speed
|
||||
buffer.writeInt((int) character.getAttributes().getRunSpeed());
|
||||
buffer.writeInt((int) character.getAttributes().getWalkSpeed());
|
||||
buffer.writeInt((int) character.getAttributes().getRunSpeed());
|
||||
buffer.writeInt((int) character.getAttributes().getWalkSpeed());
|
||||
buffer.writeInt(0); // unk
|
||||
buffer.writeInt(0); // unk
|
||||
buffer.writeInt(0); // fly speed -only if flying
|
||||
@@ -234,7 +228,7 @@ public class CharacterInformationPacket extends AbstractServerPacket {
|
||||
// writeF(_activeChar.getCollisionRadius());
|
||||
// writeF(_activeChar.getCollisionHeight());
|
||||
// }
|
||||
if (character.getSex() == Sex.MALE) {
|
||||
if (character.getSex() == ActorSex.MALE) {
|
||||
buffer.writeDouble(character.getTemplate().getMaleCollisionRadius());
|
||||
buffer.writeDouble(character.getTemplate().getMaleCollisionHeight());
|
||||
} else {
|
||||
@@ -243,7 +237,7 @@ public class CharacterInformationPacket extends AbstractServerPacket {
|
||||
buffer.writeDouble(character.getTemplate()
|
||||
.getFemaleCollisionHeight());
|
||||
}
|
||||
|
||||
|
||||
buffer.writeInt(character.getAppearance().getHairStyle().option);
|
||||
buffer.writeInt(character.getAppearance().getHairColor().option);
|
||||
buffer.writeInt(character.getAppearance().getFace().option);
|
||||
@@ -252,10 +246,8 @@ public class CharacterInformationPacket extends AbstractServerPacket {
|
||||
String title = "Testing"; // title
|
||||
BufferUtils.writeString(buffer, title);
|
||||
|
||||
int clanid = 0;
|
||||
if (character.getClanID() != null)
|
||||
clanid = character.getClanID().getID();
|
||||
buffer.writeInt(clanid); // clanid
|
||||
buffer.writeInt((character.getClanID() != null ? character.getClanID()
|
||||
.getID() : 0x00)); // clanid
|
||||
buffer.writeInt(0x00); // clan crest id
|
||||
buffer.writeInt(0x00); // ally id
|
||||
buffer.writeInt(0x00); // ally crest id
|
||||
|
||||
@@ -22,6 +22,7 @@ import com.l2jserver.game.net.Lineage2Connection;
|
||||
import com.l2jserver.game.net.packet.AbstractServerPacket;
|
||||
import com.l2jserver.game.net.packet.server.CharacterCreateFailPacket.Reason;
|
||||
import com.l2jserver.model.world.L2Character;
|
||||
import com.l2jserver.util.dimensional.Point;
|
||||
|
||||
/**
|
||||
* This packet notifies the client that the chosen character has been
|
||||
@@ -40,19 +41,24 @@ public class CharacterTeleportPacket extends AbstractServerPacket {
|
||||
* The selected character
|
||||
*/
|
||||
private final L2Character character;
|
||||
/**
|
||||
* The teleportation point
|
||||
*/
|
||||
private final Point point;
|
||||
|
||||
public CharacterTeleportPacket(L2Character character) {
|
||||
public CharacterTeleportPacket(L2Character character, Point point) {
|
||||
super(OPCODE);
|
||||
this.character = character;
|
||||
this.point = point;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(Lineage2Connection conn, ChannelBuffer buffer) {
|
||||
buffer.writeInt(character.getID().getID());
|
||||
buffer.writeInt(character.getPoint().getX());
|
||||
buffer.writeInt(character.getPoint().getY());
|
||||
buffer.writeInt(character.getPoint().getZ());
|
||||
buffer.writeInt(point.getX());
|
||||
buffer.writeInt(point.getY());
|
||||
buffer.writeInt(point.getZ());
|
||||
buffer.writeInt(0x00); // isValidation ??
|
||||
buffer.writeInt((int) character.getPoint().getAngle()); // nYaw
|
||||
buffer.writeInt((int) point.getAngle()); // nYaw
|
||||
}
|
||||
}
|
||||
|
||||
@@ -62,21 +62,21 @@ public class NPCInformationPacket extends AbstractServerPacket {
|
||||
buffer.writeInt(0x00); // unk
|
||||
buffer.writeInt(template.getCastSpeed());
|
||||
buffer.writeInt(template.getAttackSpeed());
|
||||
buffer.writeInt((int) template.getMoveSpeed());
|
||||
buffer.writeInt((int) template.getMoveSpeed());
|
||||
buffer.writeInt((int) template.getMoveSpeed()); // swim run speed
|
||||
buffer.writeInt((int) template.getMoveSpeed()); // swim walk speed
|
||||
buffer.writeInt((int) template.getMoveSpeed()); // swim run speed
|
||||
buffer.writeInt((int) template.getMoveSpeed()); // swim walk speed
|
||||
buffer.writeInt((int) template.getMoveSpeed()); // fly run speed
|
||||
buffer.writeInt((int) template.getMoveSpeed()); // fly run speed
|
||||
buffer.writeInt((int) template.getRunSpeed());
|
||||
buffer.writeInt((int) template.getWalkSpeed());
|
||||
buffer.writeInt((int) template.getRunSpeed()); // swim run speed
|
||||
buffer.writeInt((int) template.getWalkSpeed()); // swim walk speed
|
||||
buffer.writeInt((int) template.getRunSpeed()); // swim run speed
|
||||
buffer.writeInt((int) template.getWalkSpeed()); // swim walk speed
|
||||
buffer.writeInt((int) template.getRunSpeed()); // fly run speed
|
||||
buffer.writeInt((int) template.getWalkSpeed()); // fly run speed
|
||||
buffer.writeDouble(template.getMovementSpeedMultiplier());
|
||||
buffer.writeDouble(template.getAttackSpeedMultiplier());
|
||||
buffer.writeDouble(template.getCollisionRadius());
|
||||
buffer.writeDouble(template.getCollisionHeight());
|
||||
buffer.writeInt(0x00); // right hand weapon
|
||||
buffer.writeInt(template.getRightHand().getID()); // right hand weapon
|
||||
buffer.writeInt(0x00); // chest
|
||||
buffer.writeInt(0x00); // left hand weapon
|
||||
buffer.writeInt(template.getLeftHand().getID()); // left hand weapon
|
||||
buffer.writeByte(1); // name above char 1=true ... ??
|
||||
buffer.writeByte(0x00); // is running
|
||||
buffer.writeByte(0x00); // is in combat
|
||||
|
||||
@@ -60,7 +60,8 @@ public class ServerObjectPacket extends AbstractServerPacket {
|
||||
buffer.writeDouble(template.getCollisionRadius()); // coll radius
|
||||
buffer.writeDouble(template.getCollisionHeight()); // coll height
|
||||
buffer.writeInt((template.isAttackable() ? npc.getHP() : 0x00));
|
||||
buffer.writeInt((template.isAttackable() ? template.getMaxHP() : 0x00));
|
||||
buffer.writeInt((int) (template.isAttackable() ? template.getMaxHP()
|
||||
: 0x00));
|
||||
buffer.writeInt(0x01); // object type
|
||||
buffer.writeInt(0x00); // special effects
|
||||
}
|
||||
|
||||
@@ -21,7 +21,6 @@ import org.slf4j.LoggerFactory;
|
||||
|
||||
import com.l2jserver.model.id.template.ActorTemplateID;
|
||||
import com.l2jserver.model.world.Actor;
|
||||
import com.l2jserver.model.world.Actor.Race;
|
||||
import com.l2jserver.model.world.actor.ActorAttributes;
|
||||
|
||||
/**
|
||||
@@ -37,11 +36,6 @@ public abstract class ActorTemplate<T extends Actor> extends
|
||||
private static final Logger log = LoggerFactory
|
||||
.getLogger(ActorTemplate.class);
|
||||
|
||||
/**
|
||||
* The actor race
|
||||
*/
|
||||
protected final Race race;
|
||||
|
||||
/**
|
||||
* The movement speed multiplier
|
||||
*/
|
||||
@@ -51,16 +45,21 @@ public abstract class ActorTemplate<T extends Actor> extends
|
||||
*/
|
||||
protected double attackSpeedMultiplier = 1.0;
|
||||
|
||||
protected int maxHp;
|
||||
protected double maxHP;
|
||||
protected double HP;
|
||||
|
||||
protected double maxMP;
|
||||
protected double MP;
|
||||
|
||||
protected int level;
|
||||
|
||||
/**
|
||||
* The base attributes instance
|
||||
*/
|
||||
protected ActorBaseAttributes attributes = new ActorBaseAttributes();
|
||||
|
||||
public ActorTemplate(ActorTemplateID<?> id, Race race) {
|
||||
public ActorTemplate(ActorTemplateID<?> id) {
|
||||
super(id);
|
||||
this.race = race;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -73,13 +72,6 @@ public abstract class ActorTemplate<T extends Actor> extends
|
||||
|
||||
protected abstract T createInstance();
|
||||
|
||||
/**
|
||||
* @return the race
|
||||
*/
|
||||
public Race getRace() {
|
||||
return race;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the baseAttributes
|
||||
*/
|
||||
@@ -139,7 +131,7 @@ public abstract class ActorTemplate<T extends Actor> extends
|
||||
* @return
|
||||
* @see com.l2jserver.model.template.ActorBaseAttributes#getPhysicalAttack()
|
||||
*/
|
||||
public int getPhysicalAttack() {
|
||||
public double getPhysicalAttack() {
|
||||
return attributes.getPhysicalAttack();
|
||||
}
|
||||
|
||||
@@ -147,7 +139,7 @@ public abstract class ActorTemplate<T extends Actor> extends
|
||||
* @return
|
||||
* @see com.l2jserver.model.template.ActorBaseAttributes#getMagicalAttack()
|
||||
*/
|
||||
public int getMagicalAttack() {
|
||||
public double getMagicalAttack() {
|
||||
return attributes.getMagicalAttack();
|
||||
}
|
||||
|
||||
@@ -155,7 +147,7 @@ public abstract class ActorTemplate<T extends Actor> extends
|
||||
* @return
|
||||
* @see com.l2jserver.model.template.ActorBaseAttributes#getPhysicalDefense()
|
||||
*/
|
||||
public int getPhysicalDefense() {
|
||||
public double getPhysicalDefense() {
|
||||
return attributes.getPhysicalDefense();
|
||||
}
|
||||
|
||||
@@ -163,7 +155,7 @@ public abstract class ActorTemplate<T extends Actor> extends
|
||||
* @return
|
||||
* @see com.l2jserver.model.template.ActorBaseAttributes#getMagicalDefense()
|
||||
*/
|
||||
public int getMagicalDefense() {
|
||||
public double getMagicalDefense() {
|
||||
return attributes.getMagicalDefense();
|
||||
}
|
||||
|
||||
@@ -209,10 +201,18 @@ public abstract class ActorTemplate<T extends Actor> extends
|
||||
|
||||
/**
|
||||
* @return
|
||||
* @see com.l2jserver.model.template.ActorBaseAttributes#getMoveSpeed()
|
||||
* @see com.l2jserver.model.template.ActorBaseAttributes#getRunSpeed()
|
||||
*/
|
||||
public double getMoveSpeed() {
|
||||
return attributes.getMoveSpeed();
|
||||
public double getRunSpeed() {
|
||||
return attributes.getRunSpeed();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return
|
||||
* @see com.l2jserver.model.template.ActorBaseAttributes#getWalkSpeed()
|
||||
*/
|
||||
public double getWalkSpeed() {
|
||||
return attributes.getWalkSpeed();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -248,8 +248,8 @@ public abstract class ActorTemplate<T extends Actor> extends
|
||||
/**
|
||||
* @return the max hp
|
||||
*/
|
||||
public int getMaxHP() {
|
||||
return maxHp;
|
||||
public double getMaxHP() {
|
||||
return maxHP;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -286,19 +286,19 @@ public abstract class ActorTemplate<T extends Actor> extends
|
||||
/**
|
||||
* The default physical attack
|
||||
*/
|
||||
public int physicalAttack;
|
||||
public double physicalAttack;
|
||||
/**
|
||||
* The default magical attack
|
||||
*/
|
||||
public int magicalAttack;
|
||||
public double magicalAttack;
|
||||
/**
|
||||
* The physical defense
|
||||
*/
|
||||
public int physicalDefense;
|
||||
public double physicalDefense;
|
||||
/**
|
||||
* The magical defense
|
||||
*/
|
||||
public int magicalDefense;
|
||||
public double magicalDefense;
|
||||
|
||||
/**
|
||||
* The physical attack speed
|
||||
@@ -322,9 +322,13 @@ public abstract class ActorTemplate<T extends Actor> extends
|
||||
*/
|
||||
public int evasionChance;
|
||||
/**
|
||||
* The character's movement speed
|
||||
* The character's run speed
|
||||
*/
|
||||
public float moveSpeed;
|
||||
public double runSpeed;
|
||||
/**
|
||||
* The character's walk speed
|
||||
*/
|
||||
public double walkSpeed;
|
||||
/**
|
||||
* The maximum weigth in items to be carried in the inventory
|
||||
*/
|
||||
@@ -386,7 +390,7 @@ public abstract class ActorTemplate<T extends Actor> extends
|
||||
* @return the physicalAttack
|
||||
*/
|
||||
@Override
|
||||
public int getPhysicalAttack() {
|
||||
public double getPhysicalAttack() {
|
||||
return physicalAttack;
|
||||
}
|
||||
|
||||
@@ -394,7 +398,7 @@ public abstract class ActorTemplate<T extends Actor> extends
|
||||
* @return the magicalAttack
|
||||
*/
|
||||
@Override
|
||||
public int getMagicalAttack() {
|
||||
public double getMagicalAttack() {
|
||||
return magicalAttack;
|
||||
}
|
||||
|
||||
@@ -402,7 +406,7 @@ public abstract class ActorTemplate<T extends Actor> extends
|
||||
* @return the physicalDefense
|
||||
*/
|
||||
@Override
|
||||
public int getPhysicalDefense() {
|
||||
public double getPhysicalDefense() {
|
||||
return physicalDefense;
|
||||
}
|
||||
|
||||
@@ -410,7 +414,7 @@ public abstract class ActorTemplate<T extends Actor> extends
|
||||
* @return the magicalDefense
|
||||
*/
|
||||
@Override
|
||||
public int getMagicalDefense() {
|
||||
public double getMagicalDefense() {
|
||||
return magicalDefense;
|
||||
}
|
||||
|
||||
@@ -458,8 +462,13 @@ public abstract class ActorTemplate<T extends Actor> extends
|
||||
* @return the moveSpeed
|
||||
*/
|
||||
@Override
|
||||
public double getMoveSpeed() {
|
||||
return moveSpeed;
|
||||
public double getRunSpeed() {
|
||||
return runSpeed;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getWalkSpeed() {
|
||||
return walkSpeed;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
package com.l2jserver.model.template;
|
||||
|
||||
import com.l2jserver.model.id.template.CharacterTemplateID;
|
||||
import com.l2jserver.model.world.Actor.ActorRace;
|
||||
import com.l2jserver.model.world.L2Character;
|
||||
import com.l2jserver.model.world.character.CharacterClass;
|
||||
import com.l2jserver.util.dimensional.Point;
|
||||
@@ -59,10 +60,10 @@ public abstract class CharacterTemplate extends ActorTemplate<L2Character> {
|
||||
* The collision height for female instances
|
||||
*/
|
||||
protected double femaleCollisionHeight = 0;
|
||||
|
||||
|
||||
protected CharacterTemplate(CharacterTemplateID id,
|
||||
CharacterClass characterClass, Point spawnLocation) {
|
||||
super(id, characterClass.race);
|
||||
super(id);
|
||||
this.characterClass = characterClass;
|
||||
this.spawnLocation = spawnLocation;
|
||||
}
|
||||
@@ -71,13 +72,20 @@ public abstract class CharacterTemplate extends ActorTemplate<L2Character> {
|
||||
public L2Character createInstance() {
|
||||
final L2Character character = new L2Character(this.getID(), attributes);
|
||||
|
||||
character.setRace(race);
|
||||
character.setRace(getRace());
|
||||
character.setCharacterClass(characterClass);
|
||||
character.setPoint(spawnLocation);
|
||||
|
||||
return character;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the race
|
||||
*/
|
||||
public ActorRace getRace() {
|
||||
return characterClass.race;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the characterClass
|
||||
*/
|
||||
@@ -91,7 +99,7 @@ public abstract class CharacterTemplate extends ActorTemplate<L2Character> {
|
||||
public Point getSpawnLocation() {
|
||||
return spawnLocation;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return the male collision radius
|
||||
*/
|
||||
|
||||
@@ -25,7 +25,7 @@ import com.l2jserver.model.id.template.NPCTemplateID;
|
||||
import com.l2jserver.model.id.template.provider.ItemTemplateIDProvider;
|
||||
import com.l2jserver.model.template.capability.Interactable;
|
||||
import com.l2jserver.model.world.Actor;
|
||||
import com.l2jserver.model.world.Actor.Race;
|
||||
import com.l2jserver.model.world.Actor.ActorSex;
|
||||
import com.l2jserver.model.world.L2Character;
|
||||
import com.l2jserver.model.world.NPC;
|
||||
import com.l2jserver.service.game.character.CannotSetTargetServiceException;
|
||||
@@ -62,10 +62,18 @@ public abstract class NPCTemplate extends ActorTemplate<NPC> implements
|
||||
* The NPC name
|
||||
*/
|
||||
protected String name = null;
|
||||
/**
|
||||
* If true will send the name in the packet
|
||||
*/
|
||||
protected boolean serverSideName;
|
||||
/**
|
||||
* The NPC title
|
||||
*/
|
||||
protected String title = null;
|
||||
/**
|
||||
* If true will send the title in the packet
|
||||
*/
|
||||
protected boolean serverSideTitle;
|
||||
/**
|
||||
* The attackable state of the NPC
|
||||
*/
|
||||
@@ -80,8 +88,36 @@ public abstract class NPCTemplate extends ActorTemplate<NPC> implements
|
||||
*/
|
||||
protected double collisionHeight = 0;
|
||||
|
||||
// id idTemplate name serverSideName title serverSideTitle class
|
||||
// collision_radius collision_height level sex type attackrange hp mp hpreg
|
||||
// mpreg str con dex int wit men exp sp patk pdef matk mdef atkspd critical
|
||||
// aggro matkspd rhand lhand enchant walkspd runspd targetable show_name
|
||||
// dropHerbGroup basestats
|
||||
|
||||
protected ActorSex sex;
|
||||
protected int level;
|
||||
|
||||
protected int attackRange;
|
||||
|
||||
protected double hpRegeneration;
|
||||
protected double mpRegeneration;
|
||||
|
||||
protected long experience;
|
||||
protected long sp;
|
||||
|
||||
protected boolean aggressive;
|
||||
|
||||
protected ItemTemplateID rightHand;
|
||||
protected ItemTemplateID leftHand;
|
||||
protected int enchantLevel;
|
||||
|
||||
protected boolean targetable;
|
||||
protected boolean showName;
|
||||
protected int dropHerbGroup;
|
||||
protected boolean baseAttributes;
|
||||
|
||||
protected NPCTemplate(NPCTemplateID id) {
|
||||
super(id, null);
|
||||
super(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -195,10 +231,122 @@ public abstract class NPCTemplate extends ActorTemplate<NPC> implements
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the race
|
||||
* @return the serverSideName
|
||||
*/
|
||||
public Race getRace() {
|
||||
return race;
|
||||
public boolean isServerSideName() {
|
||||
return serverSideName;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the serverSideTitle
|
||||
*/
|
||||
public boolean isServerSideTitle() {
|
||||
return serverSideTitle;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the sex
|
||||
*/
|
||||
public ActorSex getSex() {
|
||||
return sex;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the level
|
||||
*/
|
||||
public int getLevel() {
|
||||
return level;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the attackRange
|
||||
*/
|
||||
public int getAttackRange() {
|
||||
return attackRange;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the hpRegeneration
|
||||
*/
|
||||
public double getHPRegeneration() {
|
||||
return hpRegeneration;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the mpRegeneration
|
||||
*/
|
||||
public double getMPRegeneration() {
|
||||
return mpRegeneration;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the experience
|
||||
*/
|
||||
public long getExperience() {
|
||||
return experience;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the sp
|
||||
*/
|
||||
public long getSp() {
|
||||
return sp;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the aggressive
|
||||
*/
|
||||
public boolean isAggressive() {
|
||||
return aggressive;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the right Hand item
|
||||
*/
|
||||
public ItemTemplateID getRightHand() {
|
||||
return rightHand;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the left Hand item
|
||||
*/
|
||||
public ItemTemplateID getLeftHand() {
|
||||
return leftHand;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the enchantLevel
|
||||
*/
|
||||
public int getEnchantLevel() {
|
||||
return enchantLevel;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the targetable
|
||||
*/
|
||||
public boolean isTargetable() {
|
||||
return targetable;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the showName
|
||||
*/
|
||||
public boolean isShowName() {
|
||||
return showName;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the dropHerbGroup
|
||||
*/
|
||||
public int getDropHerbGroup() {
|
||||
return dropHerbGroup;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the baseAttributes
|
||||
*/
|
||||
public boolean isBaseAttributes() {
|
||||
return baseAttributes;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -23,7 +23,7 @@ import com.l2jserver.model.template.NPCTemplate;
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
*
|
||||
*/
|
||||
public class PenaltyNPCTemplate extends NPCTemplate {
|
||||
public class GrandBossNPCTemplate extends NPCTemplate {
|
||||
/**
|
||||
* Creates a new instance of this template
|
||||
*
|
||||
@@ -32,7 +32,7 @@ public class PenaltyNPCTemplate extends NPCTemplate {
|
||||
* @param race
|
||||
* the npc race
|
||||
*/
|
||||
protected PenaltyNPCTemplate(NPCTemplateID id) {
|
||||
protected GrandBossNPCTemplate(NPCTemplateID id) {
|
||||
super(id);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
/*
|
||||
* This file is part of l2jserver <l2jserver.com>.
|
||||
*
|
||||
* l2jserver is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* l2jserver is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with l2jserver. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jserver.model.template.npc;
|
||||
|
||||
import com.l2jserver.model.id.template.NPCTemplateID;
|
||||
|
||||
/**
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
*
|
||||
*/
|
||||
public class MysticVillageMasterNPCTemplate extends AbstractVillageMasterNPCTemplate {
|
||||
/**
|
||||
* Creates a new instance of this template
|
||||
*
|
||||
* @param id
|
||||
* the template id
|
||||
* @param race
|
||||
* the npc race
|
||||
*/
|
||||
protected MysticVillageMasterNPCTemplate(NPCTemplateID id) {
|
||||
super(id);
|
||||
}
|
||||
}
|
||||
@@ -23,7 +23,7 @@ import com.l2jserver.model.template.NPCTemplate;
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
*
|
||||
*/
|
||||
public class SignsPriestsNPCTemplate extends NPCTemplate {
|
||||
public class PenaltyMonsterNPCTemplate extends NPCTemplate {
|
||||
/**
|
||||
* Creates a new instance of this template
|
||||
*
|
||||
@@ -32,7 +32,7 @@ public class SignsPriestsNPCTemplate extends NPCTemplate {
|
||||
* @param race
|
||||
* the npc race
|
||||
*/
|
||||
protected SignsPriestsNPCTemplate(NPCTemplateID id) {
|
||||
protected PenaltyMonsterNPCTemplate(NPCTemplateID id) {
|
||||
super(id);
|
||||
}
|
||||
}
|
||||
@@ -23,7 +23,7 @@ import com.l2jserver.model.template.NPCTemplate;
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
*
|
||||
*/
|
||||
public class GrandeBossNPCTemplate extends NPCTemplate {
|
||||
public class SignsPriestNPCTemplate extends NPCTemplate {
|
||||
/**
|
||||
* Creates a new instance of this template
|
||||
*
|
||||
@@ -32,7 +32,7 @@ public class GrandeBossNPCTemplate extends NPCTemplate {
|
||||
* @param race
|
||||
* the npc race
|
||||
*/
|
||||
protected GrandeBossNPCTemplate(NPCTemplateID id) {
|
||||
protected SignsPriestNPCTemplate(NPCTemplateID id) {
|
||||
super(id);
|
||||
}
|
||||
}
|
||||
@@ -24,6 +24,7 @@ import com.l2jserver.model.id.template.NPCTemplateID;
|
||||
import com.l2jserver.model.template.NPCTemplate;
|
||||
import com.l2jserver.model.world.L2Character;
|
||||
import com.l2jserver.model.world.NPC;
|
||||
import com.l2jserver.service.game.spawn.CharacterAlreadyTeleportingServiceException;
|
||||
import com.l2jserver.service.game.spawn.NotSpawnedServiceException;
|
||||
import com.l2jserver.service.game.spawn.SpawnService;
|
||||
import com.l2jserver.util.dimensional.Coordinate;
|
||||
@@ -103,6 +104,8 @@ public class TeleporterNPCTemplate extends NPCTemplate {
|
||||
*/
|
||||
protected TeleporterNPCTemplate(NPCTemplateID id) {
|
||||
super(id);
|
||||
// TODO remove this when possible
|
||||
addLocation("Talking Island Village - temporary", TALKING_ISLAND_VILLAGE, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -138,7 +141,8 @@ public class TeleporterNPCTemplate extends NPCTemplate {
|
||||
|
||||
protected void teleport(NPC npc, L2Character character,
|
||||
Lineage2Connection conn, String name)
|
||||
throws NotSpawnedServiceException {
|
||||
throws NotSpawnedServiceException,
|
||||
CharacterAlreadyTeleportingServiceException {
|
||||
final int location = Integer.parseInt(name);
|
||||
final TeleportationMetadata metadata = locations.get(location);
|
||||
if (metadata == null) {
|
||||
|
||||
@@ -34,14 +34,14 @@ public abstract class Actor extends PositionableObject {
|
||||
/**
|
||||
* The actor race
|
||||
*/
|
||||
protected Race race;
|
||||
protected ActorRace race;
|
||||
|
||||
/**
|
||||
* Represents the actor race.
|
||||
*
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
*/
|
||||
public enum Race {
|
||||
public enum ActorRace {
|
||||
HUMAN(0x00), ELF(0x01), DARK_ELF(0x02), ORC(0x03), DWARF(0x04), KAMAEL(
|
||||
0x05);
|
||||
|
||||
@@ -50,7 +50,7 @@ public abstract class Actor extends PositionableObject {
|
||||
*/
|
||||
public final int id;
|
||||
|
||||
Race(int id) {
|
||||
ActorRace(int id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
@@ -61,8 +61,8 @@ public abstract class Actor extends PositionableObject {
|
||||
* the id
|
||||
* @return the race constant
|
||||
*/
|
||||
public static Race fromOption(int id) {
|
||||
for (final Race race : values()) {
|
||||
public static ActorRace fromOption(int id) {
|
||||
for (final ActorRace race : values()) {
|
||||
if (race.id == id)
|
||||
return race;
|
||||
}
|
||||
@@ -73,7 +73,7 @@ public abstract class Actor extends PositionableObject {
|
||||
/**
|
||||
* The actor sex
|
||||
*/
|
||||
protected Sex sex;
|
||||
protected ActorSex sex;
|
||||
|
||||
/**
|
||||
* Represent the sex of an actor.
|
||||
@@ -81,17 +81,17 @@ public abstract class Actor extends PositionableObject {
|
||||
*
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
*/
|
||||
public enum Sex {
|
||||
public enum ActorSex {
|
||||
MALE(0x00), FEMALE(0x01);
|
||||
|
||||
public final int option;
|
||||
|
||||
Sex(int option) {
|
||||
ActorSex(int option) {
|
||||
this.option = option;
|
||||
}
|
||||
|
||||
public static Sex fromOption(int option) {
|
||||
for (Sex sex : values()) {
|
||||
public static ActorSex fromOption(int option) {
|
||||
for (ActorSex sex : values()) {
|
||||
if (sex.option == option)
|
||||
return sex;
|
||||
}
|
||||
@@ -135,7 +135,7 @@ public abstract class Actor extends PositionableObject {
|
||||
/**
|
||||
* @return the race
|
||||
*/
|
||||
public Race getRace() {
|
||||
public ActorRace getRace() {
|
||||
return race;
|
||||
}
|
||||
|
||||
@@ -143,14 +143,14 @@ public abstract class Actor extends PositionableObject {
|
||||
* @param race
|
||||
* the race to set
|
||||
*/
|
||||
public void setRace(Race race) {
|
||||
public void setRace(ActorRace race) {
|
||||
this.race = race;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the sex
|
||||
*/
|
||||
public Sex getSex() {
|
||||
public ActorSex getSex() {
|
||||
return sex;
|
||||
}
|
||||
|
||||
@@ -158,7 +158,7 @@ public abstract class Actor extends PositionableObject {
|
||||
* @param sex
|
||||
* the sex to set
|
||||
*/
|
||||
public void setSex(Sex sex) {
|
||||
public void setSex(ActorSex sex) {
|
||||
this.sex = sex;
|
||||
}
|
||||
|
||||
|
||||
@@ -32,6 +32,7 @@ import com.l2jserver.model.world.character.CharacterClass;
|
||||
import com.l2jserver.model.world.character.CharacterFriendList;
|
||||
import com.l2jserver.model.world.character.CharacterInventory;
|
||||
import com.l2jserver.model.world.character.CharacterShortcutContainer;
|
||||
import com.l2jserver.util.dimensional.Point;
|
||||
|
||||
/**
|
||||
* This class represents a playable character in Lineage II world.
|
||||
@@ -129,10 +130,20 @@ public class L2Character extends Player {
|
||||
*/
|
||||
private CharacterState state;
|
||||
|
||||
/**
|
||||
* The valid states for an character
|
||||
*
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
*/
|
||||
public enum CharacterState {
|
||||
TELEPORTING, CASTING, ATTACKING, MOVING;
|
||||
}
|
||||
|
||||
/**
|
||||
* The point the player is moving, teleporting etc...
|
||||
*/
|
||||
private Point targetLocation;
|
||||
|
||||
/**
|
||||
* Creates a new instance
|
||||
*
|
||||
@@ -330,6 +341,28 @@ public class L2Character extends Player {
|
||||
return state == CharacterState.TELEPORTING;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return true if character is moving
|
||||
*/
|
||||
public boolean isMoving() {
|
||||
return state == CharacterState.MOVING;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the targetLocation
|
||||
*/
|
||||
public Point getTargetLocation() {
|
||||
return targetLocation;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param targetLocation
|
||||
* the targetLocation to set
|
||||
*/
|
||||
public void setTargetLocation(Point targetLocation) {
|
||||
this.targetLocation = targetLocation;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the inventory
|
||||
*/
|
||||
|
||||
@@ -60,22 +60,22 @@ public interface ActorAttributes {
|
||||
/**
|
||||
* @return the physicalAttack
|
||||
*/
|
||||
public int getPhysicalAttack();
|
||||
public double getPhysicalAttack();
|
||||
|
||||
/**
|
||||
* @return the magicalAttack
|
||||
*/
|
||||
public int getMagicalAttack();
|
||||
public double getMagicalAttack();
|
||||
|
||||
/**
|
||||
* @return the physicalDefense
|
||||
*/
|
||||
public int getPhysicalDefense();
|
||||
public double getPhysicalDefense();
|
||||
|
||||
/**
|
||||
* @return the magicalDefense
|
||||
*/
|
||||
public int getMagicalDefense();
|
||||
public double getMagicalDefense();
|
||||
|
||||
/**
|
||||
* @return the attackSpeed
|
||||
@@ -103,9 +103,14 @@ public interface ActorAttributes {
|
||||
public int getEvasionChance();
|
||||
|
||||
/**
|
||||
* @return the movement speed
|
||||
* @return the run speed
|
||||
*/
|
||||
public double getMoveSpeed();
|
||||
public double getRunSpeed();
|
||||
|
||||
/**
|
||||
* @return the walking speed
|
||||
*/
|
||||
public double getWalkSpeed();
|
||||
|
||||
/**
|
||||
* @return the maxWeigth
|
||||
|
||||
@@ -73,22 +73,22 @@ public class CharacterCalculatedAttributes implements ActorAttributes {
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getPhysicalAttack() {
|
||||
public double getPhysicalAttack() {
|
||||
return baseAttributes.getPhysicalAttack();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMagicalAttack() {
|
||||
public double getMagicalAttack() {
|
||||
return baseAttributes.getMagicalAttack();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getPhysicalDefense() {
|
||||
public double getPhysicalDefense() {
|
||||
return baseAttributes.getPhysicalDefense();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMagicalDefense() {
|
||||
public double getMagicalDefense() {
|
||||
return baseAttributes.getMagicalDefense();
|
||||
}
|
||||
|
||||
@@ -118,8 +118,13 @@ public class CharacterCalculatedAttributes implements ActorAttributes {
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getMoveSpeed() {
|
||||
return baseAttributes.getMoveSpeed();
|
||||
public double getRunSpeed() {
|
||||
return baseAttributes.getRunSpeed();
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getWalkSpeed() {
|
||||
return baseAttributes.getWalkSpeed();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
*/
|
||||
package com.l2jserver.model.world.character;
|
||||
|
||||
import com.l2jserver.model.world.Actor.Race;
|
||||
import com.l2jserver.model.world.Actor.ActorRace;
|
||||
|
||||
/**
|
||||
* Defines all the possible classes for an character
|
||||
@@ -27,7 +27,7 @@ public enum CharacterClass {
|
||||
/**
|
||||
* Human fighter
|
||||
*/
|
||||
HUMAN_FIGHTER(0x00, ClassType.FIGHTER, Race.HUMAN), WARRIOR(0x01,
|
||||
HUMAN_FIGHTER(0x00, ClassType.FIGHTER, ActorRace.HUMAN), WARRIOR(0x01,
|
||||
HUMAN_FIGHTER), GLADIATOR(0x02, WARRIOR), WARLORD(0x03, WARRIOR), KNIGHT(
|
||||
0x04, HUMAN_FIGHTER), PALADIN(0x05, KNIGHT), DARK_AVENGER(0x06,
|
||||
KNIGHT), ROGUE(0x07, HUMAN_FIGHTER), TREASURE_HUNTER(0x08, ROGUE), HAWKEYE(
|
||||
@@ -40,7 +40,7 @@ public enum CharacterClass {
|
||||
/**
|
||||
* Human mystic
|
||||
*/
|
||||
HUMAN_MYSTIC(0x0a, ClassType.MYSTIC, Race.HUMAN), WIZARD(0x0b, HUMAN_MYSTIC), SORCEROR(
|
||||
HUMAN_MYSTIC(0x0a, ClassType.MYSTIC, ActorRace.HUMAN), WIZARD(0x0b, HUMAN_MYSTIC), SORCEROR(
|
||||
0x0c, WIZARD), NECROMANCER(0x0d, WIZARD), WARLOCK(0x0e, true,
|
||||
WIZARD), CLERIC(0x0f, ClassType.PRIEST, HUMAN_MYSTIC), BISHOP(0x10,
|
||||
CLERIC), PROPHET(0x11, CLERIC),
|
||||
@@ -51,7 +51,7 @@ public enum CharacterClass {
|
||||
/**
|
||||
* Elven fighter
|
||||
*/
|
||||
ELVEN_FIGHTER(0x12, ClassType.FIGHTER, Race.ELF), ELVEN_KNIGHT(0x13,
|
||||
ELVEN_FIGHTER(0x12, ClassType.FIGHTER, ActorRace.ELF), ELVEN_KNIGHT(0x13,
|
||||
ELVEN_FIGHTER), TEMPLE_KNIGHT(0x14, ELVEN_KNIGHT), SWORD_SINGER(
|
||||
0x15, ELVEN_KNIGHT), ELVEN_SCOUT(0x16, ELVEN_FIGHTER), PLAINS_WALKER(
|
||||
0x17, ELVEN_SCOUT), SILVER_RANGER(0x18, ELVEN_SCOUT),
|
||||
@@ -61,7 +61,7 @@ public enum CharacterClass {
|
||||
/**
|
||||
* Elven mystic
|
||||
*/
|
||||
ELVEN_MYSTIC(0x19, ClassType.MYSTIC, Race.ELF), ELVEN_WIZARD(0x1a,
|
||||
ELVEN_MYSTIC(0x19, ClassType.MYSTIC, ActorRace.ELF), ELVEN_WIZARD(0x1a,
|
||||
ELVEN_MYSTIC), SPELLSINGER(0x1b, ELVEN_WIZARD), ELEMENTAL_SUMMONER(
|
||||
0x1c, true, ELVEN_WIZARD), ORACLE(0x1d, ClassType.PRIEST,
|
||||
ELVEN_MYSTIC), ELDER(0x1e, ORACLE),
|
||||
@@ -72,7 +72,7 @@ public enum CharacterClass {
|
||||
/**
|
||||
* Dark elf fighter
|
||||
*/
|
||||
DARK_FIGHTER(0x1f, ClassType.FIGHTER, Race.DARK_ELF), PALUS_KNIGHT(0x20,
|
||||
DARK_FIGHTER(0x1f, ClassType.FIGHTER, ActorRace.DARK_ELF), PALUS_KNIGHT(0x20,
|
||||
DARK_FIGHTER), SHILLIEN_KNIGHT(0x21, PALUS_KNIGHT), BLADEDANCER(
|
||||
0x22, PALUS_KNIGHT), ASSASSIN(0x23, DARK_FIGHTER), ABYSS_WALKER(
|
||||
0x24, ASSASSIN), PHANTOM_RANGER(0x25, ASSASSIN),
|
||||
@@ -83,7 +83,7 @@ public enum CharacterClass {
|
||||
/**
|
||||
* Dark elf mystic
|
||||
*/
|
||||
DARK_MYSTIC(0x26, ClassType.MYSTIC, Race.DARK_ELF), DARK_WIZARD(0x27,
|
||||
DARK_MYSTIC(0x26, ClassType.MYSTIC, ActorRace.DARK_ELF), DARK_WIZARD(0x27,
|
||||
DARK_MYSTIC), SPELLHOWLER(0x28, DARK_WIZARD), PHANTOM_SUMMONER(
|
||||
0x29, true, DARK_WIZARD), SHILLIEN_ORACLE(0x2a, ClassType.PRIEST,
|
||||
DARK_MYSTIC), SHILLIEN_ELDER(0x2b, SHILLIEN_ORACLE),
|
||||
@@ -94,7 +94,7 @@ public enum CharacterClass {
|
||||
/**
|
||||
* Orc fighter
|
||||
*/
|
||||
ORC_FIGHTER(0x2c, ClassType.FIGHTER, Race.ORC), ORC_RAIDER(0x2d,
|
||||
ORC_FIGHTER(0x2c, ClassType.FIGHTER, ActorRace.ORC), ORC_RAIDER(0x2d,
|
||||
ORC_FIGHTER), DESTROYER(0x2e, ORC_RAIDER), ORC_MONK(0x2f,
|
||||
ORC_FIGHTER), TYRANT(0x30, ORC_RAIDER),
|
||||
// 3rd classes
|
||||
@@ -103,7 +103,7 @@ public enum CharacterClass {
|
||||
/**
|
||||
* Orc mystic
|
||||
*/
|
||||
ORC_MYSTIC(0x31, ClassType.MYSTIC, Race.ORC), ORC_SHAMAN(0x32, ORC_MYSTIC), OVERLORD(
|
||||
ORC_MYSTIC(0x31, ClassType.MYSTIC, ActorRace.ORC), ORC_SHAMAN(0x32, ORC_MYSTIC), OVERLORD(
|
||||
0x33, ORC_SHAMAN), WARCRYER(0x34, ORC_SHAMAN),
|
||||
// 3rd classes
|
||||
DOMINATOR(0x73, OVERLORD), DOOMCRYER(0x74, WARCRYER),
|
||||
@@ -111,7 +111,7 @@ public enum CharacterClass {
|
||||
/**
|
||||
* Dwarf fighter
|
||||
*/
|
||||
DWARVEN_FIGHTER(0x35, ClassType.FIGHTER, Race.DWARF), SCAVENGER(0x36,
|
||||
DWARVEN_FIGHTER(0x35, ClassType.FIGHTER, ActorRace.DWARF), SCAVENGER(0x36,
|
||||
DWARVEN_FIGHTER), BOUNTY_HUNTER(0x37, SCAVENGER), ARTISAN(0x38,
|
||||
DWARVEN_FIGHTER), WARSMITH(0x39, ARTISAN),
|
||||
// 3rd classes
|
||||
@@ -120,7 +120,7 @@ public enum CharacterClass {
|
||||
/**
|
||||
* Kamael male soldier
|
||||
*/
|
||||
MALE_SOLDIER(0x7b, ClassType.FIGHTER, Race.KAMAEL), TROOPER(0x7D,
|
||||
MALE_SOLDIER(0x7b, ClassType.FIGHTER, ActorRace.KAMAEL), TROOPER(0x7D,
|
||||
MALE_SOLDIER), BERSEKER(0x7F, TROOPER), MALE_SOULBREAKER(0x80,
|
||||
TROOPER), DOOMBRINGER(0x83, BERSEKER), MALE_SOULDHOUND(0x84,
|
||||
MALE_SOULBREAKER),
|
||||
@@ -128,7 +128,7 @@ public enum CharacterClass {
|
||||
/**
|
||||
* Kamael female soldier
|
||||
*/
|
||||
FEMALE_SOLDIER(0x7C, ClassType.FIGHTER, Race.KAMAEL), WARDER(0x7E,
|
||||
FEMALE_SOLDIER(0x7C, ClassType.FIGHTER, ActorRace.KAMAEL), WARDER(0x7E,
|
||||
FEMALE_SOLDIER), FEMALE_SOULBREAKER(0x81, WARDER), ARBALESTER(0x82,
|
||||
WARDER), FEMALE_SOULDHOUND(0x85, FEMALE_SOULBREAKER), TRICKSTER(
|
||||
0x86, ARBALESTER), INSPECTOR(0x87, WARDER), JUDICATOR(0x88,
|
||||
@@ -174,7 +174,7 @@ public enum CharacterClass {
|
||||
/**
|
||||
* The class race
|
||||
*/
|
||||
public final Race race;
|
||||
public final ActorRace race;
|
||||
/**
|
||||
* The parent class
|
||||
*/
|
||||
@@ -194,7 +194,7 @@ public enum CharacterClass {
|
||||
* @param parent
|
||||
* the parent
|
||||
*/
|
||||
private CharacterClass(int id, ClassType type, boolean summoner, Race race,
|
||||
private CharacterClass(int id, ClassType type, boolean summoner, ActorRace race,
|
||||
CharacterClass parent) {
|
||||
this.id = id;
|
||||
this.type = type;
|
||||
@@ -242,7 +242,7 @@ public enum CharacterClass {
|
||||
* @param parent
|
||||
* the parent class
|
||||
*/
|
||||
private CharacterClass(int id, Race race, CharacterClass parent) {
|
||||
private CharacterClass(int id, ActorRace race, CharacterClass parent) {
|
||||
this(id, parent.type, parent.summoner, race, parent);
|
||||
}
|
||||
|
||||
@@ -257,7 +257,7 @@ public enum CharacterClass {
|
||||
* @param race
|
||||
* the class race
|
||||
*/
|
||||
private CharacterClass(int id, ClassType type, Race race) {
|
||||
private CharacterClass(int id, ClassType type, ActorRace race) {
|
||||
this(id, type, false, race, null);
|
||||
}
|
||||
|
||||
|
||||
@@ -84,16 +84,6 @@ public interface CharacterService extends Service {
|
||||
throws CannotSetTargetServiceException,
|
||||
ActorIsNotAttackableServiceException;
|
||||
|
||||
/**
|
||||
* Informs that an given <tt>character</tt> is appearing in the world.
|
||||
* <p>
|
||||
* This is normally called after an teleport.
|
||||
*
|
||||
* @param character
|
||||
* the character
|
||||
*/
|
||||
void appearing(L2Character character);
|
||||
|
||||
/**
|
||||
* Jails the given <tt>character</tt> for <tt>time</tt> seconds.
|
||||
*
|
||||
|
||||
@@ -220,12 +220,6 @@ public class CharacterServiceImpl extends AbstractService implements
|
||||
} else if (e instanceof PlayerTeleportedEvent
|
||||
|| e instanceof CharacterEnterWorldEvent) {
|
||||
broadcast(conn, character);
|
||||
} else if (e instanceof CharacterWalkingEvent) {
|
||||
conn.write(new CharacterMovementTypePacket(
|
||||
((CharacterWalkingEvent) e).getCharacter()));
|
||||
} else if (e instanceof CharacterRunningEvent) {
|
||||
conn.write(new CharacterMovementTypePacket(
|
||||
((CharacterRunningEvent) e).getCharacter()));
|
||||
}
|
||||
// keep listener alive
|
||||
return true;
|
||||
@@ -372,20 +366,6 @@ public class CharacterServiceImpl extends AbstractService implements
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void appearing(L2Character character) {
|
||||
Preconditions.checkNotNull(character, "character");
|
||||
final CharacterID id = character.getID();
|
||||
final Lineage2Connection conn = networkService.discover(id);
|
||||
|
||||
character.setState(null);
|
||||
|
||||
conn.write(new CharacterInformationPacket(character));
|
||||
conn.write(new CharacterInformationExtraPacket(character));
|
||||
eventDispatcher.dispatch(new PlayerTeleportedEvent(character, character
|
||||
.getPoint()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void jail(L2Character character, long time, String reason)
|
||||
throws CharacterInJailServiceException {
|
||||
@@ -414,6 +394,7 @@ public class CharacterServiceImpl extends AbstractService implements
|
||||
// validation packets, sent by client
|
||||
|
||||
character.setState(CharacterState.MOVING);
|
||||
character.setTargetLocation(coordinate.toPoint());
|
||||
|
||||
// for now, let's just write the packet, we don't have much validation
|
||||
// to be done yet. With character validation packet, another packet of
|
||||
@@ -440,8 +421,14 @@ public class CharacterServiceImpl extends AbstractService implements
|
||||
return;
|
||||
final Point old = character.getPoint();
|
||||
character.setPoint(point);
|
||||
character.setState(CharacterState.MOVING);
|
||||
eventDispatcher.dispatch(new CharacterMoveEvent(character, old));
|
||||
|
||||
if (point.getCoordinate().equals(
|
||||
character.getTargetLocation().getCoordinate())) {
|
||||
character.setState(null);
|
||||
character.setTargetLocation(null);
|
||||
// TODO dispatch stop event
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
/*
|
||||
* This file is part of l2jserver <l2jserver.com>.
|
||||
*
|
||||
* l2jserver is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* l2jserver is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with l2jserver. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jserver.service.game.spawn;
|
||||
|
||||
/**
|
||||
* Exception thrown when trying to teleport an character but its state indicates
|
||||
* that it is already teleporting.
|
||||
*
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
*/
|
||||
public class CharacterAlreadyTeleportingServiceException extends
|
||||
SpawnServiceException {
|
||||
private static final long serialVersionUID = 1L;
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
/*
|
||||
* This file is part of l2jserver <l2jserver.com>.
|
||||
*
|
||||
* l2jserver is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* l2jserver is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with l2jserver. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.l2jserver.service.game.spawn;
|
||||
|
||||
/**
|
||||
* Exception thrown when trying to finish the teleportion of an character but
|
||||
* its state is not teleporting.
|
||||
*
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
*/
|
||||
public class CharacterNotTeleportingServiceException extends
|
||||
SpawnServiceException {
|
||||
private static final long serialVersionUID = 1L;
|
||||
}
|
||||
@@ -16,9 +16,12 @@
|
||||
*/
|
||||
package com.l2jserver.service.game.spawn;
|
||||
|
||||
import com.l2jserver.model.world.L2Character;
|
||||
import com.l2jserver.model.world.L2Character.CharacterState;
|
||||
import com.l2jserver.model.world.Player;
|
||||
import com.l2jserver.model.world.PositionableObject;
|
||||
import com.l2jserver.model.world.event.SpawnEvent;
|
||||
import com.l2jserver.model.world.player.event.PlayerTeleportedEvent;
|
||||
import com.l2jserver.model.world.player.event.PlayerTeleportingEvent;
|
||||
import com.l2jserver.service.Service;
|
||||
import com.l2jserver.util.dimensional.Coordinate;
|
||||
@@ -63,9 +66,29 @@ public interface SpawnService extends Service {
|
||||
* the teleportation coordinate
|
||||
* @throws NotSpawnedServiceException
|
||||
* if the object to be teleported is not spawned
|
||||
* @throws CharacterAlreadyTeleportingServiceException
|
||||
* if this player is already being teleported. This will only be
|
||||
* thrown for {@link L2Character} instances.
|
||||
*/
|
||||
void teleport(Player player, Coordinate coordinate)
|
||||
throws NotSpawnedServiceException;
|
||||
throws NotSpawnedServiceException,
|
||||
CharacterAlreadyTeleportingServiceException;
|
||||
|
||||
/**
|
||||
* Finishes teleporting the character. This is only used for
|
||||
* {@link L2Character} instances.
|
||||
* <p>
|
||||
* An {@link PlayerTeleportedEvent} will be dispatched and the new position
|
||||
* will be broadcast to all clients.
|
||||
*
|
||||
* @param character
|
||||
* the character object
|
||||
* @throws CharacterNotTeleportingServiceException
|
||||
* if the character state is not
|
||||
* {@link CharacterState#TELEPORTING}
|
||||
*/
|
||||
void finishTeleport(L2Character character)
|
||||
throws CharacterNotTeleportingServiceException;
|
||||
|
||||
/**
|
||||
* Schedules an {@link Spawnable} object to be respawn in a certain time.
|
||||
@@ -85,5 +108,6 @@ public interface SpawnService extends Service {
|
||||
* @throws NotSpawnedServiceException
|
||||
* if the object is not spawned
|
||||
*/
|
||||
void unspawn(PositionableObject spawnable) throws NotSpawnedServiceException;
|
||||
void unspawn(PositionableObject spawnable)
|
||||
throws NotSpawnedServiceException;
|
||||
}
|
||||
|
||||
@@ -22,6 +22,8 @@ import org.slf4j.LoggerFactory;
|
||||
import com.google.common.base.Preconditions;
|
||||
import com.google.inject.Inject;
|
||||
import com.l2jserver.game.net.Lineage2Connection;
|
||||
import com.l2jserver.game.net.packet.server.CharacterInformationExtraPacket;
|
||||
import com.l2jserver.game.net.packet.server.CharacterInformationPacket;
|
||||
import com.l2jserver.game.net.packet.server.CharacterTeleportPacket;
|
||||
import com.l2jserver.model.id.object.CharacterID;
|
||||
import com.l2jserver.model.world.L2Character;
|
||||
@@ -31,6 +33,7 @@ import com.l2jserver.model.world.Player;
|
||||
import com.l2jserver.model.world.PositionableObject;
|
||||
import com.l2jserver.model.world.event.SpawnEvent;
|
||||
import com.l2jserver.model.world.npc.event.NPCSpawnEvent;
|
||||
import com.l2jserver.model.world.player.event.PlayerTeleportedEvent;
|
||||
import com.l2jserver.model.world.player.event.PlayerTeleportingEvent;
|
||||
import com.l2jserver.service.AbstractService;
|
||||
import com.l2jserver.service.AbstractService.Depends;
|
||||
@@ -111,19 +114,25 @@ public class SpawnServiceImpl extends AbstractService implements SpawnService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void teleport(Player player, Coordinate coordinate) {
|
||||
public void teleport(Player player, Coordinate coordinate)
|
||||
throws CharacterAlreadyTeleportingServiceException {
|
||||
Preconditions.checkNotNull(player, "player");
|
||||
Preconditions.checkNotNull(coordinate, "coordinate");
|
||||
System.out.println("teleport: " + coordinate);
|
||||
player.setPosition(coordinate);
|
||||
if (player instanceof L2Character) {
|
||||
if (((L2Character) player).isTeleporting())
|
||||
throw new CharacterAlreadyTeleportingServiceException();
|
||||
|
||||
final Lineage2Connection conn = networkService
|
||||
.discover((CharacterID) player.getID());
|
||||
if (conn == null)
|
||||
// TODO throw an exception here
|
||||
return;
|
||||
conn.write(new CharacterTeleportPacket(conn.getCharacter()));
|
||||
conn.write(new CharacterTeleportPacket(conn.getCharacter(),
|
||||
coordinate.toPoint()));
|
||||
((L2Character) player).setState(CharacterState.TELEPORTING);
|
||||
((L2Character) player).setTargetLocation(coordinate.toPoint());
|
||||
} else {
|
||||
player.setPosition(coordinate);
|
||||
}
|
||||
// dispatch teleport event
|
||||
eventDispatcher.dispatch(new PlayerTeleportingEvent(player, coordinate
|
||||
@@ -131,6 +140,28 @@ public class SpawnServiceImpl extends AbstractService implements SpawnService {
|
||||
// remember: broadcasting is done through events!
|
||||
}
|
||||
|
||||
@Override
|
||||
public void finishTeleport(L2Character character)
|
||||
throws CharacterNotTeleportingServiceException {
|
||||
Preconditions.checkNotNull(character, "character");
|
||||
final CharacterID id = character.getID();
|
||||
final Lineage2Connection conn = networkService.discover(id);
|
||||
|
||||
if (!character.isTeleporting())
|
||||
throw new CharacterNotTeleportingServiceException();
|
||||
|
||||
character.setState(null);
|
||||
character.setPoint(character.getTargetLocation());
|
||||
|
||||
eventDispatcher.dispatch(new PlayerTeleportedEvent(character, character
|
||||
.getTargetLocation()));
|
||||
|
||||
character.setTargetLocation(null);
|
||||
|
||||
conn.write(new CharacterInformationPacket(character));
|
||||
conn.write(new CharacterInformationExtraPacket(character));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void scheduleRespawn(PositionableObject object) {
|
||||
Preconditions.checkNotNull(object, "object");
|
||||
|
||||
@@ -21,7 +21,6 @@ import java.util.Queue;
|
||||
import java.util.Set;
|
||||
import java.util.Timer;
|
||||
import java.util.TimerTask;
|
||||
import java.util.concurrent.ArrayBlockingQueue;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.TimeoutException;
|
||||
@@ -64,10 +63,11 @@ public class WorldEventDispatcherImpl implements WorldEventDispatcher {
|
||||
/**
|
||||
* The events pending dispatch
|
||||
*/
|
||||
private Queue<EventContainer> events = new ArrayBlockingQueue<EventContainer>(
|
||||
100 * 1000);
|
||||
private Queue<EventContainer> events = CollectionFactory
|
||||
.newConcurrentQueue();
|
||||
|
||||
public void start() {
|
||||
// TODO event dispatching should be done using ThreadService
|
||||
timer = new Timer();
|
||||
final TimerTask task = new TimerTask() {
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user