1
0
mirror of https://github.com/Rogiel/l2jserver2 synced 2026-01-28 21:52:48 +00:00

Template classes for all NPC instances

Signed-off-by: Rogiel <rogiel@rogiel.com>
This commit is contained in:
2011-05-23 01:23:41 -03:00
parent ebc7947473
commit 66d5fee187
9119 changed files with 664622 additions and 410 deletions

View File

@@ -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;
}
/**

View File

@@ -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
*/

View File

@@ -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

View File

@@ -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);
}
}

View File

@@ -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);
}
}

View File

@@ -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);
}
}

View File

@@ -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);
}
}

View File

@@ -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) {