Envision, Create, Share

Welcome to HBGames, a leading amateur game development forum and Discord server. All are welcome, and amongst our ranks you will find experts in their field from all aspects of video game design and development.

[VX] Difficulties

Difficulties
by Dargor
Version 1.1


Introduction

This script let you have as many game difficulty settings as you want.

Features
  • Can have as many difficulties as you want
  • Difficulties can have a name and a description
  • Difficulty selection screen after new game
  • Modify enemies HP MP ATK DEF SPI AGI Hit and Evasion

Screenshots

Imagine a slime with muscles.

Script

Code:
#==============================================================================

# ** Difficulties

#------------------------------------------------------------------------------

#  © Dargor, 2008

#  24/06/08

#  Version 1.1

#  Requested by van hellblaze

#------------------------------------------------------------------------------

#  VERSION HISTORY:

#   - 1.0 (24/06/08), Initial release

#   - 1.1 (24/06/08), Added EXP and Gold modifiers

#------------------------------------------------------------------------------

#  INSTRUCTIONS:

#   - Paste this above main

#   - Edit the constants in Difficulty module  

#==============================================================================

 

#==============================================================================

# ** Difficulty Configuration Module

#==============================================================================

 

module Difficulty

  # Default difficulty

  Default = 1 # medium

  # Difficulty names

  Names = [

            'Easy',

            'Medium',

            'Hard',

            'Extrem'

          ]

  # Difficulty descriptions

  Descriptions = [

                  'Piece of cake.',

                  'A good practice.',

                  'They know how to kill.',

                  "You're already dead."

                ]

  # Enemy Stats modifiers

  # HP MP ATK DEF SPI AGI Hit Evasion EXP Gold

  Modifiers = [

                [0.5, 0.5, 0.5, 0.5 ,0.5 ,0.5, 0.5 ,0.5, 0.5, 0.5],

                [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],

                [1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1, 1],

                [3, 3, 3, 3, 3, 3, 3, 3, 0.5, 0.5]

              ]

  # Available in Title Screen?

  In_Title = true

end

 

#==============================================================================

# ** Game_System

#------------------------------------------------------------------------------

#  This class handles system-related data. Also manages vehicles and BGM, etc.

# The instance of this class is referenced by $game_system.

#==============================================================================

 

class Game_System

  #--------------------------------------------------------------------------

  # * Public Instance Variables

  #--------------------------------------------------------------------------

  attr_accessor :difficulty_id

  #--------------------------------------------------------------------------

  # * Alias Listing

  #--------------------------------------------------------------------------

  alias dargor_vx_difficulty_system_initialize initialize

  #--------------------------------------------------------------------------

  # * Object Initialization

  #--------------------------------------------------------------------------

  def initialize

    dargor_vx_difficulty_system_initialize

    @difficulty_id = Difficulty::Default

  end

  #--------------------------------------------------------------------------

  # * Get Difficulty

  #--------------------------------------------------------------------------

  def difficulty

    return Difficulty::Modifiers[@difficulty_id]

  end

end

 

#==============================================================================

# ** Game_Enemy

#------------------------------------------------------------------------------

#  This class handles enemy characters. It's used within the Game_Troop class

# ($game_troop).

#==============================================================================

 

class RPG::Enemy

  #--------------------------------------------------------------------------

  # * Alias Listing

  #--------------------------------------------------------------------------

  alias dargor_vx_difficulty_enemy_maxhp maxhp

  alias dargor_vx_difficulty_enemy_maxmp maxmp

  alias dargor_vx_difficulty_enemy_atk atk

  alias dargor_vx_difficulty_enemy_def def

  alias dargor_vx_difficulty_enemy_spi spi

  alias dargor_vx_difficulty_enemy_agi agi

  alias dargor_vx_difficulty_enemy_hit hit

  alias dargor_vx_difficulty_enemy_eva eva

  alias dargor_vx_difficulty_enemy_exp exp

  alias dargor_vx_difficulty_enemy_gold gold

  #--------------------------------------------------------------------------

  # * Get Maximum HP

  #--------------------------------------------------------------------------

  def maxhp

    difficulty = $game_system.difficulty

    result = dargor_vx_difficulty_enemy_maxhp * difficulty[0]

    return result.round

  end

  #--------------------------------------------------------------------------

  # * Get Maximum MP

  #--------------------------------------------------------------------------

  def maxmp

    difficulty = $game_system.difficulty

    result = dargor_vx_difficulty_enemy_maxmp * difficulty[1]

    return result.round

  end

  #--------------------------------------------------------------------------

  # * Get Attack

  #--------------------------------------------------------------------------

  def atk

    difficulty = $game_system.difficulty

    result = dargor_vx_difficulty_enemy_atk * difficulty[2]

    return result.round

  end

  #--------------------------------------------------------------------------

  # * Get Defense

  #--------------------------------------------------------------------------

  def def

    difficulty = $game_system.difficulty

    result = dargor_vx_difficulty_enemy_def * difficulty[3]

    return result.round

  end

  #--------------------------------------------------------------------------

  # * Get Spirit

  #--------------------------------------------------------------------------

  def spi

    difficulty = $game_system.difficulty

    result = dargor_vx_difficulty_enemy_spi * difficulty[4]

    return result.round

  end

  #--------------------------------------------------------------------------

  # * Get Agility

  #--------------------------------------------------------------------------

  def agi

    difficulty = $game_system.difficulty

    result = dargor_vx_difficulty_enemy_agi * difficulty[5]

    return result.round

  end

  #--------------------------------------------------------------------------

  # * Get Hit Rate

  #--------------------------------------------------------------------------

  def hit

    difficulty = $game_system.difficulty

    result = dargor_vx_difficulty_enemy_hit * difficulty[6]

    result = [result, 100].min

    return result.round

  end

  #--------------------------------------------------------------------------

  # * Get Evasion Rate

  #--------------------------------------------------------------------------

  def eva

    difficulty = $game_system.difficulty

    result = dargor_vx_difficulty_enemy_eva * difficulty[7]

    result = [result, 100].min

    return result.round

  end

  #--------------------------------------------------------------------------

  # * Get EXP

  #--------------------------------------------------------------------------

  def exp

    difficulty = $game_system.difficulty

    result = dargor_vx_difficulty_enemy_exp * difficulty[6]

    return result.round

  end

  #--------------------------------------------------------------------------

  # * Get Gold

  #--------------------------------------------------------------------------

  def gold

    difficulty = $game_system.difficulty

    result = dargor_vx_difficulty_enemy_gold * difficulty[7]

    return result.round

  end

