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

Project1

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

[已经过期] 伤害显示美化脚本的颜色问题

[复制链接]

Lv4.逐梦者

梦石
0
星屑
9280
在线时间
2504 小时
注册时间
2011-5-20
帖子
15389

开拓者

跳转到指定楼层
1
发表于 2013-12-28 21:55:31 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

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

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

x
本帖最后由 fux2 于 2013-12-31 13:07 编辑
  1. #==============================================================================
  2. # ■ Game_Battler (分割定义 3)
  3. #------------------------------------------------------------------------------
  4. #  处理战斗者的类。这个类作为 Game_Actor 类与 Game_Enemy 类的
  5. # 超级类来使用。
  6. #==============================================================================

  7. class Game_Battler
  8.   #--------------------------------------------------------------------------
  9.   # ● 可以使用特技的判定
  10.   #     skill_id : 特技 ID
  11.   #--------------------------------------------------------------------------
  12.   def skill_can_use?(skill_id)
  13.     # SP 不足的情况下不能使用
  14.     if $data_skills[skill_id].sp_cost > self.sp
  15.       return false
  16.     end
  17.     # 战斗不能的情况下不能使用
  18.     if dead?
  19.       return false
  20.     end
  21.     # 沉默状态的情况下、物理特技以外的特技不能使用
  22.     if $data_skills[skill_id].atk_f == 0 and self.restriction == 1
  23.       return false
  24.     end
  25.     if states.include?(4) or states.include?(7)#眩晕、沉默状态禁用技能
  26.       return false
  27.     end
  28.     # 获取可以使用的时机
  29.     occasion = $data_skills[skill_id].occasion
  30.     # 战斗中的情况下
  31.     if $game_temp.in_battle
  32.       # [平时] 或者是 [战斗中] 可以使用
  33.       return (occasion == 0 or occasion == 1)
  34.     # 不是战斗中的情况下
  35.     else
  36.       # [平时] 或者是 [菜单中] 可以使用
  37.       return (occasion == 0 or occasion == 2)
  38.     end
  39.   end
  40.   #--------------------------------------------------------------------------
  41.   # ● 应用通常攻击效果
  42.   #     attacker : 攻击者 (battler)
  43.   #--------------------------------------------------------------------------
  44.   def attack_effect(attacker)
  45.     # 清除会心一击标志
  46.     self.critical = false
  47.     damage = 0#敌人受到伤害
  48.     edamage = 0#敌人受到实际伤害
  49.     self.damage = 0#输出伤害
  50.     mdamage = 0#魔法盾伤害
  51.     amdamage = 0#魔法盾伤害
  52.     rdamage = 0#反弹伤害
  53. #    $game_variables[1]=0#显示HP、SP的伤害(恢复)颜色编号
  54.     if $attackercombo==0 or $attackercombo==nil
  55.       combos = attacker.as%100#概率连击
  56.       combo = (attacker.as-combos)/100#连击
  57.       mz = rand(100)
  58.       if mz <combos
  59.         combo+=1
  60.       end
  61.       $attackercombo=combo
  62.     end
  63.     mz=rand(100)
  64.     if mz > self.pdod
  65.       mz=rand(100)
  66.       if mz < attacker.phit
  67.         damage = (attacker.patk - self.pdef)*(100+attacker.pog)/100
  68.         mz=rand(100)
  69.         if mz < attacker.pcr
  70.           damage *= (100+attacker.pcrc)/100
  71.           self.critical = true
  72.         end
  73.         if damage < 0
  74.           damage = 0
  75.         end
  76.         # 状态冲击解除
  77.         remove_states_shock
  78.         edamage = damage*(100-self.pdr)/100#敌人受到实际伤害
  79.         #判断是否开启魔法盾
  80.         if states.include?(2)
  81.           mdamage = damage*self.sdr/100#计算开启魔法盾的魔力伤害
  82.           if self.sp < mdamage/self.sdd#魔力不足以支持完整的魔法盾
  83.             $game_variables[1]=1
  84.             self.damage = edamage-self.sp*self.sdd
  85.             self.damage_pop = true
  86.             self.hp -= edamage-self.sp*self.sdd
  87.             $game_variables[2]=6
  88.             self.sp_damage = self.sp
  89.             self.sp_damage_pop = true
  90.             self.sp = 0
  91.             rdamage=(edamage-self.sp*self.sdd)*self.preb/100*(100-attacker.pdr)/100#受到反弹
  92.             remove_state(2)
  93.           else
  94.             $game_variables[1]=1
  95.             self.damage = edamage - mdamage
  96.             self.damage_pop = true
  97.             self.hp -= edamage - mdamage
  98.             $game_variables[2]=6
  99.             self.sp_damage = mdamage / self.sdd
  100.             self.sp_damage_pop = true
  101.             self.sp -= mdamage / self.sdd
  102.             rdamage=(edamage-mdamage)*self.preb/100*(100-attacker.pdr)/100#受到反弹
  103.           end
  104.         else
  105.           $game_variables[1]=1
  106.           self.damage = edamage
  107.           #self.damage_pop = true#这句注释取消后颜色显示会混乱
  108.           self.hp -= edamage
  109.           rdamage=edamage*self.preb/100*(100-attacker.pdr)/100
  110.         end
  111.         
  112.         if rdamage>0
  113.           if attacker.state?(2)#判断是否开启魔法盾抵抗反弹伤害
  114.             amdamage = rdamage*attacker.sdr/100#计算开启魔法盾的魔力伤害
  115.             if attacker.sp < amdamage/attacker.sdd#魔力不足以支持完整的魔法盾
  116.               $game_variables[1]=1
  117.               attacker.damage = rdamage-attacker.sp*attacker.sdd
  118.               attacker.damage_pop = true
  119.               attacker.hp -= rdamage-attacker.sp*attacker.sdd
  120.               $game_variables[2]=6
  121.               attacker.sp_damage = attacker.sp
  122.               attacker.sp_damage_pop = true
  123.               attacker.sp = 0
  124.               remove_state(2)
  125.             else
  126.               $game_variables[1]=1
  127.               attacker.damage = rdamage - amdamage
  128.               attacker.damage_pop = true
  129.               attacker.hp -= rdamage - amdamage
  130.               $game_variables[2]=6
  131.               attacker.sp_damage = amdamage / attacker.sdd
  132.               attacker.sp_damage_pop = true
  133.               attacker.sp -= amdamage / attacker.sdd
  134.             end
  135.           else
  136.             $game_variables[1]=1
  137.             attacker.damage = rdamage
  138.             attacker.damage_pop = true
  139.             attacker.hp -= rdamage#受到反弹
  140.           end
  141.         end
  142.         $game_variables[1]=2
  143.         attacker.damage = damage * attacker.pvam / 100
  144.         attacker.damage_pop = true
  145.         attacker.hp += damage * attacker.pvam / 100#攻击吸血
  146.         
  147.         # 清除会心一击标志
  148.         self.critical = false
  149.         # 状态变化
  150.         @state_changed = false
  151.         states_plus(attacker.plus_state_set)
  152.         states_minus(attacker.minus_state_set)
  153.       else#MISS
  154.         # 伤害设置为 "Miss"
  155.         self.damage = "Miss"
  156.         # 清除会心一击标志
  157.         self.critical = false
  158.       end
  159.          
  160.     else#MISS
  161.       # 伤害设置为 "Lost"
  162.       self.damage = "Miss"
  163.       # 清除会心一击标志
  164.       self.critical = false
  165.     end
  166.     # 过程结束
  167.     return true
  168.   end
  169.   #--------------------------------------------------------------------------
  170.   # ● 应用特技效果
  171.   #     user  : 特技的使用者 (battler)
  172.   #     skill : 特技
  173.   #--------------------------------------------------------------------------
  174.   def skill_effect(user, skill)
  175.     # 清除会心一击标志
  176.     self.critical = false
  177.     # 特技的效果范围是 HP 1 以上的己方、自己的 HP 为 0、
  178.     # 或者特技的效果范围是 HP 0 的己方、自己的 HP 为 1 以上的情况下
  179.     if ((skill.scope == 3 or skill.scope == 4) and self.hp == 0) or
  180.        ((skill.scope == 5 or skill.scope == 6) and self.hp >= 1)
  181.       bdmz=true
  182.       # 过程结束
  183.       return false
  184.     end
  185.     # 清除有效标志
  186.     effective = false
  187.     # 公共事件 ID 是有效的情况下,设置为有效标志
  188.     effective |= skill.common_event_id > 0
  189.     # 第一命中判定
  190.     if $skills_dt[skill.id]==0#物理类型技能
  191.       mz=rand(100)
  192.       if mz > self.pdod
  193.         mz=rand(100)
  194.         if mz < user.phit
  195.           hit_result = true
  196.         else
  197.           hit_result = false
  198.           mz=0
  199.         end
  200.       else
  201.         hit_result = false
  202.         mz=0
  203.       end
  204.     elsif $skills_dt[skill.id]==1#魔法类型技能
  205.       mz=rand(100)
  206.       if mz > self.mdod
  207.         mz=rand(100)
  208.         if mz < user.mhit
  209.           hit_result = true
  210.         else
  211.           hit_result = false
  212.           mz=0
  213.         end
  214.       else
  215.         hit_result = false
  216.         mz=0
  217.       end
  218.     else#纯粹类型技能
  219.       mz = skill.hit
  220.     end
  221.     hit_result = (rand(100) < mz)
  222.     # 不确定的特技的情况下设置为有效标志
  223.     effective |= mz < 100
  224.     # 命中的情况下
  225.     if hit_result == true or bdmz==true
  226.       # 计算威力
  227.       if $skills_dt[skill.id]==0#物理类型技能
  228.         power = [user.patk - self.pdef, 0].max
  229.       elsif $skills_dt[skill.id]==1#魔法类型技能
  230.         power = [user.matk - self.mdef, 0].max
  231.       else#纯粹类型技能
  232.         power = skill.power
  233.       end
  234.       if power > 0
  235.         power = [power, 0].max
  236.       end
  237.       # 计算倍率
  238.       rate = 20
  239.       # 计算基本伤害
  240.       self.damage = power * rate / 20
  241.       if $skills_dt[skill.id]==0#物理类型技能
  242.         self.damage*=(100+self.pog)/100
  243.       elsif $skills_dt[skill.id]==1#魔法类型技能
  244.         self.damage*=(100+self.mog)/100
  245.       end
  246.       # 属性修正
  247.       self.damage *= elements_correct(skill.element_set)
  248.       self.damage /= 100
  249.       # 伤害符号正确的情况下
  250.       if self.damage > 0
  251.         # 暴击修正
  252.         if $skills_dt[skill.id]==0#物理类型技能
  253.           if rand(100) < user.pcr
  254.             self.damage *= (100+user.pcrc)/100
  255.             self.critical = true
  256.           end
  257.         elsif $skills_dt[skill.id]==1#魔法类型技能
  258.           if rand(100) < user.mcr
  259.             self.damage *= (100+user.mcrc)/100
  260.             self.critical = true
  261.           end
  262.         end
  263.         # 防御修正
  264.         if self.guarding?
  265.           self.damage /= 2
  266.         end
  267.       end
  268.       # 分散
  269.       if skill.variance > 0 and self.damage.abs > 0
  270.         amp = [self.damage.abs * skill.variance / 100, 1].max
  271.         self.damage += rand(amp+1) + rand(amp+1) - amp
  272.       end
  273.       # 第二命中判定
  274.       if $skills_dt[skill.id]==0#物理类型技能
  275.         mz=rand(100)
  276.         if mz > self.pdod
  277.           mz=rand(100)
  278.           if mz < user.phit
  279.             hit_result = true
  280.           else
  281.             hit_result = false
  282.             mz=0
  283.           end
  284.         else
  285.           hit_result = false
  286.           mz=0
  287.         end
  288.       elsif $skills_dt[skill.id]==1#魔法类型技能
  289.         mz=rand(100)
  290.         if mz > self.mdod
  291.           mz=rand(100)
  292.           if mz < user.mhit
  293.             hit_result = true
  294.           else
  295.             hit_result = false
  296.             mz=0
  297.           end
  298.         else
  299.           hit_result = false
  300.           mz=0
  301.         end
  302.       else#纯粹类型技能
  303.         mz = skill.hit
  304.       end
  305.       hit_result = (rand(100) < mz)
  306.       # 不确定的特技的情况下设置为有效标志
  307.       effective |= mz < 100
  308.     end
  309.     # 命中的情况下
  310.     if hit_result == true or bdmz==true
  311.       # 威力 0 以外的物理攻击的情况下
  312.       if skill.power != 0 and skill.atk_f > 0
  313.         # 状态冲击解除
  314.         remove_states_shock
  315.         # 设置有效标志
  316.         effective = true
  317.       end
  318.       if bdmz==true
  319.         # 状态冲击解除
  320.         remove_states_shock
  321.         # 设置有效标志
  322.         effective = true
  323.       end
  324.       # HP 的伤害减法运算
  325.       last_hp = self.hp
  326.       if $skills_dt[skill.id]==0#物理类型技能
  327.         self.damage*=(100-self.pdr)/100
  328.       elsif $skills_dt[skill.id]==1#魔法类型技能
  329.         self.damage*=(100-self.mdr)/100
  330.       end
  331.       #法术吸蓝
  332.       if skill.id == 10
  333.         if self.sp == 0
  334.           self.damage = 0
  335.           self.hp -= self.damage
  336.         else
  337.           self.sp -= self.damage
  338.           user.sp += self.damage * 50 / 100
  339.         end
  340.       else
  341.         #魔法盾
  342.         if states.include?(17)
  343.           if self.sp == 0
  344.             self.hp -= self.damage
  345.             remove_state(17)
  346.           else
  347.             self.hp -= self.damage * (100-self.sdd) / 100
  348.             self.sp -= self.damage * self.sdd / 100
  349.           end
  350.         else
  351.           self.hp -= self.damage
  352.         end
  353.       end
  354.       effective |= self.hp != last_hp
  355.       # 状态变化
  356.       @state_changed = false
  357.       effective |= states_plus(skill.plus_state_set)
  358.       effective |= states_minus(skill.minus_state_set)
  359.       
  360.       if $skills_dt[skill.id]==0#物理类型技能
  361.         user.hp -= self.damage * self.preb / 100#受到反弹
  362.         user.hp += self.damage * user.pvam / 100#攻击吸血
  363.       elsif $skills_dt[skill.id]==1#魔法类型技能
  364.         user.hp -= self.damage * self.mreb / 100#法术反弹
  365.         user.hp += self.damage * user.mvam / 100#法术吸血
  366.       end
  367.       
  368.       # 威力为 0 的场合
  369.       if skill.power == 0
  370.         # 伤害设置为空的字串
  371.         self.damage = ""
  372.         # 状态没有变化的情况下
  373.         unless @state_changed
  374.           # 伤害设置为 "Miss"
  375.           self.damage = "Miss"
  376.         end
  377.       end
  378.     # Miss 的情况下
  379.     else
  380.       # 伤害设置为 "Miss"
  381.       self.damage = "Miss"
  382.       # 清除会心一击标志
  383.       self.critical = false
  384.       bdmz=false
  385.     end
  386.     # 不在战斗中的情况下
  387.     unless $game_temp.in_battle
  388.       # 伤害设置为 nil
  389.       self.damage = nil
  390.     end
  391.     # 过程结束
  392.     return effective
  393.   end
  394.   #--------------------------------------------------------------------------
  395.   # ● 应用物品效果
  396.   #     item : 物品
  397.   #--------------------------------------------------------------------------
  398.   def item_effect(item)
  399.     # 清除会心一击标志
  400.     self.critical = false
  401.     # 物品的效果范围是 HP 1 以上的己方、自己的 HP 为 0、
  402.     # 或者物品的效果范围是 HP 0 的己方、自己的 HP 为 1 以上的情况下
  403.     if ((item.scope == 3 or item.scope == 4) and self.hp == 0) or
  404.        ((item.scope == 5 or item.scope == 6) and self.hp >= 1)
  405.       # 过程结束
  406.       return false
  407.     end
  408.     # 清除有效标志
  409.     effective = false
  410.     # 公共事件 ID 是有效的情况下,设置为有效标志
  411.     effective |= item.common_event_id > 0
  412.     # 命中判定
  413.     hit_result = (rand(100) < item.hit)
  414.     # 不确定的特技的情况下设置为有效标志
  415.     effective |= item.hit < 100
  416.     # 命中的情况
  417.     if hit_result == true
  418.       # 计算回复量
  419.       recover_hp = maxhp * item.recover_hp_rate / 100 + item.recover_hp
  420.       recover_sp = maxsp * item.recover_sp_rate / 100 + item.recover_sp
  421.       if recover_hp < 0
  422.         recover_hp += self.pdef * item.pdef_f / 20
  423.         recover_hp += self.mdef * item.mdef_f / 20
  424.         recover_hp = [recover_hp, 0].min
  425.       end
  426.       # 属性修正
  427.       recover_hp *= elements_correct(item.element_set)
  428.       recover_hp /= 100
  429.       recover_sp *= elements_correct(item.element_set)
  430.       recover_sp /= 100
  431.       # 分散
  432.       if item.variance > 0 and recover_hp.abs > 0
  433.         amp = [recover_hp.abs * item.variance / 100, 1].max
  434.         recover_hp += rand(amp+1) + rand(amp+1) - amp
  435.       end
  436.       if item.variance > 0 and recover_sp.abs > 0
  437.         amp = [recover_sp.abs * item.variance / 100, 1].max
  438.         recover_sp += rand(amp+1) + rand(amp+1) - amp
  439.       end
  440.       # 回复量符号为负的情况下
  441.       if recover_hp < 0
  442.         # 防御修正
  443.         if self.guarding?
  444.           recover_hp /= 2
  445.         end
  446.       end
  447.       # HP 回复量符号的反转、设置伤害值
  448.       self.damage = -recover_hp
  449.       # HP 以及 SP 的回复
  450.       last_hp = self.hp
  451.       last_sp = self.sp
  452.       self.hp += recover_hp
  453.       self.sp += recover_sp
  454.       effective |= self.hp != last_hp
  455.       effective |= self.sp != last_sp
  456.       # 状态变化
  457.       @state_changed = false
  458.       effective |= states_plus(item.plus_state_set)
  459.       effective |= states_minus(item.minus_state_set)
  460.       # 能力上升值有效的情况下
  461.       if item.parameter_type > 0 and item.parameter_points != 0
  462.         # 能力值的分支
  463.         case item.parameter_type
  464.         when 1  # MaxHP
  465.           @maxhp_plus += item.parameter_points
  466.         when 2  # MaxSP
  467.           @maxsp_plus += item.parameter_points
  468.         when 3  # 力量
  469.           @str_plus += item.parameter_points
  470.         when 4  # 灵巧
  471.           @dex_plus += item.parameter_points
  472.         when 5  # 速度
  473.           @agi_plus += item.parameter_points
  474.         when 6  # 魔力
  475.           @int_plus += item.parameter_points
  476.         end
  477.         # 设置有效标志
  478.         effective = true
  479.       end
  480.       # HP 回复率与回复量为 0 的情况下
  481.       if item.recover_hp_rate == 0 and item.recover_hp == 0
  482.         # 设置伤害为空的字符串
  483.         self.damage = ""
  484.         # SP 回复率与回复量为 0、能力上升值无效的情况下
  485.         if item.recover_sp_rate == 0 and item.recover_sp == 0 and
  486.            (item.parameter_type == 0 or item.parameter_points == 0)
  487.           # 状态没有变化的情况下
  488.           unless @state_changed
  489.             # 伤害设置为 "Miss"
  490.             self.damage = "Miss"
  491.           end
  492.         end
  493.       end
  494.     # Miss 的情况下
  495.     else
  496.       # 伤害设置为 "Miss"
  497.       self.damage = "Miss"
  498.     end
  499.     # 不在战斗中的情况下
  500.     unless $game_temp.in_battle
  501.       # 伤害设置为 nil
  502.       self.damage = nil
  503.     end
  504.     # 过程结束
  505.     return effective
  506.   end
  507.   #--------------------------------------------------------------------------
  508.   # ● 应用连续伤害效果
  509.   #--------------------------------------------------------------------------
  510.   def slip_damage_effect
  511.     # 设置伤害
  512.     self.damage = self.maxhp / 10
  513.     # 分散
  514.     if self.damage.abs > 0
  515.       amp = [self.damage.abs * 15 / 100, 1].max
  516.       self.damage += rand(amp+1) + rand(amp+1) - amp
  517.     end
  518.     # HP 的伤害减法运算
  519.     self.hp -= self.damage
  520.     # 过程结束
  521.     return true
  522.   end
  523.   #--------------------------------------------------------------------------
  524.   # ● 属性修正计算
  525.   #     element_set : 属性
  526.   #--------------------------------------------------------------------------
  527.   def elements_correct(element_set)
  528.     # 无属性的情况
  529.     if element_set == []
  530.       # 返回 100
  531.       return 100
  532.     end
  533.     # 在被赋予的属性中返回最弱的
  534.     # ※过程 element_rate 是、本类以及继承的 Game_Actor
  535.     #   和 Game_Enemy 类的定义
  536.     weakest = -100
  537.     for i in element_set
  538.       weakest = [weakest, self.element_rate(i)].max
  539.     end
  540.     return weakest
  541.   end
  542. end[code/]
  543. [code]=begin
  544. 伤害效果美化 v1.0 by SailCat
  545. 脚本使用说明:
  546. 1.使用时需要将Damage.png复制到你的游戏的Graphics/Pictures目录下
  547. 2.Damage.png文件的格式:
  548.    大小为180 x 96
  549.    (0, 0) - (179, 31)为伤害值的数字表,其中每个数字宽18,高32
  550.    (0, 32) - (179, 63)为回复值(伤害负值)的数字表,其中每个数字宽18,高32
  551.    (0, 64) - (89, 95)为会心一击标记的图画,长宽为90 x 32
  552.    (90, 64) - (179, 95)为未命中标记的图画,长宽为90 x 32
  553. 3.number.png文件的格式:
  554.    大小为270 x 270
  555.    (0, 0) - (179, 33+i)为伤害值的数字表,其中每个数字宽27,高33
  556.    (0, 233) - (89, 95)为会心一击标记的图画,长宽为90 x 32
  557.    (90, 233) - (179, 95)为未命中标记的图画,长宽为90 x 32
  558. =end
  559. module RPG
  560.   class Sprite < ::Sprite
  561.     #--------------------------------------------------------------------------
  562.     # ● 伤害值描画
  563.     #--------------------------------------------------------------------------
  564.     def damage(value, critical)
  565.       # 释放伤害
  566.       dispose_damage
  567.       # 如果伤害值是数值
  568.       if value.is_a?(Numeric)
  569.         # 绝对值转为字符串
  570.         damage_string = value.abs.to_s
  571.       else
  572.         # 转为字符串
  573.         damage_string = value.to_s
  574.       end
  575.       # 初始化位图
  576.       bitmap = Bitmap.new(270, 231)
  577.       bitmap.font.name = "Arial Black"
  578.       bitmap.font.size = 32
  579.       # 伤害值是数值的情况下
  580.       if value.is_a?(Numeric)
  581.         # 分割伤害值字符串
  582.         damage_array = damage_string.scan(/./)
  583.         damage_x = 81 - damage_string.size * 9
  584.         # 伤害值为负的情况下
  585.         x = damage_x- 20
  586.         # 循环伤害值字符串
  587.         for char in damage_array
  588.           number = char.to_i
  589.           # 显示伤害数字
  590.           if $game_variables[1]==0
  591.           bitmap.blt(damage_x, 32, RPG::Cache.picture("numbers"),
  592.             Rect.new(number * 27, 0, 27, 33))
  593.           elsif $game_variables[1]==1
  594.           bitmap.blt(damage_x, 32, RPG::Cache.picture("numbers"),
  595.             Rect.new(number * 27, 33, 27, 33))
  596.           elsif $game_variables[1]==2
  597.           bitmap.blt(damage_x, 32, RPG::Cache.picture("numbers"),
  598.             Rect.new(number * 27, 66, 27, 33))
  599.           elsif $game_variables[1]==3
  600.           bitmap.blt(damage_x, 32, RPG::Cache.picture("numbers"),
  601.             Rect.new(number * 27, 99, 27, 33))
  602.           elsif $game_variables[1]==4
  603.           bitmap.blt(damage_x, 32, RPG::Cache.picture("numbers"),
  604.             Rect.new(number * 27, 132, 27, 33))
  605.           elsif $game_variables[1]==5
  606.           bitmap.blt(damage_x, 32, RPG::Cache.picture("numbers"),
  607.             Rect.new(number * 27, 165, 27, 33))
  608.           elsif $game_variables[1]==6
  609.           bitmap.blt(damage_x, 32, RPG::Cache.picture("numbers"),
  610.             Rect.new(number * 27, 198, 27, 33))
  611.           elsif $game_variables[1]==7
  612.           bitmap.blt(damage_x, 32, RPG::Cache.picture("numbers"),
  613.             Rect.new(number * 27, 231, 27, 33))
  614.           end
  615.           # 后移一位
  616.           damage_x += 27
  617.         end
  618.       # 伤害值不是数值的情况
  619.       else
  620.         # 如果伤害值不是 Miss
  621.         unless value == "Miss"
  622.           # 系统默认描画字符串
  623.           bitmap.font.color.set(255, 0, 0)
  624.           bitmap.draw_text(-1, 27, 162, 36, damage_string, 1)
  625.           bitmap.draw_text(+1, 27, 162, 36, damage_string, 1)
  626.           bitmap.draw_text(-1, 29, 162, 36, damage_string, 1)
  627.           bitmap.draw_text(+1, 29, 162, 36, damage_string, 1)
  628.           bitmap.font.color.set(255, 255, 255)
  629.           bitmap.draw_text(0, 28, 162, 36, damage_string, 1)
  630.         # Miss 的情况下
  631.         else
  632.           # 显示未击中图画
  633.           bitmap.blt(36, 28, RPG::Cache.picture("numbers"), Rect.new(108, 233, 108, 32))
  634.         end
  635.       end
  636.       # 会心一击标志打开的情况
  637.       if critical
  638.         # 显示会心一击图画
  639.         bitmap.blt(36, 0, RPG::Cache.picture("numbers"), Rect.new(32, 233, 90, 32))
  640.       end
  641.       # 伤害值定位
  642.       @_damage_sprite = ::Sprite.new(self.viewport)
  643.       @_damage_sprite.bitmap = bitmap
  644.       @_damage_sprite.ox = 81
  645.       @_damage_sprite.oy = 70
  646.       @_damage_sprite.x = self.battler.screen_x
  647.       @_damage_sprite.y = self.y - self.oy / 2
  648.       @_damage_sprite.z = 3000
  649.       @_damage_duration = 50
  650.       $game_variables[1]=0
  651.     end
  652.   end
  653. end
  654. #==============================================================================
  655. # 本脚本来自[url]www.66RPG.com[/url],使用和转载请保留此信息
  656. #==============================================================================[code/]
  657. [code]#=============================================================================
  658. # 仿 伤害显示 ,在 Sprite 里又添加了个伤害显示,来显示 SP伤害。
  659. # 添加了第二个动画显示。(可同时两重动画)                       <- 芯☆淡如水
  660. #=============================================================================
  661. module RPG
  662.   class Sprite < ::Sprite
  663.     @@_animations = []
  664.     @@_reference_count = {}
  665.    def initialize(viewport = nil)
  666.       super(viewport)
  667.       @_whiten_duration = 0
  668.       @_appear_duration = 0
  669.       @_escape_duration = 0
  670.       @_collapse_duration = 0
  671.       @_damage_duration = 0
  672.       @_sp_damage_duration = 0
  673.       @_animation_duration = 0
  674.       @_animation_duration2 = 0
  675.       @_blink = false
  676.     end
  677.     def dispose
  678.       dispose_damage
  679.       dispose_sp_damage
  680.       dispose_animation
  681.       dispose_animation2
  682.       dispose_loop_animation
  683.       super
  684.     end
  685.     def sp_damage(value)
  686.       dispose_sp_damage
  687.       if value.is_a?(Numeric)
  688.         sp_damage_string = value.abs.to_s
  689.       end
  690.       sp_bitmap = Bitmap.new(270, 231)
  691.       sp_bitmap.font.name = "Arial Black"
  692.       sp_bitmap.font.size = 32
  693.       if value.is_a?(Numeric)
  694.         sp_damage_array = sp_damage_string.scan(/./)
  695.         sp_damage_x = 81 - sp_damage_string.size * 9
  696.         x = sp_damage_x - 20
  697.         for n in sp_damage_array
  698.           number = n.to_i
  699.           if $game_variables[2]==0
  700.           sp_bitmap.blt(sp_damage_x, 33, RPG::Cache.picture("numbers"),
  701.             Rect.new(number * 27, 0, 27, 33))
  702.           elsif $game_variables[2]==1
  703.           sp_bitmap.blt(sp_damage_x, 33, RPG::Cache.picture("numbers"),
  704.             Rect.new(number * 27, 33, 27, 33))
  705.           elsif $game_variables[2]==2
  706.           sp_bitmap.blt(sp_damage_x, 33, RPG::Cache.picture("numbers"),
  707.             Rect.new(number * 27, 66, 27, 33))
  708.           elsif $game_variables[2]==3
  709.           sp_bitmap.blt(sp_damage_x, 33, RPG::Cache.picture("numbers"),
  710.             Rect.new(number * 27, 99, 27, 33))
  711.           elsif $game_variables[2]==4
  712.           sp_bitmap.blt(sp_damage_x, 33, RPG::Cache.picture("numbers"),
  713.             Rect.new(number * 27, 132, 27, 33))
  714.           elsif $game_variables[2]==5
  715.           sp_bitmap.blt(sp_damage_x, 33, RPG::Cache.picture("numbers"),
  716.             Rect.new(number * 27, 165, 27, 33))
  717.           elsif $game_variables[2]==6
  718.           sp_bitmap.blt(sp_damage_x, 33, RPG::Cache.picture("numbers"),
  719.             Rect.new(number * 27, 198, 27, 33))
  720.           elsif $game_variables[2]==7
  721.           sp_bitmap.blt(sp_damage_x, 33, RPG::Cache.picture("numbers"),
  722.             Rect.new(number * 27, 231, 27, 33))
  723.           end
  724.           sp_damage_x += 27
  725.         end
  726.       else
  727.         sp_bitmap.blt(36, 28, RPG::Cache.picture("numbers"), Rect.new(126, 233, 90, 33))
  728.       end
  729.       @_sp_damage_sprite = ::Sprite.new(self.viewport)
  730.       @_sp_damage_sprite.bitmap = sp_bitmap
  731.       @_sp_damage_sprite.ox = 81
  732.       @_sp_damage_sprite.oy = 40
  733.       @_sp_damage_sprite.x = self.battler.screen_x
  734.       @_sp_damage_sprite.y = self.y - self.oy / 2
  735.       @_sp_damage_sprite.z = 3001
  736.       @_sp_damage_duration = 50
  737.       $game_variables[2]=0
  738.     end
  739.     def animation2(animation2, hit2)
  740.       dispose_animation2
  741.       @_animation2 = animation2
  742.       return if @_animation2 == nil
  743.       @_animation_hit2 = hit2
  744.       @_animation_duration2 = @_animation2.frame_max
  745.       animation_name = @_animation2.animation_name
  746.       animation_hue = @_animation2.animation_hue
  747.       bitmap = RPG::Cache.animation(animation_name, animation_hue)
  748.       if @@_reference_count.include?(bitmap)
  749.         @@_reference_count[bitmap] += 1
  750.       else
  751.         @@_reference_count[bitmap] = 1
  752.       end
  753.       @_animation2_sprites = []
  754.       if @_animation2.position != 3 or not @@_animations.include?(animation2)
  755.         for i in 0..15
  756.           sprite = ::Sprite.new(self.viewport)
  757.           sprite.bitmap = bitmap
  758.           sprite.visible = false
  759.           @_animation2_sprites.push(sprite)
  760.         end
  761.         unless @@_animations.include?(animation2)
  762.           @@_animations.push(animation2)
  763.         end
  764.       end
  765.       update_animation2
  766.     end
  767.     def dispose_sp_damage
  768.       if @_sp_damage_sprite != nil
  769.         @_sp_damage_sprite.bitmap.dispose
  770.         @_sp_damage_sprite.dispose
  771.         @_sp_damage_sprite = nil
  772.         @_sp_damage_duration = 0
  773.       end
  774.     end
  775.     def dispose_animation2
  776.       if @_animation2_sprites != nil
  777.         sprite = @_animation2_sprites[0]
  778.         if sprite != nil
  779.           @@_reference_count[sprite.bitmap] -= 1
  780.           if @@_reference_count[sprite.bitmap] == 0
  781.             sprite.bitmap.dispose
  782.           end
  783.         end
  784.         for sprite in @_animation2_sprites
  785.           sprite.dispose
  786.         end
  787.         @_animation2_sprites = nil
  788.         @_animation2 = nil
  789.       end
  790.     end
  791.     def effect?
  792.       @_whiten_duration > 0 or
  793.       @_appear_duration > 0 or
  794.       @_escape_duration > 0 or
  795.       @_collapse_duration > 0 or
  796.       @_damage_duration > 0 or
  797.       @_sp_damage_duration > 0 or
  798.       @_animation_duration > 0 or
  799.       @_animation_duration2 > 0
  800.     end
  801.     def update
  802.       super
  803.       if @_whiten_duration > 0
  804.         @_whiten_duration -= 1
  805.         self.color.alpha = 128 - (16 - @_whiten_duration) * 10
  806.       end
  807.       if @_appear_duration > 0
  808.         @_appear_duration -= 1
  809.         self.opacity = (16 - @_appear_duration) * 16
  810.       end
  811.       if @_escape_duration > 0
  812.         @_escape_duration -= 1
  813.         self.opacity = 256 - (32 - @_escape_duration) * 10
  814.       end
  815.       if @_collapse_duration > 0
  816.         @_collapse_duration -= 1
  817.         self.opacity = 256 - (48 - @_collapse_duration) * 6
  818.       end
  819.       if @_sp_damage_duration > 0
  820.         @_sp_damage_duration -= 1
  821.         case @_sp_damage_duration
  822.         when 48..49
  823.           @_sp_damage_sprite.y -= 4
  824.         when 46..47
  825.           @_sp_damage_sprite.y -= 2
  826.         when 44..45
  827.           @_sp_damage_sprite.y += 2
  828.         when 38..43
  829.           @_sp_damage_sprite.y += 4
  830.         end
  831.         @_sp_damage_sprite.opacity = 256 - (12 - @_sp_damage_duration) * 32
  832.         if @_sp_damage_duration == 0
  833.           dispose_sp_damage
  834.         end
  835.       end
  836.       if @_damage_duration > 0
  837.         @_damage_duration -= 1
  838.         case @_damage_duration
  839.         when 48..49
  840.           @_damage_sprite.y -= 4
  841.         when 46..47
  842.           @_damage_sprite.y -= 2
  843.         when 44..45
  844.           @_damage_sprite.y += 2
  845.         when 38..43
  846.           @_damage_sprite.y += 4
  847.         end
  848.         @_damage_sprite.opacity = 256 - (12 - @_damage_duration) * 32
  849.         if @_damage_duration == 0
  850.           dispose_damage
  851.         end
  852.       end
  853.       if @_animation != nil and (Graphics.frame_count % 2 == 0)
  854.         @_animation_duration -= 1
  855.         update_animation
  856.       end
  857.       if @_animation2 != nil and (Graphics.frame_count % 2 == 0)
  858.         @_animation_duration2 -= 1
  859.         update_animation2
  860.       end
  861.       if @_loop_animation != nil and (Graphics.frame_count % 2 == 0)
  862.         update_loop_animation
  863.         @_loop_animation_index += 1
  864.         @_loop_animation_index %= @_loop_animation.frame_max
  865.       end
  866.       if @_blink
  867.         @_blink_count = (@_blink_count + 1) % 32
  868.         if @_blink_count < 16
  869.           alpha = (16 - @_blink_count) * 6
  870.         else
  871.           alpha = (@_blink_count - 16) * 6
  872.         end
  873.         self.color.set(255, 255, 255, alpha)
  874.       end
  875.       @@_animations.clear
  876.     end
  877.     def update_animation
  878.       if @_animation_duration > 0
  879.         frame_index = @_animation.frame_max - @_animation_duration
  880.         cell_data = @_animation.frames[frame_index].cell_data
  881.         position = @_animation.position
  882.         animation_set_sprites(@_animation_sprites, cell_data, position)
  883.         for timing in @_animation.timings
  884.           if timing.frame == frame_index
  885.             animation_process_timing(timing, @_animation_hit)
  886.           end
  887.         end
  888.       else
  889.         dispose_animation
  890.       end
  891.     end
  892.     def update_animation2
  893.       if @_animation_duration2 > 0
  894.         frame_index = @_animation2.frame_max - @_animation_duration2
  895.         cell_data = @_animation2.frames[frame_index].cell_data
  896.         position = @_animation2.position
  897.         animation_set_sprites(@_animation2_sprites, cell_data, position)
  898.         for timing in @_animation2.timings
  899.           if timing.frame == frame_index
  900.             animation_process_timing(timing, @_animation_hit2)
  901.           end
  902.         end
  903.       else
  904.         dispose_animation2
  905.       end
  906.     end
  907.     def update_loop_animation
  908.       frame_index = @_loop_animation_index
  909.       cell_data = @_loop_animation.frames[frame_index].cell_data
  910.       position = @_loop_animation.position
  911.       animation_set_sprites(@_loop_animation_sprites, cell_data, position)
  912.       for timing in @_loop_animation.timings
  913.         if timing.frame == frame_index
  914.           animation_process_timing(timing, true)
  915.         end
  916.       end
  917.     end
  918.     def animation_set_sprites(sprites, cell_data, position)
  919.       for i in 0..15
  920.         sprite = sprites[i]
  921.         pattern = cell_data[i, 0]
  922.         if sprite == nil or pattern == nil or pattern == -1
  923.           sprite.visible = false if sprite != nil
  924.           next
  925.         end
  926.         sprite.visible = true
  927.         sprite.src_rect.set(pattern % 5 * 192, pattern / 5 * 192, 192, 192)
  928.         if position == 3
  929.           if self.viewport != nil
  930.             sprite.x = self.viewport.rect.width / 2
  931.             sprite.y = self.viewport.rect.height - 160
  932.           else
  933.             sprite.x = 320
  934.             sprite.y = 240
  935.           end
  936.         else
  937.           sprite.x = self.x - self.ox + self.src_rect.width / 2
  938.           sprite.y = self.y - self.oy + self.src_rect.height / 2
  939.           sprite.y -= self.src_rect.height / 4 if position == 0
  940.           sprite.y += self.src_rect.height / 4 if position == 2
  941.         end
  942.         sprite.x += cell_data[i, 1]
  943.         sprite.y += cell_data[i, 2]
  944.         sprite.z = 2000
  945.         sprite.ox = 96
  946.         sprite.oy = 96
  947.         sprite.zoom_x = cell_data[i, 3] / 100.0
  948.         sprite.zoom_y = cell_data[i, 3] / 100.0
  949.         sprite.angle = cell_data[i, 4]
  950.         sprite.mirror = (cell_data[i, 5] == 1)
  951.         sprite.opacity = cell_data[i, 6] * self.opacity / 255.0
  952.         sprite.blend_type = cell_data[i, 7]
  953.       end
  954.     end
  955.     def animation_process_timing(timing, hit)
  956.       if (timing.condition == 0) or
  957.          (timing.condition == 1 and hit == true) or
  958.          (timing.condition == 2 and hit == false)
  959.         if timing.se.name != ""
  960.           se = timing.se
  961.           Audio.se_play("Audio/SE/" + se.name, se.volume, se.pitch)
  962.         end
  963.         case timing.flash_scope
  964.         when 1
  965.           self.flash(timing.flash_color, timing.flash_duration * 2)
  966.         when 2
  967.           if self.viewport != nil
  968.             self.viewport.flash(timing.flash_color, timing.flash_duration * 2)
  969.           end
  970.         when 3
  971.           self.flash(nil, timing.flash_duration * 2)
  972.         end
  973.       end
  974.     end
  975.     def x=(x)
  976.       sx = x - self.x
  977.       if sx != 0
  978.         if @_animation_sprites != nil
  979.           for i in 0..15
  980.             @_animation_sprites[i].x += sx
  981.           end
  982.         end
  983.         if @_loop_animation_sprites != nil
  984.           for i in 0..15
  985.             @_loop_animation_sprites[i].x += sx
  986.           end
  987.         end
  988.       end
  989.       super
  990.     end
  991.     def y=(y)
  992.       sy = y - self.y
  993.       if sy != 0
  994.         if @_animation_sprites != nil
  995.           for i in 0..15
  996.             @_animation_sprites[i].y += sy
  997.           end
  998.         end
  999.         if @_loop_animation_sprites != nil
  1000.           for i in 0..15
  1001.             @_loop_animation_sprites[i].y += sy
  1002.           end
  1003.         end
  1004.       end
  1005.       super
  1006.     end
  1007.   end
  1008. end
  1009. #=============================================================================
