mirror of
https://github.com/Rogiel/l2jserver2
synced 2025-12-06 07:32:46 +00:00
Implement the skill effect engine
Implements the skill effect classes and loader from XML files
This commit is contained in:
@@ -16,9 +16,14 @@
|
||||
*/
|
||||
package com.l2jserver.model.template;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import javax.xml.bind.annotation.XmlAccessType;
|
||||
import javax.xml.bind.annotation.XmlAccessorType;
|
||||
import javax.xml.bind.annotation.XmlAttribute;
|
||||
import javax.xml.bind.annotation.XmlElement;
|
||||
import javax.xml.bind.annotation.XmlElements;
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
import javax.xml.bind.annotation.XmlType;
|
||||
import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
|
||||
@@ -26,6 +31,9 @@ import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
|
||||
import com.l2jserver.model.game.Skill;
|
||||
import com.l2jserver.model.id.object.ActorID;
|
||||
import com.l2jserver.model.id.template.SkillTemplateID;
|
||||
import com.l2jserver.model.template.skill.SkillEffect;
|
||||
import com.l2jserver.model.template.skill.effect.TeleportEffect;
|
||||
import com.l2jserver.util.factory.CollectionFactory;
|
||||
import com.l2jserver.util.jaxb.SkillTemplateIDAdapter;
|
||||
|
||||
/**
|
||||
@@ -52,6 +60,9 @@ public class SkillTemplate extends AbstractTemplate<Skill> {
|
||||
*/
|
||||
protected int maximumLevel = 1;
|
||||
|
||||
@XmlElements({ @XmlElement(name = "teleport", type = TeleportEffect.class) })
|
||||
protected List<SkillEffect> effects = CollectionFactory.newList();
|
||||
|
||||
@Override
|
||||
public Skill create() {
|
||||
return create(null);
|
||||
@@ -108,6 +119,31 @@ public class SkillTemplate extends AbstractTemplate<Skill> {
|
||||
return cooldown;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the effects
|
||||
*/
|
||||
public List<SkillEffect> getEffects() {
|
||||
return Collections.unmodifiableList(effects);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tries to locate in the effects list an effect of the given type.
|
||||
*
|
||||
* @param <E>
|
||||
* the effect type
|
||||
* @param effectType
|
||||
* the effect type class
|
||||
* @return the effect found, if any.
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public <E extends SkillEffect> E getEffect(Class<E> effectType) {
|
||||
for (final SkillEffect effect : effects) {
|
||||
if (effectType.isInstance(effect))
|
||||
return (E) effect;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SkillTemplateID getID() {
|
||||
return id;
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
/*
|
||||
* 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.skill;
|
||||
|
||||
import javax.xml.bind.annotation.XmlAccessType;
|
||||
import javax.xml.bind.annotation.XmlAccessorType;
|
||||
import javax.xml.bind.annotation.XmlType;
|
||||
|
||||
/**
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
*
|
||||
*/
|
||||
@XmlAccessorType(XmlAccessType.FIELD)
|
||||
@XmlType(name = "Effect")
|
||||
public abstract class SkillEffect {
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
/*
|
||||
* 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.skill.effect;
|
||||
|
||||
import javax.xml.bind.annotation.XmlAccessType;
|
||||
import javax.xml.bind.annotation.XmlAccessorType;
|
||||
import javax.xml.bind.annotation.XmlAttribute;
|
||||
import javax.xml.bind.annotation.XmlType;
|
||||
|
||||
import com.l2jserver.model.template.skill.SkillEffect;
|
||||
|
||||
/**
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
*/
|
||||
@XmlAccessorType(XmlAccessType.FIELD)
|
||||
@XmlType(name = "TeleportEffect")
|
||||
public class BuffEffect extends SkillEffect {
|
||||
public enum SkillTeleportEffectLocation {
|
||||
TARGET, OFFSET_FROM_TARGET, POINT;
|
||||
}
|
||||
|
||||
@XmlAttribute(name = "type", required = false)
|
||||
protected SkillTeleportEffectLocation type = SkillTeleportEffectLocation.TARGET;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @return the teleport effect type
|
||||
*/
|
||||
public SkillTeleportEffectLocation getType() {
|
||||
return type;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
/*
|
||||
* 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.skill.effect;
|
||||
|
||||
import javax.xml.bind.annotation.XmlAccessType;
|
||||
import javax.xml.bind.annotation.XmlAccessorType;
|
||||
import javax.xml.bind.annotation.XmlAttribute;
|
||||
import javax.xml.bind.annotation.XmlType;
|
||||
|
||||
import com.l2jserver.model.template.skill.SkillEffect;
|
||||
|
||||
/**
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
*/
|
||||
@XmlAccessorType(XmlAccessType.FIELD)
|
||||
@XmlType(name = "TeleportEffect")
|
||||
public class TeleportEffect extends SkillEffect {
|
||||
public enum SkillTeleportEffectLocation {
|
||||
TARGET, OFFSET_FROM_TARGET, POINT;
|
||||
}
|
||||
|
||||
@XmlAttribute(name = "type", required = false)
|
||||
protected SkillTeleportEffectLocation type = SkillTeleportEffectLocation.TARGET;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @return the teleport effect type
|
||||
*/
|
||||
public SkillTeleportEffectLocation getType() {
|
||||
return type;
|
||||
}
|
||||
}
|
||||
@@ -46,7 +46,6 @@ public class KnownListUpdateFilter extends AndFilter<PositionableObject> {
|
||||
* @param old
|
||||
* the old position
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public KnownListUpdateFilter(PositionableObject object, Point3D old) {
|
||||
super(new KnownListFilter(object), new NotFilter<PositionableObject>(
|
||||
new RangePointFilter(old, KNOWNLIST_RANGE)));
|
||||
|
||||
Reference in New Issue
Block a user