SRL Archive - Senior Scripts and Snippets

Mainscreen walking...


BenLand100

2007-12-26 19:02:18

You know, in going with the idea of being more human to protect your accounts (since we are about to loose unbalanced trades). its entirely possible to (with the new SMART) create a MainScreen walking method. If there is any interest, I could write the method that converts a tile position to a main screen position.

Special Ed

2007-12-26 20:04:32

DO IT!

That would definitely be a big push as far as making our scripts more human, because what person uses the minimap to walk 3 tiles?

mastaraymond

2007-12-27 12:53:57

From: Special Ed
DO IT!

That would definitely be a big push as far as making our scripts more human, because what person uses the minimap to walk 3 tiles?


If you can make it with Reflection, could you make it work without reflection to? :p

MMToMS? Would be pretty cool :spot:

Special Ed

2007-12-27 13:18:28

I mean I tried doing this just through SCAR a while back and it worked decently well, so I'm sure with Benland working on it and the power of Java he can make it work flawlessly.

Ruroken

2007-12-27 14:28:27

:D

Do It!

BenLand100

2007-12-27 15:06:46

From: mastaraymond
If you can make it with Reflection, could you make it work without reflection to? :p

MMToMS? Would be pretty cool :spot:

Without reflection would be much harder, nay impossible with the accuracy I'm talking about. MMtoMS, sure, why not :p

Sumilion

2007-12-27 15:36:39

Benjamin Land, will you be my wife in holy matrimony ?

Yakman

2007-12-27 18:00:30

you can take mine if you want, but I'v heard you've got loads of time to kill the days, perhaps finding an alternate set of formulas to change tiles to main screen coordinates is something you might like.

change the names to fit you own, and give credit to jagex, because this is very simply a copy of the maths they use in the client

/**
* calculates the height of the terrain at x,y
*/
public int calcTerrainHeight(int x, int y) {
int x1 = x >> 7;
int y1 = y >> 7;
if(x1 < 0 || y1 < 0 || x1 > 103 || y1 > 103)
return 0;
int plane = ac.getClient().getPlane();
int x2 = x & 127;
int y2 = y & 127;
if(plane < 3 && (ac.getClient().getGroundByteArray()[1][x1][y1] & 2) == 2)
plane++;

int calculatedX1 = (ac.getClient().getGroundIntArray()[plane][x1 + 1][y1 + 1] * x2 + (128 - x2) * ac.getClient().getGroundIntArray()[plane][x1][y1 + 1]) >> 7;
int calculatedX2 = (ac.getClient().getGroundIntArray()[plane][x1 + 1][y1] * x2 + (128 - x2) * ac.getClient().getGroundIntArray()[plane][x1][y1]) >> 7;
return y2 * calculatedX1 + calculatedX2 * (128 - y2) >> 7;
}

/**
* Calculates the main screen position of the x,y
* @param height The height of object you're calculating, 0 is on the floor
* @return The position, or -1, -1 if it its out of bounds
*/
public Point calcScreenPos(int x, int y, int height) {
if(x < 128 || y < 128 || x > 13056 || y > 13056)
return new Point(-1, -1);

int z = calcTerrainHeight(x, y) - Math.abs(height);
x -= ac.getClient().getCameraX();
y -= ac.getClient().getCameraY();
z -= ac.getClient().getCameraZ();

int curveY1 = ac.getClient().getCurveArrayX()[ac.getClient().getCameraCurveY()];
int curveY2 = ac.getClient().getCurveArrayY()[ac.getClient().getCameraCurveY()];
int curveX1 = ac.getClient().getCurveArrayX()[ac.getClient().getCameraCurveX()];
int curveX2 = ac.getClient().getCurveArrayY()[ac.getClient().getCameraCurveX()];

int tempX = x * curveX2 + y * curveX1 >> 16;
y = y * curveX2 - x * curveX1 >> 16;
x = tempX;

tempX = curveY2 * z - y * curveY1 >> 16;
y = curveY1 * z + y * curveY2 >> 16;
z = tempX;

if(y < 50)
return new Point(-1, -1);
x = (x << 9) / y + 256;
y = 167 + (z << 9) / y;

if(x > 516 || y > 338 || y < 0 || x < 0)
return new Point(-1, -1);
return new Point(x, y);
}

BenLand100

2007-12-27 19:25:12

From: Yakman
you can take mine if you want, but I'v heard you've got loads of time to kill the days, perhaps finding an alternate set of formulas to change tiles to main screen coordinates is something you might like.

change the names to fit you own, and give credit to jagex, because this is very simply a copy of the maths they use in the client

You were just a little too late ;) Anyway, I wrote my own 3d projection, its not as hard as you would think. Check the Smart downloads section.