The RPG Maker Resource Kit

RMRK RPG Maker Creation => Requests => Script Request => Topic started by: Crimson~X on October 29, 2010, 11:36:48 PM

Title: Difficulty Script
Post by: Crimson~X on October 29, 2010, 11:36:48 PM
Is there difficulty script on here, ive looked and i cant find one, i know there is one for vx, but i need one for xp

thanks
Title: Re: Difficulty Script
Post by: Mr_Wiggles on October 30, 2010, 12:00:19 PM
there is one in the Tons of Addons (http://forum.chaos-project.com/index.php?topic=105.0) script.
Title: Re: Difficulty Script
Post by: Crimson~X on November 01, 2010, 11:52:31 AM
i dont really want tons of addons...you know something like this script for VX



#==============================================================================
# ** 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