Jump to content
metin2dev
Metin2International
  • 0
avertuss

open How to block deal damage

Question

Hi. How to block deal damage to mobs if player has weared item with vnum 12345? Something like this in battle.cpp?

if (pAttacker->GetVnum() == 12345 && pkVictim->IsNPC())
{
	iAtk = iAtk*0.1;
}

 

Share this post


Link to post
Share on other sites

11 answers to this question

Recommended Posts

  • 0

For hit damage:

Look for:

	if (iDam <= 0) {
		return (BATTLE_DAMAGE);
	}

Paste this ABOVE:

	//begin hit block damage with sword +5   (vnum 15)
	if (pkAttacker->FindSpecifyItem(15) && pkVictim->IsNPC())
	{
		iDam = 0;
	}
	//end hit block damage with sword + 5(vnum 15)

Like in the print:

imagem86d661f4a7c29d0c.png

 

Go ingame and test it.

If you damage a mob with a hit while having a sword +5 (vnum) in inventory, damage will be 0.

 

That will work for weapon hits.

You also need to edit this function for arrows damage:

int CalcArrowDamage

 

And if you also want to block skills damage, you will need to edit it at char_skill.cpp, here:

FuncSplashDamage

 

Share this post


Link to post
Share on other sites
  • 0
8 godzin temu, tierrilopes napisał:

For hit damage:

Look for:


	if (iDam <= 0) {
		return (BATTLE_DAMAGE);
	}

Paste this ABOVE:


	//begin hit block damage with sword +5   (vnum 15)
	if (pkAttacker->FindSpecifyItem(15) && pkVictim->IsNPC())
	{
		iDam = 0;
	}
	//end hit block damage with sword + 5(vnum 15)

Like in the print:

imagem86d661f4a7c29d0c.png

 

Go ingame and test it.

If you damage a mob with a hit while having a sword +5 (vnum) in inventory, damage will be 0.

 

That will work for weapon hits.

You also need to edit this function for arrows damage:


int CalcArrowDamage

 

And if you also want to block skills damage, you will need to edit it at char_skill.cpp, here:


FuncSplashDamage

 

I don't need block deal damage when item is in inventory, i want block deal damage when item is equpped. 

Share this post


Link to post
Share on other sites
  • 0
	LPITEM pItem = pkAttacker->GetWear(WEAR_WEAPON);
	if (pItem && pItem->GetVnum() == 15 && pItem->IsEquipped() && pkVictim->IsNPC())
    	return 0;
	

 

Share this post


Link to post
Share on other sites
  • 0
2 godziny temu, hachiwari napisał:

	LPITEM pItem = pkAttacker->GetWear(WEAR_WEAPON);
	if (pItem && pItem->GetVnum() == 15 && pItem->IsEquipped() && pkVictim->IsNPC())
    	return 0;
	

 

Where should i add it? Will it work with WEAR_WRIST etc? 

Share this post


Link to post
Share on other sites
  • 0
4 godziny temu, WLsj24 napisał:

battle.cpp

LPITEM pItem = pkAttacker->GetWear(WEAR_WRIST);
	if (pItem && pItem->GetVnum() == 16209 && pItem->IsEquipped() && pkVictim->IsNPC())
    	return 0;

in int battle_hit(LPCHARACTER pkAttacker, LPCHARACTER pkVictim, int & iRetDam) and it doesn't work. 

Share this post


Link to post
Share on other sites
  • 0
1 hour ago, avertuss said:

LPITEM pItem = pkAttacker->GetWear(WEAR_WRIST);
	if (pItem && pItem->GetVnum() == 16209 && pItem->IsEquipped() && pkVictim->IsNPC())
    	return 0;

in int battle_hit(LPCHARACTER pkAttacker, LPCHARACTER pkVictim, int & iRetDam) and it doesn't work. 

Try this:

open: char_battle.cpp

search:

bool CHARACTER::Damage(LPCHARACTER pAttacker, int dam, EDamageType type)

after { add:

		
	if (pkAttacker->GetWear(WEAR_WRIST) and pkAttacker->IsEquipped(16209))
	{
		SendDamagePacket(pAttacker, 0, DAMAGE_BLOCK);
		return false;
	}

No tested, maybe work...

Share this post


Link to post
Share on other sites
  • 0
On 18/04/2018 at 10:55 AM, avertuss said:

I don't need block deal damage when item is in inventory, i want block deal damage when item is equpped. 

FindSpecifyItem >> GetItem (equiped cell slot)

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.

×