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

Project1

 找回密码
 注册会员
搜索

怎样在伤害值前加一个减号“—”

查看数: 1292 | 评论数: 4 | 收藏 0
关灯 | 提示:支持键盘翻页<-左 右->
    组图打开中,请稍候......
发布时间: 2013-3-29 09:34

正文摘要:

怎样在伤害值前加一个减号“—”,如:-900 补血时数值前加一个加号“+”,如:+200

回复

789456qwe 发表于 2013-3-29 20:50:44
xiaoli999999 发表于 2013-3-29 13:26
在脚本编辑器里找到Game_Battler 3这个类
找到attack_effect这个函数的
# 状态变化

Sp怎么写脚本?
亿万星辰 发表于 2013-3-29 15:44:21
  1. module RPG
  2.   class Sprite < ::Sprite
  3.     def damage(value, critical)
  4.       dispose_damage
  5.       if value.is_a?(Numeric)
  6.         damage_string = (value>0 ? "+" : (value<0 ? "-" : "")) + value.abs.to_s
  7.       else
  8.         damage_string = value.to_s
  9.       end
  10.       bitmap = Bitmap.new(160, 48)
  11.       bitmap.font.name = "Arial Black"
  12.       bitmap.font.size = 32
  13.       bitmap.font.color.set(0, 0, 0)
  14.       bitmap.draw_text(-1, 12-1, 160, 36, damage_string, 1)
  15.       bitmap.draw_text(+1, 12-1, 160, 36, damage_string, 1)
  16.       bitmap.draw_text(-1, 12+1, 160, 36, damage_string, 1)
  17.       bitmap.draw_text(+1, 12+1, 160, 36, damage_string, 1)
  18.       if value.is_a?(Numeric) and value < 0
  19.         bitmap.font.color.set(176, 255, 144)
  20.       else
  21.         bitmap.font.color.set(255, 255, 255)
  22.       end
  23.       bitmap.draw_text(0, 12, 160, 36, damage_string, 1)
  24.       if critical
  25.         bitmap.font.size = 20
  26.         bitmap.font.color.set(0, 0, 0)
  27.         bitmap.draw_text(-1, -1, 160, 20, "CRITICAL", 1)
  28.         bitmap.draw_text(+1, -1, 160, 20, "CRITICAL", 1)
  29.         bitmap.draw_text(-1, +1, 160, 20, "CRITICAL", 1)
  30.         bitmap.draw_text(+1, +1, 160, 20, "CRITICAL", 1)
  31.         bitmap.font.color.set(255, 255, 255)
  32.         bitmap.draw_text(0, 0, 160, 20, "CRITICAL", 1)
  33.       end
  34.       @_damage_sprite = ::Sprite.new(self.viewport)
  35.       @_damage_sprite.bitmap = bitmap
  36.       @_damage_sprite.ox = 80
  37.       @_damage_sprite.oy = 20
  38.       @_damage_sprite.x = self.x
  39.       @_damage_sprite.y = self.y - self.oy / 2
  40.       @_damage_sprite.z = 3000
  41.       @_damage_duration = 40
  42.     end
  43.   end
  44. end
复制代码
插入到Main前面应该有效。

评分

参与人数 1星屑 +100 收起 理由
hys111111 + 100 感谢回答

查看全部评分

xiaoli999999 发表于 2013-3-29 13:26:34
本帖最后由 xiaoli999999 于 2013-3-29 14:16 编辑

在脚本编辑器里找到Game_Battler 3这个类
找到attack_effect这个函数的
# 状态变化
      @state_changed = false
      states_plus(attacker.plus_state_set)
      states_minus(attacker.minus_state_set)
这一段,在下面加上
      if self.damage<= 0
        self.damage *=-1
        self.damage = "+#{self.damage}"
      else
        self.damage = "-#{self.damage}"
      end

然后找到skill_effect这个函数的
# HP 的伤害减法运算
      last_hp = self.hp
      self.hp -= self.damage
      effective |= self.hp != last_hp
这一段,在后面加上
     if self.damage<= 0
        self.damage *=-1
        self.damage = "+#{self.damage}"
      else
        self.damage = "-#{self.damage}"
      end

如此类推,在item_effect函数的
if item.recover_hp_rate == 0 and item.recover_hp == 0
        # 设置伤害为空的字符串
        self.damage = ""
        # SP 回复率与回复量为 0、能力上升值无效的情况下
        if item.recover_sp_rate == 0 and item.recover_sp == 0 and
           (item.parameter_type == 0 or item.parameter_points == 0)
          # 状态没有变化的情况下
          unless @state_changed
            # 伤害设置为 "Miss"
            self.damage = "Miss"
          end
        end
      end
后面
和slip_damage_effect函数的
if self.damage.abs > 0
      amp = [self.damage.abs * 15 / 100, 1].max
      self.damage += rand(amp+1) + rand(amp+1) - amp
    end
    # HP 的伤害减法运算
    self.hp -= self.damage
后面也加上
if self.damage<= 0
        self.damage *=-1
        self.damage = "+#{self.damage}"
      else
        self.damage = "-#{self.damage}"
      end
暂时测试通过没问题

点评

搞成字符串以后,恢复时的颜色应该没了~  发表于 2013-3-29 15:41
拿上你的纸笔,建造一个属于你的梦想世界,加入吧。
 注册会员
找回密码

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

GMT+8, 2025-6-27 12:16

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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