Advertisement
Falmc

FA Tool Selector + Service pack 1.2

Sep 18th, 2012
135
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 14.90 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.1 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 defined?(Map_Buttons).is_a?(String)
  266.       if !@back_sprite.nil? && Mouse.object_area?(@back_sprite.x,@back_sprite.y,
  267.         @back_sprite.width, @back_sprite.height)
  268.         $game_system.enable_ctool = true
  269.         refresh_itemcost_sprite if Mouse.trigger?(0)
  270.         create_blink_sprite
  271.       else
  272.         $game_system.enable_ctool = nil
  273.         dispose_blink_sprite
  274.       end
  275.     else
  276.       refresh_itemcost_sprite if Input.trigger?(ToolActionKey)
  277.     end
  278.     if $game_system.tool_icon_index != IntTool::icon_index
  279.       $game_system.tool_icon_index = IntTool::icon_index
  280.       refresh_icon_sprite
  281.     end
  282.   end
  283.  
  284.   def update_call_selector
  285.     if Input.trigger?(IntTool::ToolSelectorKey)
  286.       SceneManager.goto(Scene_ToolSelector)
  287.       Sound.play_ok
  288.     end
  289.   end
  290.  
  291.   def update_blink_sprite
  292.     return if @blink_sprite.nil?
  293.     @blink_sprite.opacity -= 3
  294.     @blink_sprite.opacity = 60 if @blink_sprite.opacity <= 0
  295.   end
  296. end
  297.  
  298. #-------------------------------------------------------------------------------
  299. # Window tool selection
  300. class Window_Tool_Select < Window_Selectable
  301.   def initialize(x=0, y=0, w=150, h=192)
  302.     super(x, y,  w, h)
  303.     self.z = 101
  304.     refresh
  305.     self.index = 0
  306.     activate
  307.   end
  308.  
  309.   def item
  310.     return @data[self.index]
  311.   end
  312.  
  313.   def refresh
  314.     self.contents.clear if self.contents != nil
  315.     @data = []
  316.     for weapon in IntTool.tool_weapons
  317.       if $game_player.actor.equippable?(weapon) and
  318.         $game_party.has_item?(weapon, true)
  319.         @data.push(weapon)
  320.       end
  321.     end
  322.     @item_max = @data.size
  323.     if @item_max > 0
  324.       self.contents = Bitmap.new(width - 32, row_max * 26)
  325.       for i in 0...@item_max
  326.         draw_item(i)
  327.       end
  328.     end
  329.   end
  330.  
  331.   def draw_item(index)
  332.     item = @data[index]
  333.     x, y = index % col_max * (120 + 32), index / col_max  * 24
  334.     self.contents.font.size = 18
  335.     draw_icon(item.icon_index, x, y)
  336.     self.contents.draw_text(x + 24, y, 212, 32, item.name, 0)
  337.   end
  338.  
  339.   def item_max
  340.     return @item_max.nil? ? 0 : @item_max
  341.   end
  342.  
  343.   def col_max
  344.     return IntTool.tool_weapons.size > 6 ? 2 : 1
  345.   end
  346. end
  347.  
  348. #-------------------------------------------------------------------------------
  349. # Scene tool selector
  350. class Scene_ToolSelector < Scene_MenuBase
  351.   def start
  352.     super
  353.     IntTool.tool_weapons.size > 6 ? w = 300 : w = 150
  354.     @tool_window = Window_Tool_Select.new(544/2 - w / 2, 416 / 2 - 192/2, w)
  355.     @tool_window.opacity = 200
  356.     @tool_header = Window_Base.new(@tool_window.x, @tool_window.y - 40, w, 40)
  357.     @tool_header.contents.draw_text(-6, -6, @tool_header.width, 32, 'Tools', 1)
  358.     @tool_header.opacity = @tool_window.opacity
  359.   end
  360.  
  361.   def update
  362.     super
  363.     if Input.trigger?(:B)
  364.       SceneManager.goto(Scene_Map)
  365.       Sound.play_cancel
  366.     end
  367.     if Input.trigger?(:C)
  368.       if @tool_window.item.nil?
  369.         SceneManager.goto(Scene_Map)
  370.         Sound.play_cancel
  371.         return
  372.       end
  373.       type = @tool_window.item.etype_id
  374.       $game_player.actor.change_equip_by_id(type, @tool_window.item.id)
  375.       Sound.play_equip
  376.       SceneManager.goto(Scene_Map)
  377.     end
  378.   end
  379.  
  380.   def terminate
  381.     super
  382.     @tool_window.dispose
  383.     @tool_header.dispose
  384.   end
  385. end
  386.  
  387. #-------------------------------------------------------------------------------
  388. # Sprite sets
  389. class Spriteset_Map
  390.   alias falint_toolbar_ini initialize
  391.   def initialize
  392.     @int_toolbar = Weapons_ToolBar.new
  393.     falint_toolbar_ini
  394.   end
  395.  
  396.   alias falint_toolbar_dis dispose
  397.   def dispose
  398.     @int_toolbar.dispose
  399.     falint_toolbar_dis
  400.   end
  401.  
  402.   alias falint_toolbar_up update
  403.   def update
  404.     @int_toolbar.update
  405.     falint_toolbar_up
  406.     if defined?(Map_Buttons).is_a?(String)
  407.       @interact_buttoms.mouse_over_button? ? $game_system.over_msbutton = true :
  408.       $game_system.over_msbutton = nil
  409.     end
  410.   end
  411. end
  412.  
  413. #-------------------------------------------------------------------------------
  414. # * Plugins
  415. class Game_Player < Game_Character
  416.   alias falint_toolbar_pickup_int_character pickup_int_character
  417.   def pickup_int_character(char)
  418.     return if @tool_anime > 0 || $game_system.enable_ctool ||
  419.     $game_system.over_msbutton
  420.     falint_toolbar_pickup_int_character(char)
  421.   end
  422.  
  423.   alias falint_toolbar_perform_jump perform_jump
  424.   def perform_jump
  425.     return if $game_system.enable_ctool || $game_system.over_msbutton
  426.     falint_toolbar_perform_jump
  427.   end
  428. end
  429.  
  430. #-------------------------------------------------------------------------------
  431. # * Service pack script
  432. class Game_CharacterBase
  433.   alias falcao_intservice_pack_bombcoll collide_with_bomb
  434.   def collide_with_bomb(x, y)
  435.     return false if self.is_a?(Game_Player) and self.obfalling > 0
  436.     falcao_intservice_pack_bombcoll(x, y)
  437.   end
  438.  
  439.   alias falcao_intservice_pack_barrelcoll collide_with_barrel
  440.   def collide_with_barrel(x, y)
  441.     return false if self.is_a?(Game_Player) and self.obfalling > 0
  442.     falcao_intservice_pack_barrelcoll(x, y)
  443.   end
  444. end
  445.  
  446. class Game_Player < Game_Character
  447.   def tool_canuse?(id)
  448.     return false if @obfalling > 0
  449.     IntTool::Interactive_Weapons.each do |dw , value|
  450.       if dw == id
  451.         if defined?(Map_Buttons).is_a?(String)
  452.           return false if $game_system.showing_twindow
  453.           return true if Mouse.trigger?(0) && !$game_map.interpreter.running? &&
  454.           $game_system.enable_ctool && !@player_busy &&
  455.           IntTool.equipped?(dw, value)
  456.         else
  457.           return true if Input.trigger?(ToolActionKey) && !@player_busy &&
  458.           !$game_map.interpreter.running? && IntTool.equipped?(dw, value)
  459.         end
  460.       end
  461.     end
  462.     return false
  463.   end
  464.  
  465.   alias falcao_intservice_pack_start_bomb_impact start_bomb_impact
  466.   def start_bomb_impact
  467.     falcao_intservice_pack_start_bomb_impact
  468.     applypick_grafhic if @player_busy
  469.     @gamebomb.char_steps = 0
  470.   end
  471.  
  472.   alias falcao_intservice_pack_move_straight move_straight
  473.   def move_straight(d, turn_ok = true)
  474.     return if @obfalling > 0 || @showing_hook || @showing_fire|| @tool_anime > 0
  475.     falcao_intservice_pack_move_straight(d, turn_ok = true)
  476.   end
  477. end
  478.  
  479. class Game_Arrow < Game_Character
  480.   alias falcao_intservice_pack_aini initialize
  481.   def initialize
  482.     falcao_intservice_pack_aini
  483.     @step_anime = true
  484.   end
  485. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement