SRL Archive - SRL Archives

A Few Dropping Procedures


Rich

2009-10-02 19:57:40

I know DropAllEx has been posted many times before, but I thought I might as well post it as well, since the Devs may see that we want it in :p

Anyway:

{*******************************************************************************
procedure DropAllExRan(DontDrop : TIntegerArray);
By: R1ch
Description: Drops everything except the spots in DontDrop in a random pattern
*******************************************************************************}
procedure DropAllExRan(DontDrop : TIntegerArray);
var
I : Integer;

begin
repeat
I:= Random(28) + 1;
if not InIntArray(DontDrop, I) then
DropItem(I);
until(InvEmpty);
end;

{*******************************************************************************
procedure DropAllEx(DontDrop : TIntegerArray);
By: R1ch
Description: Drops everything except the spots in DontDrop
*******************************************************************************}
procedure DropAllEx(DontDrop : TIntegerArray);
var
I : Integer;

begin
for I:= 1 to 28 do
if not InIntArray(DontDrop, I) then
DropItem(I);
end;

{*******************************************************************************
procedure DropAllRandom;
By: R1ch
Description: Drops everything in a random pattern
*******************************************************************************}
procedure DropAllRandom;
begin
DropAllExRan([]);
end;

{*******************************************************************************
function WaitLoggedIn(MaxTime : Integer) : Boolean;
By: R1ch, edited by marpis
Description: Waits max of MaxTime in MS to become logged in if the account is not
*******************************************************************************}
function WaitLoggedIn(MaxTime: Integer): Boolean;
begin
Result := WaitFunc(@LoggedIn, 100, MaxTime + Random(100));
end;

Richard.

EvilChicken!

2009-10-02 20:00:56

R1ch, R1ch, R1ch ..
If you want random dropping, just use DropArray(InvSlots: TIntegerArray);.

DropArray([1,2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12 .. ect]);


Besides, DropArray pretty much covers all of the functions you posted.

Rich

2009-10-02 20:04:02

From: EvilChicken!
R1ch, R1ch, R1ch ..
If you want random dropping, just use DropArray(InvSlots: TIntegerArray);.

DropArray([1,2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12 .. ect]);


Besides, DropArray pretty much covers all of the functions you posted.


EC, EC, EC .. But which would look neater in a script?

DropArray([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]);
Or
DropAllRandom;

EvilChicken!

2009-10-02 20:14:08

Butbutbut .. D:
when we already have something that can do what you want to, why make a new thingy to do the same thing just because it's a tiny bit 'prettier' or 'shorter'?

Besides, you can declare a global TByteArray and use that instead of writing 1..28 every time?
But on the other side, you probably won't use it that much? It's not a lot of places where a dropping procedure is called in a script, mostly just one place or two.

Rich

2009-10-02 20:16:55

OK then, we'll put DropAllRandom to the side. What about DropAllExRan?

EDIT: Why do we have DropAll then? We could do
for I:= 1 to 28 do
DropItem(I);
But we have DropAll to make it easier. Writing out 1 - 28 is tiresome.

EvilChicken!

2009-10-02 20:22:21

Again, DropAllExRan does the same as DropArray.
It drops all except for the invslots you tell it not to drop.

.. and what does DropArray do? It drops everything in the invslots you tell it to do.

Rich

2009-10-02 20:26:28

But what if you have an axe in the first inventory slot, and want to drop all of them except one. Then you would have to do DropArray from 2 to 28. If we had DropAllEx(Ran) then we could just do DropAllEx(Ran)([1]);

Honestly EC, what difference does 2 functions make to an include? It would make everyone's life easier, and would stop you having to say this to be who make this in the future if it doesn't get committed.

marpis

2009-10-02 20:30:47

How about

procedure DropArrayEx(Slots: TIntegerArray; DropThese: Boolean);
var
I: Integer;
begin
for I := 1 to 28 do
if (InIntArray(I, Slots) xor (not DropThese)) then
DropItem(I);
end;
which works like this:
DropArrayEx([1, 2, 4], True); <- drops items 1, 2, 4
DropArrayEx([1, 2, 4], False); <- drops all items except for 1, 2, 4

Rich

2009-10-02 20:34:23

From: marpis
How about

procedure DropArrayEx(Slots: TIntegerArray; DropThese: Boolean);
var
I: Integer;
begin
for I := 1 to 28 do
if (InIntArray(I, Slots) xor (not DropThese)) then
DropItem(I);
end;
which works like this:
DropArrayEx([1, 2, 4], True); <- drops items 1, 2, 4
DropArrayEx([1, 2, 4], False); <- drops all items except for 1, 2, 4


It will never happen if EC is in the mood that he is.

Added WaitLoggedIn to the first post. Please look at it.

Quickmarch

2009-10-02 20:39:16

I got a few constants for DropPattern:


const
DP_UPTODOWN = 1;
DP_SNAKE = 2;

:p, I don't know whether this is off-topic, but I didn't think it was worth creating a whole thread about it.

Rich

2009-10-02 20:43:47

From: Quickmarch
:p, I don't know whether this is off-topic, but I didn't think it was worth creating a whole thread about it.


How else am I meant to get it posted?

marpis

2009-10-02 21:21:16

Shortened your WaitLoggedIn

function WaitLoggedIn(MaxTime: Integer): Boolean;
begin
Result := WaitFunc(@LoggedIn, 100, MaxTime + Random(100));
end;

Rich

2009-10-02 23:06:39

From: marpis
Shortened your WaitLoggedIn

function WaitLoggedIn(MaxTime: Integer): Boolean;
begin
Result := WaitFunc(@LoggedIn, 100, MaxTime + Random(100));
end;


Ah, I forgot about WaitFunc. Thanks Marpis! :D

EvilChicken!

2009-10-03 09:26:39

{*******************************************************************************
procedure DropAllExcept(IgnoreInvSlots: array of Byte);
By: R1ch
Description: Drops everything in inventory. Ignores slots specified by
IgnoreInvSlots array.
*******************************************************************************}
procedure DropAllExcept(IgnoreInvSlots: array of Byte);
var
I: Byte;

begin
for I := 1 to 28 do
if (not InIntArray(IgnoreInvSlots, I)) then
DropItem(I);
end;

Added that.




Oh, and don't tell me(/others?) what kind of a mood I am in, please. That's what really gets me in "that" kind of mood.

Rich

2009-10-03 13:55:21

Yes! Finally, DropAllExcept has been added to SRL :D Thanks EC.

EDIT: I didn't mean you was in that "mood". I meant that you wasn't in the "let's commit functions" mood. I didn't mean to offend anyone. If I did, please accept my apologies.

Richard.