Which function called when character dying?

Support for the latest build of L2J Server, get help here with installations, upgrades, problems.
Do not post bugs reports here, use viewforum.php?f=77 instead.
There is no support for other server builds than the official provided by l2jserver.com
Forum rules
READ NOW: L2j Forums Rules of Conduct
Post Reply
User avatar
KGB1st
Posts: 230
Joined: Sat Jul 26, 2014 5:58 pm

Which function called when character dying?

Post by KGB1st » Thu Sep 19, 2019 10:28 pm

Which function called when character dying from mob or other character? I tried to modify public boolean doDie(L2Character killer) but it not works.. I need in moment when character dies. I want to check some abnormal effects on them, but in doDie() it not possible.

Code: Select all

	public boolean doDie(L2Character killer) {
		final TerminateReturn returnBack = EventDispatcher.getInstance().notifyEvent(new OnCreatureKill(killer, this), this, TerminateReturn.class);
		if ((returnBack != null) && returnBack.terminate()) {
			return false;
		}
		
		// killing is only possible one time
		synchronized (this) {
			if (isDead()) {
				return false;
			}
			
			LOG.info("TRYING TO SEARCH NOOBLE BUFF..");
			
			// now reset currentHp to zero
			setCurrentHp(0);
			setIsDead(true);
		}
		
		// Set target to null and cancel Attack or Cast
		setTarget(null);
		
		// Stop movement
		stopMove(null);
		
		// Stop HP/MP/CP Regeneration task
		getStatus().stopHpMpRegeneration();
		
		stopAllEffectsExceptThoseThatLastThroughDeath();
		
		calculateRewards(killer);
		
		// Send the Server->Client packet StatusUpdate with current HP and MP to all other L2PcInstance to inform
		broadcastStatusUpdate();
		
		// Notify L2Character AI
		if (hasAI()) {
			getAI().notifyEvent(CtrlEvent.EVT_DEAD);
		}
		
		if (getWorldRegion() != null) {
			getWorldRegion().onDeath(this);
		}
		
		getAttackByList().clear();
		
		if (isChannelized()) {
			getSkillChannelized().abortChannelization();
		}
		return true;
	}
And why function setIsDead() working on clear server, when no one character connected? :D L2Character called not only for characters?
Abnormal logic :'| How much instances of L2Character works on server?

Post Reply