Results 1 to 5 of 5

Thread: Do-While-Problem and question about until(..)

  1. #1
    Join Date
    Aug 2008
    Location
    Finland
    Posts
    2,851
    Mentioned
    3 Post(s)
    Quoted
    2 Post(s)

    Default Do-While-Problem and question about until(..)

    First problem
    yes, i have read tutorials but most of them are totally gibberish to me.
    Why in the gods name doesn't this work?
    SCAR Code:
    begin
          While(Fighting) do Randommovement;
         end;


    Second problem
    Is the only way to add multiple situations that end a loop to make the until(..) this complicated? Ofcourse with different result after every event that ends the loop, like this:
    SCAR Code:
    repeat
     writeln('holy cow!');
    until(
         (HpPercent < 50) or
         (not InFight) or
         (TimeFromMark(attack)>15000) or
         (somevariable < 7) or
         (Shithappens) );

    if (HpPercent<50) then
     begin
      DoThis1;
     end;

    if  not InFight then
     begin
      DoThis2;
     end;

    ETC ETC ETC...

    I thought it could be done with cases, but i didn't find a tutorial that tells me how.

  2. #2
    Join Date
    Jun 2007
    Location
    La Mirada, CA
    Posts
    2,484
    Mentioned
    1 Post(s)
    Quoted
    3 Post(s)

    Default

    SCAR Code:
    repeat
     writeln('holy cow!');
      if (HpPercent < 50) then break;
      if (not(inFight)) then break;
     etc...
    until(false);

    You probably should have the false be the TimeFromMark or counting of the variable.

    And the While Do loop, what is the fighting function like? need a little more code to make sure it is being used correctly. The odds are, you probably just run through the 'fighting' function 1 time with no repeat loop or for to do loop, so then it runs through the function 1 time and then is considered to be 'done' with the fighting function and moves on.

    "Failure is the opportunity to begin again more intelligently" (Henry Ford)


  3. #3
    Join Date
    Jan 2008
    Location
    Ontario, Canada
    Posts
    7,805
    Mentioned
    5 Post(s)
    Quoted
    3 Post(s)

    Default

    Is the function 'Fighting' (or boolean) a boolean?

    So if its a function does it go:

    function Fighting : Boolean;?

    More information would be nice.

    For the until question, what you had there was fine Just make only about three per line, and make sure you do the most computer intensive check first. Hypersecrets method is fine, but uses more lines. Its all about preference really.

    Following Hypers method you could you:

    SCAR Code:
    repeat
      if HPPercent < 50 then
      begin
        BHASDFASDFA;
        asdfasdfsd;
        Break;
      end;
    until (YOU PUT YOUR STUFF HEREEEE! :));

    Hope I helped.

    P.S. Sorry to advertise, but if you want more info on loops and stuff check my tut in my sig, or pm me
    Writing an SRL Member Application | [Updated] Pascal Scripting Statements
    My GitHub

    Progress Report:
    13:46 <@BenLand100> <SourceCode> @BenLand100: what you have just said shows you 
                        have serious physchological problems
    13:46 <@BenLand100> HE GETS IT!
    13:46 <@BenLand100> HE FINALLY GETS IT!!!!1

  4. #4
    Join Date
    Aug 2008
    Location
    Finland
    Posts
    2,851
    Mentioned
    3 Post(s)
    Quoted
    2 Post(s)

    Default

    SCAR Code:
    Procedure Fighting;
    begin
     MarkTime(attack);
     wait(4000+random(1000));  //4-5s before loop, because in ranged battle
     repeat                             // InFight doesn't always work instantly
      wait(1000+random(100));
     until(
         (HpPercent < 50) or
         (not InFight) or
         (TimeFromMark(attack)>20000) );
     Inc(KillCount);
     writeln('Monsters Killed: '+IntToStr(KillCount));
         
    end;

    Atm. its like that. I want it to DoRandomStuff while its waiting the fight to end.

  5. #5
    Join Date
    Jun 2007
    Location
    La Mirada, CA
    Posts
    2,484
    Mentioned
    1 Post(s)
    Quoted
    3 Post(s)

    Default

    SCAR Code:
    function Fighting: Boolean;
    begin
      Result := True;
      MarkTime(attack);
      wait(4000+random(1000));  //4-5s before loop, because in ranged battle
      repeat              // InFight doesn't always work instantly
        wait(1000+random(100));
      until(
         (HpPercent < 50) or
         (not InFight) or
         (TimeFromMark(attack)>20000) );
      Result := False;
      Inc(KillCount);
      writeln('Monsters Killed: '+IntToStr(KillCount));    
    end;

    Something along the lines of that, personally it isn't the way I would do it. I would have it do that random stuff in the repeat loop in this function. So

    If attackmonster then Fighting etc...

    "Failure is the opportunity to begin again more intelligently" (Henry Ford)


Thread Information

Users Browsing this Thread

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

Similar Threads

  1. 1 question
    By fert in forum OSR Help
    Replies: 4
    Last Post: 11-05-2007, 03:41 PM
  2. I have a question.
    By anandacote in forum News and General
    Replies: 1
    Last Post: 12-19-2006, 05:11 PM
  3. Another Question
    By antknee3 in forum OSR Help
    Replies: 10
    Last Post: 10-21-2006, 09:18 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
  •