Page 1 of 1

Delphi scripts for Stealth 6

Posted: 05.08.2013 4:45
by Vizit0r
вобщем-то это раздел не для мануалов, но пока тут соберу до кучи, потом в вики буду скидывать понемногу.

в стелсе начиная с 6й версии есть возможность писать скрипты на обычных, полноценных языках программирования, любых - от Delphi и Python - до .Net и asm. Происходит это путем импорта скриптовых функций из длл. Для дельфей, c# и python сделали готовые обертки для удобного и легкого написания скриптов. Под другие языки создание аналогичных оберток тоже не представляет особых проблем.
Так вот, в этой теме я пишу про стелс-скрипты на Delphi. В дальнейшем Crome, возможно создаст аналогичную тему по c#, а Boydon по питону.

В обертке я решил раскидать все скрипты по категориям, что вообще-то с самого начала планировалось в стелсе, но вначале PS не позволял такое сделать, а в дальнейшем - обратная совместимость.

Итак, поехали (приватные методы не выкладываю, только публичные + properties). Properties есть только для чтения, есть чтение+запись - желающие все увидят в исходнике, тут не буду загромождать.
TScript
TScript = record
public
{ public declarations }
MyChar : TMyChar; //maybe Character?
Target : TTargetWork;
LineFields : TLineFields;
Journal : TJournal;
FindEngine : TFindEngine;
UOObject : TUOObject;
MoveItemEngine : TMoveItemEngine;
Menu : TMenu;
Gump : TGump;
Shop : TShop;
Party : TParty;
HTTP : THTTP;
ICQ : TICQ;
Client : TClient;
Skill : TSkill;
Mover : TMover;

procedure AddToSystemJournal(Text : String);
procedure Connect;
procedure Disconnect;
function StealthInfo : TAboutData;
function MsToDateTime(TimeMS : Cardinal) : TDateTime;
function ChangeProfile(Name : String) : Integer;
function ProfileName : String;
procedure Wait(WaitTimeMS : Integer);

//maybe move to "Ability" ?
//maybe move to "TMyChar" ?
procedure UsePrimaryAbility;
procedure UseSecondaryAbility;
function GetActiveAbility : String;

procedure ToggleFly;
procedure ReqVirtuesGump;
procedure UseVirtue(VirtueName : String);

//maybe move to "TSpell" ?
function CastSpell(SpellName : String) : Boolean;
function CastSpellToObj(SpellName : String; ObjId : Cardinal) : Boolean;
function IsActiveSpellAbility(SpellName : String) : Boolean;

procedure UnsetCatchBag;
function SetCatchBag(ObjectID : Cardinal) : Byte;
procedure UseObject(ObjectID : Cardinal);
function UseType(ObjType : Word; Color : Word = $FFFF) : Cardinal;
function UseFromGround(ObjType : Word; Color : Word) : Cardinal;
procedure ClickOnObject(ObjectID : Cardinal);
function GetClilocByID(ClilocID : Cardinal) : String;
procedure OpenDoor;
procedure Bow;
procedure Salute;
function GetQuestArrow : TPoint;
function PlayWav(FileName : String) : Boolean;
procedure HelpRequest;
procedure QuestRequest;
procedure RenameMobile(Mob_ID : Cardinal; NewName : String);
function MobileCanBeRenamed(Mob_ID : Cardinal) : Boolean;
procedure ChangeStatLockState(statNum, statState : Byte);
function GetStaticArtBitmap(Id : LongWord; Hue : Word) : TBitmap;
procedure SetAlarm;
function CheckLag(timeoutMS : Integer) : Boolean;
procedure UOSay(Text : String);
procedure SendTextToUOColor(Text : String; Color : Word);
procedure SetEventProc(const eventname : TPacketEvent; const method : Pointer);
procedure ConsoleEntryReply(Text : String);
procedure ConsoleEntryUnicodeReply(Text : String);


property PauseScriptOnDisconnectStatus : Boolean;
property DressSpeed : Word;
property ARStatus : Boolean;
property Connected : Boolean;
property WorldNum : Byte;
property ConnectedTime : TDateTime;
property DisconnectedTime : TDateTime;
property LastContainer : Cardinal;
property LastTarget : Cardinal;
property LastAttack : Cardinal;
property LastStatus : Cardinal;
property LastObject : Cardinal;
property ShardName : String;
property ProxyIP : String;
property ProxyPort : Word;
property ProxyUsed : Boolean;
property Backpack : Cardinal;
property Ground : Cardinal;
end;
TMyChar
TMyChar = record
public
function WarTargetID : Cardinal;
procedure Attack(AttackedID : Cardinal);
procedure UseSelfPaperdollScroll;
procedure UseOtherPaperdollScroll(ID : Cardinal);
function ObjAtLayer(LayerType : Byte) : Cardinal;

property CharName : String;
property Self : Cardinal;
property Sex : Byte;
property CharTitle : String;
property Gold : Cardinal;
property Armor : Word;
property Weight : Word;
property MaxWeight : Word;
property Race : Byte;
property PetsMax : Byte;
property PetsCurrent : Byte;
property Luck : Integer;
property FireResist : Word;
property ColdResist : Word;
property PoisonResist : Word;
property EnergyResist : Word;
property Backpack : Cardinal;

property Str : Integer;
property Int : Integer;
property Dex : Integer;
property Life : Integer;
property Mana : Integer;
property Stam : Integer;
property MaxLife : Integer;
property MaxMana : Integer;
property MaxStam : Integer;
property ExtInfo : TExtendedInfo;
property Hidden : Boolean;
property Poisoned : Boolean;
property Paralyzed : Boolean;
property Dead : Boolean;
property WarMode : Boolean;
end;
TUOObject
TUOObject = class
public
constructor Create(ObjID : Cardinal);
function GetX : Integer; overload;
class function GetX(ObjID : Cardinal) : Integer; overload;
function GetY : Integer; overload;
class function GetY(ObjID : Cardinal) : Integer;overload;
function GetZ : ShortInt; overload;
class function GetZ(ObjID : Cardinal) : ShortInt; overload;
function GetName : String; overload;
class function GetName(ObjID : Cardinal) : String; overload;
function GetAltName : String; overload;
class function GetAltName(ObjID : Cardinal) : String;overload;
function GetTitle : String; overload;
class function GetTitle(ObjID : Cardinal) : String; overload;
function GetClilocRec : TClilocRec; overload;
class function GetClilocRec(ObjID : Cardinal) : TClilocRec; overload;
function GetTooltip : String; overload;
class function GetTooltip(ObjID : Cardinal) : String; overload;
function GetType : Word; overload;
class function GetType(ObjID : Cardinal) : Word; overload;
function GetQuantity : Integer; overload;
class function GetQuantity(ObjID : Cardinal) : Integer; overload;
function IsObjectExists : Boolean; overload;
class function IsObjectExists(ObjID : Cardinal) : Boolean; overload;
function IsNPC : Boolean; overload;
class function IsNPC(ObjID : Cardinal) : Boolean; overload;
function GetPrice : Cardinal; overload;
class function GetPrice(ObjID : Cardinal) : Cardinal; overload;
function GetDirection : Byte; overload;
class function GetDirection(ObjID : Cardinal) : Byte; overload;
function GetDistance : Integer; overload;
class function GetDistance(ObjID : Cardinal) : Integer; overload;
function GetColor : Word; overload;
class function GetColor(ObjID : Cardinal) : Word; overload;
function GetStr : Integer; overload;
class function GetStr(ObjID : Cardinal) : Integer; overload;
function GetInt : Integer; overload;
class function GetInt(ObjID : Cardinal) : Integer; overload;
function GetDex : Integer; overload;
class function GetDex(ObjID : Cardinal) : Integer; overload;
function GetHP : Integer; overload;
class function GetHP(ObjID : Cardinal) : Integer; overload;
function GetMaxHP : Integer; overload;
class function GetMaxHP(ObjID : Cardinal) : Integer; overload;
function GetMana : Integer; overload;
class function GetMana(ObjID : Cardinal) : Integer; overload;
function GetMaxMana : Integer; overload;
class function GetMaxMana(ObjID : Cardinal) : Integer; overload;
function GetStam : Integer; overload;
class function GetStam(ObjID : Cardinal) : Integer; overload;
function GetMaxStam : Integer; overload;
class function GetMaxStam(ObjID : Cardinal) : Integer; overload;
function GetNotoriety : Byte; overload;
class function GetNotoriety(ObjID : Cardinal) : Byte; overload;
function GetParent : Cardinal; overload;
class function GetParent(ObjID : Cardinal) : Cardinal; overload;
function IsWarMode : Boolean; overload;
class function IsWarMode(ObjID : Cardinal) : Boolean; overload;
function IsDead : Boolean; overload;
class function IsDead(ObjID : Cardinal) : Boolean; overload;
function IsRunning : Boolean; overload;
class function IsRunning(ObjID : Cardinal) : Boolean; overload;
function IsContainer : Boolean; overload;
class function IsContainer(ObjID : Cardinal) : Boolean; overload;
function IsHidden : Boolean; overload;
class function IsHidden(ObjID : Cardinal) : Boolean; overload;
function IsMovable : Boolean; overload;
class function IsMovable(ObjID : Cardinal) : Boolean; overload;
function IsYellowHits : Boolean; overload;
class function IsYellowHits(ObjID : Cardinal) : Boolean; overload;
function IsPoisoned : Boolean; overload;
class function IsPoisoned(ObjID : Cardinal) : Boolean; overload;
function IsParalyzed : Boolean; overload;
class function IsParalyzed(ObjID : Cardinal) : Boolean; overload;
function IsFemale : Boolean; overload;
class function IsFemale(ObjID : Cardinal) : Boolean; overload;
function ObjAtLayerEx(LayerType : Byte) : Cardinal; overload;
class function ObjAtLayerEx(LayerType : Byte; PlayerID : Cardinal) : Cardinal; overload;
function GetLayer : Byte; overload;
class function GetLayer(ObjID : Cardinal) : Byte; overload;
procedure RequestStats; overload;
class procedure RequestStats(ObjID : Cardinal); overload;
TFindEngine
TFindEngine = record
public
function FindTypeEx(ObjType : Word; Color : Word; Container : Cardinal; InSub : Boolean) : Cardinal;
function FindType(ObjType : Word; Container : Cardinal) : Cardinal;
function FindNotoriety(ObjType : Word; Notoriety : Byte) : Cardinal;
function FindAtCoord(X, Y : Word) : Cardinal;
procedure Ignore(ObjID : Cardinal);
procedure IgnoreRemove(ObjID : Cardinal);
procedure IgnoreReset;
function GetIgnoreList : TArray<Cardinal>;
function GetFindedList : TArray<Cardinal>;
function FindItem : Cardinal;
function FindCount : Integer;
function FindQuantity : Integer;
function FindFullQuantity : Integer;
property FindDistance : Cardinal;
property FindVertical : Cardinal;
property FindInNulPoint : Boolean;
end;
TMoveItemEngine
TMoveItemEngine = record
public
function DragItem(ItemID : Cardinal; Count : Integer) : Boolean;
function DropItem(MoveIntoID : Cardinal; X, Y : Word; Z : ShortInt) : Boolean;
function MoveItem(ItemID : Cardinal; Count : Integer; MoveIntoID : Cardinal; X, Y : Word; Z : ShortInt) : Boolean;
function Grab(ItemID : Cardinal; Count : Integer) : Boolean;
function Drop(ItemID : Cardinal; Count : Integer; X, Y : Smallint; Z : ShortInt) : Boolean;
function DropHere(ItemID : Cardinal) : Boolean;
function MoveItems(Container : Cardinal; ItemsType : Word; ItemsColor : Word; MoveIntoID : Cardinal; X, Y : Word; Z : ShortInt; DelayMS : Integer) : Boolean;
function EmptyContainer(Container, DestContainer : Cardinal; delay_ms : Word) : Boolean;
property DropCheckCoord : Boolean;
property DropDelay : Cardinal;
end;
TSecureTrade
TSecureTrade = record
public
function CheckTradeState : Boolean;
function GetTradeContainer(TradeNum, Num : Byte) : Cardinal;
function GetTradeOpponent(TradeNum : Byte) : Cardinal;
function GetTradeCount : Byte;
function GetTradeOpponentName(TradeNum : Byte) : String;
function TradeCheck(TradeNum, Num : Byte) : Boolean;
procedure ConfirmTrade(TradeNum : Byte);
function CancelTrade(TradeNum : Byte) : Boolean;
end;
TTargetWork
TTargetWork = record
public
function WaitForTarget(MaxWaitTimeMS : Integer) : Boolean;
procedure CancelTarget;
procedure TargetToObject(ObjectID : Cardinal);
procedure TargetToXYZ(X, Y : Word; Z : ShortInt);
procedure TargetToTile(TileModel,X,Y : Word; Z : ShortInt);
procedure WaitTargetObject(ObjID : Cardinal);
procedure WaitTargetTile(Tile,X, Y : Word; Z : ShortInt);
procedure WaitTargetXYZ(X, Y : Word; Z : ShortInt);
procedure WaitTargetSelf;
procedure WaitTargetType(ObjType : Word);
procedure CancelWaitTarget;
procedure WaitTargetGround(ObjType : Word);
procedure WaitTargetLast;

property TargetID : Cardinal;
property TargetPresent : Boolean;
end;
TLineFields
TLineFields = record
public
property FoundedParamID : Integer;
property LineID : Cardinal;
property LineType : Word;
property LineName : String;
property LineTime : TDateTime;
property LineMsgType : Byte;
property LineTextColor : Word;
property LineTextFont : Word;
property LineIndex : Integer;
property LineCount : Integer;
end;
TJournal
TJournal = record
public
procedure AddJournalIgnore(Str : String);
procedure ClearJournalIgnore;
procedure AddChatUserIgnore(User : String);
procedure ClearChatUserIgnore;
procedure ClearJournal;
function InJournal(Str : String) : Integer;
function InJournalBetweenTimes(Str : String; TimeBegin, TimeEnd : TDateTime) : Integer;
function WaitJournalLine(StartTime : TDateTime; Str : String; MaxWaitTimeMS : Integer) : Boolean;
function WaitJournalLineSystem(StartTime : TDateTime; Str : String; MaxWaitTimeMS : Integer) : Boolean;

property Low : Integer;
property High : Integer;
property Lines[Index: Cardinal] : String; default;
property LastJournalMessage : String;
end;
TContextMenu
TContextMenu = record
public
procedure RequestContextMenu(ObjectID : Cardinal);
procedure SetContextMenuHook(MenuID : Cardinal; EntryNumber : Byte);
function GetContextMenu : TArray<String>;
procedure ClearContextMenu;
end;
TMenu
TMenu = record
public
procedure WaitMenu(MenuCaption, ElementCaption : String);
procedure AutoMenu(MenuCaption, ElementCaption : String);
function MenuHookPresent : Boolean;
function MenuPresent : Boolean;
procedure CancelMenu;
procedure CloseMenu;
function GetMenuItems(MenuCaption : String) : TArray<String>;
function GetLastMenuItems : TArray<String>;
end;
TGump
TGump = record
public
procedure WaitGump(Value : Integer);
procedure WaitGumpStr(Value : String);
procedure WaitGumpTextEntry(Value : String);
procedure GumpAutoTextEntry(TextEntryID : Integer; Value : String);
procedure GumpAutoRadiobutton(RadiobuttonID, Value : Integer);
procedure GumpAutoCheckBox(CBID, Value : Integer);
function NumGumpButton(GumpIndex : Word; Value : Integer) : Boolean;
function NumGumpTextEntry(GumpIndex : Word; TextEntryID : Integer; Value : String) : Boolean;
function NumGumpRadiobutton(GumpIndex : Word; RadiobuttonID, Value : Integer) : Boolean;
function NumGumpCheckBox(GumpIndex : Word; CBID, Value : Integer) : Boolean;
function GetGumpsCount : Integer;
procedure CloseSimpleGump(GumpIndex : Word);
function IsGump : Boolean;
function GetGumpSerial(GumpIndex : Word) : Cardinal;
function GetGumpID(GumpIndex : Word) : Cardinal;
function GetGumpNoClose(GumpIndex : Word) : Boolean;
function GetGumpTextLines(GumpIndex : Word) : TArray<String>;
function GetGumpFullLines(GumpIndex : Word) : TArray<String>;
function GetGumpShortLines(GumpIndex : Word) : TArray<String>;
function GetGumpButtonsDescription(GumpIndex : Word) : TArray<String>;
function GetGumpInfo(GumpIndex : Word) : TGumpInfo;
procedure AddGumpIgnoreByID(GumpID : Cardinal);
procedure AddGumpIgnoreBySerial(GumpSerial : Cardinal);
procedure ClearGumpsIgnore;
end;
TShop
TShop = record
public
procedure AutoBuy(ItemType, ItemColor, Quantity : Word);
function GetShopList : TArray<String>;
procedure ClearShopList;
procedure AutoBuyEx(ItemType : Word; ItemColor : Word; Quantity : Word; Price : Cardinal; Name : String);
procedure AutoSell(ItemType, ItemColor, Quantity : Word);
property AutoBuyDelay : Word;
property AutoSellDelay : Word;
end;
TParty
TParty = record
public
procedure InviteToParty(ObjectID : Cardinal);
procedure RemoveFromParty(ObjectID : Cardinal);
procedure PartyMessageTo(ObjectID : Cardinal; Msg : String);
procedure PartySay(Msg : String);
procedure PartyCanLootMe(Value : Boolean);
procedure PartyAcceptInvite;
procedure PartyDeclineInvite;
procedure PartyLeave;
function InParty : Boolean;
function PartyMembersList : TArray<Cardinal>;
end;
THTTP
THTTP = record
public
procedure Get(URL : String);
function Post(URL, PostData : String) : String;
property Body : String;
property Header : String;
end;
TICQ
TICQ = record
public
procedure Connect(UIN : Cardinal; Password : String);
procedure Disconnect;
procedure SetStatus(Num : Byte);
procedure SetXStatus(Num : Byte);
procedure SendText(DestinationUIN : Cardinal; Text : String);
property Connected : Boolean;
end;
TClient
TClient = record
public
procedure Print(Msg : String);
procedure PrintEx(SenderID : Cardinal; Color, Font : Word; Msg : String);
procedure CloseUIWindow(UIWindowType : TUIWindowType; ID : Cardinal);
procedure RequestObjectTarget;
procedure RequestTileTarget;
function TargetResponsePresent : Boolean;
function TargetResponse : TTargetInfo;
function WaitForTargetResponse(MaxWaitTimeMS : Integer) : Boolean;
end;
TSkill
TSkill = class
public
constructor Create(SkillName : String);
function Use : Boolean; overload;
class function Use(SkillName : String) : Boolean; overload;
procedure ChangeLockState(skillState : Byte);overload;
class procedure ChangeLockState(SkillName : String; skillState : Byte); overload;
function GetCap : Double;overload;
class function GetCap(SkillName : String) : Double; overload;
function GetValue : Double; overload;
class function GetValue(SkillName : String) : Double;overload;
end;
TTileWord
TTileWord = record
public
function GetTileFlags(TileGroup : TileFlagsType; Tile : Word) : Cardinal;
function ConvertFlagsToFlagSet(TileGroup : TileFlagsType; Flags : LongWord) : TTileDataFlagSet;
function GetLandTileData(Tile : Word) : TLandTileData;
function GetStaticTileData(Tile : Word) : TStaticTileData;
function GetCell(X, Y : Word; WorldNum : Byte) : TMapCell;
function GetLayerCount(X, Y : word; WorldNum : byte) : Byte;
function ReadStaticsXY(X, Y : word; WorldNum : byte) : TStaticCellRealXY;
function GetSurfaceZ(X, Y : word; WorldNum : Byte) : ShortInt;
function IsWorldCellPassable(CurrX, CurrY : Word; CurrZ : ShortInt; DestX, DestY : Word; var DestZ : ShortInt; WorldNum : byte) : Boolean;
function GetStaticTilesArray(Xmin, Ymin, Xmax, Ymax : Word; WorldNum: Byte; TileType: Word; var FoundTilesArray: TFoundTilesArray): Word;
function GetLandTilesArray(Xmin, Ymin, Xmax, Ymax : Word; WorldNum : byte; TileType : Word; var FoundTilesArray: TFoundTilesArray): Word;
end;
TEasyUO
TEasyUO = record
public
function EUO2StealthType(EUO : String) : Word;
function EUO2StealthID(EUO : String) : Cardinal;
property EUOVar[VarNum : Byte] : String;
end;
TPath
TPath = record
public
property StealthPath : String;
property CurrentScriptPath : String;
property StealthProfilePath : String;
property ShardPath : String;
end;
TMover
TMover = record
public
function Step(Direction : Byte; Running : Boolean) : Byte;
function RawMove(Direction : Byte; Running : Boolean) : Boolean;
function StepQ(Direction : Byte; Running : Boolean) : Integer;
function MoveXYZ(Xdst, Ydst : Word; Zdst : ShortInt; AccuracyXY, AccuracyZ : Integer; Running : Boolean) : Boolean;
function newMoveXY(Xdst, Ydst : Word; Optimized : Boolean; Accuracy : Integer; Running : Boolean) : Boolean;
procedure SetBadLocation(X, Y : Word);
procedure SetGoodLocation(X, Y : Word);
procedure ClearBadLocationList;
procedure SetBadObject(ObjType, Color : Word; Radius : Byte);
procedure ClearBadObjectList;
function CheckLOS(xf, yf, zf, xt, yt, zt : Integer; WorldNum : Byte) : Boolean;
function GetPathArray(DestX, DestY : Word; Optimized : Boolean; Accuracy : Integer): TArray<TMyPoint>;
function GetPathArray3D(StartX, StartY : Word; StartZ : Shortint; FinishX, FinishY : Word; FinishZ : Shortint; WorldNum : Byte; AccuracyXY, AccuracyZ : Integer; Run : Boolean): TArray<TMyPoint>;
function Dist(x1, y1, x2, y2 : word) : word;
procedure CalcCoord(x, y : word; Dir : byte; var x2, y2 : word);
function CalcDir(Xfrom, Yfrom, Xto, Yto : integer) : byte;
function PredictedX : Word;
function PredictedY : Word;
function PredictedZ : ShortInt;
function PredictedDirection : Byte;

property RunUnmountTimer : Word;
property WalkMountTimer : Word;
property RunMountTimer : Word;
property WalkUnmountTimer : Word;
end;
здесь вобщем-то все просто и понятно, пояснения дам только по двум вещам - TSkill и TUOObject, на примере TSkill.
Можно сделать так:
var AnatomySk : TSkill;
begin
AnatomySk := TSkill.Create('Anatomy');
и дальше работать напрямую с AnatomySk, например AnatomySk.GetValue и т.д.
это удобно, когда надо постоянно работать с одним скиллом (например, регулярно проверять). Если же какой-то отдельный скилл надо разово проверить, то удобнее написать
TSkill.GetValue('Magery').

Аналогично с TUOObject.

Re: Delphi scripts for Stealth 6

Posted: 05.08.2013 4:45
by Vizit0r
здесь примеры скриптов.

Пример1:

вывести в сисжурнал имя текущего профиля, подождать, туда же 111, подождать 10с и завершить работу.

Code: Select all

program Project1;
{$APPTYPE CONSOLE}
{$R *.res}

uses
  System.SysUtils,
  stealth_script in '..\..\..\..\API\Delphi\stealth_script.pas';

begin
  Script.AddToSystemJournal(Script.Connection.ProfileName);
  Script.wait(1000);
  Script.AddToSystemJournal('111');
  Script.wait(10000);
end.
Пример2:
Исходный скрипт
Program CraftScrollov;

const
RegChest = $4057AA11;
LoadRegAmount = 750;

type TReagentInfo = Record
Name : String;
TypeOfReagent : Cardinal;
end;

type TItemInfo = Record
Name : String;
Tool, Container, TypeOfItem : Cardinal;
CountOfReagent, QuantityOfReg, CraftGump, CategoryBtn, ItemBtn, SmeltBtn : Integer;
Reg : array[0..9] of TReagentInfo;
end;

var
Item : TItemInfo;
Food : array[0..4] of Cardinal;

CraftForm : TSTForm;
CraftButton : TSTButton;
CraftItemTField : TSTEdit;
CraftItemQuantityTField : TSTEdit;
CraftQuantityLabel : TSTLabel;
CraftItemNameLabel : TSTLabel;
CraftChoicesLabel : TSTLabel;
CraftChoiceDescriptionLabel : TSTLabel;
CounterLabel : TSTLabel;
HowManyLeftToDoLabel : TSTLabel;
RegLabel : array[0..9] of TSTLabel;
RegLabelChest : array[0..9] of TSTLabel;
CurrentSkillLevelLabel : TSTLabel;
StatisticsLabel : TSTLabel;
StatisticsLabelChest : TSTLabel;
UsesLeftLabel : TSTLabel;
TriesMade : TSTLabel;


procedure initFood;
begin
Food[0] := $09B7;
Food[1] := $1608;
Food[2] := $09D0;
Food[3] := $160A;
Food[4] := $097B;
end;

procedure GetTItemInfo(Choice : String);
begin
if (Choice = 'recall') then
begin
Item.Name := 'Recall cкролл';
Item.Tool := $0FBF;
Item.CountOfReagent := 4;
Item.Container := $0E76;
Item.TypeOfItem := $1F4C;
Item.QuantityOfReg := 1;
Item.CraftGump := 1044009;
Item.CategoryBtn := 6;
Item.ItemBtn := 30;
Item.Reg[0].TypeOfReagent := BM;
Item.Reg[0].Name := 'Blood Moss';
Item.Reg[1].TypeOfReagent := MR;
Item.Reg[1].Name := 'Mandrake Roots';
Item.Reg[2].TypeOfReagent := BP;
Item.Reg[2].Name := 'Black Pearls';
Item.Reg[3].TypeOfReagent := $0EF3;
Item.Reg[3].Name := 'Blank scroll';
end;
if (Choice = 'gh') then
begin
Item.Name := 'GH cкролл';
Item.Tool := $0FBF;
Item.Container := $0E76;
Item.TypeOfItem := $1F49;
Item.QuantityOfReg := 1;
Item.CountOfReagent := 5;
Item.CraftGump := 1044009;
Item.CategoryBtn := 6;
Item.ItemBtn := 22;
Item.Reg[0].TypeOfReagent := SS;
Item.Reg[0].Name := 'Spider`s Silk';
Item.Reg[1].TypeOfReagent := MR;
Item.Reg[1].Name := 'Mandrake Roots';
Item.Reg[2].TypeOfReagent := GS;
Item.Reg[2].Name := 'Ginsening';
Item.Reg[3].TypeOfReagent := $0EF3;
Item.Reg[3].Name := 'Blank scroll';
Item.Reg[4].TypeOfReagent := GA;
Item.Reg[4].Name := 'Garlic';
end;
if (Choice = 'reflect') then
begin
Item.Name := 'Reflect cкролл';
Item.Tool := $0FBF;
Item.CountOfReagent := 4;
Item.Container := $0E76;
Item.TypeOfItem := $1F50;
Item.QuantityOfReg := 1;
Item.CraftGump := 1044009;
Item.CategoryBtn := 7;
Item.ItemBtn := 20;
Item.Reg[0].TypeOfReagent := GA;
Item.Reg[0].Name := 'Garlic';
Item.Reg[1].TypeOfReagent := MR;
Item.Reg[1].Name := 'Mandrake Roots';
Item.Reg[2].TypeOfReagent := SS;
Item.Reg[2].Name := 'Spider`s Silk';
Item.Reg[3].TypeOfReagent := $0EF3;
Item.Reg[3].Name := 'Blank scroll';
end;
if (Choice = 'paralyze') then
begin
Item.Name := 'Paralyze cкролл';
Item.Tool := $0FBF;
Item.CountOfReagent := 4;
Item.Container := $0E76;
Item.TypeOfItem := $1F52;
Item.QuantityOfReg := 1;
Item.CraftGump := 1044009;
Item.CategoryBtn := 7;
Item.ItemBtn := 24;
Item.Reg[0].TypeOfReagent := GA;
Item.Reg[0].Name := 'Garlic';
Item.Reg[1].TypeOfReagent := MR;
Item.Reg[1].Name := 'Mandrake Roots';
Item.Reg[2].TypeOfReagent := SS;
Item.Reg[2].Name := 'Spider`s Silk';
Item.Reg[3].TypeOfReagent := $0EF3;
Item.Reg[3].Name := 'Blank scroll';
end;
if (Choice = 'efield') then
begin
Item.Name := 'EF cкролл';
Item.Tool := $0FBF;
Item.Container := $0E76;
Item.TypeOfItem := $1F5E;
Item.QuantityOfReg := 1;
Item.CountOfReagent := 5;
Item.CraftGump := 1044009;
Item.CategoryBtn := 9;
Item.ItemBtn := 14;
Item.Reg[0].TypeOfReagent := SS;
Item.Reg[0].Name := 'Spider`s Silk';
Item.Reg[1].TypeOfReagent := MR;
Item.Reg[1].Name := 'Mandrake Roots';
Item.Reg[2].TypeOfReagent := BP;
Item.Reg[2].Name := 'Black Pearls';
Item.Reg[3].TypeOfReagent := $0EF3;
Item.Reg[3].Name := 'Blank scroll';
Item.Reg[4].TypeOfReagent := SA;
Item.Reg[4].Name := 'Sulfurous Ash';
end;
end;

procedure GumpCheckAndSolve;
var
gi :TGumpInfo;
begin
if IsGump then
begin
GetGumpInfo(GetGumpsCount-1, gi);
if not (gi.XmfHTMLGumpColor[0].Cliloc_id = Item.CraftGump) then
begin
while IsGump do
begin
CloseSimpleGump(GetGumpsCount-1);
end;
if (FindType(Item.Tool, backpack) > 0) then UseObject(FindItem);
Wait(1500);
end;
end;
if not IsGump then
begin
if (FindType(Item.Tool, backpack) > 0) then UseObject(FindItem);
Wait(1000);
end;
end;

procedure CraftOneItem;
var
gi : TGumpInfo;
begin
GumpCheckAndSolve;
GetGumpInfo(GetGumpsCount-1, gi);
if (gi.XmfHTMLGumpColor[0].Cliloc_id = Item.CraftGump) then
begin
NumGumpButton(GetGumpsCount-1, gi.GumpButtons[Item.CategoryBtn].return_value);
Wait(1500);
NumGumpButton(GetGumpsCount-1, gi.GumpButtons[Item.ItemBtn].return_value);
end;
end;

procedure SmeltItem;
var
gi : TGumpInfo;
begin
GumpCheckAndSolve;
GetGumpInfo(GetGumpsCount-1, gi);
if (gi.XmfHTMLGumpColor[0].Cliloc_id = Item.CraftGump) then
begin
NumGumpButton(GetGumpsCount-1, gi.GumpButtons[Item.SmeltBtn].return_value);
WaitForTarget(5000);
if TargetPresent then TargetToObject(FindType(Item.TypeOfItem, backpack));
Wait(1500);
end;
end;

procedure LoadUnload;
var
tmpInt : Integer;
begin
GetTItemInfo(CraftItemTField.Text);
UseObject(RegChest);
Wait(1500);
for tmpInt := 0 to (Item.CountOfReagent - 1) do
begin
if GetQuantity(FindType(Item.Reg[tmpInt].TypeOfReagent, backpack)) < Item.QuantityOfReg then
begin
MoveItem(FindType(Item.Reg[tmpInt].TypeOfReagent, RegChest), (LoadRegAmount - GetQuantity(FindType(Item.Reg[tmpInt].TypeOfReagent, backpack))), backpack, 0,0,0);
Wait(1500);
end;
end;
if FindType(Item.TypeOfItem, backpack) > 0 then
begin
MoveItem(FindItem, 0, RegChest, 0,0,0);
Wait(1500);
end;
end;
procedure Obed;
var
im : Integer;
begin
for im := 0 to 4 do
begin
if (FindType(Food[im], backpack) > 0) then
begin
UseObject(FindItem);
Wait(1500);
exit;
end;
end;
end;

function UsesLeft : Integer;
var
aa : TClilocRec;
begin
aa := GetToolTipRec(FindType(Item.Tool, backpack));
Result := (StrToInt(aa.Items[1].Params[0]));
end;

function Counter : Integer;
begin
GetTItemInfo(CraftItemTField.Text);
Result := GetQuantity(FindType(Item.TypeOfItem, backpack));
end;

procedure B_Click(Sender : TObject);
var
tmpInt1, tmpInt2, tmpInt3, k, im : Integer;
ctime : TDateTime;
begin
GetTItemInfo(CraftItemTField.Text);
Wait(1000);
UOSay(Item.Name);
im := 0;
While FindType(Item.TypeOfItem, backpack) > 0 do
begin
MoveItem(FindItem, 0, RegChest, 0,0,0);
Wait(1500);
end;
while ((Counter + (GetQuantity(FindType(Item.TypeOfItem, RegChest)))) < StrToInt(CraftItemQuantityTField.Text)) do
begin
for tmpInt1 := 0 to (Item.CountOfReagent - 1) do
begin
if (GetQuantity(FindType(Item.Reg[tmpInt1].TypeOfReagent, backpack)) <= Item.QuantityOfReg) then LoadUnload;
end;
if Mana < 20 then
begin
ctime := Now;
while not (InJournalBetweenTimes('You enter', ctime, Now) <> -1) do
begin
UseSkill('Meditation');
Wait(2500);
end;
repeat
Wait(1500);
until (Mana > 90);
end;
Obed;
im := im + 1;
TriesMade.Caption := 'Tries Made: ' + IntToStr(im);
CraftOneItem;
k := 0;
repeat
k := k + 1;
Wait(300);
until IsGump or Dead or (k > 15);
HowManyLeftToDoLabel.Caption := 'Left to do: ' + IntToStr(((StrToInt(CraftItemQuantityTField.Text))) - (Counter + (GetQuantity(FindType(Item.TypeOfItem, RegChest)))));
for tmpInt2 := 0 to (Item.CountOfReagent - 1) do
begin
RegLabel[tmpInt2].Caption := Item.Reg[tmpInt2].Name + ': ' + IntToStr(GetQuantity(FindType(Item.Reg[tmpInt2].TypeOfReagent, backpack)));
end;
CurrentSkillLevelLabel.Caption := 'Current Skill Level: ' + FloatToStrF(GetSkillValue('Inscription'),ffFixed,12,1);
CounterLabel.Caption := 'Total Items: ' + IntToStr(Counter + (GetQuantity(FindType(Item.TypeOfItem, RegChest))));
for tmpInt3 := 0 to (Item.CountOfReagent - 1) do
begin
RegLabelChest[tmpInt3].Caption := Item.Reg[tmpInt3].Name + ': ' + IntToStr(GetQuantity(FindType(Item.Reg[tmpInt3].TypeOfReagent, RegChest)));
end;
//UsesLeftLabel.Caption := 'Uses of tool left: ' + IntToStr(UsesLeft);
end;
Beep;
AddToSystemJournal('Done!');
end;

procedure FormClose(Sender: TObject; var Action : TCloseAction);
begin
Action := caFree;
raiseException(erCustomError, 'for example, script stop after form');
end;

procedure init;
var i, k, im, ik : Integer;
begin
CraftForm := TSTForm.Create;
CraftForm.OnClose := @FormClose;
CraftForm.Width := 380;
CraftForm.Height := 320;
CraftForm.Caption := 'Craft by Drabadanchik';
CraftForm.Visible := True;

CraftButton := TSTButton.Create(CraftForm);
CraftButton.OnClick := @B_Click;
CraftButton.Caption := 'Скрафтить!';
CraftButton.Top := 55;

CraftItemTField := TSTEdit.Create(CraftForm);
CraftItemQuantityTField := TSTEdit.Create(CraftForm);
CraftItemQuantityTField.Top := 30;

CraftItemNameLabel := TSTLabel.Create(CraftForm);
CraftItemNameLabel.Left := 125;
CraftItemNameLabel.Caption := '<-- Напиши название итема!';
CraftQuantityLabel := TSTLabel.Create(CraftForm);
CraftQuantityLabel.Left := 125;
CraftQuantityLabel.Top := 30;
CraftQuantityLabel.Caption := '<-- Напиши сколько хочешь скрафтить!';
CraftChoiceDescriptionLabel := TSTLabel.Create(CraftForm);
CraftChoiceDescriptionLabel.Top := 65;
CraftChoiceDescriptionLabel.Left := 95;
CraftChoiceDescriptionLabel.Caption := 'Варианты крафта: reflect, recall, paralyze, efield, gh.';
CraftChoicesLabel := TSTLabel.Create(CraftForm);
CraftChoicesLabel.Top := 95;
CraftChoicesLabel.Left := 55;
CraftChoicesLabel.Caption := 'CURRENT STATISTICS:';
CounterLabel := TSTLabel.Create(CraftForm);
CounterLabel.Top := 115;
CounterLabel.Left := 10;
HowManyLeftToDoLabel := TSTLabel.Create(CraftForm);
HowManyLeftToDoLabel.Top := 135;
HowManyLeftToDoLabel.Left := 10;
for i := 0 to 9 do
begin
k := k + 20;
RegLabel := TSTLabel.Create(CraftForm);
RegLabel.Top := k + 165;
RegLabel.Left := 10;
end;
CurrentSkillLevelLabel := TSTLabel.Create(CraftForm);
CurrentSkillLevelLabel.Top := 135;
CurrentSkillLevelLabel.Left := 145;
StatisticsLabel := TSTLabel.Create(CraftForm);
StatisticsLabel.Top := 165;
StatisticsLabel.Left := 10;
StatisticsLabel.Caption := 'Reagents in Backpack:';
for im := 0 to 9 do
begin
ik := ik + 20;
RegLabelChest[im] := TSTLabel.Create(CraftForm);
RegLabelChest[im].Top := ik + 165;
RegLabelChest[im].Left := 145;
end;
StatisticsLabelChest := TSTLabel.Create(CraftForm);
StatisticsLabelChest.Top := 165;
StatisticsLabelChest.Left := 145;
StatisticsLabelChest.Caption := 'Reagetns in Chest: ';
UsesLeftLabel := TSTLabel.Create(CraftForm);
UsesLeftLabel.Top := 115;
UsesLeftLabel.Left := 145;
TriesMade := TSTLabel.Create(CraftForm);
TriesMade.Top := 115;
TriesMade.Left := 145;
end;



begin
initFood;
init;
while True do Wait(1000);
end.
Результат
unit Unit2;

interface

uses
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
Vcl.Controls, Vcl.Forms, Vcl.Dialogs, types_const_import, TypInfo,
Vcl.StdCtrls;

type
TScrollCraftingForm = class(TForm)
CraftItemField: TEdit;
CraftButton: TButton;
TriesMadeLabel: TLabel;
HowManyLeftToDoLabel: TLabel;
RegLabel1: TLabel;
RegLabel2: TLabel;
RegLabel3: TLabel;
RegLabel4: TLabel;
RegLabel5: TLabel;
RegLabel6: TLabel;
RegLabel7: TLabel;
RegLabel8: TLabel;
RegLabel9: TLabel;
CurrentSkillLevelLabel: TLabel;
CounterLabel: TLabel;
RegLabelChest1: TLabel;
RegLabelChest2: TLabel;
RegLabelChest3: TLabel;
CraftItemNameLabel: TLabel;
CraftItemQuantityField: TEdit;
CraftQuantityLabel: TLabel;
CraftChoiceDescriptionLabel: TLabel;
CraftChoicesLabel: TLabel;
StatisticsLabel: TLabel;
StatisticsLabelChest: TLabel;
procedure CraftButtonClick(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
private
{ Private declarations }
public
procedure ScriptCraftWork;
end;

type TReagentInfo = Record
Name : String;
TypeOfReagent : Cardinal;
end;

type TItemInfo = Record
Name : String;
Tool, Container, TypeOfItem, CraftGump : Cardinal;
CountOfReagent, QuantityOfReg, CategoryBtn, ItemBtn, SmeltBtn : Integer;
Reg : array[0..9] of TReagentInfo;
end;

TItemsNames = (in_recall,
in_gh,
in_reflect,
in_paralyze,
in_efield);

var
ScrollCraftingForm: TScrollCraftingForm;
Item : TItemInfo;

const
RegChest = $4057AA11;
LoadRegAmount = 750;
Food : array[0..4] of Cardinal = ($09B7,$1608,$09D0,$160A,$097B);
Regs : array[0..9] of TReagentInfo = ((Name : 'Blood Moss';TypeOfReagent : BM), //0
(Name : 'Mandrake Roots';TypeOfReagent : MR), //1
(Name : 'Black Pearls';TypeOfReagent : BP), //2
(Name : 'Spider`s Silk';TypeOfReagent : SS), //3
(Name : 'Ginseng';TypeOfReagent : GS), //4
(Name : 'Garlic';TypeOfReagent : GA), //5
(Name : 'Sulfurous Ash';TypeOfReagent : SA), //6
(Name : 'Nightshade';TypeOfReagent : NS), //7
(Name : 'Blank scroll';TypeOfReagent : $0EF3), //8
(Name : 'not used';TypeOfReagent : 0)); //9




implementation

{$R *.dfm}

procedure GetTItemInfo(Choice : String);
begin
case TItemsNames(GetEnumValue(TypeInfo(TItemsNames), 'in_' + Choice.ToLower)) of
in_recall:
begin
Item.Name := 'Recall cкролл';
Item.Tool := $0FBF;
Item.CountOfReagent := 4;
Item.Container := $0E76;
Item.TypeOfItem := $1F4C;
Item.QuantityOfReg := 1;
Item.CraftGump := 1044009;
Item.CategoryBtn := 6;
Item.ItemBtn := 30;
Item.Reg[0] := Regs[0];
Item.Reg[1] := Regs[1];
Item.Reg[2] := Regs[2];
Item.Reg[3] := Regs[8];
end;
in_gh:
begin
Item.Name := 'GH cкролл';
Item.Tool := $0FBF;
Item.Container := $0E76;
Item.TypeOfItem := $1F49;
Item.QuantityOfReg := 1;
Item.CountOfReagent := 5;
Item.CraftGump := 1044009;
Item.CategoryBtn := 6;
Item.ItemBtn := 22;
Item.Reg[0] := Regs[3];
Item.Reg[1] := Regs[1];
Item.Reg[2] := Regs[4];
Item.Reg[3] := Regs[8];
Item.Reg[4] := Regs[5];
end;
in_reflect:
begin
Item.Name := 'Reflect cкролл';
Item.Tool := $0FBF;
Item.CountOfReagent := 4;
Item.Container := $0E76;
Item.TypeOfItem := $1F50;
Item.QuantityOfReg := 1;
Item.CraftGump := 1044009;
Item.CategoryBtn := 7;
Item.ItemBtn := 20;
Item.Reg[0] := Regs[5];
Item.Reg[1] := Regs[1];
Item.Reg[2] := Regs[3];
Item.Reg[3] := Regs[8];
end;
in_paralyze:
begin
Item.Name := 'Paralyze cкролл';
Item.Tool := $0FBF;
Item.CountOfReagent := 4;
Item.Container := $0E76;
Item.TypeOfItem := $1F52;
Item.QuantityOfReg := 1;
Item.CraftGump := 1044009;
Item.CategoryBtn := 7;
Item.ItemBtn := 24;
Item.Reg[0] := Regs[5];
Item.Reg[1] := Regs[1];
Item.Reg[2] := Regs[3];
Item.Reg[3] := Regs[8];
end;
in_efield:
begin
Item.Name := 'EF cкролл';
Item.Tool := $0FBF;
Item.Container := $0E76;
Item.TypeOfItem := $1F5E;
Item.QuantityOfReg := 1;
Item.CountOfReagent := 5;
Item.CraftGump := 1044009;
Item.CategoryBtn := 9;
Item.ItemBtn := 14;
Item.Reg[0] := Regs[3];
Item.Reg[1] := Regs[1];
Item.Reg[2] := Regs[2];
Item.Reg[3] := Regs[8];
Item.Reg[4] := Regs[6];
end;
else
begin
ShowMessage('Incorrect Item Name selected!');
Application.Terminate;
end;
end;
end;

procedure GumpCheckAndSolve;
var gi :TGumpInfo;
begin
if Script.Gump.IsGump then
begin
gi := Script.Gump.GetGumpInfo(Script.Gump.GetGumpsCount-1);
if gi.XmfHTMLGumpColor[0].Cliloc_id <> Item.CraftGump then
begin
if Script.Gump.IsGump then
Script.Gump.CloseSimpleGump(Script.Gump.GetGumpsCount-1);
if Script.FindEngine.FindType(Item.Tool, Script.MyChar.Backpack) > 0 then
Script.UseObject(Script.FindEngine.FindItem);
Script.Wait(1500);
end;
end;
if not Script.Gump.IsGump then
begin
if (Script.FindEngine.FindType(Item.Tool, Script.MyChar.backpack) > 0) then
Script.UseObject(Script.FindEngine.FindItem);
Script.Wait(1000);
end;
end;

procedure CraftOneItem;
var gi : TGumpInfo;
begin
GumpCheckAndSolve;
gi := Script.Gump.GetGumpInfo(Script.Gump.GetGumpsCount-1);
if gi.XmfHTMLGumpColor[0].Cliloc_id = Item.CraftGump then
begin
Script.Gump.NumGumpButton(Script.Gump.GetGumpsCount-1, gi.GumpButtons[Item.CategoryBtn].return_value);
Script.Wait(1500);
Script.Gump.NumGumpButton(Script.Gump.GetGumpsCount-1, gi.GumpButtons[Item.ItemBtn].return_value);
end;
end;

procedure SmeltItem;
var
gi : TGumpInfo;
begin
GumpCheckAndSolve;
gi := Script.Gump.GetGumpInfo(Script.Gump.GetGumpsCount-1);
if gi.XmfHTMLGumpColor[0].Cliloc_id = Item.CraftGump then
begin
Script.Gump.NumGumpButton(Script.Gump.GetGumpsCount-1, gi.GumpButtons[Item.SmeltBtn].return_value);
Script.Target.WaitForTarget(5000);
if Script.Target.TargetPresent then
Script.Target.TargetToObject(Script.FindEngine.FindType(Item.TypeOfItem, Script.MyChar.backpack));
Script.Wait(1500);
end;
end;

procedure LoadUnload;
var
tmpInt : Integer;
begin
GettItemInfo(ScrollCraftingForm.CraftItemField.Text);
Script.UseObject(RegChest);
Script.Wait(1500);
for tmpInt := 0 to (Item.CountOfReagent - 1) do
if TUOObject.GetQuantity(Script.FindEngine.FindType(Item.Reg[tmpInt].TypeOfReagent, Script.MyChar.backpack)) < Item.QuantityOfReg then
begin
Script.MoveItemEngine.MoveItem(Script.FindEngine.FindType(Item.Reg[tmpInt].TypeOfReagent, RegChest),
(LoadRegAmount - TUOObject.GetQuantity(Script.FindEngine.FindType(Item.Reg[tmpInt].TypeOfReagent, Script.MyChar.backpack))),
Script.MyChar.backpack, 0,0,0);
Script.Wait(1500);
end;
if Script.FindEngine.FindType(Item.TypeOfItem, Script.MyChar.backpack) > 0 then
begin
Script.MoveItemEngine.MoveItem(Script.FindEngine.FindItem, 0, RegChest, 0,0,0);
Script.Wait(1500);
end;
end;

procedure Obed;
var im : Integer;
begin
for im := 0 to 4 do
if (Script.FindEngine.FindType(Food[im], Script.MyChar.backpack) > 0) then
begin
Script.UseObject(Script.FindEngine.FindItem);
Script.Wait(1500);
Exit;
end;
end;

function UsesLeft : Integer;
var aa : TClilocRec;
begin
aa := TUOObject.GetClilocRec(Script.FindEngine.FindType(Item.Tool, Script.MyChar.backpack));
Result := (StrToInt(aa.Items[1].Params[0]));
end;

function Counter : Integer;
begin
GetTItemInfo(ScrollCraftingForm.CraftItemField.Text);
Result := TUOObject.GetQuantity(Script.FindEngine.FindType(Item.TypeOfItem, Script.MyChar.backpack));
end;

procedure TScrollCraftingForm.FormClose(Sender: TObject;
var Action: TCloseAction);
begin
ExitProcess(0);
end;

procedure TScrollCraftingForm.ScriptCraftWork;
var
tmpInt1, tmpInt2, tmpInt3, k, im : Integer;
ctime : TDateTime;
begin
GetTItemInfo(CraftItemField.Text);
Script.Wait(1000);
Script.UOSay(Item.Name);
Script.AddToSystemJournal(Item.Name);
im := 0;
While Script.FindEngine.FindType(Item.TypeOfItem, Script.MyChar.backpack) > 0 do
begin
Script.MoveItemEngine.MoveItem(Script.FindEngine.FindItem, 0, RegChest, 0,0,0);
Script.Wait(1500);
end;
while ((Counter + (TUOObject.GetQuantity(Script.FindEngine.FindType(Item.TypeOfItem, RegChest)))) < StrToInt(CraftItemQuantityField.Text)) do
begin
for tmpInt1 := 0 to (Item.CountOfReagent - 1) do
if (TUOObject.GetQuantity(Script.FindEngine.FindType(Item.Reg[tmpInt1].TypeOfReagent, Script.MyChar.backpack)) <= Item.QuantityOfReg) then
LoadUnload;
if Script.MyChar.Mana < 20 then
begin
ctime := Now;
while not (Script.Journal.InJournalBetweenTimes('You enter', ctime, Now) <> -1) do
begin
TSkill.Use('Meditation');
Script.Wait(2500);
end;
repeat
Script.Wait(1500);
until (Script.MyChar.Mana > 90);
end;
Obed;
Inc(im);
TriesMadeLabel.Caption := 'Tries Made: ' + IntToStr(im);
CraftOneItem;
k := 0;
repeat
k := k + 1;
Script.Wait(300);
until Script.Gump.IsGump or Script.MyChar.Dead or (k > 15);
HowManyLeftToDoLabel.Caption := 'Left to do: ' + IntToStr(((StrToInt(CraftItemField.Text))) - (Counter + (TUOObject.GetQuantity(Script.FindEngine.FindType(Item.TypeOfItem, RegChest)))));
for tmpInt2 := 0 to (Item.CountOfReagent - 1) do
TLabel(FindComponent('RegLabel'+IntToStr(tmpInt2))).Caption := Item.Reg[tmpInt2].Name + ': ' + IntToStr(TUOObject.GetQuantity(Script.FindEngine.FindType(Item.Reg[tmpInt2].TypeOfReagent, Script.MyChar.backpack)));
CurrentSkillLevelLabel.Caption := 'Current Skill Level: ' + FloatToStrF(TSkill.GetValue('Inscription'),ffFixed,12,1);
CounterLabel.Caption := 'Total Items: ' + IntToStr(Counter + (TUOObject.GetQuantity(Script.FindEngine.FindType(Item.TypeOfItem, RegChest))));
for tmpInt3 := 0 to (Item.CountOfReagent - 1) do
TLabel(FindComponent('RegLabelChest'+IntToStr(tmpInt3))).Caption := Item.Reg[tmpInt3].Name + ': ' + IntToStr(TUOObject.GetQuantity(Script.FindEngine.FindType(Item.Reg[tmpInt3].TypeOfReagent, RegChest)));
//UsesLeftLabel.Caption := 'Uses of tool left: ' + IntToStr(UsesLeft);
end;
Beep;
Script.AddToSystemJournal('Done!');
end;

procedure ScriptCraft;
begin
ScrollCraftingForm.ScriptCraftWork;
end;

procedure TScrollCraftingForm.CraftButtonClick(Sender: TObject);
begin
StartScriptInGUI(ScriptCraft);
end;

end.

Re: Delphi scripts for Stealth 6

Posted: 05.08.2013 4:46
by Vizit0r
здесь всякие интересные подробности и нюансы, коих хватает.


1) кого пугает большая длина скриптовых строк на выходе - например,

Code: Select all

if TUOObject.GetQuantity(Script.FindEngine.FindType(Item.Reg[tmpInt].TypeOfReagent, Script.MyChar.backpack)) < Item.QuantityOfReg then
begin
Script.MoveItemEngine.MoveItem(Script.FindEngine.FindType(Item.Reg[tmpInt].TypeOfReagent, RegChest),
(LoadRegAmount - TUOObject.GetQuantity(Script.FindEngine.FindType(Item.Reg[tmpInt].TypeOfReagent, Script.MyChar.backpack))),
Script.MyChar.backpack, 0,0,0);
Script.Wait(1500);
end;
вполне может использовать операторы With XXX do, тогда вышеописанное будет выглядеть как

Code: Select all

With Script.MoveItemEngine, Script.FindEngine, Script.MyChar do
if TUOObject.GetQuantity(FindType(Item.Reg[tmpInt].TypeOfReagent, backpack)) < Item.QuantityOfReg then
begin
MoveItem(FindType(Item.Reg[tmpInt].TypeOfReagent, RegChest),
(LoadRegAmount - TUOObject.GetQuantity(FindType(Item.Reg[tmpInt].TypeOfReagent, backpack))),
backpack, 0,0,0);
Script.Wait(1500);
end;
ну и так хоть целыми процедурами почти как в стелсовых скриптах.

Re: Delphi scripts for Stealth 6

Posted: 19.10.2014 2:08
by admir
Извиняюсь если не нашел копию в документации но данный топик мне кажется надо прилепить )

Re: Delphi scripts for Stealth 6

Posted: 09.11.2014 21:27
by Vizit0r
делал сегодня пример человеку, подумал что можно сюда его тоже кинуть)

https://cloud.mail.ru/public/c0cd214fc0e4/1.rar
пример работы скриптов в ГУИ - в отдельных потоках.
кнопка 1 - запускает скрипт в основном потоке (форма "замораживается"), 2и3 - в потоках, окно работает нормально.
обертка в комплекте.

Re: Delphi scripts for Stealth 6

Posted: 10.11.2014 17:08
by Maxwell
А где эти самые обертки для c# можно найти? И по какому принципу это все работает? Как внешнее приложение, дергающее библиотеку scripts.dll?

Re: Delphi scripts for Stealth 6

Posted: 10.11.2014 18:11
by Vizit0r
да, через длл общается со стелсом.

Re: Delphi scripts for Stealth 6

Posted: 10.11.2014 22:18
by Maxwell
Может и глупый вопрос, но как там определяется для какого из запущенных чаров применять скрипт? В том, что я видел в старой dll, есть только организация канала между стелсом и разрабатываемым софтом через named Pipe. И при этом нигде нет указания на то, кому адресованы команды скрипта.

Re: Delphi scripts for Stealth 6

Posted: 10.11.2014 22:38
by Vizit0r
все просто: либо стартуешь exe как обычный скрипт из стелса с нужного чара, либо стартуешь exe отдельно - он цепляется за первый попавшийся стелс и активного в нем чара.