RPGツクール素材メモ とかティラノスクリプトの話とか

同人RPGの制作で役立ちそうなスクリプト・プラグイン素材を書き留めておく

(RPGツクールVXAce,RGSS3)ピクチャで息遣いさせるスクリプト

ひきも記は閉鎖しました。|RPGツクール用スクリプト素材サイトさんの、
戦闘中に敵を息遣い(ゆらゆら)させるスクリプトはよく見るけど、これはバトラー限定なので、例えば自作戦闘や、会話立ち絵とかには使えない。

ピクチャで指定できた方が良い場面もあるかもね…
という事で、改変してみました。

#
# ピクチャ息遣い
# ひきも記さんのスクリプトを改変
# http://hikimoki.sakura.ne.jp/
#
# pictuer_breath_on([5,6], 150)みたいな形でイベントコマンドのスクリプトから。
# 5,6 は対象とするピクチャ番号
# 150はスピード、小さいほど遅い(100~300くらいが限度)
#
# pictuer_breath_off([1])とかで解除。
#

# イベントコマンドのスクリプト
class Game_Interpreter
  def pictuer_breath_on(ary , speed)
    for p_id in ary
      screen.pictures[p_id].breath = "on"
      screen.pictures[p_id].breath_speed = speed
    end
  end
  def pictuer_breath_off(ary)
    for p_id in ary
      screen.pictures[p_id].breath = "off"
    end
  end  
end

#
class Game_Picture
  attr_accessor   :breath
  attr_accessor   :breath_speed
  alias init_breath_basic init_basic
  def init_basic
    init_breath_basic
    @breath = ""
    @breath_speed = 0
  end
end
# 
class Sprite_Picture < Sprite
	alias breath_initialize initialize
	def initialize(viewport, picture)
    @zoom_max = nil
    @zoom_count = nil
    @breath = false
		breath_initialize(viewport, picture)
	end

	alias breath_before_update update
	def update
		breath_before_update
    breath_check
		breath_update
	end

  def breath_check
    if @picture.breath == "on"
      @zoom_max = @picture.breath_speed
      @zoom_count = 0
      @picture.breath = ""
      @breath = true
    end
    if @picture.breath == "off"
      @picture.breath = ""
      @breath = false
    end    
  end
  
	def	breath_update
    if @breath
      @zoom_count += 1
      if @zoom_count == @zoom_max
        @zoom_count = 0
      end
      f = Math.sin(Math::PI * @zoom_count / (@zoom_max / 2))
      self.zoom_y -= f * 0.015 + 0.015
      self.y -= (self.height * (1.0 - self.zoom_y) / 2).ceil
      self.zoom_x += f * 0.005 + 0.005
      self.x += (self.width * (1.0 - self.zoom_x)).ceil
    end
	end
end

スクリプト内に書いてますが、

pictuer_breath_on([ピクチャ番号], 速さ)

で指定、

pictuer_breath_off([ピクチャ番号])

で解除です。

ピクチャ番号は複数指定する事もできる。