PriSoner
2008-03-25 15:40:39
As FindLamp has to be updated at some point to include summoning now is the perfect time to fix this function.
Current Function
Currently there is no failsafe within this routine. The routine does not check to see if an invalid skill has been entered. As a result if the skill is entered wrongly the function runs, click on the lamp and then click continue. This results in the lamp not being used. As the lamp is still in the players inventory the function sets off again the next time it's called and fails again. This creates a very detectable loop.
This was first spotted when a user of my script entered summoning as a skill. Obviously summoning isn't a valid skill yet so it ended getting itself into the never ending loop.
He then also had the misfortune of changing the skill to Hunter, which is not recognised as a valid skill but hunting and hunt are! This is despite hunter being returned when you mouseover the skill.
Again this got stuck into that nasty loop.
My quick solution.
1) Add an else to the Case of i.e.
else Mouse(176, 166, 12, 12, True);
this would just default Lampskill to use Hitpoints if an invalid skill was entered.
2) add hunter to the case of.
also
Fails to detect a lamp if in invetory slot 28 (may also fail to detect it if it's in slot 25 - 27 unconfirmed)
I would sugest changing
FindColorTolerance(x, y, 1084300, 550, 200, 745, 465, 40)
FindBitmapSpiralTolerance(Lamp, x, y, 550, 200, 745, 465, 40)
to
FindColorTolerance(x, y, 1084300, MIX1, MIY1, MIX2, MIY2, 40)
FindBitmapSpiralTolerance(Lamp, x, y, MIX1, MIY1, MIX2, MIY2, 40)
Proposed Fixes
All I am doing is reporting the bug and offering a simple fix. I know that this function could probably do with a rewrite. ;) and if I get a chance I may look into it further.. in the mean time feel free to offer your far superior solution! :)
Current Function
{*******************************************************************************
function FindLamp(skill: String): Boolean;
by: Pups and Starblaster100
Description: handles Genie. Results True if lamp found and handled.
skill: Skill to use with lamp eg. 'strength', 'attack', etc.
*******************************************************************************}
function FindLamp(skill: string): Boolean;
var
LampTime, x, y, i: Integer;
begin
GameTab(4);
if FindColorTolerance(x, y, 1084300, 550, 200, 745, 465, 40) then
if (FindBitmapSpiralTolerance(Lamp, x, y, 550, 200, 745, 465, 40)) then
begin
Result := True;
TakeScreen('Lamp Random Solved');
WriteLn('******** SOLVED LAMP RANDOM ********');
WriteFileString(TheFile, '******** SOLVED LAMP RANDOM ********' + Chr(13));
Lamps := Lamps + 1;
Mouse(x, y, 1, 1, True);
Wait(1500 + Random(500));
MarkTime(LampTime);
for i:= 1 to 4 do
begin
case (LowerCase(Skill)) of
'strength': Mouse(191, 134, 12, 12, True);
'attack': Mouse(222, 136, 12, 12, True);
'ranged': Mouse(256, 134, 12, 12, True);
'magic': Mouse(289, 135, 12, 12, True);
'defence': Mouse(319, 136, 12, 12, True);
'hitpoints', 'hp': Mouse(176, 166, 12, 12, True);
'prayer', 'pray': Mouse(208, 163, 12, 12, True);
'agility': Mouse(239, 165, 12, 12, True);
'herblore': Mouse(271, 165, 12, 12, True);
'thieving', 'thief': Mouse(303, 164, 12, 12, True);
'crafting', 'craft': Mouse(335, 164, 12, 12, True);
'runecraft', 'runecrafting': Mouse(174, 193, 12, 12, True);
'slayer', 'slay': Mouse(205, 195, 12, 12, True);
'farming', 'farm': Mouse(239, 193, 12, 12, True);
'mining', 'mine': Mouse(270, 194, 12, 12, True);
'smithing', 'smith': Mouse(302, 194, 12, 12, True);
'fishing', 'fish': Mouse(334, 192, 12, 12, True);
'cooking', 'cook': Mouse(173, 220, 12, 12, True);
'firemaking', 'fire': Mouse(206, 220, 12, 12, True);
'woodcutting', 'wc': Mouse(240, 220, 12, 12, True);
'fletching', 'fletch': Mouse(274, 220, 12, 12, True);
'construction': Mouse(303, 220, 12, 12, True);
'hunting', 'hunt': Mouse(335, 220, 12, 12, True);
end;
Wait(500 + Random(200) + Random(100));
if FindColorTolerance(x, y, 2303647, 155, 117, 370, 250, 0) then Break;
if (TimeFromMark(LampTime) > 10000) then
begin
Result := False;
Logout;
Players[CurrentPlayer].Rand := 'Lamp';
Exit;
end;
end;
Mouse(261, 277, 1, 1, True);
Wait(500 + Random(150) + Random(150));
end;
end;Currently there is no failsafe within this routine. The routine does not check to see if an invalid skill has been entered. As a result if the skill is entered wrongly the function runs, click on the lamp and then click continue. This results in the lamp not being used. As the lamp is still in the players inventory the function sets off again the next time it's called and fails again. This creates a very detectable loop.
This was first spotted when a user of my script entered summoning as a skill. Obviously summoning isn't a valid skill yet so it ended getting itself into the never ending loop.
He then also had the misfortune of changing the skill to Hunter, which is not recognised as a valid skill but hunting and hunt are! This is despite hunter being returned when you mouseover the skill.
Again this got stuck into that nasty loop.
My quick solution.
1) Add an else to the Case of i.e.
else Mouse(176, 166, 12, 12, True);
this would just default Lampskill to use Hitpoints if an invalid skill was entered.
2) add hunter to the case of.
also
Fails to detect a lamp if in invetory slot 28 (may also fail to detect it if it's in slot 25 - 27 unconfirmed)
I would sugest changing
FindColorTolerance(x, y, 1084300, 550, 200, 745, 465, 40)
FindBitmapSpiralTolerance(Lamp, x, y, 550, 200, 745, 465, 40)
to
FindColorTolerance(x, y, 1084300, MIX1, MIY1, MIX2, MIY2, 40)
FindBitmapSpiralTolerance(Lamp, x, y, MIX1, MIY1, MIX2, MIY2, 40)
Proposed Fixes
{*******************************************************************************
function FindLamp(skill: String): Boolean;
by: Pups and Starblaster100
Description: handles Genie. Results True if lamp found and handled.
skill: Skill to use with lamp eg. 'strength', 'attack', etc.
*******************************************************************************}
function FindLamp(skill: string): Boolean;
var
LampTime, x, y, i: Integer;
begin
GameTab(4);
if FindColorTolerance(x, y, 1084300, MIX1, MIY1, MIX2, MIY2, 40) then
if (FindBitmapSpiralTolerance(Lamp, x, y, MIX1, MIY1, MIX2, MIY2, 40)) then
begin
Result := True;
TakeScreen('Lamp Random Solved');
WriteLn('******** SOLVED LAMP RANDOM ********');
WriteFileString(TheFile, '******** SOLVED LAMP RANDOM ********' + Chr(13));
Lamps := Lamps + 1;
Mouse(x, y, 1, 1, True);
Wait(1500 + Random(500));
MarkTime(LampTime);
for i:= 1 to 4 do
begin
case (LowerCase(Skill)) of
'strength': Mouse(191, 134, 12, 12, True);
'attack': Mouse(222, 136, 12, 12, True);
'ranged': Mouse(256, 134, 12, 12, True);
'magic': Mouse(289, 135, 12, 12, True);
'defence': Mouse(319, 136, 12, 12, True);
'hitpoints', 'hp': Mouse(176, 166, 12, 12, True);
'prayer', 'pray': Mouse(208, 163, 12, 12, True);
'agility': Mouse(239, 165, 12, 12, True);
'herblore': Mouse(271, 165, 12, 12, True);
'thieving', 'thief': Mouse(303, 164, 12, 12, True);
'crafting', 'craft': Mouse(335, 164, 12, 12, True);
'runecraft', 'runecrafting': Mouse(174, 193, 12, 12, True);
'slayer', 'slay': Mouse(205, 195, 12, 12, True);
'farming', 'farm': Mouse(239, 193, 12, 12, True);
'mining', 'mine': Mouse(270, 194, 12, 12, True);
'smithing', 'smith': Mouse(302, 194, 12, 12, True);
'fishing', 'fish': Mouse(334, 192, 12, 12, True);
'cooking', 'cook': Mouse(173, 220, 12, 12, True);
'firemaking', 'fire': Mouse(206, 220, 12, 12, True);
'woodcutting', 'wc': Mouse(240, 220, 12, 12, True);
'fletching', 'fletch': Mouse(274, 220, 12, 12, True);
'construction': Mouse(303, 220, 12, 12, True);
'hunting', 'hunt': Mouse(335, 220, 12, 12, True);
end else Mouse(176, 166, 12, 12, True);
Wait(500 + Random(200) + Random(100));
if FindColorTolerance(x, y, 2303647, 155, 117, 370, 250, 0) then Break;
if (TimeFromMark(LampTime) > 10000) then
begin
Result := False;
Logout;
Players[CurrentPlayer].Rand := 'Lamp';
Exit;
end;
end;
Mouse(261, 277, 1, 1, True);
Wait(500 + Random(150) + Random(150));
end;
end;All I am doing is reporting the bug and offering a simple fix. I know that this function could probably do with a rewrite. ;) and if I get a chance I may look into it further.. in the mean time feel free to offer your far superior solution! :)