Implemented Auto Shots with Config.

This commit is contained in:
MobiusDev
2016-07-08 23:46:39 +00:00
parent ee76eb17d9
commit 74fa05d65e
12 changed files with 97 additions and 26 deletions

View File

@@ -757,6 +757,10 @@ ExpertisePenalty = True
# Default: True # Default: True
StoreCharUiSettings = True StoreCharUiSettings = True
# Enable automatic Shot usage on player login or weapon equipped.
# Default: True
EnableAutoShots = True
# Character name restriction # Character name restriction
# Disallow characters to have a name which contains the words. # Disallow characters to have a name which contains the words.
# Split them with ",". Example: announcements,announce... # Split them with ",". Example: announcements,announce...

View File

@@ -113,6 +113,6 @@ public final class Summon extends AbstractEffect
summon.setRunning(); summon.setRunning();
summon.spawnMe(); summon.spawnMe();
player.handleAutoShots(); player.handleAutoShots(false);
} }
} }

View File

@@ -104,6 +104,6 @@ public final class SummonMulti extends AbstractEffect
summon.setRunning(); summon.setRunning();
summon.spawnMe(); summon.spawnMe();
player.handleAutoShots(); player.handleAutoShots(false);
} }
} }

View File

@@ -42,21 +42,20 @@ public class BlessedSpiritShot implements IItemHandler
return false; return false;
} }
final L2PcInstance activeChar = (L2PcInstance) playable; final L2PcInstance activeChar = playable.getActingPlayer();
final L2ItemInstance weaponInst = activeChar.getActiveWeaponInstance(); final L2ItemInstance weaponInst = activeChar.getActiveWeaponInstance();
final L2Weapon weaponItem = activeChar.getActiveWeaponItem(); final L2Weapon weaponItem = activeChar.getActiveWeaponItem();
final List<ItemSkillHolder> skills = item.getItem().getSkills(ItemSkillType.NORMAL); final List<ItemSkillHolder> skills = item.getItem().getSkills(ItemSkillType.NORMAL);
final int itemId = item.getId();
if (skills == null) if (skills == null)
{ {
_log.warning(getClass().getSimpleName() + ": is missing skills!"); _log.warning(getClass().getSimpleName() + ": is missing skills!");
return false; return false;
} }
final int itemId = item.getId();
// Check if Blessed SpiritShot can be used // Check if Blessed SpiritShot can be used
if ((weaponInst == null) || (weaponItem == null) || (weaponItem.getSpiritShotCount() == 0)) if ((weaponInst == null) || (weaponItem.getSpiritShotCount() == 0))
{ {
if (!activeChar.getAutoSoulShot().contains(itemId)) if (!activeChar.getAutoSoulShot().contains(itemId))
{ {
@@ -94,10 +93,14 @@ public class BlessedSpiritShot implements IItemHandler
return false; return false;
} }
// Send message to client // Charge Spirit shot
activeChar.sendPacket(SystemMessageId.YOUR_SPIRITSHOT_HAS_BEEN_ENABLED); activeChar.setChargedShot(ShotType.SPIRITSHOTS, true);
activeChar.setChargedShot(ShotType.BLESSED_SPIRITSHOTS, true);
// Send message to client
if (!activeChar.getAutoSoulShot().contains(item.getId()))
{
activeChar.sendPacket(SystemMessageId.YOUR_SPIRITSHOT_HAS_BEEN_ENABLED);
}
skills.forEach(holder -> Broadcast.toSelfAndKnownPlayersInRadius(activeChar, new MagicSkillUse(activeChar, activeChar, holder.getSkillId(), holder.getSkillLvl(), 0, 0), 600)); skills.forEach(holder -> Broadcast.toSelfAndKnownPlayersInRadius(activeChar, new MagicSkillUse(activeChar, activeChar, holder.getSkillId(), holder.getSkillLvl(), 0, 0), 600));
return true; return true;
} }

View File

@@ -109,7 +109,10 @@ public class SoulShots implements IItemHandler
} }
// Send message to client // Send message to client
if (!activeChar.getAutoSoulShot().contains(item.getId()))
{
activeChar.sendPacket(SystemMessageId.YOUR_SOULSHOTS_ARE_ENABLED); activeChar.sendPacket(SystemMessageId.YOUR_SOULSHOTS_ARE_ENABLED);
}
skills.forEach(holder -> Broadcast.toSelfAndKnownPlayersInRadius(activeChar, new MagicSkillUse(activeChar, activeChar, holder.getSkillId(), holder.getSkillLvl(), 0, 0), 600)); skills.forEach(holder -> Broadcast.toSelfAndKnownPlayersInRadius(activeChar, new MagicSkillUse(activeChar, activeChar, holder.getSkillId(), holder.getSkillLvl(), 0, 0), 600));
return true; return true;
} }

View File

@@ -42,7 +42,7 @@ public class SpiritShot implements IItemHandler
return false; return false;
} }
final L2PcInstance activeChar = (L2PcInstance) playable; final L2PcInstance activeChar = playable.getActingPlayer();
final L2ItemInstance weaponInst = activeChar.getActiveWeaponInstance(); final L2ItemInstance weaponInst = activeChar.getActiveWeaponInstance();
final L2Weapon weaponItem = activeChar.getActiveWeaponItem(); final L2Weapon weaponItem = activeChar.getActiveWeaponItem();
final List<ItemSkillHolder> skills = item.getItem().getSkills(ItemSkillType.NORMAL); final List<ItemSkillHolder> skills = item.getItem().getSkills(ItemSkillType.NORMAL);
@@ -54,7 +54,7 @@ public class SpiritShot implements IItemHandler
final int itemId = item.getId(); final int itemId = item.getId();
// Check if Spirit shot can be used // Check if SpiritShot can be used
if ((weaponInst == null) || (weaponItem.getSpiritShotCount() == 0)) if ((weaponInst == null) || (weaponItem.getSpiritShotCount() == 0))
{ {
if (!activeChar.getAutoSoulShot().contains(itemId)) if (!activeChar.getAutoSoulShot().contains(itemId))
@@ -64,12 +64,13 @@ public class SpiritShot implements IItemHandler
return false; return false;
} }
// Check if Spirit shot is already active // Check if SpiritShot is already active
if (activeChar.isChargedShot(ShotType.SPIRITSHOTS)) if (activeChar.isChargedShot(ShotType.SPIRITSHOTS))
{ {
return false; return false;
} }
// Check for correct grade
final boolean gradeCheck = item.isEtcItem() && (item.getEtcItem().getDefaultAction() == ActionType.SPIRITSHOT) && (weaponInst.getItem().getCrystalTypePlus() == item.getItem().getCrystalTypePlus()); final boolean gradeCheck = item.isEtcItem() && (item.getEtcItem().getDefaultAction() == ActionType.SPIRITSHOT) && (weaponInst.getItem().getCrystalTypePlus() == item.getItem().getCrystalTypePlus());
if (!gradeCheck) if (!gradeCheck)
@@ -82,7 +83,7 @@ public class SpiritShot implements IItemHandler
return false; return false;
} }
// Consume Spirit shot if player has enough of them // Consume SpiritShot if player has enough of them
if (!activeChar.destroyItemWithoutTrace("Consume", item.getObjectId(), weaponItem.getSpiritShotCount(), null, false)) if (!activeChar.destroyItemWithoutTrace("Consume", item.getObjectId(), weaponItem.getSpiritShotCount(), null, false))
{ {
if (!activeChar.disableAutoShot(itemId)) if (!activeChar.disableAutoShot(itemId))
@@ -96,7 +97,10 @@ public class SpiritShot implements IItemHandler
activeChar.setChargedShot(ShotType.SPIRITSHOTS, true); activeChar.setChargedShot(ShotType.SPIRITSHOTS, true);
// Send message to client // Send message to client
if (!activeChar.getAutoSoulShot().contains(item.getId()))
{
activeChar.sendPacket(SystemMessageId.YOUR_SPIRITSHOT_HAS_BEEN_ENABLED); activeChar.sendPacket(SystemMessageId.YOUR_SPIRITSHOT_HAS_BEEN_ENABLED);
}
skills.forEach(holder -> Broadcast.toSelfAndKnownPlayersInRadius(activeChar, new MagicSkillUse(activeChar, activeChar, holder.getSkillId(), holder.getSkillLvl(), 0, 0), 600)); skills.forEach(holder -> Broadcast.toSelfAndKnownPlayersInRadius(activeChar, new MagicSkillUse(activeChar, activeChar, holder.getSkillId(), holder.getSkillLvl(), 0, 0), 600));
return true; return true;
} }

View File

@@ -254,6 +254,7 @@ public final class Config
public static boolean EXPERTISE_PENALTY; public static boolean EXPERTISE_PENALTY;
public static boolean STORE_RECIPE_SHOPLIST; public static boolean STORE_RECIPE_SHOPLIST;
public static boolean STORE_UI_SETTINGS; public static boolean STORE_UI_SETTINGS;
public static boolean ENABLE_AUTO_SHOTS;
public static String[] FORBIDDEN_NAMES; public static String[] FORBIDDEN_NAMES;
public static boolean SILENCE_MODE_EXCLUDE; public static boolean SILENCE_MODE_EXCLUDE;
public static boolean SHOW_GOD_VIDEO_INTRO; public static boolean SHOW_GOD_VIDEO_INTRO;
@@ -1545,6 +1546,7 @@ public final class Config
EXPERTISE_PENALTY = Character.getBoolean("ExpertisePenalty", true); EXPERTISE_PENALTY = Character.getBoolean("ExpertisePenalty", true);
STORE_RECIPE_SHOPLIST = Character.getBoolean("StoreRecipeShopList", false); STORE_RECIPE_SHOPLIST = Character.getBoolean("StoreRecipeShopList", false);
STORE_UI_SETTINGS = Character.getBoolean("StoreCharUiSettings", true); STORE_UI_SETTINGS = Character.getBoolean("StoreCharUiSettings", true);
ENABLE_AUTO_SHOTS = Character.getBoolean("EnableAutoShots", true);
FORBIDDEN_NAMES = Character.getString("ForbiddenNames", "").split(","); FORBIDDEN_NAMES = Character.getString("ForbiddenNames", "").split(",");
SILENCE_MODE_EXCLUDE = Character.getBoolean("SilenceModeExclude", false); SILENCE_MODE_EXCLUDE = Character.getBoolean("SilenceModeExclude", false);
SHOW_GOD_VIDEO_INTRO = Character.getBoolean("GoDVideoIntro", true); SHOW_GOD_VIDEO_INTRO = Character.getBoolean("GoDVideoIntro", true);

View File

@@ -13798,8 +13798,13 @@ public final class L2PcInstance extends L2Playable
} }
} }
public void handleAutoShots() public void handleAutoShots(boolean force)
{ {
if (getAutoSoulShot().isEmpty() && !force)
{
return;
}
final L2ItemInstance weapon = getActiveWeaponInstance(); final L2ItemInstance weapon = getActiveWeaponInstance();
int soulShotId = 0; int soulShotId = 0;
int spiritShotId = 0; int spiritShotId = 0;
@@ -13853,10 +13858,40 @@ public final class L2PcInstance extends L2Playable
} }
} }
sendPacket(new ExAutoSoulShot(soulShotId, true, 1)); for (int shotId : getAutoSoulShot())
sendPacket(new ExAutoSoulShot(spiritShotId, true, 2)); {
sendPacket(new ExAutoSoulShot(summonSoulShotId, true, 3)); if ((shotId != soulShotId) && (shotId != spiritShotId) && (shotId != summonSoulShotId) && (shotId != summonSpiritShotId))
sendPacket(new ExAutoSoulShot(summonSpiritShotId, true, 4)); {
removeAutoSoulShot(shotId);
}
}
if (soulShotId != 0)
{
addAutoSoulShot(soulShotId);
}
if (spiritShotId != 0)
{
addAutoSoulShot(spiritShotId);
}
if (summonSoulShotId != 0)
{
addAutoSoulShot(summonSoulShotId);
}
if (summonSpiritShotId != 0)
{
addAutoSoulShot(summonSpiritShotId);
}
sendPacket(new ExAutoSoulShot(soulShotId, true, 0));
sendPacket(new ExAutoSoulShot(spiritShotId, true, 1));
sendPacket(new ExAutoSoulShot(summonSoulShotId, true, 2));
sendPacket(new ExAutoSoulShot(summonSpiritShotId, true, 3));
if (!getAutoSoulShot().isEmpty())
{
rechargeShots(true, true, true);
}
} }
public GroupType getGroupType() public GroupType getGroupType()

View File

