1
0
mirror of https://github.com/Rogiel/l2jserver2 synced 2025-12-09 08:52:51 +00:00

Character broadcast working

Signed-off-by: Rogiel <rogiel@rogiel.com>
This commit is contained in:
2011-05-22 21:32:55 -03:00
parent 49a8513ec5
commit 98feb1ecce
148 changed files with 2309 additions and 597 deletions

View File

@@ -24,11 +24,16 @@ import com.l2jserver.model.id.ID;
*
* @author <a href="http://www.rogiel.com">Rogiel</a>
*/
public class AbstractModel<T extends ID<?>> implements Model<T> {
public abstract class AbstractModel<T extends ID<?>> implements Model<T> {
/**
* The object id
*/
protected T id;
/**
* The database state. True inidicates that the object is on database, false
* indicates it must be inserted.
*/
protected boolean inDatabase;
@Override
public T getID() {
@@ -65,4 +70,14 @@ public class AbstractModel<T extends ID<?>> implements Model<T> {
return false;
return true;
}
@Override
public boolean isInDatabase() {
return inDatabase;
}
@Override
public void setIsInDatabase(boolean state) {
inDatabase = state;
}
}

View File

@@ -33,4 +33,15 @@ public interface Model<T extends ID<?>> {
* the object ID to set
*/
void setID(T ID);
/**
* @return true if object is already inserted in the database
*/
boolean isInDatabase();
/**
* @param state
* the database state
*/
void setIsInDatabase(boolean state);
}

View File

@@ -1,74 +0,0 @@
/*
* 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.game;
import com.l2jserver.model.id.template.NPCTemplateID;
import com.l2jserver.model.template.NPCTemplate;
import com.l2jserver.util.dimensional.Point;
/**
* This class represents an spawn instance of a NPC or Monster
*
* @author <a href="http://www.rogiel.com">Rogiel</a>
*/
public class Spawn {
/**
* The NPC template id
*/
private NPCTemplateID npcTemplateID;
/**
* The NPC spawn point
*/
private Point point;
/**
* @return the npcTemplate ID
*/
public NPCTemplateID getNPCTemplateID() {
return npcTemplateID;
}
/**
* @return the npcTemplate
*/
public NPCTemplate getNPCTemplate() {
return npcTemplateID.getTemplate();
}
/**
* @param npcTemplateID
* the npcTemplate ID to set
*/
public void setNPCTemplateID(NPCTemplateID npcTemplateID) {
this.npcTemplateID = npcTemplateID;
}
/**
* @return the point
*/
public Point getPoint() {
return point;
}
/**
* @param point
* the point to set
*/
public void setPoint(Point point) {
this.point = point;
}
}

View File

@@ -41,6 +41,18 @@ public abstract class ActorTemplate<T extends Actor> extends
* The actor race
*/
protected final Race race;
/**
* The movement speed multiplier
*/
protected double movementSpeedMultiplier = 1.0;
/**
* The attack speed multiplier
*/
protected double attackSpeedMultiplier = 1.0;
protected int maxHp;
/**
* The base attributes instance
*/
@@ -219,6 +231,27 @@ public abstract class ActorTemplate<T extends Actor> extends
return attributes.canCraft();
}
/**
* @return the movementSpeedMultiplier
*/
public double getMovementSpeedMultiplier() {
return movementSpeedMultiplier;
}
/**
* @return the attackSpeedMultiplier
*/
public double getAttackSpeedMultiplier() {
return attackSpeedMultiplier;
}
/**
* @return the max hp
*/
public int getMaxHP() {
return maxHp;
}
/**
* Defines the attributes of an character
*

View File

@@ -43,6 +43,23 @@ public abstract class CharacterTemplate extends ActorTemplate<L2Character> {
FIST;
}
/**
* The collision radius for male instances
*/
protected double maleCollisionRadius = 0;
/**
* The collision height for male instances
*/
protected double maleCollisionHeight = 0;
/**
* The collision radius for female instances
*/
protected double femaleCollisionRadius = 0;
/**
* The collision height for female instances
*/
protected double femaleCollisionHeight = 0;
protected CharacterTemplate(CharacterTemplateID id,
CharacterClass characterClass, Point spawnLocation) {
super(id, characterClass.race);
@@ -52,7 +69,7 @@ public abstract class CharacterTemplate extends ActorTemplate<L2Character> {
@Override
public L2Character createInstance() {
final L2Character character = new L2Character(attributes);
final L2Character character = new L2Character(this.getID(), attributes);
character.setRace(race);
character.setCharacterClass(characterClass);
@@ -74,6 +91,34 @@ public abstract class CharacterTemplate extends ActorTemplate<L2Character> {
public Point getSpawnLocation() {
return spawnLocation;
}
/**
* @return the male collision radius
*/
public double getMaleCollisionRadius() {
return maleCollisionRadius;
}
/**
* @return the male collision height
*/
public double getMaleCollisionHeight() {
return maleCollisionHeight;
}
/**
* @return the female collision radius
*/
public double getFemaleCollisionRadius() {
return femaleCollisionRadius;
}
/**
* @return the female collision height
*/
public double getFemaleCollisionHeight() {
return femaleCollisionHeight;
}
@Override
public CharacterTemplateID getID() {

View File

@@ -71,15 +71,6 @@ public abstract class NPCTemplate extends ActorTemplate<NPC> implements
*/
protected boolean attackable = false;
/**
* The movement speed multiplier
*/
protected double movementSpeedMultiplier = 1.0;
/**
* The attack speed multiplier
*/
protected double attackSpeedMultiplier = 1.0;
/**
* The collision radius
*/
@@ -89,8 +80,6 @@ public abstract class NPCTemplate extends ActorTemplate<NPC> implements
*/
protected double collisionHeight = 0;
protected int maxHp;
protected NPCTemplate(NPCTemplateID id) {
super(id, null);
}
@@ -132,8 +121,8 @@ public abstract class NPCTemplate extends ActorTemplate<NPC> implements
* the action arguments
* @throws L2Exception
*/
protected void talk(NPC npc, L2Character character, Lineage2Connection conn,
String... args) throws L2Exception {
protected void talk(NPC npc, L2Character character,
Lineage2Connection conn, String... args) throws L2Exception {
if (args.length == 0 || (args.length >= 1 && args[0].equals("Chat"))) {
String name = "";
if (args.length == 2)
@@ -192,40 +181,19 @@ public abstract class NPCTemplate extends ActorTemplate<NPC> implements
}
/**
* @return the movementSpeedMultiplier
*/
public double getMovementSpeedMultiplier() {
return movementSpeedMultiplier;
}
/**
* @return the attackSpeedMultiplier
*/
public double getAttackSpeedMultiplier() {
return attackSpeedMultiplier;
}
/**
* @return the collisionRadius
* @return the collision radius
*/
public double getCollisionRadius() {
return collisionRadius;
}
/**
* @return the collisionHeight
* @return the collision height
*/
public double getCollisionHeight() {
return collisionHeight;
}
/**
* @return the maxHp
*/
public int getMaxHP() {
return maxHp;
}
/**
* @return the race
*/

View File

@@ -77,6 +77,15 @@ public class TeleporterNPCTemplate extends NPCTemplate {
public static final Coordinate CAVE_OF_TRIALS = Coordinate.fromXYZ(9340,
-112509, -2536);
public static final Coordinate DARK_FOREST = Coordinate.fromXYZ(-22224,
14168, -3232);
public static final Coordinate SPIDER_NEST = Coordinate.fromXYZ(-61095,
75104, -3352);
public static final Coordinate SWAMPLAND = Coordinate.fromXYZ(-21966,
40544, -3192);
public static final Coordinate NEUTRAL_ZONE = Coordinate.fromXYZ(-10612,
75881, -3592);
@Inject
protected SpawnService spawnService;

View File

@@ -17,9 +17,10 @@
package com.l2jserver.model.world;
import com.l2jserver.model.id.object.ActorID;
import com.l2jserver.model.id.template.ActorTemplateID;
import com.l2jserver.model.template.ActorTemplate;
import com.l2jserver.model.world.actor.ActorEffects;
import com.l2jserver.model.world.actor.ActorSkillContainer;
import com.l2jserver.util.dimensional.Coordinate;
import com.l2jserver.util.dimensional.Point;
/**
@@ -28,6 +29,8 @@ import com.l2jserver.util.dimensional.Point;
* @author <a href="http://www.rogiel.com">Rogiel</a>
*/
public abstract class Actor extends PositionableObject {
protected ActorTemplateID<?> templateID;
/**
* The actor race
*/
@@ -117,6 +120,10 @@ public abstract class Actor extends PositionableObject {
*/
protected final ActorSkillContainer skills = new ActorSkillContainer(this);
public Actor(ActorTemplateID<?> templateID) {
this.templateID = templateID;
}
public int getHP() {
return hp;
}
@@ -174,6 +181,20 @@ public abstract class Actor extends PositionableObject {
return skills;
}
/**
* @return the templateID
*/
public ActorTemplateID<?> getTemplateID() {
return templateID;
}
/**
* @return the template
*/
public ActorTemplate<?> getTemplate() {
return templateID.getTemplate();
}
@Override
public ActorID<?> getID() {
return (ActorID<?>) super.getID();

View File

@@ -21,8 +21,6 @@ import com.l2jserver.model.id.template.ItemTemplateID;
import com.l2jserver.model.template.ItemTemplate;
import com.l2jserver.model.world.character.CharacterInventory.InventoryLocation;
import com.l2jserver.model.world.character.CharacterInventory.InventoryPaperdoll;
import com.l2jserver.util.dimensional.Coordinate;
import com.l2jserver.util.dimensional.Point;
/**
* This class represents an {@link Item} in the Lineage II World. The item can
@@ -37,10 +35,13 @@ import com.l2jserver.util.dimensional.Point;
* <li><b>Equipped by the {@link L2Character character}</b>: <tt>location</tt>
* is {@link InventoryLocation#PAPERDOLL}, <tt>paperdoll</tt> is not null and
* <tt>coordinate</tt> is null.</li>
* <li><b>Dropped on the ground</b>: <tt>location</li> and <tt>paperdoll</tt>
* <li><b>Dropped on the ground</b>: <tt>location</tt></li> and <tt>paperdoll</tt>
* are null, <tt>coordinate</tt> is not null and represents the dropping
* location.
* </ul>
* <p>
* Please note that {@link PositionableObject} values are only set if the object
* is dropped on the ground.
*
* @author <a href="http://www.rogiel.com">Rogiel</a>
*/
@@ -62,10 +63,6 @@ public class Item extends PositionableObject {
* Paperdoll slot for this item
*/
private InventoryPaperdoll paperdoll;
/**
* Drop coordinate of this item
*/
private Coordinate coordinate;
/**
* Count of items
@@ -144,12 +141,4 @@ public class Item extends PositionableObject {
public void setOwnerID(CharacterID ownerID) {
this.ownerID = ownerID;
}
public Point getPoint() {
return null;
}
public void setPoint(Point point) {
}
}

View File

@@ -23,6 +23,7 @@ import com.l2jserver.model.id.object.ActorID;
import com.l2jserver.model.id.object.CharacterID;
import com.l2jserver.model.id.object.ClanID;
import com.l2jserver.model.id.object.PetID;
import com.l2jserver.model.id.template.CharacterTemplateID;
import com.l2jserver.model.template.CharacterTemplate;
import com.l2jserver.model.world.actor.ActorAttributes;
import com.l2jserver.model.world.character.CharacterAppearance;
@@ -138,7 +139,9 @@ public class L2Character extends Player {
* @param baseAttributes
* the base attribute for this character
*/
public L2Character(CharacterTemplate.ActorBaseAttributes baseAttributes) {
public L2Character(CharacterTemplateID templateID,
CharacterTemplate.ActorBaseAttributes baseAttributes) {
super(templateID);
this.baseAttributes = baseAttributes;
this.attributes = new CharacterCalculatedAttributes(this);
}
@@ -369,6 +372,16 @@ public class L2Character extends Player {
return shortcuts;
}
@Override
public CharacterTemplateID getTemplateID() {
return (CharacterTemplateID) super.getTemplateID();
}
@Override
public CharacterTemplate getTemplate() {
return (CharacterTemplate) super.getTemplate();
}
@Override
public CharacterID getID() {
return (CharacterID) super.getID();

View File

@@ -30,11 +30,6 @@ import com.l2jserver.service.game.ai.AIScript;
* @author <a href="http://www.rogiel.com">Rogiel</a>
*/
public class NPC extends Actor {
/**
* The NPC template ID
*/
private final NPCTemplateID templateID;
/**
* Creates a new instance
*
@@ -42,21 +37,21 @@ public class NPC extends Actor {
* the {@link NPC} {@link TemplateID}
*/
public NPC(NPCTemplateID templateID) {
this.templateID = templateID;
super(templateID);
}
/**
* @return the NPC template ID
*/
public NPCTemplateID getTemplateID() {
return templateID;
return (NPCTemplateID) templateID;
}
/**
* @return the NPC template
*/
public NPCTemplate getTemplate() {
return templateID.getTemplate();
return (NPCTemplate) templateID.getTemplate();
}
@Override

View File

@@ -18,6 +18,7 @@ package com.l2jserver.model.world;
import com.l2jserver.model.id.object.CharacterID;
import com.l2jserver.model.id.object.ItemID;
import com.l2jserver.model.id.template.ActorTemplateID;
/**
* This class represents an Pet in the Lineage II World
@@ -34,6 +35,10 @@ public class Pet extends Player {
*/
private ItemID itemID;
public Pet(ActorTemplateID<?> templateID) {
super(templateID);
}
/**
* @return the owner ID
*/

View File

@@ -16,6 +16,8 @@
*/
package com.l2jserver.model.world;
import com.l2jserver.model.id.template.ActorTemplateID;
/**
* {@link Player} is any object that can be controlled by the player. The most
* common implementation is {@link L2Character}.
@@ -23,5 +25,7 @@ package com.l2jserver.model.world;
* @author Rogiel
*/
public abstract class Player extends Actor {
public Player(ActorTemplateID<?> templateID) {
super(templateID);
}
}

View File

@@ -20,10 +20,15 @@ import com.l2jserver.util.dimensional.Coordinate;
import com.l2jserver.util.dimensional.Point;
/**
* @author <a href="http://www.rogiel.com">Rogiel</a>
* This is an abstract object that objects that can be placed in world should
* extend.
*
* @author <a href="http://www.rogiel.com">Rogiel</a>
*/
public abstract class PositionableObject extends AbstractObject {
/**
* The point this object is currently in
*/
private Point point;
/**

View File

@@ -34,7 +34,7 @@ public class CharacterMoveEvent implements CharacterEvent {
*/
private final L2Character character;
/**
* The new point of the character
* The old point of the character
*/
private final Point point;
@@ -44,7 +44,7 @@ public class CharacterMoveEvent implements CharacterEvent {
* @param character
* the character
* @param point
* the character point
* the character point before moving
*/
public CharacterMoveEvent(L2Character character, Point point) {
this.character = character;
@@ -52,7 +52,7 @@ public class CharacterMoveEvent implements CharacterEvent {
}
/**
* @return the new point
* @return the old point
*/
public Point getPoint() {
return point;