赞 | 0 |
VIP | 0 |
好人卡 | 0 |
积分 | 1 |
经验 | 220 |
最后登录 | 2012-4-2 |
在线时间 | 0 小时 |
Lv1.梦旅人
- 梦石
- 0
- 星屑
- 50
- 在线时间
- 0 小时
- 注册时间
- 2008-7-12
- 帖子
- 27
|
8楼

楼主 |
发表于 2008-7-13 00:48:31
|
只看该作者
#==============================================================================
class Interpreter
#--------------------------------------------------------------------------
# ● アクターの入れ替え
#--------------------------------------------------------------------------
def command_129
# アクターを取得
actor = $game_actors[@parameters[0]]
# アクターが有効の場合
if actor != nil
# 操作で分岐
if @parameters[1] == 0
if @parameters[2] == 1
$game_actors[@parameters[0]].setup(@parameters[0])
end
$game_party.add_actor(@parameters[0])
if $game_temp.in_battle
$game_actors[@parameters[0]].at = 0
$game_actors[@parameters[0]].atp = 0
$scene.spell_reset($game_actors[@parameters[0]])
$game_actors[@parameters[0]].damage_pop = {}
$game_actors[@parameters[0]].damage = {}
$game_actors[@parameters[0]].damage_sp = {}
$game_actors[@parameters[0]].critical = {}
$game_actors[@parameters[0]].recover_hp = {}
$game_actors[@parameters[0]].recover_sp = {}
$game_actors[@parameters[0]].state_p = {}
$game_actors[@parameters[0]].state_m = {}
$game_actors[@parameters[0]].animation = []
end
else
$game_party.remove_actor(@parameters[0])
end
end
if $game_temp.in_battle
$scene.status_window.update
end
# 継続
return true
end
#--------------------------------------------------------------------------
# ● HP の増減
#--------------------------------------------------------------------------
alias :command_311_rtab :command_311
def command_311
command_311_rtab
if $game_temp.in_battle
$scene.status_window.refresh
end
end
#--------------------------------------------------------------------------
# ● SP の増減
#--------------------------------------------------------------------------
alias :command_312_rtab :command_312
def command_312
command_312_rtab
if $game_temp.in_battle
$scene.status_window.refresh
end
end
#--------------------------------------------------------------------------
# ● ステートの変更
#--------------------------------------------------------------------------
alias :command_313_rtab :command_313
def command_313
command_313_rtab
if $game_temp.in_battle
$scene.status_window.refresh
end
end
#--------------------------------------------------------------------------
# ● 全回復
#--------------------------------------------------------------------------
alias :command_314_rtab :command_314
def command_314
command_314_rtab
if $game_temp.in_battle
$scene.status_window.refresh
end
end
#--------------------------------------------------------------------------
# ● EXP の増減
#--------------------------------------------------------------------------
alias :command_315_rtab :command_315
def command_315
command_315_rtab
if $game_temp.in_battle
$scene.status_window.refresh
end
end
#--------------------------------------------------------------------------
# ● レベルの増減
#--------------------------------------------------------------------------
alias :command_316_rtab :command_316
def command_316
command_316_rtab
if $game_temp.in_battle
$scene.status_window.refresh
end
end
#--------------------------------------------------------------------------
# ● パラメータの増減
#--------------------------------------------------------------------------
alias :command_317_rtab :command_317
def command_317
command_317_rtab
if $game_temp.in_battle
$scene.status_window.refresh
end
end
#--------------------------------------------------------------------------
# ● 装備の変更
#--------------------------------------------------------------------------
alias :command_319_rtab :command_319
def command_319
command_319_rtab
if $game_temp.in_battle
$scene.status_window.refresh
end
end
#--------------------------------------------------------------------------
# ● アクターの名前変更
#--------------------------------------------------------------------------
alias :command_320_rtab :command_320
def command_320
command_320_rtab
if $game_temp.in_battle
$scene.status_window.refresh
end
end
#--------------------------------------------------------------------------
# ● アクターのクラス変更
#--------------------------------------------------------------------------
alias :command_321_rtab :command_321
def command_321
command_321_rtab
if $game_temp.in_battle
$scene.status_window.refresh
end
end
#--------------------------------------------------------------------------
# ● アニメーションの表示
#--------------------------------------------------------------------------
def command_337
# イテレータで処理
iterate_battler(@parameters[0], @parameters[1]) do |battler|
# バトラーが存在する場合
if battler.exist?
# アニメーション ID を設定
battler.animation.push([@parameters[2], true])
end
end
# 継続
return true
end
#--------------------------------------------------------------------------
# ● ダメージの処理
#--------------------------------------------------------------------------
def command_338
# 操作する値を取得
value = operate_value(0, @parameters[2], @parameters[3])
# イテレータで処理
iterate_battler(@parameters[0], @parameters[1]) do |battler|
# バトラーが存在する場合
if battler.exist?
# HP を変更
battler.hp -= value
# 戦闘中なら
if $game_temp.in_battle
# ダメージを設定
battler.damage["event"] = value
battler.damage_pop["event"] = true
end
end
end
if $game_temp.in_battle
$scene.status_window.refresh
end
# 継続
return true
end
#--------------------------------------------------------------------------
# ● アクションの強制
#--------------------------------------------------------------------------
def command_339
# 戦闘中でなければ無視
unless $game_temp.in_battle
return true
end
# ターン数が 0 なら無視
if $game_temp.battle_turn == 0
return true
end
# イテレータで処理 (便宜的なもので、複数になることはない)
iterate_battler(@parameters[0], @parameters[1]) do |battler|
# バトラーが存在する場合
if battler.exist?
# アクションを設定
battler.current_action.force_kind = @parameters[2]
if battler.current_action.force_kind == 0
battler.current_action.force_basic = @parameters[3]
else
battler.current_action.force_skill_id = @parameters[3]
end
# 行動対象を設定
if @parameters[4] == -2
if battler.is_a?(Game_Enemy)
battler.current_action.decide_last_target_for_enemy
else
battler.current_action.decide_last_target_for_actor
end
elsif @parameters[4] == -1
if battler.is_a?(Game_Enemy)
battler.current_action.decide_random_target_for_enemy
else
battler.current_action.decide_random_target_for_actor
end
elsif @parameters[4] >= 0
battler.current_action.target_index = @parameters[4]
end
# アクションが有効かつ [すぐに実行] の場合
if battler.current_action.valid? and @parameters[5] == 1
# 強制対象のバトラーを設定
$game_temp.forcing_battler = battler
# インデックスを進める
@index += 1
# 終了
return false
elsif battler.current_action.valid? and @parameters[5] == 0
battler.current_action.forcing = true
end
end
end
# 継続
return true
end
end
#==============================================================================
# ■ Spriteモジュール
#------------------------------------------------------------------------------
# アニメーションの管理を行うモジュールです。
#==============================================================================
module RPG
class Sprite < ::Sprite
def initialize(viewport = nil)
super(viewport)
@_whiten_duration = 0
@_appear_duration = 0
@_escape_duration = 0
@_collapse_duration = 0
@_damage = []
@_animation = []
@_animation_duration = 0
@_blink = false
end
def damage(value, critical, type = 0)
if value.is_a?(Numeric)
damage_string = value.abs.to_s
else
damage_string = value.to_s
end
bitmap = Bitmap.new(160, 48)
bitmap.font.name = "Arial Black"
bitmap.font.size = 32
bitmap.font.color.set(0, 0, 0)
bitmap.draw_text(-1, 12-1, 160, 36, damage_string, 1)
bitmap.draw_text(+1, 12-1, 160, 36, damage_string, 1)
bitmap.draw_text(-1, 12+1, 160, 36, damage_string, 1)
bitmap.draw_text(+1, 12+1, 160, 36, damage_string, 1)
if value.is_a?(Numeric) and value < 0
if type == 0
bitmap.font.color.set(176, 255, 144)
else
bitmap.font.color.set(176, 144, 255)
end
else
if type == 0
bitmap.font.color.set(255, 255, 255)
else
bitmap.font.color.set(255, 176, 144)
end
end
if type == 2
bitmap.font.color.set(255, 224, 128)
end
bitmap.draw_text(0, 12, 160, 36, damage_string, 1)
if critical
string = "CRITICAL"
bitmap.font.size = 20
bitmap.font.color.set(0, 0, 0)
bitmap.draw_text(-1, -1, 160, 20, string, 1)
bitmap.draw_text(+1, -1, 160, 20, string, 1)
bitmap.draw_text(-1, +1, 160, 20, string, 1)
bitmap.draw_text(+1, +1, 160, 20, string, 1)
bitmap.font.color.set(255, 255, 255)
bitmap.draw_text(0, 0, 160, 20, string, 1)
end
num = @_damage.size
if type != 2
@_damage.push([::Sprite.new, 40, 0, rand(40) - 20, rand(30) + 50])
else
@_damage.push([::Sprite.new, 40, 0, rand(20) - 10, rand(20) + 60])
end
@_damage[num][0].bitmap = bitmap
@_damage[num][0].ox = 80 + self.viewport.ox
@_damage[num][0].oy = 20 + self.viewport.oy
if self.battler.is_a?(Game_Actor)
@_damage[num][0].x = self.x
@_damage[num][0].y = self.y - self.oy / 2
else
@_damage[num][0].x = self.x + self.viewport.rect.x -
self.ox + self.src_rect.width / 2
@_damage[num][0].y = self.y - self.oy * self.zoom_y / 2 +
self.viewport.rect.y
@_damage[num][0].zoom_x = self.zoom_x
@_damage[num][0].zoom_y = self.zoom_y
@_damage[num][0].z = 3000
end
end
def animation(animation, hit)
return if animation == nil
num = @_animation.size
@_animation.push([animation, hit, animation.frame_max, []])
bitmap = RPG::Cache.animation(animation.animation_name,
animation.animation_hue)
if @@_reference_count.include?(bitmap)
@@_reference_count[bitmap] += 1
else
@@_reference_count[bitmap] = 1
end
if @_animation[num][0] != 3 or not @@_animations.include?(animation)
for i in 0..15
sprite = ::Sprite.new
sprite.bitmap = bitmap
sprite.visible = false
@_animation[num][3].push(sprite)
end
unless @@_animations.include?(animation)
@@_animations.push(animation)
end
end
update_animation(@_animation[num])
end
def loop_animation(animation)
return if animation == @_loop_animation
dispose_loop_animation
@_loop_animation = animation
return if @_loop_animation == nil
@_loop_animation_index = 0
animation_name = @_loop_animation.animation_name
animation_hue = @_loop_animation.animation_hue
bitmap = RPG::Cache.animation(animation_name, animation_hue)
if @@_reference_count.include?(bitmap)
@@_reference_count[bitmap] += 1
else
@@_reference_count[bitmap] = 1
end
@_loop_animation_sprites = []
for i in 0..15
sprite = ::Sprite.new
sprite.bitmap = bitmap
sprite.visible = false
@_loop_animation_sprites.push(sprite)
end
update_loop_animation
end
def dispose_damage
for damage in @_damage.reverse
damage[0].bitmap.dispose
damage[0].dispose
@_damage.delete(damage)
end
end
def dispose_animation
for anime in @_animation.reverse
sprite = anime[3][0]
if sprite != nil
@@_reference_count[sprite.bitmap] -= 1
if @@_reference_count[sprite.bitmap] == 0
sprite.bitmap.dispose
end
end
for sprite in anime[3]
sprite.dispose
end
@_animation.delete(anime)
end
end
def effect?
@_whiten_duration > 0 or
@_appear_duration > 0 or
@_escape_duration > 0 or
@_collapse_duration > 0 or
@_damage.size == 0 or
@_animation.size == 0
end
def update
super
if @_whiten_duration > 0
@_whiten_duration -= 1
self.color.alpha = 128 - (16 - @_whiten_duration) * 10
end
if @_appear_duration > 0
@_appear_duration -= 1
self.opacity = (16 - @_appear_duration) * 16
end
if @_escape_duration > 0
@_escape_duration -= 1
self.opacity = 256 - (32 - @_escape_duration) * 10
end
if @_collapse_duration > 0
@_collapse_duration -= 1
self.opacity = 256 - (48 - @_collapse_duration) * 6
end
for damage in @_damage
if damage[1] > 0
damage[1] -= 1
damage[4] -= 3
damage[2] -= damage[4]
if self.battler.is_a?(Game_Actor)
damage[0].x = self.x + (40 - damage[1]) * damage[3] / 10
damage[0].y = self.y - self.oy / 2 + damage[2] / 10
else
damage[0].x = self.x + self.viewport.rect.x -
self.ox + self.src_rect.width / 2 +
(40 - damage[1]) * damage[3] / 10
damage[0].y = self.y - self.oy * self.zoom_y / 2 +
self.viewport.rect.y + damage[2] / 10
damage[0].zoom_x = self.zoom_x
damage[0].zoom_y = self.zoom_y
end
damage[0].z = 2960 + damage[1]
damage[0].opacity = 256 - (12 - damage[1]) * 32
if damage[1] == 0
damage[0].bitmap.dispose
damage[0].dispose
@_damage.delete(damage)
end
end
end
for anime in @_animation
if (Graphics.frame_count % 2 == 0)
anime[2] -= 1
update_animation(anime)
end
end
if @_loop_animation != nil and (Graphics.frame_count % 2 == 0)
update_loop_animation
@_loop_animation_index += 1
@_loop_animation_index %= @_loop_animation.frame_max
end
if @_blink
@_blink_count = (@_blink_count + 1) % 32
if @_blink_count < 16
alpha = (16 - @_blink_count) * 6
else
alpha = (@_blink_count - 16) * 6
end
self.color.set(255, 255, 255, alpha)
end
@@_animations.clear
end
def update_animation(anime)
if anime[2] > 0
frame_index = anime[0].frame_max - anime[2]
cell_data = anime[0].frames[frame_index].cell_data
position = anime[0].position
animation_set_sprites(anime[3], cell_data, position)
for timing in anime[0].timings
if timing.frame == frame_index
animation_process_timing(timing, anime[1])
end
end
else
@@_reference_count[anime[3][0].bitmap] -= 1
if @@_reference_count[anime[3][0].bitmap] == 0
anime[3][0].bitmap.dispose
end
for sprite in anime[3]
sprite.dispose
end
@_animation.delete(anime)
end
end
def animation_set_sprites(sprites, cell_data, position)
for i in 0..15
sprite = sprites
pattern = cell_data[i, 0]
if sprite == nil or pattern == nil or pattern == -1
sprite.visible = false if sprite != nil
next
end
sprite.visible = true
sprite.src_rect.set(pattern % 5 * 192, pattern / 5 * 192, 192, 192)
if position == 3
if self.viewport != nil
sprite.x = self.viewport.rect.width / 2
if $game_temp.in_battle and self.battler.is_a?(Game_Enemy)
sprite.y = self.viewport.rect.height - 320
else
sprite.y = self.viewport.rect.height - 160
end
else
sprite.x = 320
sprite.y = 240
end
else
sprite.x = self.x + self.viewport.rect.x -
self.ox + self.src_rect.width / 2
if $game_temp.in_battle and self.battler.is_a?(Game_Enemy)
sprite.y = self.y - self.oy * self.zoom_y / 2 +
self.viewport.rect.y
if position == 0
sprite.y -= self.src_rect.height * self.zoom_y / 4
elsif position == 2
sprite.y += self.src_rect.height * self.zoom_y / 4
end
else
sprite.y = self.y + self.viewport.rect.y -
self.oy + self.src_rect.height / 2
sprite.y -= self.src_rect.height / 4 if position == 0
sprite.y += self.src_rect.height / 4 if position == 2
end
end
sprite.x += cell_data[i, 1]
sprite.y += cell_data[i, 2]
sprite.z = 2000
sprite.ox = 96
sprite.oy = 96
sprite.zoom_x = cell_data[i, 3] / 100.0
sprite.zoom_y = cell_data[i, 3] / 100.0
if position != 3
sprite.zoom_x *= self.zoom_x
sprite.zoom_y *= self.zoom_y
end
sprite.angle = cell_data[i, 4]
sprite.mirror = (cell_data[i, 5] == 1)
sprite.opacity = cell_data[i, 6] * self.opacity / 255.0
sprite.blend_type = cell_data[i, 7]
end
end
def x=(x)
sx = x - self.x
if sx != 0
for anime in @_animation
if anime[3] != nil
for i in 0..15
anime[3].x += sx
end
end
end
if @_loop_animation_sprites != nil
for i in 0..15
@_loop_animation_sprites.x += sx
end
end
end
super
end
def y=(y)
sy = y - self.y
if sy != 0
for anime in @_animation
if anime[3] != nil
for i in 0..15
anime[3].y += sy
end
end
end
if @_loop_animation_sprites != nil
for i in 0..15
@_loop_animation_sprites.y += sy
end
end
end
super
end
end
end
#------------------------------------------------------------------------------
# Bitmapクラスに新たな機能を追加します。
#==============================================================================
class Bitmap
#--------------------------------------------------------------------------
# ● 矩形をグラデーション表示
# color1 : スタートカラー
# color2 : エンドカラー
# align : 0:横にグラデーション
# 1:縦にグラデーション
# 2:斜めにグラデーション(激重につき注意)
#--------------------------------------------------------------------------
def gradation_rect(x, y, width, height, color1, color2, align = 0)
if align == 0
for i in x...x + width
red = color1.red + (color2.red - color1.red) * (i - x) / (width - 1)
green = color1.green +
(color2.green - color1.green) * (i - x) / (width - 1)
blue = color1.blue +
(color2.blue - color1.blue) * (i - x) / (width - 1)
alpha = color1.alpha +
(color2.alpha - color1.alpha) * (i - x) / (width - 1)
color = Color.new(red, green, blue, alpha)
fill_rect(i, y, 1, height, color)
end
elsif align == 1
for i in y...y + height
red = color1.red +
(color2.red - color1.red) * (i - y) / (height - 1)
green = color1.green +
(color2.green - color1.green) * (i - y) / (height - 1)
blue = color1.blue +
(color2.blue - color1.blue) * (i - y) / (height - 1)
alpha = color1.alpha +
(color2.alpha - color1.alpha) * (i - y) / (height - 1)
color = Color.new(red, green, blue, alpha)
fill_rect(x, i, width, 1, color)
end
elsif align == 2
for i in x...x + width
for j in y...y + height
red = color1.red + (color2.red - color1.red) *
((i - x) / (width - 1.0) + (j - y) / (height - 1.0)) / 2
green = color1.green + (color2.green - color1.green) *
((i - x) / (width - 1.0) + (j - y) / (height - 1.0)) / 2
blue = color1.blue + (color2.blue - color1.blue) *
((i - x) / (width - 1.0) + (j - y) / (height - 1.0)) / 2
alpha = color1.alpha + (color2.alpha - color1.alpha) *
((i - x) / (width - 1.0) + (j - y) / (height - 1.0)) / 2
color = Color.new(red, green, blue, alpha)
set_pixel(i, j, color)
end
end
elsif align == 3
for i in x...x + width
for j in y...y + height
red = color1.red + (color2.red - color1.red) *
((x + width - i) / (width - 1.0) + (j - y) / (height - 1.0)) / 2
green = color1.green + (color2.green - color1.green) *
((x + width - i) / (width - 1.0) + (j - y) / (height - 1.0)) / 2
blue = color1.blue + (color2.blue - color1.blue) *
((x + width - i) / (width - 1.0) + (j - y) / (height - 1.0)) / 2
alpha = color1.alpha + (color2.alpha - color1.alpha) *
((x + width - i) / (width - 1.0) + (j - y) / (height - 1.0)) / 2
color = Color.new(red, green, blue, alpha)
set_pixel(i, j, color)
end
end
end
end
end
|
|