1
0
mirror of https://github.com/Rogiel/l2jserver2 synced 2025-12-11 09:42:54 +00:00

Several improvements

Signed-off-by: Rogiel <rogiel@rogiel.com>
This commit is contained in:
2011-05-19 01:40:53 -03:00
parent 9bb83652e4
commit 2c4af6d91d
263 changed files with 2135 additions and 663 deletions

View File

@@ -19,11 +19,13 @@ package com.l2jserver.model.world;
import java.sql.Date;
import com.l2jserver.model.id.AccountID;
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.template.CharacterTemplate;
import com.l2jserver.model.world.actor.ActorAttributes;
import com.l2jserver.model.world.capability.Actor;
import com.l2jserver.model.world.character.CharacterAppearance;
import com.l2jserver.model.world.character.CharacterCalculatedAttributes;
import com.l2jserver.model.world.character.CharacterClass;
@@ -92,12 +94,21 @@ public class L2Character extends Player {
* Date of character's last access
*/
private Date lastAccess;
// ////////////////////////////////////
// / RUNTIME
// ////////////////////////////////////
/**
* The character walk mode.
* <p>
* This field is not persisted.
*/
private CharacterMoveType moveType = CharacterMoveType.WALK;
/**
* The character target, if any.
*/
private ActorID<?> targetID;
/**
* The character walking mode
@@ -263,6 +274,30 @@ public class L2Character extends Player {
this.moveType = moveType;
}
/**
* @return the target ID
*/
public ActorID<?> getTargetID() {
return targetID;
}
/**
* @return the target
*/
public Actor getTarget() {
if (targetID == null)
return null;
return targetID.getObject();
}
/**
* @param target
* the target ID to set
*/
public void setTargetID(ActorID<?> target) {
this.targetID = target;
}
/**
* @return the inventory
*/

View File

@@ -16,10 +16,53 @@
*/
package com.l2jserver.model.world;
import com.l2jserver.game.net.packet.client.CharacterActionPacket.CharacterAction;
import com.l2jserver.model.id.object.NPCID;
import com.l2jserver.model.id.template.NPCTemplateID;
import com.l2jserver.model.template.NPCTemplate;
/**
* @author <a href="http://www.rogiel.com">Rogiel</a>
*
*/
public class NPC extends AbstractActor {
/**
* The NPC template ID
*/
private final NPCTemplateID templateID;
public NPC(NPCTemplateID templateID) {
this.templateID = templateID;
}
/**
* Executes an action on this NPC
*
* @param character
* the interacting character
* @param action
* the action
*/
public void action(L2Character character, CharacterAction action) {
getTemplate().action(this, character, action);
}
/**
* @return the NPC template ID
*/
public NPCTemplateID getTemplateID() {
return templateID;
}
/**
* @return the NPC template
*/
public NPCTemplate getTemplate() {
return templateID.getTemplate();
}
@Override
public NPCID getID() {
return (NPCID) super.getID();
}
}

View File

@@ -0,0 +1,84 @@
/*
* 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.world.character.event;
import com.l2jserver.model.world.L2Character;
import com.l2jserver.model.world.Player;
import com.l2jserver.model.world.WorldObject;
import com.l2jserver.model.world.capability.Actor;
import com.l2jserver.model.world.capability.Listenable;
/**
* Event triggered once a character moves
*
* @author <a href="http://www.rogiel.com">Rogiel</a>
*/
public class CharacterTargetDeselectedEvent implements CharacterEvent {
/**
* The character that is logging in
*/
private final L2Character character;
/**
* The object target
*/
private final Actor oldTarget;
/**
* Creates a new instance
*
* @param character
* the character
* @param target
* the character target
*/
public CharacterTargetDeselectedEvent(L2Character character, Actor oldTarget) {
this.character = character;
this.oldTarget = oldTarget;
}
/**
* @return the old target
*/
public Actor getOldTarget() {
return oldTarget;
}
@Override
public Player getPlayer() {
return character;
}
@Override
public Actor getActor() {
return character;
}
@Override
public WorldObject getObject() {
return character;
}
@Override
public L2Character getCharacter() {
return character;
}
@Override
public Listenable<?, ?>[] getDispatchableObjects() {
return new Listenable<?, ?>[] { character };
}
}

View File

@@ -0,0 +1,85 @@
/*
* 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.world.character.event;
import com.l2jserver.model.world.L2Character;
import com.l2jserver.model.world.Player;
import com.l2jserver.model.world.WorldObject;
import com.l2jserver.model.world.capability.Actor;
import com.l2jserver.model.world.capability.Listenable;
/**
* Event triggered once a character moves
*
* @author <a href="http://www.rogiel.com">Rogiel</a>
*/
public class CharacterTargetSelectedEvent implements CharacterEvent {
/**
* The character that is logging in
*/
private final L2Character character;
/**
* The object target
*/
private final Actor target;
/**
* Creates a new instance
*
* @param character
* the character
* @param target
* the character target
*/
public CharacterTargetSelectedEvent(L2Character character,
Actor target) {
this.character = character;
this.target = target;
}
/**
* @return the target
*/
public Actor getTarget() {
return target;
}
@Override
public Player getPlayer() {
return character;
}
@Override
public Actor getActor() {
return character;
}
@Override
public WorldObject getObject() {
return character;
}
@Override
public L2Character getCharacter() {
return character;
}
@Override
public Listenable<?, ?>[] getDispatchableObjects() {
return new Listenable<?, ?>[] { character };
}
}