ScriptUO
Scripting Resources & Utilities => Stealth Client => Stealth Snippets\Library => Topic started by: dxrom on September 22, 2013, 09:54:08 PM
-
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:
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:
Skill('Tracking',100,12,0);
Skill('Detect Hidden',100,12,Self);
-
My default Init sub:
Program Init;
VAR
SelfID : Cardinal;
SelfIDStr : String;
Procedure Init;
begin
SelfIDStr := '$' + (IntToHex(Self,8));
SelfID := StrToInt(SelfIDStr);
end;
Checking Special Abilities sub:
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:
CheckSpecial($26C2,'Armor Ignore','Primary',2);
You'll need to figure out the TYPE of the weapon.
-
Spell Casting Sub:
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:
CastSpell('Enemy of One',1,0);
For setting up timers and such you can utilize the Fizzle variable. IE:
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...
CastSpell('Remove Curse',3,SELFID);
-
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.
-
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 :>
-
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 ;)
-
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:
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.
-
Honor Sub:
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:
HonorTarget(WhateverTargetYouWant);
-
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.
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:
MoveTo($Whoever,1,True);
True toggles running on. False would be to walk.
-
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.
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:
if( IsBalanced ) then
begin
//Pot up
end;
-
Sub to move multiple stacks of items within an array, returns integer value of length of array:
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)
GrapeTypes:=[$09D1,$0D1A];
MoveArray(GrapeTypes,Backpack,grapeBag);
if( (MoveArray(GrapeTypes,Backpack,grapeBag)=Length(GrapeTypes)) )
-
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.
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:
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...
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:
Instruments:=[$0EB2,$0E9D];
if( ItemsFound(Instruments,Backpack) ) then
begin
//do whatever
end;
Also, 600th post :>
-
Function to get use count from an item.
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.
if( (FindTypeEx($1022,$FFFF,Backpack,False)>0) ) then
begin
ClientPrint(IntToStr(GetUseCount(FindItem)));
end;
Comparing count of fletchers tools.
if( (FindTypeEx($1022,$FFFF,Backpack,False)>0) ) then
begin
if( GetUseCount(FindItem)>60 ) then
begin
//Do whatever here.
end
end;
-
I completely forgot about this thread... I guess I can start updating it again, heh...
Functions to handle weapon durability.
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:
Begin
if( UsingWep ) AND ( WeaponDurability<=1 ) then
begin
Disarm;
end;
End.