Log in

View Full Version : CTS2 help



Footy
08-13-2012, 01:16 PM
Hey guys, yesterday, brandon made me an awesome CTS2 function to find my bank, but it doesent actually find the bank... It moves the mouse about 5 pixels below the bank onto the floor, and eventually times out. Seeing how I have no knowledge of CTS2, I cant really fix it myself, even though i tried to update the colors in the function to no avail. If someone could show me what values have to be updated, and what I'd change them to, it would be great! Here is the function:
Function OpenBankCustom: Boolean; //Credit to Brandon for fixing and beefing up this function.
var
B: TBox;
Location: TPoint;
CTS, I, L: Integer;
ATPA: T2DPointArray;
TPA, TPA2: TPointArray;
begin
CTS := GetColorToleranceSpeed;
ColorToleranceSpeed(2);
SetColorSpeed2Modifiers(0.02, 2.40);
FindColorsTolerance(TPA, 8434655, MSX1, MSY1, MSX2, MSY2, 15);
If (Length(TPA) < 1) then Exit;

SortTPAFrom(TPA, Point(MSCX, MSCY));

ATPA:= TPAToATPAEx(TPA, 31, 190);
L := Length(ATPA);
If (L < 1) then Exit;

SetColorSpeed2Modifiers(0.11, 0.20);
SortATPAFromFirstPoint(ATPA, Point(MSCX, MSCY));

For I := 0 To L Do
begin
B := GetTPABounds(ATPA[I]);
with B do
begin
If (FindColorsTolerance(TPA2, 4937053, MSX1, MSY1, MSX2, MSY2, 20)) then
begin
Location := MiddleTPA(TPA2);
MMouse(Location.X, Location.Y, 0, 0);
If (WaitUptextMulti(['ank', 'Bank', 'ooth', 'booth', 'ank boo'], 600)) then
begin
ClickMouse2(MOUSE_LEFT);
Result := True;
ColorToleranceSpeed(CTS);
SetColorSpeed2Modifiers(0.2, 0.2);
Exit;
end;
end;
end;
end;
ColorToleranceSpeed(CTS);
SetColorSpeed2Modifiers(0.2, 0.2);
end;

This is my screen on ACA, I got it to highlight the bankers perfectly, there really isnt anything else on the bank booth to highlight, since the golden stuff highlights the walls and floors, and the brown highlights doors and abunch of whacky stuff. Note: This is the angle that the camera will always be turned, if it makes a difference.
http://i0.simplest-image-hosting.net/picture/untitled196.png#REMEMBER-TO-LINK-SIMPLEST-IMAGE-HOSTING.NET-WHEN-HOTLINKING

NKN
08-13-2012, 01:21 PM
SetColorSpeed2Modifiers(0.02, 2.40);
FindColorsTolerance(TPA, 8434655, MSX1, MSY1, MSX2, MSY2, 15);
Should be:
SetColorSpeed2Modifiers(3.17, 0.73);
FindColorsTolerance(TPA, 8684913, MSX1, MSY1, MSX2, MSY2, 11);

Footy
08-13-2012, 01:22 PM
ahh, those are hue and sat mods then! Thanks NKN! Ill try this, and ill let you know what happens!
E: It moves the mouse to the floor, clicks, then just sits there, not executing, not doing anything. I think its this line.
If (FindColorsTolerance(TPA2, 4937053, MSX1, MSY1, MSX2, MSY2, 20)) then
Now I dont wanna go editing this and screwing it up, but if I change the color in there to the color in my ACA, should it work?

CephaXz
08-13-2012, 01:25 PM
SetColorSpeed2Modifiers(0.11, 0.20);
SortATPAFromFirstPoint(ATPA, Point(MSCX, MSCY));

For I := 0 To L Do
begin
B := GetTPABounds(ATPA[I]);
with B do
begin
If (FindColorsTolerance(TPA2, 4937053, MSX1, MSY1, MSX2, MSY2, 20)) then


I think it should be this part. Not sure what's the first part for.

Footy
08-13-2012, 01:29 PM
^ Would I change those modifiders to my sat and hue mods, and update the color in the last line?

NKN
08-13-2012, 01:30 PM
It's the same thing as above, just checks again.
Same things apply as to what I did above.

CephaXz
08-13-2012, 01:31 PM
Hue and sat to modifiers. Color and tolerance in FindColorsTolerance. As what I understand, it will move your mouse in the middle of this TPA, regardless of size.

EDIT: I would make ATPA for more accuracy.

Footy
08-13-2012, 01:34 PM
I cant even make a TPA! Ill try you guy's suggestions, and let you know what happens.

Brandon
08-13-2012, 01:45 PM
LOL? What?! It does not just check again lol..

First it finds the creamish-brown looking colour. This is almost the entire area.. It grabs a box surrounding it.
Then it searches for the dark colour inside of the previously found area.

That's how it finds the bank booth. If your angle is too low, it's not going to be the same because the brown isn't going to be inside the previous colour.


Replace previous colour with "Cream" I didn't wanna say that because it sounds so wrong! Brown in cream -__-

CephaXz
08-13-2012, 01:49 PM
^ Now the first part makes sense :p

Footy
08-13-2012, 01:50 PM
1: Thats an interesting method of finding the bank!
2: I dont want the angle too high, because then finding the tanner will be hard. Is there an SRL function to make the camera angle in the middle? I've seen SRL_ANGLE_HIGH and SRL_ANGLE_LOW but no SRL_ANGLE_MID...

riwu
08-13-2012, 01:57 PM
1: Thats an interesting method of finding the bank!
2: I dont want the angle too high, because then finding the tanner will be hard. Is there an SRL function to make the camera angle in the middle? I've seen SRL_ANGLE_HIGH and SRL_ANGLE_LOW but no SRL_ANGLE_MID...
Because there is no way to detect the angle w/o using injection. You could create your own function by setting it to high/low first then hold the up/down arrow key for a certain period of time.

Brandon
08-13-2012, 02:03 PM
You really should learn how it works before using it.. This one will grab the blackish colours and look for the grey colour of the window within the black.


Function OpenBankCustom: Boolean; //Credit to Brandon for fixing and beefing up this function.
var
B: TBox;
Location: TPoint;
CTS, I, L: Integer;
ATPA: T2DPointArray;
TPA, TPA2: TPointArray;
begin
CTS := GetColorToleranceSpeed;
ColorToleranceSpeed(2);
SetColorSpeed2Modifiers(3.79, 0.91);
FindColorsTolerance(TPA, 4210740, MSX1, MSY1, MSX2, MSY2, 11);
If (Length(TPA) < 1) then Exit;

SortTPAFrom(TPA, Point(MSCX, MSCY));

ATPA:= TPAToATPAEx(TPA, 61, 67); //The size of each booth.. The dark part at the lowest angle.
L := Length(ATPA);
If (L < 1) then Exit;

SetColorSpeed2Modifiers(0.25, 0.41);
SortATPAFromFirstPoint(ATPA, Point(MSCX, MSCY));

For I := 0 To L Do
begin
B := GetTPABounds(ATPA[I]);
with B do
begin
If (FindColorsTolerance(TPA2, 9212318, MSX1, MSY1, MSX2, MSY2, 19)) then
begin
Location := MiddleTPA(TPA2);
MMouse(Location.X, Location.Y, 0, 0);
If (WaitUptextMulti(['ank', 'Bank', 'ooth', 'booth', 'ank boo'], 600)) then
begin
ClickMouse2(MOUSE_LEFT);
Result := True;
ColorToleranceSpeed(CTS);
SetColorSpeed2Modifiers(0.2, 0.2);
Exit;
end;
end;
end;
end;
ColorToleranceSpeed(CTS);
SetColorSpeed2Modifiers(0.2, 0.2);
end;

Footy
08-13-2012, 02:06 PM
I understand bits of it, but CTS2 is a bit out of my league at the moment... Ill try this and let you know how it goes.
Works brilliantly, and I know how to adjust the colors and some other stuff if it breaks again. Thanks!