Advertisement
roninator2

Kid Friendly Basic Quest - Battle actor Hud

Dec 13th, 2024 (edited)
34
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 8.30 KB | None | 0 0
  1. # ╔═════════════════════════════════════╦════════════════════╗
  2. # ║ Title: KFBQ Battle Actor HUD        ║  Version: 1.00     ║
  3. # ║ Author: Roninator2                  ║                    ║
  4. # ╠═════════════════════════════════════╬════════════════════╣
  5. # ║ Function:                           ║   Date Created     ║
  6. # ║                                     ╠════════════════════╣
  7. # ║   FFMQ Style Actor Battle HUD       ║    10 Mar 2023     ║
  8. # ╚═════════════════════════════════════╩════════════════════╝
  9. # ╔══════════════════════════════════════════════════════════╗
  10. # ║ Function:                                                ║
  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 Battle
  22. #==============================================================================
  23. class Scene_Battle < Scene_Base
  24.   #--------------------------------------------------------------------------
  25.   # * Start HUD
  26.   #--------------------------------------------------------------------------
  27.   def start_hud
  28.     @actor1_hud = Actor_Hud_Window.new($game_party.members[0].id)
  29.     @actor2_hud = Actor_Hud_Window.new($game_party.members[1].id) if $game_party.members[1]
  30.     draw_no_actor if !$game_party.members[1]
  31.     @actor1_level = Actor_Level_Window.new($game_party.members[0].id)
  32.     @actor1_level.viewport = Viewport.new
  33.     @actor1_level.viewport.z += 2500
  34.     @actor2_level = Actor_Level_Window.new($game_party.members[1].id) if $game_party.members[1]
  35.     @actor2_level.viewport = Viewport.new if $game_party.members[1]
  36.     @actor2_level.viewport.z += 2500 if $game_party.members[1]
  37.     @actor1_name = Actor_Name_Window.new($game_party.members[0].id)
  38.     @actor1_name.viewport = Viewport.new
  39.     @actor1_name.viewport.z += 2500
  40.     @actor2_name = Actor_Name_Window.new($game_party.members[1].id) if $game_party.members[1]
  41.     @actor2_name.viewport = Viewport.new if $game_party.members[1]
  42.     @actor2_name.viewport.z += 2500 if $game_party.members[1]
  43.     @actor2_control = Actor_Control_Window.new($game_party.members[1].id) if $game_party.members[1]
  44.     @actor2_control.viewport = Viewport.new if $game_party.members[1]
  45.     @actor2_control.viewport.z += 2500 if $game_party.members[1]
  46.     @actor_status_back = Actor_Hud_Back.new
  47.   end
  48.   #--------------------------------------------------------------------------
  49.   # * Update Status Window Information
  50.   #--------------------------------------------------------------------------
  51.   def refresh_status
  52.     @actor1_hud.refresh if @actor1_hud
  53.     @actor2_hud.refresh if @actor2_hud
  54.   end
  55.   #--------------------------------------------------------------------------
  56.   # * Update
  57.   #--------------------------------------------------------------------------
  58.   alias r2_battle_hud_update    update
  59.   def update
  60.     r2_battle_hud_update
  61.     @actor1_hud.update
  62.     if @actor2_hud == nil
  63.       @actor2_hud = Actor_Hud_Window.new($game_party.members[1].id) if $game_party.members[1]
  64.       @actor2_level = Actor_Level_Window.new($game_party.members[1].id) if $game_party.members[1]
  65.       @actor2_level.viewport = Viewport.new if $game_party.members[1]
  66.       @actor2_level.viewport.z += 100 if $game_party.members[1]
  67.       @actor2_control = Actor_Control_Window.new($game_party.members[1].id) if $game_party.members[1]
  68.       @actor2_control.viewport = Viewport.new if $game_party.members[1]
  69.       @actor2_control.viewport.z += 100 if $game_party.members[1]
  70.       @actor2_name = Actor_Name_Window.new($game_party.members[1].id) if $game_party.members[1]
  71.       @actor2_name.viewport = Viewport.new if $game_party.members[1]
  72.       @actor2_name.viewport.z += 100 if $game_party.members[1]
  73.       draw_no_actor if !$game_party.members[1] && ((@no_actor == 0) || (@no_actor == nil))
  74.     else
  75.       remove_blank_space if $game_party.members[1]
  76.       clean_actor if !$game_party.members[1]
  77.       @actor2_hud.update if $game_party.members[1]
  78.     end
  79.     check_weapon_swap
  80.   end
  81.   #--------------------------------------------------------------------------
  82.   # * Swap Weapons by Key press
  83.   #--------------------------------------------------------------------------
  84.   def check_weapon_swap
  85.     if Input.trigger?(:L)
  86.       swap_weapons(0)
  87.     elsif Input.trigger?(:R)
  88.       swap_weapons(1)
  89.     end
  90.   end
  91.   #--------------------------------------------------------------------------
  92.   # * Swap Weapons by Key press
  93.   #--------------------------------------------------------------------------
  94.   def swap_weapons(value)
  95.     wdata = []
  96.     for i in 1..$data_weapons.size - 1
  97.       wdata[i-1] = nil
  98.       weapon = $data_weapons[i]
  99.       if $game_party.has_item?(weapon, true)
  100.         weapon.note.split(/[\r\n]+/).each { |line|
  101.           case line
  102.           when /<position:[-_ ]\d+>/i
  103.             pos = $1.to_i
  104.             wdata[pos-1] = weapon.id
  105.           end
  106.         }
  107.       end
  108.     end
  109.     wdata.compact!
  110.     current = $game_party.members[0].equips[0].id
  111.     pos = current
  112.     for i in 0..wdata.size - 1
  113.       pos = i if current == wdata[i]
  114.     end
  115.     if pos == 0
  116.       if value == 1
  117.         new_id = wdata[1]
  118.       else
  119.         new_id = wdata[-1]
  120.       end
  121.     elsif pos == wdata.size - 1
  122.       if value == 1
  123.         new_id = wdata[0]
  124.       else
  125.         new_id = wdata[pos-1]
  126.       end
  127.     else
  128.       if value == 1
  129.         new_id = wdata[pos+1]
  130.       else
  131.         new_id = wdata[pos-1]
  132.       end
  133.     end
  134.     $game_party.members[0].change_equip(0, $data_weapons[new_id])
  135.     @actor1_hud.refresh
  136.   end
  137.   #--------------------------------------------------------------------------
  138.   # * Clear Actor place holder
  139.   #--------------------------------------------------------------------------
  140.   def clean_actor
  141.     return if @actor2_hud == nil
  142.     @actor2_hud.dispose
  143.     @actor2_hud = nil
  144.     @actor2_level.dispose
  145.     @actor2_control.dispose
  146.     @actor2_name.dispose
  147.   end
  148.   #--------------------------------------------------------------------------
  149.   # * Draw image when no second player
  150.   #--------------------------------------------------------------------------
  151.   def draw_no_actor
  152.     @no_actor = Sprite.new
  153.     @no_actor.bitmap = Cache.system("Blank_Actor")
  154.     @no_actor.x = Graphics.width / 2
  155.     @no_actor.y = Graphics.height - 100
  156.     @no_actor.z = 2
  157.   end
  158.   #--------------------------------------------------------------------------
  159.   # * Remove image when second player added
  160.   #--------------------------------------------------------------------------
  161.   def remove_blank_space
  162.     return if (@no_actor == 0) || (@no_actor == nil)
  163.     @no_actor.bitmap.dispose
  164.     @no_actor.dispose
  165.     @no_actor = 0
  166.   end
  167.   #--------------------------------------------------------------------------
  168.   # * Remove image when leaving map
  169.   #--------------------------------------------------------------------------
  170.   alias r2_terminator_map_sprite  terminate
  171.   def terminate
  172.     r2_terminator_map_sprite
  173.     remove_blank_space
  174.   end
  175. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement