Improved Item AI
Section 7.G
This plugin builds upon the Deluxe Battle Kit to improve upon the AI when it comes to using items from the inventory. This will generally allow AI trainers to use items more intelligently and less wastefully. AI trainers will now also consider using items to restore HP, PP, or cure the status conditions of their entire party, and not just their active Pokemon.
This also expands upon the types of items the AI is able to use in battle, allowing them to access all of the same items that the player would be able to use. This means you can give NPC's more unique items that they normally wouldn't know how to use, such as Ethers, Guard Spec. or even more obscure things like the Poke Flute.
AI Item Scores
This plugin overhauls how the AI determines to use items by implementing a "scoring" system that works very similarly to how the AI scores moves to determine which to use. While playing in debug mode, you can even turn on battle logging to be able to view the AI's decision making in regards to items within the game console.
In the plugin file [001] Battle_AI, you will find the following settings:
ITEM_FAIL_SCORE = 20
ITEM_USELESS_SCORE = 60
ITEM_BASE_SCORE = 100These are what determines the base values the AI utilizes when it comes to scoring moves. These are identical values used for move calculation, and works similarly here. You may adjust these to your liking.
Item Utilities
This plugin adds several scripting utilities to the Battle class that may be used to make coding your own AI handlers a bit easier. Below I'll cover each new method included:
Utilities
pbItemHealsHP?(item, onlyHP = false)This returns true if theitemID entered is a healing item. This includes any item included in theHP_HEAL_ITEMShash or theFULL_RESTORE_ITEMSarray in theAI_UseItemsection in Essentials. IfonlyHPis set to true, then this will only return true if the item heals HP only with no other effects (basically, this would exclude Full Restore items).pbItemCuresStatus?(item, oneStatus = false)This returns true if theitemID entered is an item that cures status conditions. This includes any item included in theONE_STATUS_CURE_ITEMSorALL_STATUS_CURE_ITEMSarrays in theAI_UseItemsection in Essentials. IfoneStatusis set to true, then this will only return true if the item only heals one particular status condition (basically, this would exclude Full Heal items).pbItemRaisesStats?(item, oneStat = false)This returns true if theitemID entered is an item that raises a battler's stats. This includes any item included in theONE_STAT_RAISE_ITEMShash or theALL_STATS_RAISE_ITEMSarray in theAI_UseItemsection in Essentials. IfoneStatis set to true, then this will only return true if the item only raises one particular stat (basically, this would exclude items like Max Mushrooms).pbItemRevivesFainted?(item)This returns true if theitemID entered is an item that revives fainted Pokemon. This includes any item included in theREVIVE_ITEMShash in theAI_UseItemsection in Essentials.pbItemRestoresPP?(item, mode = 0)This returns true if theitemID entered is an item that restores PP. This includes any item included in thePP_HEAL_ITEMSorALL_MOVE_PP_HEAL_ITEMShashes in the[001] Battle_AIfile in this plugin. Ifmodeis set to 1, then this will only return true for Ether-like items that only restore the PP for a single move. Ifmodeis set to 2, then this will only return true for Elixir-like items that restore the PP for all moves. Otherwise, this will return true if the item is either.pbGetItemValue(item, itemType)Returns the value of the entereditemID. The "value" of an item is based on what symbol is entered as the item'sitemType.When
:potion, the item's value is how much HP it heals.When
:ether, the item's value is how much PP it restores to a single move.When
:elixir, the item's value if how much PP is restored to all moves.When
:stats, the item's value is how many stages this item increases a stat by.When
:revive, the item's value is a 7 if the item fully revives, and a 5 otherwise.
pbHasHealingItem?(idxBattler, healAmt, itemType)Returns true if the trainer who owns the battler with the entered indexidxBattlerhas a healing item in their inventory of a certainitemTypethat heals less thanhealAmt. This can be used to check if a trainer has weaker healing items in their inventory, or a healing item that restores less than a certain value. TheitemTypeis set to:potionby default, which checks specifically for HP restoring items. However, you can set this to:etheror:elixirinstead, if you want to check for specific types of PP restoring items rather than HP. ThehealAmtis set to 1000 by default, which is enough to cover every healing item in the game (since things like Max Potion have a healing value of 999).
Last updated