Jump to content

Stun Bug Fix


Recommended Posts

  • Premium

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.

  • Love 9
Link to comment
Share on other sites

  • 2 weeks later...

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.

  • Love 1
Link to comment
Share on other sites

  • Premium

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

  • 5 months later...

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.