mirror of
https://github.com/Rogiel/l2jserver2
synced 2025-12-07 07:52:57 +00:00
Very simple skill templates implemented
Signed-off-by: Rogiel <rogiel@rogiel.com>
This commit is contained in:
@@ -124,4 +124,41 @@ public class Skill extends AbstractModel {
|
||||
public SkillTemplate getSkillTemplate() {
|
||||
return skillTemplateID.getTemplate();
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see java.lang.Object#hashCode()
|
||||
*/
|
||||
@Override
|
||||
public int hashCode() {
|
||||
final int prime = 31;
|
||||
int result = super.hashCode();
|
||||
result = prime * result + ((actorID == null) ? 0 : actorID.hashCode());
|
||||
result = prime * result
|
||||
+ ((skillTemplateID == null) ? 0 : skillTemplateID.hashCode());
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj)
|
||||
return true;
|
||||
if (!super.equals(obj))
|
||||
return false;
|
||||
if (getClass() != obj.getClass())
|
||||
return false;
|
||||
Skill other = (Skill) obj;
|
||||
if (actorID == null) {
|
||||
if (other.actorID != null)
|
||||
return false;
|
||||
} else if (!actorID.equals(other.actorID))
|
||||
return false;
|
||||
if (skillTemplateID == null) {
|
||||
if (other.skillTemplateID != null)
|
||||
return false;
|
||||
} else if (!skillTemplateID.equals(other.skillTemplateID))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -304,6 +304,7 @@ public class NPCTemplate extends ActorTemplate<NPC> {
|
||||
continue;
|
||||
final Skill skill = template.create();
|
||||
skill.setLevel(metadata.level);
|
||||
skill.setActorID(npc.getID());
|
||||
skills.add(skill);
|
||||
}
|
||||
npc.getSkills().load(skills);
|
||||
|
||||
@@ -16,19 +16,47 @@
|
||||
*/
|
||||
package com.l2jserver.model.template;
|
||||
|
||||
import javax.xml.bind.annotation.XmlAccessType;
|
||||
import javax.xml.bind.annotation.XmlAccessorType;
|
||||
import javax.xml.bind.annotation.XmlAttribute;
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
import javax.xml.bind.annotation.XmlType;
|
||||
import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
|
||||
|
||||
import com.l2jserver.model.game.Skill;
|
||||
import com.l2jserver.model.id.template.SkillTemplateID;
|
||||
import com.l2jserver.util.jaxb.SkillTemplateIDAdapter;
|
||||
|
||||
/**
|
||||
* Template for {@link Skill} object
|
||||
*
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
*/
|
||||
@XmlRootElement(name = "skill")
|
||||
@XmlType(namespace = "skill", name = "skill")
|
||||
@XmlAccessorType(XmlAccessType.FIELD)
|
||||
public class SkillTemplate extends AbstractTemplate<Skill> {
|
||||
@XmlAttribute(name = "id")
|
||||
@XmlJavaTypeAdapter(value = SkillTemplateIDAdapter.class)
|
||||
protected SkillTemplateID id;
|
||||
@XmlAttribute(name = "name")
|
||||
protected String name;
|
||||
@XmlAttribute(name = "delay")
|
||||
protected int delay;
|
||||
@XmlAttribute(name = "cooldown")
|
||||
protected int cooldown;
|
||||
|
||||
/**
|
||||
* The maximum level supported by this skill
|
||||
*/
|
||||
protected int maximumLevel = 1;
|
||||
|
||||
@Override
|
||||
public Skill create() {
|
||||
final Skill skill = new Skill(id);
|
||||
skill.setLevel(1);
|
||||
return skill;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the maximumLevel
|
||||
@@ -37,15 +65,36 @@ public class SkillTemplate extends AbstractTemplate<Skill> {
|
||||
return maximumLevel;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Skill create() {
|
||||
final Skill skill = new Skill(null);
|
||||
return skill;
|
||||
/**
|
||||
* @return the id
|
||||
*/
|
||||
public SkillTemplateID getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the name
|
||||
*/
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the delay
|
||||
*/
|
||||
public int getDelay() {
|
||||
return delay;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the cooldown
|
||||
*/
|
||||
public int getCooldown() {
|
||||
return cooldown;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SkillTemplateID getID() {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
return id;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,6 +16,8 @@
|
||||
*/
|
||||
package com.l2jserver.model.world.actor.stat;
|
||||
|
||||
import com.l2jserver.model.world.Actor;
|
||||
|
||||
/**
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
*/
|
||||
@@ -81,7 +83,11 @@ public enum BaseStats {
|
||||
2.17, 2.2, 2.22, 2.24, 2.26, 2.29, 2.31, 2.33, 2.35, 2.38, 2.4,
|
||||
2.43, 2.45, 2.47, 2.5, 2.52, 2.55, 2.58, 2.6, 2.63, 2.65, 2.68);
|
||||
|
||||
public double[] bonus;
|
||||
/**
|
||||
* Bonus array for the base stat. The key represents the value of the
|
||||
* attribute.
|
||||
*/
|
||||
public final double[] bonus;
|
||||
|
||||
BaseStats(double... bonus) {
|
||||
this.bonus = bonus;
|
||||
@@ -90,4 +96,26 @@ public enum BaseStats {
|
||||
public double calculateBonus(int n) {
|
||||
return bonus[n];
|
||||
}
|
||||
|
||||
public double calculateBonus(Actor actor) {
|
||||
return calculateBonus(actor.getStats());
|
||||
}
|
||||
|
||||
public double calculateBonus(ActorStats<?> stats) {
|
||||
switch (this) {
|
||||
case CON:
|
||||
return calculateBonus(stats.getConcentration());
|
||||
case DEX:
|
||||
return calculateBonus(stats.getDexterity());
|
||||
case INT:
|
||||
return calculateBonus(stats.getIntelligence());
|
||||
case MEN:
|
||||
return calculateBonus(stats.getMentality());
|
||||
case STR:
|
||||
return calculateBonus(stats.getStrength());
|
||||
case WIT:
|
||||
return calculateBonus(stats.getWitness());
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -39,6 +39,7 @@ import com.l2jserver.model.id.TemplateID;
|
||||
import com.l2jserver.model.template.CharacterTemplate;
|
||||
import com.l2jserver.model.template.ItemTemplate;
|
||||
import com.l2jserver.model.template.NPCTemplate;
|
||||
import com.l2jserver.model.template.SkillTemplate;
|
||||
import com.l2jserver.model.template.TeleportationTemplate;
|
||||
import com.l2jserver.model.template.Template;
|
||||
import com.l2jserver.service.AbstractService;
|
||||
@@ -103,7 +104,7 @@ public class XMLTemplateService extends AbstractService implements
|
||||
try {
|
||||
log.debug("Creating JAXBContext instance");
|
||||
context = JAXBContext.newInstance(CharacterTemplate.class,
|
||||
NPCTemplate.class, ItemTemplate.class,
|
||||
NPCTemplate.class, ItemTemplate.class, SkillTemplate.class,
|
||||
TeleportationTemplateContainer.class);
|
||||
|
||||
log.debug("Creating Unmarshaller instance");
|
||||
|
||||
Reference in New Issue
Block a user