ScriptUO
		Scripting Resources & Utilities => Stealth Client => Stealth Snippets\Library => Topic started by: dxrom on October 20, 2013, 03:42:42 PM
		
			
			- 
				So as some of you will most likely notice when making your scripts to train characters, when you utilize GetSkillValue(SkillName); that any +/-skill items aren't taken into consideration. This is a problem for things like Magery training with -Magery items or Ninjitsu training to get into Death Strike training sooner. There is a solution however.
What you will need:
1. A CliLoc ID.
2. A Parameter within that CliLoc.
3. A Programmer Calculator (hint: Windows has one)
4. UOFiddler.
5. Common sense.
So, how do we get a CliLocID and Parameter? Easy. With this script.
Program New;
var
  aa : TClilocRec;
  bb : TClilocItemRec;
  i,k : Integer;
begin
  aa := GetToolTipRec($0);
  AddToSystemJournal('Total lines in Toolptip: ' + IntToStr(aa.Count));
  if aa.count > 0 then
  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
      AddToSystemJournal('Param-' + IntToStr(k) + ': "' + bb.Params[k] + '"');
  end;
end.
Where aa := GetToolTipRec($0); is you need to toss in the ItemID of the Item with +/-Skill on it. This is only if you don't have the CliLocID and Parameter of the skill you want to check.
Let's say Magery. When running this script on a Scrapper's Compendium we get this output:
15:43:59:905 [dxrom]: Compiling
15:43:59:918 [dxrom]: Compiled succesfully
15:43:59:919 [dxrom]: Total lines in Toolptip: 8
15:43:59:920 [dxrom]: Line 0: 
15:43:59:920 [dxrom]: Cliloc: $00105F2C
15:43:59:921 [dxrom]: Cliloc text: Scrapper's Compendium
15:43:59:922 [dxrom]: Line 1: 
15:43:59:923 [dxrom]: Cliloc: $000FD6C5
15:43:59:924 [dxrom]: Cliloc text: Blessed
15:43:59:925 [dxrom]: Line 2: 
15:43:59:926 [dxrom]: Cliloc: $00102E63
15:43:59:927 [dxrom]: Cliloc text: ~1_skillname~ +~2_val~
15:43:59:928 [dxrom]: Param-0: "#1042372"
15:43:59:929 [dxrom]: Param-1: "10"
15:43:59:930 [dxrom]: Line 3: 
15:43:59:931 [dxrom]: Cliloc: $00102E83
15:43:59:932 [dxrom]: Cliloc text: spell damage increase ~1_val~%
15:43:59:934 [dxrom]: Param-0: "25"
15:43:59:935 [dxrom]: Line 4: 
15:43:59:936 [dxrom]: Cliloc: $00102E3C
15:43:59:937 [dxrom]: Cliloc text: faster cast recovery ~1_val~
15:43:59:938 [dxrom]: Param-0: "1"
15:43:59:939 [dxrom]: Line 5: 
15:43:59:940 [dxrom]: Cliloc: $00102E3D
15:43:59:942 [dxrom]: Cliloc text: faster casting ~1_val~
15:43:59:944 [dxrom]: Param-0: "1"
15:43:59:945 [dxrom]: Line 6: 
15:43:59:946 [dxrom]: Cliloc: $00102E51
15:43:59:948 [dxrom]: Cliloc text: lower mana cost ~1_val~%
15:43:59:949 [dxrom]: Param-0: "10"
15:43:59:950 [dxrom]: Line 7: 
15:43:59:951 [dxrom]: Cliloc: $000FE9C6
15:43:59:952 [dxrom]: Cliloc text: ~1_NUMBERS_OF_SPELLS~ Spells
15:43:59:953 [dxrom]: Param-0: "3"
15:43:59:954 [dxrom]: Succesfully executed
15:43:59:955 [dxrom]: Script GumpSearch.sc stopped successfuly
The point of interest here is: 
 Cliloc: $00102E63
Cliloc text: ~1_skillname~ +~2_val~
Param-0: "#1042372"
Param-1: "10"
Opening calculator I see that  $00102E63 HEX->DEC is 1060451. Opening UOFiddler and going to that address within the CliLoc tab I see that there are five similar CliLocs for +/-Skill.
(http://puu.sh/4VbpZ.png)
Take note of those as we'll incorporate them all.
The second thing we want to take note of is Param-0: "#1042372". That is another CliLocID, except it's already in Decimal format. So let's check out what is at that ID shall we?
(http://puu.sh/4Vbzt.png)
Okay, so we have now have the data that we need to start to write our function.
For simplicity sake we'll use jewelry. It should look something like this:
Function GetJewelrySkill(CliLocParam:String):Integer;
var
  a:TClilocRec;
  b:TClilocItemRec;
  i:Integer;
  R,BR:Integer;
begin
  if( GetType(ObjAtLayer(BraceLayer))=0 ) then
  begin
    BR:=0;
  end
  else begin
    a:=GetToolTipRec(ObjAtLayer(BraceLayer));
	if( a.Count > 0 ) then
	begin
	  for i:=0 to a.Count-1 do
	  begin
	    b:=a.Items[i];
		if( (b.ClilocID >= 1060451) AND (b.ClilocID <= 1060455) ) then
		begin
		  if( b.Params[0] = CliLocParam ) then
		  begin
		    BR:=StrToInt(b.Params[1]);
		  end;
		end;
	  end;
	end;
  end;
  
  if( GetType(ObjAtLayer(RingLayer))=0 ) then
  begin
    R:=0;
  end
  else begin
	a:=GetToolTipRec(ObjAtLayer(RingLayer));
	if( a.Count>0 ) then
	begin
	  for i:=0 to a.Count-1 do
	  begin
		b:=a.Items[i];
		if( (b.ClilocID >= 1060451) AND (b.ClilocID <= 1060455) ) then
		begin
		  if( b.Params[0] = CliLocParam ) then
		  begin
		    R:=StrToInt(b.Params[1]);
		  end;
		end;
	  end;
	end;
  end;
  
  Result:=R+BR;
end;
Those with a keen eye will have noticed, this function returns an Integer, but GetSkillValue returns a Double. That's not a problem since we can truncate the double.
Using this command will get the effective value of magery with jewelry and assign it as an Integer to variable SKILL
SKILL:=GetJewelrySkill('#1042372')+Trunc(GetSkillValue('Magery'));
I hope that this helps people out in their stealthy adventures, where you're only limitation is your imagination! :D
For more info on what layers there are to play with, check out http://stealth.od.ua/Category:Layers