Difficulty Selection

Discussion in 'RGSS3 Scripts (RMVX Ace)' started by Todd, Jun 26, 2012.

    Tags:
  1. Tsunar

    Tsunar Villager Member

    Messages:
    15
    Likes Received:
    3
    First Language:
    English
    Thank you ^.^ and take your time I understand, Life comes first, thank you for your time and efforts for us ^.^
     
    #41
  2. Todd

    Todd Game Developer Member

    Messages:
    269
    Likes Received:
    42
    First Language:
    English
    Primarily Uses:
    N/A
    Here you go. 

    Code:
    #===============================================================================## DT's Difficulty# Author: DoctorTodd# Date (06/24/2012)# Version: (1.0.0) (VXA)# Level: (Medium)# Email: Todd@beacongames.com##===============================================================================## NOTES: 1)This script will only work with ace.#        2)A difficulty must be selected before the first battle or the game WILL#        CRASH.##===============================================================================## Description: Lets the player select the games difficulty.## Credits: Me (DoctorTodd), D&P3 for saving bug fix.##===============================================================================## Instructions# Paste above main.##===============================================================================## Free for any use as long as I'm credited.##===============================================================================## Editing begins 38 and ends on 71.##===============================================================================module TODDDIFFICULTY   #Easy Text.  EASYT = "Easy"   #Normal Text.  NORMALT = "Normal"   #Heroic Text.  HEROICT = "Heroic"   #Hard Text.  HARDT = "Hard"   #Easy enemy parameters multiplier.  EASYM = 0.5   #Heroic enemy parameters multiplier (Normal is skipped since it's what put  #you into the database).  HEROICM = 1.5   #Hard enemy parameters multiplier.  HARDM = 2    #Easy enemy experience multiplier.  EASYEXPM = 0.5   #Heroic enemy experience multiplier (Normal is skipped since it's what put  #you into the database).  HEROICEXPM = 1.5   #Hard enemy experience multiplier.  HARDEXPM = 2    #Easy enemy gold multiplier.  EASYGOLDM = 0.5   #Heroic enemy gold multiplier (Normal is skipped since it's what put  #you into the database).  HEROICGOLDM = 1.5   #Hard enemy gold multiplier.  HARDGOLDM = 2      #Easy enemy drop multiplier.  EASYDROPM = 0.5   #Heroic enemy drop multiplier (Normal is skipped since it's what put  #you into the database).  HEROICDROPM = 1.5   #Hard enemy drop multiplier.  HARDDROPM = 2   #The text above where the selection is made.  TEXT = "Please select a difficulty:"   #Menu command?  MENU = true   #Sound effect to play when difficulty is selected.  SE = "Darkness8"   #Switch to allow cancelling the difficulty selection.  #MUST NOT BE ON WHEN SELECTING FOR THE FIRST TIME.  SWITCH = 5 end#==============================================================================# ** Game_Enemy#------------------------------------------------------------------------------#  This class handles enemies. It used within the Game_Troop class# ($game_troop).#============================================================================== class Game_Enemy < Game_Battler  #--------------------------------------------------------------------------  # * Get Base Value of Parameter  #--------------------------------------------------------------------------  alias todd_difficulty_gmen_param_base param_base  def param_base(param_id, *args)  n1 = todd_difficulty_gmen_param_base(param_id, *args)  n2 = case $game_system.todd_difficulty  when 0 then TODDDIFFICULTY::EASYM  when 1 then 1  when 2 then TODDDIFFICULTY::HEROICM  when 3 then TODDDIFFICULTY::HARDM  end  return n1 * n2end  #--------------------------------------------------------------------------  # * Get Experience  #--------------------------------------------------------------------------  def exp    case $game_system.todd_difficulty    when 0    enemy.exp * TODDDIFFICULTY::EASYEXPM    when 1    enemy.exp           when 2    enemy.exp * TODDDIFFICULTY::HEROICEXPM    when 3    enemy.exp * TODDDIFFICULTY::HARDEXPM  endend  #--------------------------------------------------------------------------  # * Get Gold  #--------------------------------------------------------------------------  def gold    case $game_system.todd_difficulty    when 0    enemy.gold * TODDDIFFICULTY::EASYGOLDM    when 1    enemy.gold    when 2    enemy.gold * TODDDIFFICULTY::HEROICGOLDM    when 3    enemy.gold * TODDDIFFICULTY::HARDGOLDM  end  end  #--------------------------------------------------------------------------  # * Create Array of Dropped Items  #--------------------------------------------------------------------------  def make_drop_items    case $game_system.todd_difficulty    when 0    @DropMulti = TODDDIFFICULTY::EASYDROPM    when 1    @DropMulti = 1    when 2    @DropMulti = TODDDIFFICULTY::HEROICDROPM    when 3    @DropMulti = TODDDIFFICULTY::HARDDROPM  end    enemy.drop_items.inject([]) do |r, di|      if di.kind > 0 && rand * di.denominator < drop_item_rate * @DropMulti        r.push(item_object(di.kind, di.data_id))      else        r      end    end  endend #==============================================================================# ** Game_System#------------------------------------------------------------------------------#  This class handles system data. It saves the disable state of saving and# menus. Instances of this class are referenced by $game_system.#============================================================================== class Game_System  #--------------------------------------------------------------------------  # * Public Instance Variables  #--------------------------------------------------------------------------  attr_accessor :todd_difficulty            # save forbidden  #--------------------------------------------------------------------------  # * Object Initialization  #--------------------------------------------------------------------------  alias todd_difficulty_gamesystem_init initialize  def initialize    @todd_difficulty = 0    todd_difficulty_gamesystem_init  endend #==============================================================================# ** Window_DifficultySelection#============================================================================== class Window_DifficultySelection < Window_HorzCommand  #--------------------------------------------------------------------------  # * Object Initialization  #--------------------------------------------------------------------------  def initialize    super(0, 0)  end  #--------------------------------------------------------------------------  # * Get Window Width  #--------------------------------------------------------------------------  def window_width    Graphics.width/2 + 20  end  #--------------------------------------------------------------------------  # * Get Digit Count  #--------------------------------------------------------------------------  def col_max    return 4  end  #--------------------------------------------------------------------------  # * Create Command List  #--------------------------------------------------------------------------  def make_command_list    add_command(TODDDIFFICULTY::EASYT,     :easy)    add_command(TODDDIFFICULTY::NORMALT,   :normal)    add_command(TODDDIFFICULTY::HEROICT,    :heroic)    add_command(TODDDIFFICULTY::HARDT, :hard)  endend#==============================================================================# ** Window_DifficultyName#============================================================================== class Window_DifficultyName < Window_Base  #--------------------------------------------------------------------------  # * Object Initialization  #--------------------------------------------------------------------------  def initialize    super(0, 0, window_width, fitting_height(1))    refresh  end  #--------------------------------------------------------------------------  # * Get Window Width  #--------------------------------------------------------------------------  def window_width    return Graphics.width/2 + 20  end  #--------------------------------------------------------------------------  # * Refresh  #--------------------------------------------------------------------------  def refresh    contents.clear    draw_text(15, -27, 400, 80, TODDDIFFICULTY::TEXT)  endend#==============================================================================# ** Scene_Difficulty#============================================================================== class Scene_Difficulty < Scene_MenuBase  #--------------------------------------------------------------------------  # * Start Processing  #--------------------------------------------------------------------------  def start    super    create_command_window    create_name_window  end  #--------------------------------------------------------------------------  # * Create Command Window  #--------------------------------------------------------------------------  def create_command_window    @command_window = Window_DifficultySelection.new    @command_window.set_handler(:easy,      method(:command_easy))    @command_window.set_handler(:normal,     method(:command_normal))    @command_window.set_handler(:heroic,     method(:command_heroic))    @command_window.set_handler(:hard,    method(:command_hard))    @command_window.set_handler(:cancel,    method(:return_scene))if $game_switches[TODDDIFFICULTY::SWITCH] == true    @command_window.x = Graphics.width/2 - 170    @command_window.y = Graphics.height/2 - 50  end  #--------------------------------------------------------------------------  # * Create Difficulty Window  #--------------------------------------------------------------------------  def create_name_window    @name_window = Window_DifficultyName.new    @name_window.x = Graphics.width/2 - 170    @name_window.y = Graphics.height/2 - 97  end  #--------------------------------------------------------------------------  # * [easy] Command  #--------------------------------------------------------------------------  def command_easy    $game_system.todd_difficulty = 0    Audio.se_play("Audio/SE/" + TODDDIFFICULTY::SE, 100, 100)    return_scene   end  #--------------------------------------------------------------------------  # * [normal] Command  #--------------------------------------------------------------------------  def command_normal    $game_system.todd_difficulty = 1    Audio.se_play("Audio/SE/" + TODDDIFFICULTY::SE, 100, 100)    return_scene   end  #--------------------------------------------------------------------------  # * [heroic] Command  #--------------------------------------------------------------------------  def command_heroic    $game_system.todd_difficulty = 2      Audio.se_play("Audio/SE/" + TODDDIFFICULTY::SE, 100, 100)    return_scene   end  #--------------------------------------------------------------------------  # * [hard] Command  #--------------------------------------------------------------------------  def command_hard    $game_system.todd_difficulty = 3        Audio.se_play("Audio/SE/" + TODDDIFFICULTY::SE, 100, 100)    return_scene   end end if TODDDIFFICULTY::MENU == true#==============================================================================# ** Scene_Menu#------------------------------------------------------------------------------#  This class performs the menu screen processing.#============================================================================== class Scene_Menu < Scene_MenuBase  #--------------------------------------------------------------------------  # * Create Command Window  #--------------------------------------------------------------------------  alias todd_dif_menu_add_menu_command create_command_window  def create_command_window    todd_dif_menu_add_menu_command    @command_window.set_handler(:dif,      method(:command_dif))  endend  #--------------------------------------------------------------------------  # * [Difficulty] Command  #--------------------------------------------------------------------------  def command_dif  SceneManager.call(Scene_Difficulty)  endend if TODDDIFFICULTY::MENU == true#==============================================================================# ** Window_MenuCommand#------------------------------------------------------------------------------#  This command window appears on the menu screen.#============================================================================== class Window_MenuCommand < Window_Command  #--------------------------------------------------------------------------  # * Add Main Commands to List  #--------------------------------------------------------------------------  alias todd_dif_menu_command_add_to_menu add_main_commands  def add_main_commands     todd_dif_menu_command_add_to_menu    add_command("Difficulty",   :dif,   main_commands_enabled)  end endend 
     
    #42
    txtk likes this.
  3. Kes

    Kes Global Moderators Global Mod

    Messages:
    20,782
    Likes Received:
    10,584
    First Language:
    English
    Primarily Uses:
    RMVXA
    I think I have found a bug with the latest version of the script.

    I have a fully completed project using the February version and there is no problem at all with it.

    However, my new project has the version which gives different levels of gold and experience for the various choices.  In-game there appear (so far) to be no problems.  However, it seems it is affecting the battle test function on the troops tab of the database.  It is halving all the enemy stats and the gold and experience awarded, even though on the play test I have going, I have chosen Normal.  With the alteration to enemy stats it effectively renders the battle test unusable.

    Any idea on what I can do to get it back to normal?

    Thanks
     
    Last edited by a moderator: Jul 16, 2013
    #43
  4. deilin

    deilin Ranger/Elementalist Veteran

    Messages:
    1,189
    Likes Received:
    173
    First Language:
    English
    An additional note you might want to think about.

    since you are multiplying decimals, you are getting decimals in outcomes. You need to add some .to_i if possible.

    class Game_Enemy < Game_Battler #-------------------------------------------------------------------------- # * Get Base Value of Parameter #-------------------------------------------------------------------------- def param_base(param_id) case $difficulty when 0 (enemy.params[param_id] * TODDDIFFICULTY::EASYM).to_i when 1 enemy.params[param_id] when 2 (enemy.params[param_id] * TODDDIFFICULTY::HEROICM).to_i when 3 enemy.params[param_id] * TODDDIFFICULTY::HARDM else enemy.params[param_id] end endendor in the other case:

    112. #--------------------------------------------------------------------------113. # * Get Base Value of Parameter114. #--------------------------------------------------------------------------115. alias todd_difficulty_gmen_param_base param_base116. def param_base(param_id, *args)117. n1 = todd_difficulty_gmen_param_base(param_id, *args)118. n2 = case $game_system.todd_difficulty119. when 0 then TODDDIFFICULTY::EASYM120. when 1 then 1121. when 2 then TODDDIFFICULTY::HEROICM122. when 3 then TODDDIFFICULTY::HARDM123. end124. return (n1 * n2).to_i125.end
    Which version do you use. I can write in a quick debug when in test mode.
     
    Last edited by a moderator: Jul 16, 2013
    #44
  5. Kes

    Kes Global Moderators Global Mod

    Messages:
    20,782
    Likes Received:
    10,584
    First Language:
    English
    Primarily Uses:
    RMVXA
    Last edited by a moderator: Jul 17, 2013
    #45
  6. Todd

    Todd Game Developer Member

    Messages:
    269
    Likes Received:
    42
    First Language:
    English
    Primarily Uses:
    N/A
    Sorry for the late response and thanks for fixing it deilin. 
     
    #46
  7. exodus1386

    exodus1386 Villager Member

    Messages:
    20
    Likes Received:
    0
    i saw your note about it not working with any abs. has it been tested with pearl? any plans to make this adaptable with abs?
     
    #47
  8. Todd

    Todd Game Developer Member

    Messages:
    269
    Likes Received:
    42
    First Language:
    English
    Primarily Uses:
    N/A
    I haven't tested it with Pearl. I may have fixed the issue or maybe it was something else that was causing the issue. So it's worth a shot. If it doesn't I don't have plans to make them compatible.  
     
    #48
  9. exodus1386

    exodus1386 Villager Member

    Messages:
    20
    Likes Received:
    0
    just to let it be noted it looks like it does work with pearl (not sure what the original issue was). It loaded when called, killed enemy stats and drops were multiplied correctly, saved loaded game, did not re ask me my chpice of difficulty, killed enemy and everything was multiplied again. so at least for pear it looks like it works
     
    #49
  10. Lemieux

    Lemieux Warper Member

    Messages:
    3
    Likes Received:
    0
    First Language:
    sweden
    Hello i love this idea..

    Im new to making Rpg maker games and is beggining to try and learn ruby.

    I have a question it might be stupid. In scripts for example Galv:s invader mingame and yours

    there is inside the script a variable you can call for high score and in this a switch that becomes active for each difficulty

    inside the ecript i suppose.

    So the question how do i "call" it inside the editor so that i can use it in my game to make a dungeon accesible on

    harder difficulties etc...

    Sorry if its a stupid question

    Thank you
     
    #50
  11. Kes

    Kes Global Moderators Global Mod

    Messages:
    20,782
    Likes Received:
    10,584
    First Language:
    English
    Primarily Uses:
    RMVXA
    I would like to change the enemy parameters and it looks like it should be easy, but I just wanted to check out that it won't have hidden problems.

    I would like to change the following (lines 51 and 52)

    Hard enemy parameters multiplier

    HARDM = 2

    to read

    HARDM = 1.75

    Then change the gold, experience and drop rate from 2 to 1.75 in the appropriate places.

    I can't at this stage see any problem appearing, but like I say, there could be some hidden difficulty that will only appear later on.

    Thanks
     
    #51
  12. Kes

    Kes Global Moderators Global Mod

    Messages:
    20,782
    Likes Received:
    10,584
    First Language:
    English
    Primarily Uses:
    RMVXA
    deilin's proposed fix for the decimal point problem with the allocation of exp and gold does not seem to work - at least for me.

    The first example given relates to a section of code which my version of the script does not appear to have, using ctrl + F

    In the second example I have made the alteration suggested for line 124 (though in my version it is at line 103), I then started a new game, but still got exp 25.689999999. 

    Any further suggestions about this?

    Thanks
     
    #52
  13. KadoDragon

    KadoDragon Veteran Veteran

    Messages:
    155
    Likes Received:
    9
    First Language:
    English
    Oh! Oh! I have a question. Could I get a modified version where it adds to stats rather than multiplying them? My game runs on really low stats so multiplying them would overpower monsters. Can I get a version where say if you choose a higher difficulty I can have it add 2 to each stat instead of multiplying it by 2?

    *EDIT*

    Nevermind, I figured it out myself. If anyone cares to change line 94 from

    n1 * n2

    to n1 + n2 or whatever operation you want.
     
    Last edited by a moderator: Nov 5, 2013
    #53
  14. Nosleinad

    Nosleinad Storyteller Veteran

    Messages:
    351
    Likes Received:
    28
    Location:
    Brazil
    First Language:
    Portuguese
    Hello Todd,

      I saw at the first post (where this script is copied) that the script is still at version 1.0, but some nice changes were made to it in this topic. Do you plan on adding the new changes officialy to th escript or they will stay just as custom mods? ;)
     
    #54
  15. Todd

    Todd Game Developer Member

    Messages:
    269
    Likes Received:
    42
    First Language:
    English
    Primarily Uses:
    N/A
    Just as custom mods. I've pretty much retired from scripting in RPG Maker. I do of course do customs mods every once in a while.
     
    #55
  16. DancinZombiee

    DancinZombiee Villager Member

    Messages:
    27
    Likes Received:
    0
    First Language:
    English
    i need help, how do i make the difficulty screen show?
     
    #56
  17. Kes

    Kes Global Moderators Global Mod

    Messages:
    20,782
    Likes Received:
    10,584
    First Language:
    English
    Primarily Uses:
    RMVXA
    At the point where you want the player to choose, you put in an event command, using the 'script' command at the bottom of the third tab of the Event Command Menu.  You type in - exactly like this -

    SceneManager.call(Scene_Difficulty)

    Make sure you have the latest version of the script, which is dated 06/24/2012
     
    #57
  18. DancinZombiee

    DancinZombiee Villager Member

    Messages:
    27
    Likes Received:
    0
    First Language:
    English
    Like this: file:///C:/Users/CrazyMonkey123/Documents/Gameplay/bandicam%202014-09-13%2016-03-10-940.jpg
     
    #58
  19. Kes

    Kes Global Moderators Global Mod

    Messages:
    20,782
    Likes Received:
    10,584
    First Language:
    English
    Primarily Uses:
    RMVXA
    @DancinZombiee

    According to the url that's showing up in your post, that image is on your hard drive.  Therefore, naturally, I can't access it.  You need to upload images to e.g. Photobucket or some other image hosting site, and provide a link to there.
     
    #59
  20. DancinZombiee

    DancinZombiee Villager Member

    Messages:
    27
    Likes Received:
    0
    First Language:
    English
    Last edited by a moderator: Sep 14, 2014
    #60

Share This Page