Jump to content
metin2dev
  • 0
charparodar

open Arrows quiver not working

Question

Hello,

I've tried to implement the arrows quiver system on my server, but it doesn't do any damage (either on hit or skill) and the effect doesn't show.

A little video:

https://www.youtube.com/watch?v=i-2QZvEnZsg

I already check the tutorial 3 times, but I can't seem to find anything wrong...

If anyone knew the solution, I would appreciate.

Thanks

Share this post


Link to post
Share on other sites

16 answers to this question

Recommended Posts

  • 0
8 hours ago, Xploitz said:

You probably missed something in battle.cpp. Post the CalcArrowDamage function from your battle.cpp here.

int CalcArrowDamage(LPCHARACTER pkAttacker, LPCHARACTER pkVictim, LPITEM pkBow, LPITEM pkArrow, bool bIgnoreDefense)
{
	if (!pkBow || pkBow->GetType() != ITEM_WEAPON || pkBow->GetSubType() != WEAPON_BOW)
		return 0;
	
	if (!pkArrow)
		return 0;
	
	int iDist = (int) (DISTANCE_SQRT(pkAttacker->GetX() - pkVictim->GetX(), pkAttacker->GetY() - pkVictim->GetY()));
	int iGap = (iDist / 100) - 5 - pkAttacker->GetPoint(POINT_BOW_DISTANCE);
	int iPercent = 100 - (iGap * 5);
#ifdef __NEW_ARROW_SYSTEM__
	if (pkArrow->GetSubType() == WEAPON_UNLIMITED_ARROW)
	{
		iPercent = 100;
	}
#endif
	
	if (iPercent <= 0)
		return 0;
	else if (iPercent > 100)
		iPercent = 100;
	
	int iDam = 0;
	float fAR = CalcAttackRating(pkAttacker, pkVictim, false);
	iDam = number(pkBow->GetValue(3), pkBow->GetValue(4)) * 2 + pkArrow->GetValue(3);
	
	int iAtk;
	iAtk = pkAttacker->GetPoint(POINT_ATT_GRADE) + iDam - (pkAttacker->GetLevel() * 2);
	iAtk = (int) (iAtk * fAR);
	iAtk += pkAttacker->GetLevel() * 2;
	
	iAtk += pkBow->GetValue(5) * 2;
	iAtk += pkAttacker->GetPoint(POINT_PARTY_ATTACKER_BONUS);
	iAtk = (int) (iAtk * (100 + (pkAttacker->GetPoint(POINT_ATT_BONUS) + pkAttacker->GetPoint(POINT_MELEE_MAGIC_ATT_BONUS_PER))) / 100);
	iAtk = CalcAttBonus(pkAttacker, pkVictim, iAtk);
	
	int iDef = 0;
	if (!bIgnoreDefense)
		iDef = (pkVictim->GetPoint(POINT_DEF_GRADE) * (100 + pkAttacker->GetPoint(POINT_DEF_BONUS)) / 100);
	
	if (pkAttacker->IsNPC())
		iAtk = (int) (iAtk * pkAttacker->GetMobDamageMultiply());
	
	iDam = MAX(0, iAtk - iDef);
	
	int iPureDam = iDam;
	iPureDam = (iPureDam * iPercent) / 100;
	if (test_server)
	{
		pkAttacker->ChatPacket(CHAT_TYPE_INFO, "ARROW %s -> %s, DAM %d DIST %d GAP %d %% %d", pkAttacker->GetName(), pkVictim->GetName(), iPureDam, iDist, iGap, iPercent);
	}

	return iPureDam;
}

 

Share this post


Link to post
Share on other sites
  • 0
1 minute ago, weryoliveira said:

i have a system, working damage but not working blue effect :facepalm:

The blue effect doesn't work always, but that's not a big deal, I wanted it to do damage...

Share this post


Link to post
Share on other sites
  • 0
29 minutes ago, charparodar said:

The blue effect doesn't work always, but that's not a big deal, I wanted it to do damage...

Hi, could you send me your item subtypes anum, and the subtypes of arrows and quiver you are using?

Share this post


Link to post
Share on other sites
  • 0
4 minutes ago, Syreldar said:

Hi, could you send me your item subtypes anum, and the subtypes of arrows and quiver you are using?

enum EWeaponSubTypes
{
	WEAPON_SWORD,
	WEAPON_DAGGER,
	WEAPON_BOW,
	WEAPON_TWO_HANDED,
	WEAPON_BELL,
	WEAPON_FAN,
	WEAPON_ARROW,
	WEAPON_MOUNT_SPEAR,
#ifdef __NEW_ARROW_SYSTEM__
	WEAPON_UNLIMITED_ARROW,
#endif
	WEAPON_NUM_TYPES,
};
	static string arSub1[] = { "WEAPON_SWORD", "WEAPON_DAGGER", "WEAPON_BOW", "WEAPON_TWO_HANDED",
				"WEAPON_BELL", "WEAPON_FAN", "WEAPON_ARROW", 
#ifdef __NEW_ARROW_SYSTEM__
				"WEAPON_UNLIMITED_ARROW",
#endif
				"WEAPON_MOUNT_SPEAR"};

