Jump to content

Hide weapon when using emotion - unequipped weapon bug in emotion use


Go to solution Solved by VegaS™,

Recommended Posts

  • Active Member

Hello guys,

I have implemented function to hide weapon when using emotions. Done by @xP3NG3Rx. I found a bug with weapon. Have someone solution for that? 

Video with the bug:

Spoiler
https://youtu.be/PPfHZHogehE

 

InstanceBase.cpp:

Spoiler
if (m_GraphicThingInstance.__GetCurrentMotionIndex() < CRaceMotionData::NAME_CLAP || m_GraphicThingInstance.__GetCurrentMotionIndex() == CRaceMotionData::NAME_DIG)
	{
		if (m_GraphicThingInstance.GetPartItemID(CRaceData::PART_WEAPON) != m_awPart[CRaceData::PART_WEAPON])
		{
			m_GraphicThingInstance.AttachWeapon(m_awPart[CRaceData::PART_WEAPON]);

			CItemData* pItemData;

			if (CItemManager::Instance().GetItemDataPointer(m_awPart[CRaceData::PART_WEAPON], &pItemData))
				__GetRefinedEffect(pItemData);

			if (IsAffect(AFFECT_GEOMGYEONG))
				__Warrior_SetGeomgyeongAffect(true);

			if (IsAffect(AFFECT_GWIGEOM))
				__AttachEffect(EFFECT_AFFECT + AFFECT_GWIGEOM);
		}
	}

	else if (m_GraphicThingInstance.GetPartItemID(CRaceData::PART_WEAPON))
	{
		m_GraphicThingInstance.AttachWeapon(0);
		__ClearWeaponRefineEffect();

		if (IsAffect(AFFECT_GEOMGYEONG))
			__Warrior_SetGeomgyeongAffect(false);
		if (IsAffect(AFFECT_GWIGEOM))
			__DetachEffect(EFFECT_AFFECT + AFFECT_GWIGEOM);
	}

 

ActorInstance.h:

Spoiler
public:
		WORD		__GetCurrentMotionIndex();

 

 

Edited by ReFresh
  • Love 2

I'll be always helpful! 👊 

Link to comment
Share on other sites

6 hours ago, ReFresh said:

@Cunoo I don't think it's a good fix for it 😄 and maybe it's not possible to do that, because this function probably overwriting the default function for emotion use in server source.

Default function stop it running emote... (official code) So this is same fix about ymir... You don't make more than true, false...  I think you can more, but this is not badest code.. If you can't make memory leak you are right..  Not the best but right.. 

Link to comment
Share on other sites

  • 3 weeks later...
  • 9 months later...
  • Forum Moderator
On 6/13/2022 at 1:03 AM, ReFresh said:

https://www.youtube.com/watch?v=PPfHZHogehE
Someone got an solution for that? Still got no idea, how to fix it. 

Video with the  fix: https://metin2.download/video/gV3x7RhoJZsJnMY6C61nEvmBOGrvnNn0/.mp4

I just implemented right now that function and after some tests, I found that GetPartItemID was always set to 0 when you used an emotion with a weapon equipped, from here.

The problem itself is the ChangeWeapon function, which is responsible for refreshing the weapon index and the refresh state of the wait motion, but that wasn't called properly because it always got blocked in the following condition:

This is the hidden content, please

In order that when you unequip an item from the server, it's called the ChangeWeapon(0), which means eWapon = 0, and the GetPartItemID(CRaceData::PART_WEAPON) = 0 as well, since it was set from the previous use of motion.

For fixing it, we just have to add into our condition if the eWeapon it's not 0, so it will let the function to work properly.

This is the hidden content, please

Edited by Metin2 Dev
Core X - External 2 Internal
  • Metin2 Dev 19
  • Good 2
  • Love 2
  • Love 5
Link to comment
Share on other sites

  • Premium
On 6/15/2022 at 2:47 AM, VegaS™ said:

Video with the  fix: https://metin2.download/video/gV3x7RhoJZsJnMY6C61nEvmBOGrvnNn0/.mp4

I just implemented right now that function and after some tests, I found that GetPartItemID was always set to 0 when you used an emotion with a weapon equipped, from here.

The problem itself is the ChangeWeapon function, which is responsible for refreshing the weapon index and the refresh state of the wait motion, but that wasn't called properly because it always got blocked in the following condition:

 

Hidden Content

 

void CInstanceBase::ChangeWeapon(DWORD eWeapon)
{
	if (eWeapon == m_GraphicThingInstance.GetPartItemID(CRaceData::PART_WEAPON))
		return;

	if (SetWeapon(eWeapon))
		RefreshState(CRaceMotionData::NAME_WAIT, true);
}

 

 

In order that when you unequip an item from the server, it's called the ChangeWeapon(0), which means eWapon = 0, and the GetPartItemID(CRaceData::PART_WEAPON) = 0 as well, since it was set from the previous use of motion.

For fixing it, we just have to add into our condition if the eWeapon it's not 0, so it will let the function to work properly.

 

