Sync with L2JServer Jan 24th 2015.

This commit is contained in:
mobius
2015-01-24 20:02:32 +00:00
parent d349bd3924
commit 1c6301c46d
1012 changed files with 23069 additions and 6307 deletions

View File

@ -18,11 +18,14 @@
*/
package handlers.itemhandlers;
import java.util.List;
import java.util.logging.Level;
import java.util.stream.Collectors;
import com.l2jserver.gameserver.enums.ShotType;
import com.l2jserver.gameserver.handler.IItemHandler;
import com.l2jserver.gameserver.model.actor.L2Playable;
import com.l2jserver.gameserver.model.actor.L2Summon;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
import com.l2jserver.gameserver.model.holders.SkillHolder;
import com.l2jserver.gameserver.model.items.instance.L2ItemInstance;
@ -52,7 +55,15 @@ public class BeastSpiritShot implements IItemHandler
return false;
}
if (activeOwner.getSummon().isDead())
final L2Summon pet = playable.getPet();
if ((pet != null) && pet.isDead())
{
activeOwner.sendPacket(SystemMessageId.SOULSHOTS_AND_SPIRITSHOTS_ARE_NOT_AVAILABLE_FOR_A_DEAD_PET_OR_SERVITOR_SAD_ISN_T_IT);
return false;
}
final List<L2Summon> aliveServitor = playable.getServitors().values().stream().filter(s -> !s.isDead()).collect(Collectors.toList());
if (aliveServitor.isEmpty())
{
activeOwner.sendPacket(SystemMessageId.SOULSHOTS_AND_SPIRITSHOTS_ARE_NOT_AVAILABLE_FOR_A_DEAD_PET_OR_SERVITOR_SAD_ISN_T_IT);
return false;
@ -60,9 +71,27 @@ public class BeastSpiritShot implements IItemHandler
final int itemId = item.getId();
final boolean isBlessed = ((itemId == 6647) || (itemId == 20334)); // TODO: Unhardcode these!
final short shotConsumption = activeOwner.getSummon().getSpiritShotsPerHit();
final SkillHolder[] skills = item.getItem().getSkills();
final ShotType shotType = isBlessed ? ShotType.BLESSED_SPIRITSHOTS : ShotType.SPIRITSHOTS;
short shotConsumption = 0;
if (pet != null)
{
if (!pet.isChargedShot(shotType))
{
shotConsumption += pet.getSpiritShotsPerHit();
}
}
for (L2Summon servitors : aliveServitor)
{
if (!servitors.isChargedShot(shotType))
{
shotConsumption += servitors.getSpiritShotsPerHit();
}
}
if (skills == null)
{
_log.log(Level.WARNING, getClass().getSimpleName() + ": is missing skills!");
@ -80,12 +109,6 @@ public class BeastSpiritShot implements IItemHandler
return false;
}
if (activeOwner.getSummon().isChargedShot(isBlessed ? ShotType.BLESSED_SPIRITSHOTS : ShotType.SPIRITSHOTS))
{
// shots are already active.
return false;
}
if (!activeOwner.destroyItemWithoutTrace("Consume", item.getObjectId(), shotConsumption, null, false))
{
if (!activeOwner.disableAutoShot(itemId))
@ -97,9 +120,23 @@ public class BeastSpiritShot implements IItemHandler
// Pet uses the power of spirit.
activeOwner.sendPacket(SystemMessageId.YOUR_PET_USES_SPIRITSHOT);
activeOwner.getSummon().setChargedShot(isBlessed ? ShotType.BLESSED_SPIRITSHOTS : ShotType.SPIRITSHOTS, true);
if (pet != null)
{
if (!pet.isChargedShot(shotType))
{
pet.setChargedShot(shotType, true);
Broadcast.toSelfAndKnownPlayersInRadius(activeOwner, new MagicSkillUse(pet, pet, skills[0].getSkillId(), skills[0].getSkillLvl(), 0, 0), 600);
}
}
Broadcast.toSelfAndKnownPlayersInRadius(activeOwner, new MagicSkillUse(activeOwner.getSummon(), activeOwner.getSummon(), skills[0].getSkillId(), skills[0].getSkillLvl(), 0, 0), 600);
aliveServitor.forEach(s ->
{
if (!s.isChargedShot(shotType))
{
s.setChargedShot(shotType, true);
Broadcast.toSelfAndKnownPlayersInRadius(activeOwner, new MagicSkillUse(s, s, skills[0].getSkillId(), skills[0].getSkillLvl(), 0, 0), 600);
}
});
return true;
}
}