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.

Making a duplicate item scene ?

Jason

Awesome Bro

Hi,

So basically, I've got this idea in the works (Just need to know how to do this), where you collect Artifacts (Sorta the theme of the game), and on your menu, where the list is (Item, Skills, etc.), there's going to be an "Artifacts" choice, now, I know how to do this, but it's the next thing, how would I make a duplicate item scene ?

Basically I want it to be the $scene_item, but I'm not too sure if I can just copy the scene and rename it ? (Not on my RMXP PC at the mo so I'll have to check later, just asking beforehand)

Another question I'd like to know,

How do I show a variable inside a window ? Is it just: $game.variable_ 
 
What is an artifact? what parameters does it have? What is it used for?

You can copy Scene_Item, and call it Scene_Artifact. But you will still have to edit the scene, and probably create a copy of Window_Item, the lower window that lists the items. Otherwise, your new scene would just list items.

The first thing we need to do is figure out how to create the artifacts. (thus the questions above.) The easiest thing to do would be to create additional items, and just use some kind of indicator that it's a special type of item. (something in the item name, the icon, perhaps setting a ridiculous price like 99999). Another option would be to create a Structure class to hold the artifact items & their parameters. This gives more flexibility, but requires adding all of your artifact items in the script.

To show a variable in a window, you use the draw_text method from the Bitmap class. (Look at one of the Window_ classes for an example)

self.contents.draw_text(x, y, width, height, $game_variables[n], alignment)

Be Well
 

Jason

Awesome Bro

Well yeah, the Artifacts are pretty much items, but I don't want them in the same scene/window as the Items, thats why I intend to make a whole new scene for them,

But yeah, what you've told me seems easy enough, I'll give it a shot.

Cheers.
 

Jason

Awesome Bro

Okay I've been at it for almost an hour and nothing is going as planned, is there a way I can make it so if an item is marked with say, an asterix (*), it'll go into this menu, or if not, it'll go into the Item menu ?

Cheers.
 
Yes, but then you have to parse the name string to determine if it's an artifact. I chose to use the price.
Here is Scene_Artifact & Window_Artifact (copies of *_Item), with all changes marked with ##

Code:
#==============================================================================

# ** Window_Item

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

#  This window displays items in possession on the item and battle screens.

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

 

class Window_Artifact < Window_Selectable   ##

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

  # * Object Initialization

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

  def initialize

    super(0, 64, 640, 352)

    @column_max = 2

    refresh

    self.index = 0

    # If in battle, move window to center of screen

    # and make it semi-transparent

    if $game_temp.in_battle

      self.y = 64

      self.height = 256

      self.back_opacity = 160

    end

  end

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

  # * Get Item

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

  def item

    return @data[self.index]

  end

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

  # * Refresh

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

  def refresh

    if self.contents != nil

      self.contents.dispose

      self.contents = nil

    end

    @data = []

    # Add item

    for i in 1...$data_items.size

      if $game_party.item_number(i) > 0

        if $data_items[i].price == 99999   ##

          @data.push($data_items[i])

        end                                ##

      end

    end

    # Also add weapons and items if outside of battle

##    unless $game_temp.in_battle

##      for i in 1...$data_weapons.size

##        if $game_party.weapon_number(i) > 0

##          @data.push($data_weapons[i])

##        end

##      end

##      for i in 1...$data_armors.size

##        if $game_party.armor_number(i) > 0

##          @data.push($data_armors[i])

##        end

##      end

##    end

    # If item count is not 0, make a bit map and draw all items

    @item_max = @data.size

    if @item_max > 0

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

      for i in 0...@item_max

        draw_item(i)

      end

    end

  end

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

  # * Draw Item

  #     index : item number

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

  def draw_item(index)

    item = @data[index]

    case item

    when RPG::Item

      number = $game_party.item_number(item.id)

##    when RPG::Weapon

##      number = $game_party.weapon_number(item.id)

##    when RPG::Armor

##      number = $game_party.armor_number(item.id)

    end

    if item.is_a?(RPG::Item) and

       $game_party.item_can_use?(item.id)

      self.contents.font.color = normal_color

    else

      self.contents.font.color = disabled_color

    end

    x = 4 + index % 2 * (288 + 32)

    y = index / 2 * 32

    rect = Rect.new(x, y, self.width / @column_max - 32, 32)

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

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

    opacity = self.contents.font.color == normal_color ? 255 : 128

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

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

    self.contents.draw_text(x + 240, y, 16, 32, ":", 1)

    self.contents.draw_text(x + 256, y, 24, 32, number.to_s, 2)

  end

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

  # * Help Text Update

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

  def update_help

    @help_window.set_text(self.item == nil ? "" : self.item.description)

  end

end

 
Code:
 

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

# ** Window_Artifact_Count

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

#  This window shows skill and item explanations along with actor status.

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

 

class Window_Artifact_Count < Window_Base

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

  # * Object Initialization

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

  def initialize

    super(0, 416, 640, 64)

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

    refresh

  end

  def refresh

      # draw text

      self.contents.clear

      self.contents.font.color = normal_color

      self.contents.draw_text(4, 0, self.width - 40, 32, "Artifacts:")

      text = $game_variables[1].to_s + "/" + $game_variables[2].to_s

      self.contents.draw_text(4, 0, self.width - 40, 32, text, 2)

  end

end

 
Code:
#==============================================================================

# ** Scene_Item

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

#  This class performs item screen processing.

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

 

class Scene_Artifact  ##

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

  # * Main Processing

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

  def main

    # Make help window, item window

    @help_window = Window_Help.new

    @item_window = Window_Artifact.new    ##

    @count_window = Window_Artifact_Count.new    ##

    # Associate help window

    @item_window.help_window = @help_window

    # Make target window (set to invisible / inactive)

    @target_window = Window_Target.new

    @target_window.visible = false

    @target_window.active = false

    # 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

    @help_window.dispose

    @item_window.dispose

    @target_window.dispose

    @count_window.dispose

  end

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

  # * Frame Update

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

  def update

    # Update windows

    @help_window.update

    @item_window.update

    @target_window.update

    # If item window is active: call update_item

    if @item_window.active

      update_item

      return

    end

    # If target window is active: call update_target

    if @target_window.active

      update_target

      return

    end

  end

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

  # * Frame Update (when item window is active)

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

  def update_item

    # If B button was pressed

    if Input.trigger?(Input::B)

      # Play cancel SE

      $game_system.se_play($data_system.cancel_se)

      # Switch to menu screen

      $scene = Scene_Menu.new(0)

      return

    end

    # If C button was pressed

    if Input.trigger?(Input::C)

      # Get currently selected data on the item window

      @item = @item_window.item

      # If not a use item

      unless @item.is_a?(RPG::Item)

        # Play buzzer SE

        $game_system.se_play($data_system.buzzer_se)

        return

      end

      # If it can't be used

      unless $game_party.item_can_use?(@item.id)

        # Play buzzer SE

        $game_system.se_play($data_system.buzzer_se)

        return

      end

      # Play decision SE

      $game_system.se_play($data_system.decision_se)

      # If effect scope is an ally

      if @item.scope >= 3

        # Activate target window

        @item_window.active = false

        @target_window.x = (@item_window.index + 1) % 2 * 304

        @target_window.visible = true

        @target_window.active = true

        # Set cursor position to effect scope (single / all)

        if @item.scope == 4 || @item.scope == 6

          @target_window.index = -1

        else

          @target_window.index = 0

        end

      # If effect scope is other than an ally

      else

        # If command event ID is valid

        if @item.common_event_id > 0

          # Command event call reservation

          $game_temp.common_event_id = @item.common_event_id

          # Play item use SE

          $game_system.se_play(@item.menu_se)

          # If consumable

          if @item.consumable

            # Decrease used items by 1

            $game_party.lose_item(@item.id, 1)

            # Draw item window item

            @item_window.draw_item(@item_window.index)

          end

          # Switch to map screen

          $scene = Scene_Map.new

          return

        end

      end

      return

    end

  end

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

  # * Frame Update (when target window is active)

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

  def update_target

    # If B button was pressed

    if Input.trigger?(Input::B)

      # Play cancel SE

      $game_system.se_play($data_system.cancel_se)

      # If unable to use because items ran out

      unless $game_party.item_can_use?(@item.id)

        # Remake item window contents

        @item_window.refresh

      end

      # Erase target window

      @item_window.active = true

      @target_window.visible = false

      @target_window.active = false

      return

    end

    # If C button was pressed

    if Input.trigger?(Input::C)

      # If items are used up

      if $game_party.item_number(@item.id) == 0

        # Play buzzer SE

        $game_system.se_play($data_system.buzzer_se)

        return

      end

      # If target is all

      if @target_window.index == -1

        # Apply item effects to entire party

        used = false

        for i in $game_party.actors

          used |= i.item_effect(@item)

        end

      end

      # If single target

      if @target_window.index >= 0

        # Apply item use effects to target actor

        target = $game_party.actors[@target_window.index]

        used = target.item_effect(@item)

      end

      # If an item was used

      if used

        # Play item use SE

        $game_system.se_play(@item.menu_se)

        # If consumable

        if @item.consumable

          # Decrease used items by 1

          $game_party.lose_item(@item.id, 1)

          # Redraw item window item

          @item_window.draw_item(@item_window.index)

        end

        # Remake target window contents

        @target_window.refresh

        # If all party members are dead

        if $game_party.all_dead?

          # Switch to game over screen

          $scene = Scene_Gameover.new

          return

        end

        # If common event ID is valid

        if @item.common_event_id > 0

          # Common event call reservation

          $game_temp.common_event_id = @item.common_event_id

          # Switch to map screen

          $scene = Scene_Map.new

          return

        end

      end

      # If item wasn't used

      unless used

        # Play buzzer SE

        $game_system.se_play($data_system.buzzer_se)

      end

      return

    end

  end

end

 

Now, you still need to make a similar change to the refresh method of Window_Item to display only regular items.

Code:
 

    # Add item

    for i in 1...$data_items.size

      if $game_party.item_number(i) > 0

        if $data_items[i].price != 99999   ##

          @data.push($data_items[i])

        end                                ##

      end

    end

 

Now you can just add artifact items to the item list, and set the price at 99999
 

Jason

Awesome Bro

It's working pretty much how I want it, except I can still see the Artifacts in the Item menu, any fix for this at all ?

But other than that it's working fine, lol

Edit---

Okay this is something new, I've been trying to make a window to go under the Item list (In the Artifact scene) that displays how many Artifacts you've collected, I don't get any errors with it, however, it can't be seen when I testplay the game (Yes I've updated scene_artifact), I'd paste the code but I scrapped it and restarted,


Sorry for being a bother, Brew, but my scripting experience isn't exactly the best.
 
That was the 3rd script box above. Add just the 2 lines with my comment ## to Window_Item.

Notice this one the comparison operator is != (not equal to), rather than == (equal to) like in Window_Artifact

also, make sure you set the price of your artifacts to 99999
 

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