<解決済み>ニコニコ動画風コメントをVXAceでも使いたい

たかな
記事: 48
登録日時: 2020年4月26日(日) 11:17

<解決済み>ニコニコ動画風コメントをVXAceでも使いたい

投稿記事by たかな » 2020年4月27日(月) 16:53

https://hikimoki.sakura.ne.jp/index.php ... _mini#nico
ひきも記さんのニコニコ動画風コメントスクリプトをVXAceに取り入れたいので、
RGSS3用に移植出来る方はどうかよろしくお願いいたします。
最後に編集したユーザー たかな on 2020年4月28日(火) 11:30 [ 編集 1 回目 ]

TOMO
記事: 343
登録日時: 2015年11月16日(月) 20:12
連絡を取る:

Re: ニコニコ動画風コメントをVXAceでも使いたい

投稿記事by TOMO » 2020年4月27日(月) 22:15

こんな感じでいいですか?

コード: 全て選択

#==============================================================================
# ★ ニコニコ動画風コメントスクリプト
#------------------------------------------------------------------------------
# tomoaky (http://hikimoki.sakura.ne.jp/)
# 2010/02/05  機能追加
# 2009/11/01   バグ修正、機能追加
# 2009/10/29   公開
#
# RPGツクールVXにニコニコ動画風のコメントを流すネタスクリプトです、
# "▼ 素材" と "▼ メイン" の間に挿入してください。
# 手動でコメントを流すこともできます、イベントコマンドのスクリプトで
# 以下のように入力してください。
# comment(text, color, count, option)
# 例 : comment("大丈夫?結婚する?", 1, 1, 2)
# textにコメントの内容、colorに色のインデックス(文章入力の\C[n]と同じです)、
# countに流れるまでの待機時間、optionは1なら左から右へ流れ、2なら真ん中固定に
# なります。color, count, optionの3つは省略可能です。
#==============================================================================

#==============================================================================
# ■ 設定項目
#==============================================================================
module NICO
  module Options
    MAX_COMMENT = 16          # コメントの最大同時表示数
    COMMENT_SPEED = 3         # コメントの移動速度
    AUTO_COMMENT_COUNT = 300  # 指定フレーム数の50%~150%が自動コメントの間隔
    SWT_GAIN_ITEM = 1         # アイテム入手コメント停止に使うゲームスイッチID
    SWT_GAIN_GOLD = 2         # お金入手コメント停止に使うゲームスイッチID
    SWT_COMMENT_OFF = 3       # コメント機能を無効化するゲームスイッチID
   
    CM_FKEY = [               # ファンクションキーコメント
      "うぽつ",                                # F5
      "大丈夫?結婚する?",                    # F6
      "わんわんお",                            # F7
      "ゆっくりしていってね",                  # F8
      "ダメだこいつ、はやくなんとかしないと",  # F9
    ]
    CM_NORMAL = [             # ノンジャンルコメント
      "www",
      "うぽつ",
      "でおちwww",
      "市場www",
      "アスペクト比おかしい",
      "エコノミー涙目"
    ]
    CM_PLAYTIME = [           # プレイ時間に関するコメント
      "プレイ時間%sとかwww",
      "ちょ!%sw",
      "%sか……",
      "長いな"
    ]
    CM_GAIN_ITEM = [          # アイテム入手時のコメント
      "%sktkr",
      "%sうめぇw",
      "%sってレア?",
      "売れw"
    ]
    CM_GAIN_GOLD = [          # お金入手時のコメント
      "財布が潤ったなw",
      "%sもww",
      "%sぽっちかよw",
    ]
    CM_ACTOR_DAMAGE = [       # 味方がダメージを受けたときのコメント
      "やべぇ",
      "%dも喰らった!",
      "%dww",
    ]
    CM_ENEMY_DAMAGE = [       # 敵にダメージを与えたときのコメント
      "おお",
      "%dか……",
      "%dとかww",
    ]
    CM_ACTOR_RECOVER = [      # 味方が回復したときのコメント
      "回復しすぎw",
      "%dww",
      "慎重だな",
    ]
    CM_ENEMY_RECOVER = [      # 敵が回復したときのコメント
      "うぜぇww",
      "%dもか",
      "敵w",
    ]
    CM_ACTOR_MISS = [         # 味方が攻撃を回避したときのコメント
      "ナイスw",
      "よく避けた!",
      "神回避ktkr",
    ]
    CM_ENEMY_MISS = [         # 敵が攻撃を回避したときのコメント
      "ちょ、うぜぇwww",
      "避けるなw",
      "やばくね?",
    ]
    CM_ACTOR_ADD_STATE = [    # 味方にステートが付加されたときのコメント
      "%sだw",
    ]
    CM_ENEMY_ADD_STATE = [    # 敵にステートが付加されたときのコメント
      "お、%sじゃん",
    ]
    CM_ENCOUNT = [            # 戦闘開始時のコメント
      "出たww",
      "うはw",
      "勝てるのかこれ",
    ]
    CM_VICTORY = [            # 戦闘勝利時のコメント
      "おつ",
      "勝ったw",
      "たいしたことなかったな",
    ]
    CM_DEFEAT = [             # 戦闘敗北時のコメント
      "ちょwwww",
      "死ぬなw",
      "おいww",
    ]
  end
