Method needHpUpdate simplification.
This commit is contained in:
@ -145,6 +145,8 @@ public abstract class Creature extends WorldObject implements ISkillsHolder
|
||||
{
|
||||
protected static final Logger LOGGER = Logger.getLogger(Creature.class.getName());
|
||||
|
||||
public static final double MAX_HP_BAR_PX = 352.0;
|
||||
|
||||
private long attackStance;
|
||||
private List<Creature> _attackByList;
|
||||
private Skill _lastSkillCast;
|
||||
@ -287,9 +289,9 @@ public abstract class Creature extends WorldObject implements ISkillsHolder
|
||||
*/
|
||||
protected void initCharStatusUpdateValues()
|
||||
{
|
||||
_hpUpdateInterval = getStat().getMaxHp() / 352.0; // MAX_HP div MAX_HP_BAR_PX
|
||||
_hpUpdateIncCheck = getStat().getMaxHp();
|
||||
_hpUpdateDecCheck = getStat().getMaxHp() - _hpUpdateInterval;
|
||||
_hpUpdateInterval = _stat.getMaxHp() / MAX_HP_BAR_PX;
|
||||
_hpUpdateIncCheck = _stat.getMaxHp();
|
||||
_hpUpdateDecCheck = _stat.getMaxHp() - _hpUpdateInterval;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -414,21 +416,20 @@ public abstract class Creature extends WorldObject implements ISkillsHolder
|
||||
}
|
||||
|
||||
/**
|
||||
* Need hp update.
|
||||
* @param barPixels the bar pixels
|
||||
* @return true if hp update should be done, false if not
|
||||
*/
|
||||
protected boolean needHpUpdate(int barPixels)
|
||||
protected boolean needHpUpdate()
|
||||
{
|
||||
final double currentHp = getStatus().getCurrentHp();
|
||||
if ((currentHp <= 1.0) || (getStat().getMaxHp() < barPixels))
|
||||
final double currentHp = _status.getCurrentHp();
|
||||
final double maxHp = _stat.getMaxHp();
|
||||
if ((currentHp <= 1.0) || (maxHp < MAX_HP_BAR_PX))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
if ((currentHp <= _hpUpdateDecCheck) || (currentHp >= _hpUpdateIncCheck))
|
||||
{
|
||||
if (currentHp == getStat().getMaxHp())
|
||||
if (currentHp == maxHp)
|
||||
{
|
||||
_hpUpdateIncCheck = currentHp + 1;
|
||||
_hpUpdateDecCheck = currentHp - _hpUpdateInterval;
|
||||
@ -437,9 +438,10 @@ public abstract class Creature extends WorldObject implements ISkillsHolder
|
||||
{
|
||||
final double doubleMulti = currentHp / _hpUpdateInterval;
|
||||
int intMulti = (int) doubleMulti;
|
||||
_hpUpdateDecCheck = _hpUpdateInterval * (doubleMulti < intMulti ? intMulti-- : intMulti);
|
||||
_hpUpdateDecCheck = _hpUpdateInterval * (doubleMulti < intMulti ? intMulti - 1 : intMulti);
|
||||
_hpUpdateIncCheck = _hpUpdateDecCheck + _hpUpdateInterval;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -465,7 +467,7 @@ public abstract class Creature extends WorldObject implements ISkillsHolder
|
||||
return;
|
||||
}
|
||||
|
||||
if (!needHpUpdate(352))
|
||||
if (!needHpUpdate())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
@ -4559,13 +4559,12 @@ public class PlayerInstance extends Playable
|
||||
|
||||
/**
|
||||
* Returns true if cp update should be done, false if not.
|
||||
* @param barPixels the bar pixels
|
||||
* @return boolean
|
||||
*/
|
||||
private boolean needCpUpdate(int barPixels)
|
||||
private boolean needCpUpdate()
|
||||
{
|
||||
final double currentCp = getCurrentCp();
|
||||
if ((currentCp <= 1.0) || (getMaxCp() < barPixels))
|
||||
if ((currentCp <= 1.0) || (getMaxCp() < MAX_HP_BAR_PX))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
@ -4581,7 +4580,7 @@ public class PlayerInstance extends Playable
|
||||
{
|
||||
final double doubleMulti = currentCp / _cpUpdateInterval;
|
||||
int intMulti = (int) doubleMulti;
|
||||
_cpUpdateDecCheck = _cpUpdateInterval * (doubleMulti < intMulti ? intMulti-- : intMulti);
|
||||
_cpUpdateDecCheck = _cpUpdateInterval * (doubleMulti < intMulti ? intMulti - 1 : intMulti);
|
||||
_cpUpdateIncCheck = _cpUpdateDecCheck + _cpUpdateInterval;
|
||||
}
|
||||
|
||||
@ -4593,13 +4592,12 @@ public class PlayerInstance extends Playable
|
||||
|
||||
/**
|
||||
* Returns true if mp update should be done, false if not.
|
||||
* @param barPixels the bar pixels
|
||||
* @return boolean
|
||||
*/
|
||||
private boolean needMpUpdate(int barPixels)
|
||||
private boolean needMpUpdate()
|
||||
{
|
||||
final double currentMp = getCurrentMp();
|
||||
if ((currentMp <= 1.0) || (getMaxMp() < barPixels))
|
||||
if ((currentMp <= 1.0) || (getMaxMp() < MAX_HP_BAR_PX))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
@ -4615,7 +4613,7 @@ public class PlayerInstance extends Playable
|
||||
{
|
||||
final double doubleMulti = currentMp / _mpUpdateInterval;
|
||||
int intMulti = (int) doubleMulti;
|
||||
_mpUpdateDecCheck = _mpUpdateInterval * (doubleMulti < intMulti ? intMulti-- : intMulti);
|
||||
_mpUpdateDecCheck = _mpUpdateInterval * (doubleMulti < intMulti ? intMulti - 1 : intMulti);
|
||||
_mpUpdateIncCheck = _mpUpdateDecCheck + _mpUpdateInterval;
|
||||
}
|
||||
|
||||
@ -4657,7 +4655,7 @@ public class PlayerInstance extends Playable
|
||||
}
|
||||
|
||||
// Check if a party is in progress and party window update is usefull
|
||||
if (isInParty() && (needCpUpdate(352) || super.needHpUpdate(352) || needMpUpdate(352)))
|
||||
if (isInParty() && (needCpUpdate() || needHpUpdate() || needMpUpdate()))
|
||||
{
|
||||
// Send the Server->Client packet PartySmallWindowUpdate with current HP, MP and Level to all other PlayerInstance of the Party
|
||||
getParty().broadcastToPartyMembers(this, new PartySmallWindowUpdate(this));
|
||||
|
Reference in New Issue
Block a user