SRL Archive - SRL Suggestions

4 small things.


Naum

2009-08-26 16:20:11

1) FindXP, 'prayer' augument could be shortened from this:

    'prayer': case sType of   // PRAYER
'normal bones' : Result:= 4.5; // NORMAL BURYING BONES
'burnt bones' : Result:= 4.5;
'wolf bones' : Result:= 4.5;
'monkey bones' : Result:= 5;
'bat bones' : Result:= 5.3;
'big bones' : Result:= 15;
'jogre bones' : Result:= 15;
'shaikahan bones' : Result:= 25;
'baby dragon bones': Result:= 30;
'wyvern bones' : Result:= 50;
'dragon bones' : Result:= 72;
'dagannoth bones' : Result:= 125;
'zogre bones' : Result:= 22.5;
'fayrg bones' : Result:= 84;
'raurg bones' : Result:= 96;
'ourg bones' : Result:= 140;

'g normal bones' : Result:= 4.5 * 3.5; // GILDED + BURNERS
'g burnt bones' : Result:= 4.5 * 3.5;
'g wolf bones' : Result:= 4.5 * 3.5;
'g monkey bones' : Result:= 5 * 3.5;
'g bat bones' : Result:= 5.3 * 3.5;
'g big bones' : Result:= 15 * 3.5;
'g jogre bones' : Result:= 15 * 3.5;
'g shaikahan bones' : Result:= 25 * 3.5;
'g baby dragon bones': Result:= 30 * 3.5;
'g wyvern bones' : Result:= 50 * 3.5;
'g dragon bones' : Result:= 72 * 3.5;
'g dagannoth bones' : Result:= 125 * 3.5;
'g zogre bones' : Result:= 22.5 * 3.5;
'g fayrg bones' : Result:= 84 * 3.5;
'g raurg bones' : Result:= 96 * 3.5;
'g ourg bones' : Result:= 140 * 3.5;

'e normal bones' : Result:= 4.5 * 4; // ECTOFUNTUS
'e burnt bones' : Result:= 4.5 * 4;
'e wolf bones' : Result:= 4.5 * 4;
'e monkey bones' : Result:= 5 * 4;
'e bat bones' : Result:= 5.3 * 4;
'e big bones' : Result:= 15 * 4;
'e jogre bones' : Result:= 15 * 4;
'e shaikahan bones' : Result:= 25 * 4;
'e baby dragon bones': Result:= 30 * 4;
'e wyvern bones' : Result:= 50 * 4;
'e dragon bones' : Result:= 72 * 4;
'e dagannoth bones' : Result:= 125 * 4;
'e zogre bones' : Result:= 22.5 * 4;
'e fayrg bones' : Result:= 84 * 4;
'e raurg bones' : Result:= 96 * 4;
'e ourg bones' : Result:= 140 * 4;
end;

to this:

'prayer': Begin
Case sType[1] Of
'g' : T := 3.5;
'e' : T := 4.0;
End;
If T = 3.5 Then P := 'g ';
If T = 4.0 Then P := 'e ';
If T = 0.0 Then P := '';

Case sType of // PRAYER
P+'normal bones', P+'burnt bones', P+'wolf bones' : Result:= 4.5 * (1.0 * T);
P+'monkey bones' : Result:= 5 * (1.0 * T);
P+'bat bones' : Result:= 5.3 * (1.0 * T);
P+'jogre bones', P+'big bones' : Result:= 15 * (1.0 * T); //those give same amount of XP too.
P+'shaikahan bones' : Result:= 25 * (1.0 * T);
P+'baby dragon bones': Result:= 30 * (1.0 * T);
P+'wyvern bones' : Result:= 50 * (1.0 * T);
P+'dragon bones' : Result:= 72 * (1.0 * T);
P+'dagannoth bones' : Result:= 125 * (1.0 * T);
P+'zogre bones' : Result:= 22.5 * (1.0 * T);
P+'fayrg bones' : Result:= 84 * (1.0 * T);
P+'raurg bones' : Result:= 96 * (1.0 * T);
P+'ourg bones' : Result:= 140 * (1.0 * T);
End;
End;

If this is done then 2 new variables, 'P' being a string and 'T' being an Extended would need to be added :).



2) SetAngle could be shortened and a variable could be removed:

procedure SetAngle(Highest : Boolean);
var
Key: Byte;
begin;
if (not LoggedIn) then exit;
if (Highest) then
Key := 38
else Key := 40;
KeyDown(Key);
Sleep(1000 + Random(100) + Random(200));
KeyUp(Key);
Wait(500 + Random(100));
end;

to:


procedure SetAngle(Highest : Boolean);
begin
if (not LoggedIn) then exit;
KeyDown((Integer(Not Highest)*2)+38);
Sleep(1000 + Random(300));
KeyUp((Integer(Not Highest)*2)+38);
Wait(500 + Random(100));
end;



3) A new SetupAutoCast:

function SetUpAutoCast(AutoSpell: string; Defensive: Boolean): Boolean;
var
X, Y: Integer;

begin
Result := False;
if not GameTab(tab_Combat) then exit;

if (Defensive) then
Mouse(655, 253, 50, 25, True)
else Mouse(665, 320, 50, 25, True);

Wait(2000 + Random(1500));
case LowerCase(AutoSpell) of
'wind strike', '1': Result := FindColor(X, Y, 16579836, 577, 236, 588, 246);
'water strike','2': Result := FindColor(X, Y, 16563743, 617, 236, 628, 246);
'earth strike','3': Result := FindColor(X, Y, 3003805, 657, 236, 668, 246);
'fire strike', '4': Result := FindColor(X, Y, 835570, 696, 236, 707, 246);

'wind bolt', '5': Result := FindColor(X, Y, 16579836, 577, 295, 590, 309);
'water bolt', '6': Result := FindColor(X, Y, 16563743, 617, 295, 630, 309);
'earth bolt', '7': Result := FindColor(X, Y, 3003805, 656, 295, 669, 309);
'fire bolt', '8': Result := FindColor(X, Y, 835570, 697, 295, 710, 309);

'wind blast', '9': Result := FindColor(X, Y, 16579836, 573, 356, 587, 371);
'water blast','10': Result := FindColor(X, Y, 16563743, 614, 356, 628, 371);
'earth blast','11': Result := FindColor(X, Y, 3003805, 654, 356, 668, 371);
'fire blast', '12': Result := FindColor(X, Y, 835570, 694, 357, 708, 372);

'wind wave', '13': Result := FindColor(X, Y, 16579836, 574, 414, 591, 435);
'water wave', '14': Result := FindColor(X, Y, 16563743, 614, 414, 631, 435);
'earth wave', '15': Result := FindColor(X, Y, 3003805, 655, 414, 672, 435);
'fire wave', '16': Result := FindColor(X, Y, 835570, 694, 414, 711, 435);
else
begin
srl_Warn('SetUpAutoCast', '"' + AutoSpell + '" is not a valid autocasting spell.', warn_Warning);
Mouse(687, 584, 4, 4, True); // Exits the autocasting spells setup 'popup'.
Exit;
end;
end;
if (Result) then
begin
Mouse(X, Y, 2, 2, True);
Wait(1750 + Random(1500));
end;
end;

to:

Procedure SetupAutoCast(Spell: String; Defensive: Boolean);
Var SpellNames : Array [0..1] Of TStringArray;
TSA : TStringArray;
i, xb, yb, x, y : Integer;
SpellInt : TIntegerArray;
Begin
If Not GameTab(Tab_Combat) Then Exit;
SpellNames[0] := ['wind', 'water', 'earth', 'fire'];
SpellNames[1] := ['strike', 'bolt', 'blast', 'wave'];
Mouse(655, ((Integer(not(Defensive)) * 60) + 253), 50, 25, True);
TSA := srl_Explode(Spell, ' ');
SetLength(SpellInt, 2);
For I := 0 To 1 Do
If Not(InStrArrEx(TSA[i], SpellNames[i], SpellInt[i])) Then
Begin
srl_Warn('SetupAutoCast', 'Invalid spell name', warn_AllVersions);
Exit;
End;
xb := 585 + (39 * SpellInt[0]);
yb := 245 + (60 * SpellInt[1]);
Wait(500 + Random(500));
If Not FindColor(x, y, 2, xb - 10, yb - 10, xb + 10, yb + 10) then
Mouse(xb, yb, 3, 3, True)
Else
Mouse(687, 448, 9, 4, True); //If it's invalid then exit menu
End;

Fixed a DIB error

Fixed Out Of Range Error
Fixed Co-ordinates
Removed the need for colors, found out that the outline stayed the same.
Added a Mouse() to exit the popup
Needed To Set The Length
Fixed how it would select 'Defensive', the co-ords were off by too much.
Credits go to Richard.
Big hand to Markus for letting me test it on his account :)



4) FindAxe's 'FoundAxe' output could be array'ised'.


Thanks for looking over, please post suggestions, or further shortenings :D

Gu3st...

2009-08-27 17:25:23

Nice! :)
Good work, although the new SetupAutoCast has a lot of variables :P

By the way; that's 3 things, not 4 ;)

Rich

2009-08-27 17:48:18

From: Zyt3x
By the way; that's 3 things, not 4 ;)


From: NaumanAkhlaQ
1) FindXP, 'prayer' augument could be shortened from this

2) SetAngle could be shortened and a variable could be removed:

3) A new SetupAutoCast:

4) FindAxe's 'FoundAxe' output could be array'ised'.
:p

Couldn't this
  Case sType of   // PRAYER
P+'normal bones' : Result:= 4.5 + (1.0 * T); // NORMAL BURYING BONES
P+'burnt bones' : Result:= 4.5 + (1.0 * T);
P+'wolf bones' : Result:= 4.5 + (1.0 * T);
P+'monkey bones' : Result:= 5 + (1.0 * T);
P+'bat bones' : Result:= 5.3 + (1.0 * T);
P+'big bones' : Result:= 15 + (1.0 * T);
P+'jogre bones' : Result:= 15 + (1.0 * T);
P+'shaikahan bones' : Result:= 25 + (1.0 * T);
P+'baby dragon bones': Result:= 30 + (1.0 * T);
P+'wyvern bones' : Result:= 50 + (1.0 * T);
P+'dragon bones' : Result:= 72 + (1.0 * T);
P+'dagannoth bones' : Result:= 125 + (1.0 * T);
P+'zogre bones' : Result:= 22.5 + (1.0 * T);
P+'fayrg bones' : Result:= 84 + (1.0 * T);
P+'raurg bones' : Result:= 96 + (1.0 * T);
P+'ourg bones' : Result:= 140 + (1.0 * T);

Be shortened to this?

  Case sType of   // PRAYER
P+'normal bones' : Result:= 4.5 + T; // NORMAL BURYING BONES
P+'burnt bones' : Result:= 4.5 + T;
P+'wolf bones' : Result:= 4.5 + T;
P+'monkey bones' : Result:= 5 + T;
P+'bat bones' : Result:= 5.3 + T;
P+'big bones' : Result:= 15 + T;
P+'jogre bones' : Result:= 15 + T;
P+'shaikahan bones' : Result:= 25 + T;
P+'baby dragon bones': Result:= 30 + T;
P+'wyvern bones' : Result:= 50 + T;
P+'dragon bones' : Result:= 72 + T;
P+'dagannoth bones' : Result:= 125 + T;
P+'zogre bones' : Result:= 22.5 + T;
P+'fayrg bones' : Result:= 84 + T;
P+'raurg bones' : Result:= 96 + T;
P+'ourg bones' : Result:= 140 + T;

Richard.

Naum

2009-09-06 21:01:04

- BUMP, I know at least one Dev who would have liked to see the SetupAutoCast one.

EDIT: R1ch, I made an operator error there :p, fixed.

JAD

2009-09-06 21:54:26

Couldn't this:

'prayer': Begin
Case sType[1] Of
'g' : T := 3.5;
'e' : T := 4.0;
End;
If T = 3.5 Then P := 'g ';
If T = 4.0 Then P := 'e ';
If T = 0.0 Then P := '';

Case sType of // PRAYER
P+'normal bones' : Result:= 4.5 * (1.0 * T); // NORMAL BURYING BONES
P+'burnt bones' : Result:= 4.5 * (1.0 * T);
P+'wolf bones' : Result:= 4.5 * (1.0 * T);
P+'monkey bones' : Result:= 5 * (1.0 * T);
P+'bat bones' : Result:= 5.3 * (1.0 * T);
P+'big bones' : Result:= 15 * (1.0 * T);
P+'jogre bones' : Result:= 15 * (1.0 * T);
P+'shaikahan bones' : Result:= 25 * (1.0 * T);
P+'baby dragon bones': Result:= 30 * (1.0 * T);
P+'wyvern bones' : Result:= 50 * (1.0 * T);
P+'dragon bones' : Result:= 72 * (1.0 * T);
P+'dagannoth bones' : Result:= 125 * (1.0 * T);
P+'zogre bones' : Result:= 22.5 * (1.0 * T);
P+'fayrg bones' : Result:= 84 * (1.0 * T);
P+'raurg bones' : Result:= 96 * (1.0 * T);
P+'ourg bones' : Result:= 140 * (1.0 * T);
End;
End;

Be

'prayer': Begin
Case sType[1] Of
'g' : T := 3.5;
'e' : T := 4.0;
End;
If T = 3.5 Then P := 'g ';
If T = 4.0 Then P := 'e ';
If T = 0.0 Then P := '';

Case sType of // PRAYER
P+'normal bones', P+'burnt bones', P+'wolf bones' : Result:= 4.5 * (1.0 * T);
P+'monkey bones' : Result:= 5 * (1.0 * T);
P+'bat bones' : Result:= 5.3 * (1.0 * T);
P+'big bones' : Result:= 15 * (1.0 * T);
P+'jogre bones' : Result:= 15 * (1.0 * T);
P+'shaikahan bones' : Result:= 25 * (1.0 * T);
P+'baby dragon bones': Result:= 30 * (1.0 * T);
P+'wyvern bones' : Result:= 50 * (1.0 * T);
P+'dragon bones' : Result:= 72 * (1.0 * T);
P+'dagannoth bones' : Result:= 125 * (1.0 * T);
P+'zogre bones' : Result:= 22.5 * (1.0 * T);
P+'fayrg bones' : Result:= 84 * (1.0 * T);
P+'raurg bones' : Result:= 96 * (1.0 * T);
P+'ourg bones' : Result:= 140 * (1.0 * T);
End;
End;

slackeru

2009-09-06 22:49:23

It sure could.

Edit: You could do the same with all of them?
'prayer': Begin
Case sType[1] Of
'g' : T := 3.5;
'e' : T := 4.0;
End;
If T = 3.5 Then P := 'g ';
If T = 4.0 Then P := 'e ';
If T = 0.0 Then P := '';

Case sType of // PRAYER
P+'normal bones', P+'burnt bones', P+'wolf bones' : Result:= 4.5 * (1.0 * T);
P+'monkey bones' : Result:= 5 * (1.0 * T);
P+'bat bones' : Result:= 5.3 * (1.0 * T);
P+'jogre bones', P+'big bones' : Result:= 15 * (1.0 * T); //those give same amount of XP too.
P+'shaikahan bones' : Result:= 25 * (1.0 * T);
P+'baby dragon bones': Result:= 30 * (1.0 * T);
P+'wyvern bones' : Result:= 50 * (1.0 * T);
P+'dragon bones' : Result:= 72 * (1.0 * T);
P+'dagannoth bones' : Result:= 125 * (1.0 * T);
P+'zogre bones' : Result:= 22.5 * (1.0 * T);
P+'fayrg bones' : Result:= 84 * (1.0 * T);
P+'raurg bones' : Result:= 96 * (1.0 * T);
P+'ourg bones' : Result:= 140 * (1.0 * T);
End;
End;