@@ -374,7 +374,7 @@ public abstract class Inventory extends ItemContainer
if (item.isWeapon()) if (item.isWeapon())
{ {
player.handleAutoShots(); player.handleAutoShots(false);
} }
} }
@@ -470,7 +470,7 @@ public abstract class Inventory extends ItemContainer
if (item.isWeapon()) if (item.isWeapon())
{ {
player.handleAutoShots(); player.handleAutoShots(Config.ENABLE_AUTO_SHOTS);
} }
} }
} }

View File

@@ -460,7 +460,7 @@ public class PcInventory extends Inventory
if (item.isEtcItem() && (item.getItemType() == EtcItemType.SOULSHOT)) if (item.isEtcItem() && (item.getItemType() == EtcItemType.SOULSHOT))
{ {
actor.handleAutoShots(); actor.handleAutoShots(false);
} }
// Notify to scripts // Notify to scripts
@@ -516,7 +516,7 @@ public class PcInventory extends Inventory
if (item.isEtcItem() && (item.getItemType() == EtcItemType.SOULSHOT)) if (item.isEtcItem() && (item.getItemType() == EtcItemType.SOULSHOT))
{ {
actor.handleAutoShots(); actor.handleAutoShots(false);
} }
// Notify to scripts // Notify to scripts

View File

@@ -63,6 +63,7 @@ import com.l2jmobius.gameserver.network.serverpackets.CreatureSay;
import com.l2jmobius.gameserver.network.serverpackets.Die; import com.l2jmobius.gameserver.network.serverpackets.Die;
import com.l2jmobius.gameserver.network.serverpackets.EtcStatusUpdate; import com.l2jmobius.gameserver.network.serverpackets.EtcStatusUpdate;
import com.l2jmobius.gameserver.network.serverpackets.ExAdenaInvenCount; import com.l2jmobius.gameserver.network.serverpackets.ExAdenaInvenCount;
import com.l2jmobius.gameserver.network.serverpackets.ExAutoSoulShot;
import com.l2jmobius.gameserver.network.serverpackets.ExBasicActionList; import com.l2jmobius.gameserver.network.serverpackets.ExBasicActionList;
import com.l2jmobius.gameserver.network.serverpackets.ExBeautyItemList; import com.l2jmobius.gameserver.network.serverpackets.ExBeautyItemList;
import com.l2jmobius.gameserver.network.serverpackets.ExCastleState; import com.l2jmobius.gameserver.network.serverpackets.ExCastleState;
@@ -616,7 +617,18 @@ public class EnterWorld implements IClientIncomingPacket
activeChar.sendPacket(new ExWorldChatCnt(activeChar)); activeChar.sendPacket(new ExWorldChatCnt(activeChar));
activeChar.sendPacket(new ExOneDayReceiveRewardList(activeChar)); activeChar.sendPacket(new ExOneDayReceiveRewardList(activeChar));
activeChar.sendPacket(ExConnectedTimeAndGettableReward.STATIC_PACKET); activeChar.sendPacket(ExConnectedTimeAndGettableReward.STATIC_PACKET);
activeChar.handleAutoShots();
if (Config.ENABLE_AUTO_SHOTS)
{
activeChar.handleAutoShots(true);
}
else
{
activeChar.sendPacket(new ExAutoSoulShot(0, false, 0));
activeChar.sendPacket(new ExAutoSoulShot(0, false, 1));
activeChar.sendPacket(new ExAutoSoulShot(0, false, 2));
activeChar.sendPacket(new ExAutoSoulShot(0, false, 3));
}
} }
/** /**

View File

@@ -184,11 +184,15 @@ public final class RequestAutoSoulShot implements IClientIncomingPacket
case SPIRITSHOT: case SPIRITSHOT:
case SOULSHOT: case SOULSHOT:
case FISHINGSHOT: case FISHINGSHOT:
{
return true; return true;
}
default: default:
{
return false; return false;
} }
} }
}
public static boolean isSummonShot(L2Item item) public static boolean isSummonShot(L2Item item)
{ {
@@ -196,9 +200,13 @@ public final class RequestAutoSoulShot implements IClientIncomingPacket
{ {
case SUMMON_SPIRITSHOT: case SUMMON_SPIRITSHOT:
case SUMMON_SOULSHOT: case SUMMON_SOULSHOT:
{
return true; return true;
}
default: default:
{
return false; return false;
} }
} }
} }
}