Squirrel
05-10-2007, 04:15 AM
My cow killer and hide banker.
It works reasonably well. It (usually) makes it to the cow field and back to the bank, but it doesn't always know when you're fighting a cow already and it doesn't always pick up your hides. Possible bug with PopUp maybe? It only picks up the hides of the "PopUp screen thing" is not shifted up for whatever reason i.e. the hide is located near the bottom of the screen. I took out "find fight" in the FindFastRandoms because it kept giving false positives.
All my own script, except for the FindFastRandoms. I used mostly tutorials, looking at other scripts to see how certain things are done, and the SRL Manual to put it together. Although the other cow killer hide banker in the Fighting section gave me the idea to use an array for the cow colors. :)
EDIT: Added the code to my post 'cause everyone else in this forum does it too
{
To use it, just fill in the player array. The consts don't need to be
changed, as they seemed to work fine for me all the time, but use common
sense with them. If it doen't work, something's probably wrong with
the consts. I'm not entirely sure if the multiplayer works, having
only one account to test this with that won't get owned by the cows,
but it should work. Have fun!
}
program New;
{.include srl/srl.scar}
{.include srl/srl/skill/fighting.scar}
{.include srl/srl/extended/xObject.scar}
var Road, cx, cy, Banked, TripNo, StrGained, AtkGained, DefGained,
HpGained, HP, STR, ATK, DEF, HP1, STR1, ATK1, DEF1: integer;
var
CowColors: Array[0..4] of integer;
const
HideColor=11316663;//color of the cowhide on the ground
Trips=10; //how many trips to do
FightingStyle=2; //1 attack, 2 strength, 4 defence
RareTreesColor=168729;//minimap symbol
{--------------Player-Setup---------------}
procedure DeclarePlayers;
begin
HowManyPlayers := 1; //Number of players
NumberOfPlayers(HowManyPlayers)
CurrentPlayer:= 0;
Players[0].Name :='';
Players[0].Pass :='';
Players[0].Nick :='';
Players[0].Active :=True;
Players[0].Loc :='Bank'
NickNameBMP := CreateBitmapMaskFromText(Players[CurrentPlayer].Nick, UpChars);
CowColors[0]:=3821399; //color of the cow (try to pick a brownish color)
CowColors[1]:=1915460; //darker brown
CowColors[2]:=7371917; //beigeish
CowColors[3]:=3621203; //brownish again
CowColors[4]:=7042694; //beigeish
end;
{---------------------------------------------------------------}
{----------------I-think-everyone-knows-what-this-is------------}
function FindFastRandoms: Boolean; //Yoink! Got this from the WheatPicker thing.
var i: Integer;
begin
for i:=1 to 10 do
begin
if(not(LoggedIn))then Exit;
case I of
1: if FindDead then
Result := True;
2: if FindMod then
Result := True;
3: if FindMime then
Result := True;
4: if FindMaze then
Result := True;
5: if FindQuiz then
Result := True;
6: if FindDemon then
Result := True;
7: begin
if NoGameTab then
begin
Result := True;
Players[CurrentPlayer].loc := 'No GameTab';
Players[CurrentPlayer].Active := False;
Logout;
Exit;
end;
end;
8: begin
if InBlack then
begin
Result := True;
Players[CurrentPlayer].loc := 'InBlack';
Players[CurrentPlayer].Active := False;
Logout;
Exit;
end;
end;
9: if FindTalk then
Result := True;
end;
wait(1);
end;
end;
{---------------------------------------------}
{-------------Fally-Bank-To-Cow-Pen-----------}
procedure WalkToFarm;
begin
PerfectNorth;
HighestAngle;
ATK:=GetXP('Attack')
STR:=GetXP('Strength')
DEF:=GetXP('Defence')
HP:=GetXP('Hitpoints')
WriteLn('Starting number '+IntToStr(TripNo+1)+' trip.')
Road:=FindFallyRoadColor
RadialRoadWalk(Road, 251, 243, 50, 2, 0)
Flag
RadialRoadWalk(Road, 170, 185, 66, 0, 1)
Flag
RadialRoadWalk(Road, 175, 185, 55, 0, 0)
Flag
RadialWalkEx(x, y, MMCX, MMCY, RareTreesColor, 5, 100, 140, 57)
Flag
Mouse(695, 119, 4, 4, true)
Flag
if FindObjMultiText(cx, cy, 'pen', 'Open', 'Ope', 5270137, 50)then
Mouse(cx, cy, 5, 5, true) else
Mouse(250,190,5,5,true);
WriteLn('Made it')
TripNo:=TripNo+1
Players[CurrentPlayer].Loc :='Cowfield'
end;
{************************************************* ******************************
procedure RandomMovement;
By: Krazy_Meerkat
Description: Presses random arrow keys and moves the mouse. Able to press 2 keys simultaneously.
I modified it to only press the left and right keys, cause the other keys
messed up my program
************************************************** *****************************}
procedure RandomMovements;
begin
if ((Random(3) + 1) > 1) then
begin
if (Random(2) = 1) then
begin
if (Random(2) = 1) then
begin
KeyDown(VK_RIGHT);
end else
KeyDown(VK_LEFT);
Wait(15 + Random(15));
KeyDown(VK_LEFT);
Wait(15 + Random(15));
KeyUp(VK_RIGHT);
KeyUp(VK_LEFT);
Wait(300 + Random(500));
KeyUp(VK_LEFT);
end else ;
begin
if (Random(2) = 1) then
begin
KeyDown(VK_RIGHT);
end else
KeyDown(VK_LEFT);
Wait(Random(15));
KeyDown(VK_RIGHT);
Wait(300 + Random(500))
KeyUp(VK_RIGHT);
KeyUp(VK_LEFT);
Wait(Random(15));
KeyUp(VK_RIGHT);
end;
end else ;
MMouse((Random(330) + 8), (Random(490) + 8), 3, 3);
end;
{--------------------------------------------------------------------}
{--------------Killing-the-cows-and-reaping-their-hides--------------}
procedure AttackDerCows;
var i: Integer;
begin;
for i:=0 to 4 do
if FindColorAbstract(x, y, CowColors[i], 7, 4, 4, 515, 4, 515, 335, 4, 335)then
begin;
Mouse(x, y, 4, 4, false)
PopUp('ttack')
end;
wait(1000+random(2000))
OutFight;
RandomMovements;
if FindObjFast(cx, cy, 'ake', HideColor,1)then
begin;
Mouse(cx,cy,3,3,false)
PopUp('owhide')
end
FindNormalRandoms;
FindFastRandoms;
if (not(LoggedIn))then NextPlayer(false);
if(FindNewBox)then
SolveBox;
end;
{-------------------------------------------------}
{----------------Back-to-the-bank-----------------}
procedure WalkToBank;
begin;
MakeCompass('N');
Mouse(613, 30, 3, 3, true)
Flag;
if FindObjMultiText(cx, cy, 'pen', 'Open', 'Ope', 5270137, 50)then
begin;
Mouse(cx,cy,5,5,true)
end else
Mouse(250,190,5,5,true);
wait(3000)
RadialWalk(RareTreesColor , 180, 360, 72, 1, 0);
Flag;
Road:=FindRoadColor;
RadialRoadWalk(Road, 285, 265, 47, 0, 0);
Flag;
Road:=FindFallyRoadColor;
RadialRoadWalk(Road, 20, 1, 70, 0, -2);
Flag;
Mouse(650, 20, 3, 3, true);
Flag;
if FindSymbol(x, y, 'bank')then
begin
Mouse(x, y, 3, 3, true)
end
Flag;
MakeCompass('s');
OpenBankGlass('feb', true, true)
DepositAll;
CloseBank;
Banked:=Banked+28;
Players[CurrentPlayer].Loc :='Bank'
ATK1:=GetXP('Attack')
STR1:=GetXP('Strength')
DEF1:=GetXP('Defence')
HP1:=GetXP('Hitpoints')
end;
procedure ReturnGained;
begin;
StrGained:=STR1-STR;
AtkGained:=ATK1-ATK;
DefGained:=DEF1-DEF;
HpGained:=HP1-HP;
end;
{---------Main-Loop---------}
begin;
SetUpSRL;
DeclarePlayers;
ActivateClient;
Wait(1500);
if(not(LoggedIn))then
begin;
WriteLn('Ooops! You weren''t logged on. Logging on!')
LoginPlayer;
end;
SetFightMode(FightingStyle)
repeat WalkToFarm;
repeat AttackDerCows until
InvFull;
WalkToBank;
ReturnGained;
WriteLn('===========PROGRESS REPORT============')
WriteLn('==You have gotten '+IntToStr(Banked)+' cowhides so far==');
WriteLn('==Gained '+IntToStr(AtkGained)+' attack experience==');
WriteLn('==Gained '+IntToStr(StrGained)+' strength experience==');
WriteLn('==Gained '+IntToStr(DefGained)+' defence experience==');
WriteLn('==Gained '+IntToStr(HpGained)+' hitpoints experience==');
WriteLn('======================================');
until
TripNo = Trips;
end.
It works reasonably well. It (usually) makes it to the cow field and back to the bank, but it doesn't always know when you're fighting a cow already and it doesn't always pick up your hides. Possible bug with PopUp maybe? It only picks up the hides of the "PopUp screen thing" is not shifted up for whatever reason i.e. the hide is located near the bottom of the screen. I took out "find fight" in the FindFastRandoms because it kept giving false positives.
All my own script, except for the FindFastRandoms. I used mostly tutorials, looking at other scripts to see how certain things are done, and the SRL Manual to put it together. Although the other cow killer hide banker in the Fighting section gave me the idea to use an array for the cow colors. :)
EDIT: Added the code to my post 'cause everyone else in this forum does it too
{
To use it, just fill in the player array. The consts don't need to be
changed, as they seemed to work fine for me all the time, but use common
sense with them. If it doen't work, something's probably wrong with
the consts. I'm not entirely sure if the multiplayer works, having
only one account to test this with that won't get owned by the cows,
but it should work. Have fun!
}
program New;
{.include srl/srl.scar}
{.include srl/srl/skill/fighting.scar}
{.include srl/srl/extended/xObject.scar}
var Road, cx, cy, Banked, TripNo, StrGained, AtkGained, DefGained,
HpGained, HP, STR, ATK, DEF, HP1, STR1, ATK1, DEF1: integer;
var
CowColors: Array[0..4] of integer;
const
HideColor=11316663;//color of the cowhide on the ground
Trips=10; //how many trips to do
FightingStyle=2; //1 attack, 2 strength, 4 defence
RareTreesColor=168729;//minimap symbol
{--------------Player-Setup---------------}
procedure DeclarePlayers;
begin
HowManyPlayers := 1; //Number of players
NumberOfPlayers(HowManyPlayers)
CurrentPlayer:= 0;
Players[0].Name :='';
Players[0].Pass :='';
Players[0].Nick :='';
Players[0].Active :=True;
Players[0].Loc :='Bank'
NickNameBMP := CreateBitmapMaskFromText(Players[CurrentPlayer].Nick, UpChars);
CowColors[0]:=3821399; //color of the cow (try to pick a brownish color)
CowColors[1]:=1915460; //darker brown
CowColors[2]:=7371917; //beigeish
CowColors[3]:=3621203; //brownish again
CowColors[4]:=7042694; //beigeish
end;
{---------------------------------------------------------------}
{----------------I-think-everyone-knows-what-this-is------------}
function FindFastRandoms: Boolean; //Yoink! Got this from the WheatPicker thing.
var i: Integer;
begin
for i:=1 to 10 do
begin
if(not(LoggedIn))then Exit;
case I of
1: if FindDead then
Result := True;
2: if FindMod then
Result := True;
3: if FindMime then
Result := True;
4: if FindMaze then
Result := True;
5: if FindQuiz then
Result := True;
6: if FindDemon then
Result := True;
7: begin
if NoGameTab then
begin
Result := True;
Players[CurrentPlayer].loc := 'No GameTab';
Players[CurrentPlayer].Active := False;
Logout;
Exit;
end;
end;
8: begin
if InBlack then
begin
Result := True;
Players[CurrentPlayer].loc := 'InBlack';
Players[CurrentPlayer].Active := False;
Logout;
Exit;
end;
end;
9: if FindTalk then
Result := True;
end;
wait(1);
end;
end;
{---------------------------------------------}
{-------------Fally-Bank-To-Cow-Pen-----------}
procedure WalkToFarm;
begin
PerfectNorth;
HighestAngle;
ATK:=GetXP('Attack')
STR:=GetXP('Strength')
DEF:=GetXP('Defence')
HP:=GetXP('Hitpoints')
WriteLn('Starting number '+IntToStr(TripNo+1)+' trip.')
Road:=FindFallyRoadColor
RadialRoadWalk(Road, 251, 243, 50, 2, 0)
Flag
RadialRoadWalk(Road, 170, 185, 66, 0, 1)
Flag
RadialRoadWalk(Road, 175, 185, 55, 0, 0)
Flag
RadialWalkEx(x, y, MMCX, MMCY, RareTreesColor, 5, 100, 140, 57)
Flag
Mouse(695, 119, 4, 4, true)
Flag
if FindObjMultiText(cx, cy, 'pen', 'Open', 'Ope', 5270137, 50)then
Mouse(cx, cy, 5, 5, true) else
Mouse(250,190,5,5,true);
WriteLn('Made it')
TripNo:=TripNo+1
Players[CurrentPlayer].Loc :='Cowfield'
end;
{************************************************* ******************************
procedure RandomMovement;
By: Krazy_Meerkat
Description: Presses random arrow keys and moves the mouse. Able to press 2 keys simultaneously.
I modified it to only press the left and right keys, cause the other keys
messed up my program
************************************************** *****************************}
procedure RandomMovements;
begin
if ((Random(3) + 1) > 1) then
begin
if (Random(2) = 1) then
begin
if (Random(2) = 1) then
begin
KeyDown(VK_RIGHT);
end else
KeyDown(VK_LEFT);
Wait(15 + Random(15));
KeyDown(VK_LEFT);
Wait(15 + Random(15));
KeyUp(VK_RIGHT);
KeyUp(VK_LEFT);
Wait(300 + Random(500));
KeyUp(VK_LEFT);
end else ;
begin
if (Random(2) = 1) then
begin
KeyDown(VK_RIGHT);
end else
KeyDown(VK_LEFT);
Wait(Random(15));
KeyDown(VK_RIGHT);
Wait(300 + Random(500))
KeyUp(VK_RIGHT);
KeyUp(VK_LEFT);
Wait(Random(15));
KeyUp(VK_RIGHT);
end;
end else ;
MMouse((Random(330) + 8), (Random(490) + 8), 3, 3);
end;
{--------------------------------------------------------------------}
{--------------Killing-the-cows-and-reaping-their-hides--------------}
procedure AttackDerCows;
var i: Integer;
begin;
for i:=0 to 4 do
if FindColorAbstract(x, y, CowColors[i], 7, 4, 4, 515, 4, 515, 335, 4, 335)then
begin;
Mouse(x, y, 4, 4, false)
PopUp('ttack')
end;
wait(1000+random(2000))
OutFight;
RandomMovements;
if FindObjFast(cx, cy, 'ake', HideColor,1)then
begin;
Mouse(cx,cy,3,3,false)
PopUp('owhide')
end
FindNormalRandoms;
FindFastRandoms;
if (not(LoggedIn))then NextPlayer(false);
if(FindNewBox)then
SolveBox;
end;
{-------------------------------------------------}
{----------------Back-to-the-bank-----------------}
procedure WalkToBank;
begin;
MakeCompass('N');
Mouse(613, 30, 3, 3, true)
Flag;
if FindObjMultiText(cx, cy, 'pen', 'Open', 'Ope', 5270137, 50)then
begin;
Mouse(cx,cy,5,5,true)
end else
Mouse(250,190,5,5,true);
wait(3000)
RadialWalk(RareTreesColor , 180, 360, 72, 1, 0);
Flag;
Road:=FindRoadColor;
RadialRoadWalk(Road, 285, 265, 47, 0, 0);
Flag;
Road:=FindFallyRoadColor;
RadialRoadWalk(Road, 20, 1, 70, 0, -2);
Flag;
Mouse(650, 20, 3, 3, true);
Flag;
if FindSymbol(x, y, 'bank')then
begin
Mouse(x, y, 3, 3, true)
end
Flag;
MakeCompass('s');
OpenBankGlass('feb', true, true)
DepositAll;
CloseBank;
Banked:=Banked+28;
Players[CurrentPlayer].Loc :='Bank'
ATK1:=GetXP('Attack')
STR1:=GetXP('Strength')
DEF1:=GetXP('Defence')
HP1:=GetXP('Hitpoints')
end;
procedure ReturnGained;
begin;
StrGained:=STR1-STR;
AtkGained:=ATK1-ATK;
DefGained:=DEF1-DEF;
HpGained:=HP1-HP;
end;
{---------Main-Loop---------}
begin;
SetUpSRL;
DeclarePlayers;
ActivateClient;
Wait(1500);
if(not(LoggedIn))then
begin;
WriteLn('Ooops! You weren''t logged on. Logging on!')
LoginPlayer;
end;
SetFightMode(FightingStyle)
repeat WalkToFarm;
repeat AttackDerCows until
InvFull;
WalkToBank;
ReturnGained;
WriteLn('===========PROGRESS REPORT============')
WriteLn('==You have gotten '+IntToStr(Banked)+' cowhides so far==');
WriteLn('==Gained '+IntToStr(AtkGained)+' attack experience==');
WriteLn('==Gained '+IntToStr(StrGained)+' strength experience==');
WriteLn('==Gained '+IntToStr(DefGained)+' defence experience==');
WriteLn('==Gained '+IntToStr(HpGained)+' hitpoints experience==');
WriteLn('======================================');
until
TripNo = Trips;
end.