end

 

#==============================================================================

# ** Scene_Title

#------------------------------------------------------------------------------

#  This class performs the title screen processing.

#==============================================================================

 

class Scene_Title < Scene_Base

  #--------------------------------------------------------------------------

  # * Alias Listing

  #--------------------------------------------------------------------------

  alias dargor_vx_difficulty_title_start start

  alias dargor_vx_difficulty_title_terminate terminate

  alias dargor_vx_difficulty_title_update update

  #--------------------------------------------------------------------------

  # * Start processing

  #--------------------------------------------------------------------------

  def start

    dargor_vx_difficulty_title_start

    create_difficulty_window

  end

  #--------------------------------------------------------------------------

  # * Termination Processing

  #--------------------------------------------------------------------------

  def terminate

    dargor_vx_difficulty_title_terminate

    @difficulty_window.dispose

    @help_window.dispose

  end

  #--------------------------------------------------------------------------

  # * Termination Processing

  #--------------------------------------------------------------------------

  def create_difficulty_window

    names = []

    for name in Difficulty::Names

      names << name

    end

    @difficulty_window = Window_Command.new(172, names)

    @difficulty_window.x = @command_window.x

    @difficulty_window.y = @command_window.y

    @difficulty_window.height = @command_window.height

    @difficulty_window.visible = false

    @difficulty_window.active = false

    @help_window = Window_Help.new

    @help_window.openness = 0

  end

  #--------------------------------------------------------------------------

  # * Frame Update

  #--------------------------------------------------------------------------

  def update

    @difficulty_window.update

    @help_window.update

    if @difficulty_window.active

      update_difficulty_window

      return

    end

    if @command_window.methods.include?('selection')

      condition = '@command_window.selection == Vocab::new_game'

    else

      condition = '@command_window.index == 0'

    end

    if Input.trigger?(Input::C) && eval(condition)

      if !@difficulty_window.active && Difficulty::In_Title

        Sound.play_decision

        @difficulty_window.visible = true

        @difficulty_window.active = true

        @help_window.open

        @command_window.visible = false

        @command_window.active = false

        return

      end

    end

    dargor_vx_difficulty_title_update

  end

  #--------------------------------------------------------------------------

  # * Frame Update (Difficulty)

  #--------------------------------------------------------------------------

  def update_difficulty_window

    if self.methods.include?('create_map_background')

      @spriteset.update

      $game_map.interpreter.update

      $game_map.update

    end

    if Input.trigger?(Input::B)

      Sound.play_cancel

      @difficulty_window.visible = false

      @difficulty_window.active = false

      @help_window.close

      @command_window.visible = true

      @command_window.active = true

    end

    if Input.trigger?(Input::C)

      close_difficulty_window

      command_new_game

    end

    id = $game_system.difficulty_id = @difficulty_window.index

    @help_window.set_text(Difficulty::Descriptions[id])

  end

  #--------------------------------------------------------------------------

  # * Close Command Window

  #--------------------------------------------------------------------------

  def close_difficulty_window

    @difficulty_window.close

    @help_window.close

    begin

      @difficulty_window.update

      @help_window.update

      Graphics.update

    end until @difficulty_window.openness == 0

  end

end

Credits and Thanks

Thanks to van helblaze for requesting this script.
 
Would it be possible to do conditional branches based on difficulty? Like,

Conditional Branch - Script>$game_system.difficulty_id = 2
Play True Ending
else
Conditional Branch - Script>$game_system.difficulty_id = 1
Play Normal Ending
else
Conditional Branch - Script>$game_system.difficulty_id = 0
Play Bad Ending

using the Conditional Branch event? Would that work?
 
i'm using your bestiary script and i was wondering if we picked the 'extreme' difficulty for our game, will the stats for the monsters in the bestiary be accordingly modified w/ the difficulty?
 
AlbinoWalken69":15llkulj said:
i'm using your bestiary script and i was wondering if we picked the 'extreme' difficulty for our game, will the stats for the monsters in the bestiary be accordingly modified w/ the difficulty?
I think the bestiary just reads off the stats, so there's no problem there.
 
I noticed that this script doesn't work with some KGC scripts, I'm still looking for the script it won't work with though.

EDIT: I found the issue, the script won't work with KGC_Limitbreak, otherwise it works.
 

Thank you for viewing

HBGames is a leading amateur video game development forum and Discord server open to all ability levels. Feel free to have a nosey around!

Discord

Join our growing and active Discord server to discuss all aspects of game making in a relaxed environment. Join Us

Content

  • Our Games
  • Games in Development
  • Emoji by Twemoji.
    Top