Skip to content

Add "Ai Item Improvements" and "Ai Item Optimizations" Skypatches to SkyTemple - #568

Open
HappyLappy1 wants to merge 7 commits into
SkyTemple:masterfrom
HappyLappy1:master
Open

Add "Ai Item Improvements" and "Ai Item Optimizations" Skypatches to SkyTemple#568
HappyLappy1 wants to merge 7 commits into
SkyTemple:masterfrom
HappyLappy1:master

Conversation

@HappyLappy1

Copy link
Copy Markdown

Ai Item Optimizations reduces the size of GetAiUseItemProbability without changing anything else, creating 1080 bytes of free space in overlay29.

Ai Item Improvements replaces the same function with one that tweaks team and enemy AI to use more types of items, and use them more effectively. Here's a full list of all the things it adds/modifies:

  • Made Gold Thorns and Rare Fossils Throwable by the Ai!
  • Fixed Gravelyrock bug that only checked male Bonsly and Sudowoodo.
  • Fixed Violent Seed Bug that only checked SPA instead of both ATK and SPA
  • Vile Seed now runs a check similar to Violent Seed to ensure foe is not at minimum defenses already
  • Via Seeds now behave like Warp Seeds
  • Gravelyrocks will be thrown unless the user or target is Sudowoodo/Bonsly
  • Favored Gummis (Resisted or Better) will be eaten. Wonder/Wander/Nectar will always be eaten!
  • Violent Seeds, Rebound Orbs, and All-Hit Orbs will be used at enemies over 3/4 HP!
  • Warp/Via Seeds, Gone Pebbles, Vanish Seeds, Invisify Orbs, Rollcall Orbs (Enemies only), and Pure Seeds will be used if below 1/4 HP!
  • Sleep Seeds now check for sleeplessness and yawning!
  • Chesto Berries will only ever be used if sleeping, nightmared, or yawning!
  • For Sticks and Stones, Team members have a throw chance that depends on the foe's HP!
    • Allies have a 5% chance, unless the foe has low HP. If they do, it's an 80% chance!
    • Foes still have 70% throw chance.
  • Allies will always use Rollcall Orbs if given one! Enemies will use them at low health!
  • Grimy Food will be eaten at sufficiently low hunger, or thrown: 80% if the target is healthy, and 30% otherwise.
  • Will use Weather Orbs if it would change the weather, and they "benefit" from the weather change
    • Hail: Ice only | Sandstorm: Rock, Ground, Steel | Sunny: Fire, Grass |Rainy: Water, Electric
  • Will use Keys if they are in front of a Key Door
  • Will use Drought Orbs if they cannot swim and secondary terrain is water!
  • Will eat Blast Seeds if next to enemies!
  • Will use Ginseng on themselves, rather than being forced to throw at an ally
  • Oren Berries can be used or thrown on any low HP pokemon! (The Ai may eat or throw them!!!)
  • Foes will only use Trawl Orbs if a Kecleon shop is NOT on the floor!

Integrate Ai_Item_Optimizations and AI_Item_Improvements Skypatches into Skemple.
This is on your hands, chesyon!
@github-actions

github-actions Bot commented Jan 8, 2025

Copy link
Copy Markdown

Test Results

    14 files  ±0      14 suites  ±0   45m 39s ⏱️ - 2m 57s
10 901 tests ±0  10 896 ✅  - 4      1 💤 ±0  4 ❌ +4 
32 904 runs  ±0  26 128 ✅  - 4  6 772 💤 ±0  4 ❌ +4 

For more details on these failures, see this check.

Results for commit 8e66f64. ± Comparison against base commit 0aefaaa.

♻️ This comment has been updated with latest results.

@assidion2

Copy link
Copy Markdown

Maybe you can specify where the free space begins in the description?

@Frostbyte0x70 Frostbyte0x70 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have a couple of gripes with the idea of adding these patches by default tbh

  • First, there's no way to ensure that AiItemOptimizations doesn't break anything. It's basically impossible to test that all previous AI behavior always works the same way, and if there's a bug, it's going to be basically impossible to spot.
  • Second, AiItemImprovements seems like a very specific patch that I don't see many people wanting to apply. I think it makes more sense as a community skypatch.
  • Third, you can't properly list everything AiItemImprovements does in the description, since it's too long. People won't want to apply a patch without knowing what it does, which requires checking out the patch on the community patches channel anyway, so why not keep it there?

I still pointed out a few things you need to fix, just in case.

(Note to self / other reviewers: I haven't tested if the patch applies correctly yet)

Comment thread skytemple_files/_resources/ppmdu_config/pmd2data.xml Outdated
Comment thread skytemple_files/_resources/ppmdu_config/pmd2data.xml Outdated
Comment thread skytemple_files/patch/handler/ai_item_improvements.py Outdated
Comment thread skytemple_files/patch/handler/ai_item_optimizations.py Outdated
Comment thread skytemple_files/patch/handler/ai_item_improvements.py Outdated
Comment thread skytemple_files/patch/handler/ai_item_improvements.py
@HappyLappy1

HappyLappy1 commented Jan 8, 2025

Copy link
Copy Markdown
Author
  • First, there's no way to ensure that AiItemOptimizations doesn't break anything. It's basically impossible to test that all previous AI behavior always works the same way, and if there's a bug, it's going to be basically impossible to spot.

True. I've tested every item the Ai can use at least once, with an understanding of what the behavior of each item was based on the original code and the red rescue team c code. I have checked the 3 places the function is actually called to ensure I understand what the original function was intended to do. That said, it's not enough to ensure there won't be bugs.

  • Second, AiItemImprovements seems like a very specific patch that I don't see many people wanting to apply. I think it makes more sense as a community skypatch.

Understandable. If others agree, I'll take this out and just include AiItemOptimizations.

Am going to fix the things you suggested anyway, just in case.

Addressed the comments left on my PR
Changes label names to be more intuitive, and ensure that IsAdjacentToEnemy is only used for the function. AreaEnd is identical to IsAdjacentToEnemy, but refers to the end of the function, rather than the next function.
Comment thread skytemple_files/patch/handler/ai_item_improvements.py Outdated
HappyLappy1 and others added 3 commits January 8, 2025 14:25
Co-authored-by: Chesyon <55322011+Chesyon@users.noreply.github.com>
Enemies will not attempt to use items while embargoed! Thanks Mond for the feature request!

@Frostbyte0x70 Frostbyte0x70 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd say the code looks good now (save for the formatting / linting errors). Nice job!
Athough I still don't think it makes much sense to have the patches in SkyTemple.

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.

4 participants