mirror of
https://github.com/Rogiel/l2jserver2
synced 2025-12-08 08:23:11 +00:00
Monster can now be killed. Their corpses disappear after 5 seconds and
respawn in the specified time. Signed-off-by: Rogiel <rogiel@rogiel.com>
This commit is contained in:
@@ -121,6 +121,39 @@ public abstract class Actor extends PositionableObject {
|
||||
*/
|
||||
protected int sp;
|
||||
|
||||
/**
|
||||
* State of the actor. Will be null if it is idle
|
||||
*/
|
||||
private transient ActorState state;
|
||||
|
||||
/**
|
||||
* The valid states for an actor
|
||||
*
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
*/
|
||||
public enum ActorState {
|
||||
/**
|
||||
* This state indicates the actor is being teleported
|
||||
*/
|
||||
TELEPORTING,
|
||||
/**
|
||||
* This state indicates the actor is casting a skill
|
||||
*/
|
||||
CASTING,
|
||||
/**
|
||||
* This state indicates the actor is attacking
|
||||
*/
|
||||
ATTACKING,
|
||||
/**
|
||||
* This state indicates the actor is moving
|
||||
*/
|
||||
MOVING,
|
||||
/**
|
||||
* This state indicates the actor is dead
|
||||
*/
|
||||
DEAD;
|
||||
}
|
||||
|
||||
/**
|
||||
* The currently effects active on the actor
|
||||
*/
|
||||
@@ -133,7 +166,7 @@ public abstract class Actor extends PositionableObject {
|
||||
protected Actor(ActorTemplateID<?> templateID) {
|
||||
this.templateID = templateID;
|
||||
}
|
||||
|
||||
|
||||
public abstract ActorStats<?> getStats();
|
||||
|
||||
/**
|
||||
@@ -248,6 +281,63 @@ public abstract class Actor extends PositionableObject {
|
||||
this.sp = sp;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the state
|
||||
*/
|
||||
public ActorState getState() {
|
||||
return state;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param state
|
||||
* the state to set
|
||||
*/
|
||||
public void setState(ActorState state) {
|
||||
this.state = state;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return true if character is doing nothing
|
||||
*/
|
||||
public boolean isIdle() {
|
||||
return state == null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return true if character is being teleported
|
||||
*/
|
||||
public boolean isTeleporting() {
|
||||
return state == ActorState.TELEPORTING;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return true if character is moving
|
||||
*/
|
||||
public boolean isMoving() {
|
||||
return state == ActorState.MOVING;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return true if character is dead
|
||||
*/
|
||||
public boolean isDead() {
|
||||
return state == ActorState.DEAD;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return true if character is casting
|
||||
*/
|
||||
public boolean isCasting() {
|
||||
return state == ActorState.CASTING;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return true if character is attacking
|
||||
*/
|
||||
public boolean isAttacking() {
|
||||
return state == ActorState.ATTACKING;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the active effects on this actor
|
||||
*/
|
||||
|
||||
@@ -143,38 +143,6 @@ public class L2Character extends Player {
|
||||
* The character target, if any.
|
||||
*/
|
||||
private transient ActorID<?> targetID;
|
||||
/**
|
||||
* State of the character. Will be null if it is idle
|
||||
*/
|
||||
private transient CharacterState state;
|
||||
|
||||
/**
|
||||
* The valid states for an character
|
||||
*
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
*/
|
||||
public enum CharacterState {
|
||||
/**
|
||||
* This state indicates the character is being teleported
|
||||
*/
|
||||
TELEPORTING,
|
||||
/**
|
||||
* This state indicates the character is casting a skill
|
||||
*/
|
||||
CASTING,
|
||||
/**
|
||||
* This state indicates the character is attacking
|
||||
*/
|
||||
ATTACKING,
|
||||
/**
|
||||
* This state indicates the character is moving
|
||||
*/
|
||||
MOVING,
|
||||
/**
|
||||
* This state indicates the character is dead
|
||||
*/
|
||||
DEAD;
|
||||
}
|
||||
|
||||
/**
|
||||
* The point the player is moving, teleporting etc...
|
||||
@@ -447,63 +415,6 @@ public class L2Character extends Player {
|
||||
this.targetID = target;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the state
|
||||
*/
|
||||
public CharacterState getState() {
|
||||
return state;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param state
|
||||
* the state to set
|
||||
*/
|
||||
public void setState(CharacterState state) {
|
||||
this.state = state;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return true if character is doing nothing
|
||||
*/
|
||||
public boolean isIdle() {
|
||||
return state == null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return true if character is being teleported
|
||||
*/
|
||||
public boolean isTeleporting() {
|
||||
return state == CharacterState.TELEPORTING;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return true if character is moving
|
||||
*/
|
||||
public boolean isMoving() {
|
||||
return state == CharacterState.MOVING;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return true if character is dead
|
||||
*/
|
||||
public boolean isDead() {
|
||||
return state == CharacterState.DEAD;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return true if character is casting
|
||||
*/
|
||||
public boolean isCasting() {
|
||||
return state == CharacterState.CASTING;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return true if character is attacking
|
||||
*/
|
||||
public boolean isAttacking() {
|
||||
return state == CharacterState.ATTACKING;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return true if character is alive
|
||||
*/
|
||||
|
||||
@@ -30,20 +30,16 @@ import com.l2jserver.service.game.ai.AIScript;
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
*/
|
||||
public class NPC extends Actor {
|
||||
/**
|
||||
* The {@link NPC} respawn interval
|
||||
*/
|
||||
private long respawnInterval;
|
||||
|
||||
/**
|
||||
* This NPC stats
|
||||
*/
|
||||
private final NPCStats stats = new NPCStats(this);
|
||||
|
||||
/**
|
||||
* The npc state
|
||||
*/
|
||||
private NPCState state;
|
||||
|
||||
public enum NPCState {
|
||||
MOVING, ATTACKING;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new instance
|
||||
*
|
||||
@@ -54,47 +50,27 @@ public class NPC extends Actor {
|
||||
super(templateID);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the respawnInterval
|
||||
*/
|
||||
public long getRespawnInterval() {
|
||||
return respawnInterval;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param respawnInterval
|
||||
* the respawnInterval to set
|
||||
*/
|
||||
public void setRespawnInterval(long respawnInterval) {
|
||||
desireUpdate();
|
||||
this.respawnInterval = respawnInterval;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NPCStats getStats() {
|
||||
return stats;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the state
|
||||
*/
|
||||
public NPCState getState() {
|
||||
return state;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return true if NPC is idle
|
||||
*/
|
||||
public boolean isIdle() {
|
||||
return state == null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return true if NPC is idle
|
||||
*/
|
||||
public boolean isMoving() {
|
||||
return state == NPCState.MOVING;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return true if NPC is idle
|
||||
*/
|
||||
public boolean isAttacking() {
|
||||
return state == NPCState.ATTACKING;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param state
|
||||
* the state to set
|
||||
*/
|
||||
public void setState(NPCState state) {
|
||||
this.state = state;
|
||||
}
|
||||
|
||||
// TEMPLATE WRAPPERS
|
||||
@Override
|
||||
public ActorSex getSex() {
|
||||
|
||||
@@ -0,0 +1,72 @@
|
||||
/*
|
||||
* 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.actor.event;
|
||||
|
||||
import com.l2jserver.model.id.ObjectID;
|
||||
import com.l2jserver.model.world.Actor;
|
||||
import com.l2jserver.model.world.WorldObject;
|
||||
|
||||
/**
|
||||
* Event dispatcher once an actor has died.
|
||||
*
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
*/
|
||||
public class ActorDieEvent implements ActorEvent {
|
||||
/**
|
||||
* The actor that died
|
||||
*/
|
||||
private final Actor actor;
|
||||
/**
|
||||
* The actor who killed the <tt>actor</tt>
|
||||
*/
|
||||
private final Actor killer;
|
||||
|
||||
/**
|
||||
* Creates a new instance
|
||||
*
|
||||
* @param actor
|
||||
* the actor that died
|
||||
* @param killer
|
||||
* the actor who killed the <tt>actor</tt>
|
||||
*/
|
||||
public ActorDieEvent(Actor actor, Actor killer) {
|
||||
this.actor = actor;
|
||||
this.killer = killer;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the actor who killed the <tt>actor</tt>
|
||||
*/
|
||||
public Actor getKiller() {
|
||||
return killer;
|
||||
}
|
||||
|
||||
@Override
|
||||
public WorldObject getObject() {
|
||||
return actor;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Actor getActor() {
|
||||
return actor;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ObjectID<?>[] getDispatchableObjects() {
|
||||
return new ObjectID<?>[] { actor.getID() };
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,72 @@
|
||||
/*
|
||||
* 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.actor.event;
|
||||
|
||||
import com.l2jserver.model.id.ObjectID;
|
||||
import com.l2jserver.model.world.Actor;
|
||||
import com.l2jserver.model.world.WorldObject;
|
||||
import com.l2jserver.model.world.event.UnspawnEvent;
|
||||
import com.l2jserver.util.geometry.Point3D;
|
||||
|
||||
/**
|
||||
* Event dispatcher once an actor has unspawned in the world
|
||||
*
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
*/
|
||||
public class ActorUnspawnEvent implements ActorEvent, UnspawnEvent {
|
||||
/**
|
||||
* The unspawned actor
|
||||
*/
|
||||
private final Actor actor;
|
||||
/**
|
||||
* The unspawning point
|
||||
*/
|
||||
private final Point3D point;
|
||||
|
||||
/**
|
||||
* Creates a new instance
|
||||
*
|
||||
* @param actor
|
||||
* the spawned actor
|
||||
* @param point
|
||||
* the unspawn point
|
||||
*/
|
||||
public ActorUnspawnEvent(Actor actor, Point3D point) {
|
||||
this.actor = actor;
|
||||
this.point = point;
|
||||
}
|
||||
|
||||
@Override
|
||||
public WorldObject getObject() {
|
||||
return actor;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Actor getActor() {
|
||||
return actor;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Point3D getPoint() {
|
||||
return point;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ObjectID<?>[] getDispatchableObjects() {
|
||||
return new ObjectID<?>[] { actor.getID() };
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
/*
|
||||
* 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.event;
|
||||
|
||||
import com.l2jserver.service.game.world.event.WorldEvent;
|
||||
import com.l2jserver.util.geometry.Point3D;
|
||||
|
||||
/**
|
||||
* Event for objects unspawning
|
||||
*
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
*/
|
||||
public interface UnspawnEvent extends WorldEvent {
|
||||
/**
|
||||
* @return the point the object was at
|
||||
*/
|
||||
Point3D getPoint();
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
/*
|
||||
* 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.npc.event;
|
||||
|
||||
import com.l2jserver.model.world.Actor;
|
||||
import com.l2jserver.model.world.NPC;
|
||||
import com.l2jserver.model.world.actor.event.ActorDieEvent;
|
||||
|
||||
/**
|
||||
* Event dispatched once a {@link NPC} has died.
|
||||
*
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
*/
|
||||
public class NPCDieEvent extends ActorDieEvent implements NPCEvent {
|
||||
/**
|
||||
* @param npc
|
||||
* the died npc
|
||||
* @param the
|
||||
* actor who killed the <tt>npc</tt>
|
||||
*/
|
||||
public NPCDieEvent(NPC npc, Actor killer) {
|
||||
super(npc, killer);
|
||||
}
|
||||
|
||||
@Override
|
||||
public NPC getNPC() {
|
||||
return (NPC) super.getActor();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
/*
|
||||
* 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.npc.event;
|
||||
|
||||
import com.l2jserver.model.world.NPC;
|
||||
import com.l2jserver.model.world.actor.event.ActorUnspawnEvent;
|
||||
import com.l2jserver.util.geometry.Point3D;
|
||||
|
||||
/**
|
||||
* Event dispatched once a {@link NPC} has unspawned in the world.
|
||||
*
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
*/
|
||||
public class NPCUnspawnEvent extends ActorUnspawnEvent implements NPCEvent {
|
||||
/**
|
||||
* @param npc
|
||||
* the npc
|
||||
* @param point
|
||||
* the unspawn point
|
||||
*/
|
||||
public NPCUnspawnEvent(NPC npc, Point3D point) {
|
||||
super(npc, point);
|
||||
}
|
||||
|
||||
@Override
|
||||
public NPC getNPC() {
|
||||
return (NPC) super.getActor();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user