Proper soulshot toggle.

Contributed by gigilo1968.
This commit is contained in:
MobiusDev
2017-09-23 14:51:18 +00:00
parent 013b789b40
commit 74f1bdbf36
77 changed files with 262 additions and 829 deletions

View File

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

View File

@ -247,8 +247,7 @@ public class Fishing
double chance = baitData.getChance();
if (_player.isChargedShot(ShotType.FISH_SOULSHOTS))
{
chance *= 1.25; // +25 % chance to win
_player.setChargedShot(ShotType.FISH_SOULSHOTS, false);
chance *= 1.5; // +50 % chance to win
}
if (Rnd.get(0, 100) <= chance)

View File

@ -21,7 +21,6 @@ import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.atomic.AtomicInteger;
import com.l2jmobius.gameserver.enums.InstanceType;
import com.l2jmobius.gameserver.enums.ShotType;
import com.l2jmobius.gameserver.handler.ActionHandler;
import com.l2jmobius.gameserver.handler.ActionShiftHandler;
import com.l2jmobius.gameserver.handler.IActionHandler;
@ -454,35 +453,6 @@ public abstract class L2Object extends ListenersContainer implements IIdentifiab
return false;
}
/**
* Check if current object has charged shot.
* @param type of the shot to be checked.
* @return {@code true} if the object has charged shot
*/
public boolean isChargedShot(ShotType type)
{
return false;
}
/**
* Charging shot into the current object.
* @param type of the shot to be charged.
* @param charged
*/
public void setChargedShot(ShotType type, boolean charged)
{
}
/**
* Try to recharge a shot.
* @param physical skill are using Soul shots.
* @param magical skill are using Spirit shots.
* @param fish
*/
public void rechargeShots(boolean physical, boolean magical, boolean fish)
{
}
/**
* @param <T>
* @param script

View File

@ -21,6 +21,7 @@ import static com.l2jmobius.gameserver.ai.CtrlIntention.AI_INTENTION_ACTIVE;
import java.lang.ref.WeakReference;
import java.util.Collection;
import java.util.Collections;
import java.util.EnumSet;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
@ -269,6 +270,9 @@ public abstract class L2Character extends L2Object implements ISkillsHolder, IDe
/** A map holding info about basic property mesmerizing system. */
private volatile Map<BasicProperty, BasicPropertyResist> _basicPropertyResists;
/** A set containing the shot types currently charged. */
private Set<ShotType> _chargedShots = EnumSet.noneOf(ShotType.class);
/**
* Creates a creature.
* @param template the creature template
@ -3861,7 +3865,7 @@ public abstract class L2Character extends L2Object implements ISkillsHolder, IDe
else
{
// If we didn't miss the hit, discharge the shoulshots, if any
setChargedShot(isChargedShot(ShotType.BLESSED_SOULSHOTS) ? ShotType.BLESSED_SOULSHOTS : ShotType.SOULSHOTS, false);
unchargeShot(isChargedShot(ShotType.BLESSED_SOULSHOTS) ? ShotType.BLESSED_SOULSHOTS : ShotType.SOULSHOTS);
}
// Check Raidboss attack
@ -5533,4 +5537,37 @@ public abstract class L2Character extends L2Object implements ISkillsHolder, IDe
{
return calculateDistance(target, true, false);
}
public boolean isChargedShot(ShotType type)
{
return _chargedShots.contains(type);
}
/**
* @param type of the shot to charge
* @return {@code true} if there was no shot of this type charged before, {@code false} otherwise.
*/
public boolean chargeShot(ShotType type)
{
return _chargedShots.add(type);
}
/**
* @param type of the shot to uncharge
* @return {@code true} if there was a charged shot of this type, {@code false} otherwise.
*/
public boolean unchargeShot(ShotType type)
{
return _chargedShots.remove(type);
}
public void unchargeAllShots()
{
_chargedShots = EnumSet.noneOf(ShotType.class);
}
public void rechargeShots(boolean physical, boolean magic, boolean fish)
{
// Dummy method to be overriden.
}
}

View File

@ -137,7 +137,6 @@ public class L2Npc extends L2Character
private int _spiritshotamount = 0;
private int _displayEffect = 0;
private int _shotsMask = 0;
private int _killingBlowWeaponId;
private int _cloneObjId; // Used in NpcInfo packet to clone the specified player.
@ -1301,25 +1300,6 @@ public class L2Npc extends L2Character
return WalkingManager.getInstance().isRegistered(this);
}
@Override
public boolean isChargedShot(ShotType type)
{
return (_shotsMask & type.getMask()) == type.getMask();
}
@Override
public void setChargedShot(ShotType type, boolean charged)
{
if (charged)
{
_shotsMask |= type.getMask();
}
else
{
_shotsMask &= ~type.getMask();
}
}
@Override
public void rechargeShots(boolean physical, boolean magic, boolean fish)
{
@ -1331,7 +1311,7 @@ public class L2Npc extends L2Character
}
_soulshotamount--;
Broadcast.toSelfAndKnownPlayersInRadius(this, new MagicSkillUse(this, this, 2154, 1, 0, 0), 600);
setChargedShot(ShotType.SOULSHOTS, true);
chargeShot(ShotType.SOULSHOTS);
}
if (magic && (_spiritshotamount > 0))
@ -1342,7 +1322,7 @@ public class L2Npc extends L2Character
}
_spiritshotamount--;
Broadcast.toSelfAndKnownPlayersInRadius(this, new MagicSkillUse(this, this, 2061, 1, 0, 0), 600);
setChargedShot(ShotType.SPIRITSHOTS, true);
chargeShot(ShotType.SPIRITSHOTS);
}
}

View File

@ -26,7 +26,6 @@ import com.l2jmobius.gameserver.data.xml.impl.ExperienceData;
import com.l2jmobius.gameserver.datatables.ItemTable;
import com.l2jmobius.gameserver.enums.InstanceType;
import com.l2jmobius.gameserver.enums.Race;
import com.l2jmobius.gameserver.enums.ShotType;
import com.l2jmobius.gameserver.enums.Team;
import com.l2jmobius.gameserver.handler.IItemHandler;
import com.l2jmobius.gameserver.handler.ItemHandler;
@ -77,7 +76,6 @@ public abstract class L2Summon extends L2Playable
private boolean _follow = true;
private boolean _previousFollowStatus = true;
protected boolean _restoreSummon = true;
private int _shotsMask = 0;
private int _summonPoints = 0;
// @formatter:off
@ -1026,25 +1024,6 @@ public abstract class L2Summon extends L2Playable
return true;
}
@Override
public boolean isChargedShot(ShotType type)
{
return (_shotsMask & type.getMask()) == type.getMask();
}
@Override
public void setChargedShot(ShotType type, boolean charged)
{
if (charged)
{
_shotsMask |= type.getMask();
}
else
{
_shotsMask &= ~type.getMask();
}
}
@Override
public void rechargeShots(boolean physical, boolean magic, boolean fish)
{

View File

@ -93,7 +93,6 @@ import com.l2jmobius.gameserver.enums.PrivateStoreType;
import com.l2jmobius.gameserver.enums.Race;
import com.l2jmobius.gameserver.enums.Sex;
import com.l2jmobius.gameserver.enums.ShortcutType;
import com.l2jmobius.gameserver.enums.ShotType;
import com.l2jmobius.gameserver.enums.StatusUpdateType;
import com.l2jmobius.gameserver.enums.SubclassInfoType;
import com.l2jmobius.gameserver.enums.Team;
@ -13018,23 +13017,6 @@ public final class L2PcInstance extends L2Playable
return true;
}
@Override
public boolean isChargedShot(ShotType type)
{
final L2ItemInstance weapon = getActiveWeaponInstance();
return (weapon != null) && weapon.isChargedShot(type);
}
@Override
public void setChargedShot(ShotType type, boolean charged)
{
final L2ItemInstance weapon = getActiveWeaponInstance();
if (weapon != null)
{
weapon.setChargedShot(type, charged);
}
}
/**
* @param skillId the display skill Id
* @return the custom skill
@ -13886,93 +13868,6 @@ public final class L2PcInstance extends L2Playable
}
}
public void handleAutoShots(boolean force)
{
if (getAutoSoulShot().isEmpty() && !force)
{
return;
}
final L2ItemInstance weapon = getActiveWeaponInstance();
int soulShotId = 0;
int spiritShotId = 0;
int summonSoulShotId = 0;
int summonSpiritShotId = 0;
for (L2ItemInstance item : getInventory().getItems(L2ItemInstance::isEtcItem, i -> i.getItemType() == EtcItemType.SOULSHOT))
{
switch (item.getEtcItem().getDefaultAction())
{
case SOULSHOT:
{
if ((weapon != null) && (weapon.getItemType() != WeaponType.FISHINGROD) && (weapon.getItem().getCrystalTypePlus() == item.getItem().getCrystalType()))
{
soulShotId = item.getId();
}
break;
}
case SPIRITSHOT:
{
if ((weapon != null) && (weapon.getItem().getCrystalTypePlus() == item.getItem().getCrystalType()))
{
spiritShotId = item.getId();
}
break;
}
case SUMMON_SOULSHOT:
{
if (hasSummon())
{
summonSoulShotId = item.getId();
}
break;
}
case SUMMON_SPIRITSHOT:
{
if (hasSummon())
{
summonSpiritShotId = item.getId();
}
break;
}
case FISHINGSHOT:
{
if ((weapon != null) && (weapon.getItemType() == WeaponType.FISHINGROD) && (weapon.getItem().getCrystalType() == item.getItem().getCrystalType()))
{
soulShotId = item.getId();
}
break;
}
}
}
_activeSoulShots.clear();
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));
rechargeShots(true, true, true);
}
public GroupType getGroupType()
{
return isInParty() ? (getParty().isInCommandChannel() ? GroupType.COMMAND_CHANNEL : GroupType.PARTY) : GroupType.NONE;

View File

@ -370,11 +370,6 @@ public abstract class Inventory extends ItemContainer
}
});
}
if (item.isWeapon())
{
player.handleAutoShots(false);
}
}
// Apply skill, if weapon have "skills on unequip"
@ -388,6 +383,11 @@ public abstract class Inventory extends ItemContainer
{
player.sendPacket(new SkillCoolTime(player));
}
if (item.isWeapon())
{
player.unchargeAllShots();
}
}
@Override
@ -399,6 +399,13 @@ public abstract class Inventory extends ItemContainer
}
final L2PcInstance player = (L2PcInstance) inventory.getOwner();
// Any items equipped that result in expertise penalty do not give any skills at all.
if (item.getItem().getCrystalType().getId() > player.getExpertiseLevel())
{
return;
}
final AtomicBoolean update = new AtomicBoolean();
final AtomicBoolean updateTimestamp = new AtomicBoolean();
@ -466,11 +473,6 @@ public abstract class Inventory extends ItemContainer
{
player.sendPacket(new SkillCoolTime(player));
}
if (item.isWeapon())
{
player.handleAutoShots(Config.ENABLE_AUTO_SHOTS);
}
}
}
@ -500,6 +502,12 @@ public abstract class Inventory extends ItemContainer
update = true;
}
// Very and apply visual set
if (verifyAndApply(player, item, L2ItemInstance::getVisualId))
{
update = true;
}
if (update)
{
player.sendSkillList();
@ -619,6 +627,12 @@ public abstract class Inventory extends ItemContainer
remove = true;
}
// verify and remove visual set bonus
if (verifyAndRemove(player, item, L2ItemInstance::getVisualId))
{
remove = true;
}
if (remove)
{
player.checkItemRestriction();

View File

@ -460,11 +460,6 @@ public class PcInventory extends Inventory
actor.sendItemList(false);
}
if (item.isEtcItem() && (item.getItemType() == EtcItemType.SOULSHOT))
{
actor.handleAutoShots(false);
}
// Notify to scripts
EventDispatcher.getInstance().notifyEventAsync(new OnPlayerItemAdd(actor, item), actor, item.getItem());
}
@ -516,11 +511,6 @@ public class PcInventory extends Inventory
actor.sendItemList(false);
}
if (item.isEtcItem() && (item.getItemType() == EtcItemType.SOULSHOT))
{
actor.handleAutoShots(false);
}
// Notify to scripts
EventDispatcher.getInstance().notifyEventAsync(new OnPlayerItemAdd(actor, item), actor, item.getItem());
}

View File

@ -47,7 +47,6 @@ import com.l2jmobius.gameserver.enums.AttributeType;
import com.l2jmobius.gameserver.enums.InstanceType;
import com.l2jmobius.gameserver.enums.ItemLocation;
import com.l2jmobius.gameserver.enums.ItemSkillType;
import com.l2jmobius.gameserver.enums.ShotType;
import com.l2jmobius.gameserver.enums.UserInfoType;
import com.l2jmobius.gameserver.geoengine.GeoEngine;
import com.l2jmobius.gameserver.idfactory.IdFactory;
@ -176,8 +175,6 @@ public final class L2ItemInstance extends L2Object
private final DropProtection _dropProtection = new DropProtection();
private int _shotsMask = 0;
private final List<Options> _enchantOptions = new ArrayList<>();
private final Map<Integer, EnsoulOption> _ensoulOptions = new LinkedHashMap<>(3);
private final Map<Integer, EnsoulOption> _ensoulSpecialOptions = new LinkedHashMap<>(3);
@ -1369,7 +1366,6 @@ public final class L2ItemInstance extends L2Object
final InventoryUpdate iu = new InventoryUpdate();
for (L2ItemInstance item : unequiped)
{
item.unChargeAllShots();
iu.addModifiedItem(item);
}
player.sendInventoryUpdate(iu);
@ -1797,7 +1793,6 @@ public final class L2ItemInstance extends L2Object
final InventoryUpdate iu = new InventoryUpdate();
for (L2ItemInstance item : unequiped)
{
item.unChargeAllShots();
iu.addModifiedItem(item);
}
player.sendInventoryUpdate(iu);
@ -2047,30 +2042,6 @@ public final class L2ItemInstance extends L2Object
}
}
@Override
public boolean isChargedShot(ShotType type)
{
return (_shotsMask & type.getMask()) == type.getMask();
}
@Override
public void setChargedShot(ShotType type, boolean charged)
{
if (charged)
{
_shotsMask |= type.getMask();
}
else
{
_shotsMask &= ~type.getMask();
}
}
public void unChargeAllShots()
{
_shotsMask = 0;
}
/**
* Returns enchant effect object for this item
* @return enchanteffect

View File

@ -272,11 +272,7 @@ public abstract class AbstractOlympiadGame
player.disableAutoShotsAll();
// Discharge any active shots
final L2ItemInstance item = player.getActiveWeaponInstance();
if (item != null)
{
item.unChargeAllShots();
}
player.unchargeAllShots();
// enable skills with cool time <= 15 minutes
for (Skill skill : player.getAllSkills())

View File

@ -1495,11 +1495,11 @@ public final class Skill implements IIdentifiable
{
if (useSpiritShot())
{
caster.setChargedShot(caster.isChargedShot(ShotType.BLESSED_SPIRITSHOTS) ? ShotType.BLESSED_SPIRITSHOTS : ShotType.SPIRITSHOTS, false);
caster.unchargeShot(caster.isChargedShot(ShotType.BLESSED_SPIRITSHOTS) ? ShotType.BLESSED_SPIRITSHOTS : ShotType.SPIRITSHOTS);
}
else if (useSoulShot())
{
caster.setChargedShot(caster.isChargedShot(ShotType.BLESSED_SOULSHOTS) ? ShotType.BLESSED_SOULSHOTS : ShotType.SOULSHOTS, false);
caster.unchargeShot(caster.isChargedShot(ShotType.BLESSED_SOULSHOTS) ? ShotType.BLESSED_SOULSHOTS : ShotType.SOULSHOTS);
}
}

View File

@ -217,11 +217,11 @@ public class SkillChannelizer implements Runnable
// Reduce shots.
if (skill.useSpiritShot())
{
_channelizer.setChargedShot(_channelizer.isChargedShot(ShotType.BLESSED_SPIRITSHOTS) ? ShotType.BLESSED_SPIRITSHOTS : ShotType.SPIRITSHOTS, false);
_channelizer.unchargeShot(_channelizer.isChargedShot(ShotType.BLESSED_SPIRITSHOTS) ? ShotType.BLESSED_SPIRITSHOTS : ShotType.SPIRITSHOTS);
}
else
{
_channelizer.setChargedShot(_channelizer.isChargedShot(ShotType.BLESSED_SOULSHOTS) ? ShotType.BLESSED_SOULSHOTS : ShotType.SOULSHOTS, false);
_channelizer.unchargeShot(_channelizer.isChargedShot(ShotType.BLESSED_SOULSHOTS) ? ShotType.BLESSED_SOULSHOTS : ShotType.SOULSHOTS);
}
// Shots are re-charged every cast.

View File

@ -646,17 +646,11 @@ public class EnterWorld implements IClientIncomingPacket
activeChar.sendPacket(new ExOneDayReceiveRewardList(activeChar));
activeChar.sendPacket(ExConnectedTimeAndGettableReward.STATIC_PACKET);
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));
}
// Handle soulshots, disable all on EnterWorld
activeChar.sendPacket(new ExAutoSoulShot(0, true, 0));
activeChar.sendPacket(new ExAutoSoulShot(0, true, 1));
activeChar.sendPacket(new ExAutoSoulShot(0, true, 2));
activeChar.sendPacket(new ExAutoSoulShot(0, true, 3));
if (Config.HARDWARE_INFO_ENABLED)
{

View File

@ -180,11 +180,7 @@ public final class RequestDropItem implements IClientIncomingPacket
if (item.isEquipped())
{
final L2ItemInstance[] unequiped = activeChar.getInventory().unEquipItemInSlotAndRecord(item.getLocationSlot());
for (L2ItemInstance itm : unequiped)
{
itm.unChargeAllShots();
}
activeChar.getInventory().unEquipItemInSlot(item.getLocationSlot());
activeChar.broadcastUserInfo();
activeChar.sendItemList(true);
}