Jump to content

v17.5 Element Image on Target


Recommended Posts

  • Management
On 10/31/2017 at 5:33 PM, metin2-factory said:

Small update #2

If you have installed my official like new elemental bonuses. follow the small guide below to view element icon of a target that wears

the new rings, like in official.

CxLhHukNSNe0fnTg7Ks24w.png

 

open char.cpp,look for: 


#ifdef ELEMENT_TARGET

replace the entire content of the #ifdef, until the #endif with the following:


#ifdef ELEMENT_TARGET
	p.bElement = 0;
	BYTE elementBase = 0;
	DWORD raceFlag;
	if (m_pkChrTarget)
	{
		if (m_pkChrTarget->IsMonster() && (raceFlag = m_pkChrTarget->GetMobTable().dwRaceFlag) >= RACE_FLAG_ATT_ELEC)
		{
			for (int i = RACE_FLAG_ATT_ELEC; i > 1; i /= 2)
			{
				elementBase++;
			}
			DWORD curElementBase = elementBase;
			const int ELEMENT_BASE_FLAG = pow(2, elementBase);
			for (int i = RACE_FLAG_ATT_ELEC; i <= RACE_FLAG_ATT_DARK; i *= 2)
			{
				curElementBase++;
				int diff = raceFlag - i;
				if (abs(diff) < ELEMENT_BASE_FLAG)
					break;
			}
			p.bElement = curElementBase - elementBase;
		}
		else if (m_pkChrTarget->IsPC())
		{
			LPITEM pItem = m_pkChrTarget->GetWear(WEAR_RING1);
			if (pItem)
			{
				const int BASE_ELEMENT = APPLY_ATTBONUS_ELEC;
				for (int i = 0; i < ITEM_SOCKET_MAX_NUM; i++)
				{
					if (pItem->GetNewAttributeType(i) >= APPLY_ATTBONUS_ELEC && pItem->GetSocket(i) <= APPLY_ATTBONUS_DARK)
					{
						p.bElement = pItem->GetNewAttributeType(i) - BASE_ELEMENT + 1;
						break;
					}
				}
			}
		}
	}

#endif

 

Compile server and that's it. now, when you select a target that wear a ring with elemental bonuses, an element icon will appear next to the target.

I have this error, do you know how to solve it?

char.cpp: In member function 'void CHARACTER::SetTarget(LPCHARACTER)':
char.cpp:6035:17: error: 'class CItem' has no member named 'GetNewAttributeType'
      if (pItem->GetNewAttributeType(i) >= APPLY_ATTBONUS_ELEC && pItem->GetSocket(i) <= APPLY_ATTBONUS_DARK)
                 ^
char.cpp:6037:27: error: 'class CItem' has no member named 'GetNewAttributeType'
       p.bElement = pItem->GetNewAttributeType(i) - BASE_ELEMENT + 1;
                           ^
Makefile:118: recipe for target 'OBJDIR/char.o' failed
gmake: *** [OBJDIR/char.o] Error 1

Thanks

Edited by Metin2 Dev
Core X - External 2 Internal

raw

raw

Link to comment
Share on other sites

  • Premium
45 minutes ago, charparodar said:

I have this error, do you know how to solve it?


char.cpp: In member function 'void CHARACTER::SetTarget(LPCHARACTER)':
char.cpp:6035:17: error: 'class CItem' has no member named 'GetNewAttributeType'
      if (pItem->GetNewAttributeType(i) >= APPLY_ATTBONUS_ELEC && pItem->GetSocket(i) <= APPLY_ATTBONUS_DARK)
                 ^
char.cpp:6037:27: error: 'class CItem' has no member named 'GetNewAttributeType'
       p.bElement = pItem->GetNewAttributeType(i) - BASE_ELEMENT + 1;
                           ^
Makefile:118: recipe for target 'OBJDIR/char.o' failed
gmake: *** [OBJDIR/char.o] Error 1

