» Find Revision
L2J Revision 3208:
L2JDP Revision 6295:
Hey all, I'm hoping this is the right place to post this question.
I'm experimenting a bit with titles. Essentially, the title shows the player's HP as a percent (currenthp/maxhp). It's setup to update every time the player's hp changes. My problem is, as the player is receiving damage, the number in the title always becomes 0, and only when they're receiving damage. Here's the code (my addition noted from between "//mod" and "//end mod"):
net.sf.l2j.gameserver.model.actor.status.CharStatus.java
Code: Select all
public final void setCurrentHp(double newHp, boolean broadcastPacket) { // Get the Max HP of the L2Character double maxHp = getActiveChar().getStat().getMaxHp(); synchronized (this) { if (getActiveChar().isDead()) return; if (newHp >= maxHp) { // Set the RegenActive flag to false _currentHp = maxHp; _flagsRegenActive &= ~REGEN_FLAG_HP; // Stop the HP/MP/CP Regeneration task if (_flagsRegenActive == 0) stopHpMpRegeneration(); } else { // Set the RegenActive flag to true _currentHp = newHp; _flagsRegenActive |= REGEN_FLAG_HP; // Start the HP/MP/CP Regeneration task with Medium priority startHpMpRegeneration(); } } if (getActiveChar() instanceof L2PcInstance) { //Mod double percent = (newHp/maxHp)*100; getActiveChar().sendMessage("DEBUGGING: percent - " + (int) percent); getActiveChar().setTitle("» " + (int) percent + "% «"); Broadcast.toSelfAndKnownPlayers(getActiveChar(), new UserInfo((L2PcInstance) getActiveChar())); //End mod if (getCurrentHp() <= maxHp * .3) { QuestState qs = ((L2PcInstance) getActiveChar()).getQuestState("255_Tutorial"); if (qs != null) qs.getQuest().notifyEvent("CE45", null, ((L2PcInstance) getActiveChar())); } } // Send the Server->Client packet StatusUpdate with current HP and MP to all other L2PcInstance to inform if (broadcastPacket) getActiveChar().broadcastStatusUpdate(); }
I've tried not casting "percent" to int and making an int variable assigning it the int casted value of "percent" and using that variable for the title in place of "percent" but had the same results.
I've been stuck on this for hours, any help would be appreciated!

- Austin