I guess I was lucky...
The first time I played Ultima Online was about 6 years ago and at that time I didn't know anything about programming... The first time I ever saw something similar to it was at Injection and at Sphere... I suppose I can say UO changed my life forever... Nowadays I'm studying computer science and learning how to program, learning pascal.
When the shard I used to play returned (TFG), UO was back to me.
And it happened as soon as I learned pascal enough to do any script for Stealth.
As I'm saying goodbye, maybe forever, I'm going to give my repaiment for this wondeful community, which helped me when I needed.
--------------------------------------------------------------------------------------
This macro need a few updates as I was using documentation's subprograms and I have only figured out that there were others procedures / functions after doing this script.
Example:
pole := FindType($0DBF, backpack);
useobject(pole);
instead of using UseType...
The macro is fully working 24/7 and it has comments in portuguese (should have done it in english), I hope you like it.
--------------------------------------------------------------------------------------
As in the future I want to make open source's programs I would like you guys to follow a small "license":
Don't remove the credits.
Thanks in advance.
--------------------------------------------------------------------------------------
As far as I can remember, there are 4 IDs you guys have to add, they have a comment warning you about it.
+++
Code: Select all
Program Fishing;
//
// Criado por Bad Knight para todos.
// Made by Bad Knight para todos.
//
// Por favor, não remova os créditos.
// Please, do not remove credits.
//
//
// Diagrama mostrando onde pode pegar peixe ou não. (X - pode, 0 - não pode, é o barco., # - é o seu char.):
//
// \x -6-5-4-3-2-1 0 1 2 3 4 5 6
// y\
// -6 X X X X 0 0 0 0 0 X X X X
// -5 X X X X 0 0 0 0 0 X X X X
// -4 X X X X 0 0 0 0 0 X X X X
// -3 X X X X 0 0 0 0 0 X X X X
// -2 X X X X 0 0 0 0 0 X X X X
// -1 X X X X 0 0 0 0 0 X X X X
// 0 X X X X 0 0 # 0 0 X X X X
// 1 X X X X 0 0 0 0 0 X X X X
// 2 X X X X X X X X X X X X X
// 3 X X X X X X X X X X X X X
// 4 X X X X X X X X X X X X X
// 5 X X X X X X X X X X X X X
// 6 X X X X X X X X X X X X X
//Mensagens que podem ser recebidas ao pescar.
//
//Mes1 = 'You pull out';
//Mes2 = 'You fish a while, but fail to catch anything.';
//Mes3 = 'There are no fish here.';
//Mes4 = 'That is too far away.';
//Mes5 = 'Try fishing in water.';
//Mes7 = 'Voce encontrou um Mapa !!!';
//
//
//Movimentos de um barco.
//Com1 = 'Raise Anchor';
//Com2 = 'Drop Anchor';
//Com3 = 'Forward';
//Com4 = 'Back';
//Com5 = 'Left';
//Com6 = 'Right';
//Com7 = 'Stop';
//Com8 = 'Turn Left';
//Com9 = 'Turn Right';
//Answer1 = 'Aye';
//Answer2 = 'We've stopped Cap'n';
//Answer3 = 'There's a boat next to you.'
//Answer4 = 'We cannot turn that way Cap'n'
{$Include 'all.inc'}
var
x, y, i, j : integer;
Time : TDateTime;
fish : array [1..4] of integer;
map : array [1..2] of integer;
fishBox, pole, objeto : cardinal;
procedure fecharPorta(chave, porta : cardinal);
var sair : boolean;
begin
repeat
sair := true;
Time := Now;
UseObject(chave);
WaitTargetObject(porta);
wait(200);
if InJournalBetweenTimes('unlock', Time, Now) >= 0 then
sair := false;
until sair;
end;
procedure fecharBarco;
var portaEsquerda, portaDireita, chave : cardinal;
begin
chave := $400485AB; //Colocar o ID da chave do barco.
portaEsquerda := $400485C1; //Colocar o ID da porta (prancha) esquerda.
portaDireita := $400485CF; //Colocaro ID da porta (prancha) direita.
UseObject(backpack);
wait(200);
if TargetPresent then
CancelTarget;
fecharPorta(chave, portaEsquerda);
fecharPorta(chave, portaDireita);
wait(200);
end;
procedure virar;
var TimeInterno : TDateTime;
loop1, loop2 : integer;
begin
TimeInterno := Now;
UOSay('Turn Left');
wait(200);
if (inJournalBetweenTimes('boat|cannot', TimeInterno, Now) >= 0) then //Obstáculo
begin
TimeInterno := Now;
loop1 := 0;
UOSay('Right');
repeat
wait(100)
loop1 := loop1 + 1;
until (inJournalBetweenTimes('boat|cannot|stopped', TimeInterno, Now) >= 0) OR (loop1 >= 50);
if (loop1 < 50) then //Obstáculo à direita.
begin
TimeInterno := Now;
loop2 := 0;
UOSay('Left');
repeat
wait(100)
loop2 := loop2 + 1;
until (inJournalBetweenTimes('boat|cannot|stopped', TimeInterno, Now) >= 0) OR (loop2 >= 50);
if (loop2 < 50) then //Obstáculo à esquerda.
begin
UOSay('Back');
wait(5000);
virar;
end;
end;
end;
end;
procedure mover;
var TimeInterno : TDateTime;
loop : integer;
begin
TimeInterno := Now;
loop := 0;
UOSay('Forward');
repeat
wait(100)
loop := loop + 1;
until (inJournalBetweenTimes('stopped', TimeInterno, Now) >= 0) OR (loop >= 150);
if (loop < 150) then //Obstáculo à frente.
begin
virar;
mover;
end
else
begin
UOSay('Stop');
wait(200);
end;
end;
procedure useObjectIn(objeto : cardinal; x, y : integer);
var TimeInterno : TDateTime;
k : integer;
begin
if TargetPresent then
CancelTarget;
TimeInterno := Now;
UseObject(objeto);
WaitTargetTile(0, x, y, 251);
k := 0;
repeat
wait(100);
k := k + 1;
until (inJournalBetweenTimes('pull out|while|no|too|fishing|fail|encontrou', TimeInterno, Now) >= 0) OR (k > 300);
if (inJournalBetweenTimes('pull out|fail', TimeInterno, Now) >= 0) then
useObjectIn(objeto, x, y);
end;
procedure contarPeixesMapas(fishbox : cardinal);
var a, b, m, p: integer;
begin
useobject(fishbox)
wait(200);
for a := 1 to 4 do
begin
FindType(fish[a],fishbox);
p:= p + FindQuantity; // Contando os Fishs
end;
for b := 1 to 2 do
begin
FindType(map[b],fishbox);
m:= m + FindCount; // Contando os Maps
end;
Addtosystemjournal('O Hatch possui: ' + inttostr(p) + ' Peixes. Valor Arrecadado: ' + inttostr(p*6) + ' Kgps. Maps: ' + inttostr(m) + ' unidades')
end;
begin
Unequip(RhandLayer);
Unequip(LhandLayer);
wait(200);
fishBox := $400485D1; //Colocar o ID do baú do barco.
pole := FindType($0DBF, backpack);
fish[1] := $09CC;
fish[2] := $09CD;
fish[3] := $09CE;
fish[4] := $09CF;
map[1] := $14EB;
map[2] := $14EC;
SetARStatus(true); //Reconnector
Hungry(1, backpack);
repeat
contarPeixesMapas(fishBox);
fecharBarco;
for x := -6 to 6 do //Muda o alvo no eixo X.
begin
for y := -6 to 6 do //Muda o alvo no eixo Y.
begin
ClearJournal;
if (y < 2) AND ((x > -3) OR (x < 3)) then
continue;
Time := Now;
UseObjectIn(pole, GetX(self) + x, GetY(self) + y);
UseObject(fishBox); //Abre o baú do barco para poder jogar o peixe / mapa dentro dele.
if (inJournalBetweenTimes('pull out', Time, Now) >= 0) then //Verifica se pegou algum peixe.
for i := 1 to 4 do //Para tentar todos os tipos de peixe.
if FindType(fish[i], ground) > 0 then
begin
objeto := FindType(fish[i], ground);
MoveItem(objeto, 0, fishBox, 0, 0, 0); //Move o peixe para o baú do navio.
wait(200);
end
else
if (inJournalBetweenTimes('encontrou', Time, Now) >= 0) then //Verifica se pegou algum mapa do tesouro.
for j := 1 to 2 do //Para tentar todos os tipos de mapa.
if FindType(map[j], ground) > 0 then
begin
objeto := FindType(map[j], ground);
MoveItem(objeto, 0, fishBox, 0, 0, 0); //Move o mapa do tesouro para o baú do navio.
wait(200);
end;
end;
end;
ClearJournal
Mover;
wait(500);
until False;
End.