Addition of auto play configurations.

This commit is contained in:
MobiusDevelopment
2020-03-21 08:22:14 +00:00
parent ec51b21f9d
commit ab7b3863c2
10 changed files with 150 additions and 54 deletions

View File

@@ -573,6 +573,10 @@ public class Config
public static String[] BOTREPORT_RESETPOINT_HOUR;
public static long BOTREPORT_REPORT_DELAY;
public static boolean BOTREPORT_ALLOW_REPORTS_FROM_SAME_CLAN_MEMBERS;
public static boolean ENABLE_AUTO_PLAY;
public static boolean ENABLE_AUTO_POTION;
public static boolean ENABLE_AUTO_BUFF;
public static boolean ENABLE_AUTO_ITEM;
// --------------------------------------------------
// FloodProtector Settings
@@ -2033,6 +2037,7 @@ public class Config
GRIDS_ALWAYS_ON = General.getBoolean("GridsAlwaysOn", false);
GRID_NEIGHBOR_TURNON_TIME = General.getInt("GridNeighborTurnOnTime", 1);
GRID_NEIGHBOR_TURNOFF_TIME = General.getInt("GridNeighborTurnOffTime", 90);
ENABLE_FALLING_DAMAGE = General.getBoolean("EnableFallingDamage", true);
PEACE_ZONE_MODE = General.getInt("PeaceZoneMode", 0);
DEFAULT_GLOBAL_CHAT = General.getString("GlobalChat", "ON");
DEFAULT_TRADE_CHAT = General.getString("TradeChat", "ON");
@@ -2118,7 +2123,10 @@ public class Config
BOTREPORT_RESETPOINT_HOUR = General.getString("BotReportPointsResetHour", "00:00").split(":");
BOTREPORT_REPORT_DELAY = General.getInt("BotReportDelay", 30) * 60000;
BOTREPORT_ALLOW_REPORTS_FROM_SAME_CLAN_MEMBERS = General.getBoolean("AllowReportsFromSameClanMembers", false);
ENABLE_FALLING_DAMAGE = General.getBoolean("EnableFallingDamage", true);
ENABLE_AUTO_PLAY = General.getBoolean("EnableAutoPlay", true);
ENABLE_AUTO_POTION = General.getBoolean("EnableAutoPotion", true);
ENABLE_AUTO_BUFF = General.getBoolean("EnableAutoBuff", true);
ENABLE_AUTO_ITEM = General.getBoolean("EnableAutoItem", true);
// Load FloodProtector config file
final PropertiesParser FloodProtectors = new PropertiesParser(FLOOD_PROTECTOR_CONFIG_FILE);

View File

@@ -13915,6 +13915,12 @@ public class PlayerInstance extends Playable
_autoPlayTask = ThreadPool.scheduleAtFixedRate(() ->
{
if (!Config.ENABLE_AUTO_PLAY)
{
stopAutoPlayTask();
return;
}
// Skip thinking.
if ((getTarget() != null) && getTarget().isMonster() && (((MonsterInstance) getTarget()).getTarget() == this) && !((MonsterInstance) getTarget()).isAlikeDead())
{
@@ -14011,27 +14017,30 @@ public class PlayerInstance extends Playable
return;
}
for (int itemId : _autoSupplyItems)
if (Config.ENABLE_AUTO_ITEM)
{
final ItemInstance item = _inventory.getItemByItemId(itemId);
if (item == null)
for (int itemId : _autoSupplyItems)
{
removeAutoSupplyItem(itemId);
continue;
}
final int reuseDelay = item.getReuseDelay();
if ((reuseDelay <= 0) || (getItemRemainingReuseTime(item.getObjectId()) <= 0))
{
final EtcItem etcItem = item.getEtcItem();
final IItemHandler handler = ItemHandler.getInstance().getHandler(etcItem);
if ((handler != null) && handler.useItem(this, item, false) && (reuseDelay > 0))
final ItemInstance item = _inventory.getItemByItemId(itemId);
if (item == null)
{
addTimeStampItem(item, reuseDelay);
removeAutoSupplyItem(itemId);
continue;
}
final int reuseDelay = item.getReuseDelay();
if ((reuseDelay <= 0) || (getItemRemainingReuseTime(item.getObjectId()) <= 0))
{
final EtcItem etcItem = item.getEtcItem();
final IItemHandler handler = ItemHandler.getInstance().getHandler(etcItem);
if ((handler != null) && handler.useItem(this, item, false) && (reuseDelay > 0))
{
addTimeStampItem(item, reuseDelay);
}
}
}
}
if (getCurrentHpPercent() <= _autoPotionPercent)
if (Config.ENABLE_AUTO_POTION && (getCurrentHpPercent() <= _autoPotionPercent))
{
for (int itemId : _autoPotionItems)
{
@@ -14054,17 +14063,20 @@ public class PlayerInstance extends Playable
}
}
for (int skillId : _autoSkills)
if (Config.ENABLE_AUTO_BUFF)
{
final Skill skill = getKnownSkill(skillId);
if (skill == null)
for (int skillId : _autoSkills)
{
removeAutoSkill(skillId);
continue;
}
if (!isAffectedBySkill(skillId) && !isInsideZone(ZoneId.PEACE) && !hasSkillReuse(skill.getReuseHashCode()) && skill.checkCondition(this, this, false))
{
doCast(skill);
final Skill skill = getKnownSkill(skillId);
if (skill == null)
{
removeAutoSkill(skillId);
continue;
}
if (!isAffectedBySkill(skillId) && !isInsideZone(ZoneId.PEACE) && !hasSkillReuse(skill.getReuseHashCode()) && skill.checkCondition(this, this, false))
{
doCast(skill);
}
}
}
}, 0, 1000);

View File

@@ -16,6 +16,7 @@
*/
package org.l2jmobius.gameserver.network.clientpackets.autoplay;
import org.l2jmobius.Config;
import org.l2jmobius.commons.network.PacketReader;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
import org.l2jmobius.gameserver.network.GameClient;
@@ -60,6 +61,11 @@ public class ExAutoPlaySetting implements IClientIncomingPacket
player.sendPacket(new ExAutoPlaySettingSend(_options, _active, _pickUp, _nextTargetMode, _longRange, _potionPercent, _respectfulHunting));
player.setAutoPotionPercent(_potionPercent);
if (!Config.ENABLE_AUTO_PLAY)
{
return;
}
if (_active)
{
player.startAutoPlayTask(_pickUp, _longRange, _respectfulHunting);

View File

@@ -16,6 +16,7 @@
*/
package org.l2jmobius.gameserver.network.clientpackets.autoplay;
import org.l2jmobius.Config;
import org.l2jmobius.commons.network.PacketReader;
import org.l2jmobius.gameserver.model.Shortcut;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
@@ -93,7 +94,7 @@ public class ExRequestActivateAutoShortcut implements IClientIncomingPacket
if (_room > 263)
{
// auto supply
if (item != null)
if (Config.ENABLE_AUTO_ITEM && (item != null))
{
player.addAutoSupplyItem(item.getId());
}
@@ -103,14 +104,14 @@ public class ExRequestActivateAutoShortcut implements IClientIncomingPacket
// auto potion
if ((page == 23) && (slot == 1))
{
if ((item != null) && item.isPotion())
if (Config.ENABLE_AUTO_POTION && (item != null) && item.isPotion())
{
player.addAutoPotionItem(item.getId());
return;
}
}
// auto skill
if (skill != null)
if (Config.ENABLE_AUTO_BUFF && (skill != null))
{
player.addAutoSkill(skill.getId());
}