Separation of auto skills from auto buffs and order of skills.
This commit is contained in:
parent
3fb20833da
commit
2c31230f18
@ -9894,7 +9894,14 @@ public class PlayerInstance extends Playable
|
||||
// 9. Resend a class change animation effect to broadcast to all nearby players.
|
||||
for (Skill oldSkill : getAllSkills())
|
||||
{
|
||||
AutoUseTaskManager.getInstance().removeAutoSkill(this, oldSkill.getId());
|
||||
if (oldSkill.isBad())
|
||||
{
|
||||
AutoUseTaskManager.getInstance().removeAutoSkill(this, oldSkill.getId());
|
||||
}
|
||||
else
|
||||
{
|
||||
AutoUseTaskManager.getInstance().removeAutoBuff(this, oldSkill.getId());
|
||||
}
|
||||
removeSkill(oldSkill, false, true);
|
||||
}
|
||||
|
||||
@ -14364,7 +14371,7 @@ public class PlayerInstance extends Playable
|
||||
continue;
|
||||
}
|
||||
|
||||
if (_autoUseSettings.getAutoSkills().contains(shortcut.getId()))
|
||||
if (_autoUseSettings.isAutoSkill(shortcut.getId()))
|
||||
{
|
||||
if (getKnownSkill(shortcut.getId()) != null)
|
||||
{
|
||||
@ -14397,11 +14404,19 @@ public class PlayerInstance extends Playable
|
||||
continue;
|
||||
}
|
||||
|
||||
if (getKnownSkill(shortcut.getId()) != null)
|
||||
final Skill knownSkill = getKnownSkill(shortcut.getId());
|
||||
if (knownSkill != null)
|
||||
{
|
||||
shortcut.setAutoUse(true);
|
||||
sendPacket(new ExActivateAutoShortcut(shortcut, true));
|
||||
AutoUseTaskManager.getInstance().addAutoSkill(this, shortcut.getId());
|
||||
if (knownSkill.isBad())
|
||||
{
|
||||
AutoUseTaskManager.getInstance().addAutoSkill(this, shortcut.getId());
|
||||
}
|
||||
else
|
||||
{
|
||||
AutoUseTaskManager.getInstance().addAutoBuff(this, shortcut.getId());
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -17,7 +17,9 @@
|
||||
package org.l2jmobius.gameserver.model.holders;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.CopyOnWriteArrayList;
|
||||
|
||||
/**
|
||||
* @author Mobius
|
||||
@ -26,8 +28,10 @@ public class AutoUseSettingsHolder
|
||||
{
|
||||
private final Collection<Integer> _autoSupplyItems = ConcurrentHashMap.newKeySet();
|
||||
private final Collection<Integer> _autoPotionItems = ConcurrentHashMap.newKeySet();
|
||||
private final Collection<Integer> _autoSkills = ConcurrentHashMap.newKeySet();
|
||||
private final Collection<Integer> _autoActions = ConcurrentHashMap.newKeySet();
|
||||
private final Collection<Integer> _autoBuffs = ConcurrentHashMap.newKeySet();
|
||||
private final List<Integer> _autoSkills = new CopyOnWriteArrayList<>();
|
||||
private int _skillIndex = -1;
|
||||
|
||||
public AutoUseSettingsHolder()
|
||||
{
|
||||
@ -43,14 +47,50 @@ public class AutoUseSettingsHolder
|
||||
return _autoPotionItems;
|
||||
}
|
||||
|
||||
public Collection<Integer> getAutoActions()
|
||||
{
|
||||
return _autoActions;
|
||||
}
|
||||
|
||||
public Collection<Integer> getAutoBuffs()
|
||||
{
|
||||
return _autoBuffs;
|
||||
}
|
||||
|
||||
public Collection<Integer> getAutoSkills()
|
||||
{
|
||||
return _autoSkills;
|
||||
}
|
||||
|
||||
public Collection<Integer> getAutoActions()
|
||||
public boolean isAutoSkill(int skillId)
|
||||
{
|
||||
return _autoActions;
|
||||
return _autoSkills.contains(skillId) || _autoBuffs.contains(skillId);
|
||||
}
|
||||
|
||||
public int getNextSkillId()
|
||||
{
|
||||
_skillIndex++;
|
||||
if (_skillIndex >= _autoSkills.size())
|
||||
{
|
||||
_skillIndex = 0;
|
||||
}
|
||||
|
||||
int skillId = 0;
|
||||
try
|
||||
{
|
||||
skillId = _autoSkills.get(_skillIndex);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
resetSkillOrder();
|
||||
}
|
||||
|
||||
return skillId;
|
||||
}
|
||||
|
||||
public void resetSkillOrder()
|
||||
{
|
||||
_skillIndex = -1;
|
||||
}
|
||||
|
||||
public boolean isEmpty()
|
||||
|
@ -79,6 +79,7 @@ public class RequestShortCutDel implements IClientIncomingPacket
|
||||
}
|
||||
else
|
||||
{
|
||||
AutoUseTaskManager.getInstance().removeAutoBuff(player, id);
|
||||
AutoUseTaskManager.getInstance().removeAutoSkill(player, id);
|
||||
}
|
||||
player.restoreAutoShortcutVisual();
|
||||
|
@ -76,7 +76,7 @@ public class RequestShortCutReg implements IClientIncomingPacket
|
||||
player.sendPacket(new ExActivateAutoShortcut(sc, _active));
|
||||
|
||||
// When id is not auto used, deactivate auto shortcuts.
|
||||
if (!player.getAutoUseSettings().getAutoSkills().contains(_id) && !player.getAutoUseSettings().getAutoSupplyItems().contains(_id))
|
||||
if (!player.getAutoUseSettings().isAutoSkill(_id) && !player.getAutoUseSettings().getAutoSupplyItems().contains(_id))
|
||||
{
|
||||
final List<Integer> positions = player.getVariables().getIntegerList(PlayerVariables.AUTO_USE_SHORTCUTS);
|
||||
final Integer position = _slot + (_page * ShortCuts.MAX_SHORTCUTS_PER_BAR);
|
||||
|
@ -99,7 +99,14 @@ public class ExRequestActivateAutoShortcut implements IClientIncomingPacket
|
||||
// auto skill
|
||||
if (skill != null)
|
||||
{
|
||||
AutoUseTaskManager.getInstance().removeAutoSkill(player, skill.getId());
|
||||
if (skill.isBad())
|
||||
{
|
||||
AutoUseTaskManager.getInstance().removeAutoSkill(player, skill.getId());
|
||||
}
|
||||
else
|
||||
{
|
||||
AutoUseTaskManager.getInstance().removeAutoBuff(player, skill.getId());
|
||||
}
|
||||
}
|
||||
else // action
|
||||
{
|
||||
@ -131,7 +138,14 @@ public class ExRequestActivateAutoShortcut implements IClientIncomingPacket
|
||||
// auto skill
|
||||
if (Config.ENABLE_AUTO_SKILL && (skill != null))
|
||||
{
|
||||
AutoUseTaskManager.getInstance().addAutoSkill(player, skill.getId());
|
||||
if (skill.isBad())
|
||||
{
|
||||
AutoUseTaskManager.getInstance().addAutoSkill(player, skill.getId());
|
||||
}
|
||||
else
|
||||
{
|
||||
AutoUseTaskManager.getInstance().addAutoBuff(player, skill.getId());
|
||||
}
|
||||
return;
|
||||
}
|
||||
// action
|
||||
|
@ -163,7 +163,7 @@ public class AutoUseTaskManager implements Runnable
|
||||
|
||||
if (Config.ENABLE_AUTO_SKILL)
|
||||
{
|
||||
BUFFS: for (Integer skillId : player.getAutoUseSettings().getAutoSkills())
|
||||
BUFFS: for (Integer skillId : player.getAutoUseSettings().getAutoBuffs())
|
||||
{
|
||||
// Fixes start area issue.
|
||||
if (isInPeaceZone)
|
||||
@ -186,13 +186,7 @@ public class AutoUseTaskManager implements Runnable
|
||||
final Skill skill = player.getKnownSkill(skillId.intValue());
|
||||
if (skill == null)
|
||||
{
|
||||
player.getAutoUseSettings().getAutoSkills().remove(skillId);
|
||||
continue BUFFS;
|
||||
}
|
||||
|
||||
// Not a buff.
|
||||
if (skill.isBad())
|
||||
{
|
||||
player.getAutoUseSettings().getAutoBuffs().remove(skillId);
|
||||
continue BUFFS;
|
||||
}
|
||||
|
||||
@ -220,7 +214,7 @@ public class AutoUseTaskManager implements Runnable
|
||||
continue;
|
||||
}
|
||||
|
||||
SKILLS: for (Integer skillId : player.getAutoUseSettings().getAutoSkills())
|
||||
SKILLS:
|
||||
{
|
||||
// Already casting.
|
||||
if (player.isCastingNow())
|
||||
@ -234,36 +228,32 @@ public class AutoUseTaskManager implements Runnable
|
||||
break SKILLS;
|
||||
}
|
||||
|
||||
final Skill skill = player.getKnownSkill(skillId.intValue());
|
||||
// Acquire next skill.
|
||||
final int skillId = player.getAutoUseSettings().getNextSkillId();
|
||||
final Skill skill = player.getKnownSkill(skillId);
|
||||
if (skill == null)
|
||||
{
|
||||
player.getAutoUseSettings().getAutoSkills().remove(skillId);
|
||||
continue SKILLS;
|
||||
}
|
||||
|
||||
// Not an offensive skill.
|
||||
if (!skill.isBad())
|
||||
{
|
||||
continue SKILLS;
|
||||
break SKILLS;
|
||||
}
|
||||
|
||||
// Casting on self stops movement.
|
||||
final WorldObject target = player.getTarget();
|
||||
if (target == player)
|
||||
{
|
||||
continue SKILLS;
|
||||
break SKILLS;
|
||||
}
|
||||
|
||||
// Check bad skill target.
|
||||
if ((target == null) || !target.isAttackable())
|
||||
{
|
||||
continue SKILLS;
|
||||
break SKILLS;
|
||||
}
|
||||
|
||||
// Do not attack guards.
|
||||
if (target instanceof GuardInstance)
|
||||
{
|
||||
continue SKILLS;
|
||||
break SKILLS;
|
||||
}
|
||||
|
||||
if (canUseMagic(player, target, skill))
|
||||
@ -361,6 +351,7 @@ public class AutoUseTaskManager implements Runnable
|
||||
|
||||
public void stopAutoUseTask(PlayerInstance player)
|
||||
{
|
||||
player.getAutoUseSettings().resetSkillOrder();
|
||||
if (player.getAutoUseSettings().isEmpty() || !player.isOnline() || player.isInOfflineMode())
|
||||
{
|
||||
PLAYERS.remove(player);
|
||||
@ -391,6 +382,18 @@ public class AutoUseTaskManager implements Runnable
|
||||
stopAutoUseTask(player);
|
||||
}
|
||||
|
||||
public void addAutoBuff(PlayerInstance player, int skillId)
|
||||
{
|
||||
player.getAutoUseSettings().getAutoBuffs().add(skillId);
|
||||
startAutoUseTask(player);
|
||||
}
|
||||
|
||||
public void removeAutoBuff(PlayerInstance player, int skillId)
|
||||
{
|
||||
player.getAutoUseSettings().getAutoBuffs().remove(skillId);
|
||||
stopAutoUseTask(player);
|
||||
}
|
||||
|
||||
public void addAutoSkill(PlayerInstance player, int skillId)
|
||||
{
|
||||
player.getAutoUseSettings().getAutoSkills().add(skillId);
|
||||
|
@ -9996,7 +9996,14 @@ public class PlayerInstance extends Playable
|
||||
// 9. Resend a class change animation effect to broadcast to all nearby players.
|
||||
for (Skill oldSkill : getAllSkills())
|
||||
{
|
||||
AutoUseTaskManager.getInstance().removeAutoSkill(this, oldSkill.getId());
|
||||
if (oldSkill.isBad())
|
||||
{
|
||||
AutoUseTaskManager.getInstance().removeAutoSkill(this, oldSkill.getId());
|
||||
}
|
||||
else
|
||||
{
|
||||
AutoUseTaskManager.getInstance().removeAutoBuff(this, oldSkill.getId());
|
||||
}
|
||||
removeSkill(oldSkill, false, true);
|
||||
}
|
||||
|
||||
@ -14434,7 +14441,7 @@ public class PlayerInstance extends Playable
|
||||
continue;
|
||||
}
|
||||
|
||||
if (_autoUseSettings.getAutoSkills().contains(shortcut.getId()))
|
||||
if (_autoUseSettings.isAutoSkill(shortcut.getId()))
|
||||
{
|
||||
if (getKnownSkill(shortcut.getId()) != null)
|
||||
{
|
||||
@ -14467,11 +14474,19 @@ public class PlayerInstance extends Playable
|
||||
continue;
|
||||
}
|
||||
|
||||
if (getKnownSkill(shortcut.getId()) != null)
|
||||
final Skill knownSkill = getKnownSkill(shortcut.getId());
|
||||
if (knownSkill != null)
|
||||
{
|
||||
shortcut.setAutoUse(true);
|
||||
sendPacket(new ExActivateAutoShortcut(shortcut, true));
|
||||
AutoUseTaskManager.getInstance().addAutoSkill(this, shortcut.getId());
|
||||
if (knownSkill.isBad())
|
||||
{
|
||||
AutoUseTaskManager.getInstance().addAutoSkill(this, shortcut.getId());
|
||||
}
|
||||
else
|
||||
{
|
||||
AutoUseTaskManager.getInstance().addAutoBuff(this, shortcut.getId());
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -17,7 +17,9 @@
|
||||
package org.l2jmobius.gameserver.model.holders;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.CopyOnWriteArrayList;
|
||||
|
||||
/**
|
||||
* @author Mobius
|
||||
@ -26,8 +28,10 @@ public class AutoUseSettingsHolder
|
||||
{
|
||||
private final Collection<Integer> _autoSupplyItems = ConcurrentHashMap.newKeySet();
|
||||
private final Collection<Integer> _autoPotionItems = ConcurrentHashMap.newKeySet();
|
||||
private final Collection<Integer> _autoSkills = ConcurrentHashMap.newKeySet();
|
||||
private final Collection<Integer> _autoActions = ConcurrentHashMap.newKeySet();
|
||||
private final Collection<Integer> _autoBuffs = ConcurrentHashMap.newKeySet();
|
||||
private final List<Integer> _autoSkills = new CopyOnWriteArrayList<>();
|
||||
private int _skillIndex = -1;
|
||||
|
||||
public AutoUseSettingsHolder()
|
||||
{
|
||||
@ -43,14 +47,50 @@ public class AutoUseSettingsHolder
|
||||
return _autoPotionItems;
|
||||
}
|
||||
|
||||
public Collection<Integer> getAutoActions()
|
||||
{
|
||||
return _autoActions;
|
||||
}
|
||||
|
||||
public Collection<Integer> getAutoBuffs()
|
||||
{
|
||||
return _autoBuffs;
|
||||
}
|
||||
|
||||
public Collection<Integer> getAutoSkills()
|
||||
{
|
||||
return _autoSkills;
|
||||
}
|
||||
|
||||
public Collection<Integer> getAutoActions()
|
||||
public boolean isAutoSkill(int skillId)
|
||||
{
|
||||
return _autoActions;
|
||||
return _autoSkills.contains(skillId) || _autoBuffs.contains(skillId);
|
||||
}
|
||||
|
||||
public int getNextSkillId()
|
||||
{
|
||||
_skillIndex++;
|
||||
if (_skillIndex >= _autoSkills.size())
|
||||
{
|
||||
_skillIndex = 0;
|
||||
}
|
||||
|
||||
int skillId = 0;
|
||||
try
|
||||
{
|
||||
skillId = _autoSkills.get(_skillIndex);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
resetSkillOrder();
|
||||
}
|
||||
|
||||
return skillId;
|
||||
}
|
||||
|
||||
public void resetSkillOrder()
|
||||
{
|
||||
_skillIndex = -1;
|
||||
}
|
||||
|
||||
public boolean isEmpty()
|
||||
|
@ -79,6 +79,7 @@ public class RequestShortCutDel implements IClientIncomingPacket
|
||||
}
|
||||
else
|
||||
{
|
||||
AutoUseTaskManager.getInstance().removeAutoBuff(player, id);
|
||||
AutoUseTaskManager.getInstance().removeAutoSkill(player, id);
|
||||
}
|
||||
player.restoreAutoShortcutVisual();
|
||||
|
@ -76,7 +76,7 @@ public class RequestShortCutReg implements IClientIncomingPacket
|
||||
player.sendPacket(new ExActivateAutoShortcut(sc, _active));
|
||||
|
||||
// When id is not auto used, deactivate auto shortcuts.
|
||||
if (!player.getAutoUseSettings().getAutoSkills().contains(_id) && !player.getAutoUseSettings().getAutoSupplyItems().contains(_id))
|
||||
if (!player.getAutoUseSettings().isAutoSkill(_id) && !player.getAutoUseSettings().getAutoSupplyItems().contains(_id))
|
||||
{
|
||||
final List<Integer> positions = player.getVariables().getIntegerList(PlayerVariables.AUTO_USE_SHORTCUTS);
|
||||
final Integer position = _slot + (_page * ShortCuts.MAX_SHORTCUTS_PER_BAR);
|
||||
|
@ -99,7 +99,14 @@ public class ExRequestActivateAutoShortcut implements IClientIncomingPacket
|
||||
// auto skill
|
||||
if (skill != null)
|
||||
{
|
||||
AutoUseTaskManager.getInstance().removeAutoSkill(player, skill.getId());
|
||||
if (skill.isBad())
|
||||
{
|
||||
AutoUseTaskManager.getInstance().removeAutoSkill(player, skill.getId());
|
||||
}
|
||||
else
|
||||
{
|
||||
AutoUseTaskManager.getInstance().removeAutoBuff(player, skill.getId());
|
||||
}
|
||||
}
|
||||
else // action
|
||||
{
|
||||
@ -131,7 +138,14 @@ public class ExRequestActivateAutoShortcut implements IClientIncomingPacket
|
||||
// auto skill
|
||||
if (Config.ENABLE_AUTO_SKILL && (skill != null))
|
||||
{
|
||||
AutoUseTaskManager.getInstance().addAutoSkill(player, skill.getId());
|
||||
if (skill.isBad())
|
||||
{
|
||||
AutoUseTaskManager.getInstance().addAutoSkill(player, skill.getId());
|
||||
}
|
||||
else
|
||||
{
|
||||
AutoUseTaskManager.getInstance().addAutoBuff(player, skill.getId());
|
||||
}
|
||||
return;
|
||||
}
|
||||
// action
|
||||
|
@ -163,7 +163,7 @@ public class AutoUseTaskManager implements Runnable
|
||||
|
||||
if (Config.ENABLE_AUTO_SKILL)
|
||||
{
|
||||
BUFFS: for (Integer skillId : player.getAutoUseSettings().getAutoSkills())
|
||||
BUFFS: for (Integer skillId : player.getAutoUseSettings().getAutoBuffs())
|
||||
{
|
||||
// Fixes start area issue.
|
||||
if (isInPeaceZone)
|
||||
@ -186,13 +186,7 @@ public class AutoUseTaskManager implements Runnable
|
||||
final Skill skill = player.getKnownSkill(skillId.intValue());
|
||||
if (skill == null)
|
||||
{
|
||||
player.getAutoUseSettings().getAutoSkills().remove(skillId);
|
||||
continue BUFFS;
|
||||
}
|
||||
|
||||
// Not a buff.
|
||||
if (skill.isBad())
|
||||
{
|
||||
player.getAutoUseSettings().getAutoBuffs().remove(skillId);
|
||||
continue BUFFS;
|
||||
}
|
||||
|
||||
@ -220,7 +214,7 @@ public class AutoUseTaskManager implements Runnable
|
||||
continue;
|
||||
}
|
||||
|
||||
SKILLS: for (Integer skillId : player.getAutoUseSettings().getAutoSkills())
|
||||
SKILLS:
|
||||
{
|
||||
// Already casting.
|
||||
if (player.isCastingNow())
|
||||
@ -234,36 +228,32 @@ public class AutoUseTaskManager implements Runnable
|
||||
break SKILLS;
|
||||
}
|
||||
|
||||
final Skill skill = player.getKnownSkill(skillId.intValue());
|
||||
// Acquire next skill.
|
||||
final int skillId = player.getAutoUseSettings().getNextSkillId();
|
||||
final Skill skill = player.getKnownSkill(skillId);
|
||||
if (skill == null)
|
||||
{
|
||||
player.getAutoUseSettings().getAutoSkills().remove(skillId);
|
||||
continue SKILLS;
|
||||
}
|
||||
|
||||
// Not an offensive skill.
|
||||
if (!skill.isBad())
|
||||
{
|
||||
continue SKILLS;
|
||||
break SKILLS;
|
||||
}
|
||||
|
||||
// Casting on self stops movement.
|
||||
final WorldObject target = player.getTarget();
|
||||
if (target == player)
|
||||
{
|
||||
continue SKILLS;
|
||||
break SKILLS;
|
||||
}
|
||||
|
||||
// Check bad skill target.
|
||||
if ((target == null) || !target.isAttackable())
|
||||
{
|
||||
continue SKILLS;
|
||||
break SKILLS;
|
||||
}
|
||||
|
||||
// Do not attack guards.
|
||||
if (target instanceof GuardInstance)
|
||||
{
|
||||
continue SKILLS;
|
||||
break SKILLS;
|
||||
}
|
||||
|
||||
if (canUseMagic(player, target, skill))
|
||||
@ -361,6 +351,7 @@ public class AutoUseTaskManager implements Runnable
|
||||
|
||||
public void stopAutoUseTask(PlayerInstance player)
|
||||
{
|
||||
player.getAutoUseSettings().resetSkillOrder();
|
||||
if (player.getAutoUseSettings().isEmpty() || !player.isOnline() || player.isInOfflineMode())
|
||||
{
|
||||
PLAYERS.remove(player);
|
||||
@ -391,6 +382,18 @@ public class AutoUseTaskManager implements Runnable
|
||||
stopAutoUseTask(player);
|
||||
}
|
||||
|
||||
public void addAutoBuff(PlayerInstance player, int skillId)
|
||||
{
|
||||
player.getAutoUseSettings().getAutoBuffs().add(skillId);
|
||||
startAutoUseTask(player);
|
||||
}
|
||||
|
||||
public void removeAutoBuff(PlayerInstance player, int skillId)
|
||||
{
|
||||
player.getAutoUseSettings().getAutoBuffs().remove(skillId);
|
||||
stopAutoUseTask(player);
|
||||
}
|
||||
|
||||
public void addAutoSkill(PlayerInstance player, int skillId)
|
||||
{
|
||||
player.getAutoUseSettings().getAutoSkills().add(skillId);
|
||||
|
@ -10022,7 +10022,14 @@ public class PlayerInstance extends Playable
|
||||
// 9. Resend a class change animation effect to broadcast to all nearby players.
|
||||
for (Skill oldSkill : getAllSkills())
|
||||
{
|
||||
AutoUseTaskManager.getInstance().removeAutoSkill(this, oldSkill.getId());
|
||||
if (oldSkill.isBad())
|
||||
{
|
||||
AutoUseTaskManager.getInstance().removeAutoSkill(this, oldSkill.getId());
|
||||
}
|
||||
else
|
||||
{
|
||||
AutoUseTaskManager.getInstance().removeAutoBuff(this, oldSkill.getId());
|
||||
}
|
||||
removeSkill(oldSkill, false, true);
|
||||
}
|
||||
|
||||
@ -14471,7 +14478,7 @@ public class PlayerInstance extends Playable
|
||||
continue;
|
||||
}
|
||||
|
||||
if (_autoUseSettings.getAutoSkills().contains(shortcut.getId()))
|
||||
if (_autoUseSettings.isAutoSkill(shortcut.getId()))
|
||||
{
|
||||
if (getKnownSkill(shortcut.getId()) != null)
|
||||
{
|
||||
@ -14504,11 +14511,19 @@ public class PlayerInstance extends Playable
|
||||
continue;
|
||||
}
|
||||
|
||||
if (getKnownSkill(shortcut.getId()) != null)
|
||||
final Skill knownSkill = getKnownSkill(shortcut.getId());
|
||||
if (knownSkill != null)
|
||||
{
|
||||
shortcut.setAutoUse(true);
|
||||
sendPacket(new ExActivateAutoShortcut(shortcut, true));
|
||||
AutoUseTaskManager.getInstance().addAutoSkill(this, shortcut.getId());
|
||||
if (knownSkill.isBad())
|
||||
{
|
||||
AutoUseTaskManager.getInstance().addAutoSkill(this, shortcut.getId());
|
||||
}
|
||||
else
|
||||
{
|
||||
AutoUseTaskManager.getInstance().addAutoBuff(this, shortcut.getId());
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -17,7 +17,9 @@
|
||||
package org.l2jmobius.gameserver.model.holders;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.CopyOnWriteArrayList;
|
||||
|
||||
/**
|
||||
* @author Mobius
|
||||
@ -26,8 +28,10 @@ public class AutoUseSettingsHolder
|
||||
{
|
||||
private final Collection<Integer> _autoSupplyItems = ConcurrentHashMap.newKeySet();
|
||||
private final Collection<Integer> _autoPotionItems = ConcurrentHashMap.newKeySet();
|
||||
private final Collection<Integer> _autoSkills = ConcurrentHashMap.newKeySet();
|
||||
private final Collection<Integer> _autoActions = ConcurrentHashMap.newKeySet();
|
||||
private final Collection<Integer> _autoBuffs = ConcurrentHashMap.newKeySet();
|
||||
private final List<Integer> _autoSkills = new CopyOnWriteArrayList<>();
|
||||
private int _skillIndex = -1;
|
||||
|
||||
public AutoUseSettingsHolder()
|
||||
{
|
||||
@ -43,14 +47,50 @@ public class AutoUseSettingsHolder
|
||||
return _autoPotionItems;
|
||||
}
|
||||
|
||||
public Collection<Integer> getAutoActions()
|
||||
{
|
||||
return _autoActions;
|
||||
}
|
||||
|
||||
public Collection<Integer> getAutoBuffs()
|
||||
{
|
||||
return _autoBuffs;
|
||||
}
|
||||
|
||||
public Collection<Integer> getAutoSkills()
|
||||
{
|
||||
return _autoSkills;
|
||||
}
|
||||
|
||||
public Collection<Integer> getAutoActions()
|
||||
public boolean isAutoSkill(int skillId)
|
||||
{
|
||||
return _autoActions;
|
||||
return _autoSkills.contains(skillId) || _autoBuffs.contains(skillId);
|
||||
}
|
||||
|
||||
public int getNextSkillId()
|
||||
{
|
||||
_skillIndex++;
|
||||
if (_skillIndex >= _autoSkills.size())
|
||||
{
|
||||
_skillIndex = 0;
|
||||
}
|
||||
|
||||
int skillId = 0;
|
||||
try
|
||||
{
|
||||
skillId = _autoSkills.get(_skillIndex);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
resetSkillOrder();
|
||||
}
|
||||
|
||||
return skillId;
|
||||
}
|
||||
|
||||
public void resetSkillOrder()
|
||||
{
|
||||
_skillIndex = -1;
|
||||
}
|
||||
|
||||
public boolean isEmpty()
|
||||
|
@ -79,6 +79,7 @@ public class RequestShortCutDel implements IClientIncomingPacket
|
||||
}
|
||||
else
|
||||
{
|
||||
AutoUseTaskManager.getInstance().removeAutoBuff(player, id);
|
||||
AutoUseTaskManager.getInstance().removeAutoSkill(player, id);
|
||||
}
|
||||
player.restoreAutoShortcutVisual();
|
||||
|
@ -76,7 +76,7 @@ public class RequestShortCutReg implements IClientIncomingPacket
|
||||
player.sendPacket(new ExActivateAutoShortcut(sc, _active));
|
||||
|
||||
// When id is not auto used, deactivate auto shortcuts.
|
||||
if (!player.getAutoUseSettings().getAutoSkills().contains(_id) && !player.getAutoUseSettings().getAutoSupplyItems().contains(_id))
|
||||
if (!player.getAutoUseSettings().isAutoSkill(_id) && !player.getAutoUseSettings().getAutoSupplyItems().contains(_id))
|
||||
{
|
||||
final List<Integer> positions = player.getVariables().getIntegerList(PlayerVariables.AUTO_USE_SHORTCUTS);
|
||||
final Integer position = _slot + (_page * ShortCuts.MAX_SHORTCUTS_PER_BAR);
|
||||
|
@ -99,7 +99,14 @@ public class ExRequestActivateAutoShortcut implements IClientIncomingPacket
|
||||
// auto skill
|
||||
if (skill != null)
|
||||
{
|
||||
AutoUseTaskManager.getInstance().removeAutoSkill(player, skill.getId());
|
||||
if (skill.isBad())
|
||||
{
|
||||
AutoUseTaskManager.getInstance().removeAutoSkill(player, skill.getId());
|
||||
}
|
||||
else
|
||||
{
|
||||
AutoUseTaskManager.getInstance().removeAutoBuff(player, skill.getId());
|
||||
}
|
||||
}
|
||||
else // action
|
||||
{
|
||||
@ -131,7 +138,14 @@ public class ExRequestActivateAutoShortcut implements IClientIncomingPacket
|
||||
// auto skill
|
||||
if (Config.ENABLE_AUTO_SKILL && (skill != null))
|
||||
{
|
||||
AutoUseTaskManager.getInstance().addAutoSkill(player, skill.getId());
|
||||
if (skill.isBad())
|
||||
{
|
||||
AutoUseTaskManager.getInstance().addAutoSkill(player, skill.getId());
|
||||
}
|
||||
else
|
||||
{
|
||||
AutoUseTaskManager.getInstance().addAutoBuff(player, skill.getId());
|
||||
}
|
||||
return;
|
||||
}
|
||||
// action
|
||||
|
@ -163,7 +163,7 @@ public class AutoUseTaskManager implements Runnable
|
||||
|
||||
if (Config.ENABLE_AUTO_SKILL)
|
||||
{
|
||||
BUFFS: for (Integer skillId : player.getAutoUseSettings().getAutoSkills())
|
||||
BUFFS: for (Integer skillId : player.getAutoUseSettings().getAutoBuffs())
|
||||
{
|
||||
// Fixes start area issue.
|
||||
if (isInPeaceZone)
|
||||
@ -186,13 +186,7 @@ public class AutoUseTaskManager implements Runnable
|
||||
final Skill skill = player.getKnownSkill(skillId.intValue());
|
||||
if (skill == null)
|
||||
{
|
||||
player.getAutoUseSettings().getAutoSkills().remove(skillId);
|
||||
continue BUFFS;
|
||||
}
|
||||
|
||||
// Not a buff.
|
||||
if (skill.isBad())
|
||||
{
|
||||
player.getAutoUseSettings().getAutoBuffs().remove(skillId);
|
||||
continue BUFFS;
|
||||
}
|
||||
|
||||
@ -220,7 +214,7 @@ public class AutoUseTaskManager implements Runnable
|
||||
continue;
|
||||
}
|
||||
|
||||
SKILLS: for (Integer skillId : player.getAutoUseSettings().getAutoSkills())
|
||||
SKILLS:
|
||||
{
|
||||
// Already casting.
|
||||
if (player.isCastingNow())
|
||||
@ -234,36 +228,32 @@ public class AutoUseTaskManager implements Runnable
|
||||
break SKILLS;
|
||||
}
|
||||
|
||||
final Skill skill = player.getKnownSkill(skillId.intValue());
|
||||
// Acquire next skill.
|
||||
final int skillId = player.getAutoUseSettings().getNextSkillId();
|
||||
final Skill skill = player.getKnownSkill(skillId);
|
||||
if (skill == null)
|
||||
{
|
||||
player.getAutoUseSettings().getAutoSkills().remove(skillId);
|
||||
continue SKILLS;
|
||||
}
|
||||
|
||||
// Not an offensive skill.
|
||||
if (!skill.isBad())
|
||||
{
|
||||
continue SKILLS;
|
||||
break SKILLS;
|
||||
}
|
||||
|
||||
// Casting on self stops movement.
|
||||
final WorldObject target = player.getTarget();
|
||||
if (target == player)
|
||||
{
|
||||
continue SKILLS;
|
||||
break SKILLS;
|
||||
}
|
||||
|
||||
// Check bad skill target.
|
||||
if ((target == null) || !target.isAttackable())
|
||||
{
|
||||
continue SKILLS;
|
||||
break SKILLS;
|
||||
}
|
||||
|
||||
// Do not attack guards.
|
||||
if (target instanceof GuardInstance)
|
||||
{
|
||||
continue SKILLS;
|
||||
break SKILLS;
|
||||
}
|
||||
|
||||
if (canUseMagic(player, target, skill))
|
||||
@ -361,6 +351,7 @@ public class AutoUseTaskManager implements Runnable
|
||||
|
||||
public void stopAutoUseTask(PlayerInstance player)
|
||||
{
|
||||
player.getAutoUseSettings().resetSkillOrder();
|
||||
if (player.getAutoUseSettings().isEmpty() || !player.isOnline() || player.isInOfflineMode())
|
||||
{
|
||||
PLAYERS.remove(player);
|
||||
@ -391,6 +382,18 @@ public class AutoUseTaskManager implements Runnable
|
||||
stopAutoUseTask(player);
|
||||
}
|
||||
|
||||
public void addAutoBuff(PlayerInstance player, int skillId)
|
||||
{
|
||||
player.getAutoUseSettings().getAutoBuffs().add(skillId);
|
||||
startAutoUseTask(player);
|
||||
}
|
||||
|
||||
public void removeAutoBuff(PlayerInstance player, int skillId)
|
||||
{
|
||||
player.getAutoUseSettings().getAutoBuffs().remove(skillId);
|
||||
stopAutoUseTask(player);
|
||||
}
|
||||
|
||||
public void addAutoSkill(PlayerInstance player, int skillId)
|
||||
{
|
||||
player.getAutoUseSettings().getAutoSkills().add(skillId);
|
||||
|
@ -9770,7 +9770,14 @@ public class PlayerInstance extends Playable
|
||||
// 9. Resend a class change animation effect to broadcast to all nearby players.
|
||||
for (Skill oldSkill : getAllSkills())
|
||||
{
|
||||
AutoUseTaskManager.getInstance().removeAutoSkill(this, oldSkill.getId());
|
||||
if (oldSkill.isBad())
|
||||
{
|
||||
AutoUseTaskManager.getInstance().removeAutoSkill(this, oldSkill.getId());
|
||||
}
|
||||
else
|
||||
{
|
||||
AutoUseTaskManager.getInstance().removeAutoBuff(this, oldSkill.getId());
|
||||
}
|
||||
removeSkill(oldSkill, false, true);
|
||||
}
|
||||
|
||||
@ -14361,7 +14368,7 @@ public class PlayerInstance extends Playable
|
||||
continue;
|
||||
}
|
||||
|
||||
if (_autoUseSettings.getAutoSkills().contains(shortcut.getId()))
|
||||
if (_autoUseSettings.isAutoSkill(shortcut.getId()))
|
||||
{
|
||||
if (getKnownSkill(shortcut.getId()) != null)
|
||||
{
|
||||
@ -14394,11 +14401,19 @@ public class PlayerInstance extends Playable
|
||||
continue;
|
||||
}
|
||||
|
||||
if (getKnownSkill(shortcut.getId()) != null)
|
||||
final Skill knownSkill = getKnownSkill(shortcut.getId());
|
||||
if (knownSkill != null)
|
||||
{
|
||||
shortcut.setAutoUse(true);
|
||||
sendPacket(new ExActivateAutoShortcut(shortcut, true));
|
||||
AutoUseTaskManager.getInstance().addAutoSkill(this, shortcut.getId());
|
||||
if (knownSkill.isBad())
|
||||
{
|
||||
AutoUseTaskManager.getInstance().addAutoSkill(this, shortcut.getId());
|
||||
}
|
||||
else
|
||||
{
|
||||
AutoUseTaskManager.getInstance().addAutoBuff(this, shortcut.getId());
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -17,7 +17,9 @@
|
||||
package org.l2jmobius.gameserver.model.holders;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.CopyOnWriteArrayList;
|
||||
|
||||
/**
|
||||
* @author Mobius
|
||||
@ -26,8 +28,10 @@ public class AutoUseSettingsHolder
|
||||
{
|
||||
private final Collection<Integer> _autoSupplyItems = ConcurrentHashMap.newKeySet();
|
||||
private final Collection<Integer> _autoPotionItems = ConcurrentHashMap.newKeySet();
|
||||
private final Collection<Integer> _autoSkills = ConcurrentHashMap.newKeySet();
|
||||
private final Collection<Integer> _autoActions = ConcurrentHashMap.newKeySet();
|
||||
private final Collection<Integer> _autoBuffs = ConcurrentHashMap.newKeySet();
|
||||
private final List<Integer> _autoSkills = new CopyOnWriteArrayList<>();
|
||||
private int _skillIndex = -1;
|
||||
|
||||
public AutoUseSettingsHolder()
|
||||
{
|
||||
@ -43,14 +47,50 @@ public class AutoUseSettingsHolder
|
||||
return _autoPotionItems;
|
||||
}
|
||||
|
||||
public Collection<Integer> getAutoActions()
|
||||
{
|
||||
return _autoActions;
|
||||
}
|
||||
|
||||
public Collection<Integer> getAutoBuffs()
|
||||
{
|
||||
return _autoBuffs;
|
||||
}
|
||||
|
||||
public Collection<Integer> getAutoSkills()
|
||||
{
|
||||
return _autoSkills;
|
||||
}
|
||||
|
||||
public Collection<Integer> getAutoActions()
|
||||
public boolean isAutoSkill(int skillId)
|
||||
{
|
||||
return _autoActions;
|
||||
return _autoSkills.contains(skillId) || _autoBuffs.contains(skillId);
|
||||
}
|
||||
|
||||
public int getNextSkillId()
|
||||
{
|
||||
_skillIndex++;
|
||||
if (_skillIndex >= _autoSkills.size())
|
||||
{
|
||||
_skillIndex = 0;
|
||||
}
|
||||
|
||||
int skillId = 0;
|
||||
try
|
||||
{
|
||||
skillId = _autoSkills.get(_skillIndex);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
resetSkillOrder();
|
||||
}
|
||||
|
||||
return skillId;
|
||||
}
|
||||
|
||||
public void resetSkillOrder()
|
||||
{
|
||||
_skillIndex = -1;
|
||||
}
|
||||
|
||||
public boolean isEmpty()
|
||||
|
@ -79,6 +79,7 @@ public class RequestShortCutDel implements IClientIncomingPacket
|
||||
}
|
||||
else
|
||||
{
|
||||
AutoUseTaskManager.getInstance().removeAutoBuff(player, id);
|
||||
AutoUseTaskManager.getInstance().removeAutoSkill(player, id);
|
||||
}
|
||||
player.restoreAutoShortcutVisual();
|
||||
|
@ -76,7 +76,7 @@ public class RequestShortCutReg implements IClientIncomingPacket
|
||||
player.sendPacket(new ExActivateAutoShortcut(sc, _active));
|
||||
|
||||
// When id is not auto used, deactivate auto shortcuts.
|
||||
if (!player.getAutoUseSettings().getAutoSkills().contains(_id) && !player.getAutoUseSettings().getAutoSupplyItems().contains(_id))
|
||||
if (!player.getAutoUseSettings().isAutoSkill(_id) && !player.getAutoUseSettings().getAutoSupplyItems().contains(_id))
|
||||
{
|
||||
final List<Integer> positions = player.getVariables().getIntegerList(PlayerVariables.AUTO_USE_SHORTCUTS);
|
||||
final Integer position = _slot + (_page * ShortCuts.MAX_SHORTCUTS_PER_BAR);
|
||||
|
@ -99,7 +99,14 @@ public class ExRequestActivateAutoShortcut implements IClientIncomingPacket
|
||||
// auto skill
|
||||
if (skill != null)
|
||||
{
|
||||
AutoUseTaskManager.getInstance().removeAutoSkill(player, skill.getId());
|
||||
if (skill.isBad())
|
||||
{
|
||||
AutoUseTaskManager.getInstance().removeAutoSkill(player, skill.getId());
|
||||
}
|
||||
else
|
||||
{
|
||||
AutoUseTaskManager.getInstance().removeAutoBuff(player, skill.getId());
|
||||
}
|
||||
}
|
||||
else // action
|
||||
{
|
||||
@ -131,7 +138,14 @@ public class ExRequestActivateAutoShortcut implements IClientIncomingPacket
|
||||
// auto skill
|
||||
if (Config.ENABLE_AUTO_SKILL && (skill != null))
|
||||
{
|
||||
AutoUseTaskManager.getInstance().addAutoSkill(player, skill.getId());
|
||||
if (skill.isBad())
|
||||
{
|
||||
AutoUseTaskManager.getInstance().addAutoSkill(player, skill.getId());
|
||||
}
|
||||
else
|
||||
{
|
||||
AutoUseTaskManager.getInstance().addAutoBuff(player, skill.getId());
|
||||
}
|
||||
return;
|
||||
}
|
||||
// action
|
||||
|
@ -163,7 +163,7 @@ public class AutoUseTaskManager implements Runnable
|
||||
|
||||
if (Config.ENABLE_AUTO_SKILL)
|
||||
{
|
||||
BUFFS: for (Integer skillId : player.getAutoUseSettings().getAutoSkills())
|
||||
BUFFS: for (Integer skillId : player.getAutoUseSettings().getAutoBuffs())
|
||||
{
|
||||
// Fixes start area issue.
|
||||
if (isInPeaceZone)
|
||||
@ -186,13 +186,7 @@ public class AutoUseTaskManager implements Runnable
|
||||
final Skill skill = player.getKnownSkill(skillId.intValue());
|
||||
if (skill == null)
|
||||
{
|
||||
player.getAutoUseSettings().getAutoSkills().remove(skillId);
|
||||
continue BUFFS;
|
||||
}
|
||||
|
||||
// Not a buff.
|
||||
if (skill.isBad())
|
||||
{
|
||||
player.getAutoUseSettings().getAutoBuffs().remove(skillId);
|
||||
continue BUFFS;
|
||||
}
|
||||
|
||||
@ -220,7 +214,7 @@ public class AutoUseTaskManager implements Runnable
|
||||
continue;
|
||||
}
|
||||
|
||||
SKILLS: for (Integer skillId : player.getAutoUseSettings().getAutoSkills())
|
||||
SKILLS:
|
||||
{
|
||||
// Already casting.
|
||||
if (player.isCastingNow())
|
||||
@ -234,36 +228,32 @@ public class AutoUseTaskManager implements Runnable
|
||||
break SKILLS;
|
||||
}
|
||||
|
||||
final Skill skill = player.getKnownSkill(skillId.intValue());
|
||||
// Acquire next skill.
|
||||
final int skillId = player.getAutoUseSettings().getNextSkillId();
|
||||
final Skill skill = player.getKnownSkill(skillId);
|
||||
if (skill == null)
|
||||
{
|
||||
player.getAutoUseSettings().getAutoSkills().remove(skillId);
|
||||
continue SKILLS;
|
||||
}
|
||||
|
||||
// Not an offensive skill.
|
||||
if (!skill.isBad())
|
||||
{
|
||||
continue SKILLS;
|
||||
break SKILLS;
|
||||
}
|
||||
|
||||
// Casting on self stops movement.
|
||||
final WorldObject target = player.getTarget();
|
||||
if (target == player)
|
||||
{
|
||||
continue SKILLS;
|
||||
break SKILLS;
|
||||
}
|
||||
|
||||
// Check bad skill target.
|
||||
if ((target == null) || !target.isAttackable())
|
||||
{
|
||||
continue SKILLS;
|
||||
break SKILLS;
|
||||
}
|
||||
|
||||
// Do not attack guards.
|
||||
if (target instanceof GuardInstance)
|
||||
{
|
||||
continue SKILLS;
|
||||
break SKILLS;
|
||||
}
|
||||
|
||||
if (canUseMagic(player, target, skill))
|
||||
@ -361,6 +351,7 @@ public class AutoUseTaskManager implements Runnable
|
||||
|
||||
public void stopAutoUseTask(PlayerInstance player)
|
||||
{
|
||||
player.getAutoUseSettings().resetSkillOrder();
|
||||
if (player.getAutoUseSettings().isEmpty() || !player.isOnline() || player.isInOfflineMode())
|
||||
{
|
||||
PLAYERS.remove(player);
|
||||
@ -391,6 +382,18 @@ public class AutoUseTaskManager implements Runnable
|
||||
stopAutoUseTask(player);
|
||||
}
|
||||
|
||||
public void addAutoBuff(PlayerInstance player, int skillId)
|
||||
{
|
||||
player.getAutoUseSettings().getAutoBuffs().add(skillId);
|
||||
startAutoUseTask(player);
|
||||
}
|
||||
|
||||
public void removeAutoBuff(PlayerInstance player, int skillId)
|
||||
{
|
||||
player.getAutoUseSettings().getAutoBuffs().remove(skillId);
|
||||
stopAutoUseTask(player);
|
||||
}
|
||||
|
||||
public void addAutoSkill(PlayerInstance player, int skillId)
|
||||
{
|
||||
player.getAutoUseSettings().getAutoSkills().add(skillId);
|
||||
|
@ -9923,7 +9923,14 @@ public class PlayerInstance extends Playable
|
||||
// 9. Resend a class change animation effect to broadcast to all nearby players.
|
||||
for (Skill oldSkill : getAllSkills())
|
||||
{
|
||||
AutoUseTaskManager.getInstance().removeAutoSkill(this, oldSkill.getId());
|
||||
if (oldSkill.isBad())
|
||||
{
|
||||
AutoUseTaskManager.getInstance().removeAutoSkill(this, oldSkill.getId());
|
||||
}
|
||||
else
|
||||
{
|
||||
AutoUseTaskManager.getInstance().removeAutoBuff(this, oldSkill.getId());
|
||||
}
|
||||
removeSkill(oldSkill, false, true);
|
||||
}
|
||||
|
||||
@ -14621,7 +14628,7 @@ public class PlayerInstance extends Playable
|
||||
continue;
|
||||
}
|
||||
|
||||
if (_autoUseSettings.getAutoSkills().contains(shortcut.getId()))
|
||||
if (_autoUseSettings.isAutoSkill(shortcut.getId()))
|
||||
{
|
||||
if (getKnownSkill(shortcut.getId()) != null)
|
||||
{
|
||||
@ -14654,11 +14661,19 @@ public class PlayerInstance extends Playable
|
||||
continue;
|
||||
}
|
||||
|
||||
if (getKnownSkill(shortcut.getId()) != null)
|
||||
final Skill knownSkill = getKnownSkill(shortcut.getId());
|
||||
if (knownSkill != null)
|
||||
{
|
||||
shortcut.setAutoUse(true);
|
||||
sendPacket(new ExActivateAutoShortcut(shortcut, true));
|
||||
AutoUseTaskManager.getInstance().addAutoSkill(this, shortcut.getId());
|
||||
if (knownSkill.isBad())
|
||||
{
|
||||
AutoUseTaskManager.getInstance().addAutoSkill(this, shortcut.getId());
|
||||
}
|
||||
else
|
||||
{
|
||||
AutoUseTaskManager.getInstance().addAutoBuff(this, shortcut.getId());
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -17,7 +17,9 @@
|
||||
package org.l2jmobius.gameserver.model.holders;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.CopyOnWriteArrayList;
|
||||
|
||||
/**
|
||||
* @author Mobius
|
||||
@ -26,8 +28,10 @@ public class AutoUseSettingsHolder
|
||||
{
|
||||
private final Collection<Integer> _autoSupplyItems = ConcurrentHashMap.newKeySet();
|
||||
private final Collection<Integer> _autoPotionItems = ConcurrentHashMap.newKeySet();
|
||||
private final Collection<Integer> _autoSkills = ConcurrentHashMap.newKeySet();
|
||||
private final Collection<Integer> _autoActions = ConcurrentHashMap.newKeySet();
|
||||
private final Collection<Integer> _autoBuffs = ConcurrentHashMap.newKeySet();
|
||||
private final List<Integer> _autoSkills = new CopyOnWriteArrayList<>();
|
||||
private int _skillIndex = -1;
|
||||
|
||||
public AutoUseSettingsHolder()
|
||||
{
|
||||
@ -43,14 +47,50 @@ public class AutoUseSettingsHolder
|
||||
return _autoPotionItems;
|
||||
}
|
||||
|
||||
public Collection<Integer> getAutoActions()
|
||||
{
|
||||
return _autoActions;
|
||||
}
|
||||
|
||||
public Collection<Integer> getAutoBuffs()
|
||||
{
|
||||
return _autoBuffs;
|
||||
}
|
||||
|
||||
public Collection<Integer> getAutoSkills()
|
||||
{
|
||||
return _autoSkills;
|
||||
}
|
||||
|
||||
public Collection<Integer> getAutoActions()
|
||||
public boolean isAutoSkill(int skillId)
|
||||
{
|
||||
return _autoActions;
|
||||
return _autoSkills.contains(skillId) || _autoBuffs.contains(skillId);
|
||||
}
|
||||
|
||||
public int getNextSkillId()
|
||||
{
|
||||
_skillIndex++;
|
||||
if (_skillIndex >= _autoSkills.size())
|
||||
{
|
||||
_skillIndex = 0;
|
||||
}
|
||||
|
||||
int skillId = 0;
|
||||
try
|
||||
{
|
||||
skillId = _autoSkills.get(_skillIndex);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
resetSkillOrder();
|
||||
}
|
||||
|
||||
return skillId;
|
||||
}
|
||||
|
||||
public void resetSkillOrder()
|
||||
{
|
||||
_skillIndex = -1;
|
||||
}
|
||||
|
||||
public boolean isEmpty()
|
||||
|
@ -79,6 +79,7 @@ public class RequestShortCutDel implements IClientIncomingPacket
|
||||
}
|
||||
else
|
||||
{
|
||||
AutoUseTaskManager.getInstance().removeAutoBuff(player, id);
|
||||
AutoUseTaskManager.getInstance().removeAutoSkill(player, id);
|
||||
}
|
||||
player.restoreAutoShortcutVisual();
|
||||
|
@ -76,7 +76,7 @@ public class RequestShortCutReg implements IClientIncomingPacket
|
||||
player.sendPacket(new ExActivateAutoShortcut(sc, _active));
|
||||
|
||||
// When id is not auto used, deactivate auto shortcuts.
|
||||
if (!player.getAutoUseSettings().getAutoSkills().contains(_id) && !player.getAutoUseSettings().getAutoSupplyItems().contains(_id))
|
||||
if (!player.getAutoUseSettings().isAutoSkill(_id) && !player.getAutoUseSettings().getAutoSupplyItems().contains(_id))
|
||||
{
|
||||
final List<Integer> positions = player.getVariables().getIntegerList(PlayerVariables.AUTO_USE_SHORTCUTS);
|
||||
final Integer position = _slot + (_page * ShortCuts.MAX_SHORTCUTS_PER_BAR);
|
||||
|
@ -99,7 +99,14 @@ public class ExRequestActivateAutoShortcut implements IClientIncomingPacket
|
||||
// auto skill
|
||||
if (skill != null)
|
||||
{
|
||||
AutoUseTaskManager.getInstance().removeAutoSkill(player, skill.getId());
|
||||
if (skill.isBad())
|
||||
{
|
||||
AutoUseTaskManager.getInstance().removeAutoSkill(player, skill.getId());
|
||||
}
|
||||
else
|
||||
{
|
||||
AutoUseTaskManager.getInstance().removeAutoBuff(player, skill.getId());
|
||||
}
|
||||
}
|
||||
else // action
|
||||
{
|
||||
@ -131,7 +138,14 @@ public class ExRequestActivateAutoShortcut implements IClientIncomingPacket
|
||||
// auto skill
|
||||
if (Config.ENABLE_AUTO_SKILL && (skill != null))
|
||||
{
|
||||
AutoUseTaskManager.getInstance().addAutoSkill(player, skill.getId());
|
||||
if (skill.isBad())
|
||||
{
|
||||
AutoUseTaskManager.getInstance().addAutoSkill(player, skill.getId());
|
||||
}
|
||||
else
|
||||
{
|
||||
AutoUseTaskManager.getInstance().addAutoBuff(player, skill.getId());
|
||||
}
|
||||
return;
|
||||
}
|
||||
// action
|
||||
|
@ -163,7 +163,7 @@ public class AutoUseTaskManager implements Runnable
|
||||
|
||||
if (Config.ENABLE_AUTO_SKILL)
|
||||
{
|
||||
BUFFS: for (Integer skillId : player.getAutoUseSettings().getAutoSkills())
|
||||
BUFFS: for (Integer skillId : player.getAutoUseSettings().getAutoBuffs())
|
||||
{
|
||||
// Fixes start area issue.
|
||||
if (isInPeaceZone)
|
||||
@ -186,13 +186,7 @@ public class AutoUseTaskManager implements Runnable
|
||||
final Skill skill = player.getKnownSkill(skillId.intValue());
|
||||
if (skill == null)
|
||||
{
|
||||
player.getAutoUseSettings().getAutoSkills().remove(skillId);
|
||||
continue BUFFS;
|
||||
}
|
||||
|
||||
// Not a buff.
|
||||
if (skill.isBad())
|
||||
{
|
||||
player.getAutoUseSettings().getAutoBuffs().remove(skillId);
|
||||
continue BUFFS;
|
||||
}
|
||||
|
||||
@ -220,7 +214,7 @@ public class AutoUseTaskManager implements Runnable
|
||||
continue;
|
||||
}
|
||||
|
||||
SKILLS: for (Integer skillId : player.getAutoUseSettings().getAutoSkills())
|
||||
SKILLS:
|
||||
{
|
||||
// Already casting.
|
||||
if (player.isCastingNow())
|
||||
@ -234,36 +228,32 @@ public class AutoUseTaskManager implements Runnable
|
||||
break SKILLS;
|
||||
}
|
||||
|
||||
final Skill skill = player.getKnownSkill(skillId.intValue());
|
||||
// Acquire next skill.
|
||||
final int skillId = player.getAutoUseSettings().getNextSkillId();
|
||||
final Skill skill = player.getKnownSkill(skillId);
|
||||
if (skill == null)
|
||||
{
|
||||
player.getAutoUseSettings().getAutoSkills().remove(skillId);
|
||||
continue SKILLS;
|
||||
}
|
||||
|
||||
// Not an offensive skill.
|
||||
if (!skill.isBad())
|
||||
{
|
||||
continue SKILLS;
|
||||
break SKILLS;
|
||||
}
|
||||
|
||||
// Casting on self stops movement.
|
||||
final WorldObject target = player.getTarget();
|
||||
if (target == player)
|
||||
{
|
||||
continue SKILLS;
|
||||
break SKILLS;
|
||||
}
|
||||
|
||||
// Check bad skill target.
|
||||
if ((target == null) || !target.isAttackable())
|
||||
{
|
||||
continue SKILLS;
|
||||
break SKILLS;
|
||||
}
|
||||
|
||||
// Do not attack guards.
|
||||
if (target instanceof GuardInstance)
|
||||
{
|
||||
continue SKILLS;
|
||||
break SKILLS;
|
||||
}
|
||||
|
||||
if (canUseMagic(player, target, skill))
|
||||
@ -361,6 +351,7 @@ public class AutoUseTaskManager implements Runnable
|
||||
|
||||
public void stopAutoUseTask(PlayerInstance player)
|
||||
{
|
||||
player.getAutoUseSettings().resetSkillOrder();
|
||||
if (player.getAutoUseSettings().isEmpty() || !player.isOnline() || player.isInOfflineMode())
|
||||
{
|
||||
PLAYERS.remove(player);
|
||||
@ -391,6 +382,18 @@ public class AutoUseTaskManager implements Runnable
|
||||
stopAutoUseTask(player);
|
||||
}
|
||||
|
||||
public void addAutoBuff(PlayerInstance player, int skillId)
|
||||
{
|
||||
player.getAutoUseSettings().getAutoBuffs().add(skillId);
|
||||
startAutoUseTask(player);
|
||||
}
|
||||
|
||||
public void removeAutoBuff(PlayerInstance player, int skillId)
|
||||
{
|
||||
player.getAutoUseSettings().getAutoBuffs().remove(skillId);
|
||||
stopAutoUseTask(player);
|
||||
}
|
||||
|
||||
public void addAutoSkill(PlayerInstance player, int skillId)
|
||||
{
|
||||
player.getAutoUseSettings().getAutoSkills().add(skillId);
|
||||
|
@ -9989,7 +9989,14 @@ public class PlayerInstance extends Playable
|
||||
// 9. Resend a class change animation effect to broadcast to all nearby players.
|
||||
for (Skill oldSkill : getAllSkills())
|
||||
{
|
||||
AutoUseTaskManager.getInstance().removeAutoSkill(this, oldSkill.getId());
|
||||
if (oldSkill.isBad())
|
||||
{
|
||||
AutoUseTaskManager.getInstance().removeAutoSkill(this, oldSkill.getId());
|
||||
}
|
||||
else
|
||||
{
|
||||
AutoUseTaskManager.getInstance().removeAutoBuff(this, oldSkill.getId());
|
||||
}
|
||||
removeSkill(oldSkill, false, true);
|
||||
}
|
||||
|
||||
@ -14698,7 +14705,7 @@ public class PlayerInstance extends Playable
|
||||
continue;
|
||||
}
|
||||
|
||||
if (_autoUseSettings.getAutoSkills().contains(shortcut.getId()))
|
||||
if (_autoUseSettings.isAutoSkill(shortcut.getId()))
|
||||
{
|
||||
if (getKnownSkill(shortcut.getId()) != null)
|
||||
{
|
||||
@ -14731,11 +14738,19 @@ public class PlayerInstance extends Playable
|
||||
continue;
|
||||
}
|
||||
|
||||
if (getKnownSkill(shortcut.getId()) != null)
|
||||
final Skill knownSkill = getKnownSkill(shortcut.getId());
|
||||
if (knownSkill != null)
|
||||
{
|
||||
shortcut.setAutoUse(true);
|
||||
sendPacket(new ExActivateAutoShortcut(shortcut, true));
|
||||
AutoUseTaskManager.getInstance().addAutoSkill(this, shortcut.getId());
|
||||
if (knownSkill.isBad())
|
||||
{
|
||||
AutoUseTaskManager.getInstance().addAutoSkill(this, shortcut.getId());
|
||||
}
|
||||
else
|
||||
{
|
||||
AutoUseTaskManager.getInstance().addAutoBuff(this, shortcut.getId());
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -17,7 +17,9 @@
|
||||
package org.l2jmobius.gameserver.model.holders;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.CopyOnWriteArrayList;
|
||||
|
||||
/**
|
||||
* @author Mobius
|
||||
@ -26,8 +28,10 @@ public class AutoUseSettingsHolder
|
||||
{
|
||||
private final Collection<Integer> _autoSupplyItems = ConcurrentHashMap.newKeySet();
|
||||
private final Collection<Integer> _autoPotionItems = ConcurrentHashMap.newKeySet();
|
||||
private final Collection<Integer> _autoSkills = ConcurrentHashMap.newKeySet();
|
||||
private final Collection<Integer> _autoActions = ConcurrentHashMap.newKeySet();
|
||||
private final Collection<Integer> _autoBuffs = ConcurrentHashMap.newKeySet();
|
||||
private final List<Integer> _autoSkills = new CopyOnWriteArrayList<>();
|
||||
private int _skillIndex = -1;
|
||||
|
||||
public AutoUseSettingsHolder()
|
||||
{
|
||||
@ -43,14 +47,50 @@ public class AutoUseSettingsHolder
|
||||
return _autoPotionItems;
|
||||
}
|
||||
|
||||
public Collection<Integer> getAutoActions()
|
||||
{
|
||||
return _autoActions;
|
||||
}
|
||||
|
||||
public Collection<Integer> getAutoBuffs()
|
||||
{
|
||||
return _autoBuffs;
|
||||
}
|
||||
|
||||
public Collection<Integer> getAutoSkills()
|
||||
{
|
||||
return _autoSkills;
|
||||
}
|
||||
|
||||
public Collection<Integer> getAutoActions()
|
||||
public boolean isAutoSkill(int skillId)
|
||||
{
|
||||
return _autoActions;
|
||||
return _autoSkills.contains(skillId) || _autoBuffs.contains(skillId);
|
||||
}
|
||||
|
||||
public int getNextSkillId()
|
||||
{
|
||||
_skillIndex++;
|
||||
if (_skillIndex >= _autoSkills.size())
|
||||
{
|
||||
_skillIndex = 0;
|
||||
}
|
||||
|
||||
int skillId = 0;
|
||||
try
|
||||
{
|
||||
skillId = _autoSkills.get(_skillIndex);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
resetSkillOrder();
|
||||
}
|
||||
|
||||
return skillId;
|
||||
}
|
||||
|
||||
public void resetSkillOrder()
|
||||
{
|
||||
_skillIndex = -1;
|
||||
}
|
||||
|
||||
public boolean isEmpty()
|
||||
|
@ -79,6 +79,7 @@ public class RequestShortCutDel implements IClientIncomingPacket
|
||||
}
|
||||
else
|
||||
{
|
||||
AutoUseTaskManager.getInstance().removeAutoBuff(player, id);
|
||||
AutoUseTaskManager.getInstance().removeAutoSkill(player, id);
|
||||
}
|
||||
player.restoreAutoShortcutVisual();
|
||||
|
@ -76,7 +76,7 @@ public class RequestShortCutReg implements IClientIncomingPacket
|
||||
player.sendPacket(new ExActivateAutoShortcut(sc, _active));
|
||||
|
||||
// When id is not auto used, deactivate auto shortcuts.
|
||||
if (!player.getAutoUseSettings().getAutoSkills().contains(_id) && !player.getAutoUseSettings().getAutoSupplyItems().contains(_id))
|
||||
if (!player.getAutoUseSettings().isAutoSkill(_id) && !player.getAutoUseSettings().getAutoSupplyItems().contains(_id))
|
||||
{
|
||||
final List<Integer> positions = player.getVariables().getIntegerList(PlayerVariables.AUTO_USE_SHORTCUTS);
|
||||
final Integer position = _slot + (_page * ShortCuts.MAX_SHORTCUTS_PER_BAR);
|
||||
|
@ -99,7 +99,14 @@ public class ExRequestActivateAutoShortcut implements IClientIncomingPacket
|
||||
// auto skill
|
||||
if (skill != null)
|
||||
{
|
||||
AutoUseTaskManager.getInstance().removeAutoSkill(player, skill.getId());
|
||||
if (skill.isBad())
|
||||
{
|
||||
AutoUseTaskManager.getInstance().removeAutoSkill(player, skill.getId());
|
||||
}
|
||||
else
|
||||
{
|
||||
AutoUseTaskManager.getInstance().removeAutoBuff(player, skill.getId());
|
||||
}
|
||||
}
|
||||
else // action
|
||||
{
|
||||
@ -131,7 +138,14 @@ public class ExRequestActivateAutoShortcut implements IClientIncomingPacket
|
||||
// auto skill
|
||||
if (Config.ENABLE_AUTO_SKILL && (skill != null))
|
||||
{
|
||||
AutoUseTaskManager.getInstance().addAutoSkill(player, skill.getId());
|
||||
if (skill.isBad())
|
||||
{
|
||||
AutoUseTaskManager.getInstance().addAutoSkill(player, skill.getId());
|
||||
}
|
||||
else
|
||||
{
|
||||
AutoUseTaskManager.getInstance().addAutoBuff(player, skill.getId());
|
||||
}
|
||||
return;
|
||||
}
|
||||
// action
|
||||
|
@ -163,7 +163,7 @@ public class AutoUseTaskManager implements Runnable
|
||||
|
||||
if (Config.ENABLE_AUTO_SKILL)
|
||||
{
|
||||
BUFFS: for (Integer skillId : player.getAutoUseSettings().getAutoSkills())
|
||||
BUFFS: for (Integer skillId : player.getAutoUseSettings().getAutoBuffs())
|
||||
{
|
||||
// Fixes start area issue.
|
||||
if (isInPeaceZone)
|
||||
@ -186,13 +186,7 @@ public class AutoUseTaskManager implements Runnable
|
||||
final Skill skill = player.getKnownSkill(skillId.intValue());
|
||||
if (skill == null)
|
||||
{
|
||||
player.getAutoUseSettings().getAutoSkills().remove(skillId);
|
||||
continue BUFFS;
|
||||
}
|
||||
|
||||
// Not a buff.
|
||||
if (skill.isBad())
|
||||
{
|
||||
player.getAutoUseSettings().getAutoBuffs().remove(skillId);
|
||||
continue BUFFS;
|
||||
}
|
||||
|
||||
@ -220,7 +214,7 @@ public class AutoUseTaskManager implements Runnable
|
||||
continue;
|
||||
}
|
||||
|
||||
SKILLS: for (Integer skillId : player.getAutoUseSettings().getAutoSkills())
|
||||
SKILLS:
|
||||
{
|
||||
// Already casting.
|
||||
if (player.isCastingNow())
|
||||
@ -234,36 +228,32 @@ public class AutoUseTaskManager implements Runnable
|
||||
break SKILLS;
|
||||
}
|
||||
|
||||
final Skill skill = player.getKnownSkill(skillId.intValue());
|
||||
// Acquire next skill.
|
||||
final int skillId = player.getAutoUseSettings().getNextSkillId();
|
||||
final Skill skill = player.getKnownSkill(skillId);
|
||||
if (skill == null)
|
||||
{
|
||||
player.getAutoUseSettings().getAutoSkills().remove(skillId);
|
||||
continue SKILLS;
|
||||
}
|
||||
|
||||
// Not an offensive skill.
|
||||
if (!skill.isBad())
|
||||
{
|
||||
continue SKILLS;
|
||||
break SKILLS;
|
||||
}
|
||||
|
||||
// Casting on self stops movement.
|
||||
final WorldObject target = player.getTarget();
|
||||
if (target == player)
|
||||
{
|
||||
continue SKILLS;
|
||||
break SKILLS;
|
||||
}
|
||||
|
||||
// Check bad skill target.
|
||||
if ((target == null) || !target.isAttackable())
|
||||
{
|
||||
continue SKILLS;
|
||||
break SKILLS;
|
||||
}
|
||||
|
||||
// Do not attack guards.
|
||||
if (target instanceof GuardInstance)
|
||||
{
|
||||
continue SKILLS;
|
||||
break SKILLS;
|
||||
}
|
||||
|
||||
if (canUseMagic(player, target, skill))
|
||||
@ -361,6 +351,7 @@ public class AutoUseTaskManager implements Runnable
|
||||
|
||||
public void stopAutoUseTask(PlayerInstance player)
|
||||
{
|
||||
player.getAutoUseSettings().resetSkillOrder();
|
||||
if (player.getAutoUseSettings().isEmpty() || !player.isOnline() || player.isInOfflineMode())
|
||||
{
|
||||
PLAYERS.remove(player);
|
||||
@ -391,6 +382,18 @@ public class AutoUseTaskManager implements Runnable
|
||||
stopAutoUseTask(player);
|
||||
}
|
||||
|
||||
public void addAutoBuff(PlayerInstance player, int skillId)
|
||||
{
|
||||
player.getAutoUseSettings().getAutoBuffs().add(skillId);
|
||||
startAutoUseTask(player);
|
||||
}
|
||||
|
||||
public void removeAutoBuff(PlayerInstance player, int skillId)
|
||||
{
|
||||
player.getAutoUseSettings().getAutoBuffs().remove(skillId);
|
||||
stopAutoUseTask(player);
|
||||
}
|
||||
|
||||
public void addAutoSkill(PlayerInstance player, int skillId)
|
||||
{
|
||||
player.getAutoUseSettings().getAutoSkills().add(skillId);
|
||||
|
Loading…
Reference in New Issue
Block a user