ape
2009-10-16 20:29:00
This is a method I made during the production of my auto miner. It drops the specified inventory slot array in a randomly selected pattern. It has 7 base patterns built in and these can be reversed adding up to 14 different patterns.
Patterns include:
Patterns include:
- Snake Columns: Follows up and down each column without skipping.
- Snake Rows: Similar to columns
- Box Spiral: Follows through all inventory slots in a spiral pattern.
- Columns: Drops each column separately starting at the top/bottom of each one consistently.
- Rows: Similar behavior as columns except with rows.
- Every other row: Self explanatory.
- Every other column: Self explanatory.
{*******************************************************************************
procedure DropPatternEx(InvSlots: TIntegerArray; Exclude: Boolean);
By: Ape
Description: Drops items in slots specified in "InvSlots" in 14 randomly selected patterns.
If Exclude is True, it will drop all slots, except the specified slots.
If Exclude is False, it will drop only the specified slots.
Usage: "DropPatternEx([1, 3, 5, 8], False);" drops slots 1, 3, 5, 8.
"DropPatternEx([1, 3, 5, 8], True);" drops all slots except 1, 3, 5, 8.
*******************************************************************************}
procedure DropPatternEx(InvSlots: TIntegerArray; Exclude: Boolean);
var
I: Byte;
Ptn: TIntegerArray;
begin
SetLength(Ptn, 28);
Gametab(tab_inv);
{ -Patterns-
0: Snake columns
1: Snake rows
2: Box spiral
3: Columns
4: Rows
5: Every other row
6: Every other column }
case Random(7) of
0: Ptn:=[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];
1: Ptn:=[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];
2: Ptn:=[1,2,3,4,8,12,16,20,24,28,27,26,25,21,17,13,9,5,6,7,11,15,19,23,22,18,14,10];
3: Ptn:=[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];
4: Ptn:=[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];
5: Ptn:=[1,2,3,4,9,10,11,12,17,18,19,20,25,26,27,28,5,6,7,8,13,14,15,16,21,22,23,24];
6: Ptn:=[1,5,9,13,17,21,25,4,8,12,16,20,24,28,2,6,10,14,18,22,26,3,7,11,15,19,23,27];
end;
if Random(2) = 1 then
InvertTIA(Ptn);
for I := 0 to 27 do
if(Exclude)then
if (not InIntArray(InvSlots, Ptn[I])) then
DropItem(Ptn[i])
else
if (InIntArray(InvSlots, Ptn[I])) then
DropItem(Ptn[i]);
end;
{*******************************************************************************
procedure DropAll;
By: Ape
Description: Drops all items in inventory using patterns.
*******************************************************************************}
procedure DropAll;
begin
DropPatternEx([], True);
end;
{*******************************************************************************
procedure DropAllExcept(IgnoreInvSlots: TIntegerArray);
By: Ape
Description: Drops all items except specified in inventory using patterns.
*******************************************************************************}
procedure DropAllExcept(IgnoreInvSlots: TIntegerArray);
begin
DropPatternEx(IgnoreInvSlots, True);
end;
{*******************************************************************************
procedure DropArray(InvSlots: TIntegerArray);
By: Ape
Description: Drops item positioned equivalent to numbers in "InvSlots" array.
Example: "DropArray([2, 4, 9, 12]);" would drop items in InvSlot 2, 4, 9 and 12.
*******************************************************************************}
procedure DropArray(InvSlots: TIntegerArray);
begin
DropPatternEx(InvSlots, False);
end;
{*******************************************************************************
(DEPRECATED)Procedure DropPattern(Which: Integer);(DEPRECATED)
By: Ape
Description: Drops all items in inventory using DropAll; (DEPRECATED)
WARNING: This method is out of date! Use "DropAll;" instead!
*******************************************************************************}
procedure DropPattern(Which: Integer);
begin
DropAll;
end;