Code: Select all
Program Provoc;
var t :Integer;
res_all: Boolean;
Delay,Idle:Cardinal;
Animal : Array[1..10] of Cardinal;
res: Array[1..10] of Boolean;
cnt:Integer;
const
Basic_wait=5500; {in mSec.}
Animal_type=$000C;
Lute_type=$0EB3;
{$Include 'all.inc'}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////
Function Provoce(Animal : Cardinal) : Boolean;
var tmp_type: Word;
start_time: TDateTime;
tmr: Cardinal;
i: Integer;
begin
i:=0;
result:=TRUE;
tmp_type:=GetType(Animal);
if tmp_type <> Animal_type then result:=FALSE
else
begin
repeat
start_time := Now;
if TargetPresent then CancelTarget;
WaitTargetObject(Animal);
tmr:=Timer;
CheckSave;
UseSkill('Provocation');
WaitJournalLine(start_time,'Select the creature to provoke.|under|irritated|enrage|Your music doesnt seem to have any effect.|must|already|broke',40000);
if (InJournalBetweenTimes('You must|not seem|under|irritated|already|broke',start_time,Now) < 0) then
begin
WaitforTarget(10000);
if TargetPresent then TargetToObject(self);
WaitJournalLine(start_time,'Select a target to provoke this onto.|under|irritated|enrage|Your music doesnt seem to have any effect.|must|already|broke',40000);
if InJournalBetweenTimes('must|already doing',start_time,Now) >= 0 then wait(1000)
else if ((Timer - tmr) < Basic_wait) then wait(Basic_wait-(Timer - tmr));
if (InJournalBetweenTimes('already performing',start_time,Now) >=0) then i:=i+1;
if i>=15 then
begin
SetARStatus(TRUE);
Disconnect;
WaitConnection(10000);
i:=0;
end;
end;
until InJournalBetweenTimes('must|already doing|already performing|broke',start_time,Now) < 0;
end;
end;
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
Function Check_lute():Boolean;
var cnt_pack,cnt_ground : Integer;
tmp_serial: Cardinal;
begin
result:=TRUE;
cnt_pack:=Count(Lute_type);
cnt_ground:=CountGround(Lute_type);
if (cnt_pack = 0) AND (cnt_ground = 0) then result:=FALSE;
if (cnt_pack = 0) AND (cnt_ground > 0) then
begin
tmp_serial:=FindType(Lute_type,ground);
if tmp_serial <> 0 then
begin
Grab(tmp_serial,1);
repeat
wait(100);
until Count(Lute_type) > 0;
end;
end;
end;
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
function TimerEx(var T_Min : cardinal): boolean;
begin
result:=false;
if ((Timer>(Idle+(T_Min*1000*60))) or (Idle=0)) then
begin
result:=true;
Idle:=Timer;
end;
end;
///////////////////////////////////////////////////////////////////////////////////////
Function Find_animal():Integer;
var tmp_serial: Cardinal;
i:Integer;
begin
i:=1;
repeat
tmp_serial:=FindType(Animal_type,ground);
if FindCount > 0 then
begin
Animal[i]:=tmp_serial;
Ignore(tmp_serial);
i:=i+1;
end
else result:=0;
until (FindCount = 0);
result:=i;
IgnoreReset;
end;
/////////////////////////////////////////////////////////////////////////////////////////
Begin
Delay:=15;
Idle:=0;
FindDistance := 8;
FindVertical:=1;
tmp_dist:=0;
SetARStatus(TRUE);
res_all:=TRUE
cnt:=Find_animal();
While TRUE do
begin
if NOT Connected then SetARStatus(TRUE);
WaitConnection(30000);
if TimerEx(Delay) AND Connected then
begin
Hungry(1,ground);
cnt:=Find_animal();
end;
if NOT Check_lute then
begin
SetARStatus(FALSE);
Disconnect;
Exit;
end;
for t:=1 to cnt do
begin
CheckTargetError(20,1);
res[t]:=Provoce(Animal[t]);
if NOT res[t] then AddToSystemJournal('Animal '+IntToStr(Animal[t])+' is lost!');
end;
if (NOT res[1]) AND (NOT res[2]) then
begin
SetARStatus(FALSE);
Disconnect;
Exit;
end;
end;
End.