Heya,
In my first autofighter, the attacking loop i built is as follows:
SCAR Code:
repeat
if not InFight then begin
FindNormalRandoms;
if(FightNPC(FoeColors, 5, 1000)) then begin
if InFight then begin
writeln('Foe attacked!');
wait(200+random(800));
end
end
end;
wait(300 +random(700));
until false;
// FoeColors is an array.
// First "IF" makes sure the attacking only occurs if not in fight.
// Second "IF" attacks the foe.
// Third "IF" checks whether the attacking has been successful. If not, the first
// IF will be "True" and in 2 seconds max, the script will try again.
(I put some comments under it for readability). Ok, the loop was a bit more than this, but I removed irrelevant pieces of code.
I thougt: "This is rather ugly in the main loop, I want to have a function/procedure doing this...". So i wrote:
SCAR Code:
function FightFoe(FoeColors: array[1..6] of Integer; Foe : Integer) : Boolean;
begin
if(FightNPC(FoeColors, 5, 1000)) then begin
if InFight then begin
writeln('Foe attacked!');
wait(200+random(800));
Result:=InFight;
end
else Result:=Infight;
end
else Result:=False;
end;
This function doesn't seem to work, SCAR even doesnt recognize it in the function list to the right (where it does recognize other functions). What is wrong with my code?
PS The Integer FOE is used to count attacked Foe's. it is used in the whole code; irrelevant.
Thank you!