ScriptUO

Scripting Resources & Utilities => Stealth Client => Stealth archive => Topic started by: slyone on November 08, 2013, 07:34:13 PM

Title: How do you get a target cursor in Stealth?
Post by: slyone on November 08, 2013, 07:34:13 PM
In my easyuo scripts I like to use the cursor to get the ID of an item I plan to use.  An example of the code I usually use is:
Code: [Select]
set #TARGCURS 1
target ;wait 3s for target cursor to appear
; loop until the player targets an item
while #TARGCURS = 1
    wait 0
; save the id into %myvar
set %myvar #LTARGETID

How would you write similar code in Stealth?
Title: Re: How do you get a target cursor in Stealth?
Post by: Orich on November 08, 2013, 07:43:37 PM
I encourage you to peruse through the C# script tutorial.  It goes over this ... but here are two examples :


1.  Bring up a local client target, get an object ID


Using ScriptAPI.cs
Code: [Select]
   Item Result = Target.RequestTarget();

Using ScriptDotNet.DLL Normal API :
Code: [Select]
   Stealth.Script_ClientRequestObjectTarget(); // This brings up a target cursor in Client.exe

   while(Stealth.Script_ClientTargetResponsePresent() == false) // while Client.exe does NOT have a target
      Stealth.Script_Wait(100); // Wait 100ms, then loop

   var ChosenTarget = Stealth.Script_ClientTargetResponse(); // This function returns a TTargetInfo object with ID, Tile, X, Y, Z


Now, in those two examples this is bringing up a "Virtual Target" ... Meaning, we are requesting a target in Client.exe, but it will never send the result back to the game server.  This is a local interaction between Stealth and the Client.exe

If, say, you wanted to cast a spell and wait for the server's target :


Code: [Select]
   Stealth.Script_CastSpell("Greater Heal");  // same as Self.Cast()
   
   Stealth.Script_WaitForTarget(10000); // Wait for target to appear, timeout after 10,000 milliseconds (10 seconds)
   uint LastTarget = Stealth.Script_GetLastTarget();
Title: Re: How do you get a target cursor in Stealth?
Post by: slyone on November 09, 2013, 07:51:57 AM
Excellent examples, thank you!

For reference, I found the point in the video tutorial (https://www.youtube.com/watch?v=xPQh2YlIZzM#t=740) that you describe the bag setup.  Also, the ChooseBag function starts on line 43 in Program.cs (https://bitbucket.org/Orich/orune/src/a43f6b2078210ab70efe7e0019672f451e7dfff4/oRune/Program.cs?at=master) from the C# tutorial (http://www.scriptuo.com/index.php?topic=11675.0).

Thanks again,
S