SRL Archive - SRL Bugs

Cast is having issues


senrath

2009-05-21 00:22:39

Alright, Cast no longer seems to work. I've tried it with multiple different spells and it always returns false (and doesn't do anything but change to the magic tab), even if the spell can be cast.

I'm using the OpenDev Repository.

Dynamite

2009-05-21 00:25:25

Edit it then ;)
I'll check it out later :)

T~M

Richard

2009-05-21 00:25:37

Would this be due to the new style of the magic interface? With the new way of laying out spells?

Dynamite

2009-05-21 00:27:47

Edit sorry read wrong

T~M

Naike

2009-05-21 01:31:35

Yes. Would fix it, but stuck up with other sheite ;/

Naum

2009-05-21 01:54:23

I'll get on to it :). In another 16 hrs :( - because of sleep.

Richard

2009-05-21 01:59:17

I think we're going to have to start adding a new method of spell casting.

Look at the include:

function Cast(Spell: string): Boolean;
var
spArr: TStringArray;
spNo, X, Y, II, CTS: Integer;
B: TBox;
Lum, H, S, L: Extended;
colArr: TIntegerArray;
begin
case (Lowercase(Spell)) of
'home teleport': Spell := 'lumbridge home teleport';
'bolt enchantment': Spell := 'enchant crossbow bolt';
'enchant level 1 jewelry': Spell := 'lvl-1 enchant';
'enchant level 2 jewelry': Spell := 'lvl-2 enchant';
'enchant level 3 jewelry': Spell := 'lvl-3 enchant';
'enchant level 4 jewelry': Spell := 'lvl-4 enchant';
'enchant level 5 jewelry': Spell := 'lvl-5 enchant';
'enchant level 6 jewelry': Spell := 'lvl-6 enchant';
end;
spArr := ['lumbridge home teleport', 'wind strike', 'confuse', 'enchant crossbow bolt', 'water strike', 'lvl-1 enchant',
'earth strike', 'weaken', 'fire strike', 'bones to bananas', 'wind bolt', 'curse', 'bind', 'low level alchemy',
'water bolt', 'varrock teleport', 'lvl-2 enchant', 'earth bolt', 'lumbridge teleport', 'bounty locate', 'telekinetic grab',
'fire bolt', 'falador teleport', 'crumble undead', 'teleport to house', 'wind blast', 'superheat item', 'camelot teleport',
'water blast', 'lvl-3 enchant', 'iban blast', 'snare', 'magic dart', 'ardougne teleport', 'earth blast', 'high level alchemy',
'charge water orb', 'lvl-4 enchant', 'watchtower teleport', 'fire blast', 'charge earth orb', 'bones to peaches',
'saradomin strike', 'claws of guthix', 'flames of zamorak', 'trollheim teleport', 'wind wave', 'charge fire orb',
'teleport to ape atoll', 'water wave', 'charge air orb', 'vulnerability', 'lvl-5 enchant', 'earth wave', 'enfeeble',
'teleother lumbridge', 'fire wave', 'entangle', 'stun', 'charge', 'teleother falador', 'teleport block', 'lvl-6 enchant',
'teleother camelot'];
Spell := Lowercase(Spell);
if (GetNumbers(Spell) = Spell) and (InRange(StrToIntDef(GetNumbers(Spell), -1), 1, Length(spArr))) then
spNo := StrToInt(Spell) - 1
else
if (not(InStrArrEx(Spell, spArr, spNo))) then
begin
srl_Warn('Cast', 'Invalid Spell Name/Number: ''' + Spell + '''', warn_AllVersions);
Exit;
end;

if (GetCurrentTab <> 7) then
begin
GameTab(7);
Wait(500 + Random(500));
end;
B.X1 := spNo mod 7 * 24 + 560;
B.Y1 := spNo div 7 * 24 + 217;
B.X2 := B.X1 + 23;
B.Y2 := B.Y1 + 23;
if (FindColor(X, Y, 2070783, MIX1, MIY1, MIX2, MIY2)) then MouseBox(MMX1, MMY1, MMX2, MMY2, 3);
FixSpells;

colArr := GetColors(TPAFromBox(B));
ClearSameIntegers(colArr);
CTS := GetColorToleranceSpeed;
ColorToleranceSpeed(2);
SetColorSpeed2Modifiers(0.72, 1.05);
for II := 0 to High(colArr) do
begin
if (SimilarColors(colArr[II], 3292228, 3)) then Continue;
ColorToHSL(colArr[II], H, S, L);
Lum := MaxE(Lum, L);
end;
SetColorSpeed2Modifiers(0.2, 0.2);
ColorToleranceSpeed(CTS);
Result := (Lum > 20.0);
if (Result) then
begin
MouseBox(B.X1, B.Y1, B.X2, B.Y2, 1);
Wait(500 + Random(500));
end;

end;

It only runs on coords, and with the new system, it probably has different coords than the new system. I'll see what I can do.

Naum

2009-05-21 02:04:14

I know what to do, I have an Idea on how to tackle this - It can be done with making a grid of boxes based on some vars so if the boxes change all you do is specify a new start co-ord.


Btw have you checked that B.X1 etc are right? Because if you change those then it might fix it :)

senrath

2009-05-21 02:25:25

I found the problem! Bounty Locate has been removed!

Here is a fixed version:
function Cast(Spell: string): Boolean;
var
spArr: TStringArray;
spNo, X, Y, II, CTS: Integer;
B: TBox;
Lum, H, S, L: Extended;
colArr: TIntegerArray;
begin
case (Lowercase(Spell)) of
'home teleport': Spell := 'lumbridge home teleport';
'bolt enchantment': Spell := 'enchant crossbow bolt';
'enchant level 1 jewelry': Spell := 'lvl-1 enchant';
'enchant level 2 jewelry': Spell := 'lvl-2 enchant';
'enchant level 3 jewelry': Spell := 'lvl-3 enchant';
'enchant level 4 jewelry': Spell := 'lvl-4 enchant';
'enchant level 5 jewelry': Spell := 'lvl-5 enchant';
'enchant level 6 jewelry': Spell := 'lvl-6 enchant';
end;
spArr := ['lumbridge home teleport', 'wind strike', 'confuse', 'enchant crossbow bolt', 'water strike', 'lvl-1 enchant',
'earth strike', 'weaken', 'fire strike', 'bones to bananas', 'wind bolt', 'curse', 'bind', 'low level alchemy',
'water bolt', 'varrock teleport', 'lvl-2 enchant', 'earth bolt', 'lumbridge teleport', 'telekinetic grab',
'fire bolt', 'falador teleport', 'crumble undead', 'teleport to house', 'wind blast', 'superheat item', 'camelot teleport',
'water blast', 'lvl-3 enchant', 'iban blast', 'snare', 'magic dart', 'ardougne teleport', 'earth blast', 'high level alchemy',
'charge water orb', 'lvl-4 enchant', 'watchtower teleport', 'fire blast', 'charge earth orb', 'bones to peaches',
'saradomin strike', 'claws of guthix', 'flames of zamorak', 'trollheim teleport', 'wind wave', 'charge fire orb',
'teleport to ape atoll', 'water wave', 'charge air orb', 'vulnerability', 'lvl-5 enchant', 'earth wave', 'enfeeble',
'teleother lumbridge', 'fire wave', 'entangle', 'stun', 'charge', 'teleother falador', 'teleport block', 'lvl-6 enchant',
'teleother camelot'];
Spell := Lowercase(Spell);
if (GetNumbers(Spell) = Spell) and (InRange(StrToIntDef(GetNumbers(Spell), -1), 1, Length(spArr))) then
spNo := StrToInt(Spell) - 1
else
if (not(InStrArrEx(Spell, spArr, spNo))) then
begin
srl_Warn('Cast', 'Invalid Spell Name/Number: ''' + Spell + '''', warn_AllVersions);
Exit;
end;

if (GetCurrentTab <> 7) then
begin
GameTab(7);
Wait(500 + Random(500));
end;
B.X1 := spNo mod 7 * 24 + 560;
B.Y1 := spNo div 7 * 24 + 217;
B.X2 := B.X1 + 23;
B.Y2 := B.Y1 + 23;
if (FindColor(X, Y, 2070783, MIX1, MIY1, MIX2, MIY2)) then MouseBox(MMX1, MMY1, MMX2, MMY2, 3);
FixSpells;

colArr := GetColors(TPAFromBox(B));
ClearSameIntegers(colArr);
CTS := GetColorToleranceSpeed;
ColorToleranceSpeed(2);
SetColorSpeed2Modifiers(0.72, 1.05);
for II := 0 to High(colArr) do
begin
if (SimilarColors(colArr[II], 3292228, 3)) then Continue;
ColorToHSL(colArr[II], H, S, L);
Lum := MaxE(Lum, L);
end;
SetColorSpeed2Modifiers(0.2, 0.2);
ColorToleranceSpeed(CTS);
Result := (Lum > 20.0);
if (Result) then
begin
MouseBox(B.X1, B.Y1, B.X2, B.Y2, 1);
Wait(500 + Random(500));
end;

end;

Richard

2009-05-21 02:37:55

What about support for the different ways of organising the spells? I'll see if I can make it change to the default method after gametab(7) is called.

Cazax

2009-05-21 02:41:56

I already made a spell organizer… Though nobody paid attention: http://www.villavu.com/forum/showthread.php?t=43392

Richard

2009-05-21 02:50:20

Then surely you'd just:

Function GetMagicsSort: Integer;
Var
I : Integer;
Pnts : TPointArray;
Begin
GameTab(7);
Wait(150 + Random(100));
Pnts := [Point(678, 443), Point(697, 443), Point(716, 443)];
For I := 0 To 2 Do
If GetColor(Pnts[i].X, Pnts[i].Y) <> 7038086 Then
Begin
Result := I + 1;
Exit;
End;
End;

Procedure SortMagics(Order : Integer);
Var
X : Integer;
Begin
If Not InIntArray([1, 2, 3], Order) Then
Exit;
X := 659 + (19 * Order);
GameTab(7);
MouseBox(X, 443, X + 12, 458, 1);
End;

function Cast(Spell: string): Boolean;
var
spArr: TStringArray;
spNo, X, Y, II, CTS: Integer;
B: TBox;
Lum, H, S, L: Extended;
colArr: TIntegerArray;
begin
case (Lowercase(Spell)) of
'home teleport': Spell := 'lumbridge home teleport';
'bolt enchantment': Spell := 'enchant crossbow bolt';
'enchant level 1 jewelry': Spell := 'lvl-1 enchant';
'enchant level 2 jewelry': Spell := 'lvl-2 enchant';
'enchant level 3 jewelry': Spell := 'lvl-3 enchant';
'enchant level 4 jewelry': Spell := 'lvl-4 enchant';
'enchant level 5 jewelry': Spell := 'lvl-5 enchant';
'enchant level 6 jewelry': Spell := 'lvl-6 enchant';
end;
spArr := ['lumbridge home teleport', 'wind strike', 'confuse', 'enchant crossbow bolt', 'water strike', 'lvl-1 enchant',
'earth strike', 'weaken', 'fire strike', 'bones to bananas', 'wind bolt', 'curse', 'bind', 'low level alchemy',
'water bolt', 'varrock teleport', 'lvl-2 enchant', 'earth bolt', 'lumbridge teleport', 'telekinetic grab',
'fire bolt', 'falador teleport', 'crumble undead', 'teleport to house', 'wind blast', 'superheat item', 'camelot teleport',
'water blast', 'lvl-3 enchant', 'iban blast', 'snare', 'magic dart', 'ardougne teleport', 'earth blast', 'high level alchemy',
'charge water orb', 'lvl-4 enchant', 'watchtower teleport', 'fire blast', 'charge earth orb', 'bones to peaches',
'saradomin strike', 'claws of guthix', 'flames of zamorak', 'trollheim teleport', 'wind wave', 'charge fire orb',
'teleport to ape atoll', 'water wave', 'charge air orb', 'vulnerability', 'lvl-5 enchant', 'earth wave', 'enfeeble',
'teleother lumbridge', 'fire wave', 'entangle', 'stun', 'charge', 'teleother falador', 'teleport block', 'lvl-6 enchant',
'teleother camelot'];
Spell := Lowercase(Spell);
if (GetNumbers(Spell) = Spell) and (InRange(StrToIntDef(GetNumbers(Spell), -1), 1, Length(spArr))) then
spNo := StrToInt(Spell) - 1
else
if (not(InStrArrEx(Spell, spArr, spNo))) then
begin
srl_Warn('Cast', 'Invalid Spell Name/Number: ''' + Spell + '''', warn_AllVersions);
Exit;
end;

if (GetCurrentTab <> 7) then
begin
GameTab(7);
Wait(500 + Random(500));
end;
SortMagics(1);
B.X1 := spNo mod 7 * 24 + 560;
B.Y1 := spNo div 7 * 24 + 217;
B.X2 := B.X1 + 23;
B.Y2 := B.Y1 + 23;
if (FindColor(X, Y, 2070783, MIX1, MIY1, MIX2, MIY2)) then MouseBox(MMX1, MMY1, MMX2, MMY2, 3);
FixSpells;

colArr := GetColors(TPAFromBox(B));
ClearSameIntegers(colArr);
CTS := GetColorToleranceSpeed;
ColorToleranceSpeed(2);
SetColorSpeed2Modifiers(0.72, 1.05);
for II := 0 to High(colArr) do
begin
if (SimilarColors(colArr[II], 3292228, 3)) then Continue;
ColorToHSL(colArr[II], H, S, L);
Lum := MaxE(Lum, L);
end;
SetColorSpeed2Modifiers(0.2, 0.2);
ColorToleranceSpeed(CTS);
Result := (Lum > 20.0);
if (Result) then
begin
MouseBox(B.X1, B.Y1, B.X2, B.Y2, 1);
Wait(500 + Random(500));
end;

end;

No?

ZephyrsFury

2009-05-21 11:02:47

From: Richard
What about support for the different ways of organising the spells? I'll see if I can make it change to the default method after gametab(7) is called.



FixSpells;

Handle thats ^.

Seems like the problem was with a spell getting removed as senrath found. Any other changes that need to be addressed?

Oh and btw this function has only been out since Rev 32. So no "old system/new system" incompatibilities.

Dark Arcana

2009-05-21 11:40:44

Read this.

ZephyrsFury

2009-05-21 11:42:38

From: Dark Arcana
Read this.


Meh thats not even updated. I assume you're refering to the other Cast bug which isn't the one thats the problem here.

Speaking of which I've commited a fix to the open dev repos. Thanks senrath!. :D

senrath

2009-05-22 10:51:20

Glad I could help.