Results 1 to 6 of 6

Thread: Random Drop

  1. #1
    Join Date
    Mar 2008
    Location
    Indiana
    Posts
    192
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default Random Drop

    My SRL or Scar isn't working correctly so I can't test this yet.
    But it does compile.

    Test please.

    It random drops the MinPos inventory slot to the MaxPos inventory slot.
    It makes it more.... human like

    SCAR Code:
    program RandDrop;
    {.include SRL/SRL.scar}
    procedure RandDrop(MinPos, MaxPos: integer);
    var
      Done : array of boolean;
      A : integer;
    begin
      SetArrayLength(Done, 28);
      while ((MaxPos - MinPos) >= A) do
      begin
        case RandomRange(MinPos, MaxPos) of
          1: begin if (Done[1] = False) then DropItem(1); Done[1] := True; A := A + 1; end;
          2: begin if (Done[2] = False) then DropItem(2); Done[2] := True; A := A + 1; end;
          3: begin if (Done[3] = False) then DropItem(3); Done[3] := True; A := A + 1; end;
          4: begin if (Done[4] = False) then DropItem(4); Done[4] := True; A := A + 1; end;
          5: begin if (Done[5] = False) then DropItem(5); Done[5] := True; A := A + 1; end;
          6: begin if (Done[6] = False) then DropItem(6); Done[6] := True; A := A + 1; end;
          7: begin if (Done[7] = False) then DropItem(7); Done[7] := True; A := A + 1; end;
          8: begin if (Done[8] = False) then DropItem(8); Done[8] := True; A := A + 1; end;
          9: begin if (Done[9] = False) then DropItem(9); Done[9] := True; A := A + 1; end;
          10: begin if (Done[10] = False) then DropItem(10); Done[10] := True; A := A + 1; end;
          11: begin if (Done[11] = False) then DropItem(11); Done[11] := True; A := A + 1; end;
          12: begin if (Done[12] = False) then DropItem(12); Done[12] := True; A := A + 1; end;
          13: begin if (Done[13] = False) then DropItem(13); Done[13] := True; A := A + 1; end;
          14: begin if (Done[14] = False) then DropItem(14); Done[14] := True; A := A + 1; end;
          15: begin if (Done[15] = False) then DropItem(15); Done[15] := True; A := A + 1; end;
          16: begin if (Done[16] = False) then DropItem(16); Done[16] := True; A := A + 1; end;
          17: begin if (Done[17] = False) then DropItem(17); Done[17] := True; A := A + 1; end;
          18: begin if (Done[18] = False) then DropItem(18); Done[18] := True; A := A + 1; end;
          19: begin if (Done[19] = False) then DropItem(19); Done[19] := True; A := A + 1; end;
          20: begin if (Done[20] = False) then DropItem(20); Done[20] := True; A := A + 1; end;
          21: begin if (Done[21] = False) then DropItem(21); Done[21] := True; A := A + 1; end;
          22: begin if (Done[22] = False) then DropItem(22); Done[22] := True; A := A + 1; end;
          23: begin if (Done[23] = False) then DropItem(23); Done[23] := True; A := A + 1; end;
          24: begin if (Done[24] = False) then DropItem(24); Done[24] := True; A := A + 1; end;
          25: begin if (Done[25] = False) then DropItem(25); Done[25] := True; A := A + 1; end;
          26: begin if (Done[26] = False) then DropItem(26); Done[26] := True; A := A + 1; end;
          27: begin if (Done[27] = False) then DropItem(27); Done[27] := True; A := A + 1; end;
          28: begin if (Done[28] = False) then DropItem(28); Done[28] := True; A := A + 1; end;
         end;
      end;
    end;


    begin
      SetupSRL;
      RandDrop(2, 3); //Drops Slots 2 to 3
    end.

  2. #2
    Join Date
    Jun 2007
    Location
    Wednesday
    Posts
    2,446
    Mentioned
    3 Post(s)
    Quoted
    1 Post(s)

    Default

    You double posted it
    Also, I've never known anyone who randomly drops items. They always drop via going along then up a line or down then across a line. Also, this is actually quite a peculiar method as it does actually have the possibility to get into an endless loop thus seriously delaying the script as if RandomRange keeps generating similar numbers, then it will continually run the 'if' statement without anything happening. A better run time random dropping procedure would be something resembling this:
    SCAR Code:
    procedure RandomDrop(sPos, ePos: Integer);
    var
      uPosA: array of Integer;
      i: Integer;
    begin
      SetLength(uPosA, ePos - sPos);
      for i := 0 to (ePos - sPos) do
        uPosA[i] := sPos + i;
      i := 0;
      while GetArrayLength(uPosA) > 0 do
      begin
        i := Random(GetArrayLength(uPosA));
        Drop(i);
        uPosA := uPosA[High(uPosA)];
        SetArrayLength(uPosA, High(uPosA));
      end;
    end;
    And that should work fine and won't run into a possible endless loop
    By reading this signature you agree that mixster is superior to you in each and every way except the bad ways but including the really bad ways.

  3. #3
    Join Date
    Mar 2008
    Location
    Indiana
    Posts
    192
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Questions:
    1. Where did you find:
    SCAR Code:
    Drop(i);
    I couldn't find it.

    2. What does the
    SCAR Code:
    High(uPosA)
    do?

    Got Rid of second post. (I was lagging)

    Edit: Maybe ill make it so it will drop like in lines or rows. More Human like...

  4. #4
    Join Date
    Jun 2007
    Location
    Wednesday
    Posts
    2,446
    Mentioned
    3 Post(s)
    Quoted
    1 Post(s)

    Default

    1. I meant to put DropItem, I usually code inside FF so I don't normally double check it except for spelling based mistakes.
    2. High = GetArrayKength or Length then minus 1, so basically the highest index of an array for example, if an array was from [0] to [5], GetArrayLength returns 6 as 0 -> 5 is 6 numbers, while High returns 5.
    By reading this signature you agree that mixster is superior to you in each and every way except the bad ways but including the really bad ways.

  5. #5
    Join Date
    Dec 2006
    Location
    Copy pastin to my C#
    Posts
    3,788
    Mentioned
    8 Post(s)
    Quoted
    29 Post(s)

    Default

    ehm... Anyone even considered about looking into SRL?

    SCAR Code:
    {*******************************************************************************
    procedure DropAll;
    By: Lorax
    Description: Drops all items
    *******************************************************************************}


    procedure DropAll;
    var
      i: Integer;
      arr:array of Integer;
    begin
      arr :=[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];
         
      for i := 1 to 28 - 4 do
        Swap(arr[RandomRange(i - 1, i + 4)], arr[RandomRange(i - 1, i + 4)] );

      for i := 0 to 27 do
        DropItem(arr[i]);
    end;

  6. #6
    Join Date
    Jun 2007
    Location
    Wednesday
    Posts
    2,446
    Mentioned
    3 Post(s)
    Quoted
    1 Post(s)

    Default

    But 'DropAll' doesn't drop a range of items, only all of them, and if you did convert it to, it would only be a bit shorter than mine. Also, DropAll doesn't use ExistItem, so it can't be that good (I know mine doesn't, but mine sucks ^^).
    By reading this signature you agree that mixster is superior to you in each and every way except the bad ways but including the really bad ways.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. What Do I Use For DROP Now???!!!
    By Ilikepie1995 in forum OSR Help
    Replies: 4
    Last Post: 09-30-2007, 08:15 PM
  2. drop
    By marre in forum OSR Help
    Replies: 6
    Last Post: 09-15-2007, 05:40 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •