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

Помогите с 1 простеньким вопросом

тут можно задать вопрос по скриптингу
Post Reply
Ooops
Neophyte
Neophyte
Posts: 11
Joined: 26.10.2010 14:27

Помогите с 1 простеньким вопросом

Post by Ooops »

HomeRuneIndex = 0; если руна в рун буке первая, то какое число писать вместо нуля? Заранее благодарен
CFA
Developer
Developer
Posts: 492
Joined: 20.04.2006 6:03
Contact:

Re: Помогите с 1 простеньким вопросом

Post by CFA »

Ooops wrote:HomeRuneIndex = 0; если руна в рун буке первая, то какое число писать вместо нуля? Заранее благодарен
думаю на разных шардах номера рун рассчитываются по своему.
Например на моем шарде номер руны если реколится с помощью регов рассчитывается как порядковый_номер*2, а для реколла с помощью зарядов рунбука как порядковый_номер+600
Ooops
Neophyte
Neophyte
Posts: 11
Joined: 26.10.2010 14:27

Post by Ooops »

тоесть если я одет в 100 лрк, руна в рун бук первая по счёту, значит получится HomeRuneIndex = 2, я правильно понял?
Ooops
Neophyte
Neophyte
Posts: 11
Joined: 26.10.2010 14:27

Post by Ooops »

Я пытаюсь настроить скрипт мининг са, ввёл все переменные запускаю скрипт возле дома, он реколится на первую руну в шахте копает руду наберает 400 веса и должен реколится домой скидывать руду в сундук, но етого не делает и вместо етого руколится на ту точку где стоит при етом пишется что точка заблокирована и все, так вечно, зашел на клиент посмотреть что делает, он открывает рун буку с руной домой пишет Send Gump reply from stealth и открывает рун буку по местам копки и пытается среколится туда) подскажи пожалуйсто в чём может быть проблема, я вот и решил что неправильно забитый индекс руны домой и поэтому он и не может домой среколится )
Fenix
Developer
Developer
Posts: 275
Joined: 24.08.2010 7:20
Location: Ставрополь
Contact:

Post by Fenix »

Давай ты таки выложишь полный скрипт. А то я чувствую ты там понаменял того чего не нужно. Если при реколе домой он открывает рунбуку с рунами к шахтам, значит как домашняя рунбука у него прописан ID рунбуки к шахтам. Если админ твоего шарда - Wyatt, то скрипт точно рабочий, нужно только правильно некоторые переменные исправить.
Помните – ничто так не защищает ваши зубы 12 часов днем и 12 часов ночью как уважительное отношение к окружающим.
"Многие из вас знакомы с достоинствами программиста. Их всего три, и разумеется это: лень, нетерпеливость и гордыня"© Larry Wall
Ooops
Neophyte
Neophyte
Posts: 11
Joined: 26.10.2010 14:27

Post by Ooops »

program Mining;

const
Anvile = $40CB2B3B;
IngotsStorage = $402064C1;
IngotsType = $1BF2;

HomeRuneBook = $404402FB;
HomeRuneIndex = 01;
RuneBookShift = 75; //50 for Recal, 75 for Sacred Journey, 100 for Gate Travel

MiningType = $0F39;

TinkerType = $1EB8;
TKNumFirst = 8;
TKNumSecond = 23;

TKMinerNumFirst = 8;
TKMinerNumSecond = 72;

IronColor = $0000;
IronCount = $40;

WaitTime = 1000;
RecalTime = 5000;
WaitCycles = 7;
LagWait = 10000;

var
Terminated: Boolean;
CurrentRune: Byte;
CurrentBook: Integer;
OreTypes: array of Word;
RuneBooks: array of Cardinal;
MiningTool: Cardinal;
TinkerTool: Cardinal;

