Author Topic: Questions on DX's Magery Spellbook Filler  (Read 3038 times)

0 Members and 1 Guest are viewing this topic.

Offline CrisisTopic starter

  • Global Moderator
  • *
  • *
  • Posts: 3014
  • Activity:
    4%
  • Reputation Power: 41
  • Crisis is a force to reckon with.Crisis is a force to reckon with.Crisis is a force to reckon with.Crisis is a force to reckon with.Crisis is a force to reckon with.Crisis is a force to reckon with.Crisis is a force to reckon with.Crisis is a force to reckon with.
  • Gender: Male
  • Scripting well enough to break things!
  • Respect: +206
  • Referrals: 2
    • View Profile
Questions on DX's Magery Spellbook Filler
« on: June 24, 2014, 05:56:53 AM »
0
I am trying to learn from some of DX's stealth scripts since he is writing them in Pascal which is what I am starting with to learn.

First off this is listed as a freeshard script. Is there as much of a difference between freeshards and osi shards when using stealth like there is when using euo?

Here is his code, and so far I am liking that it seems a lot simpler and cleaner than what goes into euo.

Code: [Select]
Program SpellbookFiller;
(*Written by dxrom for ScriptUO.com
  Script to fill spellbooks with scrolls that have
  been sorted via my spell sorter script.
  
  Like before:
  
  Chest - the main container hold the 8 containers for each circle of spell
  EmptyBooks - the container holding empty spellbooks to be filled
  CxBAG - Bags representing spell circles, contained within Chest.
  
  NOTES: I have not implemented a feature to put spellbooks back after
  being filled.*)

const
  C1BAG = $405AE12D; C5BAG = $405AE123;
  C2BAG = $405AE12B; C6BAG = $405AE101;
  C3BAG = $405AE138; C7BAG = $405AE13F;
  C4BAG = $405AE137; C8BAG = $405AE12E;
  G1BAG = $4073F9B2;
  
  Chest = $405AE140;
  EmptyBooks = $401AF5A9;
  
var
  spellBook : Cardinal;
  k : Integer;
  
  C1 : Array of Cardinal; C5 : Array of Cardinal;
  C2 : Array of Cardinal; C6 : Array of Cardinal;
  C3 : Array of Cardinal; C7 : Array of Cardinal;
  C4 : Array of Cardinal; C8 : Array of Cardinal;

procedure GetItem(Item:Cardinal; Source:Cardinal; Amount:Integer; Dest:Cardinal);
begin
  UseObject(Source);
  wait(1200);
  MoveItem(FindType(Item,Source),Amount,Dest,0,0,0);
  wait(1200);
  if (Item = $0EFA) then
    spellBook := FindItem;
end;

procedure FillBook(Circle:Array of Cardinal;Book:Cardinal;Source:Cardinal);
var
  i : Integer;
begin
  UseObject(Chest);
  wait(1200);
  UseObject(Source);
  wait(1200);
  
  for i := 0 to (Length(Circle)-1) do
    GetItem(Circle[i],Source,1,spellBook);
end;

begin
  C1:=[$1F2D,$1F2E,$1F2F,$1F30,$1F31,$1F32,$1F33,$1F34];
  C2:=[$1F35,$1F36,$1F37,$1F38,$1F39,$1F3A,$1F3B,$1F3C];
  C3:=[$1F3D,$1F3E,$1F3F,$1F40,$1F41,$1F42,$1F43,$1F44];
  C4:=[$1F45,$1F46,$1F47,$1F48,$1F49,$1F4A,$1F4B,$1F4C];
  C5:=[$1F4D,$1F4E,$1F4F,$1F50,$1F51,$1F52,$1F53,$1F54];
  C6:=[$1F55,$1F56,$1F57,$1F58,$1F59,$1F5A,$1F5B,$1F5C];
  C7:=[$1F5D,$1F5E,$1F5F,$1F60,$1F61,$1F62,$1F63,$1F64];
  C8:=[$1F65,$1F66,$1F67,$1F68,$1F69,$1F6A,$1F6B,$1F6C];
  
  for k := 0 to (CountEx($0EFA,$FFFF,EmptyBooks)-1) do
  begin
    GetItem($0EFA,EmptyBooks,0,Backpack);
    FillBook(C1,spellBook,C1BAG);
    FillBook(C2,spellBook,C2BAG);
    FillBook(C3,spellBook,C3BAG);
    FillBook(C4,spellBook,C4BAG);
    FillBook(C5,spellBook,C5BAG);
    FillBook(C6,spellBook,C6BAG);
    FillBook(C7,spellBook,C7BAG);
    FillBook(C8,spellBook,C8BAG);
  end;
end.

To make sure that I understand what is going on, I will break it up into sections.

This part here is labeled const and is a command letting stealth know that these are not going to change. Looks like secure bags separated by circle, then the secure holding them and the empty books. It matches up with the little preview thing he put up.

Code: [Select]
const
  C1BAG = $405AE12D; C5BAG = $405AE123;
  C2BAG = $405AE12B; C6BAG = $405AE101;
  C3BAG = $405AE138; C7BAG = $405AE13F;
  C4BAG = $405AE137; C8BAG = $405AE12E;
  G1BAG = $4073F9B2;
  
  Chest = $405AE140;
  EmptyBooks = $401AF5A9;

Here are the variables. I am not sure what the cardinal stands for other than the spellbook. Is it a specific name used in pascal language or just what DX wanted to name the spellbook? The integer tells stealth the number for each circle bag and then it tells stealth that the array will go to each bag?

Code: [Select]
var
  spellBook : Cardinal;
  k : Integer;
  
  C1 : Array of Cardinal; C5 : Array of Cardinal;
  C2 : Array of Cardinal; C6 : Array of Cardinal;
  C3 : Array of Cardinal; C7 : Array of Cardinal;
  C4 : Array of Cardinal; C8 : Array of Cardinal;

This next part tells stealth to find the spellbook notated as cardinal and grab it out of the secure, then it tells stealth to look into the chest and then into the bags separated by circle for the spell scrolls?

Code: [Select]
procedure GetItem(Item:Cardinal; Source:Cardinal; Amount:Integer; Dest:Cardinal);
begin
  UseObject(Source);
  wait(1200);
  MoveItem(FindType(Item,Source),Amount,Dest,0,0,0);
  wait(1200);
  if (Item = $0EFA) then
    spellBook := FindItem;
end;

procedure FillBook(Circle:Array of Cardinal;Book:Cardinal;Source:Cardinal);
var
  i : Integer;
begin
  UseObject(Chest);
  wait(1200);
  UseObject(Source);
  wait(1200);
  
  for i := 0 to (Length(Circle)-1) do
    GetItem(Circle[i],Source,1,spellBook);
end;

Finally it is telling stealth to grab out each scroll and drop it onto the spellbook?

Code: [Select]
begin
  C1:=[$1F2D,$1F2E,$1F2F,$1F30,$1F31,$1F32,$1F33,$1F34];
  C2:=[$1F35,$1F36,$1F37,$1F38,$1F39,$1F3A,$1F3B,$1F3C];
  C3:=[$1F3D,$1F3E,$1F3F,$1F40,$1F41,$1F42,$1F43,$1F44];
  C4:=[$1F45,$1F46,$1F47,$1F48,$1F49,$1F4A,$1F4B,$1F4C];
  C5:=[$1F4D,$1F4E,$1F4F,$1F50,$1F51,$1F52,$1F53,$1F54];
  C6:=[$1F55,$1F56,$1F57,$1F58,$1F59,$1F5A,$1F5B,$1F5C];
  C7:=[$1F5D,$1F5E,$1F5F,$1F60,$1F61,$1F62,$1F63,$1F64];
  C8:=[$1F65,$1F66,$1F67,$1F68,$1F69,$1F6A,$1F6B,$1F6C];
  
  for k := 0 to (CountEx($0EFA,$FFFF,EmptyBooks)-1) do
  begin
    GetItem($0EFA,EmptyBooks,0,Backpack);
    FillBook(C1,spellBook,C1BAG);
    FillBook(C2,spellBook,C2BAG);
    FillBook(C3,spellBook,C3BAG);
    FillBook(C4,spellBook,C4BAG);
    FillBook(C5,spellBook,C5BAG);
    FillBook(C6,spellBook,C6BAG);
    FillBook(C7,spellBook,C7BAG);
    FillBook(C8,spellBook,C8BAG);
  end;
end.

It seems pretty simple and straight forward which kind of scares me that I have mistakenly come to think that certain scripts could really be this easy. Would it be written differently for OSI?
« Last Edit: June 24, 2014, 06:00:17 AM by Crisis »

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: +211
  • Referrals: 10
    • View Profile
    • ScriptSDK
Re: Questions on DX's Magery Spellbook Filler
« Reply #1 on: June 24, 2014, 07:11:53 AM »
0
« Last Edit: June 24, 2014, 07:32:51 AM by Crome969 »

Tags: