Closed khalidahmedshalabi closed 7 years ago
Seems good, don't know why I couldn't think of this at the time. You won't get it exactly to work like the game because it does some weird multiplication every frame for sprint speed I think On Mar 4, 2016 5:59 PM, "Khalid" notifications@github.com wrote:
You know how much this is hated, so not gonna go on that.. So
define MAX_SPRINT_SPEED 11.0f
HOOK CHookManager::KeyPress() {if (SPRINT_KEY != 0) { if (VAR_CURRENT_VEHICLE == 0 && Misc::GetMacroLocks() == true) { if (GetTickCount() < dwLastSprint) { // Player taps sprint key too quick or is holding it????????????!?!?!?!?
} else { // Player taps sprint key normally dwLastSprint = GetTickCount() + 80; VAR_SPRINT_SPEED += 0.3f; } } }
}
HOOK CHookManager::SprintHook() { __asm { fstp dword ptr[ecx + 1Ch] mov ecx, [edi + 00000480h] pushad }
if (VAR_SPRINT_SPEED > MAX_SPRINT_SPEED && Misc::GetMacroLocks() == true && VAR_CURRENT_VEHICLE == 0) { VAR_SPRINT_SPEED = MAX_SPRINT_SPEED; } __asm { popad jmp[SprintHookJmpBack] }
}
This code makes me sprint without problem kinda like the original game. But does it please sprint-macros users? I don't get how oftenKeyPress() is called very well. I tested this code with a few players and they were happy with it because they can sprint normally and sprint macros can't get you too fast or give you a great advantage as well. I will test it tomorrow with more people to get more feedback.
— Reply to this email directly or view it on GitHub https://github.com/Whitetigerswt/SAMP_AC_v2/issues/140.
There's a problem I think. This part is always called
if (GetTickCount() < dwLastSprint)
{
// Player taps sprint key too quick or is holding it
}
however, this is probably never reached
else
{
// Player taps sprint key normally
dwLastSprint = GetTickCount() + 80;
VAR_SPRINT_SPEED += 0.3f;
}
It seems like KeyPress()
is called in a really weird way that makes my code not work as I expect it to (the difference between key presses is always 0ms). I think I have another solution though, I will just make use of the hooking you done and create our own sprinting system.
Nope, I was wrong. Time difference isn't always 0ms, but it's still weird, I tapped the sprint key normally like what a noob would do and got this
tick count diff: 109
tick count diff: 0
tick count diff: 16
tick count diff: 16
tick count diff: 125
tick count diff: 0
tick count diff: 16
tick count diff: 16
tick count diff: 94
tick count diff: 0
tick count diff: 31
tick count diff: 31
tick count diff: 47
tick count diff: 47
tick count diff: 125
tick count diff: 0
tick count diff: 94
tick count diff: 0
tick count diff: 16
tick count diff: 16
tick count diff: 47
tick count diff: 47
tick count diff: 125
tick count diff: 0
tick count diff: 16
tick count diff: 16
Isn't there just someplace you could hook into and limit the currently calculated sprint speed? That way they could use any macro they want, but it still wouldn't do them any good.
Also, those time diffs appear to be aligned to frames in 60 FPS.
This is just how it works right now. Tapping sprint key has no effect. Whether you tap sprint key or hold it, you will get the same "limited" speed. However, this makes people very angry because they consider it as a skill cap.
That's not what I meant - I meant limit the max speed you can reach by tapping.
Wouldn't that let macro users reach max speed quicker than normal players?
Right, so what you wish to do is limit how many key pressed are registered each second?
This is what I've opened this issue for. I'm trying to achieve this, but KeyPress()
hook doesn't work as expected, it doesn't work like SAMP key press callback, so it gives weird key pressing rates (16ms and lower. Sometimes 0ms continuously) on which you can't depend. Maybe some formula could be done to get good results from KeyPress()
, I haven't tested that though and I don't know of it.
Where does GTA calculate the number of key pressed into sprint speed? I'm saying that's probably where you want to look.
I think it's this hook by WhiteTiger
// Hook sprint speed
CMem::ApplyJmp(FUNC_SprintHook, (DWORD)SprintHook, 9);
Anyway, I got the same stupid key press rates there
15
32
15
16
31
16
15
32
15
16
31
16
15
32
15
16
31
16
15
32
15
31
16
16
31
There should be a conversion formula I think...
There is no internal sprint limit in gta sa. On Mar 9, 2016 4:05 AM, "oscar-broman" notifications@github.com wrote:
Isn't there just someplace you could hook into and limit the currently calculated sprint speed? That way they could use any macro they want, but it still wouldn't do them any good.
Also, those time diffs appear to be aligned to frames in 60 FPS.
— Reply to this email directly or view it on GitHub https://github.com/Whitetigerswt/SAMP_AC_v2/issues/140#issuecomment-194192985 .
But there is some place where the rate of pressing the sprint key is calculated and turned into the actual sprint speed..? Just add a hook there and add a limit.
Khalid what values do you get when you change your FPS? Try both 20 and 100.
Yes, this is where the sprint hook is placed. On Mar 9, 2016 8:36 PM, "oscar-broman" notifications@github.com wrote:
But there is some place where the rate of pressing the sprint key is calculated and turned into the actual sprint speed..? Just add a hook there and add a limit.
Khalid what values do you get when you change your FPS? Try both 20 and 100.
— Reply to this email directly or view it on GitHub https://github.com/Whitetigerswt/SAMP_AC_v2/issues/140#issuecomment-194607903 .
/fpslimit 20:
63
47
47
46
47
63
47
47
46
47
47
47
63
46
47
47
47
63
46
47
47
47
63
46
47
47
63
47
46
47
47
47
47
62
47
/fpslimit 90
15
16
15
16
16
15
32
15
16
15
16
16
15
16
16
15
16
15
16
16
15
32
15
16
15
16
16
15
16
16
15
16
15
16
16
15
16
31
That address is the place where sprint speed is changed. Try changing the address I defined as sprint speed to 99999 in cheat engine and sprinting. On Mar 10, 2016 7:48 AM, "Khalid" notifications@github.com wrote:
/fpslimit 20:
63 47 47 46 47 63 47 47 46 47 47 47 63 46 47 47 47 63 46 47 47 47 63 46 47 47 63 47 46 47 47 47 47 62 47
/fpslimit 90
15 16 15 16 16 15 32 15 16 15 16 16 15 16 16 15 16 15 16 16 15 32 15 16 15 16 16 15 16 16 15 16 15 16 16 15 16 31
— Reply to this email directly or view it on GitHub https://github.com/Whitetigerswt/SAMP_AC_v2/issues/140#issuecomment-194828523 .
Seems like whatever 17 has done people have accepted, so I'm going to close this...
You know how much this is hated, so not gonna go on that.. So
This code makes me sprint without problem kinda like the original game. But does it please sprint-macros users? I don't get how often
KeyPress()
is called very well. I tested this code with a few players and they were happy with it because they can sprint normally and sprint macros can't get you too fast or give you a great advantage as well. I will test it tomorrow with more people to get more feedback.