1
0
mirror of https://github.com/Rogiel/l2jserver2 synced 2025-12-09 17:02:53 +00:00

Event dispatcher changes and packet implementations

Signed-off-by: Rogiel <rogiel@rogiel.com>
This commit is contained in:
2011-05-19 13:08:32 -03:00
parent 2c4af6d91d
commit 2d1181483a
77 changed files with 796 additions and 519 deletions

View File

@@ -19,13 +19,16 @@ package com.l2jserver.model.template;
import com.google.inject.Inject;
import com.l2jserver.game.net.Lineage2Connection;
import com.l2jserver.game.net.packet.client.CharacterActionPacket.CharacterAction;
import com.l2jserver.model.id.template.ItemTemplateID;
import com.l2jserver.model.id.template.NPCTemplateID;
import com.l2jserver.model.id.template.provider.ItemTemplateIDProvider;
import com.l2jserver.model.world.AbstractActor.Race;
import com.l2jserver.model.world.L2Character;
import com.l2jserver.model.world.NPC;
import com.l2jserver.model.world.capability.Actor;
import com.l2jserver.service.game.CharacterService;
import com.l2jserver.service.network.NetworkService;
import com.l2jserver.util.calculator.Calculator;
/**
* Template for {@link NPC}
@@ -33,22 +36,52 @@ import com.l2jserver.service.network.NetworkService;
* @author <a href="http://www.rogiel.com">Rogiel</a>
*/
public abstract class NPCTemplate extends ActorTemplate<NPC> {
/**
* The {@link NetworkService}
*/
@Inject
protected NetworkService networkService;
/**
* The {@link CharacterService}
*/
@Inject
protected CharacterService charService;
/**
* The {@link ItemTemplateID} provider
*/
@Inject
protected ItemTemplateIDProvider itemTemplateIdProvider;
/**
* The NPC name
*/
protected String name = null;
/**
* The NPC title
*/
protected String title = null;
/**
* The attackable state of the NPC
*/
protected boolean attackable = false;
/**
* The movement speed multiplier
*/
protected double movementSpeedMultiplier = 1.0;
/**
* The attack speed multiplier
*/
protected double attackSpeedMultiplier = 1.0;
/**
* The collision radius
*/
protected double collisionRadius = 0;
protected double collisionHeigth = 0;
/**
* The collision height
*/
protected double collisionHeight = 0;
protected int maxHp;
@@ -70,10 +103,23 @@ public abstract class NPCTemplate extends ActorTemplate<NPC> {
.getID());
if (conn == null)
return;
System.out.println(action);
charService.target(character, npc);
}
/**
* Receives an attack from an {@link Actor}
*
* @param npc
* the {@link NPC} being attacked
* @param calculator
* the calculator
* @param attacker
* the attacker actor
*/
public void receiveAttack(NPC npc, Calculator calculator, Actor attacker) {
// TODO add attributes to calculator!
}
@Override
public NPC createInstance() {
return new NPC(this.getID());
@@ -122,10 +168,10 @@ public abstract class NPCTemplate extends ActorTemplate<NPC> {
}
/**
* @return the collisionHeigth
* @return the collisionHeight
*/
public double getCollisionHeigth() {
return collisionHeigth;
public double getCollisionHeight() {
return collisionHeight;
}
/**

View File

@@ -26,8 +26,8 @@ import com.l2jserver.model.world.Item;
import com.l2jserver.model.world.character.CharacterInventory.InventoryPaperdoll;
import com.l2jserver.util.calculator.Calculator;
import com.l2jserver.util.calculator.DivisionFunction;
import com.l2jserver.util.calculator.MultiplicationFunction;
import com.l2jserver.util.calculator.Function;
import com.l2jserver.util.calculator.MultiplicationFunction;
import com.l2jserver.util.calculator.SetFunction;
import com.l2jserver.util.calculator.SubtractFunction;
import com.l2jserver.util.calculator.SumFunction;
@@ -152,7 +152,7 @@ public abstract class WeaponTemplate extends ItemTemplate implements Attackable
*/
public class WeaponAttribute {
private final Map<WeaponAttributeType, Map<Integer, Function<Double>>> operations = CollectionFactory
.newMap(null, null);
.newMap();
/**
* Sets the result of an calculator
@@ -248,7 +248,7 @@ public abstract class WeaponTemplate extends ItemTemplate implements Attackable
private Map<Integer, Function<Double>> getMap(WeaponAttributeType type) {
Map<Integer, Function<Double>> map = operations.get(type);
if (map == null) {
map = CollectionFactory.newMap(null, null);
map = CollectionFactory.newMap();
operations.put(type, map);
}
return map;