Project1
标题:
战斗中如何让角色死亡后变成死亡图块,而不是消失?
[打印本页]
作者:
418166499
时间:
2011-9-4 10:06
标题:
战斗中如何让角色死亡后变成死亡图块,而不是消失?
以下是工程的Spriteset_Battle和行走图作战斗图两个脚本,
#==============================================================================
# 本脚本来自www.66RPG.com,使用和转载请保留此信息
#==============================================================================
#==============================================================================
#冲突脚本:宠物脚本1.2版(66主页拿的宠物脚本应该都会冲突)
#注意:以下一共有两个脚本,插入后就能达到战斗动画。
#插入脚本后先进入游戏进行战斗一下,然后就会明白素材问题了
#素材问题:脚本采用了战斗图自动选择行走图~~~
#使用方法:插module RPG入main前即可
#==============================================================================
#==============================================================================
# ■ Sprite_Battler
#==============================================================================
class Sprite_Battler < RPG::Sprite
#--------------------------------------------------------------------------
# ● instance变量
#--------------------------------------------------------------------------
attr_accessor :battler # butler
#--------------------------------------------------------------------------
# ● 初始化
# viewport : viewport
# battler : butler(Game_Battler)
#--------------------------------------------------------------------------
def initialize(viewport, battler = nil)
super(viewport)
@battler = battler
@battler_visible = false
# 定义动画用变量
@hoko_wait = 0
@hoko_pattern = 0
end
#--------------------------------------------------------------------------
# ● 解放
#--------------------------------------------------------------------------
def dispose
if self.bitmap != nil
self.bitmap.dispose
end
super
end
#--------------------------------------------------------------------------
# ● 更新
#--------------------------------------------------------------------------
def update
super
# butler nil 的场合
if @battler == nil
self.bitmap = nil
loop_animation(nil)
return
end
# 如果文件名或者色相与现在的东西不同
if @battler.battler_name != @battler_name or
@battler.battler_hue != @battler_hue
# 取得位图设定
@battler_name = @battler.battler_name
@battler_hue = @battler.battler_hue
# battler→character变更
#self.bitmap = RPG::Cache.battler(@battler_name, @battler_hue)
self.bitmap = RPG::Cache.character(@battler_name, @battler_hue)
@width = bitmap.width / 4
@height = bitmap.height / 4
self.ox = @width / 1.3
self.oy = bitmap.height - 28
if @battler.is_a?(Game_Actor)
self.src_rect.set(@hoko_pattern * @width, 96, @width, @height)
else
self.src_rect.set(@hoko_pattern * @width, 48, @width, @height)
end
# 战斗不能再隐藏要是状态把不透明度做为 0
if @battler.dead? or @battler.hidden and @_collapse_duration > 0
self.opacity = 255
end
end
# 如果动画ID与现在的东西有差异
if @battler.damage == nil and
@battler.state_animation_id != @state_animation_id
@state_animation_id = @battler.state_animation_id
loop_animation($data_animations[@state_animation_id])
end
# 应该被表示actor的场合
if @battler.is_a?(Game_Actor) and @battler_visible
# 不是主要阶段的时候把不透明度稍稍下降
if $game_temp.battle_main_phase
self.opacity += 3 if self.opacity < 255
else
self.opacity -= 3 if self.opacity > 207
end
end
# 闪烁
if @battler.blink
@battler.screen_x += 8 if @battler.is_a?(Game_Actor) and @battler.screen_x < 200
blink_on
elsif
[email protected]
@battler.screen_x -= 8 if @battler.is_a?(Game_Actor) and @battler.screen_x > 160
@battler.screen_x += 8 if @battler.is_a?(Game_Enemy) and @battler.screen_x < 480
blink_off
end
if @battler.is_a?(Game_Actor)
if @battler.forward and @battler.screen_x < 200
@battler.screen_x += 8
end
elsif @battler.forward and @battler.screen_x > 440
@battler.screen_x -= 8
end
if @battler.zero
@hoko_pattern = 0
@battler.zero = false
end
# 不可见的场合
unless @battler_visible
# 出现
if not @battler.hidden and not @battler.dead? and
(@battler.damage == nil or @battler.damage_pop)
appear
@battler_visible = true
end
end
# 可见的场合
if @battler_visible
# 逃走
if @battler.hidden
$game_system.se_play($data_system.escape_se)
escape
@battler_visible = false
end
# 白闪光
if @battler.white_flash
whiten
@battler.white_flash = false
end
# 动画
if @battler.animation_id != 0
animation = $data_animations[@battler.animation_id]
animation(animation, @battler.animation_hit)
@battler.animation_id = 0
end
# 损坏
if @battler.damage_pop
damage(@battler.damage, @battler.critical)
@battler.damage = nil
@battler.critical = false
@battler.damage_pop = false
end
# korapusu
if @battler.damage == nil and @battler.dead?
if @battler.is_a?(Game_Enemy)
$game_system.se_play($data_system.enemy_collapse_se)
else
$game_system.se_play($data_system.actor_collapse_se)
end
collapse
@battler_visible = false
end
# 行走动画
hoko_anime()
# p @hoko_pattern
end
# 设定行走图位置的坐标
self.x = @battler.screen_x + 7
self.y = @battler.screen_y + 108
self.z = @battler.screen_z
end
#--------------------------------------------------------------------------
# ● 行走动画(@hoko_pattern * @width, 0, @width, @height)能设置行走图方向
#--------------------------------------------------------------------------
def hoko_anime()
@hoko_wait += 1
if @hoko_wait > 6
@hoko_wait = 0
@hoko_pattern += 1
if @hoko_pattern > 3
@hoko_pattern = 0
end
# if @battler.is_a?(Game_Actor)
self.src_rect.set(@hoko_pattern * @width, @battler.up_row, @width, @height)
# else
# self.src_rect.set(@hoko_pattern * @width, @battler.up_row, @width, @height)
# end
# self.src_rect.set(@hoko_pattern * @width, 0, @width, @height)
end
end
end
#==============================================================================
#冲突脚本:宠物脚本1.2版(66主页拿的宠物脚本应该都会冲突)
#注意:以下一共有两个脚本,插入后就能达到战斗动画。
#插入脚本后先进入游戏进行战斗一下,然后就会明白素材问题了
#素材问题:脚本采用了战斗图自动选择行走图~~~
#==============================================================================
#==============================================================================
# ■ Game_BattleAction
#------------------------------------------------------------------------------
#是处理动作 (战斗中的行动)的级。这个级在 Game_Battler kura# su内部被使用。
#==============================================================================
class Game_BattleAction
#--------------------------------------------------------------------------
# ● instance变量
#--------------------------------------------------------------------------
attr_accessor :speed # 速度
attr_accessor :kind # 类别(基本/ 技艺 / 物品)
attr_accessor :basic # 基本(攻击/防御/逃跑)
attr_accessor :skill_id # 特技ID
attr_accessor :item_id # 物品ID
attr_accessor :target_index # 对象禁书目录
attr_accessor :forcing # 强制标志
#--------------------------------------------------------------------------
# ● 初始化
#--------------------------------------------------------------------------
def initialize
clear
end
#--------------------------------------------------------------------------
# ● clearness
#--------------------------------------------------------------------------
def clear
@speed = 0
@kind = 0
@basic = 3
@skill_id = 0
@item_id = 0
@target_index = -1
@forcing = false
end
#--------------------------------------------------------------------------
# ● 判断
#--------------------------------------------------------------------------
def valid?
return (not (@kind == 0 and @basic == 3))
end
#--------------------------------------------------------------------------
# ● 单体判断
#--------------------------------------------------------------------------
def for_one_friend?
# 类别特技,效果范围包含伙伴单体(HP 0 的)场合
if @kind == 1 and [3, 5].include?($data_skills[@skill_id].scope)
return true
end
# 类别以条款,效果范围包含伙伴单体(HP 0 的)场合
if @kind == 2 and [3, 5].include?($data_items[@item_id].scope)
return true
end
return false
end
#--------------------------------------------------------------------------
# ● 单体用(HP 0)判断
#--------------------------------------------------------------------------
def for_one_friend_hp0?
# 特技效果范围单体(HP 0 )的场合
if @kind == 1 and [5].include?($data_skills[@skill_id].scope)
return true
end
# 物品效果范围单体(HP 0 )的场合
if @kind == 2 and [5].include?($data_items[@item_id].scope)
return true
end
return false
end
#--------------------------------------------------------------------------
# ● random目标 (actor用)
#--------------------------------------------------------------------------
def decide_random_target_for_actor
# 效果范围分歧
if for_one_friend_hp0?
battler = $game_party.random_target_actor_hp0
elsif for_one_friend?
battler = $game_party.random_target_actor
else
battler = $game_troop.random_target_enemy
end
# 如果对象存在取得禁书目录,
# 对象不存在的情况clearness动作
if battler != nil
@target_index = battler.index
else
clear
end
end
#--------------------------------------------------------------------------
# ● random目标 (enemy用)
#--------------------------------------------------------------------------
def decide_random_target_for_enemy
# 效果范围分歧
if for_one_friend_hp0?
battler = $game_troop.random_target_enemy_hp0
elsif for_one_friend?
battler = $game_troop.random_target_enemy
else
battler = $game_party.random_target_actor
end
# 如果对象存在取得禁书目录,
# 对象不存在的情况clearness动作
if battler != nil
@target_index = battler.index
else
clear
end
end
#--------------------------------------------------------------------------
# ● 最后目标 (actor)
#--------------------------------------------------------------------------
def decide_last_target_for_actor
# 单体actor效果范围,(enemy)
if @target_index == -1
battler = nil
elsif for_one_friend?
battler = $game_party.actors[@target_index]
else
battler = $game_troop.enemies[@target_index]
end
# 对象不存在的情况clearness动作
if battler == nil or not battler.exist?
clear
end
end
#--------------------------------------------------------------------------
# ● 最后目标 (enemy)
#--------------------------------------------------------------------------
def decide_last_target_for_enemy
# 单体enemy效果范围 (actor)
if @target_index == -1
battler = nil
elsif for_one_friend?
battler = $game_troop.enemies[@target_index]
else
battler = $game_party.actors[@target_index]
end
# 对象不存在的情况clearness动作
if battler == nil or not battler.exist?
clear
end
end
end
#==============================================================================
# 本脚本来自www.66RPG.com,使用和转载请保留此信息
#==============================================================================
复制代码
#==============================================================================
# ■ Spriteset_Battle
#------------------------------------------------------------------------------
# 处理战斗画面的活动块的类。本类在 Scene_Battle 类
# 的内部使用。
#==============================================================================
class Spriteset_Battle
#--------------------------------------------------------------------------
# ● 定义实例变量
#--------------------------------------------------------------------------
attr_reader :viewport1 # 敌人方的显示端口
attr_reader :viewport2 # 角色方的显示端口
#--------------------------------------------------------------------------
# ● 初始化变量
#--------------------------------------------------------------------------
def initialize
# 生成显示端口
@viewport1 = Viewport.new(0, 0, 640, 320)
@viewport2 = Viewport.new(0, 0, 640, 480)
@viewport3 = Viewport.new(0, 0, 640, 480)
@viewport4 = Viewport.new(0, 0, 640, 480)
@viewport2.z = 101
@viewport3.z = 200
@viewport4.z = 5000
# 生成战斗背景活动块
@battleback_sprite = Sprite.new(@viewport1)
# 生成敌人活动块
@enemy_sprites = []
for enemy in $game_troop.enemies.reverse
@enemy_sprites.push(Sprite_Battler.new(@viewport1, enemy))
end
# 生成敌人活动块
@actor_sprites = []
@actor_sprites.push(Sprite_Battler.new(@viewport2))
@actor_sprites.push(Sprite_Battler.new(@viewport2))
@actor_sprites.push(Sprite_Battler.new(@viewport2))
@actor_sprites.push(Sprite_Battler.new(@viewport2))
@actor_sprites.push(Sprite_Battler.new(@viewport2))
# 生成天候
@weather = RPG::Weather.new(@viewport1)
# 生成图片活动块
@picture_sprites = []
for i in 51..100
@picture_sprites.push(Sprite_Picture.new(@viewport3,
$game_screen.pictures[i]))
end
# 生成计时器块
@timer_sprite = Sprite_Timer.new
# 刷新画面
update
end
#--------------------------------------------------------------------------
# ● 释放
#--------------------------------------------------------------------------
def dispose
# 如果战斗背景位图存在的情况下就释放
if @battleback_sprite.bitmap != nil
@battleback_sprite.bitmap.dispose
end
# 释放战斗背景活动块
@battleback_sprite.dispose
# 释放敌人活动块、角色活动块
for sprite in @enemy_sprites + @actor_sprites
sprite.dispose
end
# 释放天候
@weather.dispose
# 释放图片活动块
for sprite in @picture_sprites
sprite.dispose
end
# 释放计时器活动块
@timer_sprite.dispose
# 释放显示端口
@viewport1.dispose
@viewport2.dispose
@viewport3.dispose
@viewport4.dispose
end
#--------------------------------------------------------------------------
# ● 显示效果中判定
#--------------------------------------------------------------------------
def effect?
# 如果是在显示效果中的话就返回 true
for sprite in @enemy_sprites + @actor_sprites
return true if sprite.effect?
end
return false
end
#--------------------------------------------------------------------------
# ● 刷新画面
#--------------------------------------------------------------------------
def update
# 刷新角色的活动块 (对应角色的替换)
@actor_sprites[0].battler = $game_party.actors[0]
@actor_sprites[1].battler = $game_party.actors[1]
@actor_sprites[2].battler = $game_party.actors[2]
@actor_sprites[3].battler = $game_party.actors[3]
@actor_sprites[4].battler = $game_party.actors[4]
# 战斗背景的文件名与现在情况有差异的情况下
if @battleback_name != $game_temp.battleback_name
@battleback_name = $game_temp.battleback_name
if @battleback_sprite.bitmap != nil
@battleback_sprite.bitmap.dispose
end
@battleback_sprite.bitmap = RPG::Cache.battleback(@battleback_name)
@battleback_sprite.src_rect.set(0, 0, 640, 320)
end
# 刷新战斗者的活动块
for sprite in @enemy_sprites + @actor_sprites
sprite.update
end
# 刷新天气图形
@weather.type = $game_screen.weather_type
@weather.max = $game_screen.weather_max
@weather.update
# 刷新图片活动块
for sprite in @picture_sprites
sprite.update
end
# 刷新计时器活动块
@timer_sprite.update
# 设置画面的色调与震动位置
@viewport1.tone = $game_screen.tone
@viewport1.ox = $game_screen.shake
# 设置画面的闪烁色
@viewport4.color = $game_screen.flash_color
# 刷新显示端口
@viewport1.update
@viewport2.update
@viewport4.update
end
end
复制代码
我想让角色死亡后变成死亡图块,而不是消失。 dsu_plus_rewardpost_czw
作者:
418166499
时间:
2011-9-4 10:08
忘了一点,队员战斗虚弱后,显示虚弱图块,但加满血后开始战斗还是虚弱图块,战斗一回合后才能恢复。
求助各位帮忙解决,我是新手。
作者:
77777741
时间:
2011-9-4 12:31
提示:
作者被禁止或删除 内容自动屏蔽
欢迎光临 Project1 (https://rpg.blue/)
Powered by Discuz! X3.1