SRL Archive - OSR Help

TPA help


grats

2011-03-07 01:58:47

So I was trying to make a tiny script that would right click something and then select an option

I learned bitmaps from doing so, pretty well from the tutorial..


The TPA tutorial I don't understand at all.

If someone can help me I have msn, aim… this thread & PM obviously

I'm going for a script to right click a farmer and then pickpocket them (that's all, no randoms or anything etc)

I'd like to learn how to do this so I can apply it to other things, train said he can help but he's very busy doing models for RRL etc

thanks to anyone who can help!

NCDS

2011-03-07 02:01:13

Do you have any code written for it so far?

I can help you a bit before I go to bed, they're quite simple once you get the concept of working with arrays.

grats

2011-03-07 02:08:40

From: NCDS
Do you have any code written for it so far?

I can help you a bit before I go to bed, they're quite simple once you get the concept of working with arrays.


No I tried with bitmaps but I guess it was dumb because of how much the farmer moves & his bitmap pretty much changes when he turns directions

yea train said it would take like 2 minutes to write something that simple lol.. I honestly have no idea where to start with arrays, I was looking through a lot of scripts that had it (via the search) so I can kind of see what they do, but don't know how to create

NCDS

2011-03-07 02:15:46

From: grats
No I tried with bitmaps but I guess it was dumb because of how much the farmer moves & his bitmap pretty much changes when he turns directions

yea train said it would take like 2 minutes to write something that simple lol.. I honestly have no idea where to start with arrays, I was looking through a lot of scripts that had it (via the search) so I can kind of see what they do, but don't know how to create


The functions in WizzyPLugin are your best friend when working with arrays. I strongly urge you to check them out.


If your unsure of what an array actually is; it's just a group of the specified data type. (probably not the best way to word it)

So you want to use TPointArray's. All it is, is an array (group) of TPoints (points on the screen).

You would gather the array by using one of the FindColors() functions in WizzyPlugin.

There are also a bunch of nice functions in there to manipulate the arrays for most anything you need.

Sorry for the quick run through, but I reeaally have to get to bed.

Good luck. :)

If you want; try throwing something together tonight and I can look it over tomorrow for you.

grats

2011-03-07 02:27:16

From: NCDS
The functions in WizzyPLugin are your best friend when working with arrays. I strongly urge you to check them out.


If your unsure of what an array actually is; it's just a group of the specified data type. (probably not the best way to word it)

So you want to use TPointArray's. All it is, is an array (group) of TPoints (points on the screen).

You would gather the array by using one of the FindColors() functions in WizzyPlugin.

There are also a bunch of nice functions in there to manipulate the arrays for most anything you need.

Sorry for the quick run through, but I reeaally have to get to bed.

Good luck. :)

If you want; try throwing something together tonight and I can look it over tomorrow for you.


Yea I (now) understand the arrays better, lots of points on a screen in a group etc, makes sense


//-----------------------------------------------------------------//
//-- Scar Standard Resource Library --//
//-- WizzyPlugin routines --//
//-----------------------------------------------------------------//
//-- By: Boreas, Nielsie95, MastaRaymond, Killerdou and Wizzup? --//
//-----------------------------------------------------------------//

