Addition of CreatureState enum and cast fix.
This commit is contained in:
parent
9df81f0aa6
commit
85ff555dcf
@ -0,0 +1,33 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program 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 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program 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 this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
package org.l2jmobius.gameserver.enums;
|
||||
|
||||
/**
|
||||
* @author Mobius
|
||||
*/
|
||||
public enum CreatureState
|
||||
{
|
||||
IDLE,
|
||||
PICKUP_ITEM,
|
||||
CASTING,
|
||||
RESTING,
|
||||
ATTACKING,
|
||||
RANDOM_WALK,
|
||||
INTERACT,
|
||||
FOLLOW,
|
||||
}
|
@ -26,21 +26,14 @@ import org.l2jmobius.gameserver.network.serverpackets.SystemMessage;
|
||||
|
||||
public class DamageSkill implements ISkillHandler
|
||||
{
|
||||
public static final int POWER_STRIKE = 3;
|
||||
public static final int WIND_STRIKE = 1177;
|
||||
public static final int FLAME_STRIKE = 1181;
|
||||
public static final int MORTAL_BLOW = 16;
|
||||
public static final int POWER_SHOT = 56;
|
||||
public static final int IRON_PUNCH = 29;
|
||||
|
||||
private static int[] _skillIds = new int[]
|
||||
{
|
||||
3,
|
||||
1177,
|
||||
1181,
|
||||
16,
|
||||
56,
|
||||
29
|
||||
3, // Power Strike
|
||||
16, // Mortal Blow
|
||||
29, // Iron Punch
|
||||
56, // Power Shot
|
||||
1177, // Wind Strike
|
||||
1181, // Flame Strike
|
||||
};
|
||||
|
||||
@Override
|
||||
@ -48,8 +41,8 @@ public class DamageSkill implements ISkillHandler
|
||||
{
|
||||
if (target instanceof Creature)
|
||||
{
|
||||
Creature targetChar = (Creature) target;
|
||||
int mdef = targetChar.getMagicalDefense();
|
||||
Creature creature = (Creature) target;
|
||||
int mdef = creature.getMagicalDefense();
|
||||
if (mdef == 0)
|
||||
{
|
||||
mdef = 350;
|
||||
@ -58,11 +51,11 @@ public class DamageSkill implements ISkillHandler
|
||||
SystemMessage sm = new SystemMessage(35);
|
||||
sm.addNumber(dmg);
|
||||
activeChar.sendPacket(sm);
|
||||
targetChar.reduceCurrentHp(dmg, activeChar);
|
||||
if (targetChar.getCurrentHp() > targetChar.getMaxHp())
|
||||
if (creature.getCurrentHp() > creature.getMaxHp())
|
||||
{
|
||||
targetChar.setCurrentHp(targetChar.getMaxHp());
|
||||
creature.setCurrentHp(creature.getMaxHp());
|
||||
}
|
||||
creature.reduceCurrentHp(dmg, activeChar);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -29,24 +29,16 @@ import org.l2jmobius.gameserver.network.serverpackets.SystemMessage;
|
||||
|
||||
public class HealSkill implements ISkillHandler
|
||||
{
|
||||
private static final int SELF_HEAL = 1216;
|
||||
private static final int DEVINE_HEAL = 45;
|
||||
private static final int ELEMENTAL_HEAL = 58;
|
||||
private static final int HEAL = 1011;
|
||||
private static final int BATTLE_HEAL = 1015;
|
||||
private static final int GROUP_HEAL = 1027;
|
||||
private static final int SERVITOR_HEAL = 1127;
|
||||
private static final int GREATER_GROUP_HEAL = 1219;
|
||||
private static int[] _skillIds = new int[]
|
||||
{
|
||||
SELF_HEAL,
|
||||
DEVINE_HEAL,
|
||||
ELEMENTAL_HEAL,
|
||||
HEAL,
|
||||
BATTLE_HEAL,
|
||||
GROUP_HEAL,
|
||||
SERVITOR_HEAL,
|
||||
GREATER_GROUP_HEAL
|
||||
45, // Divine Heal
|
||||
58, // Elemental Heal
|
||||
1011, // Heal
|
||||
1015, // Battle Heal
|
||||
1027, // Group Heal
|
||||
1127, // Servitor Heal
|
||||
1216, // Self Heal
|
||||
1219, // Greater Group Heal
|
||||
};
|
||||
|
||||
@Override
|
||||
|
@ -29,6 +29,7 @@ import java.util.logging.Logger;
|
||||
|
||||
import org.l2jmobius.Config;
|
||||
import org.l2jmobius.gameserver.data.ItemTable;
|
||||
import org.l2jmobius.gameserver.enums.CreatureState;
|
||||
import org.l2jmobius.gameserver.model.DropData;
|
||||
import org.l2jmobius.gameserver.model.Party;
|
||||
import org.l2jmobius.gameserver.model.World;
|
||||
@ -48,7 +49,7 @@ public class Attackable extends NpcInstance
|
||||
// private int _moveRadius;
|
||||
private boolean _active;
|
||||
private AITask _currentAiTask;
|
||||
private AIAttackeTask _currentAIAttackeTask;
|
||||
private AIAttackeTask _currentAIAttackTask;
|
||||
private static Timer _aiTimer = new Timer(true);
|
||||
private static Timer _attackTimer = new Timer(true);
|
||||
private final Map<WorldObject, Integer> _aggroList = new HashMap<>();
|
||||
@ -72,16 +73,12 @@ public class Attackable extends NpcInstance
|
||||
super.onTargetReached();
|
||||
switch (getCurrentState())
|
||||
{
|
||||
case 1:
|
||||
{
|
||||
break;
|
||||
}
|
||||
case 5:
|
||||
case ATTACKING:
|
||||
{
|
||||
startCombat();
|
||||
break;
|
||||
}
|
||||
case 6:
|
||||
case RANDOM_WALK:
|
||||
{
|
||||
randomWalk();
|
||||
break;
|
||||
@ -104,15 +101,15 @@ public class Attackable extends NpcInstance
|
||||
_currentAiTask = new AITask(this);
|
||||
int wait = (10 + Rnd.get(120)) * 1000;
|
||||
_aiTimer.schedule(_currentAiTask, wait);
|
||||
setCurrentState((byte) 6);
|
||||
setCurrentState(CreatureState.RANDOM_WALK);
|
||||
}
|
||||
|
||||
protected synchronized void startTargetScan()
|
||||
{
|
||||
if ((_currentAIAttackeTask == null) && (getTarget() == null))
|
||||
if ((_currentAIAttackTask == null) && (getTarget() == null))
|
||||
{
|
||||
_currentAIAttackeTask = new AIAttackeTask(this);
|
||||
_attackTimer.scheduleAtFixedRate(_currentAIAttackeTask, 100L, 1000L);
|
||||
_currentAIAttackTask = new AIAttackeTask(this);
|
||||
_attackTimer.scheduleAtFixedRate(_currentAIAttackTask, 100L, 1000L);
|
||||
}
|
||||
}
|
||||
|
||||
@ -326,15 +323,15 @@ public class Attackable extends NpcInstance
|
||||
|
||||
protected boolean isTargetScanActive()
|
||||
{
|
||||
return _currentAIAttackeTask != null;
|
||||
return _currentAIAttackTask != null;
|
||||
}
|
||||
|
||||
protected synchronized void stopTargetScan()
|
||||
{
|
||||
if (_currentAIAttackeTask != null)
|
||||
if (_currentAIAttackTask != null)
|
||||
{
|
||||
_currentAIAttackeTask.cancel();
|
||||
_currentAIAttackeTask = null;
|
||||
_currentAIAttackTask.cancel();
|
||||
_currentAIAttackTask = null;
|
||||
}
|
||||
}
|
||||
|
||||
@ -430,9 +427,9 @@ public class Attackable extends NpcInstance
|
||||
startAttack(player);
|
||||
}
|
||||
}
|
||||
else if (_currentAIAttackeTask != null)
|
||||
else if (_currentAIAttackTask != null)
|
||||
{
|
||||
_currentAIAttackeTask.cancel();
|
||||
_currentAIAttackTask.cancel();
|
||||
}
|
||||
}
|
||||
catch (Throwable e)
|
||||
|
@ -27,6 +27,7 @@ import java.util.Timer;
|
||||
import java.util.TimerTask;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import org.l2jmobius.gameserver.enums.CreatureState;
|
||||
import org.l2jmobius.gameserver.model.World;
|
||||
import org.l2jmobius.gameserver.model.WorldObject;
|
||||
import org.l2jmobius.gameserver.model.actor.instance.NpcInstance;
|
||||
@ -119,15 +120,7 @@ public abstract class Creature extends WorldObject
|
||||
private double _collisionHeight;
|
||||
private WorldObject _target;
|
||||
private int _activeSoulShotGrade;
|
||||
private byte _currentState = 0;
|
||||
public static final byte STATE_IDLE = 0;
|
||||
public static final byte STATE_PICKUP_ITEM = 1;
|
||||
public static final byte STATE_CASTING = 2;
|
||||
public static final byte STATE_RESTING = 3;
|
||||
public static final byte STATE_ATTACKING = 5;
|
||||
public static final byte STATE_RANDOM_WALK = 6;
|
||||
public static final byte STATE_INTERACT = 7;
|
||||
public static final byte STATE_FOLLOW = 8;
|
||||
private CreatureState _currentState = CreatureState.IDLE;
|
||||
private boolean _inCombat;
|
||||
private boolean _moving;
|
||||
private boolean _movingToPawn;
|
||||
@ -663,12 +656,12 @@ public abstract class Creature extends WorldObject
|
||||
return _target;
|
||||
}
|
||||
|
||||
public byte getCurrentState()
|
||||
public CreatureState getCurrentState()
|
||||
{
|
||||
return _currentState;
|
||||
}
|
||||
|
||||
public void setCurrentState(byte currentState)
|
||||
public void setCurrentState(CreatureState currentState)
|
||||
{
|
||||
_currentState = currentState;
|
||||
}
|
||||
@ -800,12 +793,16 @@ public abstract class Creature extends WorldObject
|
||||
broadcastStatusUpdate();
|
||||
}
|
||||
|
||||
public void reduceCurrentHp(int i, Creature attacker)
|
||||
public void reduceCurrentHp(int amount, Creature attacker)
|
||||
{
|
||||
Object object = _hpLock;
|
||||
synchronized (object)
|
||||
synchronized (_hpLock)
|
||||
{
|
||||
_currentHp -= i;
|
||||
if (!_hpRegenActive)
|
||||
{
|
||||
startHpRegeneration();
|
||||
}
|
||||
|
||||
_currentHp -= amount;
|
||||
if (_currentHp <= 0.0)
|
||||
{
|
||||
_currentHp = 0.0;
|
||||
@ -823,7 +820,6 @@ public abstract class Creature extends WorldObject
|
||||
{
|
||||
_currentMoveTask.cancel();
|
||||
}
|
||||
broadcastStatusUpdate();
|
||||
StopMove stop = new StopMove(this);
|
||||
Die die = new Die(this);
|
||||
broadcastPacket(stop);
|
||||
@ -834,11 +830,6 @@ public abstract class Creature extends WorldObject
|
||||
{
|
||||
attacker.setTarget(null);
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (!_hpRegenActive)
|
||||
{
|
||||
startHpRegeneration();
|
||||
}
|
||||
}
|
||||
broadcastStatusUpdate();
|
||||
@ -859,9 +850,9 @@ public abstract class Creature extends WorldObject
|
||||
}
|
||||
calculateMovement(x, y, z, distance);
|
||||
CharMoveToLocation mov = new CharMoveToLocation(this);
|
||||
if (getCurrentState() == 2)
|
||||
if (getCurrentState() == CreatureState.CASTING)
|
||||
{
|
||||
setCurrentState((byte) 0);
|
||||
setCurrentState(CreatureState.IDLE);
|
||||
}
|
||||
enableAllSkills();
|
||||
broadcastPacket(mov);
|
||||
@ -902,7 +893,7 @@ public abstract class Creature extends WorldObject
|
||||
{
|
||||
stopMove();
|
||||
}
|
||||
if ((getPawnTarget() != null) && (distance <= getAttackRange()) && (getCurrentState() == 8))
|
||||
if ((getPawnTarget() != null) && (distance <= getAttackRange()) && (getCurrentState() == CreatureState.FOLLOW))
|
||||
{
|
||||
ArriveTask newMoveTask = new ArriveTask(this);
|
||||
_moveTimer.schedule(newMoveTask, 3000L);
|
||||
@ -951,7 +942,7 @@ public abstract class Creature extends WorldObject
|
||||
ArriveTask newMoveTask = new ArriveTask(this);
|
||||
if (getPawnTarget() != null)
|
||||
{
|
||||
if (getCurrentState() == 7)
|
||||
if (getCurrentState() == CreatureState.INTERACT)
|
||||
{
|
||||
_moveTimer.schedule(newMoveTask, _timeToTarget);
|
||||
_currentMoveTask = newMoveTask;
|
||||
@ -1033,12 +1024,12 @@ public abstract class Creature extends WorldObject
|
||||
int y = getPawnTarget().getY();
|
||||
int z = getPawnTarget().getZ();
|
||||
double distance = getDistance(x, y);
|
||||
if (getCurrentState() == 8)
|
||||
if (getCurrentState() == CreatureState.FOLLOW)
|
||||
{
|
||||
calculateMovement(x, y, z, distance);
|
||||
return;
|
||||
}
|
||||
if (((distance > getAttackRange()) && (getCurrentState() == 5)) || (getPawnTarget().isMoving() && (getCurrentState() != 5)))
|
||||
if (((distance > getAttackRange()) && (getCurrentState() == CreatureState.ATTACKING)) || (getPawnTarget().isMoving() && (getCurrentState() != CreatureState.ATTACKING)))
|
||||
{
|
||||
calculateMovement(x, y, z, distance);
|
||||
return;
|
||||
@ -1061,7 +1052,7 @@ public abstract class Creature extends WorldObject
|
||||
setHeading(heading);
|
||||
if (isMoving())
|
||||
{
|
||||
setCurrentState((byte) 0);
|
||||
setCurrentState(CreatureState.IDLE);
|
||||
setto = new StopMove(this);
|
||||
broadcastPacket(setto);
|
||||
}
|
||||
@ -1096,10 +1087,10 @@ public abstract class Creature extends WorldObject
|
||||
{
|
||||
_currentAttackTask = null;
|
||||
Creature target = (Creature) _attackTarget;
|
||||
if (isDead() || (target == null) || target.isDead() || ((getCurrentState() != 5) && (getCurrentState() != 2)) || !target.knownsObject(this) || !knownsObject(target))
|
||||
if (isDead() || (target == null) || target.isDead() || ((getCurrentState() != CreatureState.ATTACKING) && (getCurrentState() != CreatureState.CASTING)) || !target.knownsObject(this) || !knownsObject(target))
|
||||
{
|
||||
setInCombat(false);
|
||||
setCurrentState((byte) 0);
|
||||
setCurrentState(CreatureState.IDLE);
|
||||
ActionFailed af = new ActionFailed();
|
||||
sendPacket(af);
|
||||
return;
|
||||
@ -1107,7 +1098,7 @@ public abstract class Creature extends WorldObject
|
||||
if ((getActiveWeapon().getWeaponType() == 5) && !checkAndEquipArrows())
|
||||
{
|
||||
setInCombat(false);
|
||||
setCurrentState((byte) 0);
|
||||
setCurrentState(CreatureState.IDLE);
|
||||
ActionFailed af = new ActionFailed();
|
||||
sendPacket(af);
|
||||
sendPacket(new SystemMessage(112));
|
||||
@ -1119,13 +1110,13 @@ public abstract class Creature extends WorldObject
|
||||
moveTo(_attackTarget.getX(), _attackTarget.getY(), _attackTarget.getZ(), getAttackRange());
|
||||
return;
|
||||
}
|
||||
if ((getCurrentState() == 5) && !_currentlyAttacking)
|
||||
if ((getCurrentState() == CreatureState.ATTACKING) && !_currentlyAttacking)
|
||||
{
|
||||
Weapon weaponItem = getActiveWeapon();
|
||||
if (weaponItem == null)
|
||||
{
|
||||
setInCombat(false);
|
||||
setCurrentState((byte) 0);
|
||||
setCurrentState(CreatureState.IDLE);
|
||||
ActionFailed af = new ActionFailed();
|
||||
sendPacket(af);
|
||||
return;
|
||||
@ -1183,7 +1174,7 @@ public abstract class Creature extends WorldObject
|
||||
{
|
||||
sendPacket(new SystemMessage(24));
|
||||
setInCombat(false);
|
||||
setCurrentState((byte) 0);
|
||||
setCurrentState(CreatureState.IDLE);
|
||||
ActionFailed af = new ActionFailed();
|
||||
sendPacket(af);
|
||||
return;
|
||||
@ -1223,7 +1214,7 @@ public abstract class Creature extends WorldObject
|
||||
{
|
||||
setInCombat(false);
|
||||
setTarget(null);
|
||||
setCurrentState((byte) 0);
|
||||
setCurrentState(CreatureState.IDLE);
|
||||
ActionFailed af = new ActionFailed();
|
||||
sendPacket(af);
|
||||
return;
|
||||
@ -1302,14 +1293,14 @@ public abstract class Creature extends WorldObject
|
||||
if (target == null)
|
||||
{
|
||||
setInCombat(false);
|
||||
setCurrentState((byte) 0);
|
||||
setCurrentState(CreatureState.IDLE);
|
||||
ActionFailed af = new ActionFailed();
|
||||
sendPacket(af);
|
||||
return;
|
||||
}
|
||||
setTarget(target);
|
||||
_attackTarget = target;
|
||||
setCurrentState((byte) 5);
|
||||
setCurrentState(CreatureState.ATTACKING);
|
||||
moveTo(target.getX(), target.getY(), target.getZ(), getAttackRange());
|
||||
}
|
||||
|
||||
@ -1466,8 +1457,7 @@ public abstract class Creature extends WorldObject
|
||||
{
|
||||
try
|
||||
{
|
||||
Object object = _hpLock;
|
||||
synchronized (object)
|
||||
synchronized (_hpLock)
|
||||
{
|
||||
double nowHp = _instance.getCurrentHp();
|
||||
if (_instance.getCurrentHp() < _instance.getMaxHp())
|
||||
|
@ -17,6 +17,7 @@
|
||||
*/
|
||||
package org.l2jmobius.gameserver.model.actor.instance;
|
||||
|
||||
import org.l2jmobius.gameserver.enums.CreatureState;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.ActionFailed;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.CharInfo;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.MyTargetSelected;
|
||||
@ -37,7 +38,7 @@ public class ClassMasterInstance extends NpcInstance
|
||||
{
|
||||
if (getObjectId() != player.getTargetId())
|
||||
{
|
||||
player.setCurrentState((byte) 0);
|
||||
player.setCurrentState(CreatureState.IDLE);
|
||||
player.setTarget(this);
|
||||
MyTargetSelected my = new MyTargetSelected(getObjectId(), player.getLevel() - getLevel());
|
||||
player.sendPacket(my);
|
||||
|
@ -17,6 +17,7 @@
|
||||
*/
|
||||
package org.l2jmobius.gameserver.model.actor.instance;
|
||||
|
||||
import org.l2jmobius.gameserver.enums.CreatureState;
|
||||
import org.l2jmobius.gameserver.model.WorldObject;
|
||||
import org.l2jmobius.gameserver.model.actor.Attackable;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.ActionFailed;
|
||||
@ -35,7 +36,7 @@ public class GuardInstance extends Attackable
|
||||
public GuardInstance(Npc template)
|
||||
{
|
||||
super(template);
|
||||
setCurrentState((byte) 0);
|
||||
setCurrentState(CreatureState.IDLE);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -102,7 +103,7 @@ public class GuardInstance extends Attackable
|
||||
{
|
||||
if (getObjectId() != player.getTargetId())
|
||||
{
|
||||
player.setCurrentState((byte) 0);
|
||||
player.setCurrentState(CreatureState.IDLE);
|
||||
player.setTarget(this);
|
||||
MyTargetSelected my = new MyTargetSelected(getObjectId(), 0);
|
||||
player.sendPacket(my);
|
||||
@ -117,14 +118,14 @@ public class GuardInstance extends Attackable
|
||||
double distance = getDistance(player.getX(), player.getY());
|
||||
if (distance > INTERACTION_DISTANCE)
|
||||
{
|
||||
player.setCurrentState((byte) 7);
|
||||
player.setCurrentState(CreatureState.INTERACT);
|
||||
player.moveTo(getX(), getY(), getZ(), 150);
|
||||
}
|
||||
else
|
||||
{
|
||||
showChatWindow(player, 0);
|
||||
player.sendPacket(new ActionFailed());
|
||||
player.setCurrentState((byte) 0);
|
||||
player.setCurrentState(CreatureState.IDLE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -17,6 +17,7 @@
|
||||
*/
|
||||
package org.l2jmobius.gameserver.model.actor.instance;
|
||||
|
||||
import org.l2jmobius.gameserver.enums.CreatureState;
|
||||
import org.l2jmobius.gameserver.model.WorldObject;
|
||||
import org.l2jmobius.gameserver.templates.EtcItem;
|
||||
import org.l2jmobius.gameserver.templates.Item;
|
||||
@ -109,7 +110,7 @@ public class ItemInstance extends WorldObject
|
||||
@Override
|
||||
public void onAction(PlayerInstance player)
|
||||
{
|
||||
player.setCurrentState((byte) 1);
|
||||
player.setCurrentState(CreatureState.PICKUP_ITEM);
|
||||
player.setTarget(this);
|
||||
player.moveTo(getX(), getY(), getZ(), 0);
|
||||
}
|
||||
|
@ -17,6 +17,7 @@
|
||||
*/
|
||||
package org.l2jmobius.gameserver.model.actor.instance;
|
||||
|
||||
import org.l2jmobius.gameserver.enums.CreatureState;
|
||||
import org.l2jmobius.gameserver.model.WorldObject;
|
||||
import org.l2jmobius.gameserver.model.actor.Attackable;
|
||||
import org.l2jmobius.gameserver.model.actor.Creature;
|
||||
@ -28,7 +29,7 @@ public class MonsterInstance extends Attackable
|
||||
{
|
||||
super(template);
|
||||
// this.setMoveRadius(2000);
|
||||
setCurrentState((byte) 6);
|
||||
setCurrentState(CreatureState.RANDOM_WALK);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -70,7 +71,7 @@ public class MonsterInstance extends Attackable
|
||||
}
|
||||
return;
|
||||
}
|
||||
if ((getCurrentState() != 6) && !isDead() && (getTarget() == null))
|
||||
if ((getCurrentState() != CreatureState.RANDOM_WALK) && !isDead() && (getTarget() == null))
|
||||
{
|
||||
startRandomWalking();
|
||||
if (isAggressive())
|
||||
|
@ -23,6 +23,7 @@ import java.util.Timer;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import org.l2jmobius.Config;
|
||||
import org.l2jmobius.gameserver.enums.CreatureState;
|
||||
import org.l2jmobius.gameserver.model.Spawn;
|
||||
import org.l2jmobius.gameserver.model.World;
|
||||
import org.l2jmobius.gameserver.model.actor.Creature;
|
||||
@ -121,11 +122,11 @@ public class NpcInstance extends Creature
|
||||
{
|
||||
if (this != player.getTarget())
|
||||
{
|
||||
if (player.getCurrentState() == 2)
|
||||
if (player.getCurrentState() == CreatureState.CASTING)
|
||||
{
|
||||
player.cancelCastMagic();
|
||||
}
|
||||
player.setCurrentState((byte) 0);
|
||||
player.setCurrentState(CreatureState.IDLE);
|
||||
player.setTarget(this);
|
||||
MyTargetSelected my = new MyTargetSelected(getObjectId(), player.getLevel() - getLevel());
|
||||
player.sendPacket(my);
|
||||
@ -149,7 +150,7 @@ public class NpcInstance extends Creature
|
||||
double distance = getDistance(player.getX(), player.getY());
|
||||
if (distance > INTERACTION_DISTANCE)
|
||||
{
|
||||
player.setCurrentState((byte) 7);
|
||||
player.setCurrentState(CreatureState.INTERACT);
|
||||
player.setInteractTarget(this);
|
||||
player.moveTo(getX(), getY(), getZ(), 150);
|
||||
}
|
||||
@ -157,7 +158,7 @@ public class NpcInstance extends Creature
|
||||
{
|
||||
showChatWindow(player, 0);
|
||||
player.sendPacket(new ActionFailed());
|
||||
player.setCurrentState((byte) 0);
|
||||
player.setCurrentState(CreatureState.IDLE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -21,6 +21,7 @@ import java.util.Timer;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import org.l2jmobius.gameserver.data.ExperienceTable;
|
||||
import org.l2jmobius.gameserver.enums.CreatureState;
|
||||
import org.l2jmobius.gameserver.model.Inventory;
|
||||
import org.l2jmobius.gameserver.model.World;
|
||||
import org.l2jmobius.gameserver.model.WorldObject;
|
||||
@ -74,7 +75,7 @@ public class PetInstance extends Creature
|
||||
{
|
||||
setCollisionHeight(template.getHeight());
|
||||
setCollisionRadius(template.getRadius());
|
||||
setCurrentState((byte) 0);
|
||||
setCurrentState(CreatureState.IDLE);
|
||||
setPhysicalAttack(9999);
|
||||
_template = template;
|
||||
}
|
||||
@ -88,7 +89,7 @@ public class PetInstance extends Creature
|
||||
player.sendPacket(new PetStatusUpdate(this));
|
||||
player.sendPacket(new ActionFailed());
|
||||
}
|
||||
player.setCurrentState((byte) 0);
|
||||
player.setCurrentState(CreatureState.IDLE);
|
||||
player.setTarget(this);
|
||||
MyTargetSelected my = new MyTargetSelected(getObjectId(), player.getLevel() - getLevel());
|
||||
player.sendPacket(my);
|
||||
@ -283,7 +284,7 @@ public class PetInstance extends Creature
|
||||
|
||||
public void followOwner(PlayerInstance owner)
|
||||
{
|
||||
setCurrentState((byte) 8);
|
||||
setCurrentState(CreatureState.FOLLOW);
|
||||
setTarget(owner);
|
||||
moveTo(owner.getX(), owner.getY(), owner.getZ(), 30);
|
||||
broadcastPacket(new PetStatusUpdate(this));
|
||||
@ -298,12 +299,12 @@ public class PetInstance extends Creature
|
||||
{
|
||||
switch (getCurrentState())
|
||||
{
|
||||
case 1:
|
||||
case PICKUP_ITEM:
|
||||
{
|
||||
doPickupItem();
|
||||
break;
|
||||
}
|
||||
case 5:
|
||||
case ATTACKING:
|
||||
{
|
||||
startCombat();
|
||||
break;
|
||||
@ -364,7 +365,7 @@ public class PetInstance extends Creature
|
||||
if (!pickupOk)
|
||||
{
|
||||
_owner.sendPacket(new ActionFailed());
|
||||
setCurrentState((byte) 0);
|
||||
setCurrentState(CreatureState.IDLE);
|
||||
return;
|
||||
}
|
||||
GetItem gi = new GetItem(target, getObjectId());
|
||||
@ -375,7 +376,7 @@ public class PetInstance extends Creature
|
||||
getInventory().addItem(target);
|
||||
PetItemList iu = new PetItemList(this);
|
||||
_owner.sendPacket(iu);
|
||||
setCurrentState((byte) 0);
|
||||
setCurrentState(CreatureState.IDLE);
|
||||
if (getFollowStatus())
|
||||
{
|
||||
followOwner(_owner);
|
||||
|
@ -32,6 +32,7 @@ import org.l2jmobius.gameserver.data.ExperienceTable;
|
||||
import org.l2jmobius.gameserver.data.ItemTable;
|
||||
import org.l2jmobius.gameserver.data.LevelUpData;
|
||||
import org.l2jmobius.gameserver.data.SkillTable;
|
||||
import org.l2jmobius.gameserver.enums.CreatureState;
|
||||
import org.l2jmobius.gameserver.handler.ISkillHandler;
|
||||
import org.l2jmobius.gameserver.handler.SkillHandler;
|
||||
import org.l2jmobius.gameserver.managers.GmListManager;
|
||||
@ -511,10 +512,10 @@ public class PlayerInstance extends Creature
|
||||
}
|
||||
else
|
||||
{
|
||||
player.setCurrentState((byte) 8);
|
||||
player.setCurrentState(CreatureState.FOLLOW);
|
||||
if (getPrivateStoreType() != 0)
|
||||
{
|
||||
player.setCurrentState((byte) 7);
|
||||
player.setCurrentState(CreatureState.INTERACT);
|
||||
}
|
||||
player.moveTo(getX(), getY(), getZ(), 36);
|
||||
}
|
||||
@ -613,21 +614,21 @@ public class PlayerInstance extends Creature
|
||||
{
|
||||
switch (getCurrentState())
|
||||
{
|
||||
case 1:
|
||||
case PICKUP_ITEM:
|
||||
{
|
||||
doPickupItem();
|
||||
break;
|
||||
}
|
||||
case 5:
|
||||
case ATTACKING:
|
||||
{
|
||||
startCombat();
|
||||
break;
|
||||
}
|
||||
case 2:
|
||||
case CASTING:
|
||||
{
|
||||
useMagic(_skill);
|
||||
}
|
||||
case 7:
|
||||
case INTERACT:
|
||||
{
|
||||
if (getTarget() instanceof PlayerInstance)
|
||||
{
|
||||
@ -641,7 +642,7 @@ public class PlayerInstance extends Creature
|
||||
{
|
||||
sendPacket(new PrivateBuyListBuy(temp, this));
|
||||
}
|
||||
setCurrentState((byte) 0);
|
||||
setCurrentState(CreatureState.IDLE);
|
||||
break;
|
||||
}
|
||||
if (_interactTarget == null)
|
||||
@ -660,7 +661,7 @@ public class PlayerInstance extends Creature
|
||||
|
||||
private void doPickupItem()
|
||||
{
|
||||
setCurrentState((byte) 0);
|
||||
setCurrentState(CreatureState.IDLE);
|
||||
if (!(getTarget() instanceof ItemInstance))
|
||||
{
|
||||
_log.warning("trying to pickup wrong target." + getTarget());
|
||||
@ -735,7 +736,7 @@ public class PlayerInstance extends Creature
|
||||
public void setTarget(WorldObject newTarget)
|
||||
{
|
||||
WorldObject oldTarget;
|
||||
if (getCurrentState() == 2)
|
||||
if (getCurrentState() == CreatureState.CASTING)
|
||||
{
|
||||
cancelCastMagic();
|
||||
}
|
||||
@ -1244,6 +1245,7 @@ public class PlayerInstance extends Creature
|
||||
{
|
||||
Creature target = null;
|
||||
target = getTarget() instanceof Creature ? (Creature) getTarget() : this;
|
||||
|
||||
if ((skill.getTargetType() == Skill.TARGET_SELF) || (skill.getTargetType() == Skill.TARGET_PARTY))
|
||||
{
|
||||
target = this;
|
||||
@ -1256,6 +1258,7 @@ public class PlayerInstance extends Creature
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
int weaponType = getActiveWeapon().getWeaponType();
|
||||
int skillId = skill.getId();
|
||||
if ((skillId == 56) && (weaponType != 5))
|
||||
@ -1274,10 +1277,11 @@ public class PlayerInstance extends Creature
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (SkillHandler.getInstance().getSkillHandler(skill.getId()) == null)
|
||||
{
|
||||
SystemMessage sm = new SystemMessage(614);
|
||||
sm.addString("This skill is not implemented yet");
|
||||
sm.addString("This skill is not implemented yet.");
|
||||
sendPacket(sm);
|
||||
return;
|
||||
}
|
||||
@ -1291,7 +1295,7 @@ public class PlayerInstance extends Creature
|
||||
sendPacket(new SystemMessage(23));
|
||||
return;
|
||||
}
|
||||
setCurrentState((byte) 2);
|
||||
setCurrentState(CreatureState.CASTING);
|
||||
setSkill(skill);
|
||||
double distance = getDistance(target.getX(), target.getY());
|
||||
if ((skill.getCastRange() > 0) && (distance > skill.getCastRange()))
|
||||
@ -1313,10 +1317,10 @@ public class PlayerInstance extends Creature
|
||||
if (skill.getSkillTime() > 300)
|
||||
{
|
||||
disableSkill(skill.getId(), true);
|
||||
_enableSkillTimer.schedule(new EnableSkill(skill.getId()), skill.getReuseDelay());
|
||||
disableAllSkills();
|
||||
_enableAllSkillsTimer.schedule(new EnableAllSkills(skill), skill.getSkillTime());
|
||||
_magicUseTimer.schedule(new MagicUseTask(target, skill), skill.getHitTime());
|
||||
_enableSkillTimer.schedule(new EnableSkill(skill.getId()), skill.getReuseDelay());
|
||||
_enableAllSkillsTimer.schedule(new EnableAllSkills(skill), skill.getSkillTime());
|
||||
}
|
||||
}
|
||||
|
||||
@ -1391,7 +1395,7 @@ public class PlayerInstance extends Creature
|
||||
|
||||
public void onMagicUseTimer(Creature target, Skill skill)
|
||||
{
|
||||
if ((getCurrentState() == 2) && _allSkillsDisabled && isSkillDisabled(skill.getId()) && (getSkill() == skill))
|
||||
if ((getCurrentState() == CreatureState.CASTING) && (getSkill() == skill))
|
||||
{
|
||||
int magicId = skill.getId();
|
||||
int level = getSkillLevel(magicId);
|
||||
@ -1417,13 +1421,13 @@ public class PlayerInstance extends Creature
|
||||
ISkillHandler handler = SkillHandler.getInstance().getSkillHandler(skill.getId());
|
||||
if (handler == null)
|
||||
{
|
||||
_log.warning("no skillhandler registered for skillId:" + skill.getId());
|
||||
_log.warning("No skillhandler registered for skillId: " + skill.getId());
|
||||
}
|
||||
else
|
||||
{
|
||||
handler.useSkill(this, skill, target);
|
||||
}
|
||||
setCurrentState((byte) 0);
|
||||
setCurrentState(CreatureState.IDLE);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1512,7 +1516,7 @@ public class PlayerInstance extends Creature
|
||||
|
||||
public void cancelCastMagic()
|
||||
{
|
||||
setCurrentState((byte) 0);
|
||||
setCurrentState(CreatureState.IDLE);
|
||||
enableAllSkills();
|
||||
MagicSkillCanceld msc = new MagicSkillCanceld(getObjectId());
|
||||
sendPacket(msc);
|
||||
@ -1578,5 +1582,4 @@ public class PlayerInstance extends Creature
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -17,6 +17,7 @@
|
||||
*/
|
||||
package org.l2jmobius.gameserver.network.clientpackets;
|
||||
|
||||
import org.l2jmobius.gameserver.enums.CreatureState;
|
||||
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
|
||||
import org.l2jmobius.gameserver.network.ClientThread;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.ActionFailed;
|
||||
@ -36,20 +37,20 @@ public class MoveBackwardToLocation extends ClientBasePacket
|
||||
int originY = readD();
|
||||
int originZ = readD();
|
||||
PlayerInstance activeChar = client.getActiveChar();
|
||||
if (activeChar.getCurrentState() == 2)
|
||||
if (activeChar.getCurrentState() == CreatureState.CASTING)
|
||||
{
|
||||
activeChar.sendPacket(new ActionFailed());
|
||||
}
|
||||
else
|
||||
{
|
||||
if (activeChar.getCurrentState() == 5)
|
||||
if (activeChar.getCurrentState() == CreatureState.ATTACKING)
|
||||
{
|
||||
AttackCanceld ac = new AttackCanceld(activeChar.getObjectId());
|
||||
activeChar.sendPacket(ac);
|
||||
activeChar.broadcastPacket(ac);
|
||||
}
|
||||
activeChar.setInCombat(false);
|
||||
activeChar.setCurrentState((byte) 0);
|
||||
activeChar.setCurrentState(CreatureState.IDLE);
|
||||
activeChar.setX(originX);
|
||||
activeChar.setY(originY);
|
||||
activeChar.setZ(originZ);
|
||||
|
@ -17,6 +17,7 @@
|
||||
*/
|
||||
package org.l2jmobius.gameserver.network.clientpackets;
|
||||
|
||||
import org.l2jmobius.gameserver.enums.CreatureState;
|
||||
import org.l2jmobius.gameserver.model.actor.Creature;
|
||||
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
|
||||
import org.l2jmobius.gameserver.network.ClientThread;
|
||||
@ -70,14 +71,14 @@ public class RequestActionUse extends ClientBasePacket
|
||||
{
|
||||
break;
|
||||
}
|
||||
if (activeChar.getPet().getCurrentState() != 8)
|
||||
if (activeChar.getPet().getCurrentState() != CreatureState.FOLLOW)
|
||||
{
|
||||
activeChar.getPet().setCurrentState((byte) 8);
|
||||
activeChar.getPet().setCurrentState(CreatureState.FOLLOW);
|
||||
activeChar.getPet().setFollowStatus(true);
|
||||
activeChar.getPet().followOwner(activeChar);
|
||||
break;
|
||||
}
|
||||
activeChar.getPet().setCurrentState((byte) 0);
|
||||
activeChar.getPet().setCurrentState(CreatureState.IDLE);
|
||||
activeChar.getPet().setFollowStatus(false);
|
||||
activeChar.getPet().setMovingToPawn(false);
|
||||
activeChar.getPet().setPawnTarget(null);
|
||||
@ -100,13 +101,13 @@ public class RequestActionUse extends ClientBasePacket
|
||||
{
|
||||
break;
|
||||
}
|
||||
if (activeChar.getPet().getCurrentState() == 8)
|
||||
if (activeChar.getPet().getCurrentState() == CreatureState.FOLLOW)
|
||||
{
|
||||
activeChar.getPet().setFollowStatus(false);
|
||||
activeChar.getPet().setMovingToPawn(false);
|
||||
activeChar.getPet().setPawnTarget(null);
|
||||
}
|
||||
activeChar.getPet().setCurrentState((byte) 0);
|
||||
activeChar.getPet().setCurrentState(CreatureState.IDLE);
|
||||
activeChar.getPet().stopMove();
|
||||
activeChar.getPet().broadcastPacket(new StopMove(activeChar.getPet()));
|
||||
break;
|
||||
|
@ -34,6 +34,7 @@ public class RequestMagicSkillUse extends ClientBasePacket
|
||||
int data2 = readD();
|
||||
@SuppressWarnings("unused")
|
||||
int data3 = readC();
|
||||
|
||||
PlayerInstance activeChar = client.getActiveChar();
|
||||
int level = activeChar.getSkillLevel(magicId);
|
||||
Skill skill = SkillTable.getInstance().getInfo(magicId, level);
|
||||
@ -44,7 +45,7 @@ public class RequestMagicSkillUse extends ClientBasePacket
|
||||
}
|
||||
else
|
||||
{
|
||||
_log.warning("No skill found!!");
|
||||
_log.warning(activeChar + " tried to cast skill " + magicId);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -17,6 +17,7 @@
|
||||
*/
|
||||
package org.l2jmobius.gameserver.network.clientpackets;
|
||||
|
||||
import org.l2jmobius.gameserver.enums.CreatureState;
|
||||
import org.l2jmobius.gameserver.model.World;
|
||||
import org.l2jmobius.gameserver.model.actor.instance.ItemInstance;
|
||||
import org.l2jmobius.gameserver.network.ClientThread;
|
||||
@ -32,7 +33,7 @@ public class RequestPetGetItem extends ClientBasePacket
|
||||
World world = World.getInstance();
|
||||
ItemInstance item = (ItemInstance) world.findObject(objectId);
|
||||
client.getActiveChar().getPet().setTarget(item);
|
||||
client.getActiveChar().getPet().setCurrentState((byte) 1);
|
||||
client.getActiveChar().getPet().setCurrentState(CreatureState.PICKUP_ITEM);
|
||||
client.getActiveChar().getPet().moveTo(item.getX(), item.getY(), item.getZ(), 0);
|
||||
}
|
||||
|
||||
|
@ -17,6 +17,7 @@
|
||||
*/
|
||||
package org.l2jmobius.gameserver.network.clientpackets;
|
||||
|
||||
import org.l2jmobius.gameserver.enums.CreatureState;
|
||||
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
|
||||
import org.l2jmobius.gameserver.network.ClientThread;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.SocialAction;
|
||||
@ -30,7 +31,7 @@ public class RequestSocialAction extends ClientBasePacket
|
||||
super(decrypt);
|
||||
int actionId = readD();
|
||||
PlayerInstance activeChar = client.getActiveChar();
|
||||
if ((activeChar.getPrivateStoreType() == 0) && (activeChar.getTransactionRequester() == null) && (activeChar.getCurrentState() == 0))
|
||||
if ((activeChar.getPrivateStoreType() == 0) && (activeChar.getTransactionRequester() == null) && (activeChar.getCurrentState() == CreatureState.IDLE))
|
||||
{
|
||||
SocialAction atk = new SocialAction(client.getActiveChar().getObjectId(), actionId);
|
||||
activeChar.sendPacket(atk);
|
||||
|
Loading…
Reference in New Issue
Block a user