设为首页收藏本站|繁體中文

Project1

 找回密码
 注册会员
搜索
查看: 2143|回复: 7
打印 上一主题 下一主题

[已经解决] 受到攻击时战斗图移动

[复制链接]

Lv3.寻梦者

梦石
0
星屑
3531
在线时间
1888 小时
注册时间
2010-6-19
帖子
1210
跳转到指定楼层
1
发表于 2014-7-23 14:08:41 | 只看该作者 |只看大图 回帖奖励 |正序浏览 |阅读模式

加入我们,或者,欢迎回来。

您需要 登录 才可以下载或查看,没有帐号?注册会员

x
下面的脚本是【Miss伤害时战斗图移动】,如何改成收到攻击时战斗图移动。
  1. class Game_Battler
  2.   attr_accessor :add_x
  3.   attr_accessor :add_y
  4.   alias hzhj_old_ini initialize
  5.   def initialize
  6.     hzhj_old_ini
  7.     @add_x = 0
  8.     @add_y = 0
  9.   end
  10. end

  11. class Sprite_Battler < RPG::Sprite
  12.   MoveSpeed = 8    # X 方向每次移动多少像素
  13.   MoveSpeed_Y = 6  # Y 方向每次移动多少像素
  14.   Jump_SE = RPG::AudioFile.new("任务-翻页音效", 0, 0)  #躲避显示音效,后面2个0是声音大小
  15.   
  16.   alias hzhj_old_initialize initialize
  17.   def initialize(*args)
  18.     hzhj_old_initialize(*args)
  19.     if not @battler.nil?
  20.       self.x = @battler.screen_x
  21.       self.y = @battler.screen_y
  22.       self.z = @battler.screen_y
  23.       @hzhj_play_jump = true
  24.     end
  25.     @hzhj_x = self.x
  26.     @hzhj_y = self.y
  27.   end
  28.   def battler=(value)
  29.     if [url=home.php?mod=space&uid=133701]@battler[/url] != value and value != nil
  30.       self.x = value.screen_x
  31.       self.y = value.screen_y
  32.       self.z = value.screen_y
  33.       @hzhj_play_jump = true
  34.     end
  35.     @hzhj_x = self.x
  36.     @hzhj_y = self.y
  37.     @battler = value
  38.   end
  39.   alias hzhj_old_update update
  40.   def update
  41.     if not @battler.nil? and not @battler.dead?
  42.       if self.x < @battler.screen_x + @battler.add_x
  43.         self.x = [self.x + MoveSpeed, @battler.screen_x + @battler.add_x].min
  44.         if @hzhj_play_jump
  45.           Audio.se_play("Audio/SE/#{Jump_SE.name}", Jump_SE.volume, Jump_SE.pitch)
  46.           @hzhj_play_jump = false
  47.         end
  48.       elsif self.x > @battler.screen_x + @battler.add_x
  49.         self.x = [self.x - MoveSpeed, @battler.screen_x + @battler.add_x].max
  50.         if @hzhj_play_jump
  51.           Audio.se_play("Audio/SE/#{Jump_SE.name}", Jump_SE.volume, Jump_SE.pitch)
  52.           @hzhj_play_jump = false
  53.         end
  54.       end
  55.       if self.y < @battler.screen_y + @battler.add_y
  56.         self.y = [self.y + MoveSpeed_Y, @battler.screen_y + @battler.add_y].min
  57.         if @hzhj_play_jump
  58.           Audio.se_play("Audio/SE/#{Jump_SE.name}", Jump_SE.volume, Jump_SE.pitch)
  59.           @hzhj_play_jump = false
  60.         end
  61.       elsif self.y > @battler.screen_y + @battler.add_y
  62.         self.y = [self.y - MoveSpeed_Y, @battler.screen_y + @battler.add_y].max
  63.         if @hzhj_play_jump
  64.           Audio.se_play("Audio/SE/#{Jump_SE.name}", Jump_SE.volume, Jump_SE.pitch)
  65.           @hzhj_play_jump = false
  66.         end
  67.       end
  68.       if self.x == @battler.screen_x and self.y == @battler.screen_y
  69.         @hzhj_play_jump = true
  70.       end
  71.     end
  72.     @hzhj_x = self.x
  73.     @hzhj_y = self.y
  74.     hzhj_old_update
  75.     self.x = @hzhj_x
  76.     self.y = @hzhj_y
  77.     self.z = @hzhj_y
  78.   end
  79.   def x
  80.     if @effect_hzhj
  81.       if @battler.nil?
  82.         return super
  83.       else
  84.         return @battler.screen_x
  85.       end
  86.     else
  87.       return super
  88.     end
  89.   end
  90.   def y
  91.     if @effect_hzhj
  92.       if @battler.nil?
  93.         return super
  94.       else
  95.         return @battler.screen_y
  96.       end
  97.     else
  98.       return super
  99.     end
  100.   end
  101.   def update_animation
  102.     @effect_hzhj = true
  103.     super
  104.     @effect_hzhj = false
  105.   end
  106.   def animation(*args)
  107.     @effect_hzhj = true
  108.     super(*args)
  109.     @effect_hzhj = false
  110.   end
  111.   def update_damage
  112.     @effect_hzhj = true
  113.     super
  114.     @effect_hzhj = false
  115.   end
  116.   def damage(*args)
  117.     @effect_hzhj = true
  118.     super(*args)
  119.     @effect_hzhj = false
  120.   end
  121. end

  122. class Scene_Battle
  123.   ACTOR_ADD_X = 10        # X 方向角色一共要移动的像素
  124.   ACTOR_ADD_Y = 10        # Y 方向角色一共要移动的像素
  125.   ENEMY_ADD_X = -10       # X 方向敌人一共要移动的像素
  126.   ENEMY_ADD_Y = -10       # Y 方向敌人一共要移动的像素
  127.   alias hzhj_old_update_phase4_step4 update_phase4_step4
  128.   def update_phase4_step4
  129.     hzhj_old_update_phase4_step4
  130.     for target in @target_battlers
  131.       next if target.dead?
  132.       next if target.damage != "Miss"
  133.       if target.is_a?(Game_Actor)
  134.         target.add_x = ACTOR_ADD_X
  135.         target.add_y = ACTOR_ADD_Y
  136.       elsif target.is_a?(Game_Enemy)
  137.         target.add_x = ENEMY_ADD_X
  138.         target.add_y = ENEMY_ADD_Y
  139.       end
  140.     end
  141.   end
  142.   alias hzhj_old_update_phase4_step5 update_phase4_step5
  143.   def update_phase4_step5
  144.     hzhj_old_update_phase4_step5
  145.     for target in @target_battlers
  146.       target.add_x = 0
  147.       target.add_y = 0
  148.     end
  149.   end
  150. end
复制代码

Lv2.观梦者

梦石
0
星屑
590
在线时间
392 小时
注册时间
2012-1-20
帖子
223

开拓者

8
发表于 2014-7-24 16:42:11 | 只看该作者
本帖最后由 哆啦溯 于 2014-7-24 16:43 编辑
恐惧剑刃 发表于 2014-7-24 10:30
把你提供的脚本135行

改成


报错的是第30行,这个

QQ截图20140724164259.png (1.39 KB, 下载次数: 4)

QQ截图20140724164259.png
支持一下下我的这个游戏吧~~
大雄与空间军团
回复 支持 反对

使用道具 举报

Lv2.观梦者

梦石
0
星屑
590
在线时间
392 小时
注册时间
2012-1-20
帖子
223

开拓者

7
发表于 2014-7-24 14:14:59 | 只看该作者
咦,为什么用LZ的脚本时会说第30行
    if @battler != value and value != nil
有错?

点评

你看现在显示的内容和脚本报错的那一行一样吗?  发表于 2014-7-24 15:21
支持一下下我的这个游戏吧~~
大雄与空间军团
回复 支持 反对

使用道具 举报

Lv3.寻梦者

梦石
0
星屑
3531
在线时间
1888 小时
注册时间
2010-6-19
帖子
1210
6
 楼主| 发表于 2014-7-24 13:07:41 | 只看该作者
恐惧剑刃 发表于 2014-7-24 10:30
把你提供的脚本135行

改成

好了,谢谢
回复 支持 反对

使用道具 举报

Lv1.梦旅人

薄凉看客

梦石
0
星屑
50
在线时间
1269 小时
注册时间
2010-6-20
帖子
1316
5
发表于 2014-7-24 10:30:51 | 只看该作者
本帖最后由 恐惧剑刃 于 2014-7-24 10:35 编辑

把你提供的脚本135行

改成
next if !target.damage.is_a?(Numeric) or target.damage <= 0
另外那两个0不都是音量大小
第一个0是响度或者说音量大小 第二个0是节拍
回复 支持 反对

使用道具 举报

Lv3.寻梦者

梦石
0
星屑
3531
在线时间
1888 小时
注册时间
2010-6-19
帖子
1210
4
 楼主| 发表于 2014-7-24 07:06:09 | 只看该作者
恐惧剑刃 发表于 2014-7-23 17:53
看起来好长!
删了去吧~直接用默认的,找到Sprite_Battler

有没办法改成,在动画显示的时候移动,而不是动画结束之后移动
回复 支持 反对

使用道具 举报

Lv1.梦旅人

薄凉看客

梦石
0
星屑
50
在线时间
1269 小时
注册时间
2010-6-20
帖子
1316
3
发表于 2014-7-23 17:53:53 | 只看该作者
看起来好长!
删了去吧~直接用默认的,找到Sprite_Battler

找到108行  # 伤害

改为
  1. # 伤害
  2.       if @battler.damage_pop
  3.         if @battler.damage.is_a?(Numeric) and @battler.damage > 0
  4.           for i in 1..5
  5.             self.x += 1
  6.             Graphics.update
  7.           end
  8.           for i in 1..5
  9.             self.x -= 1
  10.             Graphics.update
  11.           end
  12.         end
  13.         damage(@battler.damage, @battler.critical)
  14.         @battler.damage = nil
  15.         @battler.critical = false
  16.         @battler.damage_pop = false
  17.         
  18.       end
复制代码

点评

还有当受到法术攻击的时候角色会1个1个显示移动,而不是一起移动,那样看起来很奇怪。  发表于 2014-7-24 07:13

评分

参与人数 1星屑 +150 收起 理由
RyanBern + 150 认可答案

查看全部评分

回复 支持 反对

使用道具 举报

Lv3.寻梦者

梦石
0
星屑
1743
在线时间
485 小时
注册时间
2006-1-7
帖子
1073
2
发表于 2014-7-23 16:19:06 | 只看该作者
代码太长了。在网吧,没有RM
提供思路:
1.找到miss情况下执行的脚本段落
2.把这个脚本段落应用到受到攻击的时候
楼主是在做XY3的同人吧,希望能帮到你。
初从文,三年不中;后习武,校场发一矢,中鼓吏,逐之出;遂学医,有所成。自撰一良方,服之,卒。
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册会员

本版积分规则

拿上你的纸笔,建造一个属于你的梦想世界,加入吧。
 注册会员
找回密码

站长信箱:[email protected]|手机版|小黑屋|无图版|Project1游戏制作

GMT+8, 2024-10-1 02:27

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表