Zetu

SEX Fix

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