SRL Archive - SRL Bugs

Cast Results False if Spell is Already Set to Autocast


YoHoJo

2011-12-10 18:17:42

function Cast(Spell: string; AutoCast: Boolean): Boolean;
var
X, Y: Integer;
B: TBox;
SInfo: TSpell;
begin
if not LoggedIn then
Exit;

SInfo := GetSpellInfo(Spell);
if AutoCast then
if not SInfo.AutoCast then
begin
srl_Warn('Cast', Spell + ' is not autocast-able', warn_AllVersions);
Exit;
end;
if not SpellAvailable(B, Spell) then
Exit;

GetMousePos(X, Y);
if AutoCast then
begin
if not WaitUpTextMulti(['Autocast', 'ocast', 'utoca'], 300+Random(100)) then
Exit;

if not(CountColor(16711422, B.X1-10, B.Y1-10, B.X2+10, B.Y2+10) > 50) then
begin
Mouse(X, Y, 0, 0, True);
Result := True;
end;
Exit;
end;

Mouse(X, Y, 0, 0, not SInfo.AutoCast);
if SInfo.AutoCast then
Result := WaitOptionMulti(['Cast', 'ast', 'Cas'], 300+Random(100))
else
Result := WaitUpTextMulti(['Cast', 'ast', 'Cas'], 500+Random(100));
end;

If user already has the spell set to autocast (There is a colored box around the spell, then when calling this function like
Cast('fire strike', True); 
it results false!
It should result true, AND cast the spell like it's being told.

Currently, it just goes to magic tab, hovers the spells for a split second, and then (because of my script Logs out).

I unno, someone check it out? :D

Coh3n

2011-12-10 20:05:14

Looks like this line

if not(CountColor(16711422, B.X1-10, B.Y1-10, B.X2+10, B.Y2+10) > 50) then
Try debugging it, or try this:

if not(CountColor(16711422, B.X1-10, B.Y1-10, B.X2+10, B.Y2+10) > 50) then
begin
Mouse(X, Y, 0, 0, True);
Result := True;
end else
Result := True;
It just looks like it wasn't setting the result if the countColor was > 50. I'm assuming that's the line that checks for the white box.

YoHoJo

2011-12-10 21:07:37

I was thinking same too, just wanted to know for sure, thanks Coh3n I'll do that in a while and see. That's probably it. I'll figure out the new color/count or just tweak it to work and post it somewhere for a commit.

Coh3n

2011-12-11 02:04:38

From: YoHoJo
I was thinking same too, just wanted to know for sure, thanks Coh3n I'll do that in a while and see. That's probably it. I'll figure out the new color/count or just tweak it to work and post it somewhere for a commit.
Just post it here. ;)

Kyle Undefined

2011-12-12 21:15:54

I don't know if this has been fixed or not, but here's the updated Cast() function. I reloaded the RS client several times to get the highest color count for the Autocast white box.


function Cast(Spell: string; AutoCast: Boolean): Boolean;
var
X, Y: Integer;
B: TBox;
SInfo: TSpell;
begin
if not LoggedIn then
Exit;

SInfo := GetSpellInfo(Spell);
if AutoCast then
if not SInfo.AutoCast then
begin
srl_Warn('Cast', Spell + ' is not autocast-able', warn_AllVersions);
Exit;
end;
if not SpellAvailable(B, Spell) then
Exit;

GetMousePos(X, Y);
if AutoCast then
begin
if not WaitUpTextMulti(['Autocast', 'ocast', 'utoca'], 300+Random(100)) then
Exit;

if not(CountColor(16711422, B.X1-10, B.Y1-10, B.X2+10, B.Y2+10) > 76) then
begin
Mouse(X, Y, 0, 0, True);
Result := True;
end;
Exit;
end;

Mouse(X, Y, 0, 0, not SInfo.AutoCast);
if SInfo.AutoCast then
Result := WaitOptionMulti(['Cast', 'ast', 'Cas'], 300+Random(100))
else
Result := WaitUpTextMulti(['Cast', 'ast', 'Cas'], 500+Random(100));
end;

Coh3n

2011-12-12 23:33:00

I don't think that was the problem, Camo. It was that the function wasn't returning false if the spell was already set to be auto-casted.

E: Fixed in SRL5.

Kyle Undefined

2011-12-13 00:02:45

From: Coh3n
I don't think that was the problem, Camo. It was that the function wasn't returning false if the spell was already set to be auto-casted.

E: Fixed in SRL5.


You're right, here's the real version:


function Cast(Spell: string; AutoCast: Boolean): Boolean;
var
X, Y: Integer;
B: TBox;
SInfo: TSpell;
begin
if not LoggedIn then
Exit;

SInfo := GetSpellInfo(Spell);
if AutoCast then
if not SInfo.AutoCast then
begin
srl_Warn('Cast', Spell + ' is not autocast-able', warn_AllVersions);
Exit;
end;
if not SpellAvailable(B, Spell) then
Exit;

GetMousePos(X, Y);
if AutoCast then
begin
if not WaitUpTextMulti(['Autocast', 'ocast', 'utoca'], 300+Random(100)) then
Exit;

if not(CountColor(16711422, B.X1-10, B.Y1-10, B.X2+10, B.Y2+10) > 50) then
begin
Mouse(X, Y, 0, 0, True);
Result := True;
end;
//Exit; // This was causing it return false since it would Exit before even casting
end;

Mouse(X, Y, 0, 0, not SInfo.AutoCast);
if SInfo.AutoCast then
Result := WaitOptionMulti(['Cast', 'ast', 'Cas'], 300+Random(100))
else
Result := WaitUpTextMulti(['Cast', 'ast', 'Cas'], 500+Random(100));
end;

Coh3n

2011-12-13 01:28:00

Thanks, Camo. :) I did it wrong in my commit.