end

#==============================================================================
# ■ コマンド
#==============================================================================
module NICO
  module Commands
    module_function
    #--------------------------------------------------------------------------
    # ○ コメントを流す
    #--------------------------------------------------------------------------
    def comment(text, color = 0, count = 1, option = 0)
      $game_temp.add_comment(text, color, count, option)
    end
  end
end
class Game_Interpreter
  include NICO::Commands
end

#==============================================================================
# ■ Game_Temp
#==============================================================================
class Game_Temp
  #--------------------------------------------------------------------------
  # ● 公開インスタンス変数
  #--------------------------------------------------------------------------
  attr_accessor :comments                   # コメント
  #--------------------------------------------------------------------------
  # ● オブジェクト初期化
  #--------------------------------------------------------------------------
  alias nico_game_temp_initialize initialize
  def initialize
    nico_game_temp_initialize
    @cm_count = NICO::Options::AUTO_COMMENT_COUNT # 自然発生コメントのカウント
    @comments = []
    for i in 0...NICO::Options::MAX_COMMENT
      @comments[i] = Game_Comment.new
    end
  end
  #--------------------------------------------------------------------------
  # ○ コメントの追加
  #--------------------------------------------------------------------------
  def add_comment(text, color = 0, count = 1, option = 0)
    return if $game_switches[NICO::Options::SWT_COMMENT_OFF]
    for comment in @comments
      if comment.erased?
        comment.set(text, color, count, option)
        break
      end
    end
  end
  #--------------------------------------------------------------------------
  # ○ コメントの更新
  #--------------------------------------------------------------------------
  def update_comment
    for comment in @comments do comment.update end
      @cm_count -= 1
      if @cm_count == 0
        add_auto_comment
        @cm_count = NICO::Options::AUTO_COMMENT_COUNT
        @cm_count += rand(@cm_count) - @cm_count / 2
      end
  end
  #--------------------------------------------------------------------------
  # ○ 自動コメントの追加
  #--------------------------------------------------------------------------
  def add_auto_comment
    case rand(4)
    when 0..2     # ノンジャンルコメント
      text = NICO::Options::CM_NORMAL[rand(NICO::Options::CM_NORMAL.size)]
    when 3        # プレイ時間に関するコメント
      total_sec = Graphics.frame_count / Graphics.frame_rate
      hour = total_sec / 60 / 60
      min = total_sec / 60 % 60
      sec = total_sec % 60
      time_string = sprintf("%02d:%02d:%02d", hour, min, sec)
      text = NICO::Options::CM_PLAYTIME[rand(NICO::Options::CM_PLAYTIME.size)]
      text = sprintf(text, time_string)
    end
    add_comment(text)
  end
end

