khanhdu

scripts khung nhân vật

Oct 3rd, 2015
228
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 21.88 KB | None | 0 0
  1. #==============================================================================
  2. # ¦ VXAce-RGSS3-43 VN [Ver.1.0.2]       by Claimh
  3. #------------------------------------------------------------------------------
  4. # KHUNG CUA Window
  5. #==============================================================================
  6. #DONGCOQT1
  7. #==============================================================================
  8. # ¦THIET LAP DAY DU NHU
  9. #==============================================================================
  10. module MenuEx3
  11.   # CHIEU DOC
  12.   HMAX = 4
  13.  
  14.   # CHIEU NGANG
  15.   WMAX = 2
  16.  
  17.   # SU DUNG KI TU
  18.   #   true  : KI TU HIEN THI   
  19.   #   false : MANG HINH HIEN THI KHUON MAT
  20.   CHAR = true
  21.  
  22.   # HP/MPVITRIDIEUCHINH
  23.   PX = 20
  24. end
  25.  
  26.  
  27. #==============================================================================
  28. # ¦ CAI DAT IEN THI KI TU
  29. #------------------------------------------------------------------------------
  30. # NHAN VAT TRONG TRAN CHIEN
  31. # ·GIA TRI BAN DAU
  32. #   DIEN DAN
  33. #     @dead_c[TIEPTIN,index,CHISONVindex]
  34. #      VD) Eric   … @dead_c[Damage3,6,0]
  35. #          Ernest  … @dead_c[Damage3,7,0]
  36. #          Brenda  … @dead_c[Damage4,0,3]
  37. # ·THAYDOI
  38. #   KICHBANSUKIEN
  39. #     set_dead_c(DIENVIENID, "TTENFILE", index,CHISOindex)
  40. #------------------------------------------------------------------------------
  41. # NVTRANGTHAIXAU
  42. # ·GIATRIBANGDAU
  43. #   GHICHUNV
  44. #     @badst_c[TENTT, index, CHISONVindex]
  45. #      VD)Eric   … @badst_c[Damage3,6,1]
  46. #         Ernest … @badst_c[Damage3,7,1]
  47. #         Brenda … @badst_c[Damage4,0,4]
  48. # ·THOIGIAN
  49. #   SUKIEN
  50. #     set_badst_c(NVID, "TENFIKE", index, CHISOindex)
  51. # ·QUYENDINHXAU
  52. #   DUOC THIET LAP
  53. #     @badst
  54. #==============================================================================
  55. module MoveActor
  56.   # DINHHUONGNV
  57.   #   2 : TRC
  58.   #   4 : CONLAI
  59.   #   6 : RIGHT
  60.   #   8 : TROLAI
  61.   CHAR_DIR = 2
  62.  
  63.   # HANHVI(TDO)
  64.   MOVE_CHAR = true
  65.  
  66.   # TOCDONV
  67.   MOVE_SPD = 20
  68. end
  69.  
  70.  
  71. #==============================================================================
  72. # ¦ MoveCharData
  73. #==============================================================================
  74. class MoveCharData
  75.   #--------------------------------------------------------------------------
  76.   # ? ??????????
  77.   #--------------------------------------------------------------------------
  78.   attr_reader   :enabled        # ??(??????)
  79.   attr_reader   :dead           # ????
  80.   attr_reader   :badst          # ???????
  81.   attr_reader   :pending        # ????
  82.   attr_reader   :pending_color  # ????????
  83.   attr_reader   :name           # ?????? ?????
  84.   attr_reader   :index          # ?????? ??????
  85.   attr_reader   :pattern        # ?????? ????(????????)
  86.   #--------------------------------------------------------------------------
  87.   # CONGCONG
  88.   #--------------------------------------------------------------------------
  89.   def initialize(actor, pending=false, pending_color=Color.new(0,0,0,0))
  90.     @enabled = $game_party.battle_members.include?(actor)
  91.     @pending = pending
  92.     @pending_color = pending_color
  93.     @dead  = actor.dead?
  94.     @badst = actor.badst?
  95.     if @dead
  96.       @name    = actor.dead_character_name
  97.       @index   = actor.dead_character_index
  98.       @pattern = actor.dead_character_pattern
  99.     elsif @badst
  100.       @name    = actor.badst_character_name
  101.       @index   = actor.badst_character_index
  102.       @pattern = actor.badst_character_pattern
  103.       self
  104.     else
  105.       @name    = actor.character_name
  106.       @index   = actor.character_index
  107.       @pattern = 0
  108.     end
  109.   end
  110.   #--------------------------------------------------------------------------
  111.   # KHOITAO
  112.   #--------------------------------------------------------------------------
  113.   def st_normal?
  114.     !(@dead or @badst)
  115.   end
  116. end
  117.  
  118. #==============================================================================
  119. # ¦ MoveCharacter
  120. #==============================================================================
  121. class MoveCharacter
  122.   include MoveActor
  123.   CHANGE  = MOVE_SPD * 4
  124.   MAX_CNT = MOVE_SPD * 4 * 4
  125.   #--------------------------------------------------------------------------
  126.   # BINHTHUONGKO
  127.   #--------------------------------------------------------------------------
  128.   def initialize(bitmap, rect, character)
  129.     @rect   = rect     # ????
  130.     @bitmap = bitmap   # ?????????
  131.     @count = MOVE_CHAR ? 0 : MOVE_SPD
  132.     set_char(character)
  133.   end
  134.   #--------------------------------------------------------------------------
  135.   # DONGCO1
  136.   #--------------------------------------------------------------------------
  137.   def set_char(character, force=false)
  138.     @character = character
  139.     redraw_character(force)
  140.   end
  141.   #--------------------------------------------------------------------------
  142.   # DONGCO2(CR VA CD)
  143.   #--------------------------------------------------------------------------
  144.   def character_rect_base
  145.     b = Cache.character(@character.name)
  146.     sign = @character.name[/^[\!\$]./]
  147.     if sign && sign.include?('$')
  148.       cw = b.width / 3
  149.       ch = b.height / 4
  150.     else
  151.       cw = b.width / 12
  152.       ch = b.height / 8
  153.     end
  154.     Rect.new(0, 0, cw, ch)
  155.   end
  156.   #--------------------------------------------------------------------------
  157.   # DONGCO3
  158.   #--------------------------------------------------------------------------
  159.   def character_rect(pattern)
  160.     rect = character_rect_base
  161.     if @character.dead or @character.badst
  162.       rect.x = (@character.index % 4 * 3 + @character.pattern % 3) * rect.width
  163.       rect.y = (@character.index / 4 * 4 + @character.pattern / 3) * rect.height
  164.     else
  165.       rect.x = (@character.index % 4 * 3 + pattern) * rect.width
  166.       rect.y = (@character.index / 4 * 4 + (CHAR_DIR - 2) / 2) * rect.height
  167.     end
  168.     rect
  169.   end
  170.   #--------------------------------------------------------------------------
  171.   # DONGCO4
  172.   #--------------------------------------------------------------------------
  173.   def draw_background
  174.     @bitmap.fill_rect(@rect, @character.pending_color)
  175.   end
  176.   #--------------------------------------------------------------------------
  177.   # DONGCO5
  178.   #--------------------------------------------------------------------------
  179.   def draw_character(pattern)
  180.     return if @character.name == ""
  181.     pattern = 1 if pattern >= 3
  182.     src_rect = character_rect(pattern)
  183.     op = @character.enabled ? 255 : 160
  184.     @bitmap.blt(@rect.x, @rect.y, Cache.character(@character.name), src_rect, op)
  185.   end
  186.   #--------------------------------------------------------------------------
  187.   # DONGCO6
  188.   #--------------------------------------------------------------------------
  189.   def redraw_character(force=false)
  190.     return if !@character.st_normal? and !force
  191.     @bitmap.clear_rect(@rect)
  192.     draw_background if @character.pending
  193.     draw_character((@count / MOVE_SPD) % 4)
  194.   end
  195.   #--------------------------------------------------------------------------
  196.   # DONGCO7
  197.   #--------------------------------------------------------------------------
  198.   def update
  199.     return unless MOVE_CHAR
  200.     @count = (@count + 1) % MAX_CNT
  201.     redraw_character if (@count % MOVE_SPD) == 0
  202.   end
  203. end
  204.  
  205.  
  206. #==============================================================================
  207. # ¦ Game_Actor
  208. #==============================================================================
  209. class Game_Actor < Game_Battler
  210.   #--------------------------------------------------------------------------
  211.   # ? ??????????
  212.   #--------------------------------------------------------------------------
  213.   attr_accessor  :dead_character_name      # ?????????? ?????
  214.   attr_accessor  :dead_character_index     # ?????????? ??????
  215.   attr_accessor  :dead_character_pattern   # ?????????? ????
  216.   attr_accessor  :badst_character_name     # ?????????? ?????
  217.   attr_accessor  :badst_character_index    # ?????????? ??????
  218.   attr_accessor  :badst_character_pattern  # ?????????? ????
  219.   #--------------------------------------------------------------------------
  220.   # DONGCO8
  221.   #--------------------------------------------------------------------------
  222.   alias setup_move_actor setup
  223.   def setup(actor_id)
  224.     setup_move_actor(actor_id)
  225.     setup_dead_character(actor_id)
  226.     setup_badst_character(actor_id)
  227.   end
  228.   #--------------------------------------------------------------------------
  229.   # DONGCO9 (SU TAI HOP)
  230.   #--------------------------------------------------------------------------
  231.   def setup_dead_character(actor_id)
  232.     result = $data_actors[actor_id].note.scan(/@dead_c\[(.*?+),(\d+),(\d+)\]/i)
  233.     if result.nil? or result.empty?
  234.       @dead_character_name  = ""
  235.       @dead_character_index = @dead_character_pattern = 0
  236.     else
  237.       @dead_character_name    = result[0][0].to_s
  238.       @dead_character_index   = result[0][1].to_i
  239.       @dead_character_pattern = result[0][2].to_i
  240.     end
  241.   end
  242.   #--------------------------------------------------------------------------
  243.   #DONGCO10 (DB)
  244.   #--------------------------------------------------------------------------
  245.   def setup_badst_character(actor_id)
  246.     result = $data_actors[actor_id].note.scan(/@badst_c\[(.*?+),(\d+),(\d+)\]/i)
  247.     if result.nil? or result.empty?
  248.       @badst_character_name  = ""
  249.       @badst_character_index = @badst_character_pattern = 0
  250.     else
  251.       @badst_character_name    = result[0][0].to_s
  252.       @badst_character_index   = result[0][1].to_i
  253.       @badst_character_pattern = result[0][2].to_i
  254.     end
  255.   end
  256.   #--------------------------------------------------------------------------
  257.   # DONGCO11
  258.   #--------------------------------------------------------------------------
  259.   def badst?
  260.     states.any? {|s| s.note.include?("@badst")}
  261.   end
  262. end
  263.  
  264.  
  265. #==============================================================================
  266. # ¦ Game_Interpreter
  267. #==============================================================================
  268. class Game_Interpreter
  269.   #--------------------------------------------------------------------------
  270.   # DONGCO12
  271.   #--------------------------------------------------------------------------
  272.   def set_dead_c(actor_id, name, index, pattern)
  273.     actor = $game_actors[actor_id]
  274.     actor.dead_character_name    = name
  275.     actor.dead_character_index   = index
  276.     actor.dead_character_pattern = pattern
  277.   end
  278.   #--------------------------------------------------------------------------
  279.   # DONGCO13
  280.   #--------------------------------------------------------------------------
  281.   def set_badst_c(actor_id, name, index, pattern)
  282.     actor = $game_actors[actor_id]
  283.     actor.badst_character_name    = name
  284.     actor.badst_character_index   = index
  285.     actor.badst_character_pattern = pattern
  286.   end
  287. end
  288.  
  289.  
  290. #==============================================================================
  291. # ¦ Window_MenuOneActor
  292. #==============================================================================
  293. class Window_MenuOneActor < Window_Base
  294.   #--------------------------------------------------------------------------
  295.   #DONGCO14
  296.   #--------------------------------------------------------------------------
  297.   attr_accessor   :pending            # ????(?????)
  298.   #--------------------------------------------------------------------------
  299.   # DONGCO125
  300.   #--------------------------------------------------------------------------
  301.   def initialize(x, y, index)
  302.     @offset_x = 160
  303.     @pending  = false
  304.     @index    = index
  305.     super(x, y, window_width, window_height)
  306.     create_char_object if MenuEx3::CHAR
  307.   end
  308.   #--------------------------------------------------------------------------
  309.   # DONGCO16 (TAIHOP)
  310.   #--------------------------------------------------------------------------
  311.   def create_char_object
  312.     h = contents.height - line_height
  313.     char_rect = Rect.new(12, line_height + (h - 32) / 2, 32, 32)
  314.     actor = $game_party.members[@index]
  315.     @char = MoveCharacter.new(contents, char_rect, MoveCharData.new(actor))
  316.   end
  317.   #--------------------------------------------------------------------------
  318.   # DONGCO17
  319.   #--------------------------------------------------------------------------
  320.   def window_width
  321.     (Graphics.width - @offset_x) / MenuEx3::WMAX
  322.   end
  323.   #--------------------------------------------------------------------------
  324.   # DONGCO18
  325.   #--------------------------------------------------------------------------
  326.   def window_height
  327.     Graphics.height / MenuEx3::HMAX
  328.   end
  329.   #--------------------------------------------------------------------------
  330.   # DONGCO189
  331.   #--------------------------------------------------------------------------
  332.   def draw_item_background
  333.     contents.fill_rect(Rect.new(0,0,contents.width,contents.height), pending_color) if @pending
  334.   end
  335.   #--------------------------------------------------------------------------
  336.   # DONGCO120
  337.   #     enabled : ??????false ?????????
  338.   #--------------------------------------------------------------------------
  339.   def draw_face(face_name, face_index, x, y, enabled = true)
  340.     bitmap = Cache.face(face_name)
  341.     h = contents.height - line_height - 4
  342.     sy = h < 96 ? ((96 - h) / 2) : 0
  343.     h  = h < 96 ? h : 96
  344.     rect = Rect.new(face_index % 4 * 96, face_index / 4 * 96 + sy, 96, h)
  345.     contents.blt(x, y, bitmap, rect, enabled ? 255 : translucent_alpha)
  346.     bitmap.dispose
  347.   end
  348.   #--------------------------------------------------------------------------
  349.   # VITRI/VITOIDAHIENTAI
  350.   #     current : HT
  351.   #     max     : TOIDA
  352.   #     color1  : HT1
  353.   #     color2  : TOIDA
  354.   #--------------------------------------------------------------------------
  355.   def draw_current_and_max_values(x, y, width, current, max, color1, color2)
  356.     change_color(color1)
  357.     xr = x + width
  358.     if width < 120  # 96??4????NG?????
  359.       draw_text(xr - 40, y, 42, line_height, current, 2)
  360.     else
  361.       draw_text(xr - 92, y, 42, line_height, current, 2)
  362.       change_color(color2)
  363.       draw_text(xr - 52, y, 12, line_height, "/", 2)
  364.       draw_text(xr - 42, y, 42, line_height, max, 2)
  365.     end
  366.   end
  367.   #--------------------------------------------------------------------------
  368.   #  DONGCO122
  369.   #--------------------------------------------------------------------------
  370.   def refresh
  371.     contents.clear
  372.     actor = $game_party.members[@index]
  373.     enabled = $game_party.battle_members.include?(actor)
  374.     rect = Rect.new(0, 0, contents.width, contents.height)
  375.     draw_item_background
  376.     draw_actor_name(actor, 4, 0, rect.width - 60)
  377.     draw_actor_level(actor, rect.width - 56, 0)
  378.     if MenuEx3::CHAR
  379.       @char.set_char(MoveCharData.new(actor, @pending, pending_color), true)
  380.       x = 12 * 2 + 32 + 4
  381.     else
  382.       draw_actor_face(actor, 4, line_height, enabled)
  383.       x = (rect.width - 108) > 96 ? (rect.width - 96) : 102
  384.     end
  385.     if (rect.height - line_height) < (line_height * 3)
  386.       ic = false
  387.       h = (rect.height - line_height) / 2
  388.     else
  389.       ic = true
  390.       h = (rect.height - line_height - 2) / 3
  391.     end
  392.     x += MenuEx3::PX
  393.  
  394.     w = rect.width - x - 4
  395.     draw_actor_hp(actor, x, line_height + h * 0, w)
  396.     draw_actor_mp(actor, x, line_height + h * 1, w)
  397.     if ic
  398.       draw_actor_icons(actor, x, line_height + h * 2, w)
  399.     elsif MenuEx3::CHAR
  400.       # CHAR????2???????????????????
  401.       #draw_actor_icons(actor, 0, rect.height - line_height, 100)
  402.     else
  403.       draw_actor_icons(actor, 0, rect.height - line_height, 100)
  404.     end
  405.   end
  406.   #--------------------------------------------------------------------------
  407.   #  DONGCO129
  408.   #--------------------------------------------------------------------------
  409.   def enable_cursor
  410.     cursor_rect.set(Rect.new(0, 0, contents.width, contents.height))
  411.   end
  412.   def disable_cursor
  413.     cursor_rect.empty
  414.   end
  415.   #--------------------------------------------------------------------------
  416.   # DONGCO130
  417.   #--------------------------------------------------------------------------
  418.   def pending=(flag)
  419.     @pending = flag
  420.     refresh
  421.   end
  422.   #--------------------------------------------------------------------------
  423.   #  DONGCO12567
  424.   #--------------------------------------------------------------------------
  425.   def update
  426.     super
  427.     @char.update if MenuEx3::CHAR
  428.   end
  429. end
  430.  
  431.  
  432. #==============================================================================
  433. # ¦ Window_MenuStatusEx
  434. #==============================================================================
  435. class Window_MenuStatusEx < Window_Selectable
  436.   #--------------------------------------------------------------------------
  437.   #  DONGCO120864
  438.   #--------------------------------------------------------------------------
  439.   attr_reader   :pending_index            # ????(?????)
  440.   #--------------------------------------------------------------------------
  441.   #  DONGCO120617283
  442.   #--------------------------------------------------------------------------
  443.   def initialize(x, y)
  444.     @offset_x = 160
  445.     super(x, y, window_width, window_height)
  446.     create_windows
  447.     self.opacity = 0
  448.     @pending_index = -1
  449.     refresh
  450.   end
  451.   #--------------------------------------------------------------------------
  452.   #  DONGCO215271
  453.   #--------------------------------------------------------------------------
  454.   def dispose
  455.     @windows.each {|w| w.dispose}
  456.     super
  457.   end
  458.   #--------------------------------------------------------------------------
  459.   #  DONGCO120568
  460.   #--------------------------------------------------------------------------
  461.   def show
  462.     @windows.each {|w| w.show}
  463.     super
  464.   end
  465.   #--------------------------------------------------------------------------
  466.   #  DONGCO1206663833
  467.   #--------------------------------------------------------------------------
  468.   def hide
  469.     @windows.each {|w| w.hide}
  470.     super
  471.   end
  472.   #--------------------------------------------------------------------------
  473.   # DONGCO120 ( MAU )
  474.   #--------------------------------------------------------------------------
  475.   def col_max
  476.     MenuEx3::WMAX
  477.   end
  478.   #--------------------------------------------------------------------------
  479.   #  DONGCO199
  480.   #--------------------------------------------------------------------------
  481.   def create_windows
  482.     @windows = []
  483.     w = window_width  / MenuEx3::WMAX
  484.     h = window_height / MenuEx3::HMAX
  485.     item_max.times do |i|
  486.       x = @offset_x + w * (i % MenuEx3::WMAX)
  487.       y = h * (i / MenuEx3::WMAX)
  488.       @windows.push(Window_MenuOneActor.new(x, y, i))
  489.     end
  490.   end
  491.   #--------------------------------------------------------------------------
  492.   #  DONGCOTTTT
  493.   #--------------------------------------------------------------------------
  494.   def window_width
  495.     Graphics.width - @offset_x
  496.   end
  497.   #--------------------------------------------------------------------------
  498.   #  DONGCO123469
  499.   #--------------------------------------------------------------------------
  500.   def window_height
  501.     Graphics.height
  502.   end
  503.   #--------------------------------------------------------------------------
  504.   #  TTT1
  505.   #--------------------------------------------------------------------------
  506.   def item_max
  507.     $game_party.members.size
  508.   end
  509.   #--------------------------------------------------------------------------
  510.   #  DONGCO456
  511.   #--------------------------------------------------------------------------
  512.   def item_height
  513.     (Graphics.height - standard_padding * 2) / MenuEx3::HMAX
  514.   end
  515.   #--------------------------------------------------------------------------
  516.   #  DONGCO120543
  517.   #--------------------------------------------------------------------------
  518.   def draw_item(index)
  519.     @windows[index].refresh
  520.   end
  521.   #--------------------------------------------------------------------------
  522.   #  DONGCOQT1
  523.   #--------------------------------------------------------------------------
  524.   def index=(index)
  525.     @windows[@index].disable_cursor if @index >= 0
  526.     super(index)
  527.     @windows[@index].enable_cursor  if @index >= 0
  528.   end
  529.   #--------------------------------------------------------------------------
  530.   #DONGCOQT2
  531.   #--------------------------------------------------------------------------
  532.   def process_ok
  533.     super
  534.     $game_party.menu_actor = $game_party.members[index]
  535.   end
  536.   #--------------------------------------------------------------------------
  537.   # DONGCOQT3
  538.   #--------------------------------------------------------------------------
  539.   def select_last
  540.     select($game_party.menu_actor.index || 0)
  541.   end
  542.   #--------------------------------------------------------------------------
  543.   # DONGCOQT4
  544.   #--------------------------------------------------------------------------
  545.   def pending_index=(index)
  546.     @windows[@pending_index].pending = false if @pending_index >= 0
  547.     @pending_index = index
  548.     @windows[@pending_index].pending = true  if @pending_index >= 0
  549.   end
  550.   #--------------------------------------------------------------------------
  551.   #DONGCOQT6
  552.   #--------------------------------------------------------------------------
  553.   def top_row=(row)
  554.     super(row)
  555.     h = window_height / MenuEx3::HMAX
  556.     item_max.times do |i|
  557.       @windows[i].y = h * (i / col_max - (top_row * col_max) / col_max)
  558.     end
  559.   end
  560.   #--------------------------------------------------------------------------
  561.   # DONGCOQT7
  562.   #--------------------------------------------------------------------------
  563.   def update
  564.     super
  565.     @windows.each {|w| w.update}
  566.   end
  567.   #--------------------------------------------------------------------------
  568.   # DONGCOQT8
  569.   #--------------------------------------------------------------------------
  570.   def update_cursor
  571.     super
  572.     cursor_rect.empty   # ??????????
  573.   end
  574. end
  575.  
  576.  
  577. #==============================================================================
  578. # ¦ Scene_Menu
  579. #==============================================================================
  580. class Scene_Menu < Scene_MenuBase
  581.   #--------------------------------------------------------------------------
  582.   # DONGCOQT9
  583.   #--------------------------------------------------------------------------
  584.   def create_status_window
  585.     @status_window = Window_MenuStatusEx.new(@command_window.width, 0)
  586.   end
  587. end
Advertisement
Add Comment
Please, Sign In to add comment