Jump to content

BUFF AFFECT AFTER DEAD


Recommended Posts

I installed a system, when i die the buffs stays on my character.  But when i die, this two left side affect disappear. The buffs stays on me.
https://metin2.download/picture/WIFE5GLyK63OBCS4ysvOUI32TSw3j1Os/.jpg -> picture

 

Anyone help?

Edited by Metin2 Dev
Core X - External 2 Internal
  • Metin2 Dev 2
  • Angry 1
  • Love 1
Link to comment
Share on other sites

  • 2 weeks later...
  • Premium

Gotta check on char_affect.cpp for IS_NO_CLEAR_ON_DEATH_AFFECT, and add the buffs you want to stay after the character's death. Be aware that in this case, the buffs will stay on even in PvP. If you wanna avoid that, on the top of my head, you could do this:

go on char_battle.cpp and search for ClearAffect(true); in void CHARACTER::Dead(LPCHARACTER pkKiller, bool bImmediateDead) and edit the line like this:

if (pkKiller && IsPC())
	ClearAffect(true, true);
else
	ClearAffect(true, false);

then edit void CHARACTER::ClearAffect(bool bSave) in char_affect.cpp into:
 

void CHARACTER::ClearAffect(bool bSave, bool bIsPC)

then in the function check for while (it != m_list_pkAffect.end()) and edit like this:

	while (it != m_list_pkAffect.end())
	{
		CAffect * pkAff = *it;

		if (bSave)
		{
			if(bIsPC)
			{
				if ( IS_NO_CLEAR_ON_DEATH_AFFECT_PC(pkAff->dwType) || 
				IS_NO_SAVE_AFFECT(pkAff->dwType)) //add the others that you might previously have had
				{
					++it;
					continue;
				}
			}
			else if(!bIsPC)
			{
				if ( IS_NO_CLEAR_ON_DEATH_AFFECT(pkAff->dwType) || 
				IS_NO_SAVE_AFFECT(pkAff->dwType)) //add the others that you might previously have had
				{
					++it;
					continue;
				}
			}
			if (IsPC())
			{
				SendAffectRemovePacket(GetDesc(), GetPlayerID(), pkAff->dwType, pkAff->bApplyOn, pkAff->dwFlag);
			}
		}
		ComputeAffect(pkAff, false);

		it = m_list_pkAffect.erase(it);
		CAffect::Release(pkAff);
	}

	if (afOld != m_afAffectFlag ||
			wMovSpd != GetPoint(POINT_MOV_SPEED) ||
			wAttSpd != GetPoint(POINT_ATT_SPEED))
		UpdatePacket();

	CheckMaximumPoints();

	if (m_list_pkAffect.empty())
		event_cancel(&m_pkAffectEvent);
}

Copy IS_NO_CLEAR_ON_DEATH_AFFECT into a new line and edit the name into IS_NO_CLEAR_ON_DEATH_AFFECT_PC where you remove the buffs that you want to remove in PvP.

And finally, edit the function in char.h:

void			ClearAffect(bool bSave=false, bool bIsPC = false);

 

 

might also wanna check where ClearAffect is used and edit as you see fit

Edited by xXIntelXx
Link to comment
Share on other sites

  • 2 years later...
On 12/22/2020 at 5:45 AM, xXIntelXx said:

Gotta check on char_affect.cpp for IS_NO_CLEAR_ON_DEATH_AFFECT, and add the buffs you want to stay after the character's death. Be aware that in this case, the buffs will stay on even in PvP. If you wanna avoid that, on the top of my head, you could do this:

go on char_battle.cpp and search for ClearAffect(true); in void CHARACTER::Dead(LPCHARACTER pkKiller, bool bImmediateDead) and edit the line like this:

if (pkKiller && IsPC())
	ClearAffect(true, true);
else
	ClearAffect(true, false);

then edit void CHARACTER::ClearAffect(bool bSave) in char_affect.cpp into:
 

void CHARACTER::ClearAffect(bool bSave, bool bIsPC)

