Nadeem
2009-06-28 06:39:33
Hi,
I've thought of a new way of making accurate decisions for inventory related features, not sure though if its already been done and possible failed?
Anyway, what it does it first, grab a count of black colors inside the inventory spot and also choose 1 random color that is not related to the brown background, and counts the number of those colors and saves that. Then when you can relocate your items to what ever spots, and using the color indexes it will locate the item we are looking for, and I chose black and a random color as a failsafe kinda thing.
It can almost be like color reflection, since all the items have static colors, we can like store color arrays for the items and load em up. We don't necessarily have to add the exact amount aswell, we can make it a range of -3, +3, and if its between that range it 'assumes' and if it is wrong it will update it self :)
I've been already using it for my new script, and works pretty much flawlessly.
You don't gotta try it unless you wanna, I've just copied and pasted from what I'm using right now so you can see whats being done.
Please let me know what you think :) ~ Thanks!
~NS
I've thought of a new way of making accurate decisions for inventory related features, not sure though if its already been done and possible failed?
Anyway, what it does it first, grab a count of black colors inside the inventory spot and also choose 1 random color that is not related to the brown background, and counts the number of those colors and saves that. Then when you can relocate your items to what ever spots, and using the color indexes it will locate the item we are looking for, and I chose black and a random color as a failsafe kinda thing.
It can almost be like color reflection, since all the items have static colors, we can like store color arrays for the items and load em up. We don't necessarily have to add the exact amount aswell, we can make it a range of -3, +3, and if its between that range it 'assumes' and if it is wrong it will update it self :)
I've been already using it for my new script, and works pretty much flawlessly.
You don't gotta try it unless you wanna, I've just copied and pasted from what I'm using right now so you can see whats being done.
Please let me know what you think :) ~ Thanks!
function CountColorEx(BCol, BTol: Integer; B: TBox; var Col: Integer): Integer;
var
P: TPoint;
label
NewPoint;
begin
NewPoint:
P.x := RandomRange(B.x1, B.x2);
P.y := RandomRange(B.y1 + 19, B.y2);
Col := GetColor(P.x, P.y);
if (SimilarColors(BCol, Col, BTol) or (Col = 65536)) then goto NewPoint;
Result := CountColor(Col, B.x1, B.y1 + 19, B.x2, B.y2);
ns_Debug('CountColorEx', ' | Point.x: ' + IntToStr(P.x) +
' | Point.y: ' + IntToStr(P.y) +
' | Color: ' + IntToStr(Col) +
' | Result: ' + IntToStr(Result));
end;
function GetInventory: TStringArray;
var
B: TBox;
I, R, T: Integer;
begin
T := GetSystemTime;
for I := 1 to 28 do
if ExistsItem(I) then
begin
MMouseItem(I);
Wait(100 + Random(100));
with Fighter[Tzhaar.Player] do
begin
B := InvBox(I);
Inven[R].ID := I;
Inven[R].Item := Capitalize(Between(' ', ' /', rs_GetUpText));
Inven[R].ColRec := CountColor(16 shl 12, B.x1, B.y1 + 19, B.x2, B.y2);
Inven[R].PColRec := CountColorEx(3424328, 19, B, Inven[R].PCol);
SetLength(Result, R + 1);
Result[R] := Inven[R].Item;
ns_Debug('GetInventory', 'Result[' + IntToStr(R) + '] = ' + Result[R] +
' | ColRec = ' + IntToStr(Inven[R].ColRec));
R := R + 1;
end;
end;
ns_Debug('GetInventory', 'List Took: ' + IntToStr(GetSystemTime - T) + 'ms');
end;
function GetWeapons: TStringArray;
var
G: TStringArray;
I, II, R: Integer;
begin
G := GetInventory;
for I := 0 to High(G) - 1 do
begin
for II := 0 to High(Fighter[Tzhaar.Player].Weapons) do
begin
if (pos(Fighter[Tzhaar.Player].Weapons[II], G[I]) > 0) then
begin
SetLength(Result, R + 1);
Result[R] := G[I];
R := R + 1;
end;
end;
end;
for I := 0 to R - 1 do
ns_Debug('GetWeapons', 'Result[' + IntToStr(I) + ']: ' + Result[I]);
end;
~NS