mirror of
https://github.com/Rogiel/l2jserver2
synced 2025-12-08 00:13:11 +00:00
@@ -18,7 +18,7 @@ package com.l2jserver;
|
||||
|
||||
import com.google.inject.AbstractModule;
|
||||
import com.google.inject.Module;
|
||||
import com.l2jserver.db.H2DAOModule;
|
||||
import com.l2jserver.db.MySQL5DAOModule;
|
||||
import com.l2jserver.model.id.provider.IDProviderModule;
|
||||
import com.l2jserver.service.ServiceModule;
|
||||
|
||||
@@ -32,6 +32,6 @@ public class GameServerModule extends AbstractModule {
|
||||
protected void configure() {
|
||||
install(new ServiceModule());
|
||||
install(new IDProviderModule());
|
||||
install(new H2DAOModule());
|
||||
install(new MySQL5DAOModule());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -254,8 +254,7 @@ public class Lineage2Connection {
|
||||
* has been written.
|
||||
*/
|
||||
public ChannelFuture sendMessage(String message) {
|
||||
return write(new SM_SYSTEM_MESSAGE(SystemMessage.S1)
|
||||
.addString(message));
|
||||
return write(new SM_SYSTEM_MESSAGE(SystemMessage.S1).addString(message));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -277,8 +276,8 @@ public class Lineage2Connection {
|
||||
* the {@link SystemMessage}
|
||||
* @param args
|
||||
* the arguments of the message, they will be automatically
|
||||
* detected and inserted. See {@link SM_SYSTEM_MESSAGE} for
|
||||
* more about supported formats.
|
||||
* detected and inserted. See {@link SM_SYSTEM_MESSAGE} for more
|
||||
* about supported formats.
|
||||
* @return the {@link ChannelFuture} that will be notified once the packet
|
||||
* has been written.
|
||||
* @see SM_SYSTEM_MESSAGE
|
||||
@@ -293,8 +292,10 @@ public class Lineage2Connection {
|
||||
packet.addItem((ItemTemplate) obj);
|
||||
else if (obj instanceof Item)
|
||||
packet.addItem((Item) obj);
|
||||
else if (obj instanceof Number)
|
||||
packet.addNumber((Integer) obj);
|
||||
}
|
||||
return write(message.packet);
|
||||
return write(packet);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -54,6 +54,10 @@ public class SM_ATTACK extends AbstractServerPacket {
|
||||
Collections.addAll(this.hits, hits);
|
||||
}
|
||||
|
||||
public SM_ATTACK(AttackHit... hits) {
|
||||
this(hits[0].getAttacker(), hits);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(Lineage2Connection conn, ChannelBuffer buffer) {
|
||||
buffer.writeInt(attacker.getID().getID());
|
||||
|
||||
@@ -78,6 +78,22 @@ public class AttackHit {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new instance
|
||||
*
|
||||
* @param attacker
|
||||
* the actor attacking <tt>target</tt>
|
||||
* @param target
|
||||
* the actor being attacked by <tt>attacker</tt>
|
||||
* @param damage
|
||||
* the damage issued in this hit
|
||||
*/
|
||||
public AttackHit(Actor attacker, Actor target, double damage) {
|
||||
this.attacker = attacker;
|
||||
this.target = target;
|
||||
this.damage = damage;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new instance
|
||||
*
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
/*
|
||||
* 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.server.attack;
|
||||
|
||||
import com.l2jserver.util.calculator.SimpleCalculator;
|
||||
|
||||
/**
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
*/
|
||||
public class AttackCalculator extends SimpleCalculator<AttackCalculatorContext> {
|
||||
public AttackCalculator(AttackCalculatorFunction... functions) {
|
||||
super(functions);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
/*
|
||||
* 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.server.attack;
|
||||
|
||||
import com.l2jserver.model.world.Actor;
|
||||
import com.l2jserver.util.calculator.CalculatorContext;
|
||||
|
||||
/**
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
*/
|
||||
public class AttackCalculatorContext extends CalculatorContext {
|
||||
public final Actor attacker;
|
||||
public final Actor target;
|
||||
|
||||
public AttackCalculatorContext(Actor attacker, Actor target) {
|
||||
this.attacker = attacker;
|
||||
this.target = target;
|
||||
}
|
||||
}
|
||||
@@ -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.server.attack;
|
||||
|
||||
import com.l2jserver.model.world.Actor;
|
||||
import com.l2jserver.util.calculator.AbstractDoubleFunction;
|
||||
|
||||
/**
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
*/
|
||||
public abstract class AttackCalculatorFunction extends
|
||||
AbstractDoubleFunction<AttackCalculatorContext> {
|
||||
public AttackCalculatorFunction(int order) {
|
||||
super(order);
|
||||
}
|
||||
|
||||
@Override
|
||||
public double calculate(AttackCalculatorContext ctx, double value) {
|
||||
return calculate(ctx.attacker, ctx.target, value);
|
||||
}
|
||||
|
||||
public abstract double calculate(Actor attacker, Actor target, double value);
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
/*
|
||||
* 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.server.attack;
|
||||
|
||||
import com.l2jserver.model.world.Actor;
|
||||
|
||||
/**
|
||||
* Calculator used to calculate physical damage on each hit.
|
||||
*
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
*/
|
||||
public class PhysicalAttackCalculator extends AttackCalculator {
|
||||
public PhysicalAttackCalculator() {
|
||||
super(new AttackCalculatorFunction(0x000) {
|
||||
@Override
|
||||
public double calculate(Actor attacker, Actor target, double value) {
|
||||
// TODO this is certainly not right!!!
|
||||
// this is just an simple calculator for testing!
|
||||
return attacker.getStats().getPhysicalAttack()
|
||||
- target.getStats().getPhysicalDefense();
|
||||
}
|
||||
}, new AttackCalculatorFunction(Integer.MAX_VALUE) {
|
||||
@Override
|
||||
public double calculate(Actor attacker, Actor target, double value) {
|
||||
if (value <= 0)
|
||||
return 1;
|
||||
return value;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -28,6 +28,7 @@ import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import com.l2jserver.model.id.template.ItemTemplateID;
|
||||
import com.l2jserver.model.template.calculator.ItemPhysicalDamageActorCalculator;
|
||||
import com.l2jserver.model.world.Item;
|
||||
import com.l2jserver.util.jaxb.ItemTemplateIDAdapter;
|
||||
|
||||
@@ -58,15 +59,26 @@ public class ItemTemplate extends AbstractTemplate<Item> {
|
||||
protected int price = 0;
|
||||
@XmlElement(name = "icon")
|
||||
protected String icon;
|
||||
@XmlElement(name = "weight")
|
||||
@XmlElement(name = "effect")
|
||||
protected EffectContainer effect;
|
||||
|
||||
@XmlType(namespace = "item")
|
||||
private static class EffectContainer {
|
||||
@XmlAttribute(name = "type")
|
||||
protected EffectType effect = null;
|
||||
protected EffectType effect;
|
||||
}
|
||||
|
||||
@XmlType(namespace = "item")
|
||||
protected static class StatsContainer {
|
||||
@XmlElement(name = "physicalDamage")
|
||||
protected StatAttribute physicalDamage;
|
||||
@XmlElement(name = "magicalDamage")
|
||||
protected StatAttribute magicalDamage;
|
||||
}
|
||||
|
||||
@XmlElement(name = "stats")
|
||||
protected StatsContainer stats;
|
||||
|
||||
protected ItemMaterial material;
|
||||
|
||||
public enum ItemMaterial {
|
||||
@@ -77,6 +89,38 @@ public class ItemTemplate extends AbstractTemplate<Item> {
|
||||
IMMEDIATE;
|
||||
}
|
||||
|
||||
@XmlType(namespace = "item")
|
||||
public static class StatAttribute {
|
||||
@XmlElement(name = "set")
|
||||
protected StatSet set;
|
||||
|
||||
public static class StatSet {
|
||||
protected int order;
|
||||
protected double value;
|
||||
|
||||
/**
|
||||
* @return the order
|
||||
*/
|
||||
public int getOrder() {
|
||||
return order;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the value
|
||||
*/
|
||||
public double getValue() {
|
||||
return value;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the set
|
||||
*/
|
||||
public StatSet getSet() {
|
||||
return set;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Item create() {
|
||||
log.debug("Creating a new Item instance with template {}", this);
|
||||
@@ -125,6 +169,24 @@ public class ItemTemplate extends AbstractTemplate<Item> {
|
||||
return material;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the physical damage
|
||||
*/
|
||||
public ItemPhysicalDamageActorCalculator getPhysicalDamage() {
|
||||
if (stats == null)
|
||||
return null;
|
||||
return new ItemPhysicalDamageActorCalculator(stats.physicalDamage.set);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the magical damage
|
||||
*/
|
||||
public StatAttribute getMagicalDamage() {
|
||||
if (stats == null)
|
||||
return null;
|
||||
return stats.magicalDamage;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
|
||||
@@ -14,30 +14,24 @@
|
||||
* 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.calculator.base;
|
||||
package com.l2jserver.model.template.calculator;
|
||||
|
||||
import com.l2jserver.model.template.NPCTemplate;
|
||||
import com.l2jserver.model.world.NPC;
|
||||
import com.l2jserver.model.world.npc.calculator.NPCCalculator;
|
||||
import com.l2jserver.model.world.npc.calculator.NPCCalculatorFunction;
|
||||
import com.l2jserver.model.template.ActorTemplate;
|
||||
import com.l2jserver.model.template.ItemTemplate.StatAttribute.StatSet;
|
||||
import com.l2jserver.model.world.Actor;
|
||||
import com.l2jserver.model.world.actor.calculator.ActorCalculator;
|
||||
import com.l2jserver.model.world.actor.calculator.ActorCalculatorFunction;
|
||||
|
||||
/**
|
||||
* Calculates the character base accuracy.
|
||||
*
|
||||
* <pre>
|
||||
* ctx.result = c.getTemplate().getBaseAccuracy();
|
||||
* </pre>
|
||||
*
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
*
|
||||
*/
|
||||
public class NPCBaseAttackAccuracyCalculator extends NPCCalculator {
|
||||
public NPCBaseAttackAccuracyCalculator() {
|
||||
super(new NPCCalculatorFunction(0x000) {
|
||||
public class ItemPhysicalDamageActorCalculator extends ActorCalculator {
|
||||
public ItemPhysicalDamageActorCalculator(final StatSet set) {
|
||||
super(new ActorCalculatorFunction(set.getOrder()) {
|
||||
@Override
|
||||
protected double calculate(NPC c, NPCTemplate t, double value) {
|
||||
// return t.getEvasion()
|
||||
// TODO
|
||||
return value;
|
||||
protected double calculate(Actor a, ActorTemplate<?> t, double value) {
|
||||
return set.getValue();
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -30,8 +30,14 @@ import com.l2jserver.service.game.ai.AIScript;
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
*/
|
||||
public class NPC extends Actor {
|
||||
private NPCStats stats;
|
||||
/**
|
||||
* This NPC stats
|
||||
*/
|
||||
private final NPCStats stats = new NPCStats(this);
|
||||
|
||||
/**
|
||||
* The npc state
|
||||
*/
|
||||
private NPCState state;
|
||||
|
||||
public enum NPCState {
|
||||
@@ -48,9 +54,7 @@ public class NPC extends Actor {
|
||||
super(templateID);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the stats
|
||||
*/
|
||||
@Override
|
||||
public NPCStats getStats() {
|
||||
return stats;
|
||||
}
|
||||
@@ -90,7 +94,8 @@ public class NPC extends Actor {
|
||||
public void setState(NPCState state) {
|
||||
this.state = state;
|
||||
}
|
||||
|
||||
|
||||
// TEMPLATE WRAPPERS
|
||||
@Override
|
||||
public ActorSex getSex() {
|
||||
return this.getTemplate().getSex();
|
||||
|
||||
@@ -16,12 +16,12 @@
|
||||
*/
|
||||
package com.l2jserver.model.world.actor.calculator;
|
||||
|
||||
import com.l2jserver.util.calculator.Calculator;
|
||||
import com.l2jserver.util.calculator.SimpleCalculator;
|
||||
|
||||
/**
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
*/
|
||||
public class ActorCalculator extends Calculator<ActorCalculatorContext> {
|
||||
public class ActorCalculator extends SimpleCalculator<ActorCalculatorContext> {
|
||||
public ActorCalculator(ActorCalculatorFunction... functions) {
|
||||
super(functions);
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@ package com.l2jserver.model.world.actor.calculator;
|
||||
|
||||
import com.l2jserver.model.template.ActorTemplate;
|
||||
import com.l2jserver.model.world.Actor;
|
||||
import com.l2jserver.util.calculator.AbstractFunction;
|
||||
import com.l2jserver.util.calculator.AbstractDoubleFunction;
|
||||
|
||||
/**
|
||||
* An calculator for character formulas.
|
||||
@@ -26,7 +26,7 @@ import com.l2jserver.util.calculator.AbstractFunction;
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
*/
|
||||
public abstract class ActorCalculatorFunction extends
|
||||
AbstractFunction<ActorCalculatorContext> {
|
||||
AbstractDoubleFunction<ActorCalculatorContext> {
|
||||
public ActorCalculatorFunction(int order) {
|
||||
super(order);
|
||||
}
|
||||
|
||||
@@ -16,11 +16,9 @@
|
||||
*/
|
||||
package com.l2jserver.model.world.actor.calculator;
|
||||
|
||||
import com.l2jserver.model.template.CharacterTemplate;
|
||||
import com.l2jserver.model.world.L2Character;
|
||||
import com.l2jserver.model.template.ActorTemplate;
|
||||
import com.l2jserver.model.world.Actor;
|
||||
import com.l2jserver.model.world.actor.stat.BaseStats;
|
||||
import com.l2jserver.model.world.character.calculator.CharacterCalculator;
|
||||
import com.l2jserver.model.world.character.calculator.CharacterCalculatorFunction;
|
||||
|
||||
/**
|
||||
* Calculates the character base run speed
|
||||
@@ -31,12 +29,11 @@ import com.l2jserver.model.world.character.calculator.CharacterCalculatorFunctio
|
||||
*
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
*/
|
||||
public class RunSpeedBonusCalculator extends CharacterCalculator {
|
||||
public class RunSpeedBonusCalculator extends ActorCalculator {
|
||||
public RunSpeedBonusCalculator() {
|
||||
super(new CharacterCalculatorFunction(0x300) {
|
||||
super(new ActorCalculatorFunction(0x300) {
|
||||
@Override
|
||||
protected double calculate(L2Character c, CharacterTemplate t,
|
||||
double value) {
|
||||
protected double calculate(Actor c, ActorTemplate<?> t, double value) {
|
||||
return value
|
||||
* BaseStats.DEX.calculateBonus(c.getStats()
|
||||
.getDexterity());
|
||||
|
||||
@@ -16,11 +16,9 @@
|
||||
*/
|
||||
package com.l2jserver.model.world.actor.calculator;
|
||||
|
||||
import com.l2jserver.model.template.CharacterTemplate;
|
||||
import com.l2jserver.model.world.L2Character;
|
||||
import com.l2jserver.model.template.ActorTemplate;
|
||||
import com.l2jserver.model.world.Actor;
|
||||
import com.l2jserver.model.world.actor.stat.BaseStats;
|
||||
import com.l2jserver.model.world.character.calculator.CharacterCalculator;
|
||||
import com.l2jserver.model.world.character.calculator.CharacterCalculatorFunction;
|
||||
|
||||
/**
|
||||
* Calculates the character base walk speed
|
||||
@@ -31,12 +29,11 @@ import com.l2jserver.model.world.character.calculator.CharacterCalculatorFunctio
|
||||
*
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
*/
|
||||
public class WalkSpeedBonusCalculator extends CharacterCalculator {
|
||||
public class WalkSpeedBonusCalculator extends ActorCalculator {
|
||||
public WalkSpeedBonusCalculator() {
|
||||
super(new CharacterCalculatorFunction(0x300) {
|
||||
super(new ActorCalculatorFunction(0x300) {
|
||||
@Override
|
||||
protected double calculate(L2Character c, CharacterTemplate t,
|
||||
double value) {
|
||||
protected double calculate(Actor c, ActorTemplate<?> t, double value) {
|
||||
return value
|
||||
* BaseStats.DEX.calculateBonus(c.getStats()
|
||||
.getDexterity());
|
||||
|
||||
@@ -0,0 +1,68 @@
|
||||
/*
|
||||
* 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.server.AttackHit;
|
||||
import com.l2jserver.model.world.Actor;
|
||||
import com.l2jserver.model.world.WorldObject;
|
||||
|
||||
/**
|
||||
* Event dispatcher once an actor has received/dealt an attack hit.
|
||||
* <p>
|
||||
* Please note that the same event is dispatched for both attacker and attackee.
|
||||
*
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
*/
|
||||
public class ActorAttackHitEvent implements ActorEvent {
|
||||
/**
|
||||
* The spawned player
|
||||
*/
|
||||
private final AttackHit hit;
|
||||
|
||||
/**
|
||||
* Creates a new instance
|
||||
*
|
||||
* @param hit
|
||||
* the attack hit
|
||||
*/
|
||||
public ActorAttackHitEvent(AttackHit hit) {
|
||||
this.hit = hit;
|
||||
}
|
||||
|
||||
@Override
|
||||
public WorldObject getObject() {
|
||||
return hit.getAttacker();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Actor getActor() {
|
||||
return hit.getAttacker();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the attack hit
|
||||
*/
|
||||
public AttackHit getHit() {
|
||||
return hit;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ObjectID<?>[] getDispatchableObjects() {
|
||||
return new ObjectID<?>[] { hit.getAttacker().getID() };
|
||||
}
|
||||
}
|
||||
@@ -32,7 +32,7 @@ import com.l2jserver.model.world.actor.calculator.PhysicalCriticalRateBonusCalcu
|
||||
import com.l2jserver.model.world.actor.calculator.PhysicalDefenseBonusCalculator;
|
||||
import com.l2jserver.model.world.actor.calculator.RunSpeedBonusCalculator;
|
||||
import com.l2jserver.model.world.actor.calculator.WalkSpeedBonusCalculator;
|
||||
import com.l2jserver.util.calculator.Calculator;
|
||||
import com.l2jserver.util.calculator.SimpleCalculator;
|
||||
|
||||
/**
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
@@ -152,12 +152,12 @@ public abstract class ActorStats<T extends ActorCalculatorContext> {
|
||||
* speed gain is much higher.
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
private final Calculator<T>[] calculators = new Calculator[StatType
|
||||
private final SimpleCalculator<T>[] calculators = new SimpleCalculator[StatType
|
||||
.values().length];
|
||||
|
||||
public ActorStats() {
|
||||
for (int i = 0; i < calculators.length; i++) {
|
||||
calculators[i] = new Calculator<T>();
|
||||
calculators[i] = new SimpleCalculator<T>();
|
||||
}
|
||||
|
||||
// bonuses
|
||||
@@ -334,7 +334,7 @@ public abstract class ActorStats<T extends ActorCalculatorContext> {
|
||||
* calculator {@link StatType}
|
||||
* @return the calculator object associated with the given <tt>type</tt>
|
||||
*/
|
||||
protected Calculator<T> getCalculator(StatType type) {
|
||||
protected SimpleCalculator<T> getCalculator(StatType type) {
|
||||
return calculators[type.ordinal()];
|
||||
}
|
||||
|
||||
@@ -350,5 +350,9 @@ public abstract class ActorStats<T extends ActorCalculatorContext> {
|
||||
return getCalculator(type).calculate(ctx);
|
||||
}
|
||||
|
||||
public void updateCalculators() {
|
||||
|
||||
}
|
||||
|
||||
protected abstract T createContext();
|
||||
}
|
||||
|
||||
@@ -19,6 +19,7 @@ package com.l2jserver.model.world.character;
|
||||
import com.l2jserver.model.world.L2Character;
|
||||
import com.l2jserver.model.world.actor.stat.ActorStats;
|
||||
import com.l2jserver.model.world.actor.stat.StatType;
|
||||
import com.l2jserver.model.world.character.CharacterInventory.InventoryPaperdoll;
|
||||
import com.l2jserver.model.world.character.calculator.CharacterCalculator;
|
||||
import com.l2jserver.model.world.character.calculator.CharacterCalculatorContext;
|
||||
import com.l2jserver.model.world.character.calculator.MaximumCPAddCalculator;
|
||||
@@ -46,17 +47,17 @@ import com.l2jserver.model.world.character.calculator.base.CharacterBaseRunSpeed
|
||||
import com.l2jserver.model.world.character.calculator.base.CharacterBaseStrengthCalculator;
|
||||
import com.l2jserver.model.world.character.calculator.base.CharacterBaseWalkSpeedCalculator;
|
||||
import com.l2jserver.model.world.character.calculator.base.CharacterBaseWitnessCalculator;
|
||||
import com.l2jserver.util.calculator.Calculator;
|
||||
import com.l2jserver.util.calculator.SimpleCalculator;
|
||||
|
||||
/**
|
||||
* This class is responsible for calculating the real character stats. The real
|
||||
* stats vary from the values from the templates, also, skills and items
|
||||
* equipped can change those values. Once an buff is applied, a new calculator
|
||||
* is {@link Calculator#importFunctions(Calculator) imported} and their
|
||||
* functions are added to this class calculator. Once the skill effect has past
|
||||
* away, all the functions that were imported are now
|
||||
* {@link Calculator#removeFunctions(Calculator) removed} and the calculator
|
||||
* return to its original state.
|
||||
* is {@link SimpleCalculator#importFunctions(SimpleCalculator) imported} and
|
||||
* their functions are added to this class calculator. Once the skill effect has
|
||||
* past away, all the functions that were imported are now
|
||||
* {@link SimpleCalculator#removeFunctions(SimpleCalculator) removed} and the
|
||||
* calculator return to its original state.
|
||||
* <p>
|
||||
* Another important note is that calculators should perform calculations as
|
||||
* fast as possible.
|
||||
@@ -219,7 +220,7 @@ public class CharacterStats extends ActorStats<CharacterCalculatorContext> {
|
||||
* shared.</u>
|
||||
*/
|
||||
private static final CharacterCalculator BASE_ATTACK_EVASION_CALCULATOR = new CharacterBaseAttackEvasionCalculator();
|
||||
|
||||
|
||||
// BONUS
|
||||
/**
|
||||
* The calculator for CP bonus
|
||||
@@ -228,7 +229,7 @@ public class CharacterStats extends ActorStats<CharacterCalculatorContext> {
|
||||
* shared.</u>
|
||||
*/
|
||||
private static final CharacterCalculator CP_BONUS_CALCULATOR = new MaximumCPBonusCalculator();
|
||||
|
||||
|
||||
// ADD
|
||||
/**
|
||||
* The calculator for HP add
|
||||
@@ -299,10 +300,10 @@ public class CharacterStats extends ActorStats<CharacterCalculatorContext> {
|
||||
add(StatType.MAX_HP, HP_ADD_CALCULATOR);
|
||||
add(StatType.MAX_MP, MP_ADD_CALCULATOR);
|
||||
add(StatType.MAX_CP, CP_ADD_CALCULATOR);
|
||||
|
||||
|
||||
// bonus
|
||||
add(StatType.MAX_CP, CP_BONUS_CALCULATOR);
|
||||
|
||||
|
||||
// TODO henna stats calculators
|
||||
}
|
||||
|
||||
@@ -320,6 +321,17 @@ public class CharacterStats extends ActorStats<CharacterCalculatorContext> {
|
||||
return (int) calc(StatType.MAX_LOAD);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateCalculators() {
|
||||
super.updateCalculators();
|
||||
if (character.getInventory().has(InventoryPaperdoll.RIGHT_HAND)) {
|
||||
add(StatType.POWER_ATTACK,
|
||||
character.getInventory()
|
||||
.getItem(InventoryPaperdoll.RIGHT_HAND)
|
||||
.getTemplateID().getTemplate().getPhysicalDamage());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected CharacterCalculatorContext createContext() {
|
||||
return new CharacterCalculatorContext(character);
|
||||
|
||||
@@ -21,7 +21,6 @@ import com.l2jserver.model.world.actor.stat.ActorStats;
|
||||
import com.l2jserver.model.world.actor.stat.StatType;
|
||||
import com.l2jserver.model.world.npc.calculator.NPCCalculator;
|
||||
import com.l2jserver.model.world.npc.calculator.NPCCalculatorContext;
|
||||
import com.l2jserver.model.world.npc.calculator.base.NPCBaseAttackAccuracyCalculator;
|
||||
import com.l2jserver.model.world.npc.calculator.base.NPCBaseAttackEvasionCalculator;
|
||||
import com.l2jserver.model.world.npc.calculator.base.NPCBaseConcentrationCalculator;
|
||||
import com.l2jserver.model.world.npc.calculator.base.NPCBaseDexterityCalculator;
|
||||
@@ -41,16 +40,16 @@ import com.l2jserver.model.world.npc.calculator.base.NPCBaseRunSpeedCalculator;
|
||||
import com.l2jserver.model.world.npc.calculator.base.NPCBaseStrengthCalculator;
|
||||
import com.l2jserver.model.world.npc.calculator.base.NPCBaseWalkSpeedCalculator;
|
||||
import com.l2jserver.model.world.npc.calculator.base.NPCBaseWitnessCalculator;
|
||||
import com.l2jserver.util.calculator.Calculator;
|
||||
import com.l2jserver.util.calculator.SimpleCalculator;
|
||||
|
||||
/**
|
||||
* This class is responsible for calculating the real NPC stats. The real stats
|
||||
* vary from the values from the templates, also, skills and items equipped can
|
||||
* change those values. Once an buff is applied, a new calculator is
|
||||
* {@link Calculator#importFunctions(Calculator) imported} and their functions
|
||||
* {@link SimpleCalculator#importFunctions(SimpleCalculator) imported} and their functions
|
||||
* are added to this class calculator. Once the skill effect has past away, all
|
||||
* the functions that were imported are now
|
||||
* {@link Calculator#removeFunctions(Calculator) removed} and the calculator
|
||||
* {@link SimpleCalculator#removeFunctions(SimpleCalculator) removed} and the calculator
|
||||
* return to its original state.
|
||||
* <p>
|
||||
* Another important note is that calculators should perform calculations as
|
||||
@@ -192,13 +191,6 @@ public class NPCStats extends ActorStats<NPCCalculatorContext> {
|
||||
*/
|
||||
private static final NPCCalculator BASE_MAGICAL_DEFENSE_CALCULATOR = new NPCBaseMagicalDefenseCalculator();
|
||||
|
||||
/**
|
||||
* The calculator base attack accuracy
|
||||
* <p>
|
||||
* <u>This calculator does not store any state and thus is safe to be
|
||||
* shared.</u>
|
||||
*/
|
||||
private static final NPCCalculator BASE_ATTACK_ACCURACY_CALCULATOR = new NPCBaseAttackAccuracyCalculator();
|
||||
/**
|
||||
* The calculator base evasion
|
||||
* <p>
|
||||
@@ -245,7 +237,6 @@ public class NPCStats extends ActorStats<NPCCalculatorContext> {
|
||||
add(StatType.MCRITICAL_RATE, BASE_MAGICAL_CRITICAL_RATE_CALCULATOR);
|
||||
add(StatType.MAGIC_DEFENSE, BASE_MAGICAL_DEFENSE_CALCULATOR);
|
||||
|
||||
add(StatType.ACCURACY_COMBAT, BASE_ATTACK_ACCURACY_CALCULATOR);
|
||||
add(StatType.EVASION_RATE, BASE_ATTACK_EVASION_CALCULATOR);
|
||||
}
|
||||
|
||||
|
||||
@@ -41,7 +41,9 @@ public class ServiceManager {
|
||||
* The Guice Injector
|
||||
*/
|
||||
private final Injector injector;
|
||||
|
||||
/**
|
||||
* List of all known services by this manager
|
||||
*/
|
||||
private final Set<Service> knownServices = CollectionFactory.newSet();
|
||||
|
||||
@Inject
|
||||
|
||||
@@ -31,6 +31,8 @@ import com.l2jserver.service.core.vfs.VFSService;
|
||||
import com.l2jserver.service.core.vfs.VFSServiceImpl;
|
||||
import com.l2jserver.service.database.DatabaseService;
|
||||
import com.l2jserver.service.database.JDBCDatabaseService;
|
||||
import com.l2jserver.service.game.AttackService;
|
||||
import com.l2jserver.service.game.AttackServiceImpl;
|
||||
import com.l2jserver.service.game.character.CharacterService;
|
||||
import com.l2jserver.service.game.character.CharacterServiceImpl;
|
||||
import com.l2jserver.service.game.chat.ChatService;
|
||||
@@ -53,6 +55,8 @@ import com.l2jserver.service.game.world.event.WorldEventDispatcher;
|
||||
import com.l2jserver.service.game.world.event.WorldEventDispatcherImpl;
|
||||
import com.l2jserver.service.network.NettyNetworkService;
|
||||
import com.l2jserver.service.network.NetworkService;
|
||||
import com.l2jserver.service.network.gameguard.GameGuardService;
|
||||
import com.l2jserver.service.network.gameguard.GameGuardServiceImpl;
|
||||
import com.l2jserver.service.network.keygen.BlowfishKeygenService;
|
||||
import com.l2jserver.service.network.keygen.SecureBlowfishKeygenService;
|
||||
|
||||
@@ -86,6 +90,8 @@ public class ServiceModule extends AbstractModule {
|
||||
.in(Scopes.SINGLETON);
|
||||
bind(NetworkService.class).to(NettyNetworkService.class).in(
|
||||
Scopes.SINGLETON);
|
||||
bind(GameGuardService.class).to(GameGuardServiceImpl.class).in(
|
||||
Scopes.SINGLETON);
|
||||
bind(ScriptingService.class).to(ScriptingServiceImpl.class).in(
|
||||
Scopes.SINGLETON);
|
||||
bind(TemplateService.class).to(XMLTemplateService.class).in(
|
||||
@@ -97,6 +103,8 @@ public class ServiceModule extends AbstractModule {
|
||||
.in(Scopes.SINGLETON);
|
||||
bind(CharacterService.class).to(CharacterServiceImpl.class).in(
|
||||
Scopes.SINGLETON);
|
||||
bind(AttackService.class).to(AttackServiceImpl.class).in(
|
||||
Scopes.SINGLETON);
|
||||
bind(NPCService.class).to(NPCServiceImpl.class).in(Scopes.SINGLETON);
|
||||
|
||||
bind(WorldService.class).to(WorldServiceImpl.class)
|
||||
|
||||
@@ -21,8 +21,13 @@ import java.util.concurrent.Callable;
|
||||
import com.google.common.base.Preconditions;
|
||||
import com.google.inject.Inject;
|
||||
import com.l2jserver.model.server.AttackHit;
|
||||
import com.l2jserver.model.server.attack.AttackCalculator;
|
||||
import com.l2jserver.model.server.attack.AttackCalculatorContext;
|
||||
import com.l2jserver.model.server.attack.PhysicalAttackCalculator;
|
||||
import com.l2jserver.model.world.Actor;
|
||||
import com.l2jserver.model.world.actor.event.ActorAttackHitEvent;
|
||||
import com.l2jserver.service.AbstractService;
|
||||
import com.l2jserver.service.AbstractService.Depends;
|
||||
import com.l2jserver.service.core.threading.AsyncFuture;
|
||||
import com.l2jserver.service.core.threading.ThreadService;
|
||||
import com.l2jserver.service.game.world.event.WorldEventDispatcher;
|
||||
@@ -30,7 +35,13 @@ import com.l2jserver.service.game.world.event.WorldEventDispatcher;
|
||||
/**
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
*/
|
||||
@Depends({ ThreadService.class })
|
||||
public class AttackServiceImpl extends AbstractService implements AttackService {
|
||||
/**
|
||||
* Calculator used to compute physical attacks
|
||||
*/
|
||||
private static final AttackCalculator PHYSICAL_ATTACK_CALCULATOR = new PhysicalAttackCalculator();
|
||||
|
||||
/**
|
||||
* The {@link ThreadService} is used to schedule asynchronous attacks
|
||||
*/
|
||||
@@ -39,7 +50,6 @@ public class AttackServiceImpl extends AbstractService implements AttackService
|
||||
* The {@link WorldEventDispatcher} is used to dispatch attack events to the
|
||||
* world
|
||||
*/
|
||||
@SuppressWarnings("unused")
|
||||
private final WorldEventDispatcher eventDispatcher;
|
||||
|
||||
@Inject
|
||||
@@ -67,12 +77,10 @@ public class AttackServiceImpl extends AbstractService implements AttackService
|
||||
/**
|
||||
* The attacker
|
||||
*/
|
||||
@SuppressWarnings("unused")
|
||||
private final Actor attacker;
|
||||
/**
|
||||
* The target
|
||||
*/
|
||||
@SuppressWarnings("unused")
|
||||
private final Actor target;
|
||||
|
||||
public AttackCallable(Actor attacker, Actor target) {
|
||||
@@ -82,8 +90,15 @@ public class AttackServiceImpl extends AbstractService implements AttackService
|
||||
|
||||
@Override
|
||||
public AttackHit call() throws Exception {
|
||||
|
||||
return null;
|
||||
final double damage = PHYSICAL_ATTACK_CALCULATOR
|
||||
.calculate(new AttackCalculatorContext(attacker, target));
|
||||
// TODO calculate miss
|
||||
// TODO calculate critical
|
||||
// TODO calculate soulshot
|
||||
|
||||
final AttackHit hit = new AttackHit(attacker, target, damage);
|
||||
eventDispatcher.dispatch(new ActorAttackHitEvent(hit));
|
||||
return hit;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,6 +21,7 @@ import com.google.inject.Inject;
|
||||
import com.l2jserver.db.dao.ItemDAO;
|
||||
import com.l2jserver.game.net.Lineage2Connection;
|
||||
import com.l2jserver.game.net.SystemMessage;
|
||||
import com.l2jserver.game.net.packet.server.SM_ATTACK;
|
||||
import com.l2jserver.game.net.packet.server.SM_CHAR_INFO;
|
||||
import com.l2jserver.game.net.packet.server.SM_CHAR_INFO_BROADCAST;
|
||||
import com.l2jserver.game.net.packet.server.SM_CHAR_INFO_EXTRA;
|
||||
@@ -32,7 +33,6 @@ import com.l2jserver.game.net.packet.server.SM_NPC_INFO;
|
||||
import com.l2jserver.game.net.packet.server.SM_OBJECT_REMOVE;
|
||||
import com.l2jserver.game.net.packet.server.SM_TARGET;
|
||||
import com.l2jserver.model.id.object.CharacterID;
|
||||
import com.l2jserver.model.template.NPCTemplate;
|
||||
import com.l2jserver.model.world.Actor;
|
||||
import com.l2jserver.model.world.L2Character;
|
||||
import com.l2jserver.model.world.L2Character.CharacterMoveType;
|
||||
@@ -40,6 +40,7 @@ import com.l2jserver.model.world.L2Character.CharacterState;
|
||||
import com.l2jserver.model.world.NPC;
|
||||
import com.l2jserver.model.world.PositionableObject;
|
||||
import com.l2jserver.model.world.WorldObject;
|
||||
import com.l2jserver.model.world.actor.event.ActorAttackHitEvent;
|
||||
import com.l2jserver.model.world.character.event.CharacterEnterWorldEvent;
|
||||
import com.l2jserver.model.world.character.event.CharacterEvent;
|
||||
import com.l2jserver.model.world.character.event.CharacterLeaveWorldEvent;
|
||||
@@ -54,6 +55,7 @@ import com.l2jserver.model.world.player.event.PlayerTeleportedEvent;
|
||||
import com.l2jserver.model.world.player.event.PlayerTeleportingEvent;
|
||||
import com.l2jserver.service.AbstractService;
|
||||
import com.l2jserver.service.AbstractService.Depends;
|
||||
import com.l2jserver.service.game.AttackService;
|
||||
import com.l2jserver.service.game.chat.ChatChannel;
|
||||
import com.l2jserver.service.game.chat.ChatChannelListener;
|
||||
import com.l2jserver.service.game.chat.ChatMessageDestination;
|
||||
@@ -83,7 +85,7 @@ import com.l2jserver.util.geometry.Point3D;
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
*/
|
||||
@Depends({ WorldService.class, ChatService.class, NetworkService.class,
|
||||
SpawnService.class })
|
||||
SpawnService.class, AttackService.class, GameGuardService.class })
|
||||
public class CharacterServiceImpl extends AbstractService implements
|
||||
CharacterService {
|
||||
/**
|
||||
@@ -152,6 +154,9 @@ public class CharacterServiceImpl extends AbstractService implements
|
||||
itemDao.loadInventory(character);
|
||||
|
||||
character.setOnline(true);
|
||||
|
||||
// inventory interfere on calculators
|
||||
character.getStats().updateCalculators();
|
||||
|
||||
// chat listener
|
||||
final ChatChannelListener globalChatListener = new ChatChannelListener() {
|
||||
@@ -231,6 +236,11 @@ public class CharacterServiceImpl extends AbstractService implements
|
||||
} else if (e instanceof PlayerTeleportedEvent
|
||||
|| e instanceof CharacterEnterWorldEvent) {
|
||||
broadcast(conn, character);
|
||||
} else if (e instanceof ActorAttackHitEvent) {
|
||||
conn.write(new SM_ATTACK(((ActorAttackHitEvent) e).getHit()));
|
||||
conn.sendSystemMessage(SystemMessage.YOU_DID_S1_DMG,
|
||||
(int) ((ActorAttackHitEvent) e).getHit()
|
||||
.getDamage());
|
||||
}
|
||||
// keep listener alive
|
||||
return true;
|
||||
@@ -369,10 +379,6 @@ public class CharacterServiceImpl extends AbstractService implements
|
||||
// check if this Actor can be attacked
|
||||
if (target instanceof NPC) {
|
||||
final NPC npc = (NPC) target;
|
||||
final NPCTemplate template = npc.getTemplate();
|
||||
if (!template.isAttackable()) {
|
||||
throw new ActorIsNotAttackableServiceException();
|
||||
}
|
||||
// first try to target this, if it is not already
|
||||
target(character, target);
|
||||
|
||||
|
||||
@@ -27,9 +27,7 @@ import com.google.inject.Injector;
|
||||
import com.l2jserver.db.dao.NPCDAO;
|
||||
import com.l2jserver.game.net.Lineage2Connection;
|
||||
import com.l2jserver.game.net.packet.client.CM_CHAR_ACTION.CharacterAction;
|
||||
import com.l2jserver.game.net.packet.server.SM_ATTACK;
|
||||
import com.l2jserver.model.server.AttackHit;
|
||||
import com.l2jserver.model.server.AttackHit.AttackHitFlag;
|
||||
import com.l2jserver.model.template.NPCTemplate;
|
||||
import com.l2jserver.model.world.L2Character;
|
||||
import com.l2jserver.model.world.NPC;
|
||||
import com.l2jserver.model.world.NPC.NPCState;
|
||||
@@ -38,6 +36,7 @@ import com.l2jserver.service.AbstractService;
|
||||
import com.l2jserver.service.AbstractService.Depends;
|
||||
import com.l2jserver.service.core.threading.AsyncFuture;
|
||||
import com.l2jserver.service.core.threading.ThreadService;
|
||||
import com.l2jserver.service.game.AttackService;
|
||||
import com.l2jserver.service.game.character.CannotSetTargetServiceException;
|
||||
import com.l2jserver.service.game.character.CharacterService;
|
||||
import com.l2jserver.service.game.spawn.AlreadySpawnedServiceException;
|
||||
@@ -54,7 +53,7 @@ import com.l2jserver.util.geometry.Point3D;
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
*/
|
||||
@Depends({ SpawnService.class, NetworkService.class, CharacterService.class,
|
||||
ThreadService.class })
|
||||
ThreadService.class, AttackService.class })
|
||||
public class NPCServiceImpl extends AbstractService implements NPCService {
|
||||
/**
|
||||
* The {@link SpawnService} used to spawn the {@link NPC} instances
|
||||
@@ -72,6 +71,10 @@ public class NPCServiceImpl extends AbstractService implements NPCService {
|
||||
* The {@link ThreadService}
|
||||
*/
|
||||
private final ThreadService threadService;
|
||||
/**
|
||||
* The {@link AttackService}
|
||||
*/
|
||||
private final AttackService attackService;
|
||||
|
||||
/**
|
||||
* The {@link NPCDAO}
|
||||
@@ -93,11 +96,13 @@ public class NPCServiceImpl extends AbstractService implements NPCService {
|
||||
@Inject
|
||||
public NPCServiceImpl(SpawnService spawnService,
|
||||
NetworkService networkService, CharacterService characterService,
|
||||
ThreadService threadService, NPCDAO npcDao, Injector injector) {
|
||||
ThreadService threadService, AttackService attackService,
|
||||
NPCDAO npcDao, Injector injector) {
|
||||
this.spawnService = spawnService;
|
||||
this.networkService = networkService;
|
||||
this.characterService = characterService;
|
||||
this.threadService = threadService;
|
||||
this.attackService = attackService;
|
||||
this.npcDao = npcDao;
|
||||
this.injector = injector;
|
||||
}
|
||||
@@ -183,9 +188,12 @@ public class NPCServiceImpl extends AbstractService implements NPCService {
|
||||
Preconditions.checkNotNull(conn, "conn");
|
||||
Preconditions.checkNotNull(attacker, "attacker");
|
||||
|
||||
conn.write(new SM_ATTACK(conn.getCharacter(), new AttackHit(
|
||||
conn.getCharacter(), npc, AttackHitFlag.MISS,
|
||||
AttackHitFlag.SOULSHOT)));
|
||||
final NPCTemplate template = npc.getTemplate();
|
||||
if (!template.isAttackable()) {
|
||||
throw new NotAttackableNPCServiceException();
|
||||
}
|
||||
|
||||
attackService.attack(attacker, npc);
|
||||
}
|
||||
|
||||
private NPCController getController(NPC npc) {
|
||||
|
||||
@@ -19,13 +19,14 @@ package com.l2jserver.service.network.gameguard;
|
||||
import java.util.concurrent.Future;
|
||||
|
||||
import com.l2jserver.game.net.Lineage2Connection;
|
||||
import com.l2jserver.service.Service;
|
||||
|
||||
/**
|
||||
* This service is responsible for querying and validating GameGuard packets
|
||||
*
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
*/
|
||||
public interface GameGuardService {
|
||||
public interface GameGuardService extends Service {
|
||||
/**
|
||||
* Queries the client GameGuard for an response
|
||||
*
|
||||
|
||||
@@ -18,7 +18,6 @@ package com.l2jserver.service.network.gameguard;
|
||||
|
||||
import java.security.MessageDigest;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.util.Arrays;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.Future;
|
||||
|
||||
@@ -29,8 +28,10 @@ import com.google.common.util.concurrent.AbstractFuture;
|
||||
import com.l2jserver.game.net.Lineage2Connection;
|
||||
import com.l2jserver.game.net.packet.server.SM_GG_QUERY;
|
||||
import com.l2jserver.service.AbstractService;
|
||||
import com.l2jserver.service.AbstractService.Depends;
|
||||
import com.l2jserver.service.ServiceStartException;
|
||||
import com.l2jserver.service.ServiceStopException;
|
||||
import com.l2jserver.service.network.NetworkService;
|
||||
import com.l2jserver.util.factory.CollectionFactory;
|
||||
|
||||
/**
|
||||
@@ -38,6 +39,7 @@ import com.l2jserver.util.factory.CollectionFactory;
|
||||
*
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
*/
|
||||
@Depends({ NetworkService.class })
|
||||
public class GameGuardServiceImpl extends AbstractService implements
|
||||
GameGuardService {
|
||||
/**
|
||||
@@ -106,9 +108,10 @@ public class GameGuardServiceImpl extends AbstractService implements
|
||||
* @return true if key is valid
|
||||
*/
|
||||
private boolean validate(Lineage2Connection conn, byte[] key) {
|
||||
synchronized (digester) {
|
||||
return Arrays.equals(VALID_KEY_SHA1, digester.digest(key));
|
||||
}
|
||||
// synchronized (digester) {
|
||||
// return Arrays.equals(VALID_KEY_SHA1, digester.digest(key));
|
||||
// }
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -74,6 +74,6 @@ public class XMLMappingTest {
|
||||
final CharacterTemplate t = (CharacterTemplate) u.unmarshal(new File(
|
||||
"data/templates/character/HumanFighter.xml"));
|
||||
System.out.println(t.getID());
|
||||
System.out.println(t.getCharacterClass());
|
||||
System.out.println(t.getBasePhysicalAttack());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,11 +20,11 @@ package com.l2jserver.util.calculator;
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
*
|
||||
*/
|
||||
public abstract class AbstractFunction<T extends CalculatorContext> implements
|
||||
public abstract class AbstractDoubleFunction<T extends CalculatorContext> implements
|
||||
Function<T> {
|
||||
private final int order;
|
||||
|
||||
public AbstractFunction(int order) {
|
||||
public AbstractDoubleFunction(int order) {
|
||||
this.order = order;
|
||||
}
|
||||
|
||||
@@ -22,7 +22,7 @@ package com.l2jserver.util.calculator;
|
||||
*
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
*/
|
||||
public class DivisionFunction extends AbstractFunction<CalculatorContext> {
|
||||
public class DivisionFunction extends AbstractDoubleFunction<CalculatorContext> {
|
||||
/**
|
||||
* The value
|
||||
*/
|
||||
|
||||
@@ -21,7 +21,7 @@ package com.l2jserver.util.calculator;
|
||||
*
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
*/
|
||||
public interface Function<T extends CalculatorContext> {
|
||||
public interface Function<C extends CalculatorContext> {
|
||||
/**
|
||||
* Performs the operation in the calculation process.
|
||||
* <p>
|
||||
@@ -33,7 +33,7 @@ public interface Function<T extends CalculatorContext> {
|
||||
* the input value
|
||||
* @return the output value
|
||||
*/
|
||||
double calculate(T ctx, double value);
|
||||
double calculate(C ctx, double value);
|
||||
|
||||
/**
|
||||
* @return the order this function will be executed
|
||||
|
||||
@@ -22,7 +22,7 @@ package com.l2jserver.util.calculator;
|
||||
*
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
*/
|
||||
public class ModulusFunction extends AbstractFunction<CalculatorContext> {
|
||||
public class ModulusFunction extends AbstractDoubleFunction<CalculatorContext> {
|
||||
public ModulusFunction(int order) {
|
||||
super(order);
|
||||
}
|
||||
|
||||
@@ -22,7 +22,7 @@ package com.l2jserver.util.calculator;
|
||||
*
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
*/
|
||||
public class MultiplicationFunction extends AbstractFunction<CalculatorContext> {
|
||||
public class MultiplicationFunction extends AbstractDoubleFunction<CalculatorContext> {
|
||||
/**
|
||||
* The value
|
||||
*/
|
||||
|
||||
@@ -22,7 +22,7 @@ package com.l2jserver.util.calculator;
|
||||
*
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
*/
|
||||
public class NegateFunction extends AbstractFunction<CalculatorContext> {
|
||||
public class NegateFunction extends AbstractDoubleFunction<CalculatorContext> {
|
||||
public NegateFunction(int order) {
|
||||
super(order);
|
||||
}
|
||||
|
||||
@@ -21,7 +21,7 @@ package com.l2jserver.util.calculator;
|
||||
*
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
*/
|
||||
public class RoundFunction extends AbstractFunction<CalculatorContext> {
|
||||
public class RoundFunction extends AbstractDoubleFunction<CalculatorContext> {
|
||||
public RoundFunction(int order) {
|
||||
super(order);
|
||||
}
|
||||
|
||||
@@ -21,7 +21,7 @@ package com.l2jserver.util.calculator;
|
||||
*
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
*/
|
||||
public class SetFunction extends AbstractFunction<CalculatorContext> {
|
||||
public class SetFunction extends AbstractDoubleFunction<CalculatorContext> {
|
||||
/**
|
||||
* The value
|
||||
*/
|
||||
|
||||
@@ -16,11 +16,8 @@
|
||||
*/
|
||||
package com.l2jserver.util.calculator;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.Arrays;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
|
||||
import com.l2jserver.util.factory.CollectionFactory;
|
||||
|
||||
/**
|
||||
* An calculator is used to compute data and outputs its result. Note also, that
|
||||
@@ -28,20 +25,21 @@ import com.l2jserver.util.factory.CollectionFactory;
|
||||
*
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
*/
|
||||
public class Calculator<T extends CalculatorContext> extends
|
||||
AbstractFunction<T> {
|
||||
public class SimpleCalculator<T extends CalculatorContext> extends
|
||||
AbstractDoubleFunction<T> {
|
||||
/**
|
||||
* List of operations in this calculator
|
||||
*/
|
||||
private final List<Function<? super T>> functions = CollectionFactory
|
||||
.newList();
|
||||
private Function<? super T>[] functions;
|
||||
|
||||
/**
|
||||
* Creates a new empty calculator. Functions can be add using
|
||||
* {@link #add(int, Function)}.
|
||||
*/
|
||||
public Calculator() {
|
||||
@SuppressWarnings("unchecked")
|
||||
public SimpleCalculator() {
|
||||
super(0x00);
|
||||
functions = new Function[0];
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -51,11 +49,9 @@ public class Calculator<T extends CalculatorContext> extends
|
||||
* @param functions
|
||||
* the calculator functions
|
||||
*/
|
||||
public Calculator(Function<? super T>... functions) {
|
||||
public SimpleCalculator(Function<? super T>... functions) {
|
||||
super(0x00);
|
||||
for (final Function<? super T> func : functions) {
|
||||
this.functions.add(func);
|
||||
}
|
||||
this.functions = functions;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -70,8 +66,9 @@ public class Calculator<T extends CalculatorContext> extends
|
||||
* the operation
|
||||
*/
|
||||
public void add(Function<? super T> function) {
|
||||
functions.add(function);
|
||||
Collections.sort(functions, FunctionOrderComparator.SHARED_INSTANCE);
|
||||
functions = Arrays.copyOf(functions, functions.length + 1);
|
||||
functions[functions.length - 1] = function;
|
||||
Arrays.sort(functions, FunctionOrderComparator.SHARED_INSTANCE);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -84,12 +81,12 @@ public class Calculator<T extends CalculatorContext> extends
|
||||
* @param calculator
|
||||
* the calculator
|
||||
*/
|
||||
public void importFunctions(Calculator<? super T> calculator) {
|
||||
public void importFunctions(SimpleCalculator<? super T> calculator) {
|
||||
for (final Function<? super T> function : calculator.functions) {
|
||||
if (function instanceof Calculator) {
|
||||
importFunctions((Calculator<? super T>) function);
|
||||
if (function instanceof SimpleCalculator) {
|
||||
importFunctions((SimpleCalculator<? super T>) function);
|
||||
} else {
|
||||
functions.add(function);
|
||||
add(function);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -102,12 +99,13 @@ public class Calculator<T extends CalculatorContext> extends
|
||||
* @param calculator
|
||||
* the calculator
|
||||
*/
|
||||
public void removeFunctions(Calculator<? super T> calculator) {
|
||||
public void removeFunctions(SimpleCalculator<? super T> calculator) {
|
||||
for (final Function<? super T> function : calculator.functions) {
|
||||
if (function instanceof Calculator) {
|
||||
removeFunctions((Calculator<? super T>) function);
|
||||
if (function instanceof SimpleCalculator) {
|
||||
removeFunctions((SimpleCalculator<? super T>) function);
|
||||
} else {
|
||||
functions.remove(function);
|
||||
// TODO
|
||||
// remove(function);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -22,7 +22,7 @@ package com.l2jserver.util.calculator;
|
||||
*
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
*/
|
||||
public class SubtractFunction extends AbstractFunction<CalculatorContext> {
|
||||
public class SubtractFunction extends AbstractDoubleFunction<CalculatorContext> {
|
||||
/**
|
||||
* The value
|
||||
*/
|
||||
|
||||
@@ -22,7 +22,7 @@ package com.l2jserver.util.calculator;
|
||||
*
|
||||
* @author <a href="http://www.rogiel.com">Rogiel</a>
|
||||
*/
|
||||
public class SumFunction extends AbstractFunction<CalculatorContext> {
|
||||
public class SumFunction extends AbstractDoubleFunction<CalculatorContext> {
|
||||
/**
|
||||
* The value
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user