mirror of
https://github.com/Rogiel/l2jserver2
synced 2025-12-08 00:13:11 +00:00
Created CharacterTemplate object for all classes
Signed-off-by: Rogiel <rogiel@rogiel.com>
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
package com.l2jserver.model.id;
|
||||
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.assistedinject.Assisted;
|
||||
|
||||
/**
|
||||
@@ -15,6 +16,7 @@ public class AccountID extends ID<String> {
|
||||
* @param login
|
||||
* the login
|
||||
*/
|
||||
@Inject
|
||||
public AccountID(@Assisted String login) {
|
||||
super(login);
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@ import com.l2jserver.model.world.AbstractActor.Race;
|
||||
import com.l2jserver.model.world.L2Character;
|
||||
import com.l2jserver.model.world.character.CharacterBaseAttributes;
|
||||
import com.l2jserver.model.world.character.CharacterClass;
|
||||
import com.l2jserver.util.Coordinate;
|
||||
import com.l2jserver.util.dimensional.Point;
|
||||
|
||||
/**
|
||||
* Template for {@link L2Character}
|
||||
@@ -33,7 +33,7 @@ public abstract class CharacterTemplate extends AbstractTemplate<L2Character> {
|
||||
/**
|
||||
* The initial location for the character to be spawned
|
||||
*/
|
||||
protected final Coordinate spawnLocation;
|
||||
protected final Point spawnLocation;
|
||||
/**
|
||||
* The base attributes instance
|
||||
*/
|
||||
@@ -45,7 +45,7 @@ public abstract class CharacterTemplate extends AbstractTemplate<L2Character> {
|
||||
int physicalAttack, int magicalAttack, int physicalDefense,
|
||||
int magicalDefense, int attackSpeed, int castSpeed, int accuracy,
|
||||
int criticalChance, int evasionChance, int moveSpeed,
|
||||
int maxWeigth, boolean craft, Coordinate spawnLocation) {
|
||||
int maxWeigth, boolean craft, Point spawnLocation) {
|
||||
super(id);
|
||||
this.race = characterClass.race;
|
||||
this.characterClass = characterClass;
|
||||
@@ -64,7 +64,7 @@ public abstract class CharacterTemplate extends AbstractTemplate<L2Character> {
|
||||
|
||||
character.setRace(race);
|
||||
character.setCharacterClass(characterClass);
|
||||
character.setPosition(spawnLocation);
|
||||
character.setPoint(spawnLocation);
|
||||
|
||||
// character.getBaseAttributes().setIntelligence(intelligence);
|
||||
// character.getBaseAttributes().setStrength(strength);
|
||||
@@ -91,9 +91,9 @@ public abstract class CharacterTemplate extends AbstractTemplate<L2Character> {
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the spawnLocation
|
||||
* @return the initial spawn location
|
||||
*/
|
||||
public Coordinate getSpawnLocation() {
|
||||
public Point getSpawnLocation() {
|
||||
return spawnLocation;
|
||||
}
|
||||
|
||||
|
||||
@@ -8,7 +8,8 @@ import com.l2jserver.model.world.capability.Attacker;
|
||||
import com.l2jserver.model.world.capability.Castable;
|
||||
import com.l2jserver.model.world.capability.Equipable;
|
||||
import com.l2jserver.model.world.capability.Equiper;
|
||||
import com.l2jserver.util.Coordinate;
|
||||
import com.l2jserver.util.dimensional.Coordinate;
|
||||
import com.l2jserver.util.dimensional.Point;
|
||||
|
||||
/**
|
||||
* Abstract {@link Actor} class.
|
||||
@@ -83,9 +84,9 @@ public abstract class AbstractActor extends AbstractObject implements Actor {
|
||||
*/
|
||||
protected int hp;
|
||||
/**
|
||||
* The actor coordinate
|
||||
* The actor coordinate point
|
||||
*/
|
||||
protected Coordinate position;
|
||||
protected Point point;
|
||||
/**
|
||||
* The currently effects active on the actor
|
||||
*/
|
||||
@@ -138,14 +139,29 @@ public abstract class AbstractActor extends AbstractObject implements Actor {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the coordinate point
|
||||
*/
|
||||
public Point getPoint() {
|
||||
return point;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param point
|
||||
* the coordinate point to set
|
||||
*/
|
||||
public void setPoint(Point point) {
|
||||
this.point = point;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Coordinate getPosition() {
|
||||
return position;
|
||||
return point.getCoordinate();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPosition(Coordinate coord) {
|
||||
this.position = coord;
|
||||
this.point = new Point(coord, (point != null ? point.getAngle() : 0));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -10,7 +10,7 @@ import com.l2jserver.model.world.character.CharacterInventory.InventoryLocation;
|
||||
import com.l2jserver.model.world.character.CharacterInventory.InventoryPaperdoll;
|
||||
import com.l2jserver.model.world.item.ItemEvent;
|
||||
import com.l2jserver.model.world.item.ItemListener;
|
||||
import com.l2jserver.util.Coordinate;
|
||||
import com.l2jserver.util.dimensional.Coordinate;
|
||||
|
||||
/**
|
||||
* This class represents an {@link Item} in the Lineage II World. The item can
|
||||
|
||||
@@ -3,7 +3,7 @@ package com.l2jserver.model.world;
|
||||
import com.l2jserver.model.id.object.CharacterID;
|
||||
import com.l2jserver.model.id.object.ItemID;
|
||||
import com.l2jserver.model.world.capability.Summonable;
|
||||
import com.l2jserver.util.Coordinate;
|
||||
import com.l2jserver.util.dimensional.Coordinate;
|
||||
|
||||
/**
|
||||
* This class represents an Pet in the Lineage II World
|
||||
|
||||
@@ -3,7 +3,7 @@ package com.l2jserver.model.world;
|
||||
import com.l2jserver.model.world.capability.Actor;
|
||||
import com.l2jserver.model.world.capability.Playable;
|
||||
import com.l2jserver.model.world.capability.Teleportable;
|
||||
import com.l2jserver.util.Coordinate;
|
||||
import com.l2jserver.util.dimensional.Coordinate;
|
||||
|
||||
/**
|
||||
* {@link Player} is any object that can be controlled by the player. The most
|
||||
|
||||
@@ -12,7 +12,7 @@ import com.l2jserver.model.world.actor.ActorListener;
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
*/
|
||||
public interface Actor extends Listenable<ActorListener, ActorEvent>,
|
||||
Spawnable, Positionable, Damagable, Attackable, Attacker, Castable,
|
||||
Spawnable, Pointable, Damagable, Attackable, Attacker, Castable,
|
||||
Caster, Levelable, Killable, Equiper, Equipable {
|
||||
ActorEffects getEffects();
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package com.l2jserver.model.world.capability;
|
||||
|
||||
import com.l2jserver.model.world.AbstractObject;
|
||||
import com.l2jserver.util.Coordinate;
|
||||
import com.l2jserver.util.dimensional.Coordinate;
|
||||
|
||||
/**
|
||||
* Defines an {@link AbstractObject} that can be dropped on the ground.
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
package com.l2jserver.model.world.capability;
|
||||
|
||||
import com.l2jserver.model.world.AbstractObject;
|
||||
import com.l2jserver.util.dimensional.Point;
|
||||
|
||||
/**
|
||||
* Defines an {@link AbstractObject} that can be positioned and pointed in the
|
||||
* world.
|
||||
*
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
*/
|
||||
public interface Pointable extends Positionable {
|
||||
Point getPoint();
|
||||
|
||||
void setPoint(Point point);
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
package com.l2jserver.model.world.capability;
|
||||
|
||||
import com.l2jserver.model.world.AbstractObject;
|
||||
import com.l2jserver.util.Coordinate;
|
||||
import com.l2jserver.util.dimensional.Coordinate;
|
||||
|
||||
/**
|
||||
* Defines an {@link AbstractObject} that can be positioned in the world.
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package com.l2jserver.model.world.capability;
|
||||
|
||||
import com.l2jserver.model.world.AbstractObject;
|
||||
import com.l2jserver.util.Coordinate;
|
||||
import com.l2jserver.util.dimensional.Coordinate;
|
||||
|
||||
/**
|
||||
* Represents an {@link AbstractObject} that can be spawned.
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package com.l2jserver.model.world.capability;
|
||||
|
||||
import com.l2jserver.model.world.AbstractObject;
|
||||
import com.l2jserver.util.Coordinate;
|
||||
import com.l2jserver.util.dimensional.Coordinate;
|
||||
|
||||
/**
|
||||
* Represents an {@link AbstractObject} that can be summoned.
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package com.l2jserver.model.world.capability;
|
||||
|
||||
import com.l2jserver.model.world.AbstractObject;
|
||||
import com.l2jserver.util.Coordinate;
|
||||
import com.l2jserver.util.dimensional.Coordinate;
|
||||
|
||||
/**
|
||||
* Defines an {@link AbstractObject} that can be teleported by
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package com.l2jserver.model.world.capability;
|
||||
|
||||
import com.l2jserver.model.world.AbstractObject;
|
||||
import com.l2jserver.util.Coordinate;
|
||||
import com.l2jserver.util.dimensional.Coordinate;
|
||||
|
||||
/**
|
||||
* Defines an {@link AbstractObject} that can teleport {@link Teleportable}
|
||||
|
||||
@@ -285,7 +285,7 @@ public enum CharacterClass {
|
||||
* the class id
|
||||
* @return the {@link CharacterClass} instance found
|
||||
*/
|
||||
public CharacterClass fromID(int id) {
|
||||
public static CharacterClass fromID(int id) {
|
||||
for (final CharacterClass c : values()) {
|
||||
if (c.id == id)
|
||||
return c;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package com.l2jserver.model.world.event;
|
||||
|
||||
import com.l2jserver.model.world.capability.Spawnable;
|
||||
import com.l2jserver.util.Coordinate;
|
||||
import com.l2jserver.util.dimensional.Coordinate;
|
||||
|
||||
/**
|
||||
* Event for objects spawning
|
||||
|
||||
@@ -2,7 +2,7 @@ package com.l2jserver.model.world.filter.impl;
|
||||
|
||||
import com.l2jserver.model.world.capability.Positionable;
|
||||
import com.l2jserver.model.world.filter.WorldObjectFilter;
|
||||
import com.l2jserver.util.Coordinate;
|
||||
import com.l2jserver.util.dimensional.Coordinate;
|
||||
|
||||
/**
|
||||
* Filter objects that are in the <tt>range</tt> of <tt>coordinate</tt>
|
||||
|
||||
@@ -5,7 +5,7 @@ import com.l2jserver.model.world.capability.Actor;
|
||||
import com.l2jserver.model.world.capability.Listenable;
|
||||
import com.l2jserver.model.world.capability.Spawnable;
|
||||
import com.l2jserver.model.world.event.SpawnEvent;
|
||||
import com.l2jserver.util.Coordinate;
|
||||
import com.l2jserver.util.dimensional.Coordinate;
|
||||
|
||||
/**
|
||||
* Event dispatcher once an player has spawned in the world
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package com.l2jserver.model.world.player;
|
||||
|
||||
import com.l2jserver.model.world.Player;
|
||||
import com.l2jserver.util.Coordinate;
|
||||
import com.l2jserver.util.dimensional.Coordinate;
|
||||
|
||||
/**
|
||||
* Event dispatched once an player is teleported.
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
package com.l2jserver.util;
|
||||
package com.l2jserver.util.dimensional;
|
||||
|
||||
import org.apache.commons.math.geometry.Vector3D;
|
||||
|
||||
/**
|
||||
* Represents an coordinate in the game world.
|
||||
@@ -8,18 +10,12 @@ package com.l2jserver.util;
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
*/
|
||||
public class Coordinate {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* The X point
|
||||
* The backing vector of this Coordinate
|
||||
*/
|
||||
private final int x;
|
||||
/**
|
||||
* The Y point
|
||||
*/
|
||||
private final int y;
|
||||
/**
|
||||
* The Z point
|
||||
*/
|
||||
private final int z;
|
||||
protected final Vector3D vector;
|
||||
|
||||
/**
|
||||
* Creates a new coordinate
|
||||
@@ -32,30 +28,19 @@ public class Coordinate {
|
||||
* the z point
|
||||
*/
|
||||
protected Coordinate(int x, int y, int z) {
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.z = z;
|
||||
this.vector = new Vector3D(x, y, z);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the x point
|
||||
*/
|
||||
public int getX() {
|
||||
return x;
|
||||
return (int) vector.getX();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the y point
|
||||
*/
|
||||
public int getY() {
|
||||
return y;
|
||||
return (int) vector.getY();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the z point
|
||||
*/
|
||||
public int getZ() {
|
||||
return z;
|
||||
return (int) vector.getZ();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -63,12 +48,11 @@ public class Coordinate {
|
||||
* <tt>other</tt>
|
||||
*
|
||||
* @param other
|
||||
* the other coodinate
|
||||
* @return the computed distance
|
||||
* the other coordinate
|
||||
* @return the calculated distance
|
||||
*/
|
||||
public int getDistance(Coordinate other) {
|
||||
// TODO calculation
|
||||
return x + y + z;
|
||||
public double getDistance(Coordinate other) {
|
||||
return Vector3D.distance(vector, other.vector);
|
||||
}
|
||||
|
||||
/**
|
||||
142
src/main/java/com/l2jserver/util/dimensional/Point.java
Normal file
142
src/main/java/com/l2jserver/util/dimensional/Point.java
Normal file
@@ -0,0 +1,142 @@
|
||||
package com.l2jserver.util.dimensional;
|
||||
|
||||
import org.apache.commons.math.geometry.Rotation;
|
||||
|
||||
/**
|
||||
* An point is composed of an Coordinate and an angle. The angle represents the
|
||||
* facing angle of the point, that is, the direction the point is "looking".
|
||||
*
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
*/
|
||||
public class Point {
|
||||
/**
|
||||
* The point coordinate
|
||||
*/
|
||||
protected final Coordinate coordinate;
|
||||
/**
|
||||
* Te point rotation
|
||||
*/
|
||||
protected final Rotation rotation;
|
||||
|
||||
/**
|
||||
* Creates a new point
|
||||
*
|
||||
* @param coordinate
|
||||
* the coordinate
|
||||
* @param angle
|
||||
* the angle
|
||||
*/
|
||||
public Point(Coordinate coordinate, double angle) {
|
||||
this.coordinate = coordinate;
|
||||
this.rotation = new Rotation(coordinate.vector, angle);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the x
|
||||
* @see com.l2jserver.util.dimensional.Coordinate#getX()
|
||||
*/
|
||||
public int getX() {
|
||||
return coordinate.getX();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the y
|
||||
* @see com.l2jserver.util.dimensional.Coordinate#getY()
|
||||
*/
|
||||
public int getY() {
|
||||
return coordinate.getY();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the z
|
||||
* @see com.l2jserver.util.dimensional.Coordinate#getZ()
|
||||
*/
|
||||
public int getZ() {
|
||||
return coordinate.getZ();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param other
|
||||
* the other coordinate
|
||||
* @return the distance
|
||||
* @see com.l2jserver.util.dimensional.Coordinate#getDistance(com.l2jserver.util.dimensional.Coordinate)
|
||||
*/
|
||||
public double getDistance(Coordinate other) {
|
||||
return coordinate.getDistance(other);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param other
|
||||
* the other point
|
||||
* @return the distance
|
||||
* @see com.l2jserver.util.dimensional.Coordinate#getDistance(com.l2jserver.util.dimensional.Coordinate)
|
||||
*/
|
||||
public double getDistance(Point other) {
|
||||
return coordinate.getDistance(other.coordinate);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the angle
|
||||
* @see org.apache.commons.math.geometry.Rotation#getAngle()
|
||||
*/
|
||||
public double getAngle() {
|
||||
return rotation.getAngle();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param other
|
||||
* the other point
|
||||
* @return the angle difference between the two points
|
||||
* @see org.apache.commons.math.geometry.Rotation#distance(Rotation,
|
||||
* Rotation)
|
||||
*/
|
||||
public double getAngleDifference(Point other) {
|
||||
return Rotation.distance(this.rotation, other.rotation);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the coordinate
|
||||
*/
|
||||
public Coordinate getCoordinate() {
|
||||
return coordinate;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the rotation
|
||||
*/
|
||||
public Rotation getRotation() {
|
||||
return rotation;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new instance from the 3 points and an angle
|
||||
*
|
||||
* @param x
|
||||
* the x point
|
||||
* @param y
|
||||
* the y point
|
||||
* @param z
|
||||
* the z point
|
||||
* @param angle
|
||||
* the angle
|
||||
* @return the new {@link Point} object created
|
||||
*/
|
||||
public static Point fromXYZA(int x, int y, int z, double angle) {
|
||||
return new Point(Coordinate.fromXYZ(x, y, z), angle);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new instance from the 3 points. The angle will be zero.
|
||||
*
|
||||
* @param x
|
||||
* the x point
|
||||
* @param y
|
||||
* the y point
|
||||
* @param z
|
||||
* the z point
|
||||
* @return the new {@link Point} object created
|
||||
*/
|
||||
public static Point fromXYZ(int x, int y, int z) {
|
||||
return fromXYZA(x, y, z, 0);
|
||||
}
|
||||
}
|
||||
@@ -8,9 +8,10 @@ CREATE TABLE `character` (
|
||||
`level` int(3) NOT NULL,
|
||||
`experience` int(15) NOT NULL,
|
||||
`sp` int(15) NOT NULL,
|
||||
`position_x` int(10) NOT NULL,
|
||||
`position_y` int(10) NOT NULL,
|
||||
`position_z` int(10) NOT NULL,
|
||||
`point_x` int(10) NOT NULL,
|
||||
`point_y` int(10) NOT NULL,
|
||||
`point_z` int(10) NOT NULL,
|
||||
`point_angle` DOUBLE NOT NULL,
|
||||
`appearance_hair_style` enum('STYLE_A','STYLE_B','STYLE_C','STYLE_D','STYLE_E') NOT NULL DEFAULT 'STYLE_A',
|
||||
`appearance_hair_color` enum('COLOR_A','COLOR_B','COLOR_C','COLOR_D') NOT NULL DEFAULT 'COLOR_A',
|
||||
`apperance_face` enum('FACE_A','FACE_B','FACE_C') NOT NULL DEFAULT 'FACE_A',
|
||||
|
||||
Reference in New Issue
Block a user