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.

Script Analysis: My 2ND attempt at RGSS *New Script*

--------------------------------------------------------------------------------

::: Simple Single Hero CMS 2 ::: by Reverie's Eclipse [Rev1] (*WIP*)

Screenshot :

funwithfonts0ve.png


Script:

Code:
#(Default Settings)

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

#                                                                         (2) #

#     ::: One-Hero CMS :::              :: by Rev1 ::        #

#                                                                             #

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

# Instructions: Insert in a new class above Main.                             #

#============================= Begin Script ==================================#

class Bitmap

 

 #Sets Text (and shadow color) for all methods using "draw_text" by default.

 #For Dedicated Custom Colors, change method to "original_draw_text" instead.

 if not method_defined?('original_draw_text')

  alias original_draw_text draw_text

 

 def draw_text(*arg)

    original_color = self.font.color.dup

    self.font.color = Color.new( 0, 0, 0, 255)

    self.font.italic = false

    self.font.bold = false

    self.font.name = "Arial" 

    self.font.size = 22 

    if arg[0].is_a?(Rect)

      arg[0].x += 2

      arg[0].y += 2

      self.original_draw_text(*arg)

      arg[0].x -= 2

      arg[0].y -= 2

    else

      arg[0] += 2

      arg[1] += 2

      self.original_draw_text(*arg)

      arg[0] -= 2

      arg[1] -= 2

    end

    self.font.color = original_color

    self.original_draw_text(*arg)

  end

 end

end

###############################################################################

class Scene_Menu

  

  def initialize(menu_index = 0)

    @menu_index = menu_index

  end

  

  def main

    # Parent Map @ Menu BG

    @spriteset = Spriteset_Map.new

    s1 = $data_system.words.skill

    s2 = $data_system.words.item

    s3 = $data_system.words.equip

    s4 = "Status"

    s5 = "Save"

    s6 = "End Game"

    @command_window = Window_Command.new(110, [s1, s2, s3, s4, s5, s6])

    @command_window.index = @menu_index

    @command_window.x = 280

    @command_window.y = 0

    # :NEW CLASS: NewMenu_Status ::Actor Parameters::

    @status_window = Window_NewMenuStatus.new

    @status_window.x = 0

    @status_window.y = 110

    # :NEW CLASS: Window_Character ::Actor Graphic/Name/Weapon Equipped::

    @character_window = Window_Character.new

    @character_window.x = 0

    @character_window.y = 0

    @window_gold = Window_Gold.new

    @window_gold.x = 0

    @window_gold.y = 330

    @window_playtime = Window_PlayTime.new

    @window_playtime.x = 0

    @window_playtime.y = 384

    if $game_party.actors.size == 0

      @command_window.disable_item(0)

      @command_window.disable_item(1)

      @command_window.disable_item(2)

      @command_window.disable_item(3)

    end

    if $game_system.save_disabled

      @command_window.disable_item(4)

    end

    Graphics.transition

    loop do

      Graphics.update

      Input.update

      update

      if $scene != self

        break

      end

    end

    Graphics.freeze

    @command_window.dispose

    @status_window.dispose

    # Dispose Map BG

    @spriteset.dispose

    # Dispose Window @ Window_Character

    @character_window.dispose

    @window_gold.dispose

    @window_playtime.dispose

  end

  # Removed PlayTime & Steps Updates

  def update

    @command_window.update

    @window_playtime.update

    if @command_window.active

      update_command

      return

    end

  end

  

  def update_command

    if Input.trigger?(Input::B)

      $game_system.se_play($data_system.cancel_se)

      $scene = Scene_Map.new

      return

    end

    if Input.trigger?(Input::C)

      if $game_party.actors.size == 0 and @command_window.index < 4

        $game_system.se_play($data_system.buzzer_se)

        return

      end

      case @command_window.index

      when 0  # skill

        $game_system.se_play($data_system.decision_se)

        # Skill Menu

        $scene = Scene_Skill.new

      when 1  # item

        $game_system.se_play($data_system.decision_se)

        # Item Menu

        $scene = Scene_Item.new

      when 2  # equipment

        $game_system.se_play($data_system.decision_se)

        # Equip Menu

        $scene = Scene_Equip.new 

      when 3  # status

        $game_system.se_play($data_system.decision_se)

        $scene = Scene_Status.new 

      when 4  # save

        if $game_system.save_disabled

           $game_system.se_play($data_system.buzzer_se)

          return

        end

        $game_system.se_play($data_system.decision_se)

        $scene = Scene_Save.new

      when 5  # end game

        $game_system.se_play($data_system.decision_se)

        $scene = Scene_End.new

       end

      return

    end

  end