then in the function check for while (it != m_list_pkAffect.end()) and edit like this:

	while (it != m_list_pkAffect.end())
	{
		CAffect * pkAff = *it;

		if (bSave)
		{
			if(bIsPC)
			{
				if ( IS_NO_CLEAR_ON_DEATH_AFFECT_PC(pkAff->dwType) || 
				IS_NO_SAVE_AFFECT(pkAff->dwType)) //add the others that you might previously have had
				{
					++it;
					continue;
				}
			}
			else if(!bIsPC)
			{
				if ( IS_NO_CLEAR_ON_DEATH_AFFECT(pkAff->dwType) || 
				IS_NO_SAVE_AFFECT(pkAff->dwType)) //add the others that you might previously have had
				{
					++it;
					continue;
				}
			}
			if (IsPC())
			{
				SendAffectRemovePacket(GetDesc(), GetPlayerID(), pkAff->dwType, pkAff->bApplyOn, pkAff->dwFlag);
			}
		}
		ComputeAffect(pkAff, false);

		it = m_list_pkAffect.erase(it);
		CAffect::Release(pkAff);
	}

	if (afOld != m_afAffectFlag ||
			wMovSpd != GetPoint(POINT_MOV_SPEED) ||
			wAttSpd != GetPoint(POINT_ATT_SPEED))
		UpdatePacket();

	CheckMaximumPoints();

	if (m_list_pkAffect.empty())
		event_cancel(&m_pkAffectEvent);
}

Copy IS_NO_CLEAR_ON_DEATH_AFFECT into a new line and edit the name into IS_NO_CLEAR_ON_DEATH_AFFECT_PC where you remove the buffs that you want to remove in PvP.

And finally, edit the function in char.h:

void			ClearAffect(bool bSave=false, bool bIsPC = false);

 

 

might also wanna check where ClearAffect is used and edit as you see fit

Bad Code.

If you don't want to delete the effect in your character when he dies, the only thing you'll do.

 

char_affect.cpp open and search:

            if (IS_NO_CLEAR_ON_DEATH_AFFECT(pkAff->dwType) || IS_NO_SAVE_AFFECT(pkAff->dwType))
            {
                ++it;
                continue;
            }

Add you affect name.

Example:

 

            if (pkAff->dwType == YOU_AFFECT_NAME)
            {
                ++it;
                continue;
            }

 

This is never deleted. But if you want to delete one day, you will wipe it manually.

 

Edited by BadRomani
edit affect
Link to comment
Share on other sites

  • Premium
On 3/7/2023 at 7:29 PM, BadRomani said:

Bad Code.

If you don't want to delete the effect in your character when he dies, the only thing you'll do.

 

char_affect.cpp open and search:

            if (IS_NO_CLEAR_ON_DEATH_AFFECT(pkAff->dwType) || IS_NO_SAVE_AFFECT(pkAff->dwType))
            {
                ++it;
                continue;
            }

Add you affect name.

Example:

 

            if (pkAff->dwType == YOU_AFFECT_NAME)
            {
                ++it;
                continue;
            }

 

This is never deleted. But if you want to delete one day, you will wipe it manually.

 

Well, it is basically the same thing I've said (for clarity I would define a new list of effects), but he asked that to be disabled in PvP, so I mixed the solutions

Although it would be cleaner to be:

			if ( IS_NO_CLEAR_ON_DEATH_AFFECT(pkAff->dwType) || 
				IS_NO_SAVE_AFFECT(pkAff->dwType) || NO_CLEAR_ON_DEATH_BUT_PVP(pkAff->dwType) ) //We assume we defined NO_CLEAR_ON_DEATH_BUT_PVP
			{
				if (!bIsPC() && NO_CLEAR_ON_DEATH_BUT_PVP(pkAff->dwType)) 
				{
					++it;
					continue;
				}
				else if(!NO_CLEAR_ON_DEATH_BUT_PVP(pkAff->dwType))
				{
					++it;
					continue;
				}
			}
			

 

Edited by xXIntelXx
  • Love 1
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)

    6. 0

      Football Ground

  • 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.