God, no. || is an operator that takes two boolean operands and returns true if one of them is true. Non-zero integer numbers are converted to true in a boolean context, so you have true || true, which is true. true can be converted to an integer (1), so plusAttacklRange will be 1.
What are you even trying to accomplish? Generating a random number within a range?
God, no. || is an operator that takes two boolean operands and returns true if one of them is true. Non-zero integer numbers are converted to true in a boolean context, so you have true || true, which is true. true can be converted to an integer (1), so plusAttacklRange will be 1.
What are you even trying to accomplish? Generating a random number within a range?
int plusAttacklRange = iStalkRange + 1 || iStalkRange + 2;
|| is logical OR. It returns true if one of the sides are true. You have not used boolean (true/false) values but any non-zero value will be treated as true, zero treated as false. That means iStalkRange + 1 || iStalkRange + 2 is the same as true || true, which is true. true converted to an integer is 1 so plusAttacklRange will get the value 1.
|| is logical OR. It returns true if one of the sides are true. You have not used boolean (true/false) values but any non-zero value will be treated as true, zero treated as false. That means iStalkRange + 1 || iStalkRange + 2 will be handled as true || true which is true. true converted to an integer is 1 so plusAttacklRange will get the value 1.
so how could i accomplish plusAttackRange be 41 or 42?
void Stalker()
{
MShWnd = FindProcessWindow();
while(!bStalker)
{
Sleep(10);
if (iCharX() < (iStalkRange) + iMobX())
{
if (bWalk == true)
{
Sleep(100);
keybd_event(VK_LEFT,0, KEYEVENTF_KEYUP,0); // Left Release
Sleep(50);
keybd_event(VK_RIGHT,0,0 , 0);//Press Right
}
}
elseif (iCharX() > (iStalkRange) - iMobX())
{
if (bWalk == true)
{
Sleep(100);
keybd_event(VK_RIGHT,0, KEYEVENTF_KEYUP,0); // Right Release
Sleep(50);
keybd_event(VK_LEFT,0,0 , 0);//Press Left
}
}
}
}
what this does is basicly CharX follows MobX by moving right or left (it is a game)
and what im trying to do here its that when CharX gets to MobX coords -iStalkRange or + iStalkRange (depends wether you are going right or left)
press a key.
but my problem is that if i use
if (iCharX() == (iStalkRange) - iMobX())
{
if (bWalk == true)
{
//key press
}
my charX changes really fast so it is unlikely that it will ever be == (iStalkRange) - iMobX()
so what im trying to do here is make plusAttacklRange stand for iStalkRange or iStalkRange+1 or iStalkRange+2(like +40 but i only did +1, +2 to set example)
so then if i write
if (iCharX() == (plusAttacklRange ) - iMobX())
{
if (bWalk == true)
{
//key press
}
it has more chances for my Charx of being == (plusAttacklRange ) - iMobX()
constint stalkRange=2;
if (charX>mobX && charX-mobX<=stalkRange) //character is on the right and within range
if (charX<mobX && mobX-charX<=stalkRange) //character is on the left and within range
if (abs(charX-mobX)<=stalkRange) //character is on either side, but within range