复制代码
因为本人在战斗里面用到了伤害显示的脚本,而且战斗系统里有各种各样的伤害类型(中毒、魔法、普通攻击、反弹伤害、吸血效果等等···),所以本来是按照SP显示的那部分脚本做了反弹和吸血的对应脚本···但是后来发现做出来的反弹和吸血的显示无法消除,所以想了一个折衷的方法,用变量来决定显示伤害的颜色(缺陷是不能和普通攻击伤害的数值一起显示了),但是现在仍然出了很奇怪的BUG——只有1号变量为0,2号变量为6时显示的才是对应颜色(红、蓝),其他都会显示黄色,更讨厌的是,如果把第108行#self.damage_pop = true#这句注释取消后颜色显示会混乱的注释去掉就会彻底混乱,变成只显示红色数字的局面···用p的结果显示却是变量已经改变,所以···找不出问题了···

请勿手残 by fux2
[img]http://service.t.sina.com.cn/widget/qmd/5339802982/c02e16bd/7.png

Lv4.逐梦者

梦石
7
星屑
1113
在线时间
334 小时
注册时间
2008-1-28
帖子
1566
2
发表于 2013-12-30 00:08:46 | 只看该作者
本帖最后由 未命名 于 2013-12-30 00:11 编辑

我这边没法直接测试……目测脚本暂时没发现问题。
不过可以发一下那个“numbers”的图片看看吗?
终于有可以放在这里的游戏了……
极短13 新生 《箱子新世界》
回复 支持 反对

