Public feed
#379572
Index: C:/Documents and Settings/FBIagent/My Documents/eclipse/workspace_x86/L2_GameServer_c5/java/net/sf/l2j/gameserver/model/L2Character.java
===================================================================
--- C:/Documents and Settings/FBIagent/My Documents/eclipse/workspace_x86/L2_GameServer_c5/java/net/sf/l2j/gameserver/model/L2Character.java (revision 587)
+++ C:/Documents and Settings/FBIagent/My Documents/eclipse/workspace_x86/L2_GameServer_c5/java/net/sf/l2j/gameserver/model/L2Character.java (working copy)
@@ -150,6 +150,9 @@
private L2CharTemplate _Template; // The link on the L2CharTemplate object containing generic and static properties of this L2Character type (ex : Max HP, Speed...)
private String _Title;
private String _aiClass = "default";
+ private double _hpUpdateIncCheck;
+ private double _hpUpdateDecCheck;
+ private double _hpUpdateInterval;
/** Table of Calculators containing all used calculator */
private Calculator[] _Calculators;
@@ -214,6 +217,10 @@
_Calculators = new Calculator[Stats.NUM_STATS];
Formulas.getInstance().addFuncsToNewCharacter(this);
}
+
+ _hpUpdateInterval = getMaxHp()/352; // MAX_HP div MAX_HP_BAR_PX
+ _hpUpdateIncCheck = getMaxHp();
+ _hpUpdateDecCheck = getMaxHp()-_hpUpdateInterval;
}
// =========================================================
@@ -285,6 +292,41 @@
}
/**
+ * Returns true if status update should be done, false if not
+ * @return boolean
+ */
+ private boolean needStatusUpdate()
+ {
+ if (!(this instanceof L2MonsterInstance))
+ return true;
+
+ double currentHp = getCurrentHp();
+
+ if (currentHp <= 0.00)
+ return true;
+
+ boolean needUpdate = false;
+
+/* if (currentHp > getMaxHp())
+ currentHp = getMaxHp();*/
+
+ if (currentHp < _hpUpdateDecCheck)
+ {
+ needUpdate = true;
+ _hpUpdateDecCheck -= _hpUpdateInterval;
+ _hpUpdateIncCheck -= _hpUpdateInterval;
+ }
+ else if (currentHp > _hpUpdateIncCheck)
+ {
+ needUpdate = true;
+ _hpUpdateDecCheck += _hpUpdateInterval;
+ _hpUpdateIncCheck += _hpUpdateInterval;
+ }
+
+ return needUpdate;
+ }
+
+ /**
* Send the Server->Client packet StatusUpdate with current HP and MP to all other L2PcInstance to inform.<BR><BR>
*
* <B><U> Actions</U> :</B><BR><BR>
@@ -302,10 +344,13 @@
{
if (getStatus().getStatusListener() == null || getStatus().getStatusListener().isEmpty()) return;
+ if (!needStatusUpdate())
+ return;
+
// Create the Server->Client packet StatusUpdate with current HP and MP
StatusUpdate su = new StatusUpdate(getObjectId());
- su.addAttribute(StatusUpdate.CUR_HP, (int)getStatus().getCurrentHp());
- su.addAttribute(StatusUpdate.CUR_MP, (int)getStatus().getCurrentMp());
+ su.addAttribute(StatusUpdate.CUR_HP, (int)getCurrentHp());
+ su.addAttribute(StatusUpdate.CUR_MP, (int)getCurrentMp());
// Go through the StatusListener
// Send the Server->Client packet StatusUpdate with current HP and MP