Properly display death point values.

Thanks to Mode.
This commit is contained in:
MobiusDevelopment 2020-11-27 07:31:36 +00:00
parent 8217c8fdb2
commit b64c9cf98e
5 changed files with 37 additions and 7 deletions

View File

@ -52,7 +52,10 @@ public enum StatusUpdateType
REPUTATION(0x1B, creature -> creature.isPlayer() ? creature.getActingPlayer().getReputation() : 0),
CUR_CP(0x21, creature -> (int) creature.getCurrentCp()),
MAX_CP(0x22, Creature::getMaxCp);
MAX_CP(0x22, Creature::getMaxCp),
CUR_DP(0x28, creature -> creature.isPlayer() ? creature.getActingPlayer().getDeathPoints() : 0),
MAX_DP(0x29, creature -> creature.isPlayer() ? creature.getActingPlayer().getMaxDeathPoints() : 0);
private int _clientId;
private Function<Creature, Integer> _valueSupplier;

View File

@ -5408,6 +5408,10 @@ public abstract class Creature extends WorldObject implements ISkillsHolder, IDe
if ((oldValue == null) || (oldValue != newValue))
{
su.addUpdate(type, newValue);
if ((type == StatusUpdateType.MAX_DP) && isPlayer())
{
su.addUpdate(StatusUpdateType.CUR_DP, getActingPlayer().getDeathPoints());
}
return newValue;
}
return oldValue;

View File

@ -677,6 +677,7 @@ public class PlayerInstance extends Playable
private final static int DEATH_POINTS_PASSIVE = 45352;
private final static int DEVASTATING_MIND = 45300;
private int _deathPoints = 0;
private int _maxDeathPoints = 0;
// WorldPosition used by TARGET_SIGNET_GROUND
private Location _currentSkillWorldPosition;
@ -11317,30 +11318,34 @@ public class PlayerInstance extends Playable
return _deathPoints;
}
public int getMaxDeathPoints()
{
return _maxDeathPoints;
}
public void setDeathPoints(int value)
{
// Find current max points.
int maxPoints = 0;
// Check current death points passive level.
switch (getAffectedSkillLevel(DEATH_POINTS_PASSIVE))
{
case 1:
{
maxPoints = 500;
_maxDeathPoints = 500;
break;
}
case 2:
{
maxPoints = 700;
_maxDeathPoints = 700;
break;
}
case 3:
{
maxPoints = 1000;
_maxDeathPoints = 1000;
break;
}
}
// Set current points.
_deathPoints = Math.min(maxPoints, Math.max(0, value));
_deathPoints = Math.min(_maxDeathPoints, Math.max(0, value));
// Apply devastating mind.
final int expectedLevel = _deathPoints / 100;
if (expectedLevel > 0)
@ -11355,6 +11360,11 @@ public class PlayerInstance extends Playable
{
getEffectList().stopSkillEffects(true, DEVASTATING_MIND);
}
// Send StatusUpdate.
final StatusUpdate su = new StatusUpdate(this);
computeStatusUpdate(su, StatusUpdateType.MAX_DP);
computeStatusUpdate(su, StatusUpdateType.CUR_DP);
sendPacket(su);
}
@Override
@ -13920,6 +13930,10 @@ public class PlayerInstance extends Playable
addStatusUpdateValue(StatusUpdateType.LEVEL);
addStatusUpdateValue(StatusUpdateType.MAX_CP);
addStatusUpdateValue(StatusUpdateType.CUR_CP);
if (isPlayer() && (getActingPlayer().getClassId().getId() > 195))
{
addStatusUpdateValue(StatusUpdateType.CUR_DP);
}
}
public TrainingHolder getTraingCampInfo()

View File

@ -648,6 +648,14 @@ public class EnterWorld implements IClientIncomingPacket
player.updateAbnormalVisualEffects();
}
// Death Knight death points init.
if (player.getClassId().getId() > 195)
{
// Send twice.
player.setDeathPoints(500);
player.setDeathPoints(0); // TODO: Store death point values?
}
if (Config.ENABLE_ATTENDANCE_REWARDS)
{
ThreadPool.schedule(() ->

View File

@ -54,6 +54,7 @@ public class StatusUpdate implements IClientOutgoingPacket
case CUR_HP:
case CUR_MP:
case CUR_CP:
case CUR_DP:
{
_isVisible = true;
}