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.

Requesting a Visual Equipment Script.

I'm currently looking for a working Visual Equipment script for RMXP. I've only seen one topic on it, but the link is dead :cry: .

-Example of the Script-
Basically Visual Equipment is a script that assigns certain character sheets to items, so when the user equips that specific item, the character sheet appears upon the character to show what the character has equipped.
Test.png


If anyone has a Visual Equipment script they can upload I would be very grateful, otherwise a link to a demo, or even the script itself is much appreciated.
 
Well this is a Visual Equipment script I managed to find, it was ripped out of the NowaySkill global VE demo, I think its partially based on Me(tm)'s code so credit him and the guy in the header I guess, here is the code.

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

# â–  Visual Equipment

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

# Geso Chisku

# Version 2

# 14.02.06

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

# FEATURES

# - Shows the player equipment on the map

# - Shows NPC equipment on the map events

# - Compatible with Caterpillar and SBABS

# - Shows the equipment in windows

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

# FUTURE WORK

# - Compatibility with Guillaume multi-equip

# - Compatibility with Netplay

# - Compatibility with different size graphics

# - Compatibility with shadows/reflection (that is gonna be hard)

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

# BUGS

# - Don't work with shadow/reflection script

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

# MAKING YOUR OWN GRAPHICS

# - All graphics must be in 128 x 192 size

# - For main character graphic, make only the hair and the eyes

# - Use the template to see if the equips fits well

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

# SETTING UP YOUR GAME

# To set up the default body templates, search for "DEFAULT_ACTOR_BODY"

#

# To add a graphic to a equipment, search for "def equip_character"

#

# To add visual equipment to a event, add comments in this format:

#  Comment: Visual Equipment

#  Comment: Body [charset] [hue]

#  Comment: Armor [charset] [hue]

#  Comment: Helmet [charset] [hue]

#  Comment: Weapon [charset] [hue]

#  Comment: Accessory [charset] [hue]

#  Comment: Shield [charset] [hue]

# Replace [charset] with the filename of the equipment or with none

# and [hue] with the graphic hue, the default hue is 0

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

 

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

  # ** Game_Actor

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

  class Game_Actor < Game_Battler

    attr_accessor :body

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

    DEFAULT_ACTOR_BODY = ['body-male', 'body-male', 'body-male', 'body-male']

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

    alias geso_visual_actor_init initialize

    def initialize(actor_id)

      geso_visual_actor_init(actor_id)

      @body = DEFAULT_ACTOR_BODY[actor_id]

    end

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

    def equip_char_array

      equips = []

      equips.push([@body, 0])

      item = equip_character(0, actor_equip_id(0, self))

      equips.push(item) unless item == false

      equips.push([@character_name, @character_hue])

      for i in 1..4

        item = equip_character(i, actor_equip_id(i, self))

        equips.push(item) unless item == false

      end

      return equips

    end

  end

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

  # ** Game_Event

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

  class Game_Event < Game_Character

    attr_reader :page

  end

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

  # Determines the order the equips are draw

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

  def actor_equip_id(i, actor)

    case i

    when 0 # Body

      return actor.armor3_id

    when 1 # Helmet

      return actor.armor2_id

    when 2 # Weapon

      return actor.weapon_id

    when 3 # Accessory

      return actor.armor4_id

    when 4 # Shield

      return actor.armor1_id

    end

  end

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

  # ** Sprite_Character

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

  class Sprite_Character < RPG::Sprite

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

    alias geso_visual_equip_sprite_char_init initialize

    def initialize(viewport, character = nil)

      if character.is_a?(Game_Player)

        @actor = $game_party.actors[0]

      elsif SDK.state('SBABS') == true and character.is_a?(Game_Ally)

        @actor = $game_party.actors[character.actor_id]

      elsif SDK.state('Caterpillar') == true and character.is_a?(Game_Party_Actor)

        @actor = character.actor

      else

        @actor = nil

      end

      @equips_id = [0, 0, 0, 0, 0]

      geso_visual_equip_sprite_char_init(viewport, character)

    end

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

    def equip_changed?

      if SDK.state('Caterpillar') == true

        if @character.is_a?(Game_Party_Actor)

          if @character.actor != @actor

            @actor = @character.actor

            return true

          end

        end

      end

      if SDK.state('SBABS') == true

        if @character.is_a?(Game_Ally)

          if $game_party.actors[@character.actor_id] != @actor

            return true

          end

        end

      end

      if @character.is_a?(Game_Player)

        if $game_party.actors[0] != @actor

          @actor = $game_party.actors[0]

          return true

        end

      elsif @character.is_a?(Game_Event)

        if @page != @character.page

          @page = @character.page

          return true

        end

        return false

      end

      if @actor == nil

        return false

      end

      for i in 0..4

        return true if @equips_id[i] != actor_equip_id(i, @actor)

      end

      return false

    end

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

    def adv_update

      @character_name = ''

      update

    end

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

    def update

      # If character is a event

      super

      # If tile ID, file name, hue or equipment are different from current ones

      if @tile_id != @character.tile_id or

         @character_name != @character.character_name or

         @character_hue != @character.character_hue or

         equip_changed?

        # Remember tile ID, file name and hue

        @tile_id = @character.tile_id

        @character_name = @character.character_name

        @character_hue = @character.character_hue

        # If tile ID value is valid

        if @tile_id >= 384

          self.bitmap = RPG::Cache.tile($game_map.tileset_name,

            @tile_id, @character.character_hue)

          self.src_rect.set(0, 0, 32, 32)

          self.ox = 16

          self.oy = 32

        # If tile ID value is invalid

        else

          equips = []

          # If handling a event

          if @character.is_a?(Game_Event) == true

            # Check for comment input

            parameters = SDK.event_comment_input(@character, 6, 'Visual Equipment')

            if parameters.nil?

              equips.push([@character_name, @character_hue])

            else

              for i in 0..5

                item = parameters[i].split

                hue = item.size > 2 ? item[2] : 0

                equips.push([item[1], hue]) if item[1] != 'none'

                if i == 1

                  equips.push([@character_name, @character_hue])

                end

              end

            end

          # If handling the player

          elsif @actor != nil

            equips = @actor.equip_char_array

          end

          # Dispose old bitmap

          self.bitmap.dispose unless self.bitmap == nil

          # Draws the character bitmap

          bmp = RPG::Cache.character(@character_name, @character_hue)

          self.bitmap = Bitmap.new(bmp.width, bmp.height)

          src_rect = Rect.new(0, 0, bmp.width, bmp.height)

          # If character fits the size

          if equips.size > 0 and bmp.width == 128 and bmp.height == 192

            size = equips.size -1

            for i in 0..size

              next if equips[i] == false or equips[i][0] == false or equips[i][0] == nil

              bmp2 = RPG::Cache.character(equips[i][0], equips[i][1].to_i)

              self.bitmap.blt(0, 0, bmp2, src_rect, 255)

            end

          else

            src_rect = Rect.new(0, 0, bmp.width, bmp.height)

            self.bitmap.blt(0, 0, bmp, src_rect, 255)

          end

          @cw = bitmap.width / 4

          @ch = bitmap.height / 4

          self.ox = @cw / 2

          self.oy = @ch

        end

      end

      # Set visible situationw

      self.visible = (not @character.transparent)

      # If graphic is character

      if @tile_id == 0

        # Set rectangular transfer

        sx = @character.pattern * @cw

        sy = (@character.direction - 2) / 2 * @ch

        self.src_rect.set(sx, sy, @cw, @ch)

      end

      # Set sprite coordinates

      self.x = @character.screen_x

      self.y = @character.screen_y

      self.z = @character.screen_z(@ch)

      # Set opacity level, blend method, and bush depth

      self.opacity = @character.opacity

      self.blend_type = @character.blend_type

      self.bush_depth = @character.bush_depth

      # Animation

      if @character.animation_id != 0

        animation = $data_animations[@character.animation_id]

        animation(animation, true)

        @character.animation_id = 0

      end

    end

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

  end

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

  # ** Window_Base

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

  class Window_Base < Window

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

    def draw_actor_graphic(actor, x, y)

      bmp = RPG::Cache.character(actor.character_name, actor.character_hue)

      bitmap = Bitmap.new(bmp.width, bmp.height)

      src_rect = Rect.new(0, 0, bmp.width, bmp.height)

      

      # Setup actor equipment

      equips = actor.equip_char_array

      

      # If character fits the size

      if equips.size > 0 and bmp.width == 128 and bmp.height == 192

        size = equips.size -1

        for i in 0..size

          next if equips[i] == false or equips[i][0] == false or equips[i][0] == nil

          bmp2 = RPG::Cache.character(equips[i][0], equips[i][1].to_i)

          bitmap.blt(0, 0, bmp2, src_rect, 255)

        end

      else

        bitmap.blt(0, 0, bmp, src_rect, 255)

      end

          

      cw = bitmap.width / 4

      ch = bitmap.height / 4

      src_rect = Rect.new(0, 0, cw, ch)

      self.contents.blt(x - cw / 2, y - ch, bitmap, src_rect)

    end

  end

And the configuration part of the script, make sure this is below the other script.

Code:
  #--------------------------------------------------------------------------

  # This method returns the character name based on equipment type and id

  # To add a item to the list, add the following line:

  #   return [char_name, hue] if id == item_id

  # To add the charset 'equip-helmet', hue 0, for item 8 add the following

  #   return ['equip-helmet', 0] if id == 8

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

  def equip_character(type, id)

    if type == 2

      # WEAPONS GRAPHICS

      # Add your weapon lines here

      return ['equip\\weapon-sword01', 0] if id == 1

    else

      # ARMORS, HELMETS, SHIELDS, ACCESSORIES GRAPHICS

      # Add your armor lines here

      return ['equip\\body-armor02', 0] if id == 2

      return ['equip\\head-hat01', 0] if id == 3

       

    end

    return false

  end

That should work like a charm, get back to me if it doesn't.
 

Scuff

Member

Does this work with Mr. Mo's SBABS?
If so, then why do i get this error: Spript 'Equipment' line 104: NoMethodError occurred undenfined method 'state' for SDK:Module
 

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