SkillDat is replaced by SkillUseHolder.

This commit is contained in:
MobiusDevelopment 2020-06-16 23:33:14 +00:00
parent c0261a2539
commit 5934ae15d9
27 changed files with 276 additions and 238 deletions

View File

@ -8451,7 +8451,7 @@ public class PlayerInstance extends Playable
// Do not queue skill if called by an item.
if (item == null)
{
// Create a new SkillDat object and queue it in the player _queuedSkill
// Create a new SkillUseHolder object and queue it in the player _queuedSkill
setQueuedSkill(usedSkill, item, forceUse, dontMove);
}
sendPacket(ActionFailed.STATIC_PACKET);
@ -11146,7 +11146,7 @@ public class PlayerInstance extends Playable
}
/**
* Create a new SkillDat object and queue it in the player _queuedSkill.
* Create a new SkillUseHolder object and queue it in the player _queuedSkill.
* @param queuedSkill
* @param item
* @param ctrlPressed

View File

@ -8458,7 +8458,7 @@ public class PlayerInstance extends Playable
// Do not queue skill if called by an item.
if (item == null)
{
// Create a new SkillDat object and queue it in the player _queuedSkill
// Create a new SkillUseHolder object and queue it in the player _queuedSkill
setQueuedSkill(usedSkill, item, forceUse, dontMove);
}
sendPacket(ActionFailed.STATIC_PACKET);
@ -11153,7 +11153,7 @@ public class PlayerInstance extends Playable
}
/**
* Create a new SkillDat object and queue it in the player _queuedSkill.
* Create a new SkillUseHolder object and queue it in the player _queuedSkill.
* @param queuedSkill
* @param item
* @param ctrlPressed

View File

@ -8460,7 +8460,7 @@ public class PlayerInstance extends Playable
// Do not queue skill if called by an item.
if (item == null)
{
// Create a new SkillDat object and queue it in the player _queuedSkill
// Create a new SkillUseHolder object and queue it in the player _queuedSkill
setQueuedSkill(usedSkill, item, forceUse, dontMove);
}
sendPacket(ActionFailed.STATIC_PACKET);
@ -11155,7 +11155,7 @@ public class PlayerInstance extends Playable
}
/**
* Create a new SkillDat object and queue it in the player _queuedSkill.
* Create a new SkillUseHolder object and queue it in the player _queuedSkill.
* @param queuedSkill
* @param item
* @param ctrlPressed

View File

@ -8455,7 +8455,7 @@ public class PlayerInstance extends Playable
// Do not queue skill if called by an item.
if (item == null)
{
// Create a new SkillDat object and queue it in the player _queuedSkill
// Create a new SkillUseHolder object and queue it in the player _queuedSkill
setQueuedSkill(usedSkill, item, forceUse, dontMove);
}
sendPacket(ActionFailed.STATIC_PACKET);
@ -11136,7 +11136,7 @@ public class PlayerInstance extends Playable
}
/**
* Create a new SkillDat object and queue it in the player _queuedSkill.
* Create a new SkillUseHolder object and queue it in the player _queuedSkill.
* @param queuedSkill
* @param item
* @param ctrlPressed

View File

@ -8438,7 +8438,7 @@ public class PlayerInstance extends Playable
// Do not queue skill if called by an item.
if (item == null)
{
// Create a new SkillDat object and queue it in the player _queuedSkill
// Create a new SkillUseHolder object and queue it in the player _queuedSkill
setQueuedSkill(usedSkill, item, forceUse, dontMove);
}
sendPacket(ActionFailed.STATIC_PACKET);
@ -11123,7 +11123,7 @@ public class PlayerInstance extends Playable
}
/**
* Create a new SkillDat object and queue it in the player _queuedSkill.
* Create a new SkillUseHolder object and queue it in the player _queuedSkill.
* @param queuedSkill
* @param item
* @param ctrlPressed

View File

@ -8438,7 +8438,7 @@ public class PlayerInstance extends Playable
// Do not queue skill if called by an item.
if (item == null)
{
// Create a new SkillDat object and queue it in the player _queuedSkill
// Create a new SkillUseHolder object and queue it in the player _queuedSkill
setQueuedSkill(usedSkill, item, forceUse, dontMove);
}
sendPacket(ActionFailed.STATIC_PACKET);
@ -11126,7 +11126,7 @@ public class PlayerInstance extends Playable
}
/**
* Create a new SkillDat object and queue it in the player _queuedSkill.
* Create a new SkillUseHolder object and queue it in the player _queuedSkill.
* @param queuedSkill
* @param item
* @param ctrlPressed

View File

@ -8439,7 +8439,7 @@ public class PlayerInstance extends Playable
// Do not queue skill if called by an item.
if (item == null)
{
// Create a new SkillDat object and queue it in the player _queuedSkill
// Create a new SkillUseHolder object and queue it in the player _queuedSkill
setQueuedSkill(usedSkill, item, forceUse, dontMove);
}
sendPacket(ActionFailed.STATIC_PACKET);
@ -11132,7 +11132,7 @@ public class PlayerInstance extends Playable
}
/**
* Create a new SkillDat object and queue it in the player _queuedSkill.
* Create a new SkillUseHolder object and queue it in the player _queuedSkill.
* @param queuedSkill
* @param item
* @param ctrlPressed

View File

@ -8420,7 +8420,7 @@ public class PlayerInstance extends Playable
// Do not queue skill if called by an item.
if (item == null)
{
// Create a new SkillDat object and queue it in the player _queuedSkill
// Create a new SkillUseHolder object and queue it in the player _queuedSkill
setQueuedSkill(usedSkill, item, forceUse, dontMove);
}
sendPacket(ActionFailed.STATIC_PACKET);
@ -11104,7 +11104,7 @@ public class PlayerInstance extends Playable
}
/**
* Create a new SkillDat object and queue it in the player _queuedSkill.
* Create a new SkillUseHolder object and queue it in the player _queuedSkill.
* @param queuedSkill
* @param item
* @param ctrlPressed

View File

@ -29,11 +29,11 @@ import org.l2jmobius.gameserver.model.World;
import org.l2jmobius.gameserver.model.actor.Playable;
import org.l2jmobius.gameserver.model.actor.instance.PetInstance;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance.SkillDat;
import org.l2jmobius.gameserver.model.actor.templates.NpcTemplate;
import org.l2jmobius.gameserver.model.entity.event.CTF;
import org.l2jmobius.gameserver.model.entity.event.DM;
import org.l2jmobius.gameserver.model.entity.event.TvT;
import org.l2jmobius.gameserver.model.holders.SkillUseHolder;
import org.l2jmobius.gameserver.model.items.instance.ItemInstance;
import org.l2jmobius.gameserver.model.spawn.Spawn;
import org.l2jmobius.gameserver.network.SystemMessageId;
@ -227,8 +227,8 @@ public class SummonItems implements IItemHandler
{
try
{
final SkillDat skilldat = _player.getCurrentSkill();
if (!_player.isCastingNow() || ((skilldat != null) && (skilldat.getSkillId() != 2046)))
final SkillUseHolder skill = _player.getCurrentSkill();
if (!_player.isCastingNow() || ((skill != null) && (skill.getSkillId() != 2046)))
{
return;
}

View File

@ -73,7 +73,6 @@ import org.l2jmobius.gameserver.model.actor.instance.NpcInstance;
import org.l2jmobius.gameserver.model.actor.instance.NpcWalkerInstance;
import org.l2jmobius.gameserver.model.actor.instance.PetInstance;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance.SkillDat;
import org.l2jmobius.gameserver.model.actor.instance.RaidBossInstance;
import org.l2jmobius.gameserver.model.actor.instance.RiftInvaderInstance;
import org.l2jmobius.gameserver.model.actor.instance.SiegeFlagInstance;
@ -89,6 +88,7 @@ import org.l2jmobius.gameserver.model.entity.event.GameEvent;
import org.l2jmobius.gameserver.model.entity.event.TvT;
import org.l2jmobius.gameserver.model.entity.event.VIP;
import org.l2jmobius.gameserver.model.entity.olympiad.Olympiad;
import org.l2jmobius.gameserver.model.holders.SkillUseHolder;
import org.l2jmobius.gameserver.model.itemcontainer.Inventory;
import org.l2jmobius.gameserver.model.items.Weapon;
import org.l2jmobius.gameserver.model.items.instance.ItemInstance;
@ -7586,11 +7586,11 @@ public abstract class Creature extends WorldObject implements ISkillsHolder
if (this instanceof PlayerInstance)
{
final PlayerInstance currPlayer = (PlayerInstance) this;
final SkillDat skilldat = currPlayer.getCurrentSkill();
final SkillUseHolder skillUseHolder = currPlayer.getCurrentSkill();
// Like L2OFF if the skill is BLOW the player doesn't auto attack
// If on XML skill nextActionAttack = true the char auto attack
// If CTRL is pressed the autoattack is aborted (like L2OFF)
if ((skilldat != null) && !skilldat.isCtrlPressed() && skill.nextActionIsAttack() && (_target != null) && (_target instanceof Creature))
if ((skillUseHolder != null) && !skillUseHolder.isCtrlPressed() && skill.nextActionIsAttack() && (_target != null) && (_target instanceof Creature))
{
getAI().setIntention(AI_INTENTION_ATTACK, _target);
}
@ -7608,8 +7608,8 @@ public abstract class Creature extends WorldObject implements ISkillsHolder
if (this instanceof PlayerInstance)
{
final PlayerInstance currPlayer = (PlayerInstance) this;
final SkillDat skilldat = currPlayer.getCurrentSkill();
if ((skilldat != null) && !skilldat.isCtrlPressed() && (skill.isOffensive()) && (skill.getSkillType() != SkillType.UNLOCK) && (skill.getSkillType() != SkillType.BLOW) && (skill.getSkillType() != SkillType.DELUXE_KEY_UNLOCK) && (skill.getId() != 345) && (skill.getId() != 346))
final SkillUseHolder skillUseHolder = currPlayer.getCurrentSkill();
if ((skillUseHolder != null) && !skillUseHolder.isCtrlPressed() && (skill.isOffensive()) && (skill.getSkillType() != SkillType.UNLOCK) && (skill.getSkillType() != SkillType.BLOW) && (skill.getSkillType() != SkillType.DELUXE_KEY_UNLOCK) && (skill.getId() != 345) && (skill.getId() != 346))
{
if (!skill.isMagic() && skill.nextActionIsAttack())
{
@ -7643,7 +7643,7 @@ public abstract class Creature extends WorldObject implements ISkillsHolder
if (this instanceof PlayerInstance)
{
final PlayerInstance currPlayer = (PlayerInstance) this;
final SkillDat queuedSkill = currPlayer.getQueuedSkill();
final SkillUseHolder queuedSkill = currPlayer.getQueuedSkill();
currPlayer.setCurrentSkill(null, false, false);
if (queuedSkill != null)
{

View File

@ -134,6 +134,7 @@ import org.l2jmobius.gameserver.model.entity.siege.FortSiege;
import org.l2jmobius.gameserver.model.entity.siege.Siege;
import org.l2jmobius.gameserver.model.entity.siege.clanhalls.DevastatedCastle;
import org.l2jmobius.gameserver.model.holders.PlayerStatsHolder;
import org.l2jmobius.gameserver.model.holders.SkillUseHolder;
import org.l2jmobius.gameserver.model.holders.SummonRequestHolder;
import org.l2jmobius.gameserver.model.itemcontainer.Inventory;
import org.l2jmobius.gameserver.model.itemcontainer.ItemContainer;
@ -462,9 +463,9 @@ public class PlayerInstance extends Playable
private final List<String> _validLink = new ArrayList<>();
private Forum _forumMail;
private Forum _forumMemo;
private SkillDat _currentSkill;
private SkillDat _currentPetSkill;
private SkillDat _queuedSkill;
private SkillUseHolder _currentSkill;
private SkillUseHolder _currentPetSkill;
private SkillUseHolder _queuedSkill;
private boolean _isWearingFormalWear = false;
private Location _currentSkillWorldPosition;
private int _reviveRequested = 0;
@ -818,70 +819,6 @@ public class PlayerInstance extends Playable
}
}
/**
* Skill casting information (used to queue when several skills are cast in a short time) *.
*/
public class SkillDat
{
/** The _skill. */
private final Skill _skill;
/** The _ctrl pressed. */
private final boolean _ctrlPressed;
/** The _shift pressed. */
private final boolean _shiftPressed;
/**
* Instantiates a new skill dat.
* @param skill the skill
* @param ctrlPressed the ctrl pressed
* @param shiftPressed the shift pressed
*/
protected SkillDat(Skill skill, boolean ctrlPressed, boolean shiftPressed)
{
_skill = skill;
_ctrlPressed = ctrlPressed;
_shiftPressed = shiftPressed;
}
/**
* Checks if is ctrl pressed.
* @return true, if is ctrl pressed
*/
public boolean isCtrlPressed()
{
return _ctrlPressed;
}
/**
* Checks if is shift pressed.
* @return true, if is shift pressed
*/
public boolean isShiftPressed()
{
return _shiftPressed;
}
/**
* Gets the skill.
* @return the skill
*/
public Skill getSkill()
{
return _skill;
}
/**
* Gets the skill id.
* @return the skill id
*/
public int getSkillId()
{
return getSkill() != null ? getSkill().getId() : -1;
}
}
/**
* Gets the account name.
* @return the account name
@ -9775,7 +9712,7 @@ public class PlayerInstance extends Playable
final int skillId = skill.getId();
int currSkillId = -1;
final SkillDat current = getCurrentSkill();
final SkillUseHolder current = getCurrentSkill();
if (current != null)
{
currSkillId = current.getSkillId();
@ -9855,7 +9792,7 @@ public class PlayerInstance extends Playable
// failed to cast, or the casting is not yet in progress when this is rechecked
if ((currSkillId != -1) && (isCastingNow() || isCastingPotionNow()))
{
final SkillDat currentSkill = getCurrentSkill();
final SkillUseHolder currentSkill = getCurrentSkill();
// Check if new skill different from current skill in progress
if ((currentSkill != null) && (skill.getId() == currentSkill.getSkillId()))
{
@ -9863,7 +9800,7 @@ public class PlayerInstance extends Playable
return;
}
// Create a new SkillDat object and queue it in the player _queuedSkill
// Create a new SkillUseHolder object and queue it in the player _queuedSkill
setQueuedSkill(skill, forceUse, dontMove);
sendPacket(ActionFailed.STATIC_PACKET);
return;
@ -9897,7 +9834,7 @@ public class PlayerInstance extends Playable
// ************************************* Check Casting in Progress *******************************************
// Create a new SkillDat object and set the player _currentSkill
// Create a new SkillUseHolder object and set the player _currentSkill
// This is used mainly to save & queue the button presses, since Creature has
// _lastSkillCast which could otherwise replace it
setCurrentSkill(skill, forceUse, dontMove);
@ -9972,8 +9909,8 @@ public class PlayerInstance extends Playable
}
// Like L2OFF you can't heal random purple people without using CTRL
final SkillDat skilldat = getCurrentSkill();
if ((skilldat != null) && (skill.getSkillType() == SkillType.HEAL) && !skilldat.isCtrlPressed() && (target instanceof PlayerInstance) && (((PlayerInstance) target).getPvpFlag() == 1) && (this != target))
final SkillUseHolder skillUseHolder = getCurrentSkill();
if ((skillUseHolder != null) && (skill.getSkillType() == SkillType.HEAL) && !skillUseHolder.isCtrlPressed() && (target instanceof PlayerInstance) && (((PlayerInstance) target).getPvpFlag() == 1) && (this != target))
{
if (((getClanId() == 0) || (((PlayerInstance) target).getClanId() == 0)) || (getClanId() != ((PlayerInstance) target).getClanId()))
{
@ -10331,7 +10268,7 @@ public class PlayerInstance extends Playable
return;
}
// If all conditions are checked, create a new SkillDat object and set the player _currentSkill
// If all conditions are checked, create a new SkillUseHolder object and set the player _currentSkill
setCurrentSkill(skill, forceUse, dontMove);
// Check if the active Skill can be casted (ex : not sleeping...), Check if the target is correct and Notify the AI with AI_INTENTION_CAST and target
@ -10406,11 +10343,9 @@ public class PlayerInstance extends Playable
(target != this) && // target is not self and
(target instanceof PlayerInstance) && // target is PlayerInstance and
!isInsideZone(ZoneId.PVP) && // Pc is not in PvP zone
!((PlayerInstance) target).isInsideZone(ZoneId.PVP) // target is not in PvP zone
)
!((PlayerInstance) target).isInsideZone(ZoneId.PVP)) // target is not in PvP zone
{
final SkillDat skilldat = getCurrentSkill();
// SkillDat skilldatpet = getCurrentPetSkill();
final SkillUseHolder skillUseHolder = getCurrentSkill();
if (skill.isPvpSkill()) // pvp skill
{
if ((getClan() != null) && (((PlayerInstance) target).getClan() != null) && getClan().isAtWarWith(((PlayerInstance) target).getClan().getClanId()) && ((PlayerInstance) target).getClan().isAtWarWith(getClan().getClanId()))
@ -10423,7 +10358,7 @@ public class PlayerInstance extends Playable
return false;
}
}
else if ((skilldat != null) && !skilldat.isCtrlPressed() && skill.isOffensive() && !srcIsSummon)
else if ((skillUseHolder != null) && !skillUseHolder.isCtrlPressed() && skill.isOffensive() && !srcIsSummon)
{
if ((getClan() != null) && (((PlayerInstance) target).getClan() != null) && getClan().isAtWarWith(((PlayerInstance) target).getClan().getClanId()) && ((PlayerInstance) target).getClan().isAtWarWith(getClan().getClanId()))
{
@ -14423,13 +14358,13 @@ public class PlayerInstance extends Playable
* Get the current skill in use or return null.
* @return the current skill
*/
public SkillDat getCurrentSkill()
public SkillUseHolder getCurrentSkill()
{
return _currentSkill;
}
/**
* Create a new SkillDat object and set the player _currentSkill.
* Create a new SkillUseHolder object and set the player _currentSkill.
* @param currentSkill the current skill
* @param ctrlPressed the ctrl pressed
* @param shiftPressed the shift pressed
@ -14441,20 +14376,20 @@ public class PlayerInstance extends Playable
_currentSkill = null;
return;
}
_currentSkill = new SkillDat(currentSkill, ctrlPressed, shiftPressed);
_currentSkill = new SkillUseHolder(currentSkill, ctrlPressed, shiftPressed);
}
/**
* Gets the queued skill.
* @return the queued skill
*/
public SkillDat getQueuedSkill()
public SkillUseHolder getQueuedSkill()
{
return _queuedSkill;
}
/**
* Create a new SkillDat object and queue it in the player _queuedSkill.
* Create a new SkillUseHolder object and queue it in the player _queuedSkill.
* @param queuedSkill the queued skill
* @param ctrlPressed the ctrl pressed
* @param shiftPressed the shift pressed
@ -14466,7 +14401,7 @@ public class PlayerInstance extends Playable
_queuedSkill = null;
return;
}
_queuedSkill = new SkillDat(queuedSkill, ctrlPressed, shiftPressed);
_queuedSkill = new SkillUseHolder(queuedSkill, ctrlPressed, shiftPressed);
}
/**
@ -16291,13 +16226,13 @@ public class PlayerInstance extends Playable
* Get the current pet skill in use or return null.<br>
* @return
*/
public SkillDat getCurrentPetSkill()
public SkillUseHolder getCurrentPetSkill()
{
return _currentPetSkill;
}
/**
* Create a new SkillDat object and set the player _currentPetSkill.
* Create a new SkillUseHolder object and set the player _currentPetSkill.
* @param currentSkill
* @param ctrlPressed
* @param shiftPressed
@ -16309,7 +16244,7 @@ public class PlayerInstance extends Playable
_currentPetSkill = null;
return;
}
_currentPetSkill = new SkillDat(currentSkill, ctrlPressed, shiftPressed);
_currentPetSkill = new SkillUseHolder(currentSkill, ctrlPressed, shiftPressed);
}
@Override

View File

@ -0,0 +1,84 @@
/*
* 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 3 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, see <http://www.gnu.org/licenses/>.
*/
package org.l2jmobius.gameserver.model.holders;
import org.l2jmobius.gameserver.model.Skill;
/**
* Skill casting information (used to queue when several skills are cast in a short time).
* @author Mobius
*/
public class SkillUseHolder
{
/** The _skill. */
private final Skill _skill;
/** The _ctrl pressed. */
private final boolean _ctrlPressed;
/** The _shift pressed. */
private final boolean _shiftPressed;
/**
* Instantiates a new skill dat.
* @param skill the skill
* @param ctrlPressed the ctrl pressed
* @param shiftPressed the shift pressed
*/
public SkillUseHolder(Skill skill, boolean ctrlPressed, boolean shiftPressed)
{
_skill = skill;
_ctrlPressed = ctrlPressed;
_shiftPressed = shiftPressed;
}
/**
* Checks if is ctrl pressed.
* @return true, if is ctrl pressed
*/
public boolean isCtrlPressed()
{
return _ctrlPressed;
}
/**
* Checks if is shift pressed.
* @return true, if is shift pressed
*/
public boolean isShiftPressed()
{
return _shiftPressed;
}
/**
* Gets the skill.
* @return the skill
*/
public Skill getSkill()
{
return _skill;
}
/**
* Gets the skill id.
* @return the skill id
*/
public int getSkillId()
{
return getSkill() != null ? getSkill().getId() : -1;
}
}

View File

@ -21,7 +21,7 @@ import java.util.logging.Logger;
import org.l2jmobius.Config;
import org.l2jmobius.gameserver.datatables.xml.AdminData;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance.SkillDat;
import org.l2jmobius.gameserver.model.holders.SkillUseHolder;
import org.l2jmobius.gameserver.model.items.Item;
import org.l2jmobius.gameserver.model.items.instance.ItemInstance;
import org.l2jmobius.gameserver.model.items.type.EtcItemType;
@ -154,7 +154,7 @@ public class RequestDropItem extends GameClientPacket
if (player.isCastingNow())
{
final SkillDat skill = player.getCurrentSkill();
final SkillUseHolder skill = player.getCurrentSkill();
if (skill != null)
{
// Cannot discard item that the skill is consuming.

View File

@ -29,11 +29,11 @@ import org.l2jmobius.gameserver.model.World;
import org.l2jmobius.gameserver.model.actor.Playable;
import org.l2jmobius.gameserver.model.actor.instance.PetInstance;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance.SkillDat;
import org.l2jmobius.gameserver.model.actor.templates.NpcTemplate;
import org.l2jmobius.gameserver.model.entity.event.CTF;
import org.l2jmobius.gameserver.model.entity.event.DM;
import org.l2jmobius.gameserver.model.entity.event.TvT;
import org.l2jmobius.gameserver.model.holders.SkillUseHolder;
import org.l2jmobius.gameserver.model.items.instance.ItemInstance;
import org.l2jmobius.gameserver.model.spawn.Spawn;
import org.l2jmobius.gameserver.network.SystemMessageId;
@ -233,8 +233,8 @@ public class SummonItems implements IItemHandler
{
try
{
final SkillDat skilldat = _player.getCurrentSkill();
if (!_player.isCastingNow() || ((skilldat != null) && (skilldat.getSkillId() != 2046)))
final SkillUseHolder skill = _player.getCurrentSkill();
if (!_player.isCastingNow() || ((skill != null) && (skill.getSkillId() != 2046)))
{
return;
}

View File

@ -74,7 +74,6 @@ import org.l2jmobius.gameserver.model.actor.instance.NpcInstance;
import org.l2jmobius.gameserver.model.actor.instance.NpcWalkerInstance;
import org.l2jmobius.gameserver.model.actor.instance.PetInstance;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance.SkillDat;
import org.l2jmobius.gameserver.model.actor.instance.RaidBossInstance;
import org.l2jmobius.gameserver.model.actor.instance.RiftInvaderInstance;
import org.l2jmobius.gameserver.model.actor.instance.SiegeFlagInstance;
@ -91,6 +90,7 @@ import org.l2jmobius.gameserver.model.entity.event.GameEvent;
import org.l2jmobius.gameserver.model.entity.event.TvT;
import org.l2jmobius.gameserver.model.entity.event.VIP;
import org.l2jmobius.gameserver.model.entity.olympiad.Olympiad;
import org.l2jmobius.gameserver.model.holders.SkillUseHolder;
import org.l2jmobius.gameserver.model.itemcontainer.Inventory;
import org.l2jmobius.gameserver.model.items.Weapon;
import org.l2jmobius.gameserver.model.items.instance.ItemInstance;
@ -7635,11 +7635,11 @@ public abstract class Creature extends WorldObject implements ISkillsHolder
if (this instanceof PlayerInstance)
{
final PlayerInstance currPlayer = (PlayerInstance) this;
final SkillDat skilldat = currPlayer.getCurrentSkill();
final SkillUseHolder skillUseHolder = currPlayer.getCurrentSkill();
// Like L2OFF if the skill is BLOW the player doesn't auto attack
// If on XML skill nextActionAttack = true the char auto attack
// If CTRL is pressed the autoattack is aborted (like L2OFF)
if ((skilldat != null) && !skilldat.isCtrlPressed() && skill.nextActionIsAttack() && (_target != null) && (_target instanceof Creature))
if ((skillUseHolder != null) && !skillUseHolder.isCtrlPressed() && skill.nextActionIsAttack() && (_target != null) && (_target instanceof Creature))
{
getAI().setIntention(AI_INTENTION_ATTACK, _target);
}
@ -7657,8 +7657,8 @@ public abstract class Creature extends WorldObject implements ISkillsHolder
if (this instanceof PlayerInstance)
{
final PlayerInstance currPlayer = (PlayerInstance) this;
final SkillDat skilldat = currPlayer.getCurrentSkill();
if ((skilldat != null) && !skilldat.isCtrlPressed() && (skill.isOffensive()) && (skill.getSkillType() != SkillType.UNLOCK) && (skill.getSkillType() != SkillType.BLOW) && (skill.getSkillType() != SkillType.DELUXE_KEY_UNLOCK) && (skill.getId() != 345) && (skill.getId() != 346))
final SkillUseHolder skillUseHolder = currPlayer.getCurrentSkill();
if ((skillUseHolder != null) && !skillUseHolder.isCtrlPressed() && (skill.isOffensive()) && (skill.getSkillType() != SkillType.UNLOCK) && (skill.getSkillType() != SkillType.BLOW) && (skill.getSkillType() != SkillType.DELUXE_KEY_UNLOCK) && (skill.getId() != 345) && (skill.getId() != 346))
{
if (!skill.isMagic() && skill.nextActionIsAttack())
{
@ -7692,7 +7692,7 @@ public abstract class Creature extends WorldObject implements ISkillsHolder
if (this instanceof PlayerInstance)
{
final PlayerInstance currPlayer = (PlayerInstance) this;
final SkillDat queuedSkill = currPlayer.getQueuedSkill();
final SkillUseHolder queuedSkill = currPlayer.getQueuedSkill();
currPlayer.setCurrentSkill(null, false, false);
if (queuedSkill != null)
{

View File

@ -137,6 +137,7 @@ import org.l2jmobius.gameserver.model.entity.siege.FortSiege;
import org.l2jmobius.gameserver.model.entity.siege.Siege;
import org.l2jmobius.gameserver.model.entity.siege.clanhalls.DevastatedCastle;
import org.l2jmobius.gameserver.model.holders.PlayerStatsHolder;
import org.l2jmobius.gameserver.model.holders.SkillUseHolder;
import org.l2jmobius.gameserver.model.holders.SummonRequestHolder;
import org.l2jmobius.gameserver.model.itemcontainer.Inventory;
import org.l2jmobius.gameserver.model.itemcontainer.ItemContainer;
@ -475,9 +476,9 @@ public class PlayerInstance extends Playable
private final List<String> _validLink = new ArrayList<>();
private Forum _forumMail;
private Forum _forumMemo;
private SkillDat _currentSkill;
private SkillDat _currentPetSkill;
private SkillDat _queuedSkill;
private SkillUseHolder _currentSkill;
private SkillUseHolder _currentPetSkill;
private SkillUseHolder _queuedSkill;
private boolean _isWearingFormalWear = false;
private Location _currentSkillWorldPosition;
private int _cursedWeaponEquipedId = 0;
@ -832,70 +833,6 @@ public class PlayerInstance extends Playable
}
}
/**
* Skill casting information (used to queue when several skills are cast in a short time) *.
*/
public class SkillDat
{
/** The _skill. */
private final Skill _skill;
/** The _ctrl pressed. */
private final boolean _ctrlPressed;
/** The _shift pressed. */
private final boolean _shiftPressed;
/**
* Instantiates a new skill dat.
* @param skill the skill
* @param ctrlPressed the ctrl pressed
* @param shiftPressed the shift pressed
*/
protected SkillDat(Skill skill, boolean ctrlPressed, boolean shiftPressed)
{
_skill = skill;
_ctrlPressed = ctrlPressed;
_shiftPressed = shiftPressed;
}
/**
* Checks if is ctrl pressed.
* @return true, if is ctrl pressed
*/
public boolean isCtrlPressed()
{
return _ctrlPressed;
}
/**
* Checks if is shift pressed.
* @return true, if is shift pressed
*/
public boolean isShiftPressed()
{
return _shiftPressed;
}
/**
* Gets the skill.
* @return the skill
*/
public Skill getSkill()
{
return _skill;
}
/**
* Gets the skill id.
* @return the skill id
*/
public int getSkillId()
{
return getSkill() != null ? getSkill().getId() : -1;
}
}
/**
* Gets the account name.
* @return the account name
@ -9937,7 +9874,7 @@ public class PlayerInstance extends Playable
final int skillId = skill.getId();
int currSkillId = -1;
final SkillDat current = getCurrentSkill();
final SkillUseHolder current = getCurrentSkill();
if (current != null)
{
currSkillId = current.getSkillId();
@ -10017,7 +9954,7 @@ public class PlayerInstance extends Playable
// failed to cast, or the casting is not yet in progress when this is rechecked
if ((currSkillId != -1) && (isCastingNow() || isCastingPotionNow()))
{
final SkillDat currentSkill = getCurrentSkill();
final SkillUseHolder currentSkill = getCurrentSkill();
// Check if new skill different from current skill in progress
if ((currentSkill != null) && (skill.getId() == currentSkill.getSkillId()))
{
@ -10025,7 +9962,7 @@ public class PlayerInstance extends Playable
return;
}
// Create a new SkillDat object and queue it in the player _queuedSkill
// Create a new SkillUseHolder object and queue it in the player _queuedSkill
setQueuedSkill(skill, forceUse, dontMove);
sendPacket(ActionFailed.STATIC_PACKET);
return;
@ -10059,7 +9996,7 @@ public class PlayerInstance extends Playable
// ************************************* Check Casting in Progress *******************************************
// Create a new SkillDat object and set the player _currentSkill
// Create a new SkillUseHolder object and set the player _currentSkill
// This is used mainly to save & queue the button presses, since Creature has
// _lastSkillCast which could otherwise replace it
setCurrentSkill(skill, forceUse, dontMove);
@ -10134,8 +10071,8 @@ public class PlayerInstance extends Playable
}
// Like L2OFF you can't heal random purple people without using CTRL
final SkillDat skilldat = getCurrentSkill();
if ((skilldat != null) && (skill.getSkillType() == SkillType.HEAL) && !skilldat.isCtrlPressed() && (target instanceof PlayerInstance) && (((PlayerInstance) target).getPvpFlag() == 1) && (this != target))
final SkillUseHolder skillUseHolder = getCurrentSkill();
if ((skillUseHolder != null) && (skill.getSkillType() == SkillType.HEAL) && !skillUseHolder.isCtrlPressed() && (target instanceof PlayerInstance) && (((PlayerInstance) target).getPvpFlag() == 1) && (this != target))
{
if (((getClanId() == 0) || (((PlayerInstance) target).getClanId() == 0)) || (getClanId() != ((PlayerInstance) target).getClanId()))
{
@ -10502,7 +10439,7 @@ public class PlayerInstance extends Playable
return;
}
// If all conditions are checked, create a new SkillDat object and set the player _currentSkill
// If all conditions are checked, create a new SkillUseHolder object and set the player _currentSkill
setCurrentSkill(skill, forceUse, dontMove);
// Check if the active Skill can be casted (ex : not sleeping...), Check if the target is correct and Notify the AI with AI_INTENTION_CAST and target
@ -10578,11 +10515,9 @@ public class PlayerInstance extends Playable
(target instanceof PlayerInstance) && // target is PlayerInstance and
(!isInDuel() || (((PlayerInstance) target).getDuelId() != getDuelId())) && // self is not in a duel and attacking opponent
!isInsideZone(ZoneId.PVP) && // Pc is not in PvP zone
!((PlayerInstance) target).isInsideZone(ZoneId.PVP) // target is not in PvP zone
)
!((PlayerInstance) target).isInsideZone(ZoneId.PVP)) // target is not in PvP zone
{
final SkillDat skilldat = getCurrentSkill();
// SkillDat skilldatpet = getCurrentPetSkill();
final SkillUseHolder skillUseHolder = getCurrentSkill();
if (skill.isPvpSkill()) // pvp skill
{
if ((getClan() != null) && (((PlayerInstance) target).getClan() != null) && getClan().isAtWarWith(((PlayerInstance) target).getClan().getClanId()) && ((PlayerInstance) target).getClan().isAtWarWith(getClan().getClanId()))
@ -10595,7 +10530,7 @@ public class PlayerInstance extends Playable
return false;
}
}
else if ((skilldat != null) && !skilldat.isCtrlPressed() && skill.isOffensive() && !srcIsSummon)
else if ((skillUseHolder != null) && !skillUseHolder.isCtrlPressed() && skill.isOffensive() && !srcIsSummon)
{
if ((getClan() != null) && (((PlayerInstance) target).getClan() != null) && getClan().isAtWarWith(((PlayerInstance) target).getClan().getClanId()) && ((PlayerInstance) target).getClan().isAtWarWith(getClan().getClanId()))
{
@ -14747,13 +14682,13 @@ public class PlayerInstance extends Playable
* Get the current skill in use or return null.
* @return the current skill
*/
public SkillDat getCurrentSkill()
public SkillUseHolder getCurrentSkill()
{
return _currentSkill;
}
/**
* Create a new SkillDat object and set the player _currentSkill.
* Create a new SkillUseHolder object and set the player _currentSkill.
* @param currentSkill the current skill
* @param ctrlPressed the ctrl pressed
* @param shiftPressed the shift pressed
@ -14765,20 +14700,20 @@ public class PlayerInstance extends Playable
_currentSkill = null;
return;
}
_currentSkill = new SkillDat(currentSkill, ctrlPressed, shiftPressed);
_currentSkill = new SkillUseHolder(currentSkill, ctrlPressed, shiftPressed);
}
/**
* Gets the queued skill.
* @return the queued skill
*/
public SkillDat getQueuedSkill()
public SkillUseHolder getQueuedSkill()
{
return _queuedSkill;
}
/**
* Create a new SkillDat object and queue it in the player _queuedSkill.
* Create a new SkillUseHolder object and queue it in the player _queuedSkill.
* @param queuedSkill the queued skill
* @param ctrlPressed the ctrl pressed
* @param shiftPressed the shift pressed
@ -14790,7 +14725,7 @@ public class PlayerInstance extends Playable
_queuedSkill = null;
return;
}
_queuedSkill = new SkillDat(queuedSkill, ctrlPressed, shiftPressed);
_queuedSkill = new SkillUseHolder(queuedSkill, ctrlPressed, shiftPressed);
}
/**
@ -16662,13 +16597,13 @@ public class PlayerInstance extends Playable
* Get the current pet skill in use or return null.<br>
* @return
*/
public SkillDat getCurrentPetSkill()
public SkillUseHolder getCurrentPetSkill()
{
return _currentPetSkill;
}
/**
* Create a new SkillDat object and set the player _currentPetSkill.
* Create a new SkillUseHolder object and set the player _currentPetSkill.
* @param currentSkill
* @param ctrlPressed
* @param shiftPressed
@ -16680,7 +16615,7 @@ public class PlayerInstance extends Playable
_currentPetSkill = null;
return;
}
_currentPetSkill = new SkillDat(currentSkill, ctrlPressed, shiftPressed);
_currentPetSkill = new SkillUseHolder(currentSkill, ctrlPressed, shiftPressed);
}
@Override

View File

@ -0,0 +1,84 @@
/*
* 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 3 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, see <http://www.gnu.org/licenses/>.
*/
package org.l2jmobius.gameserver.model.holders;
import org.l2jmobius.gameserver.model.Skill;
/**
* Skill casting information (used to queue when several skills are cast in a short time).
* @author Mobius
*/
public class SkillUseHolder
{
/** The _skill. */
private final Skill _skill;
/** The _ctrl pressed. */
private final boolean _ctrlPressed;
/** The _shift pressed. */
private final boolean _shiftPressed;
/**
* Instantiates a new skill dat.
* @param skill the skill
* @param ctrlPressed the ctrl pressed
* @param shiftPressed the shift pressed
*/
public SkillUseHolder(Skill skill, boolean ctrlPressed, boolean shiftPressed)
{
_skill = skill;
_ctrlPressed = ctrlPressed;
_shiftPressed = shiftPressed;
}
/**
* Checks if is ctrl pressed.
* @return true, if is ctrl pressed
*/
public boolean isCtrlPressed()
{
return _ctrlPressed;
}
/**
* Checks if is shift pressed.
* @return true, if is shift pressed
*/
public boolean isShiftPressed()
{
return _shiftPressed;
}
/**
* Gets the skill.
* @return the skill
*/
public Skill getSkill()
{
return _skill;
}
/**
* Gets the skill id.
* @return the skill id
*/
public int getSkillId()
{
return getSkill() != null ? getSkill().getId() : -1;
}
}

View File

@ -22,7 +22,7 @@ import org.l2jmobius.Config;
import org.l2jmobius.gameserver.datatables.xml.AdminData;
import org.l2jmobius.gameserver.instancemanager.CursedWeaponsManager;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance.SkillDat;
import org.l2jmobius.gameserver.model.holders.SkillUseHolder;
import org.l2jmobius.gameserver.model.items.Item;
import org.l2jmobius.gameserver.model.items.instance.ItemInstance;
import org.l2jmobius.gameserver.model.items.type.EtcItemType;
@ -167,7 +167,7 @@ public class RequestDropItem extends GameClientPacket
if (player.isCastingNow())
{
final SkillDat skill = player.getCurrentSkill();
final SkillUseHolder skill = player.getCurrentSkill();
if (skill != null)
{
// Cannot discard item that the skill is consuming.

View File

@ -8580,14 +8580,14 @@ public class PlayerInstance extends Playable
return false;
}
// Create a new SkillDat object and queue it in the player _queuedSkill
// Create a new SkillUseHolder object and queue it in the player _queuedSkill
setQueuedSkill(skill, forceUse, dontMove);
sendPacket(ActionFailed.STATIC_PACKET);
return false;
}
setCastingNow(true);
// Create a new SkillDat object and set the player _currentSkill
// Create a new SkillUseHolder object and set the player _currentSkill
// This is used mainly to save & queue the button presses, since Creature has
// _lastSkillCast which could otherwise replace it
setCurrentSkill(skill, forceUse, dontMove);
@ -12109,7 +12109,7 @@ public class PlayerInstance extends Playable
}
/**
* Create a new SkillDat object and set the player _currentSkill.
* Create a new SkillUseHolder object and set the player _currentSkill.
* @param currentSkill
* @param ctrlPressed
* @param shiftPressed
@ -12133,7 +12133,7 @@ public class PlayerInstance extends Playable
}
/**
* Create a new SkillDat object and set the player _currentPetSkill.
* Create a new SkillUseHolder object and set the player _currentPetSkill.
* @param currentSkill
* @param ctrlPressed
* @param shiftPressed
@ -12154,7 +12154,7 @@ public class PlayerInstance extends Playable
}
/**
* Create a new SkillDat object and queue it in the player _queuedSkill.
* Create a new SkillUseHolder object and queue it in the player _queuedSkill.
* @param queuedSkill
* @param ctrlPressed
* @param shiftPressed

View File

@ -8464,14 +8464,14 @@ public class PlayerInstance extends Playable
return false;
}
// Create a new SkillDat object and queue it in the player _queuedSkill
// Create a new SkillUseHolder object and queue it in the player _queuedSkill
setQueuedSkill(skill, forceUse, dontMove);
sendPacket(ActionFailed.STATIC_PACKET);
return false;
}
setCastingNow(true);
// Create a new SkillDat object and set the player _currentSkill
// Create a new SkillUseHolder object and set the player _currentSkill
// This is used mainly to save & queue the button presses, since Creature has
// _lastSkillCast which could otherwise replace it
setCurrentSkill(skill, forceUse, dontMove);
@ -12002,7 +12002,7 @@ public class PlayerInstance extends Playable
}
/**
* Create a new SkillDat object and set the player _currentSkill.
* Create a new SkillUseHolder object and set the player _currentSkill.
* @param currentSkill
* @param ctrlPressed
* @param shiftPressed
@ -12026,7 +12026,7 @@ public class PlayerInstance extends Playable
}
/**
* Create a new SkillDat object and set the player _currentPetSkill.
* Create a new SkillUseHolder object and set the player _currentPetSkill.
* @param currentSkill
* @param ctrlPressed
* @param shiftPressed
@ -12047,7 +12047,7 @@ public class PlayerInstance extends Playable
}
/**
* Create a new SkillDat object and queue it in the player _queuedSkill.
* Create a new SkillUseHolder object and queue it in the player _queuedSkill.
* @param queuedSkill
* @param ctrlPressed
* @param shiftPressed

View File

@ -8396,7 +8396,7 @@ public class PlayerInstance extends Playable
// Do not queue skill if called by an item.
if (item == null)
{
// Create a new SkillDat object and queue it in the player _queuedSkill
// Create a new SkillUseHolder object and queue it in the player _queuedSkill
setQueuedSkill(usedSkill, item, forceUse, dontMove);
}
sendPacket(ActionFailed.STATIC_PACKET);
@ -11087,7 +11087,7 @@ public class PlayerInstance extends Playable
}
/**
* Create a new SkillDat object and queue it in the player _queuedSkill.
* Create a new SkillUseHolder object and queue it in the player _queuedSkill.
* @param queuedSkill
* @param item
* @param ctrlPressed

View File

@ -8396,7 +8396,7 @@ public class PlayerInstance extends Playable
// Do not queue skill if called by an item.
if (item == null)
{
// Create a new SkillDat object and queue it in the player _queuedSkill
// Create a new SkillUseHolder object and queue it in the player _queuedSkill
setQueuedSkill(usedSkill, item, forceUse, dontMove);
}
sendPacket(ActionFailed.STATIC_PACKET);
@ -11087,7 +11087,7 @@ public class PlayerInstance extends Playable
}
/**
* Create a new SkillDat object and queue it in the player _queuedSkill.
* Create a new SkillUseHolder object and queue it in the player _queuedSkill.
* @param queuedSkill
* @param item
* @param ctrlPressed

View File

@ -8382,7 +8382,7 @@ public class PlayerInstance extends Playable
// Do not queue skill if called by an item.
if (item == null)
{
// Create a new SkillDat object and queue it in the player _queuedSkill
// Create a new SkillUseHolder object and queue it in the player _queuedSkill
setQueuedSkill(usedSkill, item, forceUse, dontMove);
}
sendPacket(ActionFailed.STATIC_PACKET);
@ -11073,7 +11073,7 @@ public class PlayerInstance extends Playable
}
/**
* Create a new SkillDat object and queue it in the player _queuedSkill.
* Create a new SkillUseHolder object and queue it in the player _queuedSkill.
* @param queuedSkill
* @param item
* @param ctrlPressed

View File

@ -8409,7 +8409,7 @@ public class PlayerInstance extends Playable
// Do not queue skill if called by an item.
if (item == null)
{
// Create a new SkillDat object and queue it in the player _queuedSkill
// Create a new SkillUseHolder object and queue it in the player _queuedSkill
setQueuedSkill(usedSkill, item, forceUse, dontMove);
}
sendPacket(ActionFailed.STATIC_PACKET);
@ -11103,7 +11103,7 @@ public class PlayerInstance extends Playable
}
/**
* Create a new SkillDat object and queue it in the player _queuedSkill.
* Create a new SkillUseHolder object and queue it in the player _queuedSkill.
* @param queuedSkill
* @param item
* @param ctrlPressed

View File

@ -8409,7 +8409,7 @@ public class PlayerInstance extends Playable
// Do not queue skill if called by an item.
if (item == null)
{
// Create a new SkillDat object and queue it in the player _queuedSkill
// Create a new SkillUseHolder object and queue it in the player _queuedSkill
setQueuedSkill(usedSkill, item, forceUse, dontMove);
}
sendPacket(ActionFailed.STATIC_PACKET);
@ -11103,7 +11103,7 @@ public class PlayerInstance extends Playable
}
/**
* Create a new SkillDat object and queue it in the player _queuedSkill.
* Create a new SkillUseHolder object and queue it in the player _queuedSkill.
* @param queuedSkill
* @param item
* @param ctrlPressed

View File

@ -8326,7 +8326,7 @@ public class PlayerInstance extends Playable
// Do not queue skill if called by an item.
if (item == null)
{
// Create a new SkillDat object and queue it in the player _queuedSkill
// Create a new SkillUseHolder object and queue it in the player _queuedSkill
setQueuedSkill(usedSkill, item, forceUse, dontMove);
}
sendPacket(ActionFailed.STATIC_PACKET);
@ -11006,7 +11006,7 @@ public class PlayerInstance extends Playable
}
/**
* Create a new SkillDat object and queue it in the player _queuedSkill.
* Create a new SkillUseHolder object and queue it in the player _queuedSkill.
* @param queuedSkill
* @param item
* @param ctrlPressed

View File

@ -8398,7 +8398,7 @@ public class PlayerInstance extends Playable
// Do not queue skill if called by an item.
if (item == null)
{
// Create a new SkillDat object and queue it in the player _queuedSkill
// Create a new SkillUseHolder object and queue it in the player _queuedSkill
setQueuedSkill(usedSkill, item, forceUse, dontMove);
}
sendPacket(ActionFailed.STATIC_PACKET);
@ -11108,7 +11108,7 @@ public class PlayerInstance extends Playable
}
/**
* Create a new SkillDat object and queue it in the player _queuedSkill.
* Create a new SkillUseHolder object and queue it in the player _queuedSkill.
* @param queuedSkill
* @param item
* @param ctrlPressed