Jump to content

Question about delay of death


Go to solution Solved by DrTurk,

Recommended Posts

  • Active Member

One problem I face is the delay for the player to actually die, in the example below, I took the total damage from the player and there is a delay until he actually dies. In wars, where kills are counted, I often kill a player and another character steals the "kill", is there any way to solve this problem?

115718New-Project.gif

Thank you for your attention!

Link to comment
Share on other sites

  • Solution

char.cpp --> remove that:

m_dwKillerPID = 0;

char.h --> remove that:

DWORD				m_dwKillerPID;

 

char_battle.cpp --> remove/change that:

if (!pkKiller && m_dwKillerPID)
		pkKiller = CHARACTER_MANAGER::instance().FindByPID(m_dwKillerPID);

	m_dwKillerPID = 0;

change that:

if (GetHP() <= 0)
	{
		Stun();

		if (pAttacker && !pAttacker->IsNPC())
			m_dwKillerPID = pAttacker->GetPlayerID();
		else
			m_dwKillerPID = 0;
	}

to this:

if (GetHP() <= 0)
	{
		Dead(pAttacker);
	}

 

Edited by DrTurk
  • Love 1
Link to comment
Share on other sites

  • Active Member
5 hours ago, DrTurk said:

char.cpp --> remove that:

m_dwKillerPID = 0;

char.h --> remove that:

DWORD				m_dwKillerPID;

 

char_battle.cpp --> remove/change that:

if (!pkKiller && m_dwKillerPID)
		pkKiller = CHARACTER_MANAGER::instance().FindByPID(m_dwKillerPID);

	m_dwKillerPID = 0;

change that:

if (GetHP() <= 0)
	{
		Stun();

		if (pAttacker && !pAttacker->IsNPC())
			m_dwKillerPID = pAttacker->GetPlayerID();
		else
			m_dwKillerPID = 0;
	}

to this:

if (GetHP() <= 0)
	{
		Dead(pAttacker);
	}

 

Solved! (Is there any risk of causing an error/bug?)

Link to comment
Share on other sites

  • 1 month later...
  • Active Member
On 6/12/2021 at 12:56 PM, DrTurk said:

Had two servers with that change, didnt experienced any bugs

I just tried your code edits and it has at least one bug with removing char affect like poison. Try to kill the player with ninja char skill Poisoned Arrow, player will die with poison affect on yourself.

I tried to call Dead(); function instead of your changes, but there is still the same bug with affects. Dead(); is not removing the poison, bleed, etc. affects. I couldn't find differences between why Stun(); function removing the affects correctly and Dead(); function not.

Spoiler
if (GetHP() <= 0)
	{
		Stun(); or Dead(); can be called but only Stun(); removing the affects before death correctly

		if (pAttacker && !pAttacker->IsNPC())
			m_dwKillerPID = pAttacker->GetPlayerID();
		else
			m_dwKillerPID = 0;
	}

return false;

 

Would be really nice if someone can solve this problem.

Edited by ReFresh

I'll be always helpful! 👊 

Link to comment
Share on other sites

12 hours ago, ReFresh said:

I just tried your code edits and it has at least one bug with removing char affect like poison. Try to kill the player with ninja char skill Poisoned Arrow, player will die with poison affect on yourself.

I tried to call Dead(); function instead of your changes, but there is still the same bug with affects. Dead(); is not removing the poison, bleed, etc. affects. I couldn't find differences between why Stun(); function removing the affects correctly and Dead(); function not.

  Hide contents
if (GetHP() <= 0)
	{
		Stun(); or Dead(); can be called but only Stun(); removing the affects before death correctly

		if (pAttacker && !pAttacker->IsNPC())
			m_dwKillerPID = pAttacker->GetPlayerID();
		else
			m_dwKillerPID = 0;
	}

return false;

 

Would be really nice if someone can solve this problem.

Isnt that a normal m2 problem with bleed/poison/fire when you one shot someone with it?

I fixxed this before i did this change.

 

Just add

	if (ch->IsDead())
	{
		ch->RemovePoison();
	}

like that:

EVENTFUNC(poison_event)
{
	TPoisonEventInfo * info = dynamic_cast<TPoisonEventInfo *>( event->info );
	
	if ( info == NULL )
	{
		sys_err( "poison_event> <Factor> Null pointer" );
		return 0;
	}

	LPCHARACTER ch = info->ch;

	if (ch == NULL) 
	{
		return 0;
	}
	LPCHARACTER pkAttacker = CHARACTER_MANAGER::instance().FindByPID(info->attacker_pid);

	if (ch->IsDead())
	{
		ch->RemovePoison();
	}

	int dam = ch->GetMaxHP() * GetPoisonDamageRate(ch) / 1000;
	if (test_server) ch->ChatPacket(CHAT_TYPE_NOTICE, "Poison Damage %d", dam);

	if (ch->Damage(pkAttacker, dam, DAMAGE_TYPE_POISON))
	{
		ch->m_pkPoisonEvent = NULL;
		return 0;
	}

	--info->count;

	if (info->count)
		return PASSES_PER_SEC(3);
	else
	{
		ch->m_pkPoisonEvent = NULL;
		return 0;
	}
}

 

same thing with fire:

EVENTFUNC(fire_event)
{
	TFireEventInfo * info = dynamic_cast<TFireEventInfo *>( event->info );

	if ( info == NULL )
	{
		sys_err( "fire_event> <Factor> Null pointer" );
		return 0;
	}

	LPCHARACTER ch = info->ch;
	if (ch == NULL) 
	{
		return 0;
	}
	LPCHARACTER pkAttacker = CHARACTER_MANAGER::instance().FindByPID(info->attacker_pid);

	if (ch->IsDead())
	{
		ch->RemoveFire();
	}

	int dam = info->amount;
	if (test_server) ch->ChatPacket(CHAT_TYPE_NOTICE, "Fire Damage %d", dam);

	if (ch->Damage(pkAttacker, dam, DAMAGE_TYPE_FIRE))
	{
		ch->m_pkFireEvent = NULL;
		return 0;
	}

	--info->count;

	if (info->count)
		return PASSES_PER_SEC(3);
	else
	{
		ch->m_pkFireEvent = NULL;
		return 0;
	}
}

 

Link to comment
Share on other sites

  • Active Member

@DrTurk Thanks I'll try. But why did you remove that functions instead of calling Dead(); function? It should be the same thing as we call the Stun(); am I right? But mystery is why Stun(); function is able to remove these affects without editing something.

Edited by ReFresh

I'll be always helpful! 👊 

Link to comment
Share on other sites

25 minutes ago, ReFresh said:

@DrTurk Thanks I'll try. But why did you remove that functions instead of calling Dead(); function? It should be the same thing as we call the Stun(); am I right? But mystery is why Stun(); function is able to remove these affects without editing something.

as i said i had this problem even before i modifyed the dead function, but only when you one shot someone with a poison skill.

i can redo my dead function modify and it will also bug when killed with one shot which has 100% poison rate

Link to comment
Share on other sites

  • Active Member
On 8/3/2021 at 3:49 PM, DrTurk said:

as i said i had this problem even before i modifyed the dead function, but only when you one shot someone with a poison skill.

i can redo my dead function modify and it will also bug when killed with one shot which has 100% poison rate

Just call Dead(); instad of Stun(); and do the changes to affect events like you did, then change this:

Spoiler

m_pkDeadEvent = event_create(dead_event, pEventInfo, bImmediateDead ? 1 : PASSES_PER_SEC(3));

To this:

Spoiler

m_pkDeadEvent = event_create(dead_event, pEventInfo, bImmediateDead ? 1 : PASSES_PER_SEC(0));

And you are done, I think you don't need to remove something from source, just use the functions which are already done.

I'll be always helpful! 👊 

Link to comment
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now

Announcements



  • Similar Content

  • Activity

    1. 13

      Metin2 Closed Beta Content (2003-2004)

    2. 25

      [SRC] Metin2 on LINUX - The Old Metin2 Project

    3. 2

      United/Club/Midgard serverfiles?

    4. 13

      Metin2 Closed Beta Content (2003-2004)

    5. 13

      Metin2 Closed Beta Content (2003-2004)

  • Recently Browsing

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

Terms of Use / Privacy Policy / Guidelines / We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.