Naum

2009-09-07 19:51:16

Added to first post, thanks :D

Baked0420

2009-09-07 21:19:26

NaumanAkhlaQ:= Genious;

Definitely jealous of your abilities and knowledge, wish I was as good as you :)

Nice fixes, and I like your use of (not Highest) * 2, VERY creative, I don't see people do stuff like that, use the booleans returned result of 1 or 0, and it saved memory good job. What can't you do? I bet I see a new dev coming soon ;)

Rep++ for you, I bet you're getting close to 6 now haha, you'll make us have to add a 6th one.

Quickmarch

2009-09-07 23:56:28

One thing though, does SetupAutoCast(…) work with the new rs?

Bixby Sayz

2009-09-08 01:37:23

At the risk of being flamed right out of this thread, making code a tiny bit more efficient at the expensive of making it cryptic is not always a good thing.

I used to have to do maintenance on fortran code written by engineers that was so cryptic/confusing that half the time they couldn't even understand it. Drove me nuts.

Personally I say spend the couple extra cpu cycles if it means readable code. Cpu power is cheap these days.

Infantry001

2009-09-08 03:46:17

From: Bixby Sayz
At the risk of being flamed right out of this thread, making code a tiny bit more efficient at the expensive of making it cryptic is not always a good thing.

I used to have to do maintenance on fortran code written by engineers that was so cryptic/confusing that half the time they couldn't even understand it. Drove me nuts.

Personally I say spend the couple extra cpu cycles if it means readable code. Cpu power is cheap these days.

Agreed.

Shortening with things like (Not Highest)*2 is good, but most SRL functions are made so it is readable and easily edited when changed.

Baked0420

2009-09-08 05:24:57

(not highest) * 2 is very readable and easily edited. I don't think this is a hard concept for any dev to not be able to understand or edit.

Infantry001

2009-09-08 06:21:41

From: Baked0420
(not highest) * 2 is very readable and easily edited. I don't think this is a hard concept for any dev to not be able to understand or edit.

Yeah, I said that was great =)

But things like the edited SetupAutoCast, that's hard to read and edit.

Boreas

2009-09-08 08:04:06

Interesting timing, there's a discussion in dev section atm about commenting in SRL more.

Naum

2009-09-08 11:06:37

From: Bixby Sayz
At the risk of being flamed right out of this thread, making code a tiny bit more efficient at the expensive of making it cryptic is not always a good thing.

I used to have to do maintenance on fortran code written by engineers that was so cryptic/confusing that half the time they couldn't even understand it. Drove me nuts.

Personally I say spend the couple extra cpu cycles if it means readable code. Cpu power is cheap these days.


Bixby Sayz: I absolutely agree with you. The main reason I fixed it up (note: I did not make it) becuase EC! wanted to see it, as stated in the last SUAC Thread.


From: Infantry001
Yeah, I said that was great =)

But things like the edited SetupAutoCast, that's hard to read and edit.


Same as above :)


@Baked, Hey thanks :). I did the Integer(no Highest)*2 mainly because there was no discussion about efficiency (as there is a wait afterward).

snowleader

2009-09-13 19:51:48

Where would I find a tutorial on how to understand any of this? Pm please…thanks.

Main

2009-09-13 20:02:12

The answer to your question is here, and the real answer is here.

Rich

2009-09-13 20:05:29

Haha. Was about the report Snowleader for spamming after reading his other posts, but he's suspended now. Spooky...