Advertisement
Falmc

FA Tool Selector + Service pack 1.1

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