Forum in READ ONLY mode! All questions and discussions on Discord official server, invite link: https://discord.gg/VxsGzJ7

Проблемма в скрипте на спарринг

тут можно задать вопрос по скриптингу
Post Reply
K. Flint
Posts: 1
Joined: 05.04.2006 8:16

Проблемма в скрипте на спарринг

Post by K. Flint »

В общем хочу что бы чар проверял кол-во хп аппонента и если оно меньше критического, хилил его, если больше критического юзал на него анатомию.
Попробовал это осуществить с помощью проверки:
...
CriticalHP = 50;
...
if (GetHp(Enemy) > CriticalHP) then
...
Но почему то это не сработало. Скрипт компилируется но попросто постоянно хилит, как буд то проверки нету. В общем объясните плизки, правельно ли я ввел проверку с помощью GetHp(Enemy) или надо по-другому?
На всяки случай выложу весь скрипт, вдруг проблемма в другом.
Program fighter;
var HungryTime, HealTime : Cardinal;
EnemyID, ArmorBox : cardinal;
UseHeater, UseTotem, CutCorpse : Boolean;
UseDagerTime, UseCatanaTime, UseHandsTime, DT, CT, HT : Cardinal;
Char : Array[1..2] of Cardinal;

Const
EnemyType1 = $0190;
EnemyType2 = $0191;
GhostType1 = $0192;
GhostType2 = $0193;
BandageType = $0E21;
DagerType = $0F51;
CatanaType = $13FE;
HeaterType = $1B76; {Need Setup}
StamPotionType = $0F0B;
ArmorBoxType = $0E40; {Need Setup}
CriticalHP = 50; {Need Setup}


{$Include 'all.inc'}







function OpenArmorBox : Boolean;
begin
WaitConnection(2000);
CheckSave;
ArmorBox := FindType(ArmorBoxType, Ground);
if ArmorBox = 0 then
begin
AddToSystemJournal('Error: ArmorBox not finded');
FullDisconnect;
Result := false;
Exit;
end
else Result := true;
UseObject(ArmorBox);
wait(2000);
end;



procedure Heal(Enemy : Cardinal);

var Bandages : Cardinal;
stime : TDateTime;

begin

Bandages := FindType(BandageType, Ground);
if Dead then Exit;
if (GetHp(Enemy) > CriticalHP) then
begin
UseSkill('Anatomy');
WaitTargetObject(enemy);
Wait(10000);
end;
if (GetHp(Enemy) < CriticalHP) and (not Dead) then
begin
if Bandages = 0 then
begin
AddToSystemJournal('Error: No bandages');
Wait(1000);
Exit;
end;
if TargetPresent then
begin
CancelTarget;
Wait(1000);
end;

Bandages := FindType(BandageType, Ground);
stime := Now;

WaitTargetObject(Enemy);
UseObject(Bandages);
WaitJournalLine(stime, 'you have healed your patient|Your patient is at full heath|You have resurrected|You could not heal him', 15000);
Wait(4000);
end;
end;



procedure CheckWeapon;
var WeaponID : Cardinal;
begin
if TargetPresent then
begin
CancelTarget;
Wait(1000);
end;
WaitConnection(2000);
CheckSave;
{Сначала проверим щит}
if (ObjAtLayer(LhandLayer) = 0) and UseHeater then
begin
UseObject(ArmorBox);
wait(3000);
if (findtype(HeaterType, Ground) = 0) then findtype(HeaterType, ArmorBox);
WeaponID := finditem;
if WeaponID = 0 then
begin
AddToSystemJournal('Error: Heater not finded');
end
else
begin
Equip(LhandLayer,WeaponID);
AddToSystemJournal('Heater is equiped');
end;
end;
//Если в руках есть оружие, то выходим.
if ObjAtLayer(RhandLayer) > 0 then Exit;
UseObject(ArmorBox);
wait(3000);
if ((DT + UseDagerTime > Timer) or (DT = 0)) and (UseDagerTime <> 0) then
begin
if DT = 0 then
begin
AddToSystemJournal('Begin of using Dager');
DT := Timer;
end;
if (findtype(DagerType, Ground) = 0) then findtype(DagerType, ArmorBox);
WeaponID := finditem;
if WeaponID = 0 then
begin
AddToSystemJournal('Error: Dager not finded');
DT := Timer - UseDagerTime;
Exit;
end;
Equip(RhandLayer,WeaponID);
AddToSystemJournal('Dager is equiped');
Exit;
end;
if ((CT + UseCatanaTime > Timer) or (CT = 0)) and (UseCatanaTime <> 0) then
begin
if CT = 0 then
begin
AddToSystemJournal('Begin of using Catana');
CT := Timer;
end;
if (findtype(CatanaType, Ground) = 0) then findtype(CatanaType, ArmorBox);
WeaponID := finditem;
if WeaponID = 0 then
begin
AddToSystemJournal('Error: Catana not finded');
CT := Timer - UseCatanaTime;
Exit;
end;
Equip(RhandLayer,WeaponID);
AddToSystemJournal('Catana is equiped');
Exit;
end;
if ((HT + UseHandsTime > Timer) or (HT = 0)) and (UseHandsTime <> 0) then
begin
if HT = 0 then
begin
AddToSystemJournal('Begin of using Hands');
HT := Timer;
end;
Exit;
end;
DT := 0;
CT := 0;
HT := 0;
end;


procedure CheckStam;
var StamPotion : Cardinal;
begin
if TargetPresent then
begin
CancelTarget;
Wait(1000);
end;
WaitConnection(2000);
CheckSave;
if Dead then Exit;
if Stam <> 0 then Exit;
if (findtype(StamPotionType,Ground) = 0) then findtype(StamPotionType,ArmorBox);
StamPotion := finditem;
if StamPotion = 0 then Exit;
UseObject(StamPotion);
end;


procedure CheckWar;
begin
if TargetPresent then
begin
CancelTarget;
Wait(1000);
end;
WaitConnection(2000);
CheckSave;
if (wartargetid <> EnemyID) or (iswarmode(self) = false) then attack(EnemyID);
if IsDead(EnemyID) then SetWarMode(false);
end;


procedure CheckDead;
var c : Integer;
begin
WaitConnection(2000);
CheckSave;
if Dead then
begin
AddToSystemJournal('I''m Dead. Waiting while anybody resurect me.');
SetWarMode(true);
UOSay('.forgivethee');
WaitGump('1');
wait(5000);
while (Dead) do
begin
Wait (2000);
WaitGump('1');
end;
wait (2000);
WaitConnection(2000);
CheckSave;
Hungry(1, -1);
c := 0;
while (HP < MaxHP) and (c < 3) and (not Dead) do
begin
UOSay('heal');
Wait(3000);
c := c + 1;
end;
end;
end;



procedure CheckGhost;
var c : Integer;
begin
WaitConnection(2000);
CheckSave;
if (GetType(EnemyID) <> GhostType1) and (GetType(EnemyID) <> GhostType2) then Exit;
AddToSystemJournal('Detecting Ghost. Trying resurect him.');
SetWarMode(false);
Heal(EnemyID);
Wait(2000);
WaitConnection(2000);
CheckSave;
Heal(EnemyID);
Wait(1000);
c := 0;
if Dead then Exit;
while (WarTargetID = 0) or (c > 15) do
begin
Wait(1000);
c := c + 1;
end;
end;





Begin
{Начальная иницилизация}
HungryTime := 0;
HealTime := 0;
DT := 0;
CT := 0;
HT := 0;
{Now Setup 3 times. 1 Hour = 60*60*1000}
UseDagerTime := 5 * 60 * 1000; {Need Setup} {Set 0 if you don't want use it}
UseCatanaTime := 0; {Need Setup} {Set 0 if you don't want use it}
UseHandsTime := 20 * 60 * 1000; {Need Setup} {Set 0 if you don't want use it}
UseHeater := true; {Need Setup}
UseTotem := false; {Need Setup}
CutCorpse := true; {Need Setup}
Char[1] := $01394244; {Need Setup}
Char[2] := $013DB038; {Need Setup}
FindDistance := 1;
WaitConnection(2000);
CheckSave;
CheckDead;
wait(5000);
if Self = 0 then
begin
AddToSystemJournal('Error : Self = 0.');
Exit;
end;
if (Char[1] <> Self) then EnemyID := Char[1]
else EnemyID := Char[2];
CheckGhost;
if not OpenArmorBox then Exit;
AddToSystemJournal('Open ArmorBox compete');
FindType(DagerType, ArmorBox);
AddToSystemJournal('There are ' + IntToStr(FindFullQuantity) + ' dagers');
FindType(CatanaType, ArmorBox);
AddToSystemJournal('There are ' + IntToStr(FindFullQuantity) + ' catanas');
FindType(HeaterType, ArmorBox);
AddToSystemJournal('There are ' + IntToStr(FindFullQuantity) + ' heaters');
FindType(StamPotionType, ArmorBox);
AddToSystemJournal('There are ' + IntToStr(FindFullQuantity) + ' stam potions');
FindType(BandageType, Ground);
AddToSystemJournal('There are ' + IntToStr(FindFullQuantity) + ' bandages');

SetARStatus(true);


while true do
begin
WaitConnection(2000);
CheckSave;




CheckDead;
CheckGhost;
CheckWar;
CheckWeapon;
CheckStam;




{Eat by timer}
if Timer > (HungryTime + (15 * 60 * 1000)) then
begin
WaitConnection(3000);
CheckSave;
CheckDead;
if TargetPresent then
begin
CancelTarget;
Wait(1000);
end;
Hungry(1, -1);
HungryTime :=Timer;
end;


Heal(EnemyID);


{--- Check corpse ---}
if CutCorpse then
begin
if FindType($2006, Ground) <> 0 then
begin
if TargetPresent then CancelTarget;
WaitTargetObject(FindItem);
if (FindType($0F51, ArmorBox) <> 0) then
begin
UseObject(FindItem);
wait(2000);
end
else if (FindType($0F51, BackPack) <> 0) then
begin
UseObject(FindItem);
wait(2000);
end;
end;
end;
{--- End Check corpse ---}

wait(1000);
end;




End.
L'inconnu
Novice
Novice
Posts: 73
Joined: 03.02.2006 8:46
Contact:

Post by L'inconnu »

стелс не умеет определять хп итп других чаров/нпс. проверяй у аппонента скриптом и говори некую фразу.
Post Reply