Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

trace_flags #29

Closed
GLoOoccK opened this issue Aug 23, 2024 · 20 comments
Closed

trace_flags #29

GLoOoccK opened this issue Aug 23, 2024 · 20 comments
Labels
enhancement New feature or request

Comments

@GLoOoccK
Copy link

GLoOoccK commented Aug 23, 2024

@SmileYzn

Add FTRACE_BULLET to return compatibility with plugins that use this code:

s1lentq/ReGameDLL_CS#813

in:

https://github.com/SmileYzn/AccuracyFix/blob/main/AccuracyFix/AccuracyFix.cpp#L101

gpGlobals->trace_flags = FTRACE_BULLET;
g_engfuncs.pfnTraceLine(vStart, vEndRes, fNoMonsters, pentToSkip, ptr);

I don't know if the same code could be added here as well:

https://github.com/SmileYzn/AccuracyFix/blob/main/AccuracyFix/AccuracyUtil.cpp#L94

gpGlobals->trace_flags = FTRACE_BULLET;
g_engfuncs.pfnTraceLine(v_src, v_dest, 0, pEntity, &Result);
@SmileYzn SmileYzn added the enhancement New feature or request label Aug 23, 2024
@SmileYzn
Copy link
Owner

Added, thanks for tip

Ps. This cam be a fix for flash bug in ReGameDLL_CS:

s1lentq/ReGameDLL_CS#854

??

@GLoOoccK
Copy link
Author

GLoOoccK commented Aug 23, 2024

@SmileYzn

It worked, but it causes problems when using:

https://github.com/alliedmodders/amxmodx/blob/master/plugins/cstrike/statsx.sma#L172

register_event("StatusValue", "eventShowRank", "bd", "1=2")

Sometimes he ignores his teammate and directly shows his opponent's name, but now when he shoots a teammate he deals damage with all weapons

About flash bang, maybe it was necessary to do something like this? I don't know if that would solve it:

void RadiusFlash_TraceLine_hook(CBasePlayer *pPlayer, entvars_t *pevInflictor, entvars_t *pevAttacker, Vector &vecSrc, Vector &vecSpot, TraceResult *tr)
{
#ifdef REGAMEDLL_ADD
	gpGlobals->trace_flags = FTRACE_FLASH;
#endif
	UTIL_TraceLine(vecSrc, vecSpot, dont_ignore_monsters, ENT(pevInflictor), tr);
#ifdef REGAMEDLL_ADD
	gpGlobals->trace_flags = 0;
#endif
}

@SmileYzn
Copy link
Owner

To fix friendly aim that maybe need to reset trace_flags to default after trace line?

@GLoOoccK
Copy link
Author

GLoOoccK commented Aug 23, 2024

@SmileYzn

I tested this and it worked:

if (gpGlobals->trace_flags & FTRACE_BULLET)
{
	gpGlobals->trace_flags = FTRACE_BULLET;
	g_engfuncs.pfnTraceLine(vStart, vEndRes, fNoMonsters, pentToSkip, ptr);
}

Didn't work:

if (gpGlobals->trace_flags & FTRACE_BULLET)
{
	gpGlobals->trace_flags = FTRACE_BULLET;
}

g_engfuncs.pfnTraceLine(vStart, vEndRes, fNoMonsters, pentToSkip, ptr);

Because ReGameDLL will set gpGlobals->trace_flags = FTRACE_BULLET automatically before calling the hook:

https://github.com/s1lentq/ReGameDLL_CS/blob/master/regamedll/dlls/cbase.cpp#L1063
https://github.com/s1lentq/ReGameDLL_CS/blob/master/regamedll/dlls/cbase.cpp#L1209
https://github.com/s1lentq/ReGameDLL_CS/blob/master/regamedll/dlls/cbase.cpp#L1369

We need to make sure we are only changing the code when we perform a shot, we need to set gpGlobals->trace_flags = FTRACE_BULLET again and this may solve the flashbang problem if the problem comes from the module

This part is not executed, so it can be removed gpGlobals->trace_flags = FTRACE_BULLET in:

https://github.com/SmileYzn/AccuracyFix/blob/main/AccuracyFix/AccuracyUtil.cpp#L94

@SmileYzn
Copy link
Owner

SmileYzn commented Aug 23, 2024

So you tell to trace line fix only when trace_flags = FTRACE_BULLET?

if (gpGlobals->trace_flags & FTRACE_BULLET)

?

@GLoOoccK
Copy link
Author

@SmileYzn

Yes, I needed this check and everything worked correctly again, it would look like this:

if (gpGlobals->trace_flags & FTRACE_BULLET)
{
	gpGlobals->trace_flags = FTRACE_BULLET;
	g_engfuncs.pfnTraceLine(vStart, vEndRes, fNoMonsters, pentToSkip, ptr);
}

in:

https://github.com/SmileYzn/AccuracyFix/blob/main/AccuracyFix/AccuracyFix.cpp#L101-L103

@SmileYzn
Copy link
Owner

To be honest that if is needed to be in very first of of function

@SmileYzn
Copy link
Owner

Build is here: https://github.com/SmileYzn/AccuracyFix/actions/runs/10530588403

@GLoOoccK
Copy link
Author

@SmileYzn

I just tested it and everything works perfectly now, thank you very much

@SmileYzn
Copy link
Owner

🙏

@Escap3d
Copy link

Escap3d commented Aug 25, 2024

@SmileYzn I installed a new action build plugin, but the shooting has become very unfair. Both bullets and spray are not working properly. Please fix it.

@SmileYzn
Copy link
Owner

The test fix is here:

https://github.com/SmileYzn/AccuracyFix/actions/runs/10551207451

FTRACE_BULLET is not a bitwise!

@GLoOoccK
Copy link
Author

I apologize for my mistake. I just tested without:

gpGlobals->trace_flags = FTRACE_BULLET;

As it still has this value defined, then it is not necessary, just this check:

(gpGlobals->trace_flags == FTRACE_BULLET)

It turned out to be enough and at least for me everything is fine now

@SmileYzn
Copy link
Owner

So do not need to sign value to trace_flags?
Just check it on if at start of function?

@GLoOoccK
Copy link
Author

Yes it can be removed and if the inaccuracy continues it must be because you were updating the traceline the whole time, not just at the exact moment of the shot

@SmileYzn
Copy link
Owner

SmileYzn commented Aug 26, 2024

On my tests it fixed in all times, not only when shooting.

Did fixed for you? Maybe fix only at things that is not ftrace_flash flag

@GLoOoccK
Copy link
Author

Yes, that solved it for me

@Escap3d
Copy link

Escap3d commented Aug 26, 2024

The long-range shooting with the pistol and assault rifle is still experiencing quite a few misses...

@SmileYzn
Copy link
Owner

I have removed that TRACE_BULLET check, it is only now for TRACE_FLASH

@Escap3d
Copy link

Escap3d commented Aug 26, 2024

I have removed that TRACE_BULLET check, it is only now for TRACE_FLASH

thanks bro its fix and shotting love it :D

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants