Advertisement
Falmc

FA Tool Selector + Service pack 1.3

Sep 18th, 2012
192
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 14.87 KB | None | 0 0
  1. #==============================================================================#
  2. #  #*****************#                                                         #
  3. #  #*** By Falcao ***#          * Int System Tool Selector + service pack      #
  4. #  #*****************#          This script display a quick tool selection menu#
  5. #                               and provide a bug fix pack and add-ons to      #
  6. #       RMVXACE                 Falcao Interactive System 2.0                  #
  7. #                               Date: September 18 2012                        #
  8. #                                                                              #
  9. # Falcao RGSS site:  http://falcaorgss.wordpress.com                           #
  10. # Falcao Forum site: http://makerpalace.com                                    #
  11. #                                                                              #
  12. #==============================================================================#
  13. # 0.2 Fixed small bug
  14. #
  15. #-------------------------------------------------------------------------------
  16. # * Installation
  17. #
  18. # Paste this script BELOW FA Interactive System 2.0
  19. #-------------------------------------------------------------------------------
  20. # * Int System Tool Selector Features
  21. #
  22. #  - Display a quick tool selection menu
  23. #  - Display interactive weapon icon on map
  24. #  - Display item cost value below interactive weapon icon
  25. #
  26. # * Service pack add-ons and fixes
  27. #
  28. #  - Added move animation to Game_Arrow
  29. #  - Added one more non movable method by input keys when using a tool
  30. #  - Added mouse support (plugin is activated if Mouse System button is installe
  31. #  - You can now add more weapon ids to be used as interactive weapon
  32. #  - Fixed minor bug when planting bombs or a barrel next to fall tiles
  33. #  - Fixed bug when making a bomb arrow at real time (bomb movemenmet now reset)
  34. #  - Fixed bug when bomb explode forcing the player to remove pick up graphic
  35.  
  36. msgbox(sprintf('Paste me below FA Interactive System 2.0 bitch!')) if
  37. not defined?(FalInt).is_a?(String)
  38.  
  39. # Configuration module
  40. module IntTool
  41.   include FalInt
  42.  
  43.   # Slot you want to use as tools:   true = weapon slot   false = armor slot
  44.   WToolSlot = true
  45.  
  46.   # X position in tiles of the tool hud on screen
  47.   Pos_X = 9
  48.  
  49.   # Y position in tiles of the tool hud on screen
  50.   Pos_Y = 11
  51.  
  52.   # Input key to call the tool selectionwindow
  53.   ToolSelectorKey = :ALT
  54.  
  55.   # Weapon/armors ids that equips the same tool, put inside the array the corr-
  56.   # esponding weapon/armor ids (this function is helpful in case you want more
  57.   # than one id to trigger the assigned tool), separate each id with a coma
  58.   Interactive_Weapons = {
  59.  
  60.   HweaponId     => [ ],  # HookShot
  61.   FweaponId     => [ ],  # Flame
  62.   BweaponId     => [ ],  # Bomb
  63.   BAweaponId    => [ ],  # Barrel
  64.   BladeWeaponId => [ ],  # Blade
  65.   ArrowWeaponId => [ ],  # Arrow
  66.  
  67.   }
  68.  
  69.   #-----------------------------------------------------------------------------
  70.   # * Available scripts calls
  71.   #
  72.   # SceneManager.goto(Scene_ToolSelector)   - Call the tools window manually
  73.   # $game_system.hide_mhud                  - Hide tool hud on map
  74.   # $game_system.show_mhud                  - Show tool hud on map
  75.  
  76.   # Note: The tool hud on map is visible when the player have equipped an
  77.   # interactive weapon/armor.
  78.  
  79.   #-----------------------------------------------------------------------------
  80.   # get interactive weapons / armor array
  81.   def self.tool_weapons
  82.     weapons = []  ; collected = []
  83.     Interactive_Weapons.each do |w , value|
  84.       value.each {|i| collected.push(i)}
  85.       collected.push(w) unless value.include?(w)
  86.     end
  87.     WToolSlot ? data = $data_weapons : data = $data_armors
  88.     collected.each {|w_id| weapons.push(data[w_id]) }
  89.     return weapons
  90.   end
  91.  
  92.   # check if specific interactive weapon / armor is equipped?
  93.   def self.equipped?(dw, value)
  94.     value.push(dw) unless value.include?(dw)
  95.     if WToolSlot
  96.       value.any? {|wep| $game_player.actor.weapons.include?($data_weapons[wep])}
  97.     else
  98.       value.any? {|arm| $game_player.actor.armors.include?($data_armors[arm])}
  99.     end
  100.   end
  101.  
  102.   # get equipped weapon / armor icon index
  103.   def self.icon_index
  104.     for t in tool_weapons
  105.       return t.icon_index if $game_player.actor.weapons.include?(t) if WToolSlot
  106.       return t.icon_index if $game_player.actor.armors.include?(t) if !WToolSlot
  107.     end
  108.     return nil
  109.   end
  110. end
  111.  
  112. #-------------------------------------------------------------------------------
  113. # * Game system new variables
  114. class Game_System
  115.   attr_accessor :tool_icon_index
  116.   attr_accessor :showing_twindow
  117.   attr_accessor :enable_ctool
  118.   attr_accessor :over_msbutton
  119.   attr_accessor :hide_thud
  120.  
  121.   def hide_mhud
  122.     @hide_thud = true
  123.   end
  124.  
  125.   def show_mhud
  126.     @hide_thud = nil
  127.   end
  128. end
  129.  
  130. #-------------------------------------------------------------------------------
  131. # * Tools toolbar class
  132. class Weapons_ToolBar
  133.   include FalInt
  134.   def initialize
  135.     @globalpos_x = IntTool::Pos_X * 32
  136.     @globalpos_y = IntTool::Pos_Y * 32
  137.     $game_system.tool_icon_index = IntTool::icon_index
  138.   end
  139.  
  140.   def create_sprites
  141.     create_back_sprite
  142.     create_icon_sprite
  143.     create_itemcost_sprite  if item_cost > 0
  144.   end
  145.  
  146.   def create_back_sprite
  147.     return if not @back_sprite.nil?
  148.     @back_sprite = Window_Base.new(@globalpos_x, @globalpos_y, 32, 32)
  149.     @back_sprite.opacity = 150
  150.     @back_sprite.z = 0
  151.   end
  152.  
  153.   def dispose_back_sprite
  154.     return if @back_sprite.nil?
  155.     @back_sprite.dispose
  156.     @back_sprite = nil
  157.   end
  158.  
  159.   def create_icon_sprite
  160.     return if not @icon_sprite.nil?
  161.     @icon_sprite = Sprite.new
  162.     @icon_sprite.bitmap = Bitmap.new(24, 24)
  163.     @icon_sprite.x = @globalpos_x + 4
  164.     @icon_sprite.y = @globalpos_y + 4
  165.     refresh_icon_sprite
  166.   end
  167.  
  168.   def refresh_icon_sprite
  169.     return if @icon_sprite.nil?
  170.     @icon_sprite.bitmap.clear
  171.     return if $game_system.tool_icon_index.nil?
  172.     icon = $game_system.tool_icon_index
  173.     bitmap = Cache.system("Iconset")
  174.     rect = Rect.new(icon % 16 * 24, icon / 16 * 24, 24, 24)
  175.     @icon_sprite.bitmap.blt(0, 0, bitmap, rect)
  176.   end
  177.  
  178.   def dispose_icon_sprite
  179.     return if @icon_sprite.nil?
  180.     @icon_sprite.dispose
  181.     @icon_sprite.bitmap.dispose
  182.     @icon_sprite = nil
  183.   end
  184.  
  185.   def create_itemcost_sprite
  186.     return if not @itemcost_sprite.nil?
  187.     @itemcost_sprite = Sprite.new
  188.     @itemcost_sprite.bitmap = Bitmap.new(32, 32)
  189.     @itemcost_sprite.bitmap.font.size = 13
  190.     @itemcost_sprite.bitmap.font.bold = true
  191.     @itemcost_sprite.z = 50
  192.     @itemcost_sprite.x = @globalpos_x + 10
  193.     @itemcost_sprite.y = @globalpos_y + 12
  194.     refresh_itemcost_sprite
  195.   end
  196.  
  197.   def dispose_itemcost_sprite
  198.     return if @itemcost_sprite.nil?
  199.     @itemcost_sprite.dispose
  200.     @itemcost_sprite.bitmap.dispose
  201.     @itemcost_sprite = nil
  202.   end
  203.  
  204.   def refresh_itemcost_sprite
  205.     return if @itemcost_sprite.nil?
  206.     @itemcost_sprite.bitmap.clear
  207.     @itemcost_sprite.bitmap.draw_text(0, 0, 212, 32, item_cost.to_s)
  208.   end
  209.  
  210.   def create_blink_sprite
  211.     return if not @blink_sprite.nil?
  212.     @blink_sprite = Sprite.new
  213.     @blink_sprite.bitmap = Bitmap.new(32, 32)
  214.     @blink_sprite.opacity = 60
  215.     @blink_sprite.bitmap.fill_rect(0, 0, 24, 24, Color.new(255, 255, 255, 255))
  216.     @blink_sprite.x = @globalpos_x + 4
  217.     @blink_sprite.y = @globalpos_y + 4
  218.     @blink_sprite.z = 50
  219.   end
  220.  
  221.   def dispose_blink_sprite
  222.     return if @blink_sprite.nil?
  223.     @blink_sprite.dispose
  224.     @blink_sprite.bitmap.dispose
  225.     @blink_sprite = nil
  226.   end
  227.  
  228.   # item cost value
  229.   def item_cost
  230.     cost = 0
  231.     IntTool::Interactive_Weapons.each do |dw , value|
  232.       cost = $game_party.item_number($data_items[BcostItemId]) if
  233.       dw == BweaponId and IntTool.equipped?(dw, value)
  234.       cost = $game_party.item_number($data_items[BarrelItemCost]) if
  235.       dw == BAweaponId and IntTool.equipped?(dw, value)
  236.       cost = $game_party.item_number($data_items[ArrowItemCost]) if
  237.       dw == ArrowWeaponId and IntTool.equipped?(dw, value)
  238.       cost = $game_player.actor.mp if dw == FweaponId and
  239.       IntTool.equipped?(dw, value)
  240.     end
  241.     return cost
  242.   end
  243.  
  244.   def dispose
  245.     dispose_back_sprite
  246.     dispose_icon_sprite
  247.     dispose_itemcost_sprite
  248.     dispose_blink_sprite
  249.   end
  250.  
  251.   def update
  252.     update_call_selector
  253.     if $game_system.hide_thud.nil?
  254.       $game_system.tool_icon_index.nil? ?  dispose  : create_sprites
  255.       item_cost > 0 ? create_itemcost_sprite : dispose_itemcost_sprite
  256.     else
  257.       dispose
  258.       return
  259.     end
  260.     update_icon_sprite
  261.     update_blink_sprite
  262.   end
  263.  
  264.   def update_icon_sprite
  265.     if @lastcost != item_cost
  266.       @lastcost = item_cost
  267.       refresh_itemcost_sprite
  268.     end
  269.     if defined?(Map_Buttons).is_a?(String)
  270.       if !@back_sprite.nil? && Mouse.object_area?(@back_sprite.x,@back_sprite.y,
  271.         @back_sprite.width, @back_sprite.height)
  272.         $game_system.enable_ctool = true
  273.         create_blink_sprite
  274.       else
  275.         $game_system.enable_ctool = nil
  276.         dispose_blink_sprite
  277.       end
  278.     end
  279.     if $game_system.tool_icon_index != IntTool::icon_index
  280.       $game_system.tool_icon_index = IntTool::icon_index
  281.       refresh_icon_sprite
  282.     end
  283.   end
  284.  
  285.   def update_call_selector
  286.     if Input.trigger?(IntTool::ToolSelectorKey)
  287.       SceneManager.goto(Scene_ToolSelector)
  288.       Sound.play_ok
  289.     end
  290.   end
  291.  
  292.   def update_blink_sprite
  293.     return if @blink_sprite.nil?
  294.     @blink_sprite.opacity -= 3
  295.     @blink_sprite.opacity = 60 if @blink_sprite.opacity <= 0
  296.   end
  297. end
  298.  
  299. #-------------------------------------------------------------------------------
  300. # Window tool selection
  301. class Window_Tool_Select < Window_Selectable
  302.   def initialize(x=0, y=0, w=150, h=192)
  303.     super(x, y,  w, h)
  304.     self.z = 101
  305.     refresh
  306.     self.index = 0
  307.     activate
  308.   end
  309.  
  310.   def item
  311.     return @data[self.index]
  312.   end
  313.  
  314.   def refresh
  315.     self.contents.clear if self.contents != nil
  316.     @data = []
  317.     for weapon in IntTool.tool_weapons
  318.       if $game_player.actor.equippable?(weapon) and
  319.         $game_party.has_item?(weapon, true)
  320.         @data.push(weapon)
  321.       end
  322.     end
  323.     @item_max = @data.size
  324.     if @item_max > 0
  325.       self.contents = Bitmap.new(width - 32, row_max * 26)
  326.       for i in 0...@item_max
  327.         draw_item(i)
  328.       end
  329.     end
  330.   end
  331.  
  332.   def draw_item(index)
  333.     item = @data[index]
  334.     x, y = index % col_max * (120 + 32), index / col_max  * 24
  335.     self.contents.font.size = 18
  336.     draw_icon(item.icon_index, x, y)
  337.     self.contents.draw_text(x + 24, y, 212, 32, item.name, 0)
  338.   end
  339.  
  340.   def item_max
  341.     return @item_max.nil? ? 0 : @item_max
  342.   end
  343.  
  344.   def col_max
  345.     return IntTool.tool_weapons.size > 6 ? 2 : 1
  346.   end
  347. end
  348.  
  349. #-------------------------------------------------------------------------------
  350. # Scene tool selector
  351. class Scene_ToolSelector < Scene_MenuBase
  352.   def start
  353.     super
  354.     IntTool.tool_weapons.size > 6 ? w = 300 : w = 150
  355.     @tool_window = Window_Tool_Select.new(544/2 - w / 2, 416 / 2 - 192/2, w)
  356.     @tool_window.opacity = 200
  357.     @tool_header = Window_Base.new(@tool_window.x, @tool_window.y - 40, w, 40)
  358.     @tool_header.contents.draw_text(-6, -6, @tool_header.width, 32, 'Tools', 1)
  359.     @tool_header.opacity = @tool_window.opacity
  360.   end
  361.  
  362.   def update
  363.     super
  364.     if Input.trigger?(:B)
  365.       SceneManager.goto(Scene_Map)
  366.       Sound.play_cancel
  367.     end
  368.     if Input.trigger?(:C)
  369.       if @tool_window.item.nil?
  370.         SceneManager.goto(Scene_Map)
  371.         Sound.play_cancel
  372.         return
  373.       end
  374.       type = @tool_window.item.etype_id
  375.       $game_player.actor.change_equip_by_id(type, @tool_window.item.id)
  376.       Sound.play_equip
  377.       SceneManager.goto(Scene_Map)
  378.     end
  379.   end
  380.  
  381.   def terminate
  382.     super
  383.     @tool_window.dispose
  384.     @tool_header.dispose
  385.   end
  386. end
  387.  
  388. #-------------------------------------------------------------------------------
  389. # Sprite sets
  390. class Spriteset_Map
  391.   alias falint_toolbar_ini initialize
  392.   def initialize
  393.     @int_toolbar = Weapons_ToolBar.new
  394.     falint_toolbar_ini
  395.   end
  396.  
  397.   alias falint_toolbar_dis dispose
  398.   def dispose
  399.     @int_toolbar.dispose
  400.     falint_toolbar_dis
  401.   end
  402.  
  403.   alias falint_toolbar_up update
  404.   def update
  405.     @int_toolbar.update
  406.     falint_toolbar_up
  407.     if defined?(Map_Buttons).is_a?(String)
  408.       @interact_buttoms.mouse_over_button? ? $game_system.over_msbutton = true :
  409.       $game_system.over_msbutton = nil
  410.     end
  411.   end
  412. end
  413.  
  414. #-------------------------------------------------------------------------------
  415. # * Plugins
  416. class Game_Player < Game_Character
  417.   alias falint_toolbar_pickup_int_character pickup_int_character
  418.   def pickup_int_character(char)
  419.     return if @tool_anime > 0 || $game_system.enable_ctool ||
  420.     $game_system.over_msbutton
  421.     falint_toolbar_pickup_int_character(char)
  422.   end
  423.  
  424.   alias falint_toolbar_perform_jump perform_jump
  425.   def perform_jump
  426.     return if $game_system.enable_ctool || $game_system.over_msbutton
  427.     falint_toolbar_perform_jump
  428.   end
  429. end
  430.  
  431. #-------------------------------------------------------------------------------
  432. # * Service pack script
  433. class Game_CharacterBase
  434.   alias falcao_intservice_pack_bombcoll collide_with_bomb
  435.   def collide_with_bomb(x, y)
  436.     return false if self.is_a?(Game_Player) and self.obfalling > 0
  437.     falcao_intservice_pack_bombcoll(x, y)
  438.   end
  439.  
  440.   alias falcao_intservice_pack_barrelcoll collide_with_barrel
  441.   def collide_with_barrel(x, y)
  442.     return false if self.is_a?(Game_Player) and self.obfalling > 0
  443.     falcao_intservice_pack_barrelcoll(x, y)
  444.   end
  445. end
  446.  
  447. class Game_Player < Game_Character
  448.   def tool_canuse?(id)
  449.     return false if @obfalling > 0
  450.     IntTool::Interactive_Weapons.each do |dw , value|
  451.       if dw == id
  452.         if defined?(Map_Buttons).is_a?(String)
  453.           return false if $game_system.showing_twindow
  454.           return true if Mouse.trigger?(0) && !$game_map.interpreter.running? &&
  455.           $game_system.enable_ctool && !@player_busy &&
  456.           IntTool.equipped?(dw, value)
  457.         else
  458.           return true if Input.trigger?(ToolActionKey) && !@player_busy &&
  459.           !$game_map.interpreter.running? && IntTool.equipped?(dw, value)
  460.         end
  461.       end
  462.     end
  463.     return false
  464.   end
  465.  
  466.   alias falcao_intservice_pack_start_bomb_impact start_bomb_impact
  467.   def start_bomb_impact
  468.     falcao_intservice_pack_start_bomb_impact
  469.     applypick_grafhic if @player_busy
  470.     @gamebomb.char_steps = 0
  471.   end
  472.  
  473.   alias falcao_intservice_pack_move_straight move_straight
  474.   def move_straight(d, turn_ok = true)
  475.     return if @obfalling > 0 || @showing_hook || @showing_fire|| @tool_anime > 0
  476.     falcao_intservice_pack_move_straight(d, turn_ok = true)
  477.   end
  478. end
  479.  
  480. class Game_Arrow < Game_Character
  481.   alias falcao_intservice_pack_aini initialize
  482.   def initialize
  483.     falcao_intservice_pack_aini
  484.     @step_anime = true
  485.   end
  486. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement