• Our software update is now concluded. You will need to reset your password to log in. In order to do this, you will have to click "Log in" in the top right corner and then "Forgot your password?".
  • Welcome to PokéCommunity! Register now and join one of the best fan communities on the 'net to talk Pokémon and more! We are not affiliated with The Pokémon Company or Nintendo.

Script: Focus Meter System [v20.1]

1,408
Posts
10
Years
    • Seen today
    Focus Meter System for v20.1
    A battle system mod that allows you to control traditionally RNG-based mechanics through building a meter instead.
    Focus Meter System [v20.1]
    Focus Meter System [v20.1]

    Overview
    Do you dislike the heavy reliance on RNG in Pokemon battles? Looking to add a new strategic edge to your battles? Then this plugin may be just what you're looking for!
    This plugin aims to overhaul the bulk of RNG-based mechanics present in Pokemon battles with a new "Focus" mechanic that removes a lot of what makes Pokemon battles often feel cheap and unpredictable, and replaces it with something that deepens the gameplay with more meaningful decision making. In particular, the Critical Hit system, Accuracy/Evasion stats, and Additional Effect chance of moves as they currently exist in the base game are radically changed to be more fair, yet still retain the fun and flavor that have made them a mainstay in the series. Gone are the days of a rogue critical hit ruining your entire strategy, relying on dice rolls as your opponent stalls you out with Evasion spam, or feeling completely cheated because of a random Ice Beam freezing you.

    Instead of all of these mechanics being completely dependent on random chance, each Pokemon may now build their "Focus" in battle, which is represented as a meter. Once the meter is full, they can harness this Focus to ensure that these RNG-dependent mechanics will instead trigger when you want them to. For example, instead of critical hits having a random chance of happening with each attack, critical hits will instead ONLY happen if a Pokemon with a full focus meter spends this meter to deal critical damage. The type of effect using your focus meter will have can be set on each individual Pokemon, allowing you to use many different sorts of strategies utilizing the focus meter.

    Note however, that this plugin does not eliminate all RNG altogether. Random chance is deeply built into the battle system and part of what makes battles exciting. The goal here is to simply mitigate the more egregious examples of obnoxious RNG into an improved system that can be utilized in battle for powerful combos.

    Plugin Features
    • RNG overhaul for the entire battle system.
    • Introduces a new meter mechanic that builds up during battle.
    • Adds a new Pokemon property called "Focus Styles" that allows you to customize how each of your Pokemon may utilize their meter in battle.
    • Several different visual styles for displaying the focus meter that can be customized in the plugin settings.
    • A new "focus panel" pane that can be pulled up during battle to view the current focus levels of all battlers.
    • Compatible with existing save files, so starting a new game isn't required for installation.
    • Inherent compatibility with the ZUD Plugin.


    -DOWNLOAD LINK-


    Installation
    Spoiler:

    Changelog (v1.1.2 FINAL VERSION)
    Spoiler:


    What is Focus?
    Spoiler:


    Plugin Tutorials

    Focus Meter
    Spoiler:


    Focus Panel
    Spoiler:


    Focus Styles
    Spoiler:
     
    Last edited:
    10
    Posts
    8
    Years
    • Seen today
    First of all, this plugin is way better than I expected, and the Rage style is what I needed to add to the challenge, amazing job. That being said, I found a couple of oddities: Because of the way they are coded and in the PBS, the fang moves, regardless of style, always flinch and cause their seccondary effect
    I'll asume it is because of the pbAdditionalEffect in the scripts, since I added the move "Bitter Malice" for zoroark using fire fang's code and it allways causes the frostbite effect.

    Also I got this pair of errors:
    First one only happened using spark but I wasnt paying atention so idk what caused it, and the other when I burned a pokemon with syncrhonize being a fire pokemon

    Code:
    =================
    
    [2022-08-19 01:33:17 -0500]
    [Pokémon Essentials version 20.1]
    [v20.1 Hotfixes 1.0.3]
    
    Exception: NoMethodError
    Message: undefined method `*' for nil:NilClass
    
    Backtrace:
    174:Move_UsageCalculations:431:in `pbCalcDamageMultipliers'
    [ZUD Mechanics] Raid_Battle_Overrides.rb:179:in `pbCalcDamageMultipliers'
    [Focus Meter System] [007] Battle_Move.rb:141:in `pbCalcDamageMultipliers'
    174:Move_UsageCalculations:282:in `pbCalcDamage'
    [ZUD Mechanics] Raid_Battle_Overrides.rb:154:in `pbCalcDamage'
    166:Battler_UseMove:633:in `block in pbProcessMoveHit'
    166:Battler_UseMove:625:in `each'
    166:Battler_UseMove:625:in `pbProcessMoveHit'
    166:Battler_UseMove:407:in `block in pbUseMove'
    166:Battler_UseMove:405:in `times'
    
    =================
    
    [2022-08-19 01:45:52 -0500]
    [Pokémon Essentials version 20.1]
    [v20.1 Hotfixes 1.0.3]
    
    Exception: ArgumentError
    Message: wrong number of arguments (given 2, expected 0)
    
    Backtrace:
    [Focus Meter System] [005] Battle_Battler_Misc.rb:63:in `pbCanSynchronizeStatus?'
    163:Battler_Statuses:365:in `pbCanBurnSynchronize?'
    215:Battle_AbilityEffects:528:in `block in <main>'
    035:Event_Handlers:227:in `trigger'
    215:Battle_AbilityEffects:109:in `triggerOnStatusInflicted'
    163:Battler_Statuses:264:in `pbInflictStatus'
    163:Battler_Statuses:369:in `pbBurn'
    178:MoveEffects_BattlerOther:250:in `pbAdditionalEffect'
    166:Battler_UseMove:716:in `block in pbProcessMoveHit'
    166:Battler_UseMove:711:in `each'
     
    1,408
    Posts
    10
    Years
    • Seen today
    First of all, this plugin is way better than I expected, and the Rage style is what I needed to add to the challenge, amazing job. That being said, I found a couple of oddities: Because of the way they are coded and in the PBS, the fang moves, regardless of style, always flinch and cause their seccondary effect
    I'll asume it is because of the pbAdditionalEffect in the scripts, since I added the move "Bitter Malice" for zoroark using fire fang's code and it allways causes the frostbite effect.

    Yeah, this is because of the peculiar way that fang moves are specifically coded. There was no way to account for these specific effects other than just referring to them specifically in the code, so there's no way to generalize this to other moves that work like them. Fortunately, its very easy to make it so that your move is considered properly. In the plugin scripts, go to the file [005] Battle_Battler_Misc. Here, find this chunk of code:
    Code:
    def hasAddedEffect?(move)
        return true if hasActiveItem?(:QUICKCLAW) || hasActiveAbility?(:QUICKDRAW)
        return true if move.damagingMove? && hasActiveAbility?(:STENCH)
        return true if move.damagingMove? && hasActiveItem?([:KINGSROCK, :RAZORFANG])
        return true if move.contactMove? && hasActiveAbility?(:POISONTOUCH)
        # These moves are singled out due to their effect chance being programmed differently.
        return true if [:ICEFANG, :FIREFANG, :THUNDERFANG].include?(move.id)
        return true if ![0, 100].include?(move.addlEffect)
        return false
      end
    And simply add the ID of your move together with the fang moves.

    As for your errors, the second one is an easy fix, as it was just a typo on my part. The first one I'm not really sure what the issue is, and I haven't been able to replicate it. So I guess just let me know if it happens again, and what the context was.
     
    423
    Posts
    13
    Years
    • Seen Aug 31, 2023
    im liking the look of this

    if for some reason we wanted to have specific species to be set to a certain focus like spearow and mewtwo to enraged would it be a matter of editing [2] Pokemon_Misc.rb and changing
    Code:
          when :METAPOD, :KAKUNA, :WOBBUFFET, :SILCOON, 
               :CASCOON, :WYNAUT, :SPEWPA,  :PYUKUMUKU
            return :Passive
          end

    to

    Code:
          when :METAPOD, :KAKUNA, :WOBBUFFET, :SILCOON, 
               :CASCOON, :WYNAUT, :SPEWPA,  :PYUKUMUKU
            return :Passive
    	  when :SPEAROW, :FEAROW, :MEWTWO
            return :Enraged
          end

    or is there more to it than that?
     
    Last edited:
    1,408
    Posts
    10
    Years
    • Seen today
    im liking the look of this

    if for some reason we wanted to have specific species to be set to a certain focus like spearow and mewtwo to enraged would it be a matter of editing [2] Pokemon_Misc.rb and changing
    Code:
          when :METAPOD, :KAKUNA, :WOBBUFFET, :SILCOON, 
               :CASCOON, :WYNAUT, :SPEWPA,  :PYUKUMUKU
            return :Passive
          end

    to

    Code:
          when :METAPOD, :KAKUNA, :WOBBUFFET, :SILCOON, 
               :CASCOON, :WYNAUT, :SPEWPA,  :PYUKUMUKU
            return :Passive
    	  when :SPEAROW, :FEAROW, :MEWTWO
            return :Enraged
          end

    or is there more to it than that?

    Nope, it's as simple as that. Just keep in mind that this will be how every single Pokemon of that species generates - whether it's wild, gifted, or used by an NPC. You can easily override this though before battle by just setting the Focus Style of the Pokemon prior to battling/obtaining it, the same way you would set anything on a Pokemon, such as nature or shininess. And NPC trainer's Pokemon can obviously be set in their own PBS file or in-game editor.

    If setting up a Deluxe battle with Essentials Deluxe, there's an option to set the Focus Style of a wild Pokemon prior to battling it (which is noted in the tutorial for that plugin).
     
    Last edited:
    5
    Posts
    7
    Years
    • Seen Jul 2, 2023
    Sounds like a great mechanic! with the Essentials Deluxe you can change the style of the pokemon in battle? EX: turn 1 passive, turn 2 Potency, etc
     
    1,408
    Posts
    10
    Years
    • Seen today
    Sounds like a great mechanic! with the Essentials Deluxe you can change the style of the pokemon in battle? EX: turn 1 passive, turn 2 Potency, etc

    Yeah, in-battle Focus Styles are just treated as PBEffects, which Essentials Deluxe can set. So you can just set PBEffect::FocusStyle to whatever style you want each turn.

    Edit: Actually, this may require an update for Essentials Deluxe, because im not sure if I ever specifically flagged Focus Styles as an eligible effect to be changed. Mostly because I never even considered that as something that someone would want to do.
     
    1,408
    Posts
    10
    Years
    • Seen today
    Minor Update (v1.0.1)
    • Made it so that several PBEffects added by this plugin such as FocusLock, DampenFocus, and FocusStyle can be altered with the midbattle features of Essentials Deluxe.
    • Edited the focus generation rate of the Passive style. Users of this style will now gain additional focus when struck by a Physical or Special move when their Defense or Sp. Def stats have been raised, respectively. The amount of focus gained is relative to the number of stat boosts. This change emphasizes defensive play in this style, and keeps it in line with how the Critical Hit style functions, as they are meant to mirror each other.
    • Added updated description text for all Items, Moves, and Abilities that have had their effects altered by this plugin. These changes are auto-compiled, and require no additional installation steps.

    Note: This update requires that the latest update to Essentials Deluxe is also installed. The Focus Meter System will no longer work unless Essentials Deluxe is also updated.
     
    1,408
    Posts
    10
    Years
    • Seen today
    This isn't worthy of it's own update, but if anyone's interested, I now included a Focus Meter graphic for Raid Pokemon if using this along side the ZUD Plugin. I had forgotten to include this with the previous update.
     
    67
    Posts
    5
    Years
    • Seen Jan 9, 2024
    Is it possible to set a focus style based on a Pokemon's nature? Thought it make each Pokémon even more unique.
     
    1,408
    Posts
    10
    Years
    • Seen today
    Is it possible to set a focus style based on a Pokemon's nature? Thought it make each Pokémon even more unique.

    You can modify the code to set Focus Styles however you want, really. This is already done for specific cases. Open [002] Pokemon_Misc, and you'll find this chunk of code:
    Code:
    def focus_style
        if !@focus_style
          case self.species
          # These species default to Passive style due to not 
          # learning any offensive moves naturally.
          when :METAPOD, :KAKUNA, :WOBBUFFET, :SILCOON, 
               :CASCOON, :WYNAUT, :SPEWPA,  :PYUKUMUKU
            return :Passive
          end
          styles = []
          GameData::Focus.each_usable { |focus| styles.push(focus.id) }
          idx = @personalID % styles.length
          @focus_style = styles[idx]
        end
        return GameData::Focus.try_get(@focus_style)
      end

    As you can see here, the Passive Focus Style is already forced on certain species that wouldn't make sense having any other Focus Style (due to typically not having any offensive moves). You can simply modify this to check for Natures instead of Species. So you could do something like this:

    Code:
    case self.nature_id
    when :HARDY, :LONELY, :ADAMANT, :NAUGHTY, :BRAVE
      return :Accuracy
    when :CALM, :GENTLE, :CAREFUL, :QUIRKY, :SASSY
      return :Evasion
    when :TIMID, :HASTY, :JOLLY, :NAIVE, :SERIOUS
      return :Critical
    when :MODEST, :MILD, :BASHFUL, :RASH, :QUIET
      return :Potency
    when :BOLD, :DOCILE, :IMPISH, :LAX, :RELAXED
      return :Passive
    end

    And either replace the current code that assigns styles based on species, or just add this above that code so that Nature is checked first, and then the species is checked second. Obviously change the natures around to your liking.
     
    67
    Posts
    5
    Years
    • Seen Jan 9, 2024
    Thanks so much, I'll give that code a try 👍 Update: Works great! Just as I wanted.
     
    Last edited:
    142
    Posts
    15
    Years
  • This is an interesting concept and I hope more fan games try this out in the future.
    Anyway, while testing this out, the game doesn't seem to know what to do when I encountered a wild Pokémon within the Safari Zone, I got this error.


    Code:
    =================
    
    [2022-10-22 17:03:02 -0400]
    [Pokémon Essentials version 20.1]
    [v20.1 Hotfixes 1.0.6]
    
    Exception: NoMethodError
    Message: undefined method `focus_meter' for #<Battle::FakeBattler>
    
    Backtrace:
    [Focus Meter System] [008] Battle_Scene.rb:316:in `meter'
    [Focus Meter System] [008] Battle_Scene.rb:322:in `refreshMeter'
    [Essentials Deluxe] Databoxes.rb:102:in `refresh'
    192:Battle_Scene_Objects:38:in `initialize'
    [Focus Meter System] [008] Battle_Scene.rb:150:in `initialize'
    188:Scene_Initialize:80:in `new'
    188:Scene_Initialize:80:in `block in pbInitSprites'
    188:Scene_Initialize:78:in `each'
    188:Scene_Initialize:78:in `each_with_index'
    188:Scene_Initialize:78:in `pbInitSprites'
     
    Last edited:
    1,408
    Posts
    10
    Years
    • Seen today
    This is an interesting concept and I hope more fan games try this out in the future.
    Anyway, while testing this out, the game doesn't seem to know what to do when I encountered a wild Pokémon within the Safari Zone, I got this error.


    Code:
    =================
    
    [2022-10-22 17:03:02 -0400]
    [Pokémon Essentials version 20.1]
    [v20.1 Hotfixes 1.0.6]
    
    Exception: NoMethodError
    Message: undefined method `focus_meter' for #<Battle::FakeBattler>
    
    Backtrace:
    [Focus Meter System] [008] Battle_Scene.rb:316:in `meter'
    [Focus Meter System] [008] Battle_Scene.rb:322:in `refreshMeter'
    [Essentials Deluxe] Databoxes.rb:102:in `refresh'
    192:Battle_Scene_Objects:38:in `initialize'
    [Focus Meter System] [008] Battle_Scene.rb:150:in `initialize'
    188:Scene_Initialize:80:in `new'
    188:Scene_Initialize:80:in `block in pbInitSprites'
    188:Scene_Initialize:78:in `each'
    188:Scene_Initialize:78:in `each_with_index'
    188:Scene_Initialize:78:in `pbInitSprites'

    Yeah, im aware of this isssue. Fix coming soon.
     
    1,408
    Posts
    10
    Years
    • Seen today
    Minor Update (v1.0.2)

    • Fixed a bug that would cause a crash in the Safari Zone.
    • Disabled the ability to toggle the Focus Panel display while in the Safari Zone.
    • Restructured the code related to drawing the Focus Panel in battle for better compatibility with other plugins.
    • Fixed an issue that would unintentionally reveal the identity of battlers under the effects of Illusion by displaying their real icon on the Focus Panel.

    Note: This update requires that the latest update to Essentials Deluxe is also installed. The Focus Meter System will no longer work unless Essentials Deluxe is also updated.
     
    1,408
    Posts
    10
    Years
    • Seen today
    Minor Update (v1.0.3)


    • Added in a missing check for the "focus_boss" midbattle trigger used by Essentials Deluxe.
    • Added in a new "focusEnd" midbattle trigger used by Essentials Deluxe.
     
    1,408
    Posts
    10
    Years
    • Seen today
    Minor Update (v1.0.4)


    • Fixed a bug that would prevent effects that affect one side of the field (Reflect, Tailwind, etc) from properly counting down turns.
    • Fixed a bug with the Tangled Feet ability that would lower the opponent's Accuracy even when the user isn't confused.
     
    1,408
    Posts
    10
    Years
    • Seen today
    Minor Update (v1.0.5)


    • Moved the Focus Style debug tool implemented by this plugin so that it is now located in the "Deluxe" debug menu added by Essentials Deluxe.
    • Added the following debug options to the general debug menu under "Deluxe Plugins..."
      • Toggle the switch that enables/disables the Focus Meter.
      • Give the player a demo party that is built to showcase various Focus Styles.
      • Access the Focus Tutor script to change your party's Focus Styles.
     
    Back
    Top