end

###############################################################################

# CUSTOM CLASS # (Edit of/Replaces Window_MenuStatus)

class Window_NewMenuStatus < Window_Selectable

  # Resized Window @ X & Y

  def initialize

    super(0, 0, 280, 220)

    self.contents = Bitmap.new(width - 32, height - 32)

    refresh

    self.active = false

    self.index = -1

  end

  # Refresh: Set Array @ Party Max = 1 Member

  def refresh

    self.contents.clear

      @item_max = $game_party.actors.size

      i = 0

      x = 64

      y = i * 116

      actor = $game_party.actors[i]

      draw_actor_level(actor, x - 60, y)

      draw_actor_state(actor, x + 40, y + 150)

      draw_actor_exp(actor, x - 60, y + 120)

      draw_actor_hp(actor, x - 60, y + 60)

      draw_actor_sp(actor, x - 60, y + 90)

 

    # Condition Text Options

    self.contents.font.color = Color.new(255, 255, 255, 255)

    self.contents.font.size = 22

    self.contents.font.name = "Arial"    

    self.contents.draw_text(x - 60, y + 150, 220, 32, "Condition")

    

    # Class Text Options

    self.contents.font.color = Color.new(255, 255, 255, 255)

    self.contents.draw_text(x - 60, y + 30, 32, 32, "Class")

    self.contents.font.color = normal_color

    self.contents.draw_text(x - 20, y + 30, 180, 32, actor.class_name)

    end

  end

###############################################################################

class Scene_End

   

  def main

    s1 = "To Title"

    s2 = "Shutdown"

    s3 = "Cancel"

    @command_window = Window_Command.new(192, [s1, s2, s3])

    @command_window.x = 320 - @command_window.width / 2

    @command_window.y = 240 - @command_window.height / 2

    # Add Parent Map @ Menu BG

    @spriteset = Spriteset_Map.new

    Graphics.transition

    loop do

      Graphics.update

      Input.update

      update

      if $scene != self

        break

      end

    end

    Graphics.freeze

    @command_window.dispose

    # Dispose Map BG

    @spriteset.dispose

    if $scene.is_a?(Scene_Title)

      Graphics.transition

      Graphics.freeze

    end

  end

end

###############################################################################