Thanks

CItem doesn't have GetNewAttributeType.

Maybe in your source is called GetAttributeType, Visual Studio can help you autocomplete this...

Just point to CItem and call the right function to return the attribute type.

  • Love 1
Link to comment
Share on other sites

  • Management
1 hour ago, Fleon said:

CItem doesn't have GetNewAttributeType.

Maybe in your source is called GetAttributeType, Visual Studio can help you autocomplete this...

Just point to CItem and call the right function to return the attribute type.

It compiled, but now I can't see any icon when I click on the monster...

I added ATT_FIRE:

6091	"¾ß¸¶Ãµ"	"BOSS"	"MONSTER"	"MELEE"	108		"AGGR,BERSERK,STONESKIN,DEATHBLOW,REVIVE"	0	"FIRE,ATT_FIRE"	"STUN,SLOW,CURSE,TERROR"	0	"0"	0	133	66	133	33	356	490	1813838	100	1	0	0	422585	256	110	110	100	2000	300	0	0	0	0	5	5	10	15	40	35	40	40	40	40	35	0	0	0	0	4.0	6008	25	None	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0

Any tip?

Thanks

raw

raw

Link to comment
Share on other sites

vor 30 Minuten schrieb charparodar:

It compiled, but now I can't see any icon when I click on the monster...

I added ATT_FIRE:


6091	"¾ß¸¶Ãµ"	"BOSS"	"MONSTER"	"MELEE"	108		"AGGR,BERSERK,STONESKIN,DEATHBLOW,REVIVE"	0	"FIRE,ATT_FIRE"	"STUN,SLOW,CURSE,TERROR"	0	"0"	0	133	66	133	33	356	490	1813838	100	1	0	0	422585	256	110	110	100	2000	300	0	0	0	0	5	5	10	15	40	35	40	40	40	40	35	0	0	0	0	4.0	6008	25	None	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0

Any tip?

Thanks

Try with all bonus and look if anyone is working. for me only ATT_ELEC working, all others not.

Link to comment
Share on other sites

  • Management
24 minutes ago, LordZiege said:

Try with all bonus and look if anyone is working. for me only ATT_ELEC working, all others not.

Works but not works...

Works with Earth, but with the wrong image, shows me the ELEC icon instead the earth, even thought the raceflag is set to ATT_EARTH... This is the only one that works

raw

raw

Link to comment
Share on other sites

  • Management
6 hours ago, ManiacRobert said:

2018-05-18_03-09-36.gif

It's already working...

I had to change this:

enum ERaceFlags
{
RACE_FLAG_ANIMAL = (1 << 0),
RACE_FLAG_UNDEAD = (1 << 1),
RACE_FLAG_DEVIL = (1 << 2),
RACE_FLAG_HUMAN = (1 << 3),
RACE_FLAG_ORC = (1 << 4),
RACE_FLAG_MILGYO = (1 << 5),
RACE_FLAG_INSECT = (1 << 6),
RACE_FLAG_FIRE = (1 << 7),
RACE_FLAG_ICE = (1 << 8),
RACE_FLAG_DESERT = (1 << 9),
RACE_FLAG_TREE = (1 << 10),
RACE_FLAG_ELEC = (1 << 11),
RACE_FLAG_WIND = (1 << 12),
RACE_FLAG_EARTH = (1 << 13),
RACE_FLAG_DARK = (1 << 14),
RACE_FLAG_ATT_ELEC = (1 << 15),
RACE_FLAG_ATT_FIRE = (1 << 16),
RACE_FLAG_ATT_ICE = (1 << 17),
RACE_FLAG_ATT_WIND = (1 << 18),
RACE_FLAG_ATT_EARTH = (1 << 19),
RACE_FLAG_ATT_DARK = (1 << 20),
};

To:

enum ERaceFlags
{
	RACE_FLAG_ANIMAL	= (1 << 0),
	RACE_FLAG_UNDEAD	= (1 << 1),
	RACE_FLAG_DEVIL		= (1 << 2),
	RACE_FLAG_HUMAN		= (1 << 3),
	RACE_FLAG_ORC		= (1 << 4),
	RACE_FLAG_MILGYO	= (1 << 5),
	RACE_FLAG_INSECT	= (1 << 6),
	RACE_FLAG_FIRE		= (1 << 7),
	RACE_FLAG_ICE		= (1 << 8),
	RACE_FLAG_DESERT	= (1 << 9),
	RACE_FLAG_TREE		= (1 << 10),
	RACE_FLAG_ATT_ELEC	= (1 << 11),
	RACE_FLAG_ATT_FIRE	= (1 << 12),
	RACE_FLAG_ATT_ICE	= (1 << 13),
	RACE_FLAG_ATT_WIND	= (1 << 14),
	RACE_FLAG_ATT_EARTH	= (1 << 15),
	RACE_FLAG_ATT_DARK	= (1 << 16),
};

But, can I use the element bonus like this?

#ifdef ELEMENT_NEW_BONUSES
		else if (pkVictim->IsRaceFlag(RACE_FLAG_ATT_ELEC))
			iAtk += (iAtk * pkAttacker->GetPoint(POINT_ATTBONUS_ELEC)) / 100;
		else if (pkVictim->IsRaceFlag(RACE_FLAG_ATT_FIRE))
			iAtk += (iAtk * pkAttacker->GetPoint(POINT_ATTBONUS_FIRE)) / 100;
		else if (pkVictim->IsRaceFlag(RACE_FLAG_ATT_ICE))
			iAtk += (iAtk * pkAttacker->GetPoint(POINT_ATTBONUS_ICE)) / 100;
		else if (pkVictim->IsRaceFlag(RACE_FLAG_ATT_WIND))
			iAtk += (iAtk * pkAttacker->GetPoint(POINT_ATTBONUS_WIND)) / 100;
		else if (pkVictim->IsRaceFlag(RACE_FLAG_ATT_EARTH))
			iAtk += (iAtk * pkAttacker->GetPoint(POINT_ATTBONUS_EARTH)) / 100;
		else if (pkVictim->IsRaceFlag(RACE_FLAG_ATT_DARK))
			iAtk += (iAtk * pkAttacker->GetPoint(POINT_ATTBONUS_DARK)) / 100;
#endif

Thanks

Edited by Metin2 Dev
Core X - External 2 Internal

raw

raw

Link to comment
Share on other sites

10 hours ago, charparodar said:

It's already working...

I had to change this:


enum ERaceFlags
{
RACE_FLAG_ANIMAL = (1 << 0),
RACE_FLAG_UNDEAD = (1 << 1),
RACE_FLAG_DEVIL = (1 << 2),
RACE_FLAG_HUMAN = (1 << 3),
RACE_FLAG_ORC = (1 << 4),
RACE_FLAG_MILGYO = (1 << 5),
RACE_FLAG_INSECT = (1 << 6),
RACE_FLAG_FIRE = (1 << 7),
RACE_FLAG_ICE = (1 << 8),
RACE_FLAG_DESERT = (1 << 9),
RACE_FLAG_TREE = (1 << 10),
RACE_FLAG_ELEC = (1 << 11),
RACE_FLAG_WIND = (1 << 12),
RACE_FLAG_EARTH = (1 << 13),
RACE_FLAG_DARK = (1 << 14),
RACE_FLAG_ATT_ELEC = (1 << 15),
RACE_FLAG_ATT_FIRE = (1 << 16),
RACE_FLAG_ATT_ICE = (1 << 17),
RACE_FLAG_ATT_WIND = (1 << 18),
RACE_FLAG_ATT_EARTH = (1 << 19),
RACE_FLAG_ATT_DARK = (1 << 20),
};

To:


enum ERaceFlags
{
	RACE_FLAG_ANIMAL	= (1 << 0),
	RACE_FLAG_UNDEAD	= (1 << 1),
	RACE_FLAG_DEVIL		= (1 << 2),
	RACE_FLAG_HUMAN		= (1 << 3),
	RACE_FLAG_ORC		= (1 << 4),
	RACE_FLAG_MILGYO	= (1 << 5),
	RACE_FLAG_INSECT	= (1 << 6),
	RACE_FLAG_FIRE		= (1 << 7),
	RACE_FLAG_ICE		= (1 << 8),
	RACE_FLAG_DESERT	= (1 << 9),
	RACE_FLAG_TREE		= (1 << 10),
	RACE_FLAG_ATT_ELEC	= (1 << 11),
	RACE_FLAG_ATT_FIRE	= (1 << 12),
	RACE_FLAG_ATT_ICE	= (1 << 13),
	RACE_FLAG_ATT_WIND	= (1 << 14),
	RACE_FLAG_ATT_EARTH	= (1 << 15),
	RACE_FLAG_ATT_DARK	= (1 << 16),
};

But, can I use the element bonus like this?


#ifdef ELEMENT_NEW_BONUSES
		else if (pkVictim->IsRaceFlag(RACE_FLAG_ATT_ELEC))
			iAtk += (iAtk * pkAttacker->GetPoint(POINT_ATTBONUS_ELEC)) / 100;
		else if (pkVictim->IsRaceFlag(RACE_FLAG_ATT_FIRE))
			iAtk += (iAtk * pkAttacker->GetPoint(POINT_ATTBONUS_FIRE)) / 100;
		else if (pkVictim->IsRaceFlag(RACE_FLAG_ATT_ICE))
			iAtk += (iAtk * pkAttacker->GetPoint(POINT_ATTBONUS_ICE)) / 100;
		else if (pkVictim->IsRaceFlag(RACE_FLAG_ATT_WIND))
			iAtk += (iAtk * pkAttacker->GetPoint(POINT_ATTBONUS_WIND)) / 100;
		else if (pkVictim->IsRaceFlag(RACE_FLAG_ATT_EARTH))
			iAtk += (iAtk * pkAttacker->GetPoint(POINT_ATTBONUS_EARTH)) / 100;
		else if (pkVictim->IsRaceFlag(RACE_FLAG_ATT_DARK))
			iAtk += (iAtk * pkAttacker->GetPoint(POINT_ATTBONUS_DARK)) / 100;
#endif

Thanks

5DgEm1f.png

 

I believe that's how it's in official

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

29 minutes ago, metin2-factory said:

I Wouldn't recommend on using the client side one. the main reason is code duplication. if you forget to change in either client/server side you have a bug.

Your mob_proto get created from mob_proto and names that you use serverside, so the bug will inly happens if you updated the server side without the client side, which is dump.

Link to comment
Share on other sites

  • Management
4 hours ago, metin2-factory said:

I Wouldn't recommend on using the client side one. the main reason is code duplication. if you forget to change in either client/server side you have a bug.

I'm using yours and it's working, I just added the wrong piece of code, since I dont have the talismans I was using the code where the element was only displayed when using an item... But also I had to edit my Raceflag enum, had to many entries...

Also, can you share the slot management for the talismans please? 

Thanks

raw

raw

Link to comment
Share on other sites

  • 2 months later...
  • 5 months later...
On 10/31/2017 at 5:33 PM, metin2-factory said:

Small update #2

If you have installed my official like new elemental bonuses. follow the small guide below to view element icon of a target that wears

the new rings, like in official.

CxLhHukNSNe0fnTg7Ks24w.png

 

open char.cpp,look for: 


#ifdef ELEMENT_TARGET

replace the entire content of the #ifdef, until the #endif with the following:


#ifdef ELEMENT_TARGET
	p.bElement = 0;
	BYTE elementBase = 0;
	DWORD raceFlag;
	if (m_pkChrTarget)
	{
		if (m_pkChrTarget->IsMonster() && (raceFlag = m_pkChrTarget->GetMobTable().dwRaceFlag) >= RACE_FLAG_ATT_ELEC)
		{
			for (int i = RACE_FLAG_ATT_ELEC; i > 1; i /= 2)
			{
				elementBase++;
			}
			DWORD curElementBase = elementBase;
			const int ELEMENT_BASE_FLAG = pow(2, elementBase);
			for (int i = RACE_FLAG_ATT_ELEC; i <= RACE_FLAG_ATT_DARK; i *= 2)
			{
				curElementBase++;
				int diff = raceFlag - i;
				if (abs(diff) < ELEMENT_BASE_FLAG)
					break;
			}
			p.bElement = curElementBase - elementBase;
		}
		else if (m_pkChrTarget->IsPC())
		{
			LPITEM pItem = m_pkChrTarget->GetWear(WEAR_RING1);
			if (pItem)
			{
				const int BASE_ELEMENT = APPLY_ATTBONUS_ELEC;
				for (int i = 0; i < ITEM_SOCKET_MAX_NUM; i++)
				{
					if (pItem->GetNewAttributeType(i) >= APPLY_ATTBONUS_ELEC && pItem->GetSocket(i) <= APPLY_ATTBONUS_DARK)
					{
						p.bElement = pItem->GetNewAttributeType(i) - BASE_ELEMENT + 1;
						break;
					}
				}
			}
		}
	}

#endif

 

Compile server and that's it. now, when you select a target that wear a ring with elemental bonuses, an element icon will appear next to the target.

 

 

Error Compile 

 

char.cpp: In member function 'void CHARACTER::SetTarget(CHARACTER*)':
char.cpp:5622: error: call of overloaded 'pow(int, BYTE&)' is ambiguous
/usr/include/math.h:210: note: candidates are: double pow(double, double)
/usr/include/c++/4.2/cmath:373: note:                 long double std::pow(long double, int)
/usr/include/c++/4.2/cmath:369: note:                 float std::pow(float, int)
/usr/include/c++/4.2/cmath:365: note:                 double std::pow(double, int)
/usr/include/c++/4.2/cmath:361: note:                 long double std::pow(long double, long double)
/usr/include/c++/4.2/cmath:357: note:                 float std::pow(float, float)

 

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

  • 6 months later...
  • 6 months later...
  • 1 month later...

Unfortunately I don't see anything, I think the problem is the code inserted in char.cpp.

 

EDIT: Now work, it is this part of code that did not allow me to view the image:

 

#self.elementImage.SetPosition(self.GetLeft() - 40, self.GetTop())

Anyone know what I can replace this part with?

This is the effect obtained:

 

element-target.png

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

  • 2 weeks later...

UPDATE: 

 

Unfortunately I can't see the icon when the target is a player.
As for the errors related to the GetNewAttributeType and GetNewAttributeValue commands, I did so:

 

Open item.h, search: GetLimitValue and add below:

 

BYTE GetNewAttributeType (int i) {return m_pProto? m_pProto-> aApplies [i] .bType: 0;}
short GetNewAttributeValue (int i) {return m_pProto? m_pProto-> aApplies [i] .lValue: 0;}

 

Solutions?

Link to comment
Share on other sites

  • 4 weeks later...
  • 1 year later...
  • 2 months later...
  • 1 year later...
On 10/29/2017 at 1:52 PM, JeeX said:

First of all nice system, it's looking nice!

but i think i found a bug.
For Example: if i spawn the monster 7009 - after 2 seconds the element icons is changing from the yellow to the red one (Fire)
in my mob_proto: 7009 => ATT_EARTH
So why it is changing the elements?..

I have a problem similar to this but it only happens to me when I activate alchemy

Link to comment
Share on other sites

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.