Advertisement
Demonicskyers

Multislot part 1

Sep 25th, 2013
330
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 14.74 KB | None | 0 0
  1. #==============================================================================
  2. # Multi-slot equipment script
  3. #------------------------------------------------------------------------------
  4. # Section 1:  Modules
  5. #------------------------------------------------------------------------------
  6. # Guillaume777
  7. # 6.2.2
  8. # 2006/02/14
  9. #==============================================================================
  10.  
  11. # To change slots of character
  12. #     $game_actors[1].weapon_slots = [0,0]
  13. #     $game_actors[1].armor_slots = [2,3,4,5,6,7]
  14. #
  15. # To make armor equipable in new slot :
  16. #     Add (5) in its name, where 5 is its slot number
  17. # To make 2handed weapons :
  18. #     Add an element called 2handed to a weapon
  19. #     or, adds its id in TWO_HANDED_WEAPONS = []
  20. #     or, adds (2handed) in its name
  21. # To make a weapon double attack
  22. #     Add an element called 2attacks to a weapon
  23. #     or, adds its id in DOUBLE_ATTACK_WEAPONS = []
  24. #     or, adds (2atks) in its name
  25. # To make a weapon/armor cursed
  26. #     Adds its id in CURSED_WEAPONS or CURSED_ARMORS, or
  27. #     put (cursed) in its name
  28. # To make a weapon require an offhand instead of any weapon
  29. #     Adds its id in NEEDS_OFFHAND or
  30. #     Adds (needs_offhand) in its name
  31.  
  32. #==============================================================================
  33. # *** MODULE:  Guillaume777's Multi-Slot Module
  34. #------------------------------------------------------------------------------
  35. #  This is the configuration module of the Multi-Slot system.  It allows you to
  36. #  set the default names of your slots, tag your weapons and/or armors for many
  37. #  types of enhancements and features, and etc.
  38. #==============================================================================
  39. module G7_MS_MOD
  40.  
  41.   #--------------------------------------------------------------------------
  42.   # * Configuration Section
  43.   #--------------------------------------------------------------------------
  44.   #========Set weapon/armor properties ======================================
  45.   CURSED_WEAPONS        = []             # ids of weapons to be cursed
  46.   CURSED_ARMORS         = []             # ids of armors to be cursed
  47.   TWO_HANDED_WEAPONS    = []             # ids of 2handed weapons
  48.   DOUBLE_ATTACK_WEAPONS = []             # ids of double attack weapons
  49.   NEEDS_OFFHAND         = [3,4,5,6,7,8,  # ids of weapons requiring an offhand
  50.                            9,10,11,12,
  51.                            25,26,27,28,29,30,31,32,33,34,35,36,37,38]
  52.  
  53.   SWITCH_EQUIP_WEAPONS  = [[38,36], [43,42]]  # ids of weapons switched when equipped
  54.   SWITCH_EQUIP_ARMORS   = [[41,40], [42,39]]  # ids of switched armors(same above)
  55.   # Use 1 array, first value of array = false item, second value = true item
  56.   #
  57.   # First value in the above arrays is displayed in the weapons/armors you can
  58.   # choose.  When the weapon/armor is chosen, the second id value IS the weapon
  59.   # or armor that you've chosen.  Example:  Trick someone to equip a cursed bow.
  60.  
  61.   #=========Set weapon/armor properties with element tagging and name edit===
  62.   CURSED_STRING = 'cursed'  # put (cursed) in item name for it to be cursed
  63.   HANDS_ELEMENT = 'handed'  # no. of hands in front of HANDS_ELEMENT in database
  64.   HANDS_STRING  = 'handed'  # name of string in item name like (2handed)
  65.  
  66.   MULTI_ATTACK_ELEMENT = 'attacks' # name of element to tag to multi attacks
  67.                                    # like (2attacks)
  68.   MULTI_ATTACK_STRING = 'atks'     # string in item name, like (3atks)
  69.  
  70.   NEEDS_OFFHAND_STRING = 'needs_offhand' #string in item name if the weapon
  71.                                          #needs an offhand like (needs_offhand)
  72.                                          
  73.   #=====Set character slots properties =======================================
  74.   WEAPON_KINDS = [0, 0]                     # number of weapons,  0 = weapon
  75.   WEAPON_KIND_NAMES = ['R-Hand', 'L-Hand']  # custom name of extra weapon slots
  76.   WEAPON_KIND_POWERS = [100, 100]           # 100 = normal power, 90 = 90% power
  77.                                             # Leave empty or put nil inside
  78.                                             # if you want the default names.
  79.   ARMOR_KINDS = [1,2,3,4,5,6,7]
  80.   # 1 = shield
  81.   # 2 = helmet
  82.   # 3 = armor
  83.   # 4 = acc
  84.   # 5 = and more : extra slot
  85.   EXTRA_SLOT_NAMES = ['Gauntlet','Boots','Amulet']
  86.   # Name of the extra slots in equip window
  87.   # You need as many words as there are '5' or more in armor_kinds
  88.   # The first order of the slots names reflect the order of the 5 in armor_kinds
  89.   # Put (5) or more to in the armor name to have it assigned to the extra slot
  90.  
  91.  
  92.   #=============Set multi-weapon behavior====================================
  93.   IGNORE_OFFHAND          = false # ignore off_hand support
  94.   TWOHANDED_IN_OFFHAND    = true  # If false don't show two handed weapons in
  95.                                   # the offhand window
  96.   ALL_WEAPONS_FOR_SKILLS  = true  # true  = combined pwr of all weaps for skills
  97.                                   # false = only power of first weapon
  98.   SHIELD_HAND_SLOT        = 1     # slot number to be used for shield hand
  99.   WEAPON_SHIELD_SHARE     = true  # if true, can't use a shield and a second
  100.                                   # weapon at the same time
  101.   SHIELD_HAND_WIELD       = true  # true = can use shield hand for 2handed weap.
  102.   WEAPON_HAND_WIELD       = true  # true = can use weapon hand for 2handed weap.
  103.   MULTI_WEAPONS_PENALITY  = 0     # percent of atk that will be subtracted if
  104.                                   # you use two weapons at the same time.
  105.                                  
  106.   #============Set appearance properties ====================================
  107.   FONT_NAME       = 'Arial'      # Font to use
  108.   CURSED_COLOR    = Color.new(255, 50, 50)  # Color of cursed equiped items
  109.   SHOW_REMOVE     = false                   # Show empty in offhand window
  110.  
  111.   WINDOWS_STRETCH = true    # true : equip_right stretch to adjust to # of slots
  112.   MAX_SHOW_SLOTS  = 6       # Maximum number of slots in 1 screen in equip right
  113.                             # window.  Useless if windows_stretch = false
  114.   HELP_AT_BOTTOM  = false   # If true,  will leave place for help window at bot-
  115.                             # tom.  Useless if you didn't modify the help window
  116.                             # y-coordinate.
  117.  
  118.   STATUS_WINDOW_ARRANGE = true  # If true, you get a new status window.
  119.   STATUS_WINDOW_SPACING = 24    # Space between each item in new status window.
  120.   EVADE                 = false # If draw_actor_parameter is configured to
  121.                                 # receive parameter number 7 (evade), then it
  122.                                 # will show in new status window.
  123.   # EVADE = true has no effect if STATUS_WINDOW_ARRANGE is false
  124.  
  125.   #================ end of settings =========================================
  126.  
  127.   #--------------------------------------------------------------------------
  128.   # * Object Initialization
  129.   #--------------------------------------------------------------------------
  130.   def initialize
  131.     super
  132.     RPG.set_new_item_types #fix armor and weapon properties at start of game
  133.   end
  134.   #--------------------------------------------------------------------------
  135.   # * End of MODULE:  Guillaume777's Multi-Slot Module
  136.   #--------------------------------------------------------------------------
  137. end
  138.  
  139.  
  140.  
  141. #============================================================================
  142. # ** MODULE:  RPG Module
  143. #----------------------------------------------------------------------------
  144. #  This sprite is used as an arrow cursor for the battle screen. This class
  145. #  is used as a superclass for the Arrow_Enemy and Arrow_Actor classes.
  146. #============================================================================
  147. module RPG
  148.   #--------------------------------------------------------------------------
  149.   # * Set New Item Types
  150.   #--------------------------------------------------------------------------
  151.   def RPG.set_new_item_types
  152.     if @initialized_item_types then return end
  153.     for armor in $data_armors     # for each armor
  154.       unless armor == nil         # if armor
  155.         armor.set_adv_type        # set new type
  156.         armor.set_cursed          # set if item is cursed or not
  157.       end
  158.     end
  159.     for weapon in $data_weapons  # for each armor
  160.       unless weapon == nil       # if armor
  161.         weapon.set_needs_offhand # set if it needs an offhand or not
  162.         weapon.set_nb_hands      # set the number of hands to wield it
  163.         weapon.set_nb_attacks    # set the number of attacks it can do
  164.         weapon.set_cursed        # set if item is cursed or not
  165.       end
  166.     end
  167.     @initialized_item_types = true
  168.   end
  169.   #--------------------------------------------------------------------------
  170.   # * Initialized Item Types
  171.   #     bool      : boolean value (true/false)
  172.   #--------------------------------------------------------------------------  
  173.   def RPG.initialized_item_types=(bool)
  174.     @initialized_item_types = bool
  175.   end
  176.    
  177.   #==========================================================================
  178.   # ** Armor
  179.   #--------------------------------------------------------------------------
  180.   # Data class for armors, adds new armor types
  181.   #==========================================================================
  182.   class Armor
  183.     attr_accessor :cursed
  184.     #------------------------------------------------------------------------
  185.     # * Set Adv Type
  186.     #------------------------------------------------------------------------  
  187.     def set_adv_type
  188.       pattern =  /\((\d+)\)/
  189.       if @name.sub!(pattern, '') != nil
  190.         # Set kind to the number in name of armor
  191.         @kind = $1.to_i - 1
  192.       end
  193.     end
  194.     #------------------------------------------------------------------------
  195.     # * Set Cursed
  196.     #------------------------------------------------------------------------    
  197.     def set_cursed
  198.       pattern = '('+G7_MS_MOD::CURSED_STRING+')'    
  199.       if @name.sub!(pattern, '') != nil then cursed = true end
  200.       if G7_MS_MOD::CURSED_ARMORS.include?(@id) then cursed = true end
  201.       @cursed = cursed
  202.     end
  203.     #------------------------------------------------------------------------
  204.     # * End of Armor Class
  205.     #------------------------------------------------------------------------
  206.   end
  207.  
  208.   #==========================================================================
  209.   # ** Weapon
  210.   #--------------------------------------------------------------------------
  211.   # Data class for weapons, adds new weapon types
  212.   #==========================================================================
  213.   class Weapon
  214.     #------------------------------------------------------------------------
  215.     # * Public Instance Variables
  216.     #------------------------------------------------------------------------
  217.     attr_accessor :needs_offhand  # does it need an offhand weapon
  218.     attr_accessor :nb_hands       # numbers of hands it requires
  219.     attr_accessor :nb_attacks     # number of attacks it can do
  220.     attr_accessor :cursed         # true if item is cursed
  221.     #------------------------------------------------------------------------
  222.     # * Set Cursed
  223.     #------------------------------------------------------------------------  
  224.     def set_cursed
  225.       pattern = '('+G7_MS_MOD::CURSED_STRING+')'
  226.       if @name.sub!(pattern, '') != nil then cursed = true end
  227.       if G7_MS_MOD::CURSED_WEAPONS.include?(@id) then cursed = true end
  228.       @cursed = cursed
  229.     end
  230.     #------------------------------------------------------------------------
  231.     # * Set Needs OffHand
  232.     #------------------------------------------------------------------------    
  233.     def set_needs_offhand
  234.       pattern = '('+G7_MS_MOD::NEEDS_OFFHAND_STRING+')'
  235.       if @name.sub!(pattern, '') != nil then
  236.         @needs_offhand = true
  237.       elsif G7_MS_MOD::NEEDS_OFFHAND.include?(self.id) then
  238.         @needs_offhand = true
  239.       elsif @needs_offhand== nil then
  240.         @needs_offhand = false
  241.       end
  242.     end
  243.     #------------------------------------------------------------------------
  244.     # * Returns number of hands needed for weapons
  245.     #------------------------------------------------------------------------
  246.     def set_nb_hands
  247.       if G7_MS_MOD::TWO_HANDED_WEAPONS.include?(self.id) then
  248.          nb_hands = 2
  249.       end
  250.       pattern = /\((\d+)#{G7_MS_MOD::HANDS_STRING}\)/
  251.       if @name.sub!(pattern, '') != nil
  252.         nb_hands = $1.downcase.delete('a-z')
  253.         nb_hands = $1.to_i
  254.       end
  255.       # Search through the elements
  256.       for elementnb in self.element_set
  257.         elementname = $data_system.elements[elementnb].downcase
  258.         # If the weapon has an element for another attack
  259.         if elementname.delete('0-9') == G7_MS_MOD::HANDS_ELEMENT.downcase
  260.           # Get the number of attacks
  261.           elementname = elementname.delete('a-z')
  262.           if elementname != '' then
  263.             nb_hands = elementname.to_i
  264.             # Delete the element
  265.             self.element_set.delete(elementnb)
  266.           end
  267.         end
  268.       end
  269.       if nb_hands.is_a?(Integer) == false or nb_hands <= 0 then nb_hands = 1 end
  270.       @nb_hands = nb_hands
  271.     end
  272.     #------------------------------------------------------------------------
  273.     # * Returns the number of attack the weapon can do
  274.     #------------------------------------------------------------------------
  275.     def set_nb_attacks
  276.       if G7_MS_MOD::DOUBLE_ATTACK_WEAPONS.include?(self.id) then
  277.         nb_attacks = 2
  278.       else
  279.         nb_attacks = 1
  280.       end
  281.       pattern = /\((\d+)#{G7_MS_MOD::MULTI_ATTACK_STRING}\)/
  282.       if @name.sub!(pattern, '') != nil
  283.         nb_attacks = $1.downcase.delete('a-z')
  284.         nb_attacks = $1.to_i
  285.       end
  286.       # Search elements that could add more attacks  
  287.       for elementnb in self.element_set
  288.         elementname = $data_system.elements[elementnb].downcase
  289.         # If the weapon has an element for another attack
  290.         if elementname.delete('0-9') == G7_MS_MOD::MULTI_ATTACK_ELEMENT.downcase
  291.           # Get the number of attacks
  292.           elementname = elementname.delete('a-z')
  293.           if elementname != '' then
  294.             nb_attacks = elementname.to_i
  295.             # Delete the element
  296.             self.element_set.delete(elementnb)
  297.           end
  298.         end
  299.       end
  300.       if nb_attacks.is_a?(Integer) == false or nb_attacks <= 0 then nb_attacks = 1 end
  301.       @nb_attacks = nb_attacks
  302.     end
  303.     #------------------------------------------------------------------------
  304.     # * End of CLASS:  Weapon
  305.     #------------------------------------------------------------------------
  306.   end
  307.   #--------------------------------------------------------------------------
  308.   # * End of MODULE:  RPG Module
  309.   #--------------------------------------------------------------------------
  310. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement