metin2-factory 1010 Posted October 28, 2017 Share Posted October 28, 2017 M2 Download Center This is the hidden content, please Sign In or Sign Up ( 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! 115 2 3 1 2 6 2 27 6 185 Link to comment Share on other sites More sharing options...
anagonda1 5 Posted October 28, 2017 Share Posted October 28, 2017 tjhanks 1 Link to comment Share on other sites More sharing options...
Tacticus 73 Posted October 28, 2017 Share Posted October 28, 2017 thanks alot, plz upload element_image_client_files.rar 1 26 Link to comment Share on other sites More sharing options...
Jamie 12 Posted October 28, 2017 Share Posted October 28, 2017 good 1 Link to comment Share on other sites More sharing options...
Silver Sonitex 1438 Posted October 28, 2017 Silver Share Posted October 28, 2017 This is the hidden content, please Sign In or Sign Up Thank you for the contribution! 95 2 1 2 1 2 9 1 2 21 Link to comment Share on other sites More sharing options...
Chris90909090909090 50 Posted October 28, 2017 Share Posted October 28, 2017 error 1028 15:31:33351 :: TypeError 1028 15:31:33351 :: : 1028 15:31:33351 :: SetHPTargetBoard() takes exactly 4 arguments (6 given) 1028 15:31:33351 :: Link to comment Share on other sites More sharing options...
nicusor007 0 Posted October 28, 2017 Share Posted October 28, 2017 1028 16:37:29247 :: TypeError 1028 16:37:29247 :: : 1028 16:37:29247 :: SetHPTargetBoard() takes exactly 4 arguments (6 given) 1028 16:37:29247 :: Help me Link to comment Share on other sites More sharing options...
Horinna 4 Posted October 28, 2017 Share Posted October 28, 2017 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)); 1 Link to comment Share on other sites More sharing options...
Chris90909090909090 50 Posted October 28, 2017 Share Posted October 28, 2017 no icon on mob Link to comment Share on other sites More sharing options...
nicusor007 0 Posted October 28, 2017 Share Posted October 28, 2017 (edited) Problem Edited August 20, 2022 by Metin2 Dev Core X - External 2 Internal Link to comment Share on other sites More sharing options...
Chris90909090909090 50 Posted October 28, 2017 Share Posted October 28, 2017 same help pls Link to comment Share on other sites More sharing options...
metin2-factory 1010 Posted October 28, 2017 Author Share Posted October 28, 2017 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 More sharing options...
memett4545 6 Posted October 28, 2017 Share Posted October 28, 2017 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 More sharing options...
Silver Sonitex 1438 Posted October 28, 2017 Silver Share Posted October 28, 2017 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 More sharing options...
metin2-factory 1010 Posted October 28, 2017 Author Share Posted October 28, 2017 8 minutes ago, Sonitex said: 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. Do you get any error? check syserr.txt client side Link to comment Share on other sites More sharing options...
Silver Sonitex 1438 Posted October 28, 2017 Silver Share Posted October 28, 2017 5 minutes ago, metin2-factory said: Do you get any error? check syserr.txt client side That's the worst part, there is no errors... Link to comment Share on other sites More sharing options...
metin2-factory 1010 Posted October 28, 2017 Author Share Posted October 28, 2017 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 3 Link to comment Share on other sites More sharing options...
Chris90909090909090 50 Posted October 28, 2017 Share Posted October 28, 2017 (edited) yes it works perfect https://metin2.download/picture/MjG3lTR8vaqoQmt9zHyI9x17MLXYjtcI/.png Edited September 3, 2022 by Metin2 Dev Core X - External 2 Internal 3 1 Link to comment Share on other sites More sharing options...
HellFire 0 Posted October 29, 2017 Share Posted October 29, 2017 Thanks! Link to comment Share on other sites More sharing options...
JeeX 38 Posted October 29, 2017 Share Posted October 29, 2017 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 More sharing options...
metin2-factory 1010 Posted October 30, 2017 Author Share Posted October 30, 2017 (edited) 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: 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! Edited August 24, 2022 by Metin2 Dev Core X - External 2 Internal 2 6 Link to comment Share on other sites More sharing options...
Sebypunct 24 Posted October 30, 2017 Share Posted October 30, 2017 i have TARGET_DECIMAL_HP and no work , can anyone help me ? https://pastebin.com/ELUMNX0b game.py https://pastebin.com/dLbz11yM - pythonnetwork..... 1 Link to comment Share on other sites More sharing options...
metin2team 758 Posted October 30, 2017 Share Posted October 30, 2017 why do you use server-side while you can do it only using client-side? 1 Link to comment Share on other sites More sharing options...
Active Member hachiwari 138 Posted October 30, 2017 Active Member Share Posted October 30, 2017 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 More sharing options...
Sebypunct 24 Posted October 30, 2017 Share Posted October 30, 2017 1 oră în urmă, metin2team a spus: why do you use server-side while you can do it only using client-side? it's for me this mesage ? Link to comment Share on other sites More sharing options...
Recommended Posts