じ☆ve冰风 发表于 2026-7-27 11:35:27

SGD | Zalgo-Inspired Text

Zalgo-Inspired Text Version 2.0 (2.1 ish)
SGD​

Note before we start: Below this post is a reply with a fix for choices. Choices did not display correctly and lost their functionality. You can simply replace the part of the code. The Demos (V1 and V2) have not been updated. The original codes in here have. So if you are using the Demo as refference you have to manually tweak it. Please use the Fix for Version 2.0 of the Script down below.

I just finished a new script that lets you create Zalgo-inspired stacked text in RPG Maker XP. It’s designed to work per-line and integrates seamlessly with RMXP’s message system





Features:​


[*]UP, MID, and DOWN diacritics applied to every character.
[*]Per-line control via \z (intensity n ranges 0–15). (Recommended not to go higher than 6 on a lot of text.)
[*]Fully compatible with RMXP’s message system—normal messages, choices, and pauses all work.
[*]No global toggling required; just use \z wherever you want Zalgo text.

Usage:​

Insert \z at the start of any line in your message to activate Zalgo text for that line:
                Ruby:       
\zThis line will appear in Zalgo style at intensity 6
Normal lines remain unaffected


You can mix normal and Zalgo lines in the same message:
                Ruby:       
Normal line
\zZalgo line
Back to normal


Demo here (Version 1.0)

Spoiler: CODE VERSION 1.0                Ruby:       
#==============================================================================
# ** Z A L G OS T A C K E DT E X TF O RR M X P
#------------------------------------------------------------------------------
#Zalgo-Inspired Text by SGD
#------------------------------------------------------------------------------
#Use \z in message text to activate Zalgo with intensity 'n' per line:
#      \z This line will appear in Zalgo style
#      Normal lines remain unaffected.
#
#Hint: would not got too high, affects Frames and can cause stuttering.
#------------------------------------------------------------------------------
#Features:
#    - UP, MID, and DOWN marks applied per character
#    - Per-line control with \z, no global toggle needed
#    - Fully compatible with RMXP messages (no freezing)
#------------------------------------------------------------------------------
#Credits & Alterations:
#    By SGD
#    Based on SGD's previous Zalgo scripts
#------------------------------------------------------------------------------
#Date: 2025-09-01
#For: RPG Maker XP (RGSS, Ruby 1.8.1)
#==============================================================================


module Zalgo
@intensity = 4

UP   = %w( ̍ ̎ ̄ ̅ ̿ ̑ ̆ ̐ ͒ ͗ ͑ )
DOWN = %w( ̞ ̟ ̠ ̤ ̥ ̦ ̩ ̪ ̫ ̬ ̭ )
MID= %w( ̕ ̛ ̡ ̢ ̧ ̨ ̴ ̵ ̶ ͘ ͝ )

def self.intensity; @intensity; end
def self.intensity=(n); @intensity = [.max,15].min; end

def self.sample_up;   UP; end
def self.sample_down; DOWN; end
def self.sample_mid;MID; end
end

#------------------------------------------------------------------------------
# Extend Bitmap to draw Zalgo letters with stacked marks
#------------------------------------------------------------------------------
class Bitmap
def draw_zalgo_char(x, y, ch, intensity, char_width, char_height)
    draw_text(x, y, char_width, char_height, ch)
    return if ch == ' '

    intensity.times do
      ox = x + rand(char_width/2) - char_width/4
      oy = y - rand(char_height/2)
      draw_text(ox, oy, char_width, char_height, Zalgo.sample_up)
    end

    intensity.times do
      ox = x + rand(char_width/2) - char_width/4
      oy = y + rand(char_height/2)
      draw_text(ox, oy, char_width, char_height, Zalgo.sample_down)
    end

    intensity.times do
      ox = x + rand(char_width/2) - char_width/4
      oy = y + rand(char_height/2) - char_height/4
      draw_text(ox, oy, char_width, char_height, Zalgo.sample_mid)
    end
end

def draw_zalgo_text_stacked(x, y, text, height)
    cx = x
    text.scan(/./m) do |ch|
      char_width = self.text_size(ch).width
      char_height = height

      if ch == ' '
      cx += char_width
      next
      end

      draw_zalgo_char(cx, y, ch, Zalgo.intensity, char_width, char_height)
      cx += char_width
    end
end
end

#------------------------------------------------------------------------------
# Patch Window_Message for RMXP to support \z inline
#------------------------------------------------------------------------------
class Window_Message < Window_Selectable
alias zalgo_old_refresh refresh
def refresh
    text = $game_temp.message_text
    return zalgo_old_refresh unless text

    self.contents.clear
    self.contents.font.color = normal_color
    x = 4
    y = 0

    text.split("\n").each do |line|
      intensity = nil

      # Detect \z at the start of the line
      if line =~ /^\\z\[(\d+)\]/i
      intensity = $1.to_i
      line = line.gsub(/^\\z\[\d+\]/i, "")
      end

      if intensity
      Zalgo.intensity = intensity
      self.contents.draw_zalgo_text_stacked(x, y * 32, line, 32)
      else
      self.contents.draw_text(x, y * 32, 480, 32, line)
      end

      y += 1
    end
end
end


UPDATE: VERSION 2.0

Spoiler: CODE: VERSION 2.0                Ruby:       
#==============================================================================
# ** Z A L G OS T A C K E DT E X TF O RR M X P
#------------------------------------------------------------------------------
#Zalgo-Inspired Text by SGD
#------------------------------------------------------------------------------
#Use \z in message text to activate Zalgo with intensity 'n' per line:
#      \z This line will appear in Zalgo style
#      Normal lines remain unaffected.
#
#Hint: Do not set intensity too high — it affects FPS and can cause stuttering.
#------------------------------------------------------------------------------
#Features:
#    - UP, MID, and DOWN marks applied per character
#    - Independent colors and offsets for UP / MID / DOWN marks
#    - Optional per-symbol random color variation
#    - Optional slight random variation for main Zalgo text
#    - Per-line control with \z, no global toggle needed
#    - Fully compatible with RMXP messages (no freezing)
#------------------------------------------------------------------------------
#Credits & Alterations:
#    By SGD
#    Based on SGD's previous Zalgo scripts
#------------------------------------------------------------------------------
#Version 2.0
#Date: 2025-09-02
#For: RPG Maker XP (RGSS, Ruby 1.8.1)
#==============================================================================

module Zalgo
@intensity = 4

# -------------------------------
# Configurable settings
# -------------------------------
COLOR_MAIN = Color.new(255, 100, 255) # main Zalgo character color
RANDOM_COLOR_MAIN = true            # slight random variation for main Zalgo character

COLOR_UP   = Color.new(255, 100, 100) # reddish for UP marks
COLOR_MID= Color.new(100, 255, 100) # greenish for MID marks
COLOR_DOWN = Color.new(100, 100, 255) # bluish for DOWN marks

OFFSET_UP_Y   = 0# vertical offset for UP marks
OFFSET_MID_Y= 0# vertical offset for MID marks
OFFSET_DOWN_Y = 0# vertical offset for DOWN marks

RANDOM_COLOR_VARIATION = true
RANDOM_VARIATION_RANGE= 50   # max +/- change per RGB channel

# Marks
UP   = %w( ̍ ̎ ̄ ̅ ̿ ̑ ̆ ̐ ͒ ͗ ͑ ̇ ̈ ̊ ̋ ̌ ̏ ᷄ ᷅ ᷆ ᷇ ᷈ )
DOWN = %w( ̞ ̟ ̠ ̤ ̥ ̦ ̩ ̪ ̫ ̬ ̭ ̡ ̢ ̧ ̰ ̱ ̲ ̳ ̹ ̺ ̻ ͅ )
MID= %w( ̕ ̛ ̡ ̢ ̧ ̨ ̴ ̵ ̶ ͘ ͝ ̽ ̾ ͜ ͝ ͞ ͟ ͠ ͢ ͣ ͤ )

#---------------------------------------------------------------------------
# Helpers
#---------------------------------------------------------------------------
def self.intensity; @intensity; end
def self.intensity=(n); @intensity = [.max,15].min; end

def self.sample_up;   UP; end
def self.sample_down; DOWN; end
def self.sample_mid;MID; end

