じ☆ve冰风 发表于 2026-8-2 18:28:37

Resident Evil ECG

Want to have an ECG showing your health like Resident Evil? Well, now you can!
This script creates a little window with just that at the corner of your screen.

You need this image named "ECG" in the System folder:




Script:
                Ruby:       
#==============================================================================
# Resident Evil ECG v1.1
# by R_Valkyrie
#------------------------------------------------------------------------------
# Free to use for non-commercial and commercial.
#------------------------------------------------------------------------------
# Turn ON switch to show and OFF to hide.
# FINE    = above 50% hp
# CAUTION = 25% - 50% hp
# DANGER= below 25% hp
# POISON= when inflicted with state(POISON_ID)
#==============================================================================

module ECG_Options

WINDOW_POSITION = 0# 0 = top, 1 = bottom
WINDOW_SLIDE    = 24 # sliding speed for the window. set to 0 for instant.
SWITCH_ID       = 1
POISON_ID       = 2

end

class Window_ECG < Window_Base
include ECG_Options
def initialize
    y = WINDOW_POSITION == 0 ? 0 : Graphics.height - 72
    super(0, y, 104, 72)
    @bitmap = Bitmap.new("Graphics/System/ECG")
    @ecg_frame = 160
end
def draw_health(x, y)
    bitmap = @bitmap
    rect = Rect.new(ecg_status * 80, 0, 80, 48)
    contents.blt(x, y, bitmap, rect)
    draw_mask(x, y, 80, 48)
    change_color(ecg_color)
    draw_text(x + 2, y + 28, 100, line_height, actor_status)
end
def draw_mask(x, y, width, height)
    actor = $game_party.leader
    bitmap = @bitmap
    if @ecg_frame <= 0
      @ecg_frame = 80
    else
      @ecg_frame -= 1
    end
    rect = Rect.new(@ecg_frame, height, width, height)
    contents.blt(x, y, bitmap, rect)
end
def ecg_color
    actor = $game_party.leader
    color = 3
    color = 20 if actor.hp <= actor.mhp / 2
    color = 18 if actor.hp <= actor.mhp / 4
    color = 30 if actor.state?(POISON_ID)
    return text_color(color)
end
def ecg_status
    actor = $game_party.leader
    state = 0
    state = 1 if actor.hp <= actor.mhp / 2
    state = 2 if actor.hp <= actor.mhp / 4
    state = 3 if actor.state?(POISON_ID)
    return state
end
def actor_status
    actor = $game_party.leader
    frame = @ecg_frame < 40 || @ecg_frame > 80 && @ecg_frame < 120
    state = "FINE"
    state = "CAUTION" if actor.hp <= actor.mhp / 2
    state = "DANGER!" if actor.hp <= actor.mhp / 4
    state = ""      if actor.hp <= actor.mhp / 4 && frame
    state = "POISON"if actor.state?(POISON_ID)
    return state
end
def refresh
    @ecg_frame = 160 if $game_switches == false
    contents.clear
    actor = $game_party.leader
    contents.font.outline = false
    contents.font.size = 18
    draw_health(0, 0)
end
end

class Scene_Map < Scene_Base
include ECG_Options
alias create_all_windows_and_ecg create_all_windows
def create_all_windows
    create_ecg_window
    create_all_windows_and_ecg
end
def create_ecg_window
    @ecg_viewport = Viewport.new
    @ecg_window = Window_ECG.new
    @ecg_window.viewport = @ecg_viewport
    @ecg_window.viewport.ox = @ecg_window.width
end
def move_ecg_viewport(ox)
    speed = WINDOW_SLIDE == 0 ? @ecg_window.width : WINDOW_SLIDE
    current_ox = @ecg_viewport.ox
    @ecg_viewport.ox = .min if current_ox < ox
    @ecg_viewport.ox = .max if current_ox > ox
end
alias update_ecg update
def update
    @ecg_window.refresh
    new_ox = $game_switches == true ? 0 : @ecg_window.width
    move_ecg_viewport(new_ox)
    update_ecg
end
end




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