Jump to content
Maintenance ×
×
×
  • Create New...

v17.5 Element Image on Target


Recommended Posts

  • Moon

M2 Download Center

This is the hidden content, please
( Internal )

Hey there,

I have an Halloween gift for you all. i have been working for a few hours on official like element image on target window(See screenshots below).

When you click on a mob if it is defined as elemental, it will open an element image in addition to the target window.

Don't forget to hit the like button! ;)

(C) Metin2 guild wars - coded by [GA]Ruin - 27/10/2017 (I create custom metin2 systems in c++/python. if you want a custom system send me a pm and we can talk over skype).


Let's begin! 


Server Side:

Open service.h, add in the end:

#define ELEMENT_TARGET

 

Open char.cpp, search for

else
	{
		p.dwVID = 0;
		p.bHPPercent = 0;
}

 

add below:

#ifdef ELEMENT_TARGET
	const int ELEMENT_BASE = 11;
	DWORD curElementBase = ELEMENT_BASE;
	DWORD raceFlag;
	if (m_pkChrTarget && m_pkChrTarget->IsMonster() && (raceFlag = m_pkChrTarget->GetMobTable().dwRaceFlag) >= RACE_FLAG_ATT_ELEC)
	{
		for (int i = RACE_FLAG_ATT_ELEC; i <= RACE_FLAG_ATT_DARK; i *= 2)
		{
			curElementBase++;
			int diff = raceFlag - i;
			if (abs(diff) <= 1024)
				break;
		}
		p.bElement = curElementBase - ELEMENT_BASE;
	}
	else
	{
		p.bElement = 0;
	}

#endif

 

open packet.h, search for:

} TPacketGCTarget;

add above:

#ifdef ELEMENT_TARGET
	BYTE	bElement;
#endif

 

Client side:

open locale_inc.h, add in the end:

#define ELEMENT_TARGET

open packet.h, search for 

} TPacketGCTarget;

add above:

#ifdef ELEMENT_TARGET
	BYTE bElement;
#endif

open PythonNetworkPhaseGame.cpp, look for:

else if (pInstPlayer->CanViewTargetHP(*pInstTarget))

replace below with the following:

#ifdef ELEMENT_TARGET
				PyCallClassMemberFunc(m_apoPhaseWnd[PHASE_WINDOW_GAME], "SetHPTargetBoard", Py_BuildValue("(iii)", TargetPacket.dwVID, TargetPacket.bHPPercent, TargetPacket.bElement));
#else

				PyCallClassMemberFunc(m_apoPhaseWnd[PHASE_WINDOW_GAME], "SetHPTargetBoard", Py_BuildValue("(ii)", TargetPacket.dwVID, TargetPacket.bHPPercent));
#endif

open PythonApplicationModule.cpp, look for 

#ifdef ENABLE_ENERGY_SYSTEM

add above:

#ifdef ELEMENT_TARGET
	PyModule_AddIntConstant(poModule, "ENABLE_VIEW_ELEMENT", 1);
#else
	PyModule_AddIntConstant(poModule, "ENABLE_VIEW_ELEMENT", 0);
#endif

open game.py, look for 

def SetHPTargetBoard(self, vid, hpPercentage):
			if vid != self.targetBoard.GetTargetVID():
				self.targetBoard.ResetTargetBoard()
				self.targetBoard.SetEnemyVID(vid)

			self.targetBoard.SetHP(hpPercentage)
			self.targetBoard.Show()

replace with:

if app.ENABLE_VIEW_ELEMENT:
		def SetHPTargetBoard(self, vid, hpPercentage,bElement):
			if vid != self.targetBoard.GetTargetVID():
				self.targetBoard.ResetTargetBoard()
				self.targetBoard.SetEnemyVID(vid)
			
			self.targetBoard.SetHP(hpPercentage)
			self.targetBoard.SetElementImage(bElement)
			self.targetBoard.Show()
	else:
		def SetHPTargetBoard(self, vid, hpPercentage):
			if vid != self.targetBoard.GetTargetVID():
				self.targetBoard.ResetTargetBoard()
				self.targetBoard.SetEnemyVID(vid)

			self.targetBoard.SetHP(hpPercentage)
			self.targetBoard.Show()

open uitarget.py, look for 

import background

add below:

