Premium Cataclismo 86 Posted August 31, 2014 Premium Share Posted August 31, 2014 Hi everyone, I don't know if there is already a solution, but if it is I couldn't find it and I am sorry. I will post a solution found by me today. How does actually this bug works? Well, when you enter in game you will not have anti-stun until you will change the equipment and if your shield or your anti-stun item is not last then you will still not have that bonus. I saw some people trying to work with item->GetImmuneFlag() and m_pProto->dwImmuneFlag , but those functions does not return the immune bonuses... those functions returns values from item_proto so you should avoid them. I don't know exactly how this bug exactly works, but I found a solution. After you see it you may think that it's a performance issue, but it's still a fix. Of course, you can make all immunes 100% and in that case FALL will be there too and this is a problem. Of course, you can check and make 100% immune only stun, but that would mean you gived up (at least I feel that xD ). So... let's start. Search in char.h for : IsImmune(DWORD dwImmuneFlag); And add after: void UpdateImmuneFlags(); Now open char_resist.cpp and search for: #include "locale_service.h" And add after : #include "item.h" Now search in the same file for: bool CHARACTER::IsImmune(DWORD dwImmuneFlag) And add on the first line (after { ) : if (!IS_SET(m_pointsInstant.dwImmuneFlag, dwImmuneFlag)) // that means bug may be here UpdateImmuneFlags(); // we update flags And add this BEFORE the function : void CHARACTER::UpdateImmuneFlags() { m_pointsInstant.dwImmuneFlag = 0; // the flag may be reseted because we changed the equipment, but let's be sure for (int i = 0; i < WEAR_MAX_NUM; i++) // we check the entire uquipment... because immune on armor : and maybe other items { if(GetWear(i)) { for (int i2 = 0; i2 < ITEM_APPLY_MAX_NUM; ++i2) // we check the bonuses from proto { if (GetWear(i)->GetProto()->aApplies[i2].bType == APPLY_NONE) continue; else if(GetWear(i)->GetProto()->aApplies[i2].bType == APPLY_IMMUNE_STUN) // we found stun? SET_BIT(m_pointsInstant.dwImmuneFlag, IMMUNE_STUN); // we set stun else if(GetWear(i)->GetProto()->aApplies[i2].bType == APPLY_IMMUNE_SLOW) // we found slow? SET_BIT(m_pointsInstant.dwImmuneFlag, IMMUNE_SLOW); // we set slow else if(GetWear(i)->GetProto()->aApplies[i2].bType == APPLY_IMMUNE_FALL) // finally, we found fall? SET_BIT(m_pointsInstant.dwImmuneFlag, IMMUNE_FALL); // we set fall } for (int i3 = 0; i3 < ITEM_ATTRIBUTE_MAX_NUM; ++i3) // we check the bonuses from item { if (GetWear(i)->GetAttributeType(i3)) { const TPlayerItemAttribute& ia = GetWear(i)->GetAttribute(i3); if(ia.bType == APPLY_IMMUNE_STUN) // we found stun? SET_BIT(m_pointsInstant.dwImmuneFlag, IMMUNE_STUN); // we set stun else if(ia.bType == APPLY_IMMUNE_SLOW) // we found slow? SET_BIT(m_pointsInstant.dwImmuneFlag, IMMUNE_SLOW); // we set slow else if(ia.bType == APPLY_IMMUNE_FALL) // finally, we found fall? SET_BIT(m_pointsInstant.dwImmuneFlag, IMMUNE_FALL); // we set fall } } } } } Now... how actually that works? Everytime you will get attacked the server will automatically check if you have anti-stun. If server will find that you don't have will update the flags using my function and will check again and now will actually "see" if you really have anti-stun. Now some of you will probably think: "Wait... this function only add immune flags... what about deleting them?" The answer is simple: server does that and it does correctly. So don't worry. I tested that and it worked for me. This will be probably the only fix I will post over here. Why? People do not appreciate and usually they say that is copied or is theirs. At least my country does that (Romania) and every guy who just discovered the colors from syntax highlighters is saying that he knows to code. Dat country and dat people. "GG izy" Hope this will help you. If you find something wrong in my code then I am sorry. 9 Link to comment Share on other sites More sharing options...
Premium Galet 509 Posted August 31, 2014 Premium Share Posted August 31, 2014 Thanks Link to comment Share on other sites More sharing options...
LiiKeFam3 1 Posted September 1, 2014 Share Posted September 1, 2014 Thanks for sharing, greetings from Romania xD . Link to comment Share on other sites More sharing options...
Lehel 14 Posted September 1, 2014 Share Posted September 1, 2014 Is this an important fix ? Link to comment Share on other sites More sharing options...
Premium Galet 509 Posted September 1, 2014 Premium Share Posted September 1, 2014 Is this an important fix ? Important, but Metin2 has this bug since 2002-2004... the 1st release of the game. Link to comment Share on other sites More sharing options...
Think 117 Posted September 9, 2014 Share Posted September 9, 2014 I don't know exactly how this bug exactly works, but I found a solution. After you see it you may think that it's a performance issue, but it's still a fix. Isn't that kind of a bad start? If you don't know how it works, how can you claim you solved it? If you wish to fix the bug, fix it in the origin, setting/removing immune flags. Although someone else already published a solution in the forum, but well, it basically consisted of removing the recalculation of the flags so you'd get immune even if you didn't have the shield equipped, if I recall correctly. So that one was not a solution, and yours is definitely better compared (I think there were two posts, but I don't recall the other fix just right now, which I think was not correct either). Now, besides well, not being optimal as you say, for (int i2 = 0; i2 < ITEM_APPLY_MAX_NUM; ++i2) // we check the bonuses from proto why do you do that after you said I saw some people trying to work with item->GetImmuneFlag() and m_pProto->dwImmuneFlag , but those functions does not return the immune bonuses... those functions returns values from item_proto so you should avoid them. Well, avoid them if you want to get the actual immune flag, but not if you want to get the proto immune flag! PS: Yes, yes, I whine a lot, it's attempted to be constructive criticism, sorry if it comes out that way. 1 Link to comment Share on other sites More sharing options...
Premium Cataclismo 86 Posted September 10, 2014 Author Premium Share Posted September 10, 2014 You do not understood me ^.^ I don't know why exactly the flags don't update well ( and I was too lazy to search where this happen ). And also: GetImmuneFlag returns the field "dwImmuneFlag" from item_proto, not the bonuses from item_proto ... so the server should still search for flags in proto. It should search because I saw servers with immunes on armors and so on... So? ^.^ Link to comment Share on other sites More sharing options...
Active Member hachiwari 138 Posted February 19, 2015 Active Member Share Posted February 19, 2015 It -> perfectly, so why so much crap?! Link to comment Share on other sites More sharing options...
Premium tierrilopes 452 Posted February 19, 2015 Premium Share Posted February 19, 2015 It -> perfectly, so why so much crap?! Read what Think said... Link to comment Share on other sites More sharing options...
Recommended Posts