SRL Archive - OSR Help

Fight Script Issues


Zace

2015-04-19 17:21:43

Trying to simply make a reflection fighting script, that will loot items, and eat food when health is low. The eat food procedure is pretty buggy as of now I've tried to use some of Hoodz fighting script to resolve the issues but i cant get it to work that great. So right now it will just eat all the food in the inventory or eat one when the health reaches a certain point then not eat again. The item looter currently doesn't have a pickup function or procedure, although sometimes it will writeLN when finding the items in setupdrops and sometimes it won't.
Thanks for feedback or any help.

program Fighter;
{$DEFINE SMART}
{$i AeroLib/AeroLib.Simba}
{$i reflection/Reflection.simba}

const
GroundItems_Dist = 20;

var
MyPlayer: TReflectLocalPlayer;
AntibanLevel, randomHP : Integer;
Drops, Name: TStringArray;
DropsCount: TIntegerArray;

begin
MyPlayer.Username := 'UN';
MyPlayer.Password := 'Pass';
MyPlayer.Pin := '';
MyPlayer.Active := True;
MyPlayer.Create();
end;


procedure randomMouseInput(pnt:Tpoint; ranx, rany:integer);
begin
case random(3) of
0:humanMMouse(pnt, ranx, rany);
1:missMouse(pnt, ranx, rany);
2:mouse(pnt, ranx, rany, mouse_move);
end;
end;

function R_TileOnMS(Tile : TPoint; var OutputPoint : TPoint; x : integer = 0; y : integer = 0; z : integer = 0):boolean;
var tempB : TBox;
begin
OutputPoint := TReflectionTiles.TileToMS(Tile, x, y, z);
tempB := intToBox(MSX1, MSY1, MSX2, MSY2);
result := PointInBox(OutputPoint, tempB);
end;

function R_InteractTile(tile:Tpoint; action:string; x:integer = 0; y:integer = 0; z:integer = 0):boolean;
var RSTile : TPoint;
begin
if R_TileOnMS(Tile, RSTile, x, y, z) then begin
randomMouseInput(rsTile, 5, 5);
if(Reflect.Text.IsUpText(action)) then begin
FastClick(mouse_left);
result := didClick(true, 1000);
end else begin
if TReflectionText.OptionExists(action) then begin
FastClick(mouse_right);
result := Reflect.Text.ChooseOption(action);
end;
if not result then
randomMouseInput(Point(MSCX, MSCY), 500, 500);
end;
end;
end;

procedure dismissAllRandoms;
var i, j, me_indice:integer;
_npcs:TReflectNPCArray;
randoms:tstringarray;
begin
randoms := ['molly', 'niles', 'miles', 'giles', 'sandwich lady',
'drunken dwarf', 'genie', 'highwayman', 'dr jekyll', 'cap''n hand', 'security guard',
'rick turpentine', 'mysterious old man', 'frog', 'null', 'mime', 'sergeant damien', 'freaky forester',
'postie pete', 'tilt', 'flippa', 'leo', 'pillory guard', 'evil bob'];
_npcs.GetAll;
me_indice := TReflectLocalPlayer.GetPlayerIndex;
for i:=0 to high(_npcs) do begin
if (_npcs[i].getInteractingIndex = me_indice) then begin
for j:=0 to high(randoms) do begin
if (pos(randoms[j], lowercase(_npcs[i].getName)) > 0) then begin
if R_InteractTile(_npcs[i].getTile, 'Dismiss', 0, 0, 50) then begin
sleep(2500+random(1000));
writeln('Dismissed random: '+_npcs[i].getname+' Time Running: '+TimeRunning);
end;
end;
end;
end;
end;
end;


procedure AntiBan;
begin
case random(AntibanLevel) of
0..10: examineInv();
11..20: boredHuman();
21..30: pickUpMouse();
31..40: hoverSkill(Skill_strength, false);
41..50: randomRClick();
51..60: SleepAndMoveMouse(random(1000));
61..70: randomFKeys(true);
71..80: randomTab(true);
81..90: checkMovingObjs(true);
91..100: MMouseOffClient('random');
101..110: MMouseOffClient('top');
111..120: MMouseOffClient('bottom');
121..130: MMouseOffClient('left');
131..140: MMouseOffClient('right');
end;
end;


procedure customMouse(point: TPoint);
begin
case random(0, 6) of
0..2: BrakeMMouse(point, random(2), random(2), true);
3: BrakeMMouse(point, random(2), random(2), false);
4..5: MissMouse(point, random(2), random(2));
6: HumanMMouse(point, random(2), random(2));
end;
end;

function randomHPGenerate(): Integer;
begin
result := random(50, 70);
writeln('Random hp generated at: ' + toStr(result) + '%');
end;


procedure FightNpc;
var
Npc: TReflectNpc;
Point: TPoint;
I: Integer;
t: Timer;
begin
while not MyPlayer.IsUnderAttack do
begin
if Npc.Find('Moss giant') then // just change the name I.E 'Rat' 'Goblin'
Point := Npc.GetMSPoint;
begin
customMouse(Point);
fastClick(MOUSE_LEFT);
sleep(random(20, 120));
waitOption('Attack',350);
end;
if (didYellowClick()) then
begin
while MyPlayer.IsMoving and isLoggedIn do
sleep(random(250, 300));
FightNpc;
end;
while MyPlayer.IsUnderAttack do
begin
end;
end;
end;


procedure EatFood;
var
Food: TReflectInvItem;
I: Integer;
begin
gameTab(TAB_INV);
begin
Food.Find('Tuna');
Reflect.Mouse.Move(Food.GetPoint, 2, 2);
Reflect.Mouse.Click(Mouse_Left);
sleep(random(20,100));
end;
randomHP:=randomHPGenerate();
end;


Procedure setupDrops;
begin
{Drops will always be case sensetive and will always need a full name}
Drops := ['Nature rune','Iron arrow','Steel arrow', 'Curved bone', 'Long bone',
'Blood rune', 'Giant frog legs', 'Big bones'];

SetLength(DropsCount, Length(Drops));
end;


procedure handle_Drops;
var
Pile: TReflectGroundItemArray;
I, Ind: Integer;

begin
Pile.GetAll(GroundItems_Dist); {Notice how I use GroundItems_Dist here}
If Length(Pile) = 0 then
Exit;
For I:=0 to High(Pile)do
If InStrArrEx(Pile[I].GetName, Drops, Ind) then {Tries to match grounditem name with our names for a match}
begin
Writeln(Pile[I].GetName + ' found..');
DropsCount[Ind] := DropsCount[Ind] + Pile[I].GetQuantity;
end;
end;


begin
InitAL;
Reflect.Setup;
MyPlayer.Login;
setupDrops;
AntibanLevel := 7000;//higher the number the less the antiban is used
setAngle(ANGLE_HIGH);
repeat
if isLoggedIn then
begin
if MyPlayer.GetHealth < 20 then
EatFood;
end;
begin
dismissAllRandoms;
FightNpc;
AntiBan;
handle_Drops;
end;
if not isLoggedIn then
MyPlayer.Login;
until(false);
end.

Hyperion

2015-04-19 17:49:23

Just being nitpicky, but you also don't have quiz master and Capn' Arnav in your randoms list.
Might wanna add those in. :)

Zace

2015-04-19 18:02:59

From: zaboomasimba
Just being nitpicky, but you also don't have quiz master and Capn' Arnav in your randoms list.
Might wanna add those in. :)


Thanks man, lol.