Trying to make a fighting script, just for fun, like you do.
Anyways, got to the fighting part...and it didn't go so well. The FightNPC command works, but not how I want it to. It only attacks mobs that are within about a 1 cell distance. My pathetic attempt at creating a Find+Attack procedure failed, kinda. It works in a manner of speaking...just not well...and would be detectable I'm sure. So its really just the finding and attacking mobs thats screwing me up.
The timer stuff works well, as does the fightmode stuff. I'm not too sure how well the random detection is, as I would never use a fight script for more than a few minutes on each character. The antiban...I don't think it does anything...ever...its just for looks. While you guys take a gander at the fighting situation I'll work on getting food implemented.
SCAR Code:{------------------------------Script Info-------------------------------------|
| ScriptName = BubFighter |
| Author = Bubbinator |
| Description = Fights Stuff |
| Version = 1 |
| SRL Version = 4.0 Rev 17 |
| SCAR Version = 3.15 |
| Date = 7/11/08 |
|------------------------------------------------------------------------------}
{.include SRL/SRL.scar}
{.include SRL/SRL/Skill/Fighting.scar}
const
TimeToFight =5;//Minutes for each player to fight.
var
PlayerStart, BeginTime: Integer;
MobColors: Array of integer;
procedure DeclarePlayers;
Begin
NumberOfPlayers(2);//Change to reflect number of players.
CurrentPlayer := 0;
Players[0].Name :='';
Players[0].Pass :='';
Players[0].Nick :='';
Players[0].Active :=True;
Players[0].Integers[0] := ;//First Mob Color
Players[0].Integers[1] := ;//Second Mob Color
Players[0].Skill := 'strength'; //Stat to train
Players[0].Strings[0] := '';//Name of mob
Players[1].Name :='';
Players[1].Pass :='';
Players[1].Nick :='';
Players[1].Active :=True;
Players[1].Integers[0] := 0;//
Players[1].Integers[1] := 0;//
Players[1].Skill := 'attack'; //Stat to train
Players[1].Strings[0] := '';//Name of mob
{Players[2].Name :='';
Players[2].Pass :='';
Players[2].Nick :='';
Players[2].Active :=True;
Players[2].Integers[0] := 0;//
Players[2].Integers[1] := 0;//
Players[2].Skill := 'strength'; //Stat to train
Players[2].Strings[0] := '';//Name of mob
Players[3].Name :='';
Players[3].Pass :='';
Players[3].Nick :='';
Players[3].Active :=True;
Players[3].Integers[0] := 0;//
Players[3].Integers[1] := 0;//
Players[3].Skill := 'strength'; //Stat to train
Players[3].Strings[0] := '';//Name of mob
Players[4].Name :='';
Players[4].Pass :='';
Players[4].Nick :='';
Players[4].Active :=True;
Players[4].Integers[0] := 0;//
Players[4].Integers[1] := 0;//
Players[4].Skill := 'strength'; //Stat to train
Players[4].Strings[0] := '';//Name of mob}
end;
procedure Food;
var
i: Integer;
begin
if(not(loggedin))then exit;
if(HPPercent > 60) then exit;
begin
gametab(4);
if (not(InvEmpty)) then
begin
repeat
for i := 0 to (InvCount) do
MouseItem(i, False);
If IsUpText('Eat') then
ChooseOption('Eat');
Wait(250 + Random(300));
until (HPPercent > 60)
end;
end;
end;
procedure Antiban;
begin
if(not(loggedin))then exit;
begin
case Random(4) of
0: HoverSkill('random', false);
1: Wait2(Random(1000), true);
2: PickUpMouse;
3: RandomRClick;
end;
end;
end;
procedure FightMonster;
var
x, y, i: Integer;
begin
if(not(loggedin))then exit;
For i := 1 to 5 Do
If FightNPC(MobColors, 5, (500 + Random(500))) then
Break;
{repeat
FindObjCustom(x, y, [Players[CurrentPlayer].Strings[0]], MobColors, 5);
MMouse(x, y, 0, 0)
If IsUpText('ttack') then
begin
case Random(2) of
0: Mouse(x, y, 3, 3, True);
1: begin
Mouse(x, y, 3, 3, False);
ChooseOption('ttack');
end;
end;
end;
Wait(200 + Random(300))
until InFight}
If InFight then
repeat
Wait((50) + Random(200))
FindNormalRandoms;
Antiban;
until not(InFight);
Food;
end;
procedure FMode;
begin
if(Players[CurrentPlayer].Skill='attack') then SetFightMode(1);
if(Players[CurrentPlayer].Skill='strength') then SetFightMode(2);
if(Players[CurrentPlayer].Skill='defence') then SetFightMode(4);
end;
procedure SetPlay;
begin
if(not(loggedin))then exit;
SetAngle(true);
MakeCompass('n');
FMode;
SetRun(True);
MobColors := [Players[CurrentPlayer].Integers[0], Players[CurrentPlayer].Integers[1]];
MarkTime(PlayerStart);
end;
procedure FLoop;
begin
if(not(loggedin))then LoginPlayer;
repeat
SetPlay;
repeat
FightMonster;
until (TimeFromMark(PlayerStart)) > (TimeToFight * 60000);
Wait((5000) + Random(1000));
Antiban;
FindNormalRandoms;
If(loggedin)then Logout;
NextPlayer(True);
if(not(loggedin))then LoginPlayer;
until False;
end;
procedure Setup;
begin
SetupSRL;
DeclarePlayers;
MarkTime(BeginTime);
ActivateClient;
Wait(Random(1000));
if(not(loggedin))then LoginPlayer;
end;
begin
Setup;
repeat
FLoop;
until False;
end.
Update: The food thing, which should work...I think... Used santa's suggestion about the FightNPC as a boolean, worked wonders, thanks much. Still have the problem of little to no discrimination of mobs outside of a one cell distance, would the tolerance have any effect on that?


Reply With Quote