使用道具 举报

Lv4.逐梦者

梦石
0
星屑
9280
在线时间
2504 小时
注册时间
2011-5-20
帖子
15389

开拓者

3
 楼主| 发表于 2013-12-30 14:35:49 | 只看该作者
未命名 发表于 2013-12-30 00:08
我这边没法直接测试……目测脚本暂时没发现问题。
不过可以发一下那个“numbers”的图片看看吗? ...

你把这个脚本改了做成多种,然后显示的话就会有消不掉的···
[img]http://service.t.sina.com.cn/widget/qmd/5339802982/c02e16bd/7.png
回复 支持 反对

使用道具 举报

Lv4.逐梦者

梦石
7
星屑
1113
在线时间
334 小时
注册时间
2008-1-28
帖子
1566
4
发表于 2013-12-30 22:52:21 | 只看该作者
我这边有些变量没有定义,又不敢贸然修改。
但是我在默认的伤害显示里,用变量控制颜色运行正常,不过不是用图片,而是直接描绘文字。

另外,你的脚本第143行的赋值不会影响前面对variables[1]赋的值吗?
还有消不掉的原因,我猜可能是显示了多个图片重合,而你只消掉了第一个。或者是新加的SP显示没有对应消除。

啊啊,能力不行了,除此之外我还是看不出有什么问题。
终于有可以放在这里的游戏了……
极短13 新生 《箱子新世界》
回复 支持 反对

使用道具 举报

Lv4.逐梦者

梦石
0
星屑
9280
在线时间
2504 小时
注册时间
2011-5-20
帖子
15389

开拓者

5
 楼主| 发表于 2013-12-31 16:08:40 | 只看该作者
未命名 发表于 2013-12-30 22:52
我这边有些变量没有定义,又不敢贸然修改。
但是我在默认的伤害显示里,用变量控制颜色运行正常,不过不是 ...

对啊···新增加的无法消除···所以我才用了这一招···结果颜色又显示混乱···
[img]http://service.t.sina.com.cn/widget/qmd/5339802982/c02e16bd/7.png
回复 支持 反对

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2024-9-30 10:32

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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