if app.ENABLE_VIEW_ELEMENT:
	ELEMENT_IMAGE_DIC = {1: "elect", 2: "fire", 3: "ice", 4: "wind", 5: "earth", 6 : "dark"}

look for:

self.isShowButton = False

add below:

if app.ENABLE_VIEW_ELEMENT:
			self.elementImage = None

inside Destroy method, look for:

self.__Initialize()

add below:

if app.ENABLE_VIEW_ELEMENT:
			self.elementImage = None

inside ResetTargetBoard method, look for:

self.hpGauge.Hide()

add below:

if app.ENABLE_VIEW_ELEMENT and self.elementImage:
			self.elementImage = None

look for :

def SetElementImage(self,elementId):

add above:

if app.ENABLE_VIEW_ELEMENT:
		def SetElementImage(self,elementId):
			try:
				if elementId > 0 and elementId in ELEMENT_IMAGE_DIC.keys():
					self.elementImage = ui.ImageBox()
					self.elementImage.SetParent(self.name)
					self.elementImage.SetPosition(-60,-12)
					self.elementImage.LoadImage("d:/ymir work/ui/game/12zi/element/%s.sub" % (ELEMENT_IMAGE_DIC[elementId]))
					self.elementImage.Show()
			except:
				pass

 

Compile server, client source and root pack and that's it!

 

Enjoy!

Happy halloween! :)

  • Metin2 Dev 28
  • Love 140
  • Love 2
  • Good 18
  • Lmao 1
  • Think 2
  • Confused 5
  • Angry 1
  • Dislove 1
Link to comment
Share on other sites

PyCallClassMemberFunc(m_apoPhaseWnd[PHASE_WINDOW_GAME], "SetHPTargetBoard", Py_BuildValue("(iiiii)", TargetPacket.dwVID, TargetPacket.bHPPercent, TargetPacket.bElement));

to

 

PyCallClassMemberFunc(m_apoPhaseWnd[PHASE_WINDOW_GAME], "SetHPTargetBoard", Py_BuildValue("(iii)", TargetPacket.dwVID, TargetPacket.bHPPercent, TargetPacket.bElement));
  • Love 1
Link to comment
Share on other sites

  • Moon
2 hours ago, Horinna said:
PyCallClassMemberFunc(m_apoPhaseWnd[PHASE_WINDOW_GAME], "SetHPTargetBoard", Py_BuildValue("(iiiii)", TargetPacket.dwVID, TargetPacket.bHPPercent, TargetPacket.bElement));

to

 

PyCallClassMemberFunc(m_apoPhaseWnd[PHASE_WINDOW_GAME], "SetHPTargetBoard", Py_BuildValue("(iii)", TargetPacket.dwVID, TargetPacket.bHPPercent, TargetPacket.bElement));

Thanks, i'v updated my post.
If you have the error below:
 

1028 16:37:29247 :: TypeError
1028 16:37:29247 :: : 
1028 16:37:29247 :: SetHPTargetBoard() takes exactly 4 arguments (6 given)
1028 16:37:29247 :: 


open PythonNetworkPhaseGame and modify as above

Link to comment
Share on other sites

1028 21:49:07819 :: 
networkModule.py(line:209) SetSelectCharacterPhase
system.py(line:130) __pack_import
system.py(line:110) _process_result
introSelect.py(line:26) <module>
system.py(line:130) __pack_import

networkModule.SetSelectCharacterPhase - <type 'exceptions.IndentationError'>:unindent does not match any outer indentation level (uiTarget.py, line 142)

1028 21:49:07819 :: ============================================================================================================
1028 21:49:07819 :: Abort!!!!


help me pls 
  uiTarger.py Line 142:
  
  		self.isShowButton = FALSE
if app.ENABLE_VIEW_ELEMENT:
			self.elementImage = None

		self.__Initialize() #142 ?
if app.ENABLE_VIEW_ELEMENT:
			self.elementImage = None
		self.ResetTargetBoard()

 

Link to comment
Share on other sites

  • Premium
20 minutes ago, memett4545 said:
networkModule.SetSelectCharacterPhase - <type 'exceptions.IndentationError'>:unindent does not match any outer indentation level (uiTarget.py, line 142)

 

Check your tabs at line 142 in uiTarget.py

 

@metin2-factory I seem to have the same problem as others, element icons are not showing up for some reason. :( 

Link to comment
Share on other sites

  • Moon
19 minutes ago, Sonitex said:

That's the worst part, there is no errors... 

use sys_err function server side(char.cpp) and print in python(game.py) to find bElement value. 

it should be between 1 and 6 for elemental mobs. if it's not in this range then you did something wrong.

 

Also, make sure in mob_proto server side the mobs race is with ATT_
for example: ATT_ICE, ATT_FIRE, ATT_WIND etc etc

  • Love 3
Link to comment
Share on other sites

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

Link to comment
Share on other sites

  • Moon

Small update:

Added tool tip to make it more clear for players, follow the steps below to have it.

Like this post if you find it useful :)

Screens:

t0QauxcjSpaHB3IpWxtP_A.png 

Lu5jH5K9QTarD5hh0uaVeQ.png

 

in _init_ and in Destroy methods look for:

if app.ENABLE_VIEW_ELEMENT:
	self.elementImage = None

replace with:

if app.ENABLE_VIEW_ELEMENT:
	self.elementImage = None
	self.elementId = None
	self.elementImageToolTip = None

search for:

def Close(self):

add inside the method:

if app.ENABLE_VIEW_ELEMENT and self.elementImage:
	self.elementImage.Hide()

 

Search for:

ELEMENT_IMAGE_DIC = {1: "elect", 2: "fire", 3: "ice", 4: "wind", 5: "earth", 6: "dark"}

add above:

import uiToolTip

inside ResetTargetBoard method look for:

if app.ENABLE_VIEW_ELEMENT and self.elementImage:
	self.elementImage = None

replace with:

if app.ENABLE_VIEW_ELEMENT and self.elementImage:
  self.elementImage = None
  self.elementId = None
  if self.elementImageToolTip:
  self.elementImageToolTip.Hide()

Look for:

def SetElementImage(self, elementId):

replace the whole method with:

		def SetElementImage(self, elementId):
			try:
				if elementId > 0 and elementId in ELEMENT_IMAGE_DIC.keys():
					self.elementId = elementId
					self.elementImage = ui.ImageBox()
					self.elementImage.SAFE_SetStringEvent("MOUSE_OVER_IN", self.OnElementImageOverIn)
					self.elementImage.SAFE_SetStringEvent("MOUSE_OVER_OUT", self.OnElementImageOverOut)
					self.elementImage.SetPosition(self.GetLeft() - 40, self.GetTop())
					self.elementImage.LoadImage(
						"d:/ymir work/ui/game/12zi/element/%s.sub" % (ELEMENT_IMAGE_DIC[elementId]))
					self.elementImage.Show()
			except:
				pass

		def OnElementImageOverIn(self):
			if not self.elementImageToolTip:
				self.elementImageToolTip = uiToolTip.ToolTip()
			self.elementImageToolTip.ClearToolTip()
			self.elementImageToolTip.AppendTextLine(ELEMENT_IMAGE_DIC[self.elementId] + " element")
			self.elementImageToolTip.SetToolTipPosition(self.GetLeft() - 40, self.GetTop() + 70)
			self.elementImageToolTip.Show()

		def OnElementImageOverOut(self):
			if self.elementImageToolTip:
				self.elementImageToolTip.Hide()

That's it.

Enjoy!

  • Metin2 Dev 1
  • Love 6
Link to comment
Share on other sites

 

	const int ELEMENT_BASE = 11;
	DWORD curElementBase = ELEMENT_BASE;
	DWORD raceFlag;
	if (m_pkChrTarget && m_pkChrTarget->IsMonster() && (raceFlag = m_pkChrTarget->GetMobTable().dwRaceFlag) >= RACE_FLAG_ATT_ELEC)
	{
		for (int i = RACE_FLAG_ATT_ELEC; i <= RACE_FLAG_ATT_DARK; i *= 2)
		{
			curElementBase++;
			int diff = raceFlag - i;
			if (abs(diff) <= 1024)
				break;
		}
		p.bElement = curElementBase - ELEMENT_BASE;
	}
	else
	{
		p.bElement = 0;
	}

#nicecode

Link to comment
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.


  • Activity

    1. 0

      erorrs after update granny to 2.9

    2. 0

      Navicat Premium 16.1.1 x64

    3. 5

      problem Dargon Soul Changre Attribute

    4. 5

      problem Dargon Soul Changre Attribute

    5. 41

      Global Chat

    6. 5

      problem Dargon Soul Changre Attribute

    7. 2

      Startup Loading Window Library

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.