We need Help. V-EQ

Discussion in 'RGSS Script Requests' started by HGS, Jan 2, 2019.

    Tags:
  1. HGS

    HGS Villager Member

    Messages:
    9
    Likes Received:
    0
    First Language:
    Poland
    Hello
    I am looking for a Visual Equipment script for RPG Maker XP. Hands, tunic, armor, helmet, shield, weapon.
    A script that applies layers depending on the item switch and variables
    I have this script, but I can not use it because it is not my property. So I'm looking for an alternative / help.

    The script must overlap the layers in the following order: Tunic => Armor => Helmet => Hands => Shield => Weapons In addition, the game has a switch responsible for the animation of the hit, so the script should take this into account. I urgently need help writing a script in RGSS.

    The next thing is a minor patch of the mouse. It's about editing her options. For example, when you hover over an event, you must display an image.

    The game is nearing completion, but I can not publish it until I change the scripts. And getting along with the owners does not make sense.


    [​IMG]
     
    Last edited: Jan 3, 2019
    #1
  2. DerVVulfman

    DerVVulfman Resident Werewolf Veteran

    Messages:
    314
    Likes Received:
    150
    First Language:
    English
    Primarily Uses:
    RMXP
    This might seem like an odd question, but:

    Are you using my Lycan ABS system?
     
    #2
  3. HGS

    HGS Villager Member

    Messages:
    9
    Likes Received:
    0
    First Language:
    Poland
    I have own ABS on events.
    All items are variables.
    My game does not use the item database.
     
    Last edited: Jan 6, 2019
    #3
  4. DerVVulfman

    DerVVulfman Resident Werewolf Veteran

    Messages:
    314
    Likes Received:
    150
    First Language:
    English
    Primarily Uses:
    RMXP
    Hrm.... Well, try this anyway:

    Code:
    #==============================================================================
    # ** The Lycan ABS Paperdoll System
    #------------------------------------------------------------------------------
    #    version 2.0
    #    by DerVVulfman
    #    08-21-2016
    #    RGSS / RPGMaker XP (Lycan ABS Version 8.9+)
    #------------------------------------------------------------------------------
    #  
    #  INTRODUCTION:
    #  =============
    #
    #  This system is a new add-on for 'The Lycan ABS' that lets  you display the
    #  weapons and armor  your actors are equipped on their person.    This means
    #  that if you are equipping  one of your actors  with a robe,  the robe will
    #  be drawn onto the actor once equipped,  and if a suitable  robe graphic is
    #  available.
    #  
    #  The system is based  on Me(tm)'s Visual Equipment,  but heavily altered to
    #  work with The Lycan ABS. It is the second script that I am aware that lets
    #  you have a paperdoll system for an RPGMaker XP Action Battle System that I
    #  have worked on.   And to my knowledge, only Near Fantastica's  Squad Based
    #  Action Battle System may have been the only other system with one before.
    #
    #  In addition, the system was designed to work with DerVVulfman's MultiSlots
    #  system,  so you can apply additional graphics for any new slots you choose
    #  to add.
    #  
    #------------------------------------------------------------------------------
    #  
    #  INSTALLATION:
    #  =============
    #
    #  This script  requires  the use of  Frank's MultiPose Charactersets for the
    #  Lycan ABS,  which has to be pasted below The Lycan ABS.   This script then
    #  then needs to be put below both.   It may be placed  either above or below
    #  DerVVulfman's Multi-Slots system if in use.
    #  
    #  It may interfere with other scripts that alter Game_Character, Game_Player
    #  Sprite_Character and Window_SaveFile.  Placing this script  'above'  other
    #  scripts may solve any problems.  Script Placement sometimes solves compat-
    #  ability issues.
    #
    #------------------------------------------------------------------------------
    #
    #  CONFIGURATION:
    #  ==============
    #
    #  One of the main features of this script is the configuration section.  The
    #  system allows you to define the order in whicn your sprites are drawn over
    #  the actors, which is different than that of other paperdoll scripts.
    #
    #  CACHE DIRECTORY:  This is where you define the name of a subfolder within
    #                    your project's Graphics folder (like your Charactersets
    #                    folder).   This way,  you may keep  all your  paperdoll
    #                    sprites separate from all your other charactersets. You
    #                    may even create subfolders within this one.  Subfolders
    #                    such as Paperdoll/Armors may thus be created. And these
    #                    subfolders will be properly cached,  even if you create
    #                    an encrypted project.
    #
    #
    #  CONSTANT SLOTS:   The constant slots are merely constants  you create and
    #                    name based on the equipment slots in your game's equip-
    #                    ment menu. Using the default menu as a model, you would
    #                    have the following constants:
    #
    #                       WEAPON      = 1 # Slot for the Weapon
    #                       SHIELD      = 2 # Slot for the Shield
    #                       HELMET      = 3 # Slot for the Helmet
    #                       ARMOR       = 4 # Slot for the Armor
    #                       ACCESSORY   = 5 # Slot for the Accessory
    #
    #                    The values of your contants  reflect the number of your
    #                    equipment slots.   Since the Weapon  tends to always be
    #                    your first slot, it is set in the above example as '1'.
    #                    The names of these contants may be different within the
    #                    demo as the demo is using MultiSlots, and has two addi-
    #                    tional slots in use.
    #
    #
    #  SLOT ORDER STYLE: Unlike other systems, you can define the order that the
    #                    graphics are drawn, and this array is where it is done.
    #                    Not only that,  this system is unique  in that  you can
    #                    change the  display order  of the graphics  as they are
    #                    drawn based  on what direction your character sprite is
    #                    facing, whether you use  4 directional or 8 directional
    #                    sprites.  It is by use of the ORDER_STYLE set of arrays
    #                    in which you can accomplish this.
    #
    #                    You will need to make as many ORDER_STYLE arrays as you
    #                    have directions,  and each of these arrays is tied to a
    #                    valid direction by it's key, much like this:
    #                            ORDER_STYLE[6] = ........
    #                    This ORDER_STYLE array will be used  when the sprite is
    #                    facing the right (aka, direction 6).   Other valid keys
    #                    are 2, 4 and 8.  If you use 8 directional sprites, then
    #                    you also have 1, 3, 7 and 9 as well.
    #                   
    #                    After that,  merely fill each array  with the names  of
    #                    the constants in the order they will be drawn.   So the
    #                    first drawn graphic will be first within the array, and
    #                    the last drawn graphic will be last in the array.  And,
    #                    using the default system as a model, you'd have this:
    #
    #                    ORDER_STYLE[8] = [ARMOR,HELMET,ACCESSORY,SHIELD,WEAPON]
    #
    #                    When this is processed  the armor sprite will be drawn,
    #                    and all other sprites drawn overtop.  At the end of it,
    #                    the weapon is drawn last,  showing overtop of the armor
    #                    and everything else.
    #
    #                    You may wonder: "Why have multiple ORDER_STYLE arrays?"
    #                    The answer is simple.  It lets the graphics be drawn in
    #                    proper order  and to prevent  accidental overlaps.  For
    #                    example,  if is usually expected that the shield is the
    #                    last thing rendered on a sprite.  But this doesn't take
    #                    clothing like robes or capes  into consideration.   The
    #                    sprite may be  facing the right  whereby the shield  is
    #                    the furthest from the player's  (yours)  viewpoint.  If
    #                    drawn last, it may overlap flowing capes.  But if it is
    #                    the first thing drawn,  you can have  graphics  such as
    #                    bulky armors or heavy swords drawn overtop.  The effect
    #                    is done and the sprite is properly rendered.
    #
    #
    #                            *   *   *   *   *
    #
    #  PAPERDOLL FILE LIST:
    #  ====================
    #
    #  The main feature of the paperdoll system  is to read the items an actor is
    #  equipped, and retrieve the filenames that are to be drawn.   The Paperdoll
    #  file list is defined  by use  of the EQUIP array  in the Paperdoll module.
    #
    #
    #  There are two things to consider with the EQUIP array objects,  the first
    #  is that it identifies the graphic  that is drawn over the sprite, and the
    #  second is that each array is keyed to a piece of equipment worn by way of
    #  a key value.
    #
    #  When you look at each EQUIP array object, it appears as EQUIP['keytext'].
    #  The key text is a text string that identifies  the actual piece of equip-
    #  ment that the sprite is using.   It also has options if there is a custom
    #  graphic available for a single actor, or if a weapon is being used in the
    #  the slot normally reserved for shield use (by way of Multi-Slots).
    #
    #  And insofar as the graphics, each EQUIP array holds an array that has two
    #  values, the first being the graphic image while the second is the graphic
    #  image's hue value.  The entertaining part of this is that you can use one
    #  graphic file  and adjust the file's hue to make many different objects of
    #  the same design.. just different colors.  As an example, the default list
    #  shows how to make various  'rings'  with different colors while using the
    #  same graphic image.
    #
    #  The basic array which in stored in the EQUIP array is:   ["FILENAME", HUE]
    #  Where filename is typically  the filename of your graphic,  and hue is the
    #  custom hue of the graphic when drawn.
    #
    #  Alternate EQUIP array entries:
    #
    #  You can use the following arrays entries for your system:
    #  *  ["FILENAME"]
    #     This grabs the file straight from the Paperdoll folder itself, and sets
    #     the hue to the default hue of '0'
    #  *  ["FILENAME", 0]
    #     This grabs the file straight from the Paperdoll folder itself, and sets
    #     the hue to the default hue of '0'
    #  *  ["Armors/FILENAME", 180]
    #     This grabs  the file from a  subfolder named 'Armors'  within the Paper
    #     doll folder, and changes the hue by a full 180 value.
    #  *  ["#Characters/FILENAME", HUE]
    #     This grabs  the file from the 'Characters' folder  instead of  from the
    #     Paperdoll folder.
    #
    #
    #
    #------------------------------------------------------------------------------
    #
    #  SCRIPT MODULES:
    #  ===============
    #  
    #  The following modules have been added, changed or rewritten.  Please take
    #  care when using with other systems that may be affected.
    #  
    #  Aliased modules:
    #  ----------------
    #  Game_System:         initialize
    #  Sprite_Character:    initialize
    #
    #  Rewritten modules:
    #  ------------------
    #  Sprite_Character:    update
    #  Window_Base:         draw_actor_graphic
    #  Window_SaveFile:     initialize, refresh
    #   
    #  New methods:
    #  ------------
    #  Paperdoll:           get_itemid, update_dir_4, update_dir_8
    #  RPG::Cache:          self.equipment, self.graphic
    #  Game_Actor:          get_equipments
    #  Sprite_Character:    changed_equipment?, update_equipment, update_tile
    #  Window_SaveFile:     refresh_characters
    #
    #
    #------------------------------------------------------------------------------
    #
    #  CREDITS AND THANKS:
    #  ===================
    #
    #  Many thanks to Me(tm) for the basis of the Paperdoll system.
    #  
    #==============================================================================
    
    
    
    
    
    #==============================================================================
    # ** Paperdoll
    #------------------------------------------------------------------------------
    #  This module handles the image name and equipment draw order processing
    #==============================================================================
    
    module Paperdoll
      #--------------------------------------------------------------------------
      EQUIP = {}  # Do not touch
      #--------------------------------------------------------------------------
     
     
      #==========================================================================
      #                     ** C O N F I G U R A T I O N **                     #
      #==========================================================================
     
      # CACHE DIRECTORY
      # ===============
      # The name of the sub-folder in your project's graphics folder that
      # can hold your paperdoll sprites.  
      #
        CACHE_DIRECTORY = "Paperdoll"
     
     
      # CONSTANT SLOTS
      # ==============
      # Add, remove or change the value of constants to match the slots
      # used in your system.
      #
        RIGHT       = 1 # Slot for the Right hand ... weapon
        LEFT        = 2 # Slot for the Left Hand  ... weapon or shield
        HELMET      = 3 # Slot for the Helmet
        ARMOR       = 4 # Slot for the Armor
        ACCESSORY   = 5 # Slot for the Accessory
        RING        = 6 # (added for MultiSlots) Slot for the custom Ring
        SHOES       = 7 # (added for MultiSlots) Slot for the custom Shoes
     
    
      # SLOT ORDER STYLE
      # ================
      # This array defines the order in which your graphics are drawn based
      # on the slots.  Easy to use, just fill in with the IDs of the contants
      # defined above.
        ORDER_STYLE = {}
      # ======================================================================
        ORDER_STYLE[2] = [ ARMOR, SHOES, RING, HELMET, ACCESSORY, LEFT, RIGHT]
        ORDER_STYLE[4] = [ ARMOR, SHOES, RING, HELMET, ACCESSORY, RIGHT, LEFT]
        ORDER_STYLE[6] = [ ARMOR, SHOES, RING, HELMET, ACCESSORY, LEFT, RIGHT]
        ORDER_STYLE[8] = [ ARMOR, SHOES, RING, HELMET, ACCESSORY, LEFT, RIGHT]
     
    
       
       
      #==========================================================================
      # * The Equipment Array
      #--------------------------------------------------------------------------
      #  The main focus on the system is to assign new graphics that are drawn
      #  with the native sprite.  These grapics are stored in the EQUIP array.
      #
      #  Each EQUIP array value has a key,  a string that contains two to four
      #  values. The first value is the reorder value, which is used to deter-
      #  mine the type of equipment is loaded (originally the equipment slot).
      #  The second value  is the equipment's ID value  in the database.   The
      #  third value  is an optional 3-digit value  (000, 001, 002, 999)  that
      #  is used to identify  a single actor.   This way,  you can create some
      #  unique graphics  that only work  for a single actor  while all others
      #  work for everyone else. And the last optional value is a text flag of
      #  'T' if the item is (1)in the shield slot  and (2)is actually a weapon
      #  that the character can use in his left hand... being ambidextrous. As
      #  stated,  these values create the key used to identify  what equipment
      #  uses what graphics.
      #
      #  EX:  EQUIP['2,3']
      #  Sets up the graphic for the Mythril Shield (Slot 2, item #3)
      #
      #  EX:  EQUIP['2,3,003,T']
      #  Because of the 'T' flag, this sets up the Steel Shield (Item #3)  to
      #  be used in his shield slot (slot 2), and only by Cyril (Acror #3).
      #
      #  The graphics applied  to the sprite  are defined within arrays . The
      #  first value in the array is the filename  or pathway/filename combi-
      #  nation drawn.   The second value is the graphic's adjusted hue.  The
      #  hue is an optional value, defaulted to '0'.
      #
      #  NOTE:  Using Hue on colored paperdoll graphics can allow developers
      #         to make various colored overlays  with fewer needed  graphic
      #         files.  Such would be having  blue, red and/or green colored
      #         shirts, using one file that was hue adjusted in the array.
      #
      #--------------------------------------------------------------------------
      #
      # Slot,Item (& Flags)     Pathway and File                    Hue
      # ====================    =================================   ===
      # Reorder #0: Slot 4 - Armor
      # Reorder #1: Slot 7 - Shoes (Extended by MultiSlots
      # Reorder #2: Slot 6 - Ring (Extended by MultiSlots)
        EQUIP['6,25']         = ["Ring_Str",                        0]    # Red
        EQUIP['6,26']         = ["Ring_Str",                        240]  # Dk Blue
        EQUIP['6,27']         = ["Ring_Str",                        135]  # Green
        EQUIP['6,28']         = ["Ring_Str",                        30]   # Orange
        EQUIP['6,29']         = ["Ring_Str",                        0]    # Red
        EQUIP['6,30']         = ["Ring_Str",                        180]  # Lt Blue
        EQUIP['6,31']         = ["Ring_Agi",                        0]    # Yellow
        EQUIP['6,32']         = ["Ring_Str",                        210]  # Blue
      # Reorder #3: Slot 3 - Helmet
      # Reorder #4: Slot 5 - Accessory
        EQUIP['5,37,002']     = ["Basil_Gloves",                    0]    # Basil
      # Reorder #5: Slot 2 - Shield/Left Hand
        EQUIP['2,35']         = ["Shield/Bill_custom - Shield",     0]
        EQUIP['2,34,T']       = ["#Characters/Bill_custom - Sword", 0]    #2handed?
      # Reorder #6: Slot 1 - Weapon/Right Hand
        EQUIP['1,34']         = ["#Characters/Bill_custom - Sword", 0]
        EQUIP['1,35']         = ["#Characters/Bill_custom - Bow",   0]
         
         
    end  
     
     
     
    #==============================================================================
    # ** Paperdoll
    #------------------------------------------------------------------------------
    #  This module handles the image name and equipment draw order processing
    #==============================================================================
    module Paperdoll
      #--------------------------------------------------------------------------
      # * Make method functions global
      #--------------------------------------------------------------------------
      module_function
      #--------------------------------------------------------------------------
      # * Get the graphic file
      #   type          : equipment type slot
      #   item_id       : id of the weapon or armor
      #   shield_weapon : id of the weapon or armor
      #   actor_id      : (optional) id of the actor... for scripters
      #--------------------------------------------------------------------------
      def get_file(type, item_id, shield_weapon=false, actor_id=0)
        equip_id  = item_id.to_i                      # Convert item to usable form
        key       = type.to_s + ',' + equip_id.to_s   # Obtain key from type/item
        text      = sprintf("%03d", actor_id)         # Get Extra key for actor
        key2      = key + ',' + text                  # Obtain 2nd key.
        if shield_weapon == true                      # If a shield weapon
          key2      = key2 + ',T'                     # Apply 'T' flag to actor key
          key       = key  + ',T'                     # Apply 'T' flag to norm key
        end
        if EQUIP.has_key?(key2)                       # If key present with actorID
          return EQUIP[key2]                          # Get actor-related graphic
        elsif EQUIP.has_key?(key)                     # If key present with actorID
          return EQUIP[key]                           # Get general graphic
        end
        return false                                  # Exit false if no valid data
      end   
      #--------------------------------------------------------------------------
      # * Set the order or drawing the equipments / returns the id of the item
      #--------------------------------------------------------------------------
      def get_itemid(order_i, actor, order_dir=nil)
        return_array = []
        return [-1, nil] if actor == nil
        if order_dir.nil?
          if $game_party.actors[0].actor_id == actor.id
            order_dir = $game_player.direction
          else
            for companion in $game_companions.values
              if $game_party.actors[companion.actor_id].actor_id == actor.id
                order_dir = companion.direction
              end
            end
          end
        end
        order_dir = (Lycan::CHARSET_POSES == 8) ? update_dir_8(order_dir) : update_dir_4(order_dir)
        slot_id = ORDER_STYLE[order_dir][order_i-1]
        # Depending if you use MultiSlots (auto-detected)
        if $game_system.m_slot_detected == true
          # If a character using two weapons
          if actor.two_weapons == true
            # Branch by slot (literally now)
            case slot_id
              when 1 ; return_array = [slot_id, actor.weapon_id]
              when 2 ; return_array = [slot_id, actor.weapons[1]]
              else   ; return_array = [slot_id, actor.armor_id[slot_id - 1]]
            end
          # Or if using just one weapon   
          else
            # Branch by slot (literally now)
            case slot_id
              when 1 ; return_array = [slot_id, actor.weapon_id]
              else   ; return_array = [slot_id, actor.armor_id[slot_id - 1]]
            end
          end
        # Or if you use the default
        else
          # Branch by slot (literally now)
          case slot_id
            when 5; return_array = [slot_id, actor.armor4_id]  # Access  (5th natural slot)
            when 4; return_array = [slot_id, actor.armor3_id]  # Armor   (4th natural slot)
            when 3; return_array = [slot_id, actor.armor2_id]  # Helmet  (3rd natural slot)
            when 2; return_array = [slot_id, actor.armor1_id]  # Shield  (2nd natural slot)
            when 1; return_array = [slot_id, actor.weapon_id]  # Weapon  (1st natural slot)
          end
        end
        # Return what is sent
        return return_array
      end
      #--------------------------------------------------------------------------
      # * Frame Update (if determining character default direction)
      #--------------------------------------------------------------------------  
      def update_dir_4(direction)
        case direction
        when 1; new_direction = 2
        when 2; new_direction = 2  
        when 3; new_direction = 6
        when 4; new_direction = 4  
        when 6; new_direction = 6
        when 7; new_direction = 4  
        when 8; new_direction = 8
        when 9; new_direction = 8  
        else  ; new_direction = 2
        end
        return new_direction
      end
      #--------------------------------------------------------------------------
      # * Frame Update (if determining character default direction)
      #--------------------------------------------------------------------------  
      def update_dir_8(direction)
        case direction
        when 1; new_direction = 1
        when 2; new_direction = 2  
        when 3; new_direction = 3
        when 4; new_direction = 4  
        when 6; new_direction = 6
        when 7; new_direction = 7
        when 8; new_direction = 8
        when 9; new_direction = 9  
        else  ; new_direction = 2
        end
        return new_direction
      end   
    end
    
    
    
    #==============================================================================
    # ** RPG::Cache
    #------------------------------------------------------------------------------
    #  This is a module that loads each of RPGXP's graphic formats, creates a
    #  Bitmap object, and retains it.
    #==============================================================================
    
    module RPG::Cache
      #--------------------------------------------------------------------------
      # * Load equipment
      #     filename : filename of the cached bitmap
      #     hue      : hue of the cached bitmap
      #--------------------------------------------------------------------------
      def self.equipment(filename, hue=0)
        begin
          self.load_bitmap("Graphics/"+Paperdoll::CACHE_DIRECTORY+"/", filename, hue)
        rescue
          self.load_bitmap("Graphics/"+Paperdoll::CACHE_DIRECTORY+"/", "", hue)
        end
      end
      #--------------------------------------------------------------------------
      # * Load graphic
      #     filename : filename of the cached bitmap
      #     hue      : hue of the cached bitmap
      #--------------------------------------------------------------------------
      def self.graphic(filename, hue=0)
        filename.slice!("#")
        begin
          self.load_bitmap("Graphics/", filename, hue)
        rescue
          self.load_bitmap("Graphics/", "", hue)
        end
      end  
    end
    
    
    
    #==============================================================================
    # ** Game_System
    #------------------------------------------------------------------------------
    #  This class handles data surrounding the system. Backround music, etc.
    #  is managed here as well. Refer to "$game_system" for the instance of
    #  this class.
    #==============================================================================
    
    class Game_System
      #--------------------------------------------------------------------------
      # * Public Instance Variables
      #--------------------------------------------------------------------------
      attr_accessor :m_slot_detected          # timer working flag
      #--------------------------------------------------------------------------
      # * Alias Listings
      #--------------------------------------------------------------------------
      alias lycan_paperdoll_game_system_init initialize
      #--------------------------------------------------------------------------
      # * Object Initialization
      #--------------------------------------------------------------------------
      def initialize
        lycan_paperdoll_game_system_init
        @m_slot_detected = nil
      end
    end
    
    
    
    #==============================================================================
    # ** Game_Actor
    #------------------------------------------------------------------------------
    #  This class handles the actor. It's used within the Game_Actors class
    #  ($game_actors) and refers to the Game_Party class ($game_party).
    #==============================================================================
    
    class Game_Actor < Game_Battler
      #--------------------------------------------------------------------------
      # * Public Instance Variables
      #--------------------------------------------------------------------------
      attr_accessor :weapons                  # weapon IDs
      attr_accessor :two_weapons              # Automatic switch for dual weilders
      #--------------------------------------------------------------------------
      # * Get's the needed equipments / Also determines ordeR!
      #--------------------------------------------------------------------------
      def get_equipments(order_dir=nil)
        $game_system.m_slot_detected = true if defined?(custom_slot_names)
        # Empty's equipments array for use
        equipments = []
        # Insert the character
        equipments.push(["#Characters/#{@character_name}", @character_hue]) if equipments.size != 1
        # Add the equipments, if there is a file for the equipments
        if order_dir.nil?
          if $game_party.actors[0].actor_id == self.id
            order_dir = $game_player.direction
          else
            for companion in $game_companions.values
              if $game_party.actors[companion.actor_id].actor_id == self.id
                order_dir = companion.direction
              end
            end
          end
        end
        order_dir = (Lycan::CHARSET_POSES == 8) ? Paperdoll.update_dir_8(order_dir) : Paperdoll.update_dir_4(order_dir)
        # Add the equipments, if there is a file for the equipments
        for equipnumber in 1...Paperdoll::ORDER_STYLE[order_dir].size+1
          # First, get the item_id of the equipment
          object  = Paperdoll.get_itemid(equipnumber, self, order_dir)
          slot_id, item_id = object[0], object[1]
          next if slot_id.nil?
          item_id = 0 if item_id.nil?
          shield_weapon = false
          if $game_system.m_slot_detected
            shield_weapon = true if @two_weapons == true
          end
          # Second, get the filename and hue of the file attached to the id
          item      = Paperdoll.get_file(slot_id, item_id, shield_weapon, @actor_id)
          # Put the item into the array if a file name was found
          equipments.push(item) unless item == false or item == nil
        end
        # Return all the equipments
        return equipments
      end
    end
    
    
    
    #==============================================================================
    # ** Sprite_Character
    #------------------------------------------------------------------------------
    #  This sprite is used to display the character.It observes the Game_Character
    #  class and automatically changes sprite conditions.
    #==============================================================================
    class Sprite_Character < RPG::Sprite
      #--------------------------------------------------------------------------
      # * Alias Listings
      #--------------------------------------------------------------------------
      alias lycan_paperdoll_sprite_character_initialize initialize
      #--------------------------------------------------------------------------
      # * Object Initialization
      #     viewport  : viewport
      #     character : character (Game_Character)
      #--------------------------------------------------------------------------
      def initialize(viewport, character = nil)
        # How many id's are there?
        number = Paperdoll::ORDER_STYLE[2].size
        # Make the equipment array
        @equips_id = Array.new(number,0)
        # What kind is the character?
        if character.is_a?(Game_Player)
          @actor = $game_party.actors[0]
        elsif @character.is_a?(Game_ABS_Companion)
          @actor = $game_party.actors[@character.actor_id]
        else
          @actor = nil
        end
        # Perform the original call
        lycan_paperdoll_sprite_character_initialize(viewport, character)
      end
      #--------------------------------------------------------------------------
      # * Frame Update (when refreshing updated characters)
      #--------------------------------------------------------------------------
      def update_refresh_character
        # If tile ID, file name, or hue are different from current ones
        return unless ( @tile_id        != @character.tile_id or
                        @character_name != @character.character_name or
                        @character_hue  != @character.character_hue or
                        changed_equipment?)
        update_equipment
        # Remember tile ID, file name, and hue
        update_previous_character
        # Handle tile or character sprite updates
        (@tile_id >= 384) ? update_tile_character : update_sprite_character
      end
      #--------------------------------------------------------------------------
      # * Frame Update (when retrieving characterset graphics)
      #--------------------------------------------------------------------------
      def update_sprite_character
        # Create an Equpment awway
        equips = []
        # load Equipment if a valid actor
        equips = @actor.get_equipments if @actor != nil
        # 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)
        # Draw if equipments available and is a custom-type
        if equips.size > 0 && @character_name.include?(Lycan::CHARSET_TAG)
          # Cycle through the equipment
          for graphic in equips
            # Skip if not valid
            next if graphic[0] == nil or graphic[0] == false or graphic[0] == "false"
            # Load if a 'character' or 'Equipment' folder
            graphic_equipment = update_tile_graphic_cache(graphic)
            self.bitmap.blt(0, 0, graphic_equipment, src_rect, 255)
          end
        # Otherwise, no equipment
        else
          src_rect = Rect.new(0, 0, bmp.width, bmp.height)
          self.bitmap.blt(0, 0, bmp, src_rect, 255)
        end
        # If a custom designed character
        if @character.character_name.include?(Lycan::CHARSET_TAG)
          # Custom design  
          if Lycan::CHARSET_STAND_FRAME
            @cw = bitmap.width / (Lycan::CHARSET_FRAMES + 1)
          else
            @cw = bitmap.width / Lycan::CHARSET_FRAMES
          end
          @ch = bitmap.height / Lycan::CHARSET_TOTAL_POSES
        else
          @cw = bitmap.width / 4
          @ch = bitmap.height / 4
        end         
        # Check for special Lycan Center Character in filename  
        chkname = @character.character_name.dup
        lastval = chkname[chkname.size-1,1]
        self.ox = @cw / 2
        if lastval == Lycan::SUFFIX_CENTER
          self.oy = @ch / 1.5
        else
          self.oy = @ch
        end     
      end
      #--------------------------------------------------------------------------
      # * Frame Update : Acquire image from Cache
      #--------------------------------------------------------------------------
      def update_tile_graphic_cache(graphic)
        if graphic[0].include?("#Characters/")
          img_file = RPG::Cache.graphic("#{graphic[0]}", graphic[1].to_i)
        else
          img_file = RPG::Cache.equipment("#{graphic[0]}", graphic[1].to_i)
        end
        return img_file
      end  
      #--------------------------------------------------------------------------
      # * Did the equipment changed?
      #--------------------------------------------------------------------------
      def changed_equipment?
        # According to the kind of the actor, the check is made...
        if @character.is_a?(Game_Player)
          # Get Character Direction
          order_dir = (Lycan::CHARSET_POSES == 8) ?
                      Paperdoll.update_dir_8(@character.direction) :
                      Paperdoll.update_dir_4(@character.direction)
          # Cycle through equipment
          for equipment_id in 1...Paperdoll::ORDER_STYLE[order_dir].size+1
            object            = Paperdoll.get_itemid(equipment_id, @actor, order_dir)
            slot_id, item_id  = object[0], object[1]
            next              if slot_id.nil?
            item_id = 0       if item_id.nil?
            return true       if @equips_id[slot_id] != item_id
          end
        elsif @character.is_a?(Game_ABS_Companion)
          # Obtain actor data from companion
          @actor = $game_party.actors[@character.actor_id]
          # Get Character Direction
          order_dir = (Lycan::CHARSET_POSES == 8) ?
                      Paperdoll.update_dir_8(@character.direction) :
                      Paperdoll.update_dir_4(@character.direction)
          # Cycle through equipment
          for equipment_id in 1...Paperdoll::ORDER_STYLE[order_dir].size+1
            object            = Paperdoll.get_itemid(equipment_id, @actor, order_dir)
            slot_id, item_id  = object[0], object[1]
            next              if slot_id.nil?
            item_id = 0       if item_id.nil?
            return true       if @equips_id[slot_id] != item_id
          end
        else
          return false
        end
        return false
      end
      #--------------------------------------------------------------------------
      # * Update known equipment
      #--------------------------------------------------------------------------
      def update_equipment
        # Remember tile ID, file name and hue
        @tile_id                = @character.tile_id
        @character_name         = @character.character_name
        @character_hue          = @character.character_hue
        # If the actor isent supported, return immideatly
        return                  if @actor == nil
         # According to the kind of the actor, the update is made...
        if @character.is_a?(Game_Player)
          # Get Character Direction
          order_dir = (Lycan::CHARSET_POSES == 8) ?
                      Paperdoll.update_dir_8(@character.direction) :
                      Paperdoll.update_dir_4(@character.direction)
          for equipment in 1...Paperdoll::ORDER_STYLE[order_dir].size+1
            object              = Paperdoll.get_itemid(equipment, @actor, order_dir)
            slot_id, item_id    = object[0], object[1]
            next                if slot_id.nil?
            item_id = 0         if item_id.nil?
            @equips_id[slot_id] = item_id
          end
        elsif @character.is_a?(Game_ABS_Companion)
          @actor = $game_party.actors[@character.actor_id]
          # Get Character Direction
          order_dir = (Lycan::CHARSET_POSES == 8) ?
                      Paperdoll.update_dir_8(@character.direction) :
                      Paperdoll.update_dir_4(@character.direction)
          for equipment in 1...Paperdoll::ORDER_STYLE[order_dir].size+1
            object              = Paperdoll.get_itemid(equipment, @actor, order_dir)
            slot_id, item_id    = object[0], object[1]
            next                if slot_id.nil?
            item_id = 0         if item_id.nil?
            @equips_id[slot_id] = item_id
          end
        end
      end
    end
    
    
    
    #==============================================================================
    # ** Window_Base
    #------------------------------------------------------------------------------
    #  This class is for all in-game windows.
    #==============================================================================
    class Window_Base < Window
      #--------------------------------------------------------------------------
      # * Draw Graphic
      #     actor : actor
      #     x     : draw spot x-coordinate
      #     y     : draw spot y-coordinate
      #--------------------------------------------------------------------------
      def draw_actor_graphic(actor, x, y)
        return if actor.nil?
        # Create an Equpment awway
        equips = []
        # Get the equipments
        equips = actor.get_equipments
        # Set the base bitmap
        bmp = RPG::Cache.character(actor.character_name, actor.character_hue)
        # Get the width and height of the bitmap pieces
        if actor.character_name.include?(Lycan::CHARSET_TAG)
          cw = bmp.width / Lycan::CHARSET_FRAMES
          ch = bmp.height / Lycan::CHARSET_TOTAL_POSES
        else
          cw = bmp.width / 4
          ch = bmp.height / 4
        end
        # Set the rectangle
        src_rect = Rect.new(0, 0, cw, ch)
        # Draw if equipments available and is a custom-type
        if equips.size > 0 && actor.character_name.include?(Lycan::CHARSET_TAG)
          # Cycle through the equipment
          for graphic in equips
            # Skip if not valid
            next if graphic[0] == nil or
              graphic[0] == false or graphic[0] == "false"
            # Load if a 'character' or 'Equipment' folder
            graphic_equipment = update_tile_graphic_cache(graphic)
            self.contents.blt(x - cw / 2, y - ch, graphic_equipment, src_rect, 255)
          end
        # Otherwise, no equipment
        else
          self.contents.blt(x - cw / 2, y - ch, bmp, src_rect, 255)
        end
      end
      #--------------------------------------------------------------------------
      # * Frame Update : Acquire image from Cache
      #--------------------------------------------------------------------------
      def update_tile_graphic_cache(graphic)
        if graphic[0].include?("#Characters/")
          img_file = RPG::Cache.graphic("#{graphic[0]}", graphic[1].to_i)
        else
          img_file = RPG::Cache.equipment("#{graphic[0]}", graphic[1].to_i)
        end
        return img_file
      end  
    end
    
    
    
    #==============================================================================
    # ** Window_SaveFile
    #------------------------------------------------------------------------------
    #  This window displays save files on the save and load screens.
    #==============================================================================
    
    class Window_SaveFile < Window_Base
      #--------------------------------------------------------------------------
      # * Object Initialization
      #     file_index : save file index (0-3)
      #     filename   : file name
      #--------------------------------------------------------------------------
      def initialize(file_index, filename)
        super(0, 64 + file_index % 4 * 104, 640, 104)
        self.contents = Bitmap.new(width - 32, height - 32)
        @file_index = file_index
        @filename = "Save#{@file_index + 1}.rxdata"
        @time_stamp = Time.at(0)
        @file_exist = FileTest.exist?(@filename)
        if @file_exist
          file = File.open(@filename, "r")
          @time_stamp         = file.mtime
          @characters         = Marshal.load(file)
          @frame_count        = Marshal.load(file)
          @game_system        = Marshal.load(file)
          @game_switches      = Marshal.load(file)
          @game_variables     = Marshal.load(file)
          @game_self_switches = Marshal.load(file)
          @game_screen        = Marshal.load(file)
          @game_actors        = Marshal.load(file) # Required for direction system
          @game_party         = Marshal.load(file) # Required for direction system
          @game_troop         = Marshal.load(file) # ---- filler ----
          @game_map           = Marshal.load(file) # ---- filler ----
          @game_player        = Marshal.load(file) # Required for direction system
          @saved_events       = Marshal.load(file) # ---- filler ----
          @kts                = Marshal.load(file) # ---- filler ----
          @abs                = Marshal.load(file) # ---- filler ----
          @game_companions    = Marshal.load(file) # Required for direction system
          @total_sec          = @frame_count / Graphics.frame_rate
          file.close
        end
        refresh
        @selected = false
      end  
      #--------------------------------------------------------------------------
      # * Refresh
      #--------------------------------------------------------------------------
      def refresh
        self.contents.clear
        # Draw file number
        self.contents.font.color = normal_color
        name = "File#{@file_index + 1}"
        self.contents.draw_text(4, 0, 600, 32, name)
        @name_width = contents.text_size(name).width
        # If save file exists
        if @file_exist
          # Draw character
          refresh_characters
          # Draw play time
          hour = @total_sec / 60 / 60
          min = @total_sec / 60 % 60
          sec = @total_sec % 60
          time_string = sprintf("%02d:%02d:%02d", hour, min, sec)
          self.contents.font.color = normal_color
          self.contents.draw_text(4, 8, 600, 32, time_string, 2)
          # Draw timestamp
          self.contents.font.color = normal_color
          time_string = @time_stamp.strftime("%Y/%m/%d %H:%M")
          self.contents.draw_text(4, 40, 600, 32, time_string, 2)
        end
      end
      #--------------------------------------------------------------------------
      # * Refresh characters
      #--------------------------------------------------------------------------
      def refresh_characters
        j=0
        for actor in @game_party.actors
         
          if @game_party.actors[0].actor_id == actor.id
            order_dir = @game_player.direction
          else
            for companion in @game_companions.values
              if @game_party.actors[companion.actor_id] == actor.id
                order_dir = companion.direction
              end
            end
          end     
          # Create an Equipment array
          equips = []
          # Get the equipments
          equips = actor.get_equipments(order_dir)
          # Set the base bitmap
          bmp = RPG::Cache.character(actor.character_name, actor.character_hue)
          # Get the width and height of the bitmap pieces
          if actor.character_name.include?(Lycan::CHARSET_TAG)
            cw = bmp.width / Lycan::CHARSET_FRAMES
            ch = bmp.height / Lycan::CHARSET_TOTAL_POSES
          else
            cw = bmp.width / 4
            ch = bmp.height / 4
          end
          # Set the rectangle
          src_rect = Rect.new(0, 0, cw, ch)
          # Set x position
          x = 300 - @game_party.actors.size * 32 + j * 64 - cw / 2
          # Draw if equipments available and is a custom-type
          if equips.size > 0 && actor.character_name.include?(Lycan::CHARSET_TAG)
            # Cycle through the equipment
            for graphic in equips
              # Skip if not valid
              next if graphic[0] == nil or
                graphic[0] == false or graphic[0] == "false"
              # Load if a 'character' or 'Equipment' folder
              graphic_equipment = update_tile_graphic_cache(graphic)  
              # Load if a 'character' or 'Equipment' folder
              self.contents.blt(x, 74 - ch, graphic_equipment, src_rect,255)
            end
          # Otherwise, no equipment
          else
            self.contents.blt(x, 74 - ch, bmp, src_rect,255)
          end
          j += 1
        end
      end
      #--------------------------------------------------------------------------
      # * Frame Update : Acquire image from Cache
      #--------------------------------------------------------------------------
      def update_tile_graphic_cache(graphic)
        if graphic[0].include?("#Characters/")
          img_file = RPG::Cache.graphic("#{graphic[0]}", graphic[1].to_i)
        else
          img_file = RPG::Cache.equipment("#{graphic[0]}", graphic[1].to_i)
        end
        return img_file
      end  
    end
    This is a custom Paperdoll system that I crafted for my Lycan ABS system. It allows you to use a Multiple Slot script, primarily my MultiSlots script, to let you use more than the basic 5 equipment slots.

    You will see some code parallel to code by Rataime and Me(tm)'s. However, my configuration system is different in that you have an array area called ORDER STYLE which changes the way the overlay is displayed based on a character's facing direction. Bet you never though about that, did ya? Shield might be more visible when the sprite is facing one way, but hidden by things like the cloak when facing the other.

    I cannot guarantee it will work as I made it for Lycan. But still... give it a try.
     
    #4
  5. HGS

    HGS Villager Member

    Messages:
    9
    Likes Received:
    0
    First Language:
    Poland
    Thank you
    I will check it in my spare time. I will be able to count on help in adapting your code to my game? If you had time of course :)
     
    #5
  6. DerVVulfman

    DerVVulfman Resident Werewolf Veteran

    Messages:
    314
    Likes Received:
    150
    First Language:
    English
    Primarily Uses:
    RMXP
    I try to make my scripts, when released as separate units, to be default-system adaptable. And usually with enough information and options for the end-user (ie YOU) to be able to customize yourself. Now I will say that this was something I penned for my Lycan system. But I try to still follow that pattern, so I hope you have no issues. Heheh... I'm a busy werewolf.
     
    #6

Share This Page