Project1
标题:
关于战斗待机动画
[打印本页]
作者:
an1ji1er1
时间:
2013-4-11 10:44
标题:
关于战斗待机动画
本帖最后由 an1ji1er1 于 2013-4-11 18:03 编辑
用了三国凡人传里的行走图战斗脚本,进入战斗后发现人物的位置和人物战斗图位置差距好大,用鼠标点自己和敌人时候都不需要点到人就可以选到,以下是脚本。请问还有什么脚本能实现战斗有待机动画的呀,站内搜了好久也没有搜到,还望各位帮帮忙啊~
#==============================================================================
# 本脚本来自
www.66RPG.com
,使用和转载请保留此信息
#==============================================================================
#==============================================================================
#冲突脚本:宠物脚本1.2版(66主页拿的宠物脚本应该都会冲突)
#注意:以下一共有两个脚本,插入后就能达到战斗动画。
#插入脚本后先进入游戏进行战斗一下,然后就会明白素材问题了
#素材问题:脚本采用了战斗图自动选择行走图~~~
#使用方法:插入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.animation(@battler_name, @battler_hue)
@width = bitmap.width / 4
@height
= bitmap.height
self.ox = @width
self.oy = bitmap.height
self.src_rect.set(@hoko_pattern * @width, 0, @width, @height)
# 战斗不能再隐藏要是状态把不透明度做为 0
if @battler.dead? or @battler.hidden
self.opacity = 0
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
blink_on
else
blink_off
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 + 190
self.y = @battler.screen_y
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
# p "0"
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
,使用和转载请保留此信息
#==============================================================================
#插件
module RPG
class Sprite < ::Sprite
def damage(value, critical)
dispose_damage
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
bitmap.font.color.set(176, 255, 144)
else
bitmap.font.color.set(255, 255, 255)
end
bitmap.draw_text(0, 12, 160, 36, damage_string, 1)
if critical
bitmap.font.size = 20
bitmap.font.color.set(0, 0, 0)
bitmap.draw_text(-1, -1, 160, 20, "CRITICAL", 1)
bitmap.draw_text(+1, -1, 160, 20, "CRITICAL", 1)
bitmap.draw_text(-1, +1, 160, 20, "CRITICAL", 1)
bitmap.draw_text(+1, +1, 160, 20, "CRITICAL", 1)
bitmap.font.color.set(255, 255, 255)
bitmap.draw_text(0, 0, 160, 20, "CRITICAL", 1)
end
@_damage_sprite = ::Sprite.new(self.viewport)
@_damage_sprite.bitmap = bitmap
@_damage_sprite.ox = 20
@_damage_sprite.oy = 20
@_damage_sprite.x = self.x - self.ox
@_damage_sprite.y = self.y - self.oy / 2
@_damage_sprite.z = 3000
@_damage_duration = 40
end
end
end
欢迎光临 Project1 (https://rpg.blue/)
Powered by Discuz! X3.1