Auto Forage addition

Discussion in 'E3' started by Casai, Aug 13, 2020.

  1. Casai

    Casai Orc Legionnaire

    Messages:
    109
    I've been testing it for a while and it works for me

    e3_Background.inc - change Sub background_Background_Events / and add at the end of the file Sub ForageBackground
    Code:
    Sub background_Background_Events
        /doevents manualTributeSet
        /doevents updateAliases
        /doevents YourKill
        /if (${Me.Skill[Forage]} && ${Me.CombatState.NotEqual[COMBAT]}) /call ForageBackground
    /return
    
    Sub ForageBackground
        |/echo ForageBackground started
        /if (${Me.Skill[Forage]} && ${Me.CombatState.NotEqual[COMBAT]}) {
            |/echo not in combat and have forage
            } else {
            /goto :exityamf
            }
            /if (${Me.AbilityReady[Forage]}) {
                |/echo Forage ready
            }  else {
            /goto :exityamf
            }
            /if (${Me.Class.ShortName.Equal[RNG]}) {
                |/echo RNG forage started
                /call FORAGEYAMF
                :rnghandle
                /if (${Cursor.ID}) /call HandleYAMFItemForage
                /delay 15
                /if (${Cursor.ID}) {
                /echo ${Cursor.Name} is still here
                /goto :rnghandle
                }
            }
            /if (${Me.Class.ShortName.Equal[DRU]}) {
                |/echo DRU forage started
                /call FORAGEYAMF
                :druhandle
                |/echo halding ${Cursor.Name}
                /if (${Cursor.ID}) /call HandleYAMFItemForage
                /delay 15
            
                /if (${Cursor.ID}) {
                /echo ${Cursor.Name} is still here
                /goto :druhandle
                }
            }
        }
     
        /if (${Me.Class.ShortName.Equal[DRU]}) {
        /if (${Cursor.ID}) {
            /echo backup item handling activated ${Cursor.Name}
            /call HandleYAMFItemForage
        }
        }
        /if (${Me.Class.ShortName.Equal[RNG]}) {
        /if (${Cursor.ID}) {
            /echo backup item handling activated ${Cursor.Name}
            /call HandleYAMFItemForage
        }
        }
        :exityamf
    /return
    file e3_Setup.inc
    Code:
    #include e3 Includes\e3_forageyamf.inc
    new file e3_forageyamf.inc
    Code:
    | notes
    
    sub FORAGEYAMF
        /declare ItemSetting int local
        /declare NotFound int local
        /cleanup
        /if (${Me.Skill[Forage]}==0) {
        /echo You cannot forage, silly person!
        /goto :Exit
        }
    
        /if (${Cursor.ID}) {
        /goto :HandleItemYAMF
        }
    
        | Stand up.  Can't forage while sitting.
        :StandMark
        /if (${Me.State.NotEqual[STAND]}) {
            /stand
            /if (${Me.State.NotEqual[STAND]}) {
               /delay 15 ${Me.State.Equal[STAND]}
            /goto :StandMark
            }
        }
    
    
        | If we can forage then do so.
        /if (${Me.AbilityReady[Forage]}) {
        /doability forage
        }
        | If we successfully foraged something then take care of it.
        /if (${Cursor.ID}) {
        |/echo yamf stuff in cursor
        /goto :HandleItemYAMF
        }
     
        :HandleItemYAMF
        /echo yamf handling item ${Cursor.Name}
        /varset NotFound -1
        | Look up this item in yamf.ini
        /varset ItemSetting ${Ini[e3 Macro Inis\yamf.ini,ForageList,${Cursor.Name},${NotFound}]}
        | If the item isn't in the .ini file then add it.
        /if (${ItemSetting}==${NotFound}) {
        /echo yamf not found $${Cursor.Name}
        /ini "e3 Macro Inis\yamf.ini" "ForageList" "${Cursor.Name}" "1"
    
        /varset ItemSetting 1
    
        }
    
        | If we're keeping this item then stash it in our bags.
        | Otherwise, just destroy it.
        /if (${ItemSetting}==1) {
    
        :LootIt
        /autoinventory
        /if (${Cursor.ID}) /goto :LootIt
    
        } else {
    
        /destroy
    
        }
        /if (${Cursor.ID}) {
        /goto :HandleItemYAMF
        }
        :Exit
    /return
    
    sub HandleYAMFItemForage
    
       /declare ItemSetting int local
       /declare NotFound int local
    
       /varset NotFound -1
    
       | Look up this item in yamf.ini
      /varset ItemSetting ${Ini[e3 Macro Inis\yamf.ini,ForageList,${Cursor.Name},${NotFound}]}
    
       | If the item isn't in the .ini file then add it.
       /if (${ItemSetting}==${NotFound}) {
    
          /ini "e3 Macro Inis\yamf.ini" "ForageList" "${Cursor.Name}" "1"
    
          /varset ItemSetting 1
    
       }
    
       | If we're keeping this item then stash it in our bags.
       | Otherwise, just destroy it.
       /if (${ItemSetting}==1) {
    
          :YAMFINV
          /autoinventory
          /if (${Cursor.ID}) /goto :YAMFINV
    
       } else {
    
          /destroy
    
       }
    
    /return  
     
    Last edited: Feb 23, 2021
    • Like Like x 1
  2. huffin

    huffin GM Staff Member

    Messages:
    1,183
    In the future, please go through the proper procedure of getting a new feature approved by the GM staff, distributing unapproved macros will get you disciplinary action taken against you
     
  3. Drogerin

    Drogerin GM Staff Member

    Messages:
    703
    We're going to approve this for public use, but again adhere to huffin's request please, GM approval should always be first step before public posting of any macros.
     
  4. Casai

    Casai Orc Legionnaire

    Messages:
    109
    wasnt aware of that rule
    I've read server rules dont remember them mentioning this. Is there something else I should get myself familiar with?
     
  5. apollo

    apollo Protector of Zek

    Messages:
    503
    Excerpt from the following thread (stickied @ the top of General MQ2 section of Forums, but for reference):

    http://www.projecteq.net/forums/index.php?threads/macroquest2-approved-plug-in-usage.4979/

    "If you would like any other plug-in publicly usable here on ProjectEQ, I urge you to submit your source code to me (or even the public) so we can review it for fairness and approval on this list. A lot of the above plug-ins are available on the MacroQuest2 forums VIP section; please respect their release and distribution policy by not posting VIP plug-ins on these forums publicly without prior permission from the author of said plug-in."

    I realize yours is a sub (edit) to existing E3, but I believe that is what is being referred to here. I imagine the same is true of E3 edits to functionality.
     
  6. apollo

    apollo Protector of Zek

    Messages:
    503
    I'd agree there is a little lack of documented clarity on this.

    I feel it's something known to people who've been around on PEQ for a good length of time, but I can't find any specifics on this for people to read up on.
     
  7. Drogerin

    Drogerin GM Staff Member

    Messages:
    703

    4. Creation of any macros, programs, scripts, etc to automate certain aspects of the game while unattended is prohibited(without authorization). This includes but is not limited to combat situations, quests, healing others etc.

    We've added the "Without authorization" part today to make sure people get the idea, but the original sentence has always been there. And for the "Auto forage comment coming that it was being done while at the screen is already expected" we understand people were probably doing this afk long before this macro. We just want people to adhere to the rules is all. It starts at auto forage, then it goes from there, we've seen it before, we've banned it before.
     
  8. Casai

    Casai Orc Legionnaire

    Messages:
    109
    thank you
    I think I understand what you mean by that line now
    before I thought that rule was about that afk automation of anything isnt allowed
     
    Last edited: Aug 14, 2020
  9. Nytsierie

    Nytsierie Orc Pawn

    Messages:
    7
    Hi
    I did try this and it works perfectly for my druid, but not for my bard. I play both of them at the same time but only druid is working (I've already spend some points for unlocking ability for both)
    Any idea how to fix it ?

    Thanks
     
  10. Coreidan

    Coreidan Orc Pawn

    Messages:
    20
    I highly recommend updating this code so that it isn't doing a blind /destroy.

    It might not seem obvious, but a lot can happen in between the code evaluating the item in the INI, and doing the /destroy. The person could drop the item and pick up their epic for example.

    Instead the the first line of HandleYAMFItemForage should set a local variable containing the name of the item on the cursor named "forageItemName" or something. In fact, if you want to be really smart, the parent function should be obtaining this name the moment the item is foraged and pass it to the HandleYAMFItemForage function.

    On the line where the /destroy happens, it should be /if (${forageItemName.Equal[${Cursor.Name}]}) /destroy

    Something to that effect. That will make it virtually impossible for items to become deleted by accident, which according to /ooc it has happened a number of times already. In this case since the /destroy is happening on a line all by itself, a lot of bad things can happen.

    To anyone contemplating using this script, BE WARNED. YOUR PRECIOUS ITEMS MAY BE DELETED.
     
  11. Casai

    Casai Orc Legionnaire

    Messages:
    109
    I played with this script for over a year before posting. didnt have a single item destroyed that wasn't marked in the ini that is why I posted it. In fact I did test it with picking up items from inventory during the process to see if they get destroyed and they were not. I am not saying its 100% destroy proof but you probably have to get very creative/specific for that to happen.

    re not working for bard: this script enables auto forage only for druid/ranger
    there are a few reasons one of them is that it can and does interfere with things like meditate and other things that character should be doing instead of foraging. If you want to enable it for your bard the script is simple enough just add a class check for bard
     
    Last edited: Feb 14, 2021
  12. Coreidan

    Coreidan Orc Pawn

    Messages:
    20
    I have seen at least 3 people complain over /ooc about items being destroyed since this post was created.

    The condition in the code is clear as day. You're blindly deleting items. It might not seem like it, but it's there. You might not have deleted items, but others have. The reason is likely a factor of HOW they are playing their characters. If its a bot doing the foraging then you may never have it happen. If you're manually playing that char while auto-forage is happening, then you're going to run into the issue sooner or later.

    My suggestion would be to update the code so the condition is impossible. You need to check if the cursor = item to delete ON THE SAME LINE AS THE DELETE.

    Please fix your code before some one loses an epic. It's an easy fix. There are no excuses.

    If you need a hand just reach out to me in game.
     
    Last edited: Feb 15, 2021
  13. Casai

    Casai Orc Legionnaire

    Messages:
    109
    If you want to improve the script above go ahead and do it. I did it to my best of ability at the time of writing. Make changes I'll review and update first post and hopefully Creamo will update e3 later.
     
  14. Tharsis

    Tharsis Orc Legionnaire

    Messages:
    143
    This macro snippit does not blind /destroy anything without the user manually editing an ini file. It's an important point.

    I'm worried about any macro automatically destroying my items so I don't enable that feature -- YAFM or e3.
     
  15. Tharsis

    Tharsis Orc Legionnaire

    Messages:
    143
    Code:
           /if (${Me.Class.ShortName.Equal[RNG]}) {
               |/echo RNG forage started
               /call FORAGEYAMF
               :rnghandle
               /if (${Cursor.ID}) /call HandleYAMFItemForage
               /delay 15
               /if (${Cursor.ID}) {
               /echo ${Cursor.Name} is still here
               /goto :druhandle
               }
           }
    
    These labels don't match. They should both be :rnghandle

    Code:
       | Stand up.  Can't forage while sitting.
       :StandMark
       /if (${Me.State.NotEqual[STAND]}) {
           /stand
           /if (${Me.State.NotEqual[STAND]}) {
           /goto :StandMark
           }
       }
    This could lead to problems. Occasionally a character will get "stuck ducking" in zone geometry. Such a stick character will enter an infinite loop here. No way out. No feedback. No response to e3 commands. It may also cause an infinite loop for mounted characters.

    Code:
       | Stand up.  Can't forage while sitting.
       /if (${Me.State.NotEqual[STAND]}) {
           /stand
          /delay 15 ${Me.State.Equal[STAND]}
       }
    Use this instead. A character which can stand will try to. No infinite loop possible.
     
    Last edited: Feb 21, 2021
  16. Casai

    Casai Orc Legionnaire

    Messages:
    109
    Code:
       | Stand up.  Can't forage while sitting.
       /if (${Me.State.NotEqual[STAND]}) {
           /stand
          /delay 15 ${Me.State.Equal[STAND]}
       }
    
    thanks for revisions
    I have a question what does this do
    /delay 15 ${Me.State.Equal[STAND]}
    to me it delays and there is a variable that does nothing
     
  17. Tharsis

    Tharsis Orc Legionnaire

    Messages:
    143
    That statement delays for 15 OR UNTIL ${Me.State.Equal[STAND]}, whichever comes first. It's a technique to allow for a variable amount of delay time: just enough delay to work but not so much delay that it slows down the entire macro.
     
  18. Casai

    Casai Orc Legionnaire

    Messages:
    109
    Code:
        :StandMark
        /if (${Me.State.NotEqual[STAND]}) {
            /stand
            /if (${Me.State.NotEqual[STAND]}) {
                /delay 15 ${Me.State.Equal[STAND]}
            /goto :StandMark
            }
        }
    updated