class Window_Base < Window

  

  # Actor Level Text Options

  def draw_actor_level(actor, x, y)

    self.contents.font.name = "Arial"

    self.contents.font.bold = false

    self.contents.font.italic = false

    self.contents.font.size = 22

    self.contents.font.color = Color.new(255, 255, 255, 255)

    self.contents.draw_text(x, y, 32, 32, "LEVEL")

    self.contents.font.name = "Arial"

    self.contents.font.bold = false

    self.contents.font.italic = false

    self.contents.font.size = 22

    self.contents.font.color = normal_color

    self.contents.draw_text(x + 32, y, 24, 32, actor.level.to_s, 2)

  end

  

  # Experience Text Options 

  def draw_actor_exp(actor, x, y)

    self.contents.font.name = "Arial"

    self.contents.font.bold = false

    self.contents.font.italic = false

    self.contents.font.size = 22

    self.contents.font.color = Color.new(255, 255, 255, 255)

    self.contents.draw_text(x, y, 32, 32, "EXP")

    self.contents.font.name = "Arial"

    self.contents.font.bold = false

    self.contents.font.italic = false

    self.contents.font.size = 22

    self.contents.font.color = normal_color

    self.contents.draw_text(x + 50, y, 84, 32, actor.exp_s, 2)

    self.contents.draw_text(x + 140, y, 12, 32, "/", 1)

    self.contents.draw_text(x + 150, y, 84, 32, actor.next_exp_s)    

  end

  

  # Actor Name Text Options 

  def draw_actor_name(actor, x, y)

    self.contents.font.color = Color.new(255, 255, 255, 255)

    self.contents.font.name = "Arial"

    self.contents.font.bold = false

    self.contents.font.italic = false

    self.contents.font.size = 22

    self.contents.draw_text(x, y, 120, 32, actor.name)

  end

  

  # HP Text Options

  def draw_actor_hp(actor, x, y, width = 144)

    self.contents.font.name = "Arial"

    self.contents.font.size = 22

    self.contents.font.italic = false

    self.contents.font.bold = false

    self.contents.font.color = Color.new(255, 255, 255, 255)

    self.contents.draw_text(x, y, 32, 32, $data_system.words.hp)

    if width - 32 >= 108

      hp_x = x + width - 108

      flag = true

    elsif width - 32 >= 48

      hp_x = x + width - 48

      flag = false

    end

    self.contents.font.color = actor.hp == 0 ? knockout_color :

      actor.hp <= actor.maxhp / 4 ? crisis_color : normal_color

    self.contents.draw_text(hp_x, y, 48, 32, actor.hp.to_s, 2)

    if flag

      self.contents.font.color = normal_color

      self.contents.draw_text(hp_x + 48, y, 12, 32, "/", 1)

      self.contents.draw_text(hp_x + 60, y, 48, 32, actor.maxhp.to_s)

    end

  end

  

  # SP Text Options

  def draw_actor_sp(actor, x, y, width = 144)

    self.contents.font.name = "Arial"

    self.contents.font.size = 22

    self.contents.font.italic = false

    self.contents.font.bold = false

    self.contents.font.color = Color.new(255, 255, 255, 255)

    self.contents.draw_text(x, y, 32, 32, $data_system.words.sp)

    if width - 32 >= 108

      sp_x = x + width - 108

      flag = true

    elsif width - 32 >= 48

      sp_x = x + width - 48

      flag = false

    end

    self.contents.font.color = actor.sp == 0 ? knockout_color :

      actor.sp <= actor.maxsp / 4 ? crisis_color : normal_color

    self.contents.draw_text(sp_x, y, 48, 32, actor.sp.to_s, 2)

    if flag

      self.contents.font.color = normal_color

      self.contents.draw_text(sp_x + 48, y, 12, 32, "/", 1)

      self.contents.draw_text(sp_x + 60, y, 48, 32, actor.maxsp.to_s)

    end

  end

  

  # Item Text Options

  def draw_item_name(item, x, y)

    if item == nil

      return

    end

    bitmap = RPG::Cache.icon(item.icon_name)

    self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24))

    self.contents.font.name = "Arial"

    self.contents.font.size = 22

    self.contents.font.italic = false

    self.contents.font.bold = false

    self.contents.font.color = Color.new(255, 255, 255, 255)

    self.contents.draw_text(x + 28, y, 212, 32, item.name)

  end  

end

###############################################################################

class Window_Command < Window_Selectable

  # Command Window Text Options

  def draw_item(index, color)

    self.contents.font.color = Color.new(255, 255, 255, 255)

    rect = Rect.new(4, 32 * index, self.contents.width - 8, 32)

    self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))

    self.contents.font.name = "Arial"

    self.contents.font.italic = false

    self.contents.font.bold = false

    self.contents.font.size = 22

    self.contents.draw_text(rect, @commands[index])

  end

end

###############################################################################

class Window_Message < Window_Selectable

  # Message Text Options

  def refresh

    self.contents.clear

    self.contents.font.name = "Arial"

    self.contents.font.italic = false

    self.contents.font.bold = false

    self.contents.font.size = 22

    self.contents.font.color = Color.new(255, 255, 255, 255)

    x = y = 0

    @cursor_width = 0

    # Indent if choice

    if $game_temp.choice_start == 0

      x = 8

    end

    # If waiting for a message to be displayed

    if $game_temp.message_text != nil

      text = $game_temp.message_text

      # Control text processing

      begin

        last_text = text.clone

        text.gsub!(/\\[Vv]\[([0-9]+)\]/) { $game_variables[$1.to_i] }

      end until text == last_text

      text.gsub!(/\\[Nn]\[([0-9]+)\]/) do

        $game_actors[$1.to_i] != nil ? $game_actors[$1.to_i].name : ""

      end

      # Change "\\\\" to "\000" for convenience

      text.gsub!(/\\\\/) { "\000" }

      # Change "\\C" to "\001" and "\\G" to "\002"

      text.gsub!(/\\[Cc]\[([0-9]+)\]/) { "\001[#{$1}]" }

      text.gsub!(/\\[Gg]/) { "\002" }

      # Get 1 text character in c (loop until unable to get text)

      while ((c = text.slice!(/./m)) != nil)

        # If \\

        if c == "\000"

          # Return to original text

          c = "\\"

        end

        # If \C[n]

        if c == "\001"

          # Change text color

          text.sub!(/\[([0-9]+)\]/, "")

          color = $1.to_i

          if color >= 0 and color <= 7

            self.contents.font.color = text_color(color)

          end

          # go to next text

          next

        end

        # If \G

        if c == "\002"

          # Make gold window

          if @gold_window == nil

            @gold_window = Window_Gold.new

            @gold_window.x = 560 - @gold_window.width

            if $game_temp.in_battle

              @gold_window.y = 192

            else

              @gold_window.y = self.y >= 128 ? 32 : 384

            end

            @gold_window.opacity = self.opacity

            @gold_window.back_opacity = self.back_opacity

          end

          # go to next text

          next

        end

        # If new line text

        if c == "\n"

          # Update cursor width if choice

          if y >= $game_temp.choice_start

            @cursor_width = [@cursor_width, x].max

          end

          # Add 1 to y

          y += 1

          x = 0

          # Indent if choice

          if y >= $game_temp.choice_start

            x = 8

          end

          # go to next text

          next

        end

        # Draw text

        self.contents.original_draw_text(4 + x, 32 * y, 40, 32, c)

        # Add x to drawn text width

        x += self.contents.text_size(c).width

      end

    end

    # If choice

    if $game_temp.choice_max > 0

      @item_max = $game_temp.choice_max

      self.active = true

      self.index = 0

    end

    # If number input

    if $game_temp.num_input_variable_id > 0

      digits_max = $game_temp.num_input_digits_max

      number = $game_variables[$game_temp.num_input_variable_id]

      @input_number_window = Window_InputNumber.new(digits_max)

      @input_number_window.number = number

      @input_number_window.x = self.x + 8

      @input_number_window.y = self.y + $game_temp.num_input_start * 32

    end

  end

end

###############################################################################

class Window_Gold < Window_Base

 

  def initialize

    super(0, 0, 280, 54)

    self.contents = Bitmap.new(width - 32, height - 32)

    refresh

  end

 

  def refresh

    self.contents.clear

    cx = contents.text_size($data_system.words.gold).width

    self.contents.font.name = "Arial"

    self.contents.font.italic = false

    self.contents.font.bold = false

    self.contents.font.size = 22

    self.contents.font.color = Color.new(255, 255, 255, 255)

    # Add "$" Text

    self.contents.draw_text(- 80-cx, - 6, 124+cx, 32, "$", 2)    

    self.contents.font.name = "Arial"

    self.contents.font.italic = false

    self.contents.font.bold = false

    self.contents.font.size = 22

    self.contents.font.color = Color.new(255, 255, 255, 255)

    self.contents.draw_text(4, - 6, 180-cx-2, 32, $game_party.gold.to_s, 2)

    self.contents.font.name = "Arial"

    self.contents.font.italic = false

    self.contents.font.bold = false

    self.contents.font.size = 22

    self.contents.font.color = Color.new(255, 255, 255, 255)

    self.contents.draw_text(120-cx, - 6, 124+cx, 32, "GOLD", 2)

  end

end

############################## END ############################################

# CUSTOM CLASS #

class Window_Character < Window_Base

  # Initialize Window

  def initialize

    super(0, 0, 280, 110)

    self.contents = Bitmap.new(width - 32, height - 32)

    refresh

    self.active = false

  end  

  # Refresh: Set Array @ Party Max = 1 Member

  def refresh

      @item_max = $game_party.actors.size

      i = 0

      x = 64

      y = i * 116

      actor = $game_party.actors[i]

      draw_actor_graphic(actor, x - 40, y + 60)

      draw_actor_name(actor, x + 60, y)

      

      # Name Text Options

    self.contents.font.name = "Arial"

    self.contents.font.italic = false

    self.contents.font.bold = false

    self.contents.font.size = 22

    self.contents.font.color = Color.new(255, 255, 255, 255)

      self.contents.draw_text(x - 10 , y, 300, 32, "Name:")

      

      @actor = actor      

      @data = []

      @data.push($data_weapons[@actor.weapon_id])

      @item_max = @data.size

      draw_item_name(@data[0], 80, 40)

  end

