IceDragon200

SEX - Scene Equip X

Jul 12th, 2011
167
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 11.62 KB | None | 0 0
  1. # // IceDragon Edited on 07/10/2011 : Fixed a few issues.
  2. module Z_Systems
  3.   module SceneEquipX
  4.     #==========================================================================#
  5.     #            Multiple Equip Feature : For Redefining Equipment!            #
  6.     #             To disable this feature, set 'EQUIPS = ORIGINAL'             #
  7.     #==========================================================================#
  8.     USE_MULTI_EQUIP_SYSTEM = true
  9.     ORIGINAL = [ # Default types.  Do not edit unless you know what this does.
  10.       :weapon, :shield, :helm, :armor, :acces]
  11.    
  12.     EQUIPS = [
  13.       :weapon,  # Must be Weapon
  14.       :shield,  # Must be replaced if Weapon is two handed
  15.       :helm,
  16.       :back,
  17.       :armor,
  18.       :acces,
  19.       :acces
  20.     ] # DO NOT REMOVE
  21.     REPLACE = {
  22.       #            Condition,                New Vocab,        New Symbol
  23.       :weapon  => ['actor.two_swords_style', 'Vocab::weapon1', :weapon],
  24.       :shield  => ['actor.two_swords_style', 'Vocab::weapon2', :weapon]
  25.     }
  26.     EQUIP_DATA = {
  27.       #          Condition for Equip,           Vocab
  28.       :weapon => ['check_type(0) and noregexp', 'Vocab::weapon'],
  29.       :shield => ['check_type(1) and noregexp', 'Vocab::armor1'],
  30.       :helm   => ['check_type(2) and noregexp', 'Vocab::armor2'],
  31.       :armor  => ['check_type(3) and noregexp', 'Vocab::armor3'],
  32.       :acces  => ['check_type(4) and noregexp', 'Vocab::armor4'],
  33.       :back   => ['regexp("BACK")',             '"Back"']
  34.     }
  35.     # Scripts for above's 'Condition for Equip' ONLY!!! (All returns bool values)
  36.     # check_type(i)   => checks item's kind to original index
  37.     # regexp(string)  => checks for <equip_type: string>
  38.     # noregexp        => checks to see if <equip_type: > does not exist.
  39.    
  40.     #==========================================================================#
  41.     #           Slot and Gem Feature : Set SLOT_MAX to 0 to Disable!           #
  42.     #==========================================================================#
  43. #~     USE_SLOT_SYSTEM = false # NOT YET INSTALLED
  44. #~     SLOT_VOCAB = "Slot"
  45. #~     SLOT_MAX   = 2 #Number from 0..2 ONLY! Future versions may include more.
  46.  
  47. #========#======================#====#================================#========#
  48. #--------#                      #----# DO NOT EDIT PAST THIS POINT!!! #--------#
  49. #--------# End of Customization #----# Editing will cause death by    #--------#
  50. #--------#                      #----# brain asplosions.              #--------#
  51. #========#======================#====#================================#========#
  52.     unless USE_MULTI_EQUIP_SYSTEM
  53.       EQUIPS = ORIGINAL
  54.       REPLACE = {
  55.       ORIGINAL[0] => ['actor.two_swords_style', 'Vocab::weapon1', ORIGINAL[0]],
  56.       ORIGINAL[1] => ['actor.two_swords_style', 'Vocab::weapon2', ORIGINAL[0]]}
  57.       EQUIP_DATA = {}
  58.       for i in 0..4
  59.         EQUIP_DATA[ORIGINAL[i]] = (['check_type('+i.to_s+')'])
  60.         if i == 0
  61.           EQUIP_DATA[ORIGINAL[i]][1] = 'Vocab::weapon'
  62.         else
  63.           EQUIP_DATA[ORIGINAL[i]][1] = 'Vocab::armor'+i.to_s
  64.         end
  65.       end
  66.     end
  67.   end
  68. end
  69.  
  70. $zsys ||= {}
  71. $zsys['SceneEquipX'] = true
  72.  
  73. module Z
  74.  
  75.   def self.active_actor
  76.     return $scene.active_actor
  77.   end
  78.  
  79. end
  80.  
  81. class Scene_Base
  82.  
  83.   def active_actor
  84.     return @actor
  85.   end
  86.  
  87. end
  88.  
  89. module Z::SceneEquipX
  90.   include Z_Systems::SceneEquipX
  91.  
  92.   def self.symbol_index(i)
  93.     symbol = EQUIPS[i]
  94.     unless REPLACE[symbol].nil?
  95.       actor = Z::active_actor
  96.       actor ||= $actor
  97.       if eval(REPLACE[symbol][0])
  98.         symbol = REPLACE[symbol][2]
  99.       end
  100.     end
  101.     return symbol
  102.   end
  103.  
  104.   def self.vocab_index(i)
  105.     symbol = EQUIPS[i]
  106.     vocab  = eval(EQUIP_DATA[symbol][1])
  107.     unless REPLACE[symbol].nil?
  108.       actor = Z::active_actor
  109.       actor ||= $actor
  110.       if eval(REPLACE[symbol][0])
  111.         vocab = eval(REPLACE[symbol][1])
  112.       end
  113.     end
  114.     return vocab
  115.   end
  116.  
  117.   def self.check_type(i, item)
  118.     if i == 0
  119.       return (item.is_a?(RPG::Weapon))
  120.     else
  121.       return item.kind == i - 1
  122.     end
  123.   end
  124.  
  125.   def self.noregexp(item)
  126.     item.note.scan(/<equip_type:[ ](.*)>/i){
  127.       return (false)
  128.     }
  129.     return true
  130.   end
  131.  
  132.   def self.regexp(string, item)
  133.     item.note.scan(/<equip_type:[ ](.*)>/i){|nstring|
  134.       return (string.upcase == nstring[0].upcase)
  135.     }
  136.     return false
  137.   end
  138.  
  139.   def self.original_equipment(actor)
  140.     return [$data_weapons[actor.weapon_id],
  141.              $data_armors[actor.armor1_id],
  142.              $data_armors[actor.armor2_id],
  143.              $data_armors[actor.armor3_id],
  144.              $data_armors[actor.armor4_id]]
  145.   end
  146.  
  147. end
  148.  
  149. class RPG::BaseItem
  150.   include Z_Systems::SceneEquipX
  151.  
  152.   def symbol
  153.     for sym in EQUIPS.compact
  154.       if eval(EQUIP_DATA[sym][0])
  155.         return sym
  156.       end
  157.     end
  158.     print "Error, symbol not found for #{self.name}"
  159.   end
  160.  
  161.   def check_type(i)
  162.     return Z::SceneEquipX::check_type(i, self)
  163.   end
  164.  
  165.   def regexp(string)
  166.     return Z::SceneEquipX::regexp(string, self)
  167.   end
  168.  
  169.   def noregexp
  170.     return Z::SceneEquipX::noregexp(self)
  171.   end
  172.  
  173. end
  174.  
  175. class Window_Rect < Window_Selectable
  176.  
  177.   alias seqx_init initialize
  178.   def initialize(x, y, width, height)
  179.     seqx_init(x, y, width, height)
  180.     self.opacity = 0
  181.   end
  182.  
  183. end
  184.  
  185. class Scene_Equip < Scene_Base
  186.   include Z_Systems::SceneEquipX
  187.   EQUIP_TYPE_MAX = EQUIPS.size
  188.  
  189.    def update_status_window
  190.     if @equip_window.active
  191.       @status_window.set_new_parameters(nil, nil, nil, nil)
  192.     elsif @item_window.active
  193.       temp_actor = @actor.clone
  194.       equip = @actor.equip_at_slot(@equip_window.index)
  195.       if equip.nil?
  196.         @status_window.set_new_parameters(nil, nil, nil, nil)
  197.       else
  198.         new_atk = @actor.atk - equip.atk
  199.         new_def = @actor.def - equip.def
  200.         new_spi = @actor.spi - equip.spi
  201.         new_agi = @actor.agi - equip.agi
  202.         if !@item_window.item.nil? and @item_window.active
  203.           new_atk += @item_window.item.atk
  204.           new_def += @item_window.item.def
  205.           new_spi += @item_window.item.spi
  206.           new_agi += @item_window.item.agi
  207.         end
  208.         @status_window.set_new_parameters(new_atk, new_def, new_spi, new_agi)
  209.       end
  210.     end
  211.     @status_window.update
  212.   end
  213.  
  214.   def update_equip_selection
  215.     if Input.trigger?(Input::B)
  216.       Sound.play_cancel
  217.       return_scene
  218.     elsif Input.trigger?(Input::R)
  219.       Sound.play_cursor
  220.       next_actor
  221.     elsif Input.trigger?(Input::L)
  222.       Sound.play_cursor
  223.       prev_actor
  224.     elsif Input.trigger?(Input::C)
  225.       if @actor.fix_equipment
  226.         Sound.play_buzzer
  227.       else
  228.         Sound.play_decision
  229.         @equip_window.active = false
  230.         @item_window.active = true
  231.         @item_window.index = 0
  232.         update_status_window
  233.       end
  234.     end
  235.   end
  236.  
  237.   def update_item_selection
  238.     if Input.trigger?(Input::B)
  239.       Sound.play_cancel
  240.       @equip_window.active = true
  241.       @item_window.active = false
  242.       @item_window.index = -1
  243.     elsif Input.trigger?(Input::C)
  244.       Sound.play_equip
  245.       @actor.change_equip(@equip_window.index, @item_window.item)
  246.       @equip_window.active = true
  247.       @item_window.active = false
  248.       @item_window.index = -1
  249.       @equip_window.refresh
  250.       for item_window in @item_windows
  251.         item_window.refresh
  252.       end
  253.       update_status_window
  254.     end
  255.   end
  256.  
  257.   def update_item_windows
  258.     for i in 0...EQUIP_TYPE_MAX
  259.       @item_windows[i].visible = (@equip_window.index == i)
  260.       @item_windows[i].update
  261.     end
  262.     @item_window = @item_windows[@equip_window.index]
  263.     update_status_window
  264.   end
  265.  
  266.   def update_equip_window
  267.     @equip_window.update
  268.     update_status_window
  269.   end
  270.  
  271. end
  272.  
  273. class Window_Equip < Window_Selectable
  274.   include Z_Systems::SceneEquipX
  275.  
  276.   def refresh
  277.     @data = []
  278.     for item in @actor.equips do @data.push(item) end
  279.     @item_max = EQUIPS.size
  280.     create_contents
  281.     self.contents.font.color = system_color
  282.     for i in 0...EQUIPS.size
  283.       self.contents.draw_text(4, WLH*i, 92, WLH, Z::SceneEquipX::vocab_index(i))
  284.     end
  285.     for i in 0...EQUIPS.size
  286.       draw_item_name(@data[i], 92, WLH * i)
  287.     end
  288.   end
  289.  
  290. end
  291.  
  292. class Window_EquipItem < Window_Item
  293.  
  294.   def initialize(x, y, width, height, actor, equip_type)
  295.     @actor = actor
  296.     @equip_type = equip_type
  297.     super(x, y, width, height)
  298.   end
  299.  
  300.   def include?(item)
  301.     return true if item == nil
  302.     return false unless @actor.equippable?(item)
  303.     return (item.symbol == Z::SceneEquipX::symbol_index(@equip_type))
  304.   end
  305.  
  306. end
  307.  
  308.  
  309. class Game_Actor < Game_Battler
  310.   include Z_Systems::SceneEquipX
  311.  
  312.   alias seqx_setup setup
  313.   def setup(actor_id)
  314.     seqx_setup(actor_id)
  315.     setup_equip_ids() if @equips_id.nil?()
  316.   end
  317.  
  318.   def setup_equip_ids
  319.     @equips_id = []
  320.     $actor = self
  321.     for i in 0...EQUIPS.size
  322.       @equips_id.push(0)
  323.       for equip in Z::SceneEquipX::original_equipment(self)
  324.         next if equip.nil?
  325.         if equip.symbol == Z::SceneEquipX::symbol_index(i)
  326.           @equips_id[i] = equip.id
  327.           break
  328.         end
  329.       end
  330.     end
  331.   end
  332.  
  333.   def weapons
  334.     setup_equip_ids() if @equips_id.nil?()
  335.     result = []
  336.     for i in 0...EQUIPS.size
  337.       item = $data_weapons[@equips_id[i]]
  338.       next if Z::SceneEquipX::symbol_index(i) != ORIGINAL[0]
  339.       result.push(item)
  340.     end
  341.     return result
  342.   end
  343.  
  344.   def armors
  345.     setup_equip_ids() if @equips_id.nil?()
  346.     result = []
  347.     for i in 0...EQUIPS.size
  348.       item = $data_armors[@equips_id[i]]
  349.       next if Z::SceneEquipX::symbol_index(i) == ORIGINAL[0]
  350.       if item.nil?
  351.         result.push(nil)
  352.         next
  353.       end
  354.       result.push(item) if (Z::SceneEquipX::symbol_index(i) == item.symbol)
  355.     end
  356.     return result
  357.   end
  358.  
  359.   def atk_animation_id
  360.     if weapons.size > 1
  361.       return weapons[0].animation_id if weapons[0] != nil
  362.       return weapons[1] == nil ? 1 : 0
  363.     else
  364.       return weapons[0] == nil ? 1 : weapons[0].animation_id
  365.     end
  366.   end
  367.  
  368.   def atk_animation_id2
  369.     if weapons.size > 1
  370.       return weapons[1] == nil ? 0 : weapons[1].animation_id
  371.     else
  372.       return 0
  373.     end
  374.   end
  375.  
  376.   def change_equip_by_id(equip_type, item_id, test = false)
  377.     if Z::SceneEquipX::symbol_index(equip_type) == ORIGINAL[0]
  378.       change_equip(equip_type, $data_weapons[item_id], test)
  379.     else
  380.       change_equip(equip_type, $data_armors[item_id], test)
  381.     end
  382.   end
  383.  
  384.   def change_equip(equip_type, item, test = false)
  385.     unless test
  386.       last_item = equip_at_slot(equip_type)
  387.       return if $game_party.item_number(item) == 0 if item != nil
  388.       $game_party.gain_item(last_item, 1)
  389.       $game_party.lose_item(item, 1)
  390.     end
  391.     item_id = item == nil ? 0 : item.id
  392.     @equips_id[equip_type] = item_id
  393.   end
  394.  
  395.   def equip_at_slot(i)
  396.     id = @equips_id[i]
  397.     if Z::SceneEquipX::symbol_index(i) == ORIGINAL[0]
  398.       item = $data_weapons[id]
  399.     else
  400.       item = $data_armors[id]
  401.     end
  402.   end
  403.  
  404.   def discard_equip(item)
  405.     for i in 0...EQUIPS.size
  406.       if (@equips_id[i] == item.id and
  407.           item.symbol == Z::SceneEquipX::symbol_index(i))
  408.         @equips_id[i] = 0
  409.         break
  410.       end
  411.     end
  412.   end
  413.  
  414.   def two_hands_legal?
  415.     if weapons[0] != nil and weapons[0].two_handed
  416.       return false if @equips_id[1] != 0
  417.     end
  418.     if weapons[1] != nil and weapons[1].two_handed
  419.       return false if @equips_id[0] != 0
  420.     end
  421.     return true
  422.   end
  423.  
  424.   def class_id=(class_id)
  425.     @class_id = class_id
  426.     for i in 0..EQUIPS.size
  427.       change_equip(i, nil) unless equippable?(equips[i])
  428.     end
  429.   end
  430.  
  431. end
Advertisement
Add Comment
Please, Sign In to add comment