Submit Your Article


 
RPG Maker

Welcome Guest ( Log In | Register )


  Games Resources RPG Maker VX RPG Maker XP Scripts Tutorials Downloads

 
Closed TopicStart new topic
> Munkis' Difficulty Selector...
munkis
post Jan 4 2011, 08:24 AM
Post #1


Woah, dude...
Group Icon

Group: Revolutionary
Posts: 197
Type: Writer
RM Skill: Intermediate




Munkis' Difficulty Selector

Version: 1.5
Author: munkis
Release Date:01/04/2011


Exclusive Script at RPG RPG Revolution


Introduction
This script gives you a difficulty select screen similar to Wolfenstein 3D.

Features
Use
CODE
$scene = Munkis_Difficulty_Select.new
either in a script or a "Script" event command. Everything (except for the auto-recovery of HP amd MP after the stats are changed) is handled within the script. You still need to use one in-game switch to trigger an event that's on either "autorun" or "parallel process" to do the auto-recovery, as well as any flashy graphical stuff you may want to have. You can set the in-game variable id as well as the base value of that variable in the config module, in case you want to have more than four difficulty options in your game (the command window will scroll automatically if you go beyond the fourth option). Just be sure you add the appropriate amount of faces to the Difficulty_Select_Faces (or whatever you named it) to account for the options, or else you may get error messages. Aliased command_new_game to run as soon as you select the option. This script can also be called from the main menu error-free. Just make sure you set the value of the in-game variable to it's initial base value BEFORE you call the script in the menu command.

Script
Munkis' Difficulty Selector
CODE
#------------------------------------------------------------------------------
#  * Munkis' Event-based Difficulty select V 1.5
#  * Made by munkis
#    ╔══════════╗
#    ║ FEATURES ║
#    ╚══════════╝
#  * Similar in functionality to my Event-based Travel system, this one lets the
#    user decide how badly they get their asses kicked :)  The variable must be
#    manipulated within the event.
#  * OVERWRITES non-HECO (Hit,Evasion,Crit,Odds) stats of Game_Actor.
#  * V 1.0: Initial release.
#  * V 1.1: Added built-in customizable background animation, as well as
#           comments that I forgot to add to the config module in the first
#           place.
#  * V 1.2: Everything (except for the auto-recovery of HP amd MP after the
#           stats are changed) is now handled within the script. You still need
#           to use one in-game switch (as opposed to the four the old version
#           requires) to trigger an event that's on either "autorun" or
#           "parallel process" to do the auto-recovery, as well as any flashy
#           graphical stuff you may want to have.  You can now set the ingame
#           variable id as well as the base value of that variable in the config
#           module, in case you want to have more than four difficulty options
#           in your game (the command window will scroll automatically if you go
#           beyond the fourth option). Just be sure you add the appropriate
#           amount of faces to the Difficulty_Select_Faces (or whatever you
#           named it) to account for the options, or else you may get error
#           messages.  Aliased command_new_game to run as soon as you select the
#           option.  This script can also now be called from the main menu
#           error-free.  Just make sure you set the value of the in-game
#           variable to it's initial base value BEFORE you call the script in
#           the menu command.
#  * V 1.21: N00Bfix: The value of the in-game variable is now set in the
#            start method, where it should have been all along.  Now all you
#            need to do is call the script; no need to set the variable first!
#  * V 1.22 LITE: Removed un-necessary and redundant code.  Don't drink and
#                 script kids XD
#  * V 1.23: Added the ability to set a particular option as default.
#  * v 1.5: Made compatible with Yggdrasil 1.6.  Also cleaned up the code a bit.
#------------------------------------------------------------------------------

#[module]
module MNK_Difficulty_Select

  #[Easy option text, Normal option text, Hard option text, Insane option text]
  DIFFICULTY_TEXT = ["Thou needeth a wet-nurse.","Bringest them oneth.","Thou art a smite-meister","Black plague possesses thee."]

  #Face file used to draw the face you see when you highlight an option.
  #The picture must be stored in Graphics/Faces/
  DIFFICULTY_INDEXED_PIC = "Difficulty_Select_Faces"

  #This is the in-game switch used to select the different options.
  SELECTION_MADE = 9

  #This is the message displayed in the static message window.
  DIFFICULTY_STATIC_TEXT = "You must choose, but choose wisely..."

  #[In-game variable id, value]
  DIFFICULTY_STAT_VAR = [4,100]

  #Pretty much self-explanatory.
  WINDOW_OPACITY = 255

  #Sound effect played when you choose your fate :)
  SELECTION_SE = "Bite"

  #Option highlighted as default
  #1 -- Easy
  #2 -- Normal
  #3 -- Hard
  #4 -- Insane
  DEFAULT_OPTION = 2