end

###############################################################################

class Window_PlayTime < Window_Base

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

  # * Object Initialization

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

  def initialize

    super(0, 0, 280, 96)

    self.contents = Bitmap.new(width - 32, height - 32)

    refresh

  end

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

  # * Refresh

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

  def refresh

    self.contents.clear

    self.contents.font.name = "Arial"

    self.contents.font.italic = false

    self.contents.font.bold = false

    self.contents.font.size = 22

    self.contents.font.color = Color.new(255, 255, 255, 255)

    self.contents.draw_text(4, 0, 120, 32, "Play Time")

    @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.name = "Arial"

    self.contents.font.italic = false

    self.contents.font.bold = false

    self.contents.font.size = 22

    self.contents.font.color = Color.new(255, 255, 255, 255)    

    self.contents.draw_text(4, 32, 120, 32, text, 2)

  end

end

###############################################################################

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

# Game_Party

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

class Game_Party

  # Change Array = (1) Actor

  def add_actor(actor_id)

    # Get actor

    actor = $game_actors[actor_id]

    # If the party has less than 1 members and this actor is not in the party

    if @actors.size < 1 and not @actors.include?(actor)

      # Add actor

      @actors.push(actor)

      # Refresh player

      $game_player.refresh

    end

  end

end

###############################################################################

#___________________________   END SCRIPT   __________________________________#

###############################################################################


First Impressions?
 
I wanted to show the little bit more of what I was able to get done with this yesterday; share some ideas for where I'm looking for it to end up; and perhaps get some creative feedback on it. I won't be able to work on it today, unfortunately but I wanted to share a few of these screenshots:

http://img85.imageshack.us/img85/5808/screen012uh.png[/IMG]

Here I wanted to show the new layout. The character's condition now appears just to the right of the "Level" text when a state is in effect.
The command window is now condensed and while I personally feel it's stylish and prefer it the way it is, some may find it a little too empty; I may have to make it so there are two columns there instead of just one.
[Something like this:]
Item Skill
-=scroll down to second row=-
Equip Status
-=scroll down to third and final row=-
Save End
There will also now be dedicated sub-menus - as you can see with the work started on the Item screen just to the right of the main menu (all sub-menus will open on the empty half of the main overlay).
For certain ones - such as the "equip" and "skill" sub-menus for instance - the two windows where the character graphic/name and stats are located will disappear and be replaced by identically proportioned windows displaying the relevant info, allowing accessability to everything from one screen/scene [for example, under "equip" it will show the currently equipped weapons in the window where "Level", "HP", etc. is displayed, the character's ratings ("atk" and such) in the window at the top].
In the Gold Window, the "$" sign will be moved right, and this RTP icon will display to the left of it: http://img100.imageshack.us/img100/5633 ... m013sg.png[/img]

I also want this to be a full CMS for more than just one party member. It will likely use the LEFT and RIGHT arrow keys to cycle through the characters and update the corresponding windows accordingly.

Anyhow, I don't want this to be too long a post like the last one, so I'll just skim through the other minor things...

These next two are just showing how I'd like the Menu to update when you switch between different characters:

http://img155.imageshack.us/img155/9673/screen066kd.png[/img]

http://img443.imageshack.us/img443/4994/screen045dx.png[/img]

The last two aren't that important, but it's something I wanted to include for the message text font options:

http://img108.imageshack.us/img108/2127/screen027vh.png[/img]

http://img216.imageshack.us/img216/1979/screen059rn.png[/img]

Well, that's all I have for now. Hopefully I can get back to work on it tomorrow. So, in looking at the way it was set up before, does anyone think it will look/work at least a little bit better this way than it did initially?
 
yaaaaaaaaaayyyyyyy posttttt!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
^_^
can't wait for backups...btw this is an edit so >.<
 

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