# Randomize a Color object slightly
def self.randomize_color(base_color)
    return base_color unless RANDOM_COLOR_VARIATION
    r = [.max, 255].min
    g = [.max, 255].min
    b = [.max, 255].min
    Color.new(r, g, b, base_color.alpha)
end
end

#------------------------------------------------------------------------------
# Extend Bitmap to draw Zalgo letters with stacked marks
#------------------------------------------------------------------------------
class Bitmap
def draw_zalgo_char(x, y, ch, intensity, char_width, char_height)
    return if ch == ' '

    # ---- Draw main Zalgo character ----
    main_color = Zalgo::COLOR_MAIN
    main_color = Zalgo.randomize_color(main_color) if Zalgo::RANDOM_COLOR_MAIN
    self.font.color = main_color
    draw_text(x, y, char_width, char_height, ch)

    # ---- Draw UP marks ----
    intensity.times do
      ox = x + rand(char_width/2) - char_width/4
      oy = y - rand(char_height/2) + Zalgo::OFFSET_UP_Y
      self.font.color = Zalgo.randomize_color(Zalgo::COLOR_UP)
      draw_text(ox, oy, char_width, char_height, Zalgo.sample_up)
    end

    # ---- Draw DOWN marks ----
    intensity.times do
      ox = x + rand(char_width/2) - char_width/4
      oy = y + rand(char_height/2) + Zalgo::OFFSET_DOWN_Y
      self.font.color = Zalgo.randomize_color(Zalgo::COLOR_DOWN)
      draw_text(ox, oy, char_width, char_height, Zalgo.sample_down)
    end

    # ---- Draw MID marks ----
    intensity.times do
      ox = x + rand(char_width/2) - char_width/4
      oy = y + rand(char_height/2) - char_height/4 + Zalgo::OFFSET_MID_Y
      self.font.color = Zalgo.randomize_color(Zalgo::COLOR_MID)
      draw_text(ox, oy, char_width, char_height, Zalgo.sample_mid)
    end
end

def draw_zalgo_text_stacked(x, y, text, height)
    cx = x
    text.scan(/./m) do |ch|
      char_width= self.text_size(ch).width
      char_height = height

      if ch == ' '
      cx += char_width
      next
      end

      draw_zalgo_char(cx, y, ch, Zalgo.intensity, char_width, char_height)
      cx += char_width
    end
end
end

#------------------------------------------------------------------------------
# Patch Window_Message for RMXP to support \z inline (line-level)
#------------------------------------------------------------------------------
class Window_Message < Window_Selectable
alias zalgo_old_refresh refresh
def refresh
    # If this is a choice message, skip Zalgo and use normal refresh
    if $game_temp.choice_max > 0
      return zalgo_old_refresh
    end

    text = $game_temp.message_text
    return zalgo_old_refresh unless text

    self.contents.clear
    x = 4
    y = 0

    text.split("\n").each do |line|
      intensity = nil

      # Detect \z at the start of the line
      if line =~ /^\\z\[(\d+)\]/i
      intensity = $1.to_i
      line = line.gsub(/^\\z\[\d+\]/i, "")
      end

      if intensity
      Zalgo.intensity = intensity
      self.contents.draw_zalgo_text_stacked(x, y * 32, line, 32)
      else
      self.contents.font.color = normal_color
      self.contents.draw_text(x, y * 32, 480, 32, line)
      end

      y += 1
    end
end
end


New Features for Version 2.0:

[*]Independent mark offsets: Vertical adjustments for UP, MID, and DOWN marks (OFFSET_UP_Y, etc.).
[*]Independent colors for marks: COLOR_UP, COLOR_MID, COLOR_DOWN.
[*]Optional random color variation: Slight per-symbol color changes for marks.
[*]Main Zalgo text color: COLOR_MAIN, with optional random variation (RANDOM_COLOR_MAIN).
[*]Marks and main text fully separated: Randomization for marks does not affect normal or main text.
[*]Expanded mark sets: More symbols for UP, MID, and DOWN marks for a richer effect.

Screenshot Version 2.0





Download Demo here (Version 2.0)

Credits:​


[*]By SGD
[*]Based on SGD’s previous "SGD | Zalgo-Inspired Text" script



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