#==============================================================================
# ■ Game_Comment
#==============================================================================
class Game_Comment
  @@test_bitmap = Bitmap.new(16, 16)      # 横幅取得用スプライト
  @@test_bitmap.font.name = ["MS 明朝", "UmePlus Gothic"]
  @@test_bitmap.font.bold = true
  #--------------------------------------------------------------------------
  # ○ 公開インスタンス変数
  #--------------------------------------------------------------------------
  attr_reader   :x                        # 画面 X 座標
  attr_reader   :y                        # 画面 Y 座標
  attr_reader   :width                    # コメントの横幅
  attr_reader   :text                     # コメントの内容
  attr_reader   :color                    # カラーID
  attr_reader   :count                    # 流れるまでの待機カウント
  #--------------------------------------------------------------------------
  # ○ オブジェクト初期化
  #--------------------------------------------------------------------------
  def initialize
    @x = 0
    @y = -24
    @text = ""
    @count = 0
  end
  #--------------------------------------------------------------------------
  # ○ コメントのセット
  #--------------------------------------------------------------------------
  def set(text, color, count, option)
    @text = text
    @color = color
    @count = count
    @option = option
    @width = @@test_bitmap.text_size(@text).width
  end
  #--------------------------------------------------------------------------
  # ○ コメントの消去
  #--------------------------------------------------------------------------
  def erase
    @text = ""
  end
  #--------------------------------------------------------------------------
  # ○ コメントが消去されているかを返す
  #--------------------------------------------------------------------------
  def erased?
    return (@text == "")
  end
  #--------------------------------------------------------------------------
  # ○ フレーム更新
  #--------------------------------------------------------------------------
  def update
    return if erased?
    @count -= 1
    if @count == 0    # カウントが0になったらコメントを流す
      if @option & 1 != 0       # 左から右へ流れる場合
        @x = 0 - @width
      elsif @option & 2 != 0    # 画面下部中央へ表示する場合
        @x = (Graphics.width - @width) / 2
        @y = 220
        return
      else                      # 通常表示の場合
        @x = Graphics.width
      end
      hit = []
      for comment in $game_temp.comments    # 他のコメントとの接触判定
        next if comment.erased? or comment.count > 0
        next if @x > comment.x + comment.width or @x + @width <= comment.x
        hit.push(comment.y)
      end
      for i in 0...10
        @y = i * 24 + 4
        break unless hit.include?(@y)
      end
    else
      if @option & 1 != 0           # 左から右へ流れる場合
        @x += NICO::Options::COMMENT_SPEED
        erase if @x == Graphics.width     # 画面外へ出たら削除
      elsif @option & 2 != 0        # 画面下部中央へ表示する場合
        erase if @count == -300           # 5秒後に削除
      else                          # 通常表示の場合
        @x -= NICO::Options::COMMENT_SPEED
        erase if @x <= 0 - @width         # 画面外へ出たら削除
      end
    end
  end
end

#==============================================================================
# ■ Game_Party
#==============================================================================
class Game_Party < Game_Unit
  #--------------------------------------------------------------------------
  # ● ゴールドの増加 (減少)
  #--------------------------------------------------------------------------
  alias nico_game_party_gain_gold gain_gold
  def gain_gold(n)
    if n > 0 and not $game_switches[NICO::Options::SWT_GAIN_GOLD]
      r = rand(NICO::Options::CM_GAIN_GOLD.size)
      text = sprintf("%d%s", n, Vocab::currency_unit)
      $game_temp.add_comment(sprintf(NICO::Options::CM_GAIN_GOLD[r], text))
    end
    nico_game_party_gain_gold(n)
  end
  #--------------------------------------------------------------------------
  # ● アイテムの増加 (減少)
  #--------------------------------------------------------------------------
  alias nico_game_party_gain_item gain_item
  def gain_item(item, n, include_equip = false)
    if item != nil and n > 0 and not $game_switches[NICO::Options::SWT_GAIN_ITEM]
      r = rand(NICO::Options::CM_GAIN_ITEM.size)
      $game_temp.add_comment(sprintf(NICO::Options::CM_GAIN_ITEM[r], item.name))
    end
    nico_game_party_gain_item(item, n, include_equip)
  end
end

#==============================================================================
# ■ Game_Actor
#==============================================================================
class Game_Actor < Game_Battler
  #--------------------------------------------------------------------------
  # ● 装備の変更 (オブジェクトで指定)
  #     equip_type : 装備部位 (0..4)
  #     item       : 武器 or 防具 (nil なら装備解除)
  #     test       : テストフラグ (戦闘テスト、または装備画面での一時装備)
  #--------------------------------------------------------------------------
  alias nico_game_actor_change_equip change_equip
  def change_equip(equip_type, item)
    flag = $game_switches[NICO::Options::SWT_GAIN_ITEM]
    $game_switches[NICO::Options::SWT_GAIN_ITEM] = true
    nico_game_actor_change_equip(equip_type, item)
    $game_switches[NICO::Options::SWT_GAIN_ITEM] = flag
  end
end

#==============================================================================
# ■ Sprite_Comment
#==============================================================================
class Sprite_Comment < Sprite
  #--------------------------------------------------------------------------
  # ● オブジェクト初期化
  #     comment  : コメント (Game_Comment)
  #--------------------------------------------------------------------------
  def initialize(comment)
    super(nil)
    @dummy_window = Window_Base.new(-64, -64, 64, 64)
    @comment = comment
    self.z = 9999
  end
  #--------------------------------------------------------------------------
  # ● 解放
  #--------------------------------------------------------------------------
  def dispose
    self.bitmap.dispose if self.bitmap != nil
    super
  end
  #--------------------------------------------------------------------------
  # ● フレーム更新
  #--------------------------------------------------------------------------
  def update
    super
    if @text != @comment.text and @comment.count <= 0
      @text = @comment.text
      if @text != ""
        self.bitmap = Bitmap.new(@comment.width, 24)
        self.bitmap.font.name = ["MS 明朝", "UmePlus Gothic"]
        self.bitmap.font.bold = true
        self.bitmap.font.color = @dummy_window.text_color(@comment.color)
        self.bitmap.draw_text(0, 0, @comment.width, 24, @text)
      end
    end
    if @text == ""
      self.visible = false
    else
      self.visible = true
      self.x = @comment.x
      self.y = @comment.y
    end
  end
end

#==============================================================================
# ■ Scene_Base
#==============================================================================
class Scene_Base
  #--------------------------------------------------------------------------
  # ● 開始処理
  #--------------------------------------------------------------------------
  alias nico_scene_base_start start
  def start
    nico_scene_base_start
    @sprite_comments = []
    if $game_temp != nil
      for i in 0...NICO::Options::MAX_COMMENT
        @sprite_comments.push(Sprite_Comment.new($game_temp.comments[i]))
      end
    end
  end
  #--------------------------------------------------------------------------
  # ● フレーム更新
  #--------------------------------------------------------------------------
  alias nico_scene_base_update update
  def update
    nico_scene_base_update
    for sprite in @sprite_comments do sprite.update end
    $game_temp.update_comment
    [:F5, :F6, :F7, :F8, :F9].each_with_index do |key, i|
#~     for i in 0...5
      $game_temp.add_comment(NICO::Options::CM_FKEY[i]) if Input.trigger?(key)
    end
  end
  #--------------------------------------------------------------------------
  # ● 終了処理
  #--------------------------------------------------------------------------
  alias nico_scene_base_terminate terminate
  def terminate
    nico_scene_base_terminate
    for sprite in @sprite_comments do sprite.dispose end
  end
end

#==============================================================================
# ■ Scene_Title
#==============================================================================
class Scene_Title < Scene_Base
  #--------------------------------------------------------------------------
  # ● 開始処理
  #--------------------------------------------------------------------------
  alias nico_scene_title_start start
  def start
    nico_scene_title_start
    # コメントスプライトの再作成
    for sprite in @sprite_comments do sprite.dispose end
    @sprite_comments.clear
    if $game_temp != nil
      for i in 0...NICO::Options::MAX_COMMENT
        @sprite_comments.push(Sprite_Comment.new($game_temp.comments[i]))
      end
    end
  end
end