Hidden Content

 

	// Search for the following condition:
	if (eWeapon == m_GraphicThingInstance.GetPartItemID(CRaceData::PART_WEAPON))
  	// Replace it with:
	if (eWeapon && eWeapon == m_GraphicThingInstance.GetPartItemID(CRaceData::PART_WEAPON))

 

 

Seems all ok. Thank you!! 

Edited by WeedHex
Core X - External 2 Internal
Link to comment
Share on other sites

  • Forum Moderator
1 hour ago, WeedHex said:

I thought a thing!

May be cool also to stop the emotion animation when the char moves? Because if you think the ninja archer can't attack to stop the phase. Other games (Fortnite for eg.) use this way too.

  • GameLib/ActorInstanceMotion.cpp

https://metin2.download/video/2aqONkr36fTYmcXsHD7Nw7FJlTkGYH6H/.mp4

Replace BOOL CActorInstance::isLock() with this:

This is the hidden content, please

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

  • Forum Moderator
On 6/15/2022 at 3:47 AM, VegaS™ said:

Video with the  fix: https://metin2.download/video/gV3x7RhoJZsJnMY6C61nEvmBOGrvnNn0/.mp4

I just implemented right now that function and after some tests, I found that GetPartItemID was always set to 0 when you used an emotion with a weapon equipped, from here.

The problem itself is the ChangeWeapon function, which is responsible for refreshing the weapon index and the refresh state of the wait motion, but that wasn't called properly because it always got blocked in the following condition:

 

Hidden Content

 

void CInstanceBase::ChangeWeapon(DWORD eWeapon)
{
	if (eWeapon == m_GraphicThingInstance.GetPartItemID(CRaceData::PART_WEAPON))
		return;

	if (SetWeapon(eWeapon))
		RefreshState(CRaceMotionData::NAME_WAIT, true);
}

 

 

In order that when you unequip an item from the server, it's called the ChangeWeapon(0), which means eWapon = 0, and the GetPartItemID(CRaceData::PART_WEAPON) = 0 as well, since it was set from the previous use of motion.

For fixing it, we just have to add into our condition if the eWeapon it's not 0, so it will let the function to work properly.

 

Hidden Content

 

	// Search for the following condition:
	if (eWeapon == m_GraphicThingInstance.GetPartItemID(CRaceData::PART_WEAPON))
  	// Replace it with:
	if (eWeapon && eWeapon == m_GraphicThingInstance.GetPartItemID(CRaceData::PART_WEAPON))

 

 

UPDATE: @ ReFreshreported to me that the fix created a small visual bug on skills, but I don't have enough time in this period to investigate it.

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

  • Active Member
On 6/15/2022 at 2:47 AM, VegaS™ said:

Video with the  fix: https://metin2.download/video/gV3x7RhoJZsJnMY6C61nEvmBOGrvnNn0/.mp4

I just implemented right now that function and after some tests, I found that GetPartItemID was always set to 0 when you used an emotion with a weapon equipped, from here.

The problem itself is the ChangeWeapon function, which is responsible for refreshing the weapon index and the refresh state of the wait motion, but that wasn't called properly because it always got blocked in the following condition:

 

Hidden Content

 

void CInstanceBase::ChangeWeapon(DWORD eWeapon)
{
	if (eWeapon == m_GraphicThingInstance.GetPartItemID(CRaceData::PART_WEAPON))
		return;

	if (SetWeapon(eWeapon))
		RefreshState(CRaceMotionData::NAME_WAIT, true);
}

 

 

In order that when you unequip an item from the server, it's called the ChangeWeapon(0), which means eWapon = 0, and the GetPartItemID(CRaceData::PART_WEAPON) = 0 as well, since it was set from the previous use of motion.

For fixing it, we just have to add into our condition if the eWeapon it's not 0, so it will let the function to work properly.

 

Hidden Content

 

	// Search for the following condition:
	if (eWeapon == m_GraphicThingInstance.GetPartItemID(CRaceData::PART_WEAPON))
  	// Replace it with:
	if (eWeapon && eWeapon == m_GraphicThingInstance.GetPartItemID(CRaceData::PART_WEAPON))

 

 

This visual bug happens when you use above solution:

Spoiler

So, if someone got some time to investigate that bug and can share with us the solution, it would be really nice! 

Edited by Metin2 Dev
Core X - External 2 Internal

I'll be always helpful! 👊 

Link to comment
Share on other sites

Hello there im just trying to figure out the solution and maybe if you use any check like this:

 

Spoiler

    if (m_GraphicThingInstance.GetCurrentMotionIndex() < CRaceMotionData::NAME_CLAP || m_GraphicThingInstance.GetCurrentMotionIndex() == CRaceMotionData::NAME_DIG)
        if (eWeapon && eWeapon == m_GraphicThingInstance.GetPartItemID(CRaceData::PART_WEAPON))
            return;
    else
        if (eWeapon == m_GraphicThingInstance.GetPartItemID(CRaceData::PART_WEAPON))
            return;


But maybe it's dump.

Edited by joco1234
  • Metin2 Dev 2
Link to comment
Share on other sites

  • Forum Moderator
  • Solution

I think this should be enough.

This is the hidden content, please

Edited by VegaS™
  • Metin2 Dev 21
  • Good 3
  • Love 2
  • Love 4
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



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