SRL Archive - OSR Help

Dropping Difficulties


Valithor

2012-04-03 00:12:57

Hey Guys… I was wondering if anyone with more scripting knowledge could help me understand why my script isn't dropping. It's based off of two of YoHoJo's dropping methods. The idea is to use a random of the 4 FishPatterns provided by the DropSetup so that it would provide randomization in the dropping procedure.

Any ideas on a fix? or other dropping methods?

procedure DropSetup;
begin
SetArrayLength(FishPattern, 4);
FishPattern[0]:= [1, 5, 9, 13, 17, 21, 25, 2, 6, 10, 14, 18, 22, 26, 3, 7, 11, 15, 19, 23, 27, 4, 8, 12, 16, 20, 24, 28];
FishPattern[1]:= [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28];
FishPattern[2]:= [1, 2, 3, 4, 8, 7, 6, 5, 9, 10, 11, 12, 16, 15, 14, 13, 17, 18, 19, 20, 24, 23, 22, 21, 25, 26, 27, 28];
FishPattern[3]:= [1, 5, 9, 13, 17, 21, 25, 26, 22, 18, 14, 10, 6, 2, 3, 7, 11, 15, 19, 23, 27, 28, 24, 20, 16, 12, 8, 4];
end;

procedure Dropping;
var
MyFish_DTM, x, y, I, R: integer;
SlotBox:TBox;

begin
MyFish_DTM:= DTMFromString('myS0oPer1337dtmStr1ng');
R:= Random(4);

for I:= 0 to 27 do
begin //using the following Writeln for Debugging purposes
Writeln('Using FishPattern[' + IntToStr(R) + ']');
SlotBox:= InvBox(FishPattern[R][I]); // Getting an "Error: Out Of Range" here
if FindDTM(MyFish_DTM, x, y, SlotBox.X1, SlotBox.Y1, SlotBox.X2, SlotBox.Y2) then
begin
DropItem(FishPattern[R][I]);
Writeln('Dropping InvBox[' + IntToStr(I) + ']');
end;
end;

FreeDTM(MyFish_DTM);
end;

[Resolved] Needed to add DropSetup to my Dropping procedure. Thanks for the help that was given.

Kyle Undefined

2012-04-03 00:25:16

Change "SlotBox:= InvBox(FishPattern[2]);" to "SlotBox:= InvBox(FishPattern);" :)

Valithor

2012-04-03 00:31:09

From: Kyle Undefined
Change "SlotBox:= InvBox(FishPattern[2]);" to "SlotBox:= InvBox(FishPattern);" :)


Thanks for your speedy reply Kyle! but quick question…
what if I want to use a random of the 4 FishPatterns? If I understand correctly, what you are suggesting will only drop the items in one pattern.

will edit the original post to better express the intent…

Kyle Undefined

2012-04-03 00:33:06

Ahh I see, change the "[2]" to "[R]" as that will randomly select one of the patterns.

Valithor

2012-04-03 00:40:00

Right… but I'm still getting that "Out of Range" error.

Kyle Undefined

2012-04-03 00:46:04

Could you post your full script? That will help me figure out what's wrong.

iBlank

2012-04-03 00:50:51

Kyle is going to be much more help than me, but does the I variable need to be defined or somehow tied to the fish patterns?

Valithor

2012-04-03 00:51:07

Edited first post again…
Title says Draynor Fisher, when in reality it cages Crayfish near the Lumbridge Cemetery.
Thanks again for your help Kyle. It's been appreciated.

Edit: alevere4, the variable "I" defines the SlotBox (or Inventory Box) it's looking at. It works from 1 - 28. The FishPattern arrays define what "I" is. And the script uses that to know which Box to drop from.

Edit 2: the code in the script complies fine, but when it comes to run time is when I get the error.

Kyle Undefined

2012-04-03 01:06:57

You never call "DropSetup" in your script, that's why :)

iBlank

2012-04-03 01:08:05

From: Valithor
Edited first post again…
Title says Draynor Fisher, when in reality it cages Crayfish near the Lumbridge Cemetery.
Thanks again for your help Kyle. It's been appreciated.

Edit: alevere4, the variable "I" defines the SlotBox (or Inventory Box) it's looking at. It works from 1 - 28. The FishPattern arrays define what "I" is. And the script uses that to know which Box to drop from.

Edit 2: the code in the script complies fine, but when it comes to run time is when I get the error.


SlotBox:= InvBox(FishPattern[R]); // Getting an "Error: Out Of Range" here

Have you tried to remove the [R] from that line and just have InvBox(FishPattern). Don't see why you would need the fish pattern when using the FindDtm in the next line. Just free ballin here! Never used this procedure for dropping.

E* - Well, should have known Kyle would beat me to it!
E2 - And I am ashamed of both of my suggestions after looking at the procedure, ha.

Valithor

2012-04-03 01:12:14

From: Kyle Undefined
You never call "DropSetup" in your script, that's why :)


Hmmm… So where would I call it then? At the beginning of the Dropping Proc?

alevere4, I'm pretty sure that [R] needs to be there to get the results I'm looking for. Otherwise, it would only drop in one pattern instead of having the option of 4.

Edit: alevere, no need to be ashamed. I'm really grateful for the help that you've offered. And if nothing else, I hope you learned a thing or two.

Kyle Undefined

2012-04-03 01:19:23

Right, call it at the beginning of the drop procedure, and it will work :)

iBlank

2012-04-03 01:20:01

From: Valithor
Hmmm… So where would I call it then? At the beginning of the Dropping Proc?

alevere4, I'm pretty sure that [R] needs to be there to get the results I'm looking for. Otherwise, it would only drop in one pattern instead of having the option of 4.

Edit: alevere, no need to be ashamed. I'm really grateful for the help that you've offered. And if nothing else, I hope you learned a thing or two.


And to think I have written a working Rock-tail fisher with banking! But anything outside of that one script, I am not familiar with. You could just call DropSetup really anytime before you run the actual dropping procedure. This would work:


begin
DropSetup;
MyFish_DTM:= DTMFromString('myS0oPer1337dtmStr1ng');
R:= Random(4);

for I:= 0 to 27 do
begin //using the following Writeln for Debugging purposes
Writeln('Using FishPattern[' + IntToStr(R) + ']');
SlotBox:= InvBox(FishPattern[R][I]); // Getting an "Error: Out Of Range" here
if FindDTM(MyFish_DTM, x, y, SlotBox.X1, SlotBox.Y1, SlotBox.X2, SlotBox.Y2) then
begin
DropItem(FishPattern[R][I]);
Writeln('Dropping InvBox[' + IntToStr(I) + ']');
end;
end;

FreeDTM(MyFish_DTM);
end;

E - Arrgg! Got me again, even on the one I knew, ha.

Valithor

2012-04-03 01:30:14

Hey guys, thanks for the all the help! The script is working a lot better now! I appreciate all the help! Rep ++