Author Topic: [Pascal Example] dxrom's stealth subs  (Read 14016 times)

0 Members and 1 Guest are viewing this topic.

Offline dxromTopic starter

  • Master of the milestones!
  • Elite
  • *
  • *
  • Posts: 1080
  • Activity:
    0%
  • Reputation Power: 15
  • dxrom is working their way up.dxrom is working their way up.dxrom is working their way up.
  • KEYBOARD COWBOY, GREAT SAMURAI OF THE INTERNET.
  • Respect: +277
  • Referrals: 1
    • View Profile
[Pascal Example] dxrom's stealth subs
« on: September 22, 2013, 09:54:08 PM »
+1
I'm going to start updating this thread with various subs that I utilize with stealth, hopefully other people find uses for them as well.

Skill training sub:
Code: [Select]
Program SkillTrainingSub;

VAR
  SKILLTIMER : Cardinal;

procedure Skill(Name:String; Level:Double; Delay:Integer; Target:Cardinal);
begin
  if( GetSkillValue(Name) <= Level ) AND ( GetTickCount>SKILLTIMER ) then
  begin
    if( Target=0 ) then
    begin
      UseSkill(Name);
      SKILLTIMER:=GetTickCount()+(Delay*1000);
    end
    else begin
      CancelTarget();
      UseSkill(Name);
      if( WaitForTarget(1000) ) then
      begin
        TargetToObject(Target);
        SKILLTIMER:=GetTickCount()+(Delay*1000);
      end;
    end;
  end;
  Wait(125);
end;

Example of Skill training sub:
Code: [Select]
Skill('Tracking',100,12,0);
Skill('Detect Hidden',100,12,Self);
« Last Edit: October 09, 2013, 10:08:20 PM by Orich »



 ​_██​_
(ಠ​_ృ)
I do say, ol' Chap! Come play EVE Online! Why here is a 21 Day Free Trial!

Offline dxromTopic starter

  • Master of the milestones!
  • Elite
  • *
  • *
  • Posts: 1080
  • Activity:
    0%
  • Reputation Power: 15
  • dxrom is working their way up.dxrom is working their way up.dxrom is working their way up.
  • KEYBOARD COWBOY, GREAT SAMURAI OF THE INTERNET.
  • Respect: +277
  • Referrals: 1
    • View Profile
Re: dxrom's stealth subs
« Reply #1 on: September 22, 2013, 10:00:24 PM »
+1
My default Init sub:

Code: [Select]
Program Init;

VAR
  SelfID : Cardinal;
  SelfIDStr : String;

Procedure Init;
begin
  SelfIDStr := '$' + (IntToHex(Self,8));
  SelfID := StrToInt(SelfIDStr);
end;

Checking Special Abilities sub:
Code: [Select]
Program CheckSpecials;
//Requires default init.

procedure CheckSpecial(Wep:Cardinal; Ability:String; Special:String; Hands:Integer);
begin
  if( Hands = 1 ) then
  begin
    if( GetType(ObjAtLayer(RHandLayer())) = Wep ) then
    begin
      if( (GetActiveAbility<> Ability) AND (GetMana(SELFID)>10) ) then
      begin
        if( Special = 'Primary' ) then
        begin
          UsePrimaryAbility;
        end;
        if( Special = 'Secondary' ) then
        begin
          UseSecondaryAbility;
        end;
        
        ClientPrint(GetActiveAbility);
        wait(175);
      end;
    end;
  end;
  
  if( Hands = 2 ) then
  begin
    if( GetType(ObjAtLayer(LHandLayer())) = Wep ) then
    begin
      if( (GetActiveAbility<> Ability) AND (GetMana(SELFID)>10) ) then
      begin
        if( Special = 'Primary' ) then
        begin
          UsePrimaryAbility;
        end;
        if( Special = 'Secondary' ) then
        begin
          UseSecondaryAbility;
        end;
        
        ClientPrint(GetActiveAbility);
        wait(175);
      end;
    end;
  end;
end;

Example of how to use the sub to check special abilities:

Code: [Select]
CheckSpecial($26C2,'Armor Ignore','Primary',2);
You'll need to figure out the TYPE of the weapon.
« Last Edit: September 22, 2013, 10:03:08 PM by dxrom »



 ​_██​_
(ಠ​_ృ)
I do say, ol' Chap! Come play EVE Online! Why here is a 21 Day Free Trial!

Offline dxromTopic starter

  • Master of the milestones!
  • Elite
  • *
  • *
  • Posts: 1080
  • Activity:
    0%
  • Reputation Power: 15
  • dxrom is working their way up.dxrom is working their way up.dxrom is working their way up.
  • KEYBOARD COWBOY, GREAT SAMURAI OF THE INTERNET.
  • Respect: +277
  • Referrals: 1
    • View Profile
Re: dxrom's stealth subs
« Reply #2 on: September 22, 2013, 10:09:11 PM »
+1
Spell Casting Sub:

Code: [Select]
Program SpellCasting;

VAR
  Fizzle : Boolean;
  CastTimer : Cardinal;

procedure CastSpell(Name:String; CastTime: Integer; Target:Cardinal);
var
i:Integer;
timer:TDateTime;
begin
  if( Target=0 ) then
  begin
    i:=0;
    timer:=Now;
    
    if( GetTickCount>CastTimer ) then
    begin
      Cast(Name);
      repeat
        i:=i+100;
        wait(100);
      until( (InJournalBetweenTimes('concentration is|', timer, Now)<>-1) OR (i > 1000));
      CastTimer:=GetTickCount+2000;
    end;
  end;  
  
  if( Target<>0 ) then                                                                                                                                                    
  begin
    i:=0;
    timer:=Now;
    
    if( GetTickCount>CastTimer ) then
    begin
      Cast(Name);
      repeat
        i:=i+100;
        wait(100);
      until( (InJournalBetweenTimes('concentration is|', timer, Now)<>-1) OR ( i > 2000) OR (TargetPresent()));
      if( TargetPresent ) then
      begin
        TargetToObject(Target);
        CastTimer:=GetTickCount()+2000;
      end;
    end;
  end;
  
  if( InJournalBetweenTimes('concentration is|', timer, Now)<>-1 ) then
  begin
    Fizzle:=True;
  end
  else
  begin
    Fizzle:=False;
  end;  
wait(200);
end;

Example of Spell Casting sub:

Code: [Select]
CastSpell('Enemy of One',1,0);
For setting up timers and such you can utilize the Fizzle variable. IE:

Code: [Select]
Program ConWep;
VAR
  ConWepTimer : Cardinal;

CastSpell('Consecrate Weapon',1,0);
    if( Fizzle=False ) then
    begin
      ConWepTimer:=GetTickCount()+9000;
    end;

You can apply the target to the pass also...
Code: [Select]
CastSpell('Remove Curse',3,SELFID);
« Last Edit: September 22, 2013, 10:11:00 PM by dxrom »



 ​_██​_
(ಠ​_ృ)
I do say, ol' Chap! Come play EVE Online! Why here is a 21 Day Free Trial!

Offline Masscre

  • Gran Master Jester !!
  • Scripthack
  • *
  • Posts: 4615
  • Activity:
    0%
  • Reputation Power: 55
  • Masscre is leading the good life!Masscre is leading the good life!Masscre is leading the good life!Masscre is leading the good life!Masscre is leading the good life!Masscre is leading the good life!Masscre is leading the good life!Masscre is leading the good life!Masscre is leading the good life!Masscre is leading the good life!Masscre is leading the good life!
  • Gender: Male
  • Air Guitar Commander !!
  • Respect: +390
  • Referrals: 1
    • View Profile
Re: dxrom's stealth subs
« Reply #3 on: September 23, 2013, 05:33:36 AM »
+1
Thank you for these DXRom. I have been looking for some small script to pick apart on stealth. I really want to learn stealth now that I am having a little more time to play with UO, but not alot of script for stealth out there to look at. That is my best way to learn is pick it apart and figure what does what.

Offline dxromTopic starter

  • Master of the milestones!
  • Elite
  • *
  • *
  • Posts: 1080
  • Activity:
    0%
  • Reputation Power: 15
  • dxrom is working their way up.dxrom is working their way up.dxrom is working their way up.
  • KEYBOARD COWBOY, GREAT SAMURAI OF THE INTERNET.
  • Respect: +277
  • Referrals: 1
    • View Profile
Re: dxrom's stealth subs
« Reply #4 on: September 23, 2013, 11:10:43 AM »
+1
Thank you for these DXRom. I have been looking for some small script to pick apart on stealth. I really want to learn stealth now that I am having a little more time to play with UO, but not alot of script for stealth out there to look at. That is my best way to learn is pick it apart and figure what does what.

No problem man. I had to do the same thing when learning stealth, and am still doing it. I learn something new every time I get my hands on one of crome's scripts :>



 ​_██​_
(ಠ​_ృ)
I do say, ol' Chap! Come play EVE Online! Why here is a 21 Day Free Trial!

Offline Crome969

  • Moderator
  • *
  • *****
  • Posts: 2098
  • Activity:
    0%
  • Reputation Power: 25
  • Crome969 is on the verge of being accepted.Crome969 is on the verge of being accepted.Crome969 is on the verge of being accepted.Crome969 is on the verge of being accepted.Crome969 is on the verge of being accepted.
  • Gender: Male
  • UO Enthusiast
  • Respect: +559
  • Referrals: 10
    • View Profile
    • ScriptSDK
Re: dxrom's stealth subs
« Reply #5 on: September 23, 2013, 09:07:56 PM »
+1
No problem man. I had to do the same thing when learning stealth, and am still doing it. I learn something new every time I get my hands on one of crome's scripts :>
And you saw only the tip of the mountain *giggles*.

Good Job for releasing your Snippets! Btw we fixxed events in betaclient ;)

Offline dxromTopic starter

  • Master of the milestones!
  • Elite
  • *
  • *
  • Posts: 1080
  • Activity:
    0%
  • Reputation Power: 15
  • dxrom is working their way up.dxrom is working their way up.dxrom is working their way up.
  • KEYBOARD COWBOY, GREAT SAMURAI OF THE INTERNET.
  • Respect: +277
  • Referrals: 1
    • View Profile
Re: dxrom's stealth subs
« Reply #6 on: September 23, 2013, 10:52:51 PM »
+1
No problem man. I had to do the same thing when learning stealth, and am still doing it. I learn something new every time I get my hands on one of crome's scripts :>
And you saw only the tip of the mountain *giggles*.

Good Job for releasing your Snippets! Btw we fixxed events in betaclient ;)

I seen, still one bug though, events aren't returning as True, only false an null. I'm working around it atm with:
Code: [Select]
if( Attribute_ID = ConWepID ) then
  begin
    if( IsEnabled <> False ) AND ( IsEnabled <> True ) then
    begin
      ConWepActive:=True;
    end
    else begin
      ConWepActive:=False;
    end;
  end;

as example.



 ​_██​_
(ಠ​_ృ)
I do say, ol' Chap! Come play EVE Online! Why here is a 21 Day Free Trial!

Offline dxromTopic starter

  • Master of the milestones!
  • Elite
  • *
  • *
  • Posts: 1080
  • Activity:
    0%
  • Reputation Power: 15
  • dxrom is working their way up.dxrom is working their way up.dxrom is working their way up.
  • KEYBOARD COWBOY, GREAT SAMURAI OF THE INTERNET.
  • Respect: +277
  • Referrals: 1
    • View Profile
Re: dxrom's stealth subs
« Reply #7 on: October 09, 2013, 08:27:50 AM »
+1
Honor Sub:

Code: [Select]
Program HonorSub;

VAR
  LastHonored : Cardinal;

function CanHonor(Target:Cardinal):Boolean;
begin
  if( GetHP(Target) >= GetMaxHP(Target) ) then
  begin
    if( Target<>LastHonored ) then
    begin
      Result:=True;
      Exit;
    end;
  end;
  Result:=False;
end;

procedure HonorTarget(Target:Cardinal);
var
  t:TDateTime;
begin
  t:=Now;
  if( CanHonor(Target)=True ) then
  begin
    ReqVirtuesGump();
    UseVirtue('Honor');
    WaitForTarget(1000);
    if( TargetPresent ) then
    begin
      TargetToObject(Target);
      if( InJournalBetweenTimes('You started Honorable Combat!|Somebody else is honoring this opponent|You do not have enough honor to do that', t, Now)<>-1 ) then
      begin
        LastHonored:=Target;
      end;
    end;
  end;
end;

Example of Sub:
Code: [Select]
HonorTarget(WhateverTargetYouWant);
« Last Edit: October 09, 2013, 08:33:24 AM by dxrom »



 ​_██​_
(ಠ​_ృ)
I do say, ol' Chap! Come play EVE Online! Why here is a 21 Day Free Trial!

Offline dxromTopic starter

  • Master of the milestones!
  • Elite
  • *
  • *
  • Posts: 1080
  • Activity:
    0%
  • Reputation Power: 15
  • dxrom is working their way up.dxrom is working their way up.dxrom is working their way up.
  • KEYBOARD COWBOY, GREAT SAMURAI OF THE INTERNET.
  • Respect: +277
  • Referrals: 1
    • View Profile
Re: dxrom's stealth subs
« Reply #8 on: October 09, 2013, 01:18:41 PM »
+1
Follower, Follows 1 tile behind leader. I made this because I noticed an issue with trying to follow a target by utilize their coords to move directly to their spot, even with a variance in Accuracy.

Code: [Select]

procedure MoveTo(Anchor:Cardinal;Distance:Integer;Run:Boolean);
VAR
  X,Y : Integer;
begin
  if( GetDistance(Anchor)>Distance) then
  begin
    X:=GetX(Anchor);
    Y:=GetY(Anchor);
    case GetDirection(Anchor) of
      dirNorth : MoveXY(X,Y+1,True,0,Run);
      dirNorthEast : MoveXY(X-1,Y+1,True,0,Run);
      dirEast : MoveXY(X-1,Y,True,0,Run);
      dirSouthEast : MoveXY(X-1,Y-1,True,0,Run);
      dirSouth : MoveXY(X,Y-1,True,0,Run);
      dirSouthWest : MoveXY(X+1,Y-1,True,0,Run);
      dirWest : MoveXY(X+1,Y,True,0,Run);
      dirNorthWest : MoveXY(X+1,Y+1,True,0,Run);
    end;
    ClearBadLocationList;
  end;
end;

Example of sub:
Code: [Select]
MoveTo($Whoever,1,True);
True toggles running on. False would be to walk.
« Last Edit: October 09, 2013, 01:23:17 PM by dxrom »



 ​_██​_
(ಠ​_ృ)
I do say, ol' Chap! Come play EVE Online! Why here is a 21 Day Free Trial!

Offline dxromTopic starter

  • Master of the milestones!
  • Elite
  • *
  • *
  • Posts: 1080
  • Activity:
    0%
  • Reputation Power: 15
  • dxrom is working their way up.dxrom is working their way up.dxrom is working their way up.
  • KEYBOARD COWBOY, GREAT SAMURAI OF THE INTERNET.
  • Respect: +277
  • Referrals: 1
    • View Profile
Re: dxrom's stealth subs
« Reply #9 on: October 09, 2013, 02:51:43 PM »
+1
Checking for balanced on 2H Weapons.

This is tailored to a template that will only utilize 2H weapons. With a bit more coding it can be tailored to a template that would otherwise utilize a mix of 2H and 1H weapons.

Code: [Select]
function IsBalanced():Boolean;
VAR 
  a : TClilocRec;
  b : TClilocItemRec;
  i : Integer;
begin
  if( ObjAtLayer(LHandLayer)=0 ) AND ( ObjAtLayer(RHandLayer)=0 ) then
  begin
    Result:=True;
    Exit;
  end;
  if( ObjAtLayer(LHandLayer)>0 ) then
  begin
    a := GetToolTipRec(ObjAtLayer(LHandLayer));
    if( a.count > 0 )then
    begin
      for i := 0 TO a.Count - 1 do
      begin
        b := a.Items[i];
        if( b.ClilocID = 1072792 ) then
        begin
          Result:=True;
          Exit;
        end;
      end;
    end;
  end;
 
  if( ObjAtLayer(RHandLayer)>0 ) then
  begin
    a := GetToolTipRec(ObjAtLayer(RHandLayer));
    if( a.count > 0 )then
    begin
      for i := 0 TO a.Count - 1 do
      begin
        b := a.Items[i];
        if( b.ClilocID = 1072792 ) then
        begin
          Result:=True;
          Exit;
        end;
      end;
    end;
  end;
end;

Example:
Code: [Select]
if( IsBalanced ) then
begin
  //Pot up
end;



 ​_██​_
(ಠ​_ృ)
I do say, ol' Chap! Come play EVE Online! Why here is a 21 Day Free Trial!

Offline dxromTopic starter

  • Master of the milestones!
  • Elite
  • *
  • *
  • Posts: 1080
  • Activity:
    0%
  • Reputation Power: 15
  • dxrom is working their way up.dxrom is working their way up.dxrom is working their way up.
  • KEYBOARD COWBOY, GREAT SAMURAI OF THE INTERNET.
  • Respect: +277
  • Referrals: 1
    • View Profile
Re: [Pascal Example] dxrom's stealth subs
« Reply #10 on: October 10, 2013, 04:02:41 PM »
+1
Sub to move multiple stacks of items within an array, returns integer value of length of array:

Code: [Select]
function MoveArray(Items:Array of Cardinal;Source,Destination:Cardinal):Integer;
var
  i:Integer;
begin
  UseObject(Backpack);
  Wait(1250);
  for i:=0 to Length(Items)-1 do
  begin
    if( FindTypeEx(Items[i],$FFFF,Source,True)>0 ) then
    begin
      MoveItems(Source,Items[i],$FFFF,Destination,0,0,0,1250);
    end;
  end; 
  Result:=i;
end;

Example: (taken from my GrapeHarvester script)
Code: [Select]
GrapeTypes:=[$09D1,$0D1A];
MoveArray(GrapeTypes,Backpack,grapeBag);

if( (MoveArray(GrapeTypes,Backpack,grapeBag)=Length(GrapeTypes)) )



 ​_██​_
(ಠ​_ృ)
I do say, ol' Chap! Come play EVE Online! Why here is a 21 Day Free Trial!

Offline dxromTopic starter

  • Master of the milestones!
  • Elite
  • *
  • *
  • Posts: 1080
  • Activity:
    0%
  • Reputation Power: 15
  • dxrom is working their way up.dxrom is working their way up.dxrom is working their way up.
  • KEYBOARD COWBOY, GREAT SAMURAI OF THE INTERNET.
  • Respect: +277
  • Referrals: 1
    • View Profile
Re: [Pascal Example] dxrom's stealth subs
« Reply #11 on: October 11, 2013, 01:22:35 PM »
+1
Set Item function that supports arrays. You would use this item when you have multiple items of one type in your bag and you only need to use one. IE: Training music and having Drums, Tambourines, Harps and Lutes in your bag... Instead of support for just ONE of those or having to write four different FindTypeEx() you can use one array.

Code: [Select]
function SetItem(Items:Array of Cardinal;Container:Cardinal):Cardinal;
var
  i : Integer;
  List : TStringList;
begin
  for i:=0 to Length(Items)-1 do
  begin
    List:=TStringList.Create;
    if( FindTypeEx(Items[i],$FFFF,Container,False)>0 ) then
    begin
      GetFindedList(List);
      Result:=StrToInt('$'+List[0]);
    end;
    
    if( GetFindedList(List)<>False ) then List.Free;
  end;
end;

Example:
Code: [Select]
Instruments:=[$0EB2,$0E9D];

PlayItem:=SetItem(Instruments,Backpack);

UseObject(PlayItem);
//You can do this with targets also...


Item check function that supports arrays also. Same deal as SetItem essentially...

Code: [Select]
function ItemsFound(Items:Array of Cardinal;Container:Cardinal):Boolean;
var
  i : Integer;
begin
  for i:=0 to Length(Items)-1 do
  begin
    if( FindTypeEx(Items[i],$FFFF,Container,False)>0 ) then
    begin
      Result:=True;
      Exit;
    end;
  end;
end;

Example:
Code: [Select]
Instruments:=[$0EB2,$0E9D];

if( ItemsFound(Instruments,Backpack) ) then
begin
//do whatever
end;

Also, 600th post :>
« Last Edit: October 11, 2013, 01:24:30 PM by dxrom »



 ​_██​_
(ಠ​_ృ)
I do say, ol' Chap! Come play EVE Online! Why here is a 21 Day Free Trial!

Offline dxromTopic starter

  • Master of the milestones!
  • Elite
  • *
  • *
  • Posts: 1080
  • Activity:
    0%
  • Reputation Power: 15
  • dxrom is working their way up.dxrom is working their way up.dxrom is working their way up.
  • KEYBOARD COWBOY, GREAT SAMURAI OF THE INTERNET.
  • Respect: +277
  • Referrals: 1
    • View Profile
Re: [Pascal Example] dxrom's stealth subs
« Reply #12 on: October 13, 2013, 05:39:47 AM »
+1
Function to get use count from an item.

Code: [Select]
function GetUseCount(ItemID:Cardinal):Integer;
var
  a : TClilocRec;
  b : TClilocItemRec;
  i : Integer;

begin
  a:=GetToolTipRec(ItemID);
  if( a.Count > 0 ) then
  begin
    for i:=0 to a.Count-1 do
    begin
      b:=a.Items[i];
      if( b.ClilocID = 1060584 ) then
      begin
        Result:=StrToInt(b.Params[0]);
        Exit;
      end;
    end;
  end;

  Result:=0;
end;

Example: Printing count for fletchers tools.
Code: [Select]
if( (FindTypeEx($1022,$FFFF,Backpack,False)>0) ) then
 begin
   ClientPrint(IntToStr(GetUseCount(FindItem)));
 end;

Comparing count of fletchers tools.
Code: [Select]
if( (FindTypeEx($1022,$FFFF,Backpack,False)>0) ) then
 begin
   if( GetUseCount(FindItem)>60 ) then
   begin
     //Do whatever here.
   end
 end;
« Last Edit: October 13, 2013, 06:08:53 AM by dxrom »



 ​_██​_
(ಠ​_ృ)
I do say, ol' Chap! Come play EVE Online! Why here is a 21 Day Free Trial!

Offline dxromTopic starter

  • Master of the milestones!
  • Elite
  • *
  • *
  • Posts: 1080
  • Activity:
    0%
  • Reputation Power: 15
  • dxrom is working their way up.dxrom is working their way up.dxrom is working their way up.
  • KEYBOARD COWBOY, GREAT SAMURAI OF THE INTERNET.
  • Respect: +277
  • Referrals: 1
    • View Profile
Re: [Pascal Example] dxrom's stealth subs
« Reply #13 on: November 10, 2014, 12:42:12 PM »
+1
I completely forgot about this thread... I guess I can start updating it again, heh...

Functions to handle weapon durability.

Code: [Select]
Function WeaponDurability():Integer;
var
  a : TClilocRec;
  b : TClilocItemRec;
  i,k,v : Integer;
  WepLayers : Array of Cardinal;
begin
  WepLayers:=[RhandLayer,LhandLayer];
  for i:=0 to Length(WepLayers)-1 do
  begin
    if( ObjAtLayer(WepLayers[i])<>0 ) then
begin
  a:=GetToolTipRec(ObjAtLayer(WepLayers[i]));
  if( a.Count > 0 ) then
  begin
    for k:=0 to a.Count-1 do
begin
  b:=a.Items[k];
  if( b.ClilocID = 1060639 ) then
  begin
    v:=StrToInt(b.Params[0]);
  end;
end;
  end;
end;
  end;
  Result:=v;
end;

Function UsingWep():Boolean;
var
  i : Integer;
  WepLayers : Array of Cardinal;
begin
  WepLayers:=[RhandLayer,LhandLayer];
  for i:=0 to Length(WepLayers)-1 do
  begin
    if( ObjAtLayer(WepLayers[i])<>0 ) then
begin
  Result:=True;
  Exit;
end;
  end;
  Result:=False;
end;

example:
Code: [Select]
Begin
  if( UsingWep ) AND ( WeaponDurability<=1 ) then
  begin
    Disarm;
  end;
End.



 ​_██​_
(ಠ​_ృ)
I do say, ol' Chap! Come play EVE Online! Why here is a 21 Day Free Trial!

Tags: