查看: 2135|回复: 1

[已经解决] 怎么让显示伤害能同时显示HPSP伤害

[复制链接]
梦石
0
星屑
12161
在线时间
4435 小时
注册时间
2014-4-11
回帖
5616

开拓者

发表于 2016-6-14 22:17:51 | 显示全部楼层 |阅读模式

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

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

×
虽然可以显示SP或者HP伤害,但是不能同时显示HP和SP伤害。
加入我有技能同时减HP和SP的,那么就只能看到一个。

  1. #==============================================================================#
  2. # By Xiderowg / 桜雅 在土                                                      #                                                #
  3. #==============================================================================#                                              #  
  4. #==============================================================================#
  5. #                                   描述                                       #
  6. #==============================================================================#
  7. #这个脚本最初是由Xiderowg(桜雅 在土)创造的,但是这个脚本为了XAS中主角的编辑,#
  8. #而被Moghunter改动了很多。这个特点是动态的现实伤害值和主角获得的经验和金币。   #
  9. #==============================================================================#

  10. module XRXS_DAMAGE
  11.   def damage_x_init_velocity
  12.     return 0.2 * (rand(5) - 2)
  13.   end
  14.   def damage_y_init_velocity
  15.     return 9
  16.   end
  17.   GRAVITY = 0.58
  18.   TRANCEPARENT_START = 30
  19.   TRANCEPARENT_X_SLIDE = 0
  20. end

  21. $xrxs_damage_pop = true
  22. module XRXS_DamageSettings
  23.   DURATION = 40
  24.   CRITICAL_STRING     = "CRITICAL"
  25.   CRITICAL_FONT_SIZE  = 16
  26.   CRITICAL_FONT_COLOR = Color.new(255, 155, 50)
  27.   STATE_STRING     = "____State____"
  28.   STATE_FONT_SIZE  = 18
  29.   STATE_FONT_COLOR = Color.new(255, 255, 255)
  30.   ITEM_STRING     = "____ITEM____"
  31.   ITEM_FONT_SIZE  = 18
  32.   ITEM_FONT_COLOR = Color.new(255, 255, 255)  
  33.   DEFAULT_COLOR  = Color.new(255, 255, 255)  
  34.   DEFAULT_MINUS  = Color.new(176, 255, 144)
  35.   SPDAMAGE_COLOR = Color.new(255, 176, 144)   
  36.   SPDAMAGE_MINUS = Color.new(128, 255, 255)  
  37.   STATES_COLOR = Color.new(0, 150, 200)
  38.   STATES_MINUS = Color.new(170, 170, 170)   
  39.   SPECIAL_ACTION_COLOR_A = Color.new(250, 100, 100)
  40.   SPECIAL_ACTION_COLOR_B = Color.new(150, 150, 250)
  41.   ITEM_COLOR = Color.new(128, 200, 255)
  42.   SPECIAL_COLOR_SETS =
  43.     {"EXP"=>Color.new(155, 255, 64),
  44.        "G"=>Color.new(255, 255, 32),
  45.      "Level up!"=>Color.new(255, 255,  0)
  46.      }
  47.   def self.font
  48.     font = Font.new
  49.     font.name   = "黑体"
  50.     font.size   = 20            
  51.     font.bold   = true         
  52.     font.italic = false         
  53.     return font
  54.   end
  55. end
  56. module XRXS_ResultPop
  57.   EXP  = 50
  58.   GOLD = 30
  59. end
  60. #_______________________________________________________________________________

  61. module XRXS_DAMAGE
  62.   def update
  63.     super
  64.     @damage_sprites   = [] if @damage_sprites.nil?
  65.     @damage_durations = [] if @damage_durations.nil?
  66.     if @_damage_sprite != nil and @_damage_sprite.visible
  67.       x = damage_x_init_velocity
  68.       y = damage_y_init_velocity
  69.       d = @_damage_duration
  70.       @damage_sprites.push(Sprite_Damage.new(@_damage_sprite, x, y, d))
  71.       @_damage_sprite.visible = false
  72.     end
  73.     for damage_sprite in @damage_sprites
  74.       damage_sprite.update
  75.     end
  76.     for i in [email]0...@damage_sprites.size[/email]
  77.       @damage_sprites[i] = nil if @damage_sprites[i].disposed?
  78.     end
  79.     @damage_sprites.compact!
  80.   end
  81.   def dispose
  82.     super
  83.     if @damage_sprites != nil
  84.       for damage_sprite in @damage_sprites
  85.         damage_sprite.dispose
  86.       end
  87.     end
  88.   end
  89. end
  90. class RPG::Sprite < Sprite
  91.   include XRXS_DAMAGE
  92. end
  93. class Sprite_Damage < Sprite
  94.   def initialize(sprite, init_x_speed, init_y_speed, duration)
  95.     super(nil)
  96.     self.bitmap = sprite.bitmap.dup unless sprite.bitmap.nil?
  97.     self.opacity = sprite.opacity
  98.     self.x = sprite.x
  99.     self.y = sprite.y
  100.     self.z = sprite.z
  101.     self.ox = sprite.ox
  102.     self.oy = sprite.oy
  103.     @now_x_speed = init_x_speed
  104.     @now_y_speed = init_y_speed
  105.     @potential_x_energy = 0.0
  106.     @potential_y_energy = 0.0
  107.     @duration = duration
  108.   end
  109.   def update
  110.     if @duration <= XRXS_DAMAGE::TRANCEPARENT_START
  111.       self.opacity -= (256 / XRXS_DAMAGE::TRANCEPARENT_START)
  112.       self.x += XRXS_DAMAGE::TRANCEPARENT_X_SLIDE
  113.     end
  114.     super
  115.     n = self.oy + @now_y_speed
  116.     if n <= 0
  117.       @now_y_speed *= -1
  118.       @now_y_speed /=  2
  119.       @now_x_speed /=  2
  120.     end
  121.     self.oy  = [n, 0].max
  122.     @potential_y_energy += XRXS_DAMAGE::GRAVITY
  123.     speed = @potential_y_energy.floor
  124.     @now_y_speed        -= speed
  125.     @potential_y_energy -= speed
  126.     @potential_x_energy += @now_x_speed
  127.     speed = @potential_x_energy.floor
  128.     self.ox             += speed
  129.     @potential_x_energy -= speed
  130.     @duration -= 1
  131.     if @duration == 0
  132.       self.dispose
  133.     end
  134.   end
  135. end
  136. module XRXS_DamageSettings
  137.   def self.color(value_string)
  138.     for key in SPECIAL_COLOR_SETS.keys.sort!
  139.       return SPECIAL_COLOR_SETS[key] unless value_string.scan(key).empty?
  140.     end
  141.     unless value_string.scan($data_system.words.sp).empty?
  142.       value = (value_string.sub($data_system.words.sp){""}).to_i
  143.       color = (value >= 0 ? SPDAMAGE_COLOR : SPDAMAGE_MINUS)
  144.       value_string.gsub!("-") {""}
  145.       return color
  146.     end
  147.     unless value_string.scan("+  ").empty?
  148.       color = STATES_COLOR
  149.       return color  
  150.     end
  151.     unless value_string.scan("-  ").empty?
  152.       color = STATES_MINUS
  153.       return color  
  154.     end         
  155.     unless value_string.scan(XAS_BA_ENEMY::COUNTER_TEXT.to_s).empty?
  156.       color = SPECIAL_ACTION_COLOR_A
  157.       return color  
  158.     end      
  159.     unless value_string.scan(XAS_BA_ENEMY::FINAL_ATTACK_TEXT.to_s).empty?
  160.       color = SPECIAL_ACTION_COLOR_A
  161.       return color  
  162.     end
  163.     unless value_string.scan(XAS_SKILL::ONE_HP_TEXT.to_s).empty?
  164.       color = SPECIAL_ACTION_COLOR_A
  165.       return color  
  166.     end   
  167.     unless value_string.scan(XAS::DEATHCOUNT_TEXT_COUNT.to_s).empty?
  168.       color = SPECIAL_ACTION_COLOR_A
  169.       return color  
  170.     end   
  171.     unless value_string.scan(XAS::DEATHCOUNT_TEXT_DEATH.to_s).empty?
  172.       color = SPECIAL_ACTION_COLOR_A
  173.       return color  
  174.     end   
  175.     if $data_states[XAS::INVINCIBLE_ID] != nil
  176.     unless value_string.scan($data_states[XAS::INVINCIBLE_ID].name.to_s).empty?
  177.       color = SPECIAL_ACTION_COLOR_B
  178.       return color  
  179.     end   
  180.     end
  181.     if $data_states[XAS::REFLECT_ID] != nil
  182.     unless value_string.scan($data_states[XAS::REFLECT_ID].name.to_s).empty?           
  183.       color = SPECIAL_ACTION_COLOR_B
  184.       return color  
  185.     end   
  186.     end
  187.     unless value_string.scan(XAS_ABS_SETUP::DEFENSE_TEXT.to_s).empty?
  188.       color = SPECIAL_ACTION_COLOR_B
  189.       return color  
  190.     end      
  191.     unless value_string.scan(XAS_ABS_SETUP::ESCAPE_TEXT.to_s).empty?
  192.       color = SPECIAL_ACTION_COLOR_B
  193.       return color  
  194.     end     
  195.     unless value_string.scan(XAS_SKILL::STEAL_TEXT.to_s).empty?
  196.       color = ITEM_COLOR
  197.       return color  
  198.     end   
  199.     if $mog_rgss_ap_parameter != nil
  200.       unless value_string.scan(MOG::AP_NAME.to_s).empty?
  201.         color = ITEM_COLOR
  202.         return color  
  203.       end   
  204.     end
  205.     unless value_string.scan(" x ").empty?
  206.       color = ITEM_COLOR
  207.       return color  
  208.     end   
  209.     if $mog_rgss_xas_overdrive != nil
  210.     unless value_string.scan(MOG::OVDTEXT.to_s).empty?
  211.       color = SPECIAL_ACTION_COLOR_B
  212.       return color  
  213.     end      
  214.     end
  215.     value = (value_string).to_i
  216.     color = (value >= 0 ? DEFAULT_COLOR : DEFAULT_MINUS)
  217.     return color
  218.   end
  219. end
  220. module RPG
  221.   class Sprite < ::Sprite
  222.     def damage(value, critical, state, item)
  223.       dispose_damage
  224.       font  = XRXS_DamageSettings.font
  225.       color = XRXS_DamageSettings.color(value.to_s)
  226.       if value.is_a?(Numeric)
  227.         damage_string = value.abs.to_s
  228.       else
  229.         damage_string = value.to_s
  230.       end
  231.     #-------------------------------------------------------------------------
  232.     if value.is_a?(Numeric)
  233.       bitmap_number_image = RPG::Cache.windowskin("Damage_Number")
  234.       bitmap = Bitmap.new(bitmap_number_image.width,bitmap_number_image.height)
  235.       bitmap_im_cw = bitmap_number_image.width / 10
  236.       bitmap_im_ch = bitmap_number_image.height / 3   
  237.       bitmap_number_text = value.to_s.split(//)
  238.       if value >= 0
  239.         for r in 0..bitmap_number_text.size - 1
  240.            bitmap_number_abs = bitmap_number_text[r].to_i
  241.            if critical == false
  242.            bitmap_src_rect = Rect.new(bitmap_im_cw * bitmap_number_abs,0 , bitmap_im_cw, bitmap_im_ch)
  243.            else
  244.             bitmap_src_rect = Rect.new(bitmap_im_cw * bitmap_number_abs, bitmap_im_ch * 2, bitmap_im_cw, bitmap_im_ch)
  245.            end
  246.            bitmap.blt(60 + ((bitmap_im_cw - 7) *  r), 0, bitmap_number_image, bitmap_src_rect)        
  247.          end   
  248.       else
  249.        for r in 1..bitmap_number_text.size - 1
  250.          bitmap_number_abs = bitmap_number_text[r].to_i
  251.          bitmap_src_rect = Rect.new(bitmap_im_cw * bitmap_number_abs, bitmap_im_ch, bitmap_im_cw, bitmap_im_ch)
  252.          bitmap.blt(50 + ((bitmap_im_cw - 7) *  r), 0, bitmap_number_image, bitmap_src_rect)        
  253.         end   
  254.       end
  255.     elsif damage_string == "Miss"
  256.     bitmap_number_image = RPG::Cache.windowskin("Miss")
  257.     bitmap = Bitmap.new(bitmap_number_image.width,bitmap_number_image.height)
  258.     bitmap_im_cw = bitmap_number_image.width
  259.     bitmap_im_ch = bitmap_number_image.height / 6   
  260.     bitmap_src_rect = Rect.new(0, 0, bitmap_im_cw, bitmap_im_ch)
  261.     bitmap.blt(-25 , 0, bitmap_number_image, bitmap_src_rect)        
  262.     elsif damage_string == XAS_ABS_SETUP::GUARD_BREAK_TEXT
  263.     bitmap_number_image = RPG::Cache.windowskin("Miss")
  264.     bitmap = Bitmap.new(bitmap_number_image.width,bitmap_number_image.height)
  265.     bitmap_im_cw = bitmap_number_image.width
  266.     bitmap_im_ch = bitmap_number_image.height / 6   
  267.     bitmap_src_rect = Rect.new(0, bitmap_im_ch, bitmap_im_cw, bitmap_im_ch)
  268.     bitmap.blt(-25 , 0, bitmap_number_image, bitmap_src_rect)        
  269.     elsif damage_string == XAS_ABS_SETUP::SHIELD_TEXT
  270.     bitmap_number_image = RPG::Cache.windowskin("Miss")
  271.     bitmap = Bitmap.new(bitmap_number_image.width,bitmap_number_image.height)
  272.     bitmap_im_cw = bitmap_number_image.width
  273.     bitmap_im_ch = bitmap_number_image.height / 6   
  274.     bitmap_src_rect = Rect.new(0, bitmap_im_ch * 2, bitmap_im_cw, bitmap_im_ch)
  275.     bitmap.blt(-25 , 0, bitmap_number_image, bitmap_src_rect)        
  276.     elsif damage_string == XAS_BA::LEVEL_UP_TEXT
  277.     bitmap_number_image = RPG::Cache.windowskin("Miss")
  278.     bitmap = Bitmap.new(bitmap_number_image.width,bitmap_number_image.height)
  279.     bitmap_im_cw = bitmap_number_image.width
  280.     bitmap_im_ch = bitmap_number_image.height / 6   
  281.     bitmap_src_rect = Rect.new(0, bitmap_im_ch * 3, bitmap_im_cw, bitmap_im_ch)
  282.     bitmap.blt(-25 , 0, bitmap_number_image, bitmap_src_rect)        
  283.     elsif damage_string == "No Mp"
  284.     bitmap_number_image = RPG::Cache.windowskin("Miss")
  285.     bitmap = Bitmap.new(bitmap_number_image.width,bitmap_number_image.height)
  286.     bitmap_im_cw = bitmap_number_image.width
  287.     bitmap_im_ch = bitmap_number_image.height / 6  
  288.     bitmap_src_rect = Rect.new(0, bitmap_im_ch * 4, bitmap_im_cw, bitmap_im_ch)
  289.     bitmap.blt(-25 , 0, bitmap_number_image, bitmap_src_rect)        
  290.     elsif damage_string == "Dodge"
  291.     bitmap_number_image = RPG::Cache.windowskin("Miss")
  292.     bitmap = Bitmap.new(bitmap_number_image.width,bitmap_number_image.height)
  293.     bitmap_im_cw = bitmap_number_image.width
  294.     bitmap_im_ch = bitmap_number_image.height / 6  
  295.     bitmap_src_rect = Rect.new(0, bitmap_im_ch * 5, bitmap_im_cw, bitmap_im_ch)
  296.     bitmap.blt(-25 , 0, bitmap_number_image, bitmap_src_rect)        
  297.      
  298.       
  299.       
  300.    else
  301.       #-------------------------------------------------------------------------
  302. #=begin      
  303.       bitmap = Bitmap.new(160, 48)
  304.       bitmap.font = font
  305.       bitmap.font.color.set(0, 0, 0)
  306.       bitmap.draw_text(-1, 12-1, 160, 36, damage_string, 1)
  307.       bitmap.draw_text(+1, 12-1, 160, 36, damage_string, 1)
  308.       bitmap.draw_text(-1, 12+1, 160, 36, damage_string, 1)
  309.       bitmap.draw_text(+1, 12+1, 160, 36, damage_string, 1)
  310.       bitmap.font.color = color
  311.       bitmap.draw_text(0, 12, 160, 36, damage_string, 1)
  312.       if critical
  313.         critical_string   = XRXS_DamageSettings::CRITICAL_STRING
  314.         bitmap.font.size  = XRXS_DamageSettings::CRITICAL_FONT_SIZE
  315.         bitmap.font.color.set(0, 0, 0)
  316.         bitmap.draw_text(-1, -1, 160, 20, critical_string, 1)
  317.         bitmap.draw_text(+1, -1, 160, 20, critical_string, 1)
  318.         bitmap.draw_text(-1, +1, 160, 20, critical_string, 1)
  319.         bitmap.draw_text(+1, +1, 160, 20, critical_string, 1)
  320.         bitmap.font.color = XRXS_DamageSettings::CRITICAL_FONT_COLOR
  321.         bitmap.draw_text(0, 0, 160, 20, critical_string, 1)
  322.        elsif state
  323.         critical_string   = XRXS_DamageSettings::STATE_STRING
  324.         bitmap.font.size  = XRXS_DamageSettings::STATE_FONT_SIZE
  325.         bitmap.font.italic = true
  326.         bitmap.font.color.set(0, 0, 0)
  327.         bitmap.draw_text(-1, -1, 160, 20, critical_string, 1)
  328.         bitmap.draw_text(+1, -1, 160, 20, critical_string, 1)
  329.         bitmap.draw_text(-1, +1, 160, 20, critical_string, 1)
  330.         bitmap.draw_text(+1, +1, 160, 20, critical_string, 1)
  331.         bitmap.font.color = XRXS_DamageSettings::STATE_FONT_COLOR
  332.         bitmap.draw_text(0, 0, 160, 20, critical_string, 1)
  333.        elsif item
  334.         critical_string   = XRXS_DamageSettings::ITEM_STRING
  335.         bitmap.font.size  = XRXS_DamageSettings::ITEM_FONT_SIZE
  336.         bitmap.font.italic = true
  337.         bitmap.font.color.set(0, 0, 0)
  338.         bitmap.draw_text(-1, -1, 160, 20, critical_string, 1)
  339.         bitmap.draw_text(+1, -1, 160, 20, critical_string, 1)
  340.         bitmap.draw_text(-1, +1, 160, 20, critical_string, 1)
  341.         bitmap.draw_text(+1, +1, 160, 20, critical_string, 1)
  342.         bitmap.font.color = XRXS_DamageSettings::ITEM_FONT_COLOR
  343.         bitmap.draw_text(0, 0, 160, 20, critical_string, 1)
  344.       end   
  345.       
  346.       
  347. end      
  348. #=end
  349.       
  350.       @_damage_sprite = ::Sprite.new(self.viewport)
  351.       @_damage_sprite.bitmap = bitmap
  352.       @_damage_sprite.ox = 80
  353.       @_damage_sprite.oy = 20
  354.       @_damage_sprite.x = self.x
  355.       @_damage_sprite.y = self.y - self.oy / 2
  356.       if critical == true
  357.         @_damage_sprite.zoom_x = 2
  358.         @_damage_sprite.zoom_y = 2
  359.       end      
  360.       @_damage_sprite.z = 3000
  361.       @_damage_duration = XRXS_DamageSettings::DURATION
  362.     end
  363.   end
  364. end
  365. class Game_Battler
  366.   attr_accessor :damage_sp               
  367. end
  368. class Sprite_Battler < RPG::Sprite
  369.   alias xrxs62_update update
  370.   def update
  371.     if @battler != nil and @battler_visible and
  372.        @battler.damage_pop and @battler.damage_sp != nil and
  373.       (@battler.damage == nil or @battler.damage == "")
  374.       value = @battler.damage_sp
  375.       dispose_damage
  376.       damage_string = $data_system.words.sp + " " + value.to_s
  377.       damage(damage_string, @battler.critical,@battler.state,@battler.item)
  378.       @battler.damage_sp = nil
  379.       @battler.critical = false
  380.       @battler.state = false
  381.       @battler.item = false
  382.       @battler.damage_pop = false
  383.     end
  384.     xrxs62_update
  385.   end
  386. end
  387. module XRXS_ResultPop
  388.   def update
  389.     super
  390.     unless @xrxs_resultpop_done

  391.       if @battler == nil or not @battler.is_a?(Game_Enemy)
  392.         @xrxs_resultpop_done = true
  393.         return
  394.       end
  395.       if @_collapse_duration > 0 and @battler.gain_exp_act == true
  396.         
  397.         
  398.         if @_collapse_duration == EXP
  399.           if @battler.exp != 0
  400.             result = "EXP " + @battler.exp.to_s
  401.             damage(result, false,false,false)
  402.           end
  403.         elsif @_collapse_duration == GOLD and @battler.gain_exp_act == true
  404.           if @battler.gold != 0
  405.             result = @battler.gold.to_s + " " + $data_system.words.gold
  406.             damage(result, false,false,false)
  407.           end
  408.           @xrxs_resultpop_done = true if $mog_rgss_ap_parameter == nil
  409.          elsif $mog_rgss_ap_parameter != nil and @_collapse_duration == (GOLD / 2) and @battler.gain_exp_act == true
  410.           if @battler.ap != 0
  411.             result = @battler.ap.to_s + " " + MOG::AP_NAME
  412.             damage(result, false,false,false)
  413.           end
  414.            @xrxs_resultpop_done = true         
  415.         end
  416.       end
  417.     end
  418.   end
  419. end
  420. class RPG::Sprite < Sprite
  421.   include XRXS_ResultPop
  422. end
复制代码

素材区好人

梦石
5
星屑
12712
在线时间
4359 小时
注册时间
2011-7-21
回帖
2270

超评测参与极短28参与极短27参与极短26参与极短25参与极短24参与极短23参与极短22参与极短21参与

发表于 2016-6-14 22:41:39 | 显示全部楼层
显示的是self.damage,你只要把这个数值 = SP的变化就行了。如果不打算使用不同颜色显示HP和SP的变化,这样最简单。

比如搜索“sp +=”,找到self.sp += recover_sp (注:这个是吃药增加SP)
这里下面添加一段:

     if recover_sp != 0   #如果补SP的量不等于0
       self.damage = -recover_sp  #伤害=SP恢复量的倒数
     end
if item.recover_hp_rate == 0 and item.recover_hp == 0
这里改为:
     if item.recover_hp_rate == 0 and item.recover_hp == 0 and item.recover_sp_rate == 0 and item.recover_sp == 0  #原来只判断HP,现在附带判断SP

就行了。这样同时补血补气优先显示补气。

点评

你说的是只显示一条,可显示HP,可显示SP。但是我要的是HP和SP都显示出来,而不是只显示哪个  发表于 2016-6-14 22:53
回复

使用道具 举报

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

本版积分规则

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

在本版发帖返回顶部