The RPG Maker Resource Kit

RMRK RPG Maker Creation => XP => XP Scripts Database => Topic started by: Rune on June 29, 2008, 07:11:27 PM

Title: One-Man CMS
Post by: Rune on June 29, 2008, 07:11:27 PM
One-Man CMS
Version: 1.1
Author: Rune
Date: June 29th, 2008

Version History


(* marks current version.)

Planned Future Versions


Description


This is basically a one-character CMS. Not much more to say really.

Features


Screenshots

Default six commands
(https://rmrk.net/proxy.php?request=http%3A%2F%2Fi163.photobucket.com%2Falbums%2Ft302%2Fpsychomathic-paniac%2F1ManCMS-2-1.png&hash=6e9a9de254cb482b348608b2c1a4d1e11b71d99a)

Two extra commands
(https://rmrk.net/proxy.php?request=http%3A%2F%2Fi163.photobucket.com%2Falbums%2Ft302%2Fpsychomathic-paniac%2F1ManCMS-2-2.png&hash=0c70d86a184ac060c88e7e0f62111f07d37e6653)
(Excuse the quality of the HP/SP bars, they were only a quick paint job.)

Instructions

Instructions are inside the script, at the top. Just read through the green comment lines.

Script


Code: [Select]
#==============================================================================
# ** One-Man CMS
#  * by Rune
#------------------------------------------------------------------------------
#  Little configuration required:
#
#  Must have three images in the pictures folder of your project named "HP_bar",
#  "SP_bar" (both of these must be from 100 x 4 to 100 x 10 pixels) and one
#  named "bar_border", this one must be 102 pixels in width and the height of
#  your bars + 2 pixels, and must consist of a one pixel thick border for your
#  HP/SP bars, and may include a darker colour in the centre.
#------------------------------------------------------------------------------
# * Credit:
#   Rune
#   Modern Algebra for the HP/SP bars coding and for the Window_Command edit
#                  (I'm 99.7% sure that was him).
#==============================================================================

#==============================================================================
# * HP/SP bar configuration
#==============================================================================

HP_BAR = RPG::Cache.picture("HP_bar") # Name of your HP bar
SP_BAR = RPG::Cache.picture("SP_bar") # Name of your SP bar
BAR_BORDER = RPG::Cache.picture("bar_border") # Name of your HP/SP bar border
DECREASE_STYLE = 0 # 0 = squash, 1 = crop

#==============================================================================
# * End of HP/SP bar configuration
#==============================================================================

#==============================================================================
# * MenuStatus bar configuration
#==============================================================================

$activecharid = 1 # Change this to match the current active character
                  # The number is the character's ID in the database
                  # I.e. Arshes = 1, Basil = 2, Cyrus = 3, etc...
                  # To change ingame, use a call script command and type:
                  # $activecharid = number

#==============================================================================
# * End of MenuStatus configuration
#==============================================================================

#==============================================================================
# * Window_Base (Edit)
#==============================================================================

class Window_Base
  #--------------------------------------------------------------------------
  # * Draw Battler
  #     actor   : actor
  #     x       : draw spot x-coordinate
  #     y       : draw spot y-coordinate
  #     opacity : opacity
  #--------------------------------------------------------------------------
  def draw_actor_battler(actor, x, y, opacity)
    char = RPG::Cache.battler(actor.battler_name, actor.battler_hue)
    self.contents.blt(x, y, char, char.rect, opacity)
  end
end

#==============================================================================
# * End of Window_Base (Edit)
#==============================================================================

#==============================================================================
# * Window_Command (Rewrite)
#==============================================================================

class Window_Command < Window_Selectable
  #--------------------------------------------------------------------------
  # * Object Initialization
  #--------------------------------------------------------------------------
  def initialize(width, commands, column_max = 1, style = 0, inf_scroll = 1)
    super(0, 0, width, (commands.size * 1.0 / column_max).ceil * 32 + 32)
    @inf_scroll = inf_scroll
    @item_max = commands.size
    @commands = commands
    @column_max = column_max
    @style = style
    self.contents = Bitmap.new(width - 32, (@item_max * 1.0 / @column_max).ceil * 32)
    self.contents.font.name = "Tahoma"
    self.contents.font.size = 22
    refresh
    self.index = 0
  end
  #--------------------------------------------------------------------------
  # * Refresh
  #--------------------------------------------------------------------------
  def refresh
    self.contents.clear
    for i in 0...@item_max
      draw_item(i, normal_color)
    end
  end
  #--------------------------------------------------------------------------
  # * Draw_Item
  #--------------------------------------------------------------------------
  def draw_item(index, color)
    self.contents.font.color = color
    rect = Rect.new(index%@column_max * (self.width / @column_max) + 4, 32 * (index/@column_max), self.width / @column_max - 40, 32)
    self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
    self.contents.draw_text(rect, @commands[index], @style)
  end
  #--------------------------------------------------------------------------
  # * Disable Item
  #--------------------------------------------------------------------------
  def disable_item(index)
    draw_item(index, disabled_color)
  end
  #--------------------------------------------------------------------------
  # * Update Help
  #--------------------------------------------------------------------------
  def update_help
    @help_window.set_actor($game_party.actors[$scene.actor_index])
  end
end

#==============================================================================
# * End of Window_Command (Rewrite)
#==============================================================================

#==============================================================================
# * Window_PlayTime (Edit)
#==============================================================================

class Window_PlayTime
  def refresh
    self.contents.clear
    self.contents.font.color = system_color
    self.contents.draw_text(4, 0, 120, 32, "Play Time", 2)
    @total_sec = Graphics.frame_count / Graphics.frame_rate
    hour = @total_sec / 60 / 60
    min = @total_sec / 60 % 60
    sec = @total_sec % 60
    text = sprintf("%02d:%02d:%02d", hour, min, sec)
    self.contents.font.color = normal_color
    self.contents.draw_text(4, 32, 120, 32, text, 2)
  end
end

#==============================================================================
# * End of Window_PlayTime (Edit)
#==============================================================================

#==============================================================================
# * Window_MenuStatus (Rewrite)
#==============================================================================

class Window_MenuStatus < Window_Base
  #--------------------------------------------------------------------------
  # * Object Initialization
  #--------------------------------------------------------------------------
  def initialize
    super(240, 32, 320, 416)
    self.contents = Bitmap.new(width - 32, height - 32)
    refresh
  end
  #--------------------------------------------------------------------------
  # * Refresh
  #--------------------------------------------------------------------------
  def refresh
    self.contents.clear
    actor = $game_actors[$activecharid]
    draw_actor_battler(actor, 128, 160, 160)
    self.contents.font.size = 32
    self.contents.font.color = Color.new(0, 0, 0, 255)
    self.contents.draw_text(4, 4, 288, 32, actor.name, 1)
    self.contents.font.color = normal_color
    self.contents.draw_text(0, 0, 288, 32, actor.name, 1)
    self.contents.font.size = 22
    draw_actor_class(actor, 16, 160)
    draw_actor_level(actor, 16, 128)
    draw_actor_state(actor, 16, 192)
    draw_actor_exp(actor, 0, 96)
    border = BAR_BORDER
    src_rect = Rect.new(0, 0, 102, 12)
    self.contents.blt(39, 71, border, src_rect)
    self.contents.blt(183, 71, border, src_rect)
    hp = HP_BAR
    sp = SP_BAR
    case DECREASE_STYLE
    when 0
      hp_percent = ((actor.hp.to_f / actor.maxhp.to_f) * 100).to_i
      dest_rect = Rect.new (40, 72, hp_percent, 10)
      self.contents.stretch_blt (dest_rect, hp, hp.rect)
      sp_percent = ((actor.sp.to_f / actor.maxsp.to_f) * 100).to_i
      dest_rect = Rect.new (184, 72, sp_percent, 10)
      self.contents.stretch_blt (dest_rect, sp, sp.rect)
    when 1
      hp_percent = ((actor.hp.to_f / actor.maxhp.to_f) * 100).to_i
      src_rect = Rect.new (0, 0, hp_percent, 10)
      self.contents.blt (40, 72, hp, src_rect)
      sp_percent = ((actor.sp.to_f / actor.maxsp.to_f) * 100).to_i
      src_rect = Rect.new (0, 0, sp_percent, 10)
      self.contents.blt (184, 72, sp, src_rect)
    end
    draw_actor_hp(actor, 0, 48)
    draw_actor_sp(actor, 144, 48)
    draw_item_name($data_weapons[actor.weapon_id], 0, 224)
    draw_item_name($data_armors[actor.armor1_id], 0, 256)
    draw_item_name($data_armors[actor.armor2_id], 0, 288)
    draw_item_name($data_armors[actor.armor3_id], 0, 320)
    draw_item_name($data_armors[actor.armor4_id], 0, 352)
  end
  #--------------------------------------------------------------------------
  # * Dummy
  #--------------------------------------------------------------------------
  def dummy
    self.contents.font.color = system_color
    self.contents.draw_text(0, 112, 96, 32, $data_system.words.weapon)
    self.contents.draw_text(0, 176, 96, 32, $data_system.words.armor1)
    self.contents.draw_text(0, 240, 96, 32, $data_system.words.armor2)
    self.contents.draw_text(0, 304, 96, 32, $data_system.words.armor3)
    self.contents.draw_text(0, 368, 96, 32, $data_system.words.armor4)
    draw_item_name($data_weapons[actor.weapon_id], 0, 144)
    draw_item_name($data_armors[actor.armor1_id], 0, 208)
    draw_item_name($data_armors[actor.armor2_id], 0, 272)
    draw_item_name($data_armors[actor.armor3_id], 0, 336)
    draw_item_name($data_armors[actor.armor4_id], 0, 400)
  end
  #--------------------------------------------------------------------------
  # * Cursor Rectangle Update
  #--------------------------------------------------------------------------
  def update_cursor_rect
    if @index < 0
      self.cursor_rect.empty
    else
      self.cursor_rect.set(0, @index * 116, self.width - 32, 96)
    end
  end
end

#==============================================================================
# * End of Window_MenuStatus (Rewrite)
#==============================================================================

#==============================================================================
# * Scene_Menu
#==============================================================================

class Scene_Menu
  #--------------------------------------------------------------------------
  # * Object Initialization
  #     menu_index : command cursor's initial position
  #--------------------------------------------------------------------------
  def initialize(menu_index = 0)
    @menu_index = menu_index
  end
  #--------------------------------------------------------------------------
  # * Main Processing
  #--------------------------------------------------------------------------
  def main
    # Makes the Map appear in the background
    @spriteset = Spriteset_Map.new
    # Make command window
    s1 = "Inventory"
    s2 = "Abilities"
    s3 = "Equipment"
    s4 = "Status"
    s5 = "Save Game"
    s6 = "Quit Game"
    @command_window = Window_Command.new(160, [s1, s2, s3, s4, s5, s6], 1, 2)
    @command_window.index = @menu_index
    @command_window.y = 240 - @command_window.height / 2
    @command_window.x = 80
    # If number of party members is 0
    if $game_party.actors.size == 0
      # Disable items, skills, equipment, and status
      @command_window.disable_item(0)
      @command_window.disable_item(1)
      @command_window.disable_item(2)
      @command_window.disable_item(3)
    end
    # If save is forbidden
    if $game_system.save_disabled
      # Disable save
      @command_window.disable_item(4)
    end
    # Make status window
    @status_window = Window_MenuStatus.new
    # Make play time window
    @playtime_window = Window_PlayTime.new
    @playtime_window.x = 400
    @playtime_window.y = 160
    @playtime_window.opacity = 0
    # Make gold window
    @gold_window = Window_Gold.new
    @gold_window.x = 400
    @gold_window.y = 224
    @gold_window.opacity = 0
    # Execute transition
    Graphics.transition
    # Main loop
    loop do
      # Update game screen
      Graphics.update
      # Update input information
      Input.update
      # Frame update
      update
      # Abort loop if screen is changed
      if $scene != self
        break
      end
    end
    # Prepare for transition
    Graphics.freeze
    # Dispose of windows
    @command_window.dispose
    @playtime_window.dispose
    @spriteset.dispose
    @gold_window.dispose
    @status_window.dispose
  end
  #--------------------------------------------------------------------------
  # * Frame Update
  #--------------------------------------------------------------------------
  def update
    # Update windows
    @command_window.update
    @playtime_window.update
    @spriteset.update
    @gold_window.update
    @status_window.update
    # If command window is active: call update_command
    if @command_window.active
      update_command
      return
    end
    # If status window is active: call update_status
    if @status_window.active
      update_status
      return
    end
  end
  #--------------------------------------------------------------------------
  # * Frame Update (when command window is active)
  #--------------------------------------------------------------------------
  def update_command
    # If B button was pressed
    if Input.trigger?(Input::B)
      # Play cancel SE
      $game_system.se_play($data_system.cancel_se)
      # Switch to map screen
      $scene = Scene_Map.new
      return
    end
    # If C button was pressed
    if Input.trigger?(Input::C)
      # If command other than save or end game, and party members = 0
      if $game_party.actors.size == 0 and @command_window.index < 4
        # Play buzzer SE
        $game_system.se_play($data_system.buzzer_se)
        return
      end
      # Branch by command window cursor position
      case @command_window.index
      when 0  # item
        # Play decision SE
        $game_system.se_play($data_system.decision_se)
        # Switch to item screen
        $scene = Scene_Item.new
      when 1  # skill
        # Play decision SE
        $game_system.se_play($data_system.decision_se)
        # Switch to skill screen
        $scene = Scene_Skill.new
      when 2  # equipment
        # Play decision SE
        $game_system.se_play($data_system.decision_se)
        # Switch to equip screen
        $scene = Scene_Equip.new
      when 3  # status
        # Play decision SE
        $game_system.se_play($data_system.decision_se)
        # Switch to status screen
        $scene = Scene_Status.new
      when 4  # save
        # If saving is forbidden
        if $game_system.save_disabled
          # Play buzzer SE
          $game_system.se_play($data_system.buzzer_se)
          return
        end
        # Play decision SE
        $game_system.se_play($data_system.decision_se)
        # Switch to save screen
        $scene = Scene_Save.new
      when 5  # end game
        # Play decision SE
        $game_system.se_play($data_system.decision_se)
        # Switch to end game screen
        $scene = Scene_End.new
      end
      return
    end
  end
end

#==============================================================================
# * End of Scene_Menu
#==============================================================================

Credit



Thanks


Support


PM me on RMRK or CP if you have any issues, or just post in the topic.

Known Compatibility Issues

None known.

Demo


None needed

Author's Notes


If you have any problems, criticism, praise or queries, I'm right here. ;)

Restrictions

No restrictions. I don't care how this is used, as long as I get a little credit acknowledgment in your game's credits.

Enjoy.
Title: Re: One-Man CMS
Post by: Rune on July 01, 2008, 05:34:41 PM
Updated.
Title: Re: One-Man CMS
Post by: DJIlLuZiOnIsT on August 05, 2008, 01:51:55 PM
I love you! i have ALOT of use for this. Infact it is exactly what i need. Thanks man
Title: Detail referable pathogenesis above, cialis time mononucleosis, here authorship.
Post by: udepocoyimooq on August 23, 2019, 10:14:09 AM
They sta.vlqf.rmrk.net.nae.an hand tried allopurinol without dr prescription (http://disasterlesskerala.org/allopurinol/) propecia cost (http://modreview.net/propecia/) cialis propecia (http://modreview.net/cialis-20-mg-price/) cialis without prescription cheapest exelon (http://takara-ramen.com/exelon/) exelon for sale buy zithromax (http://ivapelocal.com/zithromax/) buy cialis online (http://puresportsnetwork.com/buy-cialis-online/) cialis 20 mg lowest price (http://vintagepowderpuff.com/generic-cialis/) bleed, saline, <a href="http://disasterlesskerala.org/allopurinol/">online allopurinol</a> <a href="http://modreview.net/propecia/">cheap propecia</a> <a href="http://modreview.net/cialis-20-mg-price/">cialis</a> <a href="http://takara-ramen.com/exelon/">exelon</a> <a href="http://ivapelocal.com/zithromax/">zithromax online</a> <a href="http://puresportsnetwork.com/buy-cialis-online/">cialis</a> <a href="http://vintagepowderpuff.com/generic-cialis/">canadian pharmacy cialis 20mg</a> preventive: climate http://disasterlesskerala.org/allopurinol/ online allopurinol http://modreview.net/propecia/ cheap propecia http://modreview.net/cialis-20-mg-price/ cialis cialis http://takara-ramen.com/exelon/ exelon http://ivapelocal.com/zithromax/ azithromycin 250mg http://puresportsnetwork.com/buy-cialis-online/ cialis buy cialis online http://vintagepowderpuff.com/generic-cialis/ cialis endoluminally oligohydramnios, happening, type.