#==============================================================================
# ■ Scene_Map
#==============================================================================
class Scene_Map < Scene_Base
  #--------------------------------------------------------------------------
  # ● 基本更新処理
  #--------------------------------------------------------------------------
  alias nico_scene_map_update_basic update_basic
  def update_basic
    nico_scene_map_update_basic
    $game_temp.update_comment
    for sprite in @sprite_comments do sprite.update end
  end
end

#==============================================================================
# ■ Scene_Battle
#==============================================================================
class Scene_Battle < Scene_Base
  #--------------------------------------------------------------------------
  # ● 基本更新処理
  #--------------------------------------------------------------------------
  alias nico_scene_battle_update_basic update_basic
  def update_basic
    nico_scene_battle_update_basic
    $game_temp.update_comment
    for sprite in @sprite_comments do sprite.update end
  end
  #--------------------------------------------------------------------------
  # ● 戦闘開始の処理
  #--------------------------------------------------------------------------
  alias nico_scene_battle_battle_start battle_start
  def battle_start
    r = rand(NICO::Options::CM_ENCOUNT.size)
    $game_temp.add_comment(NICO::Options::CM_ENCOUNT[r])
    nico_scene_battle_battle_start
  end
end

class << BattleManager
  #--------------------------------------------------------------------------
  # ● 勝利の処理
  #--------------------------------------------------------------------------
  alias nico_scene_battle_process_victory process_victory
  def process_victory
    r = rand(NICO::Options::CM_VICTORY.size)
    $game_temp.add_comment(NICO::Options::CM_VICTORY[r])
    nico_scene_battle_process_victory
  end
  #--------------------------------------------------------------------------
  # ● 敗北の処理
  #--------------------------------------------------------------------------
  alias nico_scene_battle_process_defeat process_defeat
  def process_defeat
    r = rand(NICO::Options::CM_DEFEAT.size)
    $game_temp.add_comment(NICO::Options::CM_DEFEAT[r])
    nico_scene_battle_process_defeat
  end
end

class Window_BattleLog
  #--------------------------------------------------------------------------
  # ● ミスの表示
  #--------------------------------------------------------------------------
  alias nico_scene_battle_display_miss display_miss
  def display_miss(target, obj = nil)
    nico_scene_battle_display_miss(target, obj)
    comments = target.actor? ? NICO::Options::CM_ACTOR_MISS : NICO::Options::CM_ENEMY_MISS
    $game_temp.add_comment(comments[rand(comments.size)])
  end
  #--------------------------------------------------------------------------
  # ● 回避の表示
  #--------------------------------------------------------------------------
  alias nico_scene_battle_display_evasion display_evasion
  def display_evasion(target, obj = nil)
    nico_scene_battle_display_evasion(target, obj)
    comments = target.actor? ? NICO::Options::CM_ACTOR_MISS : NICO::Options::CM_ENEMY_MISS
    $game_temp.add_comment(comments[rand(comments.size)])
  end
  #--------------------------------------------------------------------------
  # ● HP ダメージ表示
  #--------------------------------------------------------------------------
  alias nico_scene_battle_display_hp_damage display_hp_damage
  def display_hp_damage(target, obj = nil)
    nico_scene_battle_display_hp_damage(target, obj)
    return if target.result.hp_damage == 0         # ダメージ0なら終了
    if target.result.hp_damage > 0                 # ダメージ
      comments = target.actor? ? NICO::Options::CM_ACTOR_DAMAGE : NICO::Options::CM_ENEMY_DAMAGE
    elsif target.result.hp_damage < 0              # 回復
      comments = target.actor? ? NICO::Options::CM_ACTOR_RECOVER : NICO::Options::CM_ENEMY_RECOVER
    end
    $game_temp.add_comment(sprintf(comments[rand(comments.size)], target.result.hp_damage.abs))
  end
  #--------------------------------------------------------------------------
  # ● 付加されたステートの表示
  #--------------------------------------------------------------------------
  alias nico_scene_battle_display_added_states display_added_states
  def display_added_states(target)
    for state in target.result.added_state_objects
      comments = target.actor? ? NICO::Options::CM_ACTOR_ADD_STATE : NICO::Options::CM_ENEMY_ADD_STATE
      $game_temp.add_comment(sprintf(comments[rand(comments.size)], state.name))
    end
    nico_scene_battle_display_added_states(target)
  end
end

【追記】
私はひきも記様本人ではありません
名前が似てるだけの別人です
勘違いでひきも記様に迷惑を掛けられても困るので書きました
最後に編集したユーザー TOMO on 2020年4月30日(木) 15:07 [ 編集 1 回目 ]
たかな
記事: 48
登録日時: 2020年4月26日(日) 11:17

Re: <解決済み>ニコニコ動画風コメントをVXAceでも使いたい

投稿記事by たかな » 2020年4月28日(火) 14:13

制作者さん自らどうもありがとうございます。
フォントが "MS 明朝" だと違和感があるので、 "VL ゴシック" に改変させていただきます。
あと、タイトルに戻るとエラーを吐くので、233行目の
@width = @@test_bitmap.text_size(@text).width
を一文字のサイズを19、最大20文字として、
@width = 380
にさせていただきます。
ツクマテを始めたばかりでコードの書き方が分からないので、使いたい人は
参考にしたい行をトリプルクリックしてコピペしといて下さい。
9ルーズ
記事: 53
登録日時: 2020年3月14日(土) 21:11

Re: <解決済み>ニコニコ動画風コメントをVXAceでも使いたい

投稿記事by 9ルーズ » 2020年5月16日(土) 00:23

テストプレイでいちいち表示されるのが煩わしいので、SWT_COMMENT_OFFのスイッチがONの時だけコメントを表示出来ませんか?
TOMO
記事: 343
登録日時: 2015年11月16日(月) 20:12
連絡を取る:

Re: <解決済み>ニコニコ動画風コメントをVXAceでも使いたい

投稿記事by TOMO » 2020年5月16日(土) 15:01

160行目の

コード: 全て選択

return if $game_switches[NICO::Options::SWT_COMMENT_OFF]

コード: 全て選択

return if !$game_switches[NICO::Options::SWT_COMMENT_OFF]
とすれば出来ます
9ルーズ
記事: 53
登録日時: 2020年3月14日(土) 21:11

Re: <解決済み>ニコニコ動画風コメントをVXAceでも使いたい

投稿記事by 9ルーズ » 2020年5月17日(日) 16:45

返答ありがとうございます。
クリティカルや戦闘不能になった時コメントを流すにはどこを追加すればよろしいでしょうか?
TOMO
記事: 343
登録日時: 2015年11月16日(月) 20:12
連絡を取る:

Re: <解決済み>ニコニコ動画風コメントをVXAceでも使いたい

投稿記事by TOMO » 2020年5月18日(月) 05:08

まずクリティカルは、

コード: 全て選択

module NICO
  module Options
    # 味方がクリティカルヒットした時のコメント
    CM_ACTOR_CRITICAL = [
      "%sにクリティカル"
    ]
   
    # 敵がクリティカルヒットした時のコメント
    CM_ENEMY_CIRITICAL = [
      "%sにクリティカルだ!"
    ]
  end
