Code: Select all
Program MagicResistance;
// v.1.04 (c) Edred
{$Include 'all.inc'}
var
i:integer;
k:integer;
ctime : TDateTime;
const
// ID корыта с водой.
WaterTrought=$4004FEE8;
// тип бинтов
Bint=$0E21;
BlBint=$0E20;
// Значение hp, с которого нужно начинать хилиться
CritLife=100;
// Значение маны, с которого нужно начинать медитировать
tmana=40;
// Какой закл кастовать на себя
// TypeCase='Lightning';
// TypeCast='Fireball';
TypeCast='Flame Strike';
// Реги
BPreg=$0F7A;
BMreg=$0F7B;
GAreg=$0F84;
GSreg=$0F85;
MRreg=$0F86;
NSreg=$0F88;
SAreg=$0F8C;
SSreg=$0F8D;
procedure getitems(item:cardinal);
// процедура берет из контейнера 20 шт указанного предмета
begin
if (count(item)=0) then
begin
findType(item,Ground);
if (FindCount > 0) then
begin
k := FindQuantity;
Grab(finditem,20);
wait(1000);
checksave;
case item of
Bint : addtosystemjournal('взял 20 bandages из ' + inttostr(k));
BPreg : addtosystemjournal('взял 20 BP из ' + inttostr(k));
BMreg : addtosystemjournal('взял 20 BM из ' + inttostr(k));
GAreg : addtosystemjournal('взял 20 GA из ' + inttostr(k));
GSreg : addtosystemjournal('взял 20 GS из ' + inttostr(k));
MRreg : addtosystemjournal('взял 20 MR из ' + inttostr(k));
NSreg : addtosystemjournal('взял 20 NS из ' + inttostr(k));
SAreg : addtosystemjournal('взял 20 SA из ' + inttostr(k));
SSreg : addtosystemjournal('взял 20 SS из ' + inttostr(k));
end;
end
else
begin
addtosystemjournal('Мало!!!');
repeat
wait(5000);
findType(item,Ground);
until (FindCount > 0);
Grab(finditem,20);
wait(1000);
checksave;
case item of
Bint : addtosystemjournal('взял 20 bandages из ' + inttostr(k));
BPreg : addtosystemjournal('взял 20 BP из ' + inttostr(k));
BMreg : addtosystemjournal('взял 20 BM из ' + inttostr(k));
GAreg : addtosystemjournal('взял 20 GA из ' + inttostr(k));
GSreg : addtosystemjournal('взял 20 GS из ' + inttostr(k));
MRreg : addtosystemjournal('взял 20 MR из ' + inttostr(k));
NSreg : addtosystemjournal('взял 20 NS из ' + inttostr(k));
SAreg : addtosystemjournal('взял 20 SA из ' + inttostr(k));
SSreg : addtosystemjournal('взял 20 SS из ' + inttostr(k));
end;
end;
end;
end;
procedure CleanBandages;
begin
if (Count(BlBint)>=20) then
begin
repeat
findtype(BlBint,backpack);
if (FindCount > 0) then
begin
checksave;
useobject(FindItem);
waitfortarget(5000);
if TargetPresent then TargetToObject(WaterTrought);
wait(1000);
end;
until (FindCount=0);
addtosystemjournal('очистил кровавые бинты');
end;
end;
procedure Medita;
begin
waitconnection(5000);
if (mana <= tmana) then
begin
ctime := Now;
i:=0;
useskill('meditation');
repeat
wait(200);
i:=i+1;
checksave;
until (InJournalBetweenTimes('reached full mana', ctime, Now)<>-1) or (i=300);
addtosystemjournal('медитация закончена');
end;
end;
procedure Cast2Self;
begin
waitconnection(5000);
case TypeCast of
'Fireball' : begin getitems(BPreg); getitems(SAreg); end;
'Lightning' : begin getitems(BPreg); getitems(MRreg); getitems(SAreg); end;
'Flame Strike' : begin getitems(SSreg); getitems(SAreg); end;
end;
checksave;
i:=0;
ctime := Now;
cast(TypeCast);
repeat
wait(200);
i:=i+1;
until TargetPresent or (InJournalBetweenTimes('fizzles', ctime, Now)<>-1) or (i=50);
if TargetPresent then TargetToObject(self);
wait(500)
if (InJournalBetweenTimes('fizzles', ctime, Now)=-1) then addtosystemjournal('каст закончен');
end;
procedure HealChar;
begin
waitconnection(5000);
if (Life < CritLife) then
begin
getitems(Bint);
while (Life < MaxLife) and (Count(Bint) > 0) do
begin
FindType(Bint, Backpack);
if TargetPresent then CancelTarget;
ctime := Now;
UseObject(FindItem);
WaitForTarget(5000);
If TargetPresent then TargetToObject(Self);
k := 0;
repeat
wait(100);
k := k + 1;
until (InJournalBetweenTimes('You put the bloody bandage|failed.', ctime, Now)<>-1) or (k > 300);
end;
if (Life=MaxLife) then addtosystemjournal('чар полностью вылечен');
end;
end;
Begin
FindDistance:=2;
while true do
begin
waitconnection(5000);
if TargetPresent then CancelTarget;
if (WarMode = true) then SetWarMode(false);
Cast2Self;
Medita;
HealChar;
CleanBandages;
end;
End.