ExDieInfo support for non skill damage.

This commit is contained in:
MobiusDevelopment 2020-07-07 10:37:19 +00:00
parent 35a2958fab
commit 60b164e47f
10 changed files with 32 additions and 28 deletions

View File

@ -4925,20 +4925,25 @@ public class PlayerInstance extends Playable
return true;
}
public void addDamageTaken(Creature attacker, Skill skill, double damage)
public void addDamageTaken(Creature attacker, int skillId, double damage)
{
if (attacker == this)
{
return;
}
_lastDamageTaken.add(new DamageTakenHolder(attacker, skill, damage));
while (_lastDamageTaken.size() > 10)
_lastDamageTaken.add(new DamageTakenHolder(attacker, skillId, damage));
while (_lastDamageTaken.size() > 20)
{
_lastDamageTaken.remove(0);
}
}
public void clearDamageTaken()
{
_lastDamageTaken.clear();
}
private Collection<ItemInstance> onDieDropItem(Creature killer)
{
final List<ItemInstance> droppedItems = new ArrayList<>();

View File

@ -281,10 +281,7 @@ public class PlayerStatus extends PlayableStatus
if (amount > 0)
{
if ((skill != null) && skill.isBad())
{
getActiveChar().addDamageTaken(attacker, skill, amount);
}
getActiveChar().addDamageTaken(attacker, skill != null ? skill.getDisplayId() : 0, amount);
double newHp = Math.max(getCurrentHp() - amount, getActiveChar().isUndying() ? 1 : 0);
if (newHp <= 0)

View File

@ -17,7 +17,6 @@
package org.l2jmobius.gameserver.model.holders;
import org.l2jmobius.gameserver.model.actor.Creature;
import org.l2jmobius.gameserver.model.skills.Skill;
/**
* @author Mobius
@ -25,13 +24,13 @@ import org.l2jmobius.gameserver.model.skills.Skill;
public class DamageTakenHolder
{
private final Creature _creature;
private final Skill _skill;
private final int _skillId;
private final double _damage;
public DamageTakenHolder(Creature creature, Skill skill, double damage)
public DamageTakenHolder(Creature creature, int skillId, double damage)
{
_creature = creature;
_skill = skill;
_skillId = skillId;
_damage = damage;
}
@ -40,9 +39,9 @@ public class DamageTakenHolder
return _creature;
}
public Skill getSkill()
public int getSkillId()
{
return _skill;
return _skillId;
}
public double getDamage()

View File

@ -55,7 +55,7 @@ public class ExDieInfo implements IClientOutgoingPacket
{
packet.writeS(damageHolder.getCreature().getName());
packet.writeH(0x00);
packet.writeD(damageHolder.getSkill().getDisplayId());
packet.writeD(damageHolder.getSkillId());
packet.writeF(damageHolder.getDamage());
packet.writeD(0x00);
}

View File

@ -72,6 +72,7 @@ public class AttackStanceTaskManager
creature.getAI().setAutoAttacking(false);
if (creature.isPlayer() && creature.hasSummon())
{
creature.getActingPlayer().clearDamageTaken();
final Summon pet = creature.getPet();
if (pet != null)
{

View File

@ -4895,20 +4895,25 @@ public class PlayerInstance extends Playable
return true;
}
public void addDamageTaken(Creature attacker, Skill skill, double damage)
public void addDamageTaken(Creature attacker, int skillId, double damage)
{
if (attacker == this)
{
return;
}
_lastDamageTaken.add(new DamageTakenHolder(attacker, skill, damage));
while (_lastDamageTaken.size() > 10)
_lastDamageTaken.add(new DamageTakenHolder(attacker, skillId, damage));
while (_lastDamageTaken.size() > 20)
{
_lastDamageTaken.remove(0);
}
}
public void clearDamageTaken()
{
_lastDamageTaken.clear();
}
private Collection<ItemInstance> onDieDropItem(Creature killer)
{
final List<ItemInstance> droppedItems = new ArrayList<>();

View File

@ -281,10 +281,7 @@ public class PlayerStatus extends PlayableStatus
if (amount > 0)
{
if ((skill != null) && skill.isBad())
{
getActiveChar().addDamageTaken(attacker, skill, amount);
}
getActiveChar().addDamageTaken(attacker, skill != null ? skill.getDisplayId() : 0, amount);
double newHp = Math.max(getCurrentHp() - amount, getActiveChar().isUndying() ? 1 : 0);
if (newHp <= 0)

View File

@ -17,7 +17,6 @@
package org.l2jmobius.gameserver.model.holders;
import org.l2jmobius.gameserver.model.actor.Creature;
import org.l2jmobius.gameserver.model.skills.Skill;
/**
* @author Mobius
@ -25,13 +24,13 @@ import org.l2jmobius.gameserver.model.skills.Skill;
public class DamageTakenHolder
{
private final Creature _creature;
private final Skill _skill;
private final int _skillId;
private final double _damage;
public DamageTakenHolder(Creature creature, Skill skill, double damage)
public DamageTakenHolder(Creature creature, int skillId, double damage)
{
_creature = creature;
_skill = skill;
_skillId = skillId;
_damage = damage;
}
@ -40,9 +39,9 @@ public class DamageTakenHolder
return _creature;
}
public Skill getSkill()
public int getSkillId()
{
return _skill;
return _skillId;
}
public double getDamage()

View File

@ -55,7 +55,7 @@ public class ExDieInfo implements IClientOutgoingPacket
{
packet.writeS(damageHolder.getCreature().getName());
packet.writeH(0x00);
packet.writeD(damageHolder.getSkill().getDisplayId());
packet.writeD(damageHolder.getSkillId());
packet.writeF(damageHolder.getDamage());
packet.writeD(0x00);
}

View File

@ -72,6 +72,7 @@ public class AttackStanceTaskManager
creature.getAI().setAutoAttacking(false);
if (creature.isPlayer() && creature.hasSummon())
{
creature.getActingPlayer().clearDamageTaken();
final Summon pet = creature.getPet();
if (pet != null)
{