Addition of ExDieInfo packet.
This commit is contained in:
@@ -4567,7 +4567,7 @@ public abstract class Creature extends WorldObject implements ISkillsHolder, IDe
|
||||
}
|
||||
else if (isPlayer())
|
||||
{
|
||||
getActingPlayer().getStatus().reduceHp(amount, attacker, (skill == null) || !skill.isToggle(), isDOT, false, directlyToHp);
|
||||
getActingPlayer().getStatus().reduceHp(amount, attacker, skill, (skill == null) || !skill.isToggle(), isDOT, false, directlyToHp);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@@ -35,6 +35,7 @@ import java.util.Objects;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.ConcurrentSkipListMap;
|
||||
import java.util.concurrent.CopyOnWriteArrayList;
|
||||
import java.util.concurrent.Future;
|
||||
import java.util.concurrent.ScheduledFuture;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
@@ -219,6 +220,7 @@ import org.l2jmobius.gameserver.model.events.returns.TerminateReturn;
|
||||
import org.l2jmobius.gameserver.model.events.timers.TimerHolder;
|
||||
import org.l2jmobius.gameserver.model.fishing.Fishing;
|
||||
import org.l2jmobius.gameserver.model.holders.AttendanceInfoHolder;
|
||||
import org.l2jmobius.gameserver.model.holders.DamageTakenHolder;
|
||||
import org.l2jmobius.gameserver.model.holders.ItemHolder;
|
||||
import org.l2jmobius.gameserver.model.holders.MonsterBookCardHolder;
|
||||
import org.l2jmobius.gameserver.model.holders.MonsterBookRewardHolder;
|
||||
@@ -288,6 +290,7 @@ import org.l2jmobius.gameserver.network.serverpackets.ExAdenaInvenCount;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.ExAlterSkillRequest;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.ExAutoSoulShot;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.ExBrPremiumState;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.ExDieInfo;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.ExDuelUpdateUserInfo;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.ExGetBookMarkInfoPacket;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.ExGetOnAirShip;
|
||||
@@ -470,6 +473,8 @@ public class PlayerInstance extends Playable
|
||||
/** The PvP Flag state of the PlayerInstance (0=White, 1=Purple) */
|
||||
private byte _pvpFlag;
|
||||
|
||||
private final List<DamageTakenHolder> _lastDamageTaken = new CopyOnWriteArrayList<>();
|
||||
|
||||
/** The Fame of this PlayerInstance */
|
||||
private int _fame;
|
||||
private ScheduledFuture<?> _fameTask;
|
||||
@@ -4742,6 +4747,8 @@ public class PlayerInstance extends Playable
|
||||
@Override
|
||||
public boolean doDie(Creature killer)
|
||||
{
|
||||
Collection<ItemInstance> droppedItems = null;
|
||||
|
||||
if (killer != null)
|
||||
{
|
||||
final PlayerInstance pk = killer.getActingPlayer();
|
||||
@@ -4850,7 +4857,7 @@ public class PlayerInstance extends Playable
|
||||
final boolean insidePvpZone = isInsideZone(ZoneId.PVP) || isInsideZone(ZoneId.SIEGE);
|
||||
if ((pk == null) || !pk.isCursedWeaponEquipped())
|
||||
{
|
||||
onDieDropItem(killer); // Check if any item should be dropped
|
||||
droppedItems = onDieDropItem(killer); // Check if any item should be dropped
|
||||
if (!insidePvpZone && (pk != null))
|
||||
{
|
||||
final Clan pkClan = pk.getClan();
|
||||
@@ -4872,6 +4879,8 @@ public class PlayerInstance extends Playable
|
||||
}
|
||||
}
|
||||
|
||||
sendPacket(new ExDieInfo(droppedItems == null ? Collections.emptyList() : droppedItems, _lastDamageTaken));
|
||||
|
||||
if (isMounted())
|
||||
{
|
||||
stopFeed();
|
||||
@@ -4916,19 +4925,34 @@ public class PlayerInstance extends Playable
|
||||
return true;
|
||||
}
|
||||
|
||||
private void onDieDropItem(Creature killer)
|
||||
public void addDamageTaken(Creature attacker, Skill skill, double damage)
|
||||
{
|
||||
if (GameEvent.isParticipant(this) || (killer == null))
|
||||
if (attacker == this)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
_lastDamageTaken.add(new DamageTakenHolder(attacker, skill, damage));
|
||||
while (_lastDamageTaken.size() > 10)
|
||||
{
|
||||
_lastDamageTaken.remove(0);
|
||||
}
|
||||
}
|
||||
|
||||
private Collection<ItemInstance> onDieDropItem(Creature killer)
|
||||
{
|
||||
final List<ItemInstance> droppedItems = new ArrayList<>();
|
||||
if (GameEvent.isParticipant(this) || (killer == null))
|
||||
{
|
||||
return droppedItems;
|
||||
}
|
||||
|
||||
final PlayerInstance pk = killer.getActingPlayer();
|
||||
if ((getReputation() >= 0) && (pk != null) && (pk.getClan() != null) && (getClan() != null) && (pk.getClan().isAtWarWith(_clanId)
|
||||
// || _clan.isAtWarWith(((PlayerInstance)killer).getClanId())
|
||||
))
|
||||
{
|
||||
return;
|
||||
return droppedItems;
|
||||
}
|
||||
|
||||
if ((!isInsideZone(ZoneId.PVP) || (pk == null)) && (!isGM() || Config.KARMA_DROP_GM))
|
||||
@@ -4992,6 +5016,8 @@ public class PlayerInstance extends Playable
|
||||
if (Rnd.get(100) < itemDropPercent)
|
||||
{
|
||||
dropItem("DieDrop", itemDrop, killer, true);
|
||||
droppedItems.add(itemDrop);
|
||||
|
||||
if (isKarmaDrop)
|
||||
{
|
||||
LOGGER.warning(getName() + " has karma and dropped id = " + itemDrop.getId() + ", count = " + itemDrop.getCount());
|
||||
@@ -5009,6 +5035,8 @@ public class PlayerInstance extends Playable
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return droppedItems;
|
||||
}
|
||||
|
||||
public void onPlayerKill(Playable killedPlayable)
|
||||
@@ -10077,6 +10105,8 @@ public class PlayerInstance extends Playable
|
||||
{
|
||||
instance.doRevive(this);
|
||||
}
|
||||
|
||||
_lastDamageTaken.clear();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@@ -28,6 +28,7 @@ import org.l2jmobius.gameserver.model.actor.stat.PlayerStat;
|
||||
import org.l2jmobius.gameserver.model.effects.EffectFlag;
|
||||
import org.l2jmobius.gameserver.model.entity.Duel;
|
||||
import org.l2jmobius.gameserver.model.skills.AbnormalType;
|
||||
import org.l2jmobius.gameserver.model.skills.Skill;
|
||||
import org.l2jmobius.gameserver.model.stats.Formulas;
|
||||
import org.l2jmobius.gameserver.model.stats.Stat;
|
||||
import org.l2jmobius.gameserver.network.SystemMessageId;
|
||||
@@ -60,16 +61,16 @@ public class PlayerStatus extends PlayableStatus
|
||||
@Override
|
||||
public void reduceHp(double value, Creature attacker)
|
||||
{
|
||||
reduceHp(value, attacker, true, false, false, false);
|
||||
reduceHp(value, attacker, null, true, false, false, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reduceHp(double value, Creature attacker, boolean awake, boolean isDOT, boolean isHPConsumption)
|
||||
{
|
||||
reduceHp(value, attacker, awake, isDOT, isHPConsumption, false);
|
||||
reduceHp(value, attacker, null, awake, isDOT, isHPConsumption, false);
|
||||
}
|
||||
|
||||
public void reduceHp(double value, Creature attacker, boolean awake, boolean isDOT, boolean isHPConsumption, boolean ignoreCP)
|
||||
public void reduceHp(double value, Creature attacker, Skill skill, boolean awake, boolean isDOT, boolean isHPConsumption, boolean ignoreCP)
|
||||
{
|
||||
if (getActiveChar().isDead())
|
||||
{
|
||||
@@ -280,6 +281,11 @@ public class PlayerStatus extends PlayableStatus
|
||||
|
||||
if (amount > 0)
|
||||
{
|
||||
if ((skill != null) && skill.isBad())
|
||||
{
|
||||
getActiveChar().addDamageTaken(attacker, skill, amount);
|
||||
}
|
||||
|
||||
double newHp = Math.max(getCurrentHp() - amount, getActiveChar().isUndying() ? 1 : 0);
|
||||
if (newHp <= 0)
|
||||
{
|
||||
|
@@ -0,0 +1,52 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.l2jmobius.gameserver.model.holders;
|
||||
|
||||
import org.l2jmobius.gameserver.model.actor.Creature;
|
||||
import org.l2jmobius.gameserver.model.skills.Skill;
|
||||
|
||||
/**
|
||||
* @author Mobius
|
||||
*/
|
||||
public class DamageTakenHolder
|
||||
{
|
||||
private final Creature _creature;
|
||||
private final Skill _skill;
|
||||
private final double _damage;
|
||||
|
||||
public DamageTakenHolder(Creature creature, Skill skill, double amount)
|
||||
{
|
||||
_creature = creature;
|
||||
_skill = skill;
|
||||
_damage = amount;
|
||||
}
|
||||
|
||||
public Creature getCreature()
|
||||
{
|
||||
return _creature;
|
||||
}
|
||||
|
||||
public Skill getSkill()
|
||||
{
|
||||
return _skill;
|
||||
}
|
||||
|
||||
public double getDamage()
|
||||
{
|
||||
return _damage;
|
||||
}
|
||||
}
|
@@ -0,0 +1,67 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.l2jmobius.gameserver.network.serverpackets;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
import org.l2jmobius.commons.network.PacketWriter;
|
||||
import org.l2jmobius.gameserver.model.holders.DamageTakenHolder;
|
||||
import org.l2jmobius.gameserver.model.items.instance.ItemInstance;
|
||||
import org.l2jmobius.gameserver.network.OutgoingPackets;
|
||||
|
||||
/**
|
||||
* @author Mobius
|
||||
*/
|
||||
public class ExDieInfo implements IClientOutgoingPacket
|
||||
{
|
||||
private final Collection<ItemInstance> _droppedItems;
|
||||
private final Collection<DamageTakenHolder> _lastDamageTaken;
|
||||
|
||||
public ExDieInfo(Collection<ItemInstance> droppedItems, Collection<DamageTakenHolder> lastDamageTaken)
|
||||
{
|
||||
_droppedItems = droppedItems;
|
||||
_lastDamageTaken = lastDamageTaken;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean write(PacketWriter packet)
|
||||
{
|
||||
OutgoingPackets.EX_DIE_INFO.writeId(packet);
|
||||
|
||||
packet.writeH(_droppedItems.size());
|
||||
for (ItemInstance item : _droppedItems)
|
||||
{
|
||||
packet.writeD(item.getId());
|
||||
packet.writeD(item.getEnchantLevel());
|
||||
packet.writeD((int) item.getCount());
|
||||
}
|
||||
|
||||
boolean first = true; // Missing first character from first name hack.
|
||||
packet.writeH(_lastDamageTaken.size());
|
||||
for (DamageTakenHolder damageHolder : _lastDamageTaken)
|
||||
{
|
||||
packet.writeS((first ? " " : "") + damageHolder.getCreature().getName());
|
||||
packet.writeH(0x00);
|
||||
packet.writeD(damageHolder.getSkill().getDisplayId());
|
||||
packet.writeF(damageHolder.getDamage());
|
||||
packet.writeD(0x00);
|
||||
first = false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user