Advertisement
Zetu

SEX v1.02

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