SRL Archive - Research & Development Lounge

EatFood(What: String; TheHp: Integer): Boolean;


turbobk

2008-08-08 02:34:24

Hey guys,

I made this food eating function that will check your Inventory for food and eat it if your HP level is equal to or below "TheHp: Integer;".
It will also not check for food if there is no food left.


It currently searches for and eats:

  • Trout
  • Salmon
  • Tuna
  • Lobster
  • Bass
  • Swordfish
  • Monkfish
  • Shark

They are the most common food, so thats why I only did them..
So here it is.. PLEASE TEST IT AT LEAST ONCE FOR ME PLEASE ;)


{*******************************************************************************
function EatFood(What: String; TheHp: Integer);
By: TurboBk
Description: Finds the food 'What' in your Inv and eats it.
Will not eat if your HP level is not <= TheHp.
Will not eat if theres no food left.
*******************************************************************************}

Function EatFood(What: String; TheHp: Integer): Boolean;
Var
ColorSign, TheText: String;
NoFood: Boolean;
CTab, DTM, fx, fy: Integer;

Begin
If Not LoggedIn Then Exit;
If Not (GetMMLevels('hitpoints', ColorSign) <= TheHp) Then Exit;
If NoFood Then Exit;
Case What Of
'Trout': Begin
DTM := DTMFromString('78DA633CC2C4C050C5C8800C5A723319FE036' +
'990E87F2060BC0054938BAA06220B238134C89C02026A7663DA85' +
'A1663B504D0B11763511507309A8A618BF1A005C010F29');
TheText := 'rout';
End;
'Salmon': Begin
DTM := DTMFromString('78DA63CC61626078CE8002EEF9C932FC07D28' +
'C40FC1F0818CB816A6E30A0014624124883CCB943404D3C50CD07' +
'026A72816ADE12500372CF3DFC6A00633C0E4A');
TheText := 'almon';
End;
'Tuna': Begin
DTM := DTMFromString('78DA639CC6C4C0F0820105D467A531FC07D28' +
'C40FC1F0818E700D53C6040038C4824909E0854F390809A4EA09A' +
'0F04D4CC00AA794F40CD02A09A27F8D50000E64E0F58');
TheText := 'una';
End;
'Lobster': Begin
DTM := DTMFromString('78DA63FCC8C4C050C1C8800C0E664832FC07D' +
'220D1FF40C0F81DA8260B550D44164602E9F740352504D43C02AA' +
'2927A0E613504D1B01355F816ACAF0AB0100A8790ECA');
TheText := 'obste';
End;
'Bass': Begin
DTM := DTMFromString('78DA63DCCFC4C0F0820105ACCE4F62F80FA41' +
'981F83F10301E03AA79C08006189148207D00A8E63601359B816A' +
'3E105073900835A7806A9EE0570300828E107F');
TheText := 'ass';
End;
'Swordfish': Begin
DTM := DTMFromString('78DA637462626060616440060B8A5730FC07D' +
'220D1FF40C0680F54F38F010D30229140DA12A8868311BF1A5BA0' +
'1A6E026A7C806A5809A8F104AAF98FDF3D008D860A7D');
TheText := 'ordfi';
End;
'Monkfish': Begin
DTM := DTMFromString('78DA63CC616260E0626440060A0A2C0CFF813' +
'448F43F1030D600D5FC6740038C4824904E07AA6166C4AF2611A8' +
'8693809A64A01A21026A6A816AF8F0AB0100DC900927');
TheText := 'onkfi';
End;
'Shark': Begin
DTM := DTMFromString('78DA633CC4C4C050C6C8800C7243ED19FE036' +
'990E87F2060DC0354938DAA06220B2381F40E4C73B0AA6927A0E6' +
'02504D15013567816AF2F1AB0100E9180D72');
TheText := 'hark';
End;
Else Begin
WriteLn(What + ' is not a valid option.');
NoFood := True;
Exit;
End;
End;
CTab := GetCurrentTab;
GameTab(4);
Wait(200 + Random(200));
If FindDTM(DTM, fx, fy, MIX1, MIY1, MIX2, MIY2) Then
Begin
MMouse(fx, fy, 4, 4);
Wait(200 + Random(100));
If IsUpText(TheText) Then
Begin
GetMousePos(fx, fy);
Mouse(fx, fy, 0, 0, True);
Result := True;
NoFood := False;
FreeDTM(DTM);
Wait(500 + Random(500));
GameTab(CTab);
Exit;
End;
End Else
Begin
Result := False;
NoFood := True;
FreeDTM(DTM);
GameTab(CTab);
Exit;
End;
End;


This could be used in a script like..
EXAMPLE
Const
HpMax = 99; // Your HP Level.
Procedure EatIfNeeded;
Var
ColorSign: String;
a, b, c: Integer;
Begin
b := 0;
c := (HpMax - Random(10));
Repeat
EatFood('Lobster', 80);
Wait(500 + Random(500));
a := GetMMLevels('hitpoints', ColorSign);
b := b + 1;
Until(a >= c) Or (b > 2);
End;


Thanks,
TurboBk. :)

NiCbaZ

2008-08-08 04:12:25

looks nice, be good it it was 10- 15 lines tho try anew way to find the food so its much shorter now that would be l33t.

turbobk

2008-08-08 04:23:17

From: NiCbaZ
looks nice, be good it it was 10- 15 lines tho try anew way to find the food so its much shorter now that would be l33t.


I could use simple colors and UpText but then it wouldn't be anywhere near as accurate as it is now.
Also it's not that long if you think about it, and there's no lag.

Also I don't want the Mouse hovering over any similar colors in the Inv, the DTM is the fastest most efficient way I could think of, so If there's any BETTER and more ACCURATE way to do this then please post. :)

MasterKill

2008-08-08 04:27:50

Thanks for those DTM's! I need them very bad for my and timers new project.

I'll credit you for the DTM's, now I don't have to make them anymore lol.

turbobk

2008-08-08 04:42:18

From: MasterKill
Thanks for those DTM's! I need them very bad for my and timers new project.

I'll credit you for the DTM's, now I don't have to make them anymore lol.


Haha yeah cool, no problem.
You didn't even post anything about my EatFood function.. *crys* :'(

turbobk

2008-08-08 22:36:56

CAN SOME PEOPLE PLEASE TEST THIS FOR ME! <3

Just have any of the food listed above in your Inventory, crosshair over the rs client and hit run :)

Naike

2008-08-11 09:57:30

I just noticed something :)

Change Case What Of
To Case LowerCase(What) of

Becuase :
If they Type salmon etc.. it wont eat :)
LowerCase fixes that :o