查看: 1363|回复: 8

问下该脚本怎么写

  [复制链接]

幻想

梦石
0
星屑
50
在线时间
0 小时
注册时间
2007-12-23
回帖
899
发表于 2008-4-6 06:56:52 | 显示全部楼层 |阅读模式

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

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

×
关于战斗
if 角色id 攻击某敌人的情况下
  被攻击者??%附加状态id
end
也就是说我方某角色攻击敌人的话·有一定几率给被攻击敌人附加某状态.
此贴于 2008-4-13 1:00:13 被版主水迭澜提醒,请楼主看到后对本贴做出回应。
本贴由论坛斑竹禾西结贴,如楼主认为问题未解决,请重新将此贴编辑为“有事请教”,并回帖叙述疑点即可~ ^-^
[url=http://rpg.blue/upload_program/d/菜鸟飞呀飞_love_111006892.jpg]http://rpg.blue/upload_program/d/菜鸟飞呀飞_love_111006892.jpg[/url][FLY][url=http://rpg.blue/upload_program/d/菜鸟飞呀飞_yz_tb_111008420.png]http://rpg.blue/upload_program/d/菜鸟飞呀飞_yz_tb_111008420.png[/url][/FLY][url=http://rpg.blue/upload_program/d/菜鸟飞呀飞_yzs_111008459.png]http://rpg.blue/upload_program/d/菜鸟飞呀飞_yzs_111008459.png[/url]
梦石
0
星屑
50
在线时间
36 小时
注册时间
2006-8-4
回帖
373
发表于 2008-4-6 09:13:09 | 显示全部楼层
      if attacker.is_a?(Game_Actor) and attacker.id == 1
        if rand(100) < 50
         add_state(1)
        end
      end



在Game_Battler 3下修改测试OK
  #--------------------------------------------------------------------------
  # ● 应用通常攻击效果
  #     attacker : 攻击者 (battler)
  #--------------------------------------------------------------------------
  def attack_effect(attacker)
    # 清除会心一击标志
    self.critical = false
    # 第一命中判定
    hit_result = (rand(100) < attacker.hit)
    # 命中的情况下
    if hit_result == true
      # 计算基本伤害
      atk = [attacker.atk - self.pdef / 2, 0].max
      self.damage = atk * (20 + attacker.str) / 20
      # 属性修正
      self.damage *= elements_correct(attacker.element_set)
      self.damage /= 100
      # 伤害符号正确的情况下
      if self.damage > 0
        # 会心一击修正
        if rand(100) < 4 * attacker.dex / self.agi
          self.damage *= 2
          self.critical = true
        end
        # 防御修正
        if self.guarding?
          self.damage /= 2
        end
      end
      # 分散
      if self.damage.abs > 0
        amp = [self.damage.abs * 15 / 100, 1].max
        self.damage += rand(amp+1) + rand(amp+1) - amp
      end
      # 第二命中判定
      eva = 8 * self.agi / attacker.dex + self.eva
      hit = self.damage < 0 ? 100 : 100 - eva
      hit = self.cant_evade? ? 100 : hit
      hit_result = (rand(100) < hit)
    end
    # 命中的情况下
    if hit_result == true
      # 状态冲击解除
      remove_states_shock
      # HP 的伤害计算
      self.hp -= self.damage
      # 状态变化
      @state_changed = false
      states_plus(attacker.plus_state_set)
      states_minus(attacker.minus_state_set)
      
      if attacker.is_a?(Game_Actor) and attacker.id == 1
        if rand(100) < 50
         add_state(1)
        end
      end

      
    # Miss 的情况下
    else
      # 伤害设置为 "Miss"
      self.damage = "Miss"
      # 清除会心一击标志
      self.critical = false
    end
    # 过程结束
    return true
  end
哟~迷路了~
回复

使用道具 举报

幻想

梦石
0
星屑
50
在线时间
0 小时
注册时间
2007-12-23
回帖
899
 楼主| 发表于 2008-4-6 09:37:15 | 显示全部楼层
经测试···没效果···脚本好像没一句有关被攻击敌人{/gg}
[url=http://rpg.blue/upload_program/d/菜鸟飞呀飞_love_111006892.jpg]http://rpg.blue/upload_program/d/菜鸟飞呀飞_love_111006892.jpg[/url][FLY][url=http://rpg.blue/upload_program/d/菜鸟飞呀飞_yz_tb_111008420.png]http://rpg.blue/upload_program/d/菜鸟飞呀飞_yz_tb_111008420.png[/url][/FLY][url=http://rpg.blue/upload_program/d/菜鸟飞呀飞_yzs_111008459.png]http://rpg.blue/upload_program/d/菜鸟飞呀飞_yzs_111008459.png[/url]
回复

使用道具 举报

梦石
0
星屑
50
在线时间
36 小时
注册时间
2006-8-4
回帖
373
发表于 2008-4-6 09:59:41 | 显示全部楼层
是否新定义了Game_Battler
哟~迷路了~
回复

使用道具 举报

酱油的

梦石
0
星屑
1840
在线时间
2161 小时
注册时间
2007-12-22
回帖
3216

贵宾

发表于 2008-4-6 10:02:24 | 显示全部楼层
只有一半的機率,遇不上也很正常。

這裏關於畀攻擊者的語句是:

self.
不做頭像做簽名,看我囧冏有神(多謝山人有情提供 )
回复

使用道具 举报

梦石
0
星屑
50
在线时间
36 小时
注册时间
2006-8-4
回帖
373
发表于 2008-4-6 10:04:09 | 显示全部楼层
      if attacker.is_a?(Game_Actor) and attacker.id == 1
        if rand(100) < 50 and self.id == 2   #特定ID敌人
         add_state(3)
        end
      end

也可以这样
哟~迷路了~
回复

使用道具 举报

幻想

梦石
0
星屑
50
在线时间
0 小时
注册时间
2007-12-23
回帖
899
 楼主| 发表于 2008-4-6 10:40:51 | 显示全部楼层
不要特定的···因为没个敌人都可能被附加···
还有我是在新工程里测试的···命中率调到了99还是没效果
[url=http://rpg.blue/upload_program/d/菜鸟飞呀飞_love_111006892.jpg]http://rpg.blue/upload_program/d/菜鸟飞呀飞_love_111006892.jpg[/url][FLY][url=http://rpg.blue/upload_program/d/菜鸟飞呀飞_yz_tb_111008420.png]http://rpg.blue/upload_program/d/菜鸟飞呀飞_yz_tb_111008420.png[/url][/FLY][url=http://rpg.blue/upload_program/d/菜鸟飞呀飞_yzs_111008459.png]http://rpg.blue/upload_program/d/菜鸟飞呀飞_yzs_111008459.png[/url]
回复

使用道具 举报

幻想

梦石
0
星屑
50
在线时间
0 小时
注册时间
2007-12-23
回帖
899
 楼主| 发表于 2008-4-7 21:18:53 | 显示全部楼层
顶贴~~~咦人捏
回复

使用道具 举报

梦石
0
星屑
50
在线时间
36 小时
注册时间
2006-8-4
回帖
373
发表于 2008-4-7 23:12:55 | 显示全部楼层
在新工程里我十分肯定确定是可以的。       至于你 说新工程都不行 我只能怀疑你的使用方式或变通能力了
哟~迷路了~
回复

使用道具 举报

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

本版积分规则

Powered by Discuz! X5.0 © 2001-2026 Discuz! Team.

在本版发帖返回顶部