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 
SCAR Code:
{*******************************************************************************
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
SCAR Code:
Const
HpMax = 99; // Your HP Level.
SCAR Code:
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.