Project1

标题: 如何设定战斗结束后用评分来奖励物品 [打印本页]

作者: jiushiainilip19    时间: 2015-7-22 12:12
标题: 如何设定战斗结束后用评分来奖励物品
本帖最后由 jiushiainilip19 于 2015-7-22 13:46 编辑

我使用的是天干宝典的战后评分脚本
那么在评分后如何设定根据评分来获得物品奖励 下面是评分脚本
  1. #--------------------------------------------------------------------------
  2.   # ● 战斗结果等级显示 Window_Base
  3.   #--------------------------------------------------------------------------
  4.   def draw_ranking(x,y)
  5.     case $Ranking
  6.     when 1
  7.       bitmap = Bitmap.new("Graphics/Ranks/A")
  8.     when 2
  9.       bitmap = Bitmap.new("Graphics/Ranks/B")
  10.     when 3
  11.       bitmap = Bitmap.new("Graphics/Ranks/C")
  12.     when 4
  13.       bitmap = Bitmap.new("Graphics/Ranks/D")
  14.     when 5
  15.       bitmap = Bitmap.new("Graphics/Ranks/E")
  16.     when 6
  17.       bitmap = Bitmap.new("Graphics/Ranks/F")
  18.     end   
  19.     cw = bitmap.width
  20.     ch = bitmap.height
  21.     src_rect = Rect.new(0, 0, cw, ch)
  22.     self.contents.blt(x , y , bitmap, src_rect)
  23.   end
复制代码
  1. #==============================================================================
  2. # ■ Window_BattleResult
  3. #------------------------------------------------------------------------------
  4. #  战斗结束时、显示获得的 EXP 及金钱的窗口。
  5. #==============================================================================

  6. class Window_BattleResult < Window_Base
  7.   #--------------------------------------------------------------------------
  8.   # ● 初始化对像
  9.   #     exp       : EXP
  10.   #     gold      : 金钱
  11.   #     treasures : 宝物
  12.   #--------------------------------------------------------------------------
  13.   def initialize(exp, gold, treasures)
  14.     @exp = exp
  15.     @gold = gold
  16.     @treasures = treasures
  17.    # super(160, 0, 320, @treasures.size * 32 + 64)
  18.     super(120, 0, 400, 320)#添加的
  19.     self.contents = Bitmap.new(width - 32, height - 32)
  20.     self.y = 160 - height / 2
  21.     self.back_opacity = 160
  22.     self.visible = false
  23.     refresh
  24.   end

  25. ##############################################################
  26. #--------------------------------------------------------------------------
  27.   # ● 刷新
  28.   #--------------------------------------------------------------------------
  29.   def refresh
  30.     self.contents.clear
  31.   ###########################################################################
  32.   #==========================================================================
  33.   # ● 战绩报告窗口
  34.   #==========================================================================
  35.     #以下是等级计算公式,目前仅仅是根据角色HP/SP的多少来判定(毕竟是范例)
  36.     #这些可以自己定义。
  37.     @mhp = 0
  38.     @php = 0
  39.     @msp = 0
  40.     @psp = 0
  41.     for i in 0...$game_party.actors.size
  42.       @mhp += $game_party.actors[i].maxhp
  43.       @php += $game_party.actors[i].hp
  44.       if $game_party.actors[i].hp > 0
  45.         @msp += $game_party.actors[i].maxsp
  46.         @psp += $game_party.actors[i].sp
  47.       end
  48.     end
  49.     @orz = @php * 50 / @mhp  + @psp * 50 / @msp
  50.     case @orz
  51.     when 79..100
  52.       $Ranking = 1
  53.     when 67..78
  54.       $Ranking = 2
  55.     when 55..66
  56.       $Ranking = 3
  57.     when 43..54
  58.       $Ranking = 4
  59.     when 31..42
  60.       $Ranking = 5
  61.     else
  62.       $Ranking = 6
  63.     end
  64.     #描绘角色脸图
  65.     for i in 0...$game_party.actors.size
  66.       actor = $game_party.actors[i]
  67.       actor_x = i * 92
  68.     #  draw_battle_actor(actor,actor_x, 96)
  69.       draw_actor_name(actor, actor_x, 0)
  70.     #  draw_actor_state(actor, actor_x, 96, 120)
  71.     end
  72.     #以下是经验值和钱的描绘
  73.     x = 4
  74.     self.contents.font.color = normal_color
  75.     cx = contents.text_size(@exp.to_s).width
  76.     self.contents.draw_text(x, 125, cx, 32, @exp.to_s)
  77.     x += cx + 4
  78.     self.contents.font.color = system_color
  79.     cx = contents.text_size("EXP").width
  80.     self.contents.draw_text(x, 125, 64, 32, "EXP")
  81.     x += cx + 16
  82.     self.contents.font.color = normal_color
  83.     cx = contents.text_size(@gold.to_s).width
  84.     self.contents.draw_text(x, 125, cx, 32, @gold.to_s)
  85.     x += cx + 4
  86.     self.contents.font.color = system_color
  87.     self.contents.draw_text(x, 125, 128, 32, $data_system.words.gold)
  88.     #描绘本次战斗得分
  89.     self.contents.font.color = normal_color
  90.     self.contents.draw_text(200, 125, 135, 32, "得分: "+ @orz.to_s)
  91.     #描绘获得的道具
  92.     y = 160
  93.     #描绘获得的评价
  94.     if @treasures.size == 0
  95.     draw_ranking(120,160)
  96.     else
  97.     draw_ranking(200,160)
  98.     end
  99.     for item in @treasures
  100.       draw_item_name(item, 4, y)
  101.       y += 32
  102.   ###########################################################################
  103. end
  104.   end
  105. end
复制代码





欢迎光临 Project1 (https://rpg.blue/) Powered by Discuz! X3.1