end
#[/module]

class Game_Actor < Game_Battler
  alias munkis_setup setup
  def setup(actor_id)
    munkis_setup(actor_id)
    $game_variables[MNK_Difficulty_Select::DIFFICULTY_STAT_VAR[0]] = MNK_Difficulty_Select::DIFFICULTY_STAT_VAR[1]
  end
  #--------------------------------------------------------------------------
  # * Get Basic Maximum HP
  #--------------------------------------------------------------------------
  def base_maxhp
    n = actor.parameters[0, @level]
    n *= $game_variables[MNK_Difficulty_Select::DIFFICULTY_STAT_VAR[0]]; n /= 100
    return n
  end
  #--------------------------------------------------------------------------
  # * Get basic Maximum MP
  #--------------------------------------------------------------------------
  def base_maxmp
    n = actor.parameters[1, @level]
    n *= $game_variables[MNK_Difficulty_Select::DIFFICULTY_STAT_VAR[0]]; n /= 100
    return n
  end
  #--------------------------------------------------------------------------
  # * Get Basic Attack
  #--------------------------------------------------------------------------
  def base_atk
    n = actor.parameters[2, @level]
    n *= $game_variables[MNK_Difficulty_Select::DIFFICULTY_STAT_VAR[0]]; n /= 100
    for item in equips.compact do n += item.atk end
    return n
  end
  #--------------------------------------------------------------------------
  # * Get Basic Defense
  #--------------------------------------------------------------------------
  def base_def
    n = actor.parameters[3, @level]
    n *= $game_variables[MNK_Difficulty_Select::DIFFICULTY_STAT_VAR[0]]; n /= 100
    for item in equips.compact do n += item.def end
    return n
  end
  #--------------------------------------------------------------------------
  # * Get Basic Spirit
  #--------------------------------------------------------------------------
  def base_spi
    n = actor.parameters[4, @level]
    n *= $game_variables[MNK_Difficulty_Select::DIFFICULTY_STAT_VAR[0]]; n /= 100
    for item in equips.compact do n += item.spi end
    return n
  end
  #--------------------------------------------------------------------------
  # * Get Basic Agility
  #--------------------------------------------------------------------------
  def base_agi
    n = actor.parameters[5, @level]
    n *= $game_variables[MNK_Difficulty_Select::DIFFICULTY_STAT_VAR[0]]; n /= 100
    for item in equips.compact do n += item.agi end
    return n
  end
end

#------------------------------------------------------------------------------
# * This draws the Static window.
#------------------------------------------------------------------------------

class Window_Dif_Static < Window_Base
  def initialize
    super(84,110,378,50)
    self.contents.draw_text(-16, -5, self.width, WLH, MNK_Difficulty_Select::DIFFICULTY_STATIC_TEXT,1)
    self.opacity = MNK_Difficulty_Select::WINDOW_OPACITY
  end
end

#------------------------------------------------------------------------------
# * This draws the Difficulty Selection window.
#------------------------------------------------------------------------------

class Window_Dif_Picture < Window_Base
  def initialize
    super(334, 159, 128, 128)
    self.opacity = MNK_Difficulty_Select::WINDOW_OPACITY
  end
  def refresh(window_contents)    
    self.contents.clear
    draw_face(MNK_Difficulty_Select::DIFFICULTY_INDEXED_PIC, window_contents, 0, 0, 96)
  end
end

#------------------------------------------------------------------------------
# * This creates all the windows and puts them where they need to be.
#------------------------------------------------------------------------------
class Munkis_Difficulty_Select < Scene_Base
  #----------------------------------------------------------------------------
  # * Start processing
  #----------------------------------------------------------------------------
  def start
    super
    create_menu_background
    create_command_window
    @picturewindow = Window_Dif_Picture.new()
    @staticwindow = Window_Dif_Static.new
  end
  #----------------------------------------------------------------------------
  # * Post-Start Processing
  #----------------------------------------------------------------------------
  def post_start
    super
    open_command_window
  end
  #----------------------------------------------------------------------------
  # * Pre-termination Processing
  #----------------------------------------------------------------------------
  def pre_terminate
    super
    close_command_window
  end
  #----------------------------------------------------------------------------
  # * Termination Processing
  #----------------------------------------------------------------------------
  def terminate
    super
    dispose_command_window
    dispose_menu_background
    @picturewindow.dispose
    @staticwindow.dispose
  end
  #----------------------------------------------------------------------------
  # * Return to Original Screen
  #----------------------------------------------------------------------------
  def return_scene
    $scene = Scene_Map.new
  end
  #----------------------------------------------------------------------------
  # * Frame Update
  #----------------------------------------------------------------------------
  def update
    super
    update_menu_background
    @command_window.update
    if @window_contents != @command_window.index
      @window_contents = @command_window.index
    end
    @picturewindow.refresh(@window_contents)
    if Input.trigger?(Input::C)
      case @command_window.index
      when 0
        choice_1
      when 1
        choice_2
      when 2
        choice_3
      when 3
        choice_4
      end
    end
  end
  #----------------------------------------------------------------------------
  # * Create Command Window
  #----------------------------------------------------------------------------
  def create_command_window
    @command_window = Window_Command.new(250, MNK_Difficulty_Select::DIFFICULTY_TEXT)
    @command_window.x = 84
    @command_window.y = 159
    @command_window.openness = 0
    @command_window.opacity = MNK_Difficulty_Select::WINDOW_OPACITY
    @command_window.height = 128
    @command_window.index = MNK_Difficulty_Select::DEFAULT_OPTION - 1
  end
  #----------------------------------------------------------------------------
  # * Dispose of Choice Window
  #----------------------------------------------------------------------------
  def dispose_command_window
    @command_window.dispose
  end
  #----------------------------------------------------------------------------
  # * Open Choice Window
  #----------------------------------------------------------------------------
  def open_command_window
    @command_window.open
    begin
      @command_window.update
      Graphics.update
    end until @command_window.openness == 255
  end
  #----------------------------------------------------------------------------
  # * Close Choice Window
  #----------------------------------------------------------------------------
  def close_command_window
    @command_window.close
    begin
      @command_window.update
      Graphics.update
    end until @command_window.openness == 0
  end
  #----------------------------------------------------------------------------
  # * The choices are executed here
  #----------------------------------------------------------------------------
  def choice_1
    $game_switches[MNK_Difficulty_Select::SELECTION_MADE] = true
    $game_variables[MNK_Difficulty_Select::DIFFICULTY_STAT_VAR[0]] += 15
    Audio.se_play("audio/se/"+MNK_Difficulty_Select::SELECTION_SE,100,100)
    $game_switches[6] = true
    return_scene
  end
  def choice_2
    $game_switches[MNK_Difficulty_Select::SELECTION_MADE] = true
    Audio.se_play("audio/se/"+MNK_Difficulty_Select::SELECTION_SE,100,100)
    $game_switches[6] = true
    return_scene
  end
  def choice_3
    $game_switches[MNK_Difficulty_Select::SELECTION_MADE] = true
    $game_variables[MNK_Difficulty_Select::DIFFICULTY_STAT_VAR[0]] -= 15
    Audio.se_play("audio/se/"+MNK_Difficulty_Select::SELECTION_SE,100,100)
    $game_switches[6] = true
    return_scene
  end
  def choice_4
    $game_switches[MNK_Difficulty_Select::SELECTION_MADE] = true
    $game_variables[MNK_Difficulty_Select::DIFFICULTY_STAT_VAR[0]] -= 30
    Audio.se_play("audio/se/"+MNK_Difficulty_Select::SELECTION_SE,100,100)
    $game_switches[6] = true
    return_scene
  end
end


Customization
Just look at the config module in the script, it's pretty easy to understand.

Compatibility
Overwrites non-HECO (Hit, Evasion, Crit, Odds) stats of Game_Actor

Screenshot


DEMO
http://www.mediafire.com/?nrb4h6exrbd1i1f
(script in demo is out-dated, but the event structure is still valid. The demo also includes the required image.)

Installation
Place in MATERIALS, above MAIN.

FAQ
Q: ZOMG teh scriptz doesn't werk!!!
A: First of all, be more specific. Second, all reports typed in chat-speak or 1337-speak will be ignored.

Terms and Conditions
I don't mind if this script is posted or linked on other RMVX sites AS LONG AS YOU GIVE CREDIT!!! Same goes for using this in your project. Contact me if you want to use this in a commercial project.

Credits
Credit me(munkis).

This post has been edited by munkis: Feb 13 2012, 06:28 AM


__________________________
Go to the top of the page
 
+Quote Post
   
munkis
post Feb 13 2012, 06:29 AM
Post #2


Woah, dude...
Group Icon

Group: Revolutionary
Posts: 197
Type: Writer
RM Skill: Intermediate




Updated script to be compatible with Yggdrasil 1.6


__________________________
Go to the top of the page
 
+Quote Post
   

Closed TopicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 

Lo-Fi Version Time is now: 21st May 2013 - 02:47 PM
RPG RPG Revolution is an Privacy Policy and Legal
eXTReMe Tracker