Advertisement
Falmc

FA Tool Selector + Service pack done

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