[C++/Python]17.5 Element Image on target

  • 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 screens 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).




    Client files:


    Let's begin!



    Server Side:


    Open service.h, add in the end:


    Code
    1. #define ELEMENT_TARGET




    Open char.cpp, search for

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




    add below:


    Code
    1. #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:


    Code
    1. } TPacketGCTarget;


    add above:


    Code
    1. #ifdef ELEMENT_TARGETBYTE bElement;#endif




    Client side:


    open locale_inc.h, add in the end:


    Code
    1. #define ELEMENT_TARGET


    open packet.h, search for*


    Code
    1. } TPacketGCTarget;


    add above:


    Code
    1. #ifdef ELEMENT_TARGETBYTE bElement;#endif


    open PythonNetworkPhaseGame.cpp, look for:


    Code
    1. else if (pInstPlayer->CanViewTargetHP(*pInstTarget))


    replace below with the following:


    Code
    1. #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*


    Code
    1. #ifdef ENABLE_ENERGY_SYSTEM


    add above:


    Code
    1. #ifdef ELEMENT_TARGETPyModule_AddIntConstant(poModule, "ENABLE_VIEW_ELEMENT", 1);#elsePyModule_AddIntConstant(poModule, "ENABLE_VIEW_ELEMENT", 0);#endif


    open game.py, look for*

    Code
    1. 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:


    Code
    1. 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*


    Code
    1. import background


    add below:


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


    look for:


    Code
    1. self.isShowButton = False


    add below:


    Code
    1. if app.ENABLE_VIEW_ELEMENT:self.elementImage = None


    inside Destroy method, look for:

    Code
    1. self.__Initialize()


    add below:


    Code
    1. if app.ENABLE_VIEW_ELEMENT:self.elementImage = None


    inside ResetTargetBoard method, look for:


    Code
    1. self.hpGauge.Hide()


    add below:


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


    look for :


    Code
    1. def SetElementImage(self,elementId):


    add above:

    Code
    1. 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! :)


    Bitte melden Sie sich an, um dieses Bild zu sehen.


    Bitte melden Sie sich an, um dieses Bild zu sehen.


    Bitte melden Sie sich an, um dieses Bild zu sehen.


    Bitte melden Sie sich an, um dieses Bild zu sehen.

    3 Mal editiert, zuletzt von M2GW ()

  • Dieses Thema enthält 23 weitere Beiträge, die nur für registrierte Benutzer sichtbar sind, bitte registrieren Sie sich oder melden Sie sich an um diese lesen zu können.