procedure EventMinerGump(Serial, GumpID, X, Y: Cardinal);
begin
if NumGumpButton(0, TKMinerNumSecond) then Exit;
if NumGumpButton(0, TKMinerNumFirst) then Exit;
while IsGump do CloseSimpleGump(0);
end;


procedure EventTinkerGump(Serial, GumpID, X, Y: Cardinal);
begin
if NumGumpButton(0, TKNumSecond) then Exit;
if NumGumpButton(0, TKNumFirst) then Exit;
while IsGump do CloseSimpleGump(0);
end;


function CheckMiningTool: Boolean; //New
begin
CheckLag(LagWait);
FindType(MiningType, Backpack);
if GetType(MiningTool) <> MiningType then MiningTool := FindItem;
Result := FindCount > 0;
end;


function CheckTinkerTool: Boolean; //New
begin
CheckLag(LagWait);
FindType(TinkerType, Backpack);
if GetType(TinkerTool) <> TinkerType then TinkerTool := FindItem;
Result := FindCount > 1;
end;

procedure CreateTKTools;//New
var
Counter: Cardinal;
begin
AddToSystemJournal('Делаем тинкер тузлы');
SetEventProc(evIncomingGump, 'EventTinkerGump');
UseObject(TinkerTool);
Counter := 0;
while True do begin
if (Dead)
or (not Connected)
or (CheckTinkerTool) then begin
SetEventProc(evIncomingGump, '');
Break;
end else Wait(1000);
Inc(Counter);
if Counter > WaitCycles then begin
SetEventProc(evIncomingGump, '');
Break;
end;
end;
while IsGump do CloseSimpleGump(0);
AddToSystemJournal('Сделали тинкер тузлы');
end;

function CreateMiningTools: Boolean;//New
var
Counter: Cardinal;
begin
AddToSystemJournal('Делаем минер тузлы');
SetEventProc(evIncomingGump, 'EventMinerGump');
if not CheckTinkerTool then begin
CreateTKTools;
end;
UseObject(TinkerTool);
Counter := 0;
while True do begin
if (Dead)
or (not Connected)
or (CheckMiningTool) then Break;
Inc(Counter);
if Counter > WaitCycles then Break;
Wait(1000);
end;
SetEventProc(evIncomingGump, '');
while IsGump do CloseSimpleGump(0);
Result := CheckMiningTool;
AddToSystemJournal('Сделали минер тузлы');
end;

procedure SmellOre; //New
var
CurOre, CurIndex: Integer;
CurItem: Cardinal;
List: TStringList;
begin
try
List := TStringList.Create;
for CurOre := 0 to Length(OreTypes) - 1 do begin
if Dead or not Connected then Exit;
CheckLag(LagWait);
FindType(OreTypes[CurOre], Backpack);
List.Clear;
if GetFindedList(List) then begin
CurIndex := 0;
while CurIndex < List.Count do begin
if Dead or not Connected then Exit;
CurItem := StrToInt('$' + List.Strings[CurIndex]);
CheckLag(LagWait);
if (GetType(CurItem) <> OreTypes[CurOre])
or (GetQuantity(CurItem) < 2) then begin
Inc(CurIndex);
end else begin
if TargetPresent then CancelTarget;
UseObject(CurItem);
CheckLag(LagWait);
Wait(WaitTime);
if TargetPresent then begin
TargetToObject(Anvile);
CheckLag(LagWait);
Wait(WaitTime);
end;
CheckLag(LagWait);
end;
end;
end;
end;
finally
List.Free;
end;
end;

