Skip to content

Implement catching strategy in safari for RSE #477

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed

Conversation

ThibaultLassiaz
Copy link
Collaborator

@ThibaultLassiaz ThibaultLassiaz commented Oct 25, 2024

Description

This PR add support for auto catching in RSE and support for Safari mode in RSE

How flee system works

There's a grade from 0 to 20 for the flee chance, which 0 is 0% and 20 equals 100%.
On the start of a fight the Pokémon flee chance is 3 (15%).
So we can NEVER avoid that flee chance of 15% at the end of the first turn, whatever we do.

Flee chance variation depending on the Pokéblock thrown :

image

Throwing a liked Pokeblock will get him to -2 (3 - 5). But if the value is negative the game will put the cursor to 1 (5% flee chance). And once it's at 1 it can NEVER go lower.

BUT, if we stat at 3 and we throw a neutral Pokéblock (not liked/disliked) then it can go to zero, and our Pokémon flee chance is now reduce to 0%.

Since we don't read the Pokémon nature to mimic a real user behavior we will follow this pattern :

If the Pokémon's catch rate is higher than 200, throw Safari Balls. Otherwise, we throw the lowest feel Pokéblock (aka a random one).

  1. If the Pokémon is curious (escape factor = 0), throw Safari Balls.
  2. If the Pokémon ignores the Pokéblock, throw a different Pokéblock than the first one.
    2a) If the Pokémon is enthralled (escape factor = 0), throw Safari Balls.
    2b) If the Pokémon is curious (escape factor = 1), throw Safari Balls.
  3. If the Pokémon is enthralled (escape factor = 1), throw Safari Balls.

If we don't have any Pokeblock in our case, just throw balls

Just like FR/LG, if you're using catching modes such as spin, fishing or sweet scent, the bot will auto catch shinies if your auto_catch config is set to true, but will stop if your safari ball counter is less than 15.

Safari mode

Safari mode works the same as Safari mode in FR/LG, I just reduced the number of run from 50 to 30.
As we can only have 40 Pokéblocks in our Pokeblock case, and we can use 1-2 Pokéblocks (or 0 depending on the encounter), 30 runs will guarantee that we almost never run out of Pokéblocks when hunting.

Warning

Rock smash mode for Shuckle or geodude (route not implemented) is not supported on safari mode. For Shuckle people will still have to use Rock Smash mode for now, that works on Emerald for every languages.

Safari Mode is supported in all languages for RSE :

🟥 Ruby 🔷 Sapphire 🟢 Emerald
English Supported ✅ Supported ✅ Supported ✅
German Supported ✅ Supported ✅ Supported ✅
Spanish Supported ✅ Supported ✅ Supported ✅
French Supported ✅ Supported ✅ Supported ✅
Italian Supported ✅ Supported ✅ Supported ✅
Japanese Supported ✅ Supported ✅ Supported ✅

Notes

I updated the master sets with Safari mode test states

Checklist

  • Black Linter has been ran, using --line-length 120 argument
  • Wiki has been updated (if relevant)

ThibaultLassiaz and others added 24 commits October 19, 2024 15:19
…ach-listener-fire-red

Fire Red : Fix TrainerApproachListener
…red-eu-languages

Fire Red : Support SGR for EU languages
…bols-mapping

Support empty symbol mapping
…er strategy in Wiki (40Cakes#470)

Repel works by using the level of the first **non-fainted, non-egg** Pokémon in the player's party.

But both Rock Smash and Roamer Reset modes just checked the first party slot. So if the first Pokémon in the party was fainted, it would erroneously still use that for the repel level check.

Also, I have updated Rock Smash's Wiki page to advise users to use a Pokémon with the Vital Spirit or Pressure abilities as their first party member, as that gives another +35% boost to encounter rates.

This possibility was found by **14flash** on the Discord server and verified through benchmarking.
* Migrate symbol mapping from JSON to YML

* Support Daycare mode for JP Fire Red

* Refacto symbol reading to work with YML hex
…d-mapping

Rearranged Fire Red symbol mapping file & support battle functions
…er-addr

Fix zero pointers not overriding default value
This might be a terrible idea. But questions on how to do this have popped up a couple of times, so...
* Support battling modes for FR JP

* Update docs for battling modes
@ThibaultLassiaz ThibaultLassiaz force-pushed the implement-catching-safari-rse branch 2 times, most recently from 7415953 to 1cb420d Compare October 26, 2024 21:02
@ThibaultLassiaz

This comment was marked as resolved.

ThibaultLassiaz and others added 20 commits January 3, 2025 19:53
* Test and add support for Sapphire EN & GR modes

* Support battling modes for Sapphire EU

* Support Puzzle Solver for Sapphire EU

* Support Roamer resets for Sapphire EU

* Support Rock Smash for Sapphire EU

* Support Starters mode for Sapphire EU

* Support SGR, SRR for Sapphire EU

* Fix map for Sapphire JP

* Support Daycare Sapphire JP

* Support Berry Blender for Sapphire JP

* Support Puzzle Solver for Sapphire JP

* Support Feebas for Sapphire JP

* Support battling modes for Sapphire JP

* Support Starters for Sapphire JP

* Support remaining modes for Sapphire JP
* Add files via upload

* Add files via upload

* Add Wiki entry for EV train mode

Add Wiki entry for EV train mode

* Update WIKI

Update WIKI

* Updated to enable surfing

---------

Co-authored-by: Tino <[email protected]>
This extracts the bulk of the code shared between EV Train and Level Grind modes: The lookup which Pokémon Centre is closest to a chosen training spot.

Having that function might be useful for other modes or features in the future, so separating it out seems sensible. Also, it avoids having two identical data lists (current map vs. potential nearest PCs) so there's no risk of someone updating one but not the other anymore.
…s#605)

This adds a check to the EV Train mode to make it stop and switch to manual once the target EVs have been reached. Until now, it would just keep spinning and rejecting every battle. That made it a bit hard to figure out when the mode was actually done.

Also, it now checks the land encounter tables for the current map and verifies that at least one of the encounters will yield EVs that are useful towards the target.
The EV train mode shows a table with the lead Pokémon's EVs and their targets after each battle, but this was a bit hard to read since these messages fly by so quickly.

I've added some colour-coding (green for targets that have been reached, yellow for in-progress targets, regular font colour for EVs that are not being trained.)
This updates the EV Train mode's battle strategy so it always tries to run away if the lead Pokémon cannot battle.

That should avoid adding unwanted EVs to other party members if the user forgot to update their `battle.yml`.
EV Train: Improve battle strategy to never rotate lead, remove dead code, add colours to target table
…kéblocks (40Cakes#607)

When using a Pokéblock in R/S, after our block-throwing function has completed the game is already back in the action selection screen.

This means that the battle handler will never break out of that `while` loop (which is only meant to run for a single turn) and keeps providing the `decide_turn_in_safari_zone()` function with the battle state that has been generated before the Pokéblock has been thrown.

This fix just forces the battle handler to break out of the loop.
This adds pathfinding support for traversing Muddy Slopes upwards using a Mach Bike.

Also, fixes two issues:

(1) When using the Acro Bike, the bot would sometimes try to access rails from the side due to a logic bug that skipped collision checking.

(2) If the bicycle wasn't registered to the `Select` button, using the `mount_bicycle()` utility would hang because it waits for the Start Menu to reappear after using the item. But that does not happen with bicycles.
)

There is a brief moment after a battle commenced and before the battle handler callbacks are enabled, where all the conditions for 'we are no longer in a battle' are met.

That led to `on_battle_ended()` to be called at the start of a battle (as well as at the end.)

This fix just adds another check that the battle has actually started properly before considering to report the battle as done.
@ThibaultLassiaz ThibaultLassiaz force-pushed the implement-catching-safari-rse branch from 1cb420d to b2b0a8c Compare January 8, 2025 22:14
@ThibaultLassiaz ThibaultLassiaz dismissed pekempy’s stale review January 8, 2025 22:19

Rework in progress

@ThibaultLassiaz ThibaultLassiaz force-pushed the implement-catching-safari-rse branch from 7145589 to a20f3e0 Compare January 8, 2025 23:03
@ThibaultLassiaz

This comment was marked as resolved.

@ThibaultLassiaz

This comment was marked as resolved.

@ThibaultLassiaz
Copy link
Collaborator Author

ThibaultLassiaz commented Jan 20, 2025

Need to implement re-entering when on_safari_zone_timeout triggers

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants