Automate Habitica

== Summary ==
Automate Habitica is a suite of automation tools for Habitica, allowing you to focus on your tasks instead of managing gameplay. Each tool can be enabled, disabled, and configured to suit your needs.
== Features ==
=== Auto cron ===
Automatically runs cron shortly after your day start time.
=== Auto Accept Quest Invites ===
Automatically and immediately accepts quest invites from your party.
=== Force Start Quests ===
Forces pending quests to start after FORCE_START_QUESTS_AFTER_HOURS hours, regardless of how many party members have joined. If the script force starts the quest, and if NOTIFY_MEMBERS_EXCLUDED_FROM_QUEST is set to true, it sends a private message to the player with a list of party members who failed to join. Only party leaders can run this automation.
=== Auto Invite Quests ===
Whenever your party completes a quest, automatically selects a random quest scroll from your inventory and invites your party to that quest. There is a randomized 5-15 min delay between quest ending and using the quest scroll, to give other party members a chance to run their quests too, and to prevent multiple simultaneous quest invitations. If AUTO_INVITE_HOURGLASS_QUESTS is set to false, the script will not use any hourglass quest scrolls, even if they match the other quest categories.
=== Notify On Quest End ===
Sends a private message to you on Habitica to notify you whenever your party completes a quest. The message includes the name of the quest that was completed.
=== Auto Cast Skills ===
Strategically casts your skills for you. Ensures no mana is wasted, and no mana is lost at cron. In order from highest to lowest priority:
# Heals you and your party as needed (healer)
# Casts Stealth to hide you from any missed dailies just before your day start time (rogue)
# Freezes your streaks with Chilling Frost just before your day start time (mage)
# Defeats bosses with Burst of Flames (mage) or Brutal Smash (warrior) just before your day start time
# Reserves enough mana to start each day with as much mana as possible, then uses all your mana to buff your class's primary stat just after cron
# Buffs your class's primary stat whenever extra mana is available (reserves mana for the items listed above); mages will cast Ethereal Surge instead of buffs if they are about to cron
=== Auto Pause/Resume Damage ===
Automatically checks you into the inn if the current boss will do more than MAX_PLAYER_DAMAGE to you, or MAX_PARTY_DAMAGE to your party, or enough damage to kill you or one of your party members. Checks you out of the inn otherwise.
=== Auto Allocate Stat Points ===
Stat points are automatically allocated to your chosen stat.
=== Auto Purchase Gems ===
Automatically purchases gems with gold each month. Note that you must cron at least once during a month in order to buy gems for that month. Only subscribers can run this automation.
=== Auto Purchase Armoires ===
Any gold you earn over RESERVE_GOLD will automatically be spent on enchanted armoires.
=== Auto Sell Eggs/Hatching Potions/Food ===
Automatically sells your extra eggs, hatching potions, and/or food. You can configure how many you want to keep with RESERVE_EGGS, RESERVE_HATCHING_POTIONS, and RESERVE_FOOD.
=== Auto Hatch/Feed Pets ===
Automatically hatches pets, but only if:
# the player has enough eggs for all unowned pets/mounts of that species, and
# the player has enough hatching potions for all unowned pets/mounts of that color.
Automatically feeds pets, but only if:
# the player has enough eggs for all unowned pets/mounts of that species, and
# the player has enough hatching potions for all unowned pets/mounts of that color, and
# the player has enough of the pet's favorite food(s) to obtain all unowned mounts with the same favorite food(s).
In other words, the script will not choose which pets to hatch/feed for you; it will only hatch/feed pets if you have enough eggs/potions/food for ALL the unowned options! If a choice needs to be made, then the choice is left up to you.
If ONLY_USE_DROP_FOOD is set to true, the script will only feed basic foods (meat, milk, fish, etc.) to your pets. Special foods like cake, candy, pie, etc. will not be fed.
=== Hide Notifications ===
Hides notifications from groups (party & guilds) in the Habitica UI. The player can configure which groups they'd like to hide notifications from. To get the ID of a guild, visit the guild in a web browser and copy the end of the URL in your address bar (everything after the last /). Note that if you set HIDE_PARTY_NOTIFICATIONS or HIDE_ALL_GUILD_NOTIFICATIONS to true, it may take up to 10 mins for Automate Habitica to start hiding notifications from any new party/guilds you join.
If you are in a party that buffs a lot, it is recommended that you turn HIDE_PARTY_NOTIFICATIONS off, because the script needs to make 2 API calls to hide each party notification. API calls take time, so if your party is buffing continuously, you may see party notifications appear & disappear rapidly. Also, the Habitica API only allows a certain number of API calls per minute (better to use those API calls for buffs if you have lots of mana!)
Note that due to limitations with Google Apps Script, Automate Habitica may take up to 2 mins to hide party notifications if HIDE_PARTY_NOTIFICATIONS is set to true. I can fix this if the issue with Google Apps Script is fixed (see link), or if Automate Habitica is moved to a different platform. I would like to move Automate Habitica to a different platform someday, but it is a large undertaking that I don't have time for right now.
== Before Installing ==
It is highly recommended that you use a desktop computer for this, as some of the steps don't work well on mobile. First you must uninstall any scripts that do the same thing(s) as Automate Habitica. For example, if you are running the Auto Accept Quests script, you need to uninstall it, because Automate Habitica also auto accepts quest invites, and these two scripts will conflict with each other. To uninstall a script:
# Click here to see a list of your scripts. If you're not already signed into your Google account, click the "Start Scripting" button and sign in. Then click on "My Projects" in the main menu on the left.
# Click on the script you want to uninstall.
# Click the blue "Deploy" button near the top of the page, then click "Manage deployments".
# Click the "Archive" button (looks like a box with a down arrow inside), then click the "Done" button. If the script has no deployments, there will be no archive button, and you will see the message "This project has not been deployed yet". In this case, just click "Cancel".
# In the main menu on the left, click on "Triggers" (looks like an alarm clock).
# Hover your mouse over each trigger in the list, click the three dots on the right, and click "Delete trigger".
# If your script had no deployments, you can skip to the last step. If you clicked the "Archive" button, continue to the next step.
# Click here to open your API Settings. Highlight and copy your User ID (it looks something like this: 35c3fb6f-fb98-4bc3-b57a-ac01137d0847).
# Click here to open the Habitica Webhook Editor. Paste your User ID in the "User ID" box.
# On the same page where you copied your User ID, click the "Show API Token" button, and copy your API Token.
# In the Habitica Webhook Editor, paste your API Token in the "API Token" box, then click "Login".
# Click the "Delete" button next to every webhook that belongs to the script you are uninstalling. The webhook should have a large title that matches the name of the script.
# Repeat the above steps for every script you need to uninstall.
== Setup Instructions ==
It is highly recommended that you use a desktop computer for this, as some of the steps don't work well on mobile. Make sure you read the Before Installing section above, and follow the instructions there if applicable! Make sure you only install one copy of Automate Habitica per Google account, otherwise you will exceed the limit for URL Fetch calls and the script will not work.
# Click here to go to the Automate Habitica script. If you're not signed into your Google account, click on "Start Scripting", then sign in, then click on the script link again.
# Click the "Make a copy" button (looks like two pages of paper).
# At the top of your screen, click on "Copy of Automate Habitica". Rename it "Automate Habitica" and click the "Rename" button.
# Click here to open your API Settings. Highlight and copy your User ID (it looks something like this: 35c3fb6f-fb98-4bc3-b57a-ac01137d0847). In the Automate Habitica script, paste your User ID between the quotations where it says const USER_ID = "";. It should now look something like this: const USER_ID = "35c3fb6f-fb98-4bc3-b57a-ac01137d0847";
# On the same page where you copied your User ID, click the "Show API Token" button, and copy your API Token. In the Automate Habitica script, paste your API Token between the quotations where it says const API_TOKEN = "";. It should now look something like this: const API_TOKEN = "35c3fb6f-fb98-4bc3-b57a-ac01137d0847";
# Skip the line that says const WEB_APP_URL = "";. We will come back to that later. Edit all the other settings (consts) in the script to your liking. Only edit in between the = and the ;. If there are quotations "" in between the = and the ;, just type in between the quotations.
# Click the "Save project" button near the top of the page (looks like a floppy disk).
# Click the blue "Deploy" button near the top of the page, then click "New deployment", then click the "Deploy" button.
# (If this is your first time deploying) Click the "Review permissions" button and select your Google account. Click on "Advanced", then "Go to Automate Habitica (unsafe)". (Don't worry, it is safe!) Then click "Continue", then "Allow".
# Under "Web app", click the "Copy" button to copy the Web App URL. Then click the "Done" button.
# Paste your Web App URL inside the quotations where it says const WEB_APP_URL = "";.
# Click the drop-down menu to the right of the "Debug" button, near the top of the page. Select "install" from the drop-down.
# Click the "Run" button to the left of the "Debug" button. Wait for it to say "Execution completed".
You're all done! If you need to change the settings or uninstall the script at some point, follow the steps below.
== Changing the Settings ==
It is highly recommended that you use a desktop computer for this, as some of the steps don't work well on mobile.
# Click here to see a list of your scripts. If you're not already signed into your Google account, click the "Start Scripting" button and sign in. Then click on "My Projects" in the main menu on the left.
# Click on "Automate Habitica".
# Edit the settings (consts) to your liking.
# Click the "Save project" button near the top of the page (looks like a floppy disk).
# Click the blue "Deploy" button near the top of the page, then click "Manage deployments".
# Click the "Edit" button (looks like a pencil). Under "Version", select "New version".
# Click the "Deploy" button, then the "Done" button.
# Click the drop-down menu to the right of the "Debug" button, near the top of the page. Select "install" from the drop-down.
# Click the "Run" button to the left of the "Debug" button. Wait for it to say "Execution completed".
== Uninstalling the Script ==
It is highly recommended that you use a desktop computer for this, as some of the steps don't work well on mobile.
# Click here to see a list of your scripts. If you're not already signed into your Google account, click the "Start Scripting" button and sign in. Then click on "My Projects" in the main menu on the left.
# Click on "Automate Habitica".
# Click the drop-down menu to the right of the "Debug" button, near the top of the page. Select "uninstall" from the drop-down.
# Click the "Run" button to the left of the "Debug" button. Wait for it to say "Execution completed".
# Click the blue "Deploy" button near the top of the page, then click "Manage deployments".
# Click the "Archive" button (looks like a box with a down arrow inside). Then click the "Done" button.
== Updating the Script ==
It is highly recommended that you use a desktop computer for this, as some of the steps don't work well on mobile.
# Follow the steps in Uninstalling the Script above.
# Copy & paste your settings (consts) into a text editor so you can reference them while setting up the new version.
# In the main menu on the left, click on "Overview" (looks like a lowercase letter i inside a circle).
# Click the "Remove project" button (looks like a trash can).
# Follow the Setup Instructions above.
== Contact ==
❔ Questions: https://github.com/bumbleshoot/automate-habitica/discussions/categories/q-a
💡 Suggestions: https://github.com/bumbleshoot/automate-habitica/discussions/categories/suggestions
🐞 Report a bug: https://github.com/bumbleshoot/automate-habitica/issues
💗 Donate: https://github.com/sponsors/bumbleshoot