225 lines
9 KiB
Ruby
225 lines
9 KiB
Ruby
=begin
|
||
RGSS3
|
||
|
||
★ フキダシアイコン常時再生 ★
|
||
|
||
フキダシアイコンを表示し続けるキャラクターを作ります。
|
||
寝ているキャラなどにどうぞ。
|
||
新たな画像ファイルを作って、お店の看板代わりとかもいいかも。
|
||
|
||
● 仕様 ●==========================================================
|
||
横に8分割されたフキダシアイコン画像の内、
|
||
左から 3~7つ目をループ再生します。
|
||
====================================================================
|
||
|
||
● 使い方 ●========================================================
|
||
イベント>自律移動>カスタム>移動ルート>スクリプトに
|
||
@auto_balloon = n
|
||
と記述してください。nはフキダシアイコンのIDです。
|
||
====================================================================
|
||
|
||
ver1.00
|
||
|
||
Last Update : 2011/12/18
|
||
12/18 : 新規
|
||
|
||
ろかん http://kaisou-ryouiki.sakura.ne.jp/
|
||
=end
|
||
|
||
#===========================================
|
||
# 設定箇所
|
||
#===========================================
|
||
module Rokan
|
||
module Auto_Balloon
|
||
# フキダシの半透明化が始まるプレイヤーとの距離
|
||
# 不透明化を行わない場合は"0"を設定してください。
|
||
DBO = 0
|
||
NBS = 85 #追加 このスイッチがオンの時、バルーンを非表示
|
||
end
|
||
end
|
||
#===========================================
|
||
# ここまで
|
||
#===========================================
|
||
|
||
$rsi ||= {}
|
||
$rsi["フキダシアイコン常時再生"] = true
|
||
|
||
class Game_Event < Game_Character
|
||
#--------------------------------------------------------------------------
|
||
# ● 公開インスタンス変数
|
||
#--------------------------------------------------------------------------
|
||
attr_reader :auto_balloon
|
||
#--------------------------------------------------------------------------
|
||
# ● 公開メンバ変数の初期化
|
||
#--------------------------------------------------------------------------
|
||
alias _auto_balloon_init init_public_members
|
||
def init_public_members
|
||
_auto_balloon_init
|
||
@auto_balloon = 0
|
||
@b_stop = false #追加 バルーン一時非表示フラグ
|
||
end
|
||
#--------------------------------------------------------------------------
|
||
# ● プレイヤーからの距離を取得
|
||
#--------------------------------------------------------------------------
|
||
def distance_from_player
|
||
distance_x_from($game_player.x).abs + distance_y_from($game_player.y).abs
|
||
end
|
||
#--------------------------------------------------------------------------
|
||
# ● イベントページのセットアップ
|
||
#--------------------------------------------------------------------------
|
||
alias _auto_balloon_setup_page setup_page
|
||
def setup_page(new_page)
|
||
@auto_balloon = 0
|
||
@b_stop = false
|
||
_auto_balloon_setup_page(new_page)
|
||
end
|
||
#--------------------------------------------------------------------------
|
||
# ○
|
||
#--------------------------------------------------------------------------
|
||
def b_stop?
|
||
@b_stop
|
||
end
|
||
#--------------------------------------------------------------------------
|
||
# ○
|
||
#--------------------------------------------------------------------------
|
||
def b_stop
|
||
@b_stop = true
|
||
end
|
||
#--------------------------------------------------------------------------
|
||
# ○
|
||
#--------------------------------------------------------------------------
|
||
def b_start
|
||
@b_stop = false
|
||
end
|
||
#--------------------------------------------------------------------------
|
||
# ○ オートバルーンアイコンの変更 ※ただし、場面移動をするとリセットされる為
|
||
# その場しのぎ程度にしか使えない。(セーブ後のロードでは保持される)
|
||
#--------------------------------------------------------------------------
|
||
def b_change(b_id)
|
||
@auto_balloon = b_id
|
||
end
|
||
end
|
||
|
||
#==============================================================================
|
||
# ■ Game_Interpreter
|
||
#------------------------------------------------------------------------------
|
||
# イベントコマンドを実行するインタプリタです。このクラスは Game_Map クラス、
|
||
# Game_Troop クラス、Game_Event クラスの内部で使用されます。
|
||
#==============================================================================
|
||
|
||
class Game_Interpreter
|
||
#--------------------------------------------------------------------------
|
||
# ○
|
||
#--------------------------------------------------------------------------
|
||
def b_stop(e_id = 0)
|
||
character = get_character(e_id)
|
||
character.b_stop if character
|
||
end
|
||
#--------------------------------------------------------------------------
|
||
# ○
|
||
#--------------------------------------------------------------------------
|
||
def b_start(e_id = 0)
|
||
character = get_character(e_id)
|
||
character.b_start if character
|
||
end
|
||
#--------------------------------------------------------------------------
|
||
# ○
|
||
#--------------------------------------------------------------------------
|
||
def b_change(b_id, e_id = 0)
|
||
character = get_character(e_id)
|
||
character.b_change(b_id) if character
|
||
end
|
||
end
|
||
|
||
class Sprite_Character < Sprite_Base
|
||
#--------------------------------------------------------------------------
|
||
# ● インクルード Rokan::Auto_Balloon
|
||
#--------------------------------------------------------------------------
|
||
include Rokan::Auto_Balloon
|
||
#--------------------------------------------------------------------------
|
||
# ● 解放
|
||
#--------------------------------------------------------------------------
|
||
alias _auto_balloon_dispose dispose
|
||
def dispose
|
||
dispose_auto_balloon
|
||
_auto_balloon_dispose
|
||
end
|
||
#--------------------------------------------------------------------------
|
||
# ● 常時再生フキダシアイコンの解放
|
||
#--------------------------------------------------------------------------
|
||
def dispose_auto_balloon
|
||
@bw = 10
|
||
@bx = -1
|
||
@auto_balloon_id = 0
|
||
if @auto_balloon_sprite
|
||
@auto_balloon_sprite.dispose
|
||
@auto_balloon_sprite = nil
|
||
end
|
||
end
|
||
#--------------------------------------------------------------------------
|
||
# ● フレーム更新
|
||
#--------------------------------------------------------------------------
|
||
alias _auto_balloon_update update
|
||
def update
|
||
update_auto_balloon
|
||
_auto_balloon_update
|
||
end
|
||
#--------------------------------------------------------------------------
|
||
# ● プレイヤーからの距離を取得
|
||
#--------------------------------------------------------------------------
|
||
def distance_from_player
|
||
@character.distance_from_player
|
||
end
|
||
#--------------------------------------------------------------------------
|
||
# ● 距離によるフキダシの透明度を取得
|
||
#--------------------------------------------------------------------------
|
||
def distance_balloon_opacity
|
||
DBO.zero? ? 255 : 255 - 50 * (distance_from_player - DBO)
|
||
end
|
||
#--------------------------------------------------------------------------
|
||
# ● 表示するフキダシのX座標を取得
|
||
#--------------------------------------------------------------------------
|
||
def auto_balloon_x
|
||
@bx * 32 + 64 #※ここの数字を弄るとバルーン表示部分(3~7)を変更可能
|
||
end
|
||
#--------------------------------------------------------------------------
|
||
# ● 表示するフキダシのY座標を取得
|
||
#--------------------------------------------------------------------------
|
||
def auto_balloon_y
|
||
(@auto_balloon_id - 1) * 32
|
||
end
|
||
#--------------------------------------------------------------------------
|
||
# ● 常時再生フキダシアイコン表示の開始
|
||
#--------------------------------------------------------------------------
|
||
def start_auto_balloon
|
||
dispose_auto_balloon
|
||
@auto_balloon_id = @character.auto_balloon
|
||
@auto_balloon_sprite = Sprite.new(self.viewport)
|
||
@auto_balloon_sprite.bitmap = Cache.system("Balloon")
|
||
@auto_balloon_sprite.z = self.z + 200
|
||
@auto_balloon_sprite.ox = 16
|
||
@auto_balloon_sprite.oy = 32
|
||
end
|
||
#--------------------------------------------------------------------------
|
||
# ● 常時再生フキダシアイコンの更新
|
||
#--------------------------------------------------------------------------
|
||
def update_auto_balloon
|
||
if @character.is_a?(Game_Event) #追加↓ b_stop? と NBS
|
||
if @character.auto_balloon.zero? || !@balloon_duration.zero? || @character.b_stop? || $game_switches[NBS]
|
||
dispose_auto_balloon
|
||
else
|
||
start_auto_balloon if !@auto_balloon_sprite || @auto_balloon_id != @character.auto_balloon
|
||
@auto_balloon_sprite.x = self.x
|
||
@auto_balloon_sprite.y = self.y - self.height
|
||
@auto_balloon_sprite.opacity = distance_balloon_opacity
|
||
if @bw == 10
|
||
@bw = 0
|
||
@bx = @bx == 4 ? 0 : @bx.next
|
||
@auto_balloon_sprite.src_rect.set(auto_balloon_x, auto_balloon_y, 32, 32)
|
||
else
|
||
@bw = @bw.next
|
||
end
|
||
end
|
||
end
|
||
end
|
||
end
|