Code:
public boolean withinDistance(int distance, Player otherPlr) {
if(otherPlr == null) return false;
if(heightLevel != otherPlr.heightLevel)
return false;
int deltaX = otherPlr.absX-absX, deltaY = otherPlr.absY-absY;
return deltaX <= distance && deltaX >= ((distance + 0) * -1) && deltaY <= distance && deltaY >= ((distance + 0) * -1);
}
okay well in EVERY server, there is a glitch that u can attack players that are at a diagonal if ur attacking with melee
ie:
xoo
oxo
ooo
o = blank
x = player
there attacking diagonal, in rs u can only attack north/east/west/south with melee, i was just wondering how to fix this...
after looking thru the code... its pretty complex for me to understand lol
heres wat i got so far
Code:
if(otherPlr == null) return false;
if(heightLevel != otherPlr.heightLevel)
return false;
if player doesn't exist, cancles the void
if they arn't near u, cancles the void
Code:
int deltaX = otherPlr.absX-absX, deltaY = otherPlr.absY-absY;
an int to shortest the code up a little
Code:
return deltaX <= distance && deltaX >= ((distance + 0) * -1) && deltaY <= distance && deltaY >= ((distance + 0) * -1);
this is the return statement using some form of math.. my gues is calcules since i barely understand it its a crazy void lol this part i barely understand
ANYONE THINK U WANNA WASTE A FEW MINUTES TO FIX THIS?
EDIT: a theory...
Code:
public int getNextFollowingDirection(Player player) {
int dir = -1;
boolean goNorth = false, goSouth = false, goEast = false, goWestWhereTheCowboysRoam = false;
if(absX < player.absX)
goEast = true;
else if(absX > player.absX)
goWestWhereTheCowboysRoam = true;
if(absY < player.absY)
goNorth = true;
else if(absY > player.absY)
goSouth = true;
if(!goSouth && !goNorth && !goEast && !goWestWhereTheCowboysRoam)
return -1;
if(withinDistance(1, player))
return -1;
if(!withinDistance(8, player) || player.playerLevel[3] <= 0) {
followPlayer = null;
}
if(goNorth && goEast)
dir = 2;
else if(goNorth && goWestWhereTheCowboysRoam)
dir = 14;
else if(goSouth && goEast)
dir = 6;
else if(goSouth && goWestWhereTheCowboysRoam)
dir = 10;
else if(goNorth)
dir = 0;
else if(goEast)
dir = 4;
else if(goWestWhereTheCowboysRoam)
dir = 12;
else if(goSouth)
dir = 8;
dir >>= 1;
currentX += misc.directionDeltaX[dir];
currentY += misc.directionDeltaY[dir];
absX += misc.directionDeltaX[dir];
absY += misc.directionDeltaY[dir];
return dir;
}
perhaps using some stuff in this u can use it to check if there south/north-east/west?