Well I made this goblin killer script mainly for leveling my Pure Autoed Pure, since chickens are a bit crowded and not so good XP after 20 str and attack.
This script has got an auto-eater for the few most popular f2p foods for eating while autofighting, which I think are: Meat, Chicken, Trout, Cod and Salmon.
Caution: Goblin hut is not a good place to use this script, even there are failsafes, it's pretty stupid when you get a "false flag", that there is a flag but your char wont walk.
I suggest to use it in the Stronghold of Security underneath Barbarian Village, where are 5-13 levels in one room and about 20 lvl ones in another room, so there is plenty of choice for varying levels.
It is very rare, but sometimes it might attack two goblins at the sametime, so
a) Make sure the timeout you have set in Const is high enough.
b) Your char isn't supposed to be like lvl 10 while using this script, defence should be atleast 5 or more.
It's still in quite a beta stage, the 6.2 in the name just looks cool, so report possible bugs/ flaws and post improvements.
I had a test run yesterday, worked as supposed to, Good Luck & Have Fun.
SCAR Code:
Program PowerGoblins;
{.include SRL/SRL.scar}
{.include SRL/SRL/Skill/Fighting.scar}
Const MonsterTime = 35000;
Const AmountGoblins = 40;
Const MultiCombatArea = False;
Type
FightStyle = (Accurate, Agressive, Shared, Defence);
Var
Styles: Array of FightStyle;
Var
Meat, Chicken, Trout, Cod, Salmon, Hit, Killed: Integer;
Var
gHP: Extended;
Procedure DeclarePlayers;
Begin
HowManyPlayers := 1;
NumberOfPlayers(HowManyPlayers);
CurrentPlayer := 0;
SetArrayLength(Styles, HowManyPlayers);
Players[0].Name := 'Username';
Players[0].Pass := 'Password';
Players[0].Nick := 'ser';
Players[0].Booleans[0] := True; // Eat?
Players[0].Strings[0] := ''; // Food name, if any, valid listed below.
// Valid foods: Meat, Chicken, Trout, Cod, Salmon.
Players[0].Active := True;
Styles[0] := Agressive; // Accurate, Agressive, Controlled, Defence
End;
Procedure LoadDTMs;
Begin
Meat := DTMFromString('78DA6374616060486340017DE18E0CCA409A1' +
'188FF0301A3399091CE8006189148206D05241209A87104127104' +
'D478008930026A7C814408013541402286801A7F209142408D379' +
'0C826A0C61D48141050E340841A6B2091875F0D005CFC0D51');
Chicken := DTMFromString('78DA6374626060B8C58002DA8304189481342' +
'310FF0702460B20E31E031A60442281B41D907840408D0790B84F' +
'408D1FA67B30D4F80289CB04D4F803897344987392801A7722D4D' +
'80389F304D45803894B04D4580289AB04D498110E1F00B0FF136A' +
'');
Trout := DTMFromString('78DA6374666060D8C280027A4AF2199481342' +
'310FF0702467320630F031A60442281B435116A4076ED22A0C60D' +
'486C23A0C60B486C22A0C60F48AC23A0260848AC26A0C607482C2' +
'7A0C61F482C2142CD4A026A5C80C40A026AEC81C47A026AAC80C4' +
'66026ACC80C44EFC6A005BFA141E');
Cod := DTMFromString('78DA6374626060E86440010DCB0A189481342' +
'310FF0702460B206322031A60442281B42B90E825A0C61D487411' +
'50E30524DA09A8090012F504D404813C42408D3F90A824A0C6930' +
'8735C89708F0B90A825A0C60A48741050630624FAF1AB0100FDCB' +
'1022');
Salmon := DTMFromString('78DA6374666060E060644006373CA51994813' +
'448F43F10309A0319BCA86A20B2301248DB020941026A5C81041F' +
'0135EE40828B801A3F20C14C404D10320F871A7F20F18F01BF9A0' +
'020F19B81B0393F09A8F122C22E50F8301270B30B90F8CB40382E' +
'D80898638519EFE86A00E1A40EEA');
End;
Procedure ProgressReport;
Var
H, M, S, I: Integer;
GpM: Extended;
Begin
ConvertTime(GetTimeRunning, H, M, S);
Writeln('||---------------------------------------------------||');
Writeln('||------------------Progress Report------------------||');
Writeln(Padr('|| Ran for '+IntToStr(H)+' hours, '+IntToStr(M)+' mins, '+IntToStr(S)+' sec.', 52) + ' ||');
Killed := Killed + Hit;
Hit := 0;
Writeln(Padr('|| Goblins killed: '+IntToStr(Killed), 52) +' ||');
GpM := H * 3600000 + M * 60000 + S * 1000;
GpM := GpM / 60000;
GpM := Killed / GpM;
Writeln(Padr('|| Goblins per minute: '+FloatToStr(GpM), 52) +' ||');
Writeln('||---------------------------------------------------||');
Writeln('|| Thank you for using n3s'' PowerGobliner. ||');
Writeln('||---------------------------------------------------||');
End;
Function FindGoblin(Var X, Y: Integer): Boolean;
Var
CTS, I, C: Integer;
Begin
X := MSCX;
Y := MSCY;
CTS := GetColorToleranceSpeed;
ColorToleranceSpeed(2);
For I := 0 To 2 Do
Begin
Case I of
0: C := 4040609;
1: C := 4483121;
2: C := 2715756;
End;
If FindColorSpiralTolerance(X, Y, C, MSX1, MSY1, MSX2, MSY2, 12) Then
If CountColorTolerance(C, X - 5, Y - 5, X + 5, Y + 5, 10) >= 6 Then
Begin
Result := True;
Break;
End;
End;
ColorToleranceSpeed(CTS);
End;
Function Check(X, Y, Rx, Ry: Integer): Boolean;
Begin
Mouse(X, Y, Rx, Ry, False);
Result := ChooseOption('ttac');
End;
Function ClickGoblin: Boolean;
Var
X, Y: Integer;
Begin
If Not FindGoblin(X, Y) Then
Exit;
If ((Not MultiCombatArea) Xor IsFightAt(X, Y)) Then
If Check(X, Y, 2, 2) Then
Begin
Result := true;
FFlag(0);
End;
End;
Function FindAllHPBars: Array of TPointArray;
Var
g, r: TPointArray;
Begin
FindColorsTolerance(g, 65280, MSCX - 60, MSCY - 60, MSCX + 60, MSCY + 60, 0);
FindColorsTolerance(r, 255, MSCX - 60, MSCY - 60, MSCX + 60, MSCY + 60, 0);
Result := TPAToATPAEx(CombineTPA(g, r), 31, 5);
End;
Function GetHits: TIntegerArray;
Var
TPAA: T2DPointArray;
E: Extended;
I: Integer;
TB: TBox;
Begin
TPAA := FindAllHPBars;
SetArrayLength(Result, GetArrayLength(TPAA));
For I := 0 To High(TPAA) Do
Begin
TB := GetTPABounds(TPAA[i]);
E := CountColor(65280, TB.x1, TB.y1, TB.x2, TB.y2) / 150;
Result[i] := Round(100 * E);
End;
End;
Function ChatsBlueText: TStringArray;
Var
TPA: TPointArray;
I: Byte;
Begin
SetArrayLength(TPA, 9);
For I := 1 To 8 Do
TPA[i] := TextCoords(i);
SetArrayLength(Result, 9);
For I := 1 To 8 Do
Result[I] := Trim(GetTextAtEx(TPA[i].x - 2, TPA[i].y - 2, 0, SmallChars, False,
False, 0, 1, 16711680, 80, False, tr_AllChars));
End;
Procedure ChitChat;
Var
TSA, Q: TStringArray;
I, II, Z, X: Integer;
Begin
TSA := ChatsBlueText;
TSA := [TSA[6], TSA[7]];
Q := ['hp', 'hitpoint', 'str', 'strength', 'atk', 'attack', 'def', 'defence'];
For I := 0 To 1 Do
For II := 0 To High(Q) Do
Begin
z := Pos(Q[ii], TSA[i]);
x := Pos('lvl', TSA[i]);
If x = 0 Then
x := Pos('lev', TSA[i]);
If X > Z Then
Begin
Case II Of
0, 1: x := GetSkillInfo('hitpoints', False);
2, 3: x := GetSkillInfo('strength', False);
4, 5: x := GetSkillInfo('attack', False);
6, 7: x := GetSkillInfo('defence', False);
End;
TypeSend(IntToStr(X));
Exit;
End;
End;
End;
Function FightGoblin: Boolean;
Var
Hits: TIntegerArray;
FS, I: Integer;
Begin
If Not ClickGoblin Then Exit;
Result := True;
FS := GetSystemTime;
Wait(250 + Random(50));
If FindNormalRandoms Then
If Not LoggedIn Then
Exit;
Wait(100 + Random(25));
If FindBlackChatMessage('reach') Then Exit;
Wait(25);
If FindBlackChatMessage('someone') Then Exit;
Repeat
Wait(25);
If GetSystemTime - FS > 4000 Then Break;
Hits := GetHits;
Until(GetArrayLength(Hits) >= 0);
If GetArrayLength(Hits) > 0 Then
Result := True
Else
Exit;
FS := GetSystemTime;
Repeat
Hits := GetHits;
If GetArrayLength(Hits) < 1 Then
Exit
Else
For I := 0 To High(Hits) Do
If Hits[i] = 0 Then
Exit;
Wait(100 + Random(50));
If FindNormalRandoms Then
If Not LoggedIn Then
Exit;
Wait(100 + Random(50));
ChitChat;
If GetSystemTime - FS >= MonsterTime Then
Begin
Writeln('Timeout!');
Exit;
End;
Until(Not(LoggedIn));
End;
Function FindNPCs: TPointArray;
Var
CTS: Integer;
Begin
CTS := GetColorToleranceSpeed;
ColorToleranceSpeed(2);
FindColorsTolerance(Result, 195836, MMCX - 40, MMCY - 40, MMCX + 40, MMCY + 40, 12);
ColorToleranceSpeed(CTS);
RAaSTPA(Result, 4);
End;
Function doCallibrate: Boolean;
Var
Points: T2DPointArray;
X, Y: Integer;
Begin
Points := SplitTPA(FindNPCs, 35);
SortATPASize(Points, True);
Try
MiddleTPAEx(Points[0], X, Y);
MFNF(X, Y, 2, 2);
FFlag(0);
Result := True;
Except
Result := False;
End;
End;
Function NeedHealth: Extended;
Var
CS: String;
Begin
Result := (GetMMLevels('hitpoints', CS) / gHP);
End;
Function Eat: Boolean;
Var
DTM, X, Y: Integer;
CS: String;
Begin
If Players[CurrentPlayer].Strings[0] = '' Then
Begin
Result := True;
Exit;
End;
Case LowerCase(Players[CurrentPlayer].Strings[0]) Of
'meat': DTM := Meat;
'chicken': DTM := Chicken;
'trout': DTM := Trout;
'cod': DTM := Cod;
'salmon': DTM := Salmon;
End;
Repeat
If FindDTM(DTM, X, Y, MIX1, MIY1, MIX2, MIY2) Then
Begin
Mouse(X, Y, 2, 2, True);
Result := True;
End;
Wait(650 + Random(250));
Until(GetMMLevels('hitpoints', CS) >= Round(gHP)) or (Not(Result));
End;
Procedure KillGoblins;
Var
Miss, Callibrate, Count: Integer;
Begin
Callibrate := 0;
Count := 0;
Repeat
If Not FightGoblin Then
Miss := Miss + 1
Else
Begin
Miss := 0;
Callibrate := 0;
Hit := Hit + 1;
Count := Count + 1;
End;
If (Miss >= 10) And (Callibrate = 1) Then
Begin
Writeln('No goblins');
Callibrate := 0;
Logout;
Exit;
End;
If Miss > 10 Then
If Not doCallibrate Then
Begin
Writeln('Failed to callibrate');
Logout;
Exit;
End Else
Begin
Callibrate := 1;
Miss := 0;
End;
If NeedHealth < 0.65 Then
If Not Eat Then
Begin
Writeln('Out of food');
Logout;
Exit;
End;
If FindNormalRandoms Then
If Not LoggedIn Then
Exit;
If Not LoggedIn Then Exit;
Wait(450 + Random(250));
Until(Count >= 10 + Random(20));
End;
Procedure DoStyles;
Begin
Case Styles[CurrentPlayer] Of
Accurate: SetFightMode(1);
Agressive: SetFightMode(2);
Defence: SetFightMode(3);
Shared: SetFightMode(4);
End;
End;
Procedure ScriptTerminate;
Begin
FreeDTM(Meat);
FreeDTM(Chicken);
FreeDTM(Trout);
FreeDTM(Cod);
FreeDTM(Salmon);
End;
Var
I: Integer;
begin
SetupSRL;
LoadDTMs;
DeclarePlayers;
Repeat
LoginPlayer;
For I := 2 To 5 Do
SetChat('off', i);
DoStyles;
gHP := GetSkillInfo('hitpoints', False);
SetAngle(True);
SetRun(True);
SetRetaliate(True);
Repeat
KillGoblins;
ProgressReport;
If Not LoggedIn Then Break;
Until(Hit >= AmountGoblins + Random(20));
NextPlayer(LoggedIn);
ProgressReport;
Until(False);
end.