Is this what you asked for?

Thanks

Share this post


Link to post
Share on other sites
  • 0
Just now, charparodar said:

enum EWeaponSubTypes
{
	WEAPON_SWORD,
	WEAPON_DAGGER,
	WEAPON_BOW,
	WEAPON_TWO_HANDED,
	WEAPON_BELL,
	WEAPON_FAN,
	WEAPON_ARROW,
	WEAPON_MOUNT_SPEAR,
#ifdef __NEW_ARROW_SYSTEM__
	WEAPON_UNLIMITED_ARROW,
#endif
	WEAPON_NUM_TYPES,
};

	static string arSub1[] = { "WEAPON_SWORD", "WEAPON_DAGGER", "WEAPON_BOW", "WEAPON_TWO_HANDED",
				"WEAPON_BELL", "WEAPON_FAN", "WEAPON_ARROW", 
#ifdef __NEW_ARROW_SYSTEM__
				"WEAPON_UNLIMITED_ARROW",
#endif
				"WEAPON_MOUNT_SPEAR"};

Is this what you asked for?

Thanks

The problem is for sure not in the CalcArrowDamage method, else you would receive the test_server debug messages.

Can you show me your 

int CHARACTER::GetArrowAndBow(LPITEM * ppkBow, LPITEM * ppkArrow, int iArrowCount)

and your

void CHARACTER::UseArrow(LPITEM pkArrow, DWORD dwArrowCount)

Share this post


Link to post
Share on other sites
  • 0
1 minute ago, Syreldar said:

The problem is for sure not in the CalcArrowDamage method, else you would receive the test_server debug messages.

Can you show me your 


int CHARACTER::GetArrowAndBow(LPITEM * ppkBow, LPITEM * ppkArrow, int iArrowCount)

and your


void CHARACTER::UseArrow(LPITEM pkArrow, DWORD dwArrowCount)

int CHARACTER::GetArrowAndBow(LPITEM * ppkBow, LPITEM * ppkArrow, int iArrowCount)
{
	LPITEM pkBow;
	if (!(pkBow = GetWear(WEAR_WEAPON)) || pkBow->GetProto()->bSubType != WEAPON_BOW )
	{
		return 0;
	}
	
	LPITEM pkArrow;
#ifdef __NEW_ARROW_SYSTEM__
	if (!(pkArrow = GetWear(WEAR_ARROW)) || pkArrow->GetType() != ITEM_WEAPON || pkArrow->GetProto()->bSubType != WEAPON_ARROW && pkArrow->GetProto()->bSubType != WEAPON_UNLIMITED_ARROW)
#else
	if (!(pkArrow = GetWear(WEAR_ARROW)) || pkArrow->GetType() != ITEM_WEAPON || pkArrow->GetProto()->bSubType != WEAPON_ARROW)
#endif
	{
		return 0;
	}
	
#ifdef __NEW_ARROW_SYSTEM__
	if (pkArrow->GetProto()->bSubType == WEAPON_UNLIMITED_ARROW)
	{
		iArrowCount = MIN(iArrowCount, 200);
	}
	else
	{
		iArrowCount = MIN(iArrowCount, pkArrow->GetCount());
	}
#else
	iArrowCount = MIN(iArrowCount, pkArrow->GetCount());
#endif

	*ppkBow = pkBow;
	*ppkArrow = pkArrow;
	return iArrowCount;
}

void CHARACTER::UseArrow(LPITEM pkArrow, DWORD dwArrowCount)
{
#ifdef __NEW_ARROW_SYSTEM__
	if (pkArrow->GetSubType() != WEAPON_UNLIMITED_ARROW)
	{
		int iCount = pkArrow->GetCount();
		DWORD dwVnum = pkArrow->GetVnum();
		iCount = iCount - MIN(iCount, dwArrowCount);
		pkArrow->SetCount(iCount);
		if (iCount == 0)
		{
			LPITEM pkNewArrow = FindSpecifyItem(dwVnum);
			sys_log(0, "UseArrow : FindSpecifyItem %u %p", dwVnum, get_pointer(pkNewArrow));
			if (pkNewArrow)
				EquipItem(pkNewArrow);
		}
	}
#else
	int iCount = pkArrow->GetCount();
	DWORD dwVnum = pkArrow->GetVnum();
	iCount = iCount - MIN(iCount, dwArrowCount);
	pkArrow->SetCount(iCount);
	if (iCount == 0)
	{
		LPITEM pkNewArrow = FindSpecifyItem(dwVnum);
		sys_log(0, "UseArrow : FindSpecifyItem %u %p", dwVnum, get_pointer(pkNewArrow));
		if (pkNewArrow)
			EquipItem(pkNewArrow);
	}
#endif
}

 

Share this post


Link to post
Share on other sites
  • 0

Either pkArrow returns a null value for some reason, or the subtype you are using for the quiver item is incorrect.

Share this post


Link to post
Share on other sites
  • 0
37 minutes ago, Syreldar said:

Either pkArrow returns a null value for some reason, or the subtype you are using for the quiver item is incorrect.

db/src/ProtoReader.cpp:

	static string arSub1[] = { "WEAPON_SWORD", "WEAPON_DAGGER", "WEAPON_BOW", "WEAPON_TWO_HANDED",
				"WEAPON_BELL", "WEAPON_FAN", "WEAPON_ARROW", 
#ifdef __NEW_ARROW_SYSTEM__
				"WEAPON_UNLIMITED_ARROW",
#endif
				"WEAPON_MOUNT_SPEAR"};

dump_proto/ItemCSVReader.cpp:

string arIAFVSub1[] = { "WEAPON_SWORD", "WEAPON_DAGGER", "WEAPON_BOW", "WEAPON_TWO_HANDED",
"WEAPON_BELL", "WEAPON_FAN", "WEAPON_ARROW", "WEAPON_UNLIMITED_ARROW", "WEAPON_MOUNT_SPEAR" };

common/item_lenght.h:

enum EWeaponSubTypes
{
	WEAPON_SWORD,
	WEAPON_DAGGER,
	WEAPON_BOW,
	WEAPON_TWO_HANDED,
	WEAPON_BELL,
	WEAPON_FAN,
	WEAPON_ARROW,
	WEAPON_MOUNT_SPEAR,
#ifdef __NEW_ARROW_SYSTEM__
	WEAPON_UNLIMITED_ARROW,
#endif
	WEAPON_NUM_TYPES,
};

Client/GameLib/ItemData.h:

		enum EWeaponSubTypes
		{
			WEAPON_SWORD,
			WEAPON_DAGGER,	//À̵µ·ù
			WEAPON_BOW,
			WEAPON_TWO_HANDED,
			WEAPON_BELL,
			WEAPON_FAN,
			WEAPON_ARROW,
#ifdef ENABLE_NEW_ARROW_SYSTEM
			WEAPON_UNLIMITED_ARROW,
#endif
			WEAPON_MOUNT_SPEAR,

			WEAPON_NUM_TYPES,

			WEAPON_NONE = WEAPON_NUM_TYPES+1,
		};

Item_proto.txt

79501	"??? ???1"	"ITEM_WEAPON"	"WEAPON_UNLIMITED_ARROW"	1	"ANTI_MUSA | ANTI_SURA | ANTI_MUDANG | ANTI_DROP | ANTI_GIVE | ANTI_MYSHOP | ANTI_SAFEBOX"	"ITEM_STACKABLE | ITEM_SLOW_QUERY"	"WEAR_ARROW"	"NONE"	100000	0	0	0	0	"REAL_TIME"	86400	"LIMIT_NONE"	0	"APPLY_NONE"	0	"APPLY_NONE"	0	"APPLY_NONE"	0	17	4	0	25	0	0	0	0	0
79502	"??? ???7"	"ITEM_WEAPON"	"WEAPON_UNLIMITED_ARROW"	1	"ANTI_MUSA | ANTI_SURA | ANTI_MUDANG | ANTI_DROP | ANTI_GIVE | ANTI_MYSHOP | ANTI_SAFEBOX"	"ITEM_STACKABLE | ITEM_SLOW_QUERY"	"WEAR_ARROW"	"NONE"	550000	0	0	0	0	"REAL_TIME"	604800	"LIMIT_NONE"	0	"APPLY_NONE"	0	"APPLY_NONE"	0	"APPLY_NONE"	0	17	4	0	25	0	0	0	0	0
79503	"??? ???15"	"ITEM_WEAPON"	"WEAPON_UNLIMITED_ARROW"	1	"ANTI_MUSA | ANTI_SURA | ANTI_MUDANG | ANTI_DROP | ANTI_GIVE | ANTI_MYSHOP | ANTI_SAFEBOX"	"ITEM_STACKABLE | ITEM_SLOW_QUERY"	"WEAR_ARROW"	"NONE"	0	0	0	0	0	"REAL_TIME"	1296000	"LIMIT_NONE"	0	"APPLY_NONE"	0	"APPLY_NONE"	0	"APPLY_NONE"	0	17	4	0	25	0	0	0	0	0
79504	"??? ???30"	"ITEM_WEAPON"	"WEAPON_UNLIMITED_ARROW"	1	"ANTI_MUSA | ANTI_SURA | ANTI_MUDANG | ANTI_DROP | ANTI_GIVE | ANTI_MYSHOP | ANTI_SAFEBOX"	"ITEM_STACKABLE | ITEM_SLOW_QUERY"	"WEAR_ARROW"	"NONE"	0	0	0	0	0	"REAL_TIME"	2592000	"LIMIT_NONE"	0	"APPLY_NONE"	0	"APPLY_NONE"	0	"APPLY_NONE"	0	17	4	0	25	0	0	0	0	0

I think this is all that is related to the subtype...

Share this post


Link to post
Share on other sites
  • 0

Found another bug...

If I try to attack (pressing SPACE) without having arrows equipped (either normal or unlimited) the client closes instantly...

Share this post


Link to post
Share on other sites
  • 0

Solved!

The problem was on the subtype, I had WEAPON_UNLIMITED_ARROW above on ProtoReader, but on subtype item it was bellow, and on client I had the same thing.

But I still don't have effect :(

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.

×