设为首页收藏本站同能贴吧 切换语言 繁体中文
开启辅助访问 切换到窄版
扫描二维码关注官方公众号
返回列表
+ 发新帖
查看: 117|回复: 0

[转载发布] Scrolling Battle Log

[复制链接]
累计送礼:
0 个
累计收礼:
1 个
  • TA的每日心情
    开心
    2026-7-12 04:10
  • 签到天数: 209 天

    连续签到: 2 天

    [LV.7]常住居民III

    9071

    主题

    864

    回帖

    6万

    积分

    管理员

    Rank: 9Rank: 9Rank: 9

    VIP
    7
    卡币
    58883
    OK点
    16
    推广点
    0
    同能卷
    50
    积分
    68848

    灌水之王

    发表于 2026-8-2 16:04:21 | 显示全部楼层 |阅读模式
    This script makes the messages in the battle log scroll upwards instead of the default show and pop.

    It's plug and play with additional settings and free to use for both non-commercial and commercial games, but please give credit to me if you do


    Spoiler: Script v1.4
                    Code:       
    1. #==============================================================================
    2. # Scrolling Battle Log v1.4
    3. # by R_Valkyrie
    4. #------------------------------------------------------------------------------
    5. # Plug-n-Play.
    6. # Free to use for non-commercial and commercial, just give credit to me.
    7. #==============================================================================
    8. #------------------------------------------------------------------------------
    9. # Settings
    10. #------------------------------------------------------------------------------
    11. module SCROLLING_BATTLE_LOG
    12.   LOG_X = 0
    13.   LOG_Y = 0
    14.   LOG_WIDTH = 544
    15.   LOG_HEIGHT = 6     #How many lines the log will show during battle
    16.                      #and also the fitting height for the window.
    17.                     
    18.   LOG_OPACITY = 60   #Opacity for the backlines.
    19.   LOG_SPEED = 60     #How long the log will wait between every message.
    20.   SCROLL_SPEED = 3   #How fast the log will scroll. Set to 0 for instant scroll.
    21.   TEXT_FONT = ""     #Type the font name within the "" if you want to use
    22.                      #a different font for your log or leave it blank if not.
    23.                     
    24.   TEXT_SIZE = 0      #Type the size of the font. Set to 0 for default font size.
    25.                     
    26.   TEXT_ALIGNMENT = 0 #Alignment for the displayed text.
    27.                      # 0 = right, 1 = center, 2 = left.
    28.                     
    29.   TEXT_BOLD = false  #Set to true if you want a bold font.
    30.   USE_WINDOW = false #Set to true if you want to show a window
    31.                      #instead of the lines.
    32. end
    33. #------------------------------------------------------------------------------
    34. # Don't edit anything below this line unless you know what you're doing.
    35. #------------------------------------------------------------------------------
    36. class Window_BattleLog < Window_Selectable
    37.   include SCROLLING_BATTLE_LOG
    38.   def initialize
    39.     super(LOG_X, LOG_Y, LOG_WIDTH, window_height)
    40.     self.z = 200
    41.     self.opacity = 0
    42.     self.arrows_visible = false
    43.     self.contents.font.name = TEXT_FONT unless TEXT_FONT == ""
    44.     self.contents.font.size = TEXT_SIZE unless TEXT_SIZE == 0
    45.     self.contents.font.bold = TEXT_BOLD
    46.     @lines = []
    47.     @num_wait = 0
    48.     create_back_bitmap
    49.     create_back_sprite
    50.     refresh
    51.   end
    52.   def max_line_number
    53.     return 500
    54.   end
    55.   def line_height
    56.     lh = (TEXT_SIZE == 0 ? Font.default_size : TEXT_SIZE) + 2
    57.     return lh
    58.   end
    59.   def clear
    60.     self.oy = 0
    61.     @lines.clear
    62.     refresh
    63.   end
    64.   def back_one
    65.     #
    66.   end
    67.   def add_text(text)
    68.     if @lines.size > (LOG_HEIGHT - 1)
    69.       distance = line_height
    70.       speed = SCROLL_SPEED == 0 ? line_height : SCROLL_SPEED
    71.       until distance == 0 do
    72.         self.oy += distance < speed ? distance : speed
    73.         distance -= distance < speed ? distance : speed
    74.         Graphics.update
    75.       end
    76.     end
    77.     @lines.push(text)
    78.     refresh
    79.   end
    80.   def refresh
    81.     draw_background if @lines.size < (LOG_HEIGHT + 1)
    82.     contents.clear
    83.     @lines.size.times {|i| draw_line(i) }
    84.   end
    85.   def back_opacity
    86.     USE_WINDOW ? 0 : LOG_OPACITY
    87.   end
    88.   def draw_line(line_number)
    89.     rect = item_rect_for_text(line_number)
    90.     contents.clear_rect(rect)
    91.     text_width = LOG_WIDTH - (standard_padding * 2)
    92.     ta = TEXT_ALIGNMENT
    93.     wx = ta == 2 ? -2 : rect.x
    94.     draw_text(wx, rect.y, text_width, line_height, @lines[line_number], ta)
    95.   end
    96.   def message_speed
    97.     return LOG_SPEED
    98.   end
    99.   def wait_and_clear
    100.     #
    101.   end
    102.   def display_current_state(subject)
    103.     unless subject.most_important_state_text.empty?
    104.       add_text(subject.name + subject.most_important_state_text)
    105.       wait
    106.     end
    107.   end
    108.   def display_action_results(target, item)
    109.     if target.result.used
    110.       display_critical(target, item)
    111.       display_damage(target, item)
    112.       display_affected_status(target, item)
    113.       display_failure(target, item)
    114.     end
    115.   end
    116.   def display_affected_status(target, item)
    117.     if target.result.status_affected?
    118.       display_changed_states(target)
    119.       display_changed_buffs(target)
    120.     end
    121.   end
    122.   def display_auto_affected_status(target)
    123.     if target.result.status_affected?
    124.       display_affected_status(target, nil)
    125.     end
    126.   end
    127.   def display_added_states(target)
    128.     target.result.added_state_objects.each do |state|
    129.       state_msg = target.actor? ? state.message1 : state.message2
    130.       target.perform_collapse_effect if state.id == target.death_state_id
    131.       next if state_msg.empty?
    132.       add_text(target.name + state_msg)
    133.       wait
    134.       wait_for_effect
    135.     end
    136.   end
    137.   def display_removed_states(target)
    138.     target.result.removed_state_objects.each do |state|
    139.       next if state.message4.empty?
    140.       add_text(target.name + state.message4)
    141.       wait
    142.     end
    143.   end
    144.   def display_buffs(target, buffs, fmt)
    145.     buffs.each do |param_id|
    146.       add_text(sprintf(fmt, target.name, Vocab::param(param_id)))
    147.       wait
    148.     end
    149.   end
    150. end
    151. class Window_DummyLog < Window_BattleLog
    152.   def max_line_number
    153.     return LOG_HEIGHT
    154.   end
    155.   def add_text(text)
    156.     #
    157.   end
    158. end
    159. class Scene_Battle < Scene_Base
    160.   include SCROLLING_BATTLE_LOG
    161.   alias update_message_open_and_clear_log update_message_open
    162.   def update_message_open
    163.     if $game_message.busy?
    164.       @log_window.clear
    165.       @log_window.close
    166.       @dummy_window.close
    167.     end
    168.     update_message_open_and_clear_log
    169.   end
    170.   alias create_all_windows_with_dummy create_all_windows
    171.   def create_all_windows
    172.     create_dummy_window
    173.     create_all_windows_with_dummy
    174.   end
    175.   def create_dummy_window
    176.     @dummy_window = Window_DummyLog.new
    177.     @dummy_window.z = 199
    178.     @dummy_window.openness = 0
    179.     @dummy_window.opacity = 255
    180.   end
    181.   alias turn_start_with_dummy turn_start
    182.   def turn_start
    183.     @log_window.open
    184.     @dummy_window.open if USE_WINDOW == true
    185.     turn_start_with_dummy
    186.   end
    187.   def turn_end
    188.     all_battle_members.each do |battler|
    189.       battler.on_turn_end
    190.       refresh_status
    191.       @log_window.display_auto_affected_status(battler)
    192.     end
    193.     @log_window.clear
    194.     @dummy_window.close
    195.     BattleManager.turn_end
    196.     process_event
    197.     start_party_command_selection
    198.   end
    199.   def process_action
    200.     return if scene_changing?
    201.     if !@subject || !@subject.current_action
    202.       @subject = BattleManager.next_subject
    203.     end
    204.     return turn_end unless @subject
    205.     if @subject.current_action
    206.       @subject.current_action.prepare
    207.       if @subject.current_action.valid?
    208.         @status_window.open
    209.         @log_window.open
    210.         @dummy_window.open if USE_WINDOW == true
    211.         execute_action
    212.       end
    213.       @subject.remove_current_action
    214.     end
    215.     process_action_end unless @subject.current_action
    216.   end
    217. end
    复制代码




    本贴来自国际rpgmaker官方论坛作者:R_Valkyrie处,因国际论坛即将永久关站,为了存档多年珍贵资料,署名转载到本论坛存档,由于官方帖子为英文原帖,需要中文翻译请点击论坛顶部切换语言为中文就可以将帖子翻译成中文浏览,方便大家随时查看,原文地址:https://forums.rpgmakerweb.com/threads/scrolling-battle-log.93999/

    本帖子中包含更多资源

    您需要 登录 才可以下载或查看,没有账号?立即注册

    x
    天天去同能,天天有童年!
    回复 送礼论坛版权

    使用道具 举报

    文明发言,和谐互动
    文明发言,和谐互动
    高级模式
    您需要登录后才可以回帖 登录 | 立即注册

    本版积分规则

    简体中文
    繁體中文
    English(英语)
    日本語(日语)
    Deutsch(德语)
    Русский язык(俄语)
    بالعربية(阿拉伯语)
    Türkçe(土耳其语)
    Português(葡萄牙语)
    ภาษาไทย(泰国语)
    한어(朝鲜语/韩语)
    Français(法语)
    关闭

    幸运抽奖

    社区每日抽奖来袭,快来试试你是欧皇还是非酋~

    立即查看

    聊天机器人
    Loading...

    QQ|Archiver|手机版|小黑屋|同能RPG制作大师 ( 沪ICP备12027754号-3 )

    GMT+8, 2026-8-17 10:29 , Processed in 0.141403 second(s), 53 queries .

    Powered by Discuz! X3.4

    Copyright © 2001-2020, Tencent Cloud.

    快速回复 返回顶部 返回列表