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

About Auto-Quest...... how to Compare the String?

Only for requests.
Post Reply
TheEnd
Neophyte
Neophyte
Posts: 23
Joined: 20.11.2012 11:20
Contact:

About Auto-Quest...... how to Compare the String?

Post by TheEnd »

Code: Select all

procedure startQuest();
var
  gi : TGumpInfo;
  i : Integer;
  
begin
  while (GetX(self()) <> questCoordsX) or (GetY(self()) <> questCoordsY) do
    begin
      NewMoveXY(questCoordsX, questCoordsY, True, 0, True);
      Wait(1000);
    end;
    UseObject(questGiverID);
    Wait(1000);
    if NumGumpButton(0, ContinueButton) then
    Wait(1000);
    GetGumpInfo(GetGumpsCount - 1, gi);
    if Length(gi.XmfHTMLGumpColor) > 0 then
      for i := 0 to Length(gi.XmfHTMLGumpColor) - 1 do
        if 'crossbow bolts' := GetClilocByID(gi.XmfHTMLGumpColor[i],Cliloc_id) then
        begin
          AddToSystemJournal('OK');
        end;
      //AddToSystemJournal(GetClilocByID(gi.XmfHTMLGumpColor[i].Cliloc_id));
end;
i want to receive the Quest of "Lethal Darts" , but no idea how to compare the String of 'crossbow bolts' correctly.
with the Script do not work, help me! thanks.
Crome696
Novice
Novice
Posts: 67
Joined: 04.03.2012 18:57
Location: Germany
Contact:

Re: About Auto-Quest...... how to Compare the String?

Post by Crome696 »

i would check for http://stealth.od.ua/Doc:Api/GetGumpInfo
Create Gump object of this and read specific property out of it. I have noe sample anymore(lost my library folder) but then you could compare with cliloc-ID from text\title.

edit:
i found very old code of first revision of my stealth gump handling library on the forum i introduced stealth. Here is code and the description

Code: Select all

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Name         : Gump Unit | Module
// Purpose      : Offering Functions to work with Gumps
// Version      : 0.1 Alpha
// Requirements : Stealth 4.0.3 or Greater
// Author       : Crome696 aka Jan Florian Siems
// Last Change  : 04\28\2012 | 20:22 PM - Germany
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// I only provide this Content for Users of Scriptuo.com.
// If you aren´t a full Member of this Website i won´t offer any support.
// I don´t give any warranty of Loss of Items or Accounts.
// With using this Module the User accept my Terms.
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Scriptuo 
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Unit Gumps;
Interface
// Return Amount of Gumps
function CountGumps():Integer; 
// Returns Serial of Toplayer Gump
function GetLastSerial():Cardinal; 
// Returns GumpID of Toplayer Gump
function GetLastGumpID():Cardinal;
// Returns GumpInfo of Toplayer Gump 
function GetLastGump():TGumpInfo; 
// Wait until GumpID is Toplayer GumpID
procedure WaitGumpID(GumpID:Cardinal); 
// Wait until Serial is not Toplayer Serial
procedure WaitSerial(Serial:Cardinal); 
// Click on Button and maybe wait until Serial Changed and GumpID reached
procedure ClickButton(ButtonValue:Integer;GumpID:Cardinal;UseWait:Boolean); 
// Open Gump by Clicking on Object and maybe wait until Serial Changed and GumpID reached 
procedure ClickObject(ObjectID:Integer;GumpID:Cardinal;UseWait:Boolean);
// Clicks on Button left of Cliloc
procedure ClickClilocButton(Cliloc:Integer;RangeX,RangeY:Integer;GumpID:Cardinal;UseWait:Boolean);
// Simple Close a Gump
procedure CloseGump(Simple:Boolean);
// Press Button by TileArt
procedure ClickTileButton(TileArt:Integer;GumpID:Cardinal;UseWait:Boolean);
// Search for ClilocText 
function SearchClilocText(Cliloc:Integer):Boolean;
Implementation
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
function CountGumps():Integer;
begin
  Result := (GetGumpsCount() - 1);
end;
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
function GetLastSerial():Cardinal;
begin
  Result := GetGumpSerial(CountGumps());  
end;
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
function GetLastGumpID():Cardinal;
begin
  Result := GetGumpID(CountGumps());  
end;
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
function GetLastGump():TGumpInfo;
begin
  GetGumpInfo(CountGumps(),Result);  
end;
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
procedure WaitGumpID(GumpID:Cardinal);
begin
  while GetLastGumpID() <> GumpID do
  begin
    Wait(1);
  end; 
end;
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
procedure WaitSerial(Serial:Cardinal);
begin
  while GetLastSerial() = Serial do
  begin
    Wait(1);
  end;
end; 
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
procedure ClickButton(ButtonValue:Integer;GumpID:Cardinal;UseWait:Boolean);
var Serial :Cardinal;
begin
  Serial := GetLastSerial();
  WaitGump(IntToStr(ButtonValue));
  if (UseWait = true) then
  begin
    WaitSerial(Serial);
    WaitGumpID(GumpID)
  end;
end;
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
procedure ClickObject(ObjectID:Integer;GumpID:Cardinal;UseWait:Boolean);
var Serial :Cardinal;
begin
  Serial := GetLastSerial();
  UseObject(ObjectID);
  if (UseWait = true) then
  begin
    WaitSerial(Serial);
    WaitGumpID(GumpID)
  end;
end;
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
procedure ClickClilocButton(Cliloc:Integer;RangeX,RangeY:Integer;GumpID:Cardinal;UseWait:Boolean);
var x:TGumpInfo;
var i,ii:Integer;
begin
  x :=GetLastGump();
  for i := 0 to (Length(x.XmfHTMLGumpColor) - 1)do
  begin
    if (x.XmfHTMLGumpColor[i].Cliloc_ID = Cliloc) then
    begin
      for ii := 0 to (Length(x.GumpButtons) - 1)do
      begin
        if 
        ((x.GumpButtons[ii].X = (x.XmfHTMLGumpColor[i].X - RangeX))and(x.GumpButtons[ii].Y = (x.XmfHTMLGumpColor[i].Y - RangeY)))then
        begin
          ClickButton(x.GumpButtons[ii].return_value,GumpID,UseWait);
          exit;
        end;
      end;  
    end;
  end; 
end;
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
procedure CloseGump(Simple:Boolean);
var Serial :Cardinal;
begin
  Serial := GetLastSerial();
  if (Simple = true) then
  begin
    CloseSimpleGump(CountGumps());
  end else begin
    ClickButton(0,0,false);
  end;
  WaitSerial(Serial);  
end;
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
procedure ClickTileButton(TileArt:Integer;GumpID:Cardinal;UseWait:Boolean);
var x : TGumpInfo;
var i : Integer;
var Serial :Cardinal;
begin
  Serial := GetLastSerial();
  x :=GetLastGump();
  for i := 0 to (Length(x.GumpButtons) - 1)do
  begin
    if ((x.GumpButtons[i].released_id = TileArt) or (x.GumpButtons[i].pressed_id = TileArt))then
    begin
      ClickButton(x.GumpButtons[i].return_value,GumpID,UseWait);
      exit;
    end; 
  end;
end;
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
function SearchClilocText(Cliloc:Integer):Boolean;
var x : TGumpInfo;
var i : Integer;
begin
  Result := false;
  x :=GetLastGump();
  for i := 0 to (Length(x.XmfHTMLGumpColor) - 1)do
  begin
    if (x.XmfHTMLGumpColor[i].Cliloc_ID = Cliloc) then
    begin
      Result := true; 
      exit;
    end;
  end; 
end;
end.
[size=20pt]Module Gumps[/size]
Index
  • [li]Purpose[/li]
    [li]How to Use[/li]
    [li]Function Overview[/li]
    [li]Some Examples[/li]
Purpose
Gumps are a major theme for every Coder. In Easyuo you may thought "oh those are hard to handle" but you could not say this for Stealth. Coming up with Version 4.0.3 you will have the Opportunity to work with Gumps like regular Objects.
You can find an Overview about Here.

How to Use
To work with Modules you will be needed to copy the attached file into StealthFolder\Scripts\ .
Then write following after initiate the program :
Uses Gumps;
If you followed these steps right you wont get any Syntax Errors.

Function Overview
function CountGumps():Integer;
Returns the Amount of Opened Gumps. Since they Start with 0 and end with Amount - 1 i simple wrote this function to avoid Problems by Users for trying functions out of range.
function GetLastSerial():Cardinal;

Returns the Serial (Number of the Gump received from Shard) of Toplayer Gump (Newest)
function GetLastGumpID():Cardinal;
Returns the GumpID(Static "Type" of Gump) of Toplayer Gump (Newest)
function GetLastGump():TGumpInfo;
Returns the Toplayer Gump as Object (Newest);
procedure WaitGumpID(GumpID:Cardinal);
Will wait until Toplayer GumpID is GumpID. On Liveshard it means -> Incoming Packet with GumpID + 1ms delay (Speedy or Not?)
procedure WaitSerial(Serial:Cardinal);

Will Wait until Toplayer Serial is no Longer Serial. On Liveshard it means -> Incoming Packet with new Serial + 1ms delay (Speedy or Not?)
procedure ClickButton(ButtonValue:Integer;GumpID:Cardinal;UseWait:Boolean);
Its an extension to "WaitGump" from Stealth. Will convert the ButtonValue to String and send it to Server. You need to set a GumpID (0 if you wanna skip but you will need to fill anything if you wait or not) and modify the UseWait. If UseWait is False it will skip Waiting for new Serial and the GumpID. Else it will use "WaitGumpID" and "WaitSerial" from Module for waiting.
procedure ClickObject(ObjectID:Integer;GumpID:Cardinal;UseWait:Boolean);
Similar to "ClickButton" but using ObjectID instead of Packet (NPC,Items as example) to get a gump. Options are same then "ClickButton".
ClickClilocButton(Cliloc:Integer;RangeX,RangeY:Integer;GumpID:Cardinal;UseWait:Boolean);
This function is special. Do you Remember Craft Buttons? Did you ever wanted to make those stuff dynamicly? If you want to click the button left of a text you can use this function. Cliloc means the ID of the Text(Server sends Cliloc and Client reads Text). This means no matter wich languange you will be able to click the button in left of Text.
RangeX and RangeY is the Range from TextStart. So if Button is +- 40 pixel from Text.X Range X will be 40 and when Button +- pixel from TextY and both is true then it will click this Button. Please be Aware that if you make a big range it "may " click the wrong Button. On my Runuo Example Buttons were about 35,3 from Text. So no other Button were be found in this Range and it were 100% recognized.
GumpID and UseWait are Similar to "ClickButton". It uses Clickbutton if recognize the Button.
procedure CloseGump(Simple:Boolean);
Want to Close a Gump? Some Gumps can be closed by rightclick (then Simple = true) or need to be forced by packet (Simple = false). Gump will Close and wait until Serial Changed again.

procedure ClickTileButton(TileArt:Integer;GumpID:Cardinal;UseWait:Boolean);
This function is an alternate to ClickButton. If your Button has a unique Design (Heartwooquests like Accept,Close,Refuse) you can click the Button for Searching the TileArt. Tilearts are like Clilocs. Server sends a number and Client reads the Button from files. It will check if TileArt is pressed or released as Button and use the "ClickButton" with the Value of the Button. Perfect for Heartwood ;)
function SearchClilocText(Cliloc:Integer):Boolean;
Simple function to Compare Texts in Gumps by using Cliloc.
Will check all Cliloc Texts and return true if exist and false if not. (Heartwood Questlog as example)

Some Examples
Crafting a Skirt :

Code: Select all

program test;
Uses Gumps;
begin
ClickObject($400005C7,$77567887,true);
ClickClilocButton(1015279,35,3,$77567887,true)  
ClickClilocButton(1025398,35,3,$77567887,true);
CloseGump(false);
end.
Replace $400005C7 with ID of your Tool (Sewing Kit). Will Craft you a Skirt once :)

Enjoy
Stealth Development Team & Support
TheEnd
Neophyte
Neophyte
Posts: 23
Joined: 20.11.2012 11:20
Contact:

Re: About Auto-Quest...... how to Compare the String?

Post by TheEnd »

Thank you very much , Crome696

This question troubles me for a long time,
i think i have an idea about it, now! ^_^
Thanks again.

PS: wish to complete the Auto-Quests.(Heartwood Quests)
Crome696
Novice
Novice
Posts: 67
Joined: 04.03.2012 18:57
Location: Germany
Contact:

Re: About Auto-Quest...... how to Compare the String?

Post by Crome696 »

I already finished that long time ago, but lost the code. I have a folder with around 900 script snippets\scripts i wrote but need to merge and update all code first..
Stealth Development Team & Support
TheEnd
Neophyte
Neophyte
Posts: 23
Joined: 20.11.2012 11:20
Contact:

Re: About Auto-Quest...... how to Compare the String?

Post by TheEnd »

All lost? that is too bad.
any suggests about the Item Property to evaluate?
u know, the Reward(eg:rings, bracelet,etc) to evaluate is a truble thing.
if have any example is better for me.
im a new scripter to use Stealth.

PS: im sorry for my poor english. :P
Crome696
Novice
Novice
Posts: 67
Joined: 04.03.2012 18:57
Location: Germany
Contact:

Re: About Auto-Quest...... how to Compare the String?

Post by Crome696 »

I currently writing such parts.
Converting Runuo Class Definitions as Type for Stealth.
Sample:

Code: Select all

Type Jewelry = record;
Name : String;
Weight : Double;
LowerReagentCost:Integer;
....
Then Method to Write properties from Item into Object. Returning Jewelry.
But iam on Start of this.
Written yet first Basic functionality eg. Collections, Arrayhandler,Point2D,Point3D,Size from runuo.

If you wanna toy yourself for handling properties properly i suggest the Methods Vizit0r implemented with last Update :
Program New;
var
aa : TClilocRec;
bb : TClilocItemRec;
i,k : Integer;
begin
aa := GetToolTipRec($01FC613C);
AddToSystemJournal('Total lines in Toolptip: ' + IntToStr(aa.Count));
for i := 0 to aa.Count - 1 do
begin
AddToSystemJournal('Line ' + IntToStr(i) + ': ');
bb := aa.Items;
AddToSystemJournal('Cliloc: $' + IntToHex(bb.ClilocID,8));
AddToSystemJournal('Cliloc text: ' + GetClilocByID(bb.ClilocID));
for k := 0 to Length(bb.Params) - 1 do
AddToSystemJournal('Param' + IntToStr(k) + ': "'
+ bb.Params[k] + '"');
end;
end.

Source : http://stealth.od.ua/forum/viewtopic.ph ... &start=120

Ps : My English isnt best as well. But my russian is horrible. Keep it cool.

Crome ( from Germany )
Stealth Development Team & Support
TheEnd
Neophyte
Neophyte
Posts: 23
Joined: 20.11.2012 11:20
Contact:

Re: About Auto-Quest...... how to Compare the String?

Post by TheEnd »

ive got the handling properties properly with the Methods Vizit0r implemented Scripted.
e.g:
//$00102E3C -- faster cast recovery
//$00102E3D -- faster casting
//$00102E52 -- lower reagent cost

and i complete the script like this:

Code: Select all

function Evaluation(ValuableItem:Cardinal):Boolean;
var
  aa : TClilocRec;
  bb : TClilocItemRec;
  i,k,j : Integer;
  //CurItemPro: Cardinal;
begin
  aa := GetToolTipRec(ValuableItem);
  if ((aa.Count - 2) > 3) then
  begin
    //AddToSystemJournal('Iitem Have ' + IntToStr(aa.Count - 2)+' Properties!');
    for i := 0 to aa.Count - 1 do
    begin
      //AddToSystemJournal('Line ' + IntToStr(i) + ': ');
      bb := aa.Items[i];
      //AddToSystemJournal('Cliloc: $' + IntToHex(bb.ClilocID,8));
      //AddToSystemJournal('Cliloc text: ' + GetClilocByID(bb.ClilocID));
      for k := 0 to Length(bb.Params) - 1 do
        //for j := 0 to (aa.Count - 2) do
        begin
          if ((bb.ClilocID = $00102E3C) and (StrToInt(bb.Params[k]) >= 2)) or ((bb.ClilocID = $00102E3D) and (StrToInt(bb.Params[k]) > 0))  then
          begin
          //if ((bb.ClilocID <> $00102E3D) and (StrToInt(bb.Params[k]) < 0)) then
          //begin
            Result := True;
            AddToSystemJournal('Prepair to Move Valuable Item.');
          //Exit;
          //end; 
          end;
          //AddToSystemJournal('Param' + IntToStr(k) + ': "'+ bb.Params[k] + '"');
        end;
    end; 
  end;
end;
with the Script only get One Property: "faster cast recovery" or "faster casting", not Both.
can you improved my Scripts to get Tow Properties or more?
Crome696
Novice
Novice
Posts: 67
Joined: 04.03.2012 18:57
Location: Germany
Contact:

Re: About Auto-Quest...... how to Compare the String?

Post by Crome696 »

I wroted yesterday for test some code. But rewroted most of this today again. But the old code could give you some sample how i created Jewelry Object.

http://dumpz.org/345903/
save that code as Items.pas into your Scripts folder in stealth folder and then create a script file using the following code

Code: Select all

Program Sampler;
Uses Items; 
var x : Jewelry;
begin
  if ( ReadJewelry($40017D9F,x) = True ) Then
  begin
    AddToSystemJournal( floattostr(x.ItemValue) );                                                          
  end;
end.
replace $40017D9F with an ID of yours.
if you want as sample read Faster casting use

Code: Select all

AddToSystemJournal(IntToStr(x.Attributes.CastSpeed));
Stealth Development Team & Support
User avatar
Vizit0r
Developer
Developer
Posts: 3958
Joined: 24.03.2005 17:05
Contact:

Re: About Auto-Quest...... how to Compare the String?

Post by Vizit0r »

TheEnd wrote:i want to receive the Quest of "Lethal Darts" , but no idea how to compare the String of 'crossbow bolts' correctly.
with the Script do not work, help me! thanks.
if lowerstring(XXXX) = 'crossbow bolts' then
....
"Пишите код так, как будто сопровождать его будет склонный к насилию психопат, который знает, где вы живете". (с) Макконнелл, "Совершенный код".
TheEnd
Neophyte
Neophyte
Posts: 23
Joined: 20.11.2012 11:20
Contact:

Re: About Auto-Quest...... how to Compare the String?

Post by TheEnd »

Vizit0r wrote:
TheEnd wrote:i want to receive the Quest of "Lethal Darts" , but no idea how to compare the String of 'crossbow bolts' correctly.
with the Script do not work, help me! thanks.
if lowerstring(XXXX) = 'crossbow bolts' then
....
With Crome696's useful Function "SearthClolicText",
I've got the right Quest, just only "Lethal Darts".

sure, i'll try this way to complete the Quest.

Thanks^_^
TheEnd
Neophyte
Neophyte
Posts: 23
Joined: 20.11.2012 11:20
Contact:

Re: About Auto-Quest...... how to Compare the String?

Post by TheEnd »

Crome696 wrote:I wroted yesterday for test some code. But rewroted most of this today again. But the old code could give you some sample how i created Jewelry Object.

http://dumpz.org/345903/
save that code as Items.pas into your Scripts folder in stealth folder and then create a script file using the following code

Code: Select all

Program Sampler;
Uses Items; 
var x : Jewelry;
begin
  if ( ReadJewelry($40017D9F,x) = True ) Then
  begin
    AddToSystemJournal( floattostr(x.ItemValue) );                                                          
  end;
end.
replace $40017D9F with an ID of yours.
if you want as sample read Faster casting use

Code: Select all

AddToSystemJournal(IntToStr(x.Attributes.CastSpeed));
Thank you very much.
im going to try get multi-Propeties of one objet.
and then to evaluate it.
PS: The code is very useful for me. Great job!
Crome696
Novice
Novice
Posts: 67
Joined: 04.03.2012 18:57
Location: Germany
Contact:

Re: About Auto-Quest...... how to Compare the String?

Post by Crome696 »

No Problem. Me and a User from Scriptuo currently datamining for all kind of properties and their clilocs on osi + how to handle each individual ObjectType( Sorted in different Classifications like Armor,jewelry,Shield,Melee,Range,Spellbook, Talisman,Cloth and more :) )
Stealth Development Team & Support
Post Reply