Advertisement
Falmc

FA Tool Selector + Service pack 0.3

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