What's the most appropriate approach to code range damage and range pickup

06/30/2022 01:17 theashmaster#1
Hey guys!

So, I have coded a cheat that works completely fine in which I can attack by range and pick items by range aswell. The problem is that when I use both at the same time my character keeps flickering and doesn't look as smooth as other professional cheats.

My question is: how to code so both can work properly?

Currently, I create two threads that execute functions for ranged damage and ranged pickup. The code looks something like this:

Code:
void sendAttackWrapper()
{
if(!isPressed(VK_SPACE)) return false;

TPixelPosition mobPos = getPixelPosition(mobVID);

if ((mobPos.x <= 1 or mobPos.y <= 1) or (myPos.x <= 1 or myPos.y <= 1)) return; // checks if mob position is something valid

DWORD instType = getInstanceType(mobVID);

if(instType != 0 and instType != 2) return; // if is not a mob or is not a metin, skip to the next one

float dst = getCharacterDistance(mobVID);

if(dst > args.dst) return; // if distance to the mob is bigger than the maximum distance intended, returns;

WaitForSingleObject(isPlayerAround, INFINITE); // waits if the object is signaled -> only signaled if there's a player around

Teleport(mobPos);
sendAttackPacket(mobVID);
Teleport(playerPos);
}
The code for picking is kinda the same, but applied to items.

Is the best approach actually using separate threads? I also thought on putting pickup in between sendAttackPacket and teleport calls, but after the mob is dead, if the player didn't had time to pickup the item, it wouldn't be able to teleport back to that location.

What can I do to stop this flickering?

Thanks
07/03/2022 15:43 Rucksackträger'#2
I think the flickering is the fix from GF.
07/04/2022 12:11 sad666#3
the flickering happens when you try to jump more than 2000 pixel at once. so if you want to increase that range have to separate your jumps. also try to transition between attack and pick instead of perform both at the same time because you should consider that your server position not the client one. it seems like they pick two different points that 2000 away from each other.
07/22/2022 21:16 theashmaster#4
Quote:
Originally Posted by Rucksackträger' View Post
I think the flickering is the fix from GF.
I'm actually not coding on GF servers xD

Quote:
Originally Posted by sad666 View Post
the flickering happens when you try to jump more than 2000 pixel at once. so if you want to increase that range have to separate your jumps. also try to transition between attack and pick instead of perform both at the same time because you should consider that your server position not the client one. it seems like they pick two different points that 2000 away from each other.
The issue was not the distance, causa I was teleporting in small ranges. But I managed to fix the issue by simple creating a std::mutex to avoid teleporting to attack and to pick an item at the same time. That pretty much fixed the issue.

Thanks!