procedure MoveIngots; //New
var
List: TStringList;
CurIndex: Integer;
CurIngot: Cardinal;
CurIron: Cardinal;
StartCount, ToMove: Integer;
begin
CheckLag(LagWait);
FindType(IngotsType, BackPack);
CurIron := 0;
try
List := TStringList.Create;
if GetFindedList(List) then begin
CurIndex := 0;
while CurIndex < FindCount do begin
if Dead or not Connected then Exit;
CurIngot := StrToInt('$' + List.Strings[CurIndex]);
CheckLag(LagWait);
StartCount := GetQuantity(CurIngot);
if (GetColor(CurIngot) = IronColor)
and (CurIron < IronCount) then begin
ToMove := StartCount - (IronCount - CurIron);
end else begin
ToMove := StartCount;
end;
if ToMove > 0 then begin
if MoveItem(CurIngot, ToMove, IngotsStorage, $FFFF, $FFFF, 0) then begin
Inc(CurIndex);
CurIron := CurIron + (StartCount - ToMove);
CheckLag(LagWait);
Wait(WaitTime);
end;
end else begin
Inc(CurIndex);
CurIron := CurIron + StartCount;
end;
end;
end;
finally
List.Free;
end;
end;


function RecallRune(RuneBook: Cardinal; Rune: Byte):Boolean; //New
var
Counter: Byte;
X, Y: Word;
begin
Result := False;
X := GetX(Self);
Y := GetY(Self);
CheckLag(LagWait);
Wait(WaitTime);
while Isgump do CloseSimpleGump(0);
if Dead or not Connected then Exit;
UseObject(RuneBook);
CheckLag(LagWait);
Counter := WaitCycles;
while Counter > 0 do begin
if IsGump then Break;
Wait(WaitTime);
CheckLag(LagWait);
Inc(Counter);
end;
if IsGump then begin
if NumGumpButton(0, RuneBookShift + Rune) then begin
CheckLag(LagWait);
Wait(RecalTime);
CheckLag(LagWait);
Result := (X <> GetX(Self)) or (Y <> GetY(Self));
end else Result := False;
end else Result := False;
end;


function GoBase: Boolean; //New
begin
Result := RecallRune(HomeRuneBook, HomeRuneIndex);
end;


function NextRune: Boolean; //New
var
Counter: Cardinal;
begin
Inc(CurrentRune);
if CurrentRune > 15 then begin
CurrentRune := 0
Inc(CurrentBook);
if CurrentBook >= Length(RuneBooks) then CurrentBook := 0;
end;
for Counter := 0 to WaitCycles do begin
if Dead or not Connected then Exit;
Result := RecallRune(RuneBooks[CurrentBook], CurrentRune);
if Result then Break;
Result := RecallRune(RuneBooks[CurrentBook], CurrentRune);
if Result then Break;
GoBase;
Wait(1000);
end;
end;


procedure CheckState;
begin
if MaxWeight < Weight + 40 then begin
while True do begin
if Dead or not Connected then Exit;
if GoBase() then Break;
if GoBase() then Break;
if not RecallRune(RuneBooks[CurrentBook], CurrentRune) then Wait(10000);
end;

SmellOre;
MoveIngots;

while True do begin
if Dead or not Connected then Exit;
if RecallRune(RuneBooks[CurrentBook], CurrentRune) then Break;
if RecallRune(RuneBooks[CurrentBook], CurrentRune) then Break;
if GoBase() then Continue;
if not NextRune then Wait(10000);
end;
end;
while not CheckMiningTool do begin
if Dead or not Connected then Exit;
CreateMiningTools;
end;
end;


procedure Mine(X, Y: Integer);
var
StaticData: TStaticCell;
Tile: Word;
Z: ShortInt;
Finded: Boolean;
Counter: Byte;
StartTime: TDateTime;
i: Integer;
begin
Finded := False;
StaticData := ReadStaticsXY(X, Y, WorldNum);
for i := 0 to StaticData.StaticCount - 1 do begin
if i >= StaticData.StaticCount then Break;
if (GetTileFlags(2, StaticData.Statics.Tile) and $200) = $200 then begin
Tile := StaticData.Statics.Tile;
Z := StaticData.Statics.Z;
Finded := True;
Break;
end;
end;

CheckState();
while Finded do begin
if Dead or not Connected then Exit;
if TargetPresent then CancelTarget;
while not CheckMiningTool do begin
if Dead or not Connected then Exit;
CreateMiningTools;
end;
CheckLag(LagWait);
Wait(WaitTime);
UseObject(MiningTool);
CheckLag(LagWait);
WaitForTarget(WaitTime);
if TargetPresent then begin
StartTime := Now;
TargetToTile(Tile, X, Y, Z);
Counter := WaitCycles;
Finded := False;
while (not Finded) and (Counter > 0) do begin
CheckLag(LagWait);
if InJournalBetweenTimes('t mine there|is too far away|cannot be seen|is no metal here to mine', StartTime, Now) > 0 then Exit;
if InJournalBetweenTimes('put it in your backpack|loosen some rocks but fail to find any useable ore|have worn out your tool', StartTime, Now) > 0 then Finded := True;
if Not Finded then Wait(200);
Dec(Counter);
end;
CheckState();
end;
end;
end;

procedure MinePoint; //New
var
X, Y: Word;
begin
X := GetX(Self);
Y := GetY(Self);
Mine(X, Y);
Mine(X + 1, Y);
Mine(X + 1, Y + 1);
Mine(X, Y + 1);
Mine(X - 1, Y + 1);
Mine(X - 1, Y);
Mine(X - 1, Y - 1);
Mine(X, Y - 1);
Mine(X + 1, Y - 1);
Mine(X + 2, Y + 2);
Mine(X - 2, Y + 2);
Mine(X - 2, Y - 2);
Mine(X + 2, Y - 2);
end;

begin

RuneBooks := [$4004A1DE, $4020DD60];
OreTypes := [$19B7, $19B8, $19B9, $19BA];

CurrentBook := 0;
CurrentRune := 0;

SetEventProc(evIncomingGump, '');

while not Terminated do begin
if Dead then begin
Terminated := True;
Continue;
end;
if not Connected() then begin
Connect();
Wait(10000);
Continue;
end;
NextRune;
MinePoint;
end;
end.

И так вот в общем-то скрипт, с меню тинкера я разобрался, проверил делает лопаты. Собственно в чём суть проблемы, понаблюдал за действиями чара с самого начала и вот что пишется вжурнале после того как запустил скрипт возле платформы:

[15:31:20:359] System: System New default location set.
[15:31:26:734] System: System New default location set.
[15:31:35:265] System: System New default location set.
[15:31:41:656] System: System New default location set.
[15:31:50:171] System: System New default location set.
[15:31:56:515] System: System New default location set.
[15:32:05:046] System: System New default location set.
[15:32:11:515] System: System New default location set.
[15:32:20:062] System: System New default location set.
[15:32:26:359] System: System New default location set.
[15:32:35:109] System: System New default location set.
[15:32:41:484] System: System New default location set.
[15:32:50:312] System: System New default location set.
[15:32:56:671] System: System New default location set.
[15:33:05:218] System: System New default location set.
[15:33:11:546] System: System New default location set.
[15:33:20:921] System: System You do not have that spell!
[15:33:27:140] System: System You do not have that spell!
[15:33:35:593] System: System You do not have that spell!
[15:33:41:796] System: System You do not have that spell!
[15:33:50:140] System: System You do not have that spell!
[15:33:56:343] System: System You do not have that spell!
[15:34:04:750] System: System You do not have that spell!
[15:34:11:000] System: System You do not have that spell!
[15:34:19:515] System: System You do not have that spell!
[15:34:25:734] System: System You do not have that spell!
[15:34:34:250] System: System You do not have that spell!
[15:34:40:468] System: System You do not have that spell!
[15:34:48:812] System: System You do not have that spell!
[15:34:55:000] System: System You do not have that spell!
[15:35:03:531] System: System You do not have that spell!
[15:35:09:718] System: System You do not have that spell!
[15:35:18:843] System: System You do not have that spell!
[15:35:25:093] System: System You do not have that spell!
[15:35:33:421] System: System You do not have that spell!
[15:35:39:640] System: System You do not have that spell!
[15:35:48:015] System: System You do not have that spell!
[15:35:54:203] System: System You do not have that spell!
[15:36:02:593] System: System You do not have that spell!
[15:36:08:828] System: System You do not have that spell!
[15:36:17:296] System: System You do not have that spell!
[15:36:23:515] System: System You do not have that spell!
[15:36:31:984] System: System You do not have that spell!
[15:36:38:203] System: System You do not have that spell!
[15:36:46:671] System: System You do not have that spell!
[15:36:52:937] System: System You do not have that spell!
[15:37:01:468] System: System You do not have that spell!
[15:37:07:671] System: System You do not have that spell!
[15:37:16:718] System: 4° 34'S, 50° 24'E
[15:37:16:734] BJlagbIKa: BJlagbIKa Sanctum Viatas
[15:37:23:031] System: System Where do you wish to dig?
[15:37:24:031] System: System You dig some iron ore and put it in your backpack.


С журнала вы видим что чар выбирает дефолтную руну(по которой хочет среколится в шахту), при етом наблюдая на клиенте я вижу что чар открывает все рун буки ( и домой и 2 по шахтам) поочереди - хз зачем, зачем он столько раз выбирает дефолтную руну, далее - пытаемся среколится пишет у вас нету такого спела, в скрипте я правильно поставил метод рекола 75-sacred journey - снова непонятно почему скрипт так долго не может среколится и вот наконец-то он реколится начинает капать, выкапывает руду и нам нужно домой переплавить и положить ее в сундук,но увы чар не реколится домой снова открывает все рб поочереди и пытается реколится к 1 точке копания на которой он уже стоит, естественно у него ето не выходит так как точка им же заблокирована) Я думаю что проблема в строке : HomeRuneIndex = 01; так как я не знаю как опеределить индекс руны, она первая по счёту в рун буке. Феникс я могу оставить акаунт пароль и инфо сервера что бы ты зашел под моим скриптом запустил и посмотрел что не так, ты быстрее чем я разбирешься ) Заранее благодарен тебе за помощ !
Fenix
Developer
Developer
Posts: 275
Joined: 24.08.2010 7:20
Location: Ставрополь
Contact:

Post by Fenix »

Хорошо, давай инфу по шарду и аккаунту в личку.
Помните – ничто так не защищает ваши зубы 12 часов днем и 12 часов ночью как уважительное отношение к окружающим.
"Многие из вас знакомы с достоинствами программиста. Их всего три, и разумеется это: лень, нетерпеливость и гордыня"© Larry Wall
Fenix
Developer
Developer
Posts: 275
Joined: 24.08.2010 7:20
Location: Ставрополь
Contact:

Post by Fenix »

Как и предполагалось, косяк крылся в "иной нумерации" возвратных кодов кнопок в рунбуке. Схема следующая:
1. Номер первого рекала = 5, GT = 6, SJ = 7.
2. Инкремент для получения следующего рекала = 6.
Таким образом, схема расчета кнопок в рунбуке для данного шарда: 6 * n + RuneBookShift. Где n - порядковый номер руны (нумерация, как и всегда, начинается с нуля), а RuneBookShift должен быть равен 5 для рекала, 6 для GT (кстати, реализацию прохода по GT я не делал) и 7 для SJ.
P.S.: Можно было самому догадаться и "изобрести" схему для своего шарда.
Помните – ничто так не защищает ваши зубы 12 часов днем и 12 часов ночью как уважительное отношение к окружающим.
"Многие из вас знакомы с достоинствами программиста. Их всего три, и разумеется это: лень, нетерпеливость и гордыня"© Larry Wall
Ooops
Neophyte
Neophyte
Posts: 11
Joined: 26.10.2010 14:27

Post by Ooops »

Спасибо за помощ и пояснения, щас буду разбираться)
Post Reply