// * procedure tSwap(var a, b: TPoint);
// * procedure tpaSwap(var a, b: TPointArray);
// * procedure SwapE(var a, b: Extended);
// * procedure RAaSTPAEx(var a: TPointArray; const w, h: Integer);
// * procedure RAaSTPA(var a: TPointArray; const Dist: Integer);
// * function NearbyPointInArrayEx(const P: TPoint; w, h:Integer; a: TPointArray): Boolean;
// * function NearbyPointInArray(const P: TPoint; Dist:Integer; a: TPointArray): Boolean;
// * function ReArrangeandShortenArrayEx(a: TPointArray; w, h: Integer): TPointArray;
// * function ReArrangeandShortenArray(a: TPointArray; Dist: Integer): TPointArray;
// * function TPAtoATPAEx(TPA: TPointArray; w, h: Integer): T2DPointArray;
// * function TPAtoATPA(TPA: TPointArray; Dist: Integer): T2DPointArray;
// * procedure SortTPAFrom(var a: TPointArray; const From: TPoint);
// * procedure SortATPAFrom(var a: T2DPointArray; const From: TPoint);
// * procedure SortATPAFromFirstPoint(var a: T2DPointArray; const From: TPoint);
// * procedure InvertTPA(var a: TPointArray);
// * procedure InvertATPA(var a: T2DPointArray);
// * function MiddleTPAEx(TPA: TPointArray; var x, y: Integer): Boolean;
// * function MiddleTPA(tpa: TPointArray): TPoint;
// * procedure SortATPASize(var a: T2DPointArray; const BigFirst: Boolean);
// * procedure SortATPAFromSize(var a: T2DPointArray; const Size: Integer; CloseFirst: Boolean);
// * function CombineTPA(Ar1, Ar2: TPointArray): TPointArray;
// * function CombineIntArray(Ar1, Ar2: TIntegerArray): TIntegerArray;
// * function InIntArrayEx(a: TIntegerArray; var Where: Integer; const Number: Integer): Boolean;
// * function InIntArray(a: TIntegerArray; Number: Integer): Boolean;
// * procedure ClearSameIntegers(var a: TIntegerArray);
// * procedure ClearSameIntegersAndTPA(var a: TIntegerArray; var p: TPointArray);
// * function SplitTPAEx(arr: TPointArray; w, h: Integer): T2DPointArray;
// * function SplitTPA(arr: TPointArray; Dist: Integer): T2DPointArray;
// * procedure FilterPointsPie(var Points: TPointArray; const SD, ED, MinR, MaxR: Extended; Mx, My: Integer);
// * function RemoveDistTPointArray(x, y, dist: Integer; ThePoints: TPointArray; RemoveHigher: Boolean): TPointArray;
// * function GetTPABounds(TPA: TPointArray): TBox;
// * function FindTPAinTPA(SearchTPA, TotalTPA: TPointArray; var Matches: TPointArray): Boolean;
// * function FindTextTPAinTPA(Height : integer; SearchTPA, TotalTPA: TPointArray; var Matches: TPointArray): Boolean;
// * function FindGapsTPA(TPA: TPointArray; MinPixels: Integer): T2DPointArray;
// * Function CreateTPAFromBMP(BmpDC: HDC): TPointArray;
// * procedure SortCircleWise(var tpa: TPointArray; const mx, my, StartDegree, EndDegree: Integer; SortUp: Boolean);
// * procedure LinearSort(var tpa: TPointArray; const mx, my, Deg: Integer; SortUp: Boolean);
// * Function MergeATPA(ATPA : T2DPointArray) : TPointArray;

{*******************************************************************************
procedure tSwap(var a, b: TPoint);
Description: Swaps the two TPoints.
*******************************************************************************}


{*******************************************************************************
procedure tpaSwap(var a, b: TPointArray);
Description: Swaps the two TPointArrays.
*******************************************************************************}


{*******************************************************************************
procedure SwapE(var a, b: Extended);
Description: Swaps the two Extended values.
*******************************************************************************}


{*******************************************************************************
procedure RAaSTPAEx(var a: TPointArray; const w, h: Integer);
Description: Leaves one point per box with side lengths W and H to the TPA.
*******************************************************************************}


{*******************************************************************************
procedure RAaSTPA(var a: TPointArray; const Dist: Integer);
Description: Leaves one point per box with the side length Dist.
*******************************************************************************}


{*******************************************************************************
function NearbyPointInArrayEx(const P: TPoint; w, h:Integer; a: TPointArray): Boolean;
Description: Returns true if the point P is near a point in the TPA a with the
max X and Y distances W and H.
*******************************************************************************}


{*******************************************************************************
function NearbyPointInArray(const P: TPoint; Dist:Integer; a: TPointArray): Boolean;
Description: Returns true if the point P is near a point in the TPA a with the
max distance Dist.
*******************************************************************************}


{*******************************************************************************
function ReArrangeandShortenArrayEx(a: TPointArray; w, h: Integer): TPointArray;
Description: Results the TPointArray a with one point per box with side lengths
W and H left.
*******************************************************************************}


{*******************************************************************************
function ReArrangeandShortenArray(a: TPointArray; Dist: Integer): TPointArray;
Description: Results the TPointArray a with one point per box with side length
Dist left.
*******************************************************************************}


{*******************************************************************************
function TPAtoATPAEx(TPA: TPointArray; w, h: Integer): T2DPointArray;
Description: Splits the TPA to boxes with sidelengths W and H and results
them as a T2DPointArray.
*******************************************************************************}


{*******************************************************************************
function TPAtoATPA(TPA: TPointArray; Dist: Integer): T2DPointArray;
Description: Splits the TPA to boxes with sidelength Dist and results
them as a T2DPointArray.
*******************************************************************************}


{*******************************************************************************
procedure SortTPAFrom(var a: TPointArray; const From: TPoint);
Description: Sorts the TPointArray a from the point From.
Closest one to the point is [0], second closest is [1] etc.
*******************************************************************************}


{*******************************************************************************
procedure SortATPAFrom(var a: T2DPointArray; const From: TPoint);
Description: Sorts the T2DPointArray a from the point From.
*******************************************************************************}


{*******************************************************************************
procedure SortATPAFromFirstPoint(var a: T2DPointArray; const From: TPoint);
Description: Sorts the T2DPointArray a from the point From.
*******************************************************************************}


{*******************************************************************************
procedure InvertTPA(var a: TPointArray);
Description: Inverts / Reverts the TPointArray a.
*******************************************************************************}


{*******************************************************************************
procedure InvertATPA(var a: T2DPointArray);
Description: Inverts / Reverts the T2DPointArray a.
*******************************************************************************}


{*******************************************************************************
function MiddleTPAEx(TPA: TPointArray; var x, y: Integer): Boolean;
Description: Stores the coordinates of the middle of the TPointArray a to X & Y.
*******************************************************************************}


{*******************************************************************************
function MiddleTPA(tpa: TPointArray): TPoint;
Description: Returns the middle of the TPointArray tpa.
*******************************************************************************}


{*******************************************************************************
procedure SortATPASize(var a: T2DPointArray; const BigFirst: Boolean);
Description: Sorts the T2DPointArray a from either largest or smallest, by the
amount of points in the TPAs.
*******************************************************************************}


{*******************************************************************************
function CombineTPA(Ar1, Ar2: TPointArray): TPointArray;
Description: Combines the TPointArrays Ar1 and Ar2, and results the combination.
*******************************************************************************}


{*******************************************************************************
function CombineIntArray(Ar1, Ar2: TIntegerArray): TIntegerArray;
Description: Combines the TIntegerArrays Ar1 and Ar2, and results the
combination.
*******************************************************************************}


{*******************************************************************************
function InIntArrayEx(a: TIntegerArray; var Where: Integer; const Number: Integer): Boolean;
Description: Returns true if the integer Number was found in the integer array
a, and stores the index to Where.
*******************************************************************************}


{*******************************************************************************
function InIntArray(a: TIntegerArray; Number: Integer): Boolean;
Description: Returns true if the integer Number was found in the integer array a.
*******************************************************************************}


{*******************************************************************************
procedure ClearSameIntegers(var a: TIntegerArray);
Description: Clears the duplicates in the integer array a.
*******************************************************************************}


{*******************************************************************************
procedure ClearSameIntegersAndTPA(var a: TIntegerArray; var p: TPointArray);
Description: Clears the duplicates in the integer array a and the TPointArray p.
*******************************************************************************}


{*******************************************************************************
function SplitTPAEx(arr: TPointArray; w, h: Integer): T2DPointArray;
Description: Splits the points with max X and Y distances W and H to their
own TPointArrays.
*******************************************************************************}


{*******************************************************************************
function SplitTPA(arr: TPointArray; Dist: Integer): T2DPointArray;
Description: Splits the points with max distance Dist to their own TPointArrays.
Dist 1 puts the points that are next to eachother to their own arrays.
*******************************************************************************}


{*******************************************************************************
procedure FilterPointsPie(var Points: TPointArray; const SD, ED, MinR, MaxR: Extended; Mx, My: Integer);
Description: Removes the points in the TPointArray Points that are not within
the degrees SD (StartDegree) and ED (EndDegree) and the distances
MinR (MinRadius) and MaxR (MaxRadius) from the origin (Mx, My).
*******************************************************************************}


{*******************************************************************************
function RemoveDistTPointArray(x, y, dist: Integer; ThePoints: TPointArray; RemoveHigher: Boolean): TPointArray;
Description: Removes the points that are inside or outside the distance Dist
from the point (x, y) from the TPointArray ThePoints.
*******************************************************************************}


{*******************************************************************************
function GetTPABounds(TPA: TPointArray): TBox;
Description: Returns the boundaries of the TPA as a TBox.
*******************************************************************************}


{*******************************************************************************
function FindTPAinTPA(SearchTPA, TotalTPA: TPointArray; var Matches: TPointArray): Boolean;
Description: Looks for the TPA SearchTPA in the TPA TotalTPA and returns
the matched points to the TPA Matches. Returns true if there were atleast one
match(es).
*******************************************************************************}


{*******************************************************************************
function FindTextTPAinTPA(Height: Integer; SearchTPA, TotalTPA: TPointArray; var Matches: TPointArray): Boolean;
Description: Read the description of FindTPAinTPA. Additional Height parameter.
*******************************************************************************}


{*******************************************************************************
function FindGapsTPA(TPA: TPointArray; MinPixels: Integer): T2DPointArray;
Description: Finds the possible gaps in the TPointArray TPA and results the
gaps as a T2DPointArray. Considers as a gap if the gap length is >= MinPixels.
Only horizontal, sorry folks.
*******************************************************************************}


{*******************************************************************************
Function CreateTPAFromBMP(BmpDC: HDC): TPointArray;
Description: Creates a TPointArray of the bitmap dc BmpDC.
Use GetBitmapDC to get the dc.
*******************************************************************************}


{*******************************************************************************
procedure SortCircleWise(var tpa: TPointArray; mx, my, Deg: Integer; SortUp: Boolean);
Description: Sorts all points in tpa by distance from degree (Deg) and distance from
mx and my. Sortup will return closest distance to mx and my first.
Distance will be sorted first (RadialWalk style).
*******************************************************************************}


{*******************************************************************************
procedure LinearSort(var tpa: TPointArray; mx, my, Deg: Integer; SortUp: Boolean);
Description: Sorts all points in tpa by distance from degree (Deg) and distance from
mx and my. Sortup will return closest distance to mx and my first.
Degree will be sorted first (LinearWalk style).
*******************************************************************************}


{*******************************************************************************
Function MergeATPA(ATPA: T2DPointArray): TPointArray;
Description: Merges the TPointArrays of the T2DPointArray ATPA in to one TPA.
*******************************************************************************}


That's my wizzy plugin I don't see anything for color, you'll have to show me tomorrow, I'm in no rush I do school & work at my computer :P

I'll be reading through this whole wizzyplugin thing to see what the different things do


edit:
I don't understand all the swaps stuff



The TPA's are generated by running something? and not like finding colors with simba/scar colorpicker & creating a bitmap from a picture?

so they're less manual work?

Flight

2011-03-07 02:45:34

Boreas helped me to get a better understanding of TPAs, I'd recommend you hit him up with some questions, he's very helpful. :)

TomTuff

2011-03-07 03:03:02

Gratz, I have to go soon, but here's a run down:

I had the same confusions as you when I learned about TPAs. TPAs are generated by finding a color within a certain tolerance within a box on the client screen. Every on screen coord within the color tolerance is added to the array (as a point, Eg (33, 44)). Using functions like SplitTPA or TPAtoATPA, you can split the TPA into an ATPA - an array of array of TPoint. Then, using some sort of loop, you can either get a random point in the bounds of the TPA, or use MiddleTPA to get the center point of the bounds (my preffered method). You can then mouse to it, check uptext, etc. and break from the loop when you succeed.

Add me on msn (tommyk1995@gmail.com) and I can help you out in around 18 hours from now if that wasn't a good explanation.

grats

2011-03-07 03:26:08

From: Flight
Boreas helped me to get a better understanding of TPAs, I'd recommend you hit him up with some questions, he's very helpful. :)


Will do thanks

From: TomTuff
Gratz, I have to go soon, but here's a run down:

I had the same confusions as you when I learned about TPAs. TPAs are generated by finding a color within a certain tolerance within a box on the client screen. Every on screen coord within the color tolerance is added to the array (as a point, Eg (33, 44)). Using functions like SplitTPA or TPAtoATPA, you can split the TPA into an ATPA - an array of array of TPoint. Then, using some sort of loop, you can either get a random point in the bounds of the TPA, or use MiddleTPA to get the center point of the bounds (my preffered method). You can then mouse to it, check uptext, etc. and break from the loop when you succeed.

Add me on msn (tommyk1995@gmail.com) and I can help you out in around 18 hours from now if that wasn't a good explanation.


Ah yea that gives me a better idea how they work, thanks

I added you, still not sure how to apply them, but I'm learning what they are exactly (which is good to learn first) pretty much fully understand what TPA's are, just not how to create

KingKong

2011-03-10 00:02:58

This should clarify most of your TPA doubts: http://villavu.com/forum/showthread.php?t=42428

and maybe this one too: http://villavu.com/forum/showthread.php?t=33111