end
class Window_BattleLog
  #--------------------------------------------------------------------------
  # ● クリティカルヒットの表示
  #--------------------------------------------------------------------------
  alias nico_scene_battle_display_critical display_critical
  def display_critical(target, item)
    nico_scene_battle_display_critical(target, item)
    if target.result.critical
      comments = target.actor? ? NICO::Options::CM_ACTOR_CRITICAL : NICO::Options::CM_ENEMY_CRITICAL
      $game_temp.add_comment(sprintf(comments[rand(comments.size)], target.name)
    end
  end
end
で可能なはずです

そして戦闘不能は、まず

コード: 全て選択

module NICO
  module Options
    # 味方が戦闘不能になった時のコメント
    CM_ACTOR_DEATH = [
      "%sが死んだ!"
    ]
   
    # 敵が戦闘不能になった時のコメント
    CM_ENEMY_DEATH = [
      "%sを倒した!"
    ]
  end
end
を追加し、次に

コード: 全て選択

  #--------------------------------------------------------------------------
  # ● 付加されたステートの表示
  #--------------------------------------------------------------------------
  alias nico_scene_battle_display_added_states display_added_states
  def display_added_states(target)
    for state in target.result.added_state_objects
      comments = target.actor? ? NICO::Options::CM_ACTOR_ADD_STATE : NICO::Options::CM_ENEMY_ADD_STATE
      $game_temp.add_comment(sprintf(comments[rand(comments.size)], state.name))
    end
    nico_scene_battle_display_added_states(target)
  end

コード: 全て選択

  #--------------------------------------------------------------------------
  # ● 付加されたステートの表示
  #--------------------------------------------------------------------------
  alias nico_scene_battle_display_added_states display_added_states
  def display_added_states(target)
    for state in target.result.added_state_objects
      if state.id == target.death_state_id
        comments = target.actor? ? NICO::Options::CM_ACTOR_DEATH : NICO::Options::CM_ENEMY_DEATH
        $game_temp.add_comment(sprintf(comments[rand(comments.size)], target.name))
      else
        comments = target.actor? ? NICO::Options::CM_ACTOR_ADD_STATE : NICO::Options::CM_ENEMY_ADD_STATE
        $game_temp.add_comment(sprintf(comments[rand(comments.size)], state.name))
      end
    end
    nico_scene_battle_display_added_states(target)
  end
と変えれば可能なはずです
(どちらもテストプレイしてません)
9ルーズ
記事: 53
登録日時: 2020年3月14日(土) 21:11

Re: <解決済み>ニコニコ動画風コメントをVXAceでも使いたい

投稿記事by 9ルーズ » 2020年5月18日(月) 06:33

またまた回答ありがとうございます。
自分からは最後の質問ですが、"\c[18]ファイアー\c[0]"
というようにイベント無しで色を変更するにはどうすれば良いでしょうか?
TOMO
記事: 343
登録日時: 2015年11月16日(月) 20:12
連絡を取る:

Re: <解決済み>ニコニコ動画風コメントをVXAceでも使いたい

投稿記事by TOMO » 2020年5月18日(月) 16:22

多分こんな感じです
(処理は同制作者様の「村人のつぶやき」を参考にしてます)

コード: 全て選択

class Sprite_Comment
  #--------------------------------------------------------------------------
  # ● フレーム更新
  #--------------------------------------------------------------------------
  def update
    super
    if @text != @comment.text and @comment.count <= 0
      @text = @comment.text
      if @text != ""
        self.bitmap = Bitmap.new(@comment.width, 24)
        self.bitmap.font.name = ["MS 明朝", "UmePlus Gothic"]
        self.bitmap.font.bold = true
        self.bitmap.font.color = @dummy_window.text_color(@comment.color)
       
        x = 0
        text = @dummy_window.convert_escape_characters(@text)
        text.gsub!(/\e\C\[([0-9]+)\]/i) { "\x01[#{$1}]" }
        loop do
          c = text.slice!(/./m)
          case c
          when nil; break
          when "\x01"
            text.sub!(/\[([0-9]+)\]/, "")
            self.bitmap.font.color = @dummy_window.text_color($1.to_i)
          else
            self.bitmap.draw_text(x, 0, @comment.width - x, 24, c)
            x += self.bitmap.text_size(c).width
          end
        end
       
      end
    end
    if @text == ""
      self.visible = false
    else
      self.visible = true
      self.x = @comment.x
      self.y = @comment.y
    end
  end
end
ついでに\V、\N、\P、\Gも使えるようにしてます
今回もテストプレイしてません
9ルーズ
記事: 53
登録日時: 2020年3月14日(土) 21:11

Re: <解決済み>ニコニコ動画風コメントをVXAceでも使いたい

投稿記事by 9ルーズ » 2020年5月18日(月) 18:46

度々ありがとうございます。
質問ばかりで迷惑だと思うので、これで自分からの質問は終わりにします。

“VX / Ace:スクリプト素材のリクエスト” へ戻る