SRL Archive - SRL Archives

FindLamp


Naum

2009-06-28 12:45:36

I found this suggestion from EvilChicken! on a thread:

From: EvilChicken!

2: FindLamp skill coords can be shortened using simple maths.


So I tried, a big thanks to bullzeye and nielsie for helping me with this :)

Function FindLamp(Skill: String): Boolean;
Label Finish;
Var
LampTime, x, y, Msk, MS, Col, Row : Integer;
Skills : Array Of Array Of String;
Begin
GameTab(4);
Skills := [TStringArray(['']), TStringArray(['attack', 'atk']), TStringArray(['strength', 'str']), TStringArray(['range', 'ranged']),
TStringArray(['magic']), TStringArray(['defence', 'def']), TStringArray(['crafting', 'craft']), TStringArray(['hitpoints', 'hp']),
TStringArray(['prayer', 'pray']), TStringArray(['agility']), TStringArray(['herblore', 'herb']), TStringArray(['thieving', 'thief']),
TStringArray(['fishing', 'fish']), TStringArray(['runecraft', 'runecrafting']), TStringArray(['slayer', 'slay']), TStringArray(['farming', 'farm']),
TStringArray(['mining', 'mine']), TStringArray(['smithing', 'smith']), TStringArray(['hunting', 'hunt', 'hunter']),
TStringArray(['cooking', 'cook']), TStringArray(['firemaking', 'fire']), TStringArray(['woodcutting', 'wc']), TStringArray(['']),
TStringArray(['']), TStringArray(['fletching', 'fletch']), TStringArray(['construction']), TStringArray(['summoning', 'summon'])];

For Msk := 0 to High(Skills) Do
For MS := 0 to High(Skills[Msk]) Do
If Skill = '' Then Begin Msk := 7; Break End Else
Try
If (Lowercase(Skill) = (Skills[Msk][MS])) Then
Begin
Row := Trunc(Msk / 7) + 1;
Col := (Msk - 1) Mod 7 + 1; //Bullzeye skills.
End;
Except Continue;
End;
If Row Xor 0 = 0 Then Exit;
If (Msk Mod 4) = 0 Then Dec(Row);
If Col = 0 Then Col := 7;
If FindColorTolerance(x, y, 1084300, MIX1, MIY1, MIX2, MIY2, 40) Then
If (FindTransparentBitmapTolerance(Lamp, x, y, clBlack, MIX1, MIY1, MIX2, MIY2, 40)) Then
Begin
Inc(RandSolved[rand_Lamp]);
TakeScreen('Lamp Random Solved');
AddToSRLLog('******** SOLVED LAMP RANDOM ********');
WriteLn('******** SOLVED LAMP RANDOM ********');
Mouse(x, y, 1, 1, True);
Wait(1500 + Random(500));
MarkTime(LampTime);
End;
If GetColor(115, 74) = 6325658 Then Goto Finish Else
If (TimeFromMark(LampTime) > 10000) Then
Begin
LogOut;
Players[CurrentPlayer].Rand := 'Lamp';
End;
Finish :
Begin
Mouse(51 + (55 * (Col - 1)), 84 + (55 * (Row - 1)), 45, 45, True);
Wait(1500 + Random(500));
Mouse(416, 281, 7, 1, True);
Result := True;
End;
Exit;
End;

Thanks.

ShowerThoughts

2009-06-28 13:28:31

I have a question.
If Row Xor 0 = 0 Then Exit;

0 = 0 , is always true right? then put a true.

Sir R. M8gic1an

2009-06-28 13:53:46

that is one massive unelegant, unreadable and uneditable confusion.

~RM

Naum

2009-06-28 15:17:27

From: Rasta Magician
that is one massive unelegant, unreadable and uneditable confusion.

~RM


I find it easy to read, tell me which parts look unreadable, so I may improve the readability :)

ian.

2009-06-28 15:25:46

Probably when you declare Skills.. :p

Naum

2009-06-28 15:33:26

So how is that any different to:

  Boxes := [IntToBox(37, 107, 100, 170), IntToBox(131, 107, 194, 170), IntToBox(225, 107, 288, 170), IntToBox(309, 107, 372, 170),
IntToBox(37, 179, 100, 242), IntToBox(131, 179, 194, 242), IntToBox(225, 179, 288, 242), IntToBox(37, 251, 100, 314),
IntToBox(131, 251, 194, 314), IntToBox(225, 251, 288, 314)];

?? :D

ZephyrsFury

2009-06-28 15:35:54

Honestly the current function is much easier to read/understand and to edit if Jagex makes any modifications.

senrath

2009-06-28 20:30:51

From: Hermen
I have a question.

0 = 0 , is always true right? then put a true.


But he's not comparing 0 to 0. He's comparing Row Xor 0 to 0.

Naum

2009-07-01 20:31:22

From: ZephyrsFury
Honestly the current function is much easier to read/understand and to edit if Jagex makes any modifications.


Okay I accept that :)