diff --git a/L2J_Mobius_7.0_PreludeOfWar/java/org/l2jmobius/gameserver/model/holders/AutoUseSettingsHolder.java b/L2J_Mobius_7.0_PreludeOfWar/java/org/l2jmobius/gameserver/model/holders/AutoUseSettingsHolder.java index f48e580ad3..4a25e54d51 100644 --- a/L2J_Mobius_7.0_PreludeOfWar/java/org/l2jmobius/gameserver/model/holders/AutoUseSettingsHolder.java +++ b/L2J_Mobius_7.0_PreludeOfWar/java/org/l2jmobius/gameserver/model/holders/AutoUseSettingsHolder.java @@ -27,6 +27,7 @@ public class AutoUseSettingsHolder private final Collection _autoSupplyItems = ConcurrentHashMap.newKeySet(); private final Collection _autoPotionItems = ConcurrentHashMap.newKeySet(); private final Collection _autoSkills = ConcurrentHashMap.newKeySet(); + private final Collection _autoActions = ConcurrentHashMap.newKeySet(); public AutoUseSettingsHolder() { @@ -46,4 +47,9 @@ public class AutoUseSettingsHolder { return _autoSkills; } + + public Collection getAutoActions() + { + return _autoActions; + } } diff --git a/L2J_Mobius_7.0_PreludeOfWar/java/org/l2jmobius/gameserver/network/clientpackets/autoplay/ExRequestActivateAutoShortcut.java b/L2J_Mobius_7.0_PreludeOfWar/java/org/l2jmobius/gameserver/network/clientpackets/autoplay/ExRequestActivateAutoShortcut.java index 9411b3bf7b..9cb455794c 100644 --- a/L2J_Mobius_7.0_PreludeOfWar/java/org/l2jmobius/gameserver/network/clientpackets/autoplay/ExRequestActivateAutoShortcut.java +++ b/L2J_Mobius_7.0_PreludeOfWar/java/org/l2jmobius/gameserver/network/clientpackets/autoplay/ExRequestActivateAutoShortcut.java @@ -18,6 +18,10 @@ package org.l2jmobius.gameserver.network.clientpackets.autoplay; import org.l2jmobius.Config; import org.l2jmobius.commons.network.PacketReader; +import org.l2jmobius.gameserver.data.xml.ActionData; +import org.l2jmobius.gameserver.handler.IPlayerActionHandler; +import org.l2jmobius.gameserver.handler.PlayerActionHandler; +import org.l2jmobius.gameserver.model.ActionDataHolder; import org.l2jmobius.gameserver.model.Shortcut; import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance; import org.l2jmobius.gameserver.model.items.instance.ItemInstance; @@ -88,6 +92,10 @@ public class ExRequestActivateAutoShortcut implements IClientIncomingPacket { AutoUseTaskManager.getInstance().removeAutoSkill(player, skill.getId()); } + else // action + { + AutoUseTaskManager.getInstance().removeAutoAction(player, shortcut.getId()); + } return; } @@ -115,6 +123,17 @@ public class ExRequestActivateAutoShortcut implements IClientIncomingPacket if (Config.ENABLE_AUTO_BUFF && (skill != null)) { AutoUseTaskManager.getInstance().addAutoSkill(player, skill.getId()); + return; + } + // action + final ActionDataHolder actionHolder = ActionData.getInstance().getActionData(shortcut.getId()); + if (actionHolder != null) + { + final IPlayerActionHandler actionHandler = PlayerActionHandler.getInstance().getHandler(actionHolder.getHandler()); + if (actionHandler != null) + { + AutoUseTaskManager.getInstance().addAutoAction(player, shortcut.getId()); + } } } } diff --git a/L2J_Mobius_7.0_PreludeOfWar/java/org/l2jmobius/gameserver/taskmanager/AutoUseTaskManager.java b/L2J_Mobius_7.0_PreludeOfWar/java/org/l2jmobius/gameserver/taskmanager/AutoUseTaskManager.java index ed402f6588..0da8a3d46c 100644 --- a/L2J_Mobius_7.0_PreludeOfWar/java/org/l2jmobius/gameserver/taskmanager/AutoUseTaskManager.java +++ b/L2J_Mobius_7.0_PreludeOfWar/java/org/l2jmobius/gameserver/taskmanager/AutoUseTaskManager.java @@ -16,22 +16,32 @@ */ package org.l2jmobius.gameserver.taskmanager; +import java.util.Arrays; import java.util.Set; import java.util.concurrent.ConcurrentHashMap; import org.l2jmobius.Config; import org.l2jmobius.commons.concurrent.ThreadPool; +import org.l2jmobius.gameserver.data.xml.ActionData; import org.l2jmobius.gameserver.handler.IItemHandler; +import org.l2jmobius.gameserver.handler.IPlayerActionHandler; import org.l2jmobius.gameserver.handler.ItemHandler; +import org.l2jmobius.gameserver.handler.PlayerActionHandler; +import org.l2jmobius.gameserver.model.ActionDataHolder; import org.l2jmobius.gameserver.model.WorldObject; import org.l2jmobius.gameserver.model.actor.Summon; import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance; +import org.l2jmobius.gameserver.model.effects.AbstractEffect; import org.l2jmobius.gameserver.model.holders.ItemSkillHolder; import org.l2jmobius.gameserver.model.items.EtcItem; import org.l2jmobius.gameserver.model.items.instance.ItemInstance; +import org.l2jmobius.gameserver.model.skills.AbnormalType; +import org.l2jmobius.gameserver.model.skills.BuffInfo; import org.l2jmobius.gameserver.model.skills.Skill; import org.l2jmobius.gameserver.model.skills.targets.AffectScope; import org.l2jmobius.gameserver.model.zone.ZoneId; +import org.l2jmobius.gameserver.network.SystemMessageId; +import org.l2jmobius.gameserver.network.serverpackets.ExBasicActionList; /** * @author Mobius @@ -175,6 +185,42 @@ public class AutoUseTaskManager } } } + + ACTIONS: for (Integer actionId : player.getAutoUseSettings().getAutoActions()) + { + final BuffInfo info = player.getEffectList().getFirstBuffInfoByAbnormalType(AbnormalType.BOT_PENALTY); + if (info != null) + { + for (AbstractEffect effect : info.getEffects()) + { + if (!effect.checkCondition(actionId)) + { + player.sendPacket(SystemMessageId.YOU_HAVE_BEEN_REPORTED_AS_AN_ILLEGAL_PROGRAM_USER_SO_YOUR_ACTIONS_HAVE_BEEN_RESTRICTED); + break ACTIONS; + } + } + } + + // Do not allow to do some action if player is transformed. + if (player.isTransformed()) + { + final int[] allowedActions = player.isTransformed() ? ExBasicActionList.ACTIONS_ON_TRANSFORM : ExBasicActionList.DEFAULT_ACTION_LIST; + if (Arrays.binarySearch(allowedActions, actionId) < 0) + { + continue ACTIONS; + } + } + + final ActionDataHolder actionHolder = ActionData.getInstance().getActionData(actionId); + if (actionHolder != null) + { + final IPlayerActionHandler actionHandler = PlayerActionHandler.getInstance().getHandler(actionHolder.getHandler()); + if (actionHandler != null) + { + actionHandler.useAction(player, actionHolder, false, false); + } + } + } } } @@ -231,6 +277,18 @@ public class AutoUseTaskManager stopAutoUseTask(player); } + public void addAutoAction(PlayerInstance player, Integer actionId) + { + player.getAutoUseSettings().getAutoActions().add(actionId); + startAutoUseTask(player); + } + + public void removeAutoAction(PlayerInstance player, int actionId) + { + player.getAutoUseSettings().getAutoActions().remove(actionId); + stopAutoUseTask(player); + } + public static AutoUseTaskManager getInstance() { return SingletonHolder.INSTANCE; diff --git a/L2J_Mobius_8.0_Homunculus/java/org/l2jmobius/gameserver/model/holders/AutoUseSettingsHolder.java b/L2J_Mobius_8.0_Homunculus/java/org/l2jmobius/gameserver/model/holders/AutoUseSettingsHolder.java index f48e580ad3..4a25e54d51 100644 --- a/L2J_Mobius_8.0_Homunculus/java/org/l2jmobius/gameserver/model/holders/AutoUseSettingsHolder.java +++ b/L2J_Mobius_8.0_Homunculus/java/org/l2jmobius/gameserver/model/holders/AutoUseSettingsHolder.java @@ -27,6 +27,7 @@ public class AutoUseSettingsHolder private final Collection _autoSupplyItems = ConcurrentHashMap.newKeySet(); private final Collection _autoPotionItems = ConcurrentHashMap.newKeySet(); private final Collection _autoSkills = ConcurrentHashMap.newKeySet(); + private final Collection _autoActions = ConcurrentHashMap.newKeySet(); public AutoUseSettingsHolder() { @@ -46,4 +47,9 @@ public class AutoUseSettingsHolder { return _autoSkills; } + + public Collection getAutoActions() + { + return _autoActions; + } } diff --git a/L2J_Mobius_8.0_Homunculus/java/org/l2jmobius/gameserver/network/clientpackets/autoplay/ExRequestActivateAutoShortcut.java b/L2J_Mobius_8.0_Homunculus/java/org/l2jmobius/gameserver/network/clientpackets/autoplay/ExRequestActivateAutoShortcut.java index 9411b3bf7b..9cb455794c 100644 --- a/L2J_Mobius_8.0_Homunculus/java/org/l2jmobius/gameserver/network/clientpackets/autoplay/ExRequestActivateAutoShortcut.java +++ b/L2J_Mobius_8.0_Homunculus/java/org/l2jmobius/gameserver/network/clientpackets/autoplay/ExRequestActivateAutoShortcut.java @@ -18,6 +18,10 @@ package org.l2jmobius.gameserver.network.clientpackets.autoplay; import org.l2jmobius.Config; import org.l2jmobius.commons.network.PacketReader; +import org.l2jmobius.gameserver.data.xml.ActionData; +import org.l2jmobius.gameserver.handler.IPlayerActionHandler; +import org.l2jmobius.gameserver.handler.PlayerActionHandler; +import org.l2jmobius.gameserver.model.ActionDataHolder; import org.l2jmobius.gameserver.model.Shortcut; import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance; import org.l2jmobius.gameserver.model.items.instance.ItemInstance; @@ -88,6 +92,10 @@ public class ExRequestActivateAutoShortcut implements IClientIncomingPacket { AutoUseTaskManager.getInstance().removeAutoSkill(player, skill.getId()); } + else // action + { + AutoUseTaskManager.getInstance().removeAutoAction(player, shortcut.getId()); + } return; } @@ -115,6 +123,17 @@ public class ExRequestActivateAutoShortcut implements IClientIncomingPacket if (Config.ENABLE_AUTO_BUFF && (skill != null)) { AutoUseTaskManager.getInstance().addAutoSkill(player, skill.getId()); + return; + } + // action + final ActionDataHolder actionHolder = ActionData.getInstance().getActionData(shortcut.getId()); + if (actionHolder != null) + { + final IPlayerActionHandler actionHandler = PlayerActionHandler.getInstance().getHandler(actionHolder.getHandler()); + if (actionHandler != null) + { + AutoUseTaskManager.getInstance().addAutoAction(player, shortcut.getId()); + } } } } diff --git a/L2J_Mobius_8.0_Homunculus/java/org/l2jmobius/gameserver/taskmanager/AutoUseTaskManager.java b/L2J_Mobius_8.0_Homunculus/java/org/l2jmobius/gameserver/taskmanager/AutoUseTaskManager.java index ed402f6588..0da8a3d46c 100644 --- a/L2J_Mobius_8.0_Homunculus/java/org/l2jmobius/gameserver/taskmanager/AutoUseTaskManager.java +++ b/L2J_Mobius_8.0_Homunculus/java/org/l2jmobius/gameserver/taskmanager/AutoUseTaskManager.java @@ -16,22 +16,32 @@ */ package org.l2jmobius.gameserver.taskmanager; +import java.util.Arrays; import java.util.Set; import java.util.concurrent.ConcurrentHashMap; import org.l2jmobius.Config; import org.l2jmobius.commons.concurrent.ThreadPool; +import org.l2jmobius.gameserver.data.xml.ActionData; import org.l2jmobius.gameserver.handler.IItemHandler; +import org.l2jmobius.gameserver.handler.IPlayerActionHandler; import org.l2jmobius.gameserver.handler.ItemHandler; +import org.l2jmobius.gameserver.handler.PlayerActionHandler; +import org.l2jmobius.gameserver.model.ActionDataHolder; import org.l2jmobius.gameserver.model.WorldObject; import org.l2jmobius.gameserver.model.actor.Summon; import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance; +import org.l2jmobius.gameserver.model.effects.AbstractEffect; import org.l2jmobius.gameserver.model.holders.ItemSkillHolder; import org.l2jmobius.gameserver.model.items.EtcItem; import org.l2jmobius.gameserver.model.items.instance.ItemInstance; +import org.l2jmobius.gameserver.model.skills.AbnormalType; +import org.l2jmobius.gameserver.model.skills.BuffInfo; import org.l2jmobius.gameserver.model.skills.Skill; import org.l2jmobius.gameserver.model.skills.targets.AffectScope; import org.l2jmobius.gameserver.model.zone.ZoneId; +import org.l2jmobius.gameserver.network.SystemMessageId; +import org.l2jmobius.gameserver.network.serverpackets.ExBasicActionList; /** * @author Mobius @@ -175,6 +185,42 @@ public class AutoUseTaskManager } } } + + ACTIONS: for (Integer actionId : player.getAutoUseSettings().getAutoActions()) + { + final BuffInfo info = player.getEffectList().getFirstBuffInfoByAbnormalType(AbnormalType.BOT_PENALTY); + if (info != null) + { + for (AbstractEffect effect : info.getEffects()) + { + if (!effect.checkCondition(actionId)) + { + player.sendPacket(SystemMessageId.YOU_HAVE_BEEN_REPORTED_AS_AN_ILLEGAL_PROGRAM_USER_SO_YOUR_ACTIONS_HAVE_BEEN_RESTRICTED); + break ACTIONS; + } + } + } + + // Do not allow to do some action if player is transformed. + if (player.isTransformed()) + { + final int[] allowedActions = player.isTransformed() ? ExBasicActionList.ACTIONS_ON_TRANSFORM : ExBasicActionList.DEFAULT_ACTION_LIST; + if (Arrays.binarySearch(allowedActions, actionId) < 0) + { + continue ACTIONS; + } + } + + final ActionDataHolder actionHolder = ActionData.getInstance().getActionData(actionId); + if (actionHolder != null) + { + final IPlayerActionHandler actionHandler = PlayerActionHandler.getInstance().getHandler(actionHolder.getHandler()); + if (actionHandler != null) + { + actionHandler.useAction(player, actionHolder, false, false); + } + } + } } } @@ -231,6 +277,18 @@ public class AutoUseTaskManager stopAutoUseTask(player); } + public void addAutoAction(PlayerInstance player, Integer actionId) + { + player.getAutoUseSettings().getAutoActions().add(actionId); + startAutoUseTask(player); + } + + public void removeAutoAction(PlayerInstance player, int actionId) + { + player.getAutoUseSettings().getAutoActions().remove(actionId); + stopAutoUseTask(player); + } + public static AutoUseTaskManager getInstance() { return SingletonHolder.INSTANCE; diff --git a/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/model/holders/AutoUseSettingsHolder.java b/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/model/holders/AutoUseSettingsHolder.java index f48e580ad3..4a25e54d51 100644 --- a/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/model/holders/AutoUseSettingsHolder.java +++ b/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/model/holders/AutoUseSettingsHolder.java @@ -27,6 +27,7 @@ public class AutoUseSettingsHolder private final Collection _autoSupplyItems = ConcurrentHashMap.newKeySet(); private final Collection _autoPotionItems = ConcurrentHashMap.newKeySet(); private final Collection _autoSkills = ConcurrentHashMap.newKeySet(); + private final Collection _autoActions = ConcurrentHashMap.newKeySet(); public AutoUseSettingsHolder() { @@ -46,4 +47,9 @@ public class AutoUseSettingsHolder { return _autoSkills; } + + public Collection getAutoActions() + { + return _autoActions; + } } diff --git a/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/network/clientpackets/autoplay/ExRequestActivateAutoShortcut.java b/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/network/clientpackets/autoplay/ExRequestActivateAutoShortcut.java index 9411b3bf7b..9cb455794c 100644 --- a/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/network/clientpackets/autoplay/ExRequestActivateAutoShortcut.java +++ b/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/network/clientpackets/autoplay/ExRequestActivateAutoShortcut.java @@ -18,6 +18,10 @@ package org.l2jmobius.gameserver.network.clientpackets.autoplay; import org.l2jmobius.Config; import org.l2jmobius.commons.network.PacketReader; +import org.l2jmobius.gameserver.data.xml.ActionData; +import org.l2jmobius.gameserver.handler.IPlayerActionHandler; +import org.l2jmobius.gameserver.handler.PlayerActionHandler; +import org.l2jmobius.gameserver.model.ActionDataHolder; import org.l2jmobius.gameserver.model.Shortcut; import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance; import org.l2jmobius.gameserver.model.items.instance.ItemInstance; @@ -88,6 +92,10 @@ public class ExRequestActivateAutoShortcut implements IClientIncomingPacket { AutoUseTaskManager.getInstance().removeAutoSkill(player, skill.getId()); } + else // action + { + AutoUseTaskManager.getInstance().removeAutoAction(player, shortcut.getId()); + } return; } @@ -115,6 +123,17 @@ public class ExRequestActivateAutoShortcut implements IClientIncomingPacket if (Config.ENABLE_AUTO_BUFF && (skill != null)) { AutoUseTaskManager.getInstance().addAutoSkill(player, skill.getId()); + return; + } + // action + final ActionDataHolder actionHolder = ActionData.getInstance().getActionData(shortcut.getId()); + if (actionHolder != null) + { + final IPlayerActionHandler actionHandler = PlayerActionHandler.getInstance().getHandler(actionHolder.getHandler()); + if (actionHandler != null) + { + AutoUseTaskManager.getInstance().addAutoAction(player, shortcut.getId()); + } } } } diff --git a/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/taskmanager/AutoUseTaskManager.java b/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/taskmanager/AutoUseTaskManager.java index ed402f6588..0da8a3d46c 100644 --- a/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/taskmanager/AutoUseTaskManager.java +++ b/L2J_Mobius_Classic_3.0_TheKamael/java/org/l2jmobius/gameserver/taskmanager/AutoUseTaskManager.java @@ -16,22 +16,32 @@ */ package org.l2jmobius.gameserver.taskmanager; +import java.util.Arrays; import java.util.Set; import java.util.concurrent.ConcurrentHashMap; import org.l2jmobius.Config; import org.l2jmobius.commons.concurrent.ThreadPool; +import org.l2jmobius.gameserver.data.xml.ActionData; import org.l2jmobius.gameserver.handler.IItemHandler; +import org.l2jmobius.gameserver.handler.IPlayerActionHandler; import org.l2jmobius.gameserver.handler.ItemHandler; +import org.l2jmobius.gameserver.handler.PlayerActionHandler; +import org.l2jmobius.gameserver.model.ActionDataHolder; import org.l2jmobius.gameserver.model.WorldObject; import org.l2jmobius.gameserver.model.actor.Summon; import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance; +import org.l2jmobius.gameserver.model.effects.AbstractEffect; import org.l2jmobius.gameserver.model.holders.ItemSkillHolder; import org.l2jmobius.gameserver.model.items.EtcItem; import org.l2jmobius.gameserver.model.items.instance.ItemInstance; +import org.l2jmobius.gameserver.model.skills.AbnormalType; +import org.l2jmobius.gameserver.model.skills.BuffInfo; import org.l2jmobius.gameserver.model.skills.Skill; import org.l2jmobius.gameserver.model.skills.targets.AffectScope; import org.l2jmobius.gameserver.model.zone.ZoneId; +import org.l2jmobius.gameserver.network.SystemMessageId; +import org.l2jmobius.gameserver.network.serverpackets.ExBasicActionList; /** * @author Mobius @@ -175,6 +185,42 @@ public class AutoUseTaskManager } } } + + ACTIONS: for (Integer actionId : player.getAutoUseSettings().getAutoActions()) + { + final BuffInfo info = player.getEffectList().getFirstBuffInfoByAbnormalType(AbnormalType.BOT_PENALTY); + if (info != null) + { + for (AbstractEffect effect : info.getEffects()) + { + if (!effect.checkCondition(actionId)) + { + player.sendPacket(SystemMessageId.YOU_HAVE_BEEN_REPORTED_AS_AN_ILLEGAL_PROGRAM_USER_SO_YOUR_ACTIONS_HAVE_BEEN_RESTRICTED); + break ACTIONS; + } + } + } + + // Do not allow to do some action if player is transformed. + if (player.isTransformed()) + { + final int[] allowedActions = player.isTransformed() ? ExBasicActionList.ACTIONS_ON_TRANSFORM : ExBasicActionList.DEFAULT_ACTION_LIST; + if (Arrays.binarySearch(allowedActions, actionId) < 0) + { + continue ACTIONS; + } + } + + final ActionDataHolder actionHolder = ActionData.getInstance().getActionData(actionId); + if (actionHolder != null) + { + final IPlayerActionHandler actionHandler = PlayerActionHandler.getInstance().getHandler(actionHolder.getHandler()); + if (actionHandler != null) + { + actionHandler.useAction(player, actionHolder, false, false); + } + } + } } } @@ -231,6 +277,18 @@ public class AutoUseTaskManager stopAutoUseTask(player); } + public void addAutoAction(PlayerInstance player, Integer actionId) + { + player.getAutoUseSettings().getAutoActions().add(actionId); + startAutoUseTask(player); + } + + public void removeAutoAction(PlayerInstance player, int actionId) + { + player.getAutoUseSettings().getAutoActions().remove(actionId); + stopAutoUseTask(player); + } + public static AutoUseTaskManager getInstance() { return SingletonHolder.INSTANCE; diff --git a/L2J_Mobius_Essence_4.0_DwellingOfSpirits/java/org/l2jmobius/gameserver/model/holders/AutoUseSettingsHolder.java b/L2J_Mobius_Essence_4.0_DwellingOfSpirits/java/org/l2jmobius/gameserver/model/holders/AutoUseSettingsHolder.java index f48e580ad3..4a25e54d51 100644 --- a/L2J_Mobius_Essence_4.0_DwellingOfSpirits/java/org/l2jmobius/gameserver/model/holders/AutoUseSettingsHolder.java +++ b/L2J_Mobius_Essence_4.0_DwellingOfSpirits/java/org/l2jmobius/gameserver/model/holders/AutoUseSettingsHolder.java @@ -27,6 +27,7 @@ public class AutoUseSettingsHolder private final Collection _autoSupplyItems = ConcurrentHashMap.newKeySet(); private final Collection _autoPotionItems = ConcurrentHashMap.newKeySet(); private final Collection _autoSkills = ConcurrentHashMap.newKeySet(); + private final Collection _autoActions = ConcurrentHashMap.newKeySet(); public AutoUseSettingsHolder() { @@ -46,4 +47,9 @@ public class AutoUseSettingsHolder { return _autoSkills; } + + public Collection getAutoActions() + { + return _autoActions; + } } diff --git a/L2J_Mobius_Essence_4.0_DwellingOfSpirits/java/org/l2jmobius/gameserver/network/clientpackets/autoplay/ExRequestActivateAutoShortcut.java b/L2J_Mobius_Essence_4.0_DwellingOfSpirits/java/org/l2jmobius/gameserver/network/clientpackets/autoplay/ExRequestActivateAutoShortcut.java index 9411b3bf7b..9cb455794c 100644 --- a/L2J_Mobius_Essence_4.0_DwellingOfSpirits/java/org/l2jmobius/gameserver/network/clientpackets/autoplay/ExRequestActivateAutoShortcut.java +++ b/L2J_Mobius_Essence_4.0_DwellingOfSpirits/java/org/l2jmobius/gameserver/network/clientpackets/autoplay/ExRequestActivateAutoShortcut.java @@ -18,6 +18,10 @@ package org.l2jmobius.gameserver.network.clientpackets.autoplay; import org.l2jmobius.Config; import org.l2jmobius.commons.network.PacketReader; +import org.l2jmobius.gameserver.data.xml.ActionData; +import org.l2jmobius.gameserver.handler.IPlayerActionHandler; +import org.l2jmobius.gameserver.handler.PlayerActionHandler; +import org.l2jmobius.gameserver.model.ActionDataHolder; import org.l2jmobius.gameserver.model.Shortcut; import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance; import org.l2jmobius.gameserver.model.items.instance.ItemInstance; @@ -88,6 +92,10 @@ public class ExRequestActivateAutoShortcut implements IClientIncomingPacket { AutoUseTaskManager.getInstance().removeAutoSkill(player, skill.getId()); } + else // action + { + AutoUseTaskManager.getInstance().removeAutoAction(player, shortcut.getId()); + } return; } @@ -115,6 +123,17 @@ public class ExRequestActivateAutoShortcut implements IClientIncomingPacket if (Config.ENABLE_AUTO_BUFF && (skill != null)) { AutoUseTaskManager.getInstance().addAutoSkill(player, skill.getId()); + return; + } + // action + final ActionDataHolder actionHolder = ActionData.getInstance().getActionData(shortcut.getId()); + if (actionHolder != null) + { + final IPlayerActionHandler actionHandler = PlayerActionHandler.getInstance().getHandler(actionHolder.getHandler()); + if (actionHandler != null) + { + AutoUseTaskManager.getInstance().addAutoAction(player, shortcut.getId()); + } } } } diff --git a/L2J_Mobius_Essence_4.0_DwellingOfSpirits/java/org/l2jmobius/gameserver/taskmanager/AutoUseTaskManager.java b/L2J_Mobius_Essence_4.0_DwellingOfSpirits/java/org/l2jmobius/gameserver/taskmanager/AutoUseTaskManager.java index ed402f6588..0da8a3d46c 100644 --- a/L2J_Mobius_Essence_4.0_DwellingOfSpirits/java/org/l2jmobius/gameserver/taskmanager/AutoUseTaskManager.java +++ b/L2J_Mobius_Essence_4.0_DwellingOfSpirits/java/org/l2jmobius/gameserver/taskmanager/AutoUseTaskManager.java @@ -16,22 +16,32 @@ */ package org.l2jmobius.gameserver.taskmanager; +import java.util.Arrays; import java.util.Set; import java.util.concurrent.ConcurrentHashMap; import org.l2jmobius.Config; import org.l2jmobius.commons.concurrent.ThreadPool; +import org.l2jmobius.gameserver.data.xml.ActionData; import org.l2jmobius.gameserver.handler.IItemHandler; +import org.l2jmobius.gameserver.handler.IPlayerActionHandler; import org.l2jmobius.gameserver.handler.ItemHandler; +import org.l2jmobius.gameserver.handler.PlayerActionHandler; +import org.l2jmobius.gameserver.model.ActionDataHolder; import org.l2jmobius.gameserver.model.WorldObject; import org.l2jmobius.gameserver.model.actor.Summon; import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance; +import org.l2jmobius.gameserver.model.effects.AbstractEffect; import org.l2jmobius.gameserver.model.holders.ItemSkillHolder; import org.l2jmobius.gameserver.model.items.EtcItem; import org.l2jmobius.gameserver.model.items.instance.ItemInstance; +import org.l2jmobius.gameserver.model.skills.AbnormalType; +import org.l2jmobius.gameserver.model.skills.BuffInfo; import org.l2jmobius.gameserver.model.skills.Skill; import org.l2jmobius.gameserver.model.skills.targets.AffectScope; import org.l2jmobius.gameserver.model.zone.ZoneId; +import org.l2jmobius.gameserver.network.SystemMessageId; +import org.l2jmobius.gameserver.network.serverpackets.ExBasicActionList; /** * @author Mobius @@ -175,6 +185,42 @@ public class AutoUseTaskManager } } } + + ACTIONS: for (Integer actionId : player.getAutoUseSettings().getAutoActions()) + { + final BuffInfo info = player.getEffectList().getFirstBuffInfoByAbnormalType(AbnormalType.BOT_PENALTY); + if (info != null) + { + for (AbstractEffect effect : info.getEffects()) + { + if (!effect.checkCondition(actionId)) + { + player.sendPacket(SystemMessageId.YOU_HAVE_BEEN_REPORTED_AS_AN_ILLEGAL_PROGRAM_USER_SO_YOUR_ACTIONS_HAVE_BEEN_RESTRICTED); + break ACTIONS; + } + } + } + + // Do not allow to do some action if player is transformed. + if (player.isTransformed()) + { + final int[] allowedActions = player.isTransformed() ? ExBasicActionList.ACTIONS_ON_TRANSFORM : ExBasicActionList.DEFAULT_ACTION_LIST; + if (Arrays.binarySearch(allowedActions, actionId) < 0) + { + continue ACTIONS; + } + } + + final ActionDataHolder actionHolder = ActionData.getInstance().getActionData(actionId); + if (actionHolder != null) + { + final IPlayerActionHandler actionHandler = PlayerActionHandler.getInstance().getHandler(actionHolder.getHandler()); + if (actionHandler != null) + { + actionHandler.useAction(player, actionHolder, false, false); + } + } + } } } @@ -231,6 +277,18 @@ public class AutoUseTaskManager stopAutoUseTask(player); } + public void addAutoAction(PlayerInstance player, Integer actionId) + { + player.getAutoUseSettings().getAutoActions().add(actionId); + startAutoUseTask(player); + } + + public void removeAutoAction(PlayerInstance player, int actionId) + { + player.getAutoUseSettings().getAutoActions().remove(actionId); + stopAutoUseTask(player); + } + public static AutoUseTaskManager getInstance() { return SingletonHolder.INSTANCE;