Page 1 of 3 123 LastLast
Results 1 to 25 of 54

Thread: [F-Include] Chicken Slayer, Featherer, Prayer, and Cooker

  1. #1
    Join Date
    Oct 2007
    Location
    everywhere you aint lookin
    Posts
    131
    Mentioned
    1 Post(s)
    Quoted
    6 Post(s)

    Default [F-Include] Chicken Slayer, Featherer, Prayer, and Cooker

    Hey guys! I originally joined SRL forever ago, but never contributed anything (Except for a few VERY dodgy fixes to old scripts), and now I'm back with something marginally useful!

    This is a Chicken Slayer for the Chicken Pen that has the cooking pot in the nearby house in Lumbridge. This script will train combat, prayer, and cooking skills while collecting feathers.

    The cooking portion needs some work to help with efficiency, but it works as it is.

    This script has some anti-ban in it, but not a ton. Breaking has not been implemented yet.

    Road map
    1. Drop FInclude
    2. Improve Cooking
    3. Improve Walking Procedure
    4. More "humanness"


    Long term goals
    1. Add Woodcutting training
    2. Add Firemaking training
    3. Add Fighting other mobs (cows/goblins)
    4. Add Food Consumption
    5. Add Mining?
    6. Add Fishing?
    Changelog
    V1.1
    • Added breaking
    • Fixed typo "Defense" to "Defence"
    • Minor improvement to the cooking phase. Detects when it gets lost and tries to fix it.

    V1.0
    • Initial Release

    F-Include
    You will need Fitta's F-Include.
    To install, download the file at this link, then extract the zip file to "finclude" inside of the Simba Includes directory.

    SEND EMAIL ISSUES / Pro_InitSocket
    If you use the revision of unofficial F-include i have linked, you will not have this issue, otherwise read below.

    There is currently a PR open to fix this https://github.com/FittaVillavu/finclude/pull/1/files
    Go vote for that first, then read below.

    If you are having an Error with the SendEmail procedure / Pro_InitSocket, you can get around it by fixing the procedure body for the SendEmail procedure whose definition begins on Line 4 of the Socks file.
    Simba Code:
    procedure SendEmail(URL, Email, Password, Name, Recipient, CC, BCC, Subject, Message, Attachment, AttachmentMime: String);
    var
      Sock: SSLSocket;
    begin
      Sock.Init();
      Sock.SetSecurityPolicy(false, false, true);
      Sock.SetVerbose(true);
      Sock.SMTP(PChar(URL), PChar(Email), PChar(Password), PChar(Name), PChar(Recipient), PChar(CC), PChar(BCC), PChar(Subject), PChar(Message), PChar('text/plain; charset=UTF-8'), PChar(Attachment), PChar(AttachmentMime));
      Sock.Free();
    end;


    Sample Report
    Code:
    [15:40:06:655] [Chicken Slayer] [Status] +---------------------------------v1.1-+
    [15:40:06:656] [Chicken Slayer] [Status] |                                      |
    [15:40:06:658] [Chicken Slayer] [Status] | Chickens Killed:                 804 |
    [15:40:06:660] [Chicken Slayer] [Status] | Feathers Collected:             3870 |
    [15:40:06:662] [Chicken Slayer] [Status] | Bones Buried:                    370 |
    [15:40:06:665] [Chicken Slayer] [Status] |                                      |
    [15:40:06:668] [Chicken Slayer] [Status] | Attack   Levels Gained:           11 |
    [15:40:06:671] [Chicken Slayer] [Status] | Strength Levels Gained:            0 |
    [15:40:06:674] [Chicken Slayer] [Status] | Defence  Levels Gained:            0 |
    [15:40:06:678] [Chicken Slayer] [Status] | Prayer   Levels Gained:            8 |
    [15:40:06:681] [Chicken Slayer] [Status] | Cooking  Levels Gained:           13 |
    [15:40:06:685] [Chicken Slayer] [Status] |                                      |
    [15:40:06:689] [Chicken Slayer] [Status] | Time Elapsed:          0d 9h 38m 50s |
    [15:40:06:693] [Chicken Slayer] [Status] | Breaking In:           0d 0h 29m 32s |
    [15:40:06:697] [Chicken Slayer] [Status] |                                      |
    [15:40:06:701] [Chicken Slayer] [Status] +---------------------------------v1.1-+
    Attached Files Attached Files
    Last edited by jacoby6000; 04-28-2016 at 03:16 AM.

  2. #2
    Join Date
    Jun 2013
    Location
    Scranton
    Posts
    496
    Mentioned
    5 Post(s)
    Quoted
    220 Post(s)

    Default

    that is some nicely annotated code man. You might want to tell users how to fix the Pro_InitSocket error on this thread though

  3. #3
    Join Date
    Oct 2007
    Location
    everywhere you aint lookin
    Posts
    131
    Mentioned
    1 Post(s)
    Quoted
    6 Post(s)

    Default

    Thanks! I tried to make it a point to annotate most of the code that actually does something. I don't usually use Pascal/Lape, so it's more for me than for you . Anyway, there are likely bugs in this script! It's my first real contribution to the community. Please let me know if you see any issues.

    Ah, right. Thanks for pointing that out. I had forgot that I went through that.

    I'll post this in the OP as well.

    If you are having an Error with the SendEmail procedure, you can get around it by deleting the procedure body for the SendEmail procedure whose definition begins on Line 4 of the Socks file. Note: This will mean that no simba scripts will be able to send emails! This is not a permanent fix, but if you don't care about scripts sending emails, then it should be fine. Here's what it should look like after your edit
    Code:
    Procedure SendEmail(URL, Email, Password, Name, Recipient, CC, BCC, Subject, Message, Attachment, AttachmentMime: String);
    begin
    
    end;
    Last edited by jacoby6000; 04-24-2016 at 03:29 AM.

  4. #4
    Join Date
    Jan 2012
    Posts
    1,596
    Mentioned
    78 Post(s)
    Quoted
    826 Post(s)

    Default

    Quote Originally Posted by jacoby6000 View Post
    Thanks! I tried to make it a point to annotate most of the code that actually does something. I don't usually use Pascal/Lape, so it's more for me than for you . Anyway, there are likely bugs in this script! It's my first real contribution to the community. Please let me know if you see any issues.

    Ah, right. Thanks for pointing that out. I had forgot that I went through that.

    I'll post this in the OP as well.

    If you are having an Error with the SendEmail procedure, you can get around it by deleting the procedure body for the SendEmail procedure whose definition begins on Line 4 of the Socks file. Note: This will mean that no simba scripts will be able to send emails! This is not a permanent fix, but if you don't care about scripts sending emails, then it should be fine. Here's what it should look like after your edit
    Code:
    Procedure SendEmail(URL, Email, Password, Name, Recipient, CC, BCC, Subject, Message, Attachment, AttachmentMime: String);
    begin
    
    end;
    You could just add
    Simba Code:
    Procedure SendEmail(URL, Email, Password, Name, Recipient, CC, BCC, Subject, Message, Attachment, AttachmentMime: String); override;
    begin
    end;
    to your script and it would require no edit to the files.

  5. #5
    Join Date
    Oct 2007
    Location
    everywhere you aint lookin
    Posts
    131
    Mentioned
    1 Post(s)
    Quoted
    6 Post(s)

    Default

    Quote Originally Posted by Turpinator View Post
    You could just add
    Simba Code:
    Procedure SendEmail(URL, Email, Password, Name, Recipient, CC, BCC, Subject, Message, Attachment, AttachmentMime: String); override;
    begin
    end;
    to your script and it would require no edit to the files.
    I tried that just now, and it doesn't appear to work. I assume this is because Lape processes all of the files from the include before continuing on and reading my script.

  6. #6
    Join Date
    Sep 2008
    Location
    Not here.
    Posts
    5,422
    Mentioned
    13 Post(s)
    Quoted
    242 Post(s)

    Default

    Quote Originally Posted by jacoby6000 View Post
    I tried that just now, and it doesn't appear to work. I assume this is because Lape processes all of the files from the include before continuing on and reading my script.
    It's interpreted/parsed top down, and includes are at the top.

  7. #7
    Join Date
    Oct 2007
    Location
    everywhere you aint lookin
    Posts
    131
    Mentioned
    1 Post(s)
    Quoted
    6 Post(s)

    Default

    Right. Which would explain why defining my own SendEmail would not fix this.

  8. #8
    Join Date
    Feb 2012
    Location
    Norway
    Posts
    995
    Mentioned
    145 Post(s)
    Quoted
    596 Post(s)

    Default

    Quote Originally Posted by jacoby6000 View Post
    Right. Which would explain why defining my own SendEmail would not fix this.
    You can override a method anywhere after the original method is declared and it will be used instead. You just gotta make sure it matches the original method header perfectly (you can't change any parameters).

    pascal Code:
    {$X+}
    procedure Foo(k:Int32);
    begin
      WriteLn(k); //will not be called directly
    end;

    Foo(10);      //call Foo (will call the one bellow)

    procedure Foo(k:Int32); override;
    begin
      Write('overridden! ');
      inherited;  //call the parent method
    end;

    Foo(10);      //call Foo again
    Last edited by slacky; 04-24-2016 at 02:22 PM.
    !No priv. messages please

  9. #9
    Join Date
    Oct 2007
    Location
    everywhere you aint lookin
    Posts
    131
    Mentioned
    1 Post(s)
    Quoted
    6 Post(s)

    Default

    The problem is, Lape never even gets to compiling my file. It fails to compile the Socks.simba file contained in F-Include, because it has an invalid implementation. I can override the implementation all I want, but if it can't compile F-Include, it won't matter.

    I've tried what you suggested, and still get the same error.
    Code:
    Error: Unknown declaration "Pro_InitSocket" at line 9
    Compiling failed.
    from this declaration (in Socks.simba from F-Include)
    Code:
    Procedure SendEmail(URL, Email, Password, Name, Recipient, CC, BCC, Subject, Message, Attachment, AttachmentMime: String);
    var
      Sock: SSLSocket;
    begin
      Pro_InitSocket(Sock, nil, nil, nil, nil); // Error here
      Pro_CreateSocket(Sock, ''); // Probably also here and every line below, but it fails on the above line
      Pro_SetSSL(Sock, false, false, true);
      Pro_SetVerbose(Sock, true);
      Pro_SMTP(Sock, PChar(URL), PChar(Email), PChar(Password), PChar(Name), PChar(Recipient), PChar(CC), PChar(BCC), PChar(Subject), PChar(Message), PChar('text/plain; charset=UTF-8'), PChar(Attachment), PChar(AttachmentMime));
      Pro_FreeSocket(Sock);
    end;
    Even with this override in my code
    Code:
    {
      Override the Socks SendEmail procedure, in an attempt to get rid of the errors.
    }    
    Procedure SendEmail(URL, Email, Password, Name, Recipient, CC, BCC, Subject, Message, Attachment, AttachmentMime: String); override;
    begin
    end;

  10. #10
    Join Date
    Feb 2012
    Location
    Norway
    Posts
    995
    Mentioned
    145 Post(s)
    Quoted
    596 Post(s)

    Default

    Quote Originally Posted by jacoby6000 View Post
    The problem is, Lape never even gets to compiling my file. It fails to compile the Socks.simba file contained in F-Include, because it has an invalid implementation. I can override the implementation all I want, but if it can't compile F-Include, it won't matter.

    I've tried what you suggested, and still get the same error.
    Code:
    Error: Unknown declaration "Pro_InitSocket" at line 9
    Compiling failed.
    from this declaration (in Socks.simba from F-Include)
    Code:
    Procedure SendEmail(URL, Email, Password, Name, Recipient, CC, BCC, Subject, Message, Attachment, AttachmentMime: String);
    var
      Sock: SSLSocket;
    begin
      Pro_InitSocket(Sock, nil, nil, nil, nil); // Error here
      Pro_CreateSocket(Sock, ''); // Probably also here and every line below, but it fails on the above line
      Pro_SetSSL(Sock, false, false, true);
      Pro_SetVerbose(Sock, true);
      Pro_SMTP(Sock, PChar(URL), PChar(Email), PChar(Password), PChar(Name), PChar(Recipient), PChar(CC), PChar(BCC), PChar(Subject), PChar(Message), PChar('text/plain; charset=UTF-8'), PChar(Attachment), PChar(AttachmentMime));
      Pro_FreeSocket(Sock);
    end;
    Even with this override in my code
    Code:
    {
      Override the Socks SendEmail procedure, in an attempt to get rid of the errors.
    }    
    Procedure SendEmail(URL, Email, Password, Name, Recipient, CC, BCC, Subject, Message, Attachment, AttachmentMime: String); override;
    begin
    end;
    I see, yes you can't escape compilation errors, in any way.
    ProSocks version F-Include relies on is an older version, it's that or you have an older version, but my money is on the one in F-Include.

    You might wanna just drop F-Include, and just use reflection it self. Not sure if anyone is actually maintaining F-Include. Can't be of much help outside this, I don't use "ProSocks" nor do I touch the reflection lib.
    Last edited by slacky; 04-24-2016 at 04:09 PM.
    !No priv. messages please

  11. #11
    Join Date
    Apr 2013
    Posts
    680
    Mentioned
    13 Post(s)
    Quoted
    341 Post(s)

    Default

    "F include"

    Code:
    const
      mail_AtTerminate = 1;
      mail_AtError = 2;
    
    Procedure SendEmail(URL, Email, Password, Name, Recipient, CC, BCC, Subject, Message, Attachment, AttachmentMime: String);
    var
      Sock: SSLSocket;
    begin
      Pro_InitSocket(Sock, nil, nil, nil, nil);
      Pro_CreateSocket(Sock, '');
      Pro_SetSSL(Sock, false, false, true);
      Pro_SetVerbose(Sock, true);
      Pro_SMTP(Sock, PChar(URL), PChar(Email), PChar(Password), PChar(Name), PChar(Recipient), PChar(CC), PChar(BCC), PChar(Subject), PChar(Message), PChar('text/plain; charset=UTF-8'), PChar(Attachment), PChar(AttachmentMime));
      Pro_FreeSocket(Sock);
    end;
    
    Procedure SendEmail(URL, Email, Password, Name, Recipient, CC, BCC, Subject, Message: String); overload;
    begin
      SendEmail(URL, Email, Password, Name, Recipient, CC, BCC, Subject, Message, '', '');
    end;
    
    Procedure SendEmail(URL, Email, Password, Name, Recipient, Subject, Message: String); overload;
    begin
      SendEmail(URL, Email, Password, Name, Recipient, '', '', Subject, Message);
    end;
    Updated Finclude

    Code:
    
    const
      mail_AtTerminate = 1;
      mail_AtError = 2;
    
    function SendEmail(Url: string): string;
    var
      S: SSLSocket;
      Res: ProMemoryStruct;
    begin
      S.Init();
      S.SetURLFollow(true);
      S.SetURL(URL);
      S.DoGet(Res);
      SetLength(Result, Res.Size);
      MemMove(Res.Memory^, Result[1], Res.Size);
      S.Free;
    end;
    
    Procedure SendEmail(URL, Email, Password, Name, Recipient, CC, BCC, Subject, Message: String); overload;
    begin
      SendEmail(URL);
    end;
    
    Procedure SendEmail(URL, Email, Password, Name, Recipient, Subject, Message: String); overload;
    begin
      SendEmail(URL, Email, Password, Name, Recipient, '', '', Subject, Message);
    end;
    Compiles and was sending email reports some months ago. I haven't updated either 'my custom finclude or prosocks' and can't remember if i did anything else.
    Last edited by AFools; 04-24-2016 at 04:22 PM.

    <------------------>



  12. #12
    Join Date
    Oct 2007
    Location
    everywhere you aint lookin
    Posts
    131
    Mentioned
    1 Post(s)
    Quoted
    6 Post(s)

    Default

    There already exists a fork (And a pull request) which contains a fix https://github.com/MichaelHarkins/finclude
    I'll probably just link to that fork instead of the official F-include, which hasn't been updated in 10 months.

    EDIT: Updated OP
    Last edited by jacoby6000; 04-24-2016 at 05:38 PM.

  13. #13
    Join Date
    Dec 2013
    Location
    Pitcairn Island
    Posts
    288
    Mentioned
    20 Post(s)
    Quoted
    166 Post(s)

    Default

    If you want some good advice, drop f-include and never touch it again.

    Fitta threw it together because the reflection include was missing some functionality at the time (because elfyyy was very stubborn about adding new code). When people start making 'spin-off' includes obviously the official include is lacking some important material. Since then, elfyyy has added a whole bunch of new things to reflection (antiban etc.). Using these custom includes requires people to download extra clutter, they have 1-2 developers so will eventually die, and nobody can be bothered to learn methods from multiple includes meaning nobody will use it to develop scripts (I think you're the first person to use the f-include since fitta).

    P.S. I like your script, but your whole states thing seems overly complicated. Surely you could come up with 10 lines of logic to direct the script?

  14. #14
    Join Date
    Sep 2008
    Location
    Not here.
    Posts
    5,422
    Mentioned
    13 Post(s)
    Quoted
    242 Post(s)

    Default

    Quote Originally Posted by TSN View Post
    If you want some good advice, drop f-include and never touch it again.

    Fitta threw it together because the reflection include was missing some functionality at the time (because elfyyy was very stubborn about adding new code). When people start making 'spin-off' includes obviously the official include is lacking some important material. Since then, elfyyy has added a whole bunch of new things to reflection (antiban etc.). Using these custom includes requires people to download extra clutter, they have 1-2 developers so will eventually die, and nobody can be bothered to learn methods from multiple includes meaning nobody will use it to develop scripts (I think you're the first person to use the f-include since fitta).

    P.S. I like your script, but your whole states thing seems overly complicated. Surely you could come up with 10 lines of logic to direct the script?
    States may add some bloat code, but they definitely help you think about and understand the flow of the script better(especially when you pick up code you haven't touched in a while).

  15. #15
    Join Date
    Dec 2013
    Location
    Pitcairn Island
    Posts
    288
    Mentioned
    20 Post(s)
    Quoted
    166 Post(s)

    Default

    Quote Originally Posted by tls View Post
    States may add some bloat code, but they definitely help you think about and understand the flow of the script better(especially when you pick up code you haven't touched in a while).
    Not true at all, if anything it is actually the exact opposite (in this case). Are you saying that understanding the flow of a script by tracking ambiguous states, integers that represent these states, and jumping back and forth through the script to see how these integers change is easier than say:

    Simba Code:
    if inventoryFull() then
    begin
      buryBones();
      cookFood();
    end else
    begin
      fightChickens();
      loot();
    end;

    Also, overly complicated <> bloat, although in most cases they do go together.

  16. #16
    Join Date
    Sep 2008
    Location
    Not here.
    Posts
    5,422
    Mentioned
    13 Post(s)
    Quoted
    242 Post(s)

    Default

    I honestly haven't even looked at the script. Obviously in this case it is pretty simple(I'm guessing), and he did over complicate it.

  17. #17
    Join Date
    Apr 2013
    Posts
    680
    Mentioned
    13 Post(s)
    Quoted
    341 Post(s)

    Default

    Quote Originally Posted by TSN View Post
    If you want some good advice, drop f-include and never touch it again.

    Fitta threw it together because the reflection include was missing some functionality at the time (because elfyyy was very stubborn about adding new code). When people start making 'spin-off' includes obviously the official include is lacking some important material. Since then, elfyyy has added a whole bunch of new things to reflection (antiban etc.). Using these custom includes requires people to download extra clutter, they have 1-2 developers so will eventually die, and nobody can be bothered to learn methods from multiple includes meaning nobody will use it to develop scripts (I think you're the first person to use the f-include since fitta).

    P.S. I like your script, but your whole states thing seems overly complicated. Surely you could come up with 10 lines of logic to direct the script?
    Errmmm i agree we shouldn't be trying to form more includes; as the two we currently have are great. With both (AL + Reflection) authors willing and able to add contributions if needed. BUT!

    I found @Fitta; include easier to find functions; it saved me a lot of time. Plus his coding 'style' is simply eloquent in many cases.

    I migrated some of his functions back to the standard include... this familiarized myself with the standard include.
    Last edited by AFools; 04-25-2016 at 04:49 AM.

    <------------------>



  18. #18
    Join Date
    Dec 2013
    Location
    Pitcairn Island
    Posts
    288
    Mentioned
    20 Post(s)
    Quoted
    166 Post(s)

    Default

    Quote Originally Posted by AFools View Post
    Errmmm i agree we shouldn't be trying to form more includes; as the two we currently have are great. With both (AL + Reflection) authors willing and able to add contributions if needed. BUT!

    I found @Fitta; include easier to find functions; it saved me a lot of time. Plus his coding 'style' is simply eloquent in many cases.

    I migrated some of his functions back to the standard include... this familiarized myself with the standard include.
    You are absolutely right about it saving you time; the extra methods in f-include made it easier to write scripts. Fitta’s include is essentially a bunch of useful functions that were used in most reflection scripts (i.e. InteractTile) and some other useful stuff from previous versions of SRL.

    This is the reason why it was developed in the first place (see my post above). Include developers (not limited to elfyyy) can be very particular about what code should go in the include. People like to keep it clean, simple, and “not let the include do all the work”. The problem is people end up copying and pasting a stack of methods into every script, so it is just common sense to add methods like these into the include (which is what eventually happened here). It is a common occurrence that people who think logically (i.e., mathematicians/physicists/programmers) lack a bit of common sense

    Include developers need to take feedback on board and modify includes to suit scripters, rather than being ‘purists’, because at the end of the day an include is for scripters, isn’t it? An include that is easier to use = more people using it = more scripts = more community activity.

    Reflection will survive but I can see AeroLib being phased out, and replaced with the hybrid include. It would be nice to see Reflection added back into the SRL repository, and integrated with the hybrid include, so all developers can work together once again (which hasn’t happened since the release of OSR). But that’s a discussion for another time and another thread.

  19. #19
    Join Date
    Oct 2007
    Location
    everywhere you aint lookin
    Posts
    131
    Mentioned
    1 Post(s)
    Quoted
    6 Post(s)

    Default

    I've updated the OP, v1.1 is out!

    I've added "Drop FInclude" as the next part of the road map. I'll try to work that in.

    I do not agree that using a Finite State Machine is something that overcomplicates a system which has state. Especially whenever you consider that to achieve more human-ish behavior, you have to be able to go from any state to any other state.

    Determining your state by a bunch of if/else/if/else/if statements is going to get insanely complex insanely fast, and more than anything else, will be very tightly coupled to some conditions you thought of up front.

    The state of this is much more complicated than
    Simba Code:
    if inventoryFull() then
    begin
      buryBones();
      cookFood();
    end else
    begin
      fightChickens();
      loot();
    end;

    Writing scripts like this is only fine if you don't care about your player looking completely robotic. This tightly couples your flow of state to your main loop. Using an FSM the way that I have, the application flow is determined by the current state that it's in.

    With the system I have, there is a TINY bit of setup to assign each state to an integer which is clearly named. After that small initial setup, I can exit from any state to any other state. If I want to go from wherever I am to.. burying bones, I just run Exit(PRAYING);

    The boilerplate that sets up the FSM might be confusing or convoluted because it's so abstract, but it's a small price (maybe 20 lines of code... Most real world systems have thousands of lines of boilerplate) for so easily being able to change states around. Not to mention, adding more states isn't as prone to error as if I had to chain several if/else blocks. Another cool side-effect of this is, if I wanted to, the flow of the application could be represented as a Markov Chain... so that's nice I guess.

    I really hate having to justify this here, whenever FSMs are something that have been used in the industry for decades and are widely accepted as good practice.

    EDIT:
    Quote Originally Posted by TSN View Post
    Surely you could come up with 10 lines of logic to direct the script?
    Here's my attempt to represent the application flow in ifs and elses... still ugly without a proper FSM implementation

    I'm really not sure how you'd represent any of this if you drop the idea of states at all though

    Simba Code:
    procedure MainLoop;
    begin
      if(state = fighting) then
      begin

        if(inv.isFull) then
        begin
          state = praying;
          exit;
        end;
       
        fightChicken;
        loot;

        if (Random(100) > 80) then
        begin
          state = looting;
          exit;
        end;
       
        if (Random(100) > 95) then
        begin
          state = praying;
          exit;
        end;

      end else if(state = praying) then
      begin
        if(not invHasBones) then
        begin
          state = cooking;
          exit;
        end;
       
        buryBones;
       
        if(Random(100) > 80) then
        begin
          state = cooking;
          exit;
        exit;
       
        state = fighting;
      end else if(state = cooking) then
        cookAllFood;
        dropAllFood;
       
        state = fighting;
      end else if(state = looting) then
        loot;
       
        if(Random(100) > 70) then
          state = fighting;
      end;
    end;

    And if I were to have written it that way, then adding more states or modifying behavior means decomposing that if-else in my head. With an FSM, I just go to the functions whose behaviors I want to change, and I also don't have to worry about all the crazy logic that's actually going on. I never even conceptualized the above if-else chain til now. And it was much harder to do that than it was just telling the code to exit to other states. The construction of the above logical construct is just a happy side-effect of the way the code is written, and it's flow through different states looks relatively human.
    Last edited by jacoby6000; 04-25-2016 at 01:09 PM.

  20. #20
    Join Date
    Jul 2012
    Posts
    49
    Mentioned
    1 Post(s)
    Quoted
    26 Post(s)

    Default

    Can you please help me.. When i try to run the script i get this all the time:
    Error: Unknown declaration "Pro_InitSocket" at line 9
    Compiling failed.


    I've even tried to download and replace it..

  21. #21
    Join Date
    Oct 2007
    Location
    everywhere you aint lookin
    Posts
    131
    Mentioned
    1 Post(s)
    Quoted
    6 Post(s)

    Default

    Quote Originally Posted by nt4rz View Post
    Can you please help me.. When i try to run the script i get this all the time:
    Error: Unknown declaration "Pro_InitSocket" at line 9
    Compiling failed.


    I've even tried to download and replace it..
    There are details in the OP about how to fix this, but I've also placed it below.

    Replace the broken procedure (which contains the line with the error) with the following

    Simba Code:
    procedure SendEmail(URL, Email, Password, Name, Recipient, CC, BCC, Subject, Message, Attachment, AttachmentMime: String);
    var
      Sock: SSLSocket;
    begin
      Sock.Init();
      Sock.SetSecurityPolicy(false, false, true);
      Sock.SetVerbose(true);
      Sock.SMTP(PChar(URL), PChar(Email), PChar(Password), PChar(Name), PChar(Recipient), PChar(CC), PChar(BCC), PChar(Subject), PChar(Message), PChar('text/plain; charset=UTF-8'), PChar(Attachment), PChar(AttachmentMime));
      Sock.Free();
    end;

    I'm working to get rid of FInclude so that this is no longer an issue.
    Last edited by jacoby6000; 04-25-2016 at 02:02 PM.

  22. #22
    Join Date
    Dec 2013
    Location
    Pitcairn Island
    Posts
    288
    Mentioned
    20 Post(s)
    Quoted
    166 Post(s)

    Default

    Quote Originally Posted by jacoby6000 View Post
    I really hate having to justify this here, whenever FSMs are something that have been used in the industry for decades and are widely accepted as good practice.
    You don’t have to justify anything; it was merely a suggestion but I’m actually glad that you thought about it in this level of detail. Although, when you bought up FSMs, I’m surprised you didn’t recognise the significance of the 9 lines of code I suggested (they could be interpreted as a FSM, albeit implemented with a greater degree of simplicity). The player having a full inventory is a ‘state’ is it not?

    Simba Code:
    if inventoryFull() then
    begin
      buryBones();
      cookFood();
    end else
    begin
      fightChickens();
      loot();
    end;

    Quote Originally Posted by jacoby6000 View Post
    Determining your state by a bunch of if/else/if/else/if statements is going to get insanely complex insanely fast, and more than anything else, will be very tightly coupled to some conditions you thought of up front.
    It only needs to be complicated if you make it, and for this particular case, it doesn’t need to get more complicated than those 9 lines of code. What if I told you that these 9 lines of code did exactly the same thing as all of the state logic in your script? I’m surprised you think the script flow of these 9 lines are bound by stricter conditions than your FSM. When designing a FSM, you have to have very well defined criteria when moving from one state to another, which is exactly what you have (and I have). Your states are based on exactly the same criteria mine are (see below for example).

    Quote Originally Posted by jacoby6000 View Post
    Writing scripts like this is only fine if you don't care about your player looking completely robotic. This tightly couples your flow of state to your main loop. Using an FSM the way that I have, the application flow is determined by the current state that it's in.
    You are basing this idea on the premise that your script will perform differently when using your FSM as opposed to the 9 lines of code I posted. Whilst your script logic is based on actual state variables, it still implements your methods in a static circular fashion; the same methods are called in the same order every loop. How is this different from the 9 lines of code I posted? This is not something wrong with your logic, it is just the nature of runescape itself; it is a set of predictable repetitive tasks.

    Let me give you an example:
    Simba Code:
    function FightChickens(): Integer;
    begin

      // Fighting chicken stuff

      if(Inv.IsFull) then
        Exit(PRAYING);

      Exit(Pick(CURRENT_STATE, LOOTING, 45));
    end;

    In this function you set the state to praying if the inventory is full. That is what the first few lines of my snippet do. If the inventory isn’t full, it may loot, and then it will repeat fighting chickens and looting until the inventory is full. How is that different from my snippet? You are saying your script is more humanlike because you have created physical state variables in your FSM. Based on the above observation that is totally untrue. A few things that would make your script more humanlike are:

    • Burying the bones when the inventory isn’t full
    • Rearranging the raw food in the inventory
    • Rotating the camera
    • Doing random gametab stuff
    • Not cooking ‘All’ food every time
    • Not dropping all the food at the same time, straight after cooking it
    • Mouse button click times/duration
    • Etc.


    These subtleties are the types of things that make your script more humanlike, not the way you have implemented your FSM.


    Quote Originally Posted by jacoby6000 View Post
    With the system I have, there is a TINY bit of setup to assign each state to an integer which is clearly named. After that small initial setup, I can exit from any state to any other state. If I want to go from wherever I am to.. burying bones, I just run Exit(PRAYING);
    Again, this is hard-coded. You are specifically telling the script to move from A to B. How is that any different from me switching the order of 2 lines in the above snippet?


    Quote Originally Posted by jacoby6000 View Post
    Here's my attempt to represent the application flow in ifs and elses... still ugly without a proper FSM implementation.

    I'm really not sure how you'd represent any of that if you drop the idea of states at all though
    It is clear from your code snippet you are thinking about this in the wrong angle. What would happen if you removed all the ‘states’ from this code; the answer is this is the 9 lines of code I posted above. Although, this don’t drop the idea of ‘states’, it just avoids creating physical state variables.

    As I said right at the beginning, this was simply a suggestion. If you like your FSM style and it works for you, then use it. Yes, you will sacrifice some readability and intuitive interpretation, but it doesn’t really matter because most people will just run the script without reading to see how it works.

  23. #23
    Join Date
    Oct 2007
    Location
    everywhere you aint lookin
    Posts
    131
    Mentioned
    1 Post(s)
    Quoted
    6 Post(s)

    Default

    I still fail to see how using if/else statements will accomplish what I've done in a simpler way, while still being easy to extend the code to implement more states in a non-sequential fashion. The main advantage of what I've done is loose coupling, and it's at very little cost. I don't see what's hard to understand about Exit(COOKING); or Exit(FIGHTING); meaning, exit and go to the X state. Sure, these things are hardcoded. But they're easier to change than mangling a bunch of procedures to change the way stuff gets processed, plus your procedure method is hardcoded anyway, so that's irrelevant. Everything in these scripts is going to be hardcoded except for user input. I'm going to lean on my 8 years of experience here and stick what I have.
    Last edited by jacoby6000; 04-26-2016 at 10:54 AM.

  24. #24
    Join Date
    Mar 2016
    Location
    Isle de Muerta
    Posts
    40
    Mentioned
    0 Post(s)
    Quoted
    23 Post(s)

    Default

    was using it today, but found that it get stuck in the house where cooking pot is. After cooking all raw chicken and if the doors are closed, it just clicks to attack chickens and can't get out of the house because the doors are closed and it doesn't open them Also its a little bit slow at thinking what to do And it changes states too fast, it click on raw chicken, then it should click on pot but instead it clicks to open doors and etc..
    p.s. thanks for script, its good to see new scripts
    Last edited by kyyskis; 04-27-2016 at 03:47 PM.

  25. #25
    Join Date
    Oct 2007
    Location
    everywhere you aint lookin
    Posts
    131
    Mentioned
    1 Post(s)
    Quoted
    6 Post(s)

    Default

    Quote Originally Posted by kyyskis View Post
    was using it today, but found that it get stuck in the house where cooking pot is. After cooking all raw chicken and if the doors are closed, it just clicks to attack chickens and can't get out of the house because the doors are closed and it doesn't open them Also its a little bit slow at thinking what to do And it changes states too fast, it click on raw chicken, then it should click on pot but instead it clicks to open doors and etc..
    p.s. thanks for script, its good to see new scripts
    Yeah, the cooking phase definitely needs work. About it getting stuck in the house though... I think 1.1 has a fix for that. If it fails to attack chickens some number of times, it'll figure out that it needs to open the door. But I could be mistaken and I forgot to include that.

Page 1 of 3 123 LastLast

Thread Information

Users Browsing this Thread

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

Tags for this Thread

Posting Permissions

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