Advertisement
roninator2

Kid Friendly Basic Quest - Map Actor HUD

Dec 14th, 2024
32
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 9.63 KB | None | 0 0
  1. # ╔═════════════════════════════════════╦════════════════════╗
  2. # ║ Title: KFBQ Map Actor HUD           ║  Version: 1.00     ║
  3. # ║ Author: Roninator2                  ║                    ║
  4. # ╠═════════════════════════════════════╬════════════════════╣
  5. # ║ Function:                           ║   Date Created     ║
  6. # ║                                     ╠════════════════════╣
  7. # ║   FFMQ Style Actor Map HUD          ║    09 Mar 2023     ║
  8. # ╚═════════════════════════════════════╩════════════════════╝
  9. # ╔══════════════════════════════════════════════════════════╗
  10. # ║ Instructions:                                            ║
  11. # ║                                                          ║
  12. # ║  Set the Windows to look like FFMQ.                      ║
  13. # ║                                                          ║
  14. # ╚══════════════════════════════════════════════════════════╝
  15. # ╔══════════════════════════════════════════════════════════╗
  16. # ║ Terms of use:                                            ║
  17. # ║ Free for all uses in RPG Maker - Except nudity           ║
  18. # ╚══════════════════════════════════════════════════════════╝
  19.  
  20. #==============================================================================
  21. # ** Scene Map
  22. #==============================================================================
  23. class Scene_Map < Scene_Base
  24.   #--------------------------------------------------------------------------
  25.   # * Start
  26.   #--------------------------------------------------------------------------
  27.   alias r2_map_hud_start  start
  28.   def start
  29.     r2_map_hud_start
  30.     start_hud
  31.   end
  32.   #--------------------------------------------------------------------------
  33.   # * Start HUD
  34.   #--------------------------------------------------------------------------
  35.   def start_hud
  36.     @actor1_hud = Actor_Hud_Window.new($game_party.members[0].id)
  37.     @actor2_hud = Actor_Hud_Window.new($game_party.members[1].id) if $game_party.members[1]
  38.     draw_no_actor if !$game_party.members[1]
  39.     @actor1_level = Actor_Level_Window.new($game_party.members[0].id)
  40.     @actor1_level.viewport = Viewport.new
  41.     @actor1_level.viewport.z += 100
  42.     @actor2_level = Actor_Level_Window.new($game_party.members[1].id) if $game_party.members[1]
  43.     @actor2_level.viewport = Viewport.new if $game_party.members[1]
  44.     @actor2_level.viewport.z += 100 if $game_party.members[1]
  45.     @actor1_name = Actor_Name_Window.new($game_party.members[0].id)
  46.     @actor1_name.viewport = Viewport.new
  47.     @actor1_name.viewport.z += 100
  48.     @actor2_name = Actor_Name_Window.new($game_party.members[1].id) if $game_party.members[1]
  49.     @actor2_name.viewport = Viewport.new if $game_party.members[1]
  50.     @actor2_name.viewport.z += 100 if $game_party.members[1]
  51.     @actor2_control = Actor_Control_Window.new($game_party.members[1].id) if $game_party.members[1]
  52.     @actor2_control.viewport = Viewport.new if $game_party.members[1]
  53.     @actor2_control.viewport.z += 100 if $game_party.members[1]
  54.     @actor_status_back = Actor_Hud_Back.new
  55.   end
  56.   #--------------------------------------------------------------------------
  57.   # * Call Menu
  58.   #--------------------------------------------------------------------------
  59.   alias r2_call_menu_dispose_image  call_menu
  60.   def call_menu
  61.     remove_blank_space
  62.     r2_call_menu_dispose_image
  63.   end
  64.   #--------------------------------------------------------------------------
  65.   # * Update Call Debug
  66.   #--------------------------------------------------------------------------
  67.   def update_call_debug
  68.     if $TEST && Input.press?(:F9)
  69.       remove_blank_space
  70.       r2_call_menu_dispose_image
  71.       SceneManager.call(Scene_Debug)
  72.     end
  73.   end
  74.   #--------------------------------------------------------------------------
  75.   # * Update
  76.   #--------------------------------------------------------------------------
  77.   alias r2_map_hud_update    update
  78.   def update
  79.     r2_map_hud_update
  80.     @actor1_hud.update
  81.     if @actor2_hud == nil
  82.       @actor2_hud = Actor_Hud_Window.new($game_party.members[1].id) if $game_party.members[1]
  83.       @actor2_level = Actor_Level_Window.new($game_party.members[1].id) if $game_party.members[1]
  84.       @actor2_level.viewport = Viewport.new if $game_party.members[1]
  85.       @actor2_level.viewport.z += 100 if $game_party.members[1]
  86.       @actor2_control = Actor_Control_Window.new($game_party.members[1].id) if $game_party.members[1]
  87.       @actor2_control.viewport = Viewport.new if $game_party.members[1]
  88.       @actor2_control.viewport.z += 100 if $game_party.members[1]
  89.       @actor2_name = Actor_Name_Window.new($game_party.members[1].id) if $game_party.members[1]
  90.       @actor2_name.viewport = Viewport.new if $game_party.members[1]
  91.       @actor2_name.viewport.z += 100 if $game_party.members[1]
  92.       draw_no_actor if !$game_party.members[1] && ((@no_actor == 0) || (@no_actor == nil))
  93.     else
  94.       remove_blank_space if $game_party.members[1]
  95.       clean_actor if !$game_party.members[1]
  96.       @actor2_hud.update if $game_party.members[1]
  97.     end
  98.     check_weapon_swap
  99.     check_control
  100.   end
  101.   #--------------------------------------------------------------------------
  102.   # * Swap Weapons by Key press
  103.   #--------------------------------------------------------------------------
  104.   def check_weapon_swap
  105.     if Input.trigger?(:L)
  106.       swap_weapons(0)
  107.     elsif Input.trigger?(:R)
  108.       swap_weapons(1)
  109.     end
  110.   end
  111.   #--------------------------------------------------------------------------
  112.   # * Swap Weapons by Key press
  113.   #--------------------------------------------------------------------------
  114.   def swap_weapons(value)
  115.     wdata = []
  116.     for i in 1..$data_weapons.size - 1
  117.       wdata[i-1] = nil
  118.       weapon = $data_weapons[i]
  119.       if $game_party.has_item?(weapon, true)
  120.         weapon.note.split(/[\r\n]+/).each { |line|
  121.           case line
  122.           when /<position:[-_ ]\d+>/i
  123.             pos = $1.to_i
  124.             wdata[pos-1] = weapon.id
  125.           end
  126.         }
  127.       end
  128.     end
  129.     wdata.compact!
  130.     current = $game_party.members[0].equips[0].id
  131.     pos = current
  132.     for i in 0..wdata.size - 1
  133.       pos = i if current == wdata[i]
  134.     end
  135.     if pos == 0
  136.       if value == 1
  137.         new_id = wdata[1]
  138.       else
  139.         new_id = wdata[-1]
  140.       end
  141.     elsif pos == wdata.size - 1
  142.       if value == 1
  143.         new_id = wdata[0]
  144.       else
  145.         new_id = wdata[pos-1]
  146.       end
  147.     else
  148.       if value == 1
  149.         new_id = wdata[pos+1]
  150.       else
  151.         new_id = wdata[pos-1]
  152.       end
  153.     end
  154.     if new_id == nil; new_id = current; end
  155.     $game_party.members[0].change_equip(0, $data_weapons[new_id])
  156.     @actor1_hud.refresh
  157.   end
  158.   #--------------------------------------------------------------------------
  159.   # * Change Autobattle Contol by keypress
  160.   #--------------------------------------------------------------------------
  161.   def check_control
  162.     if Input.trigger?(:X)
  163.       $game_system.autobattle = !$game_system.autobattle?
  164.       @actor2_control.refresh if @actor2_control
  165.     end
  166.   end
  167.   #--------------------------------------------------------------------------
  168.   # * Clear Actor place holder
  169.   #--------------------------------------------------------------------------
  170.   def clean_actor
  171.     return if @actor2_hud == nil
  172.     @actor2_hud.dispose
  173.     @actor2_hud = nil
  174.     @actor2_level.dispose
  175.     @actor2_control.dispose
  176.     @actor2_name.dispose
  177.   end
  178.   #--------------------------------------------------------------------------
  179.   # * Draw image when no second player
  180.   #--------------------------------------------------------------------------
  181.   def draw_no_actor
  182.     @no_actor = Sprite.new
  183.     @no_actor.bitmap = Cache.system("Blank_Actor")
  184.     @no_actor.x = Graphics.width / 2
  185.     @no_actor.y = Graphics.height - 100
  186.     @no_actor.z = 2
  187.   end
  188.   #--------------------------------------------------------------------------
  189.   # * Remove image when second player added
  190.   #--------------------------------------------------------------------------
  191.   def remove_blank_space
  192.     return if (@no_actor == 0) || (@no_actor == nil)
  193.     @no_actor.bitmap.dispose
  194.     @no_actor.dispose
  195.     @no_actor = 0
  196.   end
  197.   #--------------------------------------------------------------------------
  198.   # * Remove image when leaving map
  199.   #--------------------------------------------------------------------------
  200.   alias r2_terminator_map_sprite  terminate
  201.   def terminate
  202.     r2_terminator_map_sprite
  203.     remove_blank_space
  204.   end
  205.   #--------------------------------------------------------------------------
  206.   # * Remove image when starting battle
  207.   #--------------------------------------------------------------------------
  208.   alias r2_clear_back_battle  pre_battle_scene
  209.   def pre_battle_scene
  210.     r2_clear_back_battle
  211.     remove_